sw/qa/extras/rtfimport/data/tdf81943.rtf | 48 +++++++++++++++++++++++++ sw/qa/extras/rtfimport/rtfimport.cxx | 6 +++ writerfilter/source/rtftok/rtfdocumentimpl.cxx | 24 ++++++++++++ writerfilter/source/rtftok/rtfdocumentimpl.hxx | 2 + 4 files changed, 80 insertions(+)
New commits: commit 0c91f8f839d36c8b5af272b1d3c835d2f4af6b65 Author: Miklos Vajna <vmik...@collabora.co.uk> AuthorDate: Mon Jul 16 22:04:02 2018 +0200 Commit: Miklos Vajna <vmik...@collabora.co.uk> CommitDate: Tue Jul 17 09:03:42 2018 +0200 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. Change-Id: Idc02868eb3fe5b7637c9fd00c841bf71423adf2b Reviewed-on: https://gerrit.libreoffice.org/57531 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/sw/qa/extras/rtfimport/data/tdf81943.rtf b/sw/qa/extras/rtfimport/data/tdf81943.rtf new file mode 100644 index 000000000000..28b3f430abce --- /dev/null +++ b/sw/qa/extras/rtfimport/data/tdf81943.rtf @@ -0,0 +1,48 @@ +{\rtf1 +{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0; +\red255\green255\blue255;\red0\green0\blue128;} +\trowd \irow0\cellx6300\cellx10800\pard\plain +{\rtlch\fcs1 \af1 \ltrch\fcs0 \lang1024\langfe1024\noproof +{\shp +{\*\shpinst\shpleft-199\shptop-18\shpright11028\shpbottom2236\shpfhdr0\shpbxpage\shpbxignore\shpbypage\shpbyignore\shpwr3\shpwrk0\shpfblwtxt1\shpz0\shplockanchor\shplid1026 +{\sp +{\sn shapeType} +{\sv 75} +} +{\sp +{\sn pib} +{\sv +{\pict\picscalex99\picscaley99\piccropl0\piccropr0\piccropt0\piccropb0\picw19905\pich3997\picwgoal11285\pichgoal2266\pngblip +89504e470d0a1a0a0000000d494844520000000400000004080200000026930929000000097048597300002e2300002e230178a53f760000000774494d4507e2 +07090f031bf2645ea1000000144944415408d763cc63f8cf00034c0c480037070047bd01759ad735e20000000049454e44ae426082} +} +} +{\sp +{\sn posrelh} +{\sv 1} +} +{\sp +{\sn posrelv} +{\sv 1} +} +{\sp +{\sn fBehindDocument} +{\sv 1} +} +} +} +} +{\rtlch\fcs1 \af1 \ltrch\fcs0 \cell } +\pard \ltrpar \intbl\cell +\pard\plain \ltrpar\ql \li0\ri0\intbl\aspnum \rtlch\fcs1 \af1\afs22 \ltrch\fcs0 \f39\fs18\lang1033\langfe1033\cgrid +{\rtlch\fcs1 \af1 \ltrch\fcs0 \trowd \irow0\cellx6300\cellx10800\row } +\trowd \irow1\lastrow +\cellx6300\cellx10800\pard\plain +\f42\fs40\cf8\lang1033\langfe1033\cgrid +{\rtlch\fcs1 \af0 \ltrch\fcs0 \f31506 hello\cell} +{\rtlch\fcs1 \af0 \ltrch\fcs0 \lang1049\langfe1033 \cell } +\pard\plain +{\rtlch\fcs1 \af1 \ltrch\fcs0 \trowd \irow1\lastrow +\cellx6300\cellx10800\row } +\pard\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 664f3edb9589..fedfb7fbd4ce 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -173,6 +173,12 @@ DECLARE_RTFIMPORT_TEST(testTdf115715, "tdf115715.rtf") getProperty<sal_Int32>(getParagraph(2), "ParaFirstLineIndent")); } +DECLARE_RTFIMPORT_TEST(testTdf81943, "tdf81943.rtf") +{ + // The shape wasn't in background. + CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(getShape(1), "Opaque")); +} + DECLARE_RTFIMPORT_TEST(testTdf115155, "tdf115155.rtf") { auto xLevels diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 08e683b05921..a1afc2bc93a6 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -1064,6 +1064,13 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS aAnchorSprms.set(rCharacterSprm.first, rCharacterSprm.second); } } + + 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, @@ -1628,6 +1635,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; } @@ -2251,6 +2263,18 @@ RTFError RTFDocumentImpl::popState() m_aStates.top().pCurrentBuffer->push_back( Buf_t(BUFFER_PICTURE, pPictureValue, nullptr)); auto pValue = new 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 f5d595057d59..bdc6af35bae4 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -194,6 +194,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. _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits