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

Generated by: LCOV version 1.10