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