LCOV - code coverage report
Current view: top level - svx/source/sdr/primitive2d - sdrcustomshapeprimitive2d.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 25 26 96.2 %
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/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        1439 :         Primitive2DSequence SdrCustomShapePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
      39             :         {
      40        1439 :             Primitive2DSequence aRetval(getSubPrimitives());
      41             : 
      42             :             // add text
      43        1439 :             if(!getSdrSTAttribute().getText().isDefault())
      44             :             {
      45         525 :                 const basegfx::B2DPolygon aUnitOutline(basegfx::tools::createUnitPolygon());
      46             : 
      47             :                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
      48             :                     createTextPrimitive(
      49             :                         basegfx::B2DPolyPolygon(aUnitOutline),
      50         525 :                         getTextBox(),
      51         525 :                         getSdrSTAttribute().getText(),
      52             :                         attribute::SdrLineAttribute(),
      53             :                         false,
      54         525 :                         getWordWrap(),
      55        1575 :                         isForceTextClipToTextRange()));
      56             :             }
      57             : 
      58             :             // add shadow
      59        1439 :             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          65 :                 if(!get3DShape())
      72             :                 {
      73          65 :                     aRetval = createEmbeddedShadowPrimitive(aRetval, getSdrSTAttribute().getShadow());
      74             :                 }
      75             :             }
      76             : 
      77        1439 :             return aRetval;
      78             :         }
      79             : 
      80        1858 :         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        1858 :             mbForceTextClipToTextRange(bForceTextClipToTextRange)
      94             :         {
      95        1858 :         }
      96             : 
      97        1026 :         bool SdrCustomShapePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
      98             :         {
      99        1026 :             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
     100             :             {
     101        1026 :                 const SdrCustomShapePrimitive2D& rCompare = (SdrCustomShapePrimitive2D&)rPrimitive;
     102             : 
     103        1026 :                 return (getSdrSTAttribute() == rCompare.getSdrSTAttribute()
     104         845 :                     && getSubPrimitives() == rCompare.getSubPrimitives()
     105         450 :                     && getTextBox() == rCompare.getTextBox()
     106         423 :                     && getWordWrap() == rCompare.getWordWrap()
     107         423 :                     && get3DShape() == rCompare.get3DShape()
     108        1449 :                     && isForceTextClipToTextRange() == rCompare.isForceTextClipToTextRange());
     109             :             }
     110             : 
     111           0 :             return false;
     112             :         }
     113             : 
     114             :         // provide unique ID
     115        2528 :         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.10