sw/source/filter/ww8/wrtw8sty.cxx | 10 ++++++++++ sw/source/filter/ww8/wrtww8.hxx | 2 ++ sw/source/filter/ww8/ww8atr.cxx | 13 ++++++++++--- 3 files changed, 22 insertions(+), 3 deletions(-)
New commits: commit 493bca76c7cd8a4581deb2e930cb3b196a78acc6 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Tue Feb 7 14:17:11 2023 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Sep 22 14:57:59 2023 +0200 tdf#153083 writerfilter,sw: DOCX locale-dependent TOC \t style names, 3 The import crashed on fdo85740-1.docx with an unhandled exception. This is because it mapped the TOC style "Table of Figures" from "table of figures", but the ApplyStyleSheetsImpl() actually uses the converted name "Drawing" instead, so "Table of Figures" didn't exist. (regression from commit ca71482237d31703454062b8b2f544a8bacd2831) It turns out that once that is fixed, the DOCX export needs to convert "Drawing" back to "Table of Figures" in the TOC field. (cherry picked from commit 345f23474845da0defa4a9276228f54b5ded5736) Conflicts: writerfilter/source/dmapper/DomainMapper_Impl.cxx writerfilter/source/dmapper/StyleSheetTable.cxx [ Miklos: this is the DOC filter part, as that was not cherry-picked originally. ] Change-Id: I4858c79dd74154b229b7568610c0b8ba7b3e2b6a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157170 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index ab72b5f1cc15..1bf5c89078e1 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -471,6 +471,16 @@ OString const & MSWordStyles::GetStyleId(sal_uInt16 nSlot) const return m_aStyles[nSlot].style_id; } +OUString MSWordStyles::GetStyleWWName(SwFormat const*const pFormat) const +{ + if (auto slot = m_rExport.m_pStyles->GetSlot(pFormat); slot != 0xfff) + { + assert(!m_aStyles[slot].ww_name.isEmpty()); + return m_aStyles[slot].ww_name; + } + return OUString(); +} + /// For WW8 only - extend pO so that the size of pTableStrm is even. static void impl_SkipOdd(std::unique_ptr<ww::bytes> const& pO, std::size_t nTableStrmTell) { diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index c7c22ea52320..7f20ed491bc2 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -1645,6 +1645,8 @@ public: /// Get styleId of the nSlot-th style (nSlot is its position in m_aStyles). OString const & GetStyleId(sal_uInt16 nSlot) const; + /// the awful TOC field references names, not styleIds + OUString GetStyleWWName(SwFormat const* pFormat) const; const SwFormat* GetSwFormat(sal_uInt16 nSlot) const { return m_aStyles[nSlot].format; } /// Get numbering rule of the nSlot-th style diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 32bbe12fb5f2..9a561c05dac6 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -2404,7 +2404,11 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect ) SwTextFormatColl const*const pColl = GetExport().m_rDoc.FindTextFormatCollByName(rStyle); if (pColl) { - sStr += "\\t \"" + rStyle + sEntryEnd; + OUString const converted(GetExport().m_pStyles->GetStyleWWName(pColl)); + if (!converted.isEmpty()) + { + sStr += "\\t \"" + converted + sEntryEnd; + } } } break; @@ -2553,11 +2557,14 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect ) SwTextFormatColl* pColl = GetExport().m_rDoc.FindTextFormatCollByName(sStyle); if (pColl) { - if (!pColl->IsAssignedToListLevelOfOutlineStyle() || pColl->GetAssignedOutlineStyleLevel() < nTOXLvl) + OUString const converted(GetExport().m_pStyles->GetStyleWWName(pColl)); + if (!converted.isEmpty() && + (!pColl->IsAssignedToListLevelOfOutlineStyle() + || pColl->GetAssignedOutlineStyleLevel() < nTOXLvl)) { if( !sTOption.isEmpty() ) sTOption += tsep; - sTOption += sStyle + sLvl; + sTOption += converted + sLvl; } } }