1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_canvas.hxx"
31 #include <ctype.h> // don't ask. msdev breaks otherwise...
32 #include <vcl/window.hxx>
33 #include <vcl/canvastools.hxx>
34 #include <canvas/debug.hxx>
35 #include <canvas/verbosetrace.hxx>
36 #include <canvas/canvastools.hxx>
37 #include <tools/diagnose_ex.h>
39 #include <osl/mutex.hxx>
40 #include <cppuhelper/compbase1.hxx>
42 #include <com/sun/star/lang/NoSupportException.hpp>
43 #include <toolkit/helper/vclunohelper.hxx>
44 #include <basegfx/tools/canvastools.hxx>
45 #include "dx_linepolypolygon.hxx"
46 #include "dx_spritecanvas.hxx"
47 #include "dx_canvasbitmap.hxx"
48 #include "dx_devicehelper.hxx"
53 #include "dx_winstuff.hxx"
56 #include <vcl/sysdata.hxx>
58 using namespace ::com::sun::star
;
62 DeviceHelper::DeviceHelper() :
68 void DeviceHelper::init( HDC hdc
,
69 rendering::XGraphicDevice
& rDevice
)
75 void DeviceHelper::disposing()
77 // release all references
82 geometry::RealSize2D
DeviceHelper::getPhysicalResolution()
85 return ::canvas::tools::createInfiniteSize2D(); // we're disposed
89 "DeviceHelper::getPhysicalResolution(): cannot retrieve HDC from window" );
91 const int nHorzRes( GetDeviceCaps( hDC
,
93 const int nVertRes( GetDeviceCaps( hDC
,
96 return geometry::RealSize2D( nHorzRes
*25.4,
100 geometry::RealSize2D
DeviceHelper::getPhysicalSize()
103 return ::canvas::tools::createInfiniteSize2D(); // we're disposed
106 ENSURE_OR_THROW( hDC
,
107 "DeviceHelper::getPhysicalSize(): cannot retrieve HDC from window" );
109 const int nHorzSize( GetDeviceCaps( hDC
,
111 const int nVertSize( GetDeviceCaps( hDC
,
114 return geometry::RealSize2D( nHorzSize
,
118 uno::Reference
< rendering::XLinePolyPolygon2D
> DeviceHelper::createCompatibleLinePolyPolygon(
119 const uno::Reference
< rendering::XGraphicDevice
>& /*rDevice*/,
120 const uno::Sequence
< uno::Sequence
< geometry::RealPoint2D
> >& points
)
123 return uno::Reference
< rendering::XLinePolyPolygon2D
>(); // we're disposed
125 return uno::Reference
< rendering::XLinePolyPolygon2D
>(
127 ::basegfx::unotools::polyPolygonFromPoint2DSequenceSequence( points
) ) );
130 uno::Reference
< rendering::XBezierPolyPolygon2D
> DeviceHelper::createCompatibleBezierPolyPolygon(
131 const uno::Reference
< rendering::XGraphicDevice
>& /*rDevice*/,
132 const uno::Sequence
< uno::Sequence
< geometry::RealBezierSegment2D
> >& points
)
135 return uno::Reference
< rendering::XBezierPolyPolygon2D
>(); // we're disposed
137 return uno::Reference
< rendering::XBezierPolyPolygon2D
>(
139 ::basegfx::unotools::polyPolygonFromBezier2DSequenceSequence( points
) ) );
142 uno::Reference
< rendering::XBitmap
> DeviceHelper::createCompatibleBitmap(
143 const uno::Reference
< rendering::XGraphicDevice
>& /*rDevice*/,
144 const geometry::IntegerSize2D
& size
)
147 return uno::Reference
< rendering::XBitmap
>(); // we're disposed
149 DXBitmapSharedPtr
pBitmap(
151 ::basegfx::unotools::b2ISizeFromIntegerSize2D(size
),
154 // create a 24bit RGB system memory surface
155 return uno::Reference
< rendering::XBitmap
>(new CanvasBitmap(pBitmap
,mpDevice
));
158 uno::Reference
< rendering::XVolatileBitmap
> DeviceHelper::createVolatileBitmap(
159 const uno::Reference
< rendering::XGraphicDevice
>& /*rDevice*/,
160 const geometry::IntegerSize2D
& /*size*/ )
162 return uno::Reference
< rendering::XVolatileBitmap
>();
165 uno::Reference
< rendering::XBitmap
> DeviceHelper::createCompatibleAlphaBitmap(
166 const uno::Reference
< rendering::XGraphicDevice
>& /*rDevice*/,
167 const geometry::IntegerSize2D
& size
)
170 return uno::Reference
< rendering::XBitmap
>(); // we're disposed
172 DXBitmapSharedPtr
pBitmap(
174 ::basegfx::unotools::b2ISizeFromIntegerSize2D(size
),
177 // create a 32bit ARGB system memory surface
178 return uno::Reference
< rendering::XBitmap
>(new CanvasBitmap(pBitmap
,mpDevice
));
181 uno::Reference
< rendering::XVolatileBitmap
> DeviceHelper::createVolatileAlphaBitmap(
182 const uno::Reference
< rendering::XGraphicDevice
>& /*rDevice*/,
183 const geometry::IntegerSize2D
& /*size*/ )
185 return uno::Reference
< rendering::XVolatileBitmap
>();
188 sal_Bool
DeviceHelper::hasFullScreenMode()
193 sal_Bool
DeviceHelper::enterFullScreenMode( sal_Bool
/*bEnter*/ )
198 uno::Any
DeviceHelper::isAccelerated() const
200 return ::com::sun::star::uno::makeAny(false);
203 uno::Any
DeviceHelper::getDeviceHandle() const
207 return uno::makeAny( reinterpret_cast< sal_Int64
>(hdc
) );
212 uno::Any
DeviceHelper::getSurfaceHandle() const
214 // TODO(F1): expose DirectDraw object
215 //return mpBackBuffer->getBitmap().get();
221 struct DeviceColorSpace
: public rtl::StaticWithInit
<uno::Reference
<rendering::XColorSpace
>,
224 uno::Reference
<rendering::XColorSpace
> operator()()
226 return vcl::unotools::createStandardColorSpace();
231 uno::Reference
<rendering::XColorSpace
> DeviceHelper::getColorSpace() const
234 return DeviceColorSpace::get();