summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorSarper Akdemir <sarper.akdemir@collabora.com>2022-10-24 14:16:16 +0300
committerMiklos Vajna <vmiklos@collabora.com>2022-10-27 15:15:26 +0200
commite6a1586ff90125245cf0f898af37bf568abdcddf (patch)
treeda0cc33df25feda1957ff971e580d6be8fde76c4 /oox
parent08d0c2cd6b6bdf37d6fc5c16359bafc6dddc9d09 (diff)
related tdf#149961 pptx export: scale indents for autofitted textboxes
For autofitted textboxes, Impress scales the indents with the text size while PowerPoint doesn't. Try to compensate for this by scaling exported indents proportionally to the font scale on autofitted textboxes. Change-Id: Ib0f967e923d23553b4cdbd1bbe2e137d97b1b2e5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141758 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/drawingml.cxx26
1 files changed, 22 insertions, 4 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index e0766d0e7a7a..e8d5bef246c4 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3021,7 +3021,7 @@ void DrawingML::WriteLinespacing(const LineSpacing& rSpacing, float fFirstCharHe
}
}
-bool DrawingML::WriteParagraphProperties( const Reference< XTextContent >& rParagraph, float fFirstCharHeight, sal_Int32 nElement)
+bool DrawingML::WriteParagraphProperties(const Reference<XTextContent>& rParagraph, const Reference<XPropertySet>& rXShapePropSet, float fFirstCharHeight, sal_Int32 nElement)
{
Reference< XPropertySet > rXPropSet( rParagraph, UNO_QUERY );
Reference< XPropertyState > rXPropState( rParagraph, UNO_QUERY );
@@ -3111,6 +3111,24 @@ bool DrawingML::WriteParagraphProperties( const Reference< XTextContent >& rPara
return false;
}
+ // for autofitted textboxes, scale the indents
+ if (GetProperty(rXShapePropSet, "TextFitToSize") && mAny.get<TextFitToSizeType>() == TextFitToSizeType_AUTOFIT)
+ {
+ SvxShapeText* pTextShape = dynamic_cast<SvxShapeText*>(rXShapePropSet.get());
+ if (pTextShape)
+ {
+ SdrTextObj* pTextObject = dynamic_cast<SdrTextObj*>(pTextShape->GetSdrObject());
+ if (pTextObject)
+ {
+ const auto nFontScaleY = pTextObject->GetFontScaleY();
+ nLeftMargin = nLeftMargin * nFontScaleY / 100;
+ nLineIndentation = nLineIndentation * nFontScaleY / 100;
+ nParaLeftMargin = nParaLeftMargin * nFontScaleY / 100;
+ nParaFirstLineIndent = nParaFirstLineIndent * nFontScaleY / 100;
+ }
+ }
+ }
+
if (nParaLeftMargin) // For Paragraph
mpFS->startElementNS( XML_a, nElement,
XML_lvl, sax_fastparser::UseIf(OString::number(nLevel), nLevel > 0),
@@ -3198,7 +3216,7 @@ void DrawingML::WriteLstStyles(const css::uno::Reference<css::text::XTextContent
fFirstCharHeight = xFirstRunPropSet->getPropertyValue("CharHeight").get<float>();
mpFS->startElementNS(XML_a, XML_lstStyle);
- if( !WriteParagraphProperties(rParagraph, fFirstCharHeight, XML_lvl1pPr) )
+ if( !WriteParagraphProperties(rParagraph, rXShapePropSet, fFirstCharHeight, XML_lvl1pPr) )
mpFS->startElementNS(XML_a, XML_lvl1pPr);
WriteRunProperties(xFirstRunPropSet, false, XML_defRPr, true, rbOverridingCharHeight,
rnCharHeight, GetScriptType(rRun->getString()), rXShapePropSet);
@@ -3240,7 +3258,7 @@ void DrawingML::WriteParagraph( const Reference< XTextContent >& rParagraph,
rnCharHeight = 100 * fFirstCharHeight;
rbOverridingCharHeight = true;
}
- WriteParagraphProperties(rParagraph, fFirstCharHeight, XML_pPr);
+ WriteParagraphProperties(rParagraph, rXShapePropSet, fFirstCharHeight, XML_pPr);
bPropertiesWritten = true;
}
WriteRun( run, rbOverridingCharHeight, rnCharHeight, rXShapePropSet);
@@ -3848,7 +3866,7 @@ void DrawingML::WriteText(const Reference<XInterface>& rXIface, bool bBodyPr, bo
if( aAny >>= xParagraph )
{
mpFS->startElementNS(XML_a, XML_p);
- WriteParagraphProperties(xParagraph, nCharHeight, XML_pPr);
+ WriteParagraphProperties(xParagraph, rXPropSet, nCharHeight, XML_pPr);
sal_Int16 nDummy = -1;
WriteRunProperties(rXPropSet, false, XML_endParaRPr, false,
bOverridingCharHeight, nCharHeight, nDummy, rXPropSet);