update dev300-m58
[ooovba.git] / canvas / source / null / null_devicehelper.cxx
blobdead04d314be2b101d4072815d373705e5626e40
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_devicehelper.cxx,v $
10 * $Revision: 1.6 $
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 <canvas/verbosetrace.hxx>
36 #include <canvas/canvastools.hxx>
38 #include <osl/mutex.hxx>
39 #include <rtl/instance.hxx>
40 #include <cppuhelper/compbase1.hxx>
42 #include <com/sun/star/lang/NoSupportException.hpp>
44 #include <basegfx/tools/canvastools.hxx>
45 #include <basegfx/tools/unopolypolygon.hxx>
46 #include <vcl/canvastools.hxx>
48 #include "null_spritecanvas.hxx"
49 #include "null_canvasbitmap.hxx"
50 #include "null_devicehelper.hxx"
53 using namespace ::com::sun::star;
55 namespace nullcanvas
57 DeviceHelper::DeviceHelper() :
58 mpSpriteCanvas( NULL ),
59 maSize(),
60 mbFullScreen(false)
64 void DeviceHelper::init( SpriteCanvas& rSpriteCanvas,
65 const ::basegfx::B2ISize& rSize,
66 bool bFullscreen )
68 mpSpriteCanvas = &rSpriteCanvas;
69 maSize = rSize;
70 mbFullScreen = bFullscreen;
73 void DeviceHelper::disposing()
75 // release all references
76 mpSpriteCanvas = NULL;
79 geometry::RealSize2D DeviceHelper::getPhysicalResolution()
81 return geometry::RealSize2D( 75, 75 );
84 geometry::RealSize2D DeviceHelper::getPhysicalSize()
86 return geometry::RealSize2D( 210, 280 );
89 uno::Reference< rendering::XLinePolyPolygon2D > DeviceHelper::createCompatibleLinePolyPolygon(
90 const uno::Reference< rendering::XGraphicDevice >& /*rDevice*/,
91 const uno::Sequence< uno::Sequence< geometry::RealPoint2D > >& points )
93 // disposed?
94 if( !mpSpriteCanvas )
95 return uno::Reference< rendering::XLinePolyPolygon2D >(); // we're disposed
97 return uno::Reference< rendering::XLinePolyPolygon2D >(
98 new ::basegfx::unotools::UnoPolyPolygon(
99 ::basegfx::unotools::polyPolygonFromPoint2DSequenceSequence( points )));
102 uno::Reference< rendering::XBezierPolyPolygon2D > DeviceHelper::createCompatibleBezierPolyPolygon(
103 const uno::Reference< rendering::XGraphicDevice >& /*rDevice*/,
104 const uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > >& points )
106 // disposed?
107 if( !mpSpriteCanvas )
108 return uno::Reference< rendering::XBezierPolyPolygon2D >(); // we're disposed
110 return uno::Reference< rendering::XBezierPolyPolygon2D >(
111 new ::basegfx::unotools::UnoPolyPolygon(
112 ::basegfx::unotools::polyPolygonFromBezier2DSequenceSequence( points ) ) );
115 uno::Reference< rendering::XBitmap > DeviceHelper::createCompatibleBitmap(
116 const uno::Reference< rendering::XGraphicDevice >& /*rDevice*/,
117 const geometry::IntegerSize2D& size )
119 // disposed?
120 if( !mpSpriteCanvas )
121 return uno::Reference< rendering::XBitmap >(); // we're disposed
123 return uno::Reference< rendering::XBitmap >(
124 new CanvasBitmap(
125 ::basegfx::unotools::b2ISizeFromIntegerSize2D( size ),
126 mpSpriteCanvas,
127 false ));
130 uno::Reference< rendering::XVolatileBitmap > DeviceHelper::createVolatileBitmap(
131 const uno::Reference< rendering::XGraphicDevice >& /*rDevice*/,
132 const geometry::IntegerSize2D& /*size*/ )
134 return uno::Reference< rendering::XVolatileBitmap >();
137 uno::Reference< rendering::XBitmap > DeviceHelper::createCompatibleAlphaBitmap(
138 const uno::Reference< rendering::XGraphicDevice >& /*rDevice*/,
139 const geometry::IntegerSize2D& size )
141 // disposed?
142 if( !mpSpriteCanvas )
143 return uno::Reference< rendering::XBitmap >(); // we're disposed
145 return uno::Reference< rendering::XBitmap >(
146 new CanvasBitmap(
147 ::basegfx::unotools::b2ISizeFromIntegerSize2D( size ),
148 mpSpriteCanvas,
149 true ));
152 uno::Reference< rendering::XVolatileBitmap > DeviceHelper::createVolatileAlphaBitmap(
153 const uno::Reference< rendering::XGraphicDevice >& /*rDevice*/,
154 const geometry::IntegerSize2D& /*size*/ )
156 return uno::Reference< rendering::XVolatileBitmap >();
159 sal_Bool DeviceHelper::hasFullScreenMode()
161 // TODO(F3): offer fullscreen mode the XCanvas way
162 return false;
165 sal_Bool DeviceHelper::enterFullScreenMode( sal_Bool /*bEnter*/ )
167 // TODO(F3): offer fullscreen mode the XCanvas way
168 return false;
171 ::sal_Int32 DeviceHelper::createBuffers( ::sal_Int32 /*nBuffers*/ )
173 // TODO(F3): implement XBufferStrategy interface. For now, we
174 // _always_ will have exactly one backbuffer
175 return 1;
178 void DeviceHelper::destroyBuffers()
180 // TODO(F3): implement XBufferStrategy interface. For now, we
181 // _always_ will have exactly one backbuffer
184 ::sal_Bool DeviceHelper::showBuffer( bool bIsVisible, ::sal_Bool bUpdateAll )
186 // forward to sprite canvas helper
187 if( !bIsVisible || !mpSpriteCanvas )
188 return false;
190 return mpSpriteCanvas->updateScreen( bUpdateAll );
193 ::sal_Bool DeviceHelper::switchBuffer( bool bIsVisible, ::sal_Bool bUpdateAll )
195 // no difference for VCL canvas
196 return showBuffer( bIsVisible, bUpdateAll );
199 uno::Any DeviceHelper::isAccelerated() const
201 return ::com::sun::star::uno::makeAny(false);
204 uno::Any DeviceHelper::getDeviceHandle() const
206 return uno::Any();
209 uno::Any DeviceHelper::getSurfaceHandle() const
211 return uno::Any();
214 namespace
216 struct DeviceColorSpace: public rtl::StaticWithInit<uno::Reference<rendering::XColorSpace>,
217 DeviceColorSpace>
219 uno::Reference<rendering::XColorSpace> operator()()
221 return vcl::unotools::createStandardColorSpace();
226 uno::Reference<rendering::XColorSpace> DeviceHelper::getColorSpace() const
228 // always the same
229 return DeviceColorSpace::get();
232 void DeviceHelper::notifySizeUpdate( const awt::Rectangle& /*rBounds*/ )
234 // TODO
237 void DeviceHelper::dumpScreenContent() const
239 OSL_TRACE( "%s\n",
240 BOOST_CURRENT_FUNCTION );