xref: /trunk/main/toolkit/source/awt/vclxgraphics.cxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_toolkit.hxx"
26 
27 #include <toolkit/awt/vclxgraphics.hxx>
28 #include <toolkit/awt/vclxdevice.hxx>
29 #include <toolkit/awt/vclxfont.hxx>
30 #include <toolkit/helper/macros.hxx>
31 #include <toolkit/helper/vclunohelper.hxx>
32 #include <cppuhelper/typeprovider.hxx>
33 #include <rtl/memory.h>
34 #include <rtl/uuid.h>
35 
36 #include <vcl/svapp.hxx>
37 #include <vcl/outdev.hxx>
38 #include <vcl/image.hxx>
39 #include <vcl/gradient.hxx>
40 #include <tools/debug.hxx>
41 
42 using namespace com::sun::star;
43 
44 //  ----------------------------------------------------
45 //  class VCLXGraphics
46 //  ----------------------------------------------------
47 
48 // uno::XInterface
queryInterface(const uno::Type & rType)49 uno::Any VCLXGraphics::queryInterface( const uno::Type & rType )
50 {
51     uno::Any aRet = ::cppu::queryInterface( rType,
52                                         SAL_STATIC_CAST( awt::XGraphics*, this ),
53                                         SAL_STATIC_CAST( lang::XTypeProvider*, this ),
54                                         SAL_STATIC_CAST( lang::XUnoTunnel*, this ) );
55     return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ));
56 }
57 
58 // lang::XUnoTunnel
59 IMPL_XUNOTUNNEL( VCLXGraphics )
60 
61 // lang::XTypeProvider
IMPL_XTYPEPROVIDER_START(VCLXGraphics)62 IMPL_XTYPEPROVIDER_START( VCLXGraphics )
63     getCppuType( ( uno::Reference< awt::XGraphics>* ) NULL )
64 IMPL_XTYPEPROVIDER_END
65 
66 VCLXGraphics::VCLXGraphics() : mrMutex( Application::GetSolarMutex() )
67 {
68     mpOutputDevice = NULL;
69     mpClipRegion = NULL;
70 }
71 
~VCLXGraphics()72 VCLXGraphics::~VCLXGraphics()
73 {
74     List* pLst = mpOutputDevice ? mpOutputDevice->GetUnoGraphicsList() : NULL;
75     if ( pLst )
76         pLst->Remove( this );
77 
78     delete mpClipRegion;
79 }
80 
SetOutputDevice(OutputDevice * pOutDev)81 void VCLXGraphics::SetOutputDevice( OutputDevice* pOutDev )
82 {
83     mpOutputDevice = pOutDev;
84     mxDevice = NULL;
85     initAttrs();
86 }
87 
Init(OutputDevice * pOutDev)88 void VCLXGraphics::Init( OutputDevice* pOutDev )
89 {
90     DBG_ASSERT( !mpOutputDevice, "VCLXGraphics::Init already has pOutDev !" );
91     mpOutputDevice  = pOutDev;
92 
93     initAttrs();
94     mpClipRegion    = NULL;
95 
96     // Register at OutputDevice
97     List* pLst = mpOutputDevice->GetUnoGraphicsList();
98     if ( !pLst )
99         pLst = mpOutputDevice->CreateUnoGraphicsList();
100     pLst->Insert( this, LIST_APPEND );
101 }
102 
initAttrs()103 void VCLXGraphics::initAttrs()
104 {
105     if ( !mpOutputDevice )
106         return;
107 
108     maFont          = mpOutputDevice->GetFont();
109     maTextColor     = mpOutputDevice->GetTextColor(); /* COL_BLACK */
110     maTextFillColor = mpOutputDevice->GetTextFillColor(); /* COL_TRANSPARENT */
111     maLineColor     = mpOutputDevice->GetLineColor(); /* COL_BLACK */
112     maFillColor     = mpOutputDevice->GetFillColor(); /* COL_WHITE */
113     meRasterOp      = mpOutputDevice->GetRasterOp(); /* ROP_OVERPAINT */
114 }
115 
InitOutputDevice(sal_uInt16 nFlags)116 void VCLXGraphics::InitOutputDevice( sal_uInt16 nFlags )
117 {
118     if(mpOutputDevice)
119     {
120         vos::OGuard aVclGuard( Application::GetSolarMutex()  );
121 
122         if ( nFlags & INITOUTDEV_FONT )
123         {
124             mpOutputDevice->SetFont( maFont );
125             mpOutputDevice->SetTextColor( maTextColor );
126             mpOutputDevice->SetTextFillColor( maTextFillColor );
127         }
128 
129         if ( nFlags & INITOUTDEV_COLORS )
130         {
131             mpOutputDevice->SetLineColor( maLineColor );
132             mpOutputDevice->SetFillColor( maFillColor );
133         }
134 
135         if ( nFlags & INITOUTDEV_RASTEROP )
136         {
137             mpOutputDevice->SetRasterOp( meRasterOp );
138         }
139 
140         if ( nFlags & INITOUTDEV_CLIPREGION )
141         {
142             if( mpClipRegion )
143                 mpOutputDevice->SetClipRegion( *mpClipRegion );
144             else
145                 mpOutputDevice->SetClipRegion();
146         }
147     }
148 }
149 
getDevice()150 uno::Reference< awt::XDevice > VCLXGraphics::getDevice()
151 {
152     ::vos::OGuard aGuard( GetMutex() );
153 
154     if( !mxDevice.is() && mpOutputDevice )
155     {
156         VCLXDevice* pDev = new VCLXDevice;
157         pDev->SetOutputDevice( mpOutputDevice );
158         mxDevice = pDev;
159     }
160     return mxDevice;
161 }
162 
getFontMetric()163 awt::SimpleFontMetric VCLXGraphics::getFontMetric()
164 {
165     ::vos::OGuard aGuard( GetMutex() );
166 
167     awt::SimpleFontMetric aM;
168     if( mpOutputDevice )
169     {
170         mpOutputDevice->SetFont( maFont );
171         aM = VCLUnoHelper::CreateFontMetric( mpOutputDevice->GetFontMetric() );
172     }
173     return aM;
174 }
175 
setFont(const uno::Reference<awt::XFont> & rxFont)176 void VCLXGraphics::setFont( const uno::Reference< awt::XFont >& rxFont )
177 {
178     ::vos::OGuard aGuard( GetMutex() );
179 
180     maFont = VCLUnoHelper::CreateFont( rxFont );
181 }
182 
getFont()183 uno::Reference< awt::XFont > VCLXGraphics::getFont()
184 {
185     uno::Reference< awt::XFont > xFont;
186     uno::Reference< awt::XDevice > xDevice( getDevice() );
187 
188     ::vos::OGuard aGuard( GetMutex() );
189 
190     if ( xDevice.is() )
191     {
192         VCLXFont *pFont = new VCLXFont;
193         pFont->Init( *xDevice.get(), maFont );
194         xFont.set( static_cast< ::cppu::OWeakObject* >( pFont ), uno::UNO_QUERY );
195     }
196 
197     return xFont;
198 }
199 
selectFont(const awt::FontDescriptor & rDescription)200 void VCLXGraphics::selectFont( const awt::FontDescriptor& rDescription )
201 {
202     ::vos::OGuard aGuard( GetMutex() );
203 
204     maFont = VCLUnoHelper::CreateFont( rDescription, Font() );
205 }
206 
setTextColor(sal_Int32 nColor)207 void VCLXGraphics::setTextColor( sal_Int32 nColor )
208 {
209     ::vos::OGuard aGuard( GetMutex() );
210 
211     maTextColor = Color( (sal_uInt32)nColor );
212 }
213 
getTextColor()214 ::sal_Int32 VCLXGraphics::getTextColor()
215 {
216     ::vos::OGuard aGuard( GetMutex() );
217     return maTextColor.GetColor();
218 }
219 
setTextFillColor(sal_Int32 nColor)220 void VCLXGraphics::setTextFillColor( sal_Int32 nColor )
221 {
222     ::vos::OGuard aGuard( GetMutex() );
223 
224     maTextFillColor = Color( (sal_uInt32)nColor );
225 }
226 
getTextFillColor()227 ::sal_Int32 VCLXGraphics::getTextFillColor()
228 {
229     ::vos::OGuard aGuard( GetMutex() );
230     return maTextFillColor.GetColor();
231 }
232 
setLineColor(sal_Int32 nColor)233 void VCLXGraphics::setLineColor( sal_Int32 nColor )
234 {
235     ::vos::OGuard aGuard( GetMutex() );
236 
237     maLineColor = Color( (sal_uInt32)nColor );
238 }
239 
getLineColor()240 ::sal_Int32 VCLXGraphics::getLineColor()
241 {
242     ::vos::OGuard aGuard( GetMutex() );
243     return maLineColor.GetColor();
244 }
245 
setFillColor(sal_Int32 nColor)246 void VCLXGraphics::setFillColor( sal_Int32 nColor )
247 {
248     ::vos::OGuard aGuard( GetMutex() );
249 
250     maFillColor = Color( (sal_uInt32)nColor );
251 }
252 
getFillColor()253 ::sal_Int32 VCLXGraphics::getFillColor()
254 {
255     ::vos::OGuard aGuard( GetMutex() );
256     return maFillColor.GetColor();
257 }
258 
setRasterOp(awt::RasterOperation eROP)259 void VCLXGraphics::setRasterOp( awt::RasterOperation eROP )
260 {
261     ::vos::OGuard aGuard( GetMutex() );
262 
263     meRasterOp = (RasterOp)eROP;
264 }
265 
getRasterOp()266 awt::RasterOperation VCLXGraphics::getRasterOp()
267 {
268     ::vos::OGuard aGuard( GetMutex() );
269     return (awt::RasterOperation) meRasterOp;
270 }
271 
setClipRegion(const uno::Reference<awt::XRegion> & rxRegion)272 void VCLXGraphics::setClipRegion( const uno::Reference< awt::XRegion >& rxRegion )
273 {
274     ::vos::OGuard aGuard( GetMutex() );
275 
276     delete mpClipRegion;
277     if ( rxRegion.is() )
278         mpClipRegion = new Region( VCLUnoHelper::GetRegion( rxRegion ) );
279     else
280         mpClipRegion = NULL;
281 }
282 
intersectClipRegion(const uno::Reference<awt::XRegion> & rxRegion)283 void VCLXGraphics::intersectClipRegion( const uno::Reference< awt::XRegion >& rxRegion )
284 {
285     ::vos::OGuard aGuard( GetMutex() );
286 
287     if ( rxRegion.is() )
288     {
289         Region aRegion( VCLUnoHelper::GetRegion( rxRegion ) );
290         if ( !mpClipRegion )
291             mpClipRegion = new Region( aRegion );
292         else
293             mpClipRegion->Intersect( aRegion );
294     }
295 }
296 
push()297 void VCLXGraphics::push(  )
298 {
299     ::vos::OGuard aGuard( GetMutex() );
300 
301 
302     if( mpOutputDevice )
303         mpOutputDevice->Push();
304 }
305 
pop()306 void VCLXGraphics::pop(  )
307 {
308     ::vos::OGuard aGuard( GetMutex() );
309 
310 
311     if( mpOutputDevice )
312         mpOutputDevice->Pop();
313 }
314 
clear(const awt::Rectangle & aRect)315 void VCLXGraphics::clear(
316     const awt::Rectangle& aRect )
317 {
318     ::vos::OGuard aGuard( GetMutex() );
319 
320     if( mpOutputDevice )
321     {
322         const ::Rectangle aVCLRect = VCLUnoHelper::ConvertToVCLRect( aRect );
323         mpOutputDevice->Erase( aVCLRect );
324     }
325 }
326 
copy(const uno::Reference<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)327 void VCLXGraphics::copy( const uno::Reference< 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 )
328 {
329     ::vos::OGuard aGuard( GetMutex() );
330 
331     if ( mpOutputDevice )
332     {
333         VCLXDevice* pFromDev = VCLXDevice::GetImplementation( rxSource );
334         DBG_ASSERT( pFromDev, "VCLXGraphics::copy - invalid device" );
335         if ( pFromDev )
336         {
337             InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP );
338             mpOutputDevice->DrawOutDev( Point( nDestX, nDestY ), Size( nDestWidth, nDestHeight ),
339                                     Point( nSourceX, nSourceY ), Size( nSourceWidth, nSourceHeight ), *pFromDev->GetOutputDevice() );
340         }
341     }
342 }
343 
draw(const uno::Reference<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)344 void VCLXGraphics::draw( const uno::Reference< 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 )
345 {
346     ::vos::OGuard aGuard( GetMutex() );
347 
348     if( mpOutputDevice )
349     {
350         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP);
351         uno::Reference< awt::XBitmap > xBitmap( rxBitmapHandle, uno::UNO_QUERY );
352         BitmapEx aBmpEx = VCLUnoHelper::GetBitmap( xBitmap );
353 
354         Point aPos(nDestX - nSourceX, nDestY - nSourceY);
355         Size aSz = aBmpEx.GetSizePixel();
356 
357         if(nDestWidth != nSourceWidth)
358         {
359             float zoomX = (float)nDestWidth / (float)nSourceWidth;
360             aSz.Width() = (long) ((float)aSz.Width() * zoomX);
361         }
362 
363         if(nDestHeight != nSourceHeight)
364         {
365             float zoomY = (float)nDestHeight / (float)nSourceHeight;
366             aSz.Height() = (long) ((float)aSz.Height() * zoomY);
367         }
368 
369         if(nSourceX || nSourceY || aSz.Width() != nSourceWidth || aSz.Height() != nSourceHeight)
370             mpOutputDevice->IntersectClipRegion(Region(Rectangle(nDestX, nDestY, nDestX + nDestWidth - 1, nDestY + nDestHeight - 1)));
371 
372         mpOutputDevice->DrawBitmapEx( aPos, aSz, aBmpEx );
373     }
374 }
375 
drawPixel(sal_Int32 x,sal_Int32 y)376 void VCLXGraphics::drawPixel( sal_Int32 x, sal_Int32 y )
377 {
378     ::vos::OGuard aGuard( GetMutex() );
379 
380     if( mpOutputDevice )
381     {
382         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
383         mpOutputDevice->DrawPixel( Point( x, y ) );
384     }
385 }
386 
drawLine(sal_Int32 x1,sal_Int32 y1,sal_Int32 x2,sal_Int32 y2)387 void VCLXGraphics::drawLine( sal_Int32 x1, sal_Int32 y1, sal_Int32 x2, sal_Int32 y2 )
388 {
389     ::vos::OGuard aGuard( GetMutex() );
390 
391     if( mpOutputDevice )
392     {
393         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
394         mpOutputDevice->DrawLine( Point( x1, y1 ), Point( x2, y2 ) );
395     }
396 }
397 
drawRect(sal_Int32 x,sal_Int32 y,sal_Int32 width,sal_Int32 height)398 void VCLXGraphics::drawRect( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height )
399 {
400     ::vos::OGuard aGuard( GetMutex() );
401 
402     if( mpOutputDevice )
403     {
404         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
405         mpOutputDevice->DrawRect( Rectangle( Point( x, y ), Size( width, height ) ) );
406     }
407 }
408 
drawRoundedRect(sal_Int32 x,sal_Int32 y,sal_Int32 width,sal_Int32 height,sal_Int32 nHorzRound,sal_Int32 nVertRound)409 void VCLXGraphics::drawRoundedRect( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height, sal_Int32 nHorzRound, sal_Int32 nVertRound )
410 {
411     ::vos::OGuard aGuard( GetMutex() );
412 
413     if( mpOutputDevice )
414     {
415         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
416         mpOutputDevice->DrawRect( Rectangle( Point( x, y ), Size( width, height ) ), nHorzRound, nVertRound );
417     }
418 }
419 
drawPolyLine(const uno::Sequence<sal_Int32> & DataX,const uno::Sequence<sal_Int32> & DataY)420 void VCLXGraphics::drawPolyLine( const uno::Sequence< sal_Int32 >& DataX, const uno::Sequence< sal_Int32 >& DataY )
421 {
422     ::vos::OGuard aGuard( GetMutex() );
423 
424     if( mpOutputDevice )
425     {
426         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
427         mpOutputDevice->DrawPolyLine( VCLUnoHelper::CreatePolygon( DataX, DataY ) );
428     }
429 }
430 
drawPolygon(const uno::Sequence<sal_Int32> & DataX,const uno::Sequence<sal_Int32> & DataY)431 void VCLXGraphics::drawPolygon( const uno::Sequence< sal_Int32 >& DataX, const uno::Sequence< sal_Int32 >& DataY )
432 {
433     ::vos::OGuard aGuard( GetMutex() );
434 
435     if( mpOutputDevice )
436     {
437         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
438         mpOutputDevice->DrawPolygon( VCLUnoHelper::CreatePolygon( DataX, DataY ) );
439     }
440 }
441 
drawPolyPolygon(const uno::Sequence<uno::Sequence<sal_Int32>> & DataX,const uno::Sequence<uno::Sequence<sal_Int32>> & DataY)442 void VCLXGraphics::drawPolyPolygon( const uno::Sequence< uno::Sequence< sal_Int32 > >& DataX, const uno::Sequence< uno::Sequence< sal_Int32 > >& DataY )
443 {
444     ::vos::OGuard aGuard( GetMutex() );
445 
446     if( mpOutputDevice )
447     {
448         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
449         sal_uInt16 nPolys = (sal_uInt16) DataX.getLength();
450         PolyPolygon aPolyPoly( nPolys );
451         for ( sal_uInt16 n = 0; n < nPolys; n++ )
452             aPolyPoly[n] = VCLUnoHelper::CreatePolygon( DataX.getConstArray()[n], DataY.getConstArray()[n] );
453 
454         mpOutputDevice->DrawPolyPolygon( aPolyPoly );
455     }
456 }
457 
drawEllipse(sal_Int32 x,sal_Int32 y,sal_Int32 width,sal_Int32 height)458 void VCLXGraphics::drawEllipse( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height )
459 {
460     ::vos::OGuard aGuard( GetMutex() );
461 
462     if( mpOutputDevice )
463     {
464         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
465         mpOutputDevice->DrawEllipse( Rectangle( Point( x, y ), Size( width, height ) ) );
466     }
467 }
468 
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)469 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 )
470 {
471     ::vos::OGuard aGuard( GetMutex() );
472 
473     if( mpOutputDevice )
474     {
475         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
476         mpOutputDevice->DrawArc( Rectangle( Point( x, y ), Size( width, height ) ), Point( x1, y1 ), Point( x2, y2 ) );
477     }
478 }
479 
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)480 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 )
481 {
482     ::vos::OGuard aGuard( GetMutex() );
483 
484     if( mpOutputDevice )
485     {
486         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
487         mpOutputDevice->DrawPie( Rectangle( Point( x, y ), Size( width, height ) ), Point( x1, y1 ), Point( x2, y2 ) );
488     }
489 }
490 
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)491 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 )
492 {
493     ::vos::OGuard aGuard( GetMutex() );
494 
495     if( mpOutputDevice )
496     {
497         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
498         mpOutputDevice->DrawChord( Rectangle( Point( x, y ), Size( width, height ) ), Point( x1, y1 ), Point( x2, y2 ) );
499     }
500 }
501 
drawGradient(sal_Int32 x,sal_Int32 y,sal_Int32 width,sal_Int32 height,const awt::Gradient & rGradient)502 void VCLXGraphics::drawGradient( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height, const awt::Gradient& rGradient )
503 {
504     ::vos::OGuard aGuard( GetMutex() );
505 
506     if( mpOutputDevice )
507     {
508         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
509         Gradient aGradient((GradientStyle)rGradient.Style, rGradient.StartColor, rGradient.EndColor);
510         aGradient.SetAngle(rGradient.Angle);
511         aGradient.SetBorder(rGradient.Border);
512         aGradient.SetOfsX(rGradient.XOffset);
513         aGradient.SetOfsY(rGradient.YOffset);
514         aGradient.SetStartIntensity(rGradient.StartIntensity);
515         aGradient.SetEndIntensity(rGradient.EndIntensity);
516         aGradient.SetSteps(rGradient.StepCount);
517         mpOutputDevice->DrawGradient( Rectangle( Point( x, y ), Size( width, height ) ), aGradient );
518     }
519 }
520 
drawText(sal_Int32 x,sal_Int32 y,const::rtl::OUString & rText)521 void VCLXGraphics::drawText( sal_Int32 x, sal_Int32 y, const ::rtl::OUString& rText )
522 {
523     ::vos::OGuard aGuard( GetMutex() );
524 
525     if( mpOutputDevice )
526     {
527         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS |INITOUTDEV_FONT);
528         mpOutputDevice->DrawText( Point( x, y ), rText );
529     }
530 }
531 
drawTextArray(sal_Int32 x,sal_Int32 y,const::rtl::OUString & rText,const uno::Sequence<sal_Int32> & rLongs)532 void VCLXGraphics::drawTextArray( sal_Int32 x, sal_Int32 y, const ::rtl::OUString& rText, const uno::Sequence< sal_Int32 >& rLongs )
533 {
534     ::vos::OGuard aGuard( GetMutex() );
535 
536     if( mpOutputDevice )
537     {
538         InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS|INITOUTDEV_FONT );
539         mpOutputDevice->DrawTextArray( Point( x, y ), rText, rLongs.getConstArray() );
540     }
541 }
542 
543 
drawImage(sal_Int32 x,sal_Int32 y,sal_Int32 width,sal_Int32 height,sal_Int16 nStyle,const uno::Reference<graphic::XGraphic> & xGraphic)544 void VCLXGraphics::drawImage( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height, sal_Int16 nStyle, const uno::Reference< graphic::XGraphic >& xGraphic )
545 {
546     ::vos::OGuard aGuard( GetMutex() );
547 
548     if( mpOutputDevice && xGraphic.is() )
549     {
550         Image aImage( xGraphic );
551         if ( !!aImage )
552         {
553             InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
554             mpOutputDevice->DrawImage( Point( x, y ), Size( width, height ), aImage, nStyle );
555         }
556     }
557 }
558