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 0 : 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 0 : float nExtractFloat = 0;
70 0 : sal_Int16 nExtractShort = 0;
71 :
72 0 : switch ( nPropId )
73 : {
74 0 : case BASEPROPERTY_FONTDESCRIPTORPART_NAME: rValue >>= rFD.Name;
75 0 : break;
76 0 : case BASEPROPERTY_FONTDESCRIPTORPART_STYLENAME: rValue >>= rFD.StyleName;
77 0 : break;
78 0 : case BASEPROPERTY_FONTDESCRIPTORPART_FAMILY: rValue >>= rFD.Family;
79 0 : break;
80 0 : case BASEPROPERTY_FONTDESCRIPTORPART_CHARSET: rValue >>= rFD.CharSet;
81 0 : break;
82 0 : case BASEPROPERTY_FONTDESCRIPTORPART_HEIGHT: rValue >>= nExtractFloat; rFD.Height = (sal_Int16)nExtractFloat;
83 0 : break;
84 0 : case BASEPROPERTY_FONTDESCRIPTORPART_WEIGHT: rValue >>= rFD.Weight;
85 0 : break;
86 0 : case BASEPROPERTY_FONTDESCRIPTORPART_SLANT: if ( rValue >>= nExtractShort )
87 0 : rFD.Slant = (::com::sun::star::awt::FontSlant)nExtractShort;
88 : else
89 0 : rValue >>= rFD.Slant;
90 0 : break;
91 0 : case BASEPROPERTY_FONTDESCRIPTORPART_UNDERLINE: rValue >>= rFD.Underline;
92 0 : break;
93 0 : case BASEPROPERTY_FONTDESCRIPTORPART_STRIKEOUT: rValue >>= rFD.Strikeout;
94 0 : break;
95 0 : case BASEPROPERTY_FONTDESCRIPTORPART_WIDTH: rValue >>= rFD.Width;
96 0 : break;
97 0 : case BASEPROPERTY_FONTDESCRIPTORPART_PITCH: rValue >>= rFD.Pitch;
98 0 : break;
99 0 : case BASEPROPERTY_FONTDESCRIPTORPART_CHARWIDTH: rValue >>= rFD.CharacterWidth;
100 0 : break;
101 0 : case BASEPROPERTY_FONTDESCRIPTORPART_ORIENTATION: rValue >>= rFD.Orientation;
102 0 : break;
103 0 : case BASEPROPERTY_FONTDESCRIPTORPART_KERNING: rValue >>= rFD.Kerning;
104 0 : break;
105 0 : case BASEPROPERTY_FONTDESCRIPTORPART_WORDLINEMODE: rValue >>= rFD.WordLineMode;
106 0 : break;
107 0 : case BASEPROPERTY_FONTDESCRIPTORPART_TYPE: rValue >>= rFD.Type;
108 0 : break;
109 : default: OSL_FAIL( "FontProperty?!" );
110 : }
111 0 : }
112 :
113 :
114 : // class UnoControlModel
115 :
116 0 : UnoControlModel::UnoControlModel( const Reference< XComponentContext >& rxContext )
117 : :UnoControlModel_Base()
118 : ,MutexAndBroadcastHelper()
119 : ,OPropertySetHelper( BrdcstHelper )
120 : ,maDisposeListeners( *this )
121 0 : ,m_xContext( rxContext )
122 : {
123 : // Insert properties from Model into table,
124 : // only existing properties are valid, even if they're VOID
125 0 : }
126 :
127 0 : UnoControlModel::UnoControlModel( const UnoControlModel& rModel )
128 : : UnoControlModel_Base()
129 : , MutexAndBroadcastHelper()
130 : , OPropertySetHelper( BrdcstHelper )
131 : , maData( rModel.maData )
132 : , maDisposeListeners( *this )
133 0 : , m_xContext( rModel.m_xContext )
134 : {
135 0 : }
136 :
137 0 : ::com::sun::star::uno::Sequence<sal_Int32> UnoControlModel::ImplGetPropertyIds() const
138 : {
139 0 : sal_uInt32 nIDs = maData.size();
140 0 : ::com::sun::star::uno::Sequence<sal_Int32> aIDs( nIDs );
141 0 : sal_Int32* pIDs = aIDs.getArray();
142 0 : sal_uInt32 n = 0;
143 0 : for ( ImplPropertyTable::const_iterator it = maData.begin(); it != maData.end(); ++it )
144 0 : pIDs[n++] = it->first;
145 0 : return aIDs;
146 : }
147 :
148 0 : bool UnoControlModel::ImplHasProperty( sal_uInt16 nPropId ) const
149 : {
150 0 : if ( ( nPropId >= BASEPROPERTY_FONTDESCRIPTORPART_START ) && ( nPropId <= BASEPROPERTY_FONTDESCRIPTORPART_END ) )
151 0 : nPropId = BASEPROPERTY_FONTDESCRIPTOR;
152 :
153 0 : return maData.find( nPropId ) != maData.end() ? sal_True : sal_False;
154 : }
155 :
156 0 : ::com::sun::star::uno::Any UnoControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
157 : {
158 0 : ::com::sun::star::uno::Any aDefault;
159 :
160 0 : if (
161 0 : (nPropId == BASEPROPERTY_FONTDESCRIPTOR) ||
162 : (
163 0 : (nPropId >= BASEPROPERTY_FONTDESCRIPTORPART_START) &&
164 : (nPropId <= BASEPROPERTY_FONTDESCRIPTORPART_END)
165 : )
166 : )
167 : {
168 0 : EmptyFontDescriptor aFD;
169 0 : switch ( nPropId )
170 : {
171 0 : case BASEPROPERTY_FONTDESCRIPTOR: aDefault <<= aFD; break;
172 0 : case BASEPROPERTY_FONTDESCRIPTORPART_NAME: aDefault <<= aFD.Name; break;
173 0 : case BASEPROPERTY_FONTDESCRIPTORPART_STYLENAME: aDefault <<= aFD.StyleName; break;
174 0 : case BASEPROPERTY_FONTDESCRIPTORPART_FAMILY: aDefault <<= aFD.Family; break;
175 0 : case BASEPROPERTY_FONTDESCRIPTORPART_CHARSET: aDefault <<= aFD.CharSet; break;
176 0 : case BASEPROPERTY_FONTDESCRIPTORPART_HEIGHT: aDefault <<= (float)aFD.Height; break;
177 0 : case BASEPROPERTY_FONTDESCRIPTORPART_WEIGHT: aDefault <<= aFD.Weight; break;
178 0 : case BASEPROPERTY_FONTDESCRIPTORPART_SLANT: aDefault <<= (sal_Int16)aFD.Slant; break;
179 0 : case BASEPROPERTY_FONTDESCRIPTORPART_UNDERLINE: aDefault <<= aFD.Underline; break;
180 0 : case BASEPROPERTY_FONTDESCRIPTORPART_STRIKEOUT: aDefault <<= aFD.Strikeout; break;
181 0 : case BASEPROPERTY_FONTDESCRIPTORPART_WIDTH: aDefault <<= aFD.Width; break;
182 0 : 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 0 : case BASEPROPERTY_FONTDESCRIPTORPART_KERNING: aDefault <<= aFD.Kerning; break;
186 0 : case BASEPROPERTY_FONTDESCRIPTORPART_WORDLINEMODE: aDefault <<= aFD.WordLineMode; break;
187 0 : case BASEPROPERTY_FONTDESCRIPTORPART_TYPE: aDefault <<= aFD.Type; break;
188 : default: OSL_FAIL( "FontProperty?!" );
189 0 : }
190 : }
191 : else
192 : {
193 0 : switch ( nPropId )
194 : {
195 : case BASEPROPERTY_GRAPHIC:
196 0 : aDefault <<= Reference< graphic::XGraphic >();
197 0 : break;
198 :
199 : case BASEPROPERTY_REFERENCE_DEVICE:
200 0 : aDefault <<= Reference< awt::XDevice >();
201 0 : 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 0 : 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 0 : case BASEPROPERTY_ECHOCHAR: aDefault <<= (sal_Int16) 0; break;
227 0 : case BASEPROPERTY_BORDER: aDefault <<= (sal_Int16) 1; break;
228 0 : case BASEPROPERTY_DECIMALACCURACY: aDefault <<= (sal_Int16) 2; break;
229 0 : case BASEPROPERTY_LINECOUNT: aDefault <<= (sal_Int16) 5; break;
230 0 : case BASEPROPERTY_ALIGN: aDefault <<= (sal_Int16) PROPERTY_ALIGN_LEFT; break;
231 0 : case BASEPROPERTY_IMAGEALIGN: aDefault <<= (sal_Int16) 1 /*ImageAlign::TOP*/; break;
232 0 : case BASEPROPERTY_IMAGEPOSITION: aDefault <<= (sal_Int16) 12 /*ImagePosition::Centered*/; break;
233 0 : case BASEPROPERTY_PUSHBUTTONTYPE: aDefault <<= (sal_Int16) 0 /*PushButtonType::STANDARD*/; break;
234 0 : case BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR:aDefault <<= (sal_Int16) awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY; break;
235 :
236 0 : case BASEPROPERTY_DATEMAX: aDefault <<= util::Date( 31, 12, 2200 ); break;
237 0 : case BASEPROPERTY_DATEMIN: aDefault <<= util::Date( 1, 1, 1900 ); break;
238 0 : case BASEPROPERTY_TIMEMAX: aDefault <<= util::Time(0, 0, 59, 23, false); break;
239 0 : case BASEPROPERTY_TIMEMIN: aDefault <<= util::Time(); break;
240 0 : case BASEPROPERTY_VALUEMAX_DOUBLE: aDefault <<= (double) 1000000; break;
241 0 : case BASEPROPERTY_VALUEMIN_DOUBLE: aDefault <<= (double) -1000000; break;
242 0 : case BASEPROPERTY_VALUESTEP_DOUBLE: aDefault <<= (double ) 1; break;
243 0 : case BASEPROPERTY_PROGRESSVALUE_MAX: aDefault <<= (sal_Int32) 100; break;
244 0 : case BASEPROPERTY_PROGRESSVALUE_MIN: aDefault <<= (sal_Int32) 0; break;
245 0 : case BASEPROPERTY_SCROLLVALUE_MAX: aDefault <<= (sal_Int32) 100; break;
246 0 : case BASEPROPERTY_SCROLLVALUE_MIN: aDefault <<= (sal_Int32) 0; break;
247 0 : case BASEPROPERTY_LINEINCREMENT: aDefault <<= (sal_Int32) 1; break;
248 0 : case BASEPROPERTY_BLOCKINCREMENT: aDefault <<= (sal_Int32) 10; break;
249 0 : case BASEPROPERTY_ORIENTATION: aDefault <<= (sal_Int32) 0; break;
250 0 : case BASEPROPERTY_SPINVALUE: aDefault <<= (sal_Int32) 0; break;
251 0 : case BASEPROPERTY_SPININCREMENT: aDefault <<= (sal_Int32) 1; break;
252 0 : case BASEPROPERTY_SPINVALUE_MIN: aDefault <<= (sal_Int32) 0; break;
253 0 : case BASEPROPERTY_SPINVALUE_MAX: aDefault <<= (sal_Int32) 100; break;
254 0 : case BASEPROPERTY_REPEAT_DELAY: aDefault <<= (sal_Int32) 50; break; // 50 milliseconds
255 0 : case BASEPROPERTY_DEFAULTCONTROL: aDefault <<= ((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 0 : 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 0 : 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 0 : case BASEPROPERTY_TEXT: aDefault <<= OUString(); break;
299 :
300 : case BASEPROPERTY_WRITING_MODE:
301 : case BASEPROPERTY_CONTEXT_WRITING_MODE:
302 0 : aDefault <<= text::WritingMode2::CONTEXT;
303 0 : break;
304 :
305 : case BASEPROPERTY_STRINGITEMLIST:
306 : {
307 0 : ::com::sun::star::uno::Sequence< OUString> aStringSeq;
308 0 : aDefault <<= aStringSeq;
309 :
310 : }
311 0 : break;
312 : case BASEPROPERTY_SELECTEDITEMS:
313 : {
314 0 : ::com::sun::star::uno::Sequence<sal_Int16> aINT16Seq;
315 0 : aDefault <<= aINT16Seq;
316 : }
317 0 : break;
318 : case BASEPROPERTY_CURRENCYSYMBOL:
319 : {
320 : OUString sDefaultCurrency(
321 0 : utl::ConfigManager::getDefaultCurrency() );
322 :
323 : // extract the bank symbol
324 0 : sal_Int32 nSepPos = sDefaultCurrency.indexOf( '-' );
325 0 : OUString sBankSymbol;
326 0 : 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 0 : LanguageTag aLanguageTag( sDefaultCurrency);
334 0 : LocaleDataWrapper aLocaleInfo( m_xContext, aLanguageTag );
335 0 : if ( sBankSymbol.isEmpty() )
336 0 : sBankSymbol = aLocaleInfo.getCurrBankSymbol();
337 :
338 : // look for the currency entry (for this language) which has the given bank symbol
339 0 : Sequence< Currency2 > aAllCurrencies = aLocaleInfo.getAllCurrencies();
340 0 : const Currency2* pAllCurrencies = aAllCurrencies.getConstArray();
341 0 : const Currency2* pAllCurrenciesEnd = pAllCurrencies + aAllCurrencies.getLength();
342 :
343 0 : OUString sCurrencySymbol = aLocaleInfo.getCurrSymbol();
344 0 : 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 0 : if ( !sBankSymbol.isEmpty() )
355 : {
356 0 : bool bLegacy = false;
357 0 : for ( ;pAllCurrencies != pAllCurrenciesEnd; ++pAllCurrencies )
358 0 : if ( pAllCurrencies->BankSymbol == sBankSymbol )
359 : {
360 0 : sCurrencySymbol = pAllCurrencies->Symbol;
361 0 : if ( pAllCurrencies->LegacyOnly )
362 0 : bLegacy = true;
363 : else
364 0 : break;
365 : }
366 : DBG_ASSERT( bLegacy || pAllCurrencies != pAllCurrenciesEnd, "UnoControlModel::ImplGetDefaultValue: did not find the given bank symbol!" );
367 : (void)bLegacy;
368 : }
369 :
370 0 : aDefault <<= sCurrencySymbol;
371 : }
372 0 : break;
373 :
374 : default: OSL_FAIL( "ImplGetDefaultValue - unknown Property" );
375 : }
376 : }
377 :
378 0 : return aDefault;
379 : }
380 :
381 0 : void UnoControlModel::ImplRegisterProperty( sal_uInt16 nPropId, const ::com::sun::star::uno::Any& rDefault )
382 : {
383 0 : maData[ nPropId ] = rDefault;
384 0 : }
385 :
386 0 : void UnoControlModel::ImplRegisterProperty( sal_uInt16 nPropId )
387 : {
388 0 : ImplRegisterProperty( nPropId, ImplGetDefaultValue( nPropId ) );
389 :
390 0 : if ( nPropId == BASEPROPERTY_FONTDESCRIPTOR )
391 : {
392 : // some properties are not included in the FontDescriptor, but everytime
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 0 : ImplRegisterProperty( BASEPROPERTY_TEXTCOLOR );
397 0 : ImplRegisterProperty( BASEPROPERTY_TEXTLINECOLOR );
398 0 : ImplRegisterProperty( BASEPROPERTY_FONTRELIEF );
399 0 : ImplRegisterProperty( BASEPROPERTY_FONTEMPHASISMARK );
400 : }
401 0 : }
402 :
403 0 : void UnoControlModel::ImplRegisterProperties( const std::list< sal_uInt16 > &rIds )
404 : {
405 0 : std::list< sal_uInt16 >::const_iterator iter;
406 0 : for( iter = rIds.begin(); iter != rIds.end(); ++iter)
407 : {
408 0 : if( !ImplHasProperty( *iter ) )
409 0 : ImplRegisterProperty( *iter, ImplGetDefaultValue( *iter ) );
410 : }
411 0 : }
412 :
413 : // ::com::sun::star::uno::XInterface
414 0 : ::com::sun::star::uno::Any UnoControlModel::queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
415 : {
416 0 : Any aRet = UnoControlModel_Base::queryAggregation( rType );
417 0 : if ( !aRet.hasValue() )
418 0 : aRet = ::cppu::OPropertySetHelper::queryInterface( rType );
419 0 : return aRet;
420 : }
421 :
422 : // ::com::sun::star::lang::XUnoTunnel
423 0 : IMPL_XUNOTUNNEL_MINIMAL( UnoControlModel )
424 :
425 : // XInterface
426 0 : IMPLEMENT_FORWARD_REFCOUNT( UnoControlModel, UnoControlModel_Base )
427 :
428 : // ::com::sun::star::lang::XTypeProvider
429 0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoControlModel, UnoControlModel_Base, ::cppu::OPropertySetHelper )
430 :
431 :
432 0 : uno::Reference< util::XCloneable > UnoControlModel::createClone() throw(::com::sun::star::uno::RuntimeException, std::exception)
433 : {
434 0 : UnoControlModel* pClone = Clone();
435 0 : uno::Reference< util::XCloneable > xClone( (::cppu::OWeakObject*) pClone, uno::UNO_QUERY );
436 0 : return xClone;
437 : }
438 :
439 : // ::com::sun::star::lang::XComponent
440 0 : void UnoControlModel::dispose( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
441 : {
442 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
443 :
444 0 : ::com::sun::star::lang::EventObject aEvt;
445 0 : aEvt.Source = (::com::sun::star::uno::XAggregation*)(::cppu::OWeakAggObject*)this;
446 0 : maDisposeListeners.disposeAndClear( aEvt );
447 :
448 0 : BrdcstHelper.aLC.disposeAndClear( aEvt );
449 :
450 : // let the property set helper notify our property listeners
451 0 : OPropertySetHelper::disposing();
452 0 : }
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 0 : ::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 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
473 :
474 0 : sal_uInt16 nPropId = GetPropertyId( PropertyName );
475 :
476 0 : ::com::sun::star::uno::Any aValue = getPropertyValue( PropertyName );
477 0 : ::com::sun::star::uno::Any aDefault = ImplGetDefaultValue( nPropId );
478 :
479 0 : 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 0 : void UnoControlModel::setPropertyToDefault( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception)
499 : {
500 0 : Any aDefaultValue;
501 : {
502 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
503 0 : aDefaultValue = ImplGetDefaultValue( GetPropertyId( PropertyName ) );
504 : }
505 0 : setPropertyValue( PropertyName, aDefaultValue );
506 0 : }
507 :
508 0 : ::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 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
511 :
512 0 : 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 0 : 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 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
528 :
529 0 : ::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 0 : OutStream->writeShort( UNOCONTROL_STREAMVERSION );
533 :
534 0 : std::set<sal_uInt16> aProps;
535 :
536 0 : for (ImplPropertyTable::const_iterator it = maData.begin(); it != maData.end(); ++it )
537 : {
538 0 : if ( ( ( GetPropertyAttribs( it->first ) & ::com::sun::star::beans::PropertyAttribute::TRANSIENT ) == 0 )
539 0 : && ( getPropertyState( GetPropertyName( it->first ) ) != ::com::sun::star::beans::PropertyState_DEFAULT_VALUE ) )
540 : {
541 0 : aProps.insert( it->first );
542 : }
543 : }
544 :
545 0 : 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 0 : OutStream->writeLong( ( aProps.find( BASEPROPERTY_FONTDESCRIPTOR ) != aProps.end() ) ? ( nProps + 3 ) : nProps );
550 0 : for ( std::set<sal_uInt16>::const_iterator it = aProps.begin(); it != aProps.end(); ++it )
551 : {
552 0 : sal_Int32 nPropDataBeginMark = xMark->createMark();
553 0 : OutStream->writeLong( 0L ); // DataLen
554 :
555 0 : const ::com::sun::star::uno::Any* pProp = &(maData[*it]);
556 0 : OutStream->writeShort( *it );
557 :
558 0 : bool bVoid = pProp->getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
559 :
560 0 : OutStream->writeBoolean( bVoid );
561 :
562 0 : if ( !bVoid )
563 : {
564 0 : const ::com::sun::star::uno::Any& rValue = *pProp;
565 0 : const ::com::sun::star::uno::Type& rType = rValue.getValueType();
566 :
567 0 : if ( rType == ::getBooleanCppuType() )
568 : {
569 0 : bool b = false;
570 0 : rValue >>= b;
571 0 : OutStream->writeBoolean( b );
572 : }
573 0 : else if ( rType == ::getCppuType((const OUString*)0) )
574 : {
575 0 : OUString aUString;
576 0 : rValue >>= aUString;
577 0 : OutStream->writeUTF( aUString );
578 : }
579 0 : else if ( rType == ::getCppuType((const sal_uInt16*)0) )
580 : {
581 0 : sal_uInt16 n = 0;
582 0 : rValue >>= n;
583 0 : OutStream->writeShort( n );
584 : }
585 0 : else if ( rType == ::getCppuType((const sal_Int16*)0) )
586 : {
587 0 : sal_Int16 n = 0;
588 0 : rValue >>= n;
589 0 : OutStream->writeShort( n );
590 : }
591 0 : else if ( rType == ::getCppuType((const sal_uInt32*)0) )
592 : {
593 0 : sal_uInt32 n = 0;
594 0 : rValue >>= n;
595 0 : OutStream->writeLong( n );
596 : }
597 0 : else if ( rType == ::getCppuType((const sal_Int32*)0) )
598 : {
599 0 : sal_Int32 n = 0;
600 0 : rValue >>= n;
601 0 : OutStream->writeLong( n );
602 : }
603 0 : else if ( rType == ::getCppuType((const double*)0) )
604 : {
605 0 : double n = 0;
606 0 : rValue >>= n;
607 0 : OutStream->writeDouble( n );
608 : }
609 0 : else if ( rType == ::getCppuType((const ::com::sun::star::awt::FontDescriptor*)0) )
610 : {
611 0 : ::com::sun::star::awt::FontDescriptor aFD;
612 0 : rValue >>= aFD;
613 0 : OutStream->writeUTF( aFD.Name );
614 0 : OutStream->writeShort( aFD.Height );
615 0 : OutStream->writeShort( aFD.Width );
616 0 : OutStream->writeUTF( aFD.StyleName );
617 0 : OutStream->writeShort( aFD.Family );
618 0 : OutStream->writeShort( aFD.CharSet );
619 0 : OutStream->writeShort( aFD.Pitch );
620 0 : OutStream->writeDouble( aFD.CharacterWidth );
621 0 : OutStream->writeDouble( aFD.Weight );
622 0 : OutStream->writeShort(
623 0 : sal::static_int_cast< sal_Int16 >(aFD.Slant) );
624 0 : OutStream->writeShort( aFD.Underline );
625 0 : OutStream->writeShort( aFD.Strikeout );
626 0 : OutStream->writeDouble( aFD.Orientation );
627 0 : OutStream->writeBoolean( aFD.Kerning );
628 0 : OutStream->writeBoolean( aFD.WordLineMode );
629 0 : OutStream->writeShort( aFD.Type );
630 : }
631 0 : else if ( rType == cppu::UnoType<css::util::Date>::get() )
632 : {
633 0 : css::util::Date d;
634 0 : rValue >>= d;
635 0 : 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 == ::getCppuType((const ::com::sun::star::uno::Sequence< OUString>*)0 ) )
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 == ::getCppuType((const ::com::sun::star::uno::Sequence<sal_uInt16>*)0 ) )
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 == ::getCppuType((const ::com::sun::star::uno::Sequence<sal_Int16>*)0 ) )
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 0 : sal_Int32 nPropDataLen = xMark->offsetToMark( nPropDataBeginMark );
695 0 : xMark->jumpToMark( nPropDataBeginMark );
696 0 : OutStream->writeLong( nPropDataLen );
697 0 : xMark->jumpToFurthest();
698 0 : xMark->deleteMark(nPropDataBeginMark);
699 : }
700 :
701 0 : if ( aProps.find( BASEPROPERTY_FONTDESCRIPTOR ) != aProps.end() )
702 : {
703 0 : const ::com::sun::star::uno::Any* pProp = &maData[ BASEPROPERTY_FONTDESCRIPTOR ];
704 : // Until 5.0 export arrives, write old format..
705 0 : ::com::sun::star::awt::FontDescriptor aFD;
706 0 : (*pProp) >>= aFD;
707 :
708 0 : for ( sal_uInt16 n = BASEPROPERTY_FONT_TYPE; n <= BASEPROPERTY_FONT_ATTRIBS; n++ )
709 : {
710 0 : sal_Int32 nPropDataBeginMark = xMark->createMark();
711 0 : OutStream->writeLong( 0L ); // DataLen
712 0 : OutStream->writeShort( n ); // PropId
713 0 : OutStream->writeBoolean( sal_False ); // Void
714 :
715 0 : if ( n == BASEPROPERTY_FONT_TYPE )
716 : {
717 0 : OutStream->writeUTF( aFD.Name );
718 0 : OutStream->writeUTF( aFD.StyleName );
719 0 : OutStream->writeShort( aFD.Family );
720 0 : OutStream->writeShort( aFD.CharSet );
721 0 : OutStream->writeShort( aFD.Pitch );
722 : }
723 0 : else if ( n == BASEPROPERTY_FONT_SIZE )
724 : {
725 0 : OutStream->writeLong( aFD.Width );
726 0 : OutStream->writeLong( aFD.Height );
727 0 : OutStream->writeShort(
728 : sal::static_int_cast< sal_Int16 >(
729 0 : VCLUnoHelper::ConvertFontWidth( aFD.CharacterWidth )) );
730 : }
731 0 : else if ( n == BASEPROPERTY_FONT_ATTRIBS )
732 : {
733 0 : OutStream->writeShort(
734 : sal::static_int_cast< sal_Int16 >(
735 0 : VCLUnoHelper::ConvertFontWeight( aFD.Weight )) );
736 0 : OutStream->writeShort(
737 0 : sal::static_int_cast< sal_Int16 >(aFD.Slant) );
738 0 : OutStream->writeShort( aFD.Underline );
739 0 : OutStream->writeShort( aFD.Strikeout );
740 0 : OutStream->writeShort( (short)(aFD.Orientation * 10) );
741 0 : OutStream->writeBoolean( aFD.Kerning );
742 0 : OutStream->writeBoolean( aFD.WordLineMode );
743 : }
744 : else
745 : {
746 : OSL_FAIL( "Property?!" );
747 : }
748 :
749 0 : sal_Int32 nPropDataLen = xMark->offsetToMark( nPropDataBeginMark );
750 0 : xMark->jumpToMark( nPropDataBeginMark );
751 0 : OutStream->writeLong( nPropDataLen );
752 0 : xMark->jumpToFurthest();
753 0 : xMark->deleteMark(nPropDataBeginMark);
754 0 : }
755 0 : }
756 0 : }
757 :
758 0 : 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 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
761 :
762 0 : ::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 0 : short nVersion = InStream->readShort();
766 0 : sal_uInt32 nProps = (sal_uInt32)InStream->readLong();
767 0 : ::com::sun::star::uno::Sequence< OUString> aProps( nProps );
768 0 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> aValues( nProps );
769 0 : 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 0 : ::com::sun::star::awt::FontDescriptor* pFD = NULL;
776 :
777 : sal_uInt32 i;
778 0 : for ( i = 0; i < nProps; i++ )
779 : {
780 0 : sal_Int32 nPropDataBeginMark = xMark->createMark();
781 0 : sal_Int32 nPropDataLen = InStream->readLong();
782 :
783 0 : sal_uInt16 nPropId = (sal_uInt16)InStream->readShort();
784 :
785 0 : ::com::sun::star::uno::Any aValue;
786 0 : bool bIsVoid = InStream->readBoolean();
787 0 : if ( !bIsVoid )
788 : {
789 0 : if ( maData.find( nPropId ) != maData.end() )
790 : {
791 0 : const ::com::sun::star::uno::Type* pType = GetPropertyType( nPropId );
792 0 : if ( *pType == ::getBooleanCppuType() )
793 : {
794 0 : bool b = InStream->readBoolean();
795 0 : aValue <<= b;
796 : }
797 0 : else if ( *pType == ::getCppuType((const OUString*)0) )
798 : {
799 0 : OUString aUTF = InStream->readUTF();
800 0 : aValue <<= aUTF;
801 : }
802 0 : else if ( *pType == ::getCppuType((const sal_uInt16*)0) )
803 : {
804 0 : sal_uInt16 n = InStream->readShort();
805 0 : aValue <<= n;
806 : }
807 0 : else if ( *pType == ::getCppuType((const sal_Int16*)0) )
808 : {
809 0 : sal_Int16 n = InStream->readShort();
810 0 : aValue <<= n;
811 : }
812 0 : else if ( *pType == ::getCppuType((const sal_uInt32*)0) )
813 : {
814 0 : sal_uInt32 n = InStream->readLong();
815 0 : aValue <<= n;
816 : }
817 0 : else if ( *pType == ::getCppuType((const sal_Int32*)0) )
818 : {
819 0 : sal_Int32 n = InStream->readLong();
820 0 : aValue <<= n;
821 : }
822 0 : else if ( *pType == ::getCppuType((const double*)0) )
823 : {
824 0 : double n = InStream->readDouble();
825 0 : aValue <<= n;
826 : }
827 0 : else if ( *pType == ::getCppuType((const ::com::sun::star::awt::FontDescriptor*)0) )
828 : {
829 0 : ::com::sun::star::awt::FontDescriptor aFD;
830 0 : aFD.Name = InStream->readUTF();
831 0 : aFD.Height = InStream->readShort();
832 0 : aFD.Width = InStream->readShort();
833 0 : aFD.StyleName = InStream->readUTF();
834 0 : aFD.Family = InStream->readShort();
835 0 : aFD.CharSet = InStream->readShort();
836 0 : aFD.Pitch = InStream->readShort();
837 0 : aFD.CharacterWidth = (float)InStream->readDouble();
838 0 : aFD.Weight = (float)InStream->readDouble();
839 0 : aFD.Slant = (::com::sun::star::awt::FontSlant)InStream->readShort();
840 0 : aFD.Underline = InStream->readShort();
841 0 : aFD.Strikeout = InStream->readShort();
842 0 : aFD.Orientation = (float)InStream->readDouble();
843 0 : aFD.Kerning = InStream->readBoolean();
844 0 : aFD.WordLineMode = InStream->readBoolean();
845 0 : aFD.Type = InStream->readShort();
846 0 : aValue <<= aFD;
847 : }
848 0 : else if ( *pType == cppu::UnoType<css::util::Date>::get() )
849 : {
850 0 : sal_Int32 n = InStream->readLong(); // YYYYMMDD
851 0 : aValue <<= css::util::Date(
852 0 : 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 == ::getCppuType((const ::com::sun::star::uno::Sequence< OUString>*)0 ) )
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 == ::getCppuType((const ::com::sun::star::uno::Sequence<sal_uInt16>*)0 ) )
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 == ::getCppuType((const ::com::sun::star::uno::Sequence<sal_Int16>*)0 ) )
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 0 : if ( nPropId == BASEPROPERTY_FONT_TYPE )
908 : {
909 : // Redundant information for older versions
910 : // is skipped by MarkableStream
911 0 : 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 0 : else if ( nPropId == BASEPROPERTY_FONT_SIZE )
927 : {
928 0 : 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 0 : else if ( nPropId == BASEPROPERTY_FONT_ATTRIBS )
944 : {
945 0 : 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 0 : if ( maData.find( nPropId ) != maData.end() )
978 : {
979 0 : aProps.getArray()[i] = GetPropertyName( nPropId );
980 0 : aValues.getArray()[i] = aValue;
981 : }
982 : else
983 : {
984 0 : bInvalidEntries = true;
985 : }
986 :
987 : // Skip rest of input if there is more data in stream than this version can handle
988 0 : xMark->jumpToMark( nPropDataBeginMark );
989 0 : InStream->skipBytes( nPropDataLen );
990 0 : xMark->deleteMark(nPropDataBeginMark);
991 0 : }
992 0 : if ( bInvalidEntries )
993 : {
994 0 : for ( i = 0; i < (sal_uInt32)aProps.getLength(); i++ )
995 : {
996 0 : if ( aProps.getConstArray()[i].isEmpty() )
997 : {
998 0 : ::comphelper::removeElementAt( aProps, i );
999 0 : ::comphelper::removeElementAt( aValues, i );
1000 0 : i--;
1001 : }
1002 : }
1003 : }
1004 :
1005 : try
1006 : {
1007 0 : setPropertyValues( aProps, aValues );
1008 : }
1009 0 : catch ( const Exception& )
1010 : {
1011 : DBG_UNHANDLED_EXCEPTION();
1012 : }
1013 :
1014 0 : 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 0 : }
1021 0 : }
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 overloaded!" );
1028 0 : return OUString();
1029 :
1030 : }
1031 :
1032 0 : sal_Bool UnoControlModel::supportsService( const OUString& rServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1033 : {
1034 0 : return cppu::supportsService(this, rServiceName);
1035 : }
1036 :
1037 0 : ::com::sun::star::uno::Sequence< OUString > UnoControlModel::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1038 : {
1039 0 : OUString sName( "com.sun.star.awt.UnoControlModel" );
1040 0 : return Sequence< OUString >( &sName, 1 );
1041 : }
1042 :
1043 :
1044 : template <class TYPE>
1045 : bool convertType(Any& _rConvertedValue, const Any& _rNewValueTest, const TYPE* /* _pTypeDisambiguation */)
1046 : {
1047 : TYPE tValue;
1048 : if (_rNewValueTest >>= tValue)
1049 : {
1050 : _rConvertedValue <<= tValue;
1051 : return true;
1052 : }
1053 : }
1054 :
1055 :
1056 0 : sal_Bool UnoControlModel::convertFastPropertyValue( Any & rConvertedValue, Any & rOldValue, sal_Int32 nPropId, const Any& rValue ) throw (IllegalArgumentException)
1057 : {
1058 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
1059 :
1060 0 : bool bVoid = rValue.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
1061 0 : if ( bVoid )
1062 : {
1063 0 : rConvertedValue.clear();
1064 : }
1065 : else
1066 : {
1067 0 : const ::com::sun::star::uno::Type* pDestType = GetPropertyType( (sal_uInt16)nPropId );
1068 0 : if ( pDestType->getTypeClass() == TypeClass_ANY )
1069 : {
1070 0 : rConvertedValue = rValue;
1071 : }
1072 : else
1073 : {
1074 0 : if ( pDestType->equals( rValue.getValueType() ) )
1075 : {
1076 0 : rConvertedValue = rValue;
1077 : }
1078 : else
1079 : {
1080 0 : bool bConverted = false;
1081 : // 13.03.2001 - 84923 - frank.schoenheit@germany.sun.com
1082 :
1083 0 : switch (pDestType->getTypeClass())
1084 : {
1085 : case TypeClass_DOUBLE:
1086 : {
1087 : // try as double
1088 0 : double nAsDouble = 0;
1089 0 : bConverted = ( rValue >>= nAsDouble );
1090 0 : if ( bConverted )
1091 0 : rConvertedValue <<= nAsDouble;
1092 : else
1093 : { // try as integer
1094 0 : sal_Int32 nAsInteger = 0;
1095 0 : bConverted = ( rValue >>= nAsInteger );
1096 0 : if ( bConverted )
1097 0 : rConvertedValue <<= (double)nAsInteger;
1098 : }
1099 : }
1100 0 : break;
1101 : case TypeClass_SHORT:
1102 : {
1103 : sal_Int16 n;
1104 0 : bConverted = ( rValue >>= n );
1105 0 : if ( bConverted )
1106 0 : rConvertedValue <<= n;
1107 : }
1108 0 : break;
1109 : case TypeClass_UNSIGNED_SHORT:
1110 : {
1111 : sal_uInt16 n;
1112 0 : bConverted = ( rValue >>= n );
1113 0 : if ( bConverted )
1114 0 : rConvertedValue <<= n;
1115 : }
1116 0 : break;
1117 : case TypeClass_LONG:
1118 : {
1119 : sal_Int32 n;
1120 0 : bConverted = ( rValue >>= n );
1121 0 : if ( bConverted )
1122 0 : rConvertedValue <<= n;
1123 : }
1124 0 : break;
1125 : case TypeClass_UNSIGNED_LONG:
1126 : {
1127 : sal_uInt32 n;
1128 0 : bConverted = ( rValue >>= n );
1129 0 : if ( bConverted )
1130 0 : rConvertedValue <<= n;
1131 : }
1132 0 : break;
1133 : case TypeClass_INTERFACE:
1134 : {
1135 0 : if ( rValue.getValueType().getTypeClass() == TypeClass_INTERFACE )
1136 : {
1137 0 : Reference< XInterface > xPure( rValue, UNO_QUERY );
1138 0 : if ( xPure.is() )
1139 0 : rConvertedValue = xPure->queryInterface( *pDestType );
1140 : else
1141 0 : rConvertedValue.setValue( NULL, *pDestType );
1142 0 : bConverted = true;
1143 : }
1144 : }
1145 0 : break;
1146 : case TypeClass_ENUM:
1147 : {
1148 0 : sal_Int32 nValue = 0;
1149 0 : bConverted = ( rValue >>= nValue );
1150 0 : if ( bConverted )
1151 0 : rConvertedValue = ::cppu::int2enum( nValue, *pDestType );
1152 : }
1153 0 : break;
1154 : default: ; // avoid compiler warning
1155 : }
1156 :
1157 0 : if (!bConverted)
1158 : {
1159 0 : OUStringBuffer aErrorMessage;
1160 0 : aErrorMessage.appendAscii( "Unable to convert the given value for the property " );
1161 0 : aErrorMessage.append ( GetPropertyName( (sal_uInt16)nPropId ) );
1162 0 : aErrorMessage.appendAscii( ".\n" );
1163 0 : aErrorMessage.appendAscii( "Expected type: " );
1164 0 : aErrorMessage.append ( pDestType->getTypeName() );
1165 0 : aErrorMessage.appendAscii( "\n" );
1166 0 : aErrorMessage.appendAscii( "Found type: " );
1167 0 : aErrorMessage.append ( rValue.getValueType().getTypeName() );
1168 : throw ::com::sun::star::lang::IllegalArgumentException(
1169 : aErrorMessage.makeStringAndClear(),
1170 : static_cast< ::com::sun::star::beans::XPropertySet* >(this),
1171 0 : 1);
1172 : }
1173 : }
1174 : }
1175 : }
1176 :
1177 : // the current value
1178 0 : getFastPropertyValue( rOldValue, nPropId );
1179 0 : return !CompareProperties( rConvertedValue, rOldValue );
1180 : }
1181 :
1182 0 : void UnoControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception, std::exception)
1183 : {
1184 : // Missing: the fake solo properties of the FontDescriptor
1185 :
1186 0 : ImplPropertyTable::const_iterator it = maData.find( nPropId );
1187 0 : const ::com::sun::star::uno::Any* pProp = it == maData.end() ? NULL : &(it->second);
1188 0 : ENSURE_OR_RETURN_VOID( pProp, "UnoControlModel::setFastPropertyValue_NoBroadcast: invalid property id!" );
1189 :
1190 : 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!" );
1191 0 : maData[ nPropId ] = rValue;
1192 : }
1193 :
1194 0 : void UnoControlModel::getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nPropId ) const
1195 : {
1196 0 : ::osl::Guard< ::osl::Mutex > aGuard( ((UnoControlModel*)this)->GetMutex() );
1197 :
1198 0 : ImplPropertyTable::const_iterator it = maData.find( nPropId );
1199 0 : const ::com::sun::star::uno::Any* pProp = it == maData.end() ? NULL : &(it->second);
1200 :
1201 0 : if ( pProp )
1202 0 : rValue = *pProp;
1203 0 : else if ( ( nPropId >= BASEPROPERTY_FONTDESCRIPTORPART_START ) && ( nPropId <= BASEPROPERTY_FONTDESCRIPTORPART_END ) )
1204 : {
1205 0 : pProp = &( maData.find( BASEPROPERTY_FONTDESCRIPTOR )->second );
1206 0 : ::com::sun::star::awt::FontDescriptor aFD;
1207 0 : (*pProp) >>= aFD;
1208 0 : switch ( nPropId )
1209 : {
1210 0 : case BASEPROPERTY_FONTDESCRIPTORPART_NAME: rValue <<= aFD.Name;
1211 0 : break;
1212 0 : case BASEPROPERTY_FONTDESCRIPTORPART_STYLENAME: rValue <<= aFD.StyleName;
1213 0 : break;
1214 0 : case BASEPROPERTY_FONTDESCRIPTORPART_FAMILY: rValue <<= aFD.Family;
1215 0 : break;
1216 0 : case BASEPROPERTY_FONTDESCRIPTORPART_CHARSET: rValue <<= aFD.CharSet;
1217 0 : break;
1218 0 : case BASEPROPERTY_FONTDESCRIPTORPART_HEIGHT: rValue <<= (float)aFD.Height;
1219 0 : break;
1220 0 : case BASEPROPERTY_FONTDESCRIPTORPART_WEIGHT: rValue <<= aFD.Weight;
1221 0 : break;
1222 0 : case BASEPROPERTY_FONTDESCRIPTORPART_SLANT: rValue <<= (sal_Int16)aFD.Slant;
1223 0 : break;
1224 0 : case BASEPROPERTY_FONTDESCRIPTORPART_UNDERLINE: rValue <<= aFD.Underline;
1225 0 : break;
1226 0 : case BASEPROPERTY_FONTDESCRIPTORPART_STRIKEOUT: rValue <<= aFD.Strikeout;
1227 0 : break;
1228 0 : case BASEPROPERTY_FONTDESCRIPTORPART_WIDTH: rValue <<= aFD.Width;
1229 0 : break;
1230 0 : case BASEPROPERTY_FONTDESCRIPTORPART_PITCH: rValue <<= aFD.Pitch;
1231 0 : break;
1232 0 : case BASEPROPERTY_FONTDESCRIPTORPART_CHARWIDTH: rValue <<= aFD.CharacterWidth;
1233 0 : break;
1234 0 : case BASEPROPERTY_FONTDESCRIPTORPART_ORIENTATION: rValue <<= aFD.Orientation;
1235 0 : break;
1236 0 : case BASEPROPERTY_FONTDESCRIPTORPART_KERNING: rValue <<= aFD.Kerning;
1237 0 : break;
1238 0 : case BASEPROPERTY_FONTDESCRIPTORPART_WORDLINEMODE: rValue <<= aFD.WordLineMode;
1239 0 : break;
1240 0 : case BASEPROPERTY_FONTDESCRIPTORPART_TYPE: rValue <<= aFD.Type;
1241 0 : break;
1242 : default: OSL_FAIL( "FontProperty?!" );
1243 0 : }
1244 : }
1245 : else
1246 : {
1247 : OSL_FAIL( "getFastPropertyValue - invalid Property!" );
1248 0 : }
1249 0 : }
1250 :
1251 : // ::com::sun::star::beans::XPropertySet
1252 0 : 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)
1253 : {
1254 0 : sal_Int32 nPropId = 0;
1255 : {
1256 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
1257 0 : nPropId = (sal_Int32) GetPropertyId( rPropertyName );
1258 0 : DBG_ASSERT( nPropId, "Invalid ID in UnoControlModel::setPropertyValue" );
1259 : }
1260 0 : if( nPropId )
1261 0 : setFastPropertyValue( nPropId, rValue );
1262 : else
1263 0 : throw ::com::sun::star::beans::UnknownPropertyException();
1264 0 : }
1265 :
1266 : // ::com::sun::star::beans::XFastPropertySet
1267 0 : 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)
1268 : {
1269 0 : if ( ( nPropId >= BASEPROPERTY_FONTDESCRIPTORPART_START ) && ( nPropId <= BASEPROPERTY_FONTDESCRIPTORPART_END ) )
1270 : {
1271 0 : ::osl::ClearableMutexGuard aGuard( GetMutex() );
1272 :
1273 0 : Any aOldSingleValue;
1274 0 : getFastPropertyValue( aOldSingleValue, BASEPROPERTY_FONTDESCRIPTORPART_START );
1275 :
1276 0 : ::com::sun::star::uno::Any* pProp = &maData[ BASEPROPERTY_FONTDESCRIPTOR ];
1277 0 : FontDescriptor aOldFontDescriptor;
1278 0 : (*pProp) >>= aOldFontDescriptor;
1279 :
1280 0 : FontDescriptor aNewFontDescriptor( aOldFontDescriptor );
1281 0 : lcl_ImplMergeFontProperty( aNewFontDescriptor, (sal_uInt16)nPropId, rValue );
1282 :
1283 0 : Any aNewValue;
1284 0 : aNewValue <<= aNewFontDescriptor;
1285 0 : sal_Int32 nDescriptorId( BASEPROPERTY_FONTDESCRIPTOR );
1286 0 : nDescriptorId = BASEPROPERTY_FONTDESCRIPTOR;
1287 :
1288 : // also, we need fire a propertyChange event for the single property, since with
1289 : // the above line, only an event for the FontDescriptor property will be fired
1290 0 : Any aNewSingleValue;
1291 0 : getFastPropertyValue( aNewSingleValue, BASEPROPERTY_FONTDESCRIPTORPART_START );
1292 :
1293 0 : aGuard.clear();
1294 0 : setFastPropertyValues( 1, &nDescriptorId, &aNewValue, 1 );
1295 0 : fire( &nPropId, &aNewSingleValue, &aOldSingleValue, 1, sal_False );
1296 : }
1297 : else
1298 0 : setFastPropertyValues( 1, &nPropId, &rValue, 1 );
1299 0 : }
1300 :
1301 : // ::com::sun::star::beans::XMultiPropertySet
1302 0 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > UnoControlModel::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1303 : {
1304 : OSL_FAIL( "UnoControlModel::getPropertySetInfo() not possible!" );
1305 0 : return ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >();
1306 : }
1307 :
1308 0 : 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)
1309 : {
1310 0 : ::osl::ClearableMutexGuard aGuard( GetMutex() );
1311 :
1312 0 : sal_Int32 nProps = rPropertyNames.getLength();
1313 :
1314 : // sal_Int32* pHandles = new sal_Int32[nProps];
1315 : // don't do this - it leaks in case of an exception
1316 0 : Sequence< sal_Int32 > aHandles( nProps );
1317 0 : sal_Int32* pHandles = aHandles.getArray();
1318 :
1319 : // may need to change the order in the sequence, for this we need a non-const value sequence
1320 0 : uno::Sequence< uno::Any > aValues( Values );
1321 0 : uno::Any* pValues = aValues.getArray();
1322 :
1323 0 : sal_Int32 nValidHandles = getInfoHelper().fillHandles( pHandles, rPropertyNames );
1324 :
1325 0 : if ( nValidHandles )
1326 : {
1327 : // if somebody sets properties which are single aspects of a font descriptor,
1328 : // remove them, and build a font descriptor instead
1329 0 : boost::scoped_ptr< awt::FontDescriptor > pFD;
1330 0 : for ( sal_uInt16 n = 0; n < nProps; ++n )
1331 : {
1332 0 : if ( ( pHandles[n] >= BASEPROPERTY_FONTDESCRIPTORPART_START ) && ( pHandles[n] <= BASEPROPERTY_FONTDESCRIPTORPART_END ) )
1333 : {
1334 0 : if ( !pFD.get() )
1335 : {
1336 0 : ::com::sun::star::uno::Any* pProp = &maData[ BASEPROPERTY_FONTDESCRIPTOR ];
1337 0 : pFD.reset( new awt::FontDescriptor );
1338 0 : (*pProp) >>= *pFD;
1339 : }
1340 0 : lcl_ImplMergeFontProperty( *pFD, (sal_uInt16)pHandles[n], pValues[n] );
1341 0 : pHandles[n] = -1;
1342 0 : nValidHandles--;
1343 : }
1344 : }
1345 :
1346 0 : if ( nValidHandles )
1347 : {
1348 0 : ImplNormalizePropertySequence( nProps, pHandles, pValues, &nValidHandles );
1349 0 : aGuard.clear();
1350 : // clear our guard before calling into setFastPropertyValues - this method
1351 : // will implicitly call property listeners, and this should not happen with
1352 : // our mutex locked
1353 : // #i23451#
1354 0 : setFastPropertyValues( nProps, pHandles, pValues, nValidHandles );
1355 : }
1356 : else
1357 0 : aGuard.clear();
1358 : // same as a few lines above
1359 :
1360 : // Don't merge FD property into array, as it is sorted
1361 0 : if ( pFD.get() )
1362 : {
1363 0 : ::com::sun::star::uno::Any aValue;
1364 0 : aValue <<= *pFD;
1365 0 : sal_Int32 nHandle = BASEPROPERTY_FONTDESCRIPTOR;
1366 0 : setFastPropertyValues( 1, &nHandle, &aValue, 1 );
1367 0 : }
1368 0 : }
1369 0 : }
1370 :
1371 :
1372 :
1373 0 : void UnoControlModel::ImplNormalizePropertySequence( const sal_Int32, sal_Int32*,
1374 : uno::Any*, sal_Int32* ) const SAL_THROW(())
1375 : {
1376 : // nothing to do here
1377 0 : }
1378 :
1379 0 : void UnoControlModel::ImplEnsureHandleOrder( const sal_Int32 _nCount, sal_Int32* _pHandles,
1380 : uno::Any* _pValues, sal_Int32 _nFirstHandle, sal_Int32 _nSecondHandle ) const
1381 : {
1382 0 : for ( sal_Int32 i=0; i < _nCount; ++_pHandles, ++_pValues, ++i )
1383 : {
1384 0 : if ( _nSecondHandle == *_pHandles )
1385 : {
1386 0 : sal_Int32* pLaterHandles = _pHandles + 1;
1387 0 : uno::Any* pLaterValues = _pValues + 1;
1388 0 : for ( sal_Int32 j = i + 1; j < _nCount; ++j, ++pLaterHandles, ++pLaterValues )
1389 : {
1390 0 : if ( _nFirstHandle == *pLaterHandles )
1391 : {
1392 : // indeed it is -> exchange the both places in the sequences
1393 0 : sal_Int32 nHandle( *_pHandles );
1394 0 : *_pHandles = *pLaterHandles;
1395 0 : *pLaterHandles = nHandle;
1396 :
1397 0 : uno::Any aValue( *_pValues );
1398 0 : *_pValues = *pLaterValues;
1399 0 : *pLaterValues = aValue;
1400 :
1401 0 : break;
1402 : // this will leave the inner loop, and continue with the outer loop.
1403 : // Note that this means we will encounter the _nSecondHandle handle, again, once we reached
1404 : // (in the outer loop) the place where we just put it.
1405 : }
1406 : }
1407 : }
1408 : }
1409 0 : }
1410 :
1411 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|