LCOV - code coverage report
Current view: top level - svx/source/sdr/primitive2d - sdrrectangleprimitive2d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 35 36 97.2 %
Date: 2012-08-25 Functions: 4 4 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 49 90 54.4 %

           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/sdrrectangleprimitive2d.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                 :            : #include <basegfx/polygon/b2dpolygon.hxx>
      27                 :            : 
      28                 :            : //////////////////////////////////////////////////////////////////////////////
      29                 :            : 
      30                 :            : using namespace com::sun::star;
      31                 :            : 
      32                 :            : //////////////////////////////////////////////////////////////////////////////
      33                 :            : 
      34                 :            : namespace drawinglayer
      35                 :            : {
      36                 :            :     namespace primitive2d
      37                 :            :     {
      38                 :      23712 :         Primitive2DSequence SdrRectanglePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
      39                 :            :         {
      40         [ +  - ]:      23712 :             Primitive2DSequence aRetval;
      41                 :            : 
      42                 :            :             // create unit outline polygon
      43                 :            :             const basegfx::B2DPolygon aUnitOutline(basegfx::tools::createPolygonFromRect(
      44                 :            :                 basegfx::B2DRange(0.0, 0.0, 1.0, 1.0),
      45                 :            :                 getCornerRadiusX(),
      46 [ +  - ][ +  - ]:      23712 :                 getCornerRadiusY()));
      47                 :            : 
      48                 :            :             // add fill
      49 [ +  - ][ +  + ]:      23712 :             if(!getSdrLFSTAttribute().getFill().isDefault())
      50                 :            :             {
      51                 :            :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      52                 :            :                     createPolyPolygonFillPrimitive(
      53                 :            :                         basegfx::B2DPolyPolygon(aUnitOutline),
      54                 :       5453 :                         getTransform(),
      55                 :       5453 :                         getSdrLFSTAttribute().getFill(),
      56 [ +  - ][ +  - ]:      10906 :                         getSdrLFSTAttribute().getFillFloatTransGradient()));
         [ +  - ][ +  - ]
      57                 :            :             }
      58         [ +  + ]:      18259 :             else if(getForceFillForHitTest())
      59                 :            :             {
      60                 :            :                 // if no fill and it's a text frame, create a fill for HitTest and
      61                 :            :                 // BoundRect fallback
      62                 :            :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      63                 :            :                     createHiddenGeometryPrimitives2D(
      64                 :            :                         true,
      65                 :            :                         basegfx::B2DPolyPolygon(aUnitOutline),
      66 [ +  - ][ +  - ]:      11488 :                         getTransform()));
         [ +  - ][ +  - ]
      67                 :            :             }
      68                 :            : 
      69                 :            :             // add line
      70 [ +  - ][ +  + ]:      23712 :             if(!getSdrLFSTAttribute().getLine().isDefault())
      71                 :            :             {
      72                 :            :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      73                 :            :                     createPolygonLinePrimitive(
      74                 :            :                         aUnitOutline,
      75                 :       1366 :                         getTransform(),
      76                 :       1366 :                         getSdrLFSTAttribute().getLine(),
      77   [ +  -  +  - ]:       2732 :                         attribute::SdrLineStartEndAttribute()));
         [ +  - ][ +  - ]
      78                 :            :             }
      79         [ +  + ]:      22346 :             else if(!getForceFillForHitTest())
      80                 :            :             {
      81                 :            :                 // if initially no line is defined and it's not a text frame, create
      82                 :            :                 // a line for HitTest and BoundRect
      83                 :            :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      84                 :            :                     createHiddenGeometryPrimitives2D(
      85                 :            :                         false,
      86                 :            :                         basegfx::B2DPolyPolygon(aUnitOutline),
      87 [ +  - ][ +  - ]:      10596 :                         getTransform()));
         [ +  - ][ +  - ]
      88                 :            :             }
      89                 :            : 
      90                 :            :             // add text
      91 [ +  - ][ +  + ]:      23712 :             if(!getSdrLFSTAttribute().getText().isDefault())
      92                 :            :             {
      93                 :            :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      94                 :            :                     createTextPrimitive(
      95                 :            :                         basegfx::B2DPolyPolygon(aUnitOutline),
      96                 :      13440 :                         getTransform(),
      97                 :      13440 :                         getSdrLFSTAttribute().getText(),
      98                 :      13440 :                         getSdrLFSTAttribute().getLine(),
      99                 :            :                         false,
     100                 :            :                         false,
     101 [ +  - ][ +  - ]:      13440 :                         false));
         [ +  - ][ +  - ]
     102                 :            :             }
     103                 :            : 
     104                 :            :             // add shadow
     105 [ +  - ][ -  + ]:      23712 :             if(!getSdrLFSTAttribute().getShadow().isDefault())
     106                 :            :             {
     107                 :            :                 aRetval = createEmbeddedShadowPrimitive(
     108                 :            :                     aRetval,
     109 [ #  # ][ #  # ]:          0 :                     getSdrLFSTAttribute().getShadow());
                 [ #  # ]
     110                 :            :             }
     111                 :            : 
     112         [ +  - ]:      23712 :             return aRetval;
     113                 :            :         }
     114                 :            : 
     115                 :      49168 :         SdrRectanglePrimitive2D::SdrRectanglePrimitive2D(
     116                 :            :             const basegfx::B2DHomMatrix& rTransform,
     117                 :            :             const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute,
     118                 :            :             double fCornerRadiusX,
     119                 :            :             double fCornerRadiusY,
     120                 :            :             bool bForceFillForHitTest)
     121                 :            :         :   BufferedDecompositionPrimitive2D(),
     122                 :            :             maTransform(rTransform),
     123                 :            :             maSdrLFSTAttribute(rSdrLFSTAttribute),
     124                 :            :             mfCornerRadiusX(fCornerRadiusX),
     125                 :            :             mfCornerRadiusY(fCornerRadiusY),
     126 [ +  - ][ +  - ]:      49168 :             mbForceFillForHitTest(bForceFillForHitTest)
     127                 :            :         {
     128                 :      49168 :         }
     129                 :            : 
     130                 :      31754 :         bool SdrRectanglePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
     131                 :            :         {
     132         [ +  - ]:      31754 :             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
     133                 :            :             {
     134                 :      31754 :                 const SdrRectanglePrimitive2D& rCompare = (SdrRectanglePrimitive2D&)rPrimitive;
     135                 :            : 
     136                 :      31754 :                 return (getCornerRadiusX() == rCompare.getCornerRadiusX()
     137                 :      31754 :                     && getCornerRadiusY() == rCompare.getCornerRadiusY()
     138                 :      31754 :                     && getTransform() == rCompare.getTransform()
     139                 :      31239 :                     && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute()
     140 [ +  - ][ +  -  :     126501 :                     && getForceFillForHitTest() == rCompare.getForceFillForHitTest());
          +  -  +  +  +  
                      + ]
     141                 :            :             }
     142                 :            : 
     143                 :      31754 :             return false;
     144                 :            :         }
     145                 :            : 
     146                 :            :         // provide unique ID
     147                 :     108636 :         ImplPrimitrive2DIDBlock(SdrRectanglePrimitive2D, PRIMITIVE2D_ID_SDRRECTANGLEPRIMITIVE2D)
     148                 :            : 
     149                 :            :     } // end of namespace primitive2d
     150                 :            : } // end of namespace drawinglayer
     151                 :            : 
     152                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10