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 { 185*cf95e506SArmin Le Grand // direct draw of transformed BitmapEx primitive 186*cf95e506SArmin Le Grand const primitive2d::BitmapPrimitive2D& rBitmapCandidate = static_cast< const primitive2d::BitmapPrimitive2D& >(rCandidate); 187*cf95e506SArmin Le Grand 188*cf95e506SArmin Le Grand // check if graphic content is inside discrete local ViewPort 189*cf95e506SArmin Le Grand const basegfx::B2DRange& rDiscreteViewPort(getViewInformation2D().getDiscreteViewport()); 190*cf95e506SArmin Le Grand const basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rBitmapCandidate.getTransform()); 191*cf95e506SArmin Le Grand 192*cf95e506SArmin Le Grand if(!rDiscreteViewPort.isEmpty()) 193*cf95e506SArmin Le Grand { 194*cf95e506SArmin Le Grand basegfx::B2DRange aUnitRange(0.0, 0.0, 1.0, 1.0); 195*cf95e506SArmin Le Grand 196*cf95e506SArmin Le Grand aUnitRange.transform(aLocalTransform); 197*cf95e506SArmin Le Grand 198*cf95e506SArmin Le Grand if(!aUnitRange.overlaps(rDiscreteViewPort)) 199*cf95e506SArmin Le Grand { 200*cf95e506SArmin Le Grand // content is outside discrete local ViewPort 201*cf95e506SArmin Le Grand break; 202*cf95e506SArmin Le Grand } 203*cf95e506SArmin Le Grand } 204*cf95e506SArmin Le Grand 205cdf0e10cSrcweir RenderBitmapPrimitive2D(static_cast< const primitive2d::BitmapPrimitive2D& >(rCandidate)); 206cdf0e10cSrcweir break; 207cdf0e10cSrcweir } 208035a2f44SArmin Le Grand case PRIMITIVE2D_ID_FILLGRAPHICPRIMITIVE2D : 209cdf0e10cSrcweir { 210cdf0e10cSrcweir // direct draw of fillBitmapPrimitive 211035a2f44SArmin Le Grand RenderFillGraphicPrimitive2D(static_cast< const primitive2d::FillGraphicPrimitive2D& >(rCandidate)); 212cdf0e10cSrcweir break; 213cdf0e10cSrcweir } 214cdf0e10cSrcweir case PRIMITIVE2D_ID_POLYPOLYGONGRADIENTPRIMITIVE2D : 215cdf0e10cSrcweir { 216cdf0e10cSrcweir // direct draw of gradient 2172af35ee2SArmin Le Grand const primitive2d::PolyPolygonGradientPrimitive2D& rPolygonCandidate = static_cast< const primitive2d::PolyPolygonGradientPrimitive2D& >(rCandidate); 2182af35ee2SArmin Le Grand const attribute::FillGradientAttribute& rGradient(rPolygonCandidate.getFillGradient()); 2192af35ee2SArmin Le Grand basegfx::BColor aStartColor(maBColorModifierStack.getModifiedColor(rGradient.getStartColor())); 2202af35ee2SArmin Le Grand basegfx::BColor aEndColor(maBColorModifierStack.getModifiedColor(rGradient.getEndColor())); 2212af35ee2SArmin Le Grand basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon()); 2222af35ee2SArmin Le Grand 2232af35ee2SArmin Le Grand if(aLocalPolyPolygon.count()) 2242af35ee2SArmin Le Grand { 2252af35ee2SArmin Le Grand aLocalPolyPolygon.transform(maCurrentTransformation); 2262af35ee2SArmin Le Grand 2272af35ee2SArmin Le Grand if(aStartColor == aEndColor) 2282af35ee2SArmin Le Grand { 2292af35ee2SArmin Le Grand // no gradient at all, draw as polygon in AA and non-AA case 2302af35ee2SArmin Le Grand mpOutputDevice->SetLineColor(); 2312af35ee2SArmin Le Grand mpOutputDevice->SetFillColor(Color(aStartColor)); 2322af35ee2SArmin Le Grand mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon); 2332af35ee2SArmin Le Grand } 2342af35ee2SArmin Le Grand else 2352af35ee2SArmin Le Grand { 2362af35ee2SArmin Le Grand // use the primitive decomposition of the metafile 2372af35ee2SArmin Le Grand process(rPolygonCandidate.get2DDecomposition(getViewInformation2D())); 2382af35ee2SArmin Le Grand } 2392af35ee2SArmin Le Grand } 240cdf0e10cSrcweir break; 241cdf0e10cSrcweir } 242035a2f44SArmin Le Grand case PRIMITIVE2D_ID_POLYPOLYGONGRAPHICPRIMITIVE2D : 243cdf0e10cSrcweir { 244cdf0e10cSrcweir // direct draw of bitmap 245035a2f44SArmin Le Grand RenderPolyPolygonGraphicPrimitive2D(static_cast< const primitive2d::PolyPolygonGraphicPrimitive2D& >(rCandidate)); 246cdf0e10cSrcweir break; 247cdf0e10cSrcweir } 248cdf0e10cSrcweir case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D : 249cdf0e10cSrcweir { 250cdf0e10cSrcweir // direct draw of PolyPolygon with color 251cdf0e10cSrcweir RenderPolyPolygonColorPrimitive2D(static_cast< const primitive2d::PolyPolygonColorPrimitive2D& >(rCandidate)); 252cdf0e10cSrcweir break; 253cdf0e10cSrcweir } 254cdf0e10cSrcweir case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D : 255cdf0e10cSrcweir { 256cdf0e10cSrcweir // #i98289# 257cdf0e10cSrcweir const bool bForceLineSnap(getOptionsDrawinglayer().IsAntiAliasing() && getOptionsDrawinglayer().IsSnapHorVerLinesToDiscrete()); 258cdf0e10cSrcweir const sal_uInt16 nOldAntiAliase(mpOutputDevice->GetAntialiasing()); 259cdf0e10cSrcweir 260cdf0e10cSrcweir if(bForceLineSnap) 261cdf0e10cSrcweir { 262cdf0e10cSrcweir mpOutputDevice->SetAntialiasing(nOldAntiAliase | ANTIALIASING_PIXELSNAPHAIRLINE); 263cdf0e10cSrcweir } 264cdf0e10cSrcweir 2652af35ee2SArmin Le Grand // use new Metafile decomposition 2662af35ee2SArmin Le Grand process(rCandidate.get2DDecomposition(getViewInformation2D())); 267cdf0e10cSrcweir 268cdf0e10cSrcweir if(bForceLineSnap) 269cdf0e10cSrcweir { 270cdf0e10cSrcweir mpOutputDevice->SetAntialiasing(nOldAntiAliase); 271cdf0e10cSrcweir } 272cdf0e10cSrcweir 273cdf0e10cSrcweir break; 274cdf0e10cSrcweir } 275cdf0e10cSrcweir case PRIMITIVE2D_ID_MASKPRIMITIVE2D : 276cdf0e10cSrcweir { 277cdf0e10cSrcweir // mask group. 278cdf0e10cSrcweir RenderMaskPrimitive2DPixel(static_cast< const primitive2d::MaskPrimitive2D& >(rCandidate)); 279cdf0e10cSrcweir break; 280cdf0e10cSrcweir } 281cdf0e10cSrcweir case PRIMITIVE2D_ID_MODIFIEDCOLORPRIMITIVE2D : 282cdf0e10cSrcweir { 283cdf0e10cSrcweir // modified color group. Force output to unified color. 284cdf0e10cSrcweir RenderModifiedColorPrimitive2D(static_cast< const primitive2d::ModifiedColorPrimitive2D& >(rCandidate)); 285cdf0e10cSrcweir break; 286cdf0e10cSrcweir } 287cdf0e10cSrcweir case PRIMITIVE2D_ID_UNIFIEDTRANSPARENCEPRIMITIVE2D : 288cdf0e10cSrcweir { 289cdf0e10cSrcweir // Detect if a single PolyPolygonColorPrimitive2D is contained; in that case, 290cdf0e10cSrcweir // use the faster OutputDevice::DrawTransparent method 291cdf0e10cSrcweir const primitive2d::UnifiedTransparencePrimitive2D& rUniTransparenceCandidate = static_cast< const primitive2d::UnifiedTransparencePrimitive2D& >(rCandidate); 292cdf0e10cSrcweir const primitive2d::Primitive2DSequence rContent = rUniTransparenceCandidate.getChildren(); 293cdf0e10cSrcweir 294cdf0e10cSrcweir if(rContent.hasElements()) 295cdf0e10cSrcweir { 296cdf0e10cSrcweir if(0.0 == rUniTransparenceCandidate.getTransparence()) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir // not transparent at all, use content 299cdf0e10cSrcweir process(rUniTransparenceCandidate.getChildren()); 300cdf0e10cSrcweir } 301cdf0e10cSrcweir else if(rUniTransparenceCandidate.getTransparence() > 0.0 && rUniTransparenceCandidate.getTransparence() < 1.0) 302cdf0e10cSrcweir { 303cdf0e10cSrcweir bool bDrawTransparentUsed(false); 304cdf0e10cSrcweir 305cdf0e10cSrcweir // since DEV300 m33 DrawTransparent is supported in VCL (for some targets 306cdf0e10cSrcweir // natively), so i am now enabling this shortcut 307cdf0e10cSrcweir static bool bAllowUsingDrawTransparent(true); 308cdf0e10cSrcweir 309cdf0e10cSrcweir if(bAllowUsingDrawTransparent && 1 == rContent.getLength()) 310cdf0e10cSrcweir { 311cdf0e10cSrcweir const primitive2d::Primitive2DReference xReference(rContent[0]); 312cdf0e10cSrcweir const primitive2d::BasePrimitive2D* pBasePrimitive = dynamic_cast< const primitive2d::BasePrimitive2D* >(xReference.get()); 313cdf0e10cSrcweir 314cdf0e10cSrcweir if(pBasePrimitive) 315cdf0e10cSrcweir { 316cdf0e10cSrcweir switch(pBasePrimitive->getPrimitive2DID()) 317cdf0e10cSrcweir { 318cdf0e10cSrcweir case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D: 319cdf0e10cSrcweir { 320cdf0e10cSrcweir // single transparent PolyPolygon identified, use directly 321cdf0e10cSrcweir const primitive2d::PolyPolygonColorPrimitive2D* pPoPoColor = static_cast< const primitive2d::PolyPolygonColorPrimitive2D* >(pBasePrimitive); 322cdf0e10cSrcweir OSL_ENSURE(pPoPoColor, "OOps, PrimitiveID and PrimitiveType do not match (!)"); 323cdf0e10cSrcweir const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(pPoPoColor->getBColor())); 324cdf0e10cSrcweir mpOutputDevice->SetFillColor(Color(aPolygonColor)); 325cdf0e10cSrcweir mpOutputDevice->SetLineColor(); 326cdf0e10cSrcweir 327cdf0e10cSrcweir basegfx::B2DPolyPolygon aLocalPolyPolygon(pPoPoColor->getB2DPolyPolygon()); 328cdf0e10cSrcweir aLocalPolyPolygon.transform(maCurrentTransformation); 329cdf0e10cSrcweir 330cdf0e10cSrcweir mpOutputDevice->DrawTransparent(aLocalPolyPolygon, rUniTransparenceCandidate.getTransparence()); 331cdf0e10cSrcweir bDrawTransparentUsed = true; 332cdf0e10cSrcweir break; 333cdf0e10cSrcweir } 334cdf0e10cSrcweir // #i# need to wait for #i101378# which is in CWS vcl112 to directly paint transparent hairlines 335cdf0e10cSrcweir //case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D: 336cdf0e10cSrcweir //{ 337cdf0e10cSrcweir // // single transparent PolygonHairlinePrimitive2D identified, use directly 338cdf0e10cSrcweir // const primitive2d::PolygonHairlinePrimitive2D* pPoHair = static_cast< const primitive2d::PolygonHairlinePrimitive2D* >(pBasePrimitive); 339cdf0e10cSrcweir // OSL_ENSURE(pPoHair, "OOps, PrimitiveID and PrimitiveType do not match (!)"); 340cdf0e10cSrcweir // break; 341cdf0e10cSrcweir //} 342cdf0e10cSrcweir } 343cdf0e10cSrcweir } 344cdf0e10cSrcweir } 345cdf0e10cSrcweir 346cdf0e10cSrcweir if(!bDrawTransparentUsed) 347cdf0e10cSrcweir { 348cdf0e10cSrcweir // unified sub-transparence. Draw to VDev first. 349cdf0e10cSrcweir RenderUnifiedTransparencePrimitive2D(rUniTransparenceCandidate); 350cdf0e10cSrcweir } 351cdf0e10cSrcweir } 352cdf0e10cSrcweir } 353cdf0e10cSrcweir 354cdf0e10cSrcweir break; 355cdf0e10cSrcweir } 356cdf0e10cSrcweir case PRIMITIVE2D_ID_TRANSPARENCEPRIMITIVE2D : 357cdf0e10cSrcweir { 358cdf0e10cSrcweir // sub-transparence group. Draw to VDev first. 359cdf0e10cSrcweir RenderTransparencePrimitive2D(static_cast< const primitive2d::TransparencePrimitive2D& >(rCandidate)); 360cdf0e10cSrcweir break; 361cdf0e10cSrcweir } 362cdf0e10cSrcweir case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D : 363cdf0e10cSrcweir { 364cdf0e10cSrcweir // transform group. 365cdf0e10cSrcweir RenderTransformPrimitive2D(static_cast< const primitive2d::TransformPrimitive2D& >(rCandidate)); 366cdf0e10cSrcweir break; 367cdf0e10cSrcweir } 368cdf0e10cSrcweir case PRIMITIVE2D_ID_PAGEPREVIEWPRIMITIVE2D : 369cdf0e10cSrcweir { 370cdf0e10cSrcweir // new XDrawPage for ViewInformation2D 371cdf0e10cSrcweir RenderPagePreviewPrimitive2D(static_cast< const primitive2d::PagePreviewPrimitive2D& >(rCandidate)); 372cdf0e10cSrcweir break; 373cdf0e10cSrcweir } 374cdf0e10cSrcweir case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D : 375cdf0e10cSrcweir { 376cdf0e10cSrcweir // marker array 377cdf0e10cSrcweir RenderMarkerArrayPrimitive2D(static_cast< const primitive2d::MarkerArrayPrimitive2D& >(rCandidate)); 378cdf0e10cSrcweir break; 379cdf0e10cSrcweir } 380cdf0e10cSrcweir case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D : 381cdf0e10cSrcweir { 382cdf0e10cSrcweir // point array 383cdf0e10cSrcweir RenderPointArrayPrimitive2D(static_cast< const primitive2d::PointArrayPrimitive2D& >(rCandidate)); 384cdf0e10cSrcweir break; 385cdf0e10cSrcweir } 386cdf0e10cSrcweir case PRIMITIVE2D_ID_CONTROLPRIMITIVE2D : 387cdf0e10cSrcweir { 388cdf0e10cSrcweir // control primitive 389cdf0e10cSrcweir const primitive2d::ControlPrimitive2D& rControlPrimitive = static_cast< const primitive2d::ControlPrimitive2D& >(rCandidate); 390cdf0e10cSrcweir const uno::Reference< awt::XControl >& rXControl(rControlPrimitive.getXControl()); 391cdf0e10cSrcweir 392cdf0e10cSrcweir try 393cdf0e10cSrcweir { 394cdf0e10cSrcweir // remember old graphics and create new 395cdf0e10cSrcweir uno::Reference< awt::XView > xControlView(rXControl, uno::UNO_QUERY_THROW); 396cdf0e10cSrcweir const uno::Reference< awt::XGraphics > xOriginalGraphics(xControlView->getGraphics()); 397cdf0e10cSrcweir const uno::Reference< awt::XGraphics > xNewGraphics(mpOutputDevice->CreateUnoGraphics()); 398cdf0e10cSrcweir 399cdf0e10cSrcweir if(xNewGraphics.is()) 400cdf0e10cSrcweir { 401cdf0e10cSrcweir // link graphics and view 402cdf0e10cSrcweir xControlView->setGraphics(xNewGraphics); 403cdf0e10cSrcweir 404cdf0e10cSrcweir // get position 405cdf0e10cSrcweir const basegfx::B2DHomMatrix aObjectToPixel(maCurrentTransformation * rControlPrimitive.getTransform()); 406cdf0e10cSrcweir const basegfx::B2DPoint aTopLeftPixel(aObjectToPixel * basegfx::B2DPoint(0.0, 0.0)); 407cdf0e10cSrcweir 408cdf0e10cSrcweir // find out if the control is already visualized as a VCL-ChildWindow. If yes, 409cdf0e10cSrcweir // it does not need to be painted at all. 410cdf0e10cSrcweir uno::Reference< awt::XWindow2 > xControlWindow(rXControl, uno::UNO_QUERY_THROW); 411cdf0e10cSrcweir const bool bControlIsVisibleAsChildWindow(rXControl->getPeer().is() && xControlWindow->isVisible()); 412cdf0e10cSrcweir 413cdf0e10cSrcweir if(!bControlIsVisibleAsChildWindow) 414cdf0e10cSrcweir { 415cdf0e10cSrcweir // draw it. Do not forget to use the evtl. offsetted origin of the target device, 416cdf0e10cSrcweir // e.g. when used with mask/transparence buffer device 417cdf0e10cSrcweir const Point aOrigin(mpOutputDevice->GetMapMode().GetOrigin()); 418cdf0e10cSrcweir xControlView->draw( 419cdf0e10cSrcweir aOrigin.X() + basegfx::fround(aTopLeftPixel.getX()), 420cdf0e10cSrcweir aOrigin.Y() + basegfx::fround(aTopLeftPixel.getY())); 421cdf0e10cSrcweir } 422cdf0e10cSrcweir 423cdf0e10cSrcweir // restore original graphics 424cdf0e10cSrcweir xControlView->setGraphics(xOriginalGraphics); 425cdf0e10cSrcweir } 426cdf0e10cSrcweir } 427cdf0e10cSrcweir catch(const uno::Exception&) 428cdf0e10cSrcweir { 429cdf0e10cSrcweir // #i116763# removing since there is a good alternative when the xControlView 430cdf0e10cSrcweir // is not found and it is allowed to happen 431cdf0e10cSrcweir // DBG_UNHANDLED_EXCEPTION(); 432cdf0e10cSrcweir 433cdf0e10cSrcweir // process recursively and use the decomposition as Bitmap 434cdf0e10cSrcweir process(rCandidate.get2DDecomposition(getViewInformation2D())); 435cdf0e10cSrcweir } 436cdf0e10cSrcweir 437cdf0e10cSrcweir break; 438cdf0e10cSrcweir } 439cdf0e10cSrcweir case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D: 440cdf0e10cSrcweir { 441cdf0e10cSrcweir // the stroke primitive may be decomposed to filled polygons. To keep 442cdf0e10cSrcweir // evtl. set DrawModes aka DRAWMODE_BLACKLINE, DRAWMODE_GRAYLINE, 443cdf0e10cSrcweir // DRAWMODE_GHOSTEDLINE, DRAWMODE_WHITELINE or DRAWMODE_SETTINGSLINE 444cdf0e10cSrcweir // working, these need to be copied to the corresponding fill modes 445cdf0e10cSrcweir const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode()); 446cdf0e10cSrcweir adaptLineToFillDrawMode(); 447cdf0e10cSrcweir 448cdf0e10cSrcweir // polygon stroke primitive 449cdf0e10cSrcweir static bool bSuppressFatToHairlineCorrection(false); 450cdf0e10cSrcweir 451cdf0e10cSrcweir if(bSuppressFatToHairlineCorrection) 452cdf0e10cSrcweir { 453cdf0e10cSrcweir // remeber that we enter a PolygonStrokePrimitive2D decomposition, 454cdf0e10cSrcweir // used for AA thick line drawing 455cdf0e10cSrcweir mnPolygonStrokePrimitive2D++; 456cdf0e10cSrcweir 457cdf0e10cSrcweir // with AA there is no need to handle thin lines special 458cdf0e10cSrcweir process(rCandidate.get2DDecomposition(getViewInformation2D())); 459cdf0e10cSrcweir 460cdf0e10cSrcweir // leave PolygonStrokePrimitive2D 461cdf0e10cSrcweir mnPolygonStrokePrimitive2D--; 462cdf0e10cSrcweir } 463cdf0e10cSrcweir else 464cdf0e10cSrcweir { 465cdf0e10cSrcweir // Lines with 1 and 2 pixel width without AA need special treatment since their vsiualisation 466cdf0e10cSrcweir // as filled polygons is geometrically corret but looks wrong since polygon filling avoids 467cdf0e10cSrcweir // the right and bottom pixels. The used method evaluates that and takes the correct action, 468cdf0e10cSrcweir // including calling recursively with decomposition if line is wide enough 469cdf0e10cSrcweir const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokePrimitive = static_cast< const primitive2d::PolygonStrokePrimitive2D& >(rCandidate); 470cdf0e10cSrcweir 471cdf0e10cSrcweir RenderPolygonStrokePrimitive2D(rPolygonStrokePrimitive); 472cdf0e10cSrcweir } 473cdf0e10cSrcweir 474cdf0e10cSrcweir // restore DrawMode 475cdf0e10cSrcweir mpOutputDevice->SetDrawMode(nOriginalDrawMode); 476cdf0e10cSrcweir 477cdf0e10cSrcweir break; 478cdf0e10cSrcweir } 479cdf0e10cSrcweir case PRIMITIVE2D_ID_FILLHATCHPRIMITIVE2D : 480cdf0e10cSrcweir { 481cdf0e10cSrcweir static bool bForceIgnoreHatchSmoothing(false); 482cdf0e10cSrcweir 483cdf0e10cSrcweir if(bForceIgnoreHatchSmoothing || getOptionsDrawinglayer().IsAntiAliasing()) 484cdf0e10cSrcweir { 485cdf0e10cSrcweir // if AA is used (or ignore smoothing is on), there is no need to smooth 486cdf0e10cSrcweir // hatch painting, use decomposition 487cdf0e10cSrcweir process(rCandidate.get2DDecomposition(getViewInformation2D())); 488cdf0e10cSrcweir } 489cdf0e10cSrcweir else 490cdf0e10cSrcweir { 491cdf0e10cSrcweir // without AA, use VCL to draw the hatch. It snaps hatch distances to the next pixel 492cdf0e10cSrcweir // and forces hatch distance to be >= 3 pixels to make the hatch display look smoother. 493cdf0e10cSrcweir // This is wrong in principle, but looks nicer. This could also be done here directly 494cdf0e10cSrcweir // without VCL usage if needed 495cdf0e10cSrcweir const primitive2d::FillHatchPrimitive2D& rFillHatchPrimitive = static_cast< const primitive2d::FillHatchPrimitive2D& >(rCandidate); 496cdf0e10cSrcweir const attribute::FillHatchAttribute& rFillHatchAttributes = rFillHatchPrimitive.getFillHatch(); 497cdf0e10cSrcweir 498cdf0e10cSrcweir // create hatch polygon in range size and discrete coordinates 499cdf0e10cSrcweir basegfx::B2DRange aHatchRange(rFillHatchPrimitive.getObjectRange()); 500cdf0e10cSrcweir aHatchRange.transform(maCurrentTransformation); 501cdf0e10cSrcweir const basegfx::B2DPolygon aHatchPolygon(basegfx::tools::createPolygonFromRect(aHatchRange)); 502cdf0e10cSrcweir 503cdf0e10cSrcweir if(rFillHatchAttributes.isFillBackground()) 504cdf0e10cSrcweir { 505cdf0e10cSrcweir // #i111846# background fill is active; draw fill polygon 506cdf0e10cSrcweir const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rFillHatchPrimitive.getBColor())); 507cdf0e10cSrcweir 508cdf0e10cSrcweir mpOutputDevice->SetFillColor(Color(aPolygonColor)); 509cdf0e10cSrcweir mpOutputDevice->SetLineColor(); 510cdf0e10cSrcweir mpOutputDevice->DrawPolygon(aHatchPolygon); 511cdf0e10cSrcweir } 512cdf0e10cSrcweir 513cdf0e10cSrcweir // set hatch line color 514cdf0e10cSrcweir const basegfx::BColor aHatchColor(maBColorModifierStack.getModifiedColor(rFillHatchPrimitive.getBColor())); 515cdf0e10cSrcweir mpOutputDevice->SetFillColor(); 516cdf0e10cSrcweir mpOutputDevice->SetLineColor(Color(aHatchColor)); 517cdf0e10cSrcweir 518cdf0e10cSrcweir // get hatch style 519cdf0e10cSrcweir HatchStyle eHatchStyle(HATCH_SINGLE); 520cdf0e10cSrcweir 521cdf0e10cSrcweir switch(rFillHatchAttributes.getStyle()) 522cdf0e10cSrcweir { 523cdf0e10cSrcweir default : // HATCHSTYLE_SINGLE 524cdf0e10cSrcweir { 525cdf0e10cSrcweir break; 526cdf0e10cSrcweir } 527cdf0e10cSrcweir case attribute::HATCHSTYLE_DOUBLE : 528cdf0e10cSrcweir { 529cdf0e10cSrcweir eHatchStyle = HATCH_DOUBLE; 530cdf0e10cSrcweir break; 531cdf0e10cSrcweir } 532cdf0e10cSrcweir case attribute::HATCHSTYLE_TRIPLE : 533cdf0e10cSrcweir { 534cdf0e10cSrcweir eHatchStyle = HATCH_TRIPLE; 535cdf0e10cSrcweir break; 536cdf0e10cSrcweir } 537cdf0e10cSrcweir } 538cdf0e10cSrcweir 539cdf0e10cSrcweir // create hatch 540cdf0e10cSrcweir const basegfx::B2DVector aDiscreteDistance(maCurrentTransformation * basegfx::B2DVector(rFillHatchAttributes.getDistance(), 0.0)); 541cdf0e10cSrcweir const sal_uInt32 nDistance(basegfx::fround(aDiscreteDistance.getLength())); 542cdf0e10cSrcweir const sal_uInt16 nAngle10((sal_uInt16)basegfx::fround(rFillHatchAttributes.getAngle() / F_PI1800)); 543cdf0e10cSrcweir ::Hatch aVCLHatch(eHatchStyle, Color(rFillHatchAttributes.getColor()), nDistance, nAngle10); 544cdf0e10cSrcweir 545cdf0e10cSrcweir // draw hatch using VCL 546cdf0e10cSrcweir mpOutputDevice->DrawHatch(PolyPolygon(Polygon(aHatchPolygon)), aVCLHatch); 547cdf0e10cSrcweir } 548cdf0e10cSrcweir break; 549cdf0e10cSrcweir } 550cdf0e10cSrcweir case PRIMITIVE2D_ID_BACKGROUNDCOLORPRIMITIVE2D : 551cdf0e10cSrcweir { 552cdf0e10cSrcweir // #i98404# Handle directly, especially when AA is active 553cdf0e10cSrcweir const primitive2d::BackgroundColorPrimitive2D& rPrimitive = static_cast< const primitive2d::BackgroundColorPrimitive2D& >(rCandidate); 554cdf0e10cSrcweir const sal_uInt16 nOriginalAA(mpOutputDevice->GetAntialiasing()); 555cdf0e10cSrcweir 556cdf0e10cSrcweir // switch AA off in all cases 557cdf0e10cSrcweir mpOutputDevice->SetAntialiasing(mpOutputDevice->GetAntialiasing() & ~ANTIALIASING_ENABLE_B2DDRAW); 558cdf0e10cSrcweir 559cdf0e10cSrcweir // create color for fill 560cdf0e10cSrcweir const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rPrimitive.getBColor())); 561cdf0e10cSrcweir mpOutputDevice->SetFillColor(Color(aPolygonColor)); 562cdf0e10cSrcweir mpOutputDevice->SetLineColor(); 563cdf0e10cSrcweir 564cdf0e10cSrcweir // create rectangle for fill 565cdf0e10cSrcweir const basegfx::B2DRange& aViewport(getViewInformation2D().getDiscreteViewport()); 566cdf0e10cSrcweir const Rectangle aRectangle( 567cdf0e10cSrcweir (sal_Int32)floor(aViewport.getMinX()), (sal_Int32)floor(aViewport.getMinY()), 568cdf0e10cSrcweir (sal_Int32)ceil(aViewport.getMaxX()), (sal_Int32)ceil(aViewport.getMaxY())); 569cdf0e10cSrcweir mpOutputDevice->DrawRect(aRectangle); 570cdf0e10cSrcweir 571cdf0e10cSrcweir // restore AA setting 572cdf0e10cSrcweir mpOutputDevice->SetAntialiasing(nOriginalAA); 573cdf0e10cSrcweir break; 574cdf0e10cSrcweir } 575cdf0e10cSrcweir case PRIMITIVE2D_ID_TEXTHIERARCHYEDITPRIMITIVE2D : 576cdf0e10cSrcweir { 577cdf0e10cSrcweir // #i97628# 578cdf0e10cSrcweir // This primitive means that the content is derived from an active text edit, 579cdf0e10cSrcweir // not from model data itself. Some renderers need to suppress this content, e.g. 580cdf0e10cSrcweir // the pixel renderer used for displaying the edit view (like this one). It's 581cdf0e10cSrcweir // not to be suppressed by the MetaFile renderers, so that the edited text is 582cdf0e10cSrcweir // part of the MetaFile, e.g. needed for presentation previews. 583cdf0e10cSrcweir // Action: Ignore here, do nothing. 584cdf0e10cSrcweir break; 585cdf0e10cSrcweir } 586cdf0e10cSrcweir case PRIMITIVE2D_ID_INVERTPRIMITIVE2D : 587cdf0e10cSrcweir { 588cdf0e10cSrcweir // invert primitive (currently only used for HighContrast fallback for selection in SW and SC). 589cdf0e10cSrcweir // Set OutDev to XOR and switch AA off (XOR does not work with AA) 590cdf0e10cSrcweir mpOutputDevice->Push(); 591cdf0e10cSrcweir mpOutputDevice->SetRasterOp( ROP_XOR ); 592cdf0e10cSrcweir const sal_uInt16 nAntiAliasing(mpOutputDevice->GetAntialiasing()); 593cdf0e10cSrcweir mpOutputDevice->SetAntialiasing(nAntiAliasing & ~ANTIALIASING_ENABLE_B2DDRAW); 594cdf0e10cSrcweir 595cdf0e10cSrcweir // process content recursively 596cdf0e10cSrcweir process(rCandidate.get2DDecomposition(getViewInformation2D())); 597cdf0e10cSrcweir 598cdf0e10cSrcweir // restore OutDev 599cdf0e10cSrcweir mpOutputDevice->Pop(); 600cdf0e10cSrcweir mpOutputDevice->SetAntialiasing(nAntiAliasing); 601cdf0e10cSrcweir break; 602cdf0e10cSrcweir } 603cdf0e10cSrcweir case PRIMITIVE2D_ID_EPSPRIMITIVE2D : 604cdf0e10cSrcweir { 605cdf0e10cSrcweir RenderEpsPrimitive2D(static_cast< const primitive2d::EpsPrimitive2D& >(rCandidate)); 606cdf0e10cSrcweir break; 60739551d71SArmin Le Grand } 60839551d71SArmin Le Grand case PRIMITIVE2D_ID_SVGLINEARATOMPRIMITIVE2D: 60939551d71SArmin Le Grand { 61039551d71SArmin Le Grand RenderSvgLinearAtomPrimitive2D(static_cast< const primitive2d::SvgLinearAtomPrimitive2D& >(rCandidate)); 61139551d71SArmin Le Grand break; 61239551d71SArmin Le Grand } 61339551d71SArmin Le Grand case PRIMITIVE2D_ID_SVGRADIALATOMPRIMITIVE2D: 61439551d71SArmin Le Grand { 61539551d71SArmin Le Grand RenderSvgRadialAtomPrimitive2D(static_cast< const primitive2d::SvgRadialAtomPrimitive2D& >(rCandidate)); 61639551d71SArmin Le Grand break; 617cdf0e10cSrcweir } 618cdf0e10cSrcweir default : 619cdf0e10cSrcweir { 620cdf0e10cSrcweir // process recursively 621cdf0e10cSrcweir process(rCandidate.get2DDecomposition(getViewInformation2D())); 622cdf0e10cSrcweir break; 623cdf0e10cSrcweir } 624cdf0e10cSrcweir } 625cdf0e10cSrcweir } 626cdf0e10cSrcweir } // end of namespace processor2d 627cdf0e10cSrcweir } // end of namespace drawinglayer 628cdf0e10cSrcweir 629cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 630cdf0e10cSrcweir // eof 631