summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorTibor Nagy <nagy.tibor2@nisz.hu>2022-12-05 09:21:51 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2022-12-20 08:49:00 +0000
commit63baa8c2450e2333fa343f8ddedad5f5908234e6 (patch)
treeb55d690d8d7e5007b2a77a0bfc834b5f4cf29b8b /oox
parent8e7995a748bb0b9b77265bdcd74ce4800bc8afa2 (diff)
tdf#152070 PPTX import: fix offset of tile background image
by using bitmap image sizes instead of the original ones. Change-Id: Id6f2777bf6803bca7252878203a12ab796ac33dc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143766 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org> (cherry picked from commit b12e38c1ccb388e62e35d856d4a575e1724a10e9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144493 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/fillproperties.cxx5
-rw-r--r--oox/source/export/drawingml.cxx26
2 files changed, 19 insertions, 12 deletions
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index c68568096fd8..2627a1861850 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -831,10 +831,11 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
sal_Int32 nFillBmpSizeY = getLimitedValue< sal_Int32, double >( aOriginalSize.Height * fScaleY, 1, SAL_MAX_INT32 );
rPropMap.setProperty( ShapeProperty::FillBitmapSizeY, nFillBmpSizeY );
+ awt::Size aBmpSize(nFillBmpSizeX, nFillBmpSizeY);
// offset of the first bitmap tile (given as EMUs), convert to percent
- sal_Int16 nTileOffsetX = getDoubleIntervalValue< sal_Int16 >(std::round(maBlipProps.moTileOffsetX.value_or( 0 ) / 3.6 / aOriginalSize.Width), 0, 100 );
+ sal_Int16 nTileOffsetX = getDoubleIntervalValue< sal_Int16 >(std::round(maBlipProps.moTileOffsetX.value_or( 0 ) / 3.6 / aBmpSize.Width), 0, 100 );
rPropMap.setProperty( ShapeProperty::FillBitmapOffsetX, nTileOffsetX );
- sal_Int16 nTileOffsetY = getDoubleIntervalValue< sal_Int16 >(std::round(maBlipProps.moTileOffsetY.value_or( 0 ) / 3.6 / aOriginalSize.Height), 0, 100 );
+ sal_Int16 nTileOffsetY = getDoubleIntervalValue< sal_Int16 >(std::round(maBlipProps.moTileOffsetY.value_or( 0 ) / 3.6 / aBmpSize.Height), 0, 100 );
rPropMap.setProperty( ShapeProperty::FillBitmapOffsetY, nTileOffsetY );
}
}
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 3418a125fac5..86b9b5ac91dc 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1887,19 +1887,18 @@ void DrawingML::WriteXGraphicTile(uno::Reference<beans::XPropertySet> const& rXP
if (rMapMode.GetMapUnit() == MapUnit::MapPixel)
aOriginalSize = Application::GetDefaultDevice()->PixelToLogic(aOriginalSize,
MapMode(MapUnit::Map100thMM));
- sal_Int32 nOffsetX = 0;
- if (GetProperty(rXPropSet, "FillBitmapPositionOffsetX"))
- nOffsetX = (*o3tl::doAccess<sal_Int32>(mAny)) * aOriginalSize.Width() * 3.6;
-
- sal_Int32 nOffsetY = 0;
- if (GetProperty(rXPropSet, "FillBitmapPositionOffsetY"))
- nOffsetY = (*o3tl::doAccess<sal_Int32>(mAny)) * aOriginalSize.Height() * 3.6;
-
- // convert the X size of bitmap to a percentage
sal_Int32 nSizeX = 0;
+ sal_Int32 nOffsetX = 0;
if (GetProperty(rXPropSet, "FillBitmapSizeX"))
{
mAny >>= nSizeX;
+ if (GetProperty(rXPropSet, "FillBitmapPositionOffsetX"))
+ {
+ sal_Int32 nX = (nSizeX != 0) ? nSizeX : aOriginalSize.Width();
+ nOffsetX = (*o3tl::doAccess<sal_Int32>(mAny)) * nX * 3.6;
+ }
+
+ // convert the X size of bitmap to a percentage
if (nSizeX > 0)
nSizeX = double(nSizeX) / aOriginalSize.Width() * 100000;
else if (nSizeX < 0)
@@ -1908,11 +1907,18 @@ void DrawingML::WriteXGraphicTile(uno::Reference<beans::XPropertySet> const& rXP
nSizeX = 100000;
}
- // convert the Y size of bitmap to a percentage
sal_Int32 nSizeY = 0;
+ sal_Int32 nOffsetY = 0;
if (GetProperty(rXPropSet, "FillBitmapSizeY"))
{
mAny >>= nSizeY;
+ if (GetProperty(rXPropSet, "FillBitmapPositionOffsetY"))
+ {
+ sal_Int32 nY = (nSizeY != 0) ? nSizeY : aOriginalSize.Height();
+ nOffsetY = (*o3tl::doAccess<sal_Int32>(mAny)) * nY * 3.6;
+ }
+
+ // convert the Y size of bitmap to a percentage
if (nSizeY > 0)
nSizeY = double(nSizeY) / aOriginalSize.Height() * 100000;
else if (nSizeY < 0)