sw/qa/extras/ooxmlexport/data/tdf156105_percentSuffix.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport21.cxx | 7 ++ sw/source/core/doc/number.cxx | 33 +++----------- 3 files changed, 15 insertions(+), 25 deletions(-)
New commits: commit 65e226aff6a946ae4884b9f5afdccaa1c745bcd4 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Fri May 17 12:17:26 2024 -0400 Commit: Justin Luth <jl...@mail.com> CommitDate: Mon May 20 15:40:38 2024 +0200 tdf#156105 sw: trust SvxNumberFormat GetPrefix/GetSuffix After LO 7.4 (backported to 7.2.5) created this function that manually identifies the Prefix/Suffix, there was some work done to ensure GetPrefix and GetSuffix were trustworthy in LO 7.5's commit 835cda561217bd8c53af2de927158dd5712b06c0 Author: Justin Luth on Tue Aug 2 13:30:31 2022 -0400 related tdf#150197: use SetListFormat or SetPrefix/Suffix GetListFormat DEPENDS on having managed prefix/suffix itself... So, lets make sure we use and fix these functions in only one place. make CppunitTest_sw_ooxmlexport21 \ CPPUNIT_TEST_NAME=testTdf156105_percentSuffix Change-Id: I44c021a200ba45960e39983087c6af268751fbc1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167792 Reviewed-by: Justin Luth <jl...@mail.com> Reviewed-by: Vasily Melenchuk <vasily.melenc...@cib.de> Tested-by: Jenkins diff --git a/sw/qa/extras/ooxmlexport/data/tdf156105_percentSuffix.odt b/sw/qa/extras/ooxmlexport/data/tdf156105_percentSuffix.odt new file mode 100644 index 000000000000..a5319f7a9522 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf156105_percentSuffix.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx index 01c42d0ea34d..6cfbe8d783fc 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx @@ -293,6 +293,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf158597, "tdf158597.docx") } } +DECLARE_OOXMLEXPORT_TEST(testTdf156105_percentSuffix, "tdf156105_percentSuffix.odt") +{ + // given a numbered list with a non-escaping percent symbol in the prefix and suffix + CPPUNIT_ASSERT_EQUAL(OUString("(%)[%]"), + getProperty<OUString>(getParagraph(3), "ListLabelString")); +} + DECLARE_OOXMLEXPORT_TEST(testTdf160049_anchorMarginVML, "tdf160049_anchorMarginVML.docx") { // given a VML (Word 2003) document with a LEFT "column/text" anchored image diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx index c92d2af29a7d..f43ab140b60d 100644 --- a/sw/source/core/doc/number.cxx +++ b/sw/source/core/doc/number.cxx @@ -721,32 +721,15 @@ OUString SwNumRule::MakeNumString( const SwNumberTree::tNumberVector & rNumVecto if (rMyNFormat.GetNumberingType() == SVX_NUM_NUMBER_NONE) { - if (!rMyNFormat.HasListFormat()) { - OUString sRet = bInclStrings ? rMyNFormat.GetPrefix() + rMyNFormat.GetSuffix() : OUString(); - StripNonDelimiter(sRet); - return sRet; - } - - // If numbering is disabled for this level we should emit just prefix/suffix - // Remove everything between first %1% and last %n% (including markers) - OUString sLevelFormat = rMyNFormat.GetListFormat(bInclStrings && !bHideNonNumerical); - - if (bInclStrings && bHideNonNumerical) { - // If hiding non numerical text, we need to strip the prefix and suffix properly, so let's add them manually - OUString sPrefix = rMyNFormat.GetPrefix(); - OUString sSuffix = rMyNFormat.GetSuffix(); + // since numbering is disabled for this level, + // only emit prefix/suffix (unless they are not wanted either) + if (!bInclStrings) + return OUString(); - StripNonDelimiter(sPrefix); - StripNonDelimiter(sSuffix); - - sLevelFormat = sPrefix + sLevelFormat + sSuffix; - } - - sal_Int32 nFirstPosition = sLevelFormat.indexOf("%"); - sal_Int32 nLastPosition = sLevelFormat.lastIndexOf("%"); - if (nFirstPosition >= 0 && nLastPosition >= nFirstPosition) - sLevelFormat = sLevelFormat.replaceAt(nFirstPosition, nLastPosition - nFirstPosition + 1, u""); - return sLevelFormat; + OUString sRet = rMyNFormat.GetPrefix() + rMyNFormat.GetSuffix(); + if (bHideNonNumerical) + StripNonDelimiter(sRet); + return sRet; } css::lang::Locale aLocale( LanguageTag::convertToLocale(nLang));