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

Generated by: LCOV version 1.10