1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_canvas.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <com/sun/star/rendering/XSimpleCanvas.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/rendering/CompositeOperation.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/rendering/PanoseLetterForm.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/rendering/PanoseWeight.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceName.hpp> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <o3tl/lazy_update.hxx> 38*cdf0e10cSrcweir #include <cppuhelper/factory.hxx> 39*cdf0e10cSrcweir #include <cppuhelper/implementationentry.hxx> 40*cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx> 41*cdf0e10cSrcweir #include <cppuhelper/basemutex.hxx> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #include <comphelper/servicedecl.hxx> 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 46*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrixtools.hxx> 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir #include "canvas/canvastools.hxx" 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir #include <boost/bind.hpp> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir #define SERVICE_NAME "com.sun.star.rendering.SimpleCanvas" 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir using namespace ::com::sun::star; 55*cdf0e10cSrcweir using namespace canvas; 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir namespace 58*cdf0e10cSrcweir { 59*cdf0e10cSrcweir inline uno::Sequence< double > color2Sequence( sal_Int32 const& nColor ) 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir // TODO(F3): Color management 62*cdf0e10cSrcweir uno::Sequence< double > aRes( 4 ); 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir aRes[0] = static_cast<sal_uInt8>( (nColor&0xFF000000U) >> 24U ) / 255.0; 65*cdf0e10cSrcweir aRes[1] = static_cast<sal_uInt8>( (nColor&0x00FF0000U) >> 16U ) / 255.0; 66*cdf0e10cSrcweir aRes[2] = static_cast<sal_uInt8>( (nColor&0x0000FF00U) >> 8U ) / 255.0; 67*cdf0e10cSrcweir aRes[3] = static_cast<sal_uInt8>( (nColor&0x000000FFU) ) / 255.0; 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir return aRes; 70*cdf0e10cSrcweir } 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir inline uno::Reference< rendering::XPolyPolygon2D > rect2Poly( uno::Reference<rendering::XGraphicDevice> const& xDevice, 73*cdf0e10cSrcweir geometry::RealRectangle2D const& rRect ) 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir uno::Sequence< geometry::RealPoint2D > rectSequence( 4 ); 76*cdf0e10cSrcweir geometry::RealPoint2D* pOutput = rectSequence.getArray(); 77*cdf0e10cSrcweir pOutput[0] = geometry::RealPoint2D( rRect.X1, rRect.Y1 ); 78*cdf0e10cSrcweir pOutput[1] = geometry::RealPoint2D( rRect.X2, rRect.Y1 ); 79*cdf0e10cSrcweir pOutput[2] = geometry::RealPoint2D( rRect.X2, rRect.Y2 ); 80*cdf0e10cSrcweir pOutput[3] = geometry::RealPoint2D( rRect.X1, rRect.Y2 ); 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir uno::Sequence< uno::Sequence< geometry::RealPoint2D > > sequenceSequence( 1 ); 83*cdf0e10cSrcweir sequenceSequence[0] = rectSequence; 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir uno::Reference< rendering::XPolyPolygon2D > xRes( 86*cdf0e10cSrcweir xDevice->createCompatibleLinePolyPolygon( sequenceSequence ), 87*cdf0e10cSrcweir uno::UNO_QUERY ); 88*cdf0e10cSrcweir if( xRes.is() ) 89*cdf0e10cSrcweir xRes->setClosed( 0, sal_True ); 90*cdf0e10cSrcweir return xRes; 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir struct SimpleRenderState 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir o3tl::LazyUpdate<sal_Int32, 96*cdf0e10cSrcweir uno::Sequence<double>, 97*cdf0e10cSrcweir o3tl::LAZYUPDATE_FUNCTION_TAG > m_aPenColor; 98*cdf0e10cSrcweir o3tl::LazyUpdate<sal_Int32, 99*cdf0e10cSrcweir uno::Sequence<double>, 100*cdf0e10cSrcweir o3tl::LAZYUPDATE_FUNCTION_TAG > m_aFillColor; 101*cdf0e10cSrcweir o3tl::LazyUpdate<geometry::RealRectangle2D, 102*cdf0e10cSrcweir uno::Reference< rendering::XPolyPolygon2D >, 103*cdf0e10cSrcweir o3tl::LAZYUPDATE_FUNCTOR_TAG > m_aRectClip; 104*cdf0e10cSrcweir geometry::AffineMatrix2D m_aTransformation; 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir explicit SimpleRenderState( uno::Reference<rendering::XGraphicDevice> const& xDevice ) : 107*cdf0e10cSrcweir m_aPenColor( &color2Sequence), 108*cdf0e10cSrcweir m_aFillColor( &color2Sequence ), 109*cdf0e10cSrcweir m_aRectClip( boost::bind( &rect2Poly, 110*cdf0e10cSrcweir xDevice, 111*cdf0e10cSrcweir _1 )), 112*cdf0e10cSrcweir m_aTransformation() 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir tools::setIdentityAffineMatrix2D( m_aTransformation ); 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir }; 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::rendering::XSimpleCanvas, 120*cdf0e10cSrcweir ::com::sun::star::lang::XServiceName > SimpleCanvasBase; 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir class SimpleCanvasImpl : private cppu::BaseMutex, 123*cdf0e10cSrcweir public SimpleCanvasBase 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir private: 126*cdf0e10cSrcweir bool isStrokingEnabled() const 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir return maRenderState.m_aPenColor.getInValue() && sal_Int32(0xFF) != 0; 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir rendering::RenderState createStrokingRenderState() const 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir return rendering::RenderState(maRenderState.m_aTransformation, 134*cdf0e10cSrcweir *maRenderState.m_aRectClip, 135*cdf0e10cSrcweir *maRenderState.m_aPenColor, 136*cdf0e10cSrcweir rendering::CompositeOperation::OVER); 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir bool isFillingEnabled() const 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir return maRenderState.m_aFillColor.getInValue() && sal_Int32(0xFF) != 0; 142*cdf0e10cSrcweir } 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir rendering::RenderState createFillingRenderState() const 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir return rendering::RenderState(maRenderState.m_aTransformation, 147*cdf0e10cSrcweir *maRenderState.m_aRectClip, 148*cdf0e10cSrcweir *maRenderState.m_aFillColor, 149*cdf0e10cSrcweir rendering::CompositeOperation::OVER); 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir static uno::Reference<rendering::XCanvas> grabCanvas( uno::Sequence<uno::Any> const& rArgs ) 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir uno::Reference<rendering::XCanvas> xRet; 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir // can't do much without an XCanvas, can't we? 157*cdf0e10cSrcweir if( rArgs.getLength() < 1 ) 158*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir xRet.set( rArgs[0], uno::UNO_QUERY ); 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir // can't do much without an XCanvas, can't we? 163*cdf0e10cSrcweir if( !xRet.is() ) 164*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir return xRet; 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir public: 170*cdf0e10cSrcweir SimpleCanvasImpl( const uno::Sequence< uno::Any >& aArguments, 171*cdf0e10cSrcweir const uno::Reference< uno::XComponentContext >& ) : 172*cdf0e10cSrcweir SimpleCanvasBase( m_aMutex ), 173*cdf0e10cSrcweir mxCanvas( grabCanvas(aArguments) ), 174*cdf0e10cSrcweir maFont(boost::bind( &rendering::XCanvas::createFont, 175*cdf0e10cSrcweir boost::cref(mxCanvas), 176*cdf0e10cSrcweir _1, 177*cdf0e10cSrcweir uno::Sequence< beans::PropertyValue >(), 178*cdf0e10cSrcweir geometry::Matrix2D() )), 179*cdf0e10cSrcweir maViewState(), 180*cdf0e10cSrcweir maRenderState( mxCanvas->getDevice() ) 181*cdf0e10cSrcweir { 182*cdf0e10cSrcweir tools::initViewState(maViewState); 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////////////////////// 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir private: 188*cdf0e10cSrcweir // Ifc XServiceName 189*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getServiceName( ) throw (uno::RuntimeException) 190*cdf0e10cSrcweir { 191*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME ) ); 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir // Ifc XSimpleCanvas 195*cdf0e10cSrcweir virtual void SAL_CALL selectFont( const ::rtl::OUString& sFontName, 196*cdf0e10cSrcweir double size, 197*cdf0e10cSrcweir ::sal_Bool bold, 198*cdf0e10cSrcweir ::sal_Bool italic ) throw (uno::RuntimeException) 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir maFont->FontDescription.FamilyName = sFontName; 203*cdf0e10cSrcweir maFont->CellSize = size; 204*cdf0e10cSrcweir maFont->FontDescription.FontDescription.Weight = 205*cdf0e10cSrcweir bold ? rendering::PanoseWeight::BOLD : rendering::PanoseWeight::MEDIUM; 206*cdf0e10cSrcweir maFont->FontDescription.FontDescription.Letterform = 207*cdf0e10cSrcweir italic ? rendering::PanoseLetterForm::OBLIQUE_CONTACT : rendering::PanoseLetterForm::ANYTHING; 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir virtual void SAL_CALL setPenColor( ::sal_Int32 nsRgbaColor ) throw (uno::RuntimeException) 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 213*cdf0e10cSrcweir *(maRenderState.m_aPenColor) = nsRgbaColor; 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir virtual void SAL_CALL setFillColor( ::sal_Int32 nsRgbaColor ) throw (uno::RuntimeException) 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 219*cdf0e10cSrcweir *(maRenderState.m_aFillColor) = nsRgbaColor; 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir virtual void SAL_CALL setRectClip( const geometry::RealRectangle2D& aRect ) throw (uno::RuntimeException) 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 225*cdf0e10cSrcweir *(maRenderState.m_aRectClip) = aRect; 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir virtual void SAL_CALL setTransformation( const geometry::AffineMatrix2D& aTransform ) throw (uno::RuntimeException) 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 231*cdf0e10cSrcweir maRenderState.m_aTransformation = aTransform; 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir virtual void SAL_CALL drawPixel( const geometry::RealPoint2D& aPoint ) throw (uno::RuntimeException) 235*cdf0e10cSrcweir { 236*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 237*cdf0e10cSrcweir mxCanvas->drawPoint(aPoint, 238*cdf0e10cSrcweir maViewState, 239*cdf0e10cSrcweir createFillingRenderState()); 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir virtual void SAL_CALL drawLine( const geometry::RealPoint2D& aStartPoint, 243*cdf0e10cSrcweir const geometry::RealPoint2D& aEndPoint ) throw (uno::RuntimeException) 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 246*cdf0e10cSrcweir mxCanvas->drawLine(aStartPoint, 247*cdf0e10cSrcweir aEndPoint, 248*cdf0e10cSrcweir maViewState, 249*cdf0e10cSrcweir createStrokingRenderState()); 250*cdf0e10cSrcweir } 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir virtual void SAL_CALL drawRect( const geometry::RealRectangle2D& aRect ) throw (uno::RuntimeException) 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 255*cdf0e10cSrcweir uno::Reference< rendering::XPolyPolygon2D > xPoly( 256*cdf0e10cSrcweir rect2Poly( mxCanvas->getDevice(), 257*cdf0e10cSrcweir aRect)); 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir if( isFillingEnabled() ) 260*cdf0e10cSrcweir mxCanvas->drawPolyPolygon(xPoly, 261*cdf0e10cSrcweir maViewState, 262*cdf0e10cSrcweir createFillingRenderState()); 263*cdf0e10cSrcweir if( isStrokingEnabled() ) 264*cdf0e10cSrcweir mxCanvas->drawPolyPolygon(xPoly, 265*cdf0e10cSrcweir maViewState, 266*cdf0e10cSrcweir createStrokingRenderState()); 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir virtual void SAL_CALL drawPolyPolygon( const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon ) throw (uno::RuntimeException) 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir if( isFillingEnabled() ) 274*cdf0e10cSrcweir mxCanvas->drawPolyPolygon(xPolyPolygon, 275*cdf0e10cSrcweir maViewState, 276*cdf0e10cSrcweir createFillingRenderState()); 277*cdf0e10cSrcweir if( isStrokingEnabled() ) 278*cdf0e10cSrcweir mxCanvas->drawPolyPolygon(xPolyPolygon, 279*cdf0e10cSrcweir maViewState, 280*cdf0e10cSrcweir createStrokingRenderState()); 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir virtual void SAL_CALL drawText( const rendering::StringContext& aText, 284*cdf0e10cSrcweir const geometry::RealPoint2D& aOutPos, 285*cdf0e10cSrcweir ::sal_Int8 nTextDirection ) throw (uno::RuntimeException) 286*cdf0e10cSrcweir { 287*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 288*cdf0e10cSrcweir const basegfx::B2DHomMatrix offsetTransform(basegfx::tools::createTranslateB2DHomMatrix(aOutPos.X,aOutPos.Y)); 289*cdf0e10cSrcweir rendering::RenderState aRenderState( createStrokingRenderState() ); 290*cdf0e10cSrcweir tools::appendToRenderState(aRenderState, offsetTransform); 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir mxCanvas->drawText(aText, 293*cdf0e10cSrcweir maFont.getOutValue(), 294*cdf0e10cSrcweir maViewState, 295*cdf0e10cSrcweir aRenderState, 296*cdf0e10cSrcweir nTextDirection); 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir virtual void SAL_CALL drawBitmap( const uno::Reference< rendering::XBitmap >& xBitmap, 300*cdf0e10cSrcweir const geometry::RealPoint2D& aLeftTop ) throw (uno::RuntimeException) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 303*cdf0e10cSrcweir const basegfx::B2DHomMatrix offsetTransform(basegfx::tools::createTranslateB2DHomMatrix(aLeftTop.X,aLeftTop.Y)); 304*cdf0e10cSrcweir rendering::RenderState aRenderState( createStrokingRenderState() ); 305*cdf0e10cSrcweir tools::appendToRenderState(aRenderState, offsetTransform); 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir mxCanvas->drawBitmap(xBitmap,maViewState,aRenderState); 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir virtual uno::Reference< rendering::XGraphicDevice > SAL_CALL getDevice( ) throw (uno::RuntimeException) 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 313*cdf0e10cSrcweir return mxCanvas->getDevice(); 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir virtual uno::Reference< rendering::XCanvas > SAL_CALL getCanvas( ) throw (uno::RuntimeException) 317*cdf0e10cSrcweir { 318*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 319*cdf0e10cSrcweir return mxCanvas; 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir virtual rendering::FontMetrics SAL_CALL getFontMetrics( ) throw (uno::RuntimeException) 323*cdf0e10cSrcweir { 324*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 325*cdf0e10cSrcweir return maFont.getOutValue()->getFontMetrics(); 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir virtual uno::Reference< rendering::XCanvasFont > SAL_CALL getCurrentFont( ) throw (uno::RuntimeException) 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 331*cdf0e10cSrcweir return maFont.getOutValue(); 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir virtual ::sal_Int32 SAL_CALL getCurrentPenColor( ) throw (uno::RuntimeException) 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 337*cdf0e10cSrcweir return maRenderState.m_aPenColor.getInValue(); 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir virtual ::sal_Int32 SAL_CALL getCurrentFillColor( ) throw (uno::RuntimeException) 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 343*cdf0e10cSrcweir return maRenderState.m_aFillColor.getInValue(); 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir virtual geometry::RealRectangle2D SAL_CALL getCurrentClipRect( ) throw (uno::RuntimeException) 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 349*cdf0e10cSrcweir return maRenderState.m_aRectClip.getInValue(); 350*cdf0e10cSrcweir } 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir virtual geometry::AffineMatrix2D SAL_CALL getCurrentTransformation( ) throw (uno::RuntimeException) 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 355*cdf0e10cSrcweir return maRenderState.m_aTransformation; 356*cdf0e10cSrcweir } 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir virtual rendering::ViewState SAL_CALL getCurrentViewState( ) throw (uno::RuntimeException) 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 361*cdf0e10cSrcweir return maViewState; 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir virtual rendering::RenderState SAL_CALL getCurrentRenderState( sal_Bool bUseFillColor ) throw (uno::RuntimeException) 365*cdf0e10cSrcweir { 366*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 367*cdf0e10cSrcweir if( bUseFillColor ) 368*cdf0e10cSrcweir return createFillingRenderState(); 369*cdf0e10cSrcweir else 370*cdf0e10cSrcweir return createStrokingRenderState(); 371*cdf0e10cSrcweir } 372*cdf0e10cSrcweir 373*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////////////////////// 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir typedef o3tl::LazyUpdate< 376*cdf0e10cSrcweir rendering::FontRequest, 377*cdf0e10cSrcweir uno::Reference< rendering::XCanvasFont >, 378*cdf0e10cSrcweir o3tl::LAZYUPDATE_FUNCTOR_TAG > SimpleFont; 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir uno::Reference<rendering::XCanvas> mxCanvas; 381*cdf0e10cSrcweir SimpleFont maFont; 382*cdf0e10cSrcweir rendering::ViewState maViewState; 383*cdf0e10cSrcweir SimpleRenderState maRenderState; 384*cdf0e10cSrcweir }; 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir namespace sdecl = comphelper::service_decl; 387*cdf0e10cSrcweir #if defined (__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ <= 3) 388*cdf0e10cSrcweir sdecl::class_<SimpleCanvasImpl, sdecl::with_args<true> > serviceImpl; 389*cdf0e10cSrcweir const sdecl::ServiceDecl simpleCanvasDecl( 390*cdf0e10cSrcweir serviceImpl, 391*cdf0e10cSrcweir #else 392*cdf0e10cSrcweir const sdecl::ServiceDecl simpleCanvasDecl( 393*cdf0e10cSrcweir sdecl::class_<SimpleCanvasImpl, sdecl::with_args<true> >(), 394*cdf0e10cSrcweir #endif 395*cdf0e10cSrcweir "com.sun.star.comp.rendering.SimpleCanvas", 396*cdf0e10cSrcweir SERVICE_NAME ); 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir // The C shared lib entry points 400*cdf0e10cSrcweir COMPHELPER_SERVICEDECL_EXPORTS1(simpleCanvasDecl) 401