diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-02-03 12:29:21 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-02-27 12:10:51 +0000 |
commit | c56abb3c952e3062099d32702719825ee55b5112 (patch) | |
tree | 7748d45f97f758d2da83510947734f2bef980109 | |
parent | 58deeaea725eca0e8140b09420d5144d5d3f800c (diff) |
tdf#88811 SwXText::convertToTextFrame: handle shapes anchored to us
(cherry picked from commit 38f2b8b3b16aab19a2564ec699d253d3dccecc3c)
Conflicts:
sw/qa/extras/rtfimport/rtfimport.cxx
Change-Id: Iedf8eacd37b8ed8e307a10e8ade32f53c7417c4a
Reviewed-on: https://gerrit.libreoffice.org/14629
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sw/qa/extras/rtfimport/data/tdf88811.rtf | 26 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/rtfimport.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/unocore/unotext.cxx | 13 |
3 files changed, 44 insertions, 3 deletions
diff --git a/sw/qa/extras/rtfimport/data/tdf88811.rtf b/sw/qa/extras/rtfimport/data/tdf88811.rtf new file mode 100644 index 000000000000..a20835c4746c --- /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 db67a127b12b..41a1064ad52d 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -2095,6 +2095,14 @@ DECLARE_RTFIMPORT_TEST(testFdo82114, "fdo82114.rtf") CPPUNIT_ASSERT_EQUAL(aExpected, aActual); } +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 cd31f50fcd42..25dd3f5639d8 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -1658,14 +1658,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) { 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()); + } } SwXTextFrame *const pNewFrame = new SwXTextFrame(m_pImpl->m_pDoc); @@ -1708,7 +1715,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()); |