summaryrefslogtreecommitdiff
path: root/oox/source
diff options
context:
space:
mode:
authorSarper Akdemir <sarper.akdemir@collabora.com>2022-10-24 01:50:36 +0300
committerMiklos Vajna <vmiklos@collabora.com>2022-10-27 15:13:32 +0200
commit08d0c2cd6b6bdf37d6fc5c16359bafc6dddc9d09 (patch)
treedc953fe8526e343272322ee7d66b2f94bf28f8ec /oox/source
parenteeaac9cfdea6d8660ac72e63df3c9a1b8623db7c (diff)
tdf#149961 pptx import: fix indents for autofitted texboxes
For autofitted textboxes, Impress scales the indents with the text size while PowerPoint doesn't. Scale the indents inversely propotional to autofit font scale so that the visual appearance on import is similar to PowerPoint. Change-Id: I7876b35a1f4221789564fcf23ccbe3fe21db3d48 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141717 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'oox/source')
-rw-r--r--oox/source/drawingml/textbody.cxx5
-rw-r--r--oox/source/drawingml/textparagraph.cxx5
-rw-r--r--oox/source/drawingml/textparagraphproperties.cxx10
3 files changed, 15 insertions, 5 deletions
diff --git a/oox/source/drawingml/textbody.cxx b/oox/source/drawingml/textbody.cxx
index 0f053ab6ad74..1be15c4f885d 100644
--- a/oox/source/drawingml/textbody.cxx
+++ b/oox/source/drawingml/textbody.cxx
@@ -65,7 +65,7 @@ void TextBody::insertAt(
for (auto const& paragraph : maParagraphs)
{
paragraph->insertAt(rFilterBase, xText, xAt, rTextStyleProperties, aMasterTextStyle,
- maTextListStyle, (nIndex == 0), nCharHeight);
+ maTextListStyle, (nIndex == 0), nCharHeight, getTextProperties().mnFontScale);
++nIndex;
}
}
@@ -148,7 +148,8 @@ void TextBody::ApplyStyleEmpty(
float nCharHeight = xProps->getPropertyValue("CharHeight").get<float>();
TextParagraphProperties aParaProp;
aParaProp.apply(*pTextParagraphStyle);
- aParaProp.pushToPropSet(&rFilterBase, xProps, aioBulletList, &pTextParagraphStyle->getBulletList(), true, nCharHeight, true);
+ aParaProp.pushToPropSet(&rFilterBase, xProps, aioBulletList, &pTextParagraphStyle->getBulletList(),
+ true, nCharHeight, getTextProperties().mnFontScale, true);
}
}
diff --git a/oox/source/drawingml/textparagraph.cxx b/oox/source/drawingml/textparagraph.cxx
index 23f051cdd5df..f08efdbff3c3 100644
--- a/oox/source/drawingml/textparagraph.cxx
+++ b/oox/source/drawingml/textparagraph.cxx
@@ -87,7 +87,8 @@ void TextParagraph::insertAt(
const Reference < XTextCursor > &xAt,
const TextCharacterProperties& rTextStyleProperties,
const TextListStyle& rMasterTextListStyle,
- const TextListStyle& rTextListStyle, bool bFirst, float nDefaultCharHeight) const
+ const TextListStyle& rTextListStyle, bool bFirst,
+ float nDefaultCharHeight, sal_Int32 nAutofitFontScale) const
{
try {
sal_Int32 nParagraphSize = 0;
@@ -175,7 +176,7 @@ void TextParagraph::insertAt(
}
float fCharacterSize = nCharHeight > 0 ? GetFontHeight ( nCharHeight ) : pTextParagraphStyle->getCharHeightPoints( 12 );
- aParaProp.pushToPropSet( &rFilterBase, xProps, aioBulletList, &pTextParagraphStyle->getBulletList(), true, fCharacterSize, true );
+ aParaProp.pushToPropSet( &rFilterBase, xProps, aioBulletList, &pTextParagraphStyle->getBulletList(), true, fCharacterSize, nAutofitFontScale, true );
}
// empty paragraphs do not have bullets in ppt
diff --git a/oox/source/drawingml/textparagraphproperties.cxx b/oox/source/drawingml/textparagraphproperties.cxx
index 23efb301e963..0006b7530a76 100644
--- a/oox/source/drawingml/textparagraphproperties.cxx
+++ b/oox/source/drawingml/textparagraphproperties.cxx
@@ -405,7 +405,7 @@ void TextParagraphProperties::apply( const TextParagraphProperties& rSourceProps
void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* pFilterBase,
const Reference < XPropertySet >& xPropSet, PropertyMap& rioBulletMap, const BulletList* pMasterBuList, bool bApplyBulletMap, float fCharacterSize,
- bool bPushDefaultValues ) const
+ sal_Int32 nAutofitFontScale, bool bPushDefaultValues ) const
{
PropertySet aPropSet( xPropSet );
aPropSet.setProperties( maTextParagraphPropertyMap );
@@ -431,6 +431,14 @@ void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* p
std::optional< sal_Int32 > noParaLeftMargin( moParaLeftMargin );
std::optional< sal_Int32 > noFirstLineIndentation( moFirstLineIndentation );
+ // tdf#149961 Impress scales the indents when text is autofitted while Powerpoint doesn't
+ // Try to counteract this by multiplying indents by the inverse of the autofit font scale.
+ if ( nAutofitFontScale )
+ {
+ if ( noParaLeftMargin ) noParaLeftMargin = *noParaLeftMargin * MAX_PERCENT / nAutofitFontScale;
+ if ( noFirstLineIndentation ) noFirstLineIndentation = *noFirstLineIndentation * MAX_PERCENT / nAutofitFontScale;
+ }
+
if ( nNumberingType != NumberingType::NUMBER_NONE )
{
if ( noParaLeftMargin )