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

Generated by: LCOV version 1.10