From 818d80eb0cee65d1bcc4fdb74b32a7c42cc1336e Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 28 Jun 2013 16:47:49 +0200 Subject: RTF import: support shapes inside tables This is a better fix for fdo#47802, now that shape import is no longer buffered. Change-Id: Idce6d11e6774d1fe7fc04b6a52d5b77a3879381e --- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'writerfilter/source/rtftok/rtfdocumentimpl.cxx') diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 31cc365972de..96bfce627633 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -1197,6 +1197,10 @@ void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer) Mapper().endCharacterGroup(); else if (aPair.first == BUFFER_PAR) parBreak(); + else if (aPair.first == BUFFER_STARTSHAPE) + m_pSdrImport->resolve(aPair.second->getShape(), false); + else if (aPair.first == BUFFER_ENDSHAPE) + m_pSdrImport->close(); else SAL_WARN("writerfilter", "should not happen"); } @@ -1313,11 +1317,7 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) m_aStates.top().nDestinationState = DESTINATION_SHAPE; break; case RTF_SHPINST: - // Don't try to support shapes inside tables for now. - if (m_aStates.top().pCurrentBuffer != &m_aTableBuffer) - m_aStates.top().nDestinationState = DESTINATION_SHAPEINSTRUCTION; - else - m_aStates.top().nDestinationState = DESTINATION_SKIP; + m_aStates.top().nDestinationState = DESTINATION_SHAPEINSTRUCTION; break; case RTF_NESTTABLEPROPS: // Don't try to support nested tables having table styles for now. @@ -1445,7 +1445,15 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) dispatchFlag(RTF_PARD); m_bNeedPap = true; if (nKeyword == RTF_SHPTXT) - m_pSdrImport->resolve(m_aStates.top().aShape, false); + { + if (!m_aStates.top().pCurrentBuffer) + m_pSdrImport->resolve(m_aStates.top().aShape, false); + else + { + RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aShape)); + m_aStates.top().pCurrentBuffer->push_back(make_pair(BUFFER_STARTSHAPE, pValue)); + } + } break; case RTF_FORMFIELD: if (m_aStates.top().nDestinationState == DESTINATION_FIELDINSTRUCTION) @@ -4602,7 +4610,10 @@ int RTFDocumentImpl::popState() if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT && !m_aStates.top().aDrawingObject.bHadShapeText) { m_aStates.top().bHadShapeText = true; - m_pSdrImport->close(); + if (!m_aStates.top().pCurrentBuffer) + m_pSdrImport->close(); + else + m_aStates.top().pCurrentBuffer->push_back(make_pair(BUFFER_ENDSHAPE, RTFValue::Pointer_t())); } break; default: -- cgit