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 50c9a8bf7473bf369ccd7e3060ef732ac6cf58f5 Author: Zolnai Tamás <tamas.zol...@collabora.com> Date: Mon Dec 22 18:30:43 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/13607 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> diff --git a/oox/source/drawingml/textparagraphproperties.cxx b/oox/source/drawingml/textparagraphproperties.cxx index 76e1622..1e26066 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 "oox/helper/helper.hxx" #include "oox/helper/propertyset.hxx" @@ -380,6 +381,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, @@ -477,6 +480,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 e592841..390cb16 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 e5ab540..4ff2da3 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 <config_features.h> @@ -98,6 +99,7 @@ public: void testBnc904423(); void testShapeLineStyle(); void testBnc862510_6(); + void testBnc862510_7(); #if !defined WNT void testBnc822341(); #endif @@ -137,6 +139,7 @@ public: CPPUNIT_TEST(testBnc904423); CPPUNIT_TEST(testShapeLineStyle); CPPUNIT_TEST(testBnc862510_6); + CPPUNIT_TEST(testBnc862510_7); #if !defined WNT CPPUNIT_TEST(testBnc822341); #endif @@ -1291,6 +1294,38 @@ void SdFiltersTest::testBnc862510_6() xDocShRef->DoClose(); } +void SdFiltersTest::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")); + + 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(); +} + #if !defined WNT void SdFiltersTest::testBnc822341()
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits