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

Generated by: LCOV version 1.10