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

Generated by: LCOV version 1.10