diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-02-03 12:29:21 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-02-03 18:36:21 +0000 |
commit | 38f2b8b3b16aab19a2564ec699d253d3dccecc3c (patch) | |
tree | a84fd69df94e7defb6958e12c96375b34f69d7b9 | |
parent | 60a64d1807b075fb630774adf950612d71734171 (diff) |
tdf#88811 SwXText::convertToTextFrame: handle shapes anchored to us
Change-Id: Iedf8eacd37b8ed8e307a10e8ade32f53c7417c4a
Reviewed-on: https://gerrit.libreoffice.org/14306
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-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 014ec0780031..39c105409038 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 63dafb435de9..52e73c1645fe 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()); |