LCOV - code coverage report
Current view: top level - svx/source/sdr/primitive2d - sdrcaptionprimitive2d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 40 44 90.9 %
Date: 2012-08-25 Functions: 4 4 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 48 112 42.9 %

           Branch data     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 <svx/sdr/primitive2d/sdrcaptionprimitive2d.hxx>
      21                 :            : #include <basegfx/polygon/b2dpolygontools.hxx>
      22                 :            : #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
      23                 :            : #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
      24                 :            : #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
      25                 :            : #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
      26                 :            : 
      27                 :            : //////////////////////////////////////////////////////////////////////////////
      28                 :            : 
      29                 :            : using namespace com::sun::star;
      30                 :            : 
      31                 :            : //////////////////////////////////////////////////////////////////////////////
      32                 :            : 
      33                 :            : namespace drawinglayer
      34                 :            : {
      35                 :            :     namespace primitive2d
      36                 :            :     {
      37                 :         10 :         Primitive2DSequence SdrCaptionPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
      38                 :            :         {
      39         [ +  - ]:         10 :             Primitive2DSequence aRetval;
      40                 :            : 
      41                 :            :             // create unit outline polygon
      42                 :            :             const basegfx::B2DPolygon aUnitOutline(basegfx::tools::createPolygonFromRect(
      43                 :            :                 basegfx::B2DRange(0.0, 0.0, 1.0, 1.0),
      44                 :            :                 getCornerRadiusX(),
      45 [ +  - ][ +  - ]:         10 :                 getCornerRadiusY()));
      46                 :            : 
      47                 :            :             // add fill
      48 [ +  - ][ +  + ]:         10 :             if(getSdrLFSTAttribute().getFill().isDefault())
      49                 :            :             {
      50                 :            :                 // create invisible fill for HitTest
      51                 :            :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      52                 :            :                     createHiddenGeometryPrimitives2D(
      53                 :            :                         true,
      54                 :            :                         basegfx::B2DPolyPolygon(aUnitOutline),
      55 [ +  - ][ +  - ]:          5 :                         getTransform()));
         [ +  - ][ +  - ]
      56                 :            :             }
      57                 :            :             else
      58                 :            :             {
      59                 :            :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      60                 :            :                     createPolyPolygonFillPrimitive(
      61                 :            :                         basegfx::B2DPolyPolygon(aUnitOutline),
      62                 :          5 :                         getTransform(),
      63                 :          5 :                         getSdrLFSTAttribute().getFill(),
      64 [ +  - ][ +  - ]:         10 :                         getSdrLFSTAttribute().getFillFloatTransGradient()));
         [ +  - ][ +  - ]
      65                 :            :             }
      66                 :            : 
      67                 :            :             // add line
      68 [ +  - ][ -  + ]:         10 :             if(getSdrLFSTAttribute().getLine().isDefault())
      69                 :            :             {
      70                 :            :                 // create invisible line for HitTest/BoundRect
      71                 :            :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      72                 :            :                     createHiddenGeometryPrimitives2D(
      73                 :            :                         false,
      74                 :            :                         basegfx::B2DPolyPolygon(aUnitOutline),
      75 [ #  # ][ #  # ]:          0 :                         getTransform()));
         [ #  # ][ #  # ]
      76                 :            : 
      77                 :            :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      78                 :            :                     createHiddenGeometryPrimitives2D(
      79                 :            :                         false,
      80                 :          0 :                         basegfx::B2DPolyPolygon(getTail()),
      81 [ #  # ][ #  # ]:          0 :                         getTransform()));
         [ #  # ][ #  # ]
      82                 :            :             }
      83                 :            :             else
      84                 :            :             {
      85                 :            :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      86                 :            :                     createPolygonLinePrimitive(
      87                 :            :                         aUnitOutline,
      88                 :         10 :                         getTransform(),
      89                 :         10 :                         getSdrLFSTAttribute().getLine(),
      90   [ +  -  +  - ]:         20 :                         attribute::SdrLineStartEndAttribute()));
         [ +  - ][ +  - ]
      91                 :            : 
      92                 :            :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      93                 :            :                     createPolygonLinePrimitive(
      94                 :         10 :                         getTail(),
      95                 :         10 :                         getTransform(),
      96                 :         10 :                         getSdrLFSTAttribute().getLine(),
      97 [ +  - ][ +  - ]:         20 :                         getSdrLFSTAttribute().getLineStartEnd()));
      98                 :            :             }
      99                 :            : 
     100                 :            :             // add text
     101 [ +  - ][ +  + ]:         10 :             if(!getSdrLFSTAttribute().getText().isDefault())
     102                 :            :             {
     103                 :            :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
     104                 :            :                     createTextPrimitive(
     105                 :            :                         basegfx::B2DPolyPolygon(aUnitOutline),
     106                 :          7 :                         getTransform(),
     107                 :          7 :                         getSdrLFSTAttribute().getText(),
     108                 :          7 :                         getSdrLFSTAttribute().getLine(),
     109                 :            :                         false,
     110                 :            :                         false,
     111 [ +  - ][ +  - ]:          7 :                         false));
         [ +  - ][ +  - ]
     112                 :            :             }
     113                 :            : 
     114                 :            :             // add shadow
     115 [ +  - ][ -  + ]:         10 :             if(!getSdrLFSTAttribute().getShadow().isDefault())
     116                 :            :             {
     117 [ #  # ][ #  # ]:          0 :                 aRetval = createEmbeddedShadowPrimitive(aRetval, getSdrLFSTAttribute().getShadow());
                 [ #  # ]
     118                 :            :             }
     119                 :            : 
     120         [ +  - ]:         10 :             return aRetval;
     121                 :            :         }
     122                 :            : 
     123                 :         20 :         SdrCaptionPrimitive2D::SdrCaptionPrimitive2D(
     124                 :            :             const basegfx::B2DHomMatrix& rTransform,
     125                 :            :             const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute,
     126                 :            :             const basegfx::B2DPolygon& rTail,
     127                 :            :             double fCornerRadiusX,
     128                 :            :             double fCornerRadiusY)
     129                 :            :         :   BufferedDecompositionPrimitive2D(),
     130                 :            :             maTransform(rTransform),
     131                 :            :             maSdrLFSTAttribute(rSdrLFSTAttribute),
     132                 :            :             maTail(rTail),
     133                 :            :             mfCornerRadiusX(fCornerRadiusX),
     134 [ +  - ][ +  - ]:         20 :             mfCornerRadiusY(fCornerRadiusY)
                 [ +  - ]
     135                 :            :         {
     136                 :            :             // transform maTail to unit polygon
     137 [ +  - ][ +  - ]:         20 :             if(getTail().count())
     138                 :            :             {
     139         [ +  - ]:         20 :                 basegfx::B2DHomMatrix aInverse(getTransform());
     140         [ +  - ]:         20 :                 aInverse.invert();
     141 [ +  - ][ +  - ]:         20 :                 maTail.transform(aInverse);
     142                 :            :             }
     143                 :         20 :         }
     144                 :            : 
     145                 :         18 :         bool SdrCaptionPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
     146                 :            :         {
     147         [ +  - ]:         18 :             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
     148                 :            :             {
     149                 :         18 :                 const SdrCaptionPrimitive2D& rCompare = (SdrCaptionPrimitive2D&)rPrimitive;
     150                 :            : 
     151                 :         18 :                 return (getCornerRadiusX() == rCompare.getCornerRadiusX()
     152                 :         18 :                     && getCornerRadiusY() == rCompare.getCornerRadiusY()
     153                 :         18 :                     && getTail() == rCompare.getTail()
     154                 :         17 :                     && getTransform() == rCompare.getTransform()
     155 [ +  - ][ +  -  :         71 :                     && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute());
          +  -  +  +  +  
                      - ]
     156                 :            :             }
     157                 :            : 
     158                 :         18 :             return false;
     159                 :            :         }
     160                 :            : 
     161                 :            :         // provide unique ID
     162                 :         49 :         ImplPrimitrive2DIDBlock(SdrCaptionPrimitive2D, PRIMITIVE2D_ID_SDRCAPTIONPRIMITIVE2D)
     163                 :            : 
     164                 :            :     } // end of namespace primitive2d
     165                 :            : } // end of namespace drawinglayer
     166                 :            : 
     167                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10