summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorPaul Trojahn <paul.trojahn@gmail.com>2017-12-21 22:17:22 +0100
committerTamás Zolnai <tamas.zolnai@collabora.com>2017-12-30 17:36:52 +0100
commit87e353874a1c52f8e42946a59d2e2079eb28f7fe (patch)
tree280be0b90c80c4fbe248c515881fd54bbec402e9 /oox
parent6246d44680ec9b4cc132614e664c4cb88095b09e (diff)
tdf#90626 PPTX: Fix image bullet position in PPT
Scaled bullet points aren't centered in PPT, so padding needs to be added to get them to the correct position. Change-Id: I61509dd43ef9cd697dcbc3cabbf58a21d625ddec Reviewed-on: https://gerrit.libreoffice.org/46994 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/drawingml.cxx35
1 files changed, 31 insertions, 4 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index f0f9bee96125..62688e9b8d42 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1978,15 +1978,42 @@ void DrawingML::WriteParagraphNumbering(const Reference< XPropertySet >& rXPropS
if( !aGraphicURL.isEmpty() )
{
- OUString sRelId = WriteImage( aGraphicURL );
-
long nFirstCharHeightMm = TransformMetric(fFirstCharHeight * 100.f, FUNIT_POINT, FUNIT_MM);
float fBulletSizeRel = aGraphicSize.Height / static_cast<float>(nFirstCharHeightMm) / OOX_BULLET_LIST_SCALE_FACTOR;
+ OUString sRelationId;
+
+ if(fBulletSizeRel < 1.f)
+ {
+ // Add padding to get the bullet point centered in PPT
+ Graphic aGraphic;
+ if (lcl_URLToGraphic(aGraphicURL, aGraphic))
+ {
+ Size aDestSize(64, 64);
+ float fBulletSizeRelX = fBulletSizeRel / aGraphicSize.Height * aGraphicSize.Width;
+ long nPaddingX = std::max(static_cast<long>(0), std::lround((aDestSize.Width() - fBulletSizeRelX * aDestSize.Width()) / 2.f));
+ long nPaddingY = std::lround((aDestSize.Height() - fBulletSizeRel * aDestSize.Height()) / 2.f);
+ tools::Rectangle aDestRect(nPaddingX, nPaddingY, aDestSize.Width() - nPaddingX, aDestSize.Height() - nPaddingY);
+
+ AlphaMask aMask(aDestSize);
+ aMask.Erase(255);
+ BitmapEx aSourceBitmap(aGraphic.GetBitmapEx());
+ aSourceBitmap.Scale(aDestRect.GetSize());
+ tools::Rectangle aSourceRect(Point(0, 0), aDestRect.GetSize());
+ BitmapEx aDestBitmap(Bitmap(aDestSize, 24), aMask);
+ aDestBitmap.CopyPixel(aDestRect, aSourceRect, &aSourceBitmap);
+ Graphic aDestGraphic(aDestBitmap);
+ sRelationId = WriteImage(aDestGraphic);
+ fBulletSizeRel = 1.f;
+ }
+ }
+ else
+ sRelationId = WriteImage(aGraphicURL);
+
mpFS->singleElementNS( XML_a, XML_buSzPct,
- XML_val, IS( std::max( static_cast<sal_Int32>(25000), std::min( static_cast<sal_Int32>(400000), static_cast<sal_Int32>( std::lround( 100000.f * fBulletSizeRel ) ) ) ) ), FSEND );
+ XML_val, IS( std::min(static_cast<sal_Int32>(std::lround(100000.f * fBulletSizeRel)), static_cast<sal_Int32>(400000))), FSEND);
mpFS->startElementNS( XML_a, XML_buBlip, FSEND );
- mpFS->singleElementNS( XML_a, XML_blip, FSNS( XML_r, XML_embed ), USS( sRelId ), FSEND );
+ mpFS->singleElementNS( XML_a, XML_blip, FSNS( XML_r, XML_embed ), USS( sRelationId ), FSEND );
mpFS->endElementNS( XML_a, XML_buBlip );
}
else