summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-02-03 12:29:21 +0100
committerZolnai Tamás <zolnaitamas2000@gmail.com>2015-02-22 10:23:17 +0000
commit3e3f0f5c3051ea982f8f753e0f3e51441e8f9496 (patch)
treebbff4ca76566911f575632998938f48db6484af2
parent4bc49565331c931f0efb3590db76267a5c911053 (diff)
tdf#88811 SwXText::convertToTextFrame: handle shapes anchored to us
(cherry picked from commit 38f2b8b3b16aab19a2564ec699d253d3dccecc3c) Change-Id: Iedf8eacd37b8ed8e307a10e8ade32f53c7417c4a Reviewed-on: https://gerrit.libreoffice.org/14571 Reviewed-by: Zolnai Tamás <zolnaitamas2000@gmail.com> Tested-by: Zolnai Tamás <zolnaitamas2000@gmail.com>
-rw-r--r--sw/qa/extras/rtfimport/data/tdf88811.rtf26
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx8
-rw-r--r--sw/source/core/unocore/unotext.cxx13
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 e6a36196875c..1d77187fd3e3 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2244,6 +2244,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 ae73060fd560..2be0de2e7198 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());