summaryrefslogtreecommitdiff
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
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>
-rw-r--r--oox/source/export/drawingml.cxx35
-rw-r--r--sd/qa/unit/export-tests-ooxml2.cxx4
2 files changed, 33 insertions, 6 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
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx
index a3d477d2d1f6..1a6d3b1e4adc 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -1332,9 +1332,9 @@ void SdOOXMLExportTest2::testTdf90626()
xDocShRef->DoClose();
xmlDocPtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
- assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[1]/a:pPr/a:buSzPct", "val", "46986");
+ assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[1]/a:pPr/a:buSzPct", "val", "100000");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[2]/a:pPr/a:buSzPct", "val", "150568");
- assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[3]/a:pPr/a:buSzPct", "val", "46986");
+ assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[3]/a:pPr/a:buSzPct", "val", "100000");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[4]/a:pPr/a:buSzPct", "val", "150568");
}