summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2021-05-28 09:10:35 +0300
committerThorsten Behrens <thorsten.behrens@allotropia.de>2021-05-28 09:39:34 +0200
commit726d0a2d54da3e97de242c2c10be3afd2aedf943 (patch)
treee23e5a625fa0337c80c990b969f3625654d662f0
parent9864fbc9d5f532d9aa4742968886b3f94bc44dbc (diff)
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>
-rw-r--r--sw/qa/extras/odfexport/data/tdf137199.docxbin0 -> 13281 bytes
-rw-r--r--sw/qa/extras/odfexport/odfexport2.cxx11
-rw-r--r--xmloff/source/style/xmlnume.cxx19
3 files changed, 29 insertions, 1 deletions
diff --git a/sw/qa/extras/odfexport/data/tdf137199.docx b/sw/qa/extras/odfexport/data/tdf137199.docx
new file mode 100644
index 000000000000..25b52977beca
--- /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 21455b9d343d..b58e9e9a1d1a 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 027bef033031..132e3f701a2e 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;