summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorJustin Luth <jluth@mail.com>2024-05-20 14:28:59 -0400
committerJustin Luth <jluth@mail.com>2024-05-31 15:27:14 +0200
commit71c49057deb1a696e4b0ce9d2091aaa28572b57a (patch)
treecfc6c5f370e2ec3bd482000b150185bcd4722037 /sw/source
parent64bf123ebae9873758c30cb41aaf3a1098c5e678 (diff)
tdf#149258 sw ms export: no separator for NONE numbering level
This is to benefit ODT->DOCX. LO does not show the separators specified after a numbering level that has no numbering type (since LO 7.2.5). However, MSO does show any specified separators. So export this the way that LO sees it. Note that in the very odd case where an MSO user actually wanted these separators to be visible, LO fails to show them, and thus this will end up exporting as "data loss". How sad. make CppunitTest_sw_ooxmlexport21 \ CPPUNIT_TEST_NAME=testTdf156105_percentSuffix Change-Id: I2c084de319ef4b1e77b6f377708c71a62dcc5910 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167898 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/doc/number.cxx5
-rw-r--r--sw/source/filter/ww8/wrtw8num.cxx11
2 files changed, 14 insertions, 2 deletions
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index f43ab140b60d..e811f7b83540 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -763,8 +763,11 @@ OUString SwNumRule::MakeNumString( const SwNumberTree::tNumberVector & rNumVecto
// Numbering disabled - replacement is empty
// And we should skip all level string content until next level marker:
// so %1%.%2%.%3% with second level as NONE will result 1.1, not 1..1
+
+ // NOTE: if changed, fix MSWordExportBase::NumberingLevel to match new behaviour.
+
sal_Int32 nPositionNext = sLevelFormat.indexOf('%', nPosition + sFind.getLength());
- if (nPosition >= 0 && nPositionNext >= nPosition)
+ if (nPosition >= 0 && nPositionNext > nPosition)
{
sLevelFormat = sLevelFormat.replaceAt(nPosition, nPositionNext - nPosition, u"");
}
diff --git a/sw/source/filter/ww8/wrtw8num.cxx b/sw/source/filter/ww8/wrtw8num.cxx
index 4c56472bb6b3..e8f7b197ed59 100644
--- a/sw/source/filter/ww8/wrtw8num.cxx
+++ b/sw/source/filter/ww8/wrtw8num.cxx
@@ -489,9 +489,18 @@ void MSWordExportBase::NumberingLevel(
sal_Int32 nFnd = sNumStr.indexOf(sSrch);
if (-1 != nFnd)
{
+ sal_Int32 nLen = sSrch.getLength();
+ if (i < nLvl && rRule.Get(i).GetNumberingType() == SVX_NUM_NUMBER_NONE)
+ {
+ // LO doesn't show this level, so don't export its separator
+ const OUString sSrch2("%" + OUString::number(i + 2) + "%");
+ const sal_Int32 nFnd2 = sNumStr.indexOf(sSrch2, nFnd);
+ if (-1 != nFnd2)
+ nLen = nFnd2 - nFnd;
+ }
*pLvlPos = static_cast<sal_uInt8>(nFnd + 1);
++pLvlPos;
- sNumStr = sNumStr.replaceAt(nFnd, sSrch.getLength(), rtl::OUStringChar(static_cast<char>(i)));
+ sNumStr = sNumStr.replaceAt(nFnd, nLen, OUStringChar(static_cast<char>(i)));
}
}
}