LCOV - code coverage report
Current view: top level - toolkit/source/controls - unocontrolmodel.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 537 733 73.3 %
Date: 2014-11-03 Functions: 33 41 80.5 %
Legend: Lines: hit not hit

          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       36991 : 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       36991 :     float       nExtractFloat = 0;
      70       36991 :     sal_Int16   nExtractShort = 0;
      71             : 
      72       36991 :     switch ( nPropId )
      73             :     {
      74        2356 :         case BASEPROPERTY_FONTDESCRIPTORPART_NAME:          rValue >>= rFD.Name;
      75        2356 :                                                             break;
      76        2273 :         case BASEPROPERTY_FONTDESCRIPTORPART_STYLENAME:     rValue >>= rFD.StyleName;
      77        2273 :                                                             break;
      78        2284 :         case BASEPROPERTY_FONTDESCRIPTORPART_FAMILY:        rValue >>= rFD.Family;
      79        2284 :                                                             break;
      80        2360 :         case BASEPROPERTY_FONTDESCRIPTORPART_CHARSET:       rValue >>= rFD.CharSet;
      81        2360 :                                                             break;
      82        2362 :         case BASEPROPERTY_FONTDESCRIPTORPART_HEIGHT:        rValue >>= nExtractFloat; rFD.Height = (sal_Int16)nExtractFloat;
      83        2362 :                                                             break;
      84        2362 :         case BASEPROPERTY_FONTDESCRIPTORPART_WEIGHT:        rValue >>= rFD.Weight;
      85        2362 :                                                             break;
      86        2362 :         case BASEPROPERTY_FONTDESCRIPTORPART_SLANT:         if ( rValue >>= nExtractShort )
      87        2346 :                                                                 rFD.Slant = (::com::sun::star::awt::FontSlant)nExtractShort;
      88             :                                                             else
      89          16 :                                                                 rValue >>= rFD.Slant;
      90        2362 :                                                             break;
      91        2362 :         case BASEPROPERTY_FONTDESCRIPTORPART_UNDERLINE:     rValue >>= rFD.Underline;
      92        2362 :                                                             break;
      93        2362 :         case BASEPROPERTY_FONTDESCRIPTORPART_STRIKEOUT:     rValue >>= rFD.Strikeout;
      94        2362 :                                                             break;
      95        2272 :         case BASEPROPERTY_FONTDESCRIPTORPART_WIDTH:         rValue >>= rFD.Width;
      96        2272 :                                                             break;
      97        2272 :         case BASEPROPERTY_FONTDESCRIPTORPART_PITCH:         rValue >>= rFD.Pitch;
      98        2272 :                                                             break;
      99        2273 :         case BASEPROPERTY_FONTDESCRIPTORPART_CHARWIDTH:     rValue >>= rFD.CharacterWidth;
     100        2273 :                                                             break;
     101        2272 :         case BASEPROPERTY_FONTDESCRIPTORPART_ORIENTATION:   rValue >>= rFD.Orientation;
     102        2272 :                                                             break;
     103        2272 :         case BASEPROPERTY_FONTDESCRIPTORPART_KERNING:       rValue >>= rFD.Kerning;
     104        2272 :                                                             break;
     105        2273 :         case BASEPROPERTY_FONTDESCRIPTORPART_WORDLINEMODE:  rValue >>= rFD.WordLineMode;
     106        2273 :                                                             break;
     107        2274 :         case BASEPROPERTY_FONTDESCRIPTORPART_TYPE:          rValue >>= rFD.Type;
     108        2274 :                                                             break;
     109             :         default:                                            OSL_FAIL( "FontProperty?!" );
     110             :     }
     111       36991 : }
     112             : 
     113             : 
     114             : //  class UnoControlModel
     115             : 
     116        2447 : UnoControlModel::UnoControlModel( const Reference< XComponentContext >& rxContext )
     117             :     :UnoControlModel_Base()
     118             :     ,MutexAndBroadcastHelper()
     119             :     ,OPropertySetHelper( BrdcstHelper )
     120             :     ,maDisposeListeners( *this )
     121        2447 :     ,m_xContext( rxContext )
     122             : {
     123             :     // Insert properties from Model into table,
     124             :     // only existing properties are valid, even if they're VOID
     125        2447 : }
     126             : 
     127          84 : UnoControlModel::UnoControlModel( const UnoControlModel& rModel )
     128             :     : UnoControlModel_Base()
     129             :     , MutexAndBroadcastHelper()
     130             :     , OPropertySetHelper( BrdcstHelper )
     131             :     , maData( rModel.maData )
     132             :     , maDisposeListeners( *this )
     133          84 :     , m_xContext( rModel.m_xContext )
     134             : {
     135          84 : }
     136             : 
     137         290 : ::com::sun::star::uno::Sequence<sal_Int32> UnoControlModel::ImplGetPropertyIds() const
     138             : {
     139         290 :     sal_uInt32 nIDs = maData.size();
     140         290 :     ::com::sun::star::uno::Sequence<sal_Int32>  aIDs( nIDs );
     141         290 :     sal_Int32* pIDs = aIDs.getArray();
     142         290 :     sal_uInt32 n = 0;
     143        6360 :     for ( ImplPropertyTable::const_iterator it = maData.begin(); it != maData.end(); ++it )
     144        6070 :         pIDs[n++] = it->first;
     145         290 :     return aIDs;
     146             : }
     147             : 
     148       21183 : bool UnoControlModel::ImplHasProperty( sal_uInt16 nPropId ) const
     149             : {
     150       21183 :     if ( ( nPropId >= BASEPROPERTY_FONTDESCRIPTORPART_START ) && ( nPropId <= BASEPROPERTY_FONTDESCRIPTORPART_END ) )
     151           0 :         nPropId = BASEPROPERTY_FONTDESCRIPTOR;
     152             : 
     153       21183 :     return maData.find( nPropId ) != maData.end() ? sal_True : sal_False;
     154             : }
     155             : 
     156       36964 : ::com::sun::star::uno::Any UnoControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
     157             : {
     158       36964 :     ::com::sun::star::uno::Any aDefault;
     159             : 
     160       36964 :     if (
     161       36044 :         (nPropId == BASEPROPERTY_FONTDESCRIPTOR) ||
     162             :         (
     163           0 :          (nPropId >= BASEPROPERTY_FONTDESCRIPTORPART_START) &&
     164             :          (nPropId <= BASEPROPERTY_FONTDESCRIPTORPART_END)
     165             :         )
     166             :        )
     167             :     {
     168         920 :         EmptyFontDescriptor aFD;
     169         920 :         switch ( nPropId )
     170             :         {
     171         920 :             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         920 :         }
     190             :     }
     191             :     else
     192             :     {
     193       36044 :         switch ( nPropId )
     194             :         {
     195             :             case BASEPROPERTY_GRAPHIC:
     196          26 :                 aDefault <<= Reference< graphic::XGraphic >();
     197          26 :                 break;
     198             : 
     199             :             case BASEPROPERTY_REFERENCE_DEVICE:
     200         474 :                 aDefault <<= Reference< awt::XDevice >();
     201         474 :                 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        8740 :             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        2448 :             case BASEPROPERTY_ECHOCHAR:             aDefault <<= (sal_Int16) 0; break;
     227         522 :             case BASEPROPERTY_BORDER:               aDefault <<= (sal_Int16) 1; break;
     228          62 :             case BASEPROPERTY_DECIMALACCURACY:      aDefault <<= (sal_Int16) 2; break;
     229         106 :             case BASEPROPERTY_LINECOUNT:            aDefault <<= (sal_Int16) 5; break;
     230         768 :             case BASEPROPERTY_ALIGN:                aDefault <<= (sal_Int16) PROPERTY_ALIGN_LEFT; break;
     231         122 :             case BASEPROPERTY_IMAGEALIGN:           aDefault <<= (sal_Int16) 1 /*ImageAlign::TOP*/; break;
     232         356 :             case BASEPROPERTY_IMAGEPOSITION:        aDefault <<= (sal_Int16) 12 /*ImagePosition::Centered*/; break;
     233         122 :             case BASEPROPERTY_PUSHBUTTONTYPE:       aDefault <<= (sal_Int16) 0 /*PushButtonType::STANDARD*/; break;
     234         348 :             case BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR:aDefault <<= (sal_Int16) awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY; break;
     235             : 
     236          82 :             case BASEPROPERTY_DATEMAX:              aDefault <<= util::Date( 31, 12, 2200 );    break;
     237          82 :             case BASEPROPERTY_DATEMIN:              aDefault <<= util::Date( 1, 1, 1900 );  break;
     238          32 :             case BASEPROPERTY_TIMEMAX:              aDefault <<= util::Time(0, 0, 59, 23, false);  break;
     239          32 :             case BASEPROPERTY_TIMEMIN:              aDefault <<= util::Time();      break;
     240          62 :             case BASEPROPERTY_VALUEMAX_DOUBLE:      aDefault <<= (double) 1000000;  break;
     241          62 :             case BASEPROPERTY_VALUEMIN_DOUBLE:      aDefault <<= (double) -1000000; break;
     242          62 :             case BASEPROPERTY_VALUESTEP_DOUBLE:     aDefault <<= (double ) 1;       break;
     243          10 :             case BASEPROPERTY_PROGRESSVALUE_MAX:    aDefault <<= (sal_Int32) 100;   break;
     244          10 :             case BASEPROPERTY_PROGRESSVALUE_MIN:    aDefault <<= (sal_Int32)   0;   break;
     245          24 :             case BASEPROPERTY_SCROLLVALUE_MAX:      aDefault <<= (sal_Int32) 100;   break;
     246          24 :             case BASEPROPERTY_SCROLLVALUE_MIN:      aDefault <<= (sal_Int32)   0;   break;
     247          24 :             case BASEPROPERTY_LINEINCREMENT:        aDefault <<= (sal_Int32)   1;   break;
     248          24 :             case BASEPROPERTY_BLOCKINCREMENT:       aDefault <<= (sal_Int32)  10;   break;
     249          56 :             case BASEPROPERTY_ORIENTATION:          aDefault <<= (sal_Int32)   0;   break;
     250          22 :             case BASEPROPERTY_SPINVALUE:            aDefault <<= (sal_Int32)   0;   break;
     251          22 :             case BASEPROPERTY_SPININCREMENT:        aDefault <<= (sal_Int32)   1;   break;
     252          22 :             case BASEPROPERTY_SPINVALUE_MIN:        aDefault <<= (sal_Int32)   0;   break;
     253          22 :             case BASEPROPERTY_SPINVALUE_MAX:        aDefault <<= (sal_Int32) 100;   break;
     254         382 :             case BASEPROPERTY_REPEAT_DELAY:         aDefault <<= (sal_Int32)  50;   break;    // 50 milliseconds
     255        1513 :             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        2710 :             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        6790 :             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        7905 :             case BASEPROPERTY_TEXT:                 aDefault <<= OUString(); break;
     299             : 
     300             :             case BASEPROPERTY_WRITING_MODE:
     301             :             case BASEPROPERTY_CONTEXT_WRITING_MODE:
     302        1808 :                 aDefault <<= text::WritingMode2::CONTEXT;
     303        1808 :                 break;
     304             : 
     305             :             case BASEPROPERTY_STRINGITEMLIST:
     306             :             {
     307         102 :                 ::com::sun::star::uno::Sequence< OUString> aStringSeq;
     308         102 :                 aDefault <<= aStringSeq;
     309             : 
     310             :             }
     311         102 :             break;
     312             :             case BASEPROPERTY_SELECTEDITEMS:
     313             :             {
     314          32 :                 ::com::sun::star::uno::Sequence<sal_Int16> aINT16Seq;
     315          32 :                 aDefault <<= aINT16Seq;
     316             :             }
     317          32 :             break;
     318             :             case BASEPROPERTY_CURRENCYSYMBOL:
     319             :             {
     320             :                 OUString sDefaultCurrency(
     321          30 :                     utl::ConfigManager::getDefaultCurrency() );
     322             : 
     323             :                 // extract the bank symbol
     324          30 :                 sal_Int32 nSepPos = sDefaultCurrency.indexOf( '-' );
     325          60 :                 OUString sBankSymbol;
     326          30 :                 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          60 :                 LanguageTag aLanguageTag( sDefaultCurrency);
     334          60 :                 LocaleDataWrapper aLocaleInfo( m_xContext, aLanguageTag );
     335          30 :                 if ( sBankSymbol.isEmpty() )
     336          30 :                     sBankSymbol = aLocaleInfo.getCurrBankSymbol();
     337             : 
     338             :                 // look for the currency entry (for this language) which has the given bank symbol
     339          60 :                 Sequence< Currency2 > aAllCurrencies = aLocaleInfo.getAllCurrencies();
     340          30 :                 const Currency2* pAllCurrencies     =                       aAllCurrencies.getConstArray();
     341          30 :                 const Currency2* pAllCurrenciesEnd  =   pAllCurrencies  +   aAllCurrencies.getLength();
     342             : 
     343          60 :                 OUString sCurrencySymbol = aLocaleInfo.getCurrSymbol();
     344          30 :                 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          30 :                 if ( !sBankSymbol.isEmpty() )
     355             :                 {
     356          30 :                     bool bLegacy = false;
     357          30 :                     for ( ;pAllCurrencies != pAllCurrenciesEnd; ++pAllCurrencies )
     358          30 :                         if ( pAllCurrencies->BankSymbol == sBankSymbol )
     359             :                         {
     360          30 :                             sCurrencySymbol = pAllCurrencies->Symbol;
     361          30 :                             if ( pAllCurrencies->LegacyOnly )
     362           0 :                                 bLegacy = true;
     363             :                             else
     364          30 :                                 break;
     365             :                         }
     366             :                     DBG_ASSERT( bLegacy || pAllCurrencies != pAllCurrenciesEnd, "UnoControlModel::ImplGetDefaultValue: did not find the given bank symbol!" );
     367             :                     (void)bLegacy;
     368             :                 }
     369             : 
     370          60 :                 aDefault <<= sCurrencySymbol;
     371             :             }
     372          30 :             break;
     373             : 
     374             :             default:    OSL_FAIL( "ImplGetDefaultValue - unknown Property" );
     375             :         }
     376             :     }
     377             : 
     378       36964 :     return aDefault;
     379             : }
     380             : 
     381       38755 : void UnoControlModel::ImplRegisterProperty( sal_uInt16 nPropId, const ::com::sun::star::uno::Any& rDefault )
     382             : {
     383       38755 :     maData[ nPropId ] = rDefault;
     384       38755 : }
     385             : 
     386       17847 : void UnoControlModel::ImplRegisterProperty( sal_uInt16 nPropId )
     387             : {
     388       17847 :     ImplRegisterProperty( nPropId, ImplGetDefaultValue( nPropId ) );
     389             : 
     390       17847 :     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         146 :         ImplRegisterProperty( BASEPROPERTY_TEXTCOLOR );
     397         146 :         ImplRegisterProperty( BASEPROPERTY_TEXTLINECOLOR );
     398         146 :         ImplRegisterProperty( BASEPROPERTY_FONTRELIEF );
     399         146 :         ImplRegisterProperty( BASEPROPERTY_FONTEMPHASISMARK );
     400             :     }
     401       17847 : }
     402             : 
     403         754 : void UnoControlModel::ImplRegisterProperties( const std::list< sal_uInt16 > &rIds )
     404             : {
     405         754 :     std::list< sal_uInt16 >::const_iterator iter;
     406       21502 :     for( iter = rIds.begin(); iter != rIds.end(); ++iter)
     407             :     {
     408       20748 :         if( !ImplHasProperty( *iter ) )
     409       20748 :             ImplRegisterProperty( *iter, ImplGetDefaultValue( *iter ) );
     410             :     }
     411         754 : }
     412             : 
     413             : // ::com::sun::star::uno::XInterface
     414       83296 : ::com::sun::star::uno::Any UnoControlModel::queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     415             : {
     416       83296 :     Any aRet = UnoControlModel_Base::queryAggregation( rType );
     417       83296 :     if ( !aRet.hasValue() )
     418       13232 :         aRet = ::cppu::OPropertySetHelper::queryInterface( rType );
     419       83296 :     return aRet;
     420             : }
     421             : 
     422             : // ::com::sun::star::lang::XUnoTunnel
     423           0 : IMPL_XUNOTUNNEL_MINIMAL( UnoControlModel )
     424             : 
     425             : // XInterface
     426      414162 : IMPLEMENT_FORWARD_REFCOUNT( UnoControlModel, UnoControlModel_Base )
     427             : 
     428             : // ::com::sun::star::lang::XTypeProvider
     429         432 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoControlModel, UnoControlModel_Base, ::cppu::OPropertySetHelper )
     430             : 
     431             : 
     432          84 : uno::Reference< util::XCloneable > UnoControlModel::createClone() throw(::com::sun::star::uno::RuntimeException, std::exception)
     433             : {
     434          84 :     UnoControlModel* pClone = Clone();
     435          84 :     uno::Reference< util::XCloneable > xClone( (::cppu::OWeakObject*) pClone, uno::UNO_QUERY );
     436          84 :     return xClone;
     437             : }
     438             : 
     439             : // ::com::sun::star::lang::XComponent
     440         734 : void UnoControlModel::dispose(  ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     441             : {
     442         734 :     ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
     443             : 
     444        1468 :     ::com::sun::star::lang::EventObject aEvt;
     445         734 :     aEvt.Source = (::com::sun::star::uno::XAggregation*)(::cppu::OWeakAggObject*)this;
     446         734 :     maDisposeListeners.disposeAndClear( aEvt );
     447             : 
     448         734 :     BrdcstHelper.aLC.disposeAndClear( aEvt );
     449             : 
     450             :     // let the property set helper notify our property listeners
     451        1468 :     OPropertySetHelper::disposing();
     452         734 : }
     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        2532 : ::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        2532 :     ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
     473             : 
     474        2532 :     sal_uInt16 nPropId = GetPropertyId( PropertyName );
     475             : 
     476        5064 :     ::com::sun::star::uno::Any aValue = getPropertyValue( PropertyName );
     477        5064 :     ::com::sun::star::uno::Any aDefault = ImplGetDefaultValue( nPropId );
     478             : 
     479        5064 :     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          30 : void UnoControlModel::setPropertyToDefault( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception)
     499             : {
     500          30 :     Any aDefaultValue;
     501             :     {
     502          30 :         ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
     503          30 :         aDefaultValue = ImplGetDefaultValue( GetPropertyId( PropertyName ) );
     504             :     }
     505          30 :     setPropertyValue( PropertyName, aDefaultValue );
     506          30 : }
     507             : 
     508          30 : ::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          30 :     ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
     511             : 
     512          30 :     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          80 : 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          80 :     ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
     528             : 
     529         160 :     ::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          80 :     OutStream->writeShort( UNOCONTROL_STREAMVERSION );
     533             : 
     534         160 :     std::set<sal_uInt16> aProps;
     535             : 
     536        2118 :     for (ImplPropertyTable::const_iterator it = maData.begin(); it != maData.end(); ++it )
     537             :     {
     538        4076 :         if ( ( ( GetPropertyAttribs( it->first ) & ::com::sun::star::beans::PropertyAttribute::TRANSIENT ) == 0 )
     539        2038 :             && ( getPropertyState( GetPropertyName( it->first ) ) != ::com::sun::star::beans::PropertyState_DEFAULT_VALUE ) )
     540             :         {
     541          58 :             aProps.insert( it->first );
     542             :         }
     543             :     }
     544             : 
     545          80 :     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          80 :     OutStream->writeLong( ( aProps.find( BASEPROPERTY_FONTDESCRIPTOR ) != aProps.end() ) ? ( nProps + 3 ) : nProps );
     550         138 :     for ( std::set<sal_uInt16>::const_iterator it = aProps.begin(); it != aProps.end(); ++it )
     551             :     {
     552          58 :         sal_Int32 nPropDataBeginMark = xMark->createMark();
     553          58 :         OutStream->writeLong( 0L ); // DataLen
     554             : 
     555          58 :         const ::com::sun::star::uno::Any* pProp = &(maData[*it]);
     556          58 :         OutStream->writeShort( *it );
     557             : 
     558          58 :         bool bVoid = pProp->getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
     559             : 
     560          58 :         OutStream->writeBoolean( bVoid );
     561             : 
     562          58 :         if ( !bVoid )
     563             :         {
     564          58 :             const ::com::sun::star::uno::Any& rValue = *pProp;
     565          58 :             const ::com::sun::star::uno::Type& rType = rValue.getValueType();
     566             : 
     567          58 :             if ( rType == cppu::UnoType< bool >::get() )
     568             :             {
     569          10 :                 bool b = false;
     570          10 :                 rValue >>= b;
     571          10 :                 OutStream->writeBoolean( b );
     572             :             }
     573          48 :             else if ( rType == ::cppu::UnoType< OUString >::get() )
     574             :             {
     575          38 :                 OUString aUString;
     576          38 :                 rValue >>= aUString;
     577          38 :                 OutStream->writeUTF( aUString );
     578             :             }
     579          10 :             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          10 :             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          10 :             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          10 :             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          10 :             else if ( rType == cppu::UnoType<double>::get() )
     604             :             {
     605           0 :                 double n = 0;
     606           0 :                 rValue >>= n;
     607           0 :                 OutStream->writeDouble( n );
     608             :             }
     609          10 :             else if ( rType == cppu::UnoType< ::com::sun::star::awt::FontDescriptor >::get() )
     610             :             {
     611           4 :                 ::com::sun::star::awt::FontDescriptor aFD;
     612           4 :                 rValue >>= aFD;
     613           4 :                 OutStream->writeUTF( aFD.Name );
     614           4 :                 OutStream->writeShort( aFD.Height );
     615           4 :                 OutStream->writeShort( aFD.Width );
     616           4 :                 OutStream->writeUTF( aFD.StyleName );
     617           4 :                 OutStream->writeShort( aFD.Family );
     618           4 :                 OutStream->writeShort( aFD.CharSet );
     619           4 :                 OutStream->writeShort( aFD.Pitch );
     620           4 :                 OutStream->writeDouble( aFD.CharacterWidth );
     621           4 :                 OutStream->writeDouble( aFD.Weight );
     622           4 :                 OutStream->writeShort(
     623           4 :                     sal::static_int_cast< sal_Int16 >(aFD.Slant) );
     624           4 :                 OutStream->writeShort( aFD.Underline );
     625           4 :                 OutStream->writeShort( aFD.Strikeout );
     626           4 :                 OutStream->writeDouble( aFD.Orientation );
     627           4 :                 OutStream->writeBoolean( aFD.Kerning );
     628           4 :                 OutStream->writeBoolean( aFD.WordLineMode );
     629           4 :                 OutStream->writeShort( aFD.Type );
     630             :             }
     631           6 :             else if ( rType == cppu::UnoType<css::util::Date>::get() )
     632             :             {
     633           6 :                 css::util::Date d;
     634           6 :                 rValue >>= d;
     635           6 :                 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          58 :         sal_Int32 nPropDataLen = xMark->offsetToMark( nPropDataBeginMark );
     695          58 :         xMark->jumpToMark( nPropDataBeginMark );
     696          58 :         OutStream->writeLong( nPropDataLen );
     697          58 :         xMark->jumpToFurthest();
     698          58 :         xMark->deleteMark(nPropDataBeginMark);
     699             :     }
     700             : 
     701          80 :     if ( aProps.find( BASEPROPERTY_FONTDESCRIPTOR ) != aProps.end() )
     702             :     {
     703           4 :         const ::com::sun::star::uno::Any* pProp = &maData[ BASEPROPERTY_FONTDESCRIPTOR ];
     704             :         // Until 5.0 export arrives, write old format..
     705           4 :         ::com::sun::star::awt::FontDescriptor aFD;
     706           4 :         (*pProp) >>= aFD;
     707             : 
     708          16 :         for ( sal_uInt16 n = BASEPROPERTY_FONT_TYPE; n <= BASEPROPERTY_FONT_ATTRIBS; n++ )
     709             :         {
     710          12 :             sal_Int32 nPropDataBeginMark = xMark->createMark();
     711          12 :             OutStream->writeLong( 0L ); // DataLen
     712          12 :             OutStream->writeShort( n ); // PropId
     713          12 :             OutStream->writeBoolean( sal_False );   // Void
     714             : 
     715          12 :             if ( n == BASEPROPERTY_FONT_TYPE )
     716             :             {
     717           4 :                 OutStream->writeUTF( aFD.Name );
     718           4 :                 OutStream->writeUTF( aFD.StyleName );
     719           4 :                 OutStream->writeShort( aFD.Family );
     720           4 :                 OutStream->writeShort( aFD.CharSet );
     721           4 :                 OutStream->writeShort( aFD.Pitch );
     722             :             }
     723           8 :             else if ( n == BASEPROPERTY_FONT_SIZE )
     724             :             {
     725           4 :                 OutStream->writeLong( aFD.Width );
     726           4 :                 OutStream->writeLong( aFD.Height );
     727           4 :                 OutStream->writeShort(
     728             :                     sal::static_int_cast< sal_Int16 >(
     729           4 :                         VCLUnoHelper::ConvertFontWidth( aFD.CharacterWidth )) );
     730             :             }
     731           4 :             else if ( n == BASEPROPERTY_FONT_ATTRIBS )
     732             :             {
     733           4 :                 OutStream->writeShort(
     734             :                     sal::static_int_cast< sal_Int16 >(
     735           4 :                         VCLUnoHelper::ConvertFontWeight( aFD.Weight )) );
     736           4 :                 OutStream->writeShort(
     737           4 :                     sal::static_int_cast< sal_Int16 >(aFD.Slant) );
     738           4 :                 OutStream->writeShort( aFD.Underline );
     739           4 :                 OutStream->writeShort( aFD.Strikeout );
     740           4 :                 OutStream->writeShort( (short)(aFD.Orientation * 10) );
     741           4 :                 OutStream->writeBoolean( aFD.Kerning );
     742           4 :                 OutStream->writeBoolean( aFD.WordLineMode );
     743             :             }
     744             :             else
     745             :             {
     746             :                 OSL_FAIL( "Property?!" );
     747             :             }
     748             : 
     749          12 :             sal_Int32 nPropDataLen = xMark->offsetToMark( nPropDataBeginMark );
     750          12 :             xMark->jumpToMark( nPropDataBeginMark );
     751          12 :             OutStream->writeLong( nPropDataLen );
     752          12 :             xMark->jumpToFurthest();
     753          12 :             xMark->deleteMark(nPropDataBeginMark);
     754           4 :         }
     755          80 :     }
     756          80 : }
     757             : 
     758          80 : 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          80 :     ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
     761             : 
     762         160 :     ::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          80 :     short nVersion = InStream->readShort();
     766          80 :     sal_uInt32 nProps = (sal_uInt32)InStream->readLong();
     767         160 :     ::com::sun::star::uno::Sequence< OUString> aProps( nProps );
     768         160 :     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> aValues( nProps );
     769          80 :     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          80 :     ::com::sun::star::awt::FontDescriptor* pFD = NULL;
     776             : 
     777             :     sal_uInt32 i;
     778         150 :     for ( i = 0; i < nProps; i++ )
     779             :     {
     780          70 :         sal_Int32 nPropDataBeginMark = xMark->createMark();
     781          70 :         sal_Int32 nPropDataLen = InStream->readLong();
     782             : 
     783          70 :         sal_uInt16 nPropId = (sal_uInt16)InStream->readShort();
     784             : 
     785          70 :         ::com::sun::star::uno::Any aValue;
     786          70 :         bool bIsVoid = InStream->readBoolean();
     787          70 :         if ( !bIsVoid )
     788             :         {
     789          70 :             if ( maData.find( nPropId ) != maData.end() )
     790             :             {
     791          58 :                 const ::com::sun::star::uno::Type* pType = GetPropertyType( nPropId );
     792          58 :                 if ( *pType == ::getBooleanCppuType() )
     793             :                 {
     794          10 :                     bool b = InStream->readBoolean();
     795          10 :                     aValue <<= b;
     796             :                 }
     797          48 :                 else if ( *pType == cppu::UnoType<OUString>::get() )
     798             :                 {
     799          38 :                     OUString aUTF = InStream->readUTF();
     800          38 :                     aValue <<= aUTF;
     801             :                 }
     802          10 :                 else if ( *pType == ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get() )
     803             :                 {
     804           0 :                     sal_uInt16 n = InStream->readShort();
     805           0 :                     aValue <<= n;
     806             :                 }
     807          10 :                 else if ( *pType == cppu::UnoType<sal_Int16>::get() )
     808             :                 {
     809           0 :                     sal_Int16 n = InStream->readShort();
     810           0 :                     aValue <<= n;
     811             :                 }
     812          10 :                 else if ( *pType == cppu::UnoType<sal_uInt32>::get() )
     813             :                 {
     814           0 :                     sal_uInt32 n = InStream->readLong();
     815           0 :                     aValue <<= n;
     816             :                 }
     817          10 :                 else if ( *pType == cppu::UnoType<sal_Int32>::get() )
     818             :                 {
     819           0 :                     sal_Int32 n = InStream->readLong();
     820           0 :                     aValue <<= n;
     821             :                 }
     822          10 :                 else if ( *pType == cppu::UnoType<double>::get() )
     823             :                 {
     824           0 :                     double n = InStream->readDouble();
     825           0 :                     aValue <<= n;
     826             :                 }
     827          10 :                 else if ( *pType == cppu::UnoType< ::com::sun::star::awt::FontDescriptor >::get() )
     828             :                 {
     829           4 :                     ::com::sun::star::awt::FontDescriptor aFD;
     830           4 :                     aFD.Name = InStream->readUTF();
     831           4 :                     aFD.Height = InStream->readShort();
     832           4 :                     aFD.Width = InStream->readShort();
     833           4 :                     aFD.StyleName = InStream->readUTF();
     834           4 :                     aFD.Family = InStream->readShort();
     835           4 :                     aFD.CharSet = InStream->readShort();
     836           4 :                     aFD.Pitch = InStream->readShort();
     837           4 :                     aFD.CharacterWidth = (float)InStream->readDouble();
     838           4 :                     aFD.Weight = (float)InStream->readDouble();
     839           4 :                     aFD.Slant =  (::com::sun::star::awt::FontSlant)InStream->readShort();
     840           4 :                     aFD.Underline = InStream->readShort();
     841           4 :                     aFD.Strikeout = InStream->readShort();
     842           4 :                     aFD.Orientation = (float)InStream->readDouble();
     843           4 :                     aFD.Kerning = InStream->readBoolean();
     844           4 :                     aFD.WordLineMode = InStream->readBoolean();
     845           4 :                     aFD.Type = InStream->readShort();
     846           4 :                     aValue <<= aFD;
     847             :                 }
     848           6 :                 else if ( *pType == cppu::UnoType<css::util::Date>::get() )
     849             :                 {
     850           6 :                     sal_Int32 n = InStream->readLong(); // YYYYMMDD
     851          24 :                     aValue <<= css::util::Date(
     852          24 :                         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          12 :                 if ( nPropId == BASEPROPERTY_FONT_TYPE )
     908             :                 {
     909             :                     // Redundant information for older versions
     910             :                     // is skipped by MarkableStream
     911           4 :                     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           8 :                 else if ( nPropId == BASEPROPERTY_FONT_SIZE )
     927             :                 {
     928           4 :                     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           4 :                 else if ( nPropId == BASEPROPERTY_FONT_ATTRIBS )
     944             :                 {
     945           4 :                     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          70 :         if ( maData.find( nPropId ) != maData.end() )
     978             :         {
     979          58 :             aProps.getArray()[i] = GetPropertyName( nPropId );
     980          58 :             aValues.getArray()[i] = aValue;
     981             :         }
     982             :         else
     983             :         {
     984          12 :             bInvalidEntries = true;
     985             :         }
     986             : 
     987             :         // Skip rest of input if there is more data in stream than this version can handle
     988          70 :         xMark->jumpToMark( nPropDataBeginMark );
     989          70 :         InStream->skipBytes( nPropDataLen );
     990          70 :         xMark->deleteMark(nPropDataBeginMark);
     991          70 :     }
     992          80 :     if ( bInvalidEntries )
     993             :     {
     994          26 :         for ( i = 0; i < (sal_uInt32)aProps.getLength(); i++ )
     995             :         {
     996          22 :             if ( aProps.getConstArray()[i].isEmpty() )
     997             :             {
     998          12 :                 ::comphelper::removeElementAt( aProps, i );
     999          12 :                 ::comphelper::removeElementAt( aValues, i );
    1000          12 :                 i--;
    1001             :             }
    1002             :         }
    1003             :     }
    1004             : 
    1005             :     try
    1006             :     {
    1007          80 :         setPropertyValues( aProps, aValues );
    1008             :     }
    1009           0 :     catch ( const Exception& )
    1010             :     {
    1011             :         DBG_UNHANDLED_EXCEPTION();
    1012             :     }
    1013             : 
    1014          80 :     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          80 :     }
    1021          80 : }
    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         440 : sal_Bool UnoControlModel::supportsService( const OUString& rServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
    1033             : {
    1034         440 :     return cppu::supportsService(this, rServiceName);
    1035             : }
    1036             : 
    1037         890 : ::com::sun::star::uno::Sequence< OUString > UnoControlModel::getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException, std::exception)
    1038             : {
    1039         890 :     OUString sName( "com.sun.star.awt.UnoControlModel" );
    1040         890 :     return Sequence< OUString >( &sName, 1 );
    1041             : }
    1042             : 
    1043       64803 : sal_Bool UnoControlModel::convertFastPropertyValue( Any & rConvertedValue, Any & rOldValue, sal_Int32 nPropId, const Any& rValue ) throw (IllegalArgumentException)
    1044             : {
    1045       64803 :     ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
    1046             : 
    1047       64803 :     bool bVoid = rValue.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
    1048       64803 :     if ( bVoid )
    1049             :     {
    1050         136 :         rConvertedValue.clear();
    1051             :     }
    1052             :     else
    1053             :     {
    1054       64667 :         const ::com::sun::star::uno::Type* pDestType = GetPropertyType( (sal_uInt16)nPropId );
    1055       64667 :         if ( pDestType->getTypeClass() == TypeClass_ANY )
    1056             :         {
    1057          22 :             rConvertedValue = rValue;
    1058             :         }
    1059             :         else
    1060             :         {
    1061       64645 :             if ( pDestType->equals( rValue.getValueType() ) )
    1062             :             {
    1063       64547 :                 rConvertedValue = rValue;
    1064             :             }
    1065             :             else
    1066             :             {
    1067          98 :                 bool bConverted = false;
    1068             :                 // 13.03.2001 - 84923 - frank.schoenheit@germany.sun.com
    1069             : 
    1070          98 :                 switch (pDestType->getTypeClass())
    1071             :                 {
    1072             :                     case TypeClass_DOUBLE:
    1073             :                     {
    1074             :                         // try as double
    1075          12 :                         double nAsDouble = 0;
    1076          12 :                         bConverted = ( rValue >>= nAsDouble );
    1077          12 :                         if ( bConverted )
    1078           8 :                             rConvertedValue <<= nAsDouble;
    1079             :                         else
    1080             :                         {   // try as integer
    1081           4 :                             sal_Int32 nAsInteger = 0;
    1082           4 :                             bConverted = ( rValue >>= nAsInteger );
    1083           4 :                             if ( bConverted )
    1084           0 :                                 rConvertedValue <<= (double)nAsInteger;
    1085             :                         }
    1086             :                     }
    1087          12 :                     break;
    1088             :                     case TypeClass_SHORT:
    1089             :                     {
    1090             :                         sal_Int16 n;
    1091           4 :                         bConverted = ( rValue >>= n );
    1092           4 :                         if ( bConverted )
    1093           0 :                             rConvertedValue <<= n;
    1094             :                     }
    1095           4 :                     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          44 :                         if ( rValue.getValueType().getTypeClass() == TypeClass_INTERFACE )
    1123             :                         {
    1124          44 :                             Reference< XInterface > xPure( rValue, UNO_QUERY );
    1125          44 :                             if ( xPure.is() )
    1126           4 :                                 rConvertedValue = xPure->queryInterface( *pDestType );
    1127             :                             else
    1128          40 :                                 rConvertedValue.setValue( NULL, *pDestType );
    1129          44 :                             bConverted = true;
    1130             :                         }
    1131             :                     }
    1132          44 :                     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          98 :                 if (!bConverted)
    1145             :                 {
    1146          46 :                     OUStringBuffer aErrorMessage;
    1147          46 :                     aErrorMessage.appendAscii( "Unable to convert the given value for the property " );
    1148          46 :                     aErrorMessage.append     ( GetPropertyName( (sal_uInt16)nPropId ) );
    1149          46 :                     aErrorMessage.appendAscii( ".\n" );
    1150          46 :                     aErrorMessage.appendAscii( "Expected type: " );
    1151          46 :                     aErrorMessage.append     ( pDestType->getTypeName() );
    1152          46 :                     aErrorMessage.appendAscii( "\n" );
    1153          46 :                     aErrorMessage.appendAscii( "Found type: " );
    1154          46 :                     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          46 :                         1);
    1159             :                 }
    1160             :             }
    1161             :         }
    1162             :     }
    1163             : 
    1164             :     // the current value
    1165       64757 :     getFastPropertyValue( rOldValue, nPropId );
    1166       64803 :     return !CompareProperties( rConvertedValue, rOldValue );
    1167             : }
    1168             : 
    1169       16349 : 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       16349 :     ImplPropertyTable::const_iterator it = maData.find( nPropId );
    1174       16349 :     const ::com::sun::star::uno::Any* pProp = it == maData.end() ? NULL : &(it->second);
    1175       32698 :     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       16349 :     maData[ nPropId ] = rValue;
    1179             : }
    1180             : 
    1181      213223 : void UnoControlModel::getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nPropId ) const
    1182             : {
    1183      213223 :     ::osl::Guard< ::osl::Mutex > aGuard( ((UnoControlModel*)this)->GetMutex() );
    1184             : 
    1185      213223 :     ImplPropertyTable::const_iterator it = maData.find( nPropId );
    1186      213223 :     const ::com::sun::star::uno::Any* pProp = it == maData.end() ? NULL : &(it->second);
    1187             : 
    1188      213223 :     if ( pProp )
    1189      161451 :         rValue = *pProp;
    1190       51772 :     else if ( ( nPropId >= BASEPROPERTY_FONTDESCRIPTORPART_START ) && ( nPropId <= BASEPROPERTY_FONTDESCRIPTORPART_END ) )
    1191             :     {
    1192       51772 :         pProp = &( maData.find( BASEPROPERTY_FONTDESCRIPTOR )->second );
    1193       51772 :         ::com::sun::star::awt::FontDescriptor aFD;
    1194       51772 :         (*pProp) >>= aFD;
    1195       51772 :         switch ( nPropId )
    1196             :         {
    1197        4596 :             case BASEPROPERTY_FONTDESCRIPTORPART_NAME:          rValue <<= aFD.Name;
    1198        4596 :                                                                 break;
    1199        3143 :             case BASEPROPERTY_FONTDESCRIPTORPART_STYLENAME:     rValue <<= aFD.StyleName;
    1200        3143 :                                                                 break;
    1201        3149 :             case BASEPROPERTY_FONTDESCRIPTORPART_FAMILY:        rValue <<= aFD.Family;
    1202        3149 :                                                                 break;
    1203        3141 :             case BASEPROPERTY_FONTDESCRIPTORPART_CHARSET:       rValue <<= aFD.CharSet;
    1204        3141 :                                                                 break;
    1205        3149 :             case BASEPROPERTY_FONTDESCRIPTORPART_HEIGHT:        rValue <<= (float)aFD.Height;
    1206        3149 :                                                                 break;
    1207        3150 :             case BASEPROPERTY_FONTDESCRIPTORPART_WEIGHT:        rValue <<= aFD.Weight;
    1208        3150 :                                                                 break;
    1209        3149 :             case BASEPROPERTY_FONTDESCRIPTORPART_SLANT:         rValue <<= (sal_Int16)aFD.Slant;
    1210        3149 :                                                                 break;
    1211        3149 :             case BASEPROPERTY_FONTDESCRIPTORPART_UNDERLINE:     rValue <<= aFD.Underline;
    1212        3149 :                                                                 break;
    1213        3149 :             case BASEPROPERTY_FONTDESCRIPTORPART_STRIKEOUT:     rValue <<= aFD.Strikeout;
    1214        3149 :                                                                 break;
    1215        3141 :             case BASEPROPERTY_FONTDESCRIPTORPART_WIDTH:         rValue <<= aFD.Width;
    1216        3141 :                                                                 break;
    1217        3142 :             case BASEPROPERTY_FONTDESCRIPTORPART_PITCH:         rValue <<= aFD.Pitch;
    1218        3142 :                                                                 break;
    1219        3143 :             case BASEPROPERTY_FONTDESCRIPTORPART_CHARWIDTH:     rValue <<= aFD.CharacterWidth;
    1220        3143 :                                                                 break;
    1221        3141 :             case BASEPROPERTY_FONTDESCRIPTORPART_ORIENTATION:   rValue <<= aFD.Orientation;
    1222        3141 :                                                                 break;
    1223        3142 :             case BASEPROPERTY_FONTDESCRIPTORPART_KERNING:       rValue <<= aFD.Kerning;
    1224        3142 :                                                                 break;
    1225        3143 :             case BASEPROPERTY_FONTDESCRIPTORPART_WORDLINEMODE:  rValue <<= aFD.WordLineMode;
    1226        3143 :                                                                 break;
    1227        3145 :             case BASEPROPERTY_FONTDESCRIPTORPART_TYPE:          rValue <<= aFD.Type;
    1228        3145 :                                                                 break;
    1229             :             default: OSL_FAIL( "FontProperty?!" );
    1230       51772 :         }
    1231             :     }
    1232             :     else
    1233             :     {
    1234             :         OSL_FAIL( "getFastPropertyValue - invalid Property!" );
    1235      213223 :     }
    1236      213223 : }
    1237             : 
    1238             : // ::com::sun::star::beans::XPropertySet
    1239        3918 : 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        3918 :     sal_Int32 nPropId = 0;
    1242             :     {
    1243        3918 :         ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
    1244        3918 :         nPropId = (sal_Int32) GetPropertyId( rPropertyName );
    1245        3918 :         DBG_ASSERT( nPropId, "Invalid ID in UnoControlModel::setPropertyValue" );
    1246             :     }
    1247        3918 :     if( nPropId )
    1248        3918 :         setFastPropertyValue( nPropId, rValue );
    1249             :     else
    1250           0 :         throw ::com::sun::star::beans::UnknownPropertyException();
    1251        3918 : }
    1252             : 
    1253             : // ::com::sun::star::beans::XFastPropertySet
    1254       11774 : 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       11774 :     if ( ( nPropId >= BASEPROPERTY_FONTDESCRIPTORPART_START ) && ( nPropId <= BASEPROPERTY_FONTDESCRIPTORPART_END ) )
    1257             :     {
    1258         723 :         ::osl::ClearableMutexGuard aGuard( GetMutex() );
    1259             : 
    1260        1446 :         Any aOldSingleValue;
    1261         723 :         getFastPropertyValue( aOldSingleValue, BASEPROPERTY_FONTDESCRIPTORPART_START );
    1262             : 
    1263         723 :         ::com::sun::star::uno::Any* pProp = &maData[ BASEPROPERTY_FONTDESCRIPTOR ];
    1264        1446 :         FontDescriptor aOldFontDescriptor;
    1265         723 :         (*pProp) >>= aOldFontDescriptor;
    1266             : 
    1267        1446 :         FontDescriptor aNewFontDescriptor( aOldFontDescriptor );
    1268         723 :         lcl_ImplMergeFontProperty( aNewFontDescriptor, (sal_uInt16)nPropId, rValue );
    1269             : 
    1270        1446 :         Any aNewValue;
    1271         723 :         aNewValue <<= aNewFontDescriptor;
    1272         723 :         sal_Int32 nDescriptorId( BASEPROPERTY_FONTDESCRIPTOR );
    1273         723 :         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        1446 :         Any aNewSingleValue;
    1278         723 :         getFastPropertyValue( aNewSingleValue, BASEPROPERTY_FONTDESCRIPTORPART_START );
    1279             : 
    1280         723 :         aGuard.clear();
    1281         723 :         setFastPropertyValues( 1, &nDescriptorId, &aNewValue, 1 );
    1282        1446 :         fire( &nPropId, &aNewSingleValue, &aOldSingleValue, 1, sal_False );
    1283             :        }
    1284             :     else
    1285       11051 :         setFastPropertyValues( 1, &nPropId, &rValue, 1 );
    1286       11730 : }
    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        2750 : 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        2750 :     ::osl::ClearableMutexGuard aGuard( GetMutex() );
    1298             : 
    1299        2750 :     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        5500 :     Sequence< sal_Int32 > aHandles( nProps );
    1304        2750 :     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        5500 :     uno::Sequence< uno::Any > aValues( Values );
    1308        2750 :     uno::Any* pValues = aValues.getArray();
    1309             : 
    1310        2750 :     sal_Int32 nValidHandles = getInfoHelper().fillHandles( pHandles, rPropertyNames );
    1311             : 
    1312        2750 :     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        2706 :         boost::scoped_ptr< awt::FontDescriptor > pFD;
    1317       89318 :         for ( sal_uInt16 n = 0; n < nProps; ++n )
    1318             :         {
    1319       86612 :             if ( ( pHandles[n] >= BASEPROPERTY_FONTDESCRIPTORPART_START ) && ( pHandles[n] <= BASEPROPERTY_FONTDESCRIPTORPART_END ) )
    1320             :             {
    1321       36268 :                 if ( !pFD.get() )
    1322             :                 {
    1323        2316 :                     ::com::sun::star::uno::Any* pProp = &maData[ BASEPROPERTY_FONTDESCRIPTOR ];
    1324        2316 :                     pFD.reset( new awt::FontDescriptor );
    1325        2316 :                     (*pProp) >>= *pFD;
    1326             :                 }
    1327       36268 :                 lcl_ImplMergeFontProperty( *pFD, (sal_uInt16)pHandles[n], pValues[n] );
    1328       36268 :                 pHandles[n] = -1;
    1329       36268 :                 nValidHandles--;
    1330             :             }
    1331             :         }
    1332             : 
    1333        2706 :         if ( nValidHandles )
    1334             :         {
    1335        2706 :             ImplNormalizePropertySequence( nProps, pHandles, pValues, &nValidHandles );
    1336        2706 :             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        2706 :              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        2704 :         if ( pFD.get() )
    1349             :         {
    1350        2314 :             ::com::sun::star::uno::Any aValue;
    1351        2314 :             aValue <<= *pFD;
    1352        2314 :             sal_Int32 nHandle = BASEPROPERTY_FONTDESCRIPTOR;
    1353        2314 :             setFastPropertyValues( 1, &nHandle, &aValue, 1 );
    1354        2706 :         }
    1355        2750 :     }
    1356        2748 : }
    1357             : 
    1358             : 
    1359             : 
    1360        2706 : void UnoControlModel::ImplNormalizePropertySequence( const sal_Int32, sal_Int32*,
    1361             :     uno::Any*, sal_Int32* ) const
    1362             : {
    1363             :     // nothing to do here
    1364        2706 : }
    1365             : 
    1366         450 : void UnoControlModel::ImplEnsureHandleOrder( const sal_Int32 _nCount, sal_Int32* _pHandles,
    1367             :         uno::Any* _pValues, sal_Int32 _nFirstHandle, sal_Int32 _nSecondHandle ) const
    1368             : {
    1369       15734 :     for ( sal_Int32 i=0; i < _nCount; ++_pHandles, ++_pValues, ++i )
    1370             :     {
    1371       15284 :         if ( _nSecondHandle  == *_pHandles )
    1372             :         {
    1373         334 :             sal_Int32* pLaterHandles = _pHandles + 1;
    1374         334 :             uno::Any* pLaterValues = _pValues + 1;
    1375         662 :             for ( sal_Int32 j = i + 1; j < _nCount; ++j, ++pLaterHandles, ++pLaterValues )
    1376             :             {
    1377         400 :                 if ( _nFirstHandle == *pLaterHandles )
    1378             :                 {
    1379             :                     // indeed it is -> exchange the both places in the sequences
    1380          72 :                     sal_Int32 nHandle( *_pHandles );
    1381          72 :                     *_pHandles = *pLaterHandles;
    1382          72 :                     *pLaterHandles = nHandle;
    1383             : 
    1384          72 :                     uno::Any aValue( *_pValues );
    1385          72 :                     *_pValues = *pLaterValues;
    1386          72 :                     *pLaterValues = aValue;
    1387             : 
    1388          72 :                     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        1677 : }
    1397             : 
    1398             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10