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 ) throw(uno::RuntimeException)
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 allready 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() throw(uno::RuntimeException)
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() throw(uno::RuntimeException)
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 ) throw(uno::RuntimeException)
177 {
178 	::vos::OGuard aGuard( GetMutex() );
179 
180 	maFont = VCLUnoHelper::CreateFont( rxFont );
181 }
182 
getFont()183 uno::Reference< awt::XFont > VCLXGraphics::getFont() throw(uno::RuntimeException)
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 ) throw(uno::RuntimeException)
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 ) throw(uno::RuntimeException)
208 {
209 	::vos::OGuard aGuard( GetMutex() );
210 
211 	maTextColor = Color( (sal_uInt32)nColor );
212 }
213 
getTextColor()214 ::sal_Int32 VCLXGraphics::getTextColor() throw(uno::RuntimeException)
215 {
216     ::vos::OGuard aGuard( GetMutex() );
217     return maTextColor.GetColor();
218 }
219 
setTextFillColor(sal_Int32 nColor)220 void VCLXGraphics::setTextFillColor( sal_Int32 nColor ) throw(uno::RuntimeException)
221 {
222 	::vos::OGuard aGuard( GetMutex() );
223 
224 	maTextFillColor = Color( (sal_uInt32)nColor );
225 }
226 
getTextFillColor()227 ::sal_Int32 VCLXGraphics::getTextFillColor() throw(uno::RuntimeException)
228 {
229     ::vos::OGuard aGuard( GetMutex() );
230     return maTextFillColor.GetColor();
231 }
232 
setLineColor(sal_Int32 nColor)233 void VCLXGraphics::setLineColor( sal_Int32 nColor ) throw(uno::RuntimeException)
234 {
235 	::vos::OGuard aGuard( GetMutex() );
236 
237 	maLineColor = Color( (sal_uInt32)nColor );
238 }
239 
getLineColor()240 ::sal_Int32 VCLXGraphics::getLineColor() throw(uno::RuntimeException)
241 {
242     ::vos::OGuard aGuard( GetMutex() );
243     return maLineColor.GetColor();
244 }
245 
setFillColor(sal_Int32 nColor)246 void VCLXGraphics::setFillColor( sal_Int32 nColor ) throw(uno::RuntimeException)
247 {
248 	::vos::OGuard aGuard( GetMutex() );
249 
250 	maFillColor = Color( (sal_uInt32)nColor );
251 }
252 
getFillColor()253 ::sal_Int32 VCLXGraphics::getFillColor() throw(uno::RuntimeException)
254 {
255     ::vos::OGuard aGuard( GetMutex() );
256     return maFillColor.GetColor();
257 }
258 
setRasterOp(awt::RasterOperation eROP)259 void VCLXGraphics::setRasterOp( awt::RasterOperation eROP ) throw(uno::RuntimeException)
260 {
261 	::vos::OGuard aGuard( GetMutex() );
262 
263 	meRasterOp = (RasterOp)eROP;
264 }
265 
getRasterOp()266 awt::RasterOperation VCLXGraphics::getRasterOp()
267 throw(uno::RuntimeException)
268 {
269     ::vos::OGuard aGuard( GetMutex() );
270     return (awt::RasterOperation) meRasterOp;
271 }
272 
setClipRegion(const uno::Reference<awt::XRegion> & rxRegion)273 void VCLXGraphics::setClipRegion( const uno::Reference< awt::XRegion >& rxRegion ) throw(uno::RuntimeException)
274 {
275 	::vos::OGuard aGuard( GetMutex() );
276 
277 	delete mpClipRegion;
278 	if ( rxRegion.is() )
279 		mpClipRegion = new Region( VCLUnoHelper::GetRegion( rxRegion ) );
280 	else
281 		mpClipRegion = NULL;
282 }
283 
intersectClipRegion(const uno::Reference<awt::XRegion> & rxRegion)284 void VCLXGraphics::intersectClipRegion( const uno::Reference< awt::XRegion >& rxRegion ) throw(uno::RuntimeException)
285 {
286 	::vos::OGuard aGuard( GetMutex() );
287 
288 	if ( rxRegion.is() )
289 	{
290 		Region aRegion( VCLUnoHelper::GetRegion( rxRegion ) );
291 		if ( !mpClipRegion )
292 			mpClipRegion = new Region( aRegion );
293 		else
294 			mpClipRegion->Intersect( aRegion );
295 	}
296 }
297 
push()298 void VCLXGraphics::push(  ) throw(uno::RuntimeException)
299 {
300 	::vos::OGuard aGuard( GetMutex() );
301 
302 
303 	if( mpOutputDevice )
304 		mpOutputDevice->Push();
305 }
306 
pop()307 void VCLXGraphics::pop(  ) throw(uno::RuntimeException)
308 {
309 	::vos::OGuard aGuard( GetMutex() );
310 
311 
312 	if( mpOutputDevice )
313 		mpOutputDevice->Pop();
314 }
315 
clear(const awt::Rectangle & aRect)316 void VCLXGraphics::clear(
317     const awt::Rectangle& aRect )
318 throw(uno::RuntimeException)
319 {
320     ::vos::OGuard aGuard( GetMutex() );
321 
322     if( mpOutputDevice )
323     {
324         const ::Rectangle aVCLRect = VCLUnoHelper::ConvertToVCLRect( aRect );
325         mpOutputDevice->Erase( aVCLRect );
326     }
327 }
328 
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)329 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 ) throw(uno::RuntimeException)
330 {
331 	::vos::OGuard aGuard( GetMutex() );
332 
333 	if ( mpOutputDevice )
334 	{
335 		VCLXDevice* pFromDev = VCLXDevice::GetImplementation( rxSource );
336 		DBG_ASSERT( pFromDev, "VCLXGraphics::copy - invalid device" );
337 		if ( pFromDev )
338 		{
339 			InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP );
340 			mpOutputDevice->DrawOutDev( Point( nDestX, nDestY ), Size( nDestWidth, nDestHeight ),
341 									Point( nSourceX, nSourceY ), Size( nSourceWidth, nSourceHeight ), *pFromDev->GetOutputDevice() );
342 		}
343 	}
344 }
345 
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)346 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 ) throw(uno::RuntimeException)
347 {
348 	::vos::OGuard aGuard( GetMutex() );
349 
350 	if( mpOutputDevice )
351 	{
352 		InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP);
353 		uno::Reference< awt::XBitmap > xBitmap( rxBitmapHandle, uno::UNO_QUERY );
354 		BitmapEx aBmpEx = VCLUnoHelper::GetBitmap( xBitmap );
355 
356 		Point aPos(nDestX - nSourceX, nDestY - nSourceY);
357   		Size aSz = aBmpEx.GetSizePixel();
358 
359 		if(nDestWidth != nSourceWidth)
360 		{
361 			float zoomX = (float)nDestWidth / (float)nSourceWidth;
362 			aSz.Width() = (long) ((float)aSz.Width() * zoomX);
363 		}
364 
365 		if(nDestHeight != nSourceHeight)
366 		{
367 			float zoomY = (float)nDestHeight / (float)nSourceHeight;
368 			aSz.Height() = (long) ((float)aSz.Height() * zoomY);
369 		}
370 
371 		if(nSourceX || nSourceY || aSz.Width() != nSourceWidth || aSz.Height() != nSourceHeight)
372 			mpOutputDevice->IntersectClipRegion(Region(Rectangle(nDestX, nDestY, nDestX + nDestWidth - 1, nDestY + nDestHeight - 1)));
373 
374 		mpOutputDevice->DrawBitmapEx( aPos, aSz, aBmpEx );
375 	}
376 }
377 
drawPixel(sal_Int32 x,sal_Int32 y)378 void VCLXGraphics::drawPixel( sal_Int32 x, sal_Int32 y ) throw(uno::RuntimeException)
379 {
380 	::vos::OGuard aGuard( GetMutex() );
381 
382 	if( mpOutputDevice )
383 	{
384 		InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
385 		mpOutputDevice->DrawPixel( Point( x, y ) );
386 	}
387 }
388 
drawLine(sal_Int32 x1,sal_Int32 y1,sal_Int32 x2,sal_Int32 y2)389 void VCLXGraphics::drawLine( sal_Int32 x1, sal_Int32 y1, sal_Int32 x2, sal_Int32 y2 ) throw(uno::RuntimeException)
390 {
391 	::vos::OGuard aGuard( GetMutex() );
392 
393 	if( mpOutputDevice )
394 	{
395 		InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
396 		mpOutputDevice->DrawLine( Point( x1, y1 ), Point( x2, y2 ) );
397 	}
398 }
399 
drawRect(sal_Int32 x,sal_Int32 y,sal_Int32 width,sal_Int32 height)400 void VCLXGraphics::drawRect( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height ) throw(uno::RuntimeException)
401 {
402 	::vos::OGuard aGuard( GetMutex() );
403 
404 	if( mpOutputDevice )
405 	{
406 		InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
407 		mpOutputDevice->DrawRect( Rectangle( Point( x, y ), Size( width, height ) ) );
408 	}
409 }
410 
drawRoundedRect(sal_Int32 x,sal_Int32 y,sal_Int32 width,sal_Int32 height,sal_Int32 nHorzRound,sal_Int32 nVertRound)411 void VCLXGraphics::drawRoundedRect( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height, sal_Int32 nHorzRound, sal_Int32 nVertRound ) throw(uno::RuntimeException)
412 {
413 	::vos::OGuard aGuard( GetMutex() );
414 
415 	if( mpOutputDevice )
416 	{
417 		InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
418 		mpOutputDevice->DrawRect( Rectangle( Point( x, y ), Size( width, height ) ), nHorzRound, nVertRound );
419 	}
420 }
421 
drawPolyLine(const uno::Sequence<sal_Int32> & DataX,const uno::Sequence<sal_Int32> & DataY)422 void VCLXGraphics::drawPolyLine( const uno::Sequence< sal_Int32 >& DataX, const uno::Sequence< sal_Int32 >& DataY ) throw(uno::RuntimeException)
423 {
424 	::vos::OGuard aGuard( GetMutex() );
425 
426 	if( mpOutputDevice )
427 	{
428 		InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
429 		mpOutputDevice->DrawPolyLine( VCLUnoHelper::CreatePolygon( DataX, DataY ) );
430 	}
431 }
432 
drawPolygon(const uno::Sequence<sal_Int32> & DataX,const uno::Sequence<sal_Int32> & DataY)433 void VCLXGraphics::drawPolygon( const uno::Sequence< sal_Int32 >& DataX, const uno::Sequence< sal_Int32 >& DataY ) throw(uno::RuntimeException)
434 {
435 	::vos::OGuard aGuard( GetMutex() );
436 
437 	if( mpOutputDevice )
438 	{
439 		InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
440 		mpOutputDevice->DrawPolygon( VCLUnoHelper::CreatePolygon( DataX, DataY ) );
441 	}
442 }
443 
drawPolyPolygon(const uno::Sequence<uno::Sequence<sal_Int32>> & DataX,const uno::Sequence<uno::Sequence<sal_Int32>> & DataY)444 void VCLXGraphics::drawPolyPolygon( const uno::Sequence< uno::Sequence< sal_Int32 > >& DataX, const uno::Sequence< uno::Sequence< sal_Int32 > >& DataY ) throw(uno::RuntimeException)
445 {
446 	::vos::OGuard aGuard( GetMutex() );
447 
448 	if( mpOutputDevice )
449 	{
450 		InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
451 		sal_uInt16 nPolys = (sal_uInt16) DataX.getLength();
452 		PolyPolygon aPolyPoly( nPolys );
453 		for ( sal_uInt16 n = 0; n < nPolys; n++ )
454 			aPolyPoly[n] = VCLUnoHelper::CreatePolygon( DataX.getConstArray()[n], DataY.getConstArray()[n] );
455 
456 		mpOutputDevice->DrawPolyPolygon( aPolyPoly );
457 	}
458 }
459 
drawEllipse(sal_Int32 x,sal_Int32 y,sal_Int32 width,sal_Int32 height)460 void VCLXGraphics::drawEllipse( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height ) throw(uno::RuntimeException)
461 {
462 	::vos::OGuard aGuard( GetMutex() );
463 
464 	if( mpOutputDevice )
465 	{
466 		InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
467 		mpOutputDevice->DrawEllipse( Rectangle( Point( x, y ), Size( width, height ) ) );
468 	}
469 }
470 
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)471 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(uno::RuntimeException)
472 {
473 	::vos::OGuard aGuard( GetMutex() );
474 
475 	if( mpOutputDevice )
476 	{
477 		InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
478 		mpOutputDevice->DrawArc( Rectangle( Point( x, y ), Size( width, height ) ), Point( x1, y1 ), Point( x2, y2 ) );
479 	}
480 }
481 
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)482 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(uno::RuntimeException)
483 {
484 	::vos::OGuard aGuard( GetMutex() );
485 
486 	if( mpOutputDevice )
487 	{
488 		InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
489 		mpOutputDevice->DrawPie( Rectangle( Point( x, y ), Size( width, height ) ), Point( x1, y1 ), Point( x2, y2 ) );
490 	}
491 }
492 
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)493 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(uno::RuntimeException)
494 {
495 	::vos::OGuard aGuard( GetMutex() );
496 
497 	if( mpOutputDevice )
498 	{
499 		InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
500 		mpOutputDevice->DrawChord( Rectangle( Point( x, y ), Size( width, height ) ), Point( x1, y1 ), Point( x2, y2 ) );
501 	}
502 }
503 
drawGradient(sal_Int32 x,sal_Int32 y,sal_Int32 width,sal_Int32 height,const awt::Gradient & rGradient)504 void VCLXGraphics::drawGradient( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height, const awt::Gradient& rGradient ) throw(uno::RuntimeException)
505 {
506 	::vos::OGuard aGuard( GetMutex() );
507 
508 	if( mpOutputDevice )
509 	{
510 		InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
511 		Gradient aGradient((GradientStyle)rGradient.Style, rGradient.StartColor, rGradient.EndColor);
512 		aGradient.SetAngle(rGradient.Angle);
513 		aGradient.SetBorder(rGradient.Border);
514 		aGradient.SetOfsX(rGradient.XOffset);
515 		aGradient.SetOfsY(rGradient.YOffset);
516 		aGradient.SetStartIntensity(rGradient.StartIntensity);
517 		aGradient.SetEndIntensity(rGradient.EndIntensity);
518 		aGradient.SetSteps(rGradient.StepCount);
519 		mpOutputDevice->DrawGradient( Rectangle( Point( x, y ), Size( width, height ) ), aGradient );
520 	}
521 }
522 
drawText(sal_Int32 x,sal_Int32 y,const::rtl::OUString & rText)523 void VCLXGraphics::drawText( sal_Int32 x, sal_Int32 y, const ::rtl::OUString& rText ) throw(uno::RuntimeException)
524 {
525 	::vos::OGuard aGuard( GetMutex() );
526 
527 	if( mpOutputDevice )
528 	{
529 		InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS |INITOUTDEV_FONT);
530 		mpOutputDevice->DrawText( Point( x, y ), rText );
531 	}
532 }
533 
drawTextArray(sal_Int32 x,sal_Int32 y,const::rtl::OUString & rText,const uno::Sequence<sal_Int32> & rLongs)534 void VCLXGraphics::drawTextArray( sal_Int32 x, sal_Int32 y, const ::rtl::OUString& rText, const uno::Sequence< sal_Int32 >& rLongs ) throw(uno::RuntimeException)
535 {
536 	::vos::OGuard aGuard( GetMutex() );
537 
538 	if( mpOutputDevice )
539 	{
540 		InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS|INITOUTDEV_FONT );
541 		mpOutputDevice->DrawTextArray( Point( x, y ), rText, rLongs.getConstArray() );
542 	}
543 }
544 
545 
drawImage(sal_Int32 x,sal_Int32 y,sal_Int32 width,sal_Int32 height,sal_Int16 nStyle,const uno::Reference<graphic::XGraphic> & xGraphic)546 void VCLXGraphics::drawImage( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_Int32 height, sal_Int16 nStyle, const uno::Reference< graphic::XGraphic >& xGraphic ) throw(uno::RuntimeException)
547 {
548     ::vos::OGuard aGuard( GetMutex() );
549 
550     if( mpOutputDevice && xGraphic.is() )
551     {
552         Image aImage( xGraphic );
553         if ( !!aImage )
554         {
555             InitOutputDevice( INITOUTDEV_CLIPREGION|INITOUTDEV_RASTEROP|INITOUTDEV_COLORS );
556             mpOutputDevice->DrawImage( Point( x, y ), Size( width, height ), aImage, nStyle );
557         }
558     }
559 }
560