diff options
author | László Németh <nemeth@numbertext.org> | 2019-08-01 14:38:52 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2019-08-02 08:50:27 +0200 |
commit | 7f38fabe3f723c85482c91ce6586e38081ee013f (patch) | |
tree | 2650f6292569be969ff1ee254f4415c2dafc69c1 /sw/source/filter/ww8/wrtw8sty.cxx | |
parent | 8f36d40426fa83bf7923a818377cc50048199dfd (diff) |
tdf#126243 DOCX change tracking: pStyle needs simplified style id
in reject data to import style names correctly in MSO, too.
Change-Id: I1cf346eaf36f6d949ea7abf9d9af3bae85c7ce0e
Reviewed-on: https://gerrit.libreoffice.org/76799
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/source/filter/ww8/wrtw8sty.cxx')
-rw-r--r-- | sw/source/filter/ww8/wrtw8sty.cxx | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index 35ecc773eb05..c8ad6e9faf28 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -317,6 +317,26 @@ void MSWordStyles::BuildStylesTable() } } +OString MSWordStyles::CreateStyleId(const OUString &rName) +{ + OStringBuffer aStyleIdBuf(rName.getLength()); + for (int i = 0; i < rName.getLength(); ++i) + { + sal_Unicode nChar = rName[i]; + if (('0' <= nChar && nChar <= '9') || + ('a' <= nChar && nChar <= 'z') || + ('A' <= nChar && nChar <= 'Z')) + { + // first letter should be uppercase + if (aStyleIdBuf.isEmpty() && 'a' <= nChar && nChar <= 'z') + aStyleIdBuf.append(char(nChar - ('a' - 'A'))); + else + aStyleIdBuf.append(char(nChar)); + } + } + return aStyleIdBuf.makeStringAndClear(); +} + void MSWordStyles::BuildStyleIds() { std::unordered_set<OString> aUsed; @@ -331,23 +351,9 @@ void MSWordStyles::BuildStyleIds() aName = m_pFormatA[n]->GetName(); else if (m_aNumRules.find(n) != m_aNumRules.end()) aName = m_aNumRules[n]->GetName(); - OStringBuffer aStyleIdBuf(aName.getLength()); - for (int i = 0; i < aName.getLength(); ++i) - { - sal_Unicode nChar = aName[i]; - if (('0' <= nChar && nChar <= '9') || - ('a' <= nChar && nChar <= 'z') || - ('A' <= nChar && nChar <= 'Z')) - { - // first letter should be uppercase - if (aStyleIdBuf.isEmpty() && 'a' <= nChar && nChar <= 'z') - aStyleIdBuf.append(char(nChar - ('a' - 'A'))); - else - aStyleIdBuf.append(char(nChar)); - } - } - OString aStyleId(aStyleIdBuf.makeStringAndClear()); + OString aStyleId = CreateStyleId(aName); + if (aStyleId.isEmpty()) aStyleId = "Style"; |