[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Fri Feb 27 04:11:13 PST 2015


 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 c56abb3c952e3062099d32702719825ee55b5112
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Feb 3 12:29:21 2015 +0100

    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 at redhat.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

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 db67a12..41a1064 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 cd31f50..25dd3f5 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());


More information about the Libreoffice-commits mailing list