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