LCOV - code coverage report
Current view: top level - xmloff/source/chart - ColorPropertySet.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 20 47 42.6 %
Date: 2015-06-13 12:38:46 Functions: 10 20 50.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 "ColorPropertySet.hxx"
      21             : 
      22             : #include <cppuhelper/implbase1.hxx>
      23             : 
      24             : #include <osl/diagnose.h>
      25             : 
      26             : using namespace ::com::sun::star;
      27             : using namespace ::com::sun::star::beans;
      28             : 
      29             : using ::com::sun::star::uno::Reference;
      30             : using ::com::sun::star::uno::Sequence;
      31             : using ::com::sun::star::uno::RuntimeException;
      32             : 
      33             : namespace
      34             : {
      35          48 : class lcl_ColorPropertySetInfo : public ::cppu::WeakImplHelper1<
      36             :         XPropertySetInfo  >
      37             : {
      38             : public:
      39             :     explicit lcl_ColorPropertySetInfo( bool bFillColor );
      40             : 
      41             : protected:
      42             :     // ____ XPropertySetInfo ____
      43             :     virtual Sequence< Property > SAL_CALL getProperties()                throw (RuntimeException, std::exception) SAL_OVERRIDE;
      44             :     virtual Property SAL_CALL getPropertyByName( const OUString& aName ) throw (UnknownPropertyException, RuntimeException, std::exception) SAL_OVERRIDE;
      45             :     virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name )  throw (RuntimeException, std::exception) SAL_OVERRIDE;
      46             : 
      47             : private:
      48             :     OUString m_aColorPropName;
      49             :     Property m_aColorProp;
      50             : };
      51             : 
      52          24 : lcl_ColorPropertySetInfo::lcl_ColorPropertySetInfo( bool bFillColor ) :
      53             :         // note: length of FillColor and LineColor is 9
      54             :         m_aColorPropName( (bFillColor ? "FillColor" : "LineColor"), 9, RTL_TEXTENCODING_ASCII_US ),
      55             :         m_aColorProp( m_aColorPropName, -1,
      56          24 :                       cppu::UnoType<sal_Int32>::get(), 0)
      57          24 : {}
      58             : 
      59           0 : Sequence< Property > SAL_CALL lcl_ColorPropertySetInfo::getProperties()
      60             :     throw (RuntimeException, std::exception)
      61             : {
      62             : 
      63           0 :     return Sequence< Property >( & m_aColorProp, 1 );
      64             : }
      65             : 
      66           0 : Property SAL_CALL lcl_ColorPropertySetInfo::getPropertyByName( const OUString& aName )
      67             :     throw (UnknownPropertyException, RuntimeException, std::exception)
      68             : {
      69           0 :     if( aName.equals( m_aColorPropName ))
      70           0 :         return m_aColorProp;
      71           0 :     throw UnknownPropertyException( m_aColorPropName, static_cast< uno::XWeak * >( this ));
      72             : }
      73             : 
      74       10176 : sal_Bool SAL_CALL lcl_ColorPropertySetInfo::hasPropertyByName( const OUString& Name )
      75             :     throw (RuntimeException, std::exception)
      76             : {
      77       10176 :     return Name.equals( m_aColorPropName );
      78             : }
      79             : 
      80             : } // anonymous namespace
      81             : 
      82             : namespace xmloff
      83             : {
      84             : namespace chart
      85             : {
      86             : 
      87          24 : ColorPropertySet::ColorPropertySet( sal_Int32 nColor, bool bFillColor /* = true */ ) :
      88             :         // note: length of FillColor and LineColor is 9
      89             :         m_aColorPropName( (bFillColor ? "FillColor" : "LineColor"), 9, RTL_TEXTENCODING_ASCII_US ),
      90             :         m_nColor( nColor ),
      91             :         m_bIsFillColor( bFillColor ),
      92          24 :         m_nDefaultColor( 0x0099ccff )  // blue 8
      93          24 : {}
      94             : 
      95          48 : ColorPropertySet::~ColorPropertySet()
      96          48 : {}
      97             : 
      98             : // ____ XPropertySet ____
      99             : 
     100          24 : Reference< XPropertySetInfo > SAL_CALL ColorPropertySet::getPropertySetInfo()
     101             :     throw (uno::RuntimeException, std::exception)
     102             : {
     103          24 :     if( ! m_xInfo.is())
     104          24 :         m_xInfo.set( new lcl_ColorPropertySetInfo( m_bIsFillColor ));
     105             : 
     106          24 :     return m_xInfo;
     107             : }
     108             : 
     109           0 : void SAL_CALL ColorPropertySet::setPropertyValue( const OUString& /* aPropertyName */, const uno::Any& aValue )
     110             :     throw (UnknownPropertyException,
     111             :            PropertyVetoException,
     112             :            lang::IllegalArgumentException,
     113             :            lang::WrappedTargetException,
     114             :            uno::RuntimeException, std::exception)
     115             : {
     116           0 :     aValue >>= m_nColor;
     117           0 : }
     118             : 
     119          24 : uno::Any SAL_CALL ColorPropertySet::getPropertyValue( const OUString& /* PropertyName */ )
     120             :     throw (UnknownPropertyException,
     121             :            lang::WrappedTargetException,
     122             :            uno::RuntimeException, std::exception)
     123             : {
     124          24 :     return uno::makeAny( m_nColor );
     125             : }
     126             : 
     127           0 : void SAL_CALL ColorPropertySet::addPropertyChangeListener( const OUString& /* aPropertyName */, const Reference< XPropertyChangeListener >& /* xListener */ )
     128             :     throw (UnknownPropertyException,
     129             :            lang::WrappedTargetException,
     130             :            uno::RuntimeException, std::exception)
     131             : {
     132             :     OSL_FAIL( "Not Implemented" );
     133           0 :     return;
     134             : }
     135             : 
     136           0 : void SAL_CALL ColorPropertySet::removePropertyChangeListener( const OUString& /* aPropertyName */, const Reference< XPropertyChangeListener >& /* aListener */ )
     137             :     throw (UnknownPropertyException,
     138             :            lang::WrappedTargetException,
     139             :            uno::RuntimeException, std::exception)
     140             : {
     141             :     OSL_FAIL( "Not Implemented" );
     142           0 :     return;
     143             : }
     144             : 
     145           0 : void SAL_CALL ColorPropertySet::addVetoableChangeListener( const OUString& /* PropertyName */, const Reference< XVetoableChangeListener >& /* aListener */ )
     146             :     throw (UnknownPropertyException,
     147             :            lang::WrappedTargetException,
     148             :            uno::RuntimeException, std::exception)
     149             : {
     150             :     OSL_FAIL( "Not Implemented" );
     151           0 :     return;
     152             : }
     153             : 
     154           0 : void SAL_CALL ColorPropertySet::removeVetoableChangeListener( const OUString& /* PropertyName */, const Reference< XVetoableChangeListener >& /* aListener */ )
     155             :     throw (UnknownPropertyException,
     156             :            lang::WrappedTargetException,
     157             :            uno::RuntimeException, std::exception)
     158             : {
     159             :     OSL_FAIL( "Not Implemented" );
     160           0 :     return;
     161             : }
     162             : 
     163             : // ____ XPropertyState ____
     164             : 
     165           0 : PropertyState SAL_CALL ColorPropertySet::getPropertyState( const OUString& /* PropertyName */ )
     166             :     throw (UnknownPropertyException,
     167             :            uno::RuntimeException, std::exception)
     168             : {
     169           0 :     return PropertyState_DIRECT_VALUE;
     170             : }
     171             : 
     172          24 : Sequence< PropertyState > SAL_CALL ColorPropertySet::getPropertyStates( const Sequence< OUString >& /* aPropertyName */ )
     173             :     throw (UnknownPropertyException,
     174             :            uno::RuntimeException, std::exception)
     175             : {
     176          24 :     PropertyState aState = PropertyState_DIRECT_VALUE;
     177          24 :     return Sequence< PropertyState >( & aState, 1 );
     178             : }
     179             : 
     180           0 : void SAL_CALL ColorPropertySet::setPropertyToDefault( const OUString& PropertyName )
     181             :     throw (UnknownPropertyException,
     182             :            uno::RuntimeException, std::exception)
     183             : {
     184           0 :     if( PropertyName.equals( m_aColorPropName ))
     185           0 :         m_nColor = m_nDefaultColor;
     186           0 : }
     187             : 
     188           0 : uno::Any SAL_CALL ColorPropertySet::getPropertyDefault( const OUString& aPropertyName )
     189             :     throw (UnknownPropertyException,
     190             :            lang::WrappedTargetException,
     191             :            uno::RuntimeException, std::exception)
     192             : {
     193           0 :     if( aPropertyName.equals( m_aColorPropName ))
     194           0 :         return uno::makeAny( m_nDefaultColor );
     195           0 :     return uno::Any();
     196             : }
     197             : 
     198             : } //  namespace chart
     199             : } //  namespace xmloff
     200             : 
     201             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11