summaryrefslogtreecommitdiff
path: root/vcl/source/window/window.cxx
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-05-04 11:32:11 +0200
committerLuboš Luňák <l.lunak@collabora.com>2021-05-06 11:22:47 +0200
commit402acbcfadbc8fd9f45330b46a4bfaad3e02eb39 (patch)
treebb12f967f882208c1b13febbca435f8b68999c57 /vcl/source/window/window.cxx
parent834822413d687572691753c33d837ffdb5064f2b (diff)
make it possible to write canvas unittests
One of the problems is that canvas apparently works only with windows, but tests obviously need an offscreen surface. This patch moves Window::GetCanvas() to OutputDevice, and makes vclcanvas capable of working with OutputDevice classes that are not windows. Other canvas implementations still don't work, but presumably at least cairocanvas could be fixed too. This commit adds a "simple" test that just draws a line and tries to verify it's been drawn properly. Adding another test should be a matter of basing it on this existing one, and then copy&pasting the complicated UNO way of drawing using canvas from somewhere, such as canvas/workben/canvasdemo.cxx. Change-Id: I42db12b09433763cd31c3dd497c10157424b8598 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115117 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/source/window/window.cxx')
-rw-r--r--vcl/source/window/window.cxx29
1 files changed, 2 insertions, 27 deletions
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 94c8cc2df391..44f5438e3864 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -154,13 +154,7 @@ void Window::dispose()
// Dispose of the canvas implementation (which, currently, has an
// own wrapper window as a child to this one.
- Reference< css::rendering::XCanvas > xCanvas( mpWindowImpl->mxCanvas );
- if( xCanvas.is() )
- {
- Reference < XComponent > xCanvasComponent( xCanvas, UNO_QUERY );
- if( xCanvasComponent.is() )
- xCanvasComponent->dispose();
- }
+ ImplDisposeCanvas();
mpWindowImpl->mbInDispose = true;
@@ -3680,13 +3674,6 @@ bool Window::IsNativeWidgetEnabled() const
Reference< css::rendering::XCanvas > Window::ImplGetCanvas( bool bSpriteCanvas ) const
{
- // try to retrieve hard reference from weak member
- Reference< css::rendering::XCanvas > xCanvas( mpWindowImpl->mxCanvas );
-
- // canvas still valid? Then we're done.
- if( xCanvas.is() )
- return xCanvas;
-
Sequence< Any > aArg(5);
// Feed any with operating system's window handle
@@ -3707,6 +3694,7 @@ Reference< css::rendering::XCanvas > Window::ImplGetCanvas( bool bSpriteCanvas )
static vcl::DeleteUnoReferenceOnDeinit<XMultiComponentFactory> xStaticCanvasFactory(
css::rendering::CanvasFactory::create( xContext ) );
Reference<XMultiComponentFactory> xCanvasFactory(xStaticCanvasFactory.get());
+ Reference< css::rendering::XCanvas > xCanvas;
if(xCanvasFactory.is())
{
@@ -3740,25 +3728,12 @@ Reference< css::rendering::XCanvas > Window::ImplGetCanvas( bool bSpriteCanvas )
UNO_QUERY );
}
- mpWindowImpl->mxCanvas = xCanvas;
}
// no factory??? Empty reference, then.
return xCanvas;
}
-Reference< css::rendering::XCanvas > Window::GetCanvas() const
-{
- return ImplGetCanvas( false );
-}
-
-Reference< css::rendering::XSpriteCanvas > Window::GetSpriteCanvas() const
-{
- Reference< css::rendering::XSpriteCanvas > xSpriteCanvas(
- ImplGetCanvas( true ), UNO_QUERY );
- return xSpriteCanvas;
-}
-
OUString Window::GetSurroundingText() const
{
return OUString();