summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2016-11-15 23:18:03 +0100
committerAndras Timar <andras.timar@collabora.com>2016-11-26 20:33:54 +0000
commitf75d03bd90b27034a69c47f5413ec013dafc97c6 (patch)
treee1b41e141eab9cec714a57427881b807a74770e4 /oox
parent6c705826f506fe17b5191ee897b758843bcf5529 (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> (cherry picked from commit 5c7f3e4a7190bf9821bed102f96a926c9a894e59) Reviewed-on: https://gerrit.libreoffice.org/30940 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/drawingml/textbody.hxx8
-rw-r--r--oox/inc/drawingml/textparagraph.hxx7
-rw-r--r--oox/source/drawingml/textbody.cxx34
-rw-r--r--oox/source/drawingml/textparagraph.cxx51
-rw-r--r--oox/source/ppt/pptshape.cxx11
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 43bf51a363fa..2a4db6a1d8a7 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 985de13849e5..89e33781f3a7 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 ad02b2d672f3..f60f929a04cf 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -349,6 +349,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