bump product version to 4.1.6.2
[LibreOffice.git] / xmloff / source / chart / ColorPropertySet.cxx
blobe171214592e5236fa3a69b636a5f3160174df522
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 .
21 #include "ColorPropertySet.hxx"
23 #include <cppuhelper/implbase1.hxx>
25 using namespace ::com::sun::star;
26 using namespace ::com::sun::star::beans;
28 using ::com::sun::star::uno::Reference;
29 using ::com::sun::star::uno::Sequence;
30 using ::com::sun::star::uno::RuntimeException;
32 // ================================================================================
34 namespace
36 class lcl_ColorPropertySetInfo : public ::cppu::WeakImplHelper1<
37 XPropertySetInfo >
39 public:
40 lcl_ColorPropertySetInfo( bool bFillColor );
42 protected:
43 // ____ XPropertySetInfo ____
44 virtual Sequence< Property > SAL_CALL getProperties() throw (RuntimeException);
45 virtual Property SAL_CALL getPropertyByName( const OUString& aName ) throw (UnknownPropertyException, RuntimeException);
46 virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) throw (RuntimeException);
48 private:
49 OUString m_aColorPropName;
50 Property m_aColorProp;
53 lcl_ColorPropertySetInfo::lcl_ColorPropertySetInfo( bool bFillColor ) :
54 // note: length of FillColor and LineColor is 9
55 m_aColorPropName( (bFillColor ? "FillColor" : "LineColor"), 9, RTL_TEXTENCODING_ASCII_US ),
56 m_aColorProp( m_aColorPropName, -1,
57 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), 0)
60 Sequence< Property > SAL_CALL lcl_ColorPropertySetInfo::getProperties()
61 throw (RuntimeException)
64 return Sequence< Property >( & m_aColorProp, 1 );
67 Property SAL_CALL lcl_ColorPropertySetInfo::getPropertyByName( const OUString& aName )
68 throw (UnknownPropertyException, RuntimeException)
70 if( aName.equals( m_aColorPropName ))
71 return m_aColorProp;
72 throw UnknownPropertyException( m_aColorPropName, static_cast< uno::XWeak * >( this ));
75 sal_Bool SAL_CALL lcl_ColorPropertySetInfo::hasPropertyByName( const OUString& Name )
76 throw (RuntimeException)
78 return Name.equals( m_aColorPropName );
81 } // anonymous namespace
83 // ================================================================================
85 namespace xmloff
87 namespace chart
90 ColorPropertySet::ColorPropertySet( sal_Int32 nColor, bool bFillColor /* = true */ ) :
91 // note: length of FillColor and LineColor is 9
92 m_aColorPropName( (bFillColor ? "FillColor" : "LineColor"), 9, RTL_TEXTENCODING_ASCII_US ),
93 m_nColor( nColor ),
94 m_bIsFillColor( bFillColor ),
95 m_nDefaultColor( 0x0099ccff ) // blue 8
98 ColorPropertySet::~ColorPropertySet()
101 // ____ XPropertySet ____
103 Reference< XPropertySetInfo > SAL_CALL ColorPropertySet::getPropertySetInfo()
104 throw (uno::RuntimeException)
106 if( ! m_xInfo.is())
107 m_xInfo.set( new lcl_ColorPropertySetInfo( m_bIsFillColor ));
109 return m_xInfo;
112 void SAL_CALL ColorPropertySet::setPropertyValue( const OUString& /* aPropertyName */, const uno::Any& aValue )
113 throw (UnknownPropertyException,
114 PropertyVetoException,
115 lang::IllegalArgumentException,
116 lang::WrappedTargetException,
117 uno::RuntimeException)
119 aValue >>= m_nColor;
122 uno::Any SAL_CALL ColorPropertySet::getPropertyValue( const OUString& /* PropertyName */ )
123 throw (UnknownPropertyException,
124 lang::WrappedTargetException,
125 uno::RuntimeException)
127 return uno::makeAny( m_nColor );
130 void SAL_CALL ColorPropertySet::addPropertyChangeListener( const OUString& /* aPropertyName */, const Reference< XPropertyChangeListener >& /* xListener */ )
131 throw (UnknownPropertyException,
132 lang::WrappedTargetException,
133 uno::RuntimeException)
135 OSL_FAIL( "Not Implemented" );
136 return;
139 void SAL_CALL ColorPropertySet::removePropertyChangeListener( const OUString& /* aPropertyName */, const Reference< XPropertyChangeListener >& /* aListener */ )
140 throw (UnknownPropertyException,
141 lang::WrappedTargetException,
142 uno::RuntimeException)
144 OSL_FAIL( "Not Implemented" );
145 return;
148 void SAL_CALL ColorPropertySet::addVetoableChangeListener( const OUString& /* PropertyName */, const Reference< XVetoableChangeListener >& /* aListener */ )
149 throw (UnknownPropertyException,
150 lang::WrappedTargetException,
151 uno::RuntimeException)
153 OSL_FAIL( "Not Implemented" );
154 return;
157 void SAL_CALL ColorPropertySet::removeVetoableChangeListener( const OUString& /* PropertyName */, const Reference< XVetoableChangeListener >& /* aListener */ )
158 throw (UnknownPropertyException,
159 lang::WrappedTargetException,
160 uno::RuntimeException)
162 OSL_FAIL( "Not Implemented" );
163 return;
166 // ____ XPropertyState ____
168 PropertyState SAL_CALL ColorPropertySet::getPropertyState( const OUString& /* PropertyName */ )
169 throw (UnknownPropertyException,
170 uno::RuntimeException)
172 return PropertyState_DIRECT_VALUE;
175 Sequence< PropertyState > SAL_CALL ColorPropertySet::getPropertyStates( const Sequence< OUString >& /* aPropertyName */ )
176 throw (UnknownPropertyException,
177 uno::RuntimeException)
179 PropertyState aState = PropertyState_DIRECT_VALUE;
180 return Sequence< PropertyState >( & aState, 1 );
183 void SAL_CALL ColorPropertySet::setPropertyToDefault( const OUString& PropertyName )
184 throw (UnknownPropertyException,
185 uno::RuntimeException)
187 if( PropertyName.equals( m_aColorPropName ))
188 m_nColor = m_nDefaultColor;
191 uno::Any SAL_CALL ColorPropertySet::getPropertyDefault( const OUString& aPropertyName )
192 throw (UnknownPropertyException,
193 lang::WrappedTargetException,
194 uno::RuntimeException)
196 if( aPropertyName.equals( m_aColorPropName ))
197 return uno::makeAny( m_nDefaultColor );
198 return uno::Any();
201 } // namespace chart
202 } // namespace xmloff
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */