LCOV - code coverage report
Current view: top level - svx/source/sdr/overlay - overlayrectangle.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 24 26 92.3 %
Date: 2015-06-13 12:38:46 Functions: 3 3 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 <sdr/overlay/overlayrectangle.hxx>
      21             : #include <vcl/outdev.hxx>
      22             : #include <basegfx/matrix/b2dhommatrix.hxx>
      23             : #include <basegfx/polygon/b2dpolygontools.hxx>
      24             : #include <basegfx/polygon/b2dpolygon.hxx>
      25             : #include <basegfx/numeric/ftools.hxx>
      26             : #include <sdr/overlay/overlaytools.hxx>
      27             : #include <svx/sdr/overlay/overlaymanager.hxx>
      28             : #include <vcl/svapp.hxx>
      29             : #include <vcl/settings.hxx>
      30             : 
      31             : 
      32             : 
      33             : namespace sdr
      34             : {
      35             :     namespace overlay
      36             :     {
      37          24 :         drawinglayer::primitive2d::Primitive2DSequence OverlayRectangle::createOverlayObjectPrimitive2DSequence()
      38             :         {
      39          24 :             const basegfx::B2DRange aHatchRange(getBasePosition(), maSecondPosition);
      40          24 :             basegfx::BColor aColor(getBaseColor().getBColor());
      41             :             static double fChange(0.1); // just small optical change, do not make it annoying
      42             : 
      43          24 :             if(mbOverlayState)
      44             :             {
      45          12 :                 aColor += basegfx::B3DTuple(fChange, fChange, fChange);
      46          12 :                 aColor.clamp();
      47             :             }
      48             :             else
      49             :             {
      50          12 :                 aColor -= basegfx::B3DTuple(fChange, fChange, fChange);
      51          12 :                 aColor.clamp();
      52             :             }
      53             : 
      54             :             const drawinglayer::primitive2d::Primitive2DReference aReference(
      55             :                 new drawinglayer::primitive2d::OverlayRectanglePrimitive(
      56             :                     aHatchRange,
      57             :                     aColor,
      58             :                     getTransparence(),
      59             :                     getDiscreteGrow(),
      60             :                     getDiscreteShrink(),
      61          48 :                     getRotation()));
      62             : 
      63          48 :             return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
      64             :         }
      65             : 
      66          12 :         OverlayRectangle::OverlayRectangle(
      67             :             const basegfx::B2DPoint& rBasePosition,
      68             :             const basegfx::B2DPoint& rSecondPosition,
      69             :             const Color& rHatchColor,
      70             :             double fTransparence,
      71             :             double fDiscreteGrow,
      72             :             double fDiscreteShrink,
      73             :             double fRotation,
      74             :             sal_uInt64 nBlinkTime,
      75             :             bool bAnimate)
      76             :         :   OverlayObjectWithBasePosition(rBasePosition, rHatchColor),
      77             :             maSecondPosition(rSecondPosition),
      78             :             mfTransparence(fTransparence),
      79             :             mfDiscreteGrow(fDiscreteGrow),
      80             :             mfDiscreteShrink(fDiscreteShrink),
      81             :             mfRotation(fRotation),
      82          12 :             mnBlinkTime(impCheckBlinkTimeValueRange(nBlinkTime)),
      83          24 :             mbOverlayState(false)
      84             :         {
      85          12 :             if(Application::GetSettings().GetStyleSettings().GetHighContrastMode())
      86             :             {
      87             :                 // no animation in high contrast mode
      88           0 :                 bAnimate = false;
      89             :             }
      90             : 
      91             :             // set AllowsAnimation flag to mark this object as animation capable
      92          12 :             mbAllowsAnimation = bAnimate;
      93          12 :         }
      94             : 
      95          12 :         void OverlayRectangle::Trigger(sal_uInt32 nTime)
      96             :         {
      97          12 :             if(getOverlayManager())
      98             :             {
      99             :                 // #i53216# produce event after nTime + x
     100          12 :                 SetTime(nTime + mnBlinkTime);
     101             : 
     102             :                 // switch state
     103          12 :                 if(mbOverlayState)
     104             :                 {
     105           0 :                     mbOverlayState = false;
     106             :                 }
     107             :                 else
     108             :                 {
     109          12 :                     mbOverlayState = true;
     110             :                 }
     111             : 
     112             :                 // re-insert me as event
     113          12 :                 getOverlayManager()->InsertEvent(this);
     114             : 
     115             :                 // register change (after change)
     116          12 :                 objectChange();
     117             :             }
     118          12 :         }
     119             :     } // end of namespace overlay
     120             : } // end of namespace sdr
     121             : 
     122             : 
     123             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11