Update ooo320-m1
[ooovba.git] / xmloff / source / chart / ColorPropertySet.cxx
blob6dd03383787e687fd61bbf0a51e326c94a1e4e5a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ColorPropertySet.cxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
34 #include "ColorPropertySet.hxx"
36 #include <cppuhelper/implbase1.hxx>
38 using namespace ::com::sun::star;
39 using namespace ::com::sun::star::beans;
41 using ::com::sun::star::uno::Reference;
42 using ::com::sun::star::uno::Sequence;
43 using ::rtl::OUString;
44 using ::com::sun::star::uno::RuntimeException;
46 // ================================================================================
48 namespace
50 class lcl_ColorPropertySetInfo : public ::cppu::WeakImplHelper1<
51 XPropertySetInfo >
53 public:
54 lcl_ColorPropertySetInfo( bool bFillColor );
56 protected:
57 // ____ XPropertySetInfo ____
58 virtual Sequence< Property > SAL_CALL getProperties() throw (RuntimeException);
59 virtual Property SAL_CALL getPropertyByName( const OUString& aName ) throw (UnknownPropertyException, RuntimeException);
60 virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) throw (RuntimeException);
62 private:
63 bool m_bIsFillColor;
64 OUString m_aColorPropName;
65 Property m_aColorProp;
68 lcl_ColorPropertySetInfo::lcl_ColorPropertySetInfo( bool bFillColor ) :
69 m_bIsFillColor( bFillColor ),
70 // note: length of FillColor and LineColor is 9
71 m_aColorPropName( (bFillColor ? "FillColor" : "LineColor"), 9, RTL_TEXTENCODING_ASCII_US ),
72 m_aColorProp( m_aColorPropName, -1,
73 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), 0)
76 Sequence< Property > SAL_CALL lcl_ColorPropertySetInfo::getProperties()
77 throw (RuntimeException)
80 return Sequence< Property >( & m_aColorProp, 1 );
83 Property SAL_CALL lcl_ColorPropertySetInfo::getPropertyByName( const OUString& aName )
84 throw (UnknownPropertyException, RuntimeException)
86 if( aName.equals( m_aColorPropName ))
87 return m_aColorProp;
88 throw UnknownPropertyException( m_aColorPropName, static_cast< uno::XWeak * >( this ));
91 sal_Bool SAL_CALL lcl_ColorPropertySetInfo::hasPropertyByName( const OUString& Name )
92 throw (RuntimeException)
94 return Name.equals( m_aColorPropName );
97 } // anonymous namespace
99 // ================================================================================
101 namespace xmloff
103 namespace chart
106 ColorPropertySet::ColorPropertySet( sal_Int32 nColor, bool bFillColor /* = true */ ) :
107 // note: length of FillColor and LineColor is 9
108 m_aColorPropName( (bFillColor ? "FillColor" : "LineColor"), 9, RTL_TEXTENCODING_ASCII_US ),
109 m_nColor( nColor ),
110 m_bIsFillColor( bFillColor ),
111 m_nDefaultColor( 0x0099ccff ) // blue 8
114 ColorPropertySet::~ColorPropertySet()
117 void ColorPropertySet::setColor( sal_Int32 nColor )
119 m_nColor = nColor;
122 sal_Int32 ColorPropertySet::getColor()
124 return m_nColor;
127 // ____ XPropertySet ____
129 Reference< XPropertySetInfo > SAL_CALL ColorPropertySet::getPropertySetInfo()
130 throw (uno::RuntimeException)
132 if( ! m_xInfo.is())
133 m_xInfo.set( new lcl_ColorPropertySetInfo( m_bIsFillColor ));
135 return m_xInfo;
138 void SAL_CALL ColorPropertySet::setPropertyValue( const OUString& /* aPropertyName */, const uno::Any& aValue )
139 throw (UnknownPropertyException,
140 PropertyVetoException,
141 lang::IllegalArgumentException,
142 lang::WrappedTargetException,
143 uno::RuntimeException)
145 aValue >>= m_nColor;
148 uno::Any SAL_CALL ColorPropertySet::getPropertyValue( const OUString& /* PropertyName */ )
149 throw (UnknownPropertyException,
150 lang::WrappedTargetException,
151 uno::RuntimeException)
153 return uno::makeAny( m_nColor );
156 void SAL_CALL ColorPropertySet::addPropertyChangeListener( const OUString& /* aPropertyName */, const Reference< XPropertyChangeListener >& /* xListener */ )
157 throw (UnknownPropertyException,
158 lang::WrappedTargetException,
159 uno::RuntimeException)
161 OSL_ENSURE( false, "Not Implemented" );
162 return;
165 void SAL_CALL ColorPropertySet::removePropertyChangeListener( const OUString& /* aPropertyName */, const Reference< XPropertyChangeListener >& /* aListener */ )
166 throw (UnknownPropertyException,
167 lang::WrappedTargetException,
168 uno::RuntimeException)
170 OSL_ENSURE( false, "Not Implemented" );
171 return;
174 void SAL_CALL ColorPropertySet::addVetoableChangeListener( const OUString& /* PropertyName */, const Reference< XVetoableChangeListener >& /* aListener */ )
175 throw (UnknownPropertyException,
176 lang::WrappedTargetException,
177 uno::RuntimeException)
179 OSL_ENSURE( false, "Not Implemented" );
180 return;
183 void SAL_CALL ColorPropertySet::removeVetoableChangeListener( const OUString& /* PropertyName */, const Reference< XVetoableChangeListener >& /* aListener */ )
184 throw (UnknownPropertyException,
185 lang::WrappedTargetException,
186 uno::RuntimeException)
188 OSL_ENSURE( false, "Not Implemented" );
189 return;
192 // ____ XPropertyState ____
194 PropertyState SAL_CALL ColorPropertySet::getPropertyState( const OUString& /* PropertyName */ )
195 throw (UnknownPropertyException,
196 uno::RuntimeException)
198 return PropertyState_DIRECT_VALUE;
201 Sequence< PropertyState > SAL_CALL ColorPropertySet::getPropertyStates( const Sequence< OUString >& /* aPropertyName */ )
202 throw (UnknownPropertyException,
203 uno::RuntimeException)
205 PropertyState aState = PropertyState_DIRECT_VALUE;
206 return Sequence< PropertyState >( & aState, 1 );
209 void SAL_CALL ColorPropertySet::setPropertyToDefault( const OUString& PropertyName )
210 throw (UnknownPropertyException,
211 uno::RuntimeException)
213 if( PropertyName.equals( m_aColorPropName ))
214 m_nColor = m_nDefaultColor;
217 uno::Any SAL_CALL ColorPropertySet::getPropertyDefault( const OUString& aPropertyName )
218 throw (UnknownPropertyException,
219 lang::WrappedTargetException,
220 uno::RuntimeException)
222 if( aPropertyName.equals( m_aColorPropName ))
223 return uno::makeAny( m_nDefaultColor );
224 return uno::Any();
227 } // namespace chart
228 } // namespace xmloff