xref: /trunk/main/toolkit/source/awt/vclxgraphics.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_toolkit.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <toolkit/awt/vclxgraphics.hxx>
32*cdf0e10cSrcweir #include <toolkit/awt/vclxdevice.hxx>
33*cdf0e10cSrcweir #include <toolkit/helper/macros.hxx>
34*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
35*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
36*cdf0e10cSrcweir #include <rtl/memory.h>
37*cdf0e10cSrcweir #include <rtl/uuid.h>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include <vcl/svapp.hxx>
40*cdf0e10cSrcweir #include <vcl/outdev.hxx>
41*cdf0e10cSrcweir #include <vcl/gradient.hxx>
42*cdf0e10cSrcweir #include <tools/debug.hxx>
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir //  ----------------------------------------------------
46*cdf0e10cSrcweir //  class VCLXGraphics
47*cdf0e10cSrcweir //  ----------------------------------------------------
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir // ::com::sun::star::uno::XInterface
50*cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXGraphics::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
51*cdf0e10cSrcweir {
52*cdf0e10cSrcweir     ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
53*cdf0e10cSrcweir                                         SAL_STATIC_CAST( ::com::sun::star::awt::XGraphics*, this ),
54*cdf0e10cSrcweir                                         SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ),
55*cdf0e10cSrcweir                                         SAL_STATIC_CAST( ::com::sun::star::lang::XUnoTunnel*, this ) );
56*cdf0e10cSrcweir     return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ));
57*cdf0e10cSrcweir }
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir // ::com::sun::star::lang::XUnoTunnel
60*cdf0e10cSrcweir IMPL_XUNOTUNNEL( VCLXGraphics )
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider
63*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXGraphics )
64*cdf0e10cSrcweir     getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics>* ) NULL )
65*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir VCLXGraphics::VCLXGraphics() : mrMutex( Application::GetSolarMutex() )
68*cdf0e10cSrcweir {
69*cdf0e10cSrcweir     mpOutputDevice = NULL;
70*cdf0e10cSrcweir     mpClipRegion = NULL;
71*cdf0e10cSrcweir }
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir VCLXGraphics::~VCLXGraphics()
74*cdf0e10cSrcweir {
75*cdf0e10cSrcweir     List* pLst = mpOutputDevice ? mpOutputDevice->GetUnoGraphicsList() : NULL;
76*cdf0e10cSrcweir     if ( pLst )
77*cdf0e10cSrcweir         pLst->Remove( this );
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir     delete mpClipRegion;
80*cdf0e10cSrcweir }
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir void VCLXGraphics::SetOutputDevice( OutputDevice* pOutDev )
83*cdf0e10cSrcweir {
84*cdf0e10cSrcweir     mpOutputDevice = pOutDev;
85*cdf0e10cSrcweir     mxDevice = NULL;
86*cdf0e10cSrcweir }
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir void VCLXGraphics::Init( OutputDevice* pOutDev )
89*cdf0e10cSrcweir {
90*cdf0e10cSrcweir     DBG_ASSERT( !mpOutputDevice, "VCLXGraphics::Init allready has pOutDev !" );
91*cdf0e10cSrcweir     mpOutputDevice  = pOutDev;
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir     maFont          = mpOutputDevice->GetFont();
94*cdf0e10cSrcweir     maTextColor     = COL_BLACK;
95*cdf0e10cSrcweir     maTextFillColor = COL_TRANSPARENT;
96*cdf0e10cSrcweir     maLineColor     = COL_BLACK;
97*cdf0e10cSrcweir     maFillColor     = COL_WHITE;
98*cdf0e10cSrcweir     meRasterOp      = ROP_OVERPAINT;
99*cdf0e10cSrcweir     mpClipRegion    = NULL;
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir     // Register at OutputDevice
102*cdf0e10cSrcweir     List* pLst = mpOutputDevice->GetUnoGraphicsList();
103*cdf0e10cSrcweir     if ( !pLst )
104*cdf0e10cSrcweir         pLst = mpOutputDevice->CreateUnoGraphicsList();
105*cdf0e10cSrcweir     pLst->Insert( this, LIST_APPEND );
106*cdf0e10cSrcweir }
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir void VCLXGraphics::InitOutputDevice( sal_uInt16 nFlags )
109*cdf0e10cSrcweir {
110*cdf0e10cSrcweir     if(mpOutputDevice)
111*cdf0e10cSrcweir     {
112*cdf0e10cSrcweir         vos::OGuard aVclGuard( Application::GetSolarMutex()  );
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir         if ( nFlags & INITOUTDEV_FONT )
115*cdf0e10cSrcweir         {
116*cdf0e10cSrcweir             mpOutputDevice->SetFont( maFont );
117*cdf0e10cSrcweir             mpOutputDevice->SetTextColor( maTextColor );
118*cdf0e10cSrcweir             mpOutputDevice->SetTextFillColor( maTextFillColor );
119*cdf0e10cSrcweir         }
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir         if ( nFlags & INITOUTDEV_COLORS )
122*cdf0e10cSrcweir         {
123*cdf0e10cSrcweir             mpOutputDevice->SetLineColor( maLineColor );
124*cdf0e10cSrcweir             mpOutputDevice->SetFillColor( maFillColor );
125*cdf0e10cSrcweir         }
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir         if ( nFlags & INITOUTDEV_RASTEROP )
128*cdf0e10cSrcweir         {
129*cdf0e10cSrcweir             mpOutputDevice->SetRasterOp( meRasterOp );
130*cdf0e10cSrcweir         }
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir         if ( nFlags & INITOUTDEV_CLIPREGION )
133*cdf0e10cSrcweir         {
134*cdf0e10cSrcweir             if( mpClipRegion )
135*cdf0e10cSrcweir                 mpOutputDevice->SetClipRegion( *mpClipRegion );
136*cdf0e10cSrcweir             else
137*cdf0e10cSrcweir                 mpOutputDevice->SetClipRegion();
138*cdf0e10cSrcweir         }
139*cdf0e10cSrcweir     }
140*cdf0e10cSrcweir }
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > VCLXGraphics::getDevice() throw(::com::sun::star::uno::RuntimeException)
143*cdf0e10cSrcweir {
144*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir     if( !mxDevice.is() && mpOutputDevice )
147*cdf0e10cSrcweir     {
148*cdf0e10cSrcweir         VCLXDevice* pDev = new VCLXDevice;
149*cdf0e10cSrcweir         pDev->SetOutputDevice( mpOutputDevice );
150*cdf0e10cSrcweir         mxDevice = pDev;
151*cdf0e10cSrcweir     }
152*cdf0e10cSrcweir     return mxDevice;
153*cdf0e10cSrcweir }
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir ::com::sun::star::awt::SimpleFontMetric VCLXGraphics::getFontMetric() throw(::com::sun::star::uno::RuntimeException)
156*cdf0e10cSrcweir {
157*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir     ::com::sun::star::awt::SimpleFontMetric aM;
160*cdf0e10cSrcweir     if( mpOutputDevice )
161*cdf0e10cSrcweir     {
162*cdf0e10cSrcweir         mpOutputDevice->SetFont( maFont );
163*cdf0e10cSrcweir         aM = VCLUnoHelper::CreateFontMetric( mpOutputDevice->GetFontMetric() );
164*cdf0e10cSrcweir     }
165*cdf0e10cSrcweir     return aM;
166*cdf0e10cSrcweir }
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir void VCLXGraphics::setFont( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont >& rxFont ) throw(::com::sun::star::uno::RuntimeException)
169*cdf0e10cSrcweir {
170*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir     maFont = VCLUnoHelper::CreateFont( rxFont );
173*cdf0e10cSrcweir }
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir void VCLXGraphics::selectFont( const ::com::sun::star::awt::FontDescriptor& rDescription ) throw(::com::sun::star::uno::RuntimeException)
176*cdf0e10cSrcweir {
177*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir     maFont = VCLUnoHelper::CreateFont( rDescription, Font() );
180*cdf0e10cSrcweir }
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir void VCLXGraphics::setTextColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException)
183*cdf0e10cSrcweir {
184*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir     maTextColor = Color( (sal_uInt32)nColor );
187*cdf0e10cSrcweir }
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir void VCLXGraphics::setTextFillColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException)
190*cdf0e10cSrcweir {
191*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir     maTextFillColor = Color( (sal_uInt32)nColor );
194*cdf0e10cSrcweir }
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir void VCLXGraphics::setLineColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException)
197*cdf0e10cSrcweir {
198*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir     maLineColor = Color( (sal_uInt32)nColor );
201*cdf0e10cSrcweir }
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir void VCLXGraphics::setFillColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException)
204*cdf0e10cSrcweir {
205*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir     maFillColor = Color( (sal_uInt32)nColor );
208*cdf0e10cSrcweir }
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir void VCLXGraphics::setRasterOp( ::com::sun::star::awt::RasterOperation eROP ) throw(::com::sun::star::uno::RuntimeException)
211*cdf0e10cSrcweir {
212*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir     meRasterOp = (RasterOp)eROP;
215*cdf0e10cSrcweir }
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir void VCLXGraphics::setClipRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException)
218*cdf0e10cSrcweir {
219*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir     delete mpClipRegion;
222*cdf0e10cSrcweir     if ( rxRegion.is() )
223*cdf0e10cSrcweir         mpClipRegion = new Region( VCLUnoHelper::GetRegion( rxRegion ) );
224*cdf0e10cSrcweir     else
225*cdf0e10cSrcweir         mpClipRegion = NULL;
226*cdf0e10cSrcweir }
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir void VCLXGraphics::intersectClipRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException)
229*cdf0e10cSrcweir {
230*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir     if ( rxRegion.is() )
233*cdf0e10cSrcweir     {
234*cdf0e10cSrcweir         Region aRegion( VCLUnoHelper::GetRegion( rxRegion ) );
235*cdf0e10cSrcweir         if ( !mpClipRegion )
236*cdf0e10cSrcweir             mpClipRegion = new Region( aRegion );
237*cdf0e10cSrcweir         else
238*cdf0e10cSrcweir             mpClipRegion->Intersect( aRegion );
239*cdf0e10cSrcweir     }
240*cdf0e10cSrcweir }
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir void VCLXGraphics::push(  ) throw(::com::sun::star::uno::RuntimeException)
243*cdf0e10cSrcweir {
244*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir     if( mpOutputDevice )
248*cdf0e10cSrcweir         mpOutputDevice->Push();
249*cdf0e10cSrcweir }
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir void VCLXGraphics::pop(  ) throw(::com::sun::star::uno::RuntimeException)
252*cdf0e10cSrcweir {
253*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir     if( mpOutputDevice )
257*cdf0e10cSrcweir         mpOutputDevice->Pop();
258*cdf0e10cSrcweir }
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir void VCLXGraphics::copy( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice >& rxSource, sal_Int32 nSourceX, sal_Int32 nSourceY, sal_Int32 nSourceWidth, sal_Int32 nSourceHeight, sal_Int32 nDestX, sal_Int32 nDestY, sal_Int32 nDestWidth, sal_Int32 nDestHeight ) throw(::com::sun::star::uno::RuntimeException)
261*cdf0e10cSrcweir {
262*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir     if ( mpOutputDevice )
265*cdf0e10cSrcweir     {
266*cdf0e10cSrcweir         VCLXDevice* pFromDev = VCLXDevice::GetImplementation( rxSource );
267*cdf0e10cSrcweir         DBG_ASSERT( pFromDev, "VCLXGraphics::copy - invalid device" );
268*cdf0e10cSrcweir         if ( pFromDev )
269*cdf0e10cSrcweir         {
270*cdf0e10cSrcweir             InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP );
271*cdf0e10cSrcweir             mpOutputDevice->DrawOutDev( Point( nDestX, nDestY ), Size( nDestWidth, nDestHeight ),
272*cdf0e10cSrcweir                                     Point( nSourceX, nSourceY ), Size( nSourceWidth, nSourceHeight ), *pFromDev->GetOutputDevice() );
273*cdf0e10cSrcweir         }
274*cdf0e10cSrcweir     }
275*cdf0e10cSrcweir }
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir void VCLXGraphics::draw( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDisplayBitmap >& rxBitmapHandle, sal_Int32 nSourceX, sal_Int32 nSourceY, sal_Int32 nSourceWidth, sal_Int32 nSourceHeight, sal_Int32 nDestX, sal_Int32 nDestY, sal_Int32 nDestWidth, sal_Int32 nDestHeight ) throw(::com::sun::star::uno::RuntimeException)
278*cdf0e10cSrcweir {
279*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir     if( mpOutputDevice )
282*cdf0e10cSrcweir     {
283*cdf0e10cSrcweir         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP);
284*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > xBitmap( rxBitmapHandle, ::com::sun::star::uno::UNO_QUERY );
285*cdf0e10cSrcweir         BitmapEx aBmpEx = VCLUnoHelper::GetBitmap( xBitmap );
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir         Point aPos(nDestX - nSourceX, nDestY - nSourceY);
288*cdf0e10cSrcweir         Size aSz = aBmpEx.GetSizePixel();
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir         if(nDestWidth != nSourceWidth)
291*cdf0e10cSrcweir         {
292*cdf0e10cSrcweir             float zoomX = (float)nDestWidth / (float)nSourceWidth;
293*cdf0e10cSrcweir             aSz.Width() = (long) ((float)aSz.Width() * zoomX);
294*cdf0e10cSrcweir         }
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir         if(nDestHeight != nSourceHeight)
297*cdf0e10cSrcweir         {
298*cdf0e10cSrcweir             float zoomY = (float)nDestHeight / (float)nSourceHeight;
299*cdf0e10cSrcweir             aSz.Height() = (long) ((float)aSz.Height() * zoomY);
300*cdf0e10cSrcweir         }
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir         if(nSourceX || nSourceY || aSz.Width() != nSourceWidth || aSz.Height() != nSourceHeight)
303*cdf0e10cSrcweir             mpOutputDevice->IntersectClipRegion(Region(Rectangle(nDestX, nDestY, nDestX + nDestWidth - 1, nDestY + nDestHeight - 1)));
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir         mpOutputDevice->DrawBitmapEx( aPos, aSz, aBmpEx );
306*cdf0e10cSrcweir     }
307*cdf0e10cSrcweir }
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir void VCLXGraphics::drawPixel( sal_Int32 x, sal_Int32 y ) throw(::com::sun::star::uno::RuntimeException)
310*cdf0e10cSrcweir {
311*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir     if( mpOutputDevice )
314*cdf0e10cSrcweir     {
315*cdf0e10cSrcweir         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
316*cdf0e10cSrcweir         mpOutputDevice->DrawPixel( Point( x, y ) );
317*cdf0e10cSrcweir     }
318*cdf0e10cSrcweir }
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir void VCLXGraphics::drawLine( sal_Int32 x1, sal_Int32 y1, sal_Int32 x2, sal_Int32 y2 ) throw(::com::sun::star::uno::RuntimeException)
321*cdf0e10cSrcweir {
322*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir     if( mpOutputDevice )
325*cdf0e10cSrcweir     {
326*cdf0e10cSrcweir         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
327*cdf0e10cSrcweir         mpOutputDevice->DrawLine( Point( x1, y1 ), Point( x2, y2 ) );
328*cdf0e10cSrcweir     }
329*cdf0e10cSrcweir }
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir void VCLXGraphics::drawRect( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height ) throw(::com::sun::star::uno::RuntimeException)
332*cdf0e10cSrcweir {
333*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir     if( mpOutputDevice )
336*cdf0e10cSrcweir     {
337*cdf0e10cSrcweir         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
338*cdf0e10cSrcweir         mpOutputDevice->DrawRect( Rectangle( Point( x, y ), Size( width, height ) ) );
339*cdf0e10cSrcweir     }
340*cdf0e10cSrcweir }
341*cdf0e10cSrcweir 
342*cdf0e10cSrcweir void VCLXGraphics::drawRoundedRect( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height, sal_Int32 nHorzRound, sal_Int32 nVertRound ) throw(::com::sun::star::uno::RuntimeException)
343*cdf0e10cSrcweir {
344*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir     if( mpOutputDevice )
347*cdf0e10cSrcweir     {
348*cdf0e10cSrcweir         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
349*cdf0e10cSrcweir         mpOutputDevice->DrawRect( Rectangle( Point( x, y ), Size( width, height ) ), nHorzRound, nVertRound );
350*cdf0e10cSrcweir     }
351*cdf0e10cSrcweir }
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir void VCLXGraphics::drawPolyLine( const ::com::sun::star::uno::Sequence< sal_Int32 >& DataX, const ::com::sun::star::uno::Sequence< sal_Int32 >& DataY ) throw(::com::sun::star::uno::RuntimeException)
354*cdf0e10cSrcweir {
355*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir     if( mpOutputDevice )
358*cdf0e10cSrcweir     {
359*cdf0e10cSrcweir         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
360*cdf0e10cSrcweir         mpOutputDevice->DrawPolyLine( VCLUnoHelper::CreatePolygon( DataX, DataY ) );
361*cdf0e10cSrcweir     }
362*cdf0e10cSrcweir }
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir void VCLXGraphics::drawPolygon( const ::com::sun::star::uno::Sequence< sal_Int32 >& DataX, const ::com::sun::star::uno::Sequence< sal_Int32 >& DataY ) throw(::com::sun::star::uno::RuntimeException)
365*cdf0e10cSrcweir {
366*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir     if( mpOutputDevice )
369*cdf0e10cSrcweir     {
370*cdf0e10cSrcweir         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
371*cdf0e10cSrcweir         mpOutputDevice->DrawPolygon( VCLUnoHelper::CreatePolygon( DataX, DataY ) );
372*cdf0e10cSrcweir     }
373*cdf0e10cSrcweir }
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir void VCLXGraphics::drawPolyPolygon( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< sal_Int32 > >& DataX, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< sal_Int32 > >& DataY ) throw(::com::sun::star::uno::RuntimeException)
376*cdf0e10cSrcweir {
377*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir     if( mpOutputDevice )
380*cdf0e10cSrcweir     {
381*cdf0e10cSrcweir         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
382*cdf0e10cSrcweir         sal_uInt16 nPolys = (sal_uInt16) DataX.getLength();
383*cdf0e10cSrcweir         PolyPolygon aPolyPoly( nPolys );
384*cdf0e10cSrcweir         for ( sal_uInt16 n = 0; n < nPolys; n++ )
385*cdf0e10cSrcweir             aPolyPoly[n] = VCLUnoHelper::CreatePolygon( DataX.getConstArray()[n], DataY.getConstArray()[n] );
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir         mpOutputDevice->DrawPolyPolygon( aPolyPoly );
388*cdf0e10cSrcweir     }
389*cdf0e10cSrcweir }
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir void VCLXGraphics::drawEllipse( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height ) throw(::com::sun::star::uno::RuntimeException)
392*cdf0e10cSrcweir {
393*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir     if( mpOutputDevice )
396*cdf0e10cSrcweir     {
397*cdf0e10cSrcweir         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
398*cdf0e10cSrcweir         mpOutputDevice->DrawEllipse( Rectangle( Point( x, y ), Size( width, height ) ) );
399*cdf0e10cSrcweir     }
400*cdf0e10cSrcweir }
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir void VCLXGraphics::drawArc( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height, sal_Int32 x1, sal_Int32 y1, sal_Int32 x2, sal_Int32 y2 ) throw(::com::sun::star::uno::RuntimeException)
403*cdf0e10cSrcweir {
404*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir     if( mpOutputDevice )
407*cdf0e10cSrcweir     {
408*cdf0e10cSrcweir         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
409*cdf0e10cSrcweir         mpOutputDevice->DrawArc( Rectangle( Point( x, y ), Size( width, height ) ), Point( x1, y1 ), Point( x2, y2 ) );
410*cdf0e10cSrcweir     }
411*cdf0e10cSrcweir }
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir void VCLXGraphics::drawPie( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height, sal_Int32 x1, sal_Int32 y1, sal_Int32 x2, sal_Int32 y2 ) throw(::com::sun::star::uno::RuntimeException)
414*cdf0e10cSrcweir {
415*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir     if( mpOutputDevice )
418*cdf0e10cSrcweir     {
419*cdf0e10cSrcweir         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
420*cdf0e10cSrcweir         mpOutputDevice->DrawPie( Rectangle( Point( x, y ), Size( width, height ) ), Point( x1, y1 ), Point( x2, y2 ) );
421*cdf0e10cSrcweir     }
422*cdf0e10cSrcweir }
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir void VCLXGraphics::drawChord( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height, sal_Int32 x1, sal_Int32 y1, sal_Int32 x2, sal_Int32 y2 ) throw(::com::sun::star::uno::RuntimeException)
425*cdf0e10cSrcweir {
426*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir     if( mpOutputDevice )
429*cdf0e10cSrcweir     {
430*cdf0e10cSrcweir         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
431*cdf0e10cSrcweir         mpOutputDevice->DrawChord( Rectangle( Point( x, y ), Size( width, height ) ), Point( x1, y1 ), Point( x2, y2 ) );
432*cdf0e10cSrcweir     }
433*cdf0e10cSrcweir }
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir void VCLXGraphics::drawGradient( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height, const ::com::sun::star::awt::Gradient& rGradient ) throw(::com::sun::star::uno::RuntimeException)
436*cdf0e10cSrcweir {
437*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir     if( mpOutputDevice )
440*cdf0e10cSrcweir     {
441*cdf0e10cSrcweir         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
442*cdf0e10cSrcweir         Gradient aGradient((GradientStyle)rGradient.Style, rGradient.StartColor, rGradient.EndColor);
443*cdf0e10cSrcweir         aGradient.SetAngle(rGradient.Angle);
444*cdf0e10cSrcweir         aGradient.SetBorder(rGradient.Border);
445*cdf0e10cSrcweir         aGradient.SetOfsX(rGradient.XOffset);
446*cdf0e10cSrcweir         aGradient.SetOfsY(rGradient.YOffset);
447*cdf0e10cSrcweir         aGradient.SetStartIntensity(rGradient.StartIntensity);
448*cdf0e10cSrcweir         aGradient.SetEndIntensity(rGradient.EndIntensity);
449*cdf0e10cSrcweir         aGradient.SetSteps(rGradient.StepCount);
450*cdf0e10cSrcweir         mpOutputDevice->DrawGradient( Rectangle( Point( x, y ), Size( width, height ) ), aGradient );
451*cdf0e10cSrcweir     }
452*cdf0e10cSrcweir }
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir void VCLXGraphics::drawText( sal_Int32 x, sal_Int32 y, const ::rtl::OUString& rText ) throw(::com::sun::star::uno::RuntimeException)
455*cdf0e10cSrcweir {
456*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir     if( mpOutputDevice )
459*cdf0e10cSrcweir     {
460*cdf0e10cSrcweir         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS |INITOUTDEV_FONT);
461*cdf0e10cSrcweir         mpOutputDevice->DrawText( Point( x, y ), rText );
462*cdf0e10cSrcweir     }
463*cdf0e10cSrcweir }
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir void VCLXGraphics::drawTextArray( sal_Int32 x, sal_Int32 y, const ::rtl::OUString& rText, const ::com::sun::star::uno::Sequence< sal_Int32 >& rLongs ) throw(::com::sun::star::uno::RuntimeException)
466*cdf0e10cSrcweir {
467*cdf0e10cSrcweir     ::vos::OGuard aGuard( GetMutex() );
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir     if( mpOutputDevice )
470*cdf0e10cSrcweir     {
471*cdf0e10cSrcweir         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS|INITOUTDEV_FONT );
472*cdf0e10cSrcweir         mpOutputDevice->DrawTextArray( Point( x, y ), rText, rLongs.getConstArray() );
473*cdf0e10cSrcweir     }
474*cdf0e10cSrcweir }
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir 
479