LCOV - code coverage report
Current view: top level - svx/source/sdr/overlay - overlayobject.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 43 70 61.4 %
Date: 2014-11-03 Functions: 11 20 55.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/overlay/overlayobject.hxx>
      21             : #include <svx/sdr/overlay/overlaymanager.hxx>
      22             : #include <basegfx/matrix/b2dhommatrix.hxx>
      23             : #include <basegfx/vector/b2dvector.hxx>
      24             : #include <vcl/outdev.hxx>
      25             : #include <basegfx/polygon/b2dpolygon.hxx>
      26             : #include <basegfx/polygon/b2dpolypolygon.hxx>
      27             : #include <basegfx/polygon/b2dpolygontools.hxx>
      28             : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      29             : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
      30             : 
      31             : 
      32             : 
      33             : namespace sdr
      34             : {
      35             :     namespace overlay
      36             :     {
      37        9076 :         void OverlayObject::objectChange()
      38             :         {
      39        9076 :             const basegfx::B2DRange aPreviousRange(maBaseRange);
      40        9076 :             maBaseRange.reset();
      41        9076 :             setPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DSequence());
      42             : 
      43        9076 :             if(getOverlayManager() && !aPreviousRange.isEmpty())
      44             :             {
      45        1112 :                 getOverlayManager()->invalidateRange(aPreviousRange);
      46             :             }
      47             : 
      48        9076 :             const basegfx::B2DRange& rCurrentRange = getBaseRange();
      49             : 
      50        9076 :             if(getOverlayManager() && rCurrentRange != aPreviousRange && !rCurrentRange.isEmpty())
      51             :             {
      52         846 :                 getOverlayManager()->invalidateRange(rCurrentRange);
      53             :             }
      54        9076 :         }
      55             : 
      56             :         // OverlayObject implementations.
      57           0 :         drawinglayer::primitive2d::Primitive2DSequence OverlayObject::createOverlayObjectPrimitive2DSequence()
      58             :         {
      59             :             // Default implementation has to assert a missing implementation. It cannot
      60             :             // be useful to have overlay object derivations which have no visualisation
      61             :             // at all
      62             :             OSL_FAIL("OverlayObject derivation without visualisation definition (missing createOverlayObjectPrimitive2DSequence implementation) (!)");
      63           0 :             return drawinglayer::primitive2d::Primitive2DSequence();
      64             :         }
      65             : 
      66           0 :         sal_uInt32 OverlayObject::impCheckBlinkTimeValueRange(sal_uInt32 nBlinkTime) const
      67             :         {
      68           0 :             if(nBlinkTime < 25)
      69             :             {
      70           0 :                 nBlinkTime = 25;
      71             :             }
      72           0 :             else if(nBlinkTime > 10000)
      73             :             {
      74           0 :                 nBlinkTime = 10000;
      75             :             }
      76             : 
      77           0 :             return nBlinkTime;
      78             :         }
      79             : 
      80        7964 :         void OverlayObject::allowAntiAliase(bool bNew)
      81             :         {
      82        7964 :             if(bNew != (bool)mbAllowsAntiAliase)
      83             :             {
      84             :                 // remember new value
      85        7964 :                 mbAllowsAntiAliase = bNew;
      86             : 
      87             :                 // register change (after change)
      88        7964 :                 objectChange();
      89             :             }
      90        7964 :         }
      91             : 
      92        8714 :         OverlayObject::OverlayObject(Color aBaseColor)
      93             :         :   Event(0),
      94             :             mpOverlayManager(0),
      95             :             maBaseColor(aBaseColor),
      96             :             mbIsVisible(true),
      97             :             mbIsHittable(true),
      98             :             mbAllowsAnimation(false),
      99        8714 :             mbAllowsAntiAliase(true)
     100             :         {
     101        8714 :         }
     102             : 
     103        8714 :         OverlayObject::~OverlayObject()
     104             :         {
     105             :             OSL_ENSURE(0 == getOverlayManager(), "OverlayObject is destructed which is still registered at OverlayManager (!)");
     106        8714 :         }
     107             : 
     108       15274 :         drawinglayer::primitive2d::Primitive2DSequence OverlayObject::getOverlayObjectPrimitive2DSequence() const
     109             :         {
     110       15274 :             if(!getPrimitive2DSequence().hasElements())
     111             :             {
     112             :                 // no existing sequence; create one
     113             :                 const_cast< OverlayObject* >(this)->setPrimitive2DSequence(
     114        9826 :                     const_cast< OverlayObject* >(this)->createOverlayObjectPrimitive2DSequence());
     115             :             }
     116             : 
     117       15274 :             return getPrimitive2DSequence();
     118             :         }
     119             : 
     120       31952 :         const basegfx::B2DRange& OverlayObject::getBaseRange() const
     121             :         {
     122       31952 :             if(getOverlayManager() && maBaseRange.isEmpty())
     123             :             {
     124        9826 :                 const drawinglayer::primitive2d::Primitive2DSequence& rSequence = getOverlayObjectPrimitive2DSequence();
     125             : 
     126        9826 :                 if(rSequence.hasElements())
     127             :                 {
     128        9826 :                     const drawinglayer::geometry::ViewInformation2D aViewInformation2D(getOverlayManager()->getCurrentViewInformation2D());
     129             : 
     130             :                     const_cast< sdr::overlay::OverlayObject* >(this)->maBaseRange =
     131        9826 :                         drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(rSequence, aViewInformation2D);
     132        9826 :                 }
     133             :             }
     134             : 
     135       31952 :             return maBaseRange;
     136             :         }
     137             : 
     138         390 :         void OverlayObject::setVisible(bool bNew)
     139             :         {
     140         390 :             if(bNew != (bool)mbIsVisible)
     141             :             {
     142             :                 // remember new value
     143         260 :                 mbIsVisible = bNew;
     144             : 
     145             :                 // register change (after change)
     146         260 :                 objectChange();
     147             :             }
     148         390 :         }
     149             : 
     150           0 :         void OverlayObject::setHittable(bool bNew)
     151             :         {
     152           0 :             if(bNew != (bool)mbIsHittable)
     153             :             {
     154             :                 // remember new value
     155           0 :                 mbIsHittable = bNew;
     156             : 
     157             :                 // register change (after change)
     158           0 :                 objectChange();
     159             :             }
     160           0 :         }
     161             : 
     162           0 :         void OverlayObject::setBaseColor(Color aNew)
     163             :         {
     164           0 :             if(aNew != maBaseColor)
     165             :             {
     166             :                 // remember new value
     167           0 :                 maBaseColor = aNew;
     168             : 
     169             :                 // register change (after change)
     170           0 :                 objectChange();
     171             :             }
     172           0 :         }
     173             : 
     174           0 :         void OverlayObject::Trigger(sal_uInt32 /*nTime*/)
     175             :         {
     176             :             // default does not register again
     177           0 :         }
     178             : 
     179           0 :         void OverlayObject::stripeDefinitionHasChanged()
     180             :         {
     181             :             // default does not need to do anything
     182           0 :         }
     183             :     } // end of namespace overlay
     184             : } // end of namespace sdr
     185             : 
     186             : 
     187             : 
     188             : namespace sdr
     189             : {
     190             :     namespace overlay
     191             :     {
     192         750 :         OverlayObjectWithBasePosition::OverlayObjectWithBasePosition(const basegfx::B2DPoint& rBasePos, Color aBaseColor)
     193             :         :   OverlayObject(aBaseColor),
     194         750 :             maBasePosition(rBasePos)
     195             :         {
     196         750 :         }
     197             : 
     198         750 :         OverlayObjectWithBasePosition::~OverlayObjectWithBasePosition()
     199             :         {
     200         750 :         }
     201             : 
     202           0 :         void OverlayObjectWithBasePosition::setBasePosition(const basegfx::B2DPoint& rNew)
     203             :         {
     204           0 :             if(rNew != maBasePosition)
     205             :             {
     206             :                 // remember new value
     207           0 :                 maBasePosition = rNew;
     208             : 
     209             :                 // register change (after change)
     210           0 :                 objectChange();
     211             :             }
     212           0 :         }
     213             :     } // end of namespace overlay
     214         651 : } // end of namespace sdr
     215             : 
     216             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10