From 24fee4879c0df4fb88fad8de4f7d62598888aafe Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Fri, 21 Apr 2017 09:47:13 +0200 Subject: related tdf#68604: Write the plaintext version of the annotation... ...if the TextObject is not available. This is perfectly valid situation in the case when the SwPostItField was created via the .uno:InsertAnnotation API. Change-Id: I3ae2a529ba7cc13cf5b04d57aa299d79e2044f37 --- sw/source/filter/ww8/docxattributeoutput.cxx | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index b9d2fe38de4e..c59dc7520f5f 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -6762,7 +6762,7 @@ void DocxAttributeOutput::WritePostitFieldReference() void DocxAttributeOutput::WritePostitFields() { - for(const std::pair & rPair : m_postitFields) + for (const std::pair & rPair : m_postitFields) { OString idstr = OString::number( rPair.second); const SwPostItField* f = rPair.first; @@ -6770,11 +6770,23 @@ void DocxAttributeOutput::WritePostitFields() FSNS( XML_w, XML_author ), OUStringToOString( f->GetPar1(), RTL_TEXTENCODING_UTF8 ).getStr(), FSNS( XML_w, XML_date ), DateTimeToOString(f->GetDateTime()).getStr(), FSNS( XML_w, XML_initials ), OUStringToOString( f->GetInitials(), RTL_TEXTENCODING_UTF8 ).getStr(), FSEND ); - // Check for the text object existing, it seems that it can be NULL when saving a newly created - // comment without giving focus back to the main document. As GetText() is empty in that case as well, - // that is probably a bug in the Writer core. - if( f->GetTextObject() != nullptr ) - GetExport().WriteOutliner( *f->GetTextObject(), TXT_ATN ); + + if (f->GetTextObject() != nullptr) + { + // richtext + GetExport().WriteOutliner(*f->GetTextObject(), TXT_ATN); + } + else + { + // just plain text - eg. when the field was created via the + // .uno:InsertAnnotation API + m_pSerializer->startElementNS(XML_w, XML_p, FSEND); + m_pSerializer->startElementNS(XML_w, XML_r, FSEND); + RunText(f->GetText()); + m_pSerializer->endElementNS(XML_w, XML_r); + m_pSerializer->endElementNS(XML_w, XML_p); + } + m_pSerializer->endElementNS( XML_w, XML_comment ); } } -- cgit v1.2.3