oox/source/export/drawingml.cxx | 35 +++++++++++++++++++++++++++++++---- sd/qa/unit/export-tests-ooxml2.cxx | 4 ++-- 2 files changed, 33 insertions(+), 6 deletions(-)
New commits: commit 87e353874a1c52f8e42946a59d2e2079eb28f7fe Author: Paul Trojahn <paul.troj...@gmail.com> Date: Thu Dec 21 22:17:22 2017 +0100 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 <c...@libreoffice.org> Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> 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"); }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits