summaryrefslogtreecommitdiff
path: root/sw/qa/extras
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2021-06-14 14:27:56 +0300
committerThorsten Behrens <thorsten.behrens@allotropia.de>2021-06-29 00:48:36 +0200
commitaa5c6d127559912ad60a63fbd972b78fb8f9691b (patch)
treef58857a341fa8930ad173e82e5c11a5fedf294e0 /sw/qa/extras
parent99ef46fdb2a975e074c66a02328b86edfc05307f (diff)
new ODF numbered list parameter loext:num-list-format
Instead of style:num-prefix and style:num-suffix new list format is much more flexible for storing list multilevel numberings. Now it is possible to have not just prefix/suffix but any random separators between levels, arbitrary levels order, etc. Internal LO format for list format is changed: instead of placeholders like %1, %2, etc we right now use %1%, %2%... Reason: for ODT documents, having more than 9 levels there is ambiguity in "%10": it is "%1" followed by "0" suffix, or "%10"? Aux changes: * removed zero width space hack: since format string is always defined this hack is interfering with standard list numbers printing (see changes in ooxmlexport14.cxx, ww8export3.cxx tests) * changed cross-references values to lists: they are now including full list label string: previously this was bit self-contradictory (see changes in odfexport.cxx and check_cross_references.py tests) Change-Id: I9696cc4846375c5f6222539aeaadbca5ae58ce27 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117156 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'sw/qa/extras')
-rw-r--r--sw/qa/extras/odfexport/data/listformat.docxbin0 -> 13082 bytes
-rw-r--r--sw/qa/extras/odfexport/data/listformat.odtbin0 -> 9221 bytes
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx2
-rw-r--r--sw/qa/extras/odfexport/odfexport2.cxx66
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport14.cxx8
-rw-r--r--sw/qa/extras/rtfexport/rtfexport.cxx2
-rw-r--r--sw/qa/extras/ww8export/ww8export2.cxx18
-rw-r--r--sw/qa/extras/ww8export/ww8export3.cxx6
8 files changed, 80 insertions, 22 deletions
diff --git a/sw/qa/extras/odfexport/data/listformat.docx b/sw/qa/extras/odfexport/data/listformat.docx
new file mode 100644
index 000000000000..338678d82d3f
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/listformat.docx
Binary files differ
diff --git a/sw/qa/extras/odfexport/data/listformat.odt b/sw/qa/extras/odfexport/data/listformat.odt
new file mode 100644
index 000000000000..ec3992c8fde9
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/listformat.odt
Binary files differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index c117591d9ad8..06e675f48ee9 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -2697,7 +2697,7 @@ DECLARE_ODFEXPORT_TEST(testReferenceLanguage, "referencelanguage.odt")
OUString const aFieldTexts[] = { "A 2", "Az Isten", "Az 50-esek",
"A 2018-asok", "Az egyebek", "A fejezetek",
u"Az „Őseinket...”", "a 2",
- "Az v", "az 1", "Az e", "az 1",
+ "Az v.", "az 1", "Az e)", "az 1",
"Az (5)", "az 1", "A 2", "az 1" };
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
// update "A (4)" to "Az (5)"
diff --git a/sw/qa/extras/odfexport/odfexport2.cxx b/sw/qa/extras/odfexport/odfexport2.cxx
index b58e9e9a1d1a..bbe5d7f193e7 100644
--- a/sw/qa/extras/odfexport/odfexport2.cxx
+++ b/sw/qa/extras/odfexport/odfexport2.cxx
@@ -50,6 +50,72 @@ DECLARE_ODFEXPORT_TEST(testTdf137199, "tdf137199.docx")
CPPUNIT_ASSERT_EQUAL(OUString("HELLO2WORLD!"), getProperty<OUString>(getParagraph(4), "ListLabelString"));
}
+DECLARE_ODFEXPORT_TEST(testListFormatDocx, "listformat.docx")
+{
+ // Ensure in resulting ODT we also have not just prefix/suffux, but custom delimiters
+ CPPUNIT_ASSERT_EQUAL(OUString(">1<"), getProperty<OUString>(getParagraph(1), "ListLabelString"));
+ CPPUNIT_ASSERT_EQUAL(OUString(">>1/1<<"), getProperty<OUString>(getParagraph(2), "ListLabelString"));
+ CPPUNIT_ASSERT_EQUAL(OUString(">>1/1/1<<"), getProperty<OUString>(getParagraph(3), "ListLabelString"));
+ CPPUNIT_ASSERT_EQUAL(OUString(">>1/1/2<<"), getProperty<OUString>(getParagraph(4), "ListLabelString"));
+
+ // Check also that in numbering styles we have num-list-format defined
+ xmlDocUniquePtr pXmlDoc = parseExport("styles.xml");
+ assertXPath(pXmlDoc, "/office:document-styles/office:styles/text:list-style[@style:name='WWNum1']/"
+ "text:list-level-style-number[@text:level='1']", "num-list-format", ">%1%<");
+ assertXPath(pXmlDoc, "/office:document-styles/office:styles/text:list-style[@style:name='WWNum1']/"
+ "text:list-level-style-number[@text:level='2']", "num-list-format", ">>%1%/%2%<<");
+ assertXPath(pXmlDoc, "/office:document-styles/office:styles/text:list-style[@style:name='WWNum1']/"
+ "text:list-level-style-number[@text:level='3']", "num-list-format", ">>%1%/%2%/%3%<<");
+
+ // But for compatibility there are still prefix/suffix
+ assertXPath(pXmlDoc, "/office:document-styles/office:styles/text:list-style[@style:name='WWNum1']/"
+ "text:list-level-style-number[@text:level='1']", "num-prefix", ">");
+ assertXPath(pXmlDoc, "/office:document-styles/office:styles/text:list-style[@style:name='WWNum1']/"
+ "text:list-level-style-number[@text:level='1']", "num-suffix", "<");
+ assertXPath(pXmlDoc, "/office:document-styles/office:styles/text:list-style[@style:name='WWNum1']/"
+ "text:list-level-style-number[@text:level='2']", "num-prefix", ">>");
+ assertXPath(pXmlDoc, "/office:document-styles/office:styles/text:list-style[@style:name='WWNum1']/"
+ "text:list-level-style-number[@text:level='2']", "num-suffix", "<<");
+ assertXPath(pXmlDoc, "/office:document-styles/office:styles/text:list-style[@style:name='WWNum1']/"
+ "text:list-level-style-number[@text:level='3']", "num-prefix", ">>");
+ assertXPath(pXmlDoc, "/office:document-styles/office:styles/text:list-style[@style:name='WWNum1']/"
+ "text:list-level-style-number[@text:level='3']", "num-suffix", "<<");
+}
+
+DECLARE_ODFEXPORT_TEST(testListFormatOdt, "listformat.odt")
+{
+ // Ensure in resulting ODT we also have not just prefix/suffux, but custom delimiters
+ CPPUNIT_ASSERT_EQUAL(OUString(">1<"), getProperty<OUString>(getParagraph(1), "ListLabelString"));
+ CPPUNIT_ASSERT_EQUAL(OUString(">>1.1<<"), getProperty<OUString>(getParagraph(2), "ListLabelString"));
+ CPPUNIT_ASSERT_EQUAL(OUString(">>1.1.1<<"), getProperty<OUString>(getParagraph(3), "ListLabelString"));
+ CPPUNIT_ASSERT_EQUAL(OUString(">>1.1.2<<"), getProperty<OUString>(getParagraph(4), "ListLabelString"));
+
+ if (xmlDocUniquePtr pXmlDoc = parseExport("content.xml"))
+ {
+ // Check how conversion from prefix/suffix to list format did work
+ assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/text:list-style[@style:name='L1']/"
+ "text:list-level-style-number[@text:level='1']", "num-list-format", ">%1%<");
+ assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/text:list-style[@style:name='L1']/"
+ "text:list-level-style-number[@text:level='2']", "num-list-format", ">>%1%.%2%<<");
+ assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/text:list-style[@style:name='L1']/"
+ "text:list-level-style-number[@text:level='3']", "num-list-format", ">>%1%.%2%.%3%<<");
+
+ // But for compatibility there are still prefix/suffix as they were before
+ assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/text:list-style[@style:name='L1']/"
+ "text:list-level-style-number[@text:level='1']", "num-prefix", ">");
+ assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/text:list-style[@style:name='L1']/"
+ "text:list-level-style-number[@text:level='1']", "num-suffix", "<");
+ assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/text:list-style[@style:name='L1']/"
+ "text:list-level-style-number[@text:level='2']", "num-prefix", ">>");
+ assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/text:list-style[@style:name='L1']/"
+ "text:list-level-style-number[@text:level='2']", "num-suffix", "<<");
+ assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/text:list-style[@style:name='L1']/"
+ "text:list-level-style-number[@text:level='3']", "num-prefix", ">>");
+ assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/text:list-style[@style:name='L1']/"
+ "text:list-level-style-number[@text:level='3']", "num-suffix", "<<");
+ }
+}
+
// 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/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index d309e3577b80..e383984c1170 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -1070,12 +1070,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf120394, "tdf120394.docx")
{
uno::Reference<beans::XPropertySet> xPara(getParagraph(2), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1), getProperty<sal_Int16>(xPara, "NumberingLevel"));
- CPPUNIT_ASSERT_EQUAL(OUString(CHAR_ZWSP), getProperty<OUString>(xPara, "ListLabelString"));
+ CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(xPara, "ListLabelString"));
}
{
uno::Reference<beans::XPropertySet> xPara(getParagraph(3), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1), getProperty<sal_Int16>(xPara, "NumberingLevel"));
- CPPUNIT_ASSERT_EQUAL(OUString(CHAR_ZWSP), getProperty<OUString>(xPara, "ListLabelString"));
+ CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(xPara, "ListLabelString"));
}
{
uno::Reference<beans::XPropertySet> xPara(getParagraph(5), uno::UNO_QUERY);
@@ -1090,7 +1090,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf133605, "tdf133605.docx")
{
uno::Reference<beans::XPropertySet> xPara(getParagraph(3), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), getProperty<sal_Int16>(xPara, "NumberingLevel"));
- CPPUNIT_ASSERT_EQUAL(OUString(CHAR_ZWSP), getProperty<OUString>(xPara, "ListLabelString"));
+ CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(xPara, "ListLabelString"));
}
{
uno::Reference<beans::XPropertySet> xPara(getParagraph(4), uno::UNO_QUERY);
@@ -1116,7 +1116,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf133605_2, "tdf133605_2.docx")
{
uno::Reference<beans::XPropertySet> xPara(getParagraph(3), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), getProperty<sal_Int16>(xPara, "NumberingLevel"));
- CPPUNIT_ASSERT_EQUAL(OUString(CHAR_ZWSP), getProperty<OUString>(xPara, "ListLabelString"));
+ CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(xPara, "ListLabelString"));
}
{
uno::Reference<beans::XPropertySet> xPara(getParagraph(4), uno::UNO_QUERY);
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 75c4382324e5..714aa8f468b1 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -672,7 +672,7 @@ DECLARE_RTFEXPORT_TEST(testFdo66682, "fdo66682.rtf")
aListFormat = rProp.Value.get<OUString>();
}
// Suffix was '\0' instead of ' '.
- CPPUNIT_ASSERT_EQUAL(OUString(" %1 "), aListFormat);
+ CPPUNIT_ASSERT_EQUAL(OUString(" %1% "), aListFormat);
}
DECLARE_RTFEXPORT_TEST(testParaShadow, "para-shadow.rtf")
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx
index a1f8fe239d7a..3dc101b6f626 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -387,19 +387,11 @@ DECLARE_WW8EXPORT_TEST(testTdf119232_startEvenPage, "tdf119232_startEvenPage.doc
DECLARE_WW8EXPORT_TEST(testTdf104805, "tdf104805.doc")
{
- uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WW8Num1"), uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
- uno::Sequence<beans::PropertyValue> aNumberingRule;
- xLevels->getByIndex(1) >>= aNumberingRule; // 2nd level
- for (const auto& rPair : std::as_const(aNumberingRule))
- {
- if (rPair.Name == "Prefix")
- // This was "." instead of empty, so the second paragraph was
- // rendered as ".1" instead of "1.".
- CPPUNIT_ASSERT_EQUAL(OUString(), rPair.Value.get<OUString>());
- else if (rPair.Name == "Suffix")
- CPPUNIT_ASSERT_EQUAL(OUString("."), rPair.Value.get<OUString>());
- }
+ // Prefix was "." instead of empty, so the second paragraph was
+ // rendered as ".1" instead of "1.".
+ // Unittest modified due to Prefix/Suffix support obsolete
+ uno::Reference<beans::XPropertySet> xPara(getParagraph(2), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("1."), getProperty<OUString>(xPara, "ListLabelString"));
}
DECLARE_WW8EXPORT_TEST(testTdf104334, "tdf104334.doc")
diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx
index 9ccf3ea19a31..a69ddb7d989d 100644
--- a/sw/qa/extras/ww8export/ww8export3.cxx
+++ b/sw/qa/extras/ww8export/ww8export3.cxx
@@ -881,12 +881,12 @@ DECLARE_WW8EXPORT_TEST(testTdf120394, "tdf120394.doc")
{
uno::Reference<beans::XPropertySet> xPara(getParagraph(5), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), getProperty<sal_Int16>(xPara, "NumberingLevel"));
- CPPUNIT_ASSERT_EQUAL(OUString(CHAR_ZWSP), getProperty<OUString>(xPara, "ListLabelString"));
+ CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(xPara, "ListLabelString"));
}
{
uno::Reference<beans::XPropertySet> xPara(getParagraph(8), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(2), getProperty<sal_Int16>(xPara, "NumberingLevel"));
- CPPUNIT_ASSERT_EQUAL(OUString(CHAR_ZWSP), getProperty<OUString>(xPara, "ListLabelString"));
+ CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(xPara, "ListLabelString"));
}
{
uno::Reference<beans::XPropertySet> xPara(getParagraph(9), uno::UNO_QUERY);
@@ -896,7 +896,7 @@ DECLARE_WW8EXPORT_TEST(testTdf120394, "tdf120394.doc")
{
uno::Reference<beans::XPropertySet> xPara(getParagraph(10), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(2), getProperty<sal_Int16>(xPara, "NumberingLevel"));
- CPPUNIT_ASSERT_EQUAL(OUString(CHAR_ZWSP), getProperty<OUString>(xPara, "ListLabelString"));
+ CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(xPara, "ListLabelString"));
}
}