diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-07-16 22:04:02 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-07-24 17:25:25 +0200 |
commit | 7e863504854ae8ab286b32510aba8b363a8e314b (patch) | |
tree | 8db06e66abc96d244820fa100659c939ce7a3be4 /writerfilter | |
parent | 1706ed7334461420274584b875ae6ab209f4dad9 (diff) |
tdf#81943 sw RTF import: fix missing wrap in background for in-table shape
Regression from commit 015fd55c94b7b650ed8e572cafaf3b0f903b01b9
(tdf#96275 RTF import: fix anchor of shapes inside tables, 2016-05-10),
remember more context when delaying the import of a shape.
(cherry picked from commit 0c91f8f839d36c8b5af272b1d3c835d2f4af6b65)
Conflicts:
writerfilter/source/rtftok/rtfdocumentimpl.cxx
Change-Id: Idc02868eb3fe5b7637c9fd00c841bf71423adf2b
Reviewed-on: https://gerrit.libreoffice.org/57555
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 24 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.hxx | 2 |
2 files changed, 26 insertions, 0 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 14eba29aa4a5..d48df600c34f 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -1065,6 +1065,13 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS } } auto pAnchorWrapValue = std::make_shared<RTFValue>(aAnchorWrapAttributes); + + if (m_aStates.top().aShape.aWrapSprm.first != 0) + // Replay of a buffered shape, wrap sprm there has priority over + // character sprms of the current state. + aAnchorSprms.set(m_aStates.top().aShape.aWrapSprm.first, + m_aStates.top().aShape.aWrapSprm.second); + aAnchorSprms.set(NS_ooxml::LN_CT_Anchor_extent, pExtentValue); if (!aAnchorWrapAttributes.empty() && nWrap == -1) aAnchorSprms.set(NS_ooxml::LN_EG_WrapType_wrapSquare, pAnchorWrapValue); @@ -1633,6 +1640,11 @@ void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer, RTFSprms* const pSprms, // otherwise it gets re-buffered. RTFBuffer_t* pCurrentBuffer = m_aStates.top().pCurrentBuffer; m_aStates.top().pCurrentBuffer = nullptr; + + // Set current shape during replay, needed by e.g. wrap in + // background. + m_aStates.top().aShape = std::get<1>(aTuple)->getShape(); + m_pSdrImport->resolve(std::get<1>(aTuple)->getShape(), true, RTFSdrImport::SHAPE); m_aStates.top().pCurrentBuffer = pCurrentBuffer; } @@ -2259,6 +2271,18 @@ RTFError RTFDocumentImpl::popState() m_aStates.top().pCurrentBuffer->push_back( Buf_t(BUFFER_PICTURE, pPictureValue, nullptr)); auto pValue = std::make_shared<RTFValue>(m_aStates.top().aShape); + + // Buffer wrap type. + for (auto& rCharacterSprm : m_aStates.top().aCharacterSprms) + { + if (rCharacterSprm.first == NS_ooxml::LN_EG_WrapType_wrapNone + || rCharacterSprm.first == NS_ooxml::LN_EG_WrapType_wrapTight) + { + m_aStates.top().aShape.aWrapSprm = rCharacterSprm; + break; + } + } + m_aStates.top().pCurrentBuffer->push_back( Buf_t(BUFFER_RESOLVESHAPE, pValue, nullptr)); } diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index b5386a30181b..5c4f2410275b 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -176,6 +176,8 @@ public: RTFSprms aWrapPolygonSprms; /// Anchor attributes like wrap distance, written by RTFSdrImport::resolve(), read by RTFDocumentImpl::resolvePict(). RTFSprms aAnchorAttributes; + /// Wrap type, written by RTFDocumentImpl::popState(), read by RTFDocumentImpl::resolvePict(). + std::pair<Id, RTFValue::Pointer_t> aWrapSprm{ 0, nullptr }; }; /// Stores the properties of a drawing object. |