summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2017-04-21 09:47:13 +0200
committerJan Holesovsky <kendy@collabora.com>2017-04-21 12:28:10 +0200
commit24fee4879c0df4fb88fad8de4f7d62598888aafe (patch)
tree1625125e0cddd36dec1ea4446089ce239c9a75be
parent157013219230f251346a5aa662c39d02f15420ec (diff)
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
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx24
1 files 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<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;
@@ -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 );
}
}