LCOV - code coverage report
Current view: top level - chart2/source/tools - LinePropertiesHelper.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 51 55 92.7 %
Date: 2015-06-13 12:38:46 Functions: 5 5 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             : 
      20             : #include "LinePropertiesHelper.hxx"
      21             : #include "macros.hxx"
      22             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      23             : #include <com/sun/star/drawing/LineStyle.hpp>
      24             : #include <com/sun/star/drawing/LineDash.hpp>
      25             : #include <com/sun/star/drawing/LineJoint.hpp>
      26             : 
      27             : using namespace ::com::sun::star;
      28             : 
      29             : using ::com::sun::star::beans::Property;
      30             : 
      31             : namespace chart
      32             : {
      33             : 
      34         181 : void LinePropertiesHelper::AddPropertiesToVector(
      35             :     ::std::vector< Property > & rOutProperties )
      36             : {
      37             :     // Line Properties see service drawing::LineProperties
      38             :     rOutProperties.push_back(
      39             :         Property( "LineStyle",
      40             :                   PROP_LINE_STYLE,
      41         181 :                   cppu::UnoType<drawing::LineStyle>::get(),
      42             :                   beans::PropertyAttribute::BOUND
      43         362 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
      44             : 
      45             :      rOutProperties.push_back(
      46             :          Property( "LineDash",
      47             :                    PROP_LINE_DASH,
      48         181 :                    cppu::UnoType<drawing::LineDash>::get(),
      49             :                    beans::PropertyAttribute::BOUND
      50         362 :                    | beans::PropertyAttribute::MAYBEVOID ));
      51             : 
      52             : //not in service description
      53             :     rOutProperties.push_back(
      54             :         Property( "LineDashName",
      55             :                   PROP_LINE_DASH_NAME,
      56         181 :                   cppu::UnoType<OUString>::get(),
      57             :                   beans::PropertyAttribute::BOUND
      58             :                   | beans::PropertyAttribute::MAYBEDEFAULT
      59         362 :                   | beans::PropertyAttribute::MAYBEVOID ));
      60             : 
      61             :     rOutProperties.push_back(
      62             :         Property( "LineColor",
      63             :                   PROP_LINE_COLOR,
      64         181 :                   cppu::UnoType<sal_Int32>::get(),
      65             :                   beans::PropertyAttribute::BOUND
      66         362 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
      67             : 
      68             :     rOutProperties.push_back(
      69             :         Property( "LineTransparence",
      70             :                   PROP_LINE_TRANSPARENCE,
      71         181 :                   cppu::UnoType<sal_Int16>::get(),
      72             :                   beans::PropertyAttribute::BOUND
      73         362 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
      74             : 
      75             :     rOutProperties.push_back(
      76             :         Property( "LineWidth",
      77             :                   PROP_LINE_WIDTH,
      78         181 :                   cppu::UnoType<sal_Int32>::get(),
      79             :                   beans::PropertyAttribute::BOUND
      80         362 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
      81             : 
      82             :     rOutProperties.push_back(
      83             :         Property( "LineJoint",
      84             :                   PROP_LINE_JOINT,
      85         181 :                   cppu::UnoType<drawing::LineJoint>::get(),
      86             :                   beans::PropertyAttribute::BOUND
      87         362 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
      88         181 : }
      89             : 
      90          98 : void LinePropertiesHelper::AddDefaultsToMap(
      91             :     ::chart::tPropertyValueMap & rOutMap )
      92             : {
      93          98 :     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_STYLE, drawing::LineStyle_SOLID );
      94          98 :     ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINE_WIDTH, 0 );
      95          98 :     ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINE_COLOR, 0x000000 );  // black
      96          98 :     ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_LINE_TRANSPARENCE, 0 );
      97          98 :     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_JOINT, drawing::LineJoint_ROUND );
      98          98 : }
      99             : 
     100        5689 : bool LinePropertiesHelper::IsLineVisible( const ::com::sun::star::uno::Reference<
     101             :         ::com::sun::star::beans::XPropertySet >& xLineProperties )
     102             : {
     103        5689 :     bool bRet = false;
     104             :     try
     105             :     {
     106        5689 :         if( xLineProperties.is() )
     107             :         {
     108        5689 :             drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
     109        5689 :             xLineProperties->getPropertyValue( "LineStyle" ) >>= aLineStyle;
     110        5689 :             if( aLineStyle != drawing::LineStyle_NONE )
     111             :             {
     112        5495 :                 sal_Int16 nLineTransparence=0;
     113        5495 :                 xLineProperties->getPropertyValue( "LineTransparence" ) >>= nLineTransparence;
     114        5495 :                 if(100!=nLineTransparence)
     115             :                 {
     116        5495 :                     bRet = true;
     117             :                 }
     118             :             }
     119             :         }
     120             :     }
     121           0 :     catch( const uno::Exception & ex )
     122             :     {
     123             :         ASSERT_EXCEPTION( ex );
     124             :     }
     125        5689 :     return bRet;
     126             : }
     127             : 
     128         357 : void LinePropertiesHelper::SetLineVisible( const ::com::sun::star::uno::Reference<
     129             :     ::com::sun::star::beans::XPropertySet >& xLineProperties )
     130             : {
     131             :     try
     132             :     {
     133         357 :         if( xLineProperties.is() )
     134             :         {
     135         357 :             drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
     136         357 :             xLineProperties->getPropertyValue( "LineStyle" ) >>= aLineStyle;
     137         357 :             if( aLineStyle == drawing::LineStyle_NONE )
     138           5 :                 xLineProperties->setPropertyValue( "LineStyle", uno::makeAny( drawing::LineStyle_SOLID ) );
     139             : 
     140         357 :             sal_Int16 nLineTransparence=0;
     141         357 :             xLineProperties->getPropertyValue( "LineTransparence" ) >>= nLineTransparence;
     142         357 :             if(100==nLineTransparence)
     143           0 :                 xLineProperties->setPropertyValue( "LineTransparence", uno::makeAny( sal_Int16(0) ) );
     144             :         }
     145             :     }
     146           0 :     catch( const uno::Exception & ex )
     147             :     {
     148             :         ASSERT_EXCEPTION( ex );
     149             :     }
     150         357 : }
     151             : 
     152        1225 : void LinePropertiesHelper::SetLineInvisible( const ::com::sun::star::uno::Reference<
     153             :     ::com::sun::star::beans::XPropertySet >& xLineProperties )
     154             : {
     155             :     try
     156             :     {
     157        1225 :         if( xLineProperties.is() )
     158             :         {
     159        1225 :             drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
     160        1225 :             xLineProperties->getPropertyValue( "LineStyle" ) >>= aLineStyle;
     161        1225 :             if( aLineStyle != drawing::LineStyle_NONE )
     162        1225 :                 xLineProperties->setPropertyValue( "LineStyle", uno::makeAny( drawing::LineStyle_NONE ) );
     163             :         }
     164             :     }
     165           0 :     catch( const uno::Exception & ex )
     166             :     {
     167             :         ASSERT_EXCEPTION( ex );
     168             :     }
     169        1225 : }
     170             : 
     171             : } //  namespace chart
     172             : 
     173             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11