Kaydet (Commit) 53551d49 authored tarafından Tamás Zolnai's avatar Tamás Zolnai

tdf#51340: Line spacing is imported incorrectly from PPTX

Move the line spacing member to the TextParagraphProperties class
which is used to do the inheritance from master / layout slides.

Change-Id: I0bf92420963163eae78e06ebc7fdfa1f2c72fdf8
Reviewed-on: https://gerrit.libreoffice.org/49692Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTamás Zolnai <tamas.zolnai@collabora.com>
üst d0aca687
...@@ -97,6 +97,9 @@ public: ...@@ -97,6 +97,9 @@ public:
boost::optional< css::style::ParagraphAdjust >& getParaAdjust() { return moParaAdjust; } boost::optional< css::style::ParagraphAdjust >& getParaAdjust() { return moParaAdjust; }
void setParaAdjust( css::style::ParagraphAdjust nParaAdjust ) { moParaAdjust = nParaAdjust; } void setParaAdjust( css::style::ParagraphAdjust nParaAdjust ) { moParaAdjust = nParaAdjust; }
TextSpacing& getLineSpacing() { return maLineSpacing; }
void setLineSpacing( const TextSpacing& rLineSpacing ) { maLineSpacing = rLineSpacing; }
void apply( const TextParagraphProperties& rSourceProps ); void apply( const TextParagraphProperties& rSourceProps );
void pushToPropSet( const ::oox::core::XmlFilterBase* pFilterBase, void pushToPropSet( const ::oox::core::XmlFilterBase* pFilterBase,
const css::uno::Reference < css::beans::XPropertySet > & xPropSet, const css::uno::Reference < css::beans::XPropertySet > & xPropSet,
...@@ -126,6 +129,7 @@ protected: ...@@ -126,6 +129,7 @@ protected:
boost::optional< sal_Int32 > moFirstLineIndentation; boost::optional< sal_Int32 > moFirstLineIndentation;
boost::optional< css::style::ParagraphAdjust > moParaAdjust; boost::optional< css::style::ParagraphAdjust > moParaAdjust;
sal_Int16 mnLevel; sal_Int16 mnLevel;
TextSpacing maLineSpacing;
}; };
} } } }
......
...@@ -42,7 +42,6 @@ public: ...@@ -42,7 +42,6 @@ public:
private: private:
TextParagraphProperties& mrTextParagraphProperties; TextParagraphProperties& mrTextParagraphProperties;
TextSpacing maLineSpacing;
BulletList& mrBulletList; BulletList& mrBulletList;
std::vector< css::style::TabStop > maTabList; std::vector< css::style::TabStop > maTabList;
std::shared_ptr< BlipFillProperties > mxBlipProps; std::shared_ptr< BlipFillProperties > mxBlipProps;
......
...@@ -388,6 +388,8 @@ void TextParagraphProperties::apply( const TextParagraphProperties& rSourceProps ...@@ -388,6 +388,8 @@ void TextParagraphProperties::apply( const TextParagraphProperties& rSourceProps
mnLevel = rSourceProps.mnLevel; mnLevel = rSourceProps.mnLevel;
if( rSourceProps.moParaAdjust ) if( rSourceProps.moParaAdjust )
moParaAdjust = rSourceProps.moParaAdjust; moParaAdjust = rSourceProps.moParaAdjust;
if( rSourceProps.maLineSpacing.bHasValue )
maLineSpacing = rSourceProps.maLineSpacing;
} }
void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* pFilterBase, void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* pFilterBase,
...@@ -486,6 +488,15 @@ void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* p ...@@ -486,6 +488,15 @@ void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* p
{ {
aPropSet.setProperty( PROP_ParaAdjust, css::style::ParagraphAdjust_LEFT); aPropSet.setProperty( PROP_ParaAdjust, css::style::ParagraphAdjust_LEFT);
} }
if ( maLineSpacing.bHasValue )
{
aPropSet.setProperty( PROP_ParaLineSpacing, maLineSpacing.toLineSpacing());
}
else
{
aPropSet.setProperty( PROP_ParaLineSpacing, css::style::LineSpacing( css::style::LineSpacingMode::PROP, 100 ));
}
} }
float TextParagraphProperties::getCharHeightPoints( float fDefault ) const float TextParagraphProperties::getCharHeightPoints( float fDefault ) const
......
...@@ -133,8 +133,8 @@ TextParagraphPropertiesContext::TextParagraphPropertiesContext( ContextHandler2H ...@@ -133,8 +133,8 @@ TextParagraphPropertiesContext::TextParagraphPropertiesContext( ContextHandler2H
TextParagraphPropertiesContext::~TextParagraphPropertiesContext() TextParagraphPropertiesContext::~TextParagraphPropertiesContext()
{ {
PropertyMap& rPropertyMap( mrTextParagraphProperties.getTextParagraphPropertyMap() ); PropertyMap& rPropertyMap( mrTextParagraphProperties.getTextParagraphPropertyMap() );
if ( maLineSpacing.bHasValue ) if ( mrTextParagraphProperties.getLineSpacing().bHasValue )
rPropertyMap.setProperty( PROP_ParaLineSpacing, maLineSpacing.toLineSpacing()); rPropertyMap.setProperty( PROP_ParaLineSpacing, mrTextParagraphProperties.getLineSpacing().toLineSpacing());
else else
rPropertyMap.setProperty( PROP_ParaLineSpacing, css::style::LineSpacing( css::style::LineSpacingMode::PROP, 100 )); rPropertyMap.setProperty( PROP_ParaLineSpacing, css::style::LineSpacing( css::style::LineSpacingMode::PROP, 100 ));
...@@ -166,7 +166,7 @@ ContextHandlerRef TextParagraphPropertiesContext::onCreateContext( sal_Int32 aEl ...@@ -166,7 +166,7 @@ ContextHandlerRef TextParagraphPropertiesContext::onCreateContext( sal_Int32 aEl
switch( aElementToken ) switch( aElementToken )
{ {
case A_TOKEN( lnSpc ): // CT_TextSpacing case A_TOKEN( lnSpc ): // CT_TextSpacing
return new TextSpacingContext( *this, maLineSpacing ); return new TextSpacingContext( *this, mrTextParagraphProperties.getLineSpacing() );
case A_TOKEN( spcBef ): // CT_TextSpacing case A_TOKEN( spcBef ): // CT_TextSpacing
return new TextSpacingContext( *this, mrTextParagraphProperties.getParaTopMargin() ); return new TextSpacingContext( *this, mrTextParagraphProperties.getParaTopMargin() );
case A_TOKEN( spcAft ): // CT_TextSpacing case A_TOKEN( spcAft ): // CT_TextSpacing
...@@ -315,17 +315,18 @@ ContextHandlerRef TextParagraphPropertiesContext::onCreateContext( sal_Int32 aEl ...@@ -315,17 +315,18 @@ ContextHandlerRef TextParagraphPropertiesContext::onCreateContext( sal_Int32 aEl
OptValue<sal_Int32> oLineSpacing = rAttribs.getInteger(W_TOKEN(line)); OptValue<sal_Int32> oLineSpacing = rAttribs.getInteger(W_TOKEN(line));
if (oLineSpacing.has()) if (oLineSpacing.has())
{ {
TextSpacing& rLineSpacing = mrTextParagraphProperties.getLineSpacing();
if( !oLineRule.has() || oLineRule.get() == "auto" ) if( !oLineRule.has() || oLineRule.get() == "auto" )
{ {
maLineSpacing.nUnit = TextSpacing::Unit::Percent; rLineSpacing.nUnit = TextSpacing::Unit::Percent;
maLineSpacing.nValue = oLineSpacing.get() * MAX_PERCENT / 240; rLineSpacing.nValue = oLineSpacing.get() * MAX_PERCENT / 240;
} }
else else
{ {
maLineSpacing.nUnit = TextSpacing::Unit::Points; rLineSpacing.nUnit = TextSpacing::Unit::Points;
maLineSpacing.nValue = TWIPS_TO_MM(oLineSpacing.get()); rLineSpacing.nValue = TWIPS_TO_MM(oLineSpacing.get());
} }
maLineSpacing.bHasValue = true; rLineSpacing.bHasValue = true;
} }
} }
break; break;
......
...@@ -68,6 +68,8 @@ ...@@ -68,6 +68,8 @@
#include <com/sun/star/table/BorderLineStyle.hpp> #include <com/sun/star/table/BorderLineStyle.hpp>
#include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/table/BorderLine2.hpp>
#include <com/sun/star/style/ParagraphAdjust.hpp> #include <com/sun/star/style/ParagraphAdjust.hpp>
#include <com/sun/star/style/LineSpacing.hpp>
#include <com/sun/star/style/LineSpacingMode.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/table/XTableRows.hpp> #include <com/sun/star/table/XTableRows.hpp>
#include <com/sun/star/style/NumberingType.hpp> #include <com/sun/star/style/NumberingType.hpp>
...@@ -176,6 +178,7 @@ public: ...@@ -176,6 +178,7 @@ public:
void testTdf114821(); void testTdf114821();
void testTdf115394(); void testTdf115394();
void testTdf115394PPT(); void testTdf115394PPT();
void testTdf51340();
bool checkPattern(sd::DrawDocShellRef const & rDocRef, int nShapeNumber, std::vector<sal_uInt8>& rExpected); bool checkPattern(sd::DrawDocShellRef const & rDocRef, int nShapeNumber, std::vector<sal_uInt8>& rExpected);
void testPatternImport(); void testPatternImport();
...@@ -255,6 +258,7 @@ public: ...@@ -255,6 +258,7 @@ public:
CPPUNIT_TEST(testTdf114821); CPPUNIT_TEST(testTdf114821);
CPPUNIT_TEST(testTdf115394); CPPUNIT_TEST(testTdf115394);
CPPUNIT_TEST(testTdf115394PPT); CPPUNIT_TEST(testTdf115394PPT);
CPPUNIT_TEST(testTdf51340);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
}; };
...@@ -2439,6 +2443,44 @@ void SdImportTest::testTdf115394PPT() ...@@ -2439,6 +2443,44 @@ void SdImportTest::testTdf115394PPT()
xDocShRef->DoClose(); xDocShRef->DoClose();
} }
void SdImportTest::testTdf51340()
{
// Line spacing was not inherited from upper levels (slide layout, master slide)
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf51340.pptx"), PPTX);
uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 1, 0, xDocShRef ) );
// First paragraph has a 90% line spacing set on master slide
uno::Reference<text::XTextRange> xParagraph( getParagraphFromShape( 0, xShape ) );
uno::Reference< beans::XPropertySet > xPropSet( xParagraph, uno::UNO_QUERY_THROW );
css::style::LineSpacing aSpacing;
xPropSet->getPropertyValue( "ParaLineSpacing" ) >>= aSpacing;
CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(css::style::LineSpacingMode::PROP), aSpacing.Mode );
CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(90), aSpacing.Height );
// Second paragraph has a 125% line spacing set on slide layout
xParagraph.set( getParagraphFromShape( 1, xShape ) );
xPropSet.set( xParagraph, uno::UNO_QUERY_THROW );
xPropSet->getPropertyValue( "ParaLineSpacing" ) >>= aSpacing;
CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(css::style::LineSpacingMode::PROP), aSpacing.Mode );
CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(125), aSpacing.Height );
// Third paragraph has a 70% line spacing set directly on normal slide (master slide property ir overriden)
xParagraph.set( getParagraphFromShape( 2, xShape ) );
xPropSet.set( xParagraph, uno::UNO_QUERY_THROW );
xPropSet->getPropertyValue( "ParaLineSpacing" ) >>= aSpacing;
CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(css::style::LineSpacingMode::PROP), aSpacing.Mode );
CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(70), aSpacing.Height );
// Fourth paragraph has a 190% line spacing set directly on normal slide (slide layout property is overriden)
xParagraph.set( getParagraphFromShape( 3, xShape ) );
xPropSet.set( xParagraph, uno::UNO_QUERY_THROW );
xPropSet->getPropertyValue( "ParaLineSpacing" ) >>= aSpacing;
CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(css::style::LineSpacingMode::PROP), aSpacing.Mode );
CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(190), aSpacing.Height );
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