diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2016-11-15 23:18:03 +0100 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2016-11-17 18:01:13 +0000 |
commit | 5c7f3e4a7190bf9821bed102f96a926c9a894e59 (patch) | |
tree | 47427568c32998a130c012870f14be00591c828d /oox | |
parent | 6b35e804198ac45386805e80a3d413ed3405c3b4 (diff) |
tdf#103876: PPTX import: Title shape's character properties are wrong
Text properties are applied on a shape during text insertion,
but if a placeholder shape has no text, then it has a placehodler
text which should have the right text properties.
Change-Id: I54175d52dd25915ee4d7153298e01ec07c6be1f6
Reviewed-on: https://gerrit.libreoffice.org/30881
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/inc/drawingml/textbody.hxx | 8 | ||||
-rw-r--r-- | oox/inc/drawingml/textparagraph.hxx | 7 | ||||
-rw-r--r-- | oox/source/drawingml/textbody.cxx | 34 | ||||
-rw-r--r-- | oox/source/drawingml/textparagraph.cxx | 51 | ||||
-rw-r--r-- | oox/source/ppt/pptshape.cxx | 11 |
5 files changed, 92 insertions, 19 deletions
diff --git a/oox/inc/drawingml/textbody.hxx b/oox/inc/drawingml/textbody.hxx index 5f8b053cc8a8..043529723e76 100644 --- a/oox/inc/drawingml/textbody.hxx +++ b/oox/inc/drawingml/textbody.hxx @@ -59,7 +59,13 @@ public: const css::uno::Reference < css::text::XTextCursor > & xAt, const TextCharacterProperties& rTextStyleProperties, const TextListStylePtr& pMasterTextListStyle ) const; - bool isEmpty(); + bool isEmpty() const; + + void ApplyStyleEmpty( + const ::oox::core::XmlFilterBase& rFilterBase, + const css::uno::Reference < css::text::XText > & xText, + const TextCharacterProperties& rTextStyleProperties, + const TextListStylePtr& pMasterTextListStylePtr) const; protected: TextParagraphVector maParagraphs; TextBodyProperties maTextProperties; diff --git a/oox/inc/drawingml/textparagraph.hxx b/oox/inc/drawingml/textparagraph.hxx index 8a02a671a5b0..337d50718ad8 100644 --- a/oox/inc/drawingml/textparagraph.hxx +++ b/oox/inc/drawingml/textparagraph.hxx @@ -53,6 +53,13 @@ public: TextCharacterProperties& getEndProperties() { return maEndProperties; } const TextCharacterProperties& getEndProperties() const { return maEndProperties; } + TextCharacterProperties getCharacterStyle( + const TextCharacterProperties& rTextStyleProperties, + const TextListStyle& rTextListStyle) const; + + TextParagraphPropertiesPtr getParagraphStyle( + const TextListStyle& rTextListStyle) const; + void insertAt( const ::oox::core::XmlFilterBase& rFilterBase, const css::uno::Reference < css::text::XText > & xText, diff --git a/oox/source/drawingml/textbody.cxx b/oox/source/drawingml/textbody.cxx index 3aa835e6c047..662a52fd0113 100644 --- a/oox/source/drawingml/textbody.cxx +++ b/oox/source/drawingml/textbody.cxx @@ -22,9 +22,11 @@ #include <com/sun/star/text/XTextCursor.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include "drawingml/textparagraph.hxx" +#include "oox/helper/propertyset.hxx" using namespace ::com::sun::star::uno; using namespace ::com::sun::star::text; +using namespace ::com::sun::star::beans; using namespace ::com::sun::star::frame; namespace oox { namespace drawingml { @@ -69,7 +71,7 @@ void TextBody::insertAt( (*aIt)->insertAt( rFilterBase, xText, xAt, rTextStyleProperties, aCombinedTextStyle, aIt == aBeg, nCharHeight ); } -bool TextBody::isEmpty() +bool TextBody::isEmpty() const { if ( maParagraphs.size() <= 0 ) return true; @@ -85,6 +87,36 @@ bool TextBody::isEmpty() return aRuns[0]->getText().getLength() <= 0; } +void TextBody::ApplyStyleEmpty( + const ::oox::core::XmlFilterBase& rFilterBase, + const Reference < XText > & xText, + const TextCharacterProperties& rTextStyleProperties, + const TextListStylePtr& pMasterTextListStylePtr) const +{ + assert(isEmpty()); + + // Apply character properties + TextListStyle aCombinedTextStyle; + aCombinedTextStyle.apply( *pMasterTextListStylePtr ); + aCombinedTextStyle.apply( maTextListStyle ); + + PropertySet aPropSet(xText); + TextCharacterProperties aTextCharacterProps(maParagraphs[0]->getCharacterStyle(rTextStyleProperties, aCombinedTextStyle)); + aTextCharacterProps.pushToPropSet(aPropSet, rFilterBase); + + // Apply paragraph properties + TextParagraphPropertiesPtr pTextParagraphStyle = maParagraphs[0]->getParagraphStyle(aCombinedTextStyle); + if (pTextParagraphStyle.get()) + { + Reference< XPropertySet > xProps(xText, UNO_QUERY); + PropertyMap aioBulletList; + float nCharHeight = xProps->getPropertyValue("CharHeight").get<float>(); + TextParagraphProperties aParaProp; + aParaProp.apply(*pTextParagraphStyle); + aParaProp.pushToPropSet(&rFilterBase, xProps, aioBulletList, &pTextParagraphStyle->getBulletList(), false, nCharHeight, true); + } +} + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/textparagraph.cxx b/oox/source/drawingml/textparagraph.cxx index 24879f194009..444832be7592 100644 --- a/oox/source/drawingml/textparagraph.cxx +++ b/oox/source/drawingml/textparagraph.cxx @@ -44,6 +44,37 @@ TextParagraph::~TextParagraph() { } +TextCharacterProperties TextParagraph::getCharacterStyle ( + const TextCharacterProperties& rTextStyleProperties, + const TextListStyle& rTextListStyle) const +{ + TextParagraphPropertiesPtr pTextParagraphStyle = getParagraphStyle(rTextListStyle); + + TextCharacterProperties aTextCharacterStyle; + if (pTextParagraphStyle.get()) + aTextCharacterStyle.assignUsed(pTextParagraphStyle->getTextCharacterProperties()); + aTextCharacterStyle.assignUsed(rTextStyleProperties); + aTextCharacterStyle.assignUsed(maProperties.getTextCharacterProperties()); + return aTextCharacterStyle; +} + +TextParagraphPropertiesPtr TextParagraph::getParagraphStyle( + const TextListStyle& rTextListStyle) const +{ + sal_Int16 nLevel = maProperties.getLevel(); + + SAL_INFO("oox", "TextParagraph::getParagraphStyle - level " << nLevel); + + const TextParagraphPropertiesVector& rListStyle = rTextListStyle.getListStyle(); + if (nLevel >= static_cast< sal_Int16 >(rListStyle.size())) + nLevel = 0; + TextParagraphPropertiesPtr pTextParagraphStyle = nullptr; + if (rListStyle.size()) + pTextParagraphStyle = rListStyle[nLevel]; + + return pTextParagraphStyle; +} + void TextParagraph::insertAt( const ::oox::core::XmlFilterBase& rFilterBase, const Reference < XText > &xText, @@ -53,23 +84,7 @@ void TextParagraph::insertAt( { try { sal_Int32 nParagraphSize = 0; - - sal_Int16 nLevel = maProperties.getLevel(); - - SAL_INFO("oox", "TextParagraph::insertAt() - level " << nLevel); - - const TextParagraphPropertiesVector& rListStyle = rTextListStyle.getListStyle(); - if ( nLevel >= static_cast< sal_Int16 >( rListStyle.size() ) ) - nLevel = 0; - TextParagraphPropertiesPtr pTextParagraphStyle; - if ( rListStyle.size() ) - pTextParagraphStyle = rListStyle[ nLevel ]; - - TextCharacterProperties aTextCharacterStyle; - if ( pTextParagraphStyle.get() ) - aTextCharacterStyle.assignUsed( pTextParagraphStyle->getTextCharacterProperties() ); - aTextCharacterStyle.assignUsed( rTextStyleProperties ); - aTextCharacterStyle.assignUsed( maProperties.getTextCharacterProperties() ); + TextCharacterProperties aTextCharacterStyle = getCharacterStyle(rTextStyleProperties, rTextListStyle); if( !bFirst ) { @@ -105,6 +120,8 @@ void TextParagraph::insertAt( PropertyMap aioBulletList; Reference< XPropertySet > xProps( xAt, UNO_QUERY); + + TextParagraphPropertiesPtr pTextParagraphStyle = getParagraphStyle(rTextListStyle); if ( pTextParagraphStyle.get() ) { TextParagraphProperties aParaProp; diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx index 18a256595ae8..08e2df86150c 100644 --- a/oox/source/ppt/pptshape.cxx +++ b/oox/source/ppt/pptshape.cxx @@ -350,6 +350,17 @@ void PPTShape::addShape( } } + + // Apply text properties on placeholder text inside this placeholder shape + if (mpPlaceholder.get() != nullptr && getTextBody() && getTextBody()->isEmpty()) + { + Reference < XText > xText(mxShape, UNO_QUERY); + if (xText.is()) + { + TextCharacterProperties aCharStyleProperties; + getTextBody()->ApplyStyleEmpty(rFilterBase, xText, aCharStyleProperties, mpMasterTextListStyle); + } + } if (pShapeMap) { // bnc#705982 - if optional model id reference is |