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

Generated by: LCOV version 1.10