tdf#137199: sw: convert list format string to prefix/suffix for ODF
Since internally LO is able right now to use list level format strings
and prefixes/suffixes only for backward compatibility, there is a need
for conversion from format string (like "%1.") to prefix ("") and suffix
(".") still used by ODT.
Change-Id: If4b459e1b25b7f0ce511e6ac2de0824bb2c43d05
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116288
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
diff --git a/sw/qa/extras/odfexport/data/tdf137199.docx b/sw/qa/extras/odfexport/data/tdf137199.docx
new file mode 100644
index 0000000..25b5297
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/tdf137199.docx
Binary files differ
diff --git a/sw/qa/extras/odfexport/odfexport2.cxx b/sw/qa/extras/odfexport/odfexport2.cxx
index 21455b9..b58e9e9 100644
--- a/sw/qa/extras/odfexport/odfexport2.cxx
+++ b/sw/qa/extras/odfexport/odfexport2.cxx
@@ -39,6 +39,17 @@ DECLARE_ODFEXPORT_TEST(testTdf52065_centerTabs, "testTdf52065_centerTabs.odt")
CPPUNIT_ASSERT_EQUAL(OUString(u"Pečiatka zamestnávateľa"), parseDump("//body/txt[4]/Text[4]", "Portion"));
}
DECLARE_ODFEXPORT_TEST(testTdf137199, "tdf137199.docx")
{
CPPUNIT_ASSERT_EQUAL(OUString(">1<"), getProperty<OUString>(getParagraph(1), "ListLabelString"));
CPPUNIT_ASSERT_EQUAL(OUString("1)"), getProperty<OUString>(getParagraph(2), "ListLabelString"));
CPPUNIT_ASSERT_EQUAL(OUString("HELLO1WORLD!"), getProperty<OUString>(getParagraph(3), "ListLabelString"));
CPPUNIT_ASSERT_EQUAL(OUString("HELLO2WORLD!"), getProperty<OUString>(getParagraph(4), "ListLabelString"));
}
// This test started in LO 7.2. Use the odfexport.cxx if you intend to backport to 7.1.
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/xmloff/source/style/xmlnume.cxx b/xmloff/source/style/xmlnume.cxx
index 027bef0..132e3f7 100644
--- a/xmloff/source/style/xmlnume.cxx
+++ b/xmloff/source/style/xmlnume.cxx
@@ -121,7 +121,24 @@ void SvxXMLNumRuleExport::exportLevelStyle( sal_Int32 nLevel,
{
rProp.Value >>= sSuffix;
}
else if( rProp.Name == "BulletChar" )
else if (rProp.Name == "ListFormat")
{
OUString sListFormat;
rProp.Value >>= sListFormat;
// Since we have no support for entire format string it should be converted
// to prefix and suffix. Of course, it is not so flexible as format string,
// but it is the only option
sal_Int32 nFirstReplacement = sListFormat.indexOf('%');
sal_Int32 nLastReplacement = sListFormat.lastIndexOf('%') + 1;
if (nFirstReplacement > 0)
// Everything before first '%' will be prefix
sPrefix = sListFormat.copy(0, nFirstReplacement);
if (nLastReplacement >= 0 && nLastReplacement < sListFormat.getLength() -1 )
// Everything beyond last '%' (+1 for follow up id) is a suffix
sSuffix = sListFormat.copy(nLastReplacement + 1);
}
else if (rProp.Name == "BulletChar")
{
OUString sValue;
rProp.Value >>= sValue;