LCOV - code coverage report
Current view: top level - drawinglayer/source/primitive2d - backgroundcolorprimitive2d.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 21 24 87.5 %
Date: 2014-11-03 Functions: 6 6 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 <drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx>
      21             : #include <basegfx/polygon/b2dpolygon.hxx>
      22             : #include <basegfx/polygon/b2dpolygontools.hxx>
      23             : #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
      24             : #include <basegfx/tools/canvastools.hxx>
      25             : #include <drawinglayer/geometry/viewinformation2d.hxx>
      26             : #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
      27             : 
      28             : 
      29             : 
      30             : using namespace com::sun::star;
      31             : 
      32             : 
      33             : 
      34             : namespace drawinglayer
      35             : {
      36             :     namespace primitive2d
      37             :     {
      38         122 :         Primitive2DSequence BackgroundColorPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
      39             :         {
      40         122 :             if(!rViewInformation.getViewport().isEmpty())
      41             :             {
      42         122 :                 const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(rViewInformation.getViewport()));
      43         244 :                 const Primitive2DReference xRef(new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aOutline), getBColor()));
      44         244 :                 return Primitive2DSequence(&xRef, 1L);
      45             :             }
      46             :             else
      47             :             {
      48           0 :                 return Primitive2DSequence();
      49             :             }
      50             :         }
      51             : 
      52        2063 :         BackgroundColorPrimitive2D::BackgroundColorPrimitive2D(
      53             :             const basegfx::BColor& rBColor)
      54             :         :   BufferedDecompositionPrimitive2D(),
      55             :             maBColor(rBColor),
      56        2063 :             maLastViewport()
      57             :         {
      58        2063 :         }
      59             : 
      60        2168 :         bool BackgroundColorPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
      61             :         {
      62        2168 :             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
      63             :             {
      64        2168 :                 const BackgroundColorPrimitive2D& rCompare = static_cast<const BackgroundColorPrimitive2D&>(rPrimitive);
      65             : 
      66        2168 :                 return (getBColor() == rCompare.getBColor());
      67             :             }
      68             : 
      69           0 :             return false;
      70             :         }
      71             : 
      72        4020 :         basegfx::B2DRange BackgroundColorPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const
      73             :         {
      74             :             // always as big as the view
      75        4020 :             return rViewInformation.getViewport();
      76             :         }
      77             : 
      78         122 :         Primitive2DSequence BackgroundColorPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
      79             :         {
      80         122 :             ::osl::MutexGuard aGuard( m_aMutex );
      81             : 
      82         122 :             if(getBuffered2DDecomposition().hasElements() && (maLastViewport != rViewInformation.getViewport()))
      83             :             {
      84             :                 // conditions of last local decomposition have changed, delete
      85           0 :                 const_cast< BackgroundColorPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence());
      86             :             }
      87             : 
      88         122 :             if(!getBuffered2DDecomposition().hasElements())
      89             :             {
      90             :                 // remember ViewRange
      91         122 :                 const_cast< BackgroundColorPrimitive2D* >(this)->maLastViewport = rViewInformation.getViewport();
      92             :             }
      93             : 
      94             :             // use parent implementation
      95         122 :             return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation);
      96             :         }
      97             : 
      98             :         // provide unique ID
      99        6293 :         ImplPrimitive2DIDBlock(BackgroundColorPrimitive2D, PRIMITIVE2D_ID_BACKGROUNDCOLORPRIMITIVE2D)
     100             : 
     101             :     } // end of namespace primitive2d
     102             : } // end of namespace drawinglayer
     103             : 
     104             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10