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

Generated by: LCOV version 1.10