LCOV - code coverage report
Current view: top level - chart2/source/tools - LinePropertiesHelper.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 51 55 92.7 %
Date: 2014-04-11 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         168 : 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         168 :                   ::getCppuType( reinterpret_cast< const drawing::LineStyle * >(0)),
      42             :                   beans::PropertyAttribute::BOUND
      43         336 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
      44             : 
      45             :      rOutProperties.push_back(
      46             :          Property( "LineDash",
      47             :                    PROP_LINE_DASH,
      48         168 :                    ::getCppuType( reinterpret_cast< const drawing::LineDash * >(0)),
      49             :                    beans::PropertyAttribute::BOUND
      50         336 :                    | beans::PropertyAttribute::MAYBEVOID ));
      51             : 
      52             : //not in service description
      53             :     rOutProperties.push_back(
      54             :         Property( "LineDashName",
      55             :                   PROP_LINE_DASH_NAME,
      56         168 :                   ::getCppuType( reinterpret_cast< const OUString * >(0)),
      57             :                   beans::PropertyAttribute::BOUND
      58             :                   | beans::PropertyAttribute::MAYBEDEFAULT
      59         336 :                   | beans::PropertyAttribute::MAYBEVOID ));
      60             : 
      61             :     rOutProperties.push_back(
      62             :         Property( "LineColor",
      63             :                   PROP_LINE_COLOR,
      64         168 :                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
      65             :                   beans::PropertyAttribute::BOUND
      66         336 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
      67             : 
      68             :     rOutProperties.push_back(
      69             :         Property( "LineTransparence",
      70             :                   PROP_LINE_TRANSPARENCE,
      71         168 :                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
      72             :                   beans::PropertyAttribute::BOUND
      73         336 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
      74             : 
      75             :     rOutProperties.push_back(
      76             :         Property( "LineWidth",
      77             :                   PROP_LINE_WIDTH,
      78         168 :                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
      79             :                   beans::PropertyAttribute::BOUND
      80         336 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
      81             : 
      82             :     rOutProperties.push_back(
      83             :         Property( "LineJoint",
      84             :                   PROP_LINE_JOINT,
      85         168 :                   ::getCppuType( reinterpret_cast< const drawing::LineJoint * >(0)),
      86             :                   beans::PropertyAttribute::BOUND
      87         336 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
      88         168 : }
      89             : 
      90          89 : void LinePropertiesHelper::AddDefaultsToMap(
      91             :     ::chart::tPropertyValueMap & rOutMap )
      92             : {
      93          89 :     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_STYLE, drawing::LineStyle_SOLID );
      94          89 :     ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINE_WIDTH, 0 );
      95          89 :     ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINE_COLOR, 0x000000 );  // black
      96          89 :     ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_LINE_TRANSPARENCE, 0 );
      97          89 :     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_JOINT, drawing::LineJoint_ROUND );
      98          89 : }
      99             : 
     100        4706 : bool LinePropertiesHelper::IsLineVisible( const ::com::sun::star::uno::Reference<
     101             :         ::com::sun::star::beans::XPropertySet >& xLineProperties )
     102             : {
     103        4706 :     bool bRet = false;
     104             :     try
     105             :     {
     106        4706 :         if( xLineProperties.is() )
     107             :         {
     108        4706 :             drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
     109        4706 :             xLineProperties->getPropertyValue( "LineStyle" ) >>= aLineStyle;
     110        4706 :             if( aLineStyle != drawing::LineStyle_NONE )
     111             :             {
     112        4486 :                 sal_Int16 nLineTransparence=0;
     113        4486 :                 xLineProperties->getPropertyValue( "LineTransparence" ) >>= nLineTransparence;
     114        4486 :                 if(100!=nLineTransparence)
     115             :                 {
     116        4486 :                     bRet = true;
     117             :                 }
     118             :             }
     119             :         }
     120             :     }
     121           0 :     catch( const uno::Exception & ex )
     122             :     {
     123             :         ASSERT_EXCEPTION( ex );
     124             :     }
     125        4706 :     return bRet;
     126             : }
     127             : 
     128         442 : void LinePropertiesHelper::SetLineVisible( const ::com::sun::star::uno::Reference<
     129             :     ::com::sun::star::beans::XPropertySet >& xLineProperties )
     130             : {
     131             :     try
     132             :     {
     133         442 :         if( xLineProperties.is() )
     134             :         {
     135         442 :             drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
     136         442 :             xLineProperties->getPropertyValue( "LineStyle" ) >>= aLineStyle;
     137         442 :             if( aLineStyle == drawing::LineStyle_NONE )
     138          12 :                 xLineProperties->setPropertyValue( "LineStyle", uno::makeAny( drawing::LineStyle_SOLID ) );
     139             : 
     140         442 :             sal_Int16 nLineTransparence=0;
     141         442 :             xLineProperties->getPropertyValue( "LineTransparence" ) >>= nLineTransparence;
     142         442 :             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         442 : }
     151             : 
     152        1054 : void LinePropertiesHelper::SetLineInvisible( const ::com::sun::star::uno::Reference<
     153             :     ::com::sun::star::beans::XPropertySet >& xLineProperties )
     154             : {
     155             :     try
     156             :     {
     157        1054 :         if( xLineProperties.is() )
     158             :         {
     159        1054 :             drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
     160        1054 :             xLineProperties->getPropertyValue( "LineStyle" ) >>= aLineStyle;
     161        1054 :             if( aLineStyle != drawing::LineStyle_NONE )
     162        1054 :                 xLineProperties->setPropertyValue( "LineStyle", uno::makeAny( drawing::LineStyle_NONE ) );
     163             :         }
     164             :     }
     165           0 :     catch( const uno::Exception & ex )
     166             :     {
     167             :         ASSERT_EXCEPTION( ex );
     168             :     }
     169        1054 : }
     170             : 
     171             : } //  namespace chart
     172             : 
     173             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10