diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2019-11-14 14:35:06 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@cib.de> | 2019-11-14 18:25:26 +0100 |
commit | 4652b911c4376048a452709c953197e1a879a921 (patch) | |
tree | 2056ffe16ea82c887cd322ec5d1b4b27c67dd930 | |
parent | 80ee721c64014b373bbdbdd1fbf14e003dbd142f (diff) |
sw: RTF export: fix invalid RTF for shapes and text frames
RtfAttributeOutput::OutputFlyFrame_Impl() writes SdrObject into
m_aRunText buffer, but for a text frame it writes directly
into m_rExport.Strm(), also writing m_aRunText into it in the middle.
So if you have both SdrObject and text frame at the same anchor
position, first the shape goes into the buffer and then the first part
of the text frame is written to the stream before it and the last part
after it, and we get this:
sw/source/filter/ww8/rtfattributeoutput.cxx:1886: m_aRunText is not empty
And Word refuses to open the file with a funny error message about
running out of memory.
Reportedly this is a regression from commit
d53dd70b15f0e3f7c8a05a93f8fcd70e1147c1f7 but really it was broken
already in commit a8b59ef5951fe76b0b733ecef739173c1d104f6f.
Change-Id: If01465dee71b63531b46c39dd557066f804c425d
Reviewed-on: https://gerrit.libreoffice.org/82702
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Tested-by: Michael Stahl <michael.stahl@cib.de>
-rw-r--r-- | sw/source/filter/ww8/rtfattributeoutput.cxx | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index edc99691fe54..c37135f819c6 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -1883,7 +1883,7 @@ void RtfAttributeOutput::OutputFlyFrame_Impl(const ww8::Frame& rFrame, const Poi if (RtfSdrExport::isTextBox(rFrame.GetFrameFormat())) break; - OSL_ENSURE(m_aRunText.getLength() == 0, "m_aRunText is not empty"); + assert(m_aRunText.getLength() == 0 && "this will corrupt the document"); m_rExport.m_pParentFrame = &rFrame; m_rExport.Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_SHP); @@ -1950,11 +1950,15 @@ void RtfAttributeOutput::OutputFlyFrame_Impl(const ww8::Frame& rFrame, const Poi m_rExport.OutputFormat(rFrame.GetFrameFormat(), false, false, true); m_aRunText->append('}'); m_rExport.m_pParentFrame = nullptr; + m_rExport.Strm().WriteOString(m_aRunText.makeStringAndClear()); } if (pGrfNode) + { m_aRunText.append(dynamic_cast<const SwFlyFrameFormat*>(&rFrame.GetFrameFormat()), pGrfNode); + m_rExport.Strm().WriteOString(m_aRunText.makeStringAndClear()); + } break; case ww8::Frame::eDrawing: { @@ -1972,6 +1976,7 @@ void RtfAttributeOutput::OutputFlyFrame_Impl(const ww8::Frame& rFrame, const Poi m_aRunText->append('}'); m_aRunText->append('}'); + m_rExport.Strm().WriteOString(m_aRunText.makeStringAndClear()); } } break; |