From ea190eaa0459c3cca3c242d45ca386db8188d047 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 22 Aug 2011 17:40:34 +0200 Subject: Make frame start/end a bit more robust Don't try to start a started frame, don't try to end a not started frame. --- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 11 +++++++++-- writerfilter/source/rtftok/rtfdocumentimpl.hxx | 4 +++- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'writerfilter') diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 9aa9a26f46b8..b6ceeed48565 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -296,7 +296,8 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference const& x m_aStyleTableEntries(), m_nCurrentStyleIndex(0), m_bEq(false), - m_bWasInFrame(false) + m_bWasInFrame(false), + m_bIsInShape(false) { OSL_ASSERT(xInputStream.is()); m_pInStream = utl::UcbStreamHelper::CreateStream(xInputStream, sal_True); @@ -723,6 +724,8 @@ void RTFDocumentImpl::checkChangedFrame() // Check if this is a frame. if (inFrame() && !m_bWasInFrame) { + if (m_bIsInShape) + return; OSL_TRACE("%s starting frame", OSL_THIS_FUNC); uno::Reference xTextFrame; xTextFrame.set(getModelFactory()->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame"))), uno::UNO_QUERY); @@ -749,16 +752,20 @@ void RTFDocumentImpl::checkChangedFrame() Mapper().startShape(xShape); Mapper().startParagraphGroup(); + m_bIsInShape = true; } else if (!inFrame() && m_bWasInFrame) { + if (!m_bIsInShape) + return; OSL_TRACE("%s ending frame", OSL_THIS_FUNC); finishSubstream(); Mapper().endParagraphGroup(); Mapper().endShape(); Mapper().endParagraphGroup(); Mapper().startParagraphGroup(); - m_bWasInFrame = false; + m_bWasInFrame = false; // this is needed by invalid nested flies where the result is separate frames + m_bIsInShape = false; } } diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index d48b0498949f..aee3f79d6717 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -421,8 +421,10 @@ namespace writerfilter { RTFReferenceTable::Entries_t m_aStyleTableEntries; int m_nCurrentStyleIndex; bool m_bEq; - /// If we are in a frame. + /// If we were in a frame. bool m_bWasInFrame; + /// If a shape is already started (nesting them is not OK). + bool m_bIsInShape; }; } // namespace rtftok -- cgit v1.2.3