Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / xmloff / source / chart / ColorPropertySet.cxx
bloba14eeec48462e2ebd0b359b9f59e6ed8468894f4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "ColorPropertySet.hxx"
22 #include <cppuhelper/implbase.hxx>
24 #include <osl/diagnose.h>
26 using namespace ::com::sun::star;
27 using namespace ::com::sun::star::beans;
29 using ::com::sun::star::uno::Reference;
30 using ::com::sun::star::uno::Sequence;
31 using ::com::sun::star::uno::RuntimeException;
33 namespace
35 class lcl_ColorPropertySetInfo : public ::cppu::WeakImplHelper<
36 XPropertySetInfo >
38 public:
39 explicit lcl_ColorPropertySetInfo( bool bFillColor );
41 protected:
42 // ____ XPropertySetInfo ____
43 virtual Sequence< Property > SAL_CALL getProperties() throw (RuntimeException, std::exception) override;
44 virtual Property SAL_CALL getPropertyByName( const OUString& aName ) throw (UnknownPropertyException, RuntimeException, std::exception) override;
45 virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) throw (RuntimeException, std::exception) override;
47 private:
48 OUString m_aColorPropName;
49 Property m_aColorProp;
52 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 cppu::UnoType<sal_Int32>::get(), 0)
59 Sequence< Property > SAL_CALL lcl_ColorPropertySetInfo::getProperties()
60 throw (RuntimeException, std::exception)
63 return Sequence< Property >( & m_aColorProp, 1 );
66 Property SAL_CALL lcl_ColorPropertySetInfo::getPropertyByName( const OUString& aName )
67 throw (UnknownPropertyException, RuntimeException, std::exception)
69 if( aName.equals( m_aColorPropName ))
70 return m_aColorProp;
71 throw UnknownPropertyException( m_aColorPropName, static_cast< uno::XWeak * >( this ));
74 sal_Bool SAL_CALL lcl_ColorPropertySetInfo::hasPropertyByName( const OUString& Name )
75 throw (RuntimeException, std::exception)
77 return Name.equals( m_aColorPropName );
80 } // anonymous namespace
82 namespace xmloff
84 namespace chart
87 ColorPropertySet::ColorPropertySet( sal_Int32 nColor ) :
88 // note: length of FillColor and LineColor is 9
89 m_aColorPropName( "FillColor", 9, RTL_TEXTENCODING_ASCII_US ),
90 m_nColor( nColor ),
91 m_bIsFillColor( true ),
92 m_nDefaultColor( 0x0099ccff ) // blue 8
95 ColorPropertySet::~ColorPropertySet()
98 // ____ XPropertySet ____
100 Reference< XPropertySetInfo > SAL_CALL ColorPropertySet::getPropertySetInfo()
101 throw (uno::RuntimeException, std::exception)
103 if( ! m_xInfo.is())
104 m_xInfo.set( new lcl_ColorPropertySetInfo( m_bIsFillColor ));
106 return m_xInfo;
109 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)
116 aValue >>= m_nColor;
119 uno::Any SAL_CALL ColorPropertySet::getPropertyValue( const OUString& /* PropertyName */ )
120 throw (UnknownPropertyException,
121 lang::WrappedTargetException,
122 uno::RuntimeException, std::exception)
124 return uno::makeAny( m_nColor );
127 void SAL_CALL ColorPropertySet::addPropertyChangeListener( const OUString& /* aPropertyName */, const Reference< XPropertyChangeListener >& /* xListener */ )
128 throw (UnknownPropertyException,
129 lang::WrappedTargetException,
130 uno::RuntimeException, std::exception)
132 OSL_FAIL( "Not Implemented" );
133 return;
136 void SAL_CALL ColorPropertySet::removePropertyChangeListener( const OUString& /* aPropertyName */, const Reference< XPropertyChangeListener >& /* aListener */ )
137 throw (UnknownPropertyException,
138 lang::WrappedTargetException,
139 uno::RuntimeException, std::exception)
141 OSL_FAIL( "Not Implemented" );
142 return;
145 void SAL_CALL ColorPropertySet::addVetoableChangeListener( const OUString& /* PropertyName */, const Reference< XVetoableChangeListener >& /* aListener */ )
146 throw (UnknownPropertyException,
147 lang::WrappedTargetException,
148 uno::RuntimeException, std::exception)
150 OSL_FAIL( "Not Implemented" );
151 return;
154 void SAL_CALL ColorPropertySet::removeVetoableChangeListener( const OUString& /* PropertyName */, const Reference< XVetoableChangeListener >& /* aListener */ )
155 throw (UnknownPropertyException,
156 lang::WrappedTargetException,
157 uno::RuntimeException, std::exception)
159 OSL_FAIL( "Not Implemented" );
160 return;
163 // ____ XPropertyState ____
165 PropertyState SAL_CALL ColorPropertySet::getPropertyState( const OUString& /* PropertyName */ )
166 throw (UnknownPropertyException,
167 uno::RuntimeException, std::exception)
169 return PropertyState_DIRECT_VALUE;
172 Sequence< PropertyState > SAL_CALL ColorPropertySet::getPropertyStates( const Sequence< OUString >& /* aPropertyName */ )
173 throw (UnknownPropertyException,
174 uno::RuntimeException, std::exception)
176 PropertyState aState = PropertyState_DIRECT_VALUE;
177 return Sequence< PropertyState >( & aState, 1 );
180 void SAL_CALL ColorPropertySet::setPropertyToDefault( const OUString& PropertyName )
181 throw (UnknownPropertyException,
182 uno::RuntimeException, std::exception)
184 if( PropertyName.equals( m_aColorPropName ))
185 m_nColor = m_nDefaultColor;
188 uno::Any SAL_CALL ColorPropertySet::getPropertyDefault( const OUString& aPropertyName )
189 throw (UnknownPropertyException,
190 lang::WrappedTargetException,
191 uno::RuntimeException, std::exception)
193 if( aPropertyName.equals( m_aColorPropName ))
194 return uno::makeAny( m_nDefaultColor );
195 return uno::Any();
198 } // namespace chart
199 } // namespace xmloff
201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */