diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2012-10-21 14:46:21 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2012-10-21 16:00:32 +0200 |
commit | 9b53538a076a2370df975655c8579dfe09cff09b (patch) | |
tree | 42e447522b34483df48c8b2976bd726eed306f75 /sw/qa/extras | |
parent | ffcaa7651f5761c884b57e1c0f0ff0f92b803194 (diff) |
sw: rework import tests to match the syntax of export tests
As a side-effect, this reduces the length of the code as well.
Change-Id: I83da39968ab7629548dd3c469ea8e648c4574653
Diffstat (limited to 'sw/qa/extras')
-rw-r--r-- | sw/qa/extras/odfimport/odfimport.cxx | 24 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 170 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/rtfimport.cxx | 246 | ||||
-rw-r--r-- | sw/qa/extras/ww8import/ww8import.cxx | 41 |
4 files changed, 175 insertions, 306 deletions
diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index d7a6c0e966c7..23328263fa9c 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -42,32 +42,37 @@ public: CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) - CPPUNIT_TEST(testEmptySvgFamilyName); - CPPUNIT_TEST(testHideAllSections); - CPPUNIT_TEST(testOdtBorders); + CPPUNIT_TEST(run); #endif CPPUNIT_TEST_SUITE_END(); private: - /// Load an ODF file and make the document available via mxComponent. - void load(const OUString& rURL); + void run(); }; -void Test::load(const OUString& rFilename) +void Test::run() { - mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/odfimport/data/") + rFilename); + MethodEntry<Test> aMethods[] = { + {"empty-svg-family-name.odt", &Test::testEmptySvgFamilyName}, + {"fdo53210.odt", &Test::testHideAllSections}, + {"borders_ooo33.odt", &Test::testOdtBorders}, + }; + for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) + { + MethodEntry<Test>& rEntry = aMethods[i]; + mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/odfimport/data/") + OUString::createFromAscii(rEntry.pName)); + (this->*rEntry.pMethod)(); + } } void Test::testEmptySvgFamilyName() { // .odt import did crash on the empty font list (which I think is valid according SVG spec) - load( "empty-svg-family-name.odt" ); } void Test::testHideAllSections() { // This document has a section that is conditionally hidden, but has no empty paragraph after it. - load("fdo53210.odt"); uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XNameAccess> xMasters = xTextFieldsSupplier->getTextFieldMasters(); // Set _CS_Allgemein to 0 @@ -79,7 +84,6 @@ void Test::testHideAllSections() void Test::testOdtBorders() { - load("borders_ooo33.odt"); AllBordersMap map; uno::Sequence< table::BorderLine > tempSequence(4); diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index f30c0f13cd9f..7a1a4c709a5a 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -109,68 +109,73 @@ public: CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) - CPPUNIT_TEST(testN751054); - CPPUNIT_TEST(testN751117); - CPPUNIT_TEST(testN751017); - CPPUNIT_TEST(testN750935); - CPPUNIT_TEST(testN757890); - CPPUNIT_TEST(testFdo49940); - CPPUNIT_TEST(testN751077); - CPPUNIT_TEST(testN705956_1); - CPPUNIT_TEST(testN705956_2); - CPPUNIT_TEST(testN747461); - CPPUNIT_TEST(testN750255); - CPPUNIT_TEST(testN652364); - CPPUNIT_TEST(testN760764); - CPPUNIT_TEST(testN764005); - CPPUNIT_TEST(testSmartart); - CPPUNIT_TEST(testN764745); - CPPUNIT_TEST(testN766477); - CPPUNIT_TEST(testN758883); - CPPUNIT_TEST(testN766481); - CPPUNIT_TEST(testN766487); - CPPUNIT_TEST(testN693238); - CPPUNIT_TEST(testNumbering1); - CPPUNIT_TEST(testBnc773061); - CPPUNIT_TEST(testAllGapsWord); - CPPUNIT_TEST(testN775906); - CPPUNIT_TEST(testN775899); - CPPUNIT_TEST(testN777345); - CPPUNIT_TEST(testN777337); - CPPUNIT_TEST(testN778836); - CPPUNIT_TEST(testN778140); - CPPUNIT_TEST(testN778828); - CPPUNIT_TEST(testInk); - CPPUNIT_TEST(testN779834); - CPPUNIT_TEST(testN779627); - CPPUNIT_TEST(testN779941); - CPPUNIT_TEST(testN779957); - CPPUNIT_TEST(testFdo55187); - CPPUNIT_TEST(testN780563); - CPPUNIT_TEST(testN780853); - CPPUNIT_TEST(testN780843); - CPPUNIT_TEST(testShadow); - CPPUNIT_TEST(testN782061); - CPPUNIT_TEST(testN782345); - CPPUNIT_TEST(testN783638); - CPPUNIT_TEST(testFdo52208); + CPPUNIT_TEST(run); #endif CPPUNIT_TEST_SUITE_END(); private: - /// Load an OOXML file and make the document available via mxComponent. - void load(const OUString& rURL); + void run(); }; -void Test::load(const OUString& rFilename) +void Test::run() { - mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/ooxmlimport/data/") + rFilename); + MethodEntry<Test> aMethods[] = { + {"n751054.docx", &Test::testN751054}, + {"n751117.docx", &Test::testN751117}, + {"n751017.docx", &Test::testN751017}, + {"n750935.docx", &Test::testN750935}, + {"n757890.docx", &Test::testN757890}, + {"fdo49940.docx", &Test::testFdo49940}, + {"n751077.docx", &Test::testN751077}, + {"n705956-1.docx", &Test::testN705956_1}, + {"n705956-2.docx", &Test::testN705956_2}, + {"n747461.docx", &Test::testN747461}, + {"n750255.docx", &Test::testN750255}, + {"n652364.docx", &Test::testN652364}, + {"n760764.docx", &Test::testN760764}, + {"n764005.docx", &Test::testN764005}, + {"smartart.docx", &Test::testSmartart}, + {"n764745-alignment.docx", &Test::testN764745}, + {"n766477.docx", &Test::testN766477}, + {"n758883.docx", &Test::testN758883}, + {"n766481.docx", &Test::testN766481}, + {"n766487.docx", &Test::testN766487}, + {"n693238.docx", &Test::testN693238}, + {"numbering1.docx", &Test::testNumbering1}, + {"bnc773061.docx", &Test::testBnc773061}, + {"all_gaps_word.docx", &Test::testAllGapsWord}, + {"n775906.docx", &Test::testN775906}, + {"n775899.docx", &Test::testN775899}, + {"n777345.docx", &Test::testN777345}, + {"n777337.docx", &Test::testN777337}, + {"n778836.docx", &Test::testN778836}, + {"n778140.docx", &Test::testN778140}, + {"n778828.docx", &Test::testN778828}, + {"ink.docx", &Test::testInk}, + {"n779834.docx", &Test::testN779834}, + {"n779627.docx", &Test::testN779627}, + {"n779941.docx", &Test::testN779941}, + {"n779957.docx", &Test::testN779957}, + {"fdo55187.docx", &Test::testFdo55187}, + {"n780563.docx", &Test::testN780563}, + {"n780853.docx", &Test::testN780853}, + {"n780843.docx", &Test::testN780843}, + {"imgshadow.docx", &Test::testShadow}, + {"n782061.docx", &Test::testN782061}, + {"n782345.docx", &Test::testN782345}, + {"n783638.docx", &Test::testN783638}, + {"fdo52208.docx", &Test::testFdo52208}, + }; + for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) + { + MethodEntry<Test>& rEntry = aMethods[i]; + mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/ooxmlimport/data/") + OUString::createFromAscii(rEntry.pName)); + (this->*rEntry.pMethod)(); + } } void Test::testN751054() { - load("n751054.docx"); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY); @@ -181,8 +186,6 @@ void Test::testN751054() void Test::testN751117() { - load("n751117.docx"); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); @@ -207,7 +210,6 @@ void Test::testN751117() void Test::testN751017() { - load("n751017.docx"); uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XNameAccess> xMasters(xTextFieldsSupplier->getTextFieldMasters()); // Make sure we have a variable named foo. @@ -254,7 +256,6 @@ void Test::testN751017() void Test::testN750935() { - load("n750935.docx"); uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); @@ -277,8 +278,6 @@ void Test::testN750935() void Test::testN757890() { - load("n757890.docx"); - // The w:pStyle token affected the text outside the textbox. uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); @@ -299,8 +298,6 @@ void Test::testN757890() void Test::testFdo49940() { - load("fdo49940.docx"); - uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); @@ -312,8 +309,6 @@ void Test::testFdo49940() void Test::testN751077() { - load( "n751077.docx" ); - /* enum = ThisComponent.Text.createEnumeration enum.NextElement @@ -330,7 +325,6 @@ xray para.PageStyleName void Test::testN705956_1() { - load( "n705956-1.docx" ); /* Get the first image in the document and check it's the one image in the document. It should be also anchored inline (as character). @@ -358,7 +352,6 @@ xray image.AnchorType void Test::testN705956_2() { - load( "n705956-2.docx" ); /* <v:shapetype> must be global, reachable even from <v:shape> inside another <w:pict> image = ThisComponent.DrawPage.getByIndex(0) @@ -377,7 +370,6 @@ xray image.FillColor void Test::testN747461() { - load( "n747461.docx" ); /* The document contains 3 images (Red, Black, Green, in this order), with explicit w:relativeHeight (300, 0, 225763766). Check that they are in the right ZOrder @@ -411,7 +403,6 @@ after they are loaded. void Test::testN750255() { - load( "n750255.docx" ); /* Column break without columns on the page is a page break, so check those paragraphs @@ -437,8 +428,6 @@ xray para2.PageStyleName void Test::testN652364() { - load( "n652364.docx" ); - /* Related to 750255 above, column break with columns on the page however should be a column break. enum = ThisComponent.Text.createEnumeration @@ -463,8 +452,6 @@ xray para2.PageStyleName void Test::testN760764() { - load("n760764.docx"); - uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference<container::XEnumeration> xParaEnum(xParaEnumAccess->createEnumeration()); @@ -482,8 +469,6 @@ void Test::testN760764() void Test::testN764005() { - load("n764005.docx"); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY); @@ -499,8 +484,6 @@ void Test::testN764005() void Test::testSmartart() { - load("smartart.docx"); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); // One groupshape in the doc @@ -525,7 +508,6 @@ void Test::testSmartart() void Test::testN764745() { - load( "n764745-alignment.docx" ); /* shape = ThisComponent.DrawPage.getByIndex(0) xray shape.AnchorType @@ -565,7 +547,6 @@ void Test::testN766477() * oRun = oRuns.nextElement * xray oRun.Bookmark.Parameters.ElementNames(0) 'Checkbox_Checked */ - load("n766477.docx"); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference<container::XEnumeration> xParaEnum(xParaEnumAccess->createEnumeration()); @@ -580,8 +561,6 @@ void Test::testN766477() void Test::testN758883() { - load("n758883.docx"); - /* * The problem was that direct formatting of the paragraph was not applied * to the numbering. This is easier to test using a layout dump. @@ -639,7 +618,6 @@ void Test::testN766481() * oPara = oParas.nextElement * xray oParas.hasMoreElements ' should be false */ - load("n766481.docx"); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference<container::XEnumeration> xParaEnum(xParaEnumAccess->createEnumeration()); @@ -661,7 +639,6 @@ void Test::testN766487() * oPara = oParas.nextElement * xray oPara.ParaFirstLineIndent ' -635, was 0 */ - load("n766487.docx"); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference<container::XEnumeration> xParaEnum(xParaEnumAccess->createEnumeration()); @@ -686,7 +663,6 @@ void Test::testN693238() * * xray ThisComponent.StyleFamilies.PageStyles.Default.LeftMargin ' was 2000, should be 635 */ - load("n693238.docx"); uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName("Default"), uno::UNO_QUERY); sal_Int32 nValue = 0; xPropertySet->getPropertyValue("LeftMargin") >>= nValue; @@ -695,7 +671,6 @@ void Test::testN693238() void Test::testNumbering1() { - load( "numbering1.docx" ); /* <w:numPr> in the paragraph itself was overriden by <w:numpr> introduced by the paragraph's <w:pStyle> enum = ThisComponent.Text.createEnumeration para = enum.NextElement @@ -742,7 +717,6 @@ note that the indexes may get off as the implementation evolves, C++ code seache void Test::testBnc773061() { - load( "bnc773061.docx" ); uno::Reference< text::XTextRange > paragraph = getParagraph( 1 ); uno::Reference< text::XTextRange > normal = getRun( paragraph, 1, "Normal " ); uno::Reference< text::XTextRange > raised = getRun( paragraph, 2, "Raised" ); @@ -757,7 +731,6 @@ void Test::testBnc773061() void Test::testAllGapsWord() { - load("all_gaps_word.docx"); BorderTest borderTest; borderTest.testTheBorders(mxComponent); } @@ -772,8 +745,6 @@ void Test::testN775906() * xray oPara.ParaFirstLineIndent ' was 0 * xray oPara.ParaLeftMargin ' was 0 */ - load("n775906.docx"); - CPPUNIT_ASSERT_EQUAL(sal_Int32(-635), getProperty<sal_Int32>(getParagraph(1), "ParaFirstLineIndent")); CPPUNIT_ASSERT_EQUAL(sal_Int32(1905), getProperty<sal_Int32>(getParagraph(1), "ParaLeftMargin")); } @@ -789,8 +760,6 @@ void Test::testN775899() * oPara.supportsService("com.sun.star.text.TextTable") 'was a fake paragraph * oParas.hasMoreElements 'was true */ - load("n775899.docx"); - uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); @@ -807,8 +776,6 @@ void Test::testN775899() void Test::testN777345() { // The problem was that v:imagedata inside v:rect was ignored. - load("n777345.docx"); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); uno::Reference<document::XEmbeddedObjectSupplier2> xSupplier(xDraws->getByIndex(0), uno::UNO_QUERY); @@ -828,8 +795,6 @@ void Test::testN777337() * xray oFirst.TopMargin * xray oFirst.BottomMargin */ - load("n777337.docx"); - uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName("First Page"), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(1702), getProperty<sal_Int32>(xPropertySet, "TopMargin")); CPPUNIT_ASSERT_EQUAL(sal_Int32(1702), getProperty<sal_Int32>(xPropertySet, "BottomMargin")); @@ -841,8 +806,6 @@ void Test::testN778836() * The problem was that the paragraph inherited margins from the numbering * and parent paragraph styles and the result was incorrect. */ - load("n778836.docx"); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1270), getProperty<sal_Int32>(getParagraph(0), "ParaRightMargin")); CPPUNIT_ASSERT_EQUAL(sal_Int32(3810), getProperty<sal_Int32>(getParagraph(0), "ParaLeftMargin")); CPPUNIT_ASSERT_EQUAL(sal_Int32(-635), getProperty<sal_Int32>(getParagraph(0), "ParaFirstLineIndent")); @@ -854,8 +817,6 @@ void Test::testN778140() * The problem was that the paragraph top/bottom margins were incorrect due * to unhandled w:doNotUseHTMLParagraphAutoSpacing. */ - load("n778140.docx"); - CPPUNIT_ASSERT_EQUAL(sal_Int32(176), getProperty<sal_Int32>(getParagraph(0), "ParaTopMargin")); CPPUNIT_ASSERT_EQUAL(sal_Int32(176), getProperty<sal_Int32>(getParagraph(0), "ParaBottomMargin")); } @@ -866,8 +827,6 @@ void Test::testN778828() * The problem was that a page break after a continous section break caused * double page break on title page. */ - load("n778828.docx"); - uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); @@ -882,7 +841,6 @@ void Test::testInk() * * xray ThisComponent.DrawPage(0).supportsService("com.sun.star.drawing.OpenBezierShape") */ - load("ink.docx"); uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); uno::Reference<lang::XServiceInfo> xServiceInfo(xDraws->getByIndex(0), uno::UNO_QUERY); @@ -892,7 +850,6 @@ void Test::testInk() void Test::testN779834() { // This document simply crashed the importer. - load("n779834.docx"); } void Test::testN779627() @@ -901,7 +858,6 @@ void Test::testN779627() * The problem was that the table left position was based on the tableCellMar left value * even for nested tables, while it shouldn't. */ - load("n779627.docx"); uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xTableProperties(xTables->getByIndex(0), uno::UNO_QUERY); @@ -932,7 +888,6 @@ void Test::testN779627() void Test::testFdo55187() { // 0x010d was imported as a newline. - load("fdo55187.docx"); getParagraph(1, OUString("lupčka", 7, RTL_TEXTENCODING_UTF8)); } @@ -941,7 +896,6 @@ void Test::testN780563() /* * Make sure we have the table in the fly frame created */ - load("n780563.docx"); uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount( )); @@ -954,7 +908,6 @@ void Test::testN780853() * * xray ThisComponent.TextTables.Count 'was 0 */ - load("n780853.docx"); uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); @@ -973,7 +926,6 @@ void Test::testN780843() * oStyle = ThisComponent.StyleFamilies.PageStyles.getByName(sStyle) * xray oStyle.FooterText.String ' was "hidden footer" */ - load("n780843.docx"); uno::Reference< text::XTextRange > xPara = getParagraph(3); OUString aStyleName = getProperty<OUString>(xPara, "PageStyleName"); uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(aStyleName), uno::UNO_QUERY); @@ -987,7 +939,6 @@ void Test::testShadow() * The problem was that drop shadows on inline images were not being * imported and applied. */ - load("imgshadow.docx"); uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(1), uno::UNO_QUERY); @@ -1002,8 +953,6 @@ void Test::testN782061() /* * The problem was that the character escapement in the second run was -58. */ - load("n782061.docx"); - CPPUNIT_ASSERT_EQUAL(sal_Int32(-9), getProperty<sal_Int32>(getRun(getParagraph(1), 2), "CharEscapement")); } @@ -1012,8 +961,6 @@ void Test::testN782345() /* * The problem was that the page break was inserted before the 3rd para, instead of before the 2nd para. */ - load("n782345.docx"); - CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType")); } @@ -1022,7 +969,6 @@ void Test::testN779941() /* * Make sure top/bottom margins of tables are set to 0 (problem was: bottom margin set to 0.35cm) */ - load("n779941.docx"); uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xTableProperties(xTables->getByIndex(0), uno::UNO_QUERY); @@ -1050,7 +996,6 @@ void Test::testN779957() sal_Int32 xCoordsFromOffice[] = { 2500, -1000, 0, 0 }; sal_Int32 cellLeftMarginFromOffice[] = { 250, 100, 0, 0 }; - load("n779957.docx"); uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY); @@ -1084,8 +1029,6 @@ void Test::testN779957() void Test::testN783638() { // The problem was that the margins of inline images were not zero. - load("n783638.docx"); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY); @@ -1095,7 +1038,6 @@ void Test::testN783638() void Test::testFdo52208() { // The problem was that the document had 2 pages instead of 1. - load("fdo52208.docx"); uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 9db7579be6a7..ba098893b865 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -124,75 +124,101 @@ public: CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) - CPPUNIT_TEST(testFdo45553); - CPPUNIT_TEST(testN192129); - CPPUNIT_TEST(testFdo45543); - CPPUNIT_TEST(testN695479); - CPPUNIT_TEST(testFdo42465); - CPPUNIT_TEST(testFdo45187); - CPPUNIT_TEST(testFdo46662); - CPPUNIT_TEST(testN750757); - CPPUNIT_TEST(testFdo45563); - CPPUNIT_TEST(testFdo43965); - CPPUNIT_TEST(testN751020); - CPPUNIT_TEST(testFdo47326); - CPPUNIT_TEST(testFdo47036); - CPPUNIT_TEST(testFdo46955); - CPPUNIT_TEST(testFdo45394); - CPPUNIT_TEST(testFdo48104); - CPPUNIT_TEST(testFdo47107); - CPPUNIT_TEST(testFdo45182); - CPPUNIT_TEST(testFdo44176); - CPPUNIT_TEST(testFdo39053); - CPPUNIT_TEST(testFdo48356); - CPPUNIT_TEST(testFdo48023); - CPPUNIT_TEST(testFdo48876); - CPPUNIT_TEST(testFdo48193); - CPPUNIT_TEST(testFdo44211); - CPPUNIT_TEST(testFdo48037); - CPPUNIT_TEST(testFdo47764); - CPPUNIT_TEST(testFdo38786); - CPPUNIT_TEST(testN757651); - CPPUNIT_TEST(testFdo49501); - CPPUNIT_TEST(testFdo49271); - CPPUNIT_TEST(testFdo49692); - CPPUNIT_TEST(testFdo45190); - CPPUNIT_TEST(testFdo50539); - CPPUNIT_TEST(testFdo50665); - CPPUNIT_TEST(testFdo49659); - CPPUNIT_TEST(testFdo46966); - CPPUNIT_TEST(testFdo52066); - CPPUNIT_TEST(testFdo48033); - CPPUNIT_TEST(testFdo36089); - CPPUNIT_TEST(testFdo49892); - CPPUNIT_TEST(testFdo48446); - CPPUNIT_TEST(testFdo47495); - CPPUNIT_TEST(testAllGapsWord); - CPPUNIT_TEST(testFdo52052); - CPPUNIT_TEST(testInk); - CPPUNIT_TEST(testFdo52389); - CPPUNIT_TEST(testFdo49655); - CPPUNIT_TEST(testFdo52475); - CPPUNIT_TEST(testFdo55493); - CPPUNIT_TEST(testCopyPastePageStyle); - CPPUNIT_TEST(testShptxtPard); - CPPUNIT_TEST(testDoDhgt); - CPPUNIT_TEST(testDplinehollow); - CPPUNIT_TEST(testLeftmarginDefault); - CPPUNIT_TEST(testDppolyline); + CPPUNIT_TEST(run); #endif CPPUNIT_TEST_SUITE_END(); private: - /// Load an RTF file and make the document available via mxComponent. - void load(const OUString& rURL); + void run(); /// Get page count. int getPages(); }; -void Test::load(const OUString& rFilename) -{ - mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/rtfimport/data/") + rFilename); +void Test::run() +{ + MethodEntry<Test> aMethods[] = { + {"fdo45553.rtf", &Test::testFdo45553}, + {"n192129.rtf", &Test::testN192129}, + {"fdo45543.rtf", &Test::testFdo45543}, + {"n695479.rtf", &Test::testN695479}, + {"fdo42465.rtf", &Test::testFdo42465}, + {"fdo45187.rtf", &Test::testFdo45187}, + {"fdo46662.rtf", &Test::testFdo46662}, + {"n750757.rtf", &Test::testN750757}, + {"fdo45563.rtf", &Test::testFdo45563}, + {"fdo43965.rtf", &Test::testFdo43965}, + {"n751020.rtf", &Test::testN751020}, + {"fdo47326.rtf", &Test::testFdo47326}, + {"fdo47036.rtf", &Test::testFdo47036}, + {"fdo46955.rtf", &Test::testFdo46955}, + {"fdo45394.rtf", &Test::testFdo45394}, + {"fdo48104.rtf", &Test::testFdo48104}, + {"fdo47107.rtf", &Test::testFdo47107}, + {"fdo45182.rtf", &Test::testFdo45182}, + {"fdo44176.rtf", &Test::testFdo44176}, + {"fdo39053.rtf", &Test::testFdo39053}, + {"fdo48356.rtf", &Test::testFdo48356}, + {"fdo48023.rtf", &Test::testFdo48023}, + {"fdo48876.rtf", &Test::testFdo48876}, + {"fdo48193.rtf", &Test::testFdo48193}, + {"fdo44211.rtf", &Test::testFdo44211}, + {"fdo48037.rtf", &Test::testFdo48037}, + {"fdo47764.rtf", &Test::testFdo47764}, + {"fdo38786.rtf", &Test::testFdo38786}, + {"n757651.rtf", &Test::testN757651}, + {"fdo49501.rtf", &Test::testFdo49501}, + {"fdo49271.rtf", &Test::testFdo49271}, + {"fdo49692.rtf", &Test::testFdo49692}, + {"fdo45190.rtf", &Test::testFdo45190}, + {"fdo50539.rtf", &Test::testFdo50539}, + {"fdo50665.rtf", &Test::testFdo50665}, + {"fdo49659.rtf", &Test::testFdo49659}, + {"fdo46966.rtf", &Test::testFdo46966}, + {"fdo52066.rtf", &Test::testFdo52066}, + {"fdo48033.rtf", &Test::testFdo48033}, + {"fdo36089.rtf", &Test::testFdo36089}, + {"fdo49892.rtf", &Test::testFdo49892}, + {"fdo48446.rtf", &Test::testFdo48446}, + {"fdo47495.rtf", &Test::testFdo47495}, + {"all_gaps_word.rtf", &Test::testAllGapsWord}, + {"fdo52052.rtf", &Test::testFdo52052}, + {"ink.rtf", &Test::testInk}, + {"fdo52389.rtf", &Test::testFdo52389}, + {"fdo49655.rtf", &Test::testFdo49655}, + {"fdo52475.rtf", &Test::testFdo52475}, + {"fdo55493.rtf", &Test::testFdo55493}, + {"copypaste-pagestyle.rtf", &Test::testCopyPastePageStyle}, + {"shptxt-pard.rtf", &Test::testShptxtPard}, + {"do-dhgt.rtf", &Test::testDoDhgt}, + {"dplinehollow.rtf", &Test::testDplinehollow}, + {"leftmargin-default.rtf", &Test::testLeftmarginDefault}, + {"dppolyline.rtf", &Test::testDppolyline}, + }; + for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) + { + MethodEntry<Test>& rEntry = aMethods[i]; + AllSettings aSavedSettings(Application::GetSettings()); + if (OString(rEntry.pName) == "fdo48023.rtf") + { + AllSettings aSettings(aSavedSettings); + lang::Locale aLocale; + aLocale.Language = "ru"; + aSettings.SetLocale(aLocale); + Application::SetSettings(aSettings); + } + else if (OString(rEntry.pName) == "fdo44211.rtf") + { + AllSettings aSettings(aSavedSettings); + lang::Locale aLocale; + aLocale.Language = "lt"; + aSettings.SetLocale(aLocale); + Application::SetSettings(aSettings); + } + mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/rtfimport/data/") + OUString::createFromAscii(rEntry.pName)); + if (OString(rEntry.pName) == "fdo48023.rtf" || OString(rEntry.pName) == "fdo44211.rtf") + Application::SetSettings(aSavedSettings); + (this->*rEntry.pMethod)(); + } } int Test::getPages() @@ -206,8 +232,6 @@ int Test::getPages() void Test::testFdo45553() { - load("fdo45553.rtf"); - uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); @@ -229,8 +253,6 @@ void Test::testFdo45553() void Test::testN192129() { - load("n192129.rtf"); - // We expect that the result will be 16x16px. Size aExpectedSize(16, 16); MapMode aMap(MAP_100TH_MM); @@ -247,14 +269,11 @@ void Test::testN192129() void Test::testFdo45543() { - load("fdo45543.rtf"); CPPUNIT_ASSERT_EQUAL(5, getLength()); } void Test::testN695479() { - load("n695479.rtf"); - uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xPropertySet(xIndexAccess->getByIndex(0), uno::UNO_QUERY); @@ -297,14 +316,11 @@ void Test::testN695479() void Test::testFdo42465() { - load("fdo42465.rtf"); CPPUNIT_ASSERT_EQUAL(3, getLength()); } void Test::testFdo45187() { - load("fdo45187.rtf"); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); // There should be two shapes. @@ -315,8 +331,6 @@ void Test::testFdo45187() void Test::testFdo46662() { - load("fdo46662.rtf"); - uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum3"), uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY); uno::Sequence<beans::PropertyValue> aProps; @@ -335,7 +349,6 @@ void Test::testFdo46662() void Test::testN750757() { - load("n750757.rtf"); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); @@ -346,7 +359,6 @@ void Test::testN750757() void Test::testFdo45563() { - load("fdo45563.rtf"); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); @@ -361,7 +373,6 @@ void Test::testFdo45563() void Test::testFdo43965() { - load("fdo43965.rtf"); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); @@ -382,7 +393,6 @@ void Test::testFdo43965() void Test::testN751020() { - load("n751020.rtf"); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); @@ -392,15 +402,12 @@ void Test::testN751020() void Test::testFdo47326() { - load("fdo47326.rtf"); // This was 15 only, as \super buffered text, then the contents of it got lost. CPPUNIT_ASSERT_EQUAL(19, getLength()); } void Test::testFdo47036() { - load("fdo47036.rtf"); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); int nAtCharacter = 0; @@ -420,8 +427,6 @@ void Test::testFdo47036() void Test::testFdo46955() { - load("fdo46955.rtf"); - uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); @@ -436,8 +441,6 @@ void Test::testFdo46955() void Test::testFdo45394() { - load("fdo45394.rtf"); - uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName("Default"), "HeaderText"); OUString aActual = xHeaderText->getString(); // Encoding in the header was wrong. @@ -451,14 +454,11 @@ void Test::testFdo45394() void Test::testFdo48104() { - load("fdo48104.rtf"); CPPUNIT_ASSERT_EQUAL(2, getPages()); } void Test::testFdo47107() { - load("fdo47107.rtf"); - uno::Reference<container::XNameAccess> xNumberingStyles(getStyles("NumberingStyles")); // Make sure numbered and bullet legacy syntax is recognized, this used to throw a NoSuchElementException xNumberingStyles->getByName("WWNum1"); @@ -467,8 +467,6 @@ void Test::testFdo47107() void Test::testFdo45182() { - load("fdo45182.rtf"); - uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY); uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY); @@ -479,8 +477,6 @@ void Test::testFdo45182() void Test::testFdo44176() { - load("fdo44176.rtf"); - uno::Reference<container::XNameAccess> xPageStyles(getStyles("PageStyles")); uno::Reference<beans::XPropertySet> xFirstPage(xPageStyles->getByName("First Page"), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xDefault(xPageStyles->getByName("Default"), uno::UNO_QUERY); @@ -493,8 +489,6 @@ void Test::testFdo44176() void Test::testFdo39053() { - load("fdo39053.rtf"); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); int nAsCharacter = 0; @@ -507,8 +501,6 @@ void Test::testFdo39053() void Test::testFdo48356() { - load("fdo48356.rtf"); - uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); @@ -525,14 +517,6 @@ void Test::testFdo48356() void Test::testFdo48023() { - lang::Locale aLocale; - aLocale.Language = "ru"; - AllSettings aSettings(Application::GetSettings()); - AllSettings aSavedSettings(aSettings); - aSettings.SetLocale(aLocale); - Application::SetSettings(aSettings); - load("fdo48023.rtf"); - Application::SetSettings(aSavedSettings); uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1); // Implicit encoding detection based on locale was missing @@ -542,7 +526,6 @@ void Test::testFdo48023() void Test::testFdo48876() { - load("fdo48876.rtf"); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); @@ -552,20 +535,11 @@ void Test::testFdo48876() void Test::testFdo48193() { - load("fdo48193.rtf"); CPPUNIT_ASSERT_EQUAL(7, getLength()); } void Test::testFdo44211() { - lang::Locale aLocale; - aLocale.Language = "lt"; - AllSettings aSettings(Application::GetSettings()); - AllSettings aSavedSettings(aSettings); - aSettings.SetLocale(aLocale); - Application::SetSettings(aSettings); - load("fdo44211.rtf"); - Application::SetSettings(aSavedSettings); uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1); OUString aExpected("ąčę", 6, RTL_TEXTENCODING_UTF8); @@ -574,8 +548,6 @@ void Test::testFdo44211() void Test::testFdo48037() { - load("fdo48037.rtf"); - uno::Reference<util::XNumberFormatsSupplier> xNumberSupplier(mxComponent, uno::UNO_QUERY_THROW); lang::Locale aUSLocale, aFRLocale; aUSLocale.Language = "en"; @@ -594,16 +566,12 @@ void Test::testFdo48037() void Test::testFdo47764() { - load("fdo47764.rtf"); - // \cbpat with zero argument should mean the auto (-1) color, not a default color (black) CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(getParagraph(1), "ParaBackColor")); } void Test::testFdo38786() { - load("fdo38786.rtf"); - uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields()); uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration()); @@ -613,8 +581,6 @@ void Test::testFdo38786() void Test::testN757651() { - load("n757651.rtf"); - // The bug was that due to buggy layout the text expanded to two pages. if (Application::GetDefaultDevice()->IsFontAvailable(OUString("Times New Roman"))) CPPUNIT_ASSERT_EQUAL(1, getPages()); @@ -622,8 +588,6 @@ void Test::testN757651() void Test::testFdo49501() { - load("fdo49501.rtf"); - uno::Reference<beans::XPropertySet> xStyle(getStyles("PageStyles")->getByName("Default"), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_True, getProperty<sal_Bool>(xStyle, "IsLandscape")); @@ -636,15 +600,11 @@ void Test::testFdo49501() void Test::testFdo49271() { - load("fdo49271.rtf"); - CPPUNIT_ASSERT_EQUAL(25.f, getProperty<float>(getParagraph(2), "CharHeight")); } void Test::testFdo49692() { - load("fdo49692.rtf"); - uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY); uno::Sequence<beans::PropertyValue> aProps; @@ -661,8 +621,6 @@ void Test::testFdo49692() void Test::testFdo45190() { - load("fdo45190.rtf"); - // inherited \fi should be reset CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraph(1), "ParaFirstLineIndent")); @@ -672,15 +630,12 @@ void Test::testFdo45190() void Test::testFdo50539() { - load("fdo50539.rtf"); - // \chcbpat with zero argument should mean the auto (-1) color, not a default color (black) CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(getRun(getParagraph(1), 1), "CharBackColor")); } void Test::testFdo50665() { - load("fdo50665.rtf"); // Access the second run, which is a textfield uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1), 2), uno::UNO_QUERY); // This used to be the default, as character properties were ignored. @@ -689,8 +644,6 @@ void Test::testFdo50665() void Test::testFdo49659() { - load("fdo49659.rtf"); - // Both tables were ignored: 1) was in the header, 2) was ignored due to missing empty par at the end of the doc uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); @@ -710,8 +663,6 @@ void Test::testFdo46966() * * xray ThisComponent.StyleFamilies.PageStyles.Default.TopMargin */ - load("fdo46966.rtf"); - uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName("Default"), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(720)), getProperty<sal_Int32>(xPropertySet, "TopMargin")); } @@ -723,8 +674,6 @@ void Test::testFdo52066() * * xray ThisComponent.DrawPage(0).Size.Height */ - load("fdo52066.rtf"); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); uno::Reference<drawing::XShape> xShape(xDraws->getByIndex(0), uno::UNO_QUERY); @@ -743,7 +692,6 @@ void Test::testFdo48033() * oRun = oRuns.nextElement * xray oRun.TextPortionType ' Frame, was Text */ - load("fdo48033.rtf"); uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY); @@ -756,13 +704,11 @@ void Test::testFdo48033() void Test::testFdo36089() { - load("fdo36089.rtf"); CPPUNIT_ASSERT_EQUAL(sal_Int16(-50), getProperty<sal_Int16>(getRun(getParagraph(1), 2), "CharEscapement")); } void Test::testFdo49892() { - load("fdo49892.rtf"); uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); for (int i = 0; i < xDraws->getCount(); ++i) @@ -784,29 +730,24 @@ void Test::testFdo49892() void Test::testFdo48446() { - load("fdo48446.rtf"); - OUString aExpected("Имя", 6, RTL_TEXTENCODING_UTF8); getParagraph(1, aExpected); } void Test::testFdo47495() { - load("fdo47495.rtf"); // Used to have 4 paragraphs, as a result the original bugdoc had 2 pages instead of 1. CPPUNIT_ASSERT_EQUAL(2, getParagraphs()); } void Test::testAllGapsWord() { - load("all_gaps_word.rtf"); BorderTest borderTest; borderTest.testTheBorders(mxComponent); } void Test::testFdo52052() { - load("fdo52052.rtf"); // Make sure the textframe containing the text "third" appears on the 3rd page. CPPUNIT_ASSERT_EQUAL(OUString("third"), parseDump("/root/page[3]/body/txt/anchored/fly/txt/text()")); } @@ -822,8 +763,6 @@ void Test::testInk() * msgbox oSegments(1).Count ' was 0x2000 | 10, should be 10 * msgbox oShape.Surround ' was 2, should be 1 */ - load("ink.rtf"); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xDraws->getByIndex(0), "CustomShapeGeometry"); @@ -847,7 +786,6 @@ void Test::testInk() void Test::testFdo52389() { // The last '!' character at the end of the document was lost - load("fdo52389.rtf"); CPPUNIT_ASSERT_EQUAL(6, getLength()); } @@ -858,7 +796,6 @@ void Test::testFdo49655() * * xray ThisComponent.TextTables.Count 'was 0 */ - load("fdo49655.rtf"); uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); @@ -867,14 +804,12 @@ void Test::testFdo49655() void Test::testFdo52475() { // The problem was that \chcbpat0 resulted in no color, instead of COL_AUTO. - load("fdo52475.rtf"); CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(getRun(getParagraph(1), 3), "CharBackColor")); } void Test::testFdo55493() { // The problem was that the width of the PNG was detected as 15,24cm, instead of 3.97cm - load("fdo55493.rtf"); uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); uno::Reference<drawing::XShape> xShape(xDraws->getByIndex(0), uno::UNO_QUERY); @@ -884,8 +819,6 @@ void Test::testFdo55493() void Test::testCopyPastePageStyle() { // The problem was that RTF import during copy&paste did not ignore page styles. - load("copypaste-pagestyle.rtf"); - // Once we have more copy&paste tests, makes sense to refactor this to some helper method. uno::Reference<uno::XInterface> xInterface(m_xSFactory->createInstance("com.sun.star.comp.Writer.RtfFilter"), uno::UNO_QUERY_THROW); uno::Reference<document::XImporter> xImporter(xInterface, uno::UNO_QUERY_THROW); @@ -907,7 +840,6 @@ void Test::testCopyPastePageStyle() void Test::testShptxtPard() { // The problem was that \pard inside \shptxt caused loss of shape text - load("shptxt-pard.rtf"); uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); uno::Reference<text::XText> xText(xDraws->getByIndex(0), uno::UNO_QUERY); @@ -916,7 +848,6 @@ void Test::testShptxtPard() void Test::testDoDhgt() { - load("do-dhgt.rtf"); uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); for (int i = 0; i < xDraws->getCount(); ++i) @@ -933,7 +864,6 @@ void Test::testDoDhgt() void Test::testDplinehollow() { - load("dplinehollow.rtf"); uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY); @@ -943,14 +873,12 @@ void Test::testDplinehollow() void Test::testLeftmarginDefault() { // The default left/right margin was incorrect when the top margin was set to zero. - load("leftmargin-default.rtf"); CPPUNIT_ASSERT_EQUAL(sal_Int32(2540), getProperty<sal_Int32>(getStyles("PageStyles")->getByName("Default"), "LeftMargin")); } void Test::testDppolyline() { // This was completely ignored, for now, just make sure we have all 4 lines. - load("dppolyline.rtf"); uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xDraws->getCount()); diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx index 49c3ec08c493..13fea52d7fb9 100644 --- a/sw/qa/extras/ww8import/ww8import.cxx +++ b/sw/qa/extras/ww8import/ww8import.cxx @@ -50,30 +50,35 @@ public: CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) - CPPUNIT_TEST(testN757910); - CPPUNIT_TEST(testN760294); - CPPUNIT_TEST(testN750255); - CPPUNIT_TEST(testN652364); - CPPUNIT_TEST(testN757118); - CPPUNIT_TEST(testN757905); - CPPUNIT_TEST(testAllGapsWord); + CPPUNIT_TEST(run); #endif CPPUNIT_TEST_SUITE_END(); private: - /// Load a WW8 file and make the document available via mxComponent. - void load(const OUString& rURL); + void run(); }; -void Test::load(const OUString& rFilename) +void Test::run() { - mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/ww8import/data/") + rFilename); + MethodEntry<Test> aMethods[] = { + {"n757910.doc", &Test::testN757910}, + {"n760294.doc", &Test::testN760294}, + {"n750255.doc", &Test::testN750255}, + {"n652364.doc", &Test::testN652364}, + {"n757118.doc", &Test::testN757118}, + {"n757905.doc", &Test::testN757905}, + {"all_gaps_word.doc", &Test::testAllGapsWord}, + }; + for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) + { + MethodEntry<Test>& rEntry = aMethods[i]; + mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/ww8import/data/") + OUString::createFromAscii(rEntry.pName)); + (this->*rEntry.pMethod)(); + } } void Test::testN757910() { - load("n757910.doc"); - // The internal margin was larger than 0.28cm uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); @@ -90,8 +95,6 @@ void Test::testN757910() void Test::testN760294() { - load("n760294.doc"); - uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xTable(xIndexAccess->getByIndex(0), uno::UNO_QUERY); @@ -103,8 +106,6 @@ void Test::testN760294() void Test::testN750255() { - load( "n750255.doc" ); - /* Column break without columns on the page is a page break, so check those paragraphs are on page 2 (page style 'Convert 1') and page 3 (page style 'Convert 2') @@ -142,8 +143,6 @@ xray para2.PageStyleName void Test::testN652364() { - load( "n652364.doc" ); - /* Related to 750255 above, column break with columns on the page however should be a column break. enum = ThisComponent.Text.createEnumeration @@ -181,7 +180,6 @@ xray para2.PageStyleName void Test::testN757118() { - load( "n757118.doc" ); /* Two pairs of horizontal rules (one absolute width, one relative width) have the same width (full page width, half page width). @@ -216,15 +214,12 @@ void Test::testN757905() // paragraph height. When in Word-compat mode, we should take the max of // the two, not just the height of the fly. - load("n757905.doc"); - OUString aHeight = parseDump("/root/page/body/txt/infos/bounds", "height"); CPPUNIT_ASSERT(sal_Int32(31) < aHeight.toInt32()); } void Test::testAllGapsWord() { - load("all_gaps_word.doc"); BorderTest borderTest; borderTest.testTheBorders(mxComponent); } |