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