Kaydet (Commit) 7a64988d authored tarafından Zolnai Tamás's avatar Zolnai Tamás

bnc#862510: PPTX import: Wrong text vertical 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.

Change-Id: Ic294c5d7cc477f7515aea1c071ad9b67275c012d
üst 89206c47
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/style/TabStop.hpp> #include <com/sun/star/style/TabStop.hpp>
#include <com/sun/star/text/PositionAndSpaceMode.hpp> #include <com/sun/star/text/PositionAndSpaceMode.hpp>
#include <com/sun/star/style/ParagraphAdjust.hpp>
#include <osl/diagnose.h> #include <osl/diagnose.h>
...@@ -381,6 +382,8 @@ void TextParagraphProperties::apply( const TextParagraphProperties& rSourceProps ...@@ -381,6 +382,8 @@ void TextParagraphProperties::apply( const TextParagraphProperties& rSourceProps
moFirstLineIndentation = rSourceProps.moFirstLineIndentation; moFirstLineIndentation = rSourceProps.moFirstLineIndentation;
if( rSourceProps.mnLevel ) if( rSourceProps.mnLevel )
mnLevel = rSourceProps.mnLevel; mnLevel = rSourceProps.mnLevel;
if( rSourceProps.moParaAdjust )
moParaAdjust = rSourceProps.moParaAdjust;
} }
void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* pFilterBase, void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* pFilterBase,
...@@ -478,6 +481,15 @@ void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* p ...@@ -478,6 +481,15 @@ void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* p
aPropSet.setProperty( PROP_ParaTabStops, aSeq ); 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 float TextParagraphProperties::getCharHeightPoints( float fDefault ) const
......
...@@ -54,7 +54,10 @@ TextParagraphPropertiesContext::TextParagraphPropertiesContext( ContextHandler2H ...@@ -54,7 +54,10 @@ TextParagraphPropertiesContext::TextParagraphPropertiesContext( ContextHandler2H
PropertyMap& rPropertyMap( mrTextParagraphProperties.getTextParagraphPropertyMap() ); PropertyMap& rPropertyMap( mrTextParagraphProperties.getTextParagraphPropertyMap() );
// ST_TextAlignType // 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 // TODO see to do the same with RubyAdjust
// ST_Coordinate32 // ST_Coordinate32
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#include <com/sun/star/chart2/data/XDataSequence.hpp> #include <com/sun/star/chart2/data/XDataSequence.hpp>
#include <com/sun/star/chart2/data/XNumericalDataSequence.hpp> #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
#include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/table/BorderLine2.hpp>
#include <com/sun/star/style/ParagraphAdjust.hpp>
#include <stlpool.hxx> #include <stlpool.hxx>
...@@ -90,6 +91,7 @@ public: ...@@ -90,6 +91,7 @@ public:
void testBnc904423(); void testBnc904423();
void testShapeLineStyle(); void testShapeLineStyle();
void testBnc862510_6(); void testBnc862510_6();
void testBnc862510_7();
CPPUNIT_TEST_SUITE(SdImportTest); CPPUNIT_TEST_SUITE(SdImportTest);
CPPUNIT_TEST(testDocumentLayout); CPPUNIT_TEST(testDocumentLayout);
...@@ -120,6 +122,7 @@ public: ...@@ -120,6 +122,7 @@ public:
CPPUNIT_TEST(testBnc904423); CPPUNIT_TEST(testBnc904423);
CPPUNIT_TEST(testShapeLineStyle); CPPUNIT_TEST(testShapeLineStyle);
CPPUNIT_TEST(testBnc862510_6); CPPUNIT_TEST(testBnc862510_6);
CPPUNIT_TEST(testBnc862510_7);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
}; };
...@@ -1033,6 +1036,38 @@ void SdImportTest::testBnc862510_6() ...@@ -1033,6 +1036,38 @@ void SdImportTest::testBnc862510_6()
xDocShRef->DoClose(); 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_TEST_SUITE_REGISTRATION(SdImportTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment