update dev300-m58
[ooovba.git] / canvas / source / null / null_spritecanvas.cxx
blob1e014ed1fed51482ecf591c4c7b57d4bcbf54c61
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: null_spritecanvas.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_canvas.hxx"
34 #include <canvas/debug.hxx>
35 #include <tools/diagnose_ex.h>
36 #include <canvas/verbosetrace.hxx>
37 #include <canvas/canvastools.hxx>
39 #include <osl/mutex.hxx>
41 #include <com/sun/star/registry/XRegistryKey.hpp>
42 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
43 #include <com/sun/star/uno/XComponentContext.hpp>
45 #include <cppuhelper/factory.hxx>
46 #include <cppuhelper/implementationentry.hxx>
47 #include <comphelper/servicedecl.hxx>
49 #include <basegfx/matrix/b2dhommatrix.hxx>
50 #include <basegfx/point/b2dpoint.hxx>
51 #include <basegfx/tools/canvastools.hxx>
52 #include <basegfx/numeric/ftools.hxx>
54 #include "null_spritecanvas.hxx"
57 using namespace ::com::sun::star;
59 #define SERVICE_NAME "com.sun.star.rendering.NullCanvas"
61 namespace nullcanvas
63 SpriteCanvas::SpriteCanvas( const uno::Sequence< uno::Any >& aArguments,
64 const uno::Reference< uno::XComponentContext >& rxContext ) :
65 maArguments(aArguments),
66 mxComponentContext( rxContext )
70 void SpriteCanvas::initialize()
72 // #i64742# Only call initialize when not in probe mode
73 if( maArguments.getLength() == 0 )
74 return;
76 VERBOSE_TRACE( "SpriteCanvas::initialize called" );
78 // At index 1, we expect a system window handle here,
79 // containing a pointer to a valid window, on which to output
80 // At index 2, we expect the current window bound rect
81 ENSURE_ARG_OR_THROW( maArguments.getLength() >= 4 &&
82 maArguments[1].getValueTypeClass() == uno::TypeClass_LONG,
83 "SpriteCanvas::initialize: wrong number of arguments, or wrong types" );
85 awt::Rectangle aRect;
86 maArguments[2] >>= aRect;
87 const ::basegfx::B2ISize aSize(aRect.Width,
88 aRect.Height);
90 sal_Bool bIsFullscreen( sal_False );
91 maArguments[3] >>= bIsFullscreen;
93 // setup helper
94 maDeviceHelper.init( *this,
95 aSize,
96 bIsFullscreen );
97 maCanvasHelper.init( maRedrawManager,
98 *this,
99 aSize,
100 false );
102 maArguments.realloc(0);
105 void SAL_CALL SpriteCanvas::disposing()
107 ::osl::MutexGuard aGuard( m_aMutex );
109 mxComponentContext.clear();
111 // forward to parent
112 SpriteCanvasBaseT::disposing();
115 ::sal_Bool SAL_CALL SpriteCanvas::showBuffer( ::sal_Bool bUpdateAll ) throw (uno::RuntimeException)
117 ::osl::MutexGuard aGuard( m_aMutex );
119 // avoid repaints on hidden window (hidden: not mapped to
120 // screen). Return failure, since the screen really has _not_
121 // been updated (caller should try again later)
122 return !mbIsVisible ? false : SpriteCanvasBaseT::showBuffer( bUpdateAll );
125 ::sal_Bool SAL_CALL SpriteCanvas::switchBuffer( ::sal_Bool bUpdateAll ) throw (uno::RuntimeException)
127 ::osl::MutexGuard aGuard( m_aMutex );
129 // avoid repaints on hidden window (hidden: not mapped to
130 // screen). Return failure, since the screen really has _not_
131 // been updated (caller should try again later)
132 return !mbIsVisible ? false : SpriteCanvasBaseT::switchBuffer( bUpdateAll );
135 sal_Bool SAL_CALL SpriteCanvas::updateScreen( sal_Bool bUpdateAll ) throw (uno::RuntimeException)
137 ::osl::MutexGuard aGuard( m_aMutex );
139 // avoid repaints on hidden window (hidden: not mapped to
140 // screen). Return failure, since the screen really has _not_
141 // been updated (caller should try again later)
142 return !mbIsVisible ? false : maCanvasHelper.updateScreen(
143 ::basegfx::unotools::b2IRectangleFromAwtRectangle(maBounds),
144 bUpdateAll,
145 mbSurfaceDirty );
148 ::rtl::OUString SAL_CALL SpriteCanvas::getServiceName( ) throw (uno::RuntimeException)
150 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME ) );
153 static uno::Reference<uno::XInterface> initCanvas( SpriteCanvas* pCanvas )
155 uno::Reference<uno::XInterface> xRet(static_cast<cppu::OWeakObject*>(pCanvas));
156 pCanvas->initialize();
157 return xRet;
160 namespace sdecl = comphelper::service_decl;
161 sdecl::class_<SpriteCanvas, sdecl::with_args<true> > serviceImpl(&initCanvas);
162 const sdecl::ServiceDecl nullCanvasDecl(
163 serviceImpl,
164 "com.sun.star.comp.rendering.NullCanvas",
165 SERVICE_NAME );
168 // The C shared lib entry points
169 COMPHELPER_SERVICEDECL_EXPORTS1(nullcanvas::nullCanvasDecl)