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

Zolnai Tamás tamas.zolnai at collabora.com
Mon Jan 5 08:17:33 PST 2015


 oox/source/drawingml/textparagraphproperties.cxx        |   12 +++++
 oox/source/drawingml/textparagraphpropertiescontext.cxx |    5 +-
 sd/qa/unit/data/pptx/bnc862510_7.pptx                   |binary
 sd/qa/unit/import-tests.cxx                             |   35 ++++++++++++++++
 4 files changed, 51 insertions(+), 1 deletion(-)

New commits:
commit 5f2ceec031f06cf0b2756c8c699585e28ea1fcb8
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Mon Dec 22 18:29:36 2014 +0100

    bnc#862510: PPTX import: Wrong text horizontal adjustment inside shape.
    
    When alignment is not specified, it should be set to the
    default "left" value just on time, when properties are
    pushed to the property set, otherwise uninitialized value
    is better.
    
    (cherry picked from commit 7a64988dbc7a1542aa38f0e8f9a8a47941fbc67d)
    
    Conflicts:
    	sd/qa/unit/import-tests.cxx
    
    Conflicts:
    	sd/qa/unit/import-tests.cxx
    
    Change-Id: Ic294c5d7cc477f7515aea1c071ad9b67275c012d
    Reviewed-on: https://gerrit.libreoffice.org/13604
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/oox/source/drawingml/textparagraphproperties.cxx b/oox/source/drawingml/textparagraphproperties.cxx
index 22bab14..a4797f3 100644
--- a/oox/source/drawingml/textparagraphproperties.cxx
+++ b/oox/source/drawingml/textparagraphproperties.cxx
@@ -28,6 +28,7 @@
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/style/TabStop.hpp>
 #include <com/sun/star/text/PositionAndSpaceMode.hpp>
+#include <com/sun/star/style/ParagraphAdjust.hpp>
 
 #include <osl/diagnose.h>
 
@@ -381,6 +382,8 @@ void TextParagraphProperties::apply( const TextParagraphProperties& rSourceProps
         moFirstLineIndentation = rSourceProps.moFirstLineIndentation;
     if( rSourceProps.mnLevel )
         mnLevel = rSourceProps.mnLevel;
+    if( rSourceProps.moParaAdjust )
+        moParaAdjust = rSourceProps.moParaAdjust;
 }
 
 void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* pFilterBase,
@@ -478,6 +481,15 @@ void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* p
             aPropSet.setProperty( PROP_ParaTabStops, aSeq );
         }
     }
+
+    if ( moParaAdjust )
+    {
+        aPropSet.setProperty( PROP_ParaAdjust, moParaAdjust.get());
+    }
+    else
+    {
+        aPropSet.setProperty( PROP_ParaAdjust, com::sun::star::style::ParagraphAdjust_LEFT);
+    }
 }
 
 float TextParagraphProperties::getCharHeightPoints( float fDefault ) const
diff --git a/oox/source/drawingml/textparagraphpropertiescontext.cxx b/oox/source/drawingml/textparagraphpropertiescontext.cxx
index 6d51ee5..06c6625 100644
--- a/oox/source/drawingml/textparagraphpropertiescontext.cxx
+++ b/oox/source/drawingml/textparagraphpropertiescontext.cxx
@@ -54,7 +54,10 @@ TextParagraphPropertiesContext::TextParagraphPropertiesContext( ContextHandler2H
     PropertyMap& rPropertyMap( mrTextParagraphProperties.getTextParagraphPropertyMap() );
 
     // ST_TextAlignType
-    rPropertyMap.setProperty( PROP_ParaAdjust, GetParaAdjust( rAttribs.getToken( XML_algn, XML_l ) ));
+    if ( rAttribs.hasAttribute( XML_algn ) )
+    {
+        mrTextParagraphProperties.getParaAdjust() = GetParaAdjust( rAttribs.getToken( XML_algn, XML_l ) );
+    }
     // TODO see to do the same with RubyAdjust
 
     // ST_Coordinate32
diff --git a/sd/qa/unit/data/pptx/bnc862510_7.pptx b/sd/qa/unit/data/pptx/bnc862510_7.pptx
new file mode 100644
index 0000000..0eb3bbe
Binary files /dev/null and b/sd/qa/unit/data/pptx/bnc862510_7.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 439f153..acb2bb6 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -53,6 +53,7 @@
 #include <com/sun/star/chart2/data/XDataSequence.hpp>
 #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
 #include <com/sun/star/table/BorderLine2.hpp>
+#include <com/sun/star/style/ParagraphAdjust.hpp>
 
 #include <stlpool.hxx>
 
@@ -90,6 +91,7 @@ public:
     void testBnc904423();
     void testShapeLineStyle();
     void testBnc862510_6();
+    void testBnc862510_7();
 
     CPPUNIT_TEST_SUITE(SdImportTest);
     CPPUNIT_TEST(testDocumentLayout);
@@ -120,6 +122,7 @@ public:
     CPPUNIT_TEST(testBnc904423);
     CPPUNIT_TEST(testShapeLineStyle);
     CPPUNIT_TEST(testBnc862510_6);
+    CPPUNIT_TEST(testBnc862510_7);
 
     CPPUNIT_TEST_SUITE_END();
 };
@@ -1033,6 +1036,38 @@ void SdImportTest::testBnc862510_6()
     xDocShRef->DoClose();
 }
 
+void SdImportTest::testBnc862510_7()
+{
+    // Title shape's text was aligned to left instead of center.
+    ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc862510_7.pptx"), PPTX);
+
+    uno::Reference< drawing::XDrawPagesSupplier > xDoc(
+        xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
+
+    uno::Reference< drawing::XDrawPage > xPage(
+        xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
+
+    uno::Reference< beans::XPropertySet > xShape(
+        xPage->getByIndex(0), uno::UNO_QUERY );
+    CPPUNIT_ASSERT_MESSAGE( "no shape", xShape.is() );
+
+    // Get first paragraph
+    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<container::XEnumerationAccess> paraEnumAccess;
+    paraEnumAccess.set(xText, uno::UNO_QUERY);
+    uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
+    uno::Reference<text::XTextRange> const xParagraph(paraEnum->nextElement(),
+                uno::UNO_QUERY_THROW);
+    uno::Reference< beans::XPropertySet > xPropSet( xParagraph, uno::UNO_QUERY_THROW );
+
+    sal_Int16 nParaAdjust = 0;
+    xPropSet->getPropertyValue( "ParaAdjust" ) >>= nParaAdjust;
+    CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(nParaAdjust));
+
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


More information about the Libreoffice-commits mailing list