summaryrefslogtreecommitdiff
path: root/writerfilter/source/rtftok
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-05-10 09:16:17 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-05-10 10:33:41 +0000
commit015fd55c94b7b650ed8e572cafaf3b0f903b01b9 (patch)
treeeee92115bd9040e1916a27f6e16aaf43c745e731 /writerfilter/source/rtftok
parentf6fb8a152797de4c5339b2fa5a3adf0e2ee0c349 (diff)
tdf#96275 RTF import: fix anchor of shapes inside tables
Table text is buffered, so buffer the shape import as well, otherwise the anchor will precede the buffered text -> incorrect anchor position. Change-Id: I527b898e2cd5fafaf122a20e11df66ba8d3185cf Reviewed-on: https://gerrit.libreoffice.org/24822 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'writerfilter/source/rtftok')
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx11
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx4
2 files changed, 13 insertions, 2 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 527195f38bbe..43056acedce4 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1521,6 +1521,8 @@ void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer,
parBreak();
else if (std::get<0>(aTuple) == BUFFER_STARTSHAPE)
m_pSdrImport->resolve(std::get<1>(aTuple)->getShape(), false, RTFSdrImport::SHAPE);
+ else if (std::get<0>(aTuple) == BUFFER_RESOLVESHAPE)
+ m_pSdrImport->resolve(std::get<1>(aTuple)->getShape(), true, RTFSdrImport::SHAPE);
else if (std::get<0>(aTuple) == BUFFER_ENDSHAPE)
m_pSdrImport->close();
else if (std::get<0>(aTuple) == BUFFER_RESOLVESUBSTREAM)
@@ -2059,7 +2061,14 @@ RTFError RTFDocumentImpl::popState()
{
// Don't trigger a shape import in case we're only leaving the \shpinst of the groupshape itself.
RTFSdrImport::ShapeOrPict eType = (aState.eDestination == Destination::SHAPEINSTRUCTION) ? RTFSdrImport::SHAPE : RTFSdrImport::PICT;
- m_pSdrImport->resolve(m_aStates.top().aShape, true, eType);
+ if (!m_aStates.top().pCurrentBuffer || eType != RTFSdrImport::SHAPE)
+ m_pSdrImport->resolve(m_aStates.top().aShape, true, eType);
+ else
+ {
+ // Shape inside table: buffer the import to have correct anchor position.
+ auto pValue = std::make_shared<RTFValue>(m_aStates.top().aShape);
+ m_aStates.top().pCurrentBuffer->push_back(Buf_t(BUFFER_RESOLVESHAPE, pValue, nullptr));
+ }
}
else if (aState.bInShapeGroup && !aState.bInShape)
{
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 662b554db6f5..132df5afd640 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -44,7 +44,7 @@ enum class RTFBorderState
CHARACTER
};
-/// Minimalistic buffer of elements for nested cells.
+/// Different kind of buffers for table cell contents.
enum RTFBufferTypes
{
BUFFER_PROPS,
@@ -56,6 +56,8 @@ enum RTFBufferTypes
BUFFER_ENDRUN,
BUFFER_PAR,
BUFFER_STARTSHAPE,
+ /// Imports a shape.
+ BUFFER_RESOLVESHAPE,
BUFFER_ENDSHAPE,
BUFFER_RESOLVESUBSTREAM
};