summaryrefslogtreecommitdiff
path: root/canvas
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-12-13 14:10:42 +0100
committerStephan Bergmann <sbergman@redhat.com>2022-12-14 08:54:15 +0000
commit276e3ccbdd3259ec3daf8a1a98fa7f406b14e21c (patch)
tree17e0d9934b8f85ffe6dd8b8b4bbf3ad859bb4126 /canvas
parentcbb3f697245d7d57439cb5019e9f9834cb9cd35f (diff)
loplugin:unocast (vclcanvas::RepaintTarget)
(The overall inheritance hierarchies of the classes deriving from RepaintTarget are so over-engineered that it looks easier to make each of those classes derive from css::uno::XUnoTunnel individually, rather than deriving RepaintTarget from something like cppu::WeakImplHelper<css::uno::XUnoTunnel>. And see the upcoming commit introducing that loplugin:unocast on why such dynamic_casts from UNO types are dangerous.) Change-Id: I4bcfad4049a2fb366768602a432c1282c2bf477e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144140 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'canvas')
-rw-r--r--canvas/source/vcl/cachedbitmap.cxx3
-rw-r--r--canvas/source/vcl/canvas.cxx5
-rw-r--r--canvas/source/vcl/canvas.hxx7
-rw-r--r--canvas/source/vcl/canvasbitmap.cxx5
-rw-r--r--canvas/source/vcl/canvasbitmap.hxx7
-rw-r--r--canvas/source/vcl/canvascustomsprite.cxx5
-rw-r--r--canvas/source/vcl/canvascustomsprite.hxx7
-rw-r--r--canvas/source/vcl/repainttarget.hxx11
-rw-r--r--canvas/source/vcl/spritecanvas.cxx5
-rw-r--r--canvas/source/vcl/spritecanvas.hxx7
10 files changed, 56 insertions, 6 deletions
diff --git a/canvas/source/vcl/cachedbitmap.cxx b/canvas/source/vcl/cachedbitmap.cxx
index 60b5f7986c55..2364c073e1fa 100644
--- a/canvas/source/vcl/cachedbitmap.cxx
+++ b/canvas/source/vcl/cachedbitmap.cxx
@@ -23,6 +23,7 @@
#include <com/sun/star/rendering/RepaintResult.hpp>
#include <utility>
#include <comphelper/diagnose_ex.hxx>
+#include <comphelper/servicehelper.hxx>
#include "cachedbitmap.hxx"
#include "repainttarget.hxx"
@@ -70,7 +71,7 @@ namespace vclcanvas
if( rNewState.Clip != rOldState.Clip )
return rendering::RepaintResult::FAILED;
- RepaintTarget* pTarget = dynamic_cast< RepaintTarget* >(rTargetCanvas.get());
+ RepaintTarget* pTarget = comphelper::getFromUnoTunnel< RepaintTarget >(rTargetCanvas);
ENSURE_OR_THROW( pTarget,
"CachedBitmap::redraw(): cannot cast target to RepaintTarget" );
diff --git a/canvas/source/vcl/canvas.cxx b/canvas/source/vcl/canvas.cxx
index 7e38276e06d3..5cbda63a50ab 100644
--- a/canvas/source/vcl/canvas.cxx
+++ b/canvas/source/vcl/canvas.cxx
@@ -24,6 +24,7 @@
#include <com/sun/star/lang/NoSupportException.hpp>
#include <sal/log.hxx>
#include <comphelper/diagnose_ex.hxx>
+#include <comphelper/servicehelper.hxx>
#include <vcl/outdev.hxx>
#include "outdevholder.hxx"
@@ -96,6 +97,10 @@ namespace vclcanvas
return "com.sun.star.rendering.Canvas.VCL";
}
+ sal_Int64 Canvas::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) {
+ return comphelper::getSomethingImpl(aIdentifier, static_cast<RepaintTarget *>(this));
+ }
+
bool Canvas::repaint( const GraphicObjectSharedPtr& rGrf,
const rendering::ViewState& viewState,
const rendering::RenderState& renderState,
diff --git a/canvas/source/vcl/canvas.hxx b/canvas/source/vcl/canvas.hxx
index be7d7858e3ad..c01b8ccfcca4 100644
--- a/canvas/source/vcl/canvas.hxx
+++ b/canvas/source/vcl/canvas.hxx
@@ -22,6 +22,7 @@
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/lang/XServiceName.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/util/XUpdatable.hpp>
#include <com/sun/star/rendering/XBitmapCanvas.hpp>
#include <com/sun/star/rendering/XIntegerBitmap.hpp>
@@ -48,7 +49,8 @@ namespace vclcanvas
css::lang::XMultiServiceFactory,
css::util::XUpdatable,
css::beans::XPropertySet,
- css::lang::XServiceName > GraphicDeviceBase_Base;
+ css::lang::XServiceName,
+ css::lang::XUnoTunnel> GraphicDeviceBase_Base;
typedef ::canvas::GraphicDeviceBase< ::canvas::BaseMutexHelper< GraphicDeviceBase_Base >,
DeviceHelper,
tools::LocalGuard,
@@ -96,6 +98,9 @@ namespace vclcanvas
// XServiceName
virtual OUString SAL_CALL getServiceName( ) override;
+ // XUnoTunnel
+ sal_Int64 SAL_CALL getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) override;
+
// RepaintTarget
virtual bool repaint( const GraphicObjectSharedPtr& rGrf,
const css::rendering::ViewState& viewState,
diff --git a/canvas/source/vcl/canvasbitmap.cxx b/canvas/source/vcl/canvasbitmap.cxx
index 9ae37c2c495a..38aababdf03b 100644
--- a/canvas/source/vcl/canvasbitmap.cxx
+++ b/canvas/source/vcl/canvasbitmap.cxx
@@ -19,6 +19,7 @@
#include <sal/config.h>
+#include <comphelper/servicehelper.hxx>
#include <cppuhelper/supportsservice.hxx>
#include "canvasbitmap.hxx"
@@ -84,6 +85,10 @@ namespace vclcanvas
return { "com.sun.star.rendering.CanvasBitmap" };
}
+ sal_Int64 CanvasBitmap::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) {
+ return comphelper::getSomethingImpl(aIdentifier, static_cast<RepaintTarget *>(this));
+ }
+
BitmapEx CanvasBitmap::getBitmap() const
{
SolarMutexGuard aGuard;
diff --git a/canvas/source/vcl/canvasbitmap.hxx b/canvas/source/vcl/canvasbitmap.hxx
index 1a95ce8c632c..4e64c8b2b6c6 100644
--- a/canvas/source/vcl/canvasbitmap.hxx
+++ b/canvas/source/vcl/canvasbitmap.hxx
@@ -22,6 +22,7 @@
#include <cppuhelper/compbase.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/rendering/XBitmapCanvas.hpp>
#include <com/sun/star/rendering/XIntegerBitmap.hpp>
#include <com/sun/star/beans/XFastPropertySet.hpp>
@@ -44,7 +45,8 @@ namespace vclcanvas
typedef ::cppu::WeakComponentImplHelper< css::rendering::XBitmapCanvas,
css::rendering::XIntegerBitmap,
css::lang::XServiceInfo,
- css::beans::XFastPropertySet > CanvasBitmapBase_Base;
+ css::beans::XFastPropertySet,
+ css::lang::XUnoTunnel> CanvasBitmapBase_Base;
typedef ::canvas::IntegerBitmapBase<
canvas::BitmapCanvasBase2<
::canvas::BaseMutexHelper< CanvasBitmapBase_Base >,
@@ -82,6 +84,9 @@ namespace vclcanvas
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
+ // XUnoTunnel
+ sal_Int64 SAL_CALL getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) override;
+
// RepaintTarget interface
virtual bool repaint( const GraphicObjectSharedPtr& rGrf,
const css::rendering::ViewState& viewState,
diff --git a/canvas/source/vcl/canvascustomsprite.cxx b/canvas/source/vcl/canvascustomsprite.cxx
index 02e9b47fb233..b13fad66b8c6 100644
--- a/canvas/source/vcl/canvascustomsprite.cxx
+++ b/canvas/source/vcl/canvascustomsprite.cxx
@@ -23,6 +23,7 @@
#include <basegfx/point/b2dpoint.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <comphelper/diagnose_ex.hxx>
+#include <comphelper/servicehelper.hxx>
#include <vcl/outdev.hxx>
#include "canvascustomsprite.hxx"
@@ -116,6 +117,10 @@ namespace vclcanvas
return { "com.sun.star.rendering.CanvasCustomSprite" };
}
+ sal_Int64 CanvasCustomSprite::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) {
+ return comphelper::getSomethingImpl(aIdentifier, static_cast<RepaintTarget *>(this));
+ }
+
// Sprite
void CanvasCustomSprite::redraw( OutputDevice& rOutDev,
bool bBufferedUpdate ) const
diff --git a/canvas/source/vcl/canvascustomsprite.hxx b/canvas/source/vcl/canvascustomsprite.hxx
index 1a7d3ccfb69e..6fca0800f0c1 100644
--- a/canvas/source/vcl/canvascustomsprite.hxx
+++ b/canvas/source/vcl/canvascustomsprite.hxx
@@ -23,6 +23,7 @@
#include <comphelper/uno3.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/rendering/XBitmapCanvas.hpp>
#include <com/sun/star/rendering/XCustomSprite.hpp>
#include <com/sun/star/rendering/XIntegerBitmap.hpp>
@@ -43,7 +44,8 @@ namespace vclcanvas
typedef ::cppu::WeakComponentImplHelper< css::rendering::XCustomSprite,
css::rendering::XBitmapCanvas,
css::rendering::XIntegerBitmap,
- css::lang::XServiceInfo > CanvasCustomSpriteBase_Base;
+ css::lang::XServiceInfo,
+ css::lang::XUnoTunnel> CanvasCustomSpriteBase_Base;
/** Mixin Sprite
Have to mixin the Sprite interface before deriving from
@@ -96,6 +98,9 @@ namespace vclcanvas
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+ // XUnoTunnel
+ sal_Int64 SAL_CALL getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) override;
+
// Sprite
virtual void redraw( OutputDevice& rOutDev,
bool bBufferedUpdate ) const override;
diff --git a/canvas/source/vcl/repainttarget.hxx b/canvas/source/vcl/repainttarget.hxx
index b8bac4ab9210..57c45882a3cd 100644
--- a/canvas/source/vcl/repainttarget.hxx
+++ b/canvas/source/vcl/repainttarget.hxx
@@ -19,6 +19,10 @@
#pragma once
+#include <com/sun/star/uno/Sequence.hxx>
+#include <comphelper/servicehelper.hxx>
+#include <sal/types.h>
+
#include "cachedbitmap.hxx"
class Point;
@@ -34,7 +38,7 @@ namespace vclcanvas
This interface must be implemented on all canvas
implementations that hand out XCachedPrimitives
*/
- class SAL_LOPLUGIN_ANNOTATE("crosscast") RepaintTarget
+ class RepaintTarget
{
public:
virtual ~RepaintTarget() {}
@@ -46,6 +50,11 @@ namespace vclcanvas
const ::Point& rPt,
const ::Size& rSz,
const GraphicAttr& rAttr ) const = 0;
+
+ static css::uno::Sequence<sal_Int8> const & getUnoTunnelId() {
+ static comphelper::UnoIdInit const id;
+ return id.getSeq();
+ }
};
}
diff --git a/canvas/source/vcl/spritecanvas.cxx b/canvas/source/vcl/spritecanvas.cxx
index f67783681417..a366b32a5c4c 100644
--- a/canvas/source/vcl/spritecanvas.cxx
+++ b/canvas/source/vcl/spritecanvas.cxx
@@ -24,6 +24,7 @@
#include <com/sun/star/lang/NoSupportException.hpp>
#include <cppuhelper/supportsservice.hxx>
#include <comphelper/diagnose_ex.hxx>
+#include <comphelper/servicehelper.hxx>
#include "spritecanvas.hxx"
#include "outdevholder.hxx"
@@ -161,6 +162,10 @@ namespace vclcanvas
return cppu::supportsService(this, sServiceName);
}
+ sal_Int64 SpriteCanvas::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) {
+ return comphelper::getSomethingImpl(aIdentifier, static_cast<RepaintTarget *>(this));
+ }
+
bool SpriteCanvas::repaint( const GraphicObjectSharedPtr& rGrf,
const rendering::ViewState& viewState,
const rendering::RenderState& renderState,
diff --git a/canvas/source/vcl/spritecanvas.hxx b/canvas/source/vcl/spritecanvas.hxx
index 8f7c76880f51..335d8dcce3e3 100644
--- a/canvas/source/vcl/spritecanvas.hxx
+++ b/canvas/source/vcl/spritecanvas.hxx
@@ -25,6 +25,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XServiceName.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/awt/XWindowListener.hpp>
#include <com/sun/star/util/XUpdatable.hpp>
#include <com/sun/star/rendering/XSpriteCanvas.hpp>
@@ -57,7 +58,8 @@ namespace vclcanvas
css::util::XUpdatable,
css::beans::XPropertySet,
css::lang::XServiceName,
- css::lang::XServiceInfo > WindowGraphicDeviceBase_Base;
+ css::lang::XServiceInfo,
+ css::lang::XUnoTunnel > WindowGraphicDeviceBase_Base;
typedef ::canvas::BufferedGraphicDeviceBase< ::canvas::DisambiguationHelper< WindowGraphicDeviceBase_Base >,
SpriteDeviceHelper,
tools::LocalGuard,
@@ -138,6 +140,9 @@ namespace vclcanvas
virtual OUString SAL_CALL getImplementationName() override;
virtual sal_Bool SAL_CALL supportsService(const OUString&) override;
+ // XUnoTunnel
+ sal_Int64 SAL_CALL getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) override;
+
// RepaintTarget
virtual bool repaint( const GraphicObjectSharedPtr& rGrf,
const css::rendering::ViewState& viewState,