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 "propertyset.hxx"
22 :
23 : using namespace ::com::sun::star::uno;
24 : using namespace ::com::sun::star::beans;
25 : using namespace ::com::sun::star::lang;
26 :
27 : namespace sdr { namespace table {
28 :
29 :
30 : // FastPropertySetInfo
31 :
32 :
33 0 : FastPropertySetInfo::FastPropertySetInfo( const PropertyVector& rProps )
34 : {
35 0 : addProperties( rProps );
36 0 : }
37 :
38 :
39 :
40 0 : FastPropertySetInfo::~FastPropertySetInfo()
41 : {
42 0 : }
43 :
44 :
45 :
46 0 : void FastPropertySetInfo::addProperties( const PropertyVector& rProps )
47 : {
48 0 : sal_uInt32 nIndex = maProperties.size();
49 0 : sal_uInt32 nCount = rProps.size();
50 0 : maProperties.resize( nIndex + nCount );
51 0 : PropertyVector::const_iterator aIter( rProps.begin() );
52 0 : while( nCount-- )
53 : {
54 0 : const Property& rProperty = (*aIter++);
55 0 : maProperties[nIndex] = rProperty;
56 0 : maMap[ rProperty.Name ] = nIndex++;
57 : }
58 0 : }
59 :
60 :
61 :
62 0 : const Property& FastPropertySetInfo::getProperty( const OUString& aName ) throw (UnknownPropertyException )
63 : {
64 0 : PropertyMap::iterator aIter( maMap.find( aName ) );
65 0 : if( aIter == maMap.end() )
66 0 : throw UnknownPropertyException();
67 0 : return maProperties[(*aIter).second];
68 : }
69 :
70 :
71 :
72 0 : const Property* FastPropertySetInfo::hasProperty( const OUString& aName )
73 : {
74 0 : PropertyMap::iterator aIter( maMap.find( aName ) );
75 0 : if( aIter == maMap.end() )
76 0 : return 0;
77 : else
78 0 : return &maProperties[(*aIter).second];
79 : }
80 :
81 :
82 : // XPropertySetInfo
83 :
84 :
85 0 : Sequence< Property > SAL_CALL FastPropertySetInfo::getProperties() throw (RuntimeException, std::exception)
86 : {
87 0 : return Sequence< Property >( &maProperties[0], maProperties.size() );
88 : }
89 :
90 :
91 :
92 0 : Property SAL_CALL FastPropertySetInfo::getPropertyByName( const OUString& aName ) throw (UnknownPropertyException, RuntimeException, std::exception)
93 : {
94 0 : return getProperty( aName );
95 : }
96 :
97 :
98 :
99 0 : sal_Bool SAL_CALL FastPropertySetInfo::hasPropertyByName( const OUString& aName ) throw (RuntimeException, std::exception)
100 : {
101 0 : return hasProperty( aName ) != 0 ? sal_True : sal_False;
102 : }
103 :
104 :
105 : // FastPropertySet
106 :
107 :
108 0 : FastPropertySet::FastPropertySet( const rtl::Reference< FastPropertySetInfo >& xInfo )
109 0 : : mxInfo( xInfo )
110 : {
111 0 : }
112 :
113 :
114 :
115 0 : FastPropertySet::~FastPropertySet()
116 : {
117 0 : }
118 :
119 :
120 : // XPropertySet
121 :
122 :
123 0 : Reference< XPropertySetInfo > SAL_CALL FastPropertySet::getPropertySetInfo( ) throw (RuntimeException, std::exception)
124 : {
125 0 : return Reference< XPropertySetInfo >( mxInfo.get() );
126 : }
127 :
128 :
129 :
130 0 : void SAL_CALL FastPropertySet::setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception)
131 : {
132 0 : setFastPropertyValue( mxInfo->getProperty( aPropertyName ).Handle, aValue );
133 0 : }
134 :
135 :
136 :
137 0 : Any SAL_CALL FastPropertySet::getPropertyValue( const OUString& aPropertyName ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
138 : {
139 0 : return getFastPropertyValue( mxInfo->getProperty( aPropertyName ).Handle );
140 : }
141 :
142 :
143 :
144 0 : void SAL_CALL FastPropertySet::addPropertyChangeListener( const OUString&, const Reference< XPropertyChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
145 : {
146 0 : }
147 :
148 :
149 :
150 0 : void SAL_CALL FastPropertySet::removePropertyChangeListener( const OUString&, const Reference< XPropertyChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
151 : {
152 0 : }
153 :
154 :
155 :
156 0 : void SAL_CALL FastPropertySet::addVetoableChangeListener( const OUString&, const Reference< XVetoableChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
157 : {
158 0 : }
159 :
160 :
161 :
162 0 : void SAL_CALL FastPropertySet::removeVetoableChangeListener( const OUString&, const Reference< XVetoableChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
163 : {
164 0 : }
165 :
166 :
167 : // XMultiPropertySet
168 :
169 :
170 0 : void SAL_CALL FastPropertySet::setPropertyValues( const Sequence< OUString >& aPropertyNames, const Sequence< Any >& aValues ) throw (PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception)
171 : {
172 0 : const OUString* pPropertyNames = aPropertyNames.getConstArray();
173 0 : const Any* pValues = aValues.getConstArray();
174 0 : sal_Int32 nCount = aPropertyNames.getLength();
175 0 : if( nCount != aValues.getLength() )
176 0 : throw IllegalArgumentException();
177 :
178 0 : while( nCount-- )
179 : {
180 0 : const Property* pProperty = mxInfo->hasProperty( *pPropertyNames++ );
181 0 : if( pProperty ) try
182 : {
183 0 : setFastPropertyValue( pProperty->Handle, *pValues );
184 : }
185 0 : catch( UnknownPropertyException& )
186 : {
187 : }
188 0 : pValues++;
189 : }
190 0 : }
191 :
192 :
193 :
194 0 : Sequence< Any > SAL_CALL FastPropertySet::getPropertyValues( const Sequence< OUString >& aPropertyNames ) throw (RuntimeException, std::exception)
195 : {
196 0 : sal_Int32 nCount = aPropertyNames.getLength();
197 0 : Sequence< Any > aValues( nCount );
198 :
199 0 : const OUString* pPropertyNames = aPropertyNames.getConstArray();
200 0 : Any* pValues = aValues.getArray();
201 0 : while( nCount-- )
202 : {
203 0 : const Property* pProperty = mxInfo->hasProperty( *pPropertyNames++ );
204 0 : if( pProperty ) try
205 : {
206 0 : *pValues = getFastPropertyValue( pProperty->Handle );
207 : }
208 0 : catch( UnknownPropertyException& )
209 : {
210 : }
211 0 : pValues++;
212 : }
213 0 : return aValues;
214 : }
215 :
216 :
217 :
218 0 : void SAL_CALL FastPropertySet::addPropertiesChangeListener( const Sequence< OUString >&, const Reference< XPropertiesChangeListener >& ) throw (RuntimeException, std::exception)
219 : {
220 0 : }
221 :
222 :
223 :
224 0 : void SAL_CALL FastPropertySet::removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& ) throw (RuntimeException, std::exception)
225 : {
226 0 : }
227 :
228 :
229 :
230 0 : void SAL_CALL FastPropertySet::firePropertiesChangeEvent( const Sequence< OUString >&, const Reference< XPropertiesChangeListener >& ) throw (RuntimeException, std::exception)
231 : {
232 0 : }
233 :
234 : }}
235 :
236 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|