sw/source/filter/ww8/docxattributeoutput.cxx | 20 ++++++++++++-------- sw/source/filter/ww8/wrtw8sty.cxx | 3 ++- sw/source/filter/ww8/wrtww8.hxx | 3 --- 3 files changed, 14 insertions(+), 12 deletions(-)
New commits: commit 20adf4683c7d38ad41edac586b897757393c8029 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Thu Jan 12 15:41:38 2023 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Fri Jan 13 05:16:58 2023 +0000 tdf#152425 related: don't generate style ids in DocxAttributeOutput::Redline If the style id is unavailable from MSWordStyles::GetStyleId at this point, it is a bug (meaning that we failed to output the style to styles.xml). Local style generation here would skip the "make it unique" step anyway, so the id would be unreliable / useless. Change-Id: I32c3c6a2581a7aaa6c5b1bb3d48f09b90fb65f73 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145401 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index db4299d582b3..0a95e6c44cd6 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -3874,14 +3874,18 @@ void DocxAttributeOutput::Redline( const SwRedlineData* pRedlineData) m_pSerializer->startElementNS(XML_w, XML_pPr); - OString sStyleName; - if (auto format = m_rExport.m_rDoc.FindTextFormatCollByName(sParaStyleName)) - if (auto slot = m_rExport.m_pStyles->GetSlot(format); slot != 0xfff) - sStyleName = m_rExport.m_pStyles->GetStyleId(slot); - if (sStyleName.isEmpty()) - sStyleName = MSWordStyles::CreateStyleId(sParaStyleName); - if ( !sStyleName.isEmpty() ) - m_pSerializer->singleElementNS(XML_w, XML_pStyle, FSNS(XML_w, XML_val), sStyleName); + if (!sParaStyleName.isEmpty()) + { + OString sStyleName; + if (auto format = m_rExport.m_rDoc.FindTextFormatCollByName(sParaStyleName)) + if (auto slot = m_rExport.m_pStyles->GetSlot(format); slot != 0xfff) + sStyleName = m_rExport.m_pStyles->GetStyleId(slot); + // If the style name is empty at this point, this is a bug, meaning that we + // failed to output the style to styles.xml properly + assert(!sStyleName.isEmpty()); + 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 72fca1b3696f..21d11894f2d5 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -381,7 +381,8 @@ void MSWordStyles::BuildWwNames() } } -OString MSWordStyles::CreateStyleId(std::u16string_view aName) +/// create style id using only ASCII characters of the style name +static OString CreateStyleId(std::u16string_view aName) { OStringBuffer aStyleIdBuf(aName.size()); for (size_t i = 0; i < aName.size(); ++i) diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index cf5d0bfa104b..b44575a89bab 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -1633,9 +1633,6 @@ public: /// Get slot 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(std::u16string_view aName); - /// Get styleId of the nSlot-th style (nSlot is its position in m_aStyles). OString const & GetStyleId(sal_uInt16 nSlot) const;