sw/qa/extras/rtfimport/data/tdf88811.rtf | 26 ++++++++++++++++++++++++++ sw/qa/extras/rtfimport/rtfimport.cxx | 8 ++++++++ sw/source/core/unocore/unotext.cxx | 13 ++++++++++--- 3 files changed, 44 insertions(+), 3 deletions(-)
New commits: commit 38f2b8b3b16aab19a2564ec699d253d3dccecc3c Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Feb 3 12:29:21 2015 +0100 tdf#88811 SwXText::convertToTextFrame: handle shapes anchored to us Change-Id: Iedf8eacd37b8ed8e307a10e8ade32f53c7417c4a Reviewed-on: https://gerrit.libreoffice.org/14306 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/sw/qa/extras/rtfimport/data/tdf88811.rtf b/sw/qa/extras/rtfimport/data/tdf88811.rtf new file mode 100644 index 0000000..a20835c --- /dev/null +++ b/sw/qa/extras/rtfimport/data/tdf88811.rtf @@ -0,0 +1,26 @@ +{\rtf1\ansi\deff0 +\margl0\margr0\margt0\margb0 +\paperw11905\paperh16837 +{\shp +{\*\shpinst\shpleft4420\shptop2720\shpright4420\shpbottom3280\shpfhdr0\shpbxpage\shpbypage\shpwr3\shpwrk0\shpfblwtxt1\shpz0 +{\sp +{\sn shapeType} +{\sv 20} +} +} +} +{\pard\plain\ql\sl-180\sb40\phmrg\pvmrg\posx3520\posy2900\absw680\absh0\dxfrtext0\dfrmtxtx0\dfrmtxty0 +{\f1\fs18\b Frame1} +\par} +{\shp +{\*\shpinst\shpleft5760\shptop2720\shpright5760\shpbottom3280\shpfhdr0\shpbxpage\shpbypage\shpwr3\shpwrk0\shpfblwtxt1\shpz0 +{\sp +{\sn shapeType} +{\sv 20} +} +} +} +{\pard\plain\ql\sl-180\sb40\phmrg\pvmrg\posx4800\posy2900\absw800\absh0\dxfrtext0\dfrmtxtx0\dfrmtxty0 +{\f1\fs18\b Frame2} +\par} +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 014ec07..39c1054 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -2248,6 +2248,14 @@ DECLARE_RTFIMPORT_TEST(testFdo86750, "fdo86750.rtf") CPPUNIT_ASSERT_EQUAL(OUString("#anchor"), getProperty<OUString>(getRun(getParagraph(1), 1), "HyperLinkURL")); } +DECLARE_RTFIMPORT_TEST(testTdf88811, "tdf88811.rtf") +{ + // The problem was that shapes anchored to the paragraph that is moved into a textframe were lost, so this was 2. + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), xDrawPage->getCount()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 63dafb4..52e73c1 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -1663,14 +1663,21 @@ SwXText::convertToTextFrame( // see if there are frames already anchored to this node std::set<OUString> aAnchoredFrames; + // for shapes, we have to work with the SdrObjects, as unique name is not guaranteed in their frame format + std::set<const SdrObject*> aAnchoredShapes; for (size_t i = 0; i < m_pImpl->m_pDoc->GetSpzFrmFmts()->size(); ++i) { const SwFrmFmt* pFrmFmt = (*m_pImpl->m_pDoc->GetSpzFrmFmts())[i]; const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); - if (FLY_AT_PARA == rAnchor.GetAnchorId() && + if ((FLY_AT_PARA == rAnchor.GetAnchorId() || FLY_AT_CHAR == rAnchor.GetAnchorId()) && aStartPam.Start()->nNode.GetIndex() <= rAnchor.GetCntntAnchor()->nNode.GetIndex() && aStartPam.End()->nNode.GetIndex() >= rAnchor.GetCntntAnchor()->nNode.GetIndex()) - aAnchoredFrames.insert(pFrmFmt->GetName()); + { + if (pFrmFmt->Which() == RES_DRAWFRMFMT) + aAnchoredShapes.insert(pFrmFmt->FindSdrObject()); + else + aAnchoredFrames.insert(pFrmFmt->GetName()); + } } const uno::Reference<text::XTextFrame> xNewFrame( @@ -1714,7 +1721,7 @@ SwXText::convertToTextFrame( for (size_t i = 0; i < m_pImpl->m_pDoc->GetSpzFrmFmts()->size(); ++i) { SwFrmFmt* pFrmFmt = (*m_pImpl->m_pDoc->GetSpzFrmFmts())[i]; - if( aAnchoredFrames.find( pFrmFmt->GetName() ) != aAnchoredFrames.end() ) + if (aAnchoredFrames.find(pFrmFmt->GetName()) != aAnchoredFrames.end() || aAnchoredShapes.find(pFrmFmt->FindSdrObject()) != aAnchoredShapes.end()) { // copy the anchor to the next paragraph SwFmtAnchor aAnchor(pFrmFmt->GetAnchor()); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits