LCOV - code coverage report
Current view: top level - sfx2/source/sidebar - Paint.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 26 32 81.2 %
Date: 2015-06-13 12:38:46 Functions: 7 7 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             : using namespace css;
      24             : 
      25             : namespace sfx2 { namespace sidebar {
      26             : 
      27        1358 : Paint::Paint()
      28        1358 :     : meType(NoPaint)
      29             : {
      30        1358 : }
      31             : 
      32        1067 : Paint::Paint (const Color& rColor)
      33             :     : meType(ColorPaint),
      34        1067 :       maValue(rColor)
      35             : {
      36        1067 : }
      37             : 
      38         194 : Paint::Paint (const Gradient& rGradient)
      39             :     : meType(GradientPaint),
      40         194 :       maValue(rGradient)
      41             : {
      42         194 : }
      43             : 
      44        1261 : Paint Paint::Create (const css::uno::Any& rValue)
      45             : {
      46        1261 :     ColorData aColor (0);
      47        1261 :     if (rValue >>= aColor)
      48        1067 :         return Paint(Color(aColor));
      49             : 
      50         194 :     awt::Gradient aAwtGradient;
      51         194 :     if (rValue >>= aAwtGradient)
      52         194 :         return Paint(Tools::AwtToVclGradient(aAwtGradient));
      53             : 
      54           0 :     return Paint();
      55             : }
      56             : 
      57       15494 : const Color& Paint::GetColor() const
      58             : {
      59       15494 :     if (meType != ColorPaint)
      60             :     {
      61             :         assert(meType==ColorPaint);
      62           0 :         static Color aErrorColor;
      63           0 :         return aErrorColor;
      64             :     }
      65             :     else
      66       15494 :         return ::boost::get<Color>(maValue);
      67             : }
      68             : 
      69          20 : const Gradient& Paint::GetGradient() const
      70             : {
      71          20 :     if (meType != GradientPaint)
      72             :     {
      73             :         assert(meType==GradientPaint);
      74           0 :         static Gradient aErrorGradient;
      75           0 :         return aErrorGradient;
      76             :     }
      77             :     else
      78          20 :         return ::boost::get<Gradient>(maValue);
      79             : }
      80             : 
      81       14266 : Wallpaper Paint::GetWallpaper() const
      82             : {
      83       14266 :     switch (meType)
      84             :     {
      85             :         case Paint::NoPaint:
      86             :         default:
      87           0 :             return Wallpaper();
      88             :             break;
      89             : 
      90             :         case Paint::ColorPaint:
      91       14246 :             return Wallpaper(GetColor());
      92             :             break;
      93             : 
      94             :         case Paint::GradientPaint:
      95          20 :             return Wallpaper(GetGradient());
      96             :             break;
      97             :     }
      98             : }
      99             : 
     100             : } } // end of namespace sfx2::sidebar
     101             : 
     102             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11