[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - oox/source sd/qa

Tamás Zolnai tamas.zolnai at collabora.com
Sat Dec 10 10:30:38 UTC 2016


 oox/source/drawingml/textbody.cxx   |    4 ++
 oox/source/ppt/pptshape.cxx         |    2 -
 sd/qa/unit/data/pptx/tdf104445.pptx |binary
 sd/qa/unit/import-tests.cxx         |   53 ++++++++++++++++++++++++++++++++++++
 4 files changed, 57 insertions(+), 2 deletions(-)

New commits:
commit f9e31fe677d863f84cd3afa025e45a77432b8886
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date:   Fri Dec 9 12:38:48 2016 +0000

    tdf#104445: PPTX import: Extra bullets are added to placeholder text
    
    Reviewed-on: https://gerrit.libreoffice.org/31771
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit cb598029835477326b190bc99abd31a487cc5a91)
    
    Change-Id: I25ce98ed391f70292bed6238645b121b9cf50d5e
    Reviewed-on: https://gerrit.libreoffice.org/31791
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>

diff --git a/oox/source/drawingml/textbody.cxx b/oox/source/drawingml/textbody.cxx
index 662a52f..8efb70d 100644
--- a/oox/source/drawingml/textbody.cxx
+++ b/oox/source/drawingml/textbody.cxx
@@ -23,6 +23,7 @@
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include "drawingml/textparagraph.hxx"
 #include "oox/helper/propertyset.hxx"
+#include <oox/token/properties.hxx>
 
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::text;
@@ -110,10 +111,11 @@ void TextBody::ApplyStyleEmpty(
     {
         Reference< XPropertySet > xProps(xText, UNO_QUERY);
         PropertyMap aioBulletList;
+        aioBulletList.setProperty< sal_Int32 >(PROP_LeftMargin, 0); // Init bullets left margin to 0 (no bullets).
         float nCharHeight = xProps->getPropertyValue("CharHeight").get<float>();
         TextParagraphProperties aParaProp;
         aParaProp.apply(*pTextParagraphStyle);
-        aParaProp.pushToPropSet(&rFilterBase, xProps, aioBulletList, &pTextParagraphStyle->getBulletList(), false, nCharHeight, true);
+        aParaProp.pushToPropSet(&rFilterBase, xProps, aioBulletList, &pTextParagraphStyle->getBulletList(), true, nCharHeight, true);
     }
 }
 
diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index f60f929..1460c70 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -351,7 +351,7 @@ void PPTShape::addShape(
             }
 
             // Apply text properties on placeholder text inside this placeholder shape
-            if (mpPlaceholder.get() != nullptr && getTextBody() && getTextBody()->isEmpty())
+            if (meShapeLocation == Slide && mpPlaceholder.get() != nullptr && getTextBody() && getTextBody()->isEmpty())
             {
                 Reference < XText > xText(mxShape, UNO_QUERY);
                 if (xText.is())
diff --git a/sd/qa/unit/data/pptx/tdf104445.pptx b/sd/qa/unit/data/pptx/tdf104445.pptx
new file mode 100755
index 0000000..bee32dc
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf104445.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 4a8da29..b639c19 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -63,6 +63,7 @@
 #include <com/sun/star/style/ParagraphAdjust.hpp>
 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
 #include <com/sun/star/table/XTableRows.hpp>
+#include <com/sun/star/style/NumberingType.hpp>
 
 #include <stlpool.hxx>
 #include <comphelper/processfactory.hxx>
@@ -127,6 +128,7 @@ public:
     void testTdf103876();
     void testTdf104015();
     void testTdf104201();
+    void testTdf104445();
 
     CPPUNIT_TEST_SUITE(SdImportTest);
 
@@ -182,6 +184,7 @@ public:
     CPPUNIT_TEST(testTdf103876);
     CPPUNIT_TEST(testTdf104015);
     CPPUNIT_TEST(testTdf104201);
+    CPPUNIT_TEST(testTdf104445);
 
     CPPUNIT_TEST_SUITE_END();
 };
@@ -1541,6 +1544,56 @@ void SdImportTest::testTdf104201()
     xDocShRef->DoClose();
 }
 
+void SdImportTest::testTdf104445()
+{
+    // Extra bullets were added to the first shape
+    sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf104445.pptx"), PPTX);
+
+    // First shape should not have bullet
+   {
+        uno::Reference< beans::XPropertySet > xShape(getShapeFromPage(0, 0, xDocShRef));
+        uno::Reference< text::XText > xText = uno::Reference< text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
+        CPPUNIT_ASSERT_MESSAGE("Not a text shape", xText.is());
+        uno::Reference< beans::XPropertySet > xPropSet(xText, uno::UNO_QUERY_THROW);
+
+        uno::Reference< container::XIndexAccess > xNumRule;
+        xPropSet->getPropertyValue("NumberingRules") >>= xNumRule;
+        uno::Sequence<beans::PropertyValue> aBulletProps;
+        xNumRule->getByIndex(0) >>= aBulletProps;
+
+        for (int i = 0; i < aBulletProps.getLength(); ++i)
+        {
+            const beans::PropertyValue& rProp = aBulletProps[i];
+            if(rProp.Name == "NumberingType")
+                CPPUNIT_ASSERT_EQUAL(sal_Int16(style::NumberingType::NUMBER_NONE), rProp.Value.get<sal_Int16>());
+            if(rProp.Name == "LeftMargin")
+                CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rProp.Value.get<sal_Int32>());
+        }
+    }
+    // Second shape should have bullet set
+    {
+        uno::Reference< beans::XPropertySet > xShape(getShapeFromPage(1, 0, xDocShRef));
+        uno::Reference< text::XText > xText = uno::Reference< text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
+        CPPUNIT_ASSERT_MESSAGE("Not a text shape", xText.is());
+        uno::Reference< beans::XPropertySet > xPropSet(xText, uno::UNO_QUERY_THROW);
+
+        uno::Reference< container::XIndexAccess > xNumRule;
+        xPropSet->getPropertyValue("NumberingRules") >>= xNumRule;
+        uno::Sequence<beans::PropertyValue> aBulletProps;
+        xNumRule->getByIndex(0) >>= aBulletProps;
+
+        for(int i = 0; i < aBulletProps.getLength(); ++i)
+        {
+            const beans::PropertyValue& rProp = aBulletProps[i];
+            if(rProp.Name == "NumberingType")
+                CPPUNIT_ASSERT_EQUAL(sal_Int16(style::NumberingType::CHAR_SPECIAL), rProp.Value.get<sal_Int16>());
+            if(rProp.Name == "LeftMargin")
+                CPPUNIT_ASSERT_EQUAL(sal_Int32(635), rProp.Value.get<sal_Int32>());
+        }
+    }
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


More information about the Libreoffice-commits mailing list