sw/source/filter/ww8/rtfattributeoutput.cxx |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

New commits:
commit 4652b911c4376048a452709c953197e1a879a921
Author:     Michael Stahl <michael.st...@cib.de>
AuthorDate: Thu Nov 14 14:35:06 2019 +0100
Commit:     Michael Stahl <michael.st...@cib.de>
CommitDate: Thu Nov 14 18:25:26 2019 +0100

    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.st...@cib.de>
    Tested-by: Michael Stahl <michael.st...@cib.de>

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;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to