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