LCOV - code coverage report
Current view: top level - svx/source/sdr/primitive2d - sdrrectangleprimitive2d.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 37 39 94.9 %
Date: 2014-04-11 Functions: 4 4 100.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 <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       13939 :         Primitive2DSequence SdrRectanglePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
      39             :         {
      40       13939 :             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       27878 :                 getCornerRadiusY()));
      47             : 
      48             :             // add fill
      49       13939 :             if(!getSdrLFSTAttribute().getFill().isDefault())
      50             :             {
      51        2498 :                 basegfx::B2DPolyPolygon aTransformed(aUnitOutline);
      52             : 
      53        2498 :                 aTransformed.transform(getTransform());
      54             :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      55             :                     createPolyPolygonFillPrimitive(
      56             :                         aTransformed,
      57        2498 :                         getSdrLFSTAttribute().getFill(),
      58        4996 :                         getSdrLFSTAttribute().getFillFloatTransGradient()));
      59             :             }
      60       11441 :             else if(getForceFillForHitTest())
      61             :             {
      62             :                 // if no fill and it's a text frame, create a fill for HitTest and
      63             :                 // BoundRect fallback
      64             :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      65             :                     createHiddenGeometryPrimitives2D(
      66             :                         true,
      67             :                         basegfx::B2DPolyPolygon(aUnitOutline),
      68        7277 :                         getTransform()));
      69             :             }
      70             : 
      71             :             // add line
      72       13939 :             if(!getSdrLFSTAttribute().getLine().isDefault())
      73             :             {
      74         948 :                 basegfx::B2DPolygon aTransformed(aUnitOutline);
      75             : 
      76         948 :                 aTransformed.transform(getTransform());
      77             :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      78             :                     createPolygonLinePrimitive(
      79             :                         aTransformed,
      80         948 :                         getSdrLFSTAttribute().getLine(),
      81        1896 :                         attribute::SdrLineStartEndAttribute()));
      82             :             }
      83       12991 :             else if(!getForceFillForHitTest())
      84             :             {
      85             :                 // if initially no line is defined and it's not a text frame, create
      86             :                 // a line for HitTest and BoundRect
      87             :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      88             :                     createHiddenGeometryPrimitives2D(
      89             :                         false,
      90             :                         basegfx::B2DPolyPolygon(aUnitOutline),
      91        5609 :                         getTransform()));
      92             :             }
      93             : 
      94             :             // add text
      95       13939 :             if(!getSdrLFSTAttribute().getText().isDefault())
      96             :             {
      97             :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      98             :                     createTextPrimitive(
      99             :                         basegfx::B2DPolyPolygon(aUnitOutline),
     100        8424 :                         getTransform(),
     101        8424 :                         getSdrLFSTAttribute().getText(),
     102        8424 :                         getSdrLFSTAttribute().getLine(),
     103             :                         false,
     104             :                         false,
     105        8424 :                         false));
     106             :             }
     107             : 
     108             :             // add shadow
     109       13939 :             if(!getSdrLFSTAttribute().getShadow().isDefault())
     110             :             {
     111           0 :                 aRetval = createEmbeddedShadowPrimitive(
     112             :                     aRetval,
     113           0 :                     getSdrLFSTAttribute().getShadow());
     114             :             }
     115             : 
     116       27878 :             return aRetval;
     117             :         }
     118             : 
     119       24638 :         SdrRectanglePrimitive2D::SdrRectanglePrimitive2D(
     120             :             const basegfx::B2DHomMatrix& rTransform,
     121             :             const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute,
     122             :             double fCornerRadiusX,
     123             :             double fCornerRadiusY,
     124             :             bool bForceFillForHitTest)
     125             :         :   BufferedDecompositionPrimitive2D(),
     126             :             maTransform(rTransform),
     127             :             maSdrLFSTAttribute(rSdrLFSTAttribute),
     128             :             mfCornerRadiusX(fCornerRadiusX),
     129             :             mfCornerRadiusY(fCornerRadiusY),
     130       24638 :             mbForceFillForHitTest(bForceFillForHitTest)
     131             :         {
     132       24638 :         }
     133             : 
     134       19342 :         bool SdrRectanglePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
     135             :         {
     136       19342 :             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
     137             :             {
     138       19199 :                 const SdrRectanglePrimitive2D& rCompare = (SdrRectanglePrimitive2D&)rPrimitive;
     139             : 
     140       19199 :                 return (getCornerRadiusX() == rCompare.getCornerRadiusX()
     141       19193 :                     && getCornerRadiusY() == rCompare.getCornerRadiusY()
     142       19193 :                     && getTransform() == rCompare.getTransform()
     143       18754 :                     && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute()
     144       36816 :                     && getForceFillForHitTest() == rCompare.getForceFillForHitTest());
     145             :             }
     146             : 
     147         143 :             return false;
     148             :         }
     149             : 
     150             :         // provide unique ID
     151       54741 :         ImplPrimitive2DIDBlock(SdrRectanglePrimitive2D, PRIMITIVE2D_ID_SDRRECTANGLEPRIMITIVE2D)
     152             : 
     153             :     } // end of namespace primitive2d
     154             : } // end of namespace drawinglayer
     155             : 
     156             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10