LCOV - code coverage report
Current view: top level - svx/source/sdr/overlay - overlayobject.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 51 69 73.9 %
Date: 2015-06-13 12:38:46 Functions: 11 18 61.1 %
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        6523 :         void OverlayObject::objectChange()
      38             :         {
      39        6523 :             const basegfx::B2DRange aPreviousRange(maBaseRange);
      40        6523 :             maBaseRange.reset();
      41        6523 :             setPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DSequence());
      42             : 
      43        6523 :             if(getOverlayManager() && !aPreviousRange.isEmpty())
      44             :             {
      45         694 :                 getOverlayManager()->invalidateRange(aPreviousRange);
      46             :             }
      47             : 
      48        6523 :             const basegfx::B2DRange& rCurrentRange = getBaseRange();
      49             : 
      50        6523 :             if(getOverlayManager() && rCurrentRange != aPreviousRange && !rCurrentRange.isEmpty())
      51             :             {
      52         511 :                 getOverlayManager()->invalidateRange(rCurrentRange);
      53             :             }
      54        6523 :         }
      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          12 :         sal_uInt32 OverlayObject::impCheckBlinkTimeValueRange(sal_uInt64 nBlinkTime)
      67             :         {
      68          12 :             if(nBlinkTime < 25)
      69             :             {
      70           0 :                 nBlinkTime = 25;
      71             :             }
      72          12 :             else if(nBlinkTime > 10000)
      73             :             {
      74           0 :                 nBlinkTime = 10000;
      75             :             }
      76             : 
      77          12 :             return nBlinkTime;
      78             :         }
      79             : 
      80        5817 :         void OverlayObject::allowAntiAliase(bool bNew)
      81             :         {
      82        5817 :             if(bNew != (bool)mbAllowsAntiAliase)
      83             :             {
      84             :                 // remember new value
      85        5817 :                 mbAllowsAntiAliase = bNew;
      86             : 
      87             :                 // register change (after change)
      88        5817 :                 objectChange();
      89             :             }
      90        5817 :         }
      91             : 
      92        6328 :         OverlayObject::OverlayObject(Color aBaseColor)
      93             :         :   Event(0),
      94             :             mpOverlayManager(0),
      95             :             maBaseColor(aBaseColor),
      96             :             mbIsVisible(true),
      97             :             mbIsHittable(true),
      98             :             mbAllowsAnimation(false),
      99        6328 :             mbAllowsAntiAliase(true)
     100             :         {
     101        6328 :         }
     102             : 
     103        6317 :         OverlayObject::~OverlayObject()
     104             :         {
     105             :             OSL_ENSURE(0 == getOverlayManager(), "OverlayObject is destructed which is still registered at OverlayManager (!)");
     106        6317 :         }
     107             : 
     108       14552 :         drawinglayer::primitive2d::Primitive2DSequence OverlayObject::getOverlayObjectPrimitive2DSequence() const
     109             :         {
     110       14552 :             if(!getPrimitive2DSequence().hasElements())
     111             :             {
     112             :                 // no existing sequence; create one
     113             :                 const_cast< OverlayObject* >(this)->setPrimitive2DSequence(
     114        7022 :                     const_cast< OverlayObject* >(this)->createOverlayObjectPrimitive2DSequence());
     115             :             }
     116             : 
     117       14552 :             return getPrimitive2DSequence();
     118             :         }
     119             : 
     120       26640 :         const basegfx::B2DRange& OverlayObject::getBaseRange() const
     121             :         {
     122       26640 :             if(getOverlayManager() && maBaseRange.isEmpty())
     123             :             {
     124        7022 :                 const drawinglayer::primitive2d::Primitive2DSequence& rSequence = getOverlayObjectPrimitive2DSequence();
     125             : 
     126        7022 :                 if(rSequence.hasElements())
     127             :                 {
     128        7022 :                     const drawinglayer::geometry::ViewInformation2D aViewInformation2D(getOverlayManager()->getCurrentViewInformation2D());
     129             : 
     130             :                     const_cast< sdr::overlay::OverlayObject* >(this)->maBaseRange =
     131        7022 :                         drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(rSequence, aViewInformation2D);
     132        7022 :                 }
     133             :             }
     134             : 
     135       26640 :             return maBaseRange;
     136             :         }
     137             : 
     138         252 :         void OverlayObject::setVisible(bool bNew)
     139             :         {
     140         252 :             if(bNew != (bool)mbIsVisible)
     141             :             {
     142             :                 // remember new value
     143         168 :                 mbIsVisible = bNew;
     144             : 
     145             :                 // register change (after change)
     146         168 :                 objectChange();
     147             :             }
     148         252 :         }
     149             : 
     150          12 :         void OverlayObject::setHittable(bool bNew)
     151             :         {
     152          12 :             if(bNew != (bool)mbIsHittable)
     153             :             {
     154             :                 // remember new value
     155          12 :                 mbIsHittable = bNew;
     156             : 
     157             :                 // register change (after change)
     158          12 :                 objectChange();
     159             :             }
     160          12 :         }
     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         511 :         OverlayObjectWithBasePosition::OverlayObjectWithBasePosition(const basegfx::B2DPoint& rBasePos, Color aBaseColor)
     193             :         :   OverlayObject(aBaseColor),
     194         511 :             maBasePosition(rBasePos)
     195             :         {
     196         511 :         }
     197             : 
     198         502 :         OverlayObjectWithBasePosition::~OverlayObjectWithBasePosition()
     199             :         {
     200         502 :         }
     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.11