summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorTibor Nagy <nagy.tibor2@nisz.hu>2023-01-23 09:33:13 +0100
committerCaolán McNamara <caolan.mcnamara@collabora.com>2023-06-27 14:16:25 +0200
commitdf482562d2532956c197468740e2a02499a89f55 (patch)
tree8d63018f4badf0971e7df616b925988f95f126ac /oox
parent6460c685c3bc3f4929263c7681080056b59948fe (diff)
tdf#153107 OOXML export: fix scale of tile of shape background
Relative scale values were exported as absolute values, resulting broken shape background. Change-Id: Ia38e125862e7f8ceff5d41754340723c3a9eb028 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145996 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153576 Reviewed-by: Jaume Pujantell <jaume.pujantell@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/drawingml.cxx55
-rw-r--r--oox/source/export/shapes.cxx6
2 files changed, 34 insertions, 27 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 6599f6cb1959..f7f67595c025 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1703,7 +1703,8 @@ OUString DrawingML::WriteXGraphicBlip(uno::Reference<beans::XPropertySet> const
}
void DrawingML::WriteXGraphicBlipMode(uno::Reference<beans::XPropertySet> const & rXPropSet,
- uno::Reference<graphic::XGraphic> const & rxGraphic)
+ uno::Reference<graphic::XGraphic> const & rxGraphic,
+ css::awt::Size const& rSize)
{
BitmapMode eBitmapMode(BitmapMode_NO_REPEAT);
if (GetProperty(rXPropSet, "FillBitmapMode"))
@@ -1714,7 +1715,7 @@ void DrawingML::WriteXGraphicBlipMode(uno::Reference<beans::XPropertySet> const
switch (eBitmapMode)
{
case BitmapMode_REPEAT:
- WriteXGraphicTile(rXPropSet, rxGraphic);
+ WriteXGraphicTile(rXPropSet, rxGraphic, rSize);
break;
case BitmapMode_STRETCH:
WriteXGraphicStretch(rXPropSet, rxGraphic);
@@ -1724,7 +1725,8 @@ void DrawingML::WriteXGraphicBlipMode(uno::Reference<beans::XPropertySet> const
}
}
-void DrawingML::WriteBlipOrNormalFill( const Reference< XPropertySet >& xPropSet, const OUString& rURLPropName )
+void DrawingML::WriteBlipOrNormalFill(const Reference<XPropertySet>& xPropSet,
+ const OUString& rURLPropName, const awt::Size& rSize)
{
// check for blip and otherwise fall back to normal fill
// we always store normal fill properties but OOXML
@@ -1732,15 +1734,17 @@ void DrawingML::WriteBlipOrNormalFill( const Reference< XPropertySet >& xPropSet
if (GetProperty ( xPropSet, rURLPropName ))
WriteBlipFill( xPropSet, rURLPropName );
else
- WriteFill(xPropSet);
+ WriteFill(xPropSet, rSize);
}
-void DrawingML::WriteBlipFill( const Reference< XPropertySet >& rXPropSet, const OUString& sURLPropName )
+void DrawingML::WriteBlipFill(const Reference<XPropertySet>& rXPropSet,
+ const OUString& sURLPropName, const awt::Size& rSize)
{
- WriteBlipFill( rXPropSet, sURLPropName, XML_a );
+ WriteBlipFill( rXPropSet, rSize, sURLPropName, XML_a );
}
-void DrawingML::WriteBlipFill( const Reference< XPropertySet >& rXPropSet, const OUString& sURLPropName, sal_Int32 nXmlNamespace )
+void DrawingML::WriteBlipFill(const Reference<XPropertySet>& rXPropSet, const awt::Size& rSize,
+ const OUString& sURLPropName, sal_Int32 nXmlNamespace)
{
if ( !GetProperty( rXPropSet, sURLPropName ) )
return;
@@ -1762,13 +1766,14 @@ void DrawingML::WriteBlipFill( const Reference< XPropertySet >& rXPropSet, const
bool bWriteMode = false;
if (sURLPropName == "FillBitmap" || sURLPropName == "BackGraphic")
bWriteMode = true;
- WriteXGraphicBlipFill(rXPropSet, xGraphic, nXmlNamespace, bWriteMode);
+ WriteXGraphicBlipFill(rXPropSet, xGraphic, nXmlNamespace, bWriteMode, false, rSize);
}
}
void DrawingML::WriteXGraphicBlipFill(uno::Reference<beans::XPropertySet> const & rXPropSet,
uno::Reference<graphic::XGraphic> const & rxGraphic,
- sal_Int32 nXmlNamespace, bool bWriteMode, bool bRelPathToMedia)
+ sal_Int32 nXmlNamespace, bool bWriteMode,
+ bool bRelPathToMedia, css::awt::Size const& rSize)
{
if (!rxGraphic.is() )
return;
@@ -1785,7 +1790,7 @@ void DrawingML::WriteXGraphicBlipFill(uno::Reference<beans::XPropertySet> const
if (bWriteMode)
{
- WriteXGraphicBlipMode(rXPropSet, rxGraphic);
+ WriteXGraphicBlipMode(rXPropSet, rxGraphic, rSize);
}
else if(GetProperty(rXPropSet, "FillBitmapStretch"))
{
@@ -1976,7 +1981,8 @@ static OUString lclConvertRectanglePointToToken(RectanglePoint eRectanglePoint)
}
void DrawingML::WriteXGraphicTile(uno::Reference<beans::XPropertySet> const& rXPropSet,
- uno::Reference<graphic::XGraphic> const& rxGraphic)
+ uno::Reference<graphic::XGraphic> const& rxGraphic,
+ css::awt::Size const& rSize)
{
Graphic aGraphic(rxGraphic);
Size aOriginalSize(aGraphic.GetPrefSize());
@@ -1993,6 +1999,8 @@ void DrawingML::WriteXGraphicTile(uno::Reference<beans::XPropertySet> const& rXP
if (GetProperty(rXPropSet, "FillBitmapPositionOffsetX"))
{
sal_Int32 nX = (nSizeX != 0) ? nSizeX : aOriginalSize.Width();
+ if (nX < 0 && rSize.Width > 0)
+ nX = rSize.Width * std::abs(nX) / 100;
nOffsetX = (*o3tl::doAccess<sal_Int32>(mAny)) * nX * 3.6;
}
@@ -2013,6 +2021,8 @@ void DrawingML::WriteXGraphicTile(uno::Reference<beans::XPropertySet> const& rXP
if (GetProperty(rXPropSet, "FillBitmapPositionOffsetY"))
{
sal_Int32 nY = (nSizeY != 0) ? nSizeY : aOriginalSize.Height();
+ if (nY < 0 && rSize.Height > 0)
+ nY = rSize.Height * std::abs(nY) / 100;
nOffsetY = (*o3tl::doAccess<sal_Int32>(mAny)) * nY * 3.6;
}
@@ -2028,18 +2038,15 @@ void DrawingML::WriteXGraphicTile(uno::Reference<beans::XPropertySet> const& rXP
// if the "Scale" setting is checked in the images settings dialog.
if (nSizeX < 0 && nSizeY < 0)
{
- Reference<drawing::XDrawPagesSupplier> xDPS(GetFB()->getModel(), UNO_QUERY_THROW);
- Reference<drawing::XDrawPages> xDrawPages(xDPS->getDrawPages(), UNO_SET_THROW);
- // in this case, the size of the first slide is enough, because all slides are the same size
- Reference<XDrawPage> xDrawPage(xDrawPages->getByIndex(0), UNO_QUERY);
- css::uno::Reference<css::beans::XPropertySet> xPagePropSet(xDrawPage, UNO_QUERY);
- if (xPagePropSet)
+ if (rSize.Width != 0 && rSize.Height != 0)
+ {
+ nSizeX = rSize.Width / double(aOriginalSize.Width()) * std::abs(nSizeX);
+ nSizeY = rSize.Height / double(aOriginalSize.Height()) * std::abs(nSizeY);
+ }
+ else
{
- double nPageWidth(0.0), nPageHeight(0.0);
- xPagePropSet->getPropertyValue("Width") >>= nPageWidth;
- xPagePropSet->getPropertyValue("Height") >>= nPageHeight;
- nSizeX = nPageWidth / aOriginalSize.Width() * std::abs(nSizeX);
- nSizeY = nPageHeight / aOriginalSize.Height() * std::abs(nSizeY);
+ nSizeX = std::abs(nSizeX);
+ nSizeY = std::abs(nSizeY);
}
}
@@ -5145,7 +5152,7 @@ sax_fastparser::FSHelperPtr DrawingML::CreateOutputStream (
return p;
}
-void DrawingML::WriteFill( const Reference< XPropertySet >& xPropSet )
+void DrawingML::WriteFill(const Reference<XPropertySet>& xPropSet, const awt::Size& rSize)
{
if ( !GetProperty( xPropSet, "FillStyle" ) )
return;
@@ -5197,7 +5204,7 @@ void DrawingML::WriteFill( const Reference< XPropertySet >& xPropSet )
WriteGradientFill( xPropSet );
break;
case FillStyle_BITMAP :
- WriteBlipFill( xPropSet, "FillBitmap" );
+ WriteBlipFill( xPropSet, "FillBitmap", rSize );
break;
case FillStyle_HATCH :
WritePattFill( xPropSet );
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 801d4ad9e318..2bf1fe11a6e9 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -441,7 +441,7 @@ ShapeExport& ShapeExport::WritePolyPolygonShape( const Reference< XShape >& xSha
Reference< XPropertySet > xProps( xShape, UNO_QUERY );
if( xProps.is() ) {
if( bClosed )
- WriteFill( xProps );
+ WriteFill(xProps, aSize);
WriteOutline( xProps );
}
@@ -1111,7 +1111,7 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape )
}
if( rXPropSet.is() )
{
- WriteFill( rXPropSet );
+ WriteFill(rXPropSet, xShape->getSize());
WriteOutline( rXPropSet );
WriteShapeEffects( rXPropSet );
@@ -2482,7 +2482,7 @@ ShapeExport& ShapeExport::WriteTextShape( const Reference< XShape >& xShape )
uno::Reference<beans::XPropertySet> xPropertySet(xShape, UNO_QUERY);
if (!IsFontworkShape(xShapeProps)) // Fontwork needs fill and outline in run properties instead.
{
- WriteBlipOrNormalFill(xPropertySet, "Graphic");
+ WriteBlipOrNormalFill(xPropertySet, "Graphic", xShape->getSize());
WriteOutline(xPropertySet);
WriteShapeEffects(xPropertySet);
}