From f221d52d2ec751a3888c590f4ef20ced8d2eb1bf Mon Sep 17 00:00:00 2001 From: Kurt Zenker Date: Wed, 2 Nov 2005 12:43:15 +0000 Subject: [PATCH] INTEGRATION: CWS canvas02 (1.5.8); FILE MERGED 2005/10/09 09:19:00 thb 1.5.8.2: RESYNC: (1.5-1.6); FILE MERGED 2005/08/19 11:08:34 thb 1.5.8.1: #i53538# Changed clip setting to use basegfx polygon (cppcanvas::PolyPolygon contains reference back to canvas); changed direct access to base class member to getter method, thus, providing the actual XCanvas clip polygon lazily. --- cppcanvas/source/wrapper/implcanvas.cxx | 38 ++++++++++++++++--------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/cppcanvas/source/wrapper/implcanvas.cxx b/cppcanvas/source/wrapper/implcanvas.cxx index 2cadbfca8f70..01d8d10437c1 100644 --- a/cppcanvas/source/wrapper/implcanvas.cxx +++ b/cppcanvas/source/wrapper/implcanvas.cxx @@ -4,9 +4,9 @@ * * $RCSfile: implcanvas.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: rt $ $Date: 2005-09-08 08:26:17 $ + * last change: $Author: kz $ $Date: 2005-11-02 13:43:15 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,8 +33,6 @@ * ************************************************************************/ -#include - #ifndef _RTL_USTRING_HXX_ #include #endif @@ -44,6 +42,9 @@ #ifndef _BGFX_POLYGON_B2DPOLYPOLYGON_HXX #include #endif +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include +#endif #ifndef _COM_SUN_STAR_RENDERING_XCANVAS_HPP_ #include @@ -55,6 +56,8 @@ #include #include +#include + using namespace ::com::sun::star; @@ -65,7 +68,7 @@ namespace cppcanvas ImplCanvas::ImplCanvas( const uno::Reference< rendering::XCanvas >& xCanvas ) : maViewState(), - mpClipPolyPolygon(), + maClipPolyPolygon(), mxCanvas( xCanvas ) { OSL_ENSURE( mxCanvas.is(), "Canvas::Canvas() invalid XCanvas" ); @@ -89,19 +92,16 @@ namespace cppcanvas maViewState ); } - void ImplCanvas::setClip( const PolyPolygonSharedPtr& rClipPoly ) + void ImplCanvas::setClip( const ::basegfx::B2DPolyPolygon& rClipPoly ) { - mpClipPolyPolygon = rClipPoly; - - if( rClipPoly.get() ) - maViewState.Clip = rClipPoly->getUNOPolyPolygon(); - else - maViewState.Clip.clear(); + // TODO(T3): not thread-safe. B2DPolyPolygon employs copy-on-write + maClipPolyPolygon = rClipPoly; + maViewState.Clip.clear(); } - PolyPolygonSharedPtr ImplCanvas::getClip() const + ::basegfx::B2DPolyPolygon ImplCanvas::getClip() const { - return mpClipPolyPolygon; + return maClipPolyPolygon; } FontSharedPtr ImplCanvas::createFont( const ::rtl::OUString& rFontName, const double& rCellSize ) const @@ -128,6 +128,16 @@ namespace cppcanvas rendering::ViewState ImplCanvas::getViewState() const { + if( maClipPolyPolygon.count() && !maViewState.Clip.is() ) + { + if( !mxCanvas.is() ) + return maViewState; + + maViewState.Clip = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon( + mxCanvas->getDevice(), + maClipPolyPolygon ); + } + return maViewState; }