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