LCOV - code coverage report
Current view: top level - drawinglayer/source/primitive2d - backgroundcolorprimitive2d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 20 24 83.3 %
Date: 2012-08-25 Functions: 6 6 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 10 50 20.0 %

           Branch data     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                 :         98 :         Primitive2DSequence BackgroundColorPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
      39                 :            :         {
      40         [ -  + ]:         98 :             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                 :         98 :                 return Primitive2DSequence();
      49                 :            :             }
      50                 :            :         }
      51                 :            : 
      52                 :       2956 :         BackgroundColorPrimitive2D::BackgroundColorPrimitive2D(
      53                 :            :             const basegfx::BColor& rBColor)
      54                 :            :         :   BufferedDecompositionPrimitive2D(),
      55                 :            :             maBColor(rBColor),
      56         [ +  - ]:       2956 :             maLastViewport()
      57                 :            :         {
      58                 :       2956 :         }
      59                 :            : 
      60                 :       2475 :         bool BackgroundColorPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
      61                 :            :         {
      62         [ +  - ]:       2475 :             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
      63                 :            :             {
      64                 :       2475 :                 const BackgroundColorPrimitive2D& rCompare = (BackgroundColorPrimitive2D&)rPrimitive;
      65                 :            : 
      66                 :       2475 :                 return (getBColor() == rCompare.getBColor());
      67                 :            :             }
      68                 :            : 
      69                 :       2475 :             return false;
      70                 :            :         }
      71                 :            : 
      72                 :       6384 :         basegfx::B2DRange BackgroundColorPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const
      73                 :            :         {
      74                 :            :             // always as big as the view
      75                 :       6384 :             return rViewInformation.getViewport();
      76                 :            :         }
      77                 :            : 
      78                 :         98 :         Primitive2DSequence BackgroundColorPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
      79                 :            :         {
      80         [ +  - ]:         98 :             ::osl::MutexGuard aGuard( m_aMutex );
      81                 :            : 
      82 [ -  + ][ #  # ]:         98 :             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         [ +  - ]:         98 :             if(!getBuffered2DDecomposition().hasElements())
      89                 :            :             {
      90                 :            :                 // remember ViewRange
      91         [ +  - ]:         98 :                 const_cast< BackgroundColorPrimitive2D* >(this)->maLastViewport = rViewInformation.getViewport();
      92                 :            :             }
      93                 :            : 
      94                 :            :             // use parent implementation
      95 [ +  - ][ +  - ]:         98 :             return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation);
      96                 :            :         }
      97                 :            : 
      98                 :            :         // provide unique ID
      99                 :       8378 :         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