LCOV - code coverage report
Current view: top level - drawinglayer/source/primitive3d - polygonprimitive3d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 23 45 51.1 %
Date: 2012-08-25 Functions: 5 8 62.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 32 130 24.6 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <drawinglayer/primitive3d/polygonprimitive3d.hxx>
      30                 :            : #include <basegfx/polygon/b3dpolygontools.hxx>
      31                 :            : #include <basegfx/tools/canvastools.hxx>
      32                 :            : #include <basegfx/polygon/b3dpolypolygontools.hxx>
      33                 :            : #include <drawinglayer/primitive3d/polygontubeprimitive3d.hxx>
      34                 :            : #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
      35                 :            : 
      36                 :            : //////////////////////////////////////////////////////////////////////////////
      37                 :            : 
      38                 :            : using namespace com::sun::star;
      39                 :            : 
      40                 :            : //////////////////////////////////////////////////////////////////////////////
      41                 :            : 
      42                 :            : namespace drawinglayer
      43                 :            : {
      44                 :            :     namespace primitive3d
      45                 :            :     {
      46                 :        754 :         PolygonHairlinePrimitive3D::PolygonHairlinePrimitive3D(
      47                 :            :             const basegfx::B3DPolygon& rPolygon,
      48                 :            :             const basegfx::BColor& rBColor)
      49                 :            :         :   BasePrimitive3D(),
      50                 :            :             maPolygon(rPolygon),
      51         [ +  - ]:        754 :             maBColor(rBColor)
      52                 :            :         {
      53                 :        754 :         }
      54                 :            : 
      55                 :          0 :         bool PolygonHairlinePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
      56                 :            :         {
      57         [ #  # ]:          0 :             if(BasePrimitive3D::operator==(rPrimitive))
      58                 :            :             {
      59                 :          0 :                 const PolygonHairlinePrimitive3D& rCompare = (PolygonHairlinePrimitive3D&)rPrimitive;
      60                 :            : 
      61                 :          0 :                 return (getB3DPolygon() == rCompare.getB3DPolygon()
      62 [ #  # ][ #  # ]:          0 :                     && getBColor() == rCompare.getBColor());
      63                 :            :             }
      64                 :            : 
      65                 :          0 :             return false;
      66                 :            :         }
      67                 :            : 
      68                 :          0 :         basegfx::B3DRange PolygonHairlinePrimitive3D::getB3DRange(const geometry::ViewInformation3D& /*rViewInformation*/) const
      69                 :            :         {
      70                 :          0 :             return basegfx::tools::getRange(getB3DPolygon());
      71                 :            :         }
      72                 :            : 
      73                 :            :         // provide unique ID
      74                 :        796 :         ImplPrimitrive3DIDBlock(PolygonHairlinePrimitive3D, PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D)
      75                 :            : 
      76                 :            :     } // end of namespace primitive3d
      77                 :            : } // end of namespace drawinglayer
      78                 :            : 
      79                 :            : //////////////////////////////////////////////////////////////////////////////
      80                 :            : 
      81                 :            : namespace drawinglayer
      82                 :            : {
      83                 :            :     namespace primitive3d
      84                 :            :     {
      85                 :         18 :         Primitive3DSequence PolygonStrokePrimitive3D::create3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const
      86                 :            :         {
      87                 :         18 :             Primitive3DSequence aRetval;
      88                 :            : 
      89 [ +  - ][ +  - ]:         18 :             if(getB3DPolygon().count())
         [ +  - ][ +  - ]
      90                 :            :             {
      91         [ +  - ]:         18 :                 basegfx::B3DPolyPolygon aHairLinePolyPolygon;
      92                 :            : 
      93 [ +  - ][ +  - ]:         18 :                 if(0.0 == getStrokeAttribute().getFullDotDashLen())
      94                 :            :                 {
      95 [ +  - ][ +  - ]:         18 :                     aHairLinePolyPolygon = basegfx::B3DPolyPolygon(getB3DPolygon());
         [ +  - ][ +  - ]
                 [ +  - ]
      96                 :            :                 }
      97                 :            :                 else
      98                 :            :                 {
      99                 :            :                     // apply LineStyle
     100 [ #  # ][ #  # ]:          0 :                     basegfx::tools::applyLineDashing(getB3DPolygon(), getStrokeAttribute().getDotDashArray(), &aHairLinePolyPolygon, 0, getStrokeAttribute().getFullDotDashLen());
         [ #  # ][ #  # ]
                 [ #  # ]
     101                 :            :                 }
     102                 :            : 
     103                 :            :                 // prepare result
     104 [ +  - ][ +  - ]:         18 :                 aRetval.realloc(aHairLinePolyPolygon.count());
     105                 :            : 
     106 [ +  - ][ -  + ]:         18 :                 if(getLineAttribute().getWidth())
     107                 :            :                 {
     108                 :            :                     // create fat line data
     109         [ #  # ]:          0 :                     const double fRadius(getLineAttribute().getWidth() / 2.0);
     110         [ #  # ]:          0 :                     const basegfx::B2DLineJoin aLineJoin(getLineAttribute().getLineJoin());
     111                 :            : 
     112 [ #  # ][ #  # ]:          0 :                     for(sal_uInt32 a(0L); a < aHairLinePolyPolygon.count(); a++)
     113                 :            :                     {
     114                 :            :                         // create tube primitives
     115 [ #  # ][ #  # ]:          0 :                         const Primitive3DReference xRef(new PolygonTubePrimitive3D(aHairLinePolyPolygon.getB3DPolygon(a), getLineAttribute().getColor(), fRadius, aLineJoin));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     116 [ #  # ][ #  # ]:          0 :                         aRetval[a] = xRef;
     117                 :          0 :                     }
     118                 :            :                 }
     119                 :            :                 else
     120                 :            :                 {
     121                 :            :                     // create hair line data for all sub polygons
     122 [ +  - ][ +  + ]:         36 :                     for(sal_uInt32 a(0L); a < aHairLinePolyPolygon.count(); a++)
     123                 :            :                     {
     124         [ +  - ]:         18 :                         const basegfx::B3DPolygon aCandidate = aHairLinePolyPolygon.getB3DPolygon(a);
     125 [ +  - ][ +  - ]:         18 :                         const Primitive3DReference xRef(new PolygonHairlinePrimitive3D(aCandidate, getLineAttribute().getColor()));
         [ +  - ][ +  - ]
     126 [ +  - ][ +  - ]:         18 :                         aRetval[a] = xRef;
     127         [ +  - ]:         18 :                     }
     128         [ +  - ]:         18 :                 }
     129                 :            :             }
     130                 :            : 
     131                 :         18 :             return aRetval;
     132                 :            :         }
     133                 :            : 
     134                 :         18 :         PolygonStrokePrimitive3D::PolygonStrokePrimitive3D(
     135                 :            :             const basegfx::B3DPolygon& rPolygon,
     136                 :            :             const attribute::LineAttribute& rLineAttribute,
     137                 :            :             const attribute::StrokeAttribute& rStrokeAttribute)
     138                 :            :         :   BufferedDecompositionPrimitive3D(),
     139                 :            :             maPolygon(rPolygon),
     140                 :            :             maLineAttribute(rLineAttribute),
     141 [ +  - ][ +  - ]:         18 :             maStrokeAttribute(rStrokeAttribute)
                 [ +  - ]
     142                 :            :         {
     143                 :         18 :         }
     144                 :            : 
     145                 :          0 :         bool PolygonStrokePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
     146                 :            :         {
     147         [ #  # ]:          0 :             if(BufferedDecompositionPrimitive3D::operator==(rPrimitive))
     148                 :            :             {
     149                 :          0 :                 const PolygonStrokePrimitive3D& rCompare = (PolygonStrokePrimitive3D&)rPrimitive;
     150                 :            : 
     151 [ #  # ][ #  # ]:          0 :                 return (getB3DPolygon() == rCompare.getB3DPolygon()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     152         [ #  # ]:          0 :                     && getLineAttribute() == rCompare.getLineAttribute()
     153 [ #  # ][ #  # ]:          0 :                     && getStrokeAttribute() == rCompare.getStrokeAttribute());
         [ #  # ][ #  # ]
     154                 :            :             }
     155                 :            : 
     156                 :          0 :             return false;
     157                 :            :         }
     158                 :            : 
     159                 :            :         // provide unique ID
     160                 :         60 :         ImplPrimitrive3DIDBlock(PolygonStrokePrimitive3D, PRIMITIVE3D_ID_POLYGONSTROKEPRIMITIVE3D)
     161                 :            : 
     162                 :            :     } // end of namespace primitive3d
     163                 :            : } // end of namespace drawinglayer
     164                 :            : 
     165                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10