[Libreoffice-commits] core.git: drawinglayer/source filter/source include/drawinglayer include/toolkit svgio/CppunitTest_svgio.mk svgio/Library_svgio.mk svgio/source svx/source toolkit/inc toolkit/source

Armin Le Grand (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 10 18:38:26 UTC 2020


 drawinglayer/source/primitive2d/bitmapprimitive2d.cxx         |   25 ++++++--
 drawinglayer/source/primitive2d/controlprimitive2d.cxx        |    5 +
 drawinglayer/source/primitive2d/discretebitmapprimitive2d.cxx |    6 +
 drawinglayer/source/primitive2d/discreteshadowprimitive2d.cxx |   17 ++---
 drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx  |    5 -
 drawinglayer/source/primitive2d/markerarrayprimitive2d.cxx    |    6 +
 drawinglayer/source/primitive2d/patternfillprimitive2d.cxx    |    3 
 drawinglayer/source/primitive2d/sceneprimitive2d.cxx          |    6 +
 drawinglayer/source/primitive2d/wallpaperprimitive2d.cxx      |    5 -
 drawinglayer/source/processor2d/hittestprocessor2d.cxx        |    7 +-
 drawinglayer/source/processor2d/vclprocessor2d.cxx            |    4 -
 drawinglayer/source/tools/emfphelperdata.cxx                  |    5 +
 drawinglayer/source/tools/wmfemfhelper.cxx                    |    3 
 filter/source/pdf/pdfdecomposer.cxx                           |    4 -
 include/drawinglayer/primitive2d/bitmapprimitive2d.hxx        |   31 +++++++---
 include/toolkit/helper/vclunohelper.hxx                       |    1 
 svgio/CppunitTest_svgio.mk                                    |    1 
 svgio/Library_svgio.mk                                        |    1 
 svgio/source/svgreader/svgimagenode.cxx                       |    3 
 svx/source/sdr/contact/viewcontactofgraphic.cxx               |    4 -
 svx/source/sdr/overlay/overlaytools.cxx                       |    6 +
 toolkit/inc/awt/vclxbitmap.hxx                                |   11 +++
 toolkit/source/awt/vclxbitmap.cxx                             |    7 ++
 toolkit/source/helper/vclunohelper.cxx                        |    5 +
 24 files changed, 130 insertions(+), 41 deletions(-)

New commits:
commit ae743c6fae4543282f8930dc78175cc510fabbb3
Author:     Armin Le Grand <armin.le.grand at me.com>
AuthorDate: Fri Apr 10 18:07:41 2020 +0200
Commit:     Armin Le Grand <Armin.Le.Grand at me.com>
CommitDate: Fri Apr 10 20:37:52 2020 +0200

    Make BitmapPrimitive2D vcl-independent
    
    as preparation to have drawinglayer module
    independent from vcl in the future
    
    Change-Id: Iaa01370f27b51cba5114a54f37d1ec73d0719918
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92048
    Tested-by: Jenkins
    Reviewed-by: Armin Le Grand <Armin.Le.Grand at me.com>

diff --git a/drawinglayer/source/primitive2d/bitmapprimitive2d.cxx b/drawinglayer/source/primitive2d/bitmapprimitive2d.cxx
index 1953a36a71ac..f495d531d8ff 100644
--- a/drawinglayer/source/primitive2d/bitmapprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/bitmapprimitive2d.cxx
@@ -19,15 +19,16 @@
 
 #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
+#include <com/sun/star/awt/XBitmap.hpp>
 
 using namespace com::sun::star;
 
 namespace drawinglayer::primitive2d
 {
-BitmapPrimitive2D::BitmapPrimitive2D(const BitmapEx& rBitmapEx,
+BitmapPrimitive2D::BitmapPrimitive2D(const css::uno::Reference<css::awt::XBitmap>& rXBitmap,
                                      const basegfx::B2DHomMatrix& rTransform)
     : BasePrimitive2D()
-    , maBitmapEx(rBitmapEx)
+    , maXBitmap(rXBitmap)
     , maTransform(rTransform)
 {
 }
@@ -38,8 +39,7 @@ bool BitmapPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
     {
         const BitmapPrimitive2D& rCompare = static_cast<const BitmapPrimitive2D&>(rPrimitive);
 
-        return (getBitmapEx() == rCompare.getBitmapEx()
-                && getTransform() == rCompare.getTransform());
+        return (getXBitmap() == rCompare.getXBitmap() && getTransform() == rCompare.getTransform());
     }
 
     return false;
@@ -53,7 +53,22 @@ BitmapPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInforma
     return aRetval;
 }
 
-sal_Int64 SAL_CALL BitmapPrimitive2D::estimateUsage() { return getBitmapEx().GetSizeBytes(); }
+sal_Int64 SAL_CALL BitmapPrimitive2D::estimateUsage()
+{
+    if (!getXBitmap().is())
+    {
+        return 0;
+    }
+
+    uno::Reference<util::XAccounting> const xAcc(getXBitmap(), uno::UNO_QUERY);
+
+    if (!xAcc.is())
+    {
+        return 0;
+    }
+
+    return xAcc->estimateUsage();
+}
 
 // provide unique ID
 ImplPrimitive2DIDBlock(BitmapPrimitive2D, PRIMITIVE2D_ID_BITMAPPRIMITIVE2D)
diff --git a/drawinglayer/source/primitive2d/controlprimitive2d.cxx b/drawinglayer/source/primitive2d/controlprimitive2d.cxx
index a10f8810da73..600bb4be8a3f 100644
--- a/drawinglayer/source/primitive2d/controlprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/controlprimitive2d.cxx
@@ -37,6 +37,7 @@
 #include <toolkit/awt/vclxwindow.hxx>
 #include <vcl/window.hxx>
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
 
 using namespace com::sun::star;
 
@@ -205,7 +206,9 @@ namespace drawinglayer::primitive2d
                                     aBitmapSizeLogic.getX(), aBitmapSizeLogic.getY(), aTranslate.getX(), aTranslate.getY()));
 
                                 // create primitive
-                                xRetval = new BitmapPrimitive2D(aContent, aBitmapTransform);
+                                xRetval = new BitmapPrimitive2D(
+                                    VCLUnoHelper::CreateVCLXBitmap(aContent),
+                                    aBitmapTransform);
                             }
                             catch( const uno::Exception& )
                             {
diff --git a/drawinglayer/source/primitive2d/discretebitmapprimitive2d.cxx b/drawinglayer/source/primitive2d/discretebitmapprimitive2d.cxx
index a61c4a39f7e8..bb73067a7d36 100644
--- a/drawinglayer/source/primitive2d/discretebitmapprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/discretebitmapprimitive2d.cxx
@@ -20,6 +20,7 @@
 #include <drawinglayer/primitive2d/discretebitmapprimitive2d.hxx>
 #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
 
 
 namespace drawinglayer::primitive2d
@@ -62,7 +63,10 @@ namespace drawinglayer::primitive2d
                 aObjectTransform = aInverseObjectTransformation * aObjectTransform;
 
                 // create BitmapPrimitive2D with now object-local coordinate data
-                rContainer.push_back(new BitmapPrimitive2D(getBitmapEx(), aObjectTransform));
+                rContainer.push_back(
+                    new BitmapPrimitive2D(
+                        VCLUnoHelper::CreateVCLXBitmap(getBitmapEx()),
+                        aObjectTransform));
             }
         }
 
diff --git a/drawinglayer/source/primitive2d/discreteshadowprimitive2d.cxx b/drawinglayer/source/primitive2d/discreteshadowprimitive2d.cxx
index c3dd299148cf..116389383b4c 100644
--- a/drawinglayer/source/primitive2d/discreteshadowprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/discreteshadowprimitive2d.cxx
@@ -23,6 +23,7 @@
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
 #include <drawinglayer/geometry/viewinformation2d.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
 
 
 namespace drawinglayer::primitive2d
@@ -176,7 +177,7 @@ namespace drawinglayer::primitive2d
                 // TopLeft
                 xRetval[0] = Primitive2DReference(
                     new BitmapPrimitive2D(
-                        getDiscreteShadow().getTopLeft(),
+                        VCLUnoHelper::CreateVCLXBitmap(getDiscreteShadow().getTopLeft()),
                         basegfx::utils::createScaleTranslateB2DHomMatrix(
                             fBigLenX,
                             fBigLenY,
@@ -186,7 +187,7 @@ namespace drawinglayer::primitive2d
                 // Top
                 xRetval[1] = Primitive2DReference(
                     new BitmapPrimitive2D(
-                        getDiscreteShadow().getTop(),
+                        VCLUnoHelper::CreateVCLXBitmap(getDiscreteShadow().getTop()),
                         basegfx::utils::createScaleTranslateB2DHomMatrix(
                             1.0 - (2.0 * (fBorderX + fSingleX)) + fSingleX,
                             fBorderY,
@@ -196,7 +197,7 @@ namespace drawinglayer::primitive2d
                 // TopRight
                 xRetval[2] = Primitive2DReference(
                     new BitmapPrimitive2D(
-                        getDiscreteShadow().getTopRight(),
+                        VCLUnoHelper::CreateVCLXBitmap(getDiscreteShadow().getTopRight()),
                         basegfx::utils::createScaleTranslateB2DHomMatrix(
                             fBigLenX,
                             fBigLenY,
@@ -206,7 +207,7 @@ namespace drawinglayer::primitive2d
                 // Right
                 xRetval[3] = Primitive2DReference(
                     new BitmapPrimitive2D(
-                        getDiscreteShadow().getRight(),
+                        VCLUnoHelper::CreateVCLXBitmap(getDiscreteShadow().getRight()),
                         basegfx::utils::createScaleTranslateB2DHomMatrix(
                             fBorderX,
                             1.0 - (2.0 * (fBorderY + fSingleY)) + fSingleY,
@@ -216,7 +217,7 @@ namespace drawinglayer::primitive2d
                 // BottomRight
                 xRetval[4] = Primitive2DReference(
                     new BitmapPrimitive2D(
-                        getDiscreteShadow().getBottomRight(),
+                        VCLUnoHelper::CreateVCLXBitmap(getDiscreteShadow().getBottomRight()),
                         basegfx::utils::createScaleTranslateB2DHomMatrix(
                             fBigLenX,
                             fBigLenY,
@@ -226,7 +227,7 @@ namespace drawinglayer::primitive2d
                 // Bottom
                 xRetval[5] = Primitive2DReference(
                     new BitmapPrimitive2D(
-                        getDiscreteShadow().getBottom(),
+                        VCLUnoHelper::CreateVCLXBitmap(getDiscreteShadow().getBottom()),
                         basegfx::utils::createScaleTranslateB2DHomMatrix(
                             1.0 - (2.0 * (fBorderX + fSingleX)) + fSingleX,
                             fBorderY,
@@ -236,7 +237,7 @@ namespace drawinglayer::primitive2d
                 // BottomLeft
                 xRetval[6] = Primitive2DReference(
                     new BitmapPrimitive2D(
-                        getDiscreteShadow().getBottomLeft(),
+                        VCLUnoHelper::CreateVCLXBitmap(getDiscreteShadow().getBottomLeft()),
                         basegfx::utils::createScaleTranslateB2DHomMatrix(
                             fBigLenX,
                             fBigLenY,
@@ -246,7 +247,7 @@ namespace drawinglayer::primitive2d
                 // Left
                 xRetval[7] = Primitive2DReference(
                     new BitmapPrimitive2D(
-                        getDiscreteShadow().getLeft(),
+                        VCLUnoHelper::CreateVCLXBitmap(getDiscreteShadow().getLeft()),
                         basegfx::utils::createScaleTranslateB2DHomMatrix(
                             fBorderX,
                             1.0 - (2.0 * (fBorderY + fSingleY)) + fSingleY,
diff --git a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
index 7c8597a14498..d301adc16a9c 100644
--- a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
+++ b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
@@ -40,6 +40,7 @@
 #include <vcl/graph.hxx>
 #include <vcl/virdev.hxx>
 #include <vcl/svapp.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
 
 namespace drawinglayer::primitive2d
 {
@@ -170,7 +171,7 @@ namespace drawinglayer::primitive2d
 
                 return Primitive2DReference(
                     new BitmapPrimitive2D(
-                        BitmapEx(aMainBitmap, aMaskBitmap),
+                        VCLUnoHelper::CreateVCLXBitmap(BitmapEx(aMainBitmap, aMaskBitmap)),
                         getTransform()));
             }
 
@@ -511,7 +512,7 @@ namespace drawinglayer::primitive2d
                     {
                         aRetval.resize(1);
                         aRetval[0] = new BitmapPrimitive2D(
-                            rGraphic.GetBitmapEx(),
+                            VCLUnoHelper::CreateVCLXBitmap(rGraphic.GetBitmapEx()),
                             rTransform);
                     }
 
diff --git a/drawinglayer/source/primitive2d/markerarrayprimitive2d.cxx b/drawinglayer/source/primitive2d/markerarrayprimitive2d.cxx
index 60e504bb63e0..d038353db9be 100644
--- a/drawinglayer/source/primitive2d/markerarrayprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/markerarrayprimitive2d.cxx
@@ -22,6 +22,7 @@
 #include <drawinglayer/geometry/viewinformation2d.hxx>
 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
 #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
 
 
 using namespace com::sun::star;
@@ -59,7 +60,10 @@ namespace drawinglayer::primitive2d
                         aTransform.set(0, 2, aRange.getMinX());
                         aTransform.set(1, 2, aRange.getMinY());
 
-                        rContainer.push_back(new BitmapPrimitive2D(getMarker(), aTransform));
+                        rContainer.push_back(
+                            new BitmapPrimitive2D(
+                                VCLUnoHelper::CreateVCLXBitmap(getMarker()),
+                                aTransform));
                     }
                 }
             }
diff --git a/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx b/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx
index e754a7f97e59..5ed50cf95ebd 100644
--- a/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx
@@ -26,6 +26,7 @@
 #include <texture/texture.hxx>
 #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
 #include <drawinglayer/geometry/viewinformation2d.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
 
 #include <converters.hxx>
 
@@ -122,7 +123,7 @@ namespace drawinglayer::primitive2d
                     {
                         const primitive2d::Primitive2DReference xEmbedRefBitmap(
                             new primitive2d::BitmapPrimitive2D(
-                                aBitmapEx,
+                                VCLUnoHelper::CreateVCLXBitmap(aBitmapEx),
                                 basegfx::B2DHomMatrix()));
                         aContent = primitive2d::Primitive2DContainer { xEmbedRefBitmap };
                     }
diff --git a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx
index 66264ae9a039..c0c0fec7d41a 100644
--- a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx
@@ -33,6 +33,7 @@
 #include <basegfx/raster/bzpixelraster.hxx>
 #include <vcl/BitmapTools.hxx>
 #include <comphelper/threadpool.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
 
 using namespace com::sun::star;
 
@@ -468,7 +469,10 @@ namespace drawinglayer::primitive2d
                         aNew2DTransform *= aInverseOToV;
 
                         // create bitmap primitive and add
-                        rContainer.push_back(new BitmapPrimitive2D(maOldRenderedBitmap, aNew2DTransform));
+                        rContainer.push_back(
+                            new BitmapPrimitive2D(
+                                VCLUnoHelper::CreateVCLXBitmap(maOldRenderedBitmap),
+                                aNew2DTransform));
 
                         // test: Allow to add an outline in the debugger when tests are needed
                         static bool bAddOutlineToCreated3DSceneRepresentation(false); // loplugin:constvars:ignore
diff --git a/drawinglayer/source/primitive2d/wallpaperprimitive2d.cxx b/drawinglayer/source/primitive2d/wallpaperprimitive2d.cxx
index 921483861b60..d8926824f65a 100644
--- a/drawinglayer/source/primitive2d/wallpaperprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/wallpaperprimitive2d.cxx
@@ -26,6 +26,7 @@
 #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
 #include <vcl/graph.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
 
 
 namespace drawinglayer::primitive2d
@@ -53,7 +54,7 @@ namespace drawinglayer::primitive2d
 
                         Primitive2DReference xReference(
                             new BitmapPrimitive2D(
-                                getBitmapEx(),
+                                VCLUnoHelper::CreateVCLXBitmap(getBitmapEx()),
                                 aObjectTransform));
 
                         aRetval = xReference;
@@ -152,7 +153,7 @@ namespace drawinglayer::primitive2d
 
                             Primitive2DReference xReference(
                                 new BitmapPrimitive2D(
-                                    getBitmapEx(),
+                                    VCLUnoHelper::CreateVCLXBitmap(getBitmapEx()),
                                     aObjectTransform));
                             aRetval = xReference;
 
diff --git a/drawinglayer/source/processor2d/hittestprocessor2d.cxx b/drawinglayer/source/processor2d/hittestprocessor2d.cxx
index 525dceaef429..eb57052de924 100644
--- a/drawinglayer/source/processor2d/hittestprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/hittestprocessor2d.cxx
@@ -33,6 +33,7 @@
 #include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx>
 #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
 #include <comphelper/lok.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
 
 namespace drawinglayer::processor2d
 {
@@ -432,8 +433,8 @@ namespace drawinglayer::processor2d
                         if(!aRange.isEmpty())
                         {
                             const primitive2d::BitmapPrimitive2D& rBitmapCandidate(static_cast< const primitive2d::BitmapPrimitive2D& >(rCandidate));
-                            const BitmapEx& rBitmapEx = rBitmapCandidate.getBitmapEx();
-                            const Size& rSizePixel(rBitmapEx.GetSizePixel());
+                            const BitmapEx aBitmapEx(VCLUnoHelper::GetBitmap(rBitmapCandidate.getXBitmap()));
+                            const Size& rSizePixel(aBitmapEx.GetSizePixel());
 
                             // When tiled rendering, don't bother with the pixel size of the candidate.
                             if(rSizePixel.Width() && rSizePixel.Height() && !comphelper::LibreOfficeKit::isActive())
@@ -451,7 +452,7 @@ namespace drawinglayer::processor2d
                                     const sal_Int32 nX(basegfx::fround(aRelativePoint.getX() * rSizePixel.Width()));
                                     const sal_Int32 nY(basegfx::fround(aRelativePoint.getY() * rSizePixel.Height()));
 
-                                    mbHit = (0xff != rBitmapEx.GetTransparency(nX, nY));
+                                    mbHit = (0xff != aBitmapEx.GetTransparency(nX, nY));
                                 }
                             }
                             else
diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx
index ced2cc96998c..34ff2992934f 100644
--- a/drawinglayer/source/processor2d/vclprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx
@@ -66,6 +66,8 @@
 // for support of Title/Description in all apps when embedding pictures
 #include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx>
 
+#include <toolkit/helper/vclunohelper.hxx>
+
 using namespace com::sun::star;
 
 namespace
@@ -346,7 +348,7 @@ namespace drawinglayer::processor2d
         // direct draw of transformed BitmapEx primitive
         void VclProcessor2D::RenderBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate)
         {
-            BitmapEx aBitmapEx(rBitmapCandidate.getBitmapEx());
+            BitmapEx aBitmapEx(VCLUnoHelper::GetBitmap(rBitmapCandidate.getXBitmap()));
             const basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rBitmapCandidate.getTransform());
 
             if(maBColorModifierStack.count())
diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx
index 2758509f9856..bc04cd3e8df3 100644
--- a/drawinglayer/source/tools/emfphelperdata.cxx
+++ b/drawinglayer/source/tools/emfphelperdata.cxx
@@ -55,6 +55,7 @@
 #include <vcl/svapp.hxx>
 #include <vcl/settings.hxx>
 #include <i18nlangtag/languagetag.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
 
 #include <algorithm>
 
@@ -1510,7 +1511,9 @@ namespace emfplushelper
                                 if (aSize.Width() > 0 && aSize.Height() > 0)
                                 {
                                     mrTargetHolders.Current().append(
-                                        std::make_unique<drawinglayer::primitive2d::BitmapPrimitive2D>(aBmp, aTransformMatrix));
+                                        std::make_unique<drawinglayer::primitive2d::BitmapPrimitive2D>(
+                                            VCLUnoHelper::CreateVCLXBitmap(aBmp),
+                                            aTransformMatrix));
                                 }
                                 else
                                 {
diff --git a/drawinglayer/source/tools/wmfemfhelper.cxx b/drawinglayer/source/tools/wmfemfhelper.cxx
index bb4146ca9444..bef598449ce9 100644
--- a/drawinglayer/source/tools/wmfemfhelper.cxx
+++ b/drawinglayer/source/tools/wmfemfhelper.cxx
@@ -59,6 +59,7 @@
 #include <i18nlangtag/languagetag.hxx>
 #include <emfplushelper.hxx>
 #include <numeric>
+#include <toolkit/helper/vclunohelper.hxx>
 
 namespace drawinglayer::primitive2d
 {
@@ -661,7 +662,7 @@ namespace wmfemfhelper
 
             rTarget.append(
                 std::make_unique<drawinglayer::primitive2d::BitmapPrimitive2D>(
-                    rBitmapEx,
+                    VCLUnoHelper::CreateVCLXBitmap(rBitmapEx),
                     aObjectTransform));
         }
     }
diff --git a/filter/source/pdf/pdfdecomposer.cxx b/filter/source/pdf/pdfdecomposer.cxx
index a03e70bd5d1a..15e500343f8f 100644
--- a/filter/source/pdf/pdfdecomposer.cxx
+++ b/filter/source/pdf/pdfdecomposer.cxx
@@ -20,6 +20,7 @@
 #include <vcl/pdfread.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/outdev.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
 
 #include <com/sun/star/graphic/XPdfDecomposer.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
@@ -84,7 +85,8 @@ uno::Sequence<uno::Reference<graphic::XPrimitive2D>> SAL_CALL XPdfDecomposer::ge
 
     // create primitive
     uno::Sequence<uno::Reference<graphic::XPrimitive2D>> aSequence(1);
-    aSequence[0] = new drawinglayer::primitive2d::BitmapPrimitive2D(aReplacement, aBitmapTransform);
+    aSequence[0] = new drawinglayer::primitive2d::BitmapPrimitive2D(
+        VCLUnoHelper::CreateVCLXBitmap(aReplacement), aBitmapTransform);
 
     return aSequence;
 }
diff --git a/include/drawinglayer/primitive2d/bitmapprimitive2d.hxx b/include/drawinglayer/primitive2d/bitmapprimitive2d.hxx
index d35a2699b0af..4d84a02f8e06 100644
--- a/include/drawinglayer/primitive2d/bitmapprimitive2d.hxx
+++ b/include/drawinglayer/primitive2d/bitmapprimitive2d.hxx
@@ -23,23 +23,37 @@
 #include <drawinglayer/drawinglayerdllapi.h>
 
 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
-#include <vcl/bitmapex.hxx>
 #include <basegfx/matrix/b2dhommatrix.hxx>
 
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace awt
+{
+class XBitmap;
+}
+}
+}
+}
+
 namespace drawinglayer::primitive2d
 {
 /** BitmapPrimitive2D class
 
     This class is the central primitive for Bitmap-based primitives.
-    It provides RGBA-based bitmaps, currently using a BitmapEx from VCL.
-    This may change in the future to any other, maybe more general base
-    class providing 24bit RGBA.
+    To keep it independent of Bitmap implementations, use UNO API
+    XBitmap object as wrapper due to formally used class Bitmap being
+    vcl-dependent and requiring linking against it. Use VCLUnoHelper
+    to convert awt::XBitmap <-> Bitmap
  */
 class DRAWINGLAYER_DLLPUBLIC BitmapPrimitive2D final : public BasePrimitive2D
 {
 private:
-    /// the RGBA Bitmap-data
-    BitmapEx maBitmapEx;
+    /// the Bitmap-data
+    css::uno::Reference<css::awt::XBitmap> maXBitmap;
 
     /** the object transformation from unit coordinates, defining
         size, shear, rotate and position
@@ -48,10 +62,11 @@ private:
 
 public:
     /// constructor
-    BitmapPrimitive2D(const BitmapEx& rBitmapEx, const basegfx::B2DHomMatrix& rTransform);
+    BitmapPrimitive2D(const css::uno::Reference<css::awt::XBitmap>& rXBitmap,
+                      const basegfx::B2DHomMatrix& rTransform);
 
     /// data read access
-    const BitmapEx& getBitmapEx() const { return maBitmapEx; }
+    const css::uno::Reference<css::awt::XBitmap>& getXBitmap() const { return maXBitmap; }
     const basegfx::B2DHomMatrix& getTransform() const { return maTransform; }
 
     /// compare operator
diff --git a/include/toolkit/helper/vclunohelper.hxx b/include/toolkit/helper/vclunohelper.hxx
index 8589ff9e7bd5..b0804b3d4657 100644
--- a/include/toolkit/helper/vclunohelper.hxx
+++ b/include/toolkit/helper/vclunohelper.hxx
@@ -76,6 +76,7 @@ public:
     // Bitmap
     static BitmapEx                                                         GetBitmap( const css::uno::Reference< css::awt::XBitmap>& rxBitmap );
     static css::uno::Reference< css::awt::XBitmap>    CreateBitmap( const BitmapEx& rBitmap );
+    static css::uno::Reference< css::awt::XBitmap>    CreateVCLXBitmap( const BitmapEx& rBitmap );
 
     // Window
     static VclPtr< vcl::Window >                                                          GetWindow( const css::uno::Reference< css::awt::XWindow>& rxWindow );
diff --git a/svgio/CppunitTest_svgio.mk b/svgio/CppunitTest_svgio.mk
index 24933397d7d3..c6f4db91fc60 100644
--- a/svgio/CppunitTest_svgio.mk
+++ b/svgio/CppunitTest_svgio.mk
@@ -38,6 +38,7 @@ $(eval $(call gb_CppunitTest_use_libraries,svgio,\
     svt \
     test \
     unotest \
+    tk \
     tl \
     vcl \
 ))
diff --git a/svgio/Library_svgio.mk b/svgio/Library_svgio.mk
index 3a85da62d820..449c17f61196 100644
--- a/svgio/Library_svgio.mk
+++ b/svgio/Library_svgio.mk
@@ -38,6 +38,7 @@ $(eval $(call gb_Library_use_libraries,svgio,\
     cppu \
     cppuhelper \
     sal \
+    tk \
     tl \
     sax \
     vcl \
diff --git a/svgio/source/svgreader/svgimagenode.cxx b/svgio/source/svgreader/svgimagenode.cxx
index 8cb6f4a05917..73b1103dd44f 100644
--- a/svgio/source/svgreader/svgimagenode.cxx
+++ b/svgio/source/svgreader/svgimagenode.cxx
@@ -32,6 +32,7 @@
 #include <sal/log.hxx>
 #include <drawinglayer/geometry/viewinformation2d.hxx>
 #include <comphelper/base64.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
 
 namespace svgio::svgreader
 {
@@ -304,7 +305,7 @@ namespace svgio::svgreader
                 // as transformation to map the picture data correctly
                 aNewTarget.resize(1);
                 aNewTarget[0] = new drawinglayer::primitive2d::BitmapPrimitive2D(
-                    aBitmapEx,
+                    VCLUnoHelper::CreateVCLXBitmap(aBitmapEx),
                     basegfx::utils::createScaleTranslateB2DHomMatrix(
                         aViewBox.getRange(),
                         aViewBox.getMinimum()));
diff --git a/svx/source/sdr/contact/viewcontactofgraphic.cxx b/svx/source/sdr/contact/viewcontactofgraphic.cxx
index fab6105dbfe5..5cfd46b697af 100644
--- a/svx/source/sdr/contact/viewcontactofgraphic.cxx
+++ b/svx/source/sdr/contact/viewcontactofgraphic.cxx
@@ -46,6 +46,7 @@
 #include <editeng/colritem.hxx>
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
 #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
 
 #include <bitmaps.hlst>
 
@@ -211,7 +212,8 @@ namespace sdr::contact
                     xRetval.push_back(
                         drawinglayer::primitive2d::Primitive2DReference(
                             new drawinglayer::primitive2d::BitmapPrimitive2D(
-                                aDraftBitmap, aBitmapMatrix)));
+                                VCLUnoHelper::CreateVCLXBitmap(aDraftBitmap),
+                                aBitmapMatrix)));
 
                     // consume bitmap size in X
                     aScale.setX(std::max(0.0, aScale.getX() - (fWidth + fDistance)));
diff --git a/svx/source/sdr/overlay/overlaytools.cxx b/svx/source/sdr/overlay/overlaytools.cxx
index 6f58ceed190b..e3988797b0de 100644
--- a/svx/source/sdr/overlay/overlaytools.cxx
+++ b/svx/source/sdr/overlay/overlaytools.cxx
@@ -33,6 +33,7 @@
 #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/settings.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
 
 
 namespace drawinglayer::primitive2d
@@ -179,7 +180,10 @@ ImplPrimitive2DIDBlock(OverlayStaticRectanglePrimitive, PRIMITIVE2D_ID_OVERLAYRE
             // add BasePosition
             aTransform.translate(getBasePosition().getX(), getBasePosition().getY());
 
-            rContainer.push_back(new BitmapPrimitive2D(getBitmapEx(), aTransform));
+            rContainer.push_back(
+                new BitmapPrimitive2D(
+                    VCLUnoHelper::CreateVCLXBitmap(getBitmapEx()),
+                    aTransform));
         }
 
         bool OverlayBitmapExPrimitive::operator==( const BasePrimitive2D& rPrimitive ) const
diff --git a/toolkit/inc/awt/vclxbitmap.hxx b/toolkit/inc/awt/vclxbitmap.hxx
index 38ba3642678a..abf40aa9e9f0 100644
--- a/toolkit/inc/awt/vclxbitmap.hxx
+++ b/toolkit/inc/awt/vclxbitmap.hxx
@@ -23,6 +23,7 @@
 #include <com/sun/star/awt/XDisplayBitmap.hpp>
 #include <com/sun/star/lang/XTypeProvider.hpp>
 #include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/util/XAccounting.hpp>
 #include <comphelper/servicehelper.hxx>
 #include <cppuhelper/implbase.hxx>
 #include <osl/mutex.hxx>
@@ -34,7 +35,8 @@
 class VCLXBitmap final : public cppu::WeakImplHelper<
                             css::awt::XBitmap,
                             css::awt::XDisplayBitmap,
-                            css::lang::XUnoTunnel>
+                            css::lang::XUnoTunnel,
+                            css::util::XAccounting>
 {
     ::osl::Mutex    maMutex;
     BitmapEx        maBitmap;
@@ -43,6 +45,10 @@ class VCLXBitmap final : public cppu::WeakImplHelper<
 
 
 public:
+    // linine constructors
+    VCLXBitmap() : maMutex(), maBitmap() {}
+    VCLXBitmap(const BitmapEx& rBitmapEx) : maMutex(), maBitmap(rBitmapEx) {}
+
     void            SetBitmap( const BitmapEx& rBmp )   { maBitmap = rBmp; }
     const BitmapEx& GetBitmap() const                   { return maBitmap; }
 
@@ -53,6 +59,9 @@ public:
     css::awt::Size                 SAL_CALL getSize() override;
     css::uno::Sequence< sal_Int8 > SAL_CALL getDIB() override;
     css::uno::Sequence< sal_Int8 > SAL_CALL getMaskDIB() override;
+
+    // XAccounting
+    sal_Int64 SAL_CALL estimateUsage() override;
 };
 
 
diff --git a/toolkit/source/awt/vclxbitmap.cxx b/toolkit/source/awt/vclxbitmap.cxx
index 9bc045c2d1a1..4b08ebd40a7f 100644
--- a/toolkit/source/awt/vclxbitmap.cxx
+++ b/toolkit/source/awt/vclxbitmap.cxx
@@ -55,4 +55,11 @@ css::uno::Sequence< sal_Int8 > VCLXBitmap::getMaskDIB()
     return vcl::bitmap::GetMaskDIB(maBitmap);
 }
 
+sal_Int64 SAL_CALL VCLXBitmap::estimateUsage()
+{
+    ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+    return maBitmap.GetSizeBytes();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/toolkit/source/helper/vclunohelper.cxx b/toolkit/source/helper/vclunohelper.cxx
index 696ed16e1140..e1f0bf38d1ec 100644
--- a/toolkit/source/helper/vclunohelper.cxx
+++ b/toolkit/source/helper/vclunohelper.cxx
@@ -101,6 +101,11 @@ css::uno::Reference< css::awt::XBitmap> VCLUnoHelper::CreateBitmap( const Bitmap
     return xBmp;
 }
 
+css::uno::Reference< css::awt::XBitmap> VCLUnoHelper::CreateVCLXBitmap( const BitmapEx& rBitmap )
+{
+    return css::uno::Reference< css::awt::XBitmap >(new VCLXBitmap(rBitmap));
+}
+
 VclPtr< vcl::Window > VCLUnoHelper::GetWindow( const css::uno::Reference< css::awt::XWindow>& rxWindow )
 {
     VCLXWindow* pVCLXWindow = comphelper::getUnoTunnelImplementation<VCLXWindow>( rxWindow );


More information about the Libreoffice-commits mailing list