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