From 53551d49d3be2301985f2cf2d8bb23ff374ecfd1 Mon Sep 17 00:00:00 2001 From: Tamás Zolnai Date: Wed, 14 Feb 2018 02:15:54 +0100 Subject: tdf#51340: Line spacing is imported incorrectly from PPTX MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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/49692 Tested-by: Jenkins Reviewed-by: Tamás Zolnai --- oox/inc/drawingml/textparagraphproperties.hxx | 4 ++++ oox/inc/drawingml/textparagraphpropertiescontext.hxx | 1 - oox/source/drawingml/textparagraphproperties.cxx | 11 +++++++++++ oox/source/drawingml/textparagraphpropertiescontext.cxx | 17 +++++++++-------- 4 files changed, 24 insertions(+), 9 deletions(-) (limited to 'oox') diff --git a/oox/inc/drawingml/textparagraphproperties.hxx b/oox/inc/drawingml/textparagraphproperties.hxx index cac6d64f0447..2710dcb484b2 100644 --- a/oox/inc/drawingml/textparagraphproperties.hxx +++ b/oox/inc/drawingml/textparagraphproperties.hxx @@ -97,6 +97,9 @@ public: boost::optional< css::style::ParagraphAdjust >& getParaAdjust() { return moParaAdjust; } 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 pushToPropSet( const ::oox::core::XmlFilterBase* pFilterBase, const css::uno::Reference < css::beans::XPropertySet > & xPropSet, @@ -126,6 +129,7 @@ protected: boost::optional< sal_Int32 > moFirstLineIndentation; boost::optional< css::style::ParagraphAdjust > moParaAdjust; sal_Int16 mnLevel; + TextSpacing maLineSpacing; }; } } diff --git a/oox/inc/drawingml/textparagraphpropertiescontext.hxx b/oox/inc/drawingml/textparagraphpropertiescontext.hxx index 2de92b5b05ab..3cd2d0d375b4 100644 --- a/oox/inc/drawingml/textparagraphpropertiescontext.hxx +++ b/oox/inc/drawingml/textparagraphpropertiescontext.hxx @@ -42,7 +42,6 @@ public: private: TextParagraphProperties& mrTextParagraphProperties; - TextSpacing maLineSpacing; BulletList& mrBulletList; std::vector< css::style::TabStop > maTabList; std::shared_ptr< BlipFillProperties > mxBlipProps; diff --git a/oox/source/drawingml/textparagraphproperties.cxx b/oox/source/drawingml/textparagraphproperties.cxx index c36912bb9dca..8f4e635db48c 100644 --- a/oox/source/drawingml/textparagraphproperties.cxx +++ b/oox/source/drawingml/textparagraphproperties.cxx @@ -388,6 +388,8 @@ void TextParagraphProperties::apply( const TextParagraphProperties& rSourceProps mnLevel = rSourceProps.mnLevel; if( rSourceProps.moParaAdjust ) moParaAdjust = rSourceProps.moParaAdjust; + if( rSourceProps.maLineSpacing.bHasValue ) + maLineSpacing = rSourceProps.maLineSpacing; } void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* pFilterBase, @@ -486,6 +488,15 @@ void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* p { 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 diff --git a/oox/source/drawingml/textparagraphpropertiescontext.cxx b/oox/source/drawingml/textparagraphpropertiescontext.cxx index fdc9c3f210a9..5cf1750dec4e 100644 --- a/oox/source/drawingml/textparagraphpropertiescontext.cxx +++ b/oox/source/drawingml/textparagraphpropertiescontext.cxx @@ -133,8 +133,8 @@ TextParagraphPropertiesContext::TextParagraphPropertiesContext( ContextHandler2H TextParagraphPropertiesContext::~TextParagraphPropertiesContext() { PropertyMap& rPropertyMap( mrTextParagraphProperties.getTextParagraphPropertyMap() ); - if ( maLineSpacing.bHasValue ) - rPropertyMap.setProperty( PROP_ParaLineSpacing, maLineSpacing.toLineSpacing()); + if ( mrTextParagraphProperties.getLineSpacing().bHasValue ) + rPropertyMap.setProperty( PROP_ParaLineSpacing, mrTextParagraphProperties.getLineSpacing().toLineSpacing()); else rPropertyMap.setProperty( PROP_ParaLineSpacing, css::style::LineSpacing( css::style::LineSpacingMode::PROP, 100 )); @@ -166,7 +166,7 @@ ContextHandlerRef TextParagraphPropertiesContext::onCreateContext( sal_Int32 aEl switch( aElementToken ) { case A_TOKEN( lnSpc ): // CT_TextSpacing - return new TextSpacingContext( *this, maLineSpacing ); + return new TextSpacingContext( *this, mrTextParagraphProperties.getLineSpacing() ); case A_TOKEN( spcBef ): // CT_TextSpacing return new TextSpacingContext( *this, mrTextParagraphProperties.getParaTopMargin() ); case A_TOKEN( spcAft ): // CT_TextSpacing @@ -315,17 +315,18 @@ ContextHandlerRef TextParagraphPropertiesContext::onCreateContext( sal_Int32 aEl OptValue oLineSpacing = rAttribs.getInteger(W_TOKEN(line)); if (oLineSpacing.has()) { + TextSpacing& rLineSpacing = mrTextParagraphProperties.getLineSpacing(); if( !oLineRule.has() || oLineRule.get() == "auto" ) { - maLineSpacing.nUnit = TextSpacing::Unit::Percent; - maLineSpacing.nValue = oLineSpacing.get() * MAX_PERCENT / 240; + rLineSpacing.nUnit = TextSpacing::Unit::Percent; + rLineSpacing.nValue = oLineSpacing.get() * MAX_PERCENT / 240; } else { - maLineSpacing.nUnit = TextSpacing::Unit::Points; - maLineSpacing.nValue = TWIPS_TO_MM(oLineSpacing.get()); + rLineSpacing.nUnit = TextSpacing::Unit::Points; + rLineSpacing.nValue = TWIPS_TO_MM(oLineSpacing.get()); } - maLineSpacing.bHasValue = true; + rLineSpacing.bHasValue = true; } } break; -- cgit