From adb203bc05e3e36173cbd46b9951f79821a81799 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 11:27:54 +0200 Subject: Merging upstream version 4:24.2.1. Signed-off-by: Daniel Baumann --- sw/qa/extras/odfexport/odfexport2.cxx | 119 ++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) (limited to 'sw/qa/extras/odfexport/odfexport2.cxx') diff --git a/sw/qa/extras/odfexport/odfexport2.cxx b/sw/qa/extras/odfexport/odfexport2.cxx index 6db396c40d..37e744e9c8 100644 --- a/sw/qa/extras/odfexport/odfexport2.cxx +++ b/sw/qa/extras/odfexport/odfexport2.cxx @@ -102,6 +102,26 @@ DECLARE_ODFEXPORT_TEST(testTdf77961, "tdf77961.odt") CPPUNIT_ASSERT_EQUAL( false , getProperty(xStyle, "GridPrint")); } +CPPUNIT_TEST_FIXTURE(Test, testTdf106733) +{ + loadAndReload("tdf106733.fodt"); + CPPUNIT_ASSERT_EQUAL(1, getPages()); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + + // keep fo:hyphenate="false" in direct formatting + assertXPath( + pXmlDoc, + "//style:style[@style:name='T3']/style:text-properties"_ostr, + "hyphenate"_ostr, "false"); + + // keep fo:hyphenate="false" in character style + xmlDocUniquePtr pXmlDoc2 = parseExport("styles.xml"); + assertXPath( + pXmlDoc2, + "//style:style[@style:name='Strong_20_Emphasis']/style:text-properties"_ostr, + "hyphenate"_ostr, "false"); +} + DECLARE_ODFEXPORT_TEST(testReferenceLanguage, "referencelanguage.odt") { CPPUNIT_ASSERT_EQUAL(2, getPages()); @@ -1128,6 +1148,105 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf150408_IsLegal) "is-legal"_ostr, "true"); } +CPPUNIT_TEST_FIXTURE(Test, testTdf159382) +{ + // Testing NoGapAfterNoteNumber compat option + + createSwDoc("footnote_spacing_hanging_para.docx"); + // 1. Make sure that DOCX import sets NoGapAfterNoteNumber option, and creates + // correct layout + { + uno::Reference xFactory(mxComponent, uno::UNO_QUERY_THROW); + uno::Reference xSettings( + xFactory->createInstance(u"com.sun.star.document.Settings"_ustr), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(uno::Any(true), xSettings->getPropertyValue( + u"NoGapAfterNoteNumber"_ustr)); + + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + sal_Int32 width + = getXPath(pXmlDoc, + "/root/page/ftncont/ftn/txt/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, + "width"_ostr) + .toInt32(); + CPPUNIT_ASSERT(width); + CPPUNIT_ASSERT_LESS(sal_Int32(100), width); // It was 720, i.e. 0.5 inch + } + + saveAndReload(mpFilter); + // 2. Make sure that exported document has NoGapAfterNoteNumber option set, + // and has correct layout + { + xmlDocUniquePtr pXmlDoc = parseExport("settings.xml"); + assertXPathContent( + pXmlDoc, + "//config:config-item[@config:name='NoGapAfterNoteNumber']"_ostr, + "true"); + + uno::Reference xFactory(mxComponent, uno::UNO_QUERY_THROW); + uno::Reference xSettings( + xFactory->createInstance(u"com.sun.star.document.Settings"_ustr), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(uno::Any(true), xSettings->getPropertyValue( + u"NoGapAfterNoteNumber"_ustr)); + + pXmlDoc = parseLayoutDump(); + sal_Int32 width = getXPath( + pXmlDoc, "/root/page/ftncont/ftn/txt/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, + "width"_ostr).toInt32(); + CPPUNIT_ASSERT(width); + CPPUNIT_ASSERT_LESS(sal_Int32(100), width); + } + + createSwDoc("footnote_spacing_hanging_para.doc"); + // 3. Make sure that DOC import sets NoGapAfterNoteNumber option, and creates + // correct layout + { + uno::Reference xFactory(mxComponent, uno::UNO_QUERY_THROW); + uno::Reference xSettings( + xFactory->createInstance(u"com.sun.star.document.Settings"_ustr), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(uno::Any(true), xSettings->getPropertyValue( + u"NoGapAfterNoteNumber"_ustr)); + + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + sal_Int32 width + = getXPath(pXmlDoc, + "/root/page/ftncont/ftn/txt/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, + "width"_ostr) + .toInt32(); + CPPUNIT_ASSERT(width); + CPPUNIT_ASSERT_LESS(sal_Int32(100), width); + } + + createSwDoc("footnote_spacing_hanging_para.rtf"); + // 4. Make sure that RTF import sets NoGapAfterNoteNumber option, and creates + // correct layout + { + uno::Reference xFactory(mxComponent, uno::UNO_QUERY_THROW); + uno::Reference xSettings( + xFactory->createInstance(u"com.sun.star.document.Settings"_ustr), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(uno::Any(true), xSettings->getPropertyValue( + u"NoGapAfterNoteNumber"_ustr)); + + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + sal_Int32 width + = getXPath(pXmlDoc, + "/root/page/ftncont/ftn/txt/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, + "width"_ostr) + .toInt32(); + CPPUNIT_ASSERT(width); + CPPUNIT_ASSERT_LESS(sal_Int32(100), width); + } + + createSwDoc(); + // 5. Make sure that a new Writer document has this setting set to false + { + uno::Reference xFactory(mxComponent, uno::UNO_QUERY_THROW); + uno::Reference xSettings( + xFactory->createInstance(u"com.sun.star.document.Settings"_ustr), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(uno::Any(false), xSettings->getPropertyValue( + u"NoGapAfterNoteNumber"_ustr)); + } +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3