diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-01-11 17:02:04 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-01-12 04:34:27 +0000 |
commit | 13d30067370353ae5a43c2f2cbd69bb824363815 (patch) | |
tree | f52dfd68140b4b65b889e61e55bb974ec24fb940 /sw | |
parent | 319e2e0cbc6a1d25abd01fb27d6250cee825c072 (diff) |
tdf#152425 Synchronize import and export style names mapping
1. Make the mapping in StyleSheetTable::ConvertStyleName match the
opposite direction mapping happening in MSWordStyles::GetWWId and
ww::GetEnglishNameFromSti. Add missing styles, provide comments to
clarify the process and find respective pool format ids.
2. Instead of appending " (user)" to conflicting style names, which
is the method used by SwStyleNameMapper to disambiguate API names,
append " (WW)", which allows to avoid unwanted merging conflicting
styles.
Change-Id: I47b1c7f570da6e6e21155669fdd1b77de5cc17da
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145349
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport18.cxx | 13 | ||||
-rw-r--r-- | sw/source/filter/ww8/styles.cxx | 1 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8sty.cxx | 13 |
3 files changed, 16 insertions, 11 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx index 92e13b4b7d3b..7b7213e0f019 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx @@ -264,17 +264,12 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf152425) // Check that "List Number" and "List 5" styles don't get merged const OUString Para3Style = getProperty<OUString>(getParagraph(3), "ParaStyleName"); - CPPUNIT_ASSERT_EQUAL(OUString("List Number"), Para3Style); + CPPUNIT_ASSERT_EQUAL(OUString("Numbering 1"), Para3Style); const OUString Para4Style = getProperty<OUString>(getParagraph(4), "ParaStyleName"); - // Eventually, we need to check this: - // CPPUNIT_ASSERT_EQUAL(OUString("List 5"), Para4Style); - // But for now, just make sure that the style names differ - CPPUNIT_ASSERT(Para4Style != Para3Style); + CPPUNIT_ASSERT_EQUAL(OUString("List 5 (WW)"), Para4Style); + // Also check that "List 5" and "List Bullet 5" styles don't get merged const OUString Para5Style = getProperty<OUString>(getParagraph(5), "ParaStyleName"); - // Eventually, we need to check this: - // CPPUNIT_ASSERT_EQUAL(OUString("List Bullet 5"), Para5Style); - // But for now, just make sure that the style names differ - CPPUNIT_ASSERT(Para5Style != Para4Style); + CPPUNIT_ASSERT_EQUAL(OUString("List 5"), Para5Style); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/styles.cxx b/sw/source/filter/ww8/styles.cxx index c7a28e77e60b..33d0ad3dec5f 100644 --- a/sw/source/filter/ww8/styles.cxx +++ b/sw/source/filter/ww8/styles.cxx @@ -23,6 +23,7 @@ namespace { + // Keep in sync with StyleSheetTable::ConvertStyleName const char **GetStiNames() noexcept { // Matches enum ww::sti in sw/source/filter/inc/wwstyles.hxx diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index 9f534b1b55d2..72fca1b3696f 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -200,6 +200,7 @@ static sal_uInt16 BuildGetSlot(const SwFormat& rFormat) } +// Keep in sync with StyleSheetTable::ConvertStyleName sal_uInt16 MSWordStyles::GetWWId( const SwFormat& rFormat ) { sal_uInt16 nRet = ww::stiUser; // user style as default @@ -319,6 +320,14 @@ void MSWordStyles::BuildStylesTable() } } +// StyleSheetTable::ConvertStyleName appends the suffix do disambiguate conflicting style names +static OUString StripWWSuffix(const OUString& s) +{ + OUString ret = s; + ret.endsWith(" (WW)", &ret); + return ret; +} + void MSWordStyles::BuildWwNames() { std::unordered_set<OUString> aUsed; @@ -363,9 +372,9 @@ void MSWordStyles::BuildWwNames() if (!entry.ww_name.isEmpty()) continue; if (entry.format) - entry.ww_name = entry.format->GetName(); + entry.ww_name = StripWWSuffix(entry.format->GetName()); else if (entry.num_rule) - entry.ww_name = entry.num_rule->GetName(); + entry.ww_name = StripWWSuffix(entry.num_rule->GetName()); else continue; makeUniqueName(entry.ww_name); |