dev/null                                                  |binary
 drawinglayer/source/attribute/sdrfillgraphicattribute.cxx |   13 --
 svx/qa/unit/svdraw.cxx                                    |   68 --------------
 svx/source/customshapes/EnhancedCustomShape2d.cxx         |   27 -----
 4 files changed, 3 insertions(+), 105 deletions(-)

New commits:
commit f8d50a8fa556c5bfb0d638117b8b0deafd433af5
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Thu Sep 5 14:26:07 2024 +0200
Commit:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
CommitDate: Fri Sep 6 12:42:33 2024 +0200

    tdf#161724: Revert "tdf#153008 svx: impl crop for stretched bitmap fill"
    
    This reverts commit c30c1d12f283e75fdcc5bb508a79a9d33a431d28.
    
    it even broke the original sample file reported in tdf#153008
    See https://bug-attachments.documentfoundation.org/attachment.cgi?id=196248
    The original issue was reported in tdf#95165 but it doesn't work
    in all cases, making it much worse in some cases where images
    become very stretched
    Reverting for now, specially towards libreoffice-24-8 and
    libreoffice-24-8-1
    
    Change-Id: Ib94d2784d701d37853ce9b17135b36f26a5c084b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172898
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
    Tested-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>

diff --git a/drawinglayer/source/attribute/sdrfillgraphicattribute.cxx 
b/drawinglayer/source/attribute/sdrfillgraphicattribute.cxx
index 0acf4ba44be2..b78f3e322c38 100644
--- a/drawinglayer/source/attribute/sdrfillgraphicattribute.cxx
+++ b/drawinglayer/source/attribute/sdrfillgraphicattribute.cxx
@@ -286,19 +286,6 @@ namespace drawinglayer::attribute
                 aBitmapSize.setX(aBitmapSize.getX() / fRangeWidth);
                 aBitmapSize.setY(aBitmapSize.getY() / fRangeHeight);
             }
-            else if (mpSdrFillGraphicAttribute->getStretch())
-            {
-                //tdf#153008 We may want to calculate crop. (stretch-fillRect 
case)
-                aBitmapTopLeft.setX(getOffsetPosition().getX() * 0.01);
-                aBitmapTopLeft.setY(getOffsetPosition().getY() * 0.01);
-                if (getSize().getX() != 0.0 && getSize().getY() != 0.0)
-                {
-                    const double fRangeWidth(0.0 != rRange.getWidth() ? 
rRange.getWidth() : 1.0);
-                    const double fRangeHeight(0.0 != rRange.getHeight() ? 
rRange.getHeight() : 1.0);
-                    aBitmapSize.setX(getSize().getX() / fRangeWidth);
-                    aBitmapSize.setY(getSize().getY() / fRangeHeight);
-                }
-            }
 
             // get offset in percent
             const double fOffsetX(std::clamp(getOffset().getX() * 0.01, 0.0, 
1.0));
diff --git a/svx/qa/unit/data/tdf153008_crop_stretched_bitmap.pptx 
b/svx/qa/unit/data/tdf153008_crop_stretched_bitmap.pptx
deleted file mode 100644
index 453b81fa006a..000000000000
Binary files a/svx/qa/unit/data/tdf153008_crop_stretched_bitmap.pptx and 
/dev/null differ
diff --git a/svx/qa/unit/svdraw.cxx b/svx/qa/unit/svdraw.cxx
index 5f16baae175d..83293c52ee3f 100644
--- a/svx/qa/unit/svdraw.cxx
+++ b/svx/qa/unit/svdraw.cxx
@@ -52,17 +52,16 @@ public:
     }
 
 protected:
-    SdrPage* getFirstDrawPageWithAssert(sal_Int32 nPageIndex = 0);
+    SdrPage* getFirstDrawPageWithAssert();
 };
 
-SdrPage* SvdrawTest::getFirstDrawPageWithAssert(sal_Int32 nPageIndex /* = 0*/)
+SdrPage* SvdrawTest::getFirstDrawPageWithAssert()
 {
     uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent,
                                                                    
uno::UNO_QUERY_THROW);
     CPPUNIT_ASSERT(xDrawPagesSupplier.is());
     uno::Reference<drawing::XDrawPages> 
xDrawPages(xDrawPagesSupplier->getDrawPages());
-    uno::Reference<drawing::XDrawPage> 
xDrawPage(xDrawPages->getByIndex(nPageIndex),
-                                                 uno::UNO_QUERY_THROW);
+    uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), 
uno::UNO_QUERY_THROW);
     CPPUNIT_ASSERT(xDrawPage.is());
 
     auto pDrawPage = dynamic_cast<SvxDrawPage*>(xDrawPage.get());
@@ -466,67 +465,6 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, 
testTdf148000_CurvedTextWidth)
     }
 }
 
-CPPUNIT_TEST_FIXTURE(SvdrawTest, testTdf153008_CropStretchedBitmapFill)
-{
-    loadFromFile(u"tdf153008_crop_stretched_bitmap.pptx");
-
-    SdrPage* pSdrPage = getFirstDrawPageWithAssert();
-
-    xmlDocUniquePtr pXmlDoc = lcl_dumpAndParseFirstObjectWithAssert(pSdrPage);
-
-    // Load Polygon size
-    sal_Int16 nPolyHeight = getXPath(pXmlDoc, "//mask/polypolygon"_ostr, 
"height"_ostr).toInt32();
-    sal_Int16 nPolyWidth = getXPath(pXmlDoc, "//mask/polypolygon"_ostr, 
"width"_ostr).toInt32();
-    // polygon position is nearly 0,0
-    // Load Bitmap coordinates (from transformation matrix)
-    sal_Int16 nBmpPosX = getXPath(pXmlDoc, "//bitmap"_ostr, 
"xy13"_ostr).toInt32();
-    sal_Int16 nBmpPosY = getXPath(pXmlDoc, "//bitmap"_ostr, 
"xy23"_ostr).toInt32();
-    sal_Int16 nBmpWidth = getXPath(pXmlDoc, "//bitmap"_ostr, 
"xy11"_ostr).toInt32();
-    sal_Int16 nBmpHeight = getXPath(pXmlDoc, "//bitmap"_ostr, 
"xy22"_ostr).toInt32();
-
-    // The Bitmap should start nearly in the middle of the polygon.
-    // because of rounding errors we tolerate 2% difference
-    // Before the fix, the bitmap was always stretched to the whole polygon,
-    // that means they had the same size, and position.
-    CPPUNIT_ASSERT_DOUBLES_EQUAL(nPolyWidth / 2, nBmpPosX, nPolyWidth / 50);
-    CPPUNIT_ASSERT_DOUBLES_EQUAL(nPolyHeight / 2, nBmpPosY, nPolyHeight / 50);
-    // And should have 1/2 width, and 3/8 height of the polygon.
-    CPPUNIT_ASSERT_DOUBLES_EQUAL(nPolyWidth / 2, nBmpWidth, nPolyWidth / 50);
-    CPPUNIT_ASSERT_DOUBLES_EQUAL(nPolyHeight * 3 / 8, nBmpHeight, nPolyHeight 
/ 50);
-}
-
-CPPUNIT_TEST_FIXTURE(SvdrawTest, 
testTdf153008_CropStretchedBitmapFillNegativePosition)
-{
-    loadFromFile(u"tdf153008_crop_stretched_bitmap.pptx");
-
-    // get the 2. page
-    SdrPage* pSdrPage = getFirstDrawPageWithAssert(1);
-
-    xmlDocUniquePtr pXmlDoc = lcl_dumpAndParseFirstObjectWithAssert(pSdrPage);
-
-    // Load Polygon size
-    sal_Int16 nPolyHeight = getXPath(pXmlDoc, "//mask/polypolygon"_ostr, 
"height"_ostr).toInt32();
-    sal_Int16 nPolyWidth = getXPath(pXmlDoc, "//mask/polypolygon"_ostr, 
"width"_ostr).toInt32();
-    // polygon position is nearly 0,0
-    // Load Bitmap coordinates (from transformation matrix)
-    sal_Int16 nBmpPosX = getXPath(pXmlDoc, "//bitmap"_ostr, 
"xy13"_ostr).toInt32();
-    sal_Int16 nBmpPosY = getXPath(pXmlDoc, "//bitmap"_ostr, 
"xy23"_ostr).toInt32();
-    sal_Int16 nBmpWidth = getXPath(pXmlDoc, "//bitmap"_ostr, 
"xy11"_ostr).toInt32();
-    sal_Int16 nBmpHeight = getXPath(pXmlDoc, "//bitmap"_ostr, 
"xy22"_ostr).toInt32();
-
-    // The Bitmap should start before the polygon.
-    // At x direction it should start left from the polygon with 3/8 polygon 
width
-    // At y direction it should start up from the polygon with 3/16 polygon 
height
-    // Before the fix, negative numbers overflowed to big positive number,
-    // so the bitmap was moved to a far away place where it was not visible
-    // because of rounding errors we tolerate 2% difference
-    CPPUNIT_ASSERT_DOUBLES_EQUAL(-nPolyWidth * 3 / 8, nBmpPosX, nPolyWidth / 
50);
-    CPPUNIT_ASSERT_DOUBLES_EQUAL(-nPolyHeight * 3 / 16, nBmpPosY, nPolyHeight 
/ 50);
-    // And should have 3/2 width, and 1/1 height of the polygon.
-    CPPUNIT_ASSERT_DOUBLES_EQUAL(nPolyWidth * 3 / 2, nBmpWidth, nPolyWidth / 
50);
-    CPPUNIT_ASSERT_DOUBLES_EQUAL(nPolyHeight, nBmpHeight, nPolyHeight / 50);
-}
-
 CPPUNIT_TEST_FIXTURE(SvdrawTest, testSurfaceMetal)
 {
     loadFromFile(u"tdf140321_metal.odp");
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx 
b/svx/source/customshapes/EnhancedCustomShape2d.cxx
index db41c94769c9..135c82af6b90 100644
--- a/svx/source/customshapes/EnhancedCustomShape2d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx
@@ -43,10 +43,6 @@
 #include <svx/xbtmpit.hxx>
 #include <svx/xhatch.hxx>
 #include <svx/sdshitm.hxx>
-#include <svx/xflboxy.hxx>
-#include <svx/xflbmsxy.hxx>
-#include <svx/sdgcpitm.hxx>
-#include <svx/xflbstit.hxx>
 #include <comphelper/configuration.hxx>
 #include <com/sun/star/awt/Size.hpp>
 #include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
@@ -2639,29 +2635,6 @@ void EnhancedCustomShape2d::CreateSubPath(
             SfxItemSet aTempSet(*this);
             aTempSet.Put(makeSdrShadowItem(false));
             aTempSet.Put(XLineStyleItem(drawing::LineStyle_NONE));
-
-            // tdf#153008 If it is a stretched bitmap, with crop,
-            // then set crop data into PosOffset and BmpSize
-            // so it can be used at createFillGraphicAttribute to crop the 
image
-            if (aTempSet.HasItem(SDRATTR_GRAFCROP)
-                && aTempSet.HasItem(XATTR_FILLBITMAP)
-                && aTempSet.HasItem(XATTR_FILLBMP_STRETCH)
-                && aTempSet.Get(XATTR_FILLBMP_STRETCH).GetValue())
-            {
-                const SdrGrafCropItem& rCrop = aTempSet.Get(SDRATTR_GRAFCROP);
-                const Size& aBmpSize
-                    = 
aTempSet.Get(XATTR_FILLBITMAP).GetGraphicObject().GetPrefSize();
-
-                aTempSet.Put(XFillBmpPosOffsetXItem(rCrop.GetLeft() * 100 / 
aBmpSize.Width()));
-                aTempSet.Put(XFillBmpPosOffsetYItem(rCrop.GetTop() * 100 / 
aBmpSize.Height()));
-                aTempSet.Put(
-                    XFillBmpSizeXItem((aBmpSize.Width() - rCrop.GetLeft() - 
rCrop.GetRight())
-                                      * pFill->GetGeoRect().GetWidth() / 
aBmpSize.Width()));
-                aTempSet.Put(
-                    XFillBmpSizeYItem((aBmpSize.Height() - rCrop.GetTop() - 
rCrop.GetBottom())
-                                      * pFill->GetGeoRect().GetHeight() / 
aBmpSize.Height()));
-            }
-
             pFill->SetMergedItemSet(aTempSet);
             rObjectList.push_back(std::pair< rtl::Reference<SdrPathObj>, 
double >(std::move(pFill), dBrightness));
         }

Reply via email to