1*464702f4SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*464702f4SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*464702f4SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*464702f4SAndrew Rist * distributed with this work for additional information 6*464702f4SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*464702f4SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*464702f4SAndrew Rist * "License"); you may not use this file except in compliance 9*464702f4SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*464702f4SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*464702f4SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*464702f4SAndrew Rist * software distributed under the License is distributed on an 15*464702f4SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*464702f4SAndrew Rist * KIND, either express or implied. See the License for the 17*464702f4SAndrew Rist * specific language governing permissions and limitations 18*464702f4SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*464702f4SAndrew Rist *************************************************************/ 21*464702f4SAndrew Rist 22*464702f4SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_drawinglayer.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <drawinglayer/processor2d/vclprocessor2d.hxx> 28cdf0e10cSrcweir #include <drawinglayer/primitive2d/textprimitive2d.hxx> 29cdf0e10cSrcweir #include <drawinglayer/primitive2d/textdecoratedprimitive2d.hxx> 30cdf0e10cSrcweir #include <tools/debug.hxx> 31cdf0e10cSrcweir #include <vcl/outdev.hxx> 32cdf0e10cSrcweir #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> 33cdf0e10cSrcweir #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> 34cdf0e10cSrcweir #include <drawinglayer/primitive2d/rendergraphicprimitive2d.hxx> 35cdf0e10cSrcweir #include <vclhelperbitmaptransform.hxx> 36cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx> 37cdf0e10cSrcweir #include <vclhelperbitmaprender.hxx> 38cdf0e10cSrcweir #include <drawinglayer/attribute/sdrfillbitmapattribute.hxx> 39cdf0e10cSrcweir #include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx> 40cdf0e10cSrcweir #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> 41cdf0e10cSrcweir #include <vclhelpergradient.hxx> 42cdf0e10cSrcweir #include <drawinglayer/primitive2d/metafileprimitive2d.hxx> 43cdf0e10cSrcweir #include <drawinglayer/primitive2d/maskprimitive2d.hxx> 44cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx> 45cdf0e10cSrcweir #include <vclhelperbufferdevice.hxx> 46cdf0e10cSrcweir #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx> 47cdf0e10cSrcweir #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx> 48cdf0e10cSrcweir #include <drawinglayer/primitive2d/transparenceprimitive2d.hxx> 49cdf0e10cSrcweir #include <drawinglayer/primitive2d/transformprimitive2d.hxx> 50cdf0e10cSrcweir #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx> 51cdf0e10cSrcweir #include <drawinglayer/primitive2d/pointarrayprimitive2d.hxx> 52cdf0e10cSrcweir #include <drawinglayer/primitive2d/wrongspellprimitive2d.hxx> 53cdf0e10cSrcweir #include <svl/ctloptions.hxx> 54cdf0e10cSrcweir #include <vcl/svapp.hxx> 55cdf0e10cSrcweir #include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx> 56cdf0e10cSrcweir #include <tools/diagnose_ex.h> 57cdf0e10cSrcweir #include <vcl/metric.hxx> 58cdf0e10cSrcweir #include <drawinglayer/primitive2d/textenumsprimitive2d.hxx> 59cdf0e10cSrcweir #include <drawinglayer/primitive2d/epsprimitive2d.hxx> 60cdf0e10cSrcweir #include <vcl/rendergraphicrasterizer.hxx> 61cdf0e10cSrcweir 62cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 63cdf0e10cSrcweir // control support 64cdf0e10cSrcweir 65cdf0e10cSrcweir #include <com/sun/star/awt/XWindow2.hpp> 66cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp> 67cdf0e10cSrcweir #include <com/sun/star/awt/XView.hpp> 68cdf0e10cSrcweir #include <drawinglayer/primitive2d/controlprimitive2d.hxx> 69cdf0e10cSrcweir #include <drawinglayer/primitive2d/textlayoutdevice.hxx> 70cdf0e10cSrcweir 71cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 72cdf0e10cSrcweir // for test, can be removed again 73cdf0e10cSrcweir 74cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygonclipper.hxx> 75cdf0e10cSrcweir #include <basegfx/polygon/b2dtrapezoid.hxx> 76cdf0e10cSrcweir 77cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 78cdf0e10cSrcweir 79cdf0e10cSrcweir using namespace com::sun::star; 80cdf0e10cSrcweir 81cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 82cdf0e10cSrcweir 83cdf0e10cSrcweir namespace drawinglayer 84cdf0e10cSrcweir { 85cdf0e10cSrcweir namespace processor2d 86cdf0e10cSrcweir { 87cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 88cdf0e10cSrcweir // UNO class usages 89cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 90cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY; 91cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY_THROW; 92cdf0e10cSrcweir using ::com::sun::star::uno::Exception; 93cdf0e10cSrcweir using ::com::sun::star::awt::XView; 94cdf0e10cSrcweir using ::com::sun::star::awt::XGraphics; 95cdf0e10cSrcweir using ::com::sun::star::awt::XWindow; 96cdf0e10cSrcweir using ::com::sun::star::awt::PosSize::POSSIZE; 97cdf0e10cSrcweir 98cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 99cdf0e10cSrcweir // rendering support 100cdf0e10cSrcweir 101cdf0e10cSrcweir // directdraw of text simple portion or decorated portion primitive. When decorated, all the extra 102cdf0e10cSrcweir // information is translated to VCL parameters and set at the font. 103cdf0e10cSrcweir // Acceptance is restricted to no shearing and positive scaling in X and Y (no font mirroring 104cdf0e10cSrcweir // for VCL) 105cdf0e10cSrcweir void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D(const primitive2d::TextSimplePortionPrimitive2D& rTextCandidate) 106cdf0e10cSrcweir { 107cdf0e10cSrcweir // decompose matrix to have position and size of text 108cdf0e10cSrcweir basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rTextCandidate.getTextTransform()); 109cdf0e10cSrcweir basegfx::B2DVector aFontScaling, aTranslate; 110cdf0e10cSrcweir double fRotate, fShearX; 111cdf0e10cSrcweir aLocalTransform.decompose(aFontScaling, aTranslate, fRotate, fShearX); 112cdf0e10cSrcweir bool bPrimitiveAccepted(false); 113cdf0e10cSrcweir 114cdf0e10cSrcweir if(basegfx::fTools::equalZero(fShearX)) 115cdf0e10cSrcweir { 116cdf0e10cSrcweir if(basegfx::fTools::less(aFontScaling.getX(), 0.0) && basegfx::fTools::less(aFontScaling.getY(), 0.0)) 117cdf0e10cSrcweir { 118cdf0e10cSrcweir // handle special case: If scale is negative in (x,y) (3rd quadrant), it can 119cdf0e10cSrcweir // be expressed as rotation by PI. Use this since the Font rendering will not 120cdf0e10cSrcweir // apply the negative scales in any form 121cdf0e10cSrcweir aFontScaling = basegfx::absolute(aFontScaling); 122cdf0e10cSrcweir fRotate += F_PI; 123cdf0e10cSrcweir } 124cdf0e10cSrcweir 125cdf0e10cSrcweir if(basegfx::fTools::more(aFontScaling.getX(), 0.0) && basegfx::fTools::more(aFontScaling.getY(), 0.0)) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir // Get the VCL font (use FontHeight as FontWidth) 128cdf0e10cSrcweir Font aFont(primitive2d::getVclFontFromFontAttribute( 129cdf0e10cSrcweir rTextCandidate.getFontAttribute(), 130cdf0e10cSrcweir aFontScaling.getX(), 131cdf0e10cSrcweir aFontScaling.getY(), 132cdf0e10cSrcweir fRotate, 133cdf0e10cSrcweir rTextCandidate.getLocale())); 134cdf0e10cSrcweir 135cdf0e10cSrcweir // handle additional font attributes 136cdf0e10cSrcweir const primitive2d::TextDecoratedPortionPrimitive2D* pTCPP = 137cdf0e10cSrcweir dynamic_cast<const primitive2d::TextDecoratedPortionPrimitive2D*>( &rTextCandidate ); 138cdf0e10cSrcweir 139cdf0e10cSrcweir if( pTCPP != NULL ) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir 142cdf0e10cSrcweir // set the color of text decorations 143cdf0e10cSrcweir const basegfx::BColor aTextlineColor = maBColorModifierStack.getModifiedColor(pTCPP->getTextlineColor()); 144cdf0e10cSrcweir mpOutputDevice->SetTextLineColor( Color(aTextlineColor) ); 145cdf0e10cSrcweir 146cdf0e10cSrcweir // set Overline attribute 147cdf0e10cSrcweir const FontUnderline eFontOverline(primitive2d::mapTextLineToFontUnderline( pTCPP->getFontOverline() )); 148cdf0e10cSrcweir if( eFontOverline != UNDERLINE_NONE ) 149cdf0e10cSrcweir { 150cdf0e10cSrcweir aFont.SetOverline( eFontOverline ); 151cdf0e10cSrcweir const basegfx::BColor aOverlineColor = maBColorModifierStack.getModifiedColor(pTCPP->getOverlineColor()); 152cdf0e10cSrcweir mpOutputDevice->SetOverlineColor( Color(aOverlineColor) ); 153cdf0e10cSrcweir if( pTCPP->getWordLineMode() ) 154cdf0e10cSrcweir aFont.SetWordLineMode( true ); 155cdf0e10cSrcweir } 156cdf0e10cSrcweir 157cdf0e10cSrcweir // set Underline attribute 158cdf0e10cSrcweir const FontUnderline eFontUnderline(primitive2d::mapTextLineToFontUnderline( pTCPP->getFontUnderline() )); 159cdf0e10cSrcweir if( eFontUnderline != UNDERLINE_NONE ) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir aFont.SetUnderline( eFontUnderline ); 162cdf0e10cSrcweir if( pTCPP->getWordLineMode() ) 163cdf0e10cSrcweir aFont.SetWordLineMode( true ); 164cdf0e10cSrcweir //TODO: ??? if( pTCPP->getUnderlineAbove() ) 165cdf0e10cSrcweir // aFont.SetUnderlineAbove( true ); 166cdf0e10cSrcweir } 167cdf0e10cSrcweir 168cdf0e10cSrcweir // set Strikeout attribute 169cdf0e10cSrcweir const FontStrikeout eFontStrikeout(primitive2d::mapTextStrikeoutToFontStrikeout(pTCPP->getTextStrikeout())); 170cdf0e10cSrcweir 171cdf0e10cSrcweir if( eFontStrikeout != STRIKEOUT_NONE ) 172cdf0e10cSrcweir aFont.SetStrikeout( eFontStrikeout ); 173cdf0e10cSrcweir 174cdf0e10cSrcweir // set EmphasisMark attribute 175cdf0e10cSrcweir FontEmphasisMark eFontEmphasisMark = EMPHASISMARK_NONE; 176cdf0e10cSrcweir switch( pTCPP->getTextEmphasisMark() ) 177cdf0e10cSrcweir { 178cdf0e10cSrcweir default: 179cdf0e10cSrcweir DBG_WARNING1( "DrawingLayer: Unknown EmphasisMark style (%d)!", pTCPP->getTextEmphasisMark() ); 180cdf0e10cSrcweir // fall through 181cdf0e10cSrcweir case primitive2d::TEXT_EMPHASISMARK_NONE: eFontEmphasisMark = EMPHASISMARK_NONE; break; 182cdf0e10cSrcweir case primitive2d::TEXT_EMPHASISMARK_DOT: eFontEmphasisMark = EMPHASISMARK_DOT; break; 183cdf0e10cSrcweir case primitive2d::TEXT_EMPHASISMARK_CIRCLE: eFontEmphasisMark = EMPHASISMARK_CIRCLE; break; 184cdf0e10cSrcweir case primitive2d::TEXT_EMPHASISMARK_DISC: eFontEmphasisMark = EMPHASISMARK_DISC; break; 185cdf0e10cSrcweir case primitive2d::TEXT_EMPHASISMARK_ACCENT: eFontEmphasisMark = EMPHASISMARK_ACCENT; break; 186cdf0e10cSrcweir } 187cdf0e10cSrcweir 188cdf0e10cSrcweir if( eFontEmphasisMark != EMPHASISMARK_NONE ) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir DBG_ASSERT( (pTCPP->getEmphasisMarkAbove() != pTCPP->getEmphasisMarkBelow()), 191cdf0e10cSrcweir "DrawingLayer: Bad EmphasisMark position!" ); 192cdf0e10cSrcweir if( pTCPP->getEmphasisMarkAbove() ) 193cdf0e10cSrcweir eFontEmphasisMark |= EMPHASISMARK_POS_ABOVE; 194cdf0e10cSrcweir else 195cdf0e10cSrcweir eFontEmphasisMark |= EMPHASISMARK_POS_BELOW; 196cdf0e10cSrcweir aFont.SetEmphasisMark( eFontEmphasisMark ); 197cdf0e10cSrcweir } 198cdf0e10cSrcweir 199cdf0e10cSrcweir // set Relief attribute 200cdf0e10cSrcweir FontRelief eFontRelief = RELIEF_NONE; 201cdf0e10cSrcweir switch( pTCPP->getTextRelief() ) 202cdf0e10cSrcweir { 203cdf0e10cSrcweir default: 204cdf0e10cSrcweir DBG_WARNING1( "DrawingLayer: Unknown Relief style (%d)!", pTCPP->getTextRelief() ); 205cdf0e10cSrcweir // fall through 206cdf0e10cSrcweir case primitive2d::TEXT_RELIEF_NONE: eFontRelief = RELIEF_NONE; break; 207cdf0e10cSrcweir case primitive2d::TEXT_RELIEF_EMBOSSED: eFontRelief = RELIEF_EMBOSSED; break; 208cdf0e10cSrcweir case primitive2d::TEXT_RELIEF_ENGRAVED: eFontRelief = RELIEF_ENGRAVED; break; 209cdf0e10cSrcweir } 210cdf0e10cSrcweir 211cdf0e10cSrcweir if( eFontRelief != RELIEF_NONE ) 212cdf0e10cSrcweir aFont.SetRelief( eFontRelief ); 213cdf0e10cSrcweir 214cdf0e10cSrcweir // set Shadow attribute 215cdf0e10cSrcweir if( pTCPP->getShadow() ) 216cdf0e10cSrcweir aFont.SetShadow( true ); 217cdf0e10cSrcweir } 218cdf0e10cSrcweir 219cdf0e10cSrcweir // create transformed integer DXArray in view coordinate system 220cdf0e10cSrcweir ::std::vector< sal_Int32 > aTransformedDXArray; 221cdf0e10cSrcweir 222cdf0e10cSrcweir if(rTextCandidate.getDXArray().size()) 223cdf0e10cSrcweir { 224cdf0e10cSrcweir aTransformedDXArray.reserve(rTextCandidate.getDXArray().size()); 225cdf0e10cSrcweir const basegfx::B2DVector aPixelVector(maCurrentTransformation * basegfx::B2DVector(1.0, 0.0)); 226cdf0e10cSrcweir const double fPixelVectorFactor(aPixelVector.getLength()); 227cdf0e10cSrcweir 228cdf0e10cSrcweir for(::std::vector< double >::const_iterator aStart(rTextCandidate.getDXArray().begin()); 229cdf0e10cSrcweir aStart != rTextCandidate.getDXArray().end(); aStart++) 230cdf0e10cSrcweir { 231cdf0e10cSrcweir aTransformedDXArray.push_back(basegfx::fround((*aStart) * fPixelVectorFactor)); 232cdf0e10cSrcweir } 233cdf0e10cSrcweir } 234cdf0e10cSrcweir 235cdf0e10cSrcweir // set parameters and paint text snippet 236cdf0e10cSrcweir const basegfx::BColor aRGBFontColor(maBColorModifierStack.getModifiedColor(rTextCandidate.getFontColor())); 237cdf0e10cSrcweir const basegfx::B2DPoint aPoint(aLocalTransform * basegfx::B2DPoint(0.0, 0.0)); 238cdf0e10cSrcweir const Point aStartPoint(basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY())); 239cdf0e10cSrcweir const sal_uInt32 nOldLayoutMode(mpOutputDevice->GetLayoutMode()); 240cdf0e10cSrcweir 241cdf0e10cSrcweir if(rTextCandidate.getFontAttribute().getRTL()) 242cdf0e10cSrcweir { 243cdf0e10cSrcweir sal_uInt32 nRTLLayoutMode(nOldLayoutMode & ~(TEXT_LAYOUT_COMPLEX_DISABLED|TEXT_LAYOUT_BIDI_STRONG)); 244cdf0e10cSrcweir nRTLLayoutMode |= TEXT_LAYOUT_BIDI_RTL|TEXT_LAYOUT_TEXTORIGIN_LEFT; 245cdf0e10cSrcweir mpOutputDevice->SetLayoutMode(nRTLLayoutMode); 246cdf0e10cSrcweir } 247cdf0e10cSrcweir 248cdf0e10cSrcweir mpOutputDevice->SetFont(aFont); 249cdf0e10cSrcweir mpOutputDevice->SetTextColor(Color(aRGBFontColor)); 250cdf0e10cSrcweir 251cdf0e10cSrcweir if(aTransformedDXArray.size()) 252cdf0e10cSrcweir { 253cdf0e10cSrcweir mpOutputDevice->DrawTextArray( 254cdf0e10cSrcweir aStartPoint, 255cdf0e10cSrcweir rTextCandidate.getText(), 256cdf0e10cSrcweir &(aTransformedDXArray[0]), 257cdf0e10cSrcweir rTextCandidate.getTextPosition(), 258cdf0e10cSrcweir rTextCandidate.getTextLength()); 259cdf0e10cSrcweir } 260cdf0e10cSrcweir else 261cdf0e10cSrcweir { 262cdf0e10cSrcweir mpOutputDevice->DrawText( 263cdf0e10cSrcweir aStartPoint, 264cdf0e10cSrcweir rTextCandidate.getText(), 265cdf0e10cSrcweir rTextCandidate.getTextPosition(), 266cdf0e10cSrcweir rTextCandidate.getTextLength()); 267cdf0e10cSrcweir } 268cdf0e10cSrcweir 269cdf0e10cSrcweir if(rTextCandidate.getFontAttribute().getRTL()) 270cdf0e10cSrcweir { 271cdf0e10cSrcweir mpOutputDevice->SetLayoutMode(nOldLayoutMode); 272cdf0e10cSrcweir } 273cdf0e10cSrcweir 274cdf0e10cSrcweir bPrimitiveAccepted = true; 275cdf0e10cSrcweir } 276cdf0e10cSrcweir } 277cdf0e10cSrcweir 278cdf0e10cSrcweir if(!bPrimitiveAccepted) 279cdf0e10cSrcweir { 280cdf0e10cSrcweir // let break down 281cdf0e10cSrcweir process(rTextCandidate.get2DDecomposition(getViewInformation2D())); 282cdf0e10cSrcweir } 283cdf0e10cSrcweir } 284cdf0e10cSrcweir 285cdf0e10cSrcweir // direct draw of hairline 286cdf0e10cSrcweir void VclProcessor2D::RenderPolygonHairlinePrimitive2D(const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate, bool bPixelBased) 287cdf0e10cSrcweir { 288cdf0e10cSrcweir const basegfx::BColor aHairlineColor(maBColorModifierStack.getModifiedColor(rPolygonCandidate.getBColor())); 289cdf0e10cSrcweir mpOutputDevice->SetLineColor(Color(aHairlineColor)); 290cdf0e10cSrcweir mpOutputDevice->SetFillColor(); 291cdf0e10cSrcweir 292cdf0e10cSrcweir basegfx::B2DPolygon aLocalPolygon(rPolygonCandidate.getB2DPolygon()); 293cdf0e10cSrcweir aLocalPolygon.transform(maCurrentTransformation); 294cdf0e10cSrcweir 295cdf0e10cSrcweir static bool bCheckTrapezoidDecomposition(false); 296cdf0e10cSrcweir static bool bShowOutlinesThere(false); 297cdf0e10cSrcweir if(bCheckTrapezoidDecomposition) 298cdf0e10cSrcweir { 299cdf0e10cSrcweir // clip against discrete ViewPort 300cdf0e10cSrcweir const basegfx::B2DRange& rDiscreteViewport = getViewInformation2D().getDiscreteViewport(); 301cdf0e10cSrcweir basegfx::B2DPolyPolygon aLocalPolyPolygon(basegfx::tools::clipPolygonOnRange( 302cdf0e10cSrcweir aLocalPolygon, rDiscreteViewport, true, false)); 303cdf0e10cSrcweir 304cdf0e10cSrcweir if(aLocalPolyPolygon.count()) 305cdf0e10cSrcweir { 306cdf0e10cSrcweir // subdivide 307cdf0e10cSrcweir aLocalPolyPolygon = basegfx::tools::adaptiveSubdivideByDistance( 308cdf0e10cSrcweir aLocalPolyPolygon, 0.5); 309cdf0e10cSrcweir 310cdf0e10cSrcweir // trapezoidize 311cdf0e10cSrcweir static double fLineWidth(2.0); 312cdf0e10cSrcweir basegfx::B2DTrapezoidVector aB2DTrapezoidVector; 313cdf0e10cSrcweir basegfx::tools::createLineTrapezoidFromB2DPolyPolygon(aB2DTrapezoidVector, aLocalPolyPolygon, fLineWidth); 314cdf0e10cSrcweir 315cdf0e10cSrcweir const sal_uInt32 nCount(aB2DTrapezoidVector.size()); 316cdf0e10cSrcweir 317cdf0e10cSrcweir if(nCount) 318cdf0e10cSrcweir { 319cdf0e10cSrcweir basegfx::BColor aInvPolygonColor(aHairlineColor); 320cdf0e10cSrcweir aInvPolygonColor.invert(); 321cdf0e10cSrcweir 322cdf0e10cSrcweir for(sal_uInt32 a(0); a < nCount; a++) 323cdf0e10cSrcweir { 324cdf0e10cSrcweir const basegfx::B2DPolygon aTempPolygon(aB2DTrapezoidVector[a].getB2DPolygon()); 325cdf0e10cSrcweir 326cdf0e10cSrcweir if(bShowOutlinesThere) 327cdf0e10cSrcweir { 328cdf0e10cSrcweir mpOutputDevice->SetFillColor(Color(aHairlineColor)); 329cdf0e10cSrcweir mpOutputDevice->SetLineColor(); 330cdf0e10cSrcweir } 331cdf0e10cSrcweir 332cdf0e10cSrcweir mpOutputDevice->DrawPolygon(aTempPolygon); 333cdf0e10cSrcweir 334cdf0e10cSrcweir if(bShowOutlinesThere) 335cdf0e10cSrcweir { 336cdf0e10cSrcweir mpOutputDevice->SetFillColor(); 337cdf0e10cSrcweir mpOutputDevice->SetLineColor(Color(aInvPolygonColor)); 338cdf0e10cSrcweir mpOutputDevice->DrawPolyLine(aTempPolygon, 0.0); 339cdf0e10cSrcweir } 340cdf0e10cSrcweir } 341cdf0e10cSrcweir } 342cdf0e10cSrcweir } 343cdf0e10cSrcweir } 344cdf0e10cSrcweir else 345cdf0e10cSrcweir { 346cdf0e10cSrcweir if(bPixelBased && getOptionsDrawinglayer().IsAntiAliasing() && getOptionsDrawinglayer().IsSnapHorVerLinesToDiscrete()) 347cdf0e10cSrcweir { 348cdf0e10cSrcweir // #i98289# 349cdf0e10cSrcweir // when a Hairline is painted and AntiAliasing is on the option SnapHorVerLinesToDiscrete 350cdf0e10cSrcweir // allows to suppress AntiAliasing for pure horizontal or vertical lines. This is done since 351cdf0e10cSrcweir // not-AntiAliased such lines look more pleasing to the eye (e.g. 2D chart content). This 352cdf0e10cSrcweir // NEEDS to be done in discrete coordinates, so only useful for pixel based rendering. 353cdf0e10cSrcweir aLocalPolygon = basegfx::tools::snapPointsOfHorizontalOrVerticalEdges(aLocalPolygon); 354cdf0e10cSrcweir } 355cdf0e10cSrcweir 356cdf0e10cSrcweir mpOutputDevice->DrawPolyLine(aLocalPolygon, 0.0); 357cdf0e10cSrcweir } 358cdf0e10cSrcweir } 359cdf0e10cSrcweir 360cdf0e10cSrcweir // direct draw of transformed BitmapEx primitive 361cdf0e10cSrcweir void VclProcessor2D::RenderBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir // create local transform 364cdf0e10cSrcweir basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rBitmapCandidate.getTransform()); 365cdf0e10cSrcweir BitmapEx aBitmapEx(rBitmapCandidate.getBitmapEx()); 366cdf0e10cSrcweir bool bPainted(false); 367cdf0e10cSrcweir 368cdf0e10cSrcweir if(maBColorModifierStack.count()) 369cdf0e10cSrcweir { 370cdf0e10cSrcweir aBitmapEx = impModifyBitmapEx(maBColorModifierStack, aBitmapEx); 371cdf0e10cSrcweir 372cdf0e10cSrcweir if(aBitmapEx.IsEmpty()) 373cdf0e10cSrcweir { 374cdf0e10cSrcweir // color gets completely replaced, get it 375cdf0e10cSrcweir const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(basegfx::BColor())); 376cdf0e10cSrcweir basegfx::B2DPolygon aPolygon(basegfx::tools::createUnitPolygon()); 377cdf0e10cSrcweir aPolygon.transform(aLocalTransform); 378cdf0e10cSrcweir 379cdf0e10cSrcweir mpOutputDevice->SetFillColor(Color(aModifiedColor)); 380cdf0e10cSrcweir mpOutputDevice->SetLineColor(); 381cdf0e10cSrcweir mpOutputDevice->DrawPolygon(aPolygon); 382cdf0e10cSrcweir 383cdf0e10cSrcweir bPainted = true; 384cdf0e10cSrcweir } 385cdf0e10cSrcweir } 386cdf0e10cSrcweir 387cdf0e10cSrcweir if(!bPainted) 388cdf0e10cSrcweir { 389cdf0e10cSrcweir static bool bForceUseOfOwnTransformer(false); 390cdf0e10cSrcweir static bool bUseGraphicManager(true); 391cdf0e10cSrcweir 392cdf0e10cSrcweir // decompose matrix to check for shear, rotate and mirroring 393cdf0e10cSrcweir basegfx::B2DVector aScale, aTranslate; 394cdf0e10cSrcweir double fRotate, fShearX; 395cdf0e10cSrcweir aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX); 396cdf0e10cSrcweir 397cdf0e10cSrcweir if(!bForceUseOfOwnTransformer && basegfx::fTools::equalZero(fShearX)) 398cdf0e10cSrcweir { 399cdf0e10cSrcweir if(!bUseGraphicManager && basegfx::fTools::equalZero(fRotate)) 400cdf0e10cSrcweir { 401cdf0e10cSrcweir RenderBitmapPrimitive2D_BitmapEx(*mpOutputDevice, aBitmapEx, aLocalTransform); 402cdf0e10cSrcweir } 403cdf0e10cSrcweir else 404cdf0e10cSrcweir { 405cdf0e10cSrcweir RenderBitmapPrimitive2D_GraphicManager(*mpOutputDevice, aBitmapEx, aLocalTransform); 406cdf0e10cSrcweir } 407cdf0e10cSrcweir } 408cdf0e10cSrcweir else 409cdf0e10cSrcweir { 410cdf0e10cSrcweir if(!aBitmapEx.IsTransparent() && (!basegfx::fTools::equalZero(fShearX) || !basegfx::fTools::equalZero(fRotate))) 411cdf0e10cSrcweir { 412cdf0e10cSrcweir // parts will be uncovered, extend aBitmapEx with a mask bitmap 413cdf0e10cSrcweir const Bitmap aContent(aBitmapEx.GetBitmap()); 414cdf0e10cSrcweir aBitmapEx = BitmapEx(aContent, Bitmap(aContent.GetSizePixel(), 1)); 415cdf0e10cSrcweir } 416cdf0e10cSrcweir 417cdf0e10cSrcweir RenderBitmapPrimitive2D_self(*mpOutputDevice, aBitmapEx, aLocalTransform); 418cdf0e10cSrcweir } 419cdf0e10cSrcweir } 420cdf0e10cSrcweir } 421cdf0e10cSrcweir 422cdf0e10cSrcweir void VclProcessor2D::RenderRenderGraphicPrimitive2D(const primitive2d::RenderGraphicPrimitive2D& rRenderGraphicCandidate) 423cdf0e10cSrcweir { 424cdf0e10cSrcweir // create local transform 425cdf0e10cSrcweir basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rRenderGraphicCandidate.getTransform()); 426cdf0e10cSrcweir vcl::RenderGraphic aRenderGraphic(rRenderGraphicCandidate.getRenderGraphic()); 427cdf0e10cSrcweir bool bPainted(false); 428cdf0e10cSrcweir 429cdf0e10cSrcweir if(maBColorModifierStack.count()) 430cdf0e10cSrcweir { 431cdf0e10cSrcweir // !!! TODO 432cdf0e10cSrcweir // aRenderGraphic = impModifyRenderGraphic(maBColorModifierStack, aRenderGraphic); 433cdf0e10cSrcweir 434cdf0e10cSrcweir if(aRenderGraphic.IsEmpty()) 435cdf0e10cSrcweir { 436cdf0e10cSrcweir // color gets completely replaced, get it 437cdf0e10cSrcweir const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(basegfx::BColor())); 438cdf0e10cSrcweir basegfx::B2DPolygon aPolygon(basegfx::tools::createUnitPolygon()); 439cdf0e10cSrcweir aPolygon.transform(aLocalTransform); 440cdf0e10cSrcweir 441cdf0e10cSrcweir mpOutputDevice->SetFillColor(Color(aModifiedColor)); 442cdf0e10cSrcweir mpOutputDevice->SetLineColor(); 443cdf0e10cSrcweir mpOutputDevice->DrawPolygon(aPolygon); 444cdf0e10cSrcweir 445cdf0e10cSrcweir bPainted = true; 446cdf0e10cSrcweir } 447cdf0e10cSrcweir } 448cdf0e10cSrcweir 449cdf0e10cSrcweir if(!bPainted) 450cdf0e10cSrcweir { 451cdf0e10cSrcweir // decompose matrix to check for shear, rotate and mirroring 452cdf0e10cSrcweir basegfx::B2DVector aScale, aTranslate; 453cdf0e10cSrcweir double fRotate, fShearX; 454cdf0e10cSrcweir aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX); 455cdf0e10cSrcweir 456cdf0e10cSrcweir basegfx::B2DRange aOutlineRange(0.0, 0.0, 1.0, 1.0); 457cdf0e10cSrcweir 458cdf0e10cSrcweir if( basegfx::fTools::equalZero( fRotate ) ) 459cdf0e10cSrcweir { 460cdf0e10cSrcweir aOutlineRange.transform( aLocalTransform ); 461cdf0e10cSrcweir } 462cdf0e10cSrcweir else 463cdf0e10cSrcweir { 464cdf0e10cSrcweir // !!! TODO 465cdf0e10cSrcweir // if rotated, create the unrotated output rectangle for the GraphicManager paint 466cdf0e10cSrcweir /* 467cdf0e10cSrcweir const basegfx::B2DHomMatrix aSimpleObjectMatrix(basegfx::tools::createScaleTranslateB2DHomMatrix( 468cdf0e10cSrcweir fabs(aScale.getX()), fabs(aScale.getY()), 469cdf0e10cSrcweir aTranslate.getX(), aTranslate.getY())); 470cdf0e10cSrcweir 471cdf0e10cSrcweir aOutlineRange.transform(aSimpleObjectMatrix); 472cdf0e10cSrcweir */ 473cdf0e10cSrcweir } 474cdf0e10cSrcweir 475cdf0e10cSrcweir // prepare dest coordinates 476cdf0e10cSrcweir const Point aPoint( basegfx::fround(aOutlineRange.getMinX() ), 477cdf0e10cSrcweir basegfx::fround(aOutlineRange.getMinY() ) ); 478cdf0e10cSrcweir const Size aSize( basegfx::fround(aOutlineRange.getWidth() ), 479cdf0e10cSrcweir basegfx::fround(aOutlineRange.getHeight() ) ); 480cdf0e10cSrcweir const Size aSizePixel( mpOutputDevice->LogicToPixel( aSize ) ); 481cdf0e10cSrcweir const vcl::RenderGraphicRasterizer aRasterizer( aRenderGraphic ); 482cdf0e10cSrcweir const BitmapEx aBitmapEx( aRasterizer.Rasterize( aSizePixel, fRotate, fShearX ) ); 483cdf0e10cSrcweir 484cdf0e10cSrcweir if( !aBitmapEx.IsEmpty() ) 485cdf0e10cSrcweir { 486cdf0e10cSrcweir mpOutputDevice->DrawBitmapEx( aPoint, aSize, aBitmapEx ); 487cdf0e10cSrcweir } 488cdf0e10cSrcweir } 489cdf0e10cSrcweir } 490cdf0e10cSrcweir 491cdf0e10cSrcweir void VclProcessor2D::RenderFillBitmapPrimitive2D(const primitive2d::FillBitmapPrimitive2D& rFillBitmapCandidate) 492cdf0e10cSrcweir { 493cdf0e10cSrcweir const attribute::FillBitmapAttribute& rFillBitmapAttribute(rFillBitmapCandidate.getFillBitmap()); 494cdf0e10cSrcweir bool bPrimitiveAccepted(false); 495cdf0e10cSrcweir 496cdf0e10cSrcweir if(rFillBitmapAttribute.getTiling()) 497cdf0e10cSrcweir { 498cdf0e10cSrcweir // decompose matrix to check for shear, rotate and mirroring 499cdf0e10cSrcweir basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rFillBitmapCandidate.getTransformation()); 500cdf0e10cSrcweir basegfx::B2DVector aScale, aTranslate; 501cdf0e10cSrcweir double fRotate, fShearX; 502cdf0e10cSrcweir aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX); 503cdf0e10cSrcweir 504cdf0e10cSrcweir if(basegfx::fTools::equalZero(fRotate) && basegfx::fTools::equalZero(fShearX)) 505cdf0e10cSrcweir { 506cdf0e10cSrcweir // no shear or rotate, draw direct in pixel coordinates 507cdf0e10cSrcweir bPrimitiveAccepted = true; 508cdf0e10cSrcweir BitmapEx aBitmapEx(rFillBitmapAttribute.getBitmapEx()); 509cdf0e10cSrcweir bool bPainted(false); 510cdf0e10cSrcweir 511cdf0e10cSrcweir if(maBColorModifierStack.count()) 512cdf0e10cSrcweir { 513cdf0e10cSrcweir aBitmapEx = impModifyBitmapEx(maBColorModifierStack, aBitmapEx); 514cdf0e10cSrcweir 515cdf0e10cSrcweir if(aBitmapEx.IsEmpty()) 516cdf0e10cSrcweir { 517cdf0e10cSrcweir // color gets completely replaced, get it 518cdf0e10cSrcweir const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(basegfx::BColor())); 519cdf0e10cSrcweir basegfx::B2DPolygon aPolygon(basegfx::tools::createUnitPolygon()); 520cdf0e10cSrcweir aPolygon.transform(aLocalTransform); 521cdf0e10cSrcweir 522cdf0e10cSrcweir mpOutputDevice->SetFillColor(Color(aModifiedColor)); 523cdf0e10cSrcweir mpOutputDevice->SetLineColor(); 524cdf0e10cSrcweir mpOutputDevice->DrawPolygon(aPolygon); 525cdf0e10cSrcweir 526cdf0e10cSrcweir bPainted = true; 527cdf0e10cSrcweir } 528cdf0e10cSrcweir } 529cdf0e10cSrcweir 530cdf0e10cSrcweir if(!bPainted) 531cdf0e10cSrcweir { 532cdf0e10cSrcweir const basegfx::B2DPoint aObjTopLeft(aTranslate.getX(), aTranslate.getY()); 533cdf0e10cSrcweir const basegfx::B2DPoint aObjBottomRight(aTranslate.getX() + aScale.getX(), aTranslate.getY() + aScale.getY()); 534cdf0e10cSrcweir const Point aObjTL(mpOutputDevice->LogicToPixel(Point((sal_Int32)aObjTopLeft.getX(), (sal_Int32)aObjTopLeft.getY()))); 535cdf0e10cSrcweir const Point aObjBR(mpOutputDevice->LogicToPixel(Point((sal_Int32)aObjBottomRight.getX(), (sal_Int32)aObjBottomRight.getY()))); 536cdf0e10cSrcweir 537cdf0e10cSrcweir const basegfx::B2DPoint aBmpTopLeft(aLocalTransform * rFillBitmapAttribute.getTopLeft()); 538cdf0e10cSrcweir const basegfx::B2DPoint aBmpBottomRight(aLocalTransform * basegfx::B2DPoint(rFillBitmapAttribute.getTopLeft() + rFillBitmapAttribute.getSize())); 539cdf0e10cSrcweir const Point aBmpTL(mpOutputDevice->LogicToPixel(Point((sal_Int32)aBmpTopLeft.getX(), (sal_Int32)aBmpTopLeft.getY()))); 540cdf0e10cSrcweir const Point aBmpBR(mpOutputDevice->LogicToPixel(Point((sal_Int32)aBmpBottomRight.getX(), (sal_Int32)aBmpBottomRight.getY()))); 541cdf0e10cSrcweir 542cdf0e10cSrcweir sal_Int32 nOWidth(aObjBR.X() - aObjTL.X()); 543cdf0e10cSrcweir sal_Int32 nOHeight(aObjBR.Y() - aObjTL.Y()); 544cdf0e10cSrcweir 545cdf0e10cSrcweir // only do something when object has a size in discrete units 546cdf0e10cSrcweir if(nOWidth > 0 && nOHeight > 0) 547cdf0e10cSrcweir { 548cdf0e10cSrcweir sal_Int32 nBWidth(aBmpBR.X() - aBmpTL.X()); 549cdf0e10cSrcweir sal_Int32 nBHeight(aBmpBR.Y() - aBmpTL.Y()); 550cdf0e10cSrcweir 551cdf0e10cSrcweir // only do something when bitmap fill has a size in discrete units 552cdf0e10cSrcweir if(nBWidth > 0 && nBHeight > 0) 553cdf0e10cSrcweir { 554cdf0e10cSrcweir sal_Int32 nBLeft(aBmpTL.X()); 555cdf0e10cSrcweir sal_Int32 nBTop(aBmpTL.Y()); 556cdf0e10cSrcweir 557cdf0e10cSrcweir if(nBLeft > aObjTL.X()) 558cdf0e10cSrcweir { 559cdf0e10cSrcweir nBLeft -= ((nBLeft / nBWidth) + 1L) * nBWidth; 560cdf0e10cSrcweir } 561cdf0e10cSrcweir 562cdf0e10cSrcweir if(nBLeft + nBWidth <= aObjTL.X()) 563cdf0e10cSrcweir { 564cdf0e10cSrcweir nBLeft -= (nBLeft / nBWidth) * nBWidth; 565cdf0e10cSrcweir } 566cdf0e10cSrcweir 567cdf0e10cSrcweir if(nBTop > aObjTL.Y()) 568cdf0e10cSrcweir { 569cdf0e10cSrcweir nBTop -= ((nBTop / nBHeight) + 1L) * nBHeight; 570cdf0e10cSrcweir } 571cdf0e10cSrcweir 572cdf0e10cSrcweir if(nBTop + nBHeight <= aObjTL.Y()) 573cdf0e10cSrcweir { 574cdf0e10cSrcweir nBTop -= (nBTop / nBHeight) * nBHeight; 575cdf0e10cSrcweir } 576cdf0e10cSrcweir 577cdf0e10cSrcweir // nBWidth, nBHeight is the pixel size of the neede bitmap. To not need to scale it 578cdf0e10cSrcweir // in vcl many times, create a size-optimized version 579cdf0e10cSrcweir const Size aNeededBitmapSizePixel(nBWidth, nBHeight); 580cdf0e10cSrcweir 581cdf0e10cSrcweir if(aNeededBitmapSizePixel != aBitmapEx.GetSizePixel()) 582cdf0e10cSrcweir { 583cdf0e10cSrcweir aBitmapEx.Scale(aNeededBitmapSizePixel); 584cdf0e10cSrcweir } 585cdf0e10cSrcweir 586cdf0e10cSrcweir // prepare OutDev 587cdf0e10cSrcweir const Point aEmptyPoint(0, 0); 588cdf0e10cSrcweir const Rectangle aVisiblePixel(aEmptyPoint, mpOutputDevice->GetOutputSizePixel()); 589cdf0e10cSrcweir const bool bWasEnabled(mpOutputDevice->IsMapModeEnabled()); 590cdf0e10cSrcweir mpOutputDevice->EnableMapMode(false); 591cdf0e10cSrcweir 592cdf0e10cSrcweir for(sal_Int32 nXPos(nBLeft); nXPos < aObjTL.X() + nOWidth; nXPos += nBWidth) 593cdf0e10cSrcweir { 594cdf0e10cSrcweir for(sal_Int32 nYPos(nBTop); nYPos < aObjTL.Y() + nOHeight; nYPos += nBHeight) 595cdf0e10cSrcweir { 596cdf0e10cSrcweir const Rectangle aOutRectPixel(Point(nXPos, nYPos), aNeededBitmapSizePixel); 597cdf0e10cSrcweir 598cdf0e10cSrcweir if(aOutRectPixel.IsOver(aVisiblePixel)) 599cdf0e10cSrcweir { 600cdf0e10cSrcweir mpOutputDevice->DrawBitmapEx(aOutRectPixel.TopLeft(), aBitmapEx); 601cdf0e10cSrcweir } 602cdf0e10cSrcweir } 603cdf0e10cSrcweir } 604cdf0e10cSrcweir 605cdf0e10cSrcweir // restore OutDev 606cdf0e10cSrcweir mpOutputDevice->EnableMapMode(bWasEnabled); 607cdf0e10cSrcweir } 608cdf0e10cSrcweir } 609cdf0e10cSrcweir } 610cdf0e10cSrcweir } 611cdf0e10cSrcweir } 612cdf0e10cSrcweir 613cdf0e10cSrcweir if(!bPrimitiveAccepted) 614cdf0e10cSrcweir { 615cdf0e10cSrcweir // do not accept, use decomposition 616cdf0e10cSrcweir process(rFillBitmapCandidate.get2DDecomposition(getViewInformation2D())); 617cdf0e10cSrcweir } 618cdf0e10cSrcweir } 619cdf0e10cSrcweir 620cdf0e10cSrcweir // direct draw of gradient 621cdf0e10cSrcweir void VclProcessor2D::RenderPolyPolygonGradientPrimitive2D(const primitive2d::PolyPolygonGradientPrimitive2D& rPolygonCandidate) 622cdf0e10cSrcweir { 623cdf0e10cSrcweir const attribute::FillGradientAttribute& rGradient(rPolygonCandidate.getFillGradient()); 624cdf0e10cSrcweir basegfx::BColor aStartColor(maBColorModifierStack.getModifiedColor(rGradient.getStartColor())); 625cdf0e10cSrcweir basegfx::BColor aEndColor(maBColorModifierStack.getModifiedColor(rGradient.getEndColor())); 626cdf0e10cSrcweir basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon()); 627cdf0e10cSrcweir 628cdf0e10cSrcweir if(aLocalPolyPolygon.count()) 629cdf0e10cSrcweir { 630cdf0e10cSrcweir aLocalPolyPolygon.transform(maCurrentTransformation); 631cdf0e10cSrcweir 632cdf0e10cSrcweir if(aStartColor == aEndColor) 633cdf0e10cSrcweir { 634cdf0e10cSrcweir // no gradient at all, draw as polygon in AA and non-AA case 635cdf0e10cSrcweir mpOutputDevice->SetLineColor(); 636cdf0e10cSrcweir mpOutputDevice->SetFillColor(Color(aStartColor)); 637cdf0e10cSrcweir mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon); 638cdf0e10cSrcweir } 639cdf0e10cSrcweir else if(getOptionsDrawinglayer().IsAntiAliasing()) 640cdf0e10cSrcweir { 641cdf0e10cSrcweir // For AA, direct render has to be avoided since it uses XOR maskings which will not 642cdf0e10cSrcweir // work with AA. Instead, the decompose which uses MaskPrimitive2D with fillings is 643cdf0e10cSrcweir // used 644cdf0e10cSrcweir process(rPolygonCandidate.get2DDecomposition(getViewInformation2D())); 645cdf0e10cSrcweir } 646cdf0e10cSrcweir else 647cdf0e10cSrcweir { 648cdf0e10cSrcweir impDrawGradientToOutDev( 649cdf0e10cSrcweir *mpOutputDevice, aLocalPolyPolygon, rGradient.getStyle(), rGradient.getSteps(), 650cdf0e10cSrcweir aStartColor, aEndColor, rGradient.getBorder(), 651cdf0e10cSrcweir rGradient.getAngle(), rGradient.getOffsetX(), rGradient.getOffsetY(), false); 652cdf0e10cSrcweir } 653cdf0e10cSrcweir } 654cdf0e10cSrcweir } 655cdf0e10cSrcweir 656cdf0e10cSrcweir // direct draw of bitmap 657cdf0e10cSrcweir void VclProcessor2D::RenderPolyPolygonBitmapPrimitive2D(const primitive2d::PolyPolygonBitmapPrimitive2D& rPolygonCandidate) 658cdf0e10cSrcweir { 659cdf0e10cSrcweir bool bDone(false); 660cdf0e10cSrcweir const basegfx::B2DPolyPolygon& rPolyPolygon = rPolygonCandidate.getB2DPolyPolygon(); 661cdf0e10cSrcweir 662cdf0e10cSrcweir if(rPolyPolygon.count()) 663cdf0e10cSrcweir { 664cdf0e10cSrcweir const attribute::FillBitmapAttribute& rFillBitmapAttribute = rPolygonCandidate.getFillBitmap(); 665cdf0e10cSrcweir const BitmapEx& rBitmapEx = rFillBitmapAttribute.getBitmapEx(); 666cdf0e10cSrcweir 667cdf0e10cSrcweir if(rBitmapEx.IsEmpty()) 668cdf0e10cSrcweir { 669cdf0e10cSrcweir // empty bitmap, done 670cdf0e10cSrcweir bDone = true; 671cdf0e10cSrcweir } 672cdf0e10cSrcweir else 673cdf0e10cSrcweir { 674cdf0e10cSrcweir // try to catch cases where the bitmap will be color-modified to a single 675cdf0e10cSrcweir // color (e.g. shadow). This would NOT be optimizable with an transparence channel 676cdf0e10cSrcweir // at the Bitmap which we do not have here. When this should change, this 677cdf0e10cSrcweir // optimization has to be reworked accordingly. 678cdf0e10cSrcweir const sal_uInt32 nBColorModifierStackCount(maBColorModifierStack.count()); 679cdf0e10cSrcweir 680cdf0e10cSrcweir if(nBColorModifierStackCount) 681cdf0e10cSrcweir { 682cdf0e10cSrcweir const basegfx::BColorModifier& rTopmostModifier = maBColorModifierStack.getBColorModifier(nBColorModifierStackCount - 1); 683cdf0e10cSrcweir 684cdf0e10cSrcweir if(basegfx::BCOLORMODIFYMODE_REPLACE == rTopmostModifier.getMode()) 685cdf0e10cSrcweir { 686cdf0e10cSrcweir // the bitmap fill is in unified color, so we can replace it with 687cdf0e10cSrcweir // a single polygon fill. The form of the fill depends on tiling 688cdf0e10cSrcweir if(rFillBitmapAttribute.getTiling()) 689cdf0e10cSrcweir { 690cdf0e10cSrcweir // with tiling, fill the whole PolyPolygon with the modifier color 691cdf0e10cSrcweir basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolyPolygon); 692cdf0e10cSrcweir 693cdf0e10cSrcweir aLocalPolyPolygon.transform(maCurrentTransformation); 694cdf0e10cSrcweir mpOutputDevice->SetLineColor(); 695cdf0e10cSrcweir mpOutputDevice->SetFillColor(Color(rTopmostModifier.getBColor())); 696cdf0e10cSrcweir mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon); 697cdf0e10cSrcweir } 698cdf0e10cSrcweir else 699cdf0e10cSrcweir { 700cdf0e10cSrcweir // without tiling, only the area common to the bitmap tile and the 701cdf0e10cSrcweir // PolyPolygon is filled. Create the bitmap tile area in object 702cdf0e10cSrcweir // coordinates. For this, the object transformation needs to be created 703cdf0e10cSrcweir // from the already scaled PolyPolygon. The tile area in object 704cdf0e10cSrcweir // coordinates wil always be non-rotated, so it's not necessary to 705cdf0e10cSrcweir // work with a polygon here 706cdf0e10cSrcweir basegfx::B2DRange aTileRange(rFillBitmapAttribute.getTopLeft(), 707cdf0e10cSrcweir rFillBitmapAttribute.getTopLeft() + rFillBitmapAttribute.getSize()); 708cdf0e10cSrcweir const basegfx::B2DRange aPolyPolygonRange(rPolyPolygon.getB2DRange()); 709cdf0e10cSrcweir basegfx::B2DHomMatrix aNewObjectTransform; 710cdf0e10cSrcweir 711cdf0e10cSrcweir aNewObjectTransform.set(0, 0, aPolyPolygonRange.getWidth()); 712cdf0e10cSrcweir aNewObjectTransform.set(1, 1, aPolyPolygonRange.getHeight()); 713cdf0e10cSrcweir aNewObjectTransform.set(0, 2, aPolyPolygonRange.getMinX()); 714cdf0e10cSrcweir aNewObjectTransform.set(1, 2, aPolyPolygonRange.getMinY()); 715cdf0e10cSrcweir aTileRange.transform(aNewObjectTransform); 716cdf0e10cSrcweir 717cdf0e10cSrcweir // now clip the object polyPolygon against the tile range 718cdf0e10cSrcweir // to get the common area (OR) 719cdf0e10cSrcweir basegfx::B2DPolyPolygon aTarget = basegfx::tools::clipPolyPolygonOnRange(rPolyPolygon, aTileRange, true, false); 720cdf0e10cSrcweir 721cdf0e10cSrcweir if(aTarget.count()) 722cdf0e10cSrcweir { 723cdf0e10cSrcweir aTarget.transform(maCurrentTransformation); 724cdf0e10cSrcweir mpOutputDevice->SetLineColor(); 725cdf0e10cSrcweir mpOutputDevice->SetFillColor(Color(rTopmostModifier.getBColor())); 726cdf0e10cSrcweir mpOutputDevice->DrawPolyPolygon(aTarget); 727cdf0e10cSrcweir } 728cdf0e10cSrcweir } 729cdf0e10cSrcweir 730cdf0e10cSrcweir bDone = true; 731cdf0e10cSrcweir } 732cdf0e10cSrcweir } 733cdf0e10cSrcweir } 734cdf0e10cSrcweir } 735cdf0e10cSrcweir else 736cdf0e10cSrcweir { 737cdf0e10cSrcweir // empty polyPolygon, done 738cdf0e10cSrcweir bDone = true; 739cdf0e10cSrcweir } 740cdf0e10cSrcweir 741cdf0e10cSrcweir if(!bDone) 742cdf0e10cSrcweir { 743cdf0e10cSrcweir // use default decomposition 744cdf0e10cSrcweir process(rPolygonCandidate.get2DDecomposition(getViewInformation2D())); 745cdf0e10cSrcweir } 746cdf0e10cSrcweir } 747cdf0e10cSrcweir 748cdf0e10cSrcweir // direct draw of PolyPolygon with color 749cdf0e10cSrcweir void VclProcessor2D::RenderPolyPolygonColorPrimitive2D(const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate) 750cdf0e10cSrcweir { 751cdf0e10cSrcweir const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rPolygonCandidate.getBColor())); 752cdf0e10cSrcweir mpOutputDevice->SetFillColor(Color(aPolygonColor)); 753cdf0e10cSrcweir mpOutputDevice->SetLineColor(); 754cdf0e10cSrcweir 755cdf0e10cSrcweir basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon()); 756cdf0e10cSrcweir aLocalPolyPolygon.transform(maCurrentTransformation); 757cdf0e10cSrcweir 758cdf0e10cSrcweir static bool bCheckTrapezoidDecomposition(false); 759cdf0e10cSrcweir static bool bShowOutlinesThere(false); 760cdf0e10cSrcweir if(bCheckTrapezoidDecomposition) 761cdf0e10cSrcweir { 762cdf0e10cSrcweir // clip against discrete ViewPort 763cdf0e10cSrcweir const basegfx::B2DRange& rDiscreteViewport = getViewInformation2D().getDiscreteViewport(); 764cdf0e10cSrcweir aLocalPolyPolygon = basegfx::tools::clipPolyPolygonOnRange( 765cdf0e10cSrcweir aLocalPolyPolygon, rDiscreteViewport, true, false); 766cdf0e10cSrcweir 767cdf0e10cSrcweir if(aLocalPolyPolygon.count()) 768cdf0e10cSrcweir { 769cdf0e10cSrcweir // subdivide 770cdf0e10cSrcweir aLocalPolyPolygon = basegfx::tools::adaptiveSubdivideByDistance( 771cdf0e10cSrcweir aLocalPolyPolygon, 0.5); 772cdf0e10cSrcweir 773cdf0e10cSrcweir // trapezoidize 774cdf0e10cSrcweir basegfx::B2DTrapezoidVector aB2DTrapezoidVector; 775cdf0e10cSrcweir basegfx::tools::trapezoidSubdivide(aB2DTrapezoidVector, aLocalPolyPolygon); 776cdf0e10cSrcweir 777cdf0e10cSrcweir const sal_uInt32 nCount(aB2DTrapezoidVector.size()); 778cdf0e10cSrcweir 779cdf0e10cSrcweir if(nCount) 780cdf0e10cSrcweir { 781cdf0e10cSrcweir basegfx::BColor aInvPolygonColor(aPolygonColor); 782cdf0e10cSrcweir aInvPolygonColor.invert(); 783cdf0e10cSrcweir 784cdf0e10cSrcweir for(sal_uInt32 a(0); a < nCount; a++) 785cdf0e10cSrcweir { 786cdf0e10cSrcweir const basegfx::B2DPolygon aTempPolygon(aB2DTrapezoidVector[a].getB2DPolygon()); 787cdf0e10cSrcweir 788cdf0e10cSrcweir if(bShowOutlinesThere) 789cdf0e10cSrcweir { 790cdf0e10cSrcweir mpOutputDevice->SetFillColor(Color(aPolygonColor)); 791cdf0e10cSrcweir mpOutputDevice->SetLineColor(); 792cdf0e10cSrcweir } 793cdf0e10cSrcweir 794cdf0e10cSrcweir mpOutputDevice->DrawPolygon(aTempPolygon); 795cdf0e10cSrcweir 796cdf0e10cSrcweir if(bShowOutlinesThere) 797cdf0e10cSrcweir { 798cdf0e10cSrcweir mpOutputDevice->SetFillColor(); 799cdf0e10cSrcweir mpOutputDevice->SetLineColor(Color(aInvPolygonColor)); 800cdf0e10cSrcweir mpOutputDevice->DrawPolyLine(aTempPolygon, 0.0); 801cdf0e10cSrcweir } 802cdf0e10cSrcweir } 803cdf0e10cSrcweir } 804cdf0e10cSrcweir } 805cdf0e10cSrcweir } 806cdf0e10cSrcweir else 807cdf0e10cSrcweir { 808cdf0e10cSrcweir mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon); 809cdf0e10cSrcweir 810cdf0e10cSrcweir if(mnPolygonStrokePrimitive2D 811cdf0e10cSrcweir && getOptionsDrawinglayer().IsAntiAliasing() 812cdf0e10cSrcweir && (mpOutputDevice->GetAntialiasing() & ANTIALIASING_ENABLE_B2DDRAW)) 813cdf0e10cSrcweir { 814cdf0e10cSrcweir // when AA is on and this filled polygons are the result of stroked line geometry, 815cdf0e10cSrcweir // draw the geometry once extra as lines to avoid AA 'gaps' between partial polygons 816cdf0e10cSrcweir mpOutputDevice->SetFillColor(); 817cdf0e10cSrcweir mpOutputDevice->SetLineColor(Color(aPolygonColor)); 818cdf0e10cSrcweir const sal_uInt32 nCount(aLocalPolyPolygon.count()); 819cdf0e10cSrcweir 820cdf0e10cSrcweir for(sal_uInt32 a(0); a < nCount; a++) 821cdf0e10cSrcweir { 822cdf0e10cSrcweir mpOutputDevice->DrawPolyLine(aLocalPolyPolygon.getB2DPolygon(a), 0.0); 823cdf0e10cSrcweir } 824cdf0e10cSrcweir } 825cdf0e10cSrcweir } 826cdf0e10cSrcweir } 827cdf0e10cSrcweir 828cdf0e10cSrcweir // direct draw of MetaFile 829cdf0e10cSrcweir void VclProcessor2D::RenderMetafilePrimitive2D(const primitive2d::MetafilePrimitive2D& rMetaCandidate) 830cdf0e10cSrcweir { 831cdf0e10cSrcweir // decompose matrix to check for shear, rotate and mirroring 832cdf0e10cSrcweir basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rMetaCandidate.getTransform()); 833cdf0e10cSrcweir basegfx::B2DVector aScale, aTranslate; 834cdf0e10cSrcweir double fRotate, fShearX; 835cdf0e10cSrcweir aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX); 836cdf0e10cSrcweir 837cdf0e10cSrcweir if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0)) 838cdf0e10cSrcweir { 839cdf0e10cSrcweir // #i102175# handle special case: If scale is negative in (x,y) (3rd quadrant), it can 840cdf0e10cSrcweir // be expressed as rotation by PI. This needs to be done for Metafiles since 841cdf0e10cSrcweir // these can be rotated, but not really mirrored 842cdf0e10cSrcweir aScale = basegfx::absolute(aScale); 843cdf0e10cSrcweir fRotate += F_PI; 844cdf0e10cSrcweir } 845cdf0e10cSrcweir 846cdf0e10cSrcweir // get BoundRect 847cdf0e10cSrcweir basegfx::B2DRange aOutlineRange(rMetaCandidate.getB2DRange(getViewInformation2D())); 848cdf0e10cSrcweir aOutlineRange.transform(maCurrentTransformation); 849cdf0e10cSrcweir 850cdf0e10cSrcweir // Due to the integer MapModes used from VCL aind inside MetaFiles errors of up to three 851cdf0e10cSrcweir // pixels in size may happen. As long as there is no better way (e.g. convert the MetaFile 852cdf0e10cSrcweir // to primitives) it is necessary to reduce maximum pixel size by 1 in X and Y and to use 853cdf0e10cSrcweir // the inner pixel bounds accordingly (ceil resp. floor). This will also be done for logic 854cdf0e10cSrcweir // units e.g. when creating a new MetaFile, but since much huger value ranges are used 855cdf0e10cSrcweir // there typically will be okay for this compromize. 856cdf0e10cSrcweir Rectangle aDestRectView( 857cdf0e10cSrcweir // !!CAUTION!! Here, ceil and floor are exchanged BY PURPOSE, do NOT copy when 858cdf0e10cSrcweir // looking for a standard conversion to rectangle (!) 859cdf0e10cSrcweir (sal_Int32)ceil(aOutlineRange.getMinX()), (sal_Int32)ceil(aOutlineRange.getMinY()), 860cdf0e10cSrcweir (sal_Int32)floor(aOutlineRange.getMaxX()), (sal_Int32)floor(aOutlineRange.getMaxY())); 861cdf0e10cSrcweir 862cdf0e10cSrcweir // get metafile (copy it) 863cdf0e10cSrcweir GDIMetaFile aMetaFile; 864cdf0e10cSrcweir 865cdf0e10cSrcweir if(maBColorModifierStack.count()) 866cdf0e10cSrcweir { 867cdf0e10cSrcweir const basegfx::BColor aRGBBaseColor(0, 0, 0); 868cdf0e10cSrcweir const basegfx::BColor aRGBColor(maBColorModifierStack.getModifiedColor(aRGBBaseColor)); 869cdf0e10cSrcweir aMetaFile = rMetaCandidate.getMetaFile().GetMonochromeMtf(Color(aRGBColor)); 870cdf0e10cSrcweir } 871cdf0e10cSrcweir else 872cdf0e10cSrcweir { 873cdf0e10cSrcweir aMetaFile = rMetaCandidate.getMetaFile(); 874cdf0e10cSrcweir } 875cdf0e10cSrcweir 876cdf0e10cSrcweir // rotation 877cdf0e10cSrcweir if(!basegfx::fTools::equalZero(fRotate)) 878cdf0e10cSrcweir { 879cdf0e10cSrcweir // #i103530# 880cdf0e10cSrcweir // MetaFile::Rotate has no input parameter check, so the parameter needs to be 881cdf0e10cSrcweir // well-aligned to the old range [0..3600] 10th degrees with inverse orientation 882cdf0e10cSrcweir sal_Int16 nRotation((sal_Int16)((fRotate / F_PI180) * -10.0)); 883cdf0e10cSrcweir 884cdf0e10cSrcweir while(nRotation < 0) 885cdf0e10cSrcweir nRotation += 3600; 886cdf0e10cSrcweir 887cdf0e10cSrcweir while(nRotation >= 3600) 888cdf0e10cSrcweir nRotation -= 3600; 889cdf0e10cSrcweir 890cdf0e10cSrcweir aMetaFile.Rotate(nRotation); 891cdf0e10cSrcweir } 892cdf0e10cSrcweir 893cdf0e10cSrcweir // Prepare target output size 894cdf0e10cSrcweir Size aDestSize(aDestRectView.GetSize()); 895cdf0e10cSrcweir 896cdf0e10cSrcweir if(aDestSize.getWidth() && aDestSize.getHeight()) 897cdf0e10cSrcweir { 898cdf0e10cSrcweir // Get preferred Metafile output size. When it's very equal to the output size, it's probably 899cdf0e10cSrcweir // a rounding error somewhere, so correct it to get a 1:1 output without single pixel scalings 900cdf0e10cSrcweir // of the Metafile (esp. for contaned Bitmaps, e.g 3D charts) 901cdf0e10cSrcweir const Size aPrefSize(mpOutputDevice->LogicToPixel(aMetaFile.GetPrefSize(), aMetaFile.GetPrefMapMode())); 902cdf0e10cSrcweir 903cdf0e10cSrcweir if(aPrefSize.getWidth() && (aPrefSize.getWidth() - 1 == aDestSize.getWidth() || aPrefSize.getWidth() + 1 == aDestSize.getWidth())) 904cdf0e10cSrcweir { 905cdf0e10cSrcweir aDestSize.setWidth(aPrefSize.getWidth()); 906cdf0e10cSrcweir } 907cdf0e10cSrcweir 908cdf0e10cSrcweir if(aPrefSize.getHeight() && (aPrefSize.getHeight() - 1 == aDestSize.getHeight() || aPrefSize.getHeight() + 1 == aDestSize.getHeight())) 909cdf0e10cSrcweir { 910cdf0e10cSrcweir aDestSize.setHeight(aPrefSize.getHeight()); 911cdf0e10cSrcweir } 912cdf0e10cSrcweir 913cdf0e10cSrcweir // paint it 914cdf0e10cSrcweir aMetaFile.WindStart(); 915cdf0e10cSrcweir aMetaFile.Play(mpOutputDevice, aDestRectView.TopLeft(), aDestSize); 916cdf0e10cSrcweir } 917cdf0e10cSrcweir } 918cdf0e10cSrcweir 919cdf0e10cSrcweir // mask group. Force output to VDev and create mask from given mask 920cdf0e10cSrcweir void VclProcessor2D::RenderMaskPrimitive2DPixel(const primitive2d::MaskPrimitive2D& rMaskCandidate) 921cdf0e10cSrcweir { 922cdf0e10cSrcweir if(rMaskCandidate.getChildren().hasElements()) 923cdf0e10cSrcweir { 924cdf0e10cSrcweir basegfx::B2DPolyPolygon aMask(rMaskCandidate.getMask()); 925cdf0e10cSrcweir 926cdf0e10cSrcweir if(aMask.count()) 927cdf0e10cSrcweir { 928cdf0e10cSrcweir aMask.transform(maCurrentTransformation); 929cdf0e10cSrcweir const basegfx::B2DRange aRange(basegfx::tools::getRange(aMask)); 930cdf0e10cSrcweir impBufferDevice aBufferDevice(*mpOutputDevice, aRange, true); 931cdf0e10cSrcweir 932cdf0e10cSrcweir if(aBufferDevice.isVisible()) 933cdf0e10cSrcweir { 934cdf0e10cSrcweir // remember last OutDev and set to content 935cdf0e10cSrcweir OutputDevice* pLastOutputDevice = mpOutputDevice; 936cdf0e10cSrcweir mpOutputDevice = &aBufferDevice.getContent(); 937cdf0e10cSrcweir 938cdf0e10cSrcweir // paint to it 939cdf0e10cSrcweir process(rMaskCandidate.getChildren()); 940cdf0e10cSrcweir 941cdf0e10cSrcweir // back to old OutDev 942cdf0e10cSrcweir mpOutputDevice = pLastOutputDevice; 943cdf0e10cSrcweir 944cdf0e10cSrcweir // draw mask 945cdf0e10cSrcweir if(getOptionsDrawinglayer().IsAntiAliasing()) 946cdf0e10cSrcweir { 947cdf0e10cSrcweir // with AA, use 8bit AlphaMask to get nice borders 948cdf0e10cSrcweir VirtualDevice& rTransparence = aBufferDevice.getTransparence(); 949cdf0e10cSrcweir rTransparence.SetLineColor(); 950cdf0e10cSrcweir rTransparence.SetFillColor(COL_BLACK); 951cdf0e10cSrcweir rTransparence.DrawPolyPolygon(aMask); 952cdf0e10cSrcweir 953cdf0e10cSrcweir // dump buffer to outdev 954cdf0e10cSrcweir aBufferDevice.paint(); 955cdf0e10cSrcweir } 956cdf0e10cSrcweir else 957cdf0e10cSrcweir { 958cdf0e10cSrcweir // No AA, use 1bit mask 959cdf0e10cSrcweir VirtualDevice& rMask = aBufferDevice.getMask(); 960cdf0e10cSrcweir rMask.SetLineColor(); 961cdf0e10cSrcweir rMask.SetFillColor(COL_BLACK); 962cdf0e10cSrcweir rMask.DrawPolyPolygon(aMask); 963cdf0e10cSrcweir 964cdf0e10cSrcweir // dump buffer to outdev 965cdf0e10cSrcweir aBufferDevice.paint(); 966cdf0e10cSrcweir } 967cdf0e10cSrcweir } 968cdf0e10cSrcweir } 969cdf0e10cSrcweir } 970cdf0e10cSrcweir } 971cdf0e10cSrcweir 972cdf0e10cSrcweir // modified color group. Force output to unified color. 973cdf0e10cSrcweir void VclProcessor2D::RenderModifiedColorPrimitive2D(const primitive2d::ModifiedColorPrimitive2D& rModifiedCandidate) 974cdf0e10cSrcweir { 975cdf0e10cSrcweir if(rModifiedCandidate.getChildren().hasElements()) 976cdf0e10cSrcweir { 977cdf0e10cSrcweir maBColorModifierStack.push(rModifiedCandidate.getColorModifier()); 978cdf0e10cSrcweir process(rModifiedCandidate.getChildren()); 979cdf0e10cSrcweir maBColorModifierStack.pop(); 980cdf0e10cSrcweir } 981cdf0e10cSrcweir } 982cdf0e10cSrcweir 983cdf0e10cSrcweir // unified sub-transparence. Draw to VDev first. 984cdf0e10cSrcweir void VclProcessor2D::RenderUnifiedTransparencePrimitive2D(const primitive2d::UnifiedTransparencePrimitive2D& rTransCandidate) 985cdf0e10cSrcweir { 986cdf0e10cSrcweir static bool bForceToDecomposition(false); 987cdf0e10cSrcweir 988cdf0e10cSrcweir if(rTransCandidate.getChildren().hasElements()) 989cdf0e10cSrcweir { 990cdf0e10cSrcweir if(bForceToDecomposition) 991cdf0e10cSrcweir { 992cdf0e10cSrcweir // use decomposition 993cdf0e10cSrcweir process(rTransCandidate.get2DDecomposition(getViewInformation2D())); 994cdf0e10cSrcweir } 995cdf0e10cSrcweir else 996cdf0e10cSrcweir { 997cdf0e10cSrcweir if(0.0 == rTransCandidate.getTransparence()) 998cdf0e10cSrcweir { 999cdf0e10cSrcweir // no transparence used, so just use the content 1000cdf0e10cSrcweir process(rTransCandidate.getChildren()); 1001cdf0e10cSrcweir } 1002cdf0e10cSrcweir else if(rTransCandidate.getTransparence() > 0.0 && rTransCandidate.getTransparence() < 1.0) 1003cdf0e10cSrcweir { 1004cdf0e10cSrcweir // transparence is in visible range 1005cdf0e10cSrcweir basegfx::B2DRange aRange(primitive2d::getB2DRangeFromPrimitive2DSequence(rTransCandidate.getChildren(), getViewInformation2D())); 1006cdf0e10cSrcweir aRange.transform(maCurrentTransformation); 1007cdf0e10cSrcweir impBufferDevice aBufferDevice(*mpOutputDevice, aRange, true); 1008cdf0e10cSrcweir 1009cdf0e10cSrcweir if(aBufferDevice.isVisible()) 1010cdf0e10cSrcweir { 1011cdf0e10cSrcweir // remember last OutDev and set to content 1012cdf0e10cSrcweir OutputDevice* pLastOutputDevice = mpOutputDevice; 1013cdf0e10cSrcweir mpOutputDevice = &aBufferDevice.getContent(); 1014cdf0e10cSrcweir 1015cdf0e10cSrcweir // paint content to it 1016cdf0e10cSrcweir process(rTransCandidate.getChildren()); 1017cdf0e10cSrcweir 1018cdf0e10cSrcweir // back to old OutDev 1019cdf0e10cSrcweir mpOutputDevice = pLastOutputDevice; 1020cdf0e10cSrcweir 1021cdf0e10cSrcweir // dump buffer to outdev using given transparence 1022cdf0e10cSrcweir aBufferDevice.paint(rTransCandidate.getTransparence()); 1023cdf0e10cSrcweir } 1024cdf0e10cSrcweir } 1025cdf0e10cSrcweir } 1026cdf0e10cSrcweir } 1027cdf0e10cSrcweir } 1028cdf0e10cSrcweir 1029cdf0e10cSrcweir // sub-transparence group. Draw to VDev first. 1030cdf0e10cSrcweir void VclProcessor2D::RenderTransparencePrimitive2D(const primitive2d::TransparencePrimitive2D& rTransCandidate) 1031cdf0e10cSrcweir { 1032cdf0e10cSrcweir if(rTransCandidate.getChildren().hasElements()) 1033cdf0e10cSrcweir { 1034cdf0e10cSrcweir basegfx::B2DRange aRange(primitive2d::getB2DRangeFromPrimitive2DSequence(rTransCandidate.getChildren(), getViewInformation2D())); 1035cdf0e10cSrcweir aRange.transform(maCurrentTransformation); 1036cdf0e10cSrcweir impBufferDevice aBufferDevice(*mpOutputDevice, aRange, true); 1037cdf0e10cSrcweir 1038cdf0e10cSrcweir if(aBufferDevice.isVisible()) 1039cdf0e10cSrcweir { 1040cdf0e10cSrcweir // remember last OutDev and set to content 1041cdf0e10cSrcweir OutputDevice* pLastOutputDevice = mpOutputDevice; 1042cdf0e10cSrcweir mpOutputDevice = &aBufferDevice.getContent(); 1043cdf0e10cSrcweir 1044cdf0e10cSrcweir // paint content to it 1045cdf0e10cSrcweir process(rTransCandidate.getChildren()); 1046cdf0e10cSrcweir 1047cdf0e10cSrcweir // set to mask 1048cdf0e10cSrcweir mpOutputDevice = &aBufferDevice.getTransparence(); 1049cdf0e10cSrcweir 1050cdf0e10cSrcweir // when painting transparence masks, reset the color stack 1051cdf0e10cSrcweir basegfx::BColorModifierStack aLastBColorModifierStack(maBColorModifierStack); 1052cdf0e10cSrcweir maBColorModifierStack = basegfx::BColorModifierStack(); 1053cdf0e10cSrcweir 1054cdf0e10cSrcweir // paint mask to it (always with transparence intensities, evtl. with AA) 1055cdf0e10cSrcweir process(rTransCandidate.getTransparence()); 1056cdf0e10cSrcweir 1057cdf0e10cSrcweir // back to old color stack 1058cdf0e10cSrcweir maBColorModifierStack = aLastBColorModifierStack; 1059cdf0e10cSrcweir 1060cdf0e10cSrcweir // back to old OutDev 1061cdf0e10cSrcweir mpOutputDevice = pLastOutputDevice; 1062cdf0e10cSrcweir 1063cdf0e10cSrcweir // dump buffer to outdev 1064cdf0e10cSrcweir aBufferDevice.paint(); 1065cdf0e10cSrcweir } 1066cdf0e10cSrcweir } 1067cdf0e10cSrcweir } 1068cdf0e10cSrcweir 1069cdf0e10cSrcweir // transform group. 1070cdf0e10cSrcweir void VclProcessor2D::RenderTransformPrimitive2D(const primitive2d::TransformPrimitive2D& rTransformCandidate) 1071cdf0e10cSrcweir { 1072cdf0e10cSrcweir // remember current transformation and ViewInformation 1073cdf0e10cSrcweir const basegfx::B2DHomMatrix aLastCurrentTransformation(maCurrentTransformation); 1074cdf0e10cSrcweir const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D()); 1075cdf0e10cSrcweir 1076cdf0e10cSrcweir // create new transformations for CurrentTransformation 1077cdf0e10cSrcweir // and for local ViewInformation2D 1078cdf0e10cSrcweir maCurrentTransformation = maCurrentTransformation * rTransformCandidate.getTransformation(); 1079cdf0e10cSrcweir const geometry::ViewInformation2D aViewInformation2D( 1080cdf0e10cSrcweir getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation(), 1081cdf0e10cSrcweir getViewInformation2D().getViewTransformation(), 1082cdf0e10cSrcweir getViewInformation2D().getViewport(), 1083cdf0e10cSrcweir getViewInformation2D().getVisualizedPage(), 1084cdf0e10cSrcweir getViewInformation2D().getViewTime(), 1085cdf0e10cSrcweir getViewInformation2D().getExtendedInformationSequence()); 1086cdf0e10cSrcweir updateViewInformation(aViewInformation2D); 1087cdf0e10cSrcweir 1088cdf0e10cSrcweir // proccess content 1089cdf0e10cSrcweir process(rTransformCandidate.getChildren()); 1090cdf0e10cSrcweir 1091cdf0e10cSrcweir // restore transformations 1092cdf0e10cSrcweir maCurrentTransformation = aLastCurrentTransformation; 1093cdf0e10cSrcweir updateViewInformation(aLastViewInformation2D); 1094cdf0e10cSrcweir } 1095cdf0e10cSrcweir 1096cdf0e10cSrcweir // new XDrawPage for ViewInformation2D 1097cdf0e10cSrcweir void VclProcessor2D::RenderPagePreviewPrimitive2D(const primitive2d::PagePreviewPrimitive2D& rPagePreviewCandidate) 1098cdf0e10cSrcweir { 1099cdf0e10cSrcweir // remember current transformation and ViewInformation 1100cdf0e10cSrcweir const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D()); 1101cdf0e10cSrcweir 1102cdf0e10cSrcweir // create new local ViewInformation2D 1103cdf0e10cSrcweir const geometry::ViewInformation2D aViewInformation2D( 1104cdf0e10cSrcweir getViewInformation2D().getObjectTransformation(), 1105cdf0e10cSrcweir getViewInformation2D().getViewTransformation(), 1106cdf0e10cSrcweir getViewInformation2D().getViewport(), 1107cdf0e10cSrcweir rPagePreviewCandidate.getXDrawPage(), 1108cdf0e10cSrcweir getViewInformation2D().getViewTime(), 1109cdf0e10cSrcweir getViewInformation2D().getExtendedInformationSequence()); 1110cdf0e10cSrcweir updateViewInformation(aViewInformation2D); 1111cdf0e10cSrcweir 1112cdf0e10cSrcweir // proccess decomposed content 1113cdf0e10cSrcweir process(rPagePreviewCandidate.get2DDecomposition(getViewInformation2D())); 1114cdf0e10cSrcweir 1115cdf0e10cSrcweir // restore transformations 1116cdf0e10cSrcweir updateViewInformation(aLastViewInformation2D); 1117cdf0e10cSrcweir } 1118cdf0e10cSrcweir 1119cdf0e10cSrcweir // marker 1120cdf0e10cSrcweir void VclProcessor2D::RenderMarkerArrayPrimitive2D(const primitive2d::MarkerArrayPrimitive2D& rMarkArrayCandidate) 1121cdf0e10cSrcweir { 1122cdf0e10cSrcweir static bool bCheckCompleteMarkerDecompose(false); 1123cdf0e10cSrcweir if(bCheckCompleteMarkerDecompose) 1124cdf0e10cSrcweir { 1125cdf0e10cSrcweir process(rMarkArrayCandidate.get2DDecomposition(getViewInformation2D())); 1126cdf0e10cSrcweir return; 1127cdf0e10cSrcweir } 1128cdf0e10cSrcweir 1129cdf0e10cSrcweir // get data 1130cdf0e10cSrcweir const std::vector< basegfx::B2DPoint >& rPositions = rMarkArrayCandidate.getPositions(); 1131cdf0e10cSrcweir const sal_uInt32 nCount(rPositions.size()); 1132cdf0e10cSrcweir 1133cdf0e10cSrcweir if(nCount && !rMarkArrayCandidate.getMarker().IsEmpty()) 1134cdf0e10cSrcweir { 1135cdf0e10cSrcweir // get pixel size 1136cdf0e10cSrcweir const BitmapEx& rMarker(rMarkArrayCandidate.getMarker()); 1137cdf0e10cSrcweir const Size aBitmapSize(rMarker.GetSizePixel()); 1138cdf0e10cSrcweir 1139cdf0e10cSrcweir if(aBitmapSize.Width() && aBitmapSize.Height()) 1140cdf0e10cSrcweir { 1141cdf0e10cSrcweir // get discrete half size 1142cdf0e10cSrcweir const basegfx::B2DVector aDiscreteHalfSize( 1143cdf0e10cSrcweir (aBitmapSize.getWidth() - 1.0) * 0.5, 1144cdf0e10cSrcweir (aBitmapSize.getHeight() - 1.0) * 0.5); 1145cdf0e10cSrcweir const bool bWasEnabled(mpOutputDevice->IsMapModeEnabled()); 1146cdf0e10cSrcweir 1147cdf0e10cSrcweir // do not forget evtl. moved origin in target device MapMode when 1148cdf0e10cSrcweir // switching it off; it would be missing and lead to wrong positions. 1149cdf0e10cSrcweir // All his could be done using logic sizes and coordinates, too, but 1150cdf0e10cSrcweir // we want a 1:1 bitmap rendering here, so it's more safe and faster 1151cdf0e10cSrcweir // to work with switching off MapMode usage completely. 1152cdf0e10cSrcweir const Point aOrigin(mpOutputDevice->GetMapMode().GetOrigin()); 1153cdf0e10cSrcweir 1154cdf0e10cSrcweir mpOutputDevice->EnableMapMode(false); 1155cdf0e10cSrcweir 1156cdf0e10cSrcweir for(std::vector< basegfx::B2DPoint >::const_iterator aIter(rPositions.begin()); aIter != rPositions.end(); aIter++) 1157cdf0e10cSrcweir { 1158cdf0e10cSrcweir const basegfx::B2DPoint aDiscreteTopLeft((maCurrentTransformation * (*aIter)) - aDiscreteHalfSize); 1159cdf0e10cSrcweir const Point aDiscretePoint(basegfx::fround(aDiscreteTopLeft.getX()), basegfx::fround(aDiscreteTopLeft.getY())); 1160cdf0e10cSrcweir 1161cdf0e10cSrcweir mpOutputDevice->DrawBitmapEx(aDiscretePoint + aOrigin, rMarker); 1162cdf0e10cSrcweir } 1163cdf0e10cSrcweir 1164cdf0e10cSrcweir mpOutputDevice->EnableMapMode(bWasEnabled); 1165cdf0e10cSrcweir } 1166cdf0e10cSrcweir } 1167cdf0e10cSrcweir } 1168cdf0e10cSrcweir 1169cdf0e10cSrcweir // point 1170cdf0e10cSrcweir void VclProcessor2D::RenderPointArrayPrimitive2D(const primitive2d::PointArrayPrimitive2D& rPointArrayCandidate) 1171cdf0e10cSrcweir { 1172cdf0e10cSrcweir const std::vector< basegfx::B2DPoint >& rPositions = rPointArrayCandidate.getPositions(); 1173cdf0e10cSrcweir const basegfx::BColor aRGBColor(maBColorModifierStack.getModifiedColor(rPointArrayCandidate.getRGBColor())); 1174cdf0e10cSrcweir const Color aVCLColor(aRGBColor); 1175cdf0e10cSrcweir 1176cdf0e10cSrcweir for(std::vector< basegfx::B2DPoint >::const_iterator aIter(rPositions.begin()); aIter != rPositions.end(); aIter++) 1177cdf0e10cSrcweir { 1178cdf0e10cSrcweir const basegfx::B2DPoint aViewPosition(maCurrentTransformation * (*aIter)); 1179cdf0e10cSrcweir const Point aPos(basegfx::fround(aViewPosition.getX()), basegfx::fround(aViewPosition.getY())); 1180cdf0e10cSrcweir 1181cdf0e10cSrcweir mpOutputDevice->DrawPixel(aPos, aVCLColor); 1182cdf0e10cSrcweir } 1183cdf0e10cSrcweir } 1184cdf0e10cSrcweir 1185cdf0e10cSrcweir void VclProcessor2D::RenderPolygonStrokePrimitive2D(const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokeCandidate) 1186cdf0e10cSrcweir { 1187cdf0e10cSrcweir // #i101491# method restructured to clearly use the DrawPolyLine 1188cdf0e10cSrcweir // calls starting from a deined line width 1189cdf0e10cSrcweir const attribute::LineAttribute& rLineAttribute = rPolygonStrokeCandidate.getLineAttribute(); 1190cdf0e10cSrcweir const double fLineWidth(rLineAttribute.getWidth()); 1191cdf0e10cSrcweir bool bDone(false); 1192cdf0e10cSrcweir 1193cdf0e10cSrcweir if(basegfx::fTools::more(fLineWidth, 0.0)) 1194cdf0e10cSrcweir { 1195cdf0e10cSrcweir const basegfx::B2DVector aDiscreteUnit(maCurrentTransformation * basegfx::B2DVector(fLineWidth, 0.0)); 1196cdf0e10cSrcweir const double fDiscreteLineWidth(aDiscreteUnit.getLength()); 1197cdf0e10cSrcweir const attribute::StrokeAttribute& rStrokeAttribute = rPolygonStrokeCandidate.getStrokeAttribute(); 1198cdf0e10cSrcweir const basegfx::BColor aHairlineColor(maBColorModifierStack.getModifiedColor(rLineAttribute.getColor())); 1199cdf0e10cSrcweir basegfx::B2DPolyPolygon aHairlinePolyPolygon; 1200cdf0e10cSrcweir 1201cdf0e10cSrcweir mpOutputDevice->SetLineColor(Color(aHairlineColor)); 1202cdf0e10cSrcweir mpOutputDevice->SetFillColor(); 1203cdf0e10cSrcweir 1204cdf0e10cSrcweir if(0.0 == rStrokeAttribute.getFullDotDashLen()) 1205cdf0e10cSrcweir { 1206cdf0e10cSrcweir // no line dashing, just copy 1207cdf0e10cSrcweir aHairlinePolyPolygon.append(rPolygonStrokeCandidate.getB2DPolygon()); 1208cdf0e10cSrcweir } 1209cdf0e10cSrcweir else 1210cdf0e10cSrcweir { 1211cdf0e10cSrcweir // else apply LineStyle 1212cdf0e10cSrcweir basegfx::tools::applyLineDashing(rPolygonStrokeCandidate.getB2DPolygon(), 1213cdf0e10cSrcweir rStrokeAttribute.getDotDashArray(), 1214cdf0e10cSrcweir &aHairlinePolyPolygon, 0, rStrokeAttribute.getFullDotDashLen()); 1215cdf0e10cSrcweir } 1216cdf0e10cSrcweir 1217cdf0e10cSrcweir const sal_uInt32 nCount(aHairlinePolyPolygon.count()); 1218cdf0e10cSrcweir 1219cdf0e10cSrcweir if(nCount) 1220cdf0e10cSrcweir { 1221cdf0e10cSrcweir const bool bAntiAliased(getOptionsDrawinglayer().IsAntiAliasing()); 1222cdf0e10cSrcweir aHairlinePolyPolygon.transform(maCurrentTransformation); 1223cdf0e10cSrcweir 1224cdf0e10cSrcweir for(sal_uInt32 a(0); a < nCount; a++) 1225cdf0e10cSrcweir { 1226cdf0e10cSrcweir basegfx::B2DPolygon aCandidate(aHairlinePolyPolygon.getB2DPolygon(a)); 1227cdf0e10cSrcweir 1228cdf0e10cSrcweir if(bAntiAliased) 1229cdf0e10cSrcweir { 1230cdf0e10cSrcweir if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 1.0)) 1231cdf0e10cSrcweir { 1232cdf0e10cSrcweir // line in range ]0.0 .. 1.0[ 1233cdf0e10cSrcweir // paint as simple hairline 1234cdf0e10cSrcweir mpOutputDevice->DrawPolyLine(aCandidate, 0.0); 1235cdf0e10cSrcweir bDone = true; 1236cdf0e10cSrcweir } 1237cdf0e10cSrcweir else if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 2.0)) 1238cdf0e10cSrcweir { 1239cdf0e10cSrcweir // line in range [1.0 .. 2.0[ 1240cdf0e10cSrcweir // paint as 2x2 with dynamic line distance 1241cdf0e10cSrcweir basegfx::B2DHomMatrix aMat; 1242cdf0e10cSrcweir const double fDistance(fDiscreteLineWidth - 1.0); 1243cdf0e10cSrcweir const double fHalfDistance(fDistance * 0.5); 1244cdf0e10cSrcweir 1245cdf0e10cSrcweir aMat.set(0, 2, -fHalfDistance); 1246cdf0e10cSrcweir aMat.set(1, 2, -fHalfDistance); 1247cdf0e10cSrcweir aCandidate.transform(aMat); 1248cdf0e10cSrcweir mpOutputDevice->DrawPolyLine(aCandidate, 0.0); 1249cdf0e10cSrcweir 1250cdf0e10cSrcweir aMat.set(0, 2, fDistance); 1251cdf0e10cSrcweir aMat.set(1, 2, 0.0); 1252cdf0e10cSrcweir aCandidate.transform(aMat); 1253cdf0e10cSrcweir mpOutputDevice->DrawPolyLine(aCandidate, 0.0); 1254cdf0e10cSrcweir 1255cdf0e10cSrcweir aMat.set(0, 2, 0.0); 1256cdf0e10cSrcweir aMat.set(1, 2, fDistance); 1257cdf0e10cSrcweir aCandidate.transform(aMat); 1258cdf0e10cSrcweir mpOutputDevice->DrawPolyLine(aCandidate, 0.0); 1259cdf0e10cSrcweir 1260cdf0e10cSrcweir aMat.set(0, 2, -fDistance); 1261cdf0e10cSrcweir aMat.set(1, 2, 0.0); 1262cdf0e10cSrcweir aCandidate.transform(aMat); 1263cdf0e10cSrcweir mpOutputDevice->DrawPolyLine(aCandidate, 0.0); 1264cdf0e10cSrcweir bDone = true; 1265cdf0e10cSrcweir } 1266cdf0e10cSrcweir else if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 3.0)) 1267cdf0e10cSrcweir { 1268cdf0e10cSrcweir // line in range [2.0 .. 3.0] 1269cdf0e10cSrcweir // paint as cross in a 3x3 with dynamic line distance 1270cdf0e10cSrcweir basegfx::B2DHomMatrix aMat; 1271cdf0e10cSrcweir const double fDistance((fDiscreteLineWidth - 1.0) * 0.5); 1272cdf0e10cSrcweir 1273cdf0e10cSrcweir mpOutputDevice->DrawPolyLine(aCandidate, 0.0); 1274cdf0e10cSrcweir 1275cdf0e10cSrcweir aMat.set(0, 2, -fDistance); 1276cdf0e10cSrcweir aMat.set(1, 2, 0.0); 1277cdf0e10cSrcweir aCandidate.transform(aMat); 1278cdf0e10cSrcweir mpOutputDevice->DrawPolyLine(aCandidate, 0.0); 1279cdf0e10cSrcweir 1280cdf0e10cSrcweir aMat.set(0, 2, fDistance); 1281cdf0e10cSrcweir aMat.set(1, 2, -fDistance); 1282cdf0e10cSrcweir aCandidate.transform(aMat); 1283cdf0e10cSrcweir mpOutputDevice->DrawPolyLine(aCandidate, 0.0); 1284cdf0e10cSrcweir 1285cdf0e10cSrcweir aMat.set(0, 2, fDistance); 1286cdf0e10cSrcweir aMat.set(1, 2, fDistance); 1287cdf0e10cSrcweir aCandidate.transform(aMat); 1288cdf0e10cSrcweir mpOutputDevice->DrawPolyLine(aCandidate, 0.0); 1289cdf0e10cSrcweir 1290cdf0e10cSrcweir aMat.set(0, 2, -fDistance); 1291cdf0e10cSrcweir aMat.set(1, 2, fDistance); 1292cdf0e10cSrcweir aCandidate.transform(aMat); 1293cdf0e10cSrcweir mpOutputDevice->DrawPolyLine(aCandidate, 0.0); 1294cdf0e10cSrcweir bDone = true; 1295cdf0e10cSrcweir } 1296cdf0e10cSrcweir else 1297cdf0e10cSrcweir { 1298cdf0e10cSrcweir // #i101491# line width above 3.0 1299cdf0e10cSrcweir } 1300cdf0e10cSrcweir } 1301cdf0e10cSrcweir else 1302cdf0e10cSrcweir { 1303cdf0e10cSrcweir if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 1.5)) 1304cdf0e10cSrcweir { 1305cdf0e10cSrcweir // line width below 1.5, draw the basic hairline polygon 1306cdf0e10cSrcweir mpOutputDevice->DrawPolyLine(aCandidate, 0.0); 1307cdf0e10cSrcweir bDone = true; 1308cdf0e10cSrcweir } 1309cdf0e10cSrcweir else if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 2.5)) 1310cdf0e10cSrcweir { 1311cdf0e10cSrcweir // line width is in range ]1.5 .. 2.5], use four hairlines 1312cdf0e10cSrcweir // drawn in a square 1313cdf0e10cSrcweir basegfx::B2DHomMatrix aMat; 1314cdf0e10cSrcweir mpOutputDevice->DrawPolyLine(aCandidate, 0.0); 1315cdf0e10cSrcweir 1316cdf0e10cSrcweir aMat.set(0, 2, 1.0); 1317cdf0e10cSrcweir aMat.set(1, 2, 0.0); 1318cdf0e10cSrcweir aCandidate.transform(aMat); 1319cdf0e10cSrcweir 1320cdf0e10cSrcweir mpOutputDevice->DrawPolyLine(aCandidate, 0.0); 1321cdf0e10cSrcweir 1322cdf0e10cSrcweir aMat.set(0, 2, 0.0); 1323cdf0e10cSrcweir aMat.set(1, 2, 1.0); 1324cdf0e10cSrcweir aCandidate.transform(aMat); 1325cdf0e10cSrcweir 1326cdf0e10cSrcweir mpOutputDevice->DrawPolyLine(aCandidate, 0.0); 1327cdf0e10cSrcweir 1328cdf0e10cSrcweir aMat.set(0, 2, -1.0); 1329cdf0e10cSrcweir aMat.set(1, 2, 0.0); 1330cdf0e10cSrcweir aCandidate.transform(aMat); 1331cdf0e10cSrcweir 1332cdf0e10cSrcweir mpOutputDevice->DrawPolyLine(aCandidate, 0.0); 1333cdf0e10cSrcweir bDone = true; 1334cdf0e10cSrcweir } 1335cdf0e10cSrcweir else 1336cdf0e10cSrcweir { 1337cdf0e10cSrcweir // #i101491# line width is above 2.5 1338cdf0e10cSrcweir } 1339cdf0e10cSrcweir } 1340cdf0e10cSrcweir 1341cdf0e10cSrcweir if(!bDone && rPolygonStrokeCandidate.getB2DPolygon().count() > 1000) 1342cdf0e10cSrcweir { 1343cdf0e10cSrcweir // #i101491# If the polygon complexity uses more than a given amount, do 1344cdf0e10cSrcweir // use OuputDevice::DrawPolyLine directly; this will avoid buffering all 1345cdf0e10cSrcweir // decompositions in primtives (memory) and fallback to old line painting 1346cdf0e10cSrcweir // for very complex polygons, too 1347cdf0e10cSrcweir mpOutputDevice->DrawPolyLine(aCandidate, fDiscreteLineWidth, rLineAttribute.getLineJoin()); 1348cdf0e10cSrcweir bDone = true; 1349cdf0e10cSrcweir } 1350cdf0e10cSrcweir } 1351cdf0e10cSrcweir } 1352cdf0e10cSrcweir } 1353cdf0e10cSrcweir 1354cdf0e10cSrcweir if(!bDone) 1355cdf0e10cSrcweir { 1356cdf0e10cSrcweir // remeber that we enter a PolygonStrokePrimitive2D decomposition, 1357cdf0e10cSrcweir // used for AA thick line drawing 1358cdf0e10cSrcweir mnPolygonStrokePrimitive2D++; 1359cdf0e10cSrcweir 1360cdf0e10cSrcweir // line width is big enough for standard filled polygon visualisation or zero 1361cdf0e10cSrcweir process(rPolygonStrokeCandidate.get2DDecomposition(getViewInformation2D())); 1362cdf0e10cSrcweir 1363cdf0e10cSrcweir // leave PolygonStrokePrimitive2D 1364cdf0e10cSrcweir mnPolygonStrokePrimitive2D--; 1365cdf0e10cSrcweir } 1366cdf0e10cSrcweir } 1367cdf0e10cSrcweir 1368cdf0e10cSrcweir void VclProcessor2D::RenderEpsPrimitive2D(const primitive2d::EpsPrimitive2D& rEpsPrimitive2D) 1369cdf0e10cSrcweir { 1370cdf0e10cSrcweir // The new decomposition of Metafiles made it necessary to add an Eps 1371cdf0e10cSrcweir // primitive to handle embedded Eps data. On some devices, this can be 1372cdf0e10cSrcweir // painted directly (mac, printer). 1373cdf0e10cSrcweir // To be able to handle the replacement correctly, i need to handle it myself 1374cdf0e10cSrcweir // since DrawEPS will not be able e.g. to rotate the replacement. To be able 1375cdf0e10cSrcweir // to do that, i added a boolean return to OutputDevice::DrawEPS(..) 1376cdf0e10cSrcweir // to know when EPS was handled directly already. 1377cdf0e10cSrcweir basegfx::B2DRange aRange(0.0, 0.0, 1.0, 1.0); 1378cdf0e10cSrcweir aRange.transform(maCurrentTransformation * rEpsPrimitive2D.getEpsTransform()); 1379cdf0e10cSrcweir 1380cdf0e10cSrcweir if(!aRange.isEmpty()) 1381cdf0e10cSrcweir { 1382cdf0e10cSrcweir const Rectangle aRectangle( 1383cdf0e10cSrcweir (sal_Int32)floor(aRange.getMinX()), (sal_Int32)floor(aRange.getMinY()), 1384cdf0e10cSrcweir (sal_Int32)ceil(aRange.getMaxX()), (sal_Int32)ceil(aRange.getMaxY())); 1385cdf0e10cSrcweir 1386cdf0e10cSrcweir if(!aRectangle.IsEmpty()) 1387cdf0e10cSrcweir { 1388cdf0e10cSrcweir // try to paint EPS directly without fallback visualisation 1389cdf0e10cSrcweir const bool bEPSPaintedDirectly(mpOutputDevice->DrawEPS( 1390cdf0e10cSrcweir aRectangle.TopLeft(), 1391cdf0e10cSrcweir aRectangle.GetSize(), 1392cdf0e10cSrcweir rEpsPrimitive2D.getGfxLink(), 1393cdf0e10cSrcweir 0)); 1394cdf0e10cSrcweir 1395cdf0e10cSrcweir if(!bEPSPaintedDirectly) 1396cdf0e10cSrcweir { 1397cdf0e10cSrcweir // use the decomposition which will correctly handle the 1398cdf0e10cSrcweir // fallback visualisation using full transformation (e.g. rotation) 1399cdf0e10cSrcweir process(rEpsPrimitive2D.get2DDecomposition(getViewInformation2D())); 1400cdf0e10cSrcweir } 1401cdf0e10cSrcweir } 1402cdf0e10cSrcweir } 1403cdf0e10cSrcweir } 1404cdf0e10cSrcweir 1405cdf0e10cSrcweir void VclProcessor2D::adaptLineToFillDrawMode() const 1406cdf0e10cSrcweir { 1407cdf0e10cSrcweir const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode()); 1408cdf0e10cSrcweir 1409cdf0e10cSrcweir if(nOriginalDrawMode & (DRAWMODE_BLACKLINE|DRAWMODE_GRAYLINE|DRAWMODE_GHOSTEDLINE|DRAWMODE_WHITELINE|DRAWMODE_SETTINGSLINE)) 1410cdf0e10cSrcweir { 1411cdf0e10cSrcweir sal_uInt32 nAdaptedDrawMode(nOriginalDrawMode); 1412cdf0e10cSrcweir 1413cdf0e10cSrcweir if(nOriginalDrawMode & DRAWMODE_BLACKLINE) 1414cdf0e10cSrcweir { 1415cdf0e10cSrcweir nAdaptedDrawMode |= DRAWMODE_BLACKFILL; 1416cdf0e10cSrcweir } 1417cdf0e10cSrcweir else 1418cdf0e10cSrcweir { 1419cdf0e10cSrcweir nAdaptedDrawMode &= ~DRAWMODE_BLACKFILL; 1420cdf0e10cSrcweir } 1421cdf0e10cSrcweir 1422cdf0e10cSrcweir if(nOriginalDrawMode & DRAWMODE_GRAYLINE) 1423cdf0e10cSrcweir { 1424cdf0e10cSrcweir nAdaptedDrawMode |= DRAWMODE_GRAYFILL; 1425cdf0e10cSrcweir } 1426cdf0e10cSrcweir else 1427cdf0e10cSrcweir { 1428cdf0e10cSrcweir nAdaptedDrawMode &= ~DRAWMODE_GRAYFILL; 1429cdf0e10cSrcweir } 1430cdf0e10cSrcweir 1431cdf0e10cSrcweir if(nOriginalDrawMode & DRAWMODE_GHOSTEDLINE) 1432cdf0e10cSrcweir { 1433cdf0e10cSrcweir nAdaptedDrawMode |= DRAWMODE_GHOSTEDFILL; 1434cdf0e10cSrcweir } 1435cdf0e10cSrcweir else 1436cdf0e10cSrcweir { 1437cdf0e10cSrcweir nAdaptedDrawMode &= ~DRAWMODE_GHOSTEDFILL; 1438cdf0e10cSrcweir } 1439cdf0e10cSrcweir 1440cdf0e10cSrcweir if(nOriginalDrawMode & DRAWMODE_WHITELINE) 1441cdf0e10cSrcweir { 1442cdf0e10cSrcweir nAdaptedDrawMode |= DRAWMODE_WHITEFILL; 1443cdf0e10cSrcweir } 1444cdf0e10cSrcweir else 1445cdf0e10cSrcweir { 1446cdf0e10cSrcweir nAdaptedDrawMode &= ~DRAWMODE_WHITEFILL; 1447cdf0e10cSrcweir } 1448cdf0e10cSrcweir 1449cdf0e10cSrcweir if(nOriginalDrawMode & DRAWMODE_SETTINGSLINE) 1450cdf0e10cSrcweir { 1451cdf0e10cSrcweir nAdaptedDrawMode |= DRAWMODE_SETTINGSFILL; 1452cdf0e10cSrcweir } 1453cdf0e10cSrcweir else 1454cdf0e10cSrcweir { 1455cdf0e10cSrcweir nAdaptedDrawMode &= ~DRAWMODE_SETTINGSFILL; 1456cdf0e10cSrcweir } 1457cdf0e10cSrcweir 1458cdf0e10cSrcweir mpOutputDevice->SetDrawMode(nAdaptedDrawMode); 1459cdf0e10cSrcweir } 1460cdf0e10cSrcweir } 1461cdf0e10cSrcweir 1462cdf0e10cSrcweir void VclProcessor2D::adaptTextToFillDrawMode() const 1463cdf0e10cSrcweir { 1464cdf0e10cSrcweir const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode()); 1465cdf0e10cSrcweir if(nOriginalDrawMode & (DRAWMODE_BLACKTEXT|DRAWMODE_GRAYTEXT|DRAWMODE_GHOSTEDTEXT|DRAWMODE_WHITETEXT|DRAWMODE_SETTINGSTEXT)) 1466cdf0e10cSrcweir { 1467cdf0e10cSrcweir sal_uInt32 nAdaptedDrawMode(nOriginalDrawMode); 1468cdf0e10cSrcweir 1469cdf0e10cSrcweir if(nOriginalDrawMode & DRAWMODE_BLACKTEXT) 1470cdf0e10cSrcweir { 1471cdf0e10cSrcweir nAdaptedDrawMode |= DRAWMODE_BLACKFILL; 1472cdf0e10cSrcweir } 1473cdf0e10cSrcweir else 1474cdf0e10cSrcweir { 1475cdf0e10cSrcweir nAdaptedDrawMode &= ~DRAWMODE_BLACKFILL; 1476cdf0e10cSrcweir } 1477cdf0e10cSrcweir 1478cdf0e10cSrcweir if(nOriginalDrawMode & DRAWMODE_GRAYTEXT) 1479cdf0e10cSrcweir { 1480cdf0e10cSrcweir nAdaptedDrawMode |= DRAWMODE_GRAYFILL; 1481cdf0e10cSrcweir } 1482cdf0e10cSrcweir else 1483cdf0e10cSrcweir { 1484cdf0e10cSrcweir nAdaptedDrawMode &= ~DRAWMODE_GRAYFILL; 1485cdf0e10cSrcweir } 1486cdf0e10cSrcweir 1487cdf0e10cSrcweir if(nOriginalDrawMode & DRAWMODE_GHOSTEDTEXT) 1488cdf0e10cSrcweir { 1489cdf0e10cSrcweir nAdaptedDrawMode |= DRAWMODE_GHOSTEDFILL; 1490cdf0e10cSrcweir } 1491cdf0e10cSrcweir else 1492cdf0e10cSrcweir { 1493cdf0e10cSrcweir nAdaptedDrawMode &= ~DRAWMODE_GHOSTEDFILL; 1494cdf0e10cSrcweir } 1495cdf0e10cSrcweir 1496cdf0e10cSrcweir if(nOriginalDrawMode & DRAWMODE_WHITETEXT) 1497cdf0e10cSrcweir { 1498cdf0e10cSrcweir nAdaptedDrawMode |= DRAWMODE_WHITEFILL; 1499cdf0e10cSrcweir } 1500cdf0e10cSrcweir else 1501cdf0e10cSrcweir { 1502cdf0e10cSrcweir nAdaptedDrawMode &= ~DRAWMODE_WHITEFILL; 1503cdf0e10cSrcweir } 1504cdf0e10cSrcweir 1505cdf0e10cSrcweir if(nOriginalDrawMode & DRAWMODE_SETTINGSTEXT) 1506cdf0e10cSrcweir { 1507cdf0e10cSrcweir nAdaptedDrawMode |= DRAWMODE_SETTINGSFILL; 1508cdf0e10cSrcweir } 1509cdf0e10cSrcweir else 1510cdf0e10cSrcweir { 1511cdf0e10cSrcweir nAdaptedDrawMode &= ~DRAWMODE_SETTINGSFILL; 1512cdf0e10cSrcweir } 1513cdf0e10cSrcweir 1514cdf0e10cSrcweir mpOutputDevice->SetDrawMode(nAdaptedDrawMode); 1515cdf0e10cSrcweir } 1516cdf0e10cSrcweir } 1517cdf0e10cSrcweir 1518cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 1519cdf0e10cSrcweir // process support 1520cdf0e10cSrcweir 1521cdf0e10cSrcweir VclProcessor2D::VclProcessor2D( 1522cdf0e10cSrcweir const geometry::ViewInformation2D& rViewInformation, 1523cdf0e10cSrcweir OutputDevice& rOutDev) 1524cdf0e10cSrcweir : BaseProcessor2D(rViewInformation), 1525cdf0e10cSrcweir mpOutputDevice(&rOutDev), 1526cdf0e10cSrcweir maBColorModifierStack(), 1527cdf0e10cSrcweir maCurrentTransformation(), 1528cdf0e10cSrcweir maDrawinglayerOpt(), 1529cdf0e10cSrcweir mnPolygonStrokePrimitive2D(0) 1530cdf0e10cSrcweir { 1531cdf0e10cSrcweir // set digit language, derived from SvtCTLOptions to have the correct 1532cdf0e10cSrcweir // number display for arabic/hindi numerals 1533cdf0e10cSrcweir const SvtCTLOptions aSvtCTLOptions; 1534cdf0e10cSrcweir LanguageType eLang(LANGUAGE_SYSTEM); 1535cdf0e10cSrcweir 1536cdf0e10cSrcweir if(SvtCTLOptions::NUMERALS_HINDI == aSvtCTLOptions.GetCTLTextNumerals()) 1537cdf0e10cSrcweir { 1538cdf0e10cSrcweir eLang = LANGUAGE_ARABIC_SAUDI_ARABIA; 1539cdf0e10cSrcweir } 1540cdf0e10cSrcweir else if(SvtCTLOptions::NUMERALS_ARABIC == aSvtCTLOptions.GetCTLTextNumerals()) 1541cdf0e10cSrcweir { 1542cdf0e10cSrcweir eLang = LANGUAGE_ENGLISH; 1543cdf0e10cSrcweir } 1544cdf0e10cSrcweir else 1545cdf0e10cSrcweir { 1546cdf0e10cSrcweir eLang = (LanguageType)Application::GetSettings().GetLanguage(); 1547cdf0e10cSrcweir } 1548cdf0e10cSrcweir 1549cdf0e10cSrcweir rOutDev.SetDigitLanguage(eLang); 1550cdf0e10cSrcweir } 1551cdf0e10cSrcweir 1552cdf0e10cSrcweir VclProcessor2D::~VclProcessor2D() 1553cdf0e10cSrcweir { 1554cdf0e10cSrcweir } 1555cdf0e10cSrcweir } // end of namespace processor2d 1556cdf0e10cSrcweir } // end of namespace drawinglayer 1557cdf0e10cSrcweir 1558cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 1559cdf0e10cSrcweir // eof 1560