summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-12-09 08:46:27 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-12-09 08:46:56 +0100
commit7060525a64ef1048b387f0a6a9f842d78b52fb9a (patch)
tree9502caaf846e1de627c73fe0db54e3db6aa5edf4 /sw/source
parent4754afddc3030347ef49b401a9b798cea8fe523c (diff)
tdf#94377 RTF export: support comment formatting
The core of this change is that RtfAttributeOutput::PostitField() now uses WriteOutliner() to handle comment text, instead of trying to output the plain text as-is. To have working roundtrip of the comment text, a few more changes are needed: 1) When emptying the Styles buffer, also empty the StylesEnd one. 2) Annotations don't want a trailing \par, so don't write one for the last paragraph. 3) Inform the MSWord_SdrAttrIter about where the editeng content will end up, and make WriteOutliner() accessible outside RtfSdrExport. Change-Id: I9cbcf4ce5dc3a099d310c6f321ea8e52f8644f9b
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx8
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.hxx1
-rw-r--r--sw/source/filter/ww8/rtfsdrexport.cxx22
-rw-r--r--sw/source/filter/ww8/rtfsdrexport.hxx6
4 files changed, 27 insertions, 10 deletions
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index ab9ad06b857b..9e1c583e5c16 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -424,6 +424,11 @@ OStringBuffer& RtfAttributeOutput::RunText()
return m_aRunText.getLastBuffer();
}
+OStringBuffer& RtfAttributeOutput::StylesEnd()
+{
+ return m_aStylesEnd;
+}
+
void RtfAttributeOutput::RawText(const OUString& rText, rtl_TextEncoding eCharSet)
{
m_aRunText->append(msfilter::rtfutil::OutString(rText, eCharSet));
@@ -3466,7 +3471,8 @@ void RtfAttributeOutput::PostitField(const SwField* pField)
m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNDATE " ");
m_aRunText->append((sal_Int32)sw::ms::DateTime2DTTM(rPField.GetDateTime()));
m_aRunText->append('}');
- m_aRunText->append(OUStringToOString(OUString(rPField.GetText()), m_rExport.eCurrentEncoding));
+ if (const OutlinerParaObject* pObject = rPField.GetTextObject())
+ m_rExport.SdrExporter().WriteOutliner(*pObject, TXT_ATN);
m_aRunText->append('}');
}
diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx
index e13fcd6c2ec8..77e2303611d8 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -82,6 +82,7 @@ public:
{
return m_aStyles;
}
+ OStringBuffer& StylesEnd();
/// Output text (without markup).
virtual void RawText(const OUString& rText, rtl_TextEncoding eCharSet) override;
diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx
index 8f3f97f8eead..c9d386a34a03 100644
--- a/sw/source/filter/ww8/rtfsdrexport.cxx
+++ b/sw/source/filter/ww8/rtfsdrexport.cxx
@@ -554,23 +554,25 @@ sal_Int32 RtfSdrExport::StartShape()
if (pParaObj)
{
// this is reached only in case some text is attached to the shape
- WriteOutliner(*pParaObj);
+ WriteOutliner(*pParaObj, TXT_HFTXTBOX);
}
}
return m_nShapeType;
}
-void RtfSdrExport::WriteOutliner(const OutlinerParaObject& rParaObj)
+void RtfSdrExport::WriteOutliner(const OutlinerParaObject& rParaObj, TextTypes eType)
{
SAL_INFO("sw.rtf", OSL_THIS_FUNC << " start");
const EditTextObject& rEditObj = rParaObj.GetTextObject();
- MSWord_SdrAttrIter aAttrIter(m_rExport, rEditObj, TXT_HFTXTBOX);
+ MSWord_SdrAttrIter aAttrIter(m_rExport, rEditObj, eType);
sal_Int32 nPara = rEditObj.GetParagraphCount();
- m_rAttrOutput.RunText().append('{').append(OOO_STRING_SVTOOLS_RTF_SHPTXT).append(' ');
+ bool bShape = eType == TXT_HFTXTBOX;
+ if (bShape)
+ m_rAttrOutput.RunText().append('{').append(OOO_STRING_SVTOOLS_RTF_SHPTXT).append(' ');
for (sal_Int32 n = 0; n < nPara; ++n)
{
if (n)
@@ -584,6 +586,7 @@ void RtfSdrExport::WriteOutliner(const OutlinerParaObject& rParaObj)
aAttrIter.OutParaAttr(false);
m_rAttrOutput.RunText().append(m_rAttrOutput.Styles().makeStringAndClear());
+ m_rAttrOutput.RunText().append(m_rAttrOutput.StylesEnd().makeStringAndClear());
do
{
@@ -591,7 +594,10 @@ void RtfSdrExport::WriteOutliner(const OutlinerParaObject& rParaObj)
rtl_TextEncoding eNextChrSet = aAttrIter.GetNextCharSet();
aAttrIter.OutAttr(nAktPos);
- m_rAttrOutput.RunText().append('{').append(m_rAttrOutput.Styles().makeStringAndClear()).append(SAL_NEWLINE_STRING);
+ m_rAttrOutput.RunText().append('{');
+ m_rAttrOutput.RunText().append(m_rAttrOutput.Styles().makeStringAndClear());
+ m_rAttrOutput.RunText().append(m_rAttrOutput.StylesEnd().makeStringAndClear());
+ m_rAttrOutput.RunText().append(SAL_NEWLINE_STRING);
bool bTextAtr = aAttrIter.IsTextAttr(nAktPos);
if (!bTextAtr)
{
@@ -606,9 +612,11 @@ void RtfSdrExport::WriteOutliner(const OutlinerParaObject& rParaObj)
aAttrIter.NextPos();
}
while (nAktPos < nEnd);
- m_rAttrOutput.RunText().append(OOO_STRING_SVTOOLS_RTF_PAR);
+ if (bShape || n + 1 < nPara)
+ m_rAttrOutput.RunText().append(OOO_STRING_SVTOOLS_RTF_PAR);
}
- m_rAttrOutput.RunText().append('}');
+ if (bShape)
+ m_rAttrOutput.RunText().append('}');
SAL_INFO("sw.rtf", OSL_THIS_FUNC << " end");
}
diff --git a/sw/source/filter/ww8/rtfsdrexport.hxx b/sw/source/filter/ww8/rtfsdrexport.hxx
index ab0b24d32696..926ff7464ae6 100644
--- a/sw/source/filter/ww8/rtfsdrexport.hxx
+++ b/sw/source/filter/ww8/rtfsdrexport.hxx
@@ -27,6 +27,8 @@
#include <map>
#include <set>
+#include <wrtww8.hxx>
+
class RtfExport;
class RtfAttributeOutput;
class SwFrameFormat;
@@ -68,6 +70,8 @@ public:
/// Is this a standalone TextFrame, or used as a TextBox of a shape?
bool isTextBox(const SwFrameFormat& rFrameFormat);
+ /// Write editeng text, e.g. shape or comment.
+ void WriteOutliner(const OutlinerParaObject& rParaObj, TextTypes eType);
protected:
/// Start the shape for which we just collected the information.
@@ -101,8 +105,6 @@ private:
/// Add position and size to the OStringBuffer.
void AddRectangleDimensions(OStringBuffer& rBuffer, const Rectangle& rRectangle);
- void WriteOutliner(const OutlinerParaObject& rParaObj);
-
/// Exports the pib property of the shape
void impl_writeGraphic();
};