1464702f4SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3464702f4SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4464702f4SAndrew Rist * or more contributor license agreements. See the NOTICE file 5464702f4SAndrew Rist * distributed with this work for additional information 6464702f4SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7464702f4SAndrew Rist * to you under the Apache License, Version 2.0 (the 8464702f4SAndrew Rist * "License"); you may not use this file except in compliance 9464702f4SAndrew Rist * with the License. You may obtain a copy of the License at 10464702f4SAndrew Rist * 11464702f4SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12464702f4SAndrew Rist * 13464702f4SAndrew Rist * Unless required by applicable law or agreed to in writing, 14464702f4SAndrew Rist * software distributed under the License is distributed on an 15464702f4SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16464702f4SAndrew Rist * KIND, either express or implied. See the License for the 17464702f4SAndrew Rist * specific language governing permissions and limitations 18464702f4SAndrew Rist * under the License. 19464702f4SAndrew Rist * 20464702f4SAndrew Rist *************************************************************/ 21464702f4SAndrew Rist 22464702f4SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_drawinglayer.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <drawinglayer/processor2d/vclpixelprocessor2d.hxx> 28cdf0e10cSrcweir #include <vcl/outdev.hxx> 29cdf0e10cSrcweir #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> 30cdf0e10cSrcweir #include <drawinglayer/primitive2d/textprimitive2d.hxx> 31cdf0e10cSrcweir #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> 32cdf0e10cSrcweir #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> 33cdf0e10cSrcweir #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> 34035a2f44SArmin Le Grand #include <drawinglayer/primitive2d/fillgraphicprimitive2d.hxx> 35cdf0e10cSrcweir #include <drawinglayer/primitive2d/metafileprimitive2d.hxx> 36cdf0e10cSrcweir #include <drawinglayer/primitive2d/maskprimitive2d.hxx> 37cdf0e10cSrcweir #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx> 38cdf0e10cSrcweir #include <drawinglayer/primitive2d/transparenceprimitive2d.hxx> 39cdf0e10cSrcweir #include <drawinglayer/primitive2d/transformprimitive2d.hxx> 40cdf0e10cSrcweir #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx> 41cdf0e10cSrcweir #include <drawinglayer/primitive2d/pointarrayprimitive2d.hxx> 42cdf0e10cSrcweir #include <drawinglayer/primitive2d/wrongspellprimitive2d.hxx> 43cdf0e10cSrcweir #include <drawinglayer/primitive2d/controlprimitive2d.hxx> 44cdf0e10cSrcweir #include <com/sun/star/awt/XWindow2.hpp> 45cdf0e10cSrcweir #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx> 46cdf0e10cSrcweir #include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx> 47cdf0e10cSrcweir #include <helperwrongspellrenderer.hxx> 48cdf0e10cSrcweir #include <drawinglayer/primitive2d/fillhatchprimitive2d.hxx> 49cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx> 50cdf0e10cSrcweir #include <vcl/hatch.hxx> 51cdf0e10cSrcweir #include <tools/diagnose_ex.h> 52cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp> 53cdf0e10cSrcweir #include <drawinglayer/primitive2d/invertprimitive2d.hxx> 54cdf0e10cSrcweir #include <cstdio> 55cdf0e10cSrcweir #include <drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx> 56cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrixtools.hxx> 57cdf0e10cSrcweir #include <drawinglayer/primitive2d/epsprimitive2d.hxx> 5839551d71SArmin Le Grand #include <drawinglayer/primitive2d/svggradientprimitive2d.hxx> 59cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 60cdf0e10cSrcweir #include <vcl/window.hxx> 61cdf0e10cSrcweir 62cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 63cdf0e10cSrcweir 64cdf0e10cSrcweir using namespace com::sun::star; 65cdf0e10cSrcweir 66cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 67cdf0e10cSrcweir 68cdf0e10cSrcweir namespace drawinglayer 69cdf0e10cSrcweir { 70cdf0e10cSrcweir namespace processor2d 71cdf0e10cSrcweir { 72cdf0e10cSrcweir VclPixelProcessor2D::VclPixelProcessor2D(const geometry::ViewInformation2D& rViewInformation, OutputDevice& rOutDev) 73401c91d1SArmin Le Grand : VclProcessor2D(rViewInformation, rOutDev) 74cdf0e10cSrcweir { 75cdf0e10cSrcweir // prepare maCurrentTransformation matrix with viewTransformation to target directly to pixels 76cdf0e10cSrcweir maCurrentTransformation = rViewInformation.getObjectToViewTransformation(); 77cdf0e10cSrcweir 78cdf0e10cSrcweir // prepare output directly to pixels 79cdf0e10cSrcweir mpOutputDevice->Push(PUSH_MAPMODE); 80cdf0e10cSrcweir mpOutputDevice->SetMapMode(); 81cdf0e10cSrcweir 82cdf0e10cSrcweir // react on AntiAliasing settings 83cdf0e10cSrcweir if(getOptionsDrawinglayer().IsAntiAliasing()) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir mpOutputDevice->SetAntialiasing(mpOutputDevice->GetAntialiasing() | ANTIALIASING_ENABLE_B2DDRAW); 86cdf0e10cSrcweir } 87cdf0e10cSrcweir else 88cdf0e10cSrcweir { 89cdf0e10cSrcweir mpOutputDevice->SetAntialiasing(mpOutputDevice->GetAntialiasing() & ~ANTIALIASING_ENABLE_B2DDRAW); 90cdf0e10cSrcweir } 91cdf0e10cSrcweir } 92cdf0e10cSrcweir 93cdf0e10cSrcweir VclPixelProcessor2D::~VclPixelProcessor2D() 94cdf0e10cSrcweir { 95cdf0e10cSrcweir // restore MapMode 96cdf0e10cSrcweir mpOutputDevice->Pop(); 97cdf0e10cSrcweir 98cdf0e10cSrcweir // restore AntiAliasing 99cdf0e10cSrcweir mpOutputDevice->SetAntialiasing(mpOutputDevice->GetAntialiasing() & ~ANTIALIASING_ENABLE_B2DDRAW); 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 102cdf0e10cSrcweir void VclPixelProcessor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir switch(rCandidate.getPrimitive2DID()) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D : 107cdf0e10cSrcweir { 108cdf0e10cSrcweir // directdraw of wrong spell primitive; added test possibility to check wrong spell decompose 109cdf0e10cSrcweir static bool bHandleWrongSpellDirectly(true); 110cdf0e10cSrcweir 111cdf0e10cSrcweir if(bHandleWrongSpellDirectly) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir const primitive2d::WrongSpellPrimitive2D& rWrongSpellPrimitive = static_cast< const primitive2d::WrongSpellPrimitive2D& >(rCandidate); 114cdf0e10cSrcweir 115cdf0e10cSrcweir if(!renderWrongSpellPrimitive2D( 116cdf0e10cSrcweir rWrongSpellPrimitive, 117cdf0e10cSrcweir *mpOutputDevice, 118cdf0e10cSrcweir maCurrentTransformation, 119cdf0e10cSrcweir maBColorModifierStack)) 120cdf0e10cSrcweir { 121cdf0e10cSrcweir // fallback to decomposition (MetaFile) 122cdf0e10cSrcweir process(rWrongSpellPrimitive.get2DDecomposition(getViewInformation2D())); 123cdf0e10cSrcweir } 124cdf0e10cSrcweir } 125cdf0e10cSrcweir else 126cdf0e10cSrcweir { 127cdf0e10cSrcweir process(rCandidate.get2DDecomposition(getViewInformation2D())); 128cdf0e10cSrcweir } 129cdf0e10cSrcweir break; 130cdf0e10cSrcweir } 131cdf0e10cSrcweir case PRIMITIVE2D_ID_TEXTSIMPLEPORTIONPRIMITIVE2D : 132cdf0e10cSrcweir { 133cdf0e10cSrcweir // directdraw of text simple portion; added test possibility to check text decompose 134cdf0e10cSrcweir static bool bForceSimpleTextDecomposition(false); 135cdf0e10cSrcweir 136cdf0e10cSrcweir // Adapt evtl. used special DrawMode 137cdf0e10cSrcweir const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode()); 138cdf0e10cSrcweir adaptTextToFillDrawMode(); 139cdf0e10cSrcweir 140cdf0e10cSrcweir if(!bForceSimpleTextDecomposition && getOptionsDrawinglayer().IsRenderSimpleTextDirect()) 141cdf0e10cSrcweir { 142cdf0e10cSrcweir RenderTextSimpleOrDecoratedPortionPrimitive2D(static_cast< const primitive2d::TextSimplePortionPrimitive2D& >(rCandidate)); 143cdf0e10cSrcweir } 144cdf0e10cSrcweir else 145cdf0e10cSrcweir { 146cdf0e10cSrcweir process(rCandidate.get2DDecomposition(getViewInformation2D())); 147cdf0e10cSrcweir } 148cdf0e10cSrcweir 149cdf0e10cSrcweir // restore DrawMode 150cdf0e10cSrcweir mpOutputDevice->SetDrawMode(nOriginalDrawMode); 151cdf0e10cSrcweir 152cdf0e10cSrcweir break; 153cdf0e10cSrcweir } 154cdf0e10cSrcweir case PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D : 155cdf0e10cSrcweir { 156cdf0e10cSrcweir // directdraw of text simple portion; added test possibility to check text decompose 157cdf0e10cSrcweir static bool bForceComplexTextDecomposition(false); 158cdf0e10cSrcweir 159cdf0e10cSrcweir // Adapt evtl. used special DrawMode 160cdf0e10cSrcweir const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode()); 161cdf0e10cSrcweir adaptTextToFillDrawMode(); 162cdf0e10cSrcweir 163cdf0e10cSrcweir if(!bForceComplexTextDecomposition && getOptionsDrawinglayer().IsRenderDecoratedTextDirect()) 164cdf0e10cSrcweir { 165cdf0e10cSrcweir RenderTextSimpleOrDecoratedPortionPrimitive2D(static_cast< const primitive2d::TextSimplePortionPrimitive2D& >(rCandidate)); 166cdf0e10cSrcweir } 167cdf0e10cSrcweir else 168cdf0e10cSrcweir { 169cdf0e10cSrcweir process(rCandidate.get2DDecomposition(getViewInformation2D())); 170cdf0e10cSrcweir } 171cdf0e10cSrcweir 172cdf0e10cSrcweir // restore DrawMode 173cdf0e10cSrcweir mpOutputDevice->SetDrawMode(nOriginalDrawMode); 174cdf0e10cSrcweir 175cdf0e10cSrcweir break; 176cdf0e10cSrcweir } 177cdf0e10cSrcweir case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D : 178cdf0e10cSrcweir { 179cdf0e10cSrcweir // direct draw of hairline 180cdf0e10cSrcweir RenderPolygonHairlinePrimitive2D(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate), true); 181cdf0e10cSrcweir break; 182cdf0e10cSrcweir } 183cdf0e10cSrcweir case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D : 184cdf0e10cSrcweir { 185cdf0e10cSrcweir // direct draw of transformed BitmapEx primitive 186cdf0e10cSrcweir RenderBitmapPrimitive2D(static_cast< const primitive2d::BitmapPrimitive2D& >(rCandidate)); 187cdf0e10cSrcweir break; 188cdf0e10cSrcweir } 189035a2f44SArmin Le Grand case PRIMITIVE2D_ID_FILLGRAPHICPRIMITIVE2D : 190cdf0e10cSrcweir { 191cdf0e10cSrcweir // direct draw of fillBitmapPrimitive 192035a2f44SArmin Le Grand RenderFillGraphicPrimitive2D(static_cast< const primitive2d::FillGraphicPrimitive2D& >(rCandidate)); 193cdf0e10cSrcweir break; 194cdf0e10cSrcweir } 195cdf0e10cSrcweir case PRIMITIVE2D_ID_POLYPOLYGONGRADIENTPRIMITIVE2D : 196cdf0e10cSrcweir { 197cdf0e10cSrcweir // direct draw of gradient 198*2af35ee2SArmin Le Grand const primitive2d::PolyPolygonGradientPrimitive2D& rPolygonCandidate = static_cast< const primitive2d::PolyPolygonGradientPrimitive2D& >(rCandidate); 199*2af35ee2SArmin Le Grand const attribute::FillGradientAttribute& rGradient(rPolygonCandidate.getFillGradient()); 200*2af35ee2SArmin Le Grand basegfx::BColor aStartColor(maBColorModifierStack.getModifiedColor(rGradient.getStartColor())); 201*2af35ee2SArmin Le Grand basegfx::BColor aEndColor(maBColorModifierStack.getModifiedColor(rGradient.getEndColor())); 202*2af35ee2SArmin Le Grand basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon()); 203*2af35ee2SArmin Le Grand 204*2af35ee2SArmin Le Grand if(aLocalPolyPolygon.count()) 205*2af35ee2SArmin Le Grand { 206*2af35ee2SArmin Le Grand aLocalPolyPolygon.transform(maCurrentTransformation); 207*2af35ee2SArmin Le Grand 208*2af35ee2SArmin Le Grand if(aStartColor == aEndColor) 209*2af35ee2SArmin Le Grand { 210*2af35ee2SArmin Le Grand // no gradient at all, draw as polygon in AA and non-AA case 211*2af35ee2SArmin Le Grand mpOutputDevice->SetLineColor(); 212*2af35ee2SArmin Le Grand mpOutputDevice->SetFillColor(Color(aStartColor)); 213*2af35ee2SArmin Le Grand mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon); 214*2af35ee2SArmin Le Grand } 215*2af35ee2SArmin Le Grand else 216*2af35ee2SArmin Le Grand { 217*2af35ee2SArmin Le Grand // use the primitive decomposition of the metafile 218*2af35ee2SArmin Le Grand process(rPolygonCandidate.get2DDecomposition(getViewInformation2D())); 219*2af35ee2SArmin Le Grand } 220*2af35ee2SArmin Le Grand } 221cdf0e10cSrcweir break; 222cdf0e10cSrcweir } 223035a2f44SArmin Le Grand case PRIMITIVE2D_ID_POLYPOLYGONGRAPHICPRIMITIVE2D : 224cdf0e10cSrcweir { 225cdf0e10cSrcweir // direct draw of bitmap 226035a2f44SArmin Le Grand RenderPolyPolygonGraphicPrimitive2D(static_cast< const primitive2d::PolyPolygonGraphicPrimitive2D& >(rCandidate)); 227cdf0e10cSrcweir break; 228cdf0e10cSrcweir } 229cdf0e10cSrcweir case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D : 230cdf0e10cSrcweir { 231cdf0e10cSrcweir // direct draw of PolyPolygon with color 232cdf0e10cSrcweir RenderPolyPolygonColorPrimitive2D(static_cast< const primitive2d::PolyPolygonColorPrimitive2D& >(rCandidate)); 233cdf0e10cSrcweir break; 234cdf0e10cSrcweir } 235cdf0e10cSrcweir case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D : 236cdf0e10cSrcweir { 237cdf0e10cSrcweir // #i98289# 238cdf0e10cSrcweir const bool bForceLineSnap(getOptionsDrawinglayer().IsAntiAliasing() && getOptionsDrawinglayer().IsSnapHorVerLinesToDiscrete()); 239cdf0e10cSrcweir const sal_uInt16 nOldAntiAliase(mpOutputDevice->GetAntialiasing()); 240cdf0e10cSrcweir 241cdf0e10cSrcweir if(bForceLineSnap) 242cdf0e10cSrcweir { 243cdf0e10cSrcweir mpOutputDevice->SetAntialiasing(nOldAntiAliase | ANTIALIASING_PIXELSNAPHAIRLINE); 244cdf0e10cSrcweir } 245cdf0e10cSrcweir 246*2af35ee2SArmin Le Grand // use new Metafile decomposition 247*2af35ee2SArmin Le Grand process(rCandidate.get2DDecomposition(getViewInformation2D())); 248cdf0e10cSrcweir 249cdf0e10cSrcweir if(bForceLineSnap) 250cdf0e10cSrcweir { 251cdf0e10cSrcweir mpOutputDevice->SetAntialiasing(nOldAntiAliase); 252cdf0e10cSrcweir } 253cdf0e10cSrcweir 254cdf0e10cSrcweir break; 255cdf0e10cSrcweir } 256cdf0e10cSrcweir case PRIMITIVE2D_ID_MASKPRIMITIVE2D : 257cdf0e10cSrcweir { 258cdf0e10cSrcweir // mask group. 259cdf0e10cSrcweir RenderMaskPrimitive2DPixel(static_cast< const primitive2d::MaskPrimitive2D& >(rCandidate)); 260cdf0e10cSrcweir break; 261cdf0e10cSrcweir } 262cdf0e10cSrcweir case PRIMITIVE2D_ID_MODIFIEDCOLORPRIMITIVE2D : 263cdf0e10cSrcweir { 264cdf0e10cSrcweir // modified color group. Force output to unified color. 265cdf0e10cSrcweir RenderModifiedColorPrimitive2D(static_cast< const primitive2d::ModifiedColorPrimitive2D& >(rCandidate)); 266cdf0e10cSrcweir break; 267cdf0e10cSrcweir } 268cdf0e10cSrcweir case PRIMITIVE2D_ID_UNIFIEDTRANSPARENCEPRIMITIVE2D : 269cdf0e10cSrcweir { 270cdf0e10cSrcweir // Detect if a single PolyPolygonColorPrimitive2D is contained; in that case, 271cdf0e10cSrcweir // use the faster OutputDevice::DrawTransparent method 272cdf0e10cSrcweir const primitive2d::UnifiedTransparencePrimitive2D& rUniTransparenceCandidate = static_cast< const primitive2d::UnifiedTransparencePrimitive2D& >(rCandidate); 273cdf0e10cSrcweir const primitive2d::Primitive2DSequence rContent = rUniTransparenceCandidate.getChildren(); 274cdf0e10cSrcweir 275cdf0e10cSrcweir if(rContent.hasElements()) 276cdf0e10cSrcweir { 277cdf0e10cSrcweir if(0.0 == rUniTransparenceCandidate.getTransparence()) 278cdf0e10cSrcweir { 279cdf0e10cSrcweir // not transparent at all, use content 280cdf0e10cSrcweir process(rUniTransparenceCandidate.getChildren()); 281cdf0e10cSrcweir } 282cdf0e10cSrcweir else if(rUniTransparenceCandidate.getTransparence() > 0.0 && rUniTransparenceCandidate.getTransparence() < 1.0) 283cdf0e10cSrcweir { 284cdf0e10cSrcweir bool bDrawTransparentUsed(false); 285cdf0e10cSrcweir 286cdf0e10cSrcweir // since DEV300 m33 DrawTransparent is supported in VCL (for some targets 287cdf0e10cSrcweir // natively), so i am now enabling this shortcut 288cdf0e10cSrcweir static bool bAllowUsingDrawTransparent(true); 289cdf0e10cSrcweir 290cdf0e10cSrcweir if(bAllowUsingDrawTransparent && 1 == rContent.getLength()) 291cdf0e10cSrcweir { 292cdf0e10cSrcweir const primitive2d::Primitive2DReference xReference(rContent[0]); 293cdf0e10cSrcweir const primitive2d::BasePrimitive2D* pBasePrimitive = dynamic_cast< const primitive2d::BasePrimitive2D* >(xReference.get()); 294cdf0e10cSrcweir 295cdf0e10cSrcweir if(pBasePrimitive) 296cdf0e10cSrcweir { 297cdf0e10cSrcweir switch(pBasePrimitive->getPrimitive2DID()) 298cdf0e10cSrcweir { 299cdf0e10cSrcweir case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D: 300cdf0e10cSrcweir { 301cdf0e10cSrcweir // single transparent PolyPolygon identified, use directly 302cdf0e10cSrcweir const primitive2d::PolyPolygonColorPrimitive2D* pPoPoColor = static_cast< const primitive2d::PolyPolygonColorPrimitive2D* >(pBasePrimitive); 303cdf0e10cSrcweir OSL_ENSURE(pPoPoColor, "OOps, PrimitiveID and PrimitiveType do not match (!)"); 304cdf0e10cSrcweir const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(pPoPoColor->getBColor())); 305cdf0e10cSrcweir mpOutputDevice->SetFillColor(Color(aPolygonColor)); 306cdf0e10cSrcweir mpOutputDevice->SetLineColor(); 307cdf0e10cSrcweir 308cdf0e10cSrcweir basegfx::B2DPolyPolygon aLocalPolyPolygon(pPoPoColor->getB2DPolyPolygon()); 309cdf0e10cSrcweir aLocalPolyPolygon.transform(maCurrentTransformation); 310cdf0e10cSrcweir 311cdf0e10cSrcweir mpOutputDevice->DrawTransparent(aLocalPolyPolygon, rUniTransparenceCandidate.getTransparence()); 312cdf0e10cSrcweir bDrawTransparentUsed = true; 313cdf0e10cSrcweir break; 314cdf0e10cSrcweir } 315cdf0e10cSrcweir // #i# need to wait for #i101378# which is in CWS vcl112 to directly paint transparent hairlines 316cdf0e10cSrcweir //case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D: 317cdf0e10cSrcweir //{ 318cdf0e10cSrcweir // // single transparent PolygonHairlinePrimitive2D identified, use directly 319cdf0e10cSrcweir // const primitive2d::PolygonHairlinePrimitive2D* pPoHair = static_cast< const primitive2d::PolygonHairlinePrimitive2D* >(pBasePrimitive); 320cdf0e10cSrcweir // OSL_ENSURE(pPoHair, "OOps, PrimitiveID and PrimitiveType do not match (!)"); 321cdf0e10cSrcweir // break; 322cdf0e10cSrcweir //} 323cdf0e10cSrcweir } 324cdf0e10cSrcweir } 325cdf0e10cSrcweir } 326cdf0e10cSrcweir 327cdf0e10cSrcweir if(!bDrawTransparentUsed) 328cdf0e10cSrcweir { 329cdf0e10cSrcweir // unified sub-transparence. Draw to VDev first. 330cdf0e10cSrcweir RenderUnifiedTransparencePrimitive2D(rUniTransparenceCandidate); 331cdf0e10cSrcweir } 332cdf0e10cSrcweir } 333cdf0e10cSrcweir } 334cdf0e10cSrcweir 335cdf0e10cSrcweir break; 336cdf0e10cSrcweir } 337cdf0e10cSrcweir case PRIMITIVE2D_ID_TRANSPARENCEPRIMITIVE2D : 338cdf0e10cSrcweir { 339cdf0e10cSrcweir // sub-transparence group. Draw to VDev first. 340cdf0e10cSrcweir RenderTransparencePrimitive2D(static_cast< const primitive2d::TransparencePrimitive2D& >(rCandidate)); 341cdf0e10cSrcweir break; 342cdf0e10cSrcweir } 343cdf0e10cSrcweir case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D : 344cdf0e10cSrcweir { 345cdf0e10cSrcweir // transform group. 346cdf0e10cSrcweir RenderTransformPrimitive2D(static_cast< const primitive2d::TransformPrimitive2D& >(rCandidate)); 347cdf0e10cSrcweir break; 348cdf0e10cSrcweir } 349cdf0e10cSrcweir case PRIMITIVE2D_ID_PAGEPREVIEWPRIMITIVE2D : 350cdf0e10cSrcweir { 351cdf0e10cSrcweir // new XDrawPage for ViewInformation2D 352cdf0e10cSrcweir RenderPagePreviewPrimitive2D(static_cast< const primitive2d::PagePreviewPrimitive2D& >(rCandidate)); 353cdf0e10cSrcweir break; 354cdf0e10cSrcweir } 355cdf0e10cSrcweir case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D : 356cdf0e10cSrcweir { 357cdf0e10cSrcweir // marker array 358cdf0e10cSrcweir RenderMarkerArrayPrimitive2D(static_cast< const primitive2d::MarkerArrayPrimitive2D& >(rCandidate)); 359cdf0e10cSrcweir break; 360cdf0e10cSrcweir } 361cdf0e10cSrcweir case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D : 362cdf0e10cSrcweir { 363cdf0e10cSrcweir // point array 364cdf0e10cSrcweir RenderPointArrayPrimitive2D(static_cast< const primitive2d::PointArrayPrimitive2D& >(rCandidate)); 365cdf0e10cSrcweir break; 366cdf0e10cSrcweir } 367cdf0e10cSrcweir case PRIMITIVE2D_ID_CONTROLPRIMITIVE2D : 368cdf0e10cSrcweir { 369cdf0e10cSrcweir // control primitive 370cdf0e10cSrcweir const primitive2d::ControlPrimitive2D& rControlPrimitive = static_cast< const primitive2d::ControlPrimitive2D& >(rCandidate); 371cdf0e10cSrcweir const uno::Reference< awt::XControl >& rXControl(rControlPrimitive.getXControl()); 372cdf0e10cSrcweir 373cdf0e10cSrcweir try 374cdf0e10cSrcweir { 375cdf0e10cSrcweir // remember old graphics and create new 376cdf0e10cSrcweir uno::Reference< awt::XView > xControlView(rXControl, uno::UNO_QUERY_THROW); 377cdf0e10cSrcweir const uno::Reference< awt::XGraphics > xOriginalGraphics(xControlView->getGraphics()); 378cdf0e10cSrcweir const uno::Reference< awt::XGraphics > xNewGraphics(mpOutputDevice->CreateUnoGraphics()); 379cdf0e10cSrcweir 380cdf0e10cSrcweir if(xNewGraphics.is()) 381cdf0e10cSrcweir { 382cdf0e10cSrcweir // link graphics and view 383cdf0e10cSrcweir xControlView->setGraphics(xNewGraphics); 384cdf0e10cSrcweir 385cdf0e10cSrcweir // get position 386cdf0e10cSrcweir const basegfx::B2DHomMatrix aObjectToPixel(maCurrentTransformation * rControlPrimitive.getTransform()); 387cdf0e10cSrcweir const basegfx::B2DPoint aTopLeftPixel(aObjectToPixel * basegfx::B2DPoint(0.0, 0.0)); 388cdf0e10cSrcweir 389cdf0e10cSrcweir // find out if the control is already visualized as a VCL-ChildWindow. If yes, 390cdf0e10cSrcweir // it does not need to be painted at all. 391cdf0e10cSrcweir uno::Reference< awt::XWindow2 > xControlWindow(rXControl, uno::UNO_QUERY_THROW); 392cdf0e10cSrcweir const bool bControlIsVisibleAsChildWindow(rXControl->getPeer().is() && xControlWindow->isVisible()); 393cdf0e10cSrcweir 394cdf0e10cSrcweir if(!bControlIsVisibleAsChildWindow) 395cdf0e10cSrcweir { 396cdf0e10cSrcweir // draw it. Do not forget to use the evtl. offsetted origin of the target device, 397cdf0e10cSrcweir // e.g. when used with mask/transparence buffer device 398cdf0e10cSrcweir const Point aOrigin(mpOutputDevice->GetMapMode().GetOrigin()); 399cdf0e10cSrcweir xControlView->draw( 400cdf0e10cSrcweir aOrigin.X() + basegfx::fround(aTopLeftPixel.getX()), 401cdf0e10cSrcweir aOrigin.Y() + basegfx::fround(aTopLeftPixel.getY())); 402cdf0e10cSrcweir } 403cdf0e10cSrcweir 404cdf0e10cSrcweir // restore original graphics 405cdf0e10cSrcweir xControlView->setGraphics(xOriginalGraphics); 406cdf0e10cSrcweir } 407cdf0e10cSrcweir } 408cdf0e10cSrcweir catch(const uno::Exception&) 409cdf0e10cSrcweir { 410cdf0e10cSrcweir // #i116763# removing since there is a good alternative when the xControlView 411cdf0e10cSrcweir // is not found and it is allowed to happen 412cdf0e10cSrcweir // DBG_UNHANDLED_EXCEPTION(); 413cdf0e10cSrcweir 414cdf0e10cSrcweir // process recursively and use the decomposition as Bitmap 415cdf0e10cSrcweir process(rCandidate.get2DDecomposition(getViewInformation2D())); 416cdf0e10cSrcweir } 417cdf0e10cSrcweir 418cdf0e10cSrcweir break; 419cdf0e10cSrcweir } 420cdf0e10cSrcweir case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D: 421cdf0e10cSrcweir { 422cdf0e10cSrcweir // the stroke primitive may be decomposed to filled polygons. To keep 423cdf0e10cSrcweir // evtl. set DrawModes aka DRAWMODE_BLACKLINE, DRAWMODE_GRAYLINE, 424cdf0e10cSrcweir // DRAWMODE_GHOSTEDLINE, DRAWMODE_WHITELINE or DRAWMODE_SETTINGSLINE 425cdf0e10cSrcweir // working, these need to be copied to the corresponding fill modes 426cdf0e10cSrcweir const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode()); 427cdf0e10cSrcweir adaptLineToFillDrawMode(); 428cdf0e10cSrcweir 429cdf0e10cSrcweir // polygon stroke primitive 430cdf0e10cSrcweir static bool bSuppressFatToHairlineCorrection(false); 431cdf0e10cSrcweir 432cdf0e10cSrcweir if(bSuppressFatToHairlineCorrection) 433cdf0e10cSrcweir { 434cdf0e10cSrcweir // remeber that we enter a PolygonStrokePrimitive2D decomposition, 435cdf0e10cSrcweir // used for AA thick line drawing 436cdf0e10cSrcweir mnPolygonStrokePrimitive2D++; 437cdf0e10cSrcweir 438cdf0e10cSrcweir // with AA there is no need to handle thin lines special 439cdf0e10cSrcweir process(rCandidate.get2DDecomposition(getViewInformation2D())); 440cdf0e10cSrcweir 441cdf0e10cSrcweir // leave PolygonStrokePrimitive2D 442cdf0e10cSrcweir mnPolygonStrokePrimitive2D--; 443cdf0e10cSrcweir } 444cdf0e10cSrcweir else 445cdf0e10cSrcweir { 446cdf0e10cSrcweir // Lines with 1 and 2 pixel width without AA need special treatment since their vsiualisation 447cdf0e10cSrcweir // as filled polygons is geometrically corret but looks wrong since polygon filling avoids 448cdf0e10cSrcweir // the right and bottom pixels. The used method evaluates that and takes the correct action, 449cdf0e10cSrcweir // including calling recursively with decomposition if line is wide enough 450cdf0e10cSrcweir const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokePrimitive = static_cast< const primitive2d::PolygonStrokePrimitive2D& >(rCandidate); 451cdf0e10cSrcweir 452cdf0e10cSrcweir RenderPolygonStrokePrimitive2D(rPolygonStrokePrimitive); 453cdf0e10cSrcweir } 454cdf0e10cSrcweir 455cdf0e10cSrcweir // restore DrawMode 456cdf0e10cSrcweir mpOutputDevice->SetDrawMode(nOriginalDrawMode); 457cdf0e10cSrcweir 458cdf0e10cSrcweir break; 459cdf0e10cSrcweir } 460cdf0e10cSrcweir case PRIMITIVE2D_ID_FILLHATCHPRIMITIVE2D : 461cdf0e10cSrcweir { 462cdf0e10cSrcweir static bool bForceIgnoreHatchSmoothing(false); 463cdf0e10cSrcweir 464cdf0e10cSrcweir if(bForceIgnoreHatchSmoothing || getOptionsDrawinglayer().IsAntiAliasing()) 465cdf0e10cSrcweir { 466cdf0e10cSrcweir // if AA is used (or ignore smoothing is on), there is no need to smooth 467cdf0e10cSrcweir // hatch painting, use decomposition 468cdf0e10cSrcweir process(rCandidate.get2DDecomposition(getViewInformation2D())); 469cdf0e10cSrcweir } 470cdf0e10cSrcweir else 471cdf0e10cSrcweir { 472cdf0e10cSrcweir // without AA, use VCL to draw the hatch. It snaps hatch distances to the next pixel 473cdf0e10cSrcweir // and forces hatch distance to be >= 3 pixels to make the hatch display look smoother. 474cdf0e10cSrcweir // This is wrong in principle, but looks nicer. This could also be done here directly 475cdf0e10cSrcweir // without VCL usage if needed 476cdf0e10cSrcweir const primitive2d::FillHatchPrimitive2D& rFillHatchPrimitive = static_cast< const primitive2d::FillHatchPrimitive2D& >(rCandidate); 477cdf0e10cSrcweir const attribute::FillHatchAttribute& rFillHatchAttributes = rFillHatchPrimitive.getFillHatch(); 478cdf0e10cSrcweir 479cdf0e10cSrcweir // create hatch polygon in range size and discrete coordinates 480cdf0e10cSrcweir basegfx::B2DRange aHatchRange(rFillHatchPrimitive.getObjectRange()); 481cdf0e10cSrcweir aHatchRange.transform(maCurrentTransformation); 482cdf0e10cSrcweir const basegfx::B2DPolygon aHatchPolygon(basegfx::tools::createPolygonFromRect(aHatchRange)); 483cdf0e10cSrcweir 484cdf0e10cSrcweir if(rFillHatchAttributes.isFillBackground()) 485cdf0e10cSrcweir { 486cdf0e10cSrcweir // #i111846# background fill is active; draw fill polygon 487cdf0e10cSrcweir const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rFillHatchPrimitive.getBColor())); 488cdf0e10cSrcweir 489cdf0e10cSrcweir mpOutputDevice->SetFillColor(Color(aPolygonColor)); 490cdf0e10cSrcweir mpOutputDevice->SetLineColor(); 491cdf0e10cSrcweir mpOutputDevice->DrawPolygon(aHatchPolygon); 492cdf0e10cSrcweir } 493cdf0e10cSrcweir 494cdf0e10cSrcweir // set hatch line color 495cdf0e10cSrcweir const basegfx::BColor aHatchColor(maBColorModifierStack.getModifiedColor(rFillHatchPrimitive.getBColor())); 496cdf0e10cSrcweir mpOutputDevice->SetFillColor(); 497cdf0e10cSrcweir mpOutputDevice->SetLineColor(Color(aHatchColor)); 498cdf0e10cSrcweir 499cdf0e10cSrcweir // get hatch style 500cdf0e10cSrcweir HatchStyle eHatchStyle(HATCH_SINGLE); 501cdf0e10cSrcweir 502cdf0e10cSrcweir switch(rFillHatchAttributes.getStyle()) 503cdf0e10cSrcweir { 504cdf0e10cSrcweir default : // HATCHSTYLE_SINGLE 505cdf0e10cSrcweir { 506cdf0e10cSrcweir break; 507cdf0e10cSrcweir } 508cdf0e10cSrcweir case attribute::HATCHSTYLE_DOUBLE : 509cdf0e10cSrcweir { 510cdf0e10cSrcweir eHatchStyle = HATCH_DOUBLE; 511cdf0e10cSrcweir break; 512cdf0e10cSrcweir } 513cdf0e10cSrcweir case attribute::HATCHSTYLE_TRIPLE : 514cdf0e10cSrcweir { 515cdf0e10cSrcweir eHatchStyle = HATCH_TRIPLE; 516cdf0e10cSrcweir break; 517cdf0e10cSrcweir } 518cdf0e10cSrcweir } 519cdf0e10cSrcweir 520cdf0e10cSrcweir // create hatch 521cdf0e10cSrcweir const basegfx::B2DVector aDiscreteDistance(maCurrentTransformation * basegfx::B2DVector(rFillHatchAttributes.getDistance(), 0.0)); 522cdf0e10cSrcweir const sal_uInt32 nDistance(basegfx::fround(aDiscreteDistance.getLength())); 523cdf0e10cSrcweir const sal_uInt16 nAngle10((sal_uInt16)basegfx::fround(rFillHatchAttributes.getAngle() / F_PI1800)); 524cdf0e10cSrcweir ::Hatch aVCLHatch(eHatchStyle, Color(rFillHatchAttributes.getColor()), nDistance, nAngle10); 525cdf0e10cSrcweir 526cdf0e10cSrcweir // draw hatch using VCL 527cdf0e10cSrcweir mpOutputDevice->DrawHatch(PolyPolygon(Polygon(aHatchPolygon)), aVCLHatch); 528cdf0e10cSrcweir } 529cdf0e10cSrcweir break; 530cdf0e10cSrcweir } 531cdf0e10cSrcweir case PRIMITIVE2D_ID_BACKGROUNDCOLORPRIMITIVE2D : 532cdf0e10cSrcweir { 533cdf0e10cSrcweir // #i98404# Handle directly, especially when AA is active 534cdf0e10cSrcweir const primitive2d::BackgroundColorPrimitive2D& rPrimitive = static_cast< const primitive2d::BackgroundColorPrimitive2D& >(rCandidate); 535cdf0e10cSrcweir const sal_uInt16 nOriginalAA(mpOutputDevice->GetAntialiasing()); 536cdf0e10cSrcweir 537cdf0e10cSrcweir // switch AA off in all cases 538cdf0e10cSrcweir mpOutputDevice->SetAntialiasing(mpOutputDevice->GetAntialiasing() & ~ANTIALIASING_ENABLE_B2DDRAW); 539cdf0e10cSrcweir 540cdf0e10cSrcweir // create color for fill 541cdf0e10cSrcweir const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rPrimitive.getBColor())); 542cdf0e10cSrcweir mpOutputDevice->SetFillColor(Color(aPolygonColor)); 543cdf0e10cSrcweir mpOutputDevice->SetLineColor(); 544cdf0e10cSrcweir 545cdf0e10cSrcweir // create rectangle for fill 546cdf0e10cSrcweir const basegfx::B2DRange& aViewport(getViewInformation2D().getDiscreteViewport()); 547cdf0e10cSrcweir const Rectangle aRectangle( 548cdf0e10cSrcweir (sal_Int32)floor(aViewport.getMinX()), (sal_Int32)floor(aViewport.getMinY()), 549cdf0e10cSrcweir (sal_Int32)ceil(aViewport.getMaxX()), (sal_Int32)ceil(aViewport.getMaxY())); 550cdf0e10cSrcweir mpOutputDevice->DrawRect(aRectangle); 551cdf0e10cSrcweir 552cdf0e10cSrcweir // restore AA setting 553cdf0e10cSrcweir mpOutputDevice->SetAntialiasing(nOriginalAA); 554cdf0e10cSrcweir break; 555cdf0e10cSrcweir } 556cdf0e10cSrcweir case PRIMITIVE2D_ID_TEXTHIERARCHYEDITPRIMITIVE2D : 557cdf0e10cSrcweir { 558cdf0e10cSrcweir // #i97628# 559cdf0e10cSrcweir // This primitive means that the content is derived from an active text edit, 560cdf0e10cSrcweir // not from model data itself. Some renderers need to suppress this content, e.g. 561cdf0e10cSrcweir // the pixel renderer used for displaying the edit view (like this one). It's 562cdf0e10cSrcweir // not to be suppressed by the MetaFile renderers, so that the edited text is 563cdf0e10cSrcweir // part of the MetaFile, e.g. needed for presentation previews. 564cdf0e10cSrcweir // Action: Ignore here, do nothing. 565cdf0e10cSrcweir break; 566cdf0e10cSrcweir } 567cdf0e10cSrcweir case PRIMITIVE2D_ID_INVERTPRIMITIVE2D : 568cdf0e10cSrcweir { 569cdf0e10cSrcweir // invert primitive (currently only used for HighContrast fallback for selection in SW and SC). 570cdf0e10cSrcweir // Set OutDev to XOR and switch AA off (XOR does not work with AA) 571cdf0e10cSrcweir mpOutputDevice->Push(); 572cdf0e10cSrcweir mpOutputDevice->SetRasterOp( ROP_XOR ); 573cdf0e10cSrcweir const sal_uInt16 nAntiAliasing(mpOutputDevice->GetAntialiasing()); 574cdf0e10cSrcweir mpOutputDevice->SetAntialiasing(nAntiAliasing & ~ANTIALIASING_ENABLE_B2DDRAW); 575cdf0e10cSrcweir 576cdf0e10cSrcweir // process content recursively 577cdf0e10cSrcweir process(rCandidate.get2DDecomposition(getViewInformation2D())); 578cdf0e10cSrcweir 579cdf0e10cSrcweir // restore OutDev 580cdf0e10cSrcweir mpOutputDevice->Pop(); 581cdf0e10cSrcweir mpOutputDevice->SetAntialiasing(nAntiAliasing); 582cdf0e10cSrcweir break; 583cdf0e10cSrcweir } 584cdf0e10cSrcweir case PRIMITIVE2D_ID_EPSPRIMITIVE2D : 585cdf0e10cSrcweir { 586cdf0e10cSrcweir RenderEpsPrimitive2D(static_cast< const primitive2d::EpsPrimitive2D& >(rCandidate)); 587cdf0e10cSrcweir break; 58839551d71SArmin Le Grand } 58939551d71SArmin Le Grand case PRIMITIVE2D_ID_SVGLINEARATOMPRIMITIVE2D: 59039551d71SArmin Le Grand { 59139551d71SArmin Le Grand RenderSvgLinearAtomPrimitive2D(static_cast< const primitive2d::SvgLinearAtomPrimitive2D& >(rCandidate)); 59239551d71SArmin Le Grand break; 59339551d71SArmin Le Grand } 59439551d71SArmin Le Grand case PRIMITIVE2D_ID_SVGRADIALATOMPRIMITIVE2D: 59539551d71SArmin Le Grand { 59639551d71SArmin Le Grand RenderSvgRadialAtomPrimitive2D(static_cast< const primitive2d::SvgRadialAtomPrimitive2D& >(rCandidate)); 59739551d71SArmin Le Grand break; 598cdf0e10cSrcweir } 599cdf0e10cSrcweir default : 600cdf0e10cSrcweir { 601cdf0e10cSrcweir // process recursively 602cdf0e10cSrcweir process(rCandidate.get2DDecomposition(getViewInformation2D())); 603cdf0e10cSrcweir break; 604cdf0e10cSrcweir } 605cdf0e10cSrcweir } 606cdf0e10cSrcweir } 607cdf0e10cSrcweir } // end of namespace processor2d 608cdf0e10cSrcweir } // end of namespace drawinglayer 609cdf0e10cSrcweir 610cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 611cdf0e10cSrcweir // eof 612