sw/source/filter/ww8/docxattributeoutput.cxx | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
New commits: commit 551b163d8f235c8667df3aaf9dffb45d6c47b498 Author: Jan Holesovsky <ke...@collabora.com> Date: Fri Apr 21 09:47:13 2017 +0200 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 Reviewed-on: https://gerrit.libreoffice.org/36785 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 845fac3cf733..efda989e3f44 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -6681,7 +6681,7 @@ void DocxAttributeOutput::WritePostitFieldReference() void DocxAttributeOutput::WritePostitFields() { - for(const std::pair<const SwPostItField*,int> & rPair : m_postitFields) + for (const std::pair<const SwPostItField*,int> & rPair : m_postitFields) { OString idstr = OString::number( rPair.second); const SwPostItField* f = rPair.first; @@ -6689,11 +6689,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 ); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits