diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2024-12-05 13:15:47 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2024-12-10 16:42:32 +0100 |
commit | 0bc6fe5c1b889496fb83730545f9c8593ca65863 (patch) | |
tree | 3e75ddd1f8e12e0bd7d8b9d3a31934c8dfa6ae28 /sw | |
parent | a7a12bdb5d98244929ceb2cbb626027494975510 (diff) |
tdf#159549 sw: fix style mapping for Page Styles
lcl_getUsedPageStyles() needs to convert the style names.
Lots of tests request the UIName, testTdf87533_bidi even checks the same
style twice with different names.
Change-Id: Id173493daffadd0d0a74e089ecba8f19d2b267c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177859
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/odfimport/odfimport.cxx | 6 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 6 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/rtfimport.cxx | 24 | ||||
-rw-r--r-- | sw/qa/extras/ww8export/ww8export3.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/doc/SwStyleNameMapper.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/edit/edfcol.cxx | 7 |
6 files changed, 21 insertions, 30 deletions
diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index dd22a4937ee2..6cf97a2a9628 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -293,7 +293,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf41542_borderlessPadding) CPPUNIT_TEST_FIXTURE(Test, testPageStyleLayoutDefault) { createSwDoc("hello.odt"); - uno::Reference<beans::XPropertySet> xPropertySet(getStyles(u"PageStyles"_ustr)->getByName(u"Default Page Style"_ustr), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropertySet(getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), uno::UNO_QUERY); // This was style::PageStyleLayout_MIRRORED. CPPUNIT_ASSERT_EQUAL(style::PageStyleLayout_ALL, getProperty<style::PageStyleLayout>(xPropertySet, u"PageStyleLayout"_ustr)); } @@ -504,7 +504,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf74524) CPPUNIT_TEST_FIXTURE(Test, testPageStyleLayoutRight) { createSwDoc("hello.odt"); - uno::Reference<beans::XPropertySet> xPropertySet(getStyles(u"PageStyles"_ustr)->getByName(u"Default Page Style"_ustr), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropertySet(getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), uno::UNO_QUERY); // This caused a crash. xPropertySet->setPropertyValue(u"PageStyleLayout"_ustr, uno::Any(style::PageStyleLayout_RIGHT)); } @@ -562,7 +562,7 @@ CPPUNIT_TEST_FIXTURE(Test, testFdo79269_header) CPPUNIT_TEST_FIXTURE(Test, testPageBackground) { createSwDoc("PageBackground.odt"); - uno::Reference<beans::XPropertySet> xPropertySet(getStyles(u"PageStyles"_ustr)->getByName(u"Default Page Style"_ustr), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropertySet(getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), uno::UNO_QUERY); // The background image was lost CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, getProperty<drawing::FillStyle>(xPropertySet, u"FillStyle"_ustr)); CPPUNIT_ASSERT_EQUAL(u"Sky"_ustr, getProperty<OUString>(xPropertySet, u"FillBitmapName"_ustr)); diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 13490dff0ffe..4ce5edb38557 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -1727,12 +1727,6 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf87533_bidi) // "w:bidi" (specified inside Default paragraph properties) should not be ignored static constexpr OUString writingMode = u"WritingMode"_ustr; //getPropertyName(PROP_WRITING_MODE); - // check: "Default Style" master-style has RTL - { - const uno::Reference<beans::XPropertySet> xPropertySet(getStyles(u"PageStyles"_ustr)->getByName(u"Default Page Style"_ustr), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(text::WritingMode2::RL_TB), getProperty<sal_Int32>(xPropertySet, writingMode)); - } - // check: "Standard" master-style has RTL { const uno::Reference<beans::XPropertySet> xPropertySet(getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), uno::UNO_QUERY); diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 3aadb03618ff..1c9b80383668 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -1566,38 +1566,32 @@ CPPUNIT_TEST_FIXTURE(Test, testImportHeaderFooter) //Check if Headers/Footers only contain what they should in this document uno::Reference<text::XText> xHeaderText = getProperty<uno::Reference<text::XText>>( - getStyles(u"PageStyles"_ustr)->getByName(u"Default Page Style"_ustr), - u"HeaderTextFirst"_ustr); + getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), u"HeaderTextFirst"_ustr); OUString aActual = xHeaderText->getString(); CPPUNIT_ASSERT_EQUAL(u"First Page Header"_ustr, aActual); uno::Reference<text::XText> xHeaderTextLeft = getProperty<uno::Reference<text::XText>>( - getStyles(u"PageStyles"_ustr)->getByName(u"Default Page Style"_ustr), - u"HeaderTextLeft"_ustr); + getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), u"HeaderTextLeft"_ustr); aActual = xHeaderTextLeft->getString(); CPPUNIT_ASSERT_EQUAL(u"Header even"_ustr, aActual); uno::Reference<text::XText> xHeaderTextRight = getProperty<uno::Reference<text::XText>>( - getStyles(u"PageStyles"_ustr)->getByName(u"Default Page Style"_ustr), - u"HeaderTextRight"_ustr); + getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), u"HeaderTextRight"_ustr); aActual = xHeaderTextRight->getString(); CPPUNIT_ASSERT_EQUAL(u"Header uneven"_ustr, aActual); uno::Reference<text::XText> xFooterText = getProperty<uno::Reference<text::XText>>( - getStyles(u"PageStyles"_ustr)->getByName(u"Default Page Style"_ustr), - u"FooterTextFirst"_ustr); + getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), u"FooterTextFirst"_ustr); aActual = xFooterText->getString(); CPPUNIT_ASSERT_EQUAL(u"First Page Footer"_ustr, aActual); uno::Reference<text::XText> xFooterTextLeft = getProperty<uno::Reference<text::XText>>( - getStyles(u"PageStyles"_ustr)->getByName(u"Default Page Style"_ustr), - u"FooterTextLeft"_ustr); + getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), u"FooterTextLeft"_ustr); aActual = xFooterTextLeft->getString(); CPPUNIT_ASSERT_EQUAL(u"Footer even"_ustr, aActual); uno::Reference<text::XText> xFooterTextRight = getProperty<uno::Reference<text::XText>>( - getStyles(u"PageStyles"_ustr)->getByName(u"Default Page Style"_ustr), - u"FooterTextRight"_ustr); + getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), u"FooterTextRight"_ustr); aActual = xFooterTextRight->getString(); CPPUNIT_ASSERT_EQUAL(u"Footer uneven"_ustr, aActual); } @@ -1607,16 +1601,14 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf108947) createSwDoc("tdf108947.rtf"); //Check if Headers/Footers contain what they should in this document uno::Reference<text::XText> xHeaderTextRight = getProperty<uno::Reference<text::XText>>( - getStyles(u"PageStyles"_ustr)->getByName(u"Default Page Style"_ustr), - u"HeaderTextRight"_ustr); + getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), u"HeaderTextRight"_ustr); OUString aActual = xHeaderTextRight->getString(); CPPUNIT_ASSERT_EQUAL(u""_ustr, aActual); //Document is very fragile, hence we need this guard. #if HAVE_MORE_FONTS uno::Reference<text::XText> xHeaderTextLeft = getProperty<uno::Reference<text::XText>>( - getStyles(u"PageStyles"_ustr)->getByName(u"Default Page Style"_ustr), - u"HeaderTextLeft"_ustr); + getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), u"HeaderTextLeft"_ustr); aActual = xHeaderTextLeft->getString(); CPPUNIT_ASSERT_EQUAL(u"" SAL_NEWLINE_STRING "Header Page 2 ?"_ustr, aActual); #endif diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx index a8263d7fd73c..3e1c5497b25f 100644 --- a/sw/qa/extras/ww8export/ww8export3.cxx +++ b/sw/qa/extras/ww8export/ww8export3.cxx @@ -334,7 +334,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf138302_restartNumbering) DECLARE_WW8EXPORT_TEST(testTdf122429_header, "tdf122429_header.doc") { uno::Reference<container::XNameAccess> pageStyles = getStyles(u"PageStyles"_ustr); - uno::Reference<style::XStyle> pageStyle(pageStyles->getByName(u"Default Page Style"_ustr), uno::UNO_QUERY); + uno::Reference<style::XStyle> pageStyle(pageStyles->getByName(u"Standard"_ustr), uno::UNO_QUERY); bool headerIsOn = getProperty<bool>(pageStyle, u"HeaderIsOn"_ustr); CPPUNIT_ASSERT(headerIsOn); } @@ -344,7 +344,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf122460_header) loadAndReload("tdf122460_header.odt"); CPPUNIT_ASSERT_EQUAL(1, getPages()); uno::Reference<container::XNameAccess> pageStyles = getStyles(u"PageStyles"_ustr); - uno::Reference<style::XStyle> pageStyle(pageStyles->getByName(u"Default Page Style"_ustr), uno::UNO_QUERY); + uno::Reference<style::XStyle> pageStyle(pageStyles->getByName(u"Standard"_ustr), uno::UNO_QUERY); bool headerIsOn = getProperty<bool>(pageStyle, u"HeaderIsOn"_ustr); CPPUNIT_ASSERT(headerIsOn); } diff --git a/sw/source/core/doc/SwStyleNameMapper.cxx b/sw/source/core/doc/SwStyleNameMapper.cxx index 62d9f440e986..9bf3ae40f050 100644 --- a/sw/source/core/doc/SwStyleNameMapper.cxx +++ b/sw/source/core/doc/SwStyleNameMapper.cxx @@ -263,7 +263,7 @@ void SwStyleNameMapper::FillProgName( rFillName = rName; if (nId == USHRT_MAX ) { - if (eFlags == SwGetPoolIdFromName::TxtColl) + if (eFlags == SwGetPoolIdFromName::TxtColl || eFlags == SwGetPoolIdFromName::PageDesc) { // check if it has a " (user)" suffix, if so remove it lcl_CheckSuffixAndDelete(rFillName); @@ -305,7 +305,7 @@ void SwStyleNameMapper::FillUIName( if ( nId == USHRT_MAX ) { rFillName = aName; - if (eFlags != SwGetPoolIdFromName::TxtColl || // FIXME do it for all ids + if ((eFlags != SwGetPoolIdFromName::TxtColl && eFlags != SwGetPoolIdFromName::PageDesc) || // FIXME do it for all ids GetPoolIdFromUIName(aName, eFlags) == USHRT_MAX) { // aName isn't in our Prog name table...check if it has a " (user)" suffix, if so remove it diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx index 64b990b4a4c4..08bf9a624fd8 100644 --- a/sw/source/core/edit/edfcol.cxx +++ b/sw/source/core/edit/edfcol.cxx @@ -88,6 +88,7 @@ #include <rdfhelper.hxx> #include <sfx2/watermarkitem.hxx> +#include <SwStyleNameMapper.hxx> #include <unoparagraph.hxx> #include <strings.hrc> #include <undobj.hxx> @@ -131,7 +132,11 @@ std::vector<OUString> lcl_getUsedPageStyles(SwViewShell const * pShell) { SwPageFrame* pPage = static_cast<SwPageFrame*>(pFrame); if (const SwPageDesc *pDesc = pPage->FindPageDesc()) - aReturn.push_back(pDesc->GetName()); + { + OUString sStyleName; + SwStyleNameMapper::FillUIName(pDesc->GetName(), sStyleName, SwGetPoolIdFromName::PageDesc); + aReturn.push_back(sStyleName); + } } return aReturn; |