LCOV - code coverage report
Current view: top level - libreoffice/drawinglayer/source/processor2d - vclpixelprocessor2d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 34 187 18.2 %
Date: 2012-12-27 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10