From 0366f3a47138ceb14a4fb8cf2f10394dc9902c08 Mon Sep 17 00:00:00 2001 From: Vladimir Glazounov Date: Wed, 1 Nov 2006 16:48:18 +0000 Subject: [PATCH] INTEGRATION: CWS thbpp5 (1.13.4); FILE MERGED 2006/10/13 20:00:31 thb 1.13.4.1: #i68512# Fixed double-rotation of outline text glyphs --- cppcanvas/source/mtfrenderer/textaction.cxx | 248 ++++++++++---------- 1 file changed, 129 insertions(+), 119 deletions(-) diff --git a/cppcanvas/source/mtfrenderer/textaction.cxx b/cppcanvas/source/mtfrenderer/textaction.cxx index 5679084e120c..31c42122274f 100644 --- a/cppcanvas/source/mtfrenderer/textaction.cxx +++ b/cppcanvas/source/mtfrenderer/textaction.cxx @@ -4,9 +4,9 @@ * * $RCSfile: textaction.cxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: obo $ $Date: 2006-10-12 15:00:26 $ + * last change: $Author: vg $ $Date: 2006-11-01 17:48:18 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -1966,148 +1966,158 @@ namespace cppcanvas // PolyPolygon. That polygon is then converted to // device coordinate system. + // #i68512# Temporarily switch off font rotation + // (which is already contained in the render state + // transformation matrix - otherwise, glyph polygons + // will be rotated twice) + const ::Font aOrigFont( rVDev.GetFont() ); + ::Font aUnrotatedFont( aOrigFont ); + aUnrotatedFont.SetOrientation(0); + rVDev.SetFont( aUnrotatedFont ); + // TODO(F3): Don't understand parameter semantics of // GetTextOutlines() ::PolyPolygon aResultingVCLPolyPolygon; PolyPolyVector aVCLPolyPolyVector; - if( rVDev.GetTextOutlines( aVCLPolyPolyVector, rText, - static_cast(nStartPos), - static_cast(nStartPos), - static_cast(nLen), - TRUE, 0, pDXArray ) ) + const bool bHaveOutlines( rVDev.GetTextOutlines( aVCLPolyPolyVector, rText, + static_cast(nStartPos), + static_cast(nStartPos), + static_cast(nLen), + TRUE, 0, pDXArray ) ); + rVDev.SetFont(aOrigFont); + + if( !bHaveOutlines ) + return ActionSharedPtr(); + + ::std::vector< sal_Int32 > aPolygonGlyphMap; + + // first glyph starts at polygon index 0 + aPolygonGlyphMap.push_back( 0 ); + + // temporarily remove offsetting from mapmode + // (outline polygons must stay at origin, only + // need to be scaled) + const ::MapMode aOldMapMode( rVDev.GetMapMode() ); + + ::MapMode aScaleOnlyMapMode( aOldMapMode ); + aScaleOnlyMapMode.SetOrigin( ::Point() ); + rVDev.SetMapMode( aScaleOnlyMapMode ); + + PolyPolyVector::const_iterator aIter( aVCLPolyPolyVector.begin() ); + const PolyPolyVector::const_iterator aEnd( aVCLPolyPolyVector.end() ); + for( ; aIter!= aEnd; ++aIter ) { - ::std::vector< sal_Int32 > aPolygonGlyphMap; + ::PolyPolygon aVCLPolyPolygon; - // first glyph starts at polygon index 0 - aPolygonGlyphMap.push_back( 0 ); + aVCLPolyPolygon = rVDev.LogicToPixel( *aIter ); - // temporarily remove offsetting from mapmode - // (outline polygons must stay at origin, only - // need to be scaled) - const ::MapMode aOldMapMode( rVDev.GetMapMode() ); - - ::MapMode aScaleOnlyMapMode( aOldMapMode ); - aScaleOnlyMapMode.SetOrigin( ::Point() ); - rVDev.SetMapMode( aScaleOnlyMapMode ); - - PolyPolyVector::const_iterator aIter( aVCLPolyPolyVector.begin() ); - const PolyPolyVector::const_iterator aEnd( aVCLPolyPolyVector.end() ); - for( ; aIter!= aEnd; ++aIter ) + // append result to collecting polypoly + for( USHORT i=0; i aCharWidthSeq( - pDXArray ? - setupDXArray( pDXArray, nLen, rVDev ) : - setupDXArray( rText, - nStartPos, - nLen, - rVDev ) ); - const uno::Reference< rendering::XPolyPolygon2D > xTextPoly( - ::vcl::unotools::xPolyPolygonFromPolyPolygon( - rCanvas->getUNOCanvas()->getDevice(), - aResultingVCLPolyPolygon ) ); - - ::Point aEmptyPoint; - if( rParms.maTextTransformation.isValid() ) - { - return ActionSharedPtr( - new OutlineAction( - rStartPoint, - rReliefOffset, - rReliefColor, - rShadowOffset, - rShadowColor, - aResultingVCLPolyPolygon.GetBoundRect(), - xTextPoly, - aPolygonGlyphMap, - aCharWidthSeq, - rVDev, - rCanvas, - rState, - rParms.maTextTransformation.getValue() ) ); - } - else - { - return ActionSharedPtr( - new OutlineAction( - rStartPoint, - rReliefOffset, - rReliefColor, - rShadowOffset, - rShadowColor, - aResultingVCLPolyPolygon.GetBoundRect(), - xTextPoly, - aPolygonGlyphMap, - aCharWidthSeq, - rVDev, - rCanvas, - rState ) ); - } + // calc next glyph index + aPolygonGlyphMap.push_back( aResultingVCLPolyPolygon.Count() ); } - return ActionSharedPtr(); + rVDev.SetMapMode( aOldMapMode ); + + const uno::Sequence< double > aCharWidthSeq( + pDXArray ? + setupDXArray( pDXArray, nLen, rVDev ) : + setupDXArray( rText, + nStartPos, + nLen, + rVDev ) ); + const uno::Reference< rendering::XPolyPolygon2D > xTextPoly( + ::vcl::unotools::xPolyPolygonFromPolyPolygon( + rCanvas->getUNOCanvas()->getDevice(), + aResultingVCLPolyPolygon ) ); + + ::Point aEmptyPoint; + if( rParms.maTextTransformation.isValid() ) + { + return ActionSharedPtr( + new OutlineAction( + rStartPoint, + rReliefOffset, + rReliefColor, + rShadowOffset, + rShadowColor, + aResultingVCLPolyPolygon.GetBoundRect(), + xTextPoly, + aPolygonGlyphMap, + aCharWidthSeq, + rVDev, + rCanvas, + rState, + rParms.maTextTransformation.getValue() ) ); + } + else + { + return ActionSharedPtr( + new OutlineAction( + rStartPoint, + rReliefOffset, + rReliefColor, + rShadowOffset, + rShadowColor, + aResultingVCLPolyPolygon.GetBoundRect(), + xTextPoly, + aPolygonGlyphMap, + aCharWidthSeq, + rVDev, + rCanvas, + rState ) ); + } } - } + } // namespace // ---------------------------------------------------------------------------------