LCOV - code coverage report
Current view: top level - sfx2/source/sidebar - Paint.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 28 34 82.4 %
Date: 2014-04-11 Functions: 8 8 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             : #include "Paint.hxx"
      20             : #include <sfx2/sidebar/Tools.hxx>
      21             : #include <com/sun/star/awt/Gradient.hpp>
      22             : 
      23             : 
      24             : using namespace ::com::sun::star;
      25             : 
      26             : namespace sfx2 { namespace sidebar {
      27             : 
      28          70 : Paint::Paint (void)
      29          70 :     : meType(NoPaint)
      30             : {
      31          70 : }
      32             : 
      33             : 
      34             : 
      35             : 
      36          55 : Paint::Paint (const Color& rColor)
      37             :     : meType(ColorPaint),
      38          55 :       maValue(rColor)
      39             : {
      40          55 : }
      41             : 
      42             : 
      43             : 
      44             : 
      45          10 : Paint::Paint (const Gradient& rGradient)
      46             :     : meType(GradientPaint),
      47          10 :       maValue(rGradient)
      48             : {
      49          10 : }
      50             : 
      51             : 
      52             : 
      53             : 
      54          65 : Paint Paint::Create (const cssu::Any& rValue)
      55             : {
      56          65 :     ColorData aColor (0);
      57          65 :     if (rValue >>= aColor)
      58          55 :         return Paint(Color(aColor));
      59             : 
      60          10 :     awt::Gradient aAwtGradient;
      61          10 :     if (rValue >>= aAwtGradient)
      62          10 :         return Paint(Tools::AwtToVclGradient(aAwtGradient));
      63             : 
      64           0 :     return Paint();
      65             : }
      66             : 
      67             : 
      68             : 
      69             : 
      70         317 : Paint::Type Paint::GetType (void) const
      71             : {
      72         317 :     return meType;
      73             : }
      74             : 
      75             : 
      76             : 
      77             : 
      78         338 : const Color& Paint::GetColor (void) const
      79             : {
      80         338 :     if (meType != ColorPaint)
      81             :     {
      82             :         assert(meType==ColorPaint);
      83           0 :         static Color aErrorColor;
      84           0 :         return aErrorColor;
      85             :     }
      86             :     else
      87         338 :         return ::boost::get<Color>(maValue);
      88             : }
      89             : 
      90             : 
      91             : 
      92             : 
      93          11 : const Gradient& Paint::GetGradient (void) const
      94             : {
      95          11 :     if (meType != GradientPaint)
      96             :     {
      97             :         assert(meType==GradientPaint);
      98           0 :         static Gradient aErrorGradient;
      99           0 :         return aErrorGradient;
     100             :     }
     101             :     else
     102          11 :         return ::boost::get<Gradient>(maValue);
     103             : }
     104             : 
     105             : 
     106             : 
     107             : 
     108         149 : Wallpaper Paint::GetWallpaper (void) const
     109             : {
     110         149 :     switch (meType)
     111             :     {
     112             :         case Paint::NoPaint:
     113             :         default:
     114           0 :             return Wallpaper();
     115             :             break;
     116             : 
     117             :         case Paint::ColorPaint:
     118         138 :             return Wallpaper(GetColor());
     119             :             break;
     120             : 
     121             :         case Paint::GradientPaint:
     122          11 :             return Wallpaper(GetGradient());
     123             :             break;
     124             :     }
     125             : }
     126             : 
     127             : 
     128             : } } // end of namespace sfx2::sidebar
     129             : 
     130             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10