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 : #include <com/sun/star/beans/PropertyState.hpp>
21 : #include <com/sun/star/beans/PropertyAttribute.hpp>
22 : #include <com/sun/star/awt/FontDescriptor.hpp>
23 : #include <com/sun/star/awt/FontWidth.hpp>
24 : #include <com/sun/star/awt/FontWeight.hpp>
25 : #include <com/sun/star/awt/FontSlant.hpp>
26 : #include <com/sun/star/awt/MouseWheelBehavior.hpp>
27 : #include <com/sun/star/graphic/XGraphicProvider.hpp>
28 : #include <com/sun/star/awt/XDevice.hpp>
29 : #include <com/sun/star/text/WritingMode2.hpp>
30 : #include <com/sun/star/io/XMarkableStream.hpp>
31 : #include <toolkit/controls/unocontrolmodel.hxx>
32 : #include <toolkit/helper/macros.hxx>
33 : #include <cppuhelper/typeprovider.hxx>
34 : #include <rtl/uuid.h>
35 : #include <tools/diagnose_ex.h>
36 : #include <tools/date.hxx>
37 : #include <tools/time.hxx>
38 : #include <tools/debug.hxx>
39 : #include <toolkit/helper/property.hxx>
40 : #include <toolkit/helper/vclunohelper.hxx>
41 : #include <toolkit/helper/emptyfontdescriptor.hxx>
42 : #include <com/sun/star/lang/Locale.hpp>
43 : #include <unotools/localedatawrapper.hxx>
44 : #include <unotools/configmgr.hxx>
45 : #include <comphelper/processfactory.hxx>
46 : #include <comphelper/sequence.hxx>
47 : #include <comphelper/extract.hxx>
48 : #include <vcl/svapp.hxx>
49 : #include <uno/data.h>
50 :
51 : #include <memory>
52 : #include <set>
53 :
54 : using namespace ::com::sun::star;
55 : using namespace ::com::sun::star::uno;
56 : using namespace ::com::sun::star::lang;
57 : using namespace ::com::sun::star::i18n;
58 : using ::com::sun::star::awt::FontDescriptor;
59 :
60 :
61 : #define UNOCONTROL_STREAMVERSION (short)2
62 :
63 18470 : static void lcl_ImplMergeFontProperty( FontDescriptor& rFD, sal_uInt16 nPropId, const Any& rValue )
64 : {
65 : // some props are defined with other types than the matching FontDescriptor members have
66 : // (e.g. FontWidth, FontSlant)
67 : // 78474 - 09/19/2000 - FS
68 18470 : float nExtractFloat = 0;
69 18470 : sal_Int16 nExtractShort = 0;
70 :
71 18470 : switch ( nPropId )
72 : {
73 1174 : case BASEPROPERTY_FONTDESCRIPTORPART_NAME: rValue >>= rFD.Name;
74 1174 : break;
75 1136 : case BASEPROPERTY_FONTDESCRIPTORPART_STYLENAME: rValue >>= rFD.StyleName;
76 1136 : break;
77 1142 : case BASEPROPERTY_FONTDESCRIPTORPART_FAMILY: rValue >>= rFD.Family;
78 1142 : break;
79 1176 : case BASEPROPERTY_FONTDESCRIPTORPART_CHARSET: rValue >>= rFD.CharSet;
80 1176 : break;
81 1177 : case BASEPROPERTY_FONTDESCRIPTORPART_HEIGHT: rValue >>= nExtractFloat; rFD.Height = (sal_Int16)nExtractFloat;
82 1177 : break;
83 1177 : case BASEPROPERTY_FONTDESCRIPTORPART_WEIGHT: rValue >>= rFD.Weight;
84 1177 : break;
85 1177 : case BASEPROPERTY_FONTDESCRIPTORPART_SLANT: if ( rValue >>= nExtractShort )
86 1169 : rFD.Slant = (::com::sun::star::awt::FontSlant)nExtractShort;
87 : else
88 8 : rValue >>= rFD.Slant;
89 1177 : break;
90 1177 : case BASEPROPERTY_FONTDESCRIPTORPART_UNDERLINE: rValue >>= rFD.Underline;
91 1177 : break;
92 1178 : case BASEPROPERTY_FONTDESCRIPTORPART_STRIKEOUT: rValue >>= rFD.Strikeout;
93 1178 : break;
94 1136 : case BASEPROPERTY_FONTDESCRIPTORPART_WIDTH: rValue >>= rFD.Width;
95 1136 : break;
96 1137 : case BASEPROPERTY_FONTDESCRIPTORPART_PITCH: rValue >>= rFD.Pitch;
97 1137 : break;
98 1136 : case BASEPROPERTY_FONTDESCRIPTORPART_CHARWIDTH: rValue >>= rFD.CharacterWidth;
99 1136 : break;
100 1136 : case BASEPROPERTY_FONTDESCRIPTORPART_ORIENTATION: rValue >>= rFD.Orientation;
101 1136 : break;
102 1137 : case BASEPROPERTY_FONTDESCRIPTORPART_KERNING: rValue >>= rFD.Kerning;
103 1137 : break;
104 1138 : case BASEPROPERTY_FONTDESCRIPTORPART_WORDLINEMODE: rValue >>= rFD.WordLineMode;
105 1138 : break;
106 1136 : case BASEPROPERTY_FONTDESCRIPTORPART_TYPE: rValue >>= rFD.Type;
107 1136 : break;
108 : default: OSL_FAIL( "FontProperty?!" );
109 : }
110 18470 : }
111 :
112 : // ----------------------------------------------------
113 : // class UnoControlModel
114 : // ----------------------------------------------------
115 909 : UnoControlModel::UnoControlModel( const Reference< XComponentContext >& rxContext )
116 : :UnoControlModel_Base()
117 : ,MutexAndBroadcastHelper()
118 : ,OPropertySetHelper( BrdcstHelper )
119 : ,maDisposeListeners( *this )
120 909 : ,m_xContext( rxContext )
121 : {
122 : // Insert properties from Model into table,
123 : // only existing properties are valid, even if they're VOID
124 909 : }
125 :
126 42 : UnoControlModel::UnoControlModel( const UnoControlModel& rModel )
127 : : UnoControlModel_Base()
128 : , MutexAndBroadcastHelper()
129 : , OPropertySetHelper( BrdcstHelper )
130 : , maData( rModel.maData )
131 : , maDisposeListeners( *this )
132 42 : , m_xContext( rModel.m_xContext )
133 : {
134 42 : }
135 :
136 117 : ::com::sun::star::uno::Sequence<sal_Int32> UnoControlModel::ImplGetPropertyIds() const
137 : {
138 117 : sal_uInt32 nIDs = maData.size();
139 117 : ::com::sun::star::uno::Sequence<sal_Int32> aIDs( nIDs );
140 117 : sal_Int32* pIDs = aIDs.getArray();
141 117 : sal_uInt32 n = 0;
142 2611 : for ( ImplPropertyTable::const_iterator it = maData.begin(); it != maData.end(); ++it )
143 2494 : pIDs[n++] = it->first;
144 117 : return aIDs;
145 : }
146 :
147 9395 : sal_Bool UnoControlModel::ImplHasProperty( sal_uInt16 nPropId ) const
148 : {
149 9395 : if ( ( nPropId >= BASEPROPERTY_FONTDESCRIPTORPART_START ) && ( nPropId <= BASEPROPERTY_FONTDESCRIPTORPART_END ) )
150 0 : nPropId = BASEPROPERTY_FONTDESCRIPTOR;
151 :
152 9395 : return maData.find( nPropId ) != maData.end() ? sal_True : sal_False;
153 : }
154 :
155 15000 : ::com::sun::star::uno::Any UnoControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
156 : {
157 15000 : ::com::sun::star::uno::Any aDefault;
158 :
159 15000 : if (
160 14589 : (nPropId == BASEPROPERTY_FONTDESCRIPTOR) ||
161 : (
162 0 : (nPropId >= BASEPROPERTY_FONTDESCRIPTORPART_START) &&
163 : (nPropId <= BASEPROPERTY_FONTDESCRIPTORPART_END)
164 : )
165 : )
166 : {
167 411 : EmptyFontDescriptor aFD;
168 411 : switch ( nPropId )
169 : {
170 411 : case BASEPROPERTY_FONTDESCRIPTOR: aDefault <<= aFD; break;
171 0 : case BASEPROPERTY_FONTDESCRIPTORPART_NAME: aDefault <<= aFD.Name; break;
172 0 : case BASEPROPERTY_FONTDESCRIPTORPART_STYLENAME: aDefault <<= aFD.StyleName; break;
173 0 : case BASEPROPERTY_FONTDESCRIPTORPART_FAMILY: aDefault <<= aFD.Family; break;
174 0 : case BASEPROPERTY_FONTDESCRIPTORPART_CHARSET: aDefault <<= aFD.CharSet; break;
175 0 : case BASEPROPERTY_FONTDESCRIPTORPART_HEIGHT: aDefault <<= (float)aFD.Height; break;
176 0 : case BASEPROPERTY_FONTDESCRIPTORPART_WEIGHT: aDefault <<= aFD.Weight; break;
177 0 : case BASEPROPERTY_FONTDESCRIPTORPART_SLANT: aDefault <<= (sal_Int16)aFD.Slant; break;
178 0 : case BASEPROPERTY_FONTDESCRIPTORPART_UNDERLINE: aDefault <<= aFD.Underline; break;
179 0 : case BASEPROPERTY_FONTDESCRIPTORPART_STRIKEOUT: aDefault <<= aFD.Strikeout; break;
180 0 : case BASEPROPERTY_FONTDESCRIPTORPART_WIDTH: aDefault <<= aFD.Width; break;
181 0 : case BASEPROPERTY_FONTDESCRIPTORPART_PITCH: aDefault <<= aFD.Pitch; break;
182 0 : case BASEPROPERTY_FONTDESCRIPTORPART_CHARWIDTH: aDefault <<= aFD.CharacterWidth; break;
183 0 : case BASEPROPERTY_FONTDESCRIPTORPART_ORIENTATION: aDefault <<= aFD.Orientation; break;
184 0 : case BASEPROPERTY_FONTDESCRIPTORPART_KERNING: aDefault <<= aFD.Kerning; break;
185 0 : case BASEPROPERTY_FONTDESCRIPTORPART_WORDLINEMODE: aDefault <<= aFD.WordLineMode; break;
186 0 : case BASEPROPERTY_FONTDESCRIPTORPART_TYPE: aDefault <<= aFD.Type; break;
187 : default: OSL_FAIL( "FontProperty?!" );
188 411 : }
189 : }
190 : else
191 : {
192 14589 : switch ( nPropId )
193 : {
194 : case BASEPROPERTY_GRAPHIC:
195 9 : aDefault <<= Reference< graphic::XGraphic >();
196 9 : break;
197 :
198 : case BASEPROPERTY_REFERENCE_DEVICE:
199 216 : aDefault <<= Reference< awt::XDevice >();
200 216 : break;
201 :
202 : case BASEPROPERTY_ITEM_SEPARATOR_POS:
203 : case BASEPROPERTY_VERTICALALIGN:
204 : case BASEPROPERTY_BORDERCOLOR:
205 : case BASEPROPERTY_SYMBOL_COLOR:
206 : case BASEPROPERTY_TABSTOP:
207 : case BASEPROPERTY_TEXTCOLOR:
208 : case BASEPROPERTY_TEXTLINECOLOR:
209 : case BASEPROPERTY_DATE:
210 : case BASEPROPERTY_DATESHOWCENTURY:
211 : case BASEPROPERTY_TIME:
212 : case BASEPROPERTY_VALUE_DOUBLE:
213 : case BASEPROPERTY_PROGRESSVALUE:
214 : case BASEPROPERTY_SCROLLVALUE:
215 : case BASEPROPERTY_VISIBLESIZE:
216 : case BASEPROPERTY_BACKGROUNDCOLOR:
217 3553 : case BASEPROPERTY_FILLCOLOR: break; // Void
218 :
219 : case BASEPROPERTY_FONTRELIEF:
220 : case BASEPROPERTY_FONTEMPHASISMARK:
221 : case BASEPROPERTY_MAXTEXTLEN:
222 : case BASEPROPERTY_STATE:
223 : case BASEPROPERTY_EXTDATEFORMAT:
224 : case BASEPROPERTY_EXTTIMEFORMAT:
225 1077 : case BASEPROPERTY_ECHOCHAR: aDefault <<= (sal_Int16) 0; break;
226 225 : case BASEPROPERTY_BORDER: aDefault <<= (sal_Int16) 1; break;
227 31 : case BASEPROPERTY_DECIMALACCURACY: aDefault <<= (sal_Int16) 2; break;
228 38 : case BASEPROPERTY_LINECOUNT: aDefault <<= (sal_Int16) 5; break;
229 344 : case BASEPROPERTY_ALIGN: aDefault <<= (sal_Int16) PROPERTY_ALIGN_LEFT; break;
230 59 : case BASEPROPERTY_IMAGEALIGN: aDefault <<= (sal_Int16) 1 /*ImageAlign::TOP*/; break;
231 170 : case BASEPROPERTY_IMAGEPOSITION: aDefault <<= (sal_Int16) 12 /*ImagePosition::Centered*/; break;
232 59 : case BASEPROPERTY_PUSHBUTTONTYPE: aDefault <<= (sal_Int16) 0 /*PushButtonType::STANDARD*/; break;
233 145 : case BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR:aDefault <<= (sal_Int16) awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY; break;
234 :
235 27 : case BASEPROPERTY_DATEMAX: aDefault <<= (sal_Int32) Date( 31, 12, 2200 ).GetDate(); break;
236 27 : case BASEPROPERTY_DATEMIN: aDefault <<= (sal_Int32) Date( 1, 1, 1900 ).GetDate(); break;
237 16 : case BASEPROPERTY_TIMEMAX: aDefault <<= (sal_Int32) Time( 23, 59 ).GetTime(); break;
238 16 : case BASEPROPERTY_TIMEMIN: aDefault <<= (sal_Int32) 0; break;
239 31 : case BASEPROPERTY_VALUEMAX_DOUBLE: aDefault <<= (double) 1000000; break;
240 31 : case BASEPROPERTY_VALUEMIN_DOUBLE: aDefault <<= (double) -1000000; break;
241 31 : case BASEPROPERTY_VALUESTEP_DOUBLE: aDefault <<= (double ) 1; break;
242 5 : case BASEPROPERTY_PROGRESSVALUE_MAX: aDefault <<= (sal_Int32) 100; break;
243 5 : case BASEPROPERTY_PROGRESSVALUE_MIN: aDefault <<= (sal_Int32) 0; break;
244 12 : case BASEPROPERTY_SCROLLVALUE_MAX: aDefault <<= (sal_Int32) 100; break;
245 12 : case BASEPROPERTY_SCROLLVALUE_MIN: aDefault <<= (sal_Int32) 0; break;
246 12 : case BASEPROPERTY_LINEINCREMENT: aDefault <<= (sal_Int32) 1; break;
247 12 : case BASEPROPERTY_BLOCKINCREMENT: aDefault <<= (sal_Int32) 10; break;
248 28 : case BASEPROPERTY_ORIENTATION: aDefault <<= (sal_Int32) 0; break;
249 11 : case BASEPROPERTY_SPINVALUE: aDefault <<= (sal_Int32) 0; break;
250 11 : case BASEPROPERTY_SPININCREMENT: aDefault <<= (sal_Int32) 1; break;
251 11 : case BASEPROPERTY_SPINVALUE_MIN: aDefault <<= (sal_Int32) 0; break;
252 11 : case BASEPROPERTY_SPINVALUE_MAX: aDefault <<= (sal_Int32) 100; break;
253 175 : case BASEPROPERTY_REPEAT_DELAY: aDefault <<= (sal_Int32) 50; break; // 50 milliseconds
254 485 : case BASEPROPERTY_DEFAULTCONTROL: aDefault <<= ((UnoControlModel*)this)->getServiceName(); break;
255 :
256 : case BASEPROPERTY_AUTOHSCROLL:
257 : case BASEPROPERTY_AUTOVSCROLL:
258 : case BASEPROPERTY_MOVEABLE:
259 : case BASEPROPERTY_CLOSEABLE:
260 : case BASEPROPERTY_SIZEABLE:
261 : case BASEPROPERTY_HSCROLL:
262 : case BASEPROPERTY_DEFAULTBUTTON:
263 : case BASEPROPERTY_MULTILINE:
264 : case BASEPROPERTY_MULTISELECTION:
265 : case BASEPROPERTY_TRISTATE:
266 : case BASEPROPERTY_DROPDOWN:
267 : case BASEPROPERTY_SPIN:
268 : case BASEPROPERTY_READONLY:
269 : case BASEPROPERTY_VSCROLL:
270 : case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
271 : case BASEPROPERTY_STRICTFORMAT:
272 : case BASEPROPERTY_REPEAT:
273 : case BASEPROPERTY_PAINTTRANSPARENT:
274 : case BASEPROPERTY_DESKTOP_AS_PARENT:
275 : case BASEPROPERTY_HARDLINEBREAKS:
276 1165 : case BASEPROPERTY_NOLABEL: aDefault <<= (sal_Bool) sal_False; break;
277 :
278 : case BASEPROPERTY_MULTISELECTION_SIMPLEMODE:
279 : case BASEPROPERTY_HIDEINACTIVESELECTION:
280 : case BASEPROPERTY_ENFORCE_FORMAT:
281 : case BASEPROPERTY_AUTOCOMPLETE:
282 : case BASEPROPERTY_SCALEIMAGE:
283 : case BASEPROPERTY_ENABLED:
284 : case BASEPROPERTY_PRINTABLE:
285 : case BASEPROPERTY_ENABLEVISIBLE:
286 2660 : case BASEPROPERTY_DECORATION: aDefault <<= (sal_Bool) sal_True; break;
287 :
288 : case BASEPROPERTY_GROUPNAME:
289 : case BASEPROPERTY_HELPTEXT:
290 : case BASEPROPERTY_HELPURL:
291 : case BASEPROPERTY_IMAGEURL:
292 : case BASEPROPERTY_DIALOGSOURCEURL:
293 : case BASEPROPERTY_EDITMASK:
294 : case BASEPROPERTY_LITERALMASK:
295 : case BASEPROPERTY_LABEL:
296 : case BASEPROPERTY_TITLE:
297 2974 : case BASEPROPERTY_TEXT: aDefault <<= OUString(); break;
298 :
299 : case BASEPROPERTY_WRITING_MODE:
300 : case BASEPROPERTY_CONTEXT_WRITING_MODE:
301 826 : aDefault <<= text::WritingMode2::CONTEXT;
302 826 : break;
303 :
304 : case BASEPROPERTY_STRINGITEMLIST:
305 : {
306 36 : ::com::sun::star::uno::Sequence< OUString> aStringSeq;
307 36 : aDefault <<= aStringSeq;
308 :
309 : }
310 36 : break;
311 : case BASEPROPERTY_SELECTEDITEMS:
312 : {
313 16 : ::com::sun::star::uno::Sequence<sal_Int16> aINT16Seq;
314 16 : aDefault <<= aINT16Seq;
315 : }
316 16 : break;
317 : case BASEPROPERTY_CURRENCYSYMBOL:
318 : {
319 : OUString sDefaultCurrency(
320 15 : utl::ConfigManager::getDefaultCurrency() );
321 :
322 : // extract the bank symbol
323 15 : sal_Int32 nSepPos = sDefaultCurrency.indexOf( '-' );
324 30 : OUString sBankSymbol;
325 15 : if ( nSepPos >= 0 )
326 : {
327 0 : sBankSymbol = sDefaultCurrency.copy( 0, nSepPos );
328 0 : sDefaultCurrency = sDefaultCurrency.copy( nSepPos + 1 );
329 : }
330 :
331 : // the remaining is the locale
332 30 : LanguageTag aLanguageTag( sDefaultCurrency);
333 30 : LocaleDataWrapper aLocaleInfo( m_xContext, aLanguageTag );
334 15 : if ( sBankSymbol.isEmpty() )
335 15 : sBankSymbol = aLocaleInfo.getCurrBankSymbol();
336 :
337 : // look for the currency entry (for this language) which has the given bank symbol
338 30 : Sequence< Currency2 > aAllCurrencies = aLocaleInfo.getAllCurrencies();
339 15 : const Currency2* pAllCurrencies = aAllCurrencies.getConstArray();
340 15 : const Currency2* pAllCurrenciesEnd = pAllCurrencies + aAllCurrencies.getLength();
341 :
342 30 : OUString sCurrencySymbol = aLocaleInfo.getCurrSymbol();
343 15 : if ( sBankSymbol.isEmpty() )
344 : {
345 : DBG_ASSERT( pAllCurrencies != pAllCurrenciesEnd, "UnoControlModel::ImplGetDefaultValue: no currencies at all!" );
346 0 : if ( pAllCurrencies != pAllCurrenciesEnd )
347 : {
348 0 : sBankSymbol = pAllCurrencies->BankSymbol;
349 0 : sCurrencySymbol = pAllCurrencies->Symbol;
350 : }
351 : }
352 :
353 15 : if ( !sBankSymbol.isEmpty() )
354 : {
355 15 : bool bLegacy = false;
356 15 : for ( ;pAllCurrencies != pAllCurrenciesEnd; ++pAllCurrencies )
357 15 : if ( pAllCurrencies->BankSymbol == sBankSymbol )
358 : {
359 15 : sCurrencySymbol = pAllCurrencies->Symbol;
360 15 : if ( pAllCurrencies->LegacyOnly )
361 0 : bLegacy = true;
362 : else
363 15 : break;
364 : }
365 : DBG_ASSERT( bLegacy || pAllCurrencies != pAllCurrenciesEnd, "UnoControlModel::ImplGetDefaultValue: did not find the given bank symbol!" );
366 : (void)bLegacy;
367 : }
368 :
369 30 : aDefault <<= sCurrencySymbol;
370 : }
371 15 : break;
372 :
373 : default: OSL_FAIL( "ImplGetDefaultValue - unknown Property" );
374 : }
375 : }
376 :
377 15000 : return aDefault;
378 : }
379 :
380 15642 : void UnoControlModel::ImplRegisterProperty( sal_uInt16 nPropId, const ::com::sun::star::uno::Any& rDefault )
381 : {
382 15642 : maData[ nPropId ] = rDefault;
383 15642 : }
384 :
385 6390 : void UnoControlModel::ImplRegisterProperty( sal_uInt16 nPropId )
386 : {
387 6390 : ImplRegisterProperty( nPropId, ImplGetDefaultValue( nPropId ) );
388 :
389 6390 : if ( nPropId == BASEPROPERTY_FONTDESCRIPTOR )
390 : {
391 : // some properties are not included in the FontDescriptor, but everytime
392 : // when we have a FontDescriptor we want to have these properties too.
393 : // => Easier to register the here, istead everywhere where I register the FontDescriptor...
394 :
395 69 : ImplRegisterProperty( BASEPROPERTY_TEXTCOLOR );
396 69 : ImplRegisterProperty( BASEPROPERTY_TEXTLINECOLOR );
397 69 : ImplRegisterProperty( BASEPROPERTY_FONTRELIEF );
398 69 : ImplRegisterProperty( BASEPROPERTY_FONTEMPHASISMARK );
399 : }
400 6390 : }
401 :
402 338 : void UnoControlModel::ImplRegisterProperties( const std::list< sal_uInt16 > &rIds )
403 : {
404 338 : std::list< sal_uInt16 >::const_iterator iter;
405 9522 : for( iter = rIds.begin(); iter != rIds.end(); ++iter)
406 : {
407 9184 : if( !ImplHasProperty( *iter ) )
408 9184 : ImplRegisterProperty( *iter, ImplGetDefaultValue( *iter ) );
409 : }
410 338 : }
411 :
412 : // ::com::sun::star::uno::XInterface
413 40243 : ::com::sun::star::uno::Any UnoControlModel::queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
414 : {
415 40243 : Any aRet = UnoControlModel_Base::queryAggregation( rType );
416 40243 : if ( !aRet.hasValue() )
417 5839 : aRet = ::cppu::OPropertySetHelper::queryInterface( rType );
418 40243 : return aRet;
419 : }
420 :
421 : // ::com::sun::star::lang::XUnoTunnel
422 0 : IMPL_XUNOTUNNEL_MINIMAL( UnoControlModel )
423 :
424 : // XInterface
425 204521 : IMPLEMENT_FORWARD_REFCOUNT( UnoControlModel, UnoControlModel_Base )
426 :
427 : // ::com::sun::star::lang::XTypeProvider
428 167 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoControlModel, UnoControlModel_Base, ::cppu::OPropertySetHelper )
429 :
430 :
431 42 : uno::Reference< util::XCloneable > UnoControlModel::createClone() throw(::com::sun::star::uno::RuntimeException)
432 : {
433 42 : UnoControlModel* pClone = Clone();
434 42 : uno::Reference< util::XCloneable > xClone( (::cppu::OWeakObject*) pClone, uno::UNO_QUERY );
435 42 : return xClone;
436 : }
437 :
438 : // ::com::sun::star::lang::XComponent
439 332 : void UnoControlModel::dispose( ) throw(::com::sun::star::uno::RuntimeException)
440 : {
441 332 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
442 :
443 664 : ::com::sun::star::lang::EventObject aEvt;
444 332 : aEvt.Source = (::com::sun::star::uno::XAggregation*)(::cppu::OWeakAggObject*)this;
445 332 : maDisposeListeners.disposeAndClear( aEvt );
446 :
447 332 : BrdcstHelper.aLC.disposeAndClear( aEvt );
448 :
449 : // let the property set helper notify our property listeners
450 664 : OPropertySetHelper::disposing();
451 332 : }
452 :
453 0 : void UnoControlModel::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
454 : {
455 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
456 :
457 0 : maDisposeListeners.addInterface( rxListener );
458 0 : }
459 :
460 0 : void UnoControlModel::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
461 : {
462 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
463 :
464 0 : maDisposeListeners.removeInterface( rxListener );
465 0 : }
466 :
467 :
468 : // ::com::sun::star::beans::XPropertyState
469 1144 : ::com::sun::star::beans::PropertyState UnoControlModel::getPropertyState( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
470 : {
471 1144 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
472 :
473 1144 : sal_uInt16 nPropId = GetPropertyId( PropertyName );
474 :
475 2288 : ::com::sun::star::uno::Any aValue = getPropertyValue( PropertyName );
476 2288 : ::com::sun::star::uno::Any aDefault = ImplGetDefaultValue( nPropId );
477 :
478 2288 : return CompareProperties( aValue, aDefault ) ? ::com::sun::star::beans::PropertyState_DEFAULT_VALUE : ::com::sun::star::beans::PropertyState_DIRECT_VALUE;
479 : }
480 :
481 0 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > UnoControlModel::getPropertyStates( const ::com::sun::star::uno::Sequence< OUString >& PropertyNames ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
482 : {
483 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
484 :
485 0 : sal_uInt32 nNames = PropertyNames.getLength();
486 0 : const OUString* pNames = PropertyNames.getConstArray();
487 :
488 0 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > aStates( nNames );
489 0 : ::com::sun::star::beans::PropertyState* pStates = aStates.getArray();
490 :
491 0 : for ( sal_uInt32 n = 0; n < nNames; n++ )
492 0 : pStates[n] = getPropertyState( pNames[n] );
493 :
494 0 : return aStates;
495 : }
496 :
497 15 : void UnoControlModel::setPropertyToDefault( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
498 : {
499 15 : Any aDefaultValue;
500 : {
501 15 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
502 15 : aDefaultValue = ImplGetDefaultValue( GetPropertyId( PropertyName ) );
503 : }
504 15 : setPropertyValue( PropertyName, aDefaultValue );
505 15 : }
506 :
507 15 : ::com::sun::star::uno::Any UnoControlModel::getPropertyDefault( const OUString& rPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
508 : {
509 15 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
510 :
511 15 : return ImplGetDefaultValue( GetPropertyId( rPropertyName ) );
512 : }
513 :
514 :
515 : // ::com::sun::star::io::XPersistObjec
516 0 : OUString UnoControlModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException)
517 : {
518 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
519 :
520 : OSL_FAIL( "ServiceName von UnoControlModel ?!" );
521 0 : return OUString();
522 : }
523 :
524 40 : void UnoControlModel::write( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream >& OutStream ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
525 : {
526 40 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
527 :
528 80 : ::com::sun::star::uno::Reference< ::com::sun::star::io::XMarkableStream > xMark( OutStream, ::com::sun::star::uno::UNO_QUERY );
529 : DBG_ASSERT( xMark.is(), "write: no ::com::sun::star::io::XMarkableStream!" );
530 :
531 40 : OutStream->writeShort( UNOCONTROL_STREAMVERSION );
532 :
533 80 : std::set<sal_uInt16> aProps;
534 :
535 1059 : for (ImplPropertyTable::const_iterator it = maData.begin(); it != maData.end(); ++it )
536 : {
537 2038 : if ( ( ( GetPropertyAttribs( it->first ) & ::com::sun::star::beans::PropertyAttribute::TRANSIENT ) == 0 )
538 1019 : && ( getPropertyState( GetPropertyName( it->first ) ) != ::com::sun::star::beans::PropertyState_DEFAULT_VALUE ) )
539 : {
540 29 : aProps.insert( it->first );
541 : }
542 : }
543 :
544 40 : sal_uInt32 nProps = aProps.size();
545 :
546 : // Save FontProperty always in the old format (due to missing distinction
547 : // between 5.0 and 5.1)
548 40 : OutStream->writeLong( (long) ( aProps.find( BASEPROPERTY_FONTDESCRIPTOR ) != aProps.end() ) ? ( nProps + 3 ) : nProps );
549 69 : for ( std::set<sal_uInt16>::const_iterator it = aProps.begin(); it != aProps.end(); ++it )
550 : {
551 29 : sal_Int32 nPropDataBeginMark = xMark->createMark();
552 29 : OutStream->writeLong( 0L ); // DataLen
553 :
554 29 : const ::com::sun::star::uno::Any* pProp = &(maData[*it]);
555 29 : OutStream->writeShort( *it );
556 :
557 29 : sal_Bool bVoid = pProp->getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
558 :
559 29 : OutStream->writeBoolean( bVoid );
560 :
561 29 : if ( !bVoid )
562 : {
563 29 : const ::com::sun::star::uno::Any& rValue = *pProp;
564 29 : const ::com::sun::star::uno::Type& rType = rValue.getValueType();
565 :
566 29 : if ( rType == ::getBooleanCppuType() )
567 : {
568 5 : sal_Bool b = false;
569 5 : rValue >>= b;
570 5 : OutStream->writeBoolean( b );
571 : }
572 24 : else if ( rType == ::getCppuType((const OUString*)0) )
573 : {
574 19 : OUString aUString;
575 19 : rValue >>= aUString;
576 19 : OutStream->writeUTF( aUString );
577 : }
578 5 : else if ( rType == ::getCppuType((const sal_uInt16*)0) )
579 : {
580 0 : sal_uInt16 n = 0;
581 0 : rValue >>= n;
582 0 : OutStream->writeShort( n );
583 : }
584 5 : else if ( rType == ::getCppuType((const sal_Int16*)0) )
585 : {
586 0 : sal_Int16 n = 0;
587 0 : rValue >>= n;
588 0 : OutStream->writeShort( n );
589 : }
590 5 : else if ( rType == ::getCppuType((const sal_uInt32*)0) )
591 : {
592 0 : sal_uInt32 n = 0;
593 0 : rValue >>= n;
594 0 : OutStream->writeLong( n );
595 : }
596 5 : else if ( rType == ::getCppuType((const sal_Int32*)0) )
597 : {
598 3 : sal_Int32 n = 0;
599 3 : rValue >>= n;
600 3 : OutStream->writeLong( n );
601 : }
602 2 : else if ( rType == ::getCppuType((const double*)0) )
603 : {
604 0 : double n = 0;
605 0 : rValue >>= n;
606 0 : OutStream->writeDouble( n );
607 : }
608 2 : else if ( rType == ::getCppuType((const ::com::sun::star::awt::FontDescriptor*)0) )
609 : {
610 2 : ::com::sun::star::awt::FontDescriptor aFD;
611 2 : rValue >>= aFD;
612 2 : OutStream->writeUTF( aFD.Name );
613 2 : OutStream->writeShort( aFD.Height );
614 2 : OutStream->writeShort( aFD.Width );
615 2 : OutStream->writeUTF( aFD.StyleName );
616 2 : OutStream->writeShort( aFD.Family );
617 2 : OutStream->writeShort( aFD.CharSet );
618 2 : OutStream->writeShort( aFD.Pitch );
619 2 : OutStream->writeDouble( aFD.CharacterWidth );
620 2 : OutStream->writeDouble( aFD.Weight );
621 2 : OutStream->writeShort(
622 2 : sal::static_int_cast< sal_Int16 >(aFD.Slant) );
623 2 : OutStream->writeShort( aFD.Underline );
624 2 : OutStream->writeShort( aFD.Strikeout );
625 2 : OutStream->writeDouble( aFD.Orientation );
626 2 : OutStream->writeBoolean( aFD.Kerning );
627 2 : OutStream->writeBoolean( aFD.WordLineMode );
628 2 : OutStream->writeShort( aFD.Type );
629 : }
630 0 : else if ( rType == ::getCppuType((const ::com::sun::star::uno::Sequence< OUString>*)0 ) )
631 : {
632 0 : ::com::sun::star::uno::Sequence< OUString> aSeq;
633 0 : rValue >>= aSeq;
634 0 : long nEntries = aSeq.getLength();
635 0 : OutStream->writeLong( nEntries );
636 0 : for ( long n = 0; n < nEntries; n++ )
637 0 : OutStream->writeUTF( aSeq.getConstArray()[n] );
638 : }
639 0 : else if ( rType == ::getCppuType((const ::com::sun::star::uno::Sequence<sal_uInt16>*)0 ) )
640 : {
641 0 : ::com::sun::star::uno::Sequence<sal_uInt16> aSeq;
642 0 : rValue >>= aSeq;
643 0 : long nEntries = aSeq.getLength();
644 0 : OutStream->writeLong( nEntries );
645 0 : for ( long n = 0; n < nEntries; n++ )
646 0 : OutStream->writeShort( aSeq.getConstArray()[n] );
647 : }
648 0 : else if ( rType == ::getCppuType((const ::com::sun::star::uno::Sequence<sal_Int16>*)0 ) )
649 : {
650 0 : ::com::sun::star::uno::Sequence<sal_Int16> aSeq;
651 0 : rValue >>= aSeq;
652 0 : long nEntries = aSeq.getLength();
653 0 : OutStream->writeLong( nEntries );
654 0 : for ( long n = 0; n < nEntries; n++ )
655 0 : OutStream->writeShort( aSeq.getConstArray()[n] );
656 : }
657 0 : else if ( rType.getTypeClass() == TypeClass_ENUM )
658 : {
659 0 : sal_Int32 nAsInt = 0;
660 0 : ::cppu::enum2int( nAsInt, rValue );
661 0 : OutStream->writeLong( nAsInt );
662 : }
663 : #if OSL_DEBUG_LEVEL > 0
664 : else
665 : {
666 : OString sMessage( "UnoControlModel::write: don't know how to handle a property of type '" );
667 : OUString sTypeName( rType.getTypeName() );
668 : sMessage += OString( sTypeName.getStr(), sTypeName.getLength(), RTL_TEXTENCODING_ASCII_US );
669 : sMessage += "'.\n(Currently handling property '";
670 : OUString sPropertyName( GetPropertyName( *it ) );
671 : sMessage += OString( sPropertyName.getStr(), sPropertyName.getLength(), osl_getThreadTextEncoding() );
672 : sMessage += "'.)";
673 : OSL_FAIL( sMessage.getStr() );
674 : }
675 : #endif
676 : }
677 :
678 29 : sal_Int32 nPropDataLen = xMark->offsetToMark( nPropDataBeginMark );
679 29 : xMark->jumpToMark( nPropDataBeginMark );
680 29 : OutStream->writeLong( nPropDataLen );
681 29 : xMark->jumpToFurthest();
682 29 : xMark->deleteMark(nPropDataBeginMark);
683 : }
684 :
685 40 : if ( aProps.find( BASEPROPERTY_FONTDESCRIPTOR ) != aProps.end() )
686 : {
687 2 : const ::com::sun::star::uno::Any* pProp = &maData[ BASEPROPERTY_FONTDESCRIPTOR ];
688 : // Until 5.0 export arrives, write old format..
689 2 : ::com::sun::star::awt::FontDescriptor aFD;
690 2 : (*pProp) >>= aFD;
691 :
692 8 : for ( sal_uInt16 n = BASEPROPERTY_FONT_TYPE; n <= BASEPROPERTY_FONT_ATTRIBS; n++ )
693 : {
694 6 : sal_Int32 nPropDataBeginMark = xMark->createMark();
695 6 : OutStream->writeLong( 0L ); // DataLen
696 6 : OutStream->writeShort( n ); // PropId
697 6 : OutStream->writeBoolean( sal_False ); // Void
698 :
699 6 : if ( n == BASEPROPERTY_FONT_TYPE )
700 : {
701 2 : OutStream->writeUTF( aFD.Name );
702 2 : OutStream->writeUTF( aFD.StyleName );
703 2 : OutStream->writeShort( aFD.Family );
704 2 : OutStream->writeShort( aFD.CharSet );
705 2 : OutStream->writeShort( aFD.Pitch );
706 : }
707 4 : else if ( n == BASEPROPERTY_FONT_SIZE )
708 : {
709 2 : OutStream->writeLong( aFD.Width );
710 2 : OutStream->writeLong( aFD.Height );
711 2 : OutStream->writeShort(
712 : sal::static_int_cast< sal_Int16 >(
713 2 : VCLUnoHelper::ConvertFontWidth( aFD.CharacterWidth )) );
714 : }
715 2 : else if ( n == BASEPROPERTY_FONT_ATTRIBS )
716 : {
717 2 : OutStream->writeShort(
718 : sal::static_int_cast< sal_Int16 >(
719 2 : VCLUnoHelper::ConvertFontWeight( aFD.Weight )) );
720 2 : OutStream->writeShort(
721 2 : sal::static_int_cast< sal_Int16 >(aFD.Slant) );
722 2 : OutStream->writeShort( aFD.Underline );
723 2 : OutStream->writeShort( aFD.Strikeout );
724 2 : OutStream->writeShort( (short)(aFD.Orientation * 10) );
725 2 : OutStream->writeBoolean( aFD.Kerning );
726 2 : OutStream->writeBoolean( aFD.WordLineMode );
727 : }
728 : else
729 : {
730 : OSL_FAIL( "Property?!" );
731 : }
732 :
733 6 : sal_Int32 nPropDataLen = xMark->offsetToMark( nPropDataBeginMark );
734 6 : xMark->jumpToMark( nPropDataBeginMark );
735 6 : OutStream->writeLong( nPropDataLen );
736 6 : xMark->jumpToFurthest();
737 6 : xMark->deleteMark(nPropDataBeginMark);
738 2 : }
739 40 : }
740 40 : }
741 :
742 40 : void UnoControlModel::read( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream >& InStream ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
743 : {
744 40 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
745 :
746 80 : ::com::sun::star::uno::Reference< ::com::sun::star::io::XMarkableStream > xMark( InStream, ::com::sun::star::uno::UNO_QUERY );
747 : DBG_ASSERT( xMark.is(), "read: no ::com::sun::star::io::XMarkableStream!" );
748 :
749 40 : short nVersion = InStream->readShort();
750 40 : sal_uInt32 nProps = (sal_uInt32)InStream->readLong();
751 80 : ::com::sun::star::uno::Sequence< OUString> aProps( nProps );
752 80 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> aValues( nProps );
753 40 : sal_Bool bInvalidEntries = sal_False;
754 :
755 : // Unfortunately, there's no mark for the whole block, thus only properties may be changed.
756 : // No data for the model may be added following the properties
757 :
758 : // Used for import of old parts in ::com::sun::star::awt::FontDescriptor
759 40 : ::com::sun::star::awt::FontDescriptor* pFD = NULL;
760 :
761 : sal_uInt32 i;
762 75 : for ( i = 0; i < nProps; i++ )
763 : {
764 35 : sal_Int32 nPropDataBeginMark = xMark->createMark();
765 35 : sal_Int32 nPropDataLen = InStream->readLong();
766 :
767 35 : sal_uInt16 nPropId = (sal_uInt16)InStream->readShort();
768 :
769 35 : ::com::sun::star::uno::Any aValue;
770 35 : sal_Bool bIsVoid = InStream->readBoolean();
771 35 : if ( !bIsVoid )
772 : {
773 35 : if ( maData.find( nPropId ) != maData.end() )
774 : {
775 29 : const ::com::sun::star::uno::Type* pType = GetPropertyType( nPropId );
776 29 : if ( *pType == ::getBooleanCppuType() )
777 : {
778 5 : sal_Bool b = InStream->readBoolean();
779 5 : aValue <<= b;
780 : }
781 24 : else if ( *pType == ::getCppuType((const OUString*)0) )
782 : {
783 19 : OUString aUTF = InStream->readUTF();
784 19 : aValue <<= aUTF;
785 : }
786 5 : else if ( *pType == ::getCppuType((const sal_uInt16*)0) )
787 : {
788 0 : sal_uInt16 n = InStream->readShort();
789 0 : aValue <<= n;
790 : }
791 5 : else if ( *pType == ::getCppuType((const sal_Int16*)0) )
792 : {
793 0 : sal_Int16 n = InStream->readShort();
794 0 : aValue <<= n;
795 : }
796 5 : else if ( *pType == ::getCppuType((const sal_uInt32*)0) )
797 : {
798 0 : sal_uInt32 n = InStream->readLong();
799 0 : aValue <<= n;
800 : }
801 5 : else if ( *pType == ::getCppuType((const sal_Int32*)0) )
802 : {
803 3 : sal_Int32 n = InStream->readLong();
804 3 : aValue <<= n;
805 : }
806 2 : else if ( *pType == ::getCppuType((const double*)0) )
807 : {
808 0 : double n = InStream->readDouble();
809 0 : aValue <<= n;
810 : }
811 2 : else if ( *pType == ::getCppuType((const ::com::sun::star::awt::FontDescriptor*)0) )
812 : {
813 2 : ::com::sun::star::awt::FontDescriptor aFD;
814 2 : aFD.Name = InStream->readUTF();
815 2 : aFD.Height = InStream->readShort();
816 2 : aFD.Width = InStream->readShort();
817 2 : aFD.StyleName = InStream->readUTF();
818 2 : aFD.Family = InStream->readShort();
819 2 : aFD.CharSet = InStream->readShort();
820 2 : aFD.Pitch = InStream->readShort();
821 2 : aFD.CharacterWidth = (float)InStream->readDouble();
822 2 : aFD.Weight = (float)InStream->readDouble();
823 2 : aFD.Slant = (::com::sun::star::awt::FontSlant)InStream->readShort();
824 2 : aFD.Underline = InStream->readShort();
825 2 : aFD.Strikeout = InStream->readShort();
826 2 : aFD.Orientation = (float)InStream->readDouble();
827 2 : aFD.Kerning = InStream->readBoolean();
828 2 : aFD.WordLineMode = InStream->readBoolean();
829 2 : aFD.Type = InStream->readShort();
830 2 : aValue <<= aFD;
831 : }
832 0 : else if ( *pType == ::getCppuType((const ::com::sun::star::uno::Sequence< OUString>*)0 ) )
833 : {
834 0 : long nEntries = InStream->readLong();
835 0 : ::com::sun::star::uno::Sequence< OUString> aSeq( nEntries );
836 0 : for ( long n = 0; n < nEntries; n++ )
837 0 : aSeq.getArray()[n] = InStream->readUTF();
838 0 : aValue <<= aSeq;
839 :
840 : }
841 0 : else if ( *pType == ::getCppuType((const ::com::sun::star::uno::Sequence<sal_uInt16>*)0 ) )
842 :
843 : {
844 0 : long nEntries = InStream->readLong();
845 0 : ::com::sun::star::uno::Sequence<sal_uInt16> aSeq( nEntries );
846 0 : for ( long n = 0; n < nEntries; n++ )
847 0 : aSeq.getArray()[n] = (sal_uInt16)InStream->readShort();
848 0 : aValue <<= aSeq;
849 : }
850 0 : else if ( *pType == ::getCppuType((const ::com::sun::star::uno::Sequence<sal_Int16>*)0 ) )
851 : {
852 0 : long nEntries = InStream->readLong();
853 0 : ::com::sun::star::uno::Sequence<sal_Int16> aSeq( nEntries );
854 0 : for ( long n = 0; n < nEntries; n++ )
855 0 : aSeq.getArray()[n] = (sal_Int16)InStream->readShort();
856 0 : aValue <<= aSeq;
857 : }
858 0 : else if ( pType->getTypeClass() == TypeClass_ENUM )
859 : {
860 0 : sal_Int32 nAsInt = InStream->readLong();
861 0 : aValue = ::cppu::int2enum( nAsInt, *pType );
862 : }
863 : else
864 : {
865 0 : OString sMessage( "UnoControlModel::read: don't know how to handle a property of type '" );
866 0 : OUString sTypeName( pType->getTypeName() );
867 0 : sMessage += OString( sTypeName.getStr(), sTypeName.getLength(), RTL_TEXTENCODING_ASCII_US );
868 0 : sMessage += "'.\n(Currently handling property '";
869 0 : OUString sPropertyName( GetPropertyName( nPropId ) );
870 0 : sMessage += OString( sPropertyName.getStr(), sPropertyName.getLength(), osl_getThreadTextEncoding() );
871 0 : sMessage += "'.)";
872 0 : OSL_FAIL( sMessage.getStr() );
873 : }
874 : }
875 : else
876 : {
877 : // Old trash from 5.0
878 6 : if ( nPropId == BASEPROPERTY_FONT_TYPE )
879 : {
880 : // Redundant information for older versions
881 : // is skipped by MarkableStream
882 2 : if ( nVersion < 2 )
883 : {
884 0 : if ( !pFD )
885 : {
886 0 : pFD = new ::com::sun::star::awt::FontDescriptor;
887 0 : if ( maData.find( BASEPROPERTY_FONTDESCRIPTOR ) != maData.end() ) // wegen den Defaults...
888 0 : maData[ BASEPROPERTY_FONTDESCRIPTOR ] >>= *pFD;
889 : }
890 0 : pFD->Name = InStream->readUTF();
891 0 : pFD->StyleName = InStream->readUTF();
892 0 : pFD->Family = InStream->readShort();
893 0 : pFD->CharSet = InStream->readShort();
894 0 : pFD->Pitch = InStream->readShort();
895 : }
896 : }
897 4 : else if ( nPropId == BASEPROPERTY_FONT_SIZE )
898 : {
899 2 : if ( nVersion < 2 )
900 : {
901 0 : if ( !pFD )
902 : {
903 0 : pFD = new ::com::sun::star::awt::FontDescriptor;
904 0 : if ( maData.find(BASEPROPERTY_FONTDESCRIPTOR) != maData.end() ) // due to defaults...
905 0 : maData[BASEPROPERTY_FONTDESCRIPTOR] >>= *pFD;
906 : }
907 0 : pFD->Width = (sal_Int16)InStream->readLong();
908 0 : pFD->Height = (sal_Int16)InStream->readLong();
909 0 : InStream->readShort(); // ignore ::com::sun::star::awt::FontWidth - it was
910 : // misspelled and is no longer needed
911 0 : pFD->CharacterWidth = ::com::sun::star::awt::FontWidth::DONTKNOW;
912 : }
913 : }
914 2 : else if ( nPropId == BASEPROPERTY_FONT_ATTRIBS )
915 : {
916 2 : if ( nVersion < 2 )
917 : {
918 0 : if ( !pFD )
919 : {
920 0 : pFD = new ::com::sun::star::awt::FontDescriptor;
921 0 : if ( maData.find(BASEPROPERTY_FONTDESCRIPTOR) != maData.end() ) // due to defaults...
922 0 : maData[BASEPROPERTY_FONTDESCRIPTOR] >>= *pFD;
923 : }
924 0 : pFD->Weight = VCLUnoHelper::ConvertFontWeight( (FontWeight) InStream->readShort() );
925 0 : pFD->Slant = (::com::sun::star::awt::FontSlant)InStream->readShort();
926 0 : pFD->Underline = InStream->readShort();
927 0 : pFD->Strikeout = InStream->readShort();
928 0 : pFD->Orientation = ( (float)(double)InStream->readShort() ) / 10;
929 0 : pFD->Kerning = InStream->readBoolean();
930 0 : pFD->WordLineMode = InStream->readBoolean();
931 : }
932 : }
933 : else
934 : {
935 : OSL_FAIL( "read: unknown Property!" );
936 : }
937 : }
938 : }
939 : else // bVoid
940 : {
941 0 : if ( nPropId == BASEPROPERTY_FONTDESCRIPTOR )
942 : {
943 0 : EmptyFontDescriptor aFD;
944 0 : aValue <<= aFD;
945 : }
946 : }
947 :
948 35 : if ( maData.find( nPropId ) != maData.end() )
949 : {
950 29 : aProps.getArray()[i] = GetPropertyName( nPropId );
951 29 : aValues.getArray()[i] = aValue;
952 : }
953 : else
954 : {
955 6 : bInvalidEntries = sal_True;
956 : }
957 :
958 : // Skip rest of input if there is more data in stream than this version can handle
959 35 : xMark->jumpToMark( nPropDataBeginMark );
960 35 : InStream->skipBytes( nPropDataLen );
961 35 : xMark->deleteMark(nPropDataBeginMark);
962 35 : }
963 40 : if ( bInvalidEntries )
964 : {
965 13 : for ( i = 0; i < (sal_uInt32)aProps.getLength(); i++ )
966 : {
967 11 : if ( aProps.getConstArray()[i].isEmpty() )
968 : {
969 6 : ::comphelper::removeElementAt( aProps, i );
970 6 : ::comphelper::removeElementAt( aValues, i );
971 6 : i--;
972 : }
973 : }
974 : }
975 :
976 : try
977 : {
978 40 : setPropertyValues( aProps, aValues );
979 : }
980 0 : catch ( const Exception& )
981 : {
982 : DBG_UNHANDLED_EXCEPTION();
983 : }
984 :
985 40 : if ( pFD )
986 : {
987 0 : ::com::sun::star::uno::Any aValue;
988 0 : aValue <<= *pFD;
989 0 : setPropertyValue( GetPropertyName( BASEPROPERTY_FONTDESCRIPTOR ), aValue );
990 0 : delete pFD;
991 40 : }
992 40 : }
993 :
994 :
995 : // ::com::sun::star::lang::XServiceInfo
996 0 : OUString UnoControlModel::getImplementationName( ) throw(::com::sun::star::uno::RuntimeException)
997 : {
998 : OSL_FAIL( "This method should be overloaded!" );
999 0 : return OUString();
1000 :
1001 : }
1002 :
1003 181 : sal_Bool UnoControlModel::supportsService( const OUString& rServiceName ) throw(::com::sun::star::uno::RuntimeException)
1004 : {
1005 181 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
1006 :
1007 362 : ::com::sun::star::uno::Sequence< OUString > aSNL = getSupportedServiceNames();
1008 181 : const OUString * pArray = aSNL.getConstArray();
1009 435 : for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
1010 334 : if( pArray[i] == rServiceName )
1011 80 : return sal_True;
1012 282 : return sal_False;
1013 : }
1014 :
1015 391 : ::com::sun::star::uno::Sequence< OUString > UnoControlModel::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException)
1016 : {
1017 391 : OUString sName( "com.sun.star.awt.UnoControlModel" );
1018 391 : return Sequence< OUString >( &sName, 1 );
1019 : }
1020 :
1021 : // ------------------------------------------------------------------
1022 : template <class TYPE>
1023 : sal_Bool convertType(Any& _rConvertedValue, const Any& _rNewValueTest, const TYPE* /* _pTypeDisambiguation */)
1024 : {
1025 : TYPE tValue;
1026 : if (_rNewValueTest >>= tValue)
1027 : {
1028 : _rConvertedValue <<= tValue;
1029 : return sal_True;
1030 : }
1031 : }
1032 :
1033 : // ..................................................................
1034 32137 : sal_Bool UnoControlModel::convertFastPropertyValue( Any & rConvertedValue, Any & rOldValue, sal_Int32 nPropId, const Any& rValue ) throw (IllegalArgumentException)
1035 : {
1036 32137 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
1037 :
1038 32137 : sal_Bool bVoid = rValue.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
1039 32137 : if ( bVoid )
1040 : {
1041 67 : rConvertedValue.clear();
1042 : }
1043 : else
1044 : {
1045 32070 : const ::com::sun::star::uno::Type* pDestType = GetPropertyType( (sal_uInt16)nPropId );
1046 32070 : if ( pDestType->getTypeClass() == TypeClass_ANY )
1047 : {
1048 16 : rConvertedValue = rValue;
1049 : }
1050 : else
1051 : {
1052 32054 : if ( pDestType->equals( rValue.getValueType() ) )
1053 : {
1054 32007 : rConvertedValue = rValue;
1055 : }
1056 : else
1057 : {
1058 47 : sal_Bool bConverted = sal_False;
1059 : // 13.03.2001 - 84923 - frank.schoenheit@germany.sun.com
1060 :
1061 47 : switch (pDestType->getTypeClass())
1062 : {
1063 : case TypeClass_DOUBLE:
1064 : {
1065 : // try as double
1066 6 : double nAsDouble = 0;
1067 6 : bConverted = ( rValue >>= nAsDouble );
1068 6 : if ( bConverted )
1069 4 : rConvertedValue <<= nAsDouble;
1070 : else
1071 : { // try as integer
1072 2 : sal_Int32 nAsInteger = 0;
1073 2 : bConverted = ( rValue >>= nAsInteger );
1074 2 : if ( bConverted )
1075 0 : rConvertedValue <<= (double)nAsInteger;
1076 : }
1077 : }
1078 6 : break;
1079 : case TypeClass_SHORT:
1080 : {
1081 : sal_Int16 n;
1082 2 : bConverted = ( rValue >>= n );
1083 2 : if ( bConverted )
1084 0 : rConvertedValue <<= n;
1085 : }
1086 2 : break;
1087 : case TypeClass_UNSIGNED_SHORT:
1088 : {
1089 : sal_uInt16 n;
1090 0 : bConverted = ( rValue >>= n );
1091 0 : if ( bConverted )
1092 0 : rConvertedValue <<= n;
1093 : }
1094 0 : break;
1095 : case TypeClass_LONG:
1096 : {
1097 : sal_Int32 n;
1098 2 : bConverted = ( rValue >>= n );
1099 2 : if ( bConverted )
1100 0 : rConvertedValue <<= n;
1101 : }
1102 2 : break;
1103 : case TypeClass_UNSIGNED_LONG:
1104 : {
1105 : sal_uInt32 n;
1106 0 : bConverted = ( rValue >>= n );
1107 0 : if ( bConverted )
1108 0 : rConvertedValue <<= n;
1109 : }
1110 0 : break;
1111 : case TypeClass_INTERFACE:
1112 : {
1113 22 : if ( rValue.getValueType().getTypeClass() == TypeClass_INTERFACE )
1114 : {
1115 22 : Reference< XInterface > xPure( rValue, UNO_QUERY );
1116 22 : if ( xPure.is() )
1117 2 : rConvertedValue = xPure->queryInterface( *pDestType );
1118 : else
1119 20 : rConvertedValue.setValue( NULL, *pDestType );
1120 22 : bConverted = sal_True;
1121 : }
1122 : }
1123 22 : break;
1124 : case TypeClass_ENUM:
1125 : {
1126 0 : sal_Int32 nValue = 0;
1127 0 : bConverted = ( rValue >>= nValue );
1128 0 : if ( bConverted )
1129 0 : rConvertedValue = ::cppu::int2enum( nValue, *pDestType );
1130 : }
1131 0 : break;
1132 : default: ; // avoid compiler warning
1133 : }
1134 :
1135 47 : if (!bConverted)
1136 : {
1137 21 : OUStringBuffer aErrorMessage;
1138 21 : aErrorMessage.appendAscii( "Unable to convert the given value for the property " );
1139 21 : aErrorMessage.append ( GetPropertyName( (sal_uInt16)nPropId ) );
1140 21 : aErrorMessage.appendAscii( ".\n" );
1141 21 : aErrorMessage.appendAscii( "Expected type: " );
1142 21 : aErrorMessage.append ( pDestType->getTypeName() );
1143 21 : aErrorMessage.appendAscii( "\n" );
1144 21 : aErrorMessage.appendAscii( "Found type: " );
1145 21 : aErrorMessage.append ( rValue.getValueType().getTypeName() );
1146 : throw ::com::sun::star::lang::IllegalArgumentException(
1147 : aErrorMessage.makeStringAndClear(),
1148 : static_cast< ::com::sun::star::beans::XPropertySet* >(this),
1149 21 : 1);
1150 : }
1151 : }
1152 : }
1153 : }
1154 :
1155 : // the current value
1156 32116 : getFastPropertyValue( rOldValue, nPropId );
1157 32137 : return !CompareProperties( rConvertedValue, rOldValue );
1158 : }
1159 :
1160 7933 : void UnoControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception)
1161 : {
1162 : // Missing: the fake solo properties of the FontDescriptor
1163 :
1164 7933 : ImplPropertyTable::const_iterator it = maData.find( nPropId );
1165 7933 : const ::com::sun::star::uno::Any* pProp = it == maData.end() ? NULL : &(it->second);
1166 15866 : ENSURE_OR_RETURN_VOID( pProp, "UnoControlModel::setFastPropertyValue_NoBroadcast: invalid property id!" );
1167 :
1168 : DBG_ASSERT( ( rValue.getValueType().getTypeClass() != ::com::sun::star::uno::TypeClass_VOID ) || ( GetPropertyAttribs( (sal_uInt16)nPropId ) & ::com::sun::star::beans::PropertyAttribute::MAYBEVOID ), "Property darf nicht VOID sein!" );
1169 7933 : maData[ nPropId ] = rValue;
1170 : }
1171 :
1172 106307 : void UnoControlModel::getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nPropId ) const
1173 : {
1174 106307 : ::osl::Guard< ::osl::Mutex > aGuard( ((UnoControlModel*)this)->GetMutex() );
1175 :
1176 106307 : ImplPropertyTable::const_iterator it = maData.find( nPropId );
1177 106307 : const ::com::sun::star::uno::Any* pProp = it == maData.end() ? NULL : &(it->second);
1178 :
1179 106307 : if ( pProp )
1180 80509 : rValue = *pProp;
1181 25798 : else if ( ( nPropId >= BASEPROPERTY_FONTDESCRIPTORPART_START ) && ( nPropId <= BASEPROPERTY_FONTDESCRIPTORPART_END ) )
1182 : {
1183 25798 : pProp = &( maData.find( BASEPROPERTY_FONTDESCRIPTOR )->second );
1184 25798 : ::com::sun::star::awt::FontDescriptor aFD;
1185 25798 : (*pProp) >>= aFD;
1186 25798 : switch ( nPropId )
1187 : {
1188 2294 : case BASEPROPERTY_FONTDESCRIPTORPART_NAME: rValue <<= aFD.Name;
1189 2294 : break;
1190 1567 : case BASEPROPERTY_FONTDESCRIPTORPART_STYLENAME: rValue <<= aFD.StyleName;
1191 1567 : break;
1192 1566 : case BASEPROPERTY_FONTDESCRIPTORPART_FAMILY: rValue <<= aFD.Family;
1193 1566 : break;
1194 1566 : case BASEPROPERTY_FONTDESCRIPTORPART_CHARSET: rValue <<= aFD.CharSet;
1195 1566 : break;
1196 1566 : case BASEPROPERTY_FONTDESCRIPTORPART_HEIGHT: rValue <<= (float)aFD.Height;
1197 1566 : break;
1198 1566 : case BASEPROPERTY_FONTDESCRIPTORPART_WEIGHT: rValue <<= aFD.Weight;
1199 1566 : break;
1200 1567 : case BASEPROPERTY_FONTDESCRIPTORPART_SLANT: rValue <<= (sal_Int16)aFD.Slant;
1201 1567 : break;
1202 1567 : case BASEPROPERTY_FONTDESCRIPTORPART_UNDERLINE: rValue <<= aFD.Underline;
1203 1567 : break;
1204 1569 : case BASEPROPERTY_FONTDESCRIPTORPART_STRIKEOUT: rValue <<= aFD.Strikeout;
1205 1569 : break;
1206 1566 : case BASEPROPERTY_FONTDESCRIPTORPART_WIDTH: rValue <<= aFD.Width;
1207 1566 : break;
1208 1568 : case BASEPROPERTY_FONTDESCRIPTORPART_PITCH: rValue <<= aFD.Pitch;
1209 1568 : break;
1210 1566 : case BASEPROPERTY_FONTDESCRIPTORPART_CHARWIDTH: rValue <<= aFD.CharacterWidth;
1211 1566 : break;
1212 1566 : case BASEPROPERTY_FONTDESCRIPTORPART_ORIENTATION: rValue <<= aFD.Orientation;
1213 1566 : break;
1214 1568 : case BASEPROPERTY_FONTDESCRIPTORPART_KERNING: rValue <<= aFD.Kerning;
1215 1568 : break;
1216 1570 : case BASEPROPERTY_FONTDESCRIPTORPART_WORDLINEMODE: rValue <<= aFD.WordLineMode;
1217 1570 : break;
1218 1566 : case BASEPROPERTY_FONTDESCRIPTORPART_TYPE: rValue <<= aFD.Type;
1219 1566 : break;
1220 : default: OSL_FAIL( "FontProperty?!" );
1221 25798 : }
1222 : }
1223 : else
1224 : {
1225 : OSL_FAIL( "getFastPropertyValue - invalid Property!" );
1226 106307 : }
1227 106307 : }
1228 :
1229 : // ::com::sun::star::beans::XPropertySet
1230 1895 : void UnoControlModel::setPropertyValue( const OUString& rPropertyName, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
1231 : {
1232 1895 : sal_Int32 nPropId = 0;
1233 : {
1234 1895 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
1235 1895 : nPropId = (sal_Int32) GetPropertyId( rPropertyName );
1236 1895 : DBG_ASSERT( nPropId, "Invalid ID in UnoControlModel::setPropertyValue" );
1237 : }
1238 1895 : if( nPropId )
1239 1895 : setFastPropertyValue( nPropId, rValue );
1240 : else
1241 0 : throw ::com::sun::star::beans::UnknownPropertyException();
1242 1895 : }
1243 :
1244 : // ::com::sun::star::beans::XFastPropertySet
1245 5671 : void UnoControlModel::setFastPropertyValue( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
1246 : {
1247 5671 : if ( ( nPropId >= BASEPROPERTY_FONTDESCRIPTORPART_START ) && ( nPropId <= BASEPROPERTY_FONTDESCRIPTORPART_END ) )
1248 : {
1249 364 : ::osl::ClearableMutexGuard aGuard( GetMutex() );
1250 :
1251 728 : Any aOldSingleValue;
1252 364 : getFastPropertyValue( aOldSingleValue, BASEPROPERTY_FONTDESCRIPTORPART_START );
1253 :
1254 364 : ::com::sun::star::uno::Any* pProp = &maData[ BASEPROPERTY_FONTDESCRIPTOR ];
1255 728 : FontDescriptor aOldFontDescriptor;
1256 364 : (*pProp) >>= aOldFontDescriptor;
1257 :
1258 728 : FontDescriptor aNewFontDescriptor( aOldFontDescriptor );
1259 364 : lcl_ImplMergeFontProperty( aNewFontDescriptor, (sal_uInt16)nPropId, rValue );
1260 :
1261 728 : Any aNewValue;
1262 364 : aNewValue <<= aNewFontDescriptor;
1263 364 : sal_Int32 nDescriptorId( BASEPROPERTY_FONTDESCRIPTOR );
1264 364 : nDescriptorId = BASEPROPERTY_FONTDESCRIPTOR;
1265 :
1266 : // also, we need fire a propertyChange event for the single property, since with
1267 : // the above line, only an event for the FontDescriptor property will be fired
1268 728 : Any aNewSingleValue;
1269 364 : getFastPropertyValue( aNewSingleValue, BASEPROPERTY_FONTDESCRIPTORPART_START );
1270 :
1271 364 : aGuard.clear();
1272 364 : setFastPropertyValues( 1, &nDescriptorId, &aNewValue, 1 );
1273 728 : fire( &nPropId, &aNewSingleValue, &aOldSingleValue, 1, sal_False );
1274 : }
1275 : else
1276 5307 : setFastPropertyValues( 1, &nPropId, &rValue, 1 );
1277 5651 : }
1278 :
1279 : // ::com::sun::star::beans::XMultiPropertySet
1280 0 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > UnoControlModel::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
1281 : {
1282 : OSL_FAIL( "UnoControlModel::getPropertySetInfo() not possible!" );
1283 0 : return ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >();
1284 : }
1285 :
1286 1370 : void UnoControlModel::setPropertyValues( const ::com::sun::star::uno::Sequence< OUString >& rPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
1287 : {
1288 1370 : ::osl::ClearableMutexGuard aGuard( GetMutex() );
1289 :
1290 1370 : sal_Int32 nProps = rPropertyNames.getLength();
1291 :
1292 : // sal_Int32* pHandles = new sal_Int32[nProps];
1293 : // don't do this - it leaks in case of an exception
1294 2740 : Sequence< sal_Int32 > aHandles( nProps );
1295 1370 : sal_Int32* pHandles = aHandles.getArray();
1296 :
1297 : // may need to change the order in the sequence, for this we need a non-const value sequence
1298 2740 : uno::Sequence< uno::Any > aValues( Values );
1299 1370 : uno::Any* pValues = aValues.getArray();
1300 :
1301 1370 : sal_Int32 nValidHandles = getInfoHelper().fillHandles( pHandles, rPropertyNames );
1302 :
1303 1370 : if ( nValidHandles )
1304 : {
1305 : // if somebody sets properties which are single aspects of a font descriptor,
1306 : // remove them, and build a font descriptor instead
1307 1348 : ::std::auto_ptr< awt::FontDescriptor > pFD;
1308 44584 : for ( sal_uInt16 n = 0; n < nProps; ++n )
1309 : {
1310 43236 : if ( ( pHandles[n] >= BASEPROPERTY_FONTDESCRIPTORPART_START ) && ( pHandles[n] <= BASEPROPERTY_FONTDESCRIPTORPART_END ) )
1311 : {
1312 18106 : if ( !pFD.get() )
1313 : {
1314 1154 : ::com::sun::star::uno::Any* pProp = &maData[ BASEPROPERTY_FONTDESCRIPTOR ];
1315 1154 : pFD.reset( new awt::FontDescriptor );
1316 1154 : (*pProp) >>= *pFD;
1317 : }
1318 18106 : lcl_ImplMergeFontProperty( *pFD, (sal_uInt16)pHandles[n], pValues[n] );
1319 18106 : pHandles[n] = -1;
1320 18106 : nValidHandles--;
1321 : }
1322 : }
1323 :
1324 1348 : if ( nValidHandles )
1325 : {
1326 1348 : ImplNormalizePropertySequence( nProps, pHandles, pValues, &nValidHandles );
1327 1348 : aGuard.clear();
1328 : // clear our guard before calling into setFastPropertyValues - this method
1329 : // will implicitly call property listeners, and this should not happen with
1330 : // our mutex locked
1331 : // #i23451#
1332 1348 : setFastPropertyValues( nProps, pHandles, pValues, nValidHandles );
1333 : }
1334 : else
1335 0 : aGuard.clear();
1336 : // same as a few lines above
1337 :
1338 : // Don't merge FD property into array, as it is sorted
1339 1347 : if ( pFD.get() )
1340 : {
1341 1153 : ::com::sun::star::uno::Any aValue;
1342 1153 : aValue <<= *pFD;
1343 1153 : sal_Int32 nHandle = BASEPROPERTY_FONTDESCRIPTOR;
1344 1153 : setFastPropertyValues( 1, &nHandle, &aValue, 1 );
1345 1348 : }
1346 1370 : }
1347 1369 : }
1348 :
1349 :
1350 :
1351 1348 : void UnoControlModel::ImplNormalizePropertySequence( const sal_Int32, sal_Int32*,
1352 : uno::Any*, sal_Int32* ) const SAL_THROW(())
1353 : {
1354 : // nothing to do here
1355 1348 : }
1356 :
1357 225 : void UnoControlModel::ImplEnsureHandleOrder( const sal_Int32 _nCount, sal_Int32* _pHandles,
1358 : uno::Any* _pValues, sal_Int32 _nFirstHandle, sal_Int32 _nSecondHandle ) const
1359 : {
1360 7867 : for ( sal_Int32 i=0; i < _nCount; ++_pHandles, ++_pValues, ++i )
1361 : {
1362 7642 : if ( _nSecondHandle == *_pHandles )
1363 : {
1364 167 : sal_Int32* pLaterHandles = _pHandles + 1;
1365 167 : uno::Any* pLaterValues = _pValues + 1;
1366 331 : for ( sal_Int32 j = i + 1; j < _nCount; ++j, ++pLaterHandles, ++pLaterValues )
1367 : {
1368 200 : if ( _nFirstHandle == *pLaterHandles )
1369 : {
1370 : // indeed it is -> exchange the both places in the sequences
1371 36 : sal_Int32 nHandle( *_pHandles );
1372 36 : *_pHandles = *pLaterHandles;
1373 36 : *pLaterHandles = nHandle;
1374 :
1375 36 : uno::Any aValue( *_pValues );
1376 36 : *_pValues = *pLaterValues;
1377 36 : *pLaterValues = aValue;
1378 :
1379 36 : break;
1380 : // this will leave the inner loop, and continue with the outer loop.
1381 : // Note that this means we will encounter the _nSecondHandle handle, again, once we reached
1382 : // (in the outer loop) the place where we just put it.
1383 : }
1384 : }
1385 : }
1386 : }
1387 690 : }
1388 :
1389 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|