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

Miklos Vajna vmiklos at collabora.co.uk
Thu Sep 7 13:31:44 UTC 2017


 sw/qa/extras/globalfilter/globalfilter.cxx  |   27 +++++++++++++++++++++++++--
 sw/qa/extras/rtfexport/data/tdf104936.rtf   |   20 ++++++++++++++++++++
 sw/qa/extras/rtfexport/rtfexport.cxx        |   11 +++++++++++
 sw/source/filter/ww8/rtfattributeoutput.cxx |    8 ++++++++
 sw/source/filter/ww8/rtfsdrexport.cxx       |    4 ++++
 5 files changed, 68 insertions(+), 2 deletions(-)

New commits:
commit ece79b8f7e52f0658f63caad63134fc8a3503c34
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 5 09:07:48 2017 +0200

    tdf#104936 RTF export: implement ZOrder of TextFrames / shapes
    
    This used to work by accident for the particular textbox, but broke with
    commit 38f2b8b3b16aab19a2564ec699d253d3dccecc3c (tdf#88811
    SwXText::convertToTextFrame: handle shapes anchored to us, 2015-02-03),
    so write ZOrder explicitly, like other filters already do.
    
    (cherry picked from commit 4cde2a01be75552a0b7d37f65cc4134cb48fea26)
    
    Change-Id: Ie8f11f4ec77707fb5aec7a597544d589a99bf6ca
    Reviewed-on: https://gerrit.libreoffice.org/41942
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx
index 0fcc0a48e2a2..0400713de02d 100644
--- a/sw/qa/extras/globalfilter/globalfilter.cxx
+++ b/sw/qa/extras/globalfilter/globalfilter.cxx
@@ -283,6 +283,29 @@ void Test::testImageWithSpecialID()
     }
 }
 
+/// Gives the first embedded or linked image in a document.
+uno::Reference<drawing::XShape> lcl_getShape(const uno::Reference<lang::XComponent>& xComponent, bool bEmbedded)
+{
+    uno::Reference<drawing::XShape> xRet;
+
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xComponent, uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+    for (sal_Int32 i = 0; i < xDrawPage->getCount(); ++i)
+    {
+        uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(i), uno::UNO_QUERY);
+        OUString sURL;
+        xShape->getPropertyValue("GraphicURL") >>= sURL;
+        // Linked image: working starts with file://, broken is e.g. 'vnd.sun.star.GraphicObject:3000000000000000000000000000000000000000'.
+        if ((sURL.startsWith("file://") || sURL.endsWith("0000000000000000")) != bEmbedded)
+        {
+            xRet.set(xShape, uno::UNO_QUERY);
+            break;
+        }
+    }
+
+    return xRet;
+}
+
 void Test::testGraphicShape()
 {
     // There are two kind of images in Writer: 1) Writer specific handled by SwGrfNode and
@@ -326,7 +349,7 @@ void Test::testGraphicShape()
         const OString sFailedMessage = OString("Failed on filter: ") + aFilterNames[nFilter];
         CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(2), xDraws->getCount());
 
-        uno::Reference<drawing::XShape> xImage = getShape(1);
+        uno::Reference<drawing::XShape> xImage = lcl_getShape(mxComponent, true);
         uno::Reference< beans::XPropertySet > XPropSet( xImage, uno::UNO_QUERY_THROW );
         // First image is embedded
         // Check URL
@@ -350,7 +373,7 @@ void Test::testGraphicShape()
             return;
 
         // Second image is a linked one
-        xImage = getShape(2);
+        xImage = lcl_getShape(mxComponent, false);
         XPropSet.set( xImage, uno::UNO_QUERY_THROW );
         // Check URL
         {
diff --git a/sw/qa/extras/rtfexport/data/tdf104936.rtf b/sw/qa/extras/rtfexport/data/tdf104936.rtf
new file mode 100644
index 000000000000..3f854b642500
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf104936.rtf
@@ -0,0 +1,20 @@
+{\rtf\ansi\ansicpg1251
+{\fonttbl
+{\f1\fcharset204 Arial}
+{\f2\fcharset204 Courier New}
+}
+{\colortbl;\red0\green0\blue0;}
+\viewkind1\paperw11340\paperh16840\margl0\margr0\margt460\margb1240
+\viewkind1\paperw11340\paperh16840\margl0\margr0\margt460\margb1240
+\viewkind1\paperw11340\paperh16840\margl0\margr0\margt460\margb1240
+\viewkind1\paperw11340\paperh16840\margl0\margr0\margt460\margb1240
+{\do\dobxpage\dobypage\dprect
+\dpx0\dpy450\dpxsize11160\dpysize1943
+\dpfillfgcr255\dpfillfgcg255\dpfillfgcb255
+\dpfillbgcr255\dpfillbgcg255\dpfillbgcb255\dpfillpat1
+\dplinew0 \dplinehollow
+}
+{\pard \qc \pvpg\phpg\posx2786\posy1218\absw1080 \absh-235
+{\f2\fs20 \cf1 \b Hello\par}
+}
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index db9ea695bb1d..1a4831f35b21 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -868,6 +868,17 @@ DECLARE_RTFEXPORT_TEST(testCjklist38, "cjklist38.rtf")
     CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_UPPER_ZH, numFormat);
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf104936, "tdf104936.rtf")
+{
+    uno::Reference<text::XTextRange> xShape1(getShape(1), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(xShape1, "ZOrder"));
+    // This failed, the shape without text covered the shape with text.
+    CPPUNIT_ASSERT(xShape1->getString().isEmpty());
+    uno::Reference<text::XTextRange> xShape2(getShape(2), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), getProperty<sal_Int32>(xShape2, "ZOrder"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Hello"), xShape2->getString());
+}
+
 DECLARE_RTFEXPORT_TEST(testTableRtl, "table-rtl.rtf")
 {
     uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 6352aeb63bbb..5aedd6721559 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -1863,6 +1863,14 @@ void RtfAttributeOutput::OutputFlyFrame_Impl(const ww8::Frame& rFrame, const Poi
 
         m_rExport.m_bOutFlyFrameAttrs = m_rExport.m_bRTFFlySyntax = true;
         m_rExport.OutputFormat(rFrame.GetFrameFormat(), false, false, true);
+
+        // Write ZOrder.
+        if (const SdrObject* pObject = rFrame.GetFrameFormat().FindRealSdrObject())
+        {
+            m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPZ);
+            m_rExport.OutULong(pObject->GetOrdNum());
+        }
+
         m_rExport.Strm().WriteCharPtr(m_aRunText.makeStringAndClear().getStr());
         m_rExport.Strm().WriteCharPtr(m_aStyles.makeStringAndClear().getStr());
         m_rExport.m_bOutFlyFrameAttrs = m_rExport.m_bRTFFlySyntax = false;
diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx
index beb8adc44cf6..cb5f2c1a90c5 100644
--- a/sw/source/filter/ww8/rtfsdrexport.cxx
+++ b/sw/source/filter/ww8/rtfsdrexport.cxx
@@ -508,6 +508,10 @@ sal_Int32 RtfSdrExport::StartShape()
     // Ignore \shpbypage, \shpbymargin, and \shpbycolumn, in favor of the posrelh property.
     m_rAttrOutput.RunText().append(OOO_STRING_SVTOOLS_RTF_SHPBYIGNORE);
 
+    // Write ZOrder.
+    m_rAttrOutput.RunText().append(OOO_STRING_SVTOOLS_RTF_SHPZ);
+    m_rAttrOutput.RunText().append(OString::number(m_pSdrObject->GetOrdNum()));
+
     for (auto it = m_aShapeProps.rbegin(); it != m_aShapeProps.rend(); ++it)
         lcl_AppendSP(m_rAttrOutput.RunText(), (*it).first.getStr(), (*it).second);
 


More information about the Libreoffice-commits mailing list