LCOV - code coverage report
Current view: top level - svx/source/sdr/primitive2d - sdrcustomshapeprimitive2d.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 26 26 100.0 %
Date: 2015-06-13 12:38:46 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/sdrcustomshapeprimitive2d.hxx>
      21             : #include <basegfx/polygon/b2dpolygon.hxx>
      22             : #include <basegfx/polygon/b2dpolygontools.hxx>
      23             : #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
      24             : #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
      25             : #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
      26             : #include <drawinglayer/attribute/sdrlineattribute.hxx>
      27             : 
      28             : 
      29             : 
      30             : using namespace com::sun::star;
      31             : 
      32             : 
      33             : 
      34             : namespace drawinglayer
      35             : {
      36             :     namespace primitive2d
      37             :     {
      38        3422 :         Primitive2DSequence SdrCustomShapePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
      39             :         {
      40        3422 :             Primitive2DSequence aRetval(getSubPrimitives());
      41             : 
      42             :             // add text
      43        3422 :             if(!getSdrSTAttribute().getText().isDefault())
      44             :             {
      45         927 :                 const basegfx::B2DPolygon aUnitOutline(basegfx::tools::createUnitPolygon());
      46             : 
      47             :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      48             :                     createTextPrimitive(
      49             :                         basegfx::B2DPolyPolygon(aUnitOutline),
      50         927 :                         getTextBox(),
      51         927 :                         getSdrSTAttribute().getText(),
      52             :                         attribute::SdrLineAttribute(),
      53             :                         false,
      54         927 :                         getWordWrap(),
      55        2781 :                         isForceTextClipToTextRange()));
      56             :             }
      57             : 
      58             :             // add shadow
      59        3422 :             if(aRetval.hasElements() && !getSdrSTAttribute().getShadow().isDefault())
      60             :             {
      61             :                 // #i105323# add generic shadow only for 2D shapes. For
      62             :                 // 3D shapes shadow will be set at the individual created
      63             :                 // visualisation objects and be visualized by the 3d renderer
      64             :                 // as a single shadow.
      65             : 
      66             :                 // The shadow for AutoShapes could be handled uniformely by not setting any
      67             :                 // shadow items at the helper model objects and only adding shadow here for
      68             :                 // 2D and 3D (and it works, too), but this would lead to two 3D scenes for
      69             :                 // the 3D object; one for the shadow aond one for the content. The one for the
      70             :                 // shadow will be correct (using ColorModifierStack), but expensive.
      71         327 :                 if(!get3DShape())
      72             :                 {
      73         327 :                     aRetval = createEmbeddedShadowPrimitive(aRetval, getSdrSTAttribute().getShadow());
      74             :                 }
      75             :             }
      76             : 
      77        3422 :             return aRetval;
      78             :         }
      79             : 
      80        4973 :         SdrCustomShapePrimitive2D::SdrCustomShapePrimitive2D(
      81             :             const attribute::SdrShadowTextAttribute& rSdrSTAttribute,
      82             :             const Primitive2DSequence& rSubPrimitives,
      83             :             const basegfx::B2DHomMatrix& rTextBox,
      84             :             bool bWordWrap,
      85             :             bool b3DShape,
      86             :             bool bForceTextClipToTextRange)
      87             :         :   BufferedDecompositionPrimitive2D(),
      88             :             maSdrSTAttribute(rSdrSTAttribute),
      89             :             maSubPrimitives(rSubPrimitives),
      90             :             maTextBox(rTextBox),
      91             :             mbWordWrap(bWordWrap),
      92             :             mb3DShape(b3DShape),
      93        4973 :             mbForceTextClipToTextRange(bForceTextClipToTextRange)
      94             :         {
      95        4973 :         }
      96             : 
      97        4132 :         bool SdrCustomShapePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
      98             :         {
      99        4132 :             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
     100             :             {
     101        4126 :                 const SdrCustomShapePrimitive2D& rCompare = static_cast<const SdrCustomShapePrimitive2D&>(rPrimitive);
     102             : 
     103        4126 :                 return (getSdrSTAttribute() == rCompare.getSdrSTAttribute()
     104        3572 :                     && getSubPrimitives() == rCompare.getSubPrimitives()
     105        2161 :                     && getTextBox() == rCompare.getTextBox()
     106        2128 :                     && getWordWrap() == rCompare.getWordWrap()
     107        2128 :                     && get3DShape() == rCompare.get3DShape()
     108        6254 :                     && isForceTextClipToTextRange() == rCompare.isForceTextClipToTextRange());
     109             :             }
     110             : 
     111           6 :             return false;
     112             :         }
     113             : 
     114             :         // provide unique ID
     115        9084 :         ImplPrimitive2DIDBlock(SdrCustomShapePrimitive2D, PRIMITIVE2D_ID_SDRCUSTOMSHAPEPRIMITIVE2D)
     116             : 
     117             :     } // end of namespace primitive2d
     118             : } // end of namespace drawinglayer
     119             : 
     120             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11