sd/qa/unit/PNGExportTests.cxx             |   10 ++++++++--
 svx/source/unodraw/UnoGraphicExporter.cxx |   12 +++++++++---
 2 files changed, 17 insertions(+), 5 deletions(-)

New commits:
commit 392b2cd4889cf944ed47b3473c6dd2cc1f89e7e7
Author:     Armin Le Grand (allotropia) <armin.le.grand.ext...@allotropia.de>
AuthorDate: Wed Sep 7 16:49:56 2022 +0200
Commit:     Armin Le Grand <armin.le.gr...@me.com>
CommitDate: Thu Sep 8 09:46:26 2022 +0200

    tdf#150102 Correct PrefSize for UNO API Metafile exporter
    
    Checked that in aBound is indeed the size - 1 (probably
    due to old integer stuff using Size()/Rectangle() and
    getWidth()/GetWidth() with the old one-less paradigm
    somewhere), so just correct to the correct size. Be aware
    that checking of tdf#126319 is needed, but looks good in
    my tests. Still: Changing the central UNO API Metafile
    export is always a risky thing, so it will have to show
    if this will not influence something else.
    
    Adapted a unit test to take into account that the exported
    object as PNG no longer has an empty column at the right and
    lo longer an empty row at the bottom. That test testTdf126319
    uses now the same test-indexing as the test testTdf105998
    already used. This shows a more correct PNG conversion, it
    was curious anyways that two identical exports of objects
    with a light-red border from dfferent apps had that
    difference at all.
    
    Change-Id: I8513688dc062025c5d931b75602f4fdbd924a32a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139596
    Tested-by: Jenkins
    Reviewed-by: Armin Le Grand <armin.le.gr...@me.com>

diff --git a/sd/qa/unit/PNGExportTests.cxx b/sd/qa/unit/PNGExportTests.cxx
index 6af1b6ea0bb4..4d1091fbf536 100644
--- a/sd/qa/unit/PNGExportTests.cxx
+++ b/sd/qa/unit/PNGExportTests.cxx
@@ -159,7 +159,10 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf126319)
         for (tools::Long nX = 2; nX < aSize.Width() - 2; ++nX)
         {
             const Color aColorTop = pReadAccess->GetColor(0, nX);
-            const Color aColorBottom = pReadAccess->GetColor(aSize.Height() - 
2, nX);
+            // tdf#150102 the exported graphic now has no longer an empty 
bottom
+            // row, so test with '-1' in height , same as alrteady in test
+            // testTdf105998 above
+            const Color aColorBottom = pReadAccess->GetColor(aSize.Height() - 
1, nX);
 
             assertColorsAreSimilar("Incorrect top border", COL_LIGHTRED, 
aColorTop, 5);
 
@@ -172,7 +175,10 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf126319)
         for (tools::Long nY = 2; nY < aSize.Height() - 2; ++nY)
         {
             const Color aColorLeft = pReadAccess->GetColor(nY, 0);
-            const Color aColorRight = pReadAccess->GetColor(nY, aSize.Width() 
- 2);
+            // tdf#150102 the exported graphic now has no longer an empty right
+            // column, so test with '-1' in width , same as alrteady in test
+            // testTdf105998 above
+            const Color aColorRight = pReadAccess->GetColor(nY, aSize.Width() 
- 1);
 
             assertColorsAreSimilar("Incorrect left border", COL_LIGHTRED, 
aColorLeft, 5);
             assertColorsAreSimilar("Incorrect right border", COL_LIGHTRED, 
aColorRight, 5);
diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx 
b/svx/source/unodraw/UnoGraphicExporter.cxx
index 55eabdcd85fc..b1ffa6449007 100644
--- a/svx/source/unodraw/UnoGraphicExporter.cxx
+++ b/svx/source/unodraw/UnoGraphicExporter.cxx
@@ -962,10 +962,16 @@ bool GraphicExporter::GetGraphic( ExportSettings const & 
rSettings, Graphic& aGr
             aMtf.WindStart();
 
             // tdf#126319 Immediately add needed size to target's PrefSize
+            // tdf#150102 Checked that in aBound is indeed the size - 1 
(probably
+            // due to old integer stuff using Size()/Rectangle() and 
getWidth()/GetWidth()
+            // with the old one-less paradigm somewhere), so just correct to 
the
+            // correct size. Be aware that checking of tdf#126319 is needed, 
but
+            // looks good in my tests. Still: Changing the central UNO API 
Metafile
+            // export is always a risky thing, so it will have to show if this 
will
+            // not influence something else.
             const Size aBoundSize(
-                basegfx::fround(aBound.getWidth() + 
aHalfPixelInMtf.getWidth()),
-                basegfx::fround(aBound.getHeight() + 
aHalfPixelInMtf.getHeight()));
-
+                basegfx::fround(aBound.getWidth() + 1),
+                basegfx::fround(aBound.getHeight() + 1));
             aMtf.SetPrefMapMode( aMap );
             aMtf.SetPrefSize( aBoundSize );
 

Reply via email to