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