1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: null_devicehelper.cxx,v $
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
;
57 DeviceHelper::DeviceHelper() :
58 mpSpriteCanvas( NULL
),
64 void DeviceHelper::init( SpriteCanvas
& rSpriteCanvas
,
65 const ::basegfx::B2ISize
& rSize
,
68 mpSpriteCanvas
= &rSpriteCanvas
;
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
)
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
)
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
)
120 if( !mpSpriteCanvas
)
121 return uno::Reference
< rendering::XBitmap
>(); // we're disposed
123 return uno::Reference
< rendering::XBitmap
>(
125 ::basegfx::unotools::b2ISizeFromIntegerSize2D( size
),
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
)
142 if( !mpSpriteCanvas
)
143 return uno::Reference
< rendering::XBitmap
>(); // we're disposed
145 return uno::Reference
< rendering::XBitmap
>(
147 ::basegfx::unotools::b2ISizeFromIntegerSize2D( size
),
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
165 sal_Bool
DeviceHelper::enterFullScreenMode( sal_Bool
/*bEnter*/ )
167 // TODO(F3): offer fullscreen mode the XCanvas way
171 ::sal_Int32
DeviceHelper::createBuffers( ::sal_Int32
/*nBuffers*/ )
173 // TODO(F3): implement XBufferStrategy interface. For now, we
174 // _always_ will have exactly one backbuffer
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
)
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
209 uno::Any
DeviceHelper::getSurfaceHandle() const
216 struct DeviceColorSpace
: public rtl::StaticWithInit
<uno::Reference
<rendering::XColorSpace
>,
219 uno::Reference
<rendering::XColorSpace
> operator()()
221 return vcl::unotools::createStandardColorSpace();
226 uno::Reference
<rendering::XColorSpace
> DeviceHelper::getColorSpace() const
229 return DeviceColorSpace::get();
232 void DeviceHelper::notifySizeUpdate( const awt::Rectangle
& /*rBounds*/ )
237 void DeviceHelper::dumpScreenContent() const
240 BOOST_CURRENT_FUNCTION
);