LCOV - code coverage report
Current view: top level - svx/source/sdr/primitive2d - sdrcaptionprimitive2d.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 41 46 89.1 %
Date: 2014-11-03 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 <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          38 :         Primitive2DSequence SdrCaptionPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
      38             :         {
      39          38 :             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          76 :                 getCornerRadiusY()));
      46             : 
      47             :             // add fill
      48          38 :             if(getSdrLFSTAttribute().getFill().isDefault())
      49             :             {
      50             :                 // create invisible fill for HitTest
      51             :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      52             :                     createHiddenGeometryPrimitives2D(
      53             :                         true,
      54             :                         basegfx::B2DPolyPolygon(aUnitOutline),
      55          12 :                         getTransform()));
      56             :             }
      57             :             else
      58             :             {
      59          26 :                 basegfx::B2DPolyPolygon aTransformed(aUnitOutline);
      60             : 
      61          26 :                 aTransformed.transform(getTransform());
      62             :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      63             :                     createPolyPolygonFillPrimitive(
      64             :                         aTransformed,
      65          26 :                         getSdrLFSTAttribute().getFill(),
      66          52 :                         getSdrLFSTAttribute().getFillFloatTransGradient()));
      67             :             }
      68             : 
      69             :             // add line
      70          38 :             if(getSdrLFSTAttribute().getLine().isDefault())
      71             :             {
      72             :                 // create invisible line for HitTest/BoundRect
      73             :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      74             :                     createHiddenGeometryPrimitives2D(
      75             :                         false,
      76             :                         basegfx::B2DPolyPolygon(aUnitOutline),
      77           0 :                         getTransform()));
      78             : 
      79             :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      80             :                     createHiddenGeometryPrimitives2D(
      81             :                         false,
      82           0 :                         basegfx::B2DPolyPolygon(getTail()),
      83           0 :                         getTransform()));
      84             :             }
      85             :             else
      86             :             {
      87          38 :                 basegfx::B2DPolygon aTransformed(aUnitOutline);
      88             : 
      89          38 :                 aTransformed.transform(getTransform());
      90             :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      91             :                     createPolygonLinePrimitive(
      92             :                         aTransformed,
      93          38 :                         getSdrLFSTAttribute().getLine(),
      94          76 :                         attribute::SdrLineStartEndAttribute()));
      95             : 
      96          38 :                 aTransformed = getTail();
      97          38 :                 aTransformed.transform(getTransform());
      98             :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      99             :                     createPolygonLinePrimitive(
     100             :                         aTransformed,
     101          38 :                         getSdrLFSTAttribute().getLine(),
     102          76 :                         getSdrLFSTAttribute().getLineStartEnd()));
     103             :             }
     104             : 
     105             :             // add text
     106          38 :             if(!getSdrLFSTAttribute().getText().isDefault())
     107             :             {
     108             :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
     109             :                     createTextPrimitive(
     110             :                         basegfx::B2DPolyPolygon(aUnitOutline),
     111          34 :                         getTransform(),
     112          34 :                         getSdrLFSTAttribute().getText(),
     113          34 :                         getSdrLFSTAttribute().getLine(),
     114             :                         false,
     115             :                         false,
     116          34 :                         false));
     117             :             }
     118             : 
     119             :             // add shadow
     120          38 :             if(!getSdrLFSTAttribute().getShadow().isDefault())
     121             :             {
     122           0 :                 aRetval = createEmbeddedShadowPrimitive(aRetval, getSdrLFSTAttribute().getShadow());
     123             :             }
     124             : 
     125          76 :             return aRetval;
     126             :         }
     127             : 
     128          48 :         SdrCaptionPrimitive2D::SdrCaptionPrimitive2D(
     129             :             const basegfx::B2DHomMatrix& rTransform,
     130             :             const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute,
     131             :             const basegfx::B2DPolygon& rTail,
     132             :             double fCornerRadiusX,
     133             :             double fCornerRadiusY)
     134             :         :   BufferedDecompositionPrimitive2D(),
     135             :             maTransform(rTransform),
     136             :             maSdrLFSTAttribute(rSdrLFSTAttribute),
     137             :             maTail(rTail),
     138             :             mfCornerRadiusX(fCornerRadiusX),
     139          48 :             mfCornerRadiusY(fCornerRadiusY)
     140             :         {
     141             :             // transform maTail to unit polygon
     142          48 :             if(getTail().count())
     143             :             {
     144          48 :                 basegfx::B2DHomMatrix aInverse(getTransform());
     145          48 :                 aInverse.invert();
     146          48 :                 maTail.transform(aInverse);
     147             :             }
     148          48 :         }
     149             : 
     150          14 :         bool SdrCaptionPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
     151             :         {
     152          14 :             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
     153             :             {
     154          14 :                 const SdrCaptionPrimitive2D& rCompare = static_cast<const SdrCaptionPrimitive2D&>(rPrimitive);
     155             : 
     156          14 :                 return (getCornerRadiusX() == rCompare.getCornerRadiusX()
     157          14 :                     && getCornerRadiusY() == rCompare.getCornerRadiusY()
     158          14 :                     && getTail() == rCompare.getTail()
     159          14 :                     && getTransform() == rCompare.getTransform()
     160          28 :                     && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute());
     161             :             }
     162             : 
     163           0 :             return false;
     164             :         }
     165             : 
     166             :         // provide unique ID
     167          44 :         ImplPrimitive2DIDBlock(SdrCaptionPrimitive2D, PRIMITIVE2D_ID_SDRCAPTIONPRIMITIVE2D)
     168             : 
     169             :     } // end of namespace primitive2d
     170             : } // end of namespace drawinglayer
     171             : 
     172             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10