From 015efe95f3be2da3d0b049553824a4c65885c31c Mon Sep 17 00:00:00 2001 From: Kurt Zenker Date: Wed, 2 Nov 2005 12:40:58 +0000 Subject: [PATCH] INTEGRATION: CWS canvas02 (1.6.4); FILE MERGED 2005/10/09 09:12:39 thb 1.6.4.3: RESYNC: (1.6-1.7); FILE MERGED 2005/08/30 11:34:00 thb 1.6.4.2: #i53964# Added optional rotation angle parameter to modifyClip (and changed all call sites); passing the font rotation as an additional parameter, when calling modifyClip for TextActions. 2005/08/24 23:02:57 thb 1.6.4.1: #i52876# Added CachedPrimitiveBase base class for common XCachedPrimitive handling; removed external header guards from cxx files --- cppcanvas/source/mtfrenderer/mtftools.cxx | 86 +++++++++++++---------- 1 file changed, 47 insertions(+), 39 deletions(-) diff --git a/cppcanvas/source/mtfrenderer/mtftools.cxx b/cppcanvas/source/mtfrenderer/mtftools.cxx index c30bfcfb0f3d..f667402f07f8 100644 --- a/cppcanvas/source/mtfrenderer/mtftools.cxx +++ b/cppcanvas/source/mtfrenderer/mtftools.cxx @@ -4,9 +4,9 @@ * * $RCSfile: mtftools.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: rt $ $Date: 2005-09-08 08:19:37 $ + * last change: $Author: kz $ $Date: 2005-11-02 13:40:58 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -36,54 +36,27 @@ #include #include -#include -#include -#include - -#ifndef _COM_SUN_STAR_RENDERING_RENDERSTATE_HPP__ #include -#endif -#ifndef _COM_SUN_STAR_RENDERING_XCANVAS_HPP__ #include -#endif -#ifndef _BGFX_NUMERIC_FTOOLS_HXX #include -#endif -#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX #include -#endif -#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX #include -#endif -#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX #include -#endif -#ifndef _BGFX_RANGE_B2DRECTANGLE_HXX #include -#endif -#ifndef _BGFX_VECTOR_B2DVECTOR_HXX #include -#endif -#ifndef _CANVAS_CANVASTOOLS_HXX #include -#endif -#ifndef _SV_GDIMTF_HXX #include -#endif -#ifndef _SV_METAACT_HXX #include -#endif -#ifndef _SV_VIRDEV_HXX #include -#endif -#ifndef _SV_METRIC_HXX #include -#endif -#ifndef _TL_POLY_HXX #include -#endif + +#include "mtftools.hxx" +#include "outdevstate.hxx" +#include "polypolyaction.hxx" + using namespace ::com::sun::star; @@ -149,7 +122,8 @@ namespace cppcanvas const struct ::cppcanvas::internal::OutDevState& rOutdevState, const CanvasSharedPtr& rCanvas, const ::basegfx::B2DPoint& rOffset, - const ::basegfx::B2DVector* pScaling ) + const ::basegfx::B2DVector* pScaling, + const double* pRotation ) { const ::Point aEmptyPoint; @@ -157,8 +131,10 @@ namespace cppcanvas const bool bScaling( pScaling && pScaling->getX() != 1.0 && pScaling->getY() != 1.0 ); + const bool bRotation( pRotation && + *pRotation != 0.0 ); - if( !bOffsetting && !bScaling ) + if( !bOffsetting && !bScaling && !bRotation ) return false; // nothing to do if( rOutdevState.clip.count() ) @@ -174,6 +150,9 @@ namespace cppcanvas if( bScaling ) aTransform.scale( 1.0/pScaling->getX(), 1.0/pScaling->getY() ); + if( bRotation ) + aTransform.rotate( - *pRotation ); + aLocalClip.transform( aTransform ); o_rRenderState.Clip = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon( @@ -188,7 +167,34 @@ namespace cppcanvas const ::Rectangle aLocalClipRect( rOutdevState.clipRect ); - if( bScaling ) + if( bRotation ) + { + // rotation involved - convert to polygon first, + // then transform that + ::basegfx::B2DPolygon aLocalClip( + ::basegfx::tools::createPolygonFromRect( + ::basegfx::B2DRectangle( + (double)(aLocalClipRect.Left()), + (double)(aLocalClipRect.Top()), + (double)(aLocalClipRect.Right()), + (double)(aLocalClipRect.Bottom()) ) ) ); + ::basegfx::B2DHomMatrix aTransform; + + if( bOffsetting ) + aTransform.translate( -rOffset.getX(), + -rOffset.getY() ); + if( bScaling ) + aTransform.scale( 1.0/pScaling->getX(), 1.0/pScaling->getY() ); + + aTransform.rotate( - *pRotation ); + + aLocalClip.transform( aTransform ); + + o_rRenderState.Clip = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon( + rCanvas->getUNOCanvas()->getDevice(), + ::basegfx::B2DPolyPolygon( aLocalClip ) ); + } + else if( bScaling ) { // scale and offset - do it on the fly, have to // convert to float anyway. @@ -227,14 +233,16 @@ namespace cppcanvas const struct ::cppcanvas::internal::OutDevState& rOutdevState, const CanvasSharedPtr& rCanvas, const ::Point& rOffset, - const ::basegfx::B2DVector* pScaling ) + const ::basegfx::B2DVector* pScaling, + const double* pRotation ) { return modifyClip( o_rRenderState, rOutdevState, rCanvas, ::basegfx::B2DPoint( rOffset.X(), rOffset.Y() ), - pScaling ); + pScaling, + pRotation ); } bool modifyClip( rendering::RenderState& o_rRenderState,