LCOV - code coverage report
Current view: top level - drawinglayer/source/primitive2d - backgroundcolorprimitive2d.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 21 24 87.5 %
Date: 2015-06-13 12:38:46 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          72 :         Primitive2DSequence BackgroundColorPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
      39             :         {
      40          72 :             if(!rViewInformation.getViewport().isEmpty())
      41             :             {
      42          72 :                 const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(rViewInformation.getViewport()));
      43         144 :                 const Primitive2DReference xRef(new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aOutline), getBColor()));
      44         144 :                 return Primitive2DSequence(&xRef, 1L);
      45             :             }
      46             :             else
      47             :             {
      48           0 :                 return Primitive2DSequence();
      49             :             }
      50             :         }
      51             : 
      52        2582 :         BackgroundColorPrimitive2D::BackgroundColorPrimitive2D(
      53             :             const basegfx::BColor& rBColor)
      54             :         :   BufferedDecompositionPrimitive2D(),
      55             :             maBColor(rBColor),
      56        2582 :             maLastViewport()
      57             :         {
      58        2582 :         }
      59             : 
      60        1951 :         bool BackgroundColorPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
      61             :         {
      62        1951 :             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
      63             :             {
      64        1951 :                 const BackgroundColorPrimitive2D& rCompare = static_cast<const BackgroundColorPrimitive2D&>(rPrimitive);
      65             : 
      66        1951 :                 return (getBColor() == rCompare.getBColor());
      67             :             }
      68             : 
      69           0 :             return false;
      70             :         }
      71             : 
      72        5698 :         basegfx::B2DRange BackgroundColorPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const
      73             :         {
      74             :             // always as big as the view
      75        5698 :             return rViewInformation.getViewport();
      76             :         }
      77             : 
      78          72 :         Primitive2DSequence BackgroundColorPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
      79             :         {
      80          72 :             ::osl::MutexGuard aGuard( m_aMutex );
      81             : 
      82          72 :             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          72 :             if(!getBuffered2DDecomposition().hasElements())
      89             :             {
      90             :                 // remember ViewRange
      91          72 :                 const_cast< BackgroundColorPrimitive2D* >(this)->maLastViewport = rViewInformation.getViewport();
      92             :             }
      93             : 
      94             :             // use parent implementation
      95          72 :             return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation);
      96             :         }
      97             : 
      98             :         // provide unique ID
      99        7018 :         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.11