LCOV - code coverage report
Current view: top level - svx/source/sdr/overlay - overlayobject.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 69 0.0 %
Date: 2014-04-14 Functions: 0 18 0.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           0 :         void OverlayObject::objectChange()
      38             :         {
      39           0 :             const basegfx::B2DRange aPreviousRange(maBaseRange);
      40           0 :             maBaseRange.reset();
      41           0 :             setPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DSequence());
      42             : 
      43           0 :             if(getOverlayManager() && !aPreviousRange.isEmpty())
      44             :             {
      45           0 :                 getOverlayManager()->invalidateRange(aPreviousRange);
      46             :             }
      47             : 
      48           0 :             const basegfx::B2DRange& rCurrentRange = getBaseRange();
      49             : 
      50           0 :             if(getOverlayManager() && rCurrentRange != aPreviousRange && !rCurrentRange.isEmpty())
      51             :             {
      52           0 :                 getOverlayManager()->invalidateRange(rCurrentRange);
      53             :             }
      54           0 :         }
      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           0 :         void OverlayObject::allowAntiAliase(bool bNew)
      81             :         {
      82           0 :             if(bNew != (bool)mbAllowsAntiAliase)
      83             :             {
      84             :                 // remember new value
      85           0 :                 mbAllowsAntiAliase = bNew;
      86             : 
      87             :                 // register change (after change)
      88           0 :                 objectChange();
      89             :             }
      90           0 :         }
      91             : 
      92           0 :         OverlayObject::OverlayObject(Color aBaseColor)
      93             :         :   Event(0),
      94             :             mpOverlayManager(0),
      95             :             maBaseColor(aBaseColor),
      96             :             mbIsVisible(true),
      97             :             mbIsHittable(true),
      98             :             mbAllowsAnimation(false),
      99           0 :             mbAllowsAntiAliase(true)
     100             :         {
     101           0 :         }
     102             : 
     103           0 :         OverlayObject::~OverlayObject()
     104             :         {
     105             :             OSL_ENSURE(0 == getOverlayManager(), "OverlayObject is destructed which is still registered at OverlayManager (!)");
     106           0 :         }
     107             : 
     108           0 :         drawinglayer::primitive2d::Primitive2DSequence OverlayObject::getOverlayObjectPrimitive2DSequence() const
     109             :         {
     110           0 :             if(!getPrimitive2DSequence().hasElements())
     111             :             {
     112             :                 // no existing sequence; create one
     113             :                 const_cast< OverlayObject* >(this)->setPrimitive2DSequence(
     114           0 :                     const_cast< OverlayObject* >(this)->createOverlayObjectPrimitive2DSequence());
     115             :             }
     116             : 
     117           0 :             return getPrimitive2DSequence();
     118             :         }
     119             : 
     120           0 :         const basegfx::B2DRange& OverlayObject::getBaseRange() const
     121             :         {
     122           0 :             if(getOverlayManager() && maBaseRange.isEmpty())
     123             :             {
     124           0 :                 const drawinglayer::primitive2d::Primitive2DSequence& rSequence = getOverlayObjectPrimitive2DSequence();
     125             : 
     126           0 :                 if(rSequence.hasElements())
     127             :                 {
     128           0 :                     const drawinglayer::geometry::ViewInformation2D aViewInformation2D(getOverlayManager()->getCurrentViewInformation2D());
     129             : 
     130             :                     const_cast< sdr::overlay::OverlayObject* >(this)->maBaseRange =
     131           0 :                         drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(rSequence, aViewInformation2D);
     132           0 :                 }
     133             :             }
     134             : 
     135           0 :             return maBaseRange;
     136             :         }
     137             : 
     138           0 :         void OverlayObject::setVisible(bool bNew)
     139             :         {
     140           0 :             if(bNew != (bool)mbIsVisible)
     141             :             {
     142             :                 // remember new value
     143           0 :                 mbIsVisible = bNew;
     144             : 
     145             :                 // register change (after change)
     146           0 :                 objectChange();
     147             :             }
     148           0 :         }
     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           0 :         OverlayObjectWithBasePosition::OverlayObjectWithBasePosition(const basegfx::B2DPoint& rBasePos, Color aBaseColor)
     193             :         :   OverlayObject(aBaseColor),
     194           0 :             maBasePosition(rBasePos)
     195             :         {
     196           0 :         }
     197             : 
     198           0 :         OverlayObjectWithBasePosition::~OverlayObjectWithBasePosition()
     199             :         {
     200           0 :         }
     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             : } // end of namespace sdr
     215             : 
     216             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10