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