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

Generated by: LCOV version 1.10