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 | |
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')
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8sty.cxx | 38 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.hxx | 3 |
3 files changed, 27 insertions, 20 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 1672cc95e557..12c6c3a99640 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2995,11 +2995,9 @@ void DocxAttributeOutput::Redline( const SwRedlineData* pRedlineData) m_pSerializer->startElementNS(XML_w, XML_pPr); - if ( !sParaStyleName.isEmpty() ) - { - OString sStyleName = OUStringToOString( sParaStyleName, RTL_TEXTENCODING_UTF8 ); + OString sStyleName = MSWordStyles::CreateStyleId( sParaStyleName ); + if ( !sStyleName.isEmpty() ) m_pSerializer->singleElementNS(XML_w, XML_pStyle, FSNS(XML_w, XML_val), sStyleName); - } // The 'm_rExport.SdrExporter().getFlyAttrList()', 'm_pParagraphSpacingAttrList' are used to hold information // that should be collected by different properties in the core, and are all flushed together 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"; diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index 1ee0c86581bf..5ae31e434dbf 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -1589,6 +1589,9 @@ public: /// Get id of the style (rFormat). sal_uInt16 GetSlot( const SwFormat* pFormat ) const; + /// create style id using only ASCII characters of the style name + static OString CreateStyleId(const OUString &rName); + /// Get styleId of the nId-th style (nId is its position in pFormatA). OString const & GetStyleId(sal_uInt16 nId) const; |