LCOV - code coverage report
Current view: top level - svx/source/sdr/primitive2d - sdrgrafprimitive2d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 24 48 50.0 %
Date: 2012-08-25 Functions: 4 5 80.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 25 112 22.3 %

           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 <svx/sdr/primitive2d/sdrgrafprimitive2d.hxx>
      30                 :            : #include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
      31                 :            : #include <basegfx/polygon/b2dpolygontools.hxx>
      32                 :            : #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
      33                 :            : #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
      34                 :            : #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
      35                 :            : #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
      36                 :            : #include <basegfx/polygon/b2dpolygon.hxx>
      37                 :            : 
      38                 :            : //////////////////////////////////////////////////////////////////////////////
      39                 :            : 
      40                 :            : namespace drawinglayer
      41                 :            : {
      42                 :            :     namespace primitive2d
      43                 :            :     {
      44                 :         75 :         Primitive2DSequence SdrGrafPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
      45                 :            :         {
      46         [ +  - ]:         75 :             Primitive2DSequence  aRetval;
      47                 :            : 
      48                 :            :             // create unit outline polygon
      49         [ +  - ]:         75 :             basegfx::B2DPolygon aUnitOutline(basegfx::tools::createUnitPolygon());
      50                 :            : 
      51                 :            :             // add fill, but only when graphic ist transparent
      52 [ +  - ][ -  + ]:         75 :             if(!getSdrLFSTAttribute().getFill().isDefault() && isTransparent())
         [ #  # ][ -  + ]
      53                 :            :             {
      54                 :            :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      55                 :            :                     createPolyPolygonFillPrimitive(
      56                 :            :                         basegfx::B2DPolyPolygon(aUnitOutline),
      57                 :          0 :                         getTransform(),
      58                 :          0 :                         getSdrLFSTAttribute().getFill(),
      59 [ #  # ][ #  # ]:          0 :                         getSdrLFSTAttribute().getFillFloatTransGradient()));
         [ #  # ][ #  # ]
      60                 :            :             }
      61                 :            : 
      62                 :            :             // add line
      63 [ +  - ][ -  + ]:         75 :             if(!getSdrLFSTAttribute().getLine().isDefault())
      64                 :            :             {
      65                 :            :                 // if line width is given, polygon needs to be grown by half of it to make the
      66                 :            :                 // outline to be outside of the bitmap
      67 [ #  # ][ #  # ]:          0 :                 if(0.0 != getSdrLFSTAttribute().getLine().getWidth())
      68                 :            :                 {
      69                 :            :                     // decompose to get scale
      70                 :          0 :                     basegfx::B2DVector aScale, aTranslate;
      71                 :            :                     double fRotate, fShearX;
      72         [ #  # ]:          0 :                     getTransform().decompose(aScale, aTranslate, fRotate, fShearX);
      73                 :            : 
      74                 :            :                     // create expanded range (add relative half line width to unit rectangle)
      75         [ #  # ]:          0 :                     double fHalfLineWidth(getSdrLFSTAttribute().getLine().getWidth() * 0.5);
      76         [ #  # ]:          0 :                     double fScaleX(0.0 != aScale.getX() ? fHalfLineWidth / fabs(aScale.getX()) : 1.0);
      77         [ #  # ]:          0 :                     double fScaleY(0.0 != aScale.getY() ? fHalfLineWidth / fabs(aScale.getY()) : 1.0);
      78         [ #  # ]:          0 :                     const basegfx::B2DRange aExpandedRange(-fScaleX, -fScaleY, 1.0 + fScaleX, 1.0 + fScaleY);
      79         [ #  # ]:          0 :                     basegfx::B2DPolygon aExpandedUnitOutline(basegfx::tools::createPolygonFromRect(aExpandedRange));
      80                 :            : 
      81                 :            :                     appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      82                 :            :                         createPolygonLinePrimitive(
      83                 :            :                             aExpandedUnitOutline,
      84                 :          0 :                             getTransform(),
      85                 :          0 :                             getSdrLFSTAttribute().getLine(),
      86   [ #  #  #  # ]:          0 :                             attribute::SdrLineStartEndAttribute()));
         [ #  # ][ #  # ]
                 [ #  # ]
      87                 :            :                 }
      88                 :            :                 else
      89                 :            :                 {
      90                 :            :                     appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      91                 :            :                         createPolygonLinePrimitive(
      92                 :          0 :                             aUnitOutline, getTransform(),
      93                 :          0 :                             getSdrLFSTAttribute().getLine(),
      94   [ #  #  #  # ]:          0 :                             attribute::SdrLineStartEndAttribute()));
         [ #  # ][ #  # ]
      95                 :            :                 }
      96                 :            :             }
      97                 :            : 
      98                 :            :             // add graphic content
      99         [ +  - ]:         75 :             if(255L != getGraphicAttr().GetTransparency())
     100                 :            :             {
     101                 :            :                 const Primitive2DReference xGraphicContentPrimitive(
     102                 :            :                     new GraphicPrimitive2D(
     103                 :            :                         getTransform(),
     104                 :            :                         getGraphicObject(),
     105 [ +  - ][ +  - ]:         75 :                         getGraphicAttr()));
                 [ +  - ]
     106                 :            : 
     107         [ +  - ]:         75 :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, xGraphicContentPrimitive);
     108                 :            :             }
     109                 :            : 
     110                 :            :             // add text
     111 [ +  - ][ -  + ]:         75 :             if(!getSdrLFSTAttribute().getText().isDefault())
     112                 :            :             {
     113                 :            :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
     114                 :            :                     createTextPrimitive(
     115                 :            :                         basegfx::B2DPolyPolygon(aUnitOutline),
     116                 :          0 :                         getTransform(),
     117                 :          0 :                         getSdrLFSTAttribute().getText(),
     118                 :          0 :                         getSdrLFSTAttribute().getLine(),
     119                 :            :                         false,
     120                 :            :                         false,
     121 [ #  # ][ #  # ]:          0 :                         false));
         [ #  # ][ #  # ]
     122                 :            :             }
     123                 :            : 
     124                 :            :             // add shadow
     125 [ +  - ][ -  + ]:         75 :             if(!getSdrLFSTAttribute().getShadow().isDefault())
     126                 :            :             {
     127                 :            :                 aRetval = createEmbeddedShadowPrimitive(
     128                 :            :                     aRetval,
     129 [ #  # ][ #  # ]:          0 :                     getSdrLFSTAttribute().getShadow());
                 [ #  # ]
     130                 :            :             }
     131                 :            : 
     132         [ +  - ]:         75 :             return aRetval;
     133                 :            :         }
     134                 :            : 
     135                 :         99 :         SdrGrafPrimitive2D::SdrGrafPrimitive2D(
     136                 :            :             const basegfx::B2DHomMatrix& rTransform,
     137                 :            :             const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute,
     138                 :            :             const GraphicObject& rGraphicObject,
     139                 :            :             const GraphicAttr& rGraphicAttr)
     140                 :            :         :   BufferedDecompositionPrimitive2D(),
     141                 :            :             maTransform(rTransform),
     142                 :            :             maSdrLFSTAttribute(rSdrLFSTAttribute),
     143                 :            :             maGraphicObject(rGraphicObject),
     144 [ +  - ][ +  - ]:         99 :             maGraphicAttr(rGraphicAttr)
                 [ +  - ]
     145                 :            :         {
     146                 :            :             // reset some values from GraphicAttr which are part of transformation already
     147                 :         99 :             maGraphicAttr.SetRotation(0L);
     148                 :         99 :         }
     149                 :            : 
     150                 :         24 :         bool SdrGrafPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
     151                 :            :         {
     152         [ +  - ]:         24 :             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
     153                 :            :             {
     154                 :         24 :                 const SdrGrafPrimitive2D& rCompare = (SdrGrafPrimitive2D&)rPrimitive;
     155                 :            : 
     156                 :         24 :                 return (getTransform() == rCompare.getTransform()
     157                 :         24 :                     && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute()
     158                 :         24 :                     && getGraphicObject() == rCompare.getGraphicObject()
     159 [ +  - ][ +  -  :         72 :                     && getGraphicAttr() == rCompare.getGraphicAttr());
             +  -  +  - ]
     160                 :            :             }
     161                 :            : 
     162                 :         24 :             return false;
     163                 :            :         }
     164                 :            : 
     165                 :          0 :         bool SdrGrafPrimitive2D::isTransparent() const
     166                 :            :         {
     167 [ #  # ][ #  # ]:          0 :             return ((0L != getGraphicAttr().GetTransparency()) || (getGraphicObject().IsTransparent()));
     168                 :            :         }
     169                 :            : 
     170                 :            :         // provide unique ID
     171                 :         72 :         ImplPrimitrive2DIDBlock(SdrGrafPrimitive2D, PRIMITIVE2D_ID_SDRGRAFPRIMITIVE2D)
     172                 :            : 
     173                 :            :     } // end of namespace primitive2d
     174                 :            : } // end of namespace drawinglayer
     175                 :            : 
     176                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10