sw/source/filter/ww8/docxattributeoutput.cxx |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

New commits:
commit d09996a0d66c51908103afef9c56679b891570d8
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Wed Feb 1 12:31:46 2023 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Wed Feb 1 14:20:13 2023 +0000

    tdf#148952 sw: DOCX export: ECMA-376 1st ed does not allow title
    
    ... attribute, so fallback to merge the value with the description
    into the descr attribute.
    
    Change-Id: I4e83a67788d0c82dd762c075f06db358a7884675
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146444
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 05e0ea5f0479..aafde6a8bf0c 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -5747,10 +5747,21 @@ void DocxAttributeOutput::FlyFrameGraphic( const 
SwGrfNode* pGrfNode, const Size
     rtl::Reference<::sax_fastparser::FastAttributeList> docPrattrList = 
FastSerializerHelper::createAttrList();
     docPrattrList->add( XML_id, OString::number( m_anchorId++).getStr());
     docPrattrList->add( XML_name, OUStringToOString( pFrameFormat->GetName(), 
RTL_TEXTENCODING_UTF8 ) );
-    docPrattrList->add( XML_descr, OUStringToOString( pGrfNode ? 
pGrfNode->GetDescription() : pOLEFrameFormat->GetObjDescription(), 
RTL_TEXTENCODING_UTF8 ));
+    OUString const descr(pGrfNode ? pGrfNode->GetDescription() : 
pOLEFrameFormat->GetObjDescription());
+    OUString const title(pGrfNode ? pGrfNode->GetTitle() : 
pOLEFrameFormat->GetObjTitle());
     if (GetExport().GetFilter().getVersion() != 
oox::core::ECMA_376_1ST_EDITION)
     {
-        docPrattrList->add( XML_title, OUStringToOString( pGrfNode ? 
pGrfNode->GetTitle() : pOLEFrameFormat->GetObjTitle(), RTL_TEXTENCODING_UTF8 ));
+        docPrattrList->add(XML_descr, OUStringToOString(descr, 
RTL_TEXTENCODING_UTF8));
+        docPrattrList->add(XML_title, OUStringToOString(title, 
RTL_TEXTENCODING_UTF8));
+    }
+    else
+    {   // tdf#148952 no title attribute, merge it into descr
+        OUString const value(title.isEmpty()
+            ? descr
+            : descr.isEmpty()
+                ? title
+                : title + OUString::Concat("\n") + descr);
+        docPrattrList->add(XML_descr, OUStringToOString(value, 
RTL_TEXTENCODING_UTF8));
     }
     m_pSerializer->startElementNS( XML_wp, XML_docPr, docPrattrList );
 

Reply via email to