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

Generated by: LCOV version 1.10