LCOV - code coverage report
Current view: top level - libreoffice/svx/source/sdr/overlay - overlayobject.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 37 63 58.7 %
Date: 2012-12-27 Functions: 8 17 47.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          36 :         void OverlayObject::objectChange()
      38             :         {
      39          36 :             const basegfx::B2DRange aPreviousRange(maBaseRange);
      40          36 :             maBaseRange.reset();
      41          36 :             setPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DSequence());
      42             : 
      43          36 :             if(getOverlayManager() && !aPreviousRange.isEmpty())
      44             :             {
      45          36 :                 getOverlayManager()->invalidateRange(aPreviousRange);
      46             :             }
      47             : 
      48          36 :             const basegfx::B2DRange& rCurrentRange = getBaseRange();
      49             : 
      50          36 :             if(getOverlayManager() && rCurrentRange != aPreviousRange && !rCurrentRange.isEmpty())
      51             :             {
      52          24 :                 getOverlayManager()->invalidateRange(rCurrentRange);
      53             :             }
      54          36 :         }
      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 :         void OverlayObject::allowAntiAliase(bool bNew)
      67             :         {
      68           0 :             if(bNew != (bool)mbAllowsAntiAliase)
      69             :             {
      70             :                 // remember new value
      71           0 :                 mbAllowsAntiAliase = bNew;
      72             : 
      73             :                 // register change (after change)
      74           0 :                 objectChange();
      75             :             }
      76           0 :         }
      77             : 
      78          12 :         OverlayObject::OverlayObject(Color aBaseColor)
      79             :         :   Event(0),
      80             :             mpOverlayManager(0),
      81             :             maBaseColor(aBaseColor),
      82             :             mbIsVisible(true),
      83             :             mbIsHittable(true),
      84             :             mbAllowsAnimation(false),
      85          12 :             mbAllowsAntiAliase(true)
      86             :         {
      87          12 :         }
      88             : 
      89           6 :         OverlayObject::~OverlayObject()
      90             :         {
      91             :             OSL_ENSURE(0 == getOverlayManager(), "OverlayObject is destructed which is still registered at OverlayManager (!)");
      92           6 :         }
      93             : 
      94          66 :         drawinglayer::primitive2d::Primitive2DSequence OverlayObject::getOverlayObjectPrimitive2DSequence() const
      95             :         {
      96          66 :             if(!getPrimitive2DSequence().hasElements())
      97             :             {
      98             :                 // no existing sequence; create one
      99             :                 const_cast< OverlayObject* >(this)->setPrimitive2DSequence(
     100          48 :                     const_cast< OverlayObject* >(this)->createOverlayObjectPrimitive2DSequence());
     101             :             }
     102             : 
     103          66 :             return getPrimitive2DSequence();
     104             :         }
     105             : 
     106          72 :         const basegfx::B2DRange& OverlayObject::getBaseRange() const
     107             :         {
     108          72 :             if(getOverlayManager() && maBaseRange.isEmpty())
     109             :             {
     110          48 :                 const drawinglayer::primitive2d::Primitive2DSequence& rSequence = getOverlayObjectPrimitive2DSequence();
     111             : 
     112          48 :                 if(rSequence.hasElements())
     113             :                 {
     114          48 :                     const drawinglayer::geometry::ViewInformation2D aViewInformation2D(getOverlayManager()->getCurrentViewInformation2D());
     115             : 
     116             :                     const_cast< sdr::overlay::OverlayObject* >(this)->maBaseRange =
     117          48 :                         drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(rSequence, aViewInformation2D);
     118          48 :                 }
     119             :             }
     120             : 
     121          72 :             return maBaseRange;
     122             :         }
     123             : 
     124          18 :         void OverlayObject::setVisible(bool bNew)
     125             :         {
     126          18 :             if(bNew != (bool)mbIsVisible)
     127             :             {
     128             :                 // remember new value
     129          12 :                 mbIsVisible = bNew;
     130             : 
     131             :                 // register change (after change)
     132          12 :                 objectChange();
     133             :             }
     134          18 :         }
     135             : 
     136           0 :         void OverlayObject::setHittable(bool bNew)
     137             :         {
     138           0 :             if(bNew != (bool)mbIsHittable)
     139             :             {
     140             :                 // remember new value
     141           0 :                 mbIsHittable = bNew;
     142             : 
     143             :                 // register change (after change)
     144           0 :                 objectChange();
     145             :             }
     146           0 :         }
     147             : 
     148           0 :         void OverlayObject::setBaseColor(Color aNew)
     149             :         {
     150           0 :             if(aNew != maBaseColor)
     151             :             {
     152             :                 // remember new value
     153           0 :                 maBaseColor = aNew;
     154             : 
     155             :                 // register change (after change)
     156           0 :                 objectChange();
     157             :             }
     158           0 :         }
     159             : 
     160           0 :         void OverlayObject::Trigger(sal_uInt32 /*nTime*/)
     161             :         {
     162             :             // default does not register again
     163           0 :         }
     164             : 
     165           0 :         void OverlayObject::stripeDefinitionHasChanged()
     166             :         {
     167             :             // default does not need to do anything
     168           0 :         }
     169             :     } // end of namespace overlay
     170             : } // end of namespace sdr
     171             : 
     172             : //////////////////////////////////////////////////////////////////////////////
     173             : 
     174             : namespace sdr
     175             : {
     176             :     namespace overlay
     177             :     {
     178          12 :         OverlayObjectWithBasePosition::OverlayObjectWithBasePosition(const basegfx::B2DPoint& rBasePos, Color aBaseColor)
     179             :         :   OverlayObject(aBaseColor),
     180          12 :             maBasePosition(rBasePos)
     181             :         {
     182          12 :         }
     183             : 
     184           6 :         OverlayObjectWithBasePosition::~OverlayObjectWithBasePosition()
     185             :         {
     186           6 :         }
     187             : 
     188           0 :         void OverlayObjectWithBasePosition::setBasePosition(const basegfx::B2DPoint& rNew)
     189             :         {
     190           0 :             if(rNew != maBasePosition)
     191             :             {
     192             :                 // remember new value
     193           0 :                 maBasePosition = rNew;
     194             : 
     195             :                 // register change (after change)
     196           0 :                 objectChange();
     197             :             }
     198           0 :         }
     199             :     } // end of namespace overlay
     200             : } // end of namespace sdr
     201             : 
     202             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10