summaryrefslogtreecommitdiff
path: root/canvas/source
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-12-14 21:30:07 +0100
committerStephan Bergmann <sbergman@redhat.com>2022-12-17 09:22:46 +0000
commit53bc223cb3288e32a417696ee61c29e5f01f209d (patch)
tree65613ff8cce4c7c42dde591b07d735e5d269039f /canvas/source
parent3cb601245676a67f5cd523e4f400f777b3e53dc6 (diff)
loplugin:unocast (cairocanvas::RepaintTarget)
(See the upcoming commit introducing that loplugin:unocast on why such dynamic_casts from UNO types are dangerous.) Change-Id: Ida4ccf961301cf50396e80d9bbdc4b9925bd81f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144350 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'canvas/source')
-rw-r--r--canvas/source/cairo/cairo_cachedbitmap.cxx3
-rw-r--r--canvas/source/cairo/cairo_canvas.cxx4
-rw-r--r--canvas/source/cairo/cairo_canvas.hxx6
-rw-r--r--canvas/source/cairo/cairo_canvasbitmap.cxx4
-rw-r--r--canvas/source/cairo/cairo_canvasbitmap.hxx7
-rw-r--r--canvas/source/cairo/cairo_canvascustomsprite.cxx4
-rw-r--r--canvas/source/cairo/cairo_canvascustomsprite.hxx7
-rw-r--r--canvas/source/cairo/cairo_repainttarget.hxx14
-rw-r--r--canvas/source/cairo/cairo_spritecanvas.cxx4
-rw-r--r--canvas/source/cairo/cairo_spritecanvas.hxx7
10 files changed, 54 insertions, 6 deletions
diff --git a/canvas/source/cairo/cairo_cachedbitmap.cxx b/canvas/source/cairo/cairo_cachedbitmap.cxx
index d829e27ac3b5..56ca57c913bc 100644
--- a/canvas/source/cairo/cairo_cachedbitmap.cxx
+++ b/canvas/source/cairo/cairo_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 "cairo_cachedbitmap.hxx"
#include "cairo_repainttarget.hxx"
@@ -59,7 +60,7 @@ namespace cairocanvas
"CachedBitmap::doRedraw(): base called with changed view transform "
"(told otherwise during construction)" );
- 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/cairo/cairo_canvas.cxx b/canvas/source/cairo/cairo_canvas.cxx
index 60b807e8196b..6c9e4fe296df 100644
--- a/canvas/source/cairo/cairo_canvas.cxx
+++ b/canvas/source/cairo/cairo_canvas.cxx
@@ -128,6 +128,10 @@ namespace cairocanvas
return { getServiceName() };
}
+ sal_Int64 Canvas::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) {
+ return RepaintTarget::getSomething(aIdentifier);
+ }
+
bool Canvas::repaint( const SurfaceSharedPtr& pSurface,
const rendering::ViewState& viewState,
const rendering::RenderState& renderState )
diff --git a/canvas/source/cairo/cairo_canvas.hxx b/canvas/source/cairo/cairo_canvas.hxx
index 0c41a8a5c0d3..e9b7863b1741 100644
--- a/canvas/source/cairo/cairo_canvas.hxx
+++ b/canvas/source/cairo/cairo_canvas.hxx
@@ -50,7 +50,8 @@ namespace cairocanvas
css::util::XUpdatable,
css::beans::XPropertySet,
css::lang::XServiceName,
- css::lang::XServiceInfo > GraphicDeviceBase_Base;
+ css::lang::XServiceInfo,
+ css::lang::XUnoTunnel > GraphicDeviceBase_Base;
typedef ::canvas::GraphicDeviceBase< ::canvas::BaseMutexHelper< GraphicDeviceBase_Base >,
DeviceHelper,
::osl::MutexGuard,
@@ -122,6 +123,9 @@ namespace cairocanvas
virtual OUString SAL_CALL getImplementationName() 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
virtual bool repaint( const ::cairo::SurfaceSharedPtr& pSurface,
const css::rendering::ViewState& viewState,
diff --git a/canvas/source/cairo/cairo_canvasbitmap.cxx b/canvas/source/cairo/cairo_canvasbitmap.cxx
index ebf4f26c5321..a4f172088a17 100644
--- a/canvas/source/cairo/cairo_canvasbitmap.cxx
+++ b/canvas/source/cairo/cairo_canvasbitmap.cxx
@@ -143,6 +143,10 @@ namespace cairocanvas
return aRV;
}
+ sal_Int64 CanvasBitmap::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) {
+ return RepaintTarget::getSomething(aIdentifier);
+ }
+
OUString SAL_CALL CanvasBitmap::getImplementationName( )
{
return "CairoCanvas.CanvasBitmap";
diff --git a/canvas/source/cairo/cairo_canvasbitmap.hxx b/canvas/source/cairo/cairo_canvasbitmap.hxx
index 8826bc82ebe2..cc32408c26a1 100644
--- a/canvas/source/cairo/cairo_canvasbitmap.hxx
+++ b/canvas/source/cairo/cairo_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>
@@ -42,7 +43,8 @@ namespace cairocanvas
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;
class CanvasBitmapSpriteSurface_Base :
public ::canvas::BaseMutexHelper<CanvasBitmapBase_Base>,
public SurfaceProvider
@@ -113,6 +115,9 @@ namespace cairocanvas
virtual css::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle) override;
virtual void SAL_CALL setFastPropertyValue(sal_Int32, const css::uno::Any&) override {}
+ // XUnoTunnel
+ sal_Int64 SAL_CALL getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) override;
+
private:
SurfaceProviderRef mpSurfaceProvider;
::cairo::SurfaceSharedPtr mpBufferSurface;
diff --git a/canvas/source/cairo/cairo_canvascustomsprite.cxx b/canvas/source/cairo/cairo_canvascustomsprite.cxx
index f7fffb6e50be..98ead7036b34 100644
--- a/canvas/source/cairo/cairo_canvascustomsprite.cxx
+++ b/canvas/source/cairo/cairo_canvascustomsprite.cxx
@@ -146,6 +146,10 @@ namespace cairocanvas
{
return { "com.sun.star.rendering.CanvasCustomSprite" };
}
+
+ sal_Int64 CanvasCustomSprite::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) {
+ return RepaintTarget::getSomething(aIdentifier);
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/cairo/cairo_canvascustomsprite.hxx b/canvas/source/cairo/cairo_canvascustomsprite.hxx
index ffe766ab0966..03890bf1985d 100644
--- a/canvas/source/cairo/cairo_canvascustomsprite.hxx
+++ b/canvas/source/cairo/cairo_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>
@@ -46,7 +47,8 @@ namespace cairocanvas
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
@@ -113,6 +115,9 @@ namespace cairocanvas
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( const ::cairo::CairoSharedPtr& pCairo,
bool bBufferedUpdate ) const override;
diff --git a/canvas/source/cairo/cairo_repainttarget.hxx b/canvas/source/cairo/cairo_repainttarget.hxx
index 94d3d3845b3e..3fab51dbc3bb 100644
--- a/canvas/source/cairo/cairo_repainttarget.hxx
+++ b/canvas/source/cairo/cairo_repainttarget.hxx
@@ -21,6 +21,9 @@
#include <com/sun/star/rendering/RenderState.hpp>
#include <com/sun/star/rendering/ViewState.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <comphelper/servicehelper.hxx>
+#include <sal/types.h>
#include <vcl/cairo.hxx>
@@ -33,7 +36,7 @@ namespace cairocanvas
This interface must be implemented on all canvas
implementations that hand out XCachedPrimitives
*/
- class SAL_LOPLUGIN_ANNOTATE("crosscast") RepaintTarget
+ class RepaintTarget
{
public:
virtual ~RepaintTarget() {}
@@ -42,6 +45,15 @@ namespace cairocanvas
virtual bool repaint( const ::cairo::SurfaceSharedPtr& pSurface,
const css::rendering::ViewState& viewState,
const css::rendering::RenderState& renderState ) = 0;
+
+ sal_Int64 getSomething(css::uno::Sequence<sal_Int8> const & id) {
+ return comphelper::getSomethingImpl(id, this);
+ }
+
+ static css::uno::Sequence<sal_Int8> const & getUnoTunnelId() {
+ static comphelper::UnoIdInit const id;
+ return id.getSeq();
+ }
};
}
diff --git a/canvas/source/cairo/cairo_spritecanvas.cxx b/canvas/source/cairo/cairo_spritecanvas.cxx
index 5a394d2718aa..e414f8d8d9b5 100644
--- a/canvas/source/cairo/cairo_spritecanvas.cxx
+++ b/canvas/source/cairo/cairo_spritecanvas.cxx
@@ -151,6 +151,10 @@ namespace cairocanvas
return { getServiceName() };
}
+ sal_Int64 SpriteCanvas::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) {
+ return RepaintTarget::getSomething(aIdentifier);
+ }
+
SurfaceSharedPtr SpriteCanvas::getSurface()
{
return maDeviceHelper.getBufferSurface();
diff --git a/canvas/source/cairo/cairo_spritecanvas.hxx b/canvas/source/cairo/cairo_spritecanvas.hxx
index 7790e68904b0..41a1c5cb24d5 100644
--- a/canvas/source/cairo/cairo_spritecanvas.hxx
+++ b/canvas/source/cairo/cairo_spritecanvas.hxx
@@ -23,6 +23,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/lang/XServiceName.hpp>
#include <com/sun/star/lang/XServiceInfo.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>
@@ -54,7 +55,8 @@ namespace cairocanvas
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,
::osl::MutexGuard,
@@ -130,6 +132,9 @@ namespace cairocanvas
virtual OUString SAL_CALL getImplementationName() override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+ // XUnoTunnel
+ sal_Int64 SAL_CALL getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) override;
+
// SurfaceProvider
virtual ::cairo::SurfaceSharedPtr getSurface() override;
virtual ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, int aContent ) override;