filter/qa/pdf.cxx | 26 ++++- filter/qa/unit/textfilterdetect.cxx | 45 +++++++-- oox/qa/unit/export.cxx | 55 +++++------ svx/qa/unit/svdraw.cxx | 141 +++++++++++++++++------------- xmloff/qa/unit/draw.cxx | 4 xmloff/qa/unit/style.cxx | 168 ++++++++++++++++-------------------- 6 files changed, 246 insertions(+), 193 deletions(-)
New commits: commit a9491be1f105c47c4f632d690f27251e0ed10880 Author: Xisco Fauli <[email protected]> AuthorDate: Mon Feb 9 11:08:33 2026 +0100 Commit: Xisco Fauli <[email protected]> CommitDate: Mon Feb 9 17:02:24 2026 +0100 filter, xmloff, svx, oox: only load one document per test Change-Id: Ibb07c8069e6ce8965739c7ccef52c41bb1f04422 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198968 Reviewed-by: Xisco Fauli <[email protected]> Tested-by: Jenkins diff --git a/filter/qa/pdf.cxx b/filter/qa/pdf.cxx index 617d7ea50b77..c13b7f57d8a8 100644 --- a/filter/qa/pdf.cxx +++ b/filter/qa/pdf.cxx @@ -205,17 +205,35 @@ void Test::doTestCommentsInMargin(bool commentsInMarginEnabled) CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->openPage(0)->getObjectCount()); } -CPPUNIT_TEST_FIXTURE(Test, testCommentsInMargin) +CPPUNIT_TEST_FIXTURE(Test, testCommentsInMarginEnabled) { doTestCommentsInMargin(true); } + +CPPUNIT_TEST_FIXTURE(Test, testCommentsInMarginDisabled) { doTestCommentsInMargin(false); } + +CPPUNIT_TEST_FIXTURE(Test, testCommentsInMarginEnabledTiledAnnotationsEnabled) { - // Test that setting/unsetting the "ExportNotesInMargin" property works correctly - doTestCommentsInMargin(true); - doTestCommentsInMargin(false); comphelper::LibreOfficeKit::setActive(true); comphelper::LibreOfficeKit::setTiledAnnotations(true); doTestCommentsInMargin(true); +} + +CPPUNIT_TEST_FIXTURE(Test, testCommentsInMarginDisabledTiledAnnotationsEnabled) +{ + comphelper::LibreOfficeKit::setActive(true); + comphelper::LibreOfficeKit::setTiledAnnotations(true); doTestCommentsInMargin(false); +} + +CPPUNIT_TEST_FIXTURE(Test, testCommentsInMarginEnabledTiledAnnotationsDisabled) +{ + comphelper::LibreOfficeKit::setActive(true); comphelper::LibreOfficeKit::setTiledAnnotations(false); doTestCommentsInMargin(true); +} + +CPPUNIT_TEST_FIXTURE(Test, testCommentsInMarginDisabledTiledAnnotationsDisabled) +{ + comphelper::LibreOfficeKit::setActive(true); + comphelper::LibreOfficeKit::setTiledAnnotations(false); doTestCommentsInMargin(false); } diff --git a/filter/qa/unit/textfilterdetect.cxx b/filter/qa/unit/textfilterdetect.cxx index 7ee499c4cb73..344659d8b11c 100644 --- a/filter/qa/unit/textfilterdetect.cxx +++ b/filter/qa/unit/textfilterdetect.cxx @@ -74,7 +74,7 @@ CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testTdf114428_ignore_xml_declaration) CPPUNIT_ASSERT_EQUAL(u"HTML (StarWriter)"_ustr, aFilterName); } -CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testEmptyFile) +CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testEmptyFilePPTX) { // Given an empty file, with a pptx extension // When loading the file @@ -85,24 +85,36 @@ CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testEmptyFile) // Writer instead. CPPUNIT_ASSERT( supportsService(mxComponent, u"com.sun.star.presentation.PresentationDocument"_ustr)); +} +CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testEmptyFileODT) +{ // Now also test ODT loadFromFile(u"empty.odt"); // Make sure it opens in Writer. CPPUNIT_ASSERT(supportsService(mxComponent, u"com.sun.star.text.TextDocument"_ustr)); +} +CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testEmptyFileODS) +{ // ... and ODS loadFromFile(u"empty.ods"); // Make sure it opens in Calc. CPPUNIT_ASSERT(supportsService(mxComponent, u"com.sun.star.sheet.SpreadsheetDocument"_ustr)); +} +CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testEmptyFileODP) +{ // ... and ODP loadFromFile(u"empty.odp"); // Without the accompanying fix in place, this test would have failed, as it was opened in // Writer instead. CPPUNIT_ASSERT( supportsService(mxComponent, u"com.sun.star.presentation.PresentationDocument"_ustr)); +} +CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testEmptyFileDOC) +{ // ... and DOC // Without the accompanying fix in place, this test would have failed, the import filter aborted // loading. @@ -120,16 +132,12 @@ CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testEmptyFile) // i.e. opening worked, but saving back failed instead of producing a WW8 binary file. CPPUNIT_ASSERT_EQUAL(u"MS Word 97"_ustr, aFilterName); } +} - // Now test with default templates set - +CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testEmptyFilePPTX_Template) +{ SfxObjectFactory::SetStandardTemplate(u"com.sun.star.presentation.PresentationDocument"_ustr, createFileURL(u"impress.otp")); - SfxObjectFactory::SetStandardTemplate(u"com.sun.star.text.TextDocument"_ustr, - createFileURL(u"writer.ott")); - SfxObjectFactory::SetStandardTemplate(u"com.sun.star.sheet.SpreadsheetDocument"_ustr, - createFileURL(u"calc.ots")); - loadFromFile(u"empty.pptx"); { uno::Reference<drawing::XDrawPagesSupplier> xDoc(mxComponent, uno::UNO_QUERY_THROW); @@ -140,7 +148,12 @@ CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testEmptyFile) // Make sure the template's text was loaded CPPUNIT_ASSERT_EQUAL(u"Title of Impress template"_ustr, xBox->getString()); } +} +CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testEmptyFileODT_Template) +{ + SfxObjectFactory::SetStandardTemplate(u"com.sun.star.text.TextDocument"_ustr, + createFileURL(u"writer.ott")); loadFromFile(u"empty.odt"); { uno::Reference<text::XTextDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW); @@ -151,7 +164,12 @@ CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testEmptyFile) // Make sure the template's text was loaded CPPUNIT_ASSERT_EQUAL(u"Writer template’s first line"_ustr, xParagraph->getString()); } +} +CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testEmptyFileODS_Template) +{ + SfxObjectFactory::SetStandardTemplate(u"com.sun.star.sheet.SpreadsheetDocument"_ustr, + createFileURL(u"calc.ots")); loadFromFile(u"empty.ods"); { uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW); @@ -161,7 +179,12 @@ CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testEmptyFile) // Make sure the template's text was loaded CPPUNIT_ASSERT_EQUAL(u"Calc template’s first cell"_ustr, xC->getString()); } +} +CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testEmptyFileODP_Template) +{ + SfxObjectFactory::SetStandardTemplate(u"com.sun.star.presentation.PresentationDocument"_ustr, + createFileURL(u"impress.otp")); loadFromFile(u"empty.odp"); { uno::Reference<drawing::XDrawPagesSupplier> xDoc(mxComponent, uno::UNO_QUERY_THROW); @@ -172,6 +195,12 @@ CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testEmptyFile) // Make sure the template's text was loaded CPPUNIT_ASSERT_EQUAL(u"Title of Impress template"_ustr, xBox->getString()); } +} + +CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testEmptyFileDOC_Template) +{ + SfxObjectFactory::SetStandardTemplate(u"com.sun.star.text.TextDocument"_ustr, + createFileURL(u"writer.ott")); loadFromFile(u"empty.doc"); { uno::Reference<text::XTextDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW); diff --git a/oox/qa/unit/export.cxx b/oox/qa/unit/export.cxx index 3fb8e911ef61..76e7df34d9f4 100644 --- a/oox/qa/unit/export.cxx +++ b/oox/qa/unit/export.cxx @@ -82,44 +82,43 @@ CPPUNIT_TEST_FIXTURE(Test, testInsertCheckboxContentControlOdt) CPPUNIT_TEST_FIXTURE(Test, testInsertCheckboxContentControlDocx) { - { - loadFromFile(u"dml-groupshape-polygon.docx"); + loadFromFile(u"dml-groupshape-polygon.docx"); - // Without TrackChanges, inserting the Checkbox works just fine - // when exporting to docx. - dispatchCommand(mxComponent, u".uno:InsertCheckboxContentControl"_ustr, {}); + // Without TrackChanges, inserting the Checkbox works just fine + // when exporting to docx. + dispatchCommand(mxComponent, u".uno:InsertCheckboxContentControl"_ustr, {}); - save(TestFilter::DOCX); - } + save(TestFilter::DOCX); +} - { - loadFromFile(u"dml-groupshape-polygon.docx"); +CPPUNIT_TEST_FIXTURE(Test, testInsertCheckboxContentControlDocx_2) +{ + loadFromFile(u"dml-groupshape-polygon.docx"); - uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); - uno::Reference<text::XText> xText = xTextDocument->getText(); - uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor(); + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XText> xText = xTextDocument->getText(); + uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor(); - // With TrackChanges, the Checkbox causes an assertion in the sax serializer, - // in void sax_fastparser::FastSaxSerializer::endFastElement(sal_Int32). - // Element == maMarkStack.top()->m_DebugStartedElements.back() - // sax/source/tools/fastserializer.cxx#402 - dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {}); + // With TrackChanges, the Checkbox causes an assertion in the sax serializer, + // in void sax_fastparser::FastSaxSerializer::endFastElement(sal_Int32). + // Element == maMarkStack.top()->m_DebugStartedElements.back() + // sax/source/tools/fastserializer.cxx#402 + dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {}); - xText->insertControlCharacter(xCursor, text::ControlCharacter::PARAGRAPH_BREAK, false); + xText->insertControlCharacter(xCursor, text::ControlCharacter::PARAGRAPH_BREAK, false); - dispatchCommand(mxComponent, u".uno:InsertCheckboxContentControl"_ustr, {}); + dispatchCommand(mxComponent, u".uno:InsertCheckboxContentControl"_ustr, {}); - // Loading should not show the "corrupted" dialog, which would assert. - saveAndReload(TestFilter::DOCX); + // Loading should not show the "corrupted" dialog, which would assert. + saveAndReload(TestFilter::DOCX); - // Now that we loaded it successfully, delete the controls, - // still with change-tracking enabled, and save. - dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); - dispatchCommand(mxComponent, u".uno:Delete"_ustr, {}); + // Now that we loaded it successfully, delete the controls, + // still with change-tracking enabled, and save. + dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); + dispatchCommand(mxComponent, u".uno:Delete"_ustr, {}); - // Loading should not show the "corrupted" dialog, which would assert. - saveAndReload(TestFilter::DOCX); - } + // Loading should not show the "corrupted" dialog, which would assert. + saveAndReload(TestFilter::DOCX); } CPPUNIT_TEST_FIXTURE(Test, testDmlGroupshapePolygon) diff --git a/svx/qa/unit/svdraw.cxx b/svx/qa/unit/svdraw.cxx index 433656232329..a8dc438553ba 100644 --- a/svx/qa/unit/svdraw.cxx +++ b/svx/qa/unit/svdraw.cxx @@ -67,6 +67,9 @@ public: void setUp() override; + void testEOLinCurvedText(std::u16string_view aFileName, bool bLegacy); + void testCurveTextWidth(std::u16string_view aFileName, bool bLegacy); + #if ENABLE_PDFIMPORT uno::Reference<xml::crypto::XXMLSecurityContext>& getSecurityContext() { @@ -443,86 +446,102 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testFontWorks) CPPUNIT_TEST_FIXTURE(SvdrawTest, testTdf148000_EOLinCurvedText) { - std::vector<OUString> aFilenames - = { u"tdf148000_EOLinCurvedText.pptx"_ustr, u"tdf148000_EOLinCurvedText_New.odp"_ustr, - u"tdf148000_EOLinCurvedText_Legacy.odp"_ustr }; + testEOLinCurvedText(u"tdf148000_EOLinCurvedText.pptx", false); +} - for (int i = 0; i < 3; i++) - { - loadFromFile(aFilenames[i]); +CPPUNIT_TEST_FIXTURE(SvdrawTest, testTdf148000_EOLinCurvedText_New) +{ + testEOLinCurvedText(u"tdf148000_EOLinCurvedText_New.odp", false); +} + +CPPUNIT_TEST_FIXTURE(SvdrawTest, testTdf148000_EOLinCurvedText_Legacy) +{ + testEOLinCurvedText(u"tdf148000_EOLinCurvedText_Legacy.odp", true); +} + +void SvdrawTest::testEOLinCurvedText(std::u16string_view aFileName, bool bLegacy) +{ + loadFromFile(aFileName); - SdrPage* pSdrPage = getFirstDrawPageWithAssert(); + SdrPage* pSdrPage = getFirstDrawPageWithAssert(); - xmlDocUniquePtr pXmlDoc = lcl_dumpAndParseFirstObjectWithAssert(pSdrPage); - tools::XPath aXPath(pXmlDoc.get()); + xmlDocUniquePtr pXmlDoc = lcl_dumpAndParseFirstObjectWithAssert(pSdrPage); + tools::XPath aXPath(pXmlDoc.get()); - // this is a group shape, hence 2 nested objectinfo - auto aBasePath = aXPath.create("/primitive2D/objectinfo[4]/objectinfo/unhandled/group/" - "unhandled/group/polypolygoncolor/polypolygon"); + // this is a group shape, hence 2 nested objectinfo + auto aBasePath = aXPath.create("/primitive2D/objectinfo[4]/objectinfo/unhandled/group/" + "unhandled/group/polypolygoncolor/polypolygon"); - // The text is: "O" + eop + "O" + eol + "O" - // It should be displayed as 3 line of text. (1 "O" letter in every line) + // The text is: "O" + eop + "O" + eol + "O" + // It should be displayed as 3 line of text. (1 "O" letter in every line) - sal_Int32 nY1 = aXPath.create(aBasePath, "/polygon[1]/point[1]")->attribute("y").toInt32(); - sal_Int32 nY2 = aXPath.create(aBasePath, "/polygon[3]/point[1]")->attribute("y").toInt32(); - sal_Int32 nY3 = aXPath.create(aBasePath, "/polygon[5]/point[1]")->attribute("y").toInt32(); + sal_Int32 nY1 = aXPath.create(aBasePath, "/polygon[1]/point[1]")->attribute("y").toInt32(); + sal_Int32 nY2 = aXPath.create(aBasePath, "/polygon[3]/point[1]")->attribute("y").toInt32(); + sal_Int32 nY3 = aXPath.create(aBasePath, "/polygon[5]/point[1]")->attribute("y").toInt32(); - sal_Int32 nDiff21 = nY2 - nY1; - sal_Int32 nDiff32 = nY3 - nY2; + sal_Int32 nDiff21 = nY2 - nY1; + sal_Int32 nDiff32 = nY3 - nY2; - // the 2. "O" must be positioned much lower as the 1. "O". (the eop break the line) - CPPUNIT_ASSERT_GREATER(sal_Int32(300), nDiff21); - if (i < 2) - { - // the 3. "O" must be positioned even lower with 1 line. (the eol must break the line as well) - CPPUNIT_ASSERT_LESS(sal_Int32(50), abs(nDiff32 - nDiff21)); - } - else - { - // In legacy mode, the 3. "O" must be positioned about the same high as the 2. "O" - // the eol not break the line. - CPPUNIT_ASSERT_LESS(sal_Int32(50), nDiff32); - } + // the 2. "O" must be positioned much lower as the 1. "O". (the eop break the line) + CPPUNIT_ASSERT_GREATER(sal_Int32(300), nDiff21); + if (!bLegacy) + { + // the 3. "O" must be positioned even lower with 1 line. (the eol must break the line as well) + CPPUNIT_ASSERT_LESS(sal_Int32(50), abs(nDiff32 - nDiff21)); + } + else + { + // In legacy mode, the 3. "O" must be positioned about the same high as the 2. "O" + // the eol not break the line. + CPPUNIT_ASSERT_LESS(sal_Int32(50), nDiff32); } } CPPUNIT_TEST_FIXTURE(SvdrawTest, testTdf148000_CurvedTextWidth) { - std::vector<OUString> aFilenames - = { u"tdf148000_CurvedTextWidth.pptx"_ustr, u"tdf148000_CurvedTextWidth_New.odp"_ustr, - u"tdf148000_CurvedTextWidth_Legacy.odp"_ustr }; + testCurveTextWidth(u"tdf148000_CurvedTextWidth.pptx", false); +} - for (int i = 0; i < 3; i++) - { - loadFromFile(aFilenames[i]); +CPPUNIT_TEST_FIXTURE(SvdrawTest, testTdf148000_CurvedTextWidth_New) +{ + testCurveTextWidth(u"tdf148000_CurvedTextWidth_New.odp", false); +} - SdrPage* pSdrPage = getFirstDrawPageWithAssert(); +CPPUNIT_TEST_FIXTURE(SvdrawTest, testTdf148000_CurvedTextWidth_Legacy) +{ + testCurveTextWidth(u"tdf148000_CurvedTextWidth_Legacy.odp", true); +} - xmlDocUniquePtr pXmlDoc = lcl_dumpAndParseFirstObjectWithAssert(pSdrPage); - tools::XPath aXPath(pXmlDoc.get()); +void SvdrawTest::testCurveTextWidth(std::u16string_view aFileName, bool bLegacy) +{ + loadFromFile(aFileName); - auto aBasePath = aXPath.create("/primitive2D/objectinfo[4]/objectinfo/unhandled/group/" - "unhandled/group/polypolygoncolor/polypolygon"); + SdrPage* pSdrPage = getFirstDrawPageWithAssert(); - // The text is: 7 line od "OOOOOOO" - // Take the x coord of the 4 "O" on the corners - sal_Int32 nX1 = aXPath.create(aBasePath, "/polygon[1]/point[1]")->attribute("x").toInt32(); - sal_Int32 nX2 = aXPath.create(aBasePath, "/polygon[13]/point[1]")->attribute("x").toInt32(); - sal_Int32 nX3 = aXPath.create(aBasePath, "/polygon[85]/point[1]")->attribute("x").toInt32(); - sal_Int32 nX4 = aXPath.create(aBasePath, "/polygon[97]/point[1]")->attribute("x").toInt32(); + xmlDocUniquePtr pXmlDoc = lcl_dumpAndParseFirstObjectWithAssert(pSdrPage); + tools::XPath aXPath(pXmlDoc.get()); - if (i < 2) - { - // All the lines should be positioned similar (start/end is similar) - CPPUNIT_ASSERT_LESS(sal_Int32(150), abs(nX3 - nX1)); - CPPUNIT_ASSERT_LESS(sal_Int32(150), abs(nX4 - nX2)); - } - else - { - // In legacy mode, the outer lines become much wider - CPPUNIT_ASSERT_GREATER(sal_Int32(1500), nX3 - nX1); - CPPUNIT_ASSERT_GREATER(sal_Int32(1500), nX2 - nX4); - } + auto aBasePath = aXPath.create("/primitive2D/objectinfo[4]/objectinfo/unhandled/group/" + "unhandled/group/polypolygoncolor/polypolygon"); + + // The text is: 7 line od "OOOOOOO" + // Take the x coord of the 4 "O" on the corners + sal_Int32 nX1 = aXPath.create(aBasePath, "/polygon[1]/point[1]")->attribute("x").toInt32(); + sal_Int32 nX2 = aXPath.create(aBasePath, "/polygon[13]/point[1]")->attribute("x").toInt32(); + sal_Int32 nX3 = aXPath.create(aBasePath, "/polygon[85]/point[1]")->attribute("x").toInt32(); + sal_Int32 nX4 = aXPath.create(aBasePath, "/polygon[97]/point[1]")->attribute("x").toInt32(); + + if (!bLegacy) + { + // All the lines should be positioned similar (start/end is similar) + CPPUNIT_ASSERT_LESS(sal_Int32(150), abs(nX3 - nX1)); + CPPUNIT_ASSERT_LESS(sal_Int32(150), abs(nX4 - nX2)); + } + else + { + // In legacy mode, the outer lines become much wider + CPPUNIT_ASSERT_GREATER(sal_Int32(1500), nX3 - nX1); + CPPUNIT_ASSERT_GREATER(sal_Int32(1500), nX2 - nX4); } } diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx index fda9fc0aa78f..5dee99bc8db1 100644 --- a/xmloff/qa/unit/draw.cxx +++ b/xmloff/qa/unit/draw.cxx @@ -279,9 +279,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testFillAndLineThemeColorExportImport) checkFillAndLineComplexColors(getShape(0)); - save(TestFilter::ODP); - - loadFromURL(maTempFile.GetURL()); + saveAndReload(TestFilter::ODP); checkFillAndLineComplexColors(getShape(0)); } diff --git a/xmloff/qa/unit/style.cxx b/xmloff/qa/unit/style.cxx index 7286b5de0c21..bcf12a5767d4 100644 --- a/xmloff/qa/unit/style.cxx +++ b/xmloff/qa/unit/style.cxx @@ -171,50 +171,46 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testRtlGutter) CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testWritingModeBTLR) { - comphelper::ScopeGuard g([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); - // Load document. It has a frame style with writing-mode bt-lr. // In ODF 1.3 extended it is written as loext:writing-mode="bt-lr". // In ODF 1.3 strict, there must not be an attribute at all. loadFromFile(u"tdf150407_WritingModeBTLR_style.odt"); // Save to latest extended. Adapt test, when attribute value "bt-lr" is included in ODF strict. - { - save(TestFilter::ODT); - - // With applied fix for tdf150407 still loext:writing-mode="bt-lr" has to be written. - xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr); - assertXPath(pXmlDoc, - "/office:document-styles/office:styles/style:style[@style:name='FrameBTLR']/" - "style:graphic-properties[@loext:writing-mode]"); - assertXPath(pXmlDoc, - "/office:document-styles/office:styles/style:style[@style:name='FrameBTLR']/" - "style:graphic-properties", - "writing-mode", u"bt-lr"); - } + save(TestFilter::ODT); + // With applied fix for tdf150407 still loext:writing-mode="bt-lr" has to be written. + xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr); + assertXPath(pXmlDoc, + "/office:document-styles/office:styles/style:style[@style:name='FrameBTLR']/" + "style:graphic-properties[@loext:writing-mode]"); + assertXPath(pXmlDoc, + "/office:document-styles/office:styles/style:style[@style:name='FrameBTLR']/" + "style:graphic-properties", + "writing-mode", u"bt-lr"); +} + +CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testWritingModeBTLR_ODFVER_013) +{ + comphelper::ScopeGuard g([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); loadFromFile(u"tdf150407_WritingModeBTLR_style.odt"); // Save to ODF 1.3 strict. - { - SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_013); - // As of Nov 2024, validating against a version other than LATEST is not implemented. - skipValidation(); - save(TestFilter::ODT); - - // Without the fix an faulty 'writing-mode="bt-lr"' attribute was written in productive build. - // A debug build fails assertion in SvXMLNamespaceMap::GetQNameByKey(). - xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr); - assertXPathNoAttribute(pXmlDoc, - "/office:document-styles/office:styles/" - "style:style[@style:name='FrameBTLR']/style:graphic-properties", - "writing-mode"); - } + SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_013); + // As of Nov 2024, validating against a version other than LATEST is not implemented. + skipValidation(); + save(TestFilter::ODT); + + // Without the fix an faulty 'writing-mode="bt-lr"' attribute was written in productive build. + // A debug build fails assertion in SvXMLNamespaceMap::GetQNameByKey(). + xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr); + assertXPathNoAttribute(pXmlDoc, + "/office:document-styles/office:styles/" + "style:style[@style:name='FrameBTLR']/style:graphic-properties", + "writing-mode"); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelBottomMargin) { - comphelper::ScopeGuard g([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); - // Load document. It has a frame position with vertical position relative to bottom margin. // In ODF 1.3 extended it is written as loext:vertical-rel="page-content-bottom". // In ODF 1.3 strict, there must not be an attribute at all. @@ -222,43 +218,39 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelBottomMargin) // Save to ODF 1.3 extended. Adapt 3 (=ODFVER_LATEST) to a to be ODFVER_013_EXTENDED when // attribute value "page-content-bottom" is included in ODF strict. - { - save(TestFilter::ODT); - - // With applied fix for tdf150407 still loext:vertical-rel="page-content-bottom" has to be - // written. - xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); - assertXPath( - pXmlDoc, - "/office:document-content/office:automatic-styles/style:style[@style:name='gr1']/" - "style:graphic-properties[@loext:vertical-rel]"); - assertXPath( - pXmlDoc, - "/office:document-content/office:automatic-styles/style:style[@style:name='gr1']/" - "style:graphic-properties", - "vertical-rel", u"page-content-bottom"); - } + save(TestFilter::ODT); + + // With applied fix for tdf150407 still loext:vertical-rel="page-content-bottom" has to be + // written. + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); + assertXPath(pXmlDoc, + "/office:document-content/office:automatic-styles/style:style[@style:name='gr1']/" + "style:graphic-properties[@loext:vertical-rel]"); + assertXPath(pXmlDoc, + "/office:document-content/office:automatic-styles/style:style[@style:name='gr1']/" + "style:graphic-properties", + "vertical-rel", u"page-content-bottom"); +} +CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelBottomMargin_ODFVER_013) +{ + comphelper::ScopeGuard g([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); loadFromFile(u"tdf150407_PosRelBottomMargin.docx"); // Save to ODF 1.3 strict. - { - SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_013); - save(TestFilter::ODT); - - // Without the fix an faulty 'vertical-rel="page-content-bottom"' attribute was written in - // productive build. A debug build fails assertion in SvXMLNamespaceMap::GetQNameByKey(). - xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); - assertXPathNoAttribute(pXmlDoc, - "/office:document-content/office:automatic-styles/" - "style:style[@style:name='gr1']/style:graphic-properties", - "vertical-rel"); - } + SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_013); + save(TestFilter::ODT); + + // Without the fix an faulty 'vertical-rel="page-content-bottom"' attribute was written in + // productive build. A debug build fails assertion in SvXMLNamespaceMap::GetQNameByKey(). + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); + assertXPathNoAttribute(pXmlDoc, + "/office:document-content/office:automatic-styles/" + "style:style[@style:name='gr1']/style:graphic-properties", + "vertical-rel"); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelTopMargin) { - comphelper::ScopeGuard g([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); - // Load document. It has a frame position with vertical position relative to top margin. // In ODF 1.3 extended it is written as loext:vertical-rel="page-content-top". // In ODF 1.3 strict, there must not be an attribute at all. @@ -266,37 +258,35 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelTopMargin) // Save to ODF 1.3 extended. Adapt 3 (=ODFVER_LATEST) to a to be ODFVER_013_EXTENDED when // attribute value "page-content-top" is included in ODF strict. - { - save(TestFilter::ODT); - - // With applied fix for tdf150407 still loext:vertical-rel="page-content-top has to be - // written. - xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); - assertXPath( - pXmlDoc, - "/office:document-content/office:automatic-styles/style:style[@style:name='gr1']/" - "style:graphic-properties[@loext:vertical-rel]"); - assertXPath( - pXmlDoc, - "/office:document-content/office:automatic-styles/style:style[@style:name='gr1']/" - "style:graphic-properties", - "vertical-rel", u"page-content-top"); - } + save(TestFilter::ODT); + + // With applied fix for tdf150407 still loext:vertical-rel="page-content-top has to be + // written. + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); + assertXPath(pXmlDoc, + "/office:document-content/office:automatic-styles/style:style[@style:name='gr1']/" + "style:graphic-properties[@loext:vertical-rel]"); + assertXPath(pXmlDoc, + "/office:document-content/office:automatic-styles/style:style[@style:name='gr1']/" + "style:graphic-properties", + "vertical-rel", u"page-content-top"); +} +CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelTopMargin_ODFVER_013) +{ + comphelper::ScopeGuard g([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); loadFromFile(u"tdf150407_PosRelTopMargin.docx"); // Save to ODF 1.3 strict. - { - SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_013); - save(TestFilter::ODT); - - // Without the fix an faulty 'vertical-rel="page-content-top"' attribute was written in - // productive build. A debug build fails assertion in SvXMLNamespaceMap::GetQNameByKey(). - xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); - assertXPathNoAttribute(pXmlDoc, - "/office:document-content/office:automatic-styles/" - "style:style[@style:name='gr1']/style:graphic-properties", - "vertical-rel"); - } + SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_013); + save(TestFilter::ODT); + + // Without the fix an faulty 'vertical-rel="page-content-top"' attribute was written in + // productive build. A debug build fails assertion in SvXMLNamespaceMap::GetQNameByKey(). + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); + assertXPathNoAttribute(pXmlDoc, + "/office:document-content/office:automatic-styles/" + "style:style[@style:name='gr1']/style:graphic-properties", + "vertical-rel"); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testTdf156707)
