LCOV - code coverage report
Current view: top level - drawinglayer/source/processor2d - vclpixelprocessor2d.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 418 491 85.1 %
Date: 2015-06-13 12:38:46 Functions: 11 11 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 "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/fillgraphicprimitive2d.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 <drawinglayer/primitive2d/borderlineprimitive2d.hxx>
      38             : #include <com/sun/star/awt/XWindow2.hpp>
      39             : #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
      40             : #include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx>
      41             : #include <helperwrongspellrenderer.hxx>
      42             : #include <drawinglayer/primitive2d/fillhatchprimitive2d.hxx>
      43             : #include <basegfx/polygon/b2dpolygontools.hxx>
      44             : #include <vcl/hatch.hxx>
      45             : #include <tools/diagnose_ex.h>
      46             : #include <com/sun/star/awt/PosSize.hpp>
      47             : #include <drawinglayer/primitive2d/invertprimitive2d.hxx>
      48             : #include <cstdio>
      49             : #include <drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx>
      50             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      51             : #include <drawinglayer/primitive2d/epsprimitive2d.hxx>
      52             : #include <drawinglayer/primitive2d/svggradientprimitive2d.hxx>
      53             : #include <toolkit/helper/vclunohelper.hxx>
      54             : #include <vcl/window.hxx>
      55             : #include <svtools/borderhelper.hxx>
      56             : 
      57             : #include <com/sun/star/table/BorderLineStyle.hpp>
      58             : 
      59             : 
      60             : 
      61             : using namespace com::sun::star;
      62             : 
      63             : namespace {
      64             : 
      65       19827 : basegfx::B2DPolygon makeRectPolygon( double fX, double fY, double fW, double fH )
      66             : {
      67       19827 :     basegfx::B2DPolygon aPoly;
      68       19827 :     aPoly.append(basegfx::B2DPoint(fX, fY));
      69       19827 :     aPoly.append(basegfx::B2DPoint(fX+fW, fY));
      70       19827 :     aPoly.append(basegfx::B2DPoint(fX+fW, fY+fH));
      71       19827 :     aPoly.append(basegfx::B2DPoint(fX, fY+fH));
      72       19827 :     aPoly.setClosed(true);
      73       19827 :     return aPoly;
      74             : }
      75             : 
      76       11773 : void drawHairLine(
      77             :     OutputDevice* pOutDev, double fX1, double fY1, double fX2, double fY2,
      78             :     const basegfx::BColor& rColor )
      79             : {
      80       11773 :     basegfx::B2DPolygon aTarget;
      81       11773 :     aTarget.append(basegfx::B2DPoint(fX1, fY1));
      82       11773 :     aTarget.append(basegfx::B2DPoint(fX2, fY2));
      83             : 
      84       11773 :     pOutDev->SetFillColor();
      85       11773 :     pOutDev->SetLineColor(Color(rColor));
      86       11773 :     pOutDev->DrawPolyLine(aTarget);
      87       11773 : }
      88             : 
      89             : }
      90             : 
      91             : namespace drawinglayer
      92             : {
      93             :     namespace processor2d
      94             :     {
      95             :         struct VclPixelProcessor2D::Impl
      96             :         {
      97             :             AntialiasingFlags m_nOrigAntiAliasing;
      98             : 
      99       40910 :             explicit Impl(OutputDevice const& rOutDev)
     100       40910 :                 : m_nOrigAntiAliasing(rOutDev.GetAntialiasing())
     101       40910 :             { }
     102             :         };
     103             : 
     104       40910 :         VclPixelProcessor2D::VclPixelProcessor2D(const geometry::ViewInformation2D& rViewInformation, OutputDevice& rOutDev)
     105             :             :   VclProcessor2D(rViewInformation, rOutDev)
     106       40910 :             ,   m_pImpl(new Impl(rOutDev))
     107             :         {
     108             :             // prepare maCurrentTransformation matrix with viewTransformation to target directly to pixels
     109       40910 :             maCurrentTransformation = rViewInformation.getObjectToViewTransformation();
     110             : 
     111             :             // prepare output directly to pixels
     112       40910 :                mpOutputDevice->Push(PushFlags::MAPMODE);
     113       40910 :             mpOutputDevice->SetMapMode();
     114             : 
     115             :             // react on AntiAliasing settings
     116       40910 :             if(getOptionsDrawinglayer().IsAntiAliasing())
     117             :             {
     118             :                 mpOutputDevice->SetAntialiasing(
     119           0 :                    m_pImpl->m_nOrigAntiAliasing | AntialiasingFlags::EnableB2dDraw);
     120             :             }
     121             :             else
     122             :             {
     123             :                 mpOutputDevice->SetAntialiasing(
     124       40910 :                    m_pImpl->m_nOrigAntiAliasing & ~AntialiasingFlags::EnableB2dDraw);
     125             :             }
     126       40910 :         }
     127             : 
     128      122730 :         VclPixelProcessor2D::~VclPixelProcessor2D()
     129             :         {
     130             :             // restore MapMode
     131       40910 :             mpOutputDevice->Pop();
     132             : 
     133             :             // restore AntiAliasing
     134       40910 :             mpOutputDevice->SetAntialiasing(m_pImpl->m_nOrigAntiAliasing);
     135       81820 :         }
     136             : 
     137      290885 :         bool VclPixelProcessor2D::tryDrawPolyPolygonColorPrimitive2DDirect(const drawinglayer::primitive2d::PolyPolygonColorPrimitive2D& rSource, double fTransparency)
     138             :         {
     139      290885 :             basegfx::B2DPolyPolygon aLocalPolyPolygon(rSource.getB2DPolyPolygon());
     140             : 
     141      290885 :             if(!aLocalPolyPolygon.count())
     142             :             {
     143             :                 // no geometry, done
     144           0 :                 return true;
     145             :             }
     146             : 
     147      581770 :             const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rSource.getBColor()));
     148             : 
     149      290885 :             mpOutputDevice->SetFillColor(Color(aPolygonColor));
     150      290885 :             mpOutputDevice->SetLineColor();
     151      290885 :             aLocalPolyPolygon.transform(maCurrentTransformation);
     152             :             mpOutputDevice->DrawTransparent(
     153             :                 aLocalPolyPolygon,
     154      290885 :                 fTransparency);
     155             : 
     156      581770 :             return true;
     157             :         }
     158             : 
     159       92403 :         bool VclPixelProcessor2D::tryDrawPolygonHairlinePrimitive2DDirect(const drawinglayer::primitive2d::PolygonHairlinePrimitive2D& rSource, double fTransparency)
     160             :         {
     161       92403 :             basegfx::B2DPolygon aLocalPolygon(rSource.getB2DPolygon());
     162             : 
     163       92403 :             if(!aLocalPolygon.count())
     164             :             {
     165             :                 // no geometry, done
     166           0 :                 return true;
     167             :             }
     168             : 
     169      184806 :             const basegfx::BColor aLineColor(maBColorModifierStack.getModifiedColor(rSource.getBColor()));
     170             : 
     171       92403 :             mpOutputDevice->SetFillColor();
     172       92403 :             mpOutputDevice->SetLineColor(Color(aLineColor));
     173       92403 :             aLocalPolygon.transform(maCurrentTransformation);
     174             : 
     175             :             // try drawing; if it did not work, use standard fallback
     176       92403 :             if(mpOutputDevice->DrawPolyLineDirect( aLocalPolygon, 0.0, fTransparency))
     177             :             {
     178           0 :                 return true;
     179             :             }
     180             : 
     181      184806 :             return false;
     182             :         }
     183             : 
     184       28308 :         bool VclPixelProcessor2D::tryDrawPolygonStrokePrimitive2DDirect(const drawinglayer::primitive2d::PolygonStrokePrimitive2D& rSource, double fTransparency)
     185             :         {
     186       28308 :             basegfx::B2DPolygon aLocalPolygon(rSource.getB2DPolygon());
     187             : 
     188       28308 :             if(!aLocalPolygon.count())
     189             :             {
     190             :                 // no geometry, done
     191           0 :                 return true;
     192             :             }
     193             : 
     194       28308 :             aLocalPolygon = basegfx::tools::simplifyCurveSegments(aLocalPolygon);
     195       56616 :             basegfx::B2DPolyPolygon aHairLinePolyPolygon;
     196             : 
     197       28308 :             if(rSource.getStrokeAttribute().isDefault() || 0.0 == rSource.getStrokeAttribute().getFullDotDashLen())
     198             :             {
     199             :                 // no line dashing, just copy
     200       27060 :                 aHairLinePolyPolygon.append(aLocalPolygon);
     201             :             }
     202             :             else
     203             :             {
     204             :                 // apply LineStyle
     205             :                 basegfx::tools::applyLineDashing(
     206             :                     aLocalPolygon,
     207        1248 :                     rSource.getStrokeAttribute().getDotDashArray(),
     208             :                     &aHairLinePolyPolygon,
     209             :                     0,
     210        2496 :                     rSource.getStrokeAttribute().getFullDotDashLen());
     211             :             }
     212             : 
     213       28308 :             if(!aHairLinePolyPolygon.count())
     214             :             {
     215             :                 // no geometry, done
     216           6 :                 return true;
     217             :             }
     218             : 
     219             :             const basegfx::BColor aLineColor(
     220             :                 maBColorModifierStack.getModifiedColor(
     221       56604 :                     rSource.getLineAttribute().getColor()));
     222             : 
     223       28302 :             mpOutputDevice->SetFillColor();
     224       28302 :             mpOutputDevice->SetLineColor(Color(aLineColor));
     225       28302 :             aHairLinePolyPolygon.transform(maCurrentTransformation);
     226             : 
     227       28302 :             double fLineWidth(rSource.getLineAttribute().getWidth());
     228             : 
     229       28302 :             if(basegfx::fTools::more(fLineWidth, 0.0))
     230             :             {
     231        7333 :                 basegfx::B2DVector aLineWidth(fLineWidth, 0.0);
     232             : 
     233        7333 :                 aLineWidth = maCurrentTransformation * aLineWidth;
     234        7333 :                 fLineWidth = aLineWidth.getLength();
     235             :             }
     236             : 
     237             :             // draw simple hairline for small line widths
     238             :             // see also RenderPolygonStrokePrimitive2D which is used if this try fails
     239       28302 :             bool bIsAntiAliasing = getOptionsDrawinglayer().IsAntiAliasing();
     240      134474 :             if (   (basegfx::fTools::lessOrEqual(fLineWidth, 1.0) && bIsAntiAliasing)
     241      141510 :                 || (basegfx::fTools::lessOrEqual(fLineWidth, 1.5) && !bIsAntiAliasing))
     242             :             {
     243             :                 // draw simple hairline
     244       21854 :                 fLineWidth = 0.0;
     245             :             }
     246             : 
     247       28302 :             bool bHasPoints(false);
     248       28302 :             bool bTryWorked(false);
     249             : 
     250      126483 :             for(sal_uInt32 a(0); a < aHairLinePolyPolygon.count(); a++)
     251             :             {
     252       98181 :                 const basegfx::B2DPolygon aSingle(aHairLinePolyPolygon.getB2DPolygon(a));
     253             : 
     254       98181 :                 if(aSingle.count())
     255             :                 {
     256       98181 :                     bHasPoints = true;
     257             : 
     258       98181 :                     if(mpOutputDevice->DrawPolyLineDirect(
     259             :                         aSingle,
     260             :                         fLineWidth,
     261             :                         fTransparency,
     262       98181 :                         rSource.getLineAttribute().getLineJoin(),
     263      196362 :                         rSource.getLineAttribute().getLineCap()))
     264             :                     {
     265           0 :                         bTryWorked = true;
     266             :                     }
     267             :                 }
     268       98181 :             }
     269             : 
     270       28302 :             if(!bTryWorked && !bHasPoints)
     271             :             {
     272             :                 // no geometry despite try
     273           0 :                 bTryWorked = true;
     274             :             }
     275             : 
     276       56610 :             return bTryWorked;
     277             :         }
     278             : 
     279       12455 :         bool VclPixelProcessor2D::tryDrawBorderLinePrimitive2DDirect(
     280             :             const drawinglayer::primitive2d::BorderLinePrimitive2D& rSource)
     281             :         {
     282       12455 :             const basegfx::B2DPoint& rS = rSource.getStart();
     283       12455 :             const basegfx::B2DPoint& rE = rSource.getEnd();
     284             : 
     285       12455 :             double fX1 = rS.getX();
     286       12455 :             double fY1 = rS.getY();
     287       12455 :             double fX2 = rE.getX();
     288       12455 :             double fY2 = rE.getY();
     289             : 
     290       12455 :             bool bHorizontal = false;
     291       12455 :             if (fX1 == fX2)
     292             :             {
     293             :                 // Vertical line.
     294             :             }
     295        6457 :             else if (fY1 == fY2)
     296             :             {
     297             :                 // Horizontal line.
     298        6457 :                 bHorizontal = true;
     299             :             }
     300             :             else
     301             :                 // Neither.  Bail out.
     302           0 :                 return false;
     303             : 
     304       12455 :             switch (rSource.getStyle())
     305             :             {
     306             :                 case table::BorderLineStyle::SOLID:
     307             :                 case table::BorderLineStyle::DOUBLE_THIN:
     308             :                 {
     309             :                     const basegfx::BColor aLineColor =
     310       12292 :                         maBColorModifierStack.getModifiedColor(rSource.getRGBColorLeft());
     311       12292 :                     double nThick = rtl::math::round(rSource.getLeftWidth());
     312             : 
     313       12292 :                     bool bDouble = rSource.getStyle() == table::BorderLineStyle::DOUBLE_THIN;
     314             : 
     315       24584 :                     basegfx::B2DPolygon aTarget;
     316             : 
     317       12292 :                     if (bHorizontal)
     318             :                     {
     319             :                         // Horizontal line.  Draw it as a rectangle.
     320             : 
     321        6362 :                         aTarget = makeRectPolygon(fX1, fY1, fX2-fX1, nThick);
     322        6362 :                         aTarget.transform(maCurrentTransformation);
     323             : 
     324        6362 :                         basegfx::B2DRange aRange = aTarget.getB2DRange();
     325        6362 :                         double fH = aRange.getHeight();
     326             : 
     327        6362 :                         if (bDouble)
     328             :                         {
     329             :                             // Double line
     330             :                             drawHairLine(
     331          44 :                                 mpOutputDevice, aRange.getMinX(), aRange.getMinY()-1.0, aRange.getMaxX(), aRange.getMinY()-1.0,
     332          44 :                                 aLineColor);
     333             : 
     334             :                             drawHairLine(
     335          44 :                                 mpOutputDevice, aRange.getMinX(), aRange.getMinY()+1.0, aRange.getMaxX(), aRange.getMinY()+1.0,
     336          44 :                                 aLineColor);
     337             : 
     338        6115 :                             return true;
     339             :                         }
     340             : 
     341        6340 :                         if (fH <= 1.0)
     342             :                         {
     343             :                             // Draw it as a line.
     344             :                             drawHairLine(
     345             :                                 mpOutputDevice, aRange.getMinX(), aRange.getMinY(), aRange.getMaxX(), aRange.getMinY(),
     346        6071 :                                 aLineColor);
     347             : 
     348        6071 :                             return true;
     349             :                         }
     350             : 
     351         269 :                         double fOffset = rtl::math::round(fH/2.0, 0, rtl_math_RoundingMode_Down);
     352         269 :                         if (fOffset != 0.0)
     353             :                         {
     354             :                             // Move it up a bit to align it vertically centered.
     355         176 :                             basegfx::B2DHomMatrix aMat;
     356         176 :                             aMat.set(1, 2, -fOffset);
     357         176 :                             aTarget.transform(aMat);
     358             :                         }
     359             :                     }
     360             :                     else
     361             :                     {
     362             :                         // Vertical line.  Draw it as a rectangle.
     363             : 
     364        5930 :                         aTarget = makeRectPolygon(fX1, fY1, nThick, fY2-fY1);
     365        5930 :                         aTarget.transform(maCurrentTransformation);
     366             : 
     367        5930 :                         basegfx::B2DRange aRange = aTarget.getB2DRange();
     368        5930 :                         double fW = aRange.getWidth();
     369             : 
     370        5930 :                         if (bDouble)
     371             :                         {
     372             :                             // Draw it as a line.
     373             :                             drawHairLine(
     374          44 :                                 mpOutputDevice, aRange.getMinX()-1.0, aRange.getMinY(), aRange.getMinX()-1.0, aRange.getMaxY(),
     375          66 :                                 aLineColor);
     376             : 
     377             :                             drawHairLine(
     378          44 :                                 mpOutputDevice, aRange.getMinX()+1.0, aRange.getMinY(), aRange.getMinX()+1.0, aRange.getMaxY(),
     379          66 :                                 aLineColor);
     380             : 
     381        5658 :                             return true;
     382             :                         }
     383             : 
     384        5908 :                         if (fW <= 1.0)
     385             :                         {
     386             :                             // Draw it as a line.
     387             :                             drawHairLine(
     388             :                                 mpOutputDevice, aRange.getMinX(), aRange.getMinY(), aRange.getMinX(), aRange.getMaxY(),
     389        5614 :                                 aLineColor);
     390             : 
     391        5614 :                             return true;
     392             :                         }
     393             : 
     394         294 :                         double fOffset = rtl::math::round(fW/2.0, 0, rtl_math_RoundingMode_Down);
     395         294 :                         if (fOffset != 0.0)
     396             :                         {
     397             :                             // Move it to the left a bit to center it horizontally.
     398         182 :                             basegfx::B2DHomMatrix aMat;
     399         182 :                             aMat.set(0, 2, -fOffset);
     400         182 :                             aTarget.transform(aMat);
     401             :                         }
     402             :                     }
     403             : 
     404         563 :                     mpOutputDevice->SetFillColor(Color(aLineColor));
     405         563 :                     mpOutputDevice->SetLineColor();
     406         563 :                     mpOutputDevice->DrawPolygon(aTarget);
     407       12855 :                     return true;
     408             :                 }
     409             :                 break;
     410             :                 case table::BorderLineStyle::DOTTED:
     411             :                 case table::BorderLineStyle::DASHED:
     412             :                 case table::BorderLineStyle::DASH_DOT:
     413             :                 case table::BorderLineStyle::DASH_DOT_DOT:
     414             :                 case table::BorderLineStyle::FINE_DASHED:
     415             :                 {
     416             :                     std::vector<double> aPattern =
     417          97 :                         svtools::GetLineDashing(rSource.getStyle(), rSource.getPatternScale()*10.0);
     418             : 
     419          97 :                     if (aPattern.empty())
     420             :                         // Failed to get pattern values.
     421           0 :                         return false;
     422             : 
     423          97 :                     double nThick = rtl::math::round(rSource.getLeftWidth());
     424             : 
     425             :                     const basegfx::BColor aLineColor =
     426         194 :                         maBColorModifierStack.getModifiedColor(rSource.getRGBColorLeft());
     427             : 
     428             :                     // Transform the current line range before using it for rendering.
     429          97 :                     basegfx::B2DRange aRange(fX1, fY1, fX2, fY2);
     430          97 :                     aRange.transform(maCurrentTransformation);
     431          97 :                     fX1 = aRange.getMinX();
     432          97 :                     fX2 = aRange.getMaxX();
     433          97 :                     fY1 = aRange.getMinY();
     434          97 :                     fY2 = aRange.getMaxY();
     435             : 
     436         194 :                     basegfx::B2DPolyPolygon aTarget;
     437             : 
     438          97 :                     if (bHorizontal)
     439             :                     {
     440             :                         // Horizontal line.
     441             : 
     442          61 :                         if (basegfx::fTools::equalZero(nThick))
     443             :                         {
     444             :                             // Dash line segment too small to draw.  Substitute it with a solid line.
     445           0 :                             drawHairLine(mpOutputDevice, fX1, fY1, fX2, fY1, aLineColor);
     446           0 :                             return true;
     447             :                         }
     448             : 
     449             :                         // Create a dash unit polygon set.
     450          61 :                         basegfx::B2DPolyPolygon aDashes;
     451          61 :                         std::vector<double>::const_iterator it = aPattern.begin(), itEnd = aPattern.end();
     452         183 :                         for (; it != itEnd; ++it)
     453         122 :                             aDashes.append(makeRectPolygon(0, 0, *it, nThick));
     454             : 
     455          61 :                         aDashes.transform(maCurrentTransformation);
     456          61 :                         rtl::math::setNan(&nThick);
     457             : 
     458             :                         // Pixelize the dash unit.  We use the same height for
     459             :                         // all dash polygons.
     460         122 :                         basegfx::B2DPolyPolygon aDashesPix;
     461             : 
     462         183 :                         for (sal_uInt32 i = 0, n = aDashes.count(); i < n; ++i)
     463             :                         {
     464         122 :                             basegfx::B2DPolygon aPoly = aDashes.getB2DPolygon(i);
     465         122 :                             aRange = aPoly.getB2DRange();
     466         122 :                             double fW = rtl::math::round(aRange.getWidth());
     467         122 :                             if (basegfx::fTools::equalZero(fW))
     468             :                             {
     469             :                                 // Dash line segment too small to draw.  Substitute it with a solid line.
     470           0 :                                 drawHairLine(mpOutputDevice, fX1, fY1, fX2, fY1, aLineColor);
     471           0 :                                 return true;
     472             :                             }
     473             : 
     474         122 :                             if (rtl::math::isNan(nThick))
     475          61 :                                 nThick = rtl::math::round(aRange.getHeight());
     476             : 
     477         122 :                             aDashesPix.append(makeRectPolygon(0, 0, fW, nThick));
     478         122 :                         }
     479             : 
     480             :                         // Make all dash polygons and render them.
     481          61 :                         double fX = fX1;
     482          61 :                         bool bLine = true;
     483          61 :                         sal_uInt32 i = 0, n = aDashesPix.count();
     484       13501 :                         while (fX <= fX2)
     485             :                         {
     486       13379 :                             basegfx::B2DPolygon aPoly = aDashesPix.getB2DPolygon(i);
     487       13379 :                             aRange = aPoly.getB2DRange();
     488       13379 :                             if (bLine)
     489             :                             {
     490        6712 :                                 double fBlockW = aRange.getWidth();
     491        6712 :                                 if (fX + fBlockW > fX2)
     492             :                                     // Clip the right end in case it spills over the range.
     493          45 :                                     fBlockW = fX2 - fX + 1;
     494             : 
     495        6712 :                                 double fH = aRange.getHeight();
     496        6712 :                                 if (basegfx::fTools::equalZero(fH))
     497          96 :                                     fH = 1.0;
     498             : 
     499        6712 :                                 aTarget.append(makeRectPolygon(fX, fY1, fBlockW, fH));
     500             :                             }
     501             : 
     502       13379 :                             bLine = !bLine; // line and blank alternate.
     503       13379 :                             fX += aRange.getWidth();
     504             : 
     505       13379 :                             ++i;
     506       13379 :                             if (i >= n)
     507        6667 :                                 i = 0;
     508       13379 :                         }
     509             : 
     510          61 :                         double fOffset = rtl::math::round(nThick/2.0, 0, rtl_math_RoundingMode_Down);
     511          61 :                         if (fOffset != 0.0)
     512             :                         {
     513             :                             // Move it up a bit to align it vertically centered.
     514          44 :                             basegfx::B2DHomMatrix aMat;
     515          44 :                             aMat.set(1, 2, -fOffset);
     516          44 :                             aTarget.transform(aMat);
     517          61 :                         }
     518             :                     }
     519             :                     else
     520             :                     {
     521             :                         // Vertical line.
     522             : 
     523          36 :                         if (basegfx::fTools::equalZero(nThick))
     524             :                         {
     525             :                             // Dash line segment too small to draw.  Substitute it with a solid line.
     526           0 :                             drawHairLine(mpOutputDevice, fX1, fY1, fX1, fY2, aLineColor);
     527           0 :                             return true;
     528             :                         }
     529             : 
     530             :                         // Create a dash unit polygon set.
     531          36 :                         basegfx::B2DPolyPolygon aDashes;
     532          36 :                         std::vector<double>::const_iterator it = aPattern.begin(), itEnd = aPattern.end();
     533         108 :                         for (; it != itEnd; ++it)
     534          72 :                             aDashes.append(makeRectPolygon(0, 0, nThick, *it));
     535             : 
     536          36 :                         aDashes.transform(maCurrentTransformation);
     537          36 :                         rtl::math::setNan(&nThick);
     538             : 
     539             :                         // Pixelize the dash unit.  We use the same width for
     540             :                         // all dash polygons.
     541          72 :                         basegfx::B2DPolyPolygon aDashesPix;
     542             : 
     543         108 :                         for (sal_uInt32 i = 0, n = aDashes.count(); i < n; ++i)
     544             :                         {
     545          72 :                             basegfx::B2DPolygon aPoly = aDashes.getB2DPolygon(i);
     546          72 :                             aRange = aPoly.getB2DRange();
     547          72 :                             double fH = rtl::math::round(aRange.getHeight());
     548          72 :                             if (basegfx::fTools::equalZero(fH))
     549             :                             {
     550             :                                 // Dash line segment too small to draw.  Substitute it with a solid line.
     551           0 :                                 drawHairLine(mpOutputDevice, fX1, fY1, fX1, fY2, aLineColor);
     552           0 :                                 return true;
     553             :                             }
     554             : 
     555          72 :                             if (rtl::math::isNan(nThick))
     556          36 :                                 nThick = rtl::math::round(aRange.getWidth());
     557             : 
     558          72 :                             aDashesPix.append(makeRectPolygon(0, 0, nThick, fH));
     559          72 :                         }
     560             : 
     561             :                         // Make all dash polygons and render them.
     562          36 :                         double fY = fY1;
     563          36 :                         bool bLine = true;
     564          36 :                         sal_uInt32 i = 0, n = aDashesPix.count();
     565         922 :                         while (fY <= fY2)
     566             :                         {
     567         850 :                             basegfx::B2DPolygon aPoly = aDashesPix.getB2DPolygon(i);
     568         850 :                             aRange = aPoly.getB2DRange();
     569         850 :                             if (bLine)
     570             :                             {
     571         435 :                                 double fBlockH = aRange.getHeight();
     572         435 :                                 if (fY + fBlockH > fY2)
     573             :                                     // Clip the bottom end in case it spills over the range.
     574          20 :                                     fBlockH = fY2 - fY + 1;
     575             : 
     576         435 :                                 double fW = aRange.getWidth();
     577         435 :                                 if (basegfx::fTools::equalZero(fW))
     578           0 :                                     fW = 1.0;
     579             : 
     580         435 :                                 aTarget.append(makeRectPolygon(fX1, fY, fW, fBlockH));
     581             :                             }
     582             : 
     583         850 :                             bLine = !bLine; // line and blank alternate.
     584         850 :                             fY += aRange.getHeight();
     585             : 
     586         850 :                             ++i;
     587         850 :                             if (i >= n)
     588         415 :                                 i = 0;
     589         850 :                         }
     590             : 
     591          36 :                         double fOffset = rtl::math::round(nThick/2.0, 0, rtl_math_RoundingMode_Down);
     592          36 :                         if (fOffset != 0.0)
     593             :                         {
     594             :                             // Move it to the left a bit to center it horizontally.
     595          30 :                             basegfx::B2DHomMatrix aMat;
     596          30 :                             aMat.set(0, 2, -fOffset);
     597          30 :                             aTarget.transform(aMat);
     598          36 :                         }
     599             :                     }
     600             : 
     601          97 :                     mpOutputDevice->SetFillColor(Color(aLineColor));
     602          97 :                     mpOutputDevice->SetLineColor();
     603          97 :                     mpOutputDevice->DrawPolyPolygon(aTarget);
     604             : 
     605         194 :                     return true;
     606             :                 }
     607             :                 break;
     608             :                 default:
     609             :                     ;
     610             :             }
     611          66 :             return false;
     612             :         }
     613             : 
     614      652135 :         void VclPixelProcessor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate)
     615             :         {
     616      652135 :             switch(rCandidate.getPrimitive2DID())
     617             :             {
     618             :                 case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D :
     619             :                 {
     620             :                     // directdraw of wrong spell primitive; added test possibility to check wrong spell decompose
     621             :                     static bool bHandleWrongSpellDirectly(true);
     622             : 
     623           0 :                     if(bHandleWrongSpellDirectly)
     624             :                     {
     625           0 :                         const primitive2d::WrongSpellPrimitive2D& rWrongSpellPrimitive = static_cast< const primitive2d::WrongSpellPrimitive2D& >(rCandidate);
     626             : 
     627           0 :                         if(!renderWrongSpellPrimitive2D(
     628             :                             rWrongSpellPrimitive,
     629           0 :                             *mpOutputDevice,
     630             :                             maCurrentTransformation,
     631           0 :                             maBColorModifierStack))
     632             :                         {
     633             :                             // fallback to decomposition (MetaFile)
     634           0 :                             process(rWrongSpellPrimitive.get2DDecomposition(getViewInformation2D()));
     635             :                         }
     636             :                     }
     637             :                     else
     638             :                     {
     639           0 :                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
     640             :                     }
     641           0 :                     break;
     642             :                 }
     643             :                 case PRIMITIVE2D_ID_TEXTSIMPLEPORTIONPRIMITIVE2D :
     644             :                 {
     645             :                     // directdraw of text simple portion; added test possibility to check text decompose
     646             :                     static bool bForceSimpleTextDecomposition(false);
     647             : 
     648             :                     // Adapt evtl. used special DrawMode
     649       13454 :                     const DrawModeFlags nOriginalDrawMode(mpOutputDevice->GetDrawMode());
     650       13454 :                     adaptTextToFillDrawMode();
     651             : 
     652       13454 :                     if(!bForceSimpleTextDecomposition && getOptionsDrawinglayer().IsRenderSimpleTextDirect())
     653             :                     {
     654       13454 :                         RenderTextSimpleOrDecoratedPortionPrimitive2D(static_cast< const primitive2d::TextSimplePortionPrimitive2D& >(rCandidate));
     655             :                     }
     656             :                     else
     657             :                     {
     658           0 :                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
     659             :                     }
     660             : 
     661             :                     // restore DrawMode
     662       13454 :                     mpOutputDevice->SetDrawMode(nOriginalDrawMode);
     663             : 
     664       13454 :                     break;
     665             :                 }
     666             :                 case PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D :
     667             :                 {
     668             :                     // directdraw of decorated text portion; added test possibility to check text decompose
     669             :                     static bool bForceComplexTextDecomposition(false);
     670             : 
     671             :                     // Adapt evtl. used special DrawMode
     672        3227 :                     const DrawModeFlags nOriginalDrawMode(mpOutputDevice->GetDrawMode());
     673        3227 :                     adaptTextToFillDrawMode();
     674             : 
     675        3227 :                     if(!bForceComplexTextDecomposition && getOptionsDrawinglayer().IsRenderDecoratedTextDirect())
     676             :                     {
     677        3227 :                         RenderTextSimpleOrDecoratedPortionPrimitive2D(static_cast< const primitive2d::TextSimplePortionPrimitive2D& >(rCandidate));
     678             :                     }
     679             :                     else
     680             :                     {
     681           0 :                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
     682             :                     }
     683             : 
     684             :                     // restore DrawMode
     685        3227 :                     mpOutputDevice->SetDrawMode(nOriginalDrawMode);
     686             : 
     687        3227 :                     break;
     688             :                 }
     689             :                 case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D :
     690             :                 {
     691             :                     // try to use directly
     692       92403 :                     const primitive2d::PolygonHairlinePrimitive2D& rPolygonHairlinePrimitive2D = static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate);
     693             :                     static bool bAllowed(true);
     694             : 
     695       92403 :                     if(bAllowed && tryDrawPolygonHairlinePrimitive2DDirect(rPolygonHairlinePrimitive2D, 0.0))
     696             :                     {
     697           0 :                         break;
     698             :                     }
     699             : 
     700             :                     // direct draw of hairline
     701       92403 :                     RenderPolygonHairlinePrimitive2D(rPolygonHairlinePrimitive2D, true);
     702       92403 :                     break;
     703             :                 }
     704             :                 case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D :
     705             :                 {
     706             :                     // direct draw of transformed BitmapEx primitive
     707        7295 :                     const primitive2d::BitmapPrimitive2D& rBitmapCandidate = static_cast< const primitive2d::BitmapPrimitive2D& >(rCandidate);
     708             : 
     709             :                     // check if graphic content is inside discrete local ViewPort
     710        7295 :                     const basegfx::B2DRange& rDiscreteViewPort(getViewInformation2D().getDiscreteViewport());
     711        7295 :                     const basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rBitmapCandidate.getTransform());
     712             : 
     713        7295 :                     if(!rDiscreteViewPort.isEmpty())
     714             :                     {
     715        6875 :                         basegfx::B2DRange aUnitRange(0.0, 0.0, 1.0, 1.0);
     716             : 
     717        6875 :                         aUnitRange.transform(aLocalTransform);
     718             : 
     719        6875 :                         if(!aUnitRange.overlaps(rDiscreteViewPort))
     720             :                         {
     721             :                             // content is outside discrete local ViewPort
     722        4534 :                             break;
     723             :                         }
     724             :                     }
     725             : 
     726        2761 :                     RenderBitmapPrimitive2D(static_cast< const primitive2d::BitmapPrimitive2D& >(rCandidate));
     727        2761 :                     break;
     728             :                 }
     729             :                 case PRIMITIVE2D_ID_FILLGRAPHICPRIMITIVE2D :
     730             :                 {
     731             :                     // direct draw of fillBitmapPrimitive
     732         295 :                     RenderFillGraphicPrimitive2D(static_cast< const primitive2d::FillGraphicPrimitive2D& >(rCandidate));
     733         295 :                     break;
     734             :                 }
     735             :                 case PRIMITIVE2D_ID_POLYPOLYGONGRADIENTPRIMITIVE2D :
     736             :                 {
     737             :                     // direct draw of gradient
     738         305 :                     const primitive2d::PolyPolygonGradientPrimitive2D& rPolygonCandidate = static_cast< const primitive2d::PolyPolygonGradientPrimitive2D& >(rCandidate);
     739         305 :                     const attribute::FillGradientAttribute& rGradient(rPolygonCandidate.getFillGradient());
     740         305 :                     basegfx::BColor aStartColor(maBColorModifierStack.getModifiedColor(rGradient.getStartColor()));
     741         610 :                     basegfx::BColor aEndColor(maBColorModifierStack.getModifiedColor(rGradient.getEndColor()));
     742         610 :                     basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon());
     743             : 
     744         305 :                     if(aLocalPolyPolygon.count())
     745             :                     {
     746         305 :                         aLocalPolyPolygon.transform(maCurrentTransformation);
     747             : 
     748         305 :                         if(aStartColor == aEndColor)
     749             :                         {
     750             :                             // no gradient at all, draw as polygon in AA and non-AA case
     751          38 :                             mpOutputDevice->SetLineColor();
     752          38 :                             mpOutputDevice->SetFillColor(Color(aStartColor));
     753          38 :                             mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon);
     754             :                         }
     755             :                         else
     756             :                         {
     757             :                             // use the primitive decomposition of the metafile
     758         267 :                             process(rPolygonCandidate.get2DDecomposition(getViewInformation2D()));
     759             :                         }
     760             :                     }
     761         610 :                     break;
     762             :                 }
     763             :                 case PRIMITIVE2D_ID_POLYPOLYGONGRAPHICPRIMITIVE2D :
     764             :                 {
     765             :                     // direct draw of bitmap
     766         295 :                     RenderPolyPolygonGraphicPrimitive2D(static_cast< const primitive2d::PolyPolygonGraphicPrimitive2D& >(rCandidate));
     767         295 :                     break;
     768             :                 }
     769             :                 case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D :
     770             :                 {
     771             :                     // try to use directly
     772      290114 :                     const primitive2d::PolyPolygonColorPrimitive2D& rPolyPolygonColorPrimitive2D = static_cast< const primitive2d::PolyPolygonColorPrimitive2D& >(rCandidate);
     773      290114 :                     basegfx::B2DPolyPolygon aLocalPolyPolygon;
     774             :                     static bool bAllowed(true);
     775             : 
     776      290114 :                     if(bAllowed && tryDrawPolyPolygonColorPrimitive2DDirect(rPolyPolygonColorPrimitive2D, 0.0))
     777             :                     {
     778             :                         // okay, done. In this case no gaps should have to be repaired, too
     779             :                     }
     780             :                     else
     781             :                     {
     782             :                         // direct draw of tools::PolyPolygon with color
     783           0 :                         const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rPolyPolygonColorPrimitive2D.getBColor()));
     784             : 
     785           0 :                         mpOutputDevice->SetFillColor(Color(aPolygonColor));
     786           0 :                         mpOutputDevice->SetLineColor();
     787           0 :                         aLocalPolyPolygon = rPolyPolygonColorPrimitive2D.getB2DPolyPolygon();
     788           0 :                         aLocalPolyPolygon.transform(maCurrentTransformation);
     789           0 :                         mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon);
     790             :                     }
     791             : 
     792             :                     // when AA is on and this filled polygons are the result of stroked line geometry,
     793             :                     // draw the geometry once extra as lines to avoid AA 'gaps' between partial polygons
     794             :                     // Caution: This is needed in both cases (!)
     795      870342 :                     if(mnPolygonStrokePrimitive2D
     796       38138 :                         && getOptionsDrawinglayer().IsAntiAliasing()
     797      580228 :                         && (mpOutputDevice->GetAntialiasing() & AntialiasingFlags::EnableB2dDraw))
     798             :                     {
     799           0 :                         const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rPolyPolygonColorPrimitive2D.getBColor()));
     800           0 :                         sal_uInt32 nCount(aLocalPolyPolygon.count());
     801             : 
     802           0 :                         if(!nCount)
     803             :                         {
     804           0 :                             aLocalPolyPolygon = rPolyPolygonColorPrimitive2D.getB2DPolyPolygon();
     805           0 :                             aLocalPolyPolygon.transform(maCurrentTransformation);
     806           0 :                             nCount = aLocalPolyPolygon.count();
     807             :                         }
     808             : 
     809           0 :                         mpOutputDevice->SetFillColor();
     810           0 :                         mpOutputDevice->SetLineColor(Color(aPolygonColor));
     811             : 
     812           0 :                         for(sal_uInt32 a(0); a < nCount; a++)
     813             :                         {
     814           0 :                             mpOutputDevice->DrawPolyLine(aLocalPolyPolygon.getB2DPolygon(a), 0.0);
     815           0 :                         }
     816             :                     }
     817             : 
     818      290114 :                     break;
     819             :                 }
     820             :                 case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D :
     821             :                 {
     822             :                     // #i98289#
     823          40 :                     const bool bForceLineSnap(getOptionsDrawinglayer().IsAntiAliasing() && getOptionsDrawinglayer().IsSnapHorVerLinesToDiscrete());
     824          40 :                     const AntialiasingFlags nOldAntiAliase(mpOutputDevice->GetAntialiasing());
     825             : 
     826          40 :                     if(bForceLineSnap)
     827             :                     {
     828           0 :                         mpOutputDevice->SetAntialiasing(nOldAntiAliase | AntialiasingFlags::PixelSnapHairline);
     829             :                     }
     830             : 
     831          40 :                     const primitive2d::MetafilePrimitive2D& rMetafilePrimitive( static_cast< const primitive2d::MetafilePrimitive2D& >(rCandidate) );
     832             : 
     833             :                     static bool bTestMetaFilePrimitiveDecomposition( true );
     834          40 :                     if( bTestMetaFilePrimitiveDecomposition && !rMetafilePrimitive.getMetaFile().GetUseCanvas() )
     835             :                     {
     836             :                         // use new Metafile decomposition
     837             :                         // TODO EMF+ stuffed into METACOMMENT support required
     838          39 :                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
     839             :                     }
     840             :                     else
     841             :                     {
     842             :                         // direct draw of MetaFile
     843           1 :                         RenderMetafilePrimitive2D( rMetafilePrimitive );
     844             :                     }
     845             : 
     846          40 :                     if(bForceLineSnap)
     847             :                     {
     848           0 :                         mpOutputDevice->SetAntialiasing(nOldAntiAliase);
     849             :                     }
     850             : 
     851          40 :                     break;
     852             :                 }
     853             :                 case PRIMITIVE2D_ID_MASKPRIMITIVE2D :
     854             :                 {
     855             :                     // mask group.
     856        4516 :                     RenderMaskPrimitive2DPixel(static_cast< const primitive2d::MaskPrimitive2D& >(rCandidate));
     857        4516 :                     break;
     858             :                 }
     859             :                 case PRIMITIVE2D_ID_MODIFIEDCOLORPRIMITIVE2D :
     860             :                 {
     861             :                     // modified color group. Force output to unified color.
     862        1571 :                     RenderModifiedColorPrimitive2D(static_cast< const primitive2d::ModifiedColorPrimitive2D& >(rCandidate));
     863        1571 :                     break;
     864             :                 }
     865             :                 case PRIMITIVE2D_ID_UNIFIEDTRANSPARENCEPRIMITIVE2D :
     866             :                 {
     867             :                     // Detect if a single PolyPolygonColorPrimitive2D is contained; in that case,
     868             :                     // use the faster OutputDevice::DrawTransparent method
     869        1753 :                     const primitive2d::UnifiedTransparencePrimitive2D& rUniTransparenceCandidate = static_cast< const primitive2d::UnifiedTransparencePrimitive2D& >(rCandidate);
     870        1753 :                     const primitive2d::Primitive2DSequence rContent = rUniTransparenceCandidate.getChildren();
     871             : 
     872        1753 :                     if(rContent.hasElements())
     873             :                     {
     874        1753 :                         if(0.0 == rUniTransparenceCandidate.getTransparence())
     875             :                         {
     876             :                             // not transparent at all, use content
     877           0 :                             process(rUniTransparenceCandidate.getChildren());
     878             :                         }
     879        1753 :                         else if(rUniTransparenceCandidate.getTransparence() > 0.0 && rUniTransparenceCandidate.getTransparence() < 1.0)
     880             :                         {
     881        1753 :                             bool bDrawTransparentUsed(false);
     882             : 
     883             :                             // since DEV300 m33 DrawTransparent is supported in VCL (for some targets
     884             :                             // natively), so i am now enabling this shortcut
     885             :                             static bool bAllowUsingDrawTransparent(true);
     886             : 
     887        1753 :                             if(bAllowUsingDrawTransparent && 1 == rContent.getLength())
     888             :                             {
     889        1685 :                                 const primitive2d::Primitive2DReference xReference(rContent[0]);
     890        1685 :                                 const primitive2d::BasePrimitive2D* pBasePrimitive = dynamic_cast< const primitive2d::BasePrimitive2D* >(xReference.get());
     891             : 
     892        1685 :                                 if(pBasePrimitive)
     893             :                                 {
     894        1685 :                                     switch(pBasePrimitive->getPrimitive2DID())
     895             :                                     {
     896             :                                         case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D:
     897             :                                         {
     898             :                                             // single transparent tools::PolyPolygon identified, use directly
     899         771 :                                             const primitive2d::PolyPolygonColorPrimitive2D* pPoPoColor = static_cast< const primitive2d::PolyPolygonColorPrimitive2D* >(pBasePrimitive);
     900             :                                             OSL_ENSURE(pPoPoColor, "OOps, PrimitiveID and PrimitiveType do not match (!)");
     901         771 :                                             bDrawTransparentUsed = tryDrawPolyPolygonColorPrimitive2DDirect(*pPoPoColor, rUniTransparenceCandidate.getTransparence());
     902         771 :                                             break;
     903             :                                         }
     904             :                                         case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D:
     905             :                                         {
     906             :                                             // single transparent PolygonHairlinePrimitive2D identified, use directly
     907           0 :                                             const primitive2d::PolygonHairlinePrimitive2D* pPoHair = static_cast< const primitive2d::PolygonHairlinePrimitive2D* >(pBasePrimitive);
     908             :                                             OSL_ENSURE(pPoHair, "OOps, PrimitiveID and PrimitiveType do not match (!)");
     909             : 
     910             :                                             // do no tallow by default - problem is that self-overlapping parts of this geometry will
     911             :                                             // not be in a all-same transparency but will already alpha-cover themselves with blending.
     912             :                                             // This is not what the UnifiedTransparencePrimitive2D defines: It requires all its
     913             :                                             // content to be uniformely transparent.
     914             :                                             // For hairline the effect is pretty minimal, but still not correct.
     915             :                                             static bool bAllowed(false);
     916             : 
     917           0 :                                             bDrawTransparentUsed = bAllowed && tryDrawPolygonHairlinePrimitive2DDirect(*pPoHair, rUniTransparenceCandidate.getTransparence());
     918           0 :                                             break;
     919             :                                         }
     920             :                                         case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D:
     921             :                                         {
     922             :                                             // single transparent PolygonStrokePrimitive2D identified, use directly
     923         164 :                                             const primitive2d::PolygonStrokePrimitive2D* pPoStroke = static_cast< const primitive2d::PolygonStrokePrimitive2D* >(pBasePrimitive);
     924             :                                             OSL_ENSURE(pPoStroke, "OOps, PrimitiveID and PrimitiveType do not match (!)");
     925             : 
     926             :                                             // do no tallow by default - problem is that self-overlapping parts of this geometry will
     927             :                                             // not be in a all-same transparency but will already alpha-cover themselves with blending.
     928             :                                             // This is not what the UnifiedTransparencePrimitive2D defines: It requires all its
     929             :                                             // content to be uniformely transparent.
     930             :                                             // To check, acitvate and draw a wide transparent self-crossing line/curve
     931             :                                             static bool bAllowed(false);
     932             : 
     933         164 :                                             bDrawTransparentUsed = bAllowed && tryDrawPolygonStrokePrimitive2DDirect(*pPoStroke, rUniTransparenceCandidate.getTransparence());
     934         164 :                                             break;
     935             :                                         }
     936             :                                     default:
     937             :                                         SAL_INFO("drawinglayer", "default case for " << drawinglayer::primitive2d::idToString(rCandidate.getPrimitive2DID()));
     938         750 :                                         break;
     939             :                                     }
     940        1685 :                                 }
     941             :                             }
     942             : 
     943        1753 :                             if(!bDrawTransparentUsed)
     944             :                             {
     945             :                                 // unified sub-transparence. Draw to VDev first.
     946         982 :                                 RenderUnifiedTransparencePrimitive2D(rUniTransparenceCandidate);
     947             :                             }
     948             :                         }
     949             :                     }
     950             : 
     951        1753 :                     break;
     952             :                 }
     953             :                 case PRIMITIVE2D_ID_TRANSPARENCEPRIMITIVE2D :
     954             :                 {
     955             :                     // sub-transparence group. Draw to VDev first.
     956        1798 :                     RenderTransparencePrimitive2D(static_cast< const primitive2d::TransparencePrimitive2D& >(rCandidate));
     957        1798 :                     break;
     958             :                 }
     959             :                 case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D :
     960             :                 {
     961             :                     // transform group.
     962        9688 :                     RenderTransformPrimitive2D(static_cast< const primitive2d::TransformPrimitive2D& >(rCandidate));
     963        9688 :                     break;
     964             :                 }
     965             :                 case PRIMITIVE2D_ID_PAGEPREVIEWPRIMITIVE2D :
     966             :                 {
     967             :                     // new XDrawPage for ViewInformation2D
     968           0 :                     RenderPagePreviewPrimitive2D(static_cast< const primitive2d::PagePreviewPrimitive2D& >(rCandidate));
     969           0 :                     break;
     970             :                 }
     971             :                 case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D :
     972             :                 {
     973             :                     // marker array
     974           0 :                     RenderMarkerArrayPrimitive2D(static_cast< const primitive2d::MarkerArrayPrimitive2D& >(rCandidate));
     975           0 :                     break;
     976             :                 }
     977             :                 case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D :
     978             :                 {
     979             :                     // point array
     980           0 :                     RenderPointArrayPrimitive2D(static_cast< const primitive2d::PointArrayPrimitive2D& >(rCandidate));
     981           0 :                     break;
     982             :                 }
     983             :                 case PRIMITIVE2D_ID_CONTROLPRIMITIVE2D :
     984             :                 {
     985             :                     // control primitive
     986        7576 :                     const primitive2d::ControlPrimitive2D& rControlPrimitive = static_cast< const primitive2d::ControlPrimitive2D& >(rCandidate);
     987        7576 :                     const uno::Reference< awt::XControl >& rXControl(rControlPrimitive.getXControl());
     988             : 
     989             :                     try
     990             :                     {
     991             :                         // remember old graphics and create new
     992        7576 :                         uno::Reference< awt::XView > xControlView(rXControl, uno::UNO_QUERY_THROW);
     993        9688 :                         const uno::Reference< awt::XGraphics > xOriginalGraphics(xControlView->getGraphics());
     994        9688 :                         const uno::Reference< awt::XGraphics > xNewGraphics(mpOutputDevice->CreateUnoGraphics());
     995             : 
     996        4844 :                         if(xNewGraphics.is())
     997             :                         {
     998             :                             // link graphics and view
     999        4844 :                             xControlView->setGraphics(xNewGraphics);
    1000             : 
    1001             :                             // get position
    1002        4844 :                             const basegfx::B2DHomMatrix aObjectToPixel(maCurrentTransformation * rControlPrimitive.getTransform());
    1003        9688 :                             const basegfx::B2DPoint aTopLeftPixel(aObjectToPixel * basegfx::B2DPoint(0.0, 0.0));
    1004             : 
    1005             :                             // find out if the control is already visualized as a VCL-ChildWindow. If yes,
    1006             :                             // it does not need to be painted at all.
    1007        9688 :                             uno::Reference< awt::XWindow2 > xControlWindow(rXControl, uno::UNO_QUERY_THROW);
    1008        4844 :                             const bool bControlIsVisibleAsChildWindow(rXControl->getPeer().is() && xControlWindow->isVisible());
    1009             : 
    1010        4844 :                             if(!bControlIsVisibleAsChildWindow)
    1011             :                             {
    1012             :                                 // draw it. Do not forget to use the evtl. offsetted origin of the target device,
    1013             :                                 // e.g. when used with mask/transparence buffer device
    1014        4593 :                                 const Point aOrigin(mpOutputDevice->GetMapMode().GetOrigin());
    1015        4593 :                                 xControlView->draw(
    1016        9186 :                                     aOrigin.X() + basegfx::fround(aTopLeftPixel.getX()),
    1017       13779 :                                     aOrigin.Y() + basegfx::fround(aTopLeftPixel.getY()));
    1018             :                             }
    1019             : 
    1020             :                             // restore original graphics
    1021        9688 :                             xControlView->setGraphics(xOriginalGraphics);
    1022        4844 :                         }
    1023             :                     }
    1024        2732 :                     catch(const uno::Exception&)
    1025             :                     {
    1026             :                         // #i116763# removing since there is a good alternative when the xControlView
    1027             :                         // is not found and it is allowed to happen
    1028             :                         // DBG_UNHANDLED_EXCEPTION();
    1029             : 
    1030             :                         // process recursively and use the decomposition as Bitmap
    1031        2732 :                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
    1032             :                     }
    1033             : 
    1034        7576 :                     break;
    1035             :                 }
    1036             :                 case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D:
    1037             :                 {
    1038             :                     // try to use directly
    1039       28308 :                     const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokePrimitive2D = static_cast< const primitive2d::PolygonStrokePrimitive2D& >(rCandidate);
    1040             : 
    1041       28308 :                     if(tryDrawPolygonStrokePrimitive2DDirect(rPolygonStrokePrimitive2D, 0.0))
    1042             :                     {
    1043           6 :                         break;
    1044             :                     }
    1045             : 
    1046             :                     // the stroke primitive may be decomposed to filled polygons. To keep
    1047             :                     // evtl. set DrawModes aka DrawModeFlags::BlackLine, DrawModeFlags::GrayLine,
    1048             :                     // DrawModeFlags::GhostedLine, DrawModeFlags::WhiteLine or DrawModeFlags::SettingsLine
    1049             :                     // working, these need to be copied to the corresponding fill modes
    1050       28302 :                     const DrawModeFlags nOriginalDrawMode(mpOutputDevice->GetDrawMode());
    1051       28302 :                     adaptLineToFillDrawMode();
    1052             : 
    1053             :                     // polygon stroke primitive
    1054             :                     static bool bSuppressFatToHairlineCorrection(false);
    1055             : 
    1056       28302 :                     if(bSuppressFatToHairlineCorrection)
    1057             :                     {
    1058             :                         // remember that we enter a PolygonStrokePrimitive2D decomposition,
    1059             :                         // used for AA thick line drawing
    1060           0 :                         mnPolygonStrokePrimitive2D++;
    1061             : 
    1062             :                         // with AA there is no need to handle thin lines special
    1063           0 :                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
    1064             : 
    1065             :                         // leave PolygonStrokePrimitive2D
    1066           0 :                         mnPolygonStrokePrimitive2D--;
    1067             :                     }
    1068             :                     else
    1069             :                     {
    1070             :                         // Lines with 1 and 2 pixel width without AA need special treatment since their vsiualisation
    1071             :                         // as filled polygons is geometrically corret but looks wrong since polygon filling avoids
    1072             :                         // the right and bottom pixels. The used method evaluates that and takes the correct action,
    1073             :                         // including calling recursively with decomposition if line is wide enough
    1074       28302 :                         RenderPolygonStrokePrimitive2D(rPolygonStrokePrimitive2D);
    1075             :                     }
    1076             : 
    1077             :                     // restore DrawMode
    1078       28302 :                     mpOutputDevice->SetDrawMode(nOriginalDrawMode);
    1079             : 
    1080       28302 :                     break;
    1081             :                 }
    1082             :                 case PRIMITIVE2D_ID_FILLHATCHPRIMITIVE2D :
    1083             :                 {
    1084             :                     static bool bForceIgnoreHatchSmoothing(false);
    1085             : 
    1086         570 :                     if(bForceIgnoreHatchSmoothing || getOptionsDrawinglayer().IsAntiAliasing())
    1087             :                     {
    1088             :                         // if AA is used (or ignore smoothing is on), there is no need to smooth
    1089             :                         // hatch painting, use decomposition
    1090           0 :                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
    1091             :                     }
    1092             :                     else
    1093             :                     {
    1094             :                         // without AA, use VCL to draw the hatch. It snaps hatch distances to the next pixel
    1095             :                         // and forces hatch distance to be >= 3 pixels to make the hatch display look smoother.
    1096             :                         // This is wrong in principle, but looks nicer. This could also be done here directly
    1097             :                         // without VCL usage if needed
    1098         570 :                         const primitive2d::FillHatchPrimitive2D& rFillHatchPrimitive = static_cast< const primitive2d::FillHatchPrimitive2D& >(rCandidate);
    1099         570 :                         const attribute::FillHatchAttribute& rFillHatchAttributes = rFillHatchPrimitive.getFillHatch();
    1100             : 
    1101             :                         // create hatch polygon in range size and discrete coordinates
    1102         570 :                         basegfx::B2DRange aHatchRange(rFillHatchPrimitive.getOutputRange());
    1103         570 :                         aHatchRange.transform(maCurrentTransformation);
    1104         570 :                         const basegfx::B2DPolygon aHatchPolygon(basegfx::tools::createPolygonFromRect(aHatchRange));
    1105             : 
    1106         570 :                         if(rFillHatchAttributes.isFillBackground())
    1107             :                         {
    1108             :                             // #i111846# background fill is active; draw fill polygon
    1109           0 :                             const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rFillHatchPrimitive.getBColor()));
    1110             : 
    1111           0 :                             mpOutputDevice->SetFillColor(Color(aPolygonColor));
    1112           0 :                             mpOutputDevice->SetLineColor();
    1113           0 :                             mpOutputDevice->DrawPolygon(aHatchPolygon);
    1114             :                         }
    1115             : 
    1116             :                         // set hatch line color
    1117        1140 :                         const basegfx::BColor aHatchColor(maBColorModifierStack.getModifiedColor(rFillHatchPrimitive.getBColor()));
    1118         570 :                         mpOutputDevice->SetFillColor();
    1119         570 :                         mpOutputDevice->SetLineColor(Color(aHatchColor));
    1120             : 
    1121             :                         // get hatch style
    1122         570 :                         HatchStyle eHatchStyle(HATCH_SINGLE);
    1123             : 
    1124         570 :                         switch(rFillHatchAttributes.getStyle())
    1125             :                         {
    1126             :                             default : // HATCHSTYLE_SINGLE
    1127             :                             {
    1128         570 :                                 break;
    1129             :                             }
    1130             :                             case attribute::HATCHSTYLE_DOUBLE :
    1131             :                             {
    1132           0 :                                 eHatchStyle = HATCH_DOUBLE;
    1133           0 :                                 break;
    1134             :                             }
    1135             :                             case attribute::HATCHSTYLE_TRIPLE :
    1136             :                             {
    1137           0 :                                 eHatchStyle = HATCH_TRIPLE;
    1138           0 :                                 break;
    1139             :                             }
    1140             :                         }
    1141             : 
    1142             :                         // create hatch
    1143         570 :                         const basegfx::B2DVector aDiscreteDistance(maCurrentTransformation * basegfx::B2DVector(rFillHatchAttributes.getDistance(), 0.0));
    1144         570 :                         const sal_uInt32 nDistance(basegfx::fround(aDiscreteDistance.getLength()));
    1145         570 :                         const sal_uInt16 nAngle10((sal_uInt16)basegfx::fround(rFillHatchAttributes.getAngle() / F_PI1800));
    1146        1140 :                         ::Hatch aVCLHatch(eHatchStyle, Color(rFillHatchAttributes.getColor()), nDistance, nAngle10);
    1147             : 
    1148             :                         // draw hatch using VCL
    1149        1710 :                         mpOutputDevice->DrawHatch(tools::PolyPolygon(Polygon(aHatchPolygon)), aVCLHatch);
    1150             :                     }
    1151         570 :                     break;
    1152             :                 }
    1153             :                 case PRIMITIVE2D_ID_BACKGROUNDCOLORPRIMITIVE2D :
    1154             :                 {
    1155             :                     // #i98404# Handle directly, especially when AA is active
    1156        1685 :                     const primitive2d::BackgroundColorPrimitive2D& rPrimitive = static_cast< const primitive2d::BackgroundColorPrimitive2D& >(rCandidate);
    1157        1685 :                     const AntialiasingFlags nOriginalAA(mpOutputDevice->GetAntialiasing());
    1158             : 
    1159             :                     // switch AA off in all cases
    1160        1685 :                     mpOutputDevice->SetAntialiasing(mpOutputDevice->GetAntialiasing() & ~AntialiasingFlags::EnableB2dDraw);
    1161             : 
    1162             :                     // create color for fill
    1163        1685 :                     const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rPrimitive.getBColor()));
    1164        1685 :                     mpOutputDevice->SetFillColor(Color(aPolygonColor));
    1165        1685 :                     mpOutputDevice->SetLineColor();
    1166             : 
    1167             :                     // create rectangle for fill
    1168        1685 :                     const basegfx::B2DRange& aViewport(getViewInformation2D().getDiscreteViewport());
    1169             :                     const Rectangle aRectangle(
    1170        3370 :                         (sal_Int32)floor(aViewport.getMinX()), (sal_Int32)floor(aViewport.getMinY()),
    1171        5055 :                         (sal_Int32)ceil(aViewport.getMaxX()), (sal_Int32)ceil(aViewport.getMaxY()));
    1172        1685 :                     mpOutputDevice->DrawRect(aRectangle);
    1173             : 
    1174             :                     // restore AA setting
    1175        1685 :                     mpOutputDevice->SetAntialiasing(nOriginalAA);
    1176        1685 :                     break;
    1177             :                 }
    1178             :                 case PRIMITIVE2D_ID_TEXTHIERARCHYEDITPRIMITIVE2D :
    1179             :                 {
    1180             :                     // #i97628#
    1181             :                     // This primitive means that the content is derived from an active text edit,
    1182             :                     // not from model data itself. Some renderers need to suppress this content, e.g.
    1183             :                     // the pixel renderer used for displaying the edit view (like this one). It's
    1184             :                     // not to be suppressed by the MetaFile renderers, so that the edited text is
    1185             :                     // part of the MetaFile, e.g. needed for presentation previews.
    1186             :                     // Action: Ignore here, do nothing.
    1187           0 :                     break;
    1188             :                 }
    1189             :                 case PRIMITIVE2D_ID_INVERTPRIMITIVE2D :
    1190             :                 {
    1191             :                     // invert primitive (currently only used for HighContrast fallback for selection in SW and SC).
    1192             :                     // Set OutDev to XOR and switch AA off (XOR does not work with AA)
    1193        3612 :                     mpOutputDevice->Push();
    1194        3612 :                     mpOutputDevice->SetRasterOp( ROP_XOR );
    1195        3612 :                     const AntialiasingFlags nAntiAliasing(mpOutputDevice->GetAntialiasing());
    1196        3612 :                     mpOutputDevice->SetAntialiasing(nAntiAliasing & ~AntialiasingFlags::EnableB2dDraw);
    1197             : 
    1198             :                     // process content recursively
    1199        3612 :                     process(rCandidate.get2DDecomposition(getViewInformation2D()));
    1200             : 
    1201             :                     // restore OutDev
    1202        3612 :                     mpOutputDevice->Pop();
    1203        3612 :                     mpOutputDevice->SetAntialiasing(nAntiAliasing);
    1204        3612 :                     break;
    1205             :                 }
    1206             :                 case PRIMITIVE2D_ID_EPSPRIMITIVE2D :
    1207             :                 {
    1208           0 :                     RenderEpsPrimitive2D(static_cast< const primitive2d::EpsPrimitive2D& >(rCandidate));
    1209           0 :                     break;
    1210             :                 }
    1211             :                 case PRIMITIVE2D_ID_SVGLINEARATOMPRIMITIVE2D:
    1212             :                 {
    1213        6144 :                     RenderSvgLinearAtomPrimitive2D(static_cast< const primitive2d::SvgLinearAtomPrimitive2D& >(rCandidate));
    1214        6144 :                     break;
    1215             :                 }
    1216             :                 case PRIMITIVE2D_ID_SVGRADIALATOMPRIMITIVE2D:
    1217             :                 {
    1218         462 :                     RenderSvgRadialAtomPrimitive2D(static_cast< const primitive2d::SvgRadialAtomPrimitive2D& >(rCandidate));
    1219         462 :                     break;
    1220             :                 }
    1221             :                 case PRIMITIVE2D_ID_BORDERLINEPRIMITIVE2D:
    1222             :                 {
    1223             :                     // process recursively, but turn off anti-aliasing. Border
    1224             :                     // lines are always rectangular, and look horrible when
    1225             :                     // the anti-aliasing is enabled.
    1226       12455 :                     AntialiasingFlags nAntiAliasing = mpOutputDevice->GetAntialiasing();
    1227       12455 :                     mpOutputDevice->SetAntialiasing(nAntiAliasing & ~AntialiasingFlags::EnableB2dDraw);
    1228             : 
    1229             :                     const drawinglayer::primitive2d::BorderLinePrimitive2D& rBorder =
    1230       12455 :                         static_cast<const drawinglayer::primitive2d::BorderLinePrimitive2D&>(rCandidate);
    1231             : 
    1232       12455 :                     if (!tryDrawBorderLinePrimitive2DDirect(rBorder))
    1233          66 :                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
    1234             : 
    1235       12455 :                     mpOutputDevice->SetAntialiasing(nAntiAliasing);
    1236       12455 :                     break;
    1237             :                 }
    1238             :                 default :
    1239             :                 {
    1240             :                     SAL_INFO("drawinglayer", "default case for " << drawinglayer::primitive2d::idToString(rCandidate.getPrimitive2DID()));
    1241             :                     // process recursively
    1242      164569 :                     process(rCandidate.get2DDecomposition(getViewInformation2D()));
    1243      164569 :                     break;
    1244             :                 }
    1245             :             }
    1246      652135 :         }
    1247             :     } // end of namespace processor2d
    1248             : } // end of namespace drawinglayer
    1249             : 
    1250             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11