sw/qa/core/fields/fields.cxx | 7 ++-- sw/qa/core/layout/flycnt.cxx | 4 -- sw/qa/extras/fodfexport/fodfexport.cxx | 4 +- sw/qa/extras/htmlimport/htmlimport.cxx | 2 - sw/qa/extras/layout/layout.cxx | 12 +------ sw/qa/extras/layout/layout2.cxx | 9 +---- sw/qa/extras/layout/layout3.cxx | 45 +++++------------------------ sw/qa/extras/ooxmlexport/ooxmlexport20.cxx | 4 +- sw/qa/extras/ooxmlexport/ooxmlexport21.cxx | 4 +- sw/qa/extras/rtfexport/rtfexport3.cxx | 2 - sw/qa/filter/ww8/ww8.cxx | 6 +-- sw/qa/uibase/uiview/uiview.cxx | 5 --- 12 files changed, 30 insertions(+), 74 deletions(-)
New commits: commit 3a8278c42e14b03eb57987adf33b6d61bfb3f856 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Fri Oct 25 15:07:58 2024 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Fri Oct 25 21:39:10 2024 +0200 sw/qa: simplify a bit Change-Id: I5d75561f06ce4f981927afb333af5a99bd7ffe26 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175645 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> Tested-by: Jenkins diff --git a/sw/qa/core/fields/fields.cxx b/sw/qa/core/fields/fields.cxx index fc0edc5d61ea..a9b11aca3322 100644 --- a/sw/qa/core/fields/fields.cxx +++ b/sw/qa/core/fields/fields.cxx @@ -158,7 +158,7 @@ CPPUNIT_TEST_FIXTURE(Test, testChapterFieldsFollowedBy) CPPUNIT_TEST_FIXTURE(Test, testTdf86790) { - loadFromFile(u"tdf86790.docx"); + createSwDoc("tdf86790.docx"); uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XEnumerationAccess> xFieldsAccess( @@ -385,7 +385,7 @@ CPPUNIT_TEST_FIXTURE(Test, testFootnoteStyleRef) /// STYLEREFs with the REFFLDFLAG_HIDE_NON_NUMERICAL flag should hide all characters that are not numerical or delimiters CPPUNIT_TEST_FIXTURE(Test, testNumericalStyleRef) { - loadFromFile(u"suppress-non-numerical.docx"); + createSwDoc("suppress-non-numerical.docx"); uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XEnumerationAccess> xFieldsAccess( @@ -415,7 +415,7 @@ CPPUNIT_TEST_FIXTURE(Test, testNumericalStyleRef) /// this docx only has such stylerefs to avoid confusion) CPPUNIT_TEST_FIXTURE(Test, testOOXMLStyleRefFlags) { - loadFromFile(u"styleref-flags.docx"); + createSwDoc("styleref-flags.docx"); uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XEnumerationAccess> xFieldsAccess( @@ -446,6 +446,7 @@ CPPUNIT_TEST_FIXTURE(Test, testOOXMLStyleRefFlags) /// this docx only has such stylerefs to avoid confusion) CPPUNIT_TEST_FIXTURE(Test, testODFStyleRef) { + // if createSwDoc is used then calcLayout is called and the field values are different loadFromFile(u"styleref.odt"); uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx index 3e9fcb981125..ec4cee9ed13a 100644 --- a/sw/qa/core/layout/flycnt.cxx +++ b/sw/qa/core/layout/flycnt.cxx @@ -733,9 +733,7 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyThenTable) uno::Sequence<beans::PropertyValue> aFilterOptions = { comphelper::makePropertyValue(u"Hidden"_ustr, true), }; - mxComponent = loadFromDesktop(m_directories.getURLFromSrc(u"/sw/qa/core/layout/data/") - + "floattable-then-table.docx", - u"com.sun.star.text.TextDocument"_ustr, aFilterOptions); + loadWithParams(createFileURL(u"floattable-then-table.docx"), aFilterOptions); // When layout is calculated during PDF export: // Then make sure that finishes without errors: diff --git a/sw/qa/extras/fodfexport/fodfexport.cxx b/sw/qa/extras/fodfexport/fodfexport.cxx index a24c0c6d63b0..97d9bcdfca5b 100644 --- a/sw/qa/extras/fodfexport/fodfexport.cxx +++ b/sw/qa/extras/fodfexport/fodfexport.cxx @@ -25,7 +25,7 @@ public: CPPUNIT_TEST_FIXTURE(Test, testTdf113696) { - loadFromFile(u"tdf113696.odt"); + createSwDoc("tdf113696.odt"); CPPUNIT_ASSERT_EQUAL(1, getShapes()); CPPUNIT_ASSERT_EQUAL(1, getPages()); @@ -42,7 +42,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf113696) CPPUNIT_TEST_FIXTURE(Test, testTdf113696WriterImage) { - loadFromFile(u"tdf113696-writerimage.odt"); + createSwDoc("tdf113696-writerimage.odt"); CPPUNIT_ASSERT_EQUAL(1, getShapes()); CPPUNIT_ASSERT_EQUAL(1, getPages()); diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx index ee6b24e264a1..43163ce5a39a 100644 --- a/sw/qa/extras/htmlimport/htmlimport.cxx +++ b/sw/qa/extras/htmlimport/htmlimport.cxx @@ -443,7 +443,7 @@ CPPUNIT_TEST_FIXTURE(SwHtmlOptionsImportTest, testAllowedRTFOLEMimeTypes) comphelper::makePropertyValue(u"AllowedRTFOLEMimeTypes"_ustr, aTypes), }; OUString aURL = createFileURL(u"allowed-rtf-ole-mime-types.xhtml"); - mxComponent = loadFromDesktop(aURL, u"com.sun.star.text.TextDocument"_ustr, aLoadProperties); + loadWithParams(aURL, aLoadProperties); uno::Reference<text::XTextEmbeddedObjectsSupplier> xSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xObjects(xSupplier->getEmbeddedObjects(), uno::UNO_QUERY); diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index 2db76beeca42..739607e7db6e 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -3474,15 +3474,9 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf155345) CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf109137) { createSwDoc("tdf109137.docx"); - // FIXME: it's not possible to use 'reload' here because the validation fails with - // Error: attribute "text:start-value" has a bad value - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); - uno::Sequence<beans::PropertyValue> aDescriptor(comphelper::InitPropertySequence({ - { "FilterName", uno::Any(u"writer8"_ustr) }, - })); - xStorable->storeToURL(maTempFile.GetURL(), aDescriptor); - mxComponent->dispose(); - mxComponent = loadFromDesktop(maTempFile.GetURL(), u"com.sun.star.text.TextDocument"_ustr); + // FIXME: Error: attribute "text:start-value" has a bad value + skipValidation(); + saveAndReload(u"writer8"_ustr); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // This was 0, the blue rectangle moved from the 1st to the 2nd page. assertXPath(pXmlDoc, "/root/page[1]/body/txt/anchored/fly/notxt", diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index aa8adb36df09..3e6609931c0b 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -937,11 +937,6 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineMovingDOCX) CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTableCellInvalidate) { - if (mxComponent.is()) - mxComponent->dispose(); - - OUString const url(createFileURL(u"table_cell_overlap.fodt")); - // note: must set Hidden property, so that SfxFrameViewWindow_Impl::Resize() // does *not* forward initial VCL Window Resize and thereby triggers a // layout which does not happen on soffice --convert-to pdf. @@ -951,8 +946,8 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTableCellInvalidate) }; // inline the loading because currently properties can't be passed... - mxComponent = loadFromDesktop(url, u"com.sun.star.text.TextDocument"_ustr, - comphelper::containerToSequence(aFilterOptions)); + OUString const url(createFileURL(u"table_cell_overlap.fodt")); + loadWithParams(url, comphelper::containerToSequence(aFilterOptions)); save(u"writer_pdf_Export"_ustr); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx index 355097ecb64d..7fd080b043e2 100644 --- a/sw/qa/extras/layout/layout3.cxx +++ b/sw/qa/extras/layout/layout3.cxx @@ -929,11 +929,6 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf122607) CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf122607_regression) { - if (mxComponent.is()) - mxComponent->dispose(); - - OUString const url(createFileURL(u"tdf122607_leerzeile.odt")); - // note: must set Hidden property, so that SfxFrameViewWindow_Impl::Resize() // does *not* forward initial VCL Window Resize and thereby triggers a // layout which does not happen on soffice --convert-to pdf. @@ -943,14 +938,9 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf122607_regression) }; // inline the loading because currently properties can't be passed... - mxComponent = loadFromDesktop(url, u"com.sun.star.text.TextDocument"_ustr, - comphelper::containerToSequence(aFilterOptions)); - uno::Sequence<beans::PropertyValue> props(comphelper::InitPropertySequence({ - { "FilterName", uno::Any(u"writer_pdf_Export"_ustr) }, - })); - utl::TempFileNamed aTempFile; - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); - xStorable->storeToURL(aTempFile.GetURL(), props); + OUString const url(createFileURL(u"tdf122607_leerzeile.odt")); + loadWithParams(url, comphelper::containerToSequence(aFilterOptions)); + save(u"writer_pdf_Export"_ustr); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // somehow these 2 rows overlapped in the PDF unless CalcLayout() runs @@ -963,17 +953,10 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf122607_regression) // this was 3034, causing the overlap assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[2]/infos/bounds", "top", u"3218"); assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[2]/infos/bounds", "height", u"164"); - - aTempFile.EnableKillingFile(); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, TestTdf150616) { - if (mxComponent.is()) - mxComponent->dispose(); - - OUString const url(createFileURL(u"in_056132_mod.odt")); - // note: must set Hidden property, so that SfxFrameViewWindow_Impl::Resize() // does *not* forward initial VCL Window Resize and thereby triggers a // layout which does not happen on soffice --convert-to pdf. @@ -983,14 +966,9 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, TestTdf150616) }; // inline the loading because currently properties can't be passed... - mxComponent = loadFromDesktop(url, u"com.sun.star.text.TextDocument"_ustr, - comphelper::containerToSequence(aFilterOptions)); - uno::Sequence<beans::PropertyValue> props(comphelper::InitPropertySequence({ - { "FilterName", uno::Any(u"writer_pdf_Export"_ustr) }, - })); - utl::TempFileNamed aTempFile; - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); - xStorable->storeToURL(aTempFile.GetURL(), props); + OUString const url(createFileURL(u"in_056132_mod.odt")); + loadWithParams(url, comphelper::containerToSequence(aFilterOptions)); + save(u"writer_pdf_Export"_ustr); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); CPPUNIT_ASSERT(pXmlDoc); @@ -1010,8 +988,6 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, TestTdf150616) u"697"); assertXPath(pXmlDoc, "/root/page[1]/body/tab[3]/row[2]/cell[2]/txt[3]/infos/bounds", "top", u"8178"); - - aTempFile.EnableKillingFile(); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testBtlrCell) @@ -1791,11 +1767,6 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf128399) CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf156724) { - if (mxComponent.is()) - mxComponent->dispose(); - - OUString const url(createFileURL(u"fdo56797-2-min.odt")); - // note: must set Hidden property, so that SfxFrameViewWindow_Impl::Resize() // does *not* forward initial VCL Window Resize and thereby triggers a // layout which does not happen on soffice --convert-to pdf. @@ -1805,8 +1776,8 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf156724) }; // inline the loading because currently properties can't be passed... - mxComponent = loadFromDesktop(url, u"com.sun.star.text.TextDocument"_ustr, - comphelper::containerToSequence(aFilterOptions)); + OUString const url(createFileURL(u"fdo56797-2-min.odt")); + loadWithParams(url, comphelper::containerToSequence(aFilterOptions)); save(u"writer_pdf_Export"_ustr); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport20.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport20.cxx index 004b6b851526..d05f809098bd 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport20.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport20.cxx @@ -1034,7 +1034,7 @@ CPPUNIT_TEST_FIXTURE(Test, testtdf158044) CPPUNIT_TEST_FIXTURE(Test, testTdf158855) { // Given a table immediately followed by a section break - loadFromFile(u"section_break_after_table.docx"); + createSwDoc("section_break_after_table.docx"); // Check that the import doesn't produce an extra empty paragraph before a page break CPPUNIT_ASSERT_EQUAL(2, getPages()); // was 3 @@ -1053,7 +1053,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf158855) CPPUNIT_TEST_FIXTURE(Test, testTdf158971) { // Given a section break and an SDT in the following paragraph - loadFromFile(u"sdt_after_section_break.docx"); + createSwDoc("sdt_after_section_break.docx"); // Check that the import doesn't introduce unwanted character properties in the paragraph after // the section break diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx index b40ec3abc74d..7cee3e4a714e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx @@ -722,7 +722,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf162551, "tdf162551_notLayoutInCell_charLeft_from CPPUNIT_TEST_FIXTURE(Test, testTdf159207_footerFramePrBorder) { - loadFromFile(u"tdf159207_footerFramePrBorder.docx"); // re-imports as editeng Frame/Shape + createSwDoc("tdf159207_footerFramePrBorder.docx"); // re-imports as editeng Frame/Shape // given a doc with footer paragraphs frame (with a top border, but no left border) uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); @@ -1063,7 +1063,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf128460) CPPUNIT_TEST_FIXTURE(Test, testTdf131288) { // Given a document with an embedded chart - loadFromFile(u"tdf131288.docx"); + createSwDoc("tdf131288.docx"); // Edit the document and save **twice** uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); diff --git a/sw/qa/extras/rtfexport/rtfexport3.cxx b/sw/qa/extras/rtfexport/rtfexport3.cxx index 930ff6b8a884..6b97dca453aa 100644 --- a/sw/qa/extras/rtfexport/rtfexport3.cxx +++ b/sw/qa/extras/rtfexport/rtfexport3.cxx @@ -796,7 +796,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf152784_1) CPPUNIT_TEST_FIXTURE(Test, testFloatingTableExport) { // Given a document with a floating table: - mxComponent = loadFromDesktop(u"private:factory/swriter"_ustr); + createSwDoc(); // Insert a table: uno::Sequence<beans::PropertyValue> aArgs = { comphelper::makePropertyValue(u"Rows"_ustr, static_cast<sal_Int32>(1)), diff --git a/sw/qa/filter/ww8/ww8.cxx b/sw/qa/filter/ww8/ww8.cxx index b62075e9a3bd..becca79534b1 100644 --- a/sw/qa/filter/ww8/ww8.cxx +++ b/sw/qa/filter/ww8/ww8.cxx @@ -183,7 +183,7 @@ CPPUNIT_TEST_FIXTURE(Test, testDocxContentControlDropdownEmptyDisplayText) CPPUNIT_TEST_FIXTURE(Test, testDocxSymbolFontExport) { // Create document with symbol character and font Wingdings - mxComponent = loadFromDesktop(u"private:factory/swriter"_ustr); + createSwDoc(); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XText> xText = xTextDocument->getText(); uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor(); @@ -643,7 +643,7 @@ CPPUNIT_TEST_FIXTURE(Test, tdf71749_with_footnote) { // Without the fix in place, // loading the document would hang. - loadFromFile(u"tdf71749_with_footnote.doc"); + createSwDoc("tdf71749_with_footnote.doc"); CPPUNIT_ASSERT_EQUAL(1, getPages()); } @@ -651,7 +651,7 @@ CPPUNIT_TEST_FIXTURE(Test, tdf71749_without_footnote) { // Without the fix in place, // loading the document would hang. - loadFromFile(u"tdf71749_without_footnote.doc"); + createSwDoc("tdf71749_without_footnote.doc"); CPPUNIT_ASSERT_EQUAL(1, getPages()); } } diff --git a/sw/qa/uibase/uiview/uiview.cxx b/sw/qa/uibase/uiview/uiview.cxx index 46b69a920feb..fe4540e64e81 100644 --- a/sw/qa/uibase/uiview/uiview.cxx +++ b/sw/qa/uibase/uiview/uiview.cxx @@ -117,10 +117,7 @@ CPPUNIT_TEST_FIXTURE(SwUibaseUiviewTest, testUpdateReplacementNosetting) CPPUNIT_TEST_FIXTURE(SwUibaseUiviewTest, testKeepRatio) { // Given a document with a custom KeepRatio: - OUString aURL = createFileURL(u"keep-ratio.fodt"); - - // When loading that document: - mxComponent = loadFromDesktop(aURL); + createSwDoc("keep-ratio.fodt"); // Then make sure we read the custom value: auto pXTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get());