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