Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <canvas/debug.hxx>
31 : : #include <tools/diagnose_ex.h>
32 : : #include <canvas/verbosetrace.hxx>
33 : : #include <canvas/canvastools.hxx>
34 : :
35 : : #include <com/sun/star/registry/XRegistryKey.hpp>
36 : : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
37 : : #include <com/sun/star/uno/XComponentContext.hpp>
38 : :
39 : : #include <vcl/canvastools.hxx>
40 : : #include <vcl/outdev.hxx>
41 : : #include <vcl/window.hxx>
42 : : #include <vcl/bitmapex.hxx>
43 : :
44 : : #include <basegfx/tools/canvastools.hxx>
45 : :
46 : : #include <algorithm>
47 : :
48 : : #include "spritecanvas.hxx"
49 : : #include "windowoutdevholder.hxx"
50 : :
51 : :
52 : : using namespace ::com::sun::star;
53 : :
54 : : namespace vclcanvas
55 : : {
56 : 0 : SpriteCanvas::SpriteCanvas( const uno::Sequence< uno::Any >& aArguments,
57 : : const uno::Reference< uno::XComponentContext >& rxContext ) :
58 : : maArguments(aArguments),
59 : 0 : mxComponentContext( rxContext )
60 : : {
61 : 0 : }
62 : :
63 : 0 : void SpriteCanvas::initialize()
64 : : {
65 : 0 : SolarMutexGuard aGuard;
66 : :
67 : : // #i64742# Only call initialize when not in probe mode
68 : 0 : if( maArguments.getLength() == 0 )
69 : 0 : return;
70 : :
71 : : OSL_TRACE( "SpriteCanvas created" );
72 : :
73 : : // add our own property to GraphicDevice
74 : : maPropHelper.addProperties(
75 : : ::canvas::PropertySetHelper::MakeMap
76 : : ("UnsafeScrolling",
77 : : boost::bind(&SpriteCanvasHelper::isUnsafeScrolling,
78 : : boost::ref(maCanvasHelper)),
79 : : boost::bind(&SpriteCanvasHelper::enableUnsafeScrolling,
80 : : boost::ref(maCanvasHelper),
81 : : _1))
82 : : ("SpriteBounds",
83 : : boost::bind(&SpriteCanvasHelper::isSpriteBounds,
84 : : boost::ref(maCanvasHelper)),
85 : : boost::bind(&SpriteCanvasHelper::enableSpriteBounds,
86 : : boost::ref(maCanvasHelper),
87 : 0 : _1)));
88 : :
89 : : VERBOSE_TRACE( "VCLSpriteCanvas::initialize called" );
90 : :
91 : 0 : ENSURE_ARG_OR_THROW( maArguments.getLength() >= 1,
92 : : "VCLSpriteCanvas::initialize: wrong number of arguments" );
93 : :
94 : : /* maArguments:
95 : : 0: ptr to creating instance (Window or VirtualDevice)
96 : : 1: SystemEnvData as a streamed Any (or empty for VirtualDevice)
97 : : 2: current bounds of creating instance
98 : : 3: bool, denoting always on top state for Window (always false for VirtualDevice)
99 : : 4: XWindow for creating Window (or empty for VirtualDevice)
100 : : 5: SystemGraphicsData as a streamed Any
101 : : */
102 : 0 : ENSURE_ARG_OR_THROW( maArguments.getLength() >= 4 &&
103 : : maArguments[0].getValueTypeClass() == uno::TypeClass_HYPER &&
104 : : maArguments[4].getValueTypeClass() == uno::TypeClass_INTERFACE,
105 : : "VCLSpriteCanvas::initialize: wrong number of arguments, or wrong types" );
106 : :
107 : 0 : uno::Reference< awt::XWindow > xParentWindow;
108 : 0 : maArguments[4] >>= xParentWindow;
109 : :
110 : 0 : OutDevProviderSharedPtr pOutDev( new WindowOutDevHolder(xParentWindow) );
111 : :
112 : : // setup helper
113 : 0 : maDeviceHelper.init( pOutDev );
114 : 0 : setWindow(uno::Reference<awt::XWindow2>(xParentWindow, uno::UNO_QUERY_THROW));
115 : : maCanvasHelper.init( maDeviceHelper.getBackBuffer(),
116 : : *this,
117 : : maRedrawManager,
118 : : false, // no OutDev state preservation
119 : 0 : false ); // no alpha on surface
120 : :
121 : 0 : maArguments.realloc(0);
122 : : }
123 : :
124 : 0 : SpriteCanvas::~SpriteCanvas()
125 : : {
126 : : OSL_TRACE( "SpriteCanvas destroyed" );
127 : 0 : }
128 : :
129 : :
130 : 0 : void SpriteCanvas::disposeThis()
131 : : {
132 : 0 : SolarMutexGuard aGuard;
133 : :
134 : 0 : mxComponentContext.clear();
135 : :
136 : : // forward to parent
137 : 0 : SpriteCanvasBaseT::disposeThis();
138 : 0 : }
139 : :
140 : 0 : ::sal_Bool SAL_CALL SpriteCanvas::showBuffer( ::sal_Bool bUpdateAll ) throw (uno::RuntimeException)
141 : : {
142 : 0 : return updateScreen( bUpdateAll );
143 : : }
144 : :
145 : 0 : ::sal_Bool SAL_CALL SpriteCanvas::switchBuffer( ::sal_Bool bUpdateAll ) throw (uno::RuntimeException)
146 : : {
147 : 0 : return updateScreen( bUpdateAll );
148 : : }
149 : :
150 : 0 : sal_Bool SAL_CALL SpriteCanvas::updateScreen( sal_Bool bUpdateAll ) throw (uno::RuntimeException)
151 : : {
152 : 0 : SolarMutexGuard aGuard;
153 : :
154 : : // avoid repaints on hidden window (hidden: not mapped to
155 : : // screen). Return failure, since the screen really has _not_
156 : : // been updated (caller should try again later)
157 : : return !mbIsVisible ? false : maCanvasHelper.updateScreen(bUpdateAll,
158 : 0 : mbSurfaceDirty);
159 : : }
160 : :
161 : 0 : ::rtl::OUString SAL_CALL SpriteCanvas::getServiceName( ) throw (::com::sun::star::uno::RuntimeException)
162 : : {
163 : 0 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SPRITECANVAS_SERVICE_NAME ) );
164 : : }
165 : :
166 : 0 : bool SpriteCanvas::repaint( const GraphicObjectSharedPtr& rGrf,
167 : : const rendering::ViewState& viewState,
168 : : const rendering::RenderState& renderState,
169 : : const ::Point& rPt,
170 : : const ::Size& rSz,
171 : : const GraphicAttr& rAttr ) const
172 : : {
173 : 0 : SolarMutexGuard aGuard;
174 : :
175 : 0 : return maCanvasHelper.repaint( rGrf, viewState, renderState, rPt, rSz, rAttr );
176 : : }
177 : 0 : }
178 : :
179 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|