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/awt/XTextArea.hpp> 31*cdf0e10cSrcweir #include <com/sun/star/awt/XVclWindowPeer.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/awt/VisualEffect.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/awt/LineEndFormat.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphicProvider.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/graphic/GraphicObject.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/util/Date.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/awt/ImageScaleMode.hpp> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir #include <toolkit/controls/formattedcontrol.hxx> 43*cdf0e10cSrcweir #include <toolkit/controls/roadmapcontrol.hxx> 44*cdf0e10cSrcweir #include <toolkit/controls/unocontrols.hxx> 45*cdf0e10cSrcweir #include <toolkit/controls/stdtabcontroller.hxx> 46*cdf0e10cSrcweir #include <toolkit/helper/property.hxx> 47*cdf0e10cSrcweir #include <toolkit/helper/unopropertyarrayhelper.hxx> 48*cdf0e10cSrcweir #include <toolkit/helper/unomemorystream.hxx> 49*cdf0e10cSrcweir #include <toolkit/helper/servicenames.hxx> 50*cdf0e10cSrcweir #include <toolkit/helper/macros.hxx> 51*cdf0e10cSrcweir #include <toolkit/helper/imagealign.hxx> 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir // for introspection 54*cdf0e10cSrcweir #include <toolkit/awt/vclxwindows.hxx> 55*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 56*cdf0e10cSrcweir #include <comphelper/componentcontext.hxx> 57*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 58*cdf0e10cSrcweir #include <comphelper/extract.hxx> 59*cdf0e10cSrcweir #include <vcl/wrkwin.hxx> 60*cdf0e10cSrcweir #include <vcl/svapp.hxx> 61*cdf0e10cSrcweir #include <vcl/edit.hxx> 62*cdf0e10cSrcweir #ifndef _SV_BUTTON_HXX 63*cdf0e10cSrcweir #include <vcl/button.hxx> 64*cdf0e10cSrcweir #endif 65*cdf0e10cSrcweir #include <vcl/group.hxx> 66*cdf0e10cSrcweir #include <vcl/fixed.hxx> 67*cdf0e10cSrcweir #include <vcl/lstbox.hxx> 68*cdf0e10cSrcweir #include <vcl/combobox.hxx> 69*cdf0e10cSrcweir #include <tools/debug.hxx> 70*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 71*cdf0e10cSrcweir #include <tools/date.hxx> 72*cdf0e10cSrcweir #include <tools/time.hxx> 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir #include <algorithm> 75*cdf0e10cSrcweir #include <functional> 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir using namespace ::com::sun::star; 78*cdf0e10cSrcweir using ::com::sun::star::graphic::XGraphic; 79*cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 80*cdf0e10cSrcweir using namespace ::toolkit; 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir #define IMPL_SERVICEINFO_DERIVED( ImplName, BaseClass, ServiceName ) \ 83*cdf0e10cSrcweir ::rtl::OUString SAL_CALL ImplName::getImplementationName( ) throw(::com::sun::star::uno::RuntimeException) { return ::rtl::OUString::createFromAscii( "stardiv.Toolkit." #ImplName ); } \ 84*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL ImplName::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException) \ 85*cdf0e10cSrcweir { \ 86*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > aNames = BaseClass::getSupportedServiceNames( ); \ 87*cdf0e10cSrcweir aNames.realloc( aNames.getLength() + 1 ); \ 88*cdf0e10cSrcweir aNames[ aNames.getLength() - 1 ] = ::rtl::OUString::createFromAscii( ServiceName ); \ 89*cdf0e10cSrcweir return aNames; \ 90*cdf0e10cSrcweir } \ 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir // ---------------------------------------------------- 95*cdf0e10cSrcweir // class UnoControlEditModel 96*cdf0e10cSrcweir // ---------------------------------------------------- 97*cdf0e10cSrcweir UnoControlEditModel::UnoControlEditModel( const Reference< XMultiServiceFactory >& i_factory ) 98*cdf0e10cSrcweir :UnoControlModel( i_factory ) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXEdit ); 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir ::rtl::OUString UnoControlEditModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException) 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( szServiceName_UnoControlEditModel ); 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir uno::Any UnoControlEditModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir uno::Any aReturn; 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir switch ( nPropId ) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir case BASEPROPERTY_LINE_END_FORMAT: 115*cdf0e10cSrcweir aReturn <<= (sal_Int16)awt::LineEndFormat::LINE_FEED; // LF 116*cdf0e10cSrcweir break; 117*cdf0e10cSrcweir case BASEPROPERTY_DEFAULTCONTROL: 118*cdf0e10cSrcweir aReturn <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlEdit ); 119*cdf0e10cSrcweir break; 120*cdf0e10cSrcweir default: 121*cdf0e10cSrcweir aReturn = UnoControlModel::ImplGetDefaultValue( nPropId ); 122*cdf0e10cSrcweir break; 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir return aReturn; 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& UnoControlEditModel::getInfoHelper() 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir static UnoPropertyArrayHelper* pHelper = NULL; 130*cdf0e10cSrcweir if ( !pHelper ) 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); 133*cdf0e10cSrcweir pHelper = new UnoPropertyArrayHelper( aIDs ); 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir return *pHelper; 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir // beans::XMultiPropertySet 139*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > UnoControlEditModel::getPropertySetInfo( ) throw(uno::RuntimeException) 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 142*cdf0e10cSrcweir return xInfo; 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir // ---------------------------------------------------- 147*cdf0e10cSrcweir // class UnoEditControl 148*cdf0e10cSrcweir // ---------------------------------------------------- 149*cdf0e10cSrcweir UnoEditControl::UnoEditControl( const Reference< XMultiServiceFactory >& i_factory ) 150*cdf0e10cSrcweir :UnoControlBase( i_factory ) 151*cdf0e10cSrcweir ,maTextListeners( *this ) 152*cdf0e10cSrcweir ,mnMaxTextLen( 0 ) 153*cdf0e10cSrcweir ,mbSetTextInPeer( sal_False ) 154*cdf0e10cSrcweir ,mbSetMaxTextLenInPeer( sal_False ) 155*cdf0e10cSrcweir ,mbHasTextProperty( sal_False ) 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir maComponentInfos.nWidth = 100; 158*cdf0e10cSrcweir maComponentInfos.nHeight = 12; 159*cdf0e10cSrcweir mnMaxTextLen = 0; 160*cdf0e10cSrcweir mbSetMaxTextLenInPeer = sal_False; 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir uno::Any SAL_CALL UnoEditControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir uno::Any aReturn = UnoControlBase::queryAggregation( rType ); 166*cdf0e10cSrcweir if ( !aReturn.hasValue() ) 167*cdf0e10cSrcweir aReturn = UnoEditControl_Base::queryInterface( rType ); 168*cdf0e10cSrcweir return aReturn; 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir uno::Any SAL_CALL UnoEditControl::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException) 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir return UnoControlBase::queryInterface( rType ); 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir void SAL_CALL UnoEditControl::acquire( ) throw () 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir UnoControlBase::acquire(); 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir void SAL_CALL UnoEditControl::release( ) throw () 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir UnoControlBase::release(); 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoEditControl, UnoControlBase, UnoEditControl_Base ) 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir ::rtl::OUString UnoEditControl::GetComponentServiceName() 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir // by default, we want a simple edit field 191*cdf0e10cSrcweir ::rtl::OUString sName( ::rtl::OUString::createFromAscii( "Edit" ) ); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir // but maybe we are to display multi-line text? 194*cdf0e10cSrcweir uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_MULTILINE ) ); 195*cdf0e10cSrcweir sal_Bool b = sal_Bool(); 196*cdf0e10cSrcweir if ( ( aVal >>= b ) && b ) 197*cdf0e10cSrcweir sName= ::rtl::OUString::createFromAscii( "MultiLineEdit" ); 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir return sName; 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir sal_Bool SAL_CALL UnoEditControl::setModel(const uno::Reference< awt::XControlModel >& _rModel) throw ( uno::RuntimeException ) 203*cdf0e10cSrcweir { 204*cdf0e10cSrcweir sal_Bool bReturn = UnoControlBase::setModel( _rModel ); 205*cdf0e10cSrcweir mbHasTextProperty = ImplHasProperty( BASEPROPERTY_TEXT ); 206*cdf0e10cSrcweir return bReturn; 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir void UnoEditControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const uno::Any& rVal ) 210*cdf0e10cSrcweir { 211*cdf0e10cSrcweir sal_Bool bDone = sal_False; 212*cdf0e10cSrcweir if ( GetPropertyId( rPropName ) == BASEPROPERTY_TEXT ) 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir // #96986# use setText(), or text listener will not be called. 215*cdf0e10cSrcweir uno::Reference < awt::XTextComponent > xTextComponent( getPeer(), uno::UNO_QUERY ); 216*cdf0e10cSrcweir if ( xTextComponent.is() ) 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir ::rtl::OUString sText; 219*cdf0e10cSrcweir rVal >>= sText; 220*cdf0e10cSrcweir ImplCheckLocalize( sText ); 221*cdf0e10cSrcweir xTextComponent->setText( sText ); 222*cdf0e10cSrcweir bDone = sal_True; 223*cdf0e10cSrcweir } 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir if ( !bDone ) 227*cdf0e10cSrcweir UnoControlBase::ImplSetPeerProperty( rPropName, rVal ); 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir void UnoEditControl::dispose() throw(uno::RuntimeException) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir lang::EventObject aEvt( *this ); 233*cdf0e10cSrcweir maTextListeners.disposeAndClear( aEvt ); 234*cdf0e10cSrcweir UnoControl::dispose(); 235*cdf0e10cSrcweir } 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir void UnoEditControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException) 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir UnoControl::createPeer( rxToolkit, rParentPeer ); 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY ); 242*cdf0e10cSrcweir if ( xText.is() ) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir xText->addTextListener( this ); 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir if ( mbSetMaxTextLenInPeer ) 247*cdf0e10cSrcweir xText->setMaxTextLen( mnMaxTextLen ); 248*cdf0e10cSrcweir if ( mbSetTextInPeer ) 249*cdf0e10cSrcweir xText->setText( maText ); 250*cdf0e10cSrcweir } 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir void UnoEditControl::textChanged(const awt::TextEvent& e) throw(uno::RuntimeException) 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY ); 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir if ( mbHasTextProperty ) 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir uno::Any aAny; 260*cdf0e10cSrcweir aAny <<= xText->getText(); 261*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT ), aAny, sal_False ); 262*cdf0e10cSrcweir } 263*cdf0e10cSrcweir else 264*cdf0e10cSrcweir { 265*cdf0e10cSrcweir maText = xText->getText(); 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir if ( maTextListeners.getLength() ) 269*cdf0e10cSrcweir maTextListeners.textChanged( e ); 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir void UnoEditControl::addTextListener(const uno::Reference< awt::XTextListener > & l) throw(uno::RuntimeException) 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir maTextListeners.addInterface( l ); 275*cdf0e10cSrcweir } 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir void UnoEditControl::removeTextListener(const uno::Reference< awt::XTextListener > & l) throw(uno::RuntimeException) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir maTextListeners.removeInterface( l ); 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir void UnoEditControl::setText( const ::rtl::OUString& aText ) throw(uno::RuntimeException) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir if ( mbHasTextProperty ) 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir uno::Any aAny; 287*cdf0e10cSrcweir aAny <<= aText; 288*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT ), aAny, sal_True ); 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir else 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir maText = aText; 293*cdf0e10cSrcweir mbSetTextInPeer = sal_True; 294*cdf0e10cSrcweir uno::Reference < awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY ); 295*cdf0e10cSrcweir if ( xText.is() ) 296*cdf0e10cSrcweir xText->setText( maText ); 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir // Setting the property to the VCLXWindow doesn't call textChanged 300*cdf0e10cSrcweir if ( maTextListeners.getLength() ) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir awt::TextEvent aEvent; 303*cdf0e10cSrcweir aEvent.Source = *this; 304*cdf0e10cSrcweir maTextListeners.textChanged( aEvent ); 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir namespace 309*cdf0e10cSrcweir { 310*cdf0e10cSrcweir static void lcl_normalize( awt::Selection& _rSel ) 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir if ( _rSel.Min > _rSel.Max ) 313*cdf0e10cSrcweir ::std::swap( _rSel.Min, _rSel.Max ); 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir /* 317*cdf0e10cSrcweir static bool lcl_intersect( const awt::Selection& _rLHS, const awt::Selection& _rRHS ) 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir OSL_PRECOND( _rLHS.Min <= _rLHS.Max, "lcl_intersect: LHS to be normalized!" ); 320*cdf0e10cSrcweir OSL_PRECOND( _rRHS.Min <= _rRHS.Max, "lcl_intersect: RHS to be normalized!" ); 321*cdf0e10cSrcweir return !( ( _rLHS.Max < _rRHS.Min ) || ( _rLHS.Min > _rRHS.Max ) ); 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir */ 324*cdf0e10cSrcweir } 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir void UnoEditControl::insertText( const awt::Selection& rSel, const ::rtl::OUString& rNewText ) throw(uno::RuntimeException) 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir // normalize the selection - OUString::replaceAt has a strange behaviour if the min is greater than the max 329*cdf0e10cSrcweir awt::Selection aSelection( rSel ); 330*cdf0e10cSrcweir lcl_normalize( aSelection ); 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir // preserve the selection resp. cursor position 333*cdf0e10cSrcweir awt::Selection aNewSelection( getSelection() ); 334*cdf0e10cSrcweir #ifdef ALSO_PRESERVE_COMPLETE_SELECTION 335*cdf0e10cSrcweir // (not sure - looks uglier ...) 336*cdf0e10cSrcweir sal_Int32 nDeletedCharacters = ( aSelection.Max - aSelection.Min ) - rNewText.getLength(); 337*cdf0e10cSrcweir if ( aNewSelection.Min > aSelection.Min ) 338*cdf0e10cSrcweir aNewSelection.Min -= nDeletedCharacters; 339*cdf0e10cSrcweir if ( aNewSelection.Max > aSelection.Max ) 340*cdf0e10cSrcweir aNewSelection.Max -= nDeletedCharacters; 341*cdf0e10cSrcweir #else 342*cdf0e10cSrcweir aNewSelection.Max = ::std::min( aNewSelection.Min, aNewSelection.Max ) + rNewText.getLength(); 343*cdf0e10cSrcweir aNewSelection.Min = aNewSelection.Max; 344*cdf0e10cSrcweir #endif 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir ::rtl::OUString aOldText = getText(); 347*cdf0e10cSrcweir ::rtl::OUString aNewText = aOldText.replaceAt( aSelection.Min, aSelection.Max - aSelection.Min, rNewText ); 348*cdf0e10cSrcweir setText( aNewText ); 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir setSelection( aNewSelection ); 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir ::rtl::OUString UnoEditControl::getText() throw(uno::RuntimeException) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir ::rtl::OUString aText = maText; 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir if ( mbHasTextProperty ) 358*cdf0e10cSrcweir aText = ImplGetPropertyValue_UString( BASEPROPERTY_TEXT ); 359*cdf0e10cSrcweir else 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY ); 362*cdf0e10cSrcweir if ( xText.is() ) 363*cdf0e10cSrcweir aText = xText->getText(); 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir return aText; 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir ::rtl::OUString UnoEditControl::getSelectedText( void ) throw(uno::RuntimeException) 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir ::rtl::OUString sSelected; 372*cdf0e10cSrcweir uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY ); 373*cdf0e10cSrcweir if ( xText.is() ) 374*cdf0e10cSrcweir sSelected = xText->getSelectedText(); 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir return sSelected; 377*cdf0e10cSrcweir } 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir void UnoEditControl::setSelection( const awt::Selection& aSelection ) throw(uno::RuntimeException) 380*cdf0e10cSrcweir { 381*cdf0e10cSrcweir uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY ); 382*cdf0e10cSrcweir if ( xText.is() ) 383*cdf0e10cSrcweir xText->setSelection( aSelection ); 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir awt::Selection UnoEditControl::getSelection( void ) throw(uno::RuntimeException) 387*cdf0e10cSrcweir { 388*cdf0e10cSrcweir awt::Selection aSel; 389*cdf0e10cSrcweir uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY ); 390*cdf0e10cSrcweir if ( xText.is() ) 391*cdf0e10cSrcweir aSel = xText->getSelection(); 392*cdf0e10cSrcweir return aSel; 393*cdf0e10cSrcweir } 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir sal_Bool UnoEditControl::isEditable( void ) throw(uno::RuntimeException) 396*cdf0e10cSrcweir { 397*cdf0e10cSrcweir return !ImplGetPropertyValue_BOOL( BASEPROPERTY_READONLY ); 398*cdf0e10cSrcweir } 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir void UnoEditControl::setEditable( sal_Bool bEditable ) throw(uno::RuntimeException) 401*cdf0e10cSrcweir { 402*cdf0e10cSrcweir uno::Any aAny; 403*cdf0e10cSrcweir aAny <<= (sal_Bool)!bEditable; 404*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_READONLY ), aAny, sal_True ); 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir sal_Int16 UnoEditControl::getMaxTextLen() throw(uno::RuntimeException) 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir sal_Int16 nMaxLen = mnMaxTextLen; 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN ) ) 412*cdf0e10cSrcweir nMaxLen = ImplGetPropertyValue_INT16( BASEPROPERTY_MAXTEXTLEN ); 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir return nMaxLen; 415*cdf0e10cSrcweir } 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir void UnoEditControl::setMaxTextLen( sal_Int16 nLen ) throw(uno::RuntimeException) 418*cdf0e10cSrcweir { 419*cdf0e10cSrcweir if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN) ) 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir uno::Any aAny; 422*cdf0e10cSrcweir aAny <<= (sal_Int16)nLen; 423*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MAXTEXTLEN ), aAny, sal_True ); 424*cdf0e10cSrcweir } 425*cdf0e10cSrcweir else 426*cdf0e10cSrcweir { 427*cdf0e10cSrcweir mnMaxTextLen = nLen; 428*cdf0e10cSrcweir mbSetMaxTextLenInPeer = sal_True; 429*cdf0e10cSrcweir uno::Reference < awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY ); 430*cdf0e10cSrcweir if ( xText.is() ) 431*cdf0e10cSrcweir xText->setMaxTextLen( mnMaxTextLen ); 432*cdf0e10cSrcweir } 433*cdf0e10cSrcweir } 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir awt::Size UnoEditControl::getMinimumSize( ) throw(uno::RuntimeException) 436*cdf0e10cSrcweir { 437*cdf0e10cSrcweir return Impl_getMinimumSize(); 438*cdf0e10cSrcweir } 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir awt::Size UnoEditControl::getPreferredSize( ) throw(uno::RuntimeException) 441*cdf0e10cSrcweir { 442*cdf0e10cSrcweir return Impl_getPreferredSize(); 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir awt::Size UnoEditControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException) 446*cdf0e10cSrcweir { 447*cdf0e10cSrcweir return Impl_calcAdjustedSize( rNewSize ); 448*cdf0e10cSrcweir } 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir awt::Size UnoEditControl::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(uno::RuntimeException) 451*cdf0e10cSrcweir { 452*cdf0e10cSrcweir return Impl_getMinimumSize( nCols, nLines ); 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir void UnoEditControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(uno::RuntimeException) 456*cdf0e10cSrcweir { 457*cdf0e10cSrcweir Impl_getColumnsAndLines( nCols, nLines ); 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir // ---------------------------------------------------- 462*cdf0e10cSrcweir // class UnoControlFileControlModel 463*cdf0e10cSrcweir // ---------------------------------------------------- 464*cdf0e10cSrcweir UnoControlFileControlModel::UnoControlFileControlModel( const Reference< XMultiServiceFactory >& i_factory ) 465*cdf0e10cSrcweir :UnoControlModel( i_factory ) 466*cdf0e10cSrcweir { 467*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_ALIGN ); 468*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR ); 469*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_BORDER ); 470*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR ); 471*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL ); 472*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_ENABLED ); 473*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE ); 474*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR ); 475*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_HELPTEXT ); 476*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_HELPURL ); 477*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_PRINTABLE ); 478*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_READONLY ); 479*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_TABSTOP ); 480*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_TEXT ); 481*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_VERTICALALIGN ); 482*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_WRITING_MODE ); 483*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE ); 484*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_HIDEINACTIVESELECTION ); 485*cdf0e10cSrcweir } 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir ::rtl::OUString UnoControlFileControlModel::getServiceName() throw(::com::sun::star::uno::RuntimeException) 488*cdf0e10cSrcweir { 489*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( szServiceName_UnoControlFileControlModel ); 490*cdf0e10cSrcweir } 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir uno::Any UnoControlFileControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const 493*cdf0e10cSrcweir { 494*cdf0e10cSrcweir if ( nPropId == BASEPROPERTY_DEFAULTCONTROL ) 495*cdf0e10cSrcweir { 496*cdf0e10cSrcweir uno::Any aAny; 497*cdf0e10cSrcweir aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlFileControl ); 498*cdf0e10cSrcweir return aAny; 499*cdf0e10cSrcweir } 500*cdf0e10cSrcweir return UnoControlModel::ImplGetDefaultValue( nPropId ); 501*cdf0e10cSrcweir } 502*cdf0e10cSrcweir 503*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& UnoControlFileControlModel::getInfoHelper() 504*cdf0e10cSrcweir { 505*cdf0e10cSrcweir static UnoPropertyArrayHelper* pHelper = NULL; 506*cdf0e10cSrcweir if ( !pHelper ) 507*cdf0e10cSrcweir { 508*cdf0e10cSrcweir uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); 509*cdf0e10cSrcweir pHelper = new UnoPropertyArrayHelper( aIDs ); 510*cdf0e10cSrcweir } 511*cdf0e10cSrcweir return *pHelper; 512*cdf0e10cSrcweir } 513*cdf0e10cSrcweir 514*cdf0e10cSrcweir // beans::XMultiPropertySet 515*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > UnoControlFileControlModel::getPropertySetInfo( ) throw(uno::RuntimeException) 516*cdf0e10cSrcweir { 517*cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 518*cdf0e10cSrcweir return xInfo; 519*cdf0e10cSrcweir } 520*cdf0e10cSrcweir 521*cdf0e10cSrcweir // ---------------------------------------------------- 522*cdf0e10cSrcweir // class UnoFileControl 523*cdf0e10cSrcweir // ---------------------------------------------------- 524*cdf0e10cSrcweir UnoFileControl::UnoFileControl( const Reference< XMultiServiceFactory >& i_factory ) 525*cdf0e10cSrcweir :UnoEditControl( i_factory ) 526*cdf0e10cSrcweir { 527*cdf0e10cSrcweir } 528*cdf0e10cSrcweir 529*cdf0e10cSrcweir ::rtl::OUString UnoFileControl::GetComponentServiceName() 530*cdf0e10cSrcweir { 531*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "filecontrol" ); 532*cdf0e10cSrcweir } 533*cdf0e10cSrcweir 534*cdf0e10cSrcweir // ---------------------------------------------------- 535*cdf0e10cSrcweir // class GraphicControlModel 536*cdf0e10cSrcweir // ---------------------------------------------------- 537*cdf0e10cSrcweir uno::Any GraphicControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const 538*cdf0e10cSrcweir { 539*cdf0e10cSrcweir if ( nPropId == BASEPROPERTY_GRAPHIC ) 540*cdf0e10cSrcweir return uno::makeAny( uno::Reference< graphic::XGraphic >() ); 541*cdf0e10cSrcweir 542*cdf0e10cSrcweir return UnoControlModel::ImplGetDefaultValue( nPropId ); 543*cdf0e10cSrcweir } 544*cdf0e10cSrcweir uno::Reference< graphic::XGraphic > GraphicControlModel::getGraphicFromURL_nothrow( const ::rtl::OUString& _rURL ) 545*cdf0e10cSrcweir { 546*cdf0e10cSrcweir uno::Reference< graphic::XGraphic > xGraphic; 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir if( ( _rURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) == 0 ) ) 549*cdf0e10cSrcweir { 550*cdf0e10cSrcweir // graphic manager uniqueid 551*cdf0e10cSrcweir rtl::OUString sID = _rURL.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX ) - 1 ); 552*cdf0e10cSrcweir // get the DefaultContext 553*cdf0e10cSrcweir mxGrfObj = graphic::GraphicObject::createWithId( maContext.getUNOContext(), sID ); 554*cdf0e10cSrcweir } 555*cdf0e10cSrcweir else // linked 556*cdf0e10cSrcweir mxGrfObj = NULL; // release the GraphicObject 557*cdf0e10cSrcweir 558*cdf0e10cSrcweir if ( !_rURL.getLength() ) 559*cdf0e10cSrcweir return xGraphic; 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir try 562*cdf0e10cSrcweir { 563*cdf0e10cSrcweir uno::Reference< graphic::XGraphicProvider > xProvider; 564*cdf0e10cSrcweir if ( maContext.createComponent( "com.sun.star.graphic.GraphicProvider", xProvider ) ) 565*cdf0e10cSrcweir { 566*cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aMediaProperties(1); 567*cdf0e10cSrcweir aMediaProperties[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ); 568*cdf0e10cSrcweir aMediaProperties[0].Value <<= _rURL; 569*cdf0e10cSrcweir xGraphic = xProvider->queryGraphic( aMediaProperties ); 570*cdf0e10cSrcweir } 571*cdf0e10cSrcweir } 572*cdf0e10cSrcweir catch( const Exception& ) 573*cdf0e10cSrcweir { 574*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 575*cdf0e10cSrcweir } 576*cdf0e10cSrcweir 577*cdf0e10cSrcweir return xGraphic; 578*cdf0e10cSrcweir } 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir void SAL_CALL GraphicControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception) 581*cdf0e10cSrcweir { 582*cdf0e10cSrcweir UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue ); 583*cdf0e10cSrcweir 584*cdf0e10cSrcweir // - ImageAlign and ImagePosition need to correspond to each other 585*cdf0e10cSrcweir // - Graphic and ImageURL need to correspond to each other 586*cdf0e10cSrcweir try 587*cdf0e10cSrcweir { 588*cdf0e10cSrcweir switch ( nHandle ) 589*cdf0e10cSrcweir { 590*cdf0e10cSrcweir case BASEPROPERTY_IMAGEURL: 591*cdf0e10cSrcweir if ( !mbAdjustingGraphic && ImplHasProperty( BASEPROPERTY_GRAPHIC ) ) 592*cdf0e10cSrcweir { 593*cdf0e10cSrcweir mbAdjustingGraphic = true; 594*cdf0e10cSrcweir ::rtl::OUString sImageURL; 595*cdf0e10cSrcweir OSL_VERIFY( rValue >>= sImageURL ); 596*cdf0e10cSrcweir setDependentFastPropertyValue( BASEPROPERTY_GRAPHIC, uno::makeAny( getGraphicFromURL_nothrow( sImageURL ) ) ); 597*cdf0e10cSrcweir mbAdjustingGraphic = false; 598*cdf0e10cSrcweir } 599*cdf0e10cSrcweir break; 600*cdf0e10cSrcweir 601*cdf0e10cSrcweir case BASEPROPERTY_GRAPHIC: 602*cdf0e10cSrcweir if ( !mbAdjustingGraphic && ImplHasProperty( BASEPROPERTY_IMAGEURL ) ) 603*cdf0e10cSrcweir { 604*cdf0e10cSrcweir mbAdjustingGraphic = true; 605*cdf0e10cSrcweir setDependentFastPropertyValue( BASEPROPERTY_IMAGEURL, uno::makeAny( ::rtl::OUString() ) ); 606*cdf0e10cSrcweir mbAdjustingGraphic = false; 607*cdf0e10cSrcweir } 608*cdf0e10cSrcweir break; 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir case BASEPROPERTY_IMAGEALIGN: 611*cdf0e10cSrcweir if ( !mbAdjustingImagePosition && ImplHasProperty( BASEPROPERTY_IMAGEPOSITION ) ) 612*cdf0e10cSrcweir { 613*cdf0e10cSrcweir mbAdjustingImagePosition = true; 614*cdf0e10cSrcweir sal_Int16 nUNOValue = 0; 615*cdf0e10cSrcweir OSL_VERIFY( rValue >>= nUNOValue ); 616*cdf0e10cSrcweir setDependentFastPropertyValue( BASEPROPERTY_IMAGEPOSITION, uno::makeAny( getExtendedImagePosition( nUNOValue ) ) ); 617*cdf0e10cSrcweir mbAdjustingImagePosition = false; 618*cdf0e10cSrcweir } 619*cdf0e10cSrcweir break; 620*cdf0e10cSrcweir case BASEPROPERTY_IMAGEPOSITION: 621*cdf0e10cSrcweir if ( !mbAdjustingImagePosition && ImplHasProperty( BASEPROPERTY_IMAGEALIGN ) ) 622*cdf0e10cSrcweir { 623*cdf0e10cSrcweir mbAdjustingImagePosition = true; 624*cdf0e10cSrcweir sal_Int16 nUNOValue = 0; 625*cdf0e10cSrcweir OSL_VERIFY( rValue >>= nUNOValue ); 626*cdf0e10cSrcweir setDependentFastPropertyValue( BASEPROPERTY_IMAGEALIGN, uno::makeAny( getCompatibleImageAlign( translateImagePosition( nUNOValue ) ) ) ); 627*cdf0e10cSrcweir mbAdjustingImagePosition = false; 628*cdf0e10cSrcweir } 629*cdf0e10cSrcweir break; 630*cdf0e10cSrcweir } 631*cdf0e10cSrcweir } 632*cdf0e10cSrcweir catch( const ::com::sun::star::uno::Exception& ) 633*cdf0e10cSrcweir { 634*cdf0e10cSrcweir OSL_ENSURE( sal_False, "GraphicControlModel::setFastPropertyValue_NoBroadcast: caught an exception while aligning the ImagePosition/ImageAlign properties!" ); 635*cdf0e10cSrcweir mbAdjustingImagePosition = sal_False; 636*cdf0e10cSrcweir } 637*cdf0e10cSrcweir } 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir // ---------------------------------------------------- 640*cdf0e10cSrcweir // class UnoControlButtonModel 641*cdf0e10cSrcweir // ---------------------------------------------------- 642*cdf0e10cSrcweir UnoControlButtonModel::UnoControlButtonModel( const Reference< XMultiServiceFactory >& i_factory ) 643*cdf0e10cSrcweir :GraphicControlModel( i_factory ) 644*cdf0e10cSrcweir { 645*cdf0e10cSrcweir UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXButton ); 646*cdf0e10cSrcweir 647*cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 648*cdf0e10cSrcweir { 649*cdf0e10cSrcweir setFastPropertyValue_NoBroadcast( BASEPROPERTY_IMAGEPOSITION, ImplGetDefaultValue( BASEPROPERTY_IMAGEPOSITION ) ); 650*cdf0e10cSrcweir // this ensures that our ImagePosition is consistent with our ImageAlign property (since both 651*cdf0e10cSrcweir // defaults are not per se consistent), since both are coupled in setFastPropertyValue_NoBroadcast 652*cdf0e10cSrcweir } 653*cdf0e10cSrcweir osl_decrementInterlockedCount( &m_refCount ); 654*cdf0e10cSrcweir } 655*cdf0e10cSrcweir 656*cdf0e10cSrcweir ::rtl::OUString UnoControlButtonModel::getServiceName() throw(::com::sun::star::uno::RuntimeException) 657*cdf0e10cSrcweir { 658*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( szServiceName_UnoControlButtonModel ); 659*cdf0e10cSrcweir } 660*cdf0e10cSrcweir 661*cdf0e10cSrcweir uno::Any UnoControlButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const 662*cdf0e10cSrcweir { 663*cdf0e10cSrcweir switch ( nPropId ) 664*cdf0e10cSrcweir { 665*cdf0e10cSrcweir case BASEPROPERTY_DEFAULTCONTROL: 666*cdf0e10cSrcweir return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlButton ) ); 667*cdf0e10cSrcweir case BASEPROPERTY_TOGGLE: 668*cdf0e10cSrcweir return uno::makeAny( (sal_Bool)sal_False ); 669*cdf0e10cSrcweir case BASEPROPERTY_ALIGN: 670*cdf0e10cSrcweir return uno::makeAny( (sal_Int16)PROPERTY_ALIGN_CENTER ); 671*cdf0e10cSrcweir case BASEPROPERTY_FOCUSONCLICK: 672*cdf0e10cSrcweir return uno::makeAny( (sal_Bool)sal_True ); 673*cdf0e10cSrcweir } 674*cdf0e10cSrcweir 675*cdf0e10cSrcweir return GraphicControlModel::ImplGetDefaultValue( nPropId ); 676*cdf0e10cSrcweir } 677*cdf0e10cSrcweir 678*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& UnoControlButtonModel::getInfoHelper() 679*cdf0e10cSrcweir { 680*cdf0e10cSrcweir static UnoPropertyArrayHelper* pHelper = NULL; 681*cdf0e10cSrcweir if ( !pHelper ) 682*cdf0e10cSrcweir { 683*cdf0e10cSrcweir uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); 684*cdf0e10cSrcweir pHelper = new UnoPropertyArrayHelper( aIDs ); 685*cdf0e10cSrcweir } 686*cdf0e10cSrcweir return *pHelper; 687*cdf0e10cSrcweir } 688*cdf0e10cSrcweir 689*cdf0e10cSrcweir // beans::XMultiPropertySet 690*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > UnoControlButtonModel::getPropertySetInfo( ) throw(uno::RuntimeException) 691*cdf0e10cSrcweir { 692*cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 693*cdf0e10cSrcweir return xInfo; 694*cdf0e10cSrcweir } 695*cdf0e10cSrcweir 696*cdf0e10cSrcweir // ---------------------------------------------------- 697*cdf0e10cSrcweir // class UnoButtonControl 698*cdf0e10cSrcweir // ---------------------------------------------------- 699*cdf0e10cSrcweir UnoButtonControl::UnoButtonControl( const uno::Reference< lang::XMultiServiceFactory >& i_factory ) 700*cdf0e10cSrcweir :UnoButtonControl_Base( i_factory ) 701*cdf0e10cSrcweir ,maActionListeners( *this ) 702*cdf0e10cSrcweir ,maItemListeners( *this ) 703*cdf0e10cSrcweir { 704*cdf0e10cSrcweir maComponentInfos.nWidth = 50; 705*cdf0e10cSrcweir maComponentInfos.nHeight = 14; 706*cdf0e10cSrcweir } 707*cdf0e10cSrcweir 708*cdf0e10cSrcweir ::rtl::OUString UnoButtonControl::GetComponentServiceName() 709*cdf0e10cSrcweir { 710*cdf0e10cSrcweir ::rtl::OUString aName( ::rtl::OUString::createFromAscii( "pushbutton" ) ); 711*cdf0e10cSrcweir uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_PUSHBUTTONTYPE ) ); 712*cdf0e10cSrcweir sal_Int16 n = sal_Int16(); 713*cdf0e10cSrcweir if ( ( aVal >>= n ) && n ) 714*cdf0e10cSrcweir { 715*cdf0e10cSrcweir // Use PushButtonType later when available... 716*cdf0e10cSrcweir switch ( n ) 717*cdf0e10cSrcweir { 718*cdf0e10cSrcweir case 1 /*PushButtonType::OK*/: aName= ::rtl::OUString::createFromAscii( "okbutton" ); 719*cdf0e10cSrcweir break; 720*cdf0e10cSrcweir case 2 /*PushButtonType::CANCEL*/: aName= ::rtl::OUString::createFromAscii( "cancelbutton" ); 721*cdf0e10cSrcweir break; 722*cdf0e10cSrcweir case 3 /*PushButtonType::HELP*/: aName= ::rtl::OUString::createFromAscii( "helpbutton" ); 723*cdf0e10cSrcweir break; 724*cdf0e10cSrcweir default: 725*cdf0e10cSrcweir { 726*cdf0e10cSrcweir DBG_ERROR( "Unknown Button Type!" ); 727*cdf0e10cSrcweir } 728*cdf0e10cSrcweir } 729*cdf0e10cSrcweir } 730*cdf0e10cSrcweir return aName; 731*cdf0e10cSrcweir } 732*cdf0e10cSrcweir 733*cdf0e10cSrcweir void UnoButtonControl::dispose() throw(uno::RuntimeException) 734*cdf0e10cSrcweir { 735*cdf0e10cSrcweir lang::EventObject aEvt; 736*cdf0e10cSrcweir aEvt.Source = (::cppu::OWeakObject*)this; 737*cdf0e10cSrcweir maActionListeners.disposeAndClear( aEvt ); 738*cdf0e10cSrcweir maItemListeners.disposeAndClear( aEvt ); 739*cdf0e10cSrcweir UnoControlBase::dispose(); 740*cdf0e10cSrcweir } 741*cdf0e10cSrcweir 742*cdf0e10cSrcweir void UnoButtonControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException) 743*cdf0e10cSrcweir { 744*cdf0e10cSrcweir UnoControlBase::createPeer( rxToolkit, rParentPeer ); 745*cdf0e10cSrcweir 746*cdf0e10cSrcweir uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY ); 747*cdf0e10cSrcweir xButton->setActionCommand( maActionCommand ); 748*cdf0e10cSrcweir if ( maActionListeners.getLength() ) 749*cdf0e10cSrcweir xButton->addActionListener( &maActionListeners ); 750*cdf0e10cSrcweir 751*cdf0e10cSrcweir uno::Reference< XToggleButton > xPushButton( getPeer(), uno::UNO_QUERY ); 752*cdf0e10cSrcweir if ( xPushButton.is() ) 753*cdf0e10cSrcweir xPushButton->addItemListener( this ); 754*cdf0e10cSrcweir } 755*cdf0e10cSrcweir 756*cdf0e10cSrcweir void UnoButtonControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException) 757*cdf0e10cSrcweir { 758*cdf0e10cSrcweir maActionListeners.addInterface( l ); 759*cdf0e10cSrcweir if( getPeer().is() && maActionListeners.getLength() == 1 ) 760*cdf0e10cSrcweir { 761*cdf0e10cSrcweir uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY ); 762*cdf0e10cSrcweir xButton->addActionListener( &maActionListeners ); 763*cdf0e10cSrcweir } 764*cdf0e10cSrcweir } 765*cdf0e10cSrcweir 766*cdf0e10cSrcweir void UnoButtonControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException) 767*cdf0e10cSrcweir { 768*cdf0e10cSrcweir if( getPeer().is() && maActionListeners.getLength() == 1 ) 769*cdf0e10cSrcweir { 770*cdf0e10cSrcweir uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY ); 771*cdf0e10cSrcweir xButton->removeActionListener( &maActionListeners ); 772*cdf0e10cSrcweir } 773*cdf0e10cSrcweir maActionListeners.removeInterface( l ); 774*cdf0e10cSrcweir } 775*cdf0e10cSrcweir 776*cdf0e10cSrcweir void UnoButtonControl::addItemListener(const uno::Reference< awt::XItemListener > & l) throw(uno::RuntimeException) 777*cdf0e10cSrcweir { 778*cdf0e10cSrcweir maItemListeners.addInterface( l ); 779*cdf0e10cSrcweir } 780*cdf0e10cSrcweir 781*cdf0e10cSrcweir void UnoButtonControl::removeItemListener(const uno::Reference< awt::XItemListener > & l) throw(uno::RuntimeException) 782*cdf0e10cSrcweir { 783*cdf0e10cSrcweir maItemListeners.removeInterface( l ); 784*cdf0e10cSrcweir } 785*cdf0e10cSrcweir 786*cdf0e10cSrcweir void SAL_CALL UnoButtonControl::disposing( const lang::EventObject& Source ) throw (uno::RuntimeException) 787*cdf0e10cSrcweir { 788*cdf0e10cSrcweir UnoControlBase::disposing( Source ); 789*cdf0e10cSrcweir } 790*cdf0e10cSrcweir 791*cdf0e10cSrcweir void SAL_CALL UnoButtonControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw (uno::RuntimeException) 792*cdf0e10cSrcweir { 793*cdf0e10cSrcweir // forward to model 794*cdf0e10cSrcweir uno::Any aAny; 795*cdf0e10cSrcweir aAny <<= (sal_Int16)rEvent.Selected; 796*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_False ); 797*cdf0e10cSrcweir 798*cdf0e10cSrcweir // multiplex 799*cdf0e10cSrcweir ItemEvent aEvent( rEvent ); 800*cdf0e10cSrcweir aEvent.Source = *this; 801*cdf0e10cSrcweir maItemListeners.itemStateChanged( aEvent ); 802*cdf0e10cSrcweir } 803*cdf0e10cSrcweir 804*cdf0e10cSrcweir void UnoButtonControl::setLabel( const ::rtl::OUString& rLabel ) throw(uno::RuntimeException) 805*cdf0e10cSrcweir { 806*cdf0e10cSrcweir uno::Any aAny; 807*cdf0e10cSrcweir aAny <<= rLabel; 808*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True ); 809*cdf0e10cSrcweir } 810*cdf0e10cSrcweir 811*cdf0e10cSrcweir void UnoButtonControl::setActionCommand( const ::rtl::OUString& rCommand ) throw(uno::RuntimeException) 812*cdf0e10cSrcweir { 813*cdf0e10cSrcweir maActionCommand = rCommand; 814*cdf0e10cSrcweir if ( getPeer().is() ) 815*cdf0e10cSrcweir { 816*cdf0e10cSrcweir uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY ); 817*cdf0e10cSrcweir xButton->setActionCommand( rCommand ); 818*cdf0e10cSrcweir } 819*cdf0e10cSrcweir } 820*cdf0e10cSrcweir 821*cdf0e10cSrcweir awt::Size UnoButtonControl::getMinimumSize( ) throw(uno::RuntimeException) 822*cdf0e10cSrcweir { 823*cdf0e10cSrcweir return Impl_getMinimumSize(); 824*cdf0e10cSrcweir } 825*cdf0e10cSrcweir 826*cdf0e10cSrcweir awt::Size UnoButtonControl::getPreferredSize( ) throw(uno::RuntimeException) 827*cdf0e10cSrcweir { 828*cdf0e10cSrcweir return Impl_getPreferredSize(); 829*cdf0e10cSrcweir } 830*cdf0e10cSrcweir 831*cdf0e10cSrcweir awt::Size UnoButtonControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException) 832*cdf0e10cSrcweir { 833*cdf0e10cSrcweir return Impl_calcAdjustedSize( rNewSize ); 834*cdf0e10cSrcweir } 835*cdf0e10cSrcweir 836*cdf0e10cSrcweir // ---------------------------------------------------- 837*cdf0e10cSrcweir // class UnoControlImageControlModel 838*cdf0e10cSrcweir // ---------------------------------------------------- 839*cdf0e10cSrcweir UnoControlImageControlModel::UnoControlImageControlModel( const Reference< XMultiServiceFactory >& i_factory ) 840*cdf0e10cSrcweir :GraphicControlModel( i_factory ) 841*cdf0e10cSrcweir ,mbAdjustingImageScaleMode( false ) 842*cdf0e10cSrcweir { 843*cdf0e10cSrcweir UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXImageControl ); 844*cdf0e10cSrcweir } 845*cdf0e10cSrcweir 846*cdf0e10cSrcweir ::rtl::OUString UnoControlImageControlModel::getServiceName() throw(::com::sun::star::uno::RuntimeException) 847*cdf0e10cSrcweir { 848*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( szServiceName_UnoControlImageControlModel ); 849*cdf0e10cSrcweir } 850*cdf0e10cSrcweir 851*cdf0e10cSrcweir uno::Any UnoControlImageControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const 852*cdf0e10cSrcweir { 853*cdf0e10cSrcweir if ( nPropId == BASEPROPERTY_DEFAULTCONTROL ) 854*cdf0e10cSrcweir return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlImageControl ) ); 855*cdf0e10cSrcweir 856*cdf0e10cSrcweir if ( nPropId == BASEPROPERTY_IMAGE_SCALE_MODE ) 857*cdf0e10cSrcweir return makeAny( awt::ImageScaleMode::Anisotropic ); 858*cdf0e10cSrcweir 859*cdf0e10cSrcweir return GraphicControlModel::ImplGetDefaultValue( nPropId ); 860*cdf0e10cSrcweir } 861*cdf0e10cSrcweir 862*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& UnoControlImageControlModel::getInfoHelper() 863*cdf0e10cSrcweir { 864*cdf0e10cSrcweir static UnoPropertyArrayHelper* pHelper = NULL; 865*cdf0e10cSrcweir if ( !pHelper ) 866*cdf0e10cSrcweir { 867*cdf0e10cSrcweir uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); 868*cdf0e10cSrcweir pHelper = new UnoPropertyArrayHelper( aIDs ); 869*cdf0e10cSrcweir } 870*cdf0e10cSrcweir return *pHelper; 871*cdf0e10cSrcweir } 872*cdf0e10cSrcweir 873*cdf0e10cSrcweir // beans::XMultiPropertySet 874*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > UnoControlImageControlModel::getPropertySetInfo( ) throw(uno::RuntimeException) 875*cdf0e10cSrcweir { 876*cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 877*cdf0e10cSrcweir return xInfo; 878*cdf0e10cSrcweir } 879*cdf0e10cSrcweir 880*cdf0e10cSrcweir void SAL_CALL UnoControlImageControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::uno::Exception) 881*cdf0e10cSrcweir { 882*cdf0e10cSrcweir GraphicControlModel::setFastPropertyValue_NoBroadcast( _nHandle, _rValue ); 883*cdf0e10cSrcweir 884*cdf0e10cSrcweir // ScaleImage is an older (and less powerful) version of ScaleMode, but keep both in sync as far as possible 885*cdf0e10cSrcweir try 886*cdf0e10cSrcweir { 887*cdf0e10cSrcweir switch ( _nHandle ) 888*cdf0e10cSrcweir { 889*cdf0e10cSrcweir case BASEPROPERTY_IMAGE_SCALE_MODE: 890*cdf0e10cSrcweir if ( !mbAdjustingImageScaleMode && ImplHasProperty( BASEPROPERTY_SCALEIMAGE ) ) 891*cdf0e10cSrcweir { 892*cdf0e10cSrcweir mbAdjustingImageScaleMode = true; 893*cdf0e10cSrcweir sal_Int16 nScaleMode( awt::ImageScaleMode::Anisotropic ); 894*cdf0e10cSrcweir OSL_VERIFY( _rValue >>= nScaleMode ); 895*cdf0e10cSrcweir setDependentFastPropertyValue( BASEPROPERTY_SCALEIMAGE, uno::makeAny( sal_Bool( nScaleMode != awt::ImageScaleMode::None ) ) ); 896*cdf0e10cSrcweir mbAdjustingImageScaleMode = false; 897*cdf0e10cSrcweir } 898*cdf0e10cSrcweir break; 899*cdf0e10cSrcweir case BASEPROPERTY_SCALEIMAGE: 900*cdf0e10cSrcweir if ( !mbAdjustingImageScaleMode && ImplHasProperty( BASEPROPERTY_IMAGE_SCALE_MODE ) ) 901*cdf0e10cSrcweir { 902*cdf0e10cSrcweir mbAdjustingImageScaleMode = true; 903*cdf0e10cSrcweir sal_Bool bScale = sal_True; 904*cdf0e10cSrcweir OSL_VERIFY( _rValue >>= bScale ); 905*cdf0e10cSrcweir setDependentFastPropertyValue( BASEPROPERTY_IMAGE_SCALE_MODE, uno::makeAny( bScale ? awt::ImageScaleMode::Anisotropic : awt::ImageScaleMode::None ) ); 906*cdf0e10cSrcweir mbAdjustingImageScaleMode = false; 907*cdf0e10cSrcweir } 908*cdf0e10cSrcweir break; 909*cdf0e10cSrcweir } 910*cdf0e10cSrcweir } 911*cdf0e10cSrcweir catch( const Exception& ) 912*cdf0e10cSrcweir { 913*cdf0e10cSrcweir mbAdjustingImageScaleMode = false; 914*cdf0e10cSrcweir throw; 915*cdf0e10cSrcweir } 916*cdf0e10cSrcweir } 917*cdf0e10cSrcweir 918*cdf0e10cSrcweir // ---------------------------------------------------- 919*cdf0e10cSrcweir // class UnoImageControlControl 920*cdf0e10cSrcweir // ---------------------------------------------------- 921*cdf0e10cSrcweir UnoImageControlControl::UnoImageControlControl( const Reference< XMultiServiceFactory >& i_factory ) 922*cdf0e10cSrcweir :UnoImageControlControl_Base( i_factory ) 923*cdf0e10cSrcweir ,maActionListeners( *this ) 924*cdf0e10cSrcweir { 925*cdf0e10cSrcweir // Woher die Defaults nehmen? 926*cdf0e10cSrcweir maComponentInfos.nWidth = 100; 927*cdf0e10cSrcweir maComponentInfos.nHeight = 100; 928*cdf0e10cSrcweir } 929*cdf0e10cSrcweir 930*cdf0e10cSrcweir ::rtl::OUString UnoImageControlControl::GetComponentServiceName() 931*cdf0e10cSrcweir { 932*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "fixedimage" ); 933*cdf0e10cSrcweir } 934*cdf0e10cSrcweir 935*cdf0e10cSrcweir void UnoImageControlControl::dispose() throw(uno::RuntimeException) 936*cdf0e10cSrcweir { 937*cdf0e10cSrcweir lang::EventObject aEvt; 938*cdf0e10cSrcweir aEvt.Source = (::cppu::OWeakObject*)this; 939*cdf0e10cSrcweir maActionListeners.disposeAndClear( aEvt ); 940*cdf0e10cSrcweir UnoControl::dispose(); 941*cdf0e10cSrcweir } 942*cdf0e10cSrcweir 943*cdf0e10cSrcweir sal_Bool UnoImageControlControl::isTransparent() throw(uno::RuntimeException) 944*cdf0e10cSrcweir { 945*cdf0e10cSrcweir return sal_True; 946*cdf0e10cSrcweir } 947*cdf0e10cSrcweir 948*cdf0e10cSrcweir awt::Size UnoImageControlControl::getMinimumSize( ) throw(uno::RuntimeException) 949*cdf0e10cSrcweir { 950*cdf0e10cSrcweir return Impl_getMinimumSize(); 951*cdf0e10cSrcweir } 952*cdf0e10cSrcweir 953*cdf0e10cSrcweir awt::Size UnoImageControlControl::getPreferredSize( ) throw(uno::RuntimeException) 954*cdf0e10cSrcweir { 955*cdf0e10cSrcweir return Impl_getPreferredSize(); 956*cdf0e10cSrcweir } 957*cdf0e10cSrcweir 958*cdf0e10cSrcweir awt::Size UnoImageControlControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException) 959*cdf0e10cSrcweir { 960*cdf0e10cSrcweir return Impl_calcAdjustedSize( rNewSize ); 961*cdf0e10cSrcweir } 962*cdf0e10cSrcweir 963*cdf0e10cSrcweir // ---------------------------------------------------- 964*cdf0e10cSrcweir // class UnoControlRadioButtonModel 965*cdf0e10cSrcweir // ---------------------------------------------------- 966*cdf0e10cSrcweir UnoControlRadioButtonModel::UnoControlRadioButtonModel( const Reference< XMultiServiceFactory >& i_factory ) 967*cdf0e10cSrcweir :GraphicControlModel( i_factory ) 968*cdf0e10cSrcweir { 969*cdf0e10cSrcweir UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXRadioButton ); 970*cdf0e10cSrcweir } 971*cdf0e10cSrcweir 972*cdf0e10cSrcweir ::rtl::OUString UnoControlRadioButtonModel::getServiceName() throw(::com::sun::star::uno::RuntimeException) 973*cdf0e10cSrcweir { 974*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( szServiceName_UnoControlRadioButtonModel ); 975*cdf0e10cSrcweir } 976*cdf0e10cSrcweir 977*cdf0e10cSrcweir uno::Any UnoControlRadioButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const 978*cdf0e10cSrcweir { 979*cdf0e10cSrcweir switch ( nPropId ) 980*cdf0e10cSrcweir { 981*cdf0e10cSrcweir case BASEPROPERTY_DEFAULTCONTROL: 982*cdf0e10cSrcweir return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlRadioButton ) ); 983*cdf0e10cSrcweir 984*cdf0e10cSrcweir case BASEPROPERTY_VISUALEFFECT: 985*cdf0e10cSrcweir return uno::makeAny( (sal_Int16)awt::VisualEffect::LOOK3D ); 986*cdf0e10cSrcweir } 987*cdf0e10cSrcweir 988*cdf0e10cSrcweir return GraphicControlModel::ImplGetDefaultValue( nPropId ); 989*cdf0e10cSrcweir } 990*cdf0e10cSrcweir 991*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& UnoControlRadioButtonModel::getInfoHelper() 992*cdf0e10cSrcweir { 993*cdf0e10cSrcweir static UnoPropertyArrayHelper* pHelper = NULL; 994*cdf0e10cSrcweir if ( !pHelper ) 995*cdf0e10cSrcweir { 996*cdf0e10cSrcweir uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); 997*cdf0e10cSrcweir pHelper = new UnoPropertyArrayHelper( aIDs ); 998*cdf0e10cSrcweir } 999*cdf0e10cSrcweir return *pHelper; 1000*cdf0e10cSrcweir } 1001*cdf0e10cSrcweir 1002*cdf0e10cSrcweir // beans::XMultiPropertySet 1003*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > UnoControlRadioButtonModel::getPropertySetInfo( ) throw(uno::RuntimeException) 1004*cdf0e10cSrcweir { 1005*cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 1006*cdf0e10cSrcweir return xInfo; 1007*cdf0e10cSrcweir } 1008*cdf0e10cSrcweir 1009*cdf0e10cSrcweir 1010*cdf0e10cSrcweir 1011*cdf0e10cSrcweir // ---------------------------------------------------- 1012*cdf0e10cSrcweir // class UnoRadioButtonControl 1013*cdf0e10cSrcweir // ---------------------------------------------------- 1014*cdf0e10cSrcweir UnoRadioButtonControl::UnoRadioButtonControl( const Reference< XMultiServiceFactory >& i_factory ) 1015*cdf0e10cSrcweir :UnoRadioButtonControl_Base( i_factory ) 1016*cdf0e10cSrcweir ,maItemListeners( *this ) 1017*cdf0e10cSrcweir ,maActionListeners( *this ) 1018*cdf0e10cSrcweir { 1019*cdf0e10cSrcweir maComponentInfos.nWidth = 100; 1020*cdf0e10cSrcweir maComponentInfos.nHeight = 12; 1021*cdf0e10cSrcweir } 1022*cdf0e10cSrcweir 1023*cdf0e10cSrcweir ::rtl::OUString UnoRadioButtonControl::GetComponentServiceName() 1024*cdf0e10cSrcweir { 1025*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "radiobutton" ); 1026*cdf0e10cSrcweir } 1027*cdf0e10cSrcweir 1028*cdf0e10cSrcweir void UnoRadioButtonControl::dispose() throw(uno::RuntimeException) 1029*cdf0e10cSrcweir { 1030*cdf0e10cSrcweir lang::EventObject aEvt; 1031*cdf0e10cSrcweir aEvt.Source = (::cppu::OWeakObject*)this; 1032*cdf0e10cSrcweir maItemListeners.disposeAndClear( aEvt ); 1033*cdf0e10cSrcweir UnoControlBase::dispose(); 1034*cdf0e10cSrcweir } 1035*cdf0e10cSrcweir 1036*cdf0e10cSrcweir 1037*cdf0e10cSrcweir sal_Bool UnoRadioButtonControl::isTransparent() throw(uno::RuntimeException) 1038*cdf0e10cSrcweir { 1039*cdf0e10cSrcweir return sal_True; 1040*cdf0e10cSrcweir } 1041*cdf0e10cSrcweir 1042*cdf0e10cSrcweir void UnoRadioButtonControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException) 1043*cdf0e10cSrcweir { 1044*cdf0e10cSrcweir UnoControlBase::createPeer( rxToolkit, rParentPeer ); 1045*cdf0e10cSrcweir 1046*cdf0e10cSrcweir uno::Reference < awt::XRadioButton > xRadioButton( getPeer(), uno::UNO_QUERY ); 1047*cdf0e10cSrcweir xRadioButton->addItemListener( this ); 1048*cdf0e10cSrcweir 1049*cdf0e10cSrcweir uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY ); 1050*cdf0e10cSrcweir xButton->setActionCommand( maActionCommand ); 1051*cdf0e10cSrcweir if ( maActionListeners.getLength() ) 1052*cdf0e10cSrcweir xButton->addActionListener( &maActionListeners ); 1053*cdf0e10cSrcweir 1054*cdf0e10cSrcweir // as default, set the "AutoToggle" to true 1055*cdf0e10cSrcweir // (it is set to false in VCLXToolkit::ImplCreateWindow because of #87254#, but we want to 1056*cdf0e10cSrcweir // have it enabled by default because of 85071) 1057*cdf0e10cSrcweir uno::Reference< awt::XVclWindowPeer > xVclWindowPeer( getPeer(), uno::UNO_QUERY ); 1058*cdf0e10cSrcweir if ( xVclWindowPeer.is() ) 1059*cdf0e10cSrcweir xVclWindowPeer->setProperty( GetPropertyName( BASEPROPERTY_AUTOTOGGLE ), ::cppu::bool2any( sal_True ) ); 1060*cdf0e10cSrcweir } 1061*cdf0e10cSrcweir 1062*cdf0e10cSrcweir void UnoRadioButtonControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException) 1063*cdf0e10cSrcweir { 1064*cdf0e10cSrcweir maItemListeners.addInterface( l ); 1065*cdf0e10cSrcweir } 1066*cdf0e10cSrcweir 1067*cdf0e10cSrcweir void UnoRadioButtonControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException) 1068*cdf0e10cSrcweir { 1069*cdf0e10cSrcweir maItemListeners.removeInterface( l ); 1070*cdf0e10cSrcweir } 1071*cdf0e10cSrcweir 1072*cdf0e10cSrcweir void UnoRadioButtonControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException) 1073*cdf0e10cSrcweir { 1074*cdf0e10cSrcweir maActionListeners.addInterface( l ); 1075*cdf0e10cSrcweir if( getPeer().is() && maActionListeners.getLength() == 1 ) 1076*cdf0e10cSrcweir { 1077*cdf0e10cSrcweir uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY ); 1078*cdf0e10cSrcweir xButton->addActionListener( &maActionListeners ); 1079*cdf0e10cSrcweir } 1080*cdf0e10cSrcweir } 1081*cdf0e10cSrcweir 1082*cdf0e10cSrcweir void UnoRadioButtonControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException) 1083*cdf0e10cSrcweir { 1084*cdf0e10cSrcweir if( getPeer().is() && maActionListeners.getLength() == 1 ) 1085*cdf0e10cSrcweir { 1086*cdf0e10cSrcweir uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY ); 1087*cdf0e10cSrcweir xButton->removeActionListener( &maActionListeners ); 1088*cdf0e10cSrcweir } 1089*cdf0e10cSrcweir maActionListeners.removeInterface( l ); 1090*cdf0e10cSrcweir } 1091*cdf0e10cSrcweir 1092*cdf0e10cSrcweir void UnoRadioButtonControl::setLabel( const ::rtl::OUString& rLabel ) throw(uno::RuntimeException) 1093*cdf0e10cSrcweir { 1094*cdf0e10cSrcweir uno::Any aAny; 1095*cdf0e10cSrcweir aAny <<= rLabel; 1096*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True ); 1097*cdf0e10cSrcweir } 1098*cdf0e10cSrcweir 1099*cdf0e10cSrcweir void UnoRadioButtonControl::setActionCommand( const ::rtl::OUString& rCommand ) throw(uno::RuntimeException) 1100*cdf0e10cSrcweir { 1101*cdf0e10cSrcweir maActionCommand = rCommand; 1102*cdf0e10cSrcweir if ( getPeer().is() ) 1103*cdf0e10cSrcweir { 1104*cdf0e10cSrcweir uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY ); 1105*cdf0e10cSrcweir xButton->setActionCommand( rCommand ); 1106*cdf0e10cSrcweir } 1107*cdf0e10cSrcweir } 1108*cdf0e10cSrcweir 1109*cdf0e10cSrcweir void UnoRadioButtonControl::setState( sal_Bool bOn ) throw(uno::RuntimeException) 1110*cdf0e10cSrcweir { 1111*cdf0e10cSrcweir sal_Int16 nState = bOn ? 1 : 0; 1112*cdf0e10cSrcweir uno::Any aAny; 1113*cdf0e10cSrcweir aAny <<= nState; 1114*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_True ); 1115*cdf0e10cSrcweir } 1116*cdf0e10cSrcweir 1117*cdf0e10cSrcweir sal_Bool UnoRadioButtonControl::getState() throw(uno::RuntimeException) 1118*cdf0e10cSrcweir { 1119*cdf0e10cSrcweir sal_Int16 nState = 0; 1120*cdf0e10cSrcweir uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ) ); 1121*cdf0e10cSrcweir aVal >>= nState; 1122*cdf0e10cSrcweir return nState ? sal_True : sal_False; 1123*cdf0e10cSrcweir } 1124*cdf0e10cSrcweir 1125*cdf0e10cSrcweir void UnoRadioButtonControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException) 1126*cdf0e10cSrcweir { 1127*cdf0e10cSrcweir uno::Any aAny; 1128*cdf0e10cSrcweir aAny <<= (sal_Int16)rEvent.Selected; 1129*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_False ); 1130*cdf0e10cSrcweir 1131*cdf0e10cSrcweir // compatibility: 1132*cdf0e10cSrcweir // in OOo 1.0.x, when the user clicked a radio button in a group of buttons, this resulted 1133*cdf0e10cSrcweir // in _one_ itemStateChanged call for exactly the radio button which's state changed from 1134*cdf0e10cSrcweir // "0" to "1". 1135*cdf0e10cSrcweir // Nowadays, since the listener handling changed a lot towards 1.1 (the VCLXWindow reacts on more 1136*cdf0e10cSrcweir // basic events from the VCL-windows, not anymore on the Link-based events like in 1.0.x), this 1137*cdf0e10cSrcweir // isn't the case anymore: For instance, this method here gets called for the radio button 1138*cdf0e10cSrcweir // which is being implicitily _de_selected, too. This is pretty bad for compatibility. 1139*cdf0e10cSrcweir // Thus, we suppress all events with a new state other than "1". This is unlogical, and weird, when looking 1140*cdf0e10cSrcweir // from a pure API perspective, but it's _compatible_ with older product versions, and this is 1141*cdf0e10cSrcweir // all which matters here. 1142*cdf0e10cSrcweir // #i14703# - 2003-05-23 - fs@openoffice.org 1143*cdf0e10cSrcweir if ( 1 == rEvent.Selected ) 1144*cdf0e10cSrcweir { 1145*cdf0e10cSrcweir if ( maItemListeners.getLength() ) 1146*cdf0e10cSrcweir maItemListeners.itemStateChanged( rEvent ); 1147*cdf0e10cSrcweir } 1148*cdf0e10cSrcweir // note that speaking stricly, this is wrong: When in 1.0.x, the user would have de-selected 1149*cdf0e10cSrcweir // a radio button _without_ selecing another one, this would have caused a notification. 1150*cdf0e10cSrcweir // With the change done here, this today won't cause a notification anymore. 1151*cdf0e10cSrcweir // 1152*cdf0e10cSrcweir // Fortunately, it's not possible for the user to de-select a radio button without selecting another on, 1153*cdf0e10cSrcweir // at least not via the regular UI. It _would_ be possible via the Accessibility API, which 1154*cdf0e10cSrcweir // counts as "user input", too. But in 1.0.x, there was no Accessibility API, so there is nothing 1155*cdf0e10cSrcweir // to be inconsistent with. 1156*cdf0e10cSrcweir } 1157*cdf0e10cSrcweir 1158*cdf0e10cSrcweir awt::Size UnoRadioButtonControl::getMinimumSize( ) throw(uno::RuntimeException) 1159*cdf0e10cSrcweir { 1160*cdf0e10cSrcweir return Impl_getMinimumSize(); 1161*cdf0e10cSrcweir } 1162*cdf0e10cSrcweir 1163*cdf0e10cSrcweir awt::Size UnoRadioButtonControl::getPreferredSize( ) throw(uno::RuntimeException) 1164*cdf0e10cSrcweir { 1165*cdf0e10cSrcweir return Impl_getPreferredSize(); 1166*cdf0e10cSrcweir } 1167*cdf0e10cSrcweir 1168*cdf0e10cSrcweir awt::Size UnoRadioButtonControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException) 1169*cdf0e10cSrcweir { 1170*cdf0e10cSrcweir return Impl_calcAdjustedSize( rNewSize ); 1171*cdf0e10cSrcweir } 1172*cdf0e10cSrcweir 1173*cdf0e10cSrcweir // ---------------------------------------------------- 1174*cdf0e10cSrcweir // class UnoControlCheckBoxModel 1175*cdf0e10cSrcweir // ---------------------------------------------------- 1176*cdf0e10cSrcweir UnoControlCheckBoxModel::UnoControlCheckBoxModel( const Reference< XMultiServiceFactory >& i_factory ) 1177*cdf0e10cSrcweir :GraphicControlModel( i_factory ) 1178*cdf0e10cSrcweir { 1179*cdf0e10cSrcweir UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCheckBox ); 1180*cdf0e10cSrcweir } 1181*cdf0e10cSrcweir 1182*cdf0e10cSrcweir ::rtl::OUString UnoControlCheckBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException) 1183*cdf0e10cSrcweir { 1184*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( szServiceName_UnoControlCheckBoxModel ); 1185*cdf0e10cSrcweir } 1186*cdf0e10cSrcweir 1187*cdf0e10cSrcweir uno::Any UnoControlCheckBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const 1188*cdf0e10cSrcweir { 1189*cdf0e10cSrcweir switch ( nPropId ) 1190*cdf0e10cSrcweir { 1191*cdf0e10cSrcweir case BASEPROPERTY_DEFAULTCONTROL: 1192*cdf0e10cSrcweir return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlCheckBox ) ); 1193*cdf0e10cSrcweir 1194*cdf0e10cSrcweir case BASEPROPERTY_VISUALEFFECT: 1195*cdf0e10cSrcweir return uno::makeAny( (sal_Int16)awt::VisualEffect::LOOK3D ); 1196*cdf0e10cSrcweir } 1197*cdf0e10cSrcweir 1198*cdf0e10cSrcweir return GraphicControlModel::ImplGetDefaultValue( nPropId ); 1199*cdf0e10cSrcweir } 1200*cdf0e10cSrcweir 1201*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& UnoControlCheckBoxModel::getInfoHelper() 1202*cdf0e10cSrcweir { 1203*cdf0e10cSrcweir static UnoPropertyArrayHelper* pHelper = NULL; 1204*cdf0e10cSrcweir if ( !pHelper ) 1205*cdf0e10cSrcweir { 1206*cdf0e10cSrcweir uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); 1207*cdf0e10cSrcweir pHelper = new UnoPropertyArrayHelper( aIDs ); 1208*cdf0e10cSrcweir } 1209*cdf0e10cSrcweir return *pHelper; 1210*cdf0e10cSrcweir } 1211*cdf0e10cSrcweir 1212*cdf0e10cSrcweir // beans::XMultiPropertySet 1213*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > UnoControlCheckBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException) 1214*cdf0e10cSrcweir { 1215*cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 1216*cdf0e10cSrcweir return xInfo; 1217*cdf0e10cSrcweir } 1218*cdf0e10cSrcweir 1219*cdf0e10cSrcweir 1220*cdf0e10cSrcweir 1221*cdf0e10cSrcweir // ---------------------------------------------------- 1222*cdf0e10cSrcweir // class UnoCheckBoxControl 1223*cdf0e10cSrcweir // ---------------------------------------------------- 1224*cdf0e10cSrcweir UnoCheckBoxControl::UnoCheckBoxControl( const uno::Reference< lang::XMultiServiceFactory >& i_factory ) 1225*cdf0e10cSrcweir :UnoCheckBoxControl_Base( i_factory ) 1226*cdf0e10cSrcweir ,maItemListeners( *this ), maActionListeners( *this ) 1227*cdf0e10cSrcweir { 1228*cdf0e10cSrcweir maComponentInfos.nWidth = 100; 1229*cdf0e10cSrcweir maComponentInfos.nHeight = 12; 1230*cdf0e10cSrcweir } 1231*cdf0e10cSrcweir 1232*cdf0e10cSrcweir ::rtl::OUString UnoCheckBoxControl::GetComponentServiceName() 1233*cdf0e10cSrcweir { 1234*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "checkbox" ); 1235*cdf0e10cSrcweir } 1236*cdf0e10cSrcweir 1237*cdf0e10cSrcweir void UnoCheckBoxControl::dispose() throw(uno::RuntimeException) 1238*cdf0e10cSrcweir { 1239*cdf0e10cSrcweir lang::EventObject aEvt; 1240*cdf0e10cSrcweir aEvt.Source = (::cppu::OWeakObject*)this; 1241*cdf0e10cSrcweir maItemListeners.disposeAndClear( aEvt ); 1242*cdf0e10cSrcweir UnoControlBase::dispose(); 1243*cdf0e10cSrcweir } 1244*cdf0e10cSrcweir 1245*cdf0e10cSrcweir sal_Bool UnoCheckBoxControl::isTransparent() throw(uno::RuntimeException) 1246*cdf0e10cSrcweir { 1247*cdf0e10cSrcweir return sal_True; 1248*cdf0e10cSrcweir } 1249*cdf0e10cSrcweir 1250*cdf0e10cSrcweir void UnoCheckBoxControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException) 1251*cdf0e10cSrcweir { 1252*cdf0e10cSrcweir UnoControlBase::createPeer( rxToolkit, rParentPeer ); 1253*cdf0e10cSrcweir 1254*cdf0e10cSrcweir uno::Reference < awt::XCheckBox > xCheckBox( getPeer(), uno::UNO_QUERY ); 1255*cdf0e10cSrcweir xCheckBox->addItemListener( this ); 1256*cdf0e10cSrcweir 1257*cdf0e10cSrcweir uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY ); 1258*cdf0e10cSrcweir xButton->setActionCommand( maActionCommand ); 1259*cdf0e10cSrcweir if ( maActionListeners.getLength() ) 1260*cdf0e10cSrcweir xButton->addActionListener( &maActionListeners ); 1261*cdf0e10cSrcweir } 1262*cdf0e10cSrcweir 1263*cdf0e10cSrcweir void UnoCheckBoxControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException) 1264*cdf0e10cSrcweir { 1265*cdf0e10cSrcweir maItemListeners.addInterface( l ); 1266*cdf0e10cSrcweir } 1267*cdf0e10cSrcweir 1268*cdf0e10cSrcweir void UnoCheckBoxControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException) 1269*cdf0e10cSrcweir { 1270*cdf0e10cSrcweir maItemListeners.removeInterface( l ); 1271*cdf0e10cSrcweir } 1272*cdf0e10cSrcweir 1273*cdf0e10cSrcweir void UnoCheckBoxControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException) 1274*cdf0e10cSrcweir { 1275*cdf0e10cSrcweir maActionListeners.addInterface( l ); 1276*cdf0e10cSrcweir if( getPeer().is() && maActionListeners.getLength() == 1 ) 1277*cdf0e10cSrcweir { 1278*cdf0e10cSrcweir uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY ); 1279*cdf0e10cSrcweir xButton->addActionListener( &maActionListeners ); 1280*cdf0e10cSrcweir } 1281*cdf0e10cSrcweir } 1282*cdf0e10cSrcweir 1283*cdf0e10cSrcweir void UnoCheckBoxControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException) 1284*cdf0e10cSrcweir { 1285*cdf0e10cSrcweir if( getPeer().is() && maActionListeners.getLength() == 1 ) 1286*cdf0e10cSrcweir { 1287*cdf0e10cSrcweir uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY ); 1288*cdf0e10cSrcweir xButton->removeActionListener( &maActionListeners ); 1289*cdf0e10cSrcweir } 1290*cdf0e10cSrcweir maActionListeners.removeInterface( l ); 1291*cdf0e10cSrcweir } 1292*cdf0e10cSrcweir 1293*cdf0e10cSrcweir void UnoCheckBoxControl::setActionCommand( const ::rtl::OUString& rCommand ) throw(uno::RuntimeException) 1294*cdf0e10cSrcweir { 1295*cdf0e10cSrcweir maActionCommand = rCommand; 1296*cdf0e10cSrcweir if ( getPeer().is() ) 1297*cdf0e10cSrcweir { 1298*cdf0e10cSrcweir uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY ); 1299*cdf0e10cSrcweir xButton->setActionCommand( rCommand ); 1300*cdf0e10cSrcweir } 1301*cdf0e10cSrcweir } 1302*cdf0e10cSrcweir 1303*cdf0e10cSrcweir 1304*cdf0e10cSrcweir void UnoCheckBoxControl::setLabel( const ::rtl::OUString& rLabel ) throw(uno::RuntimeException) 1305*cdf0e10cSrcweir { 1306*cdf0e10cSrcweir uno::Any aAny; 1307*cdf0e10cSrcweir aAny <<= rLabel; 1308*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True ); 1309*cdf0e10cSrcweir } 1310*cdf0e10cSrcweir 1311*cdf0e10cSrcweir void UnoCheckBoxControl::setState( short n ) throw(uno::RuntimeException) 1312*cdf0e10cSrcweir { 1313*cdf0e10cSrcweir uno::Any aAny; 1314*cdf0e10cSrcweir aAny <<= (sal_Int16)n; 1315*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_True ); 1316*cdf0e10cSrcweir } 1317*cdf0e10cSrcweir 1318*cdf0e10cSrcweir short UnoCheckBoxControl::getState() throw(uno::RuntimeException) 1319*cdf0e10cSrcweir { 1320*cdf0e10cSrcweir short nState = 0; 1321*cdf0e10cSrcweir uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ) ); 1322*cdf0e10cSrcweir aVal >>= nState; 1323*cdf0e10cSrcweir return nState; 1324*cdf0e10cSrcweir } 1325*cdf0e10cSrcweir 1326*cdf0e10cSrcweir void UnoCheckBoxControl::enableTriState( sal_Bool b ) throw(uno::RuntimeException) 1327*cdf0e10cSrcweir { 1328*cdf0e10cSrcweir uno::Any aAny; 1329*cdf0e10cSrcweir aAny <<= b; 1330*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TRISTATE ), aAny, sal_True ); 1331*cdf0e10cSrcweir } 1332*cdf0e10cSrcweir 1333*cdf0e10cSrcweir void UnoCheckBoxControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException) 1334*cdf0e10cSrcweir { 1335*cdf0e10cSrcweir uno::Any aAny; 1336*cdf0e10cSrcweir aAny <<= (sal_Int16)rEvent.Selected; 1337*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_False ); 1338*cdf0e10cSrcweir 1339*cdf0e10cSrcweir if ( maItemListeners.getLength() ) 1340*cdf0e10cSrcweir maItemListeners.itemStateChanged( rEvent ); 1341*cdf0e10cSrcweir } 1342*cdf0e10cSrcweir 1343*cdf0e10cSrcweir awt::Size UnoCheckBoxControl::getMinimumSize( ) throw(uno::RuntimeException) 1344*cdf0e10cSrcweir { 1345*cdf0e10cSrcweir return Impl_getMinimumSize(); 1346*cdf0e10cSrcweir } 1347*cdf0e10cSrcweir 1348*cdf0e10cSrcweir awt::Size UnoCheckBoxControl::getPreferredSize( ) throw(uno::RuntimeException) 1349*cdf0e10cSrcweir { 1350*cdf0e10cSrcweir return Impl_getPreferredSize(); 1351*cdf0e10cSrcweir } 1352*cdf0e10cSrcweir 1353*cdf0e10cSrcweir awt::Size UnoCheckBoxControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException) 1354*cdf0e10cSrcweir { 1355*cdf0e10cSrcweir return Impl_calcAdjustedSize( rNewSize ); 1356*cdf0e10cSrcweir } 1357*cdf0e10cSrcweir 1358*cdf0e10cSrcweir // ---------------------------------------------------- 1359*cdf0e10cSrcweir // class UnoControlFixedHyperlinkModel 1360*cdf0e10cSrcweir // ---------------------------------------------------- 1361*cdf0e10cSrcweir UnoControlFixedHyperlinkModel::UnoControlFixedHyperlinkModel( const Reference< XMultiServiceFactory >& i_factory ) 1362*cdf0e10cSrcweir :UnoControlModel( i_factory ) 1363*cdf0e10cSrcweir { 1364*cdf0e10cSrcweir UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedHyperlink ); 1365*cdf0e10cSrcweir } 1366*cdf0e10cSrcweir 1367*cdf0e10cSrcweir ::rtl::OUString UnoControlFixedHyperlinkModel::getServiceName() throw(::com::sun::star::uno::RuntimeException) 1368*cdf0e10cSrcweir { 1369*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedHyperlinkModel ); 1370*cdf0e10cSrcweir } 1371*cdf0e10cSrcweir 1372*cdf0e10cSrcweir uno::Any UnoControlFixedHyperlinkModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const 1373*cdf0e10cSrcweir { 1374*cdf0e10cSrcweir if ( nPropId == BASEPROPERTY_DEFAULTCONTROL ) 1375*cdf0e10cSrcweir { 1376*cdf0e10cSrcweir uno::Any aAny; 1377*cdf0e10cSrcweir aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedHyperlink ); 1378*cdf0e10cSrcweir return aAny; 1379*cdf0e10cSrcweir } 1380*cdf0e10cSrcweir else if ( nPropId == BASEPROPERTY_BORDER ) 1381*cdf0e10cSrcweir { 1382*cdf0e10cSrcweir uno::Any aAny; 1383*cdf0e10cSrcweir aAny <<= (sal_Int16)0; 1384*cdf0e10cSrcweir return aAny; 1385*cdf0e10cSrcweir } 1386*cdf0e10cSrcweir else if ( nPropId == BASEPROPERTY_URL ) 1387*cdf0e10cSrcweir { 1388*cdf0e10cSrcweir uno::Any aAny; 1389*cdf0e10cSrcweir aAny <<= ::rtl::OUString(); 1390*cdf0e10cSrcweir return aAny; 1391*cdf0e10cSrcweir } 1392*cdf0e10cSrcweir 1393*cdf0e10cSrcweir return UnoControlModel::ImplGetDefaultValue( nPropId ); 1394*cdf0e10cSrcweir } 1395*cdf0e10cSrcweir 1396*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& UnoControlFixedHyperlinkModel::getInfoHelper() 1397*cdf0e10cSrcweir { 1398*cdf0e10cSrcweir static UnoPropertyArrayHelper* pHelper = NULL; 1399*cdf0e10cSrcweir if ( !pHelper ) 1400*cdf0e10cSrcweir { 1401*cdf0e10cSrcweir uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); 1402*cdf0e10cSrcweir pHelper = new UnoPropertyArrayHelper( aIDs ); 1403*cdf0e10cSrcweir } 1404*cdf0e10cSrcweir return *pHelper; 1405*cdf0e10cSrcweir } 1406*cdf0e10cSrcweir 1407*cdf0e10cSrcweir // beans::XMultiPropertySet 1408*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > UnoControlFixedHyperlinkModel::getPropertySetInfo( ) throw(uno::RuntimeException) 1409*cdf0e10cSrcweir { 1410*cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 1411*cdf0e10cSrcweir return xInfo; 1412*cdf0e10cSrcweir } 1413*cdf0e10cSrcweir 1414*cdf0e10cSrcweir // ---------------------------------------------------- 1415*cdf0e10cSrcweir // class UnoFixedHyperlinkControl 1416*cdf0e10cSrcweir // ---------------------------------------------------- 1417*cdf0e10cSrcweir UnoFixedHyperlinkControl::UnoFixedHyperlinkControl( const Reference< XMultiServiceFactory >& i_factory ) 1418*cdf0e10cSrcweir :UnoControlBase( i_factory ) 1419*cdf0e10cSrcweir ,maActionListeners( *this ) 1420*cdf0e10cSrcweir { 1421*cdf0e10cSrcweir maComponentInfos.nWidth = 100; 1422*cdf0e10cSrcweir maComponentInfos.nHeight = 12; 1423*cdf0e10cSrcweir } 1424*cdf0e10cSrcweir 1425*cdf0e10cSrcweir ::rtl::OUString UnoFixedHyperlinkControl::GetComponentServiceName() 1426*cdf0e10cSrcweir { 1427*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "fixedhyperlink" ); 1428*cdf0e10cSrcweir } 1429*cdf0e10cSrcweir 1430*cdf0e10cSrcweir // uno::XInterface 1431*cdf0e10cSrcweir uno::Any UnoFixedHyperlinkControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException) 1432*cdf0e10cSrcweir { 1433*cdf0e10cSrcweir uno::Any aRet = ::cppu::queryInterface( rType, 1434*cdf0e10cSrcweir SAL_STATIC_CAST( awt::XFixedHyperlink*, this ), 1435*cdf0e10cSrcweir SAL_STATIC_CAST( awt::XLayoutConstrains*, this ) ); 1436*cdf0e10cSrcweir return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType )); 1437*cdf0e10cSrcweir } 1438*cdf0e10cSrcweir 1439*cdf0e10cSrcweir // lang::XTypeProvider 1440*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( UnoFixedHyperlinkControl ) 1441*cdf0e10cSrcweir getCppuType( ( uno::Reference< awt::XFixedHyperlink>* ) NULL ), 1442*cdf0e10cSrcweir getCppuType( ( uno::Reference< awt::XLayoutConstrains>* ) NULL ), 1443*cdf0e10cSrcweir UnoControlBase::getTypes() 1444*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 1445*cdf0e10cSrcweir 1446*cdf0e10cSrcweir sal_Bool UnoFixedHyperlinkControl::isTransparent() throw(uno::RuntimeException) 1447*cdf0e10cSrcweir { 1448*cdf0e10cSrcweir return sal_True; 1449*cdf0e10cSrcweir } 1450*cdf0e10cSrcweir 1451*cdf0e10cSrcweir void UnoFixedHyperlinkControl::setText( const ::rtl::OUString& Text ) throw(uno::RuntimeException) 1452*cdf0e10cSrcweir { 1453*cdf0e10cSrcweir uno::Any aAny; 1454*cdf0e10cSrcweir aAny <<= Text; 1455*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True ); 1456*cdf0e10cSrcweir } 1457*cdf0e10cSrcweir 1458*cdf0e10cSrcweir ::rtl::OUString UnoFixedHyperlinkControl::getText() throw(uno::RuntimeException) 1459*cdf0e10cSrcweir { 1460*cdf0e10cSrcweir return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL ); 1461*cdf0e10cSrcweir } 1462*cdf0e10cSrcweir 1463*cdf0e10cSrcweir void UnoFixedHyperlinkControl::setURL( const ::rtl::OUString& URL ) throw(::com::sun::star::uno::RuntimeException) 1464*cdf0e10cSrcweir { 1465*cdf0e10cSrcweir uno::Any aAny; 1466*cdf0e10cSrcweir aAny <<= URL; 1467*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_URL ), aAny, sal_True ); 1468*cdf0e10cSrcweir } 1469*cdf0e10cSrcweir 1470*cdf0e10cSrcweir ::rtl::OUString UnoFixedHyperlinkControl::getURL( ) throw(::com::sun::star::uno::RuntimeException) 1471*cdf0e10cSrcweir { 1472*cdf0e10cSrcweir return ImplGetPropertyValue_UString( BASEPROPERTY_URL ); 1473*cdf0e10cSrcweir } 1474*cdf0e10cSrcweir 1475*cdf0e10cSrcweir void UnoFixedHyperlinkControl::setAlignment( short nAlign ) throw(uno::RuntimeException) 1476*cdf0e10cSrcweir { 1477*cdf0e10cSrcweir uno::Any aAny; 1478*cdf0e10cSrcweir aAny <<= (sal_Int16)nAlign; 1479*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ), aAny, sal_True ); 1480*cdf0e10cSrcweir } 1481*cdf0e10cSrcweir 1482*cdf0e10cSrcweir short UnoFixedHyperlinkControl::getAlignment() throw(uno::RuntimeException) 1483*cdf0e10cSrcweir { 1484*cdf0e10cSrcweir short nAlign = 0; 1485*cdf0e10cSrcweir if ( mxModel.is() ) 1486*cdf0e10cSrcweir { 1487*cdf0e10cSrcweir uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ) ); 1488*cdf0e10cSrcweir aVal >>= nAlign; 1489*cdf0e10cSrcweir } 1490*cdf0e10cSrcweir return nAlign; 1491*cdf0e10cSrcweir } 1492*cdf0e10cSrcweir 1493*cdf0e10cSrcweir awt::Size UnoFixedHyperlinkControl::getMinimumSize( ) throw(uno::RuntimeException) 1494*cdf0e10cSrcweir { 1495*cdf0e10cSrcweir return Impl_getMinimumSize(); 1496*cdf0e10cSrcweir } 1497*cdf0e10cSrcweir 1498*cdf0e10cSrcweir awt::Size UnoFixedHyperlinkControl::getPreferredSize( ) throw(uno::RuntimeException) 1499*cdf0e10cSrcweir { 1500*cdf0e10cSrcweir return Impl_getPreferredSize(); 1501*cdf0e10cSrcweir } 1502*cdf0e10cSrcweir 1503*cdf0e10cSrcweir awt::Size UnoFixedHyperlinkControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException) 1504*cdf0e10cSrcweir { 1505*cdf0e10cSrcweir return Impl_calcAdjustedSize( rNewSize ); 1506*cdf0e10cSrcweir } 1507*cdf0e10cSrcweir 1508*cdf0e10cSrcweir void UnoFixedHyperlinkControl::dispose() throw(uno::RuntimeException) 1509*cdf0e10cSrcweir { 1510*cdf0e10cSrcweir lang::EventObject aEvt; 1511*cdf0e10cSrcweir aEvt.Source = (::cppu::OWeakObject*)this; 1512*cdf0e10cSrcweir maActionListeners.disposeAndClear( aEvt ); 1513*cdf0e10cSrcweir UnoControlBase::dispose(); 1514*cdf0e10cSrcweir } 1515*cdf0e10cSrcweir 1516*cdf0e10cSrcweir void UnoFixedHyperlinkControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException) 1517*cdf0e10cSrcweir { 1518*cdf0e10cSrcweir UnoControlBase::createPeer( rxToolkit, rParentPeer ); 1519*cdf0e10cSrcweir 1520*cdf0e10cSrcweir uno::Reference < awt::XFixedHyperlink > xFixedHyperlink( getPeer(), uno::UNO_QUERY ); 1521*cdf0e10cSrcweir if ( maActionListeners.getLength() ) 1522*cdf0e10cSrcweir xFixedHyperlink->addActionListener( &maActionListeners ); 1523*cdf0e10cSrcweir } 1524*cdf0e10cSrcweir 1525*cdf0e10cSrcweir void UnoFixedHyperlinkControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException) 1526*cdf0e10cSrcweir { 1527*cdf0e10cSrcweir maActionListeners.addInterface( l ); 1528*cdf0e10cSrcweir if( getPeer().is() && maActionListeners.getLength() == 1 ) 1529*cdf0e10cSrcweir { 1530*cdf0e10cSrcweir uno::Reference < awt::XFixedHyperlink > xFixedHyperlink( getPeer(), uno::UNO_QUERY ); 1531*cdf0e10cSrcweir xFixedHyperlink->addActionListener( &maActionListeners ); 1532*cdf0e10cSrcweir } 1533*cdf0e10cSrcweir } 1534*cdf0e10cSrcweir 1535*cdf0e10cSrcweir void UnoFixedHyperlinkControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException) 1536*cdf0e10cSrcweir { 1537*cdf0e10cSrcweir if( getPeer().is() && maActionListeners.getLength() == 1 ) 1538*cdf0e10cSrcweir { 1539*cdf0e10cSrcweir uno::Reference < awt::XFixedHyperlink > xFixedHyperlink( getPeer(), uno::UNO_QUERY ); 1540*cdf0e10cSrcweir xFixedHyperlink->removeActionListener( &maActionListeners ); 1541*cdf0e10cSrcweir } 1542*cdf0e10cSrcweir maActionListeners.removeInterface( l ); 1543*cdf0e10cSrcweir } 1544*cdf0e10cSrcweir 1545*cdf0e10cSrcweir // ---------------------------------------------------- 1546*cdf0e10cSrcweir // class UnoControlFixedTextModel 1547*cdf0e10cSrcweir // ---------------------------------------------------- 1548*cdf0e10cSrcweir UnoControlFixedTextModel::UnoControlFixedTextModel( const Reference< XMultiServiceFactory >& i_factory ) 1549*cdf0e10cSrcweir :UnoControlModel( i_factory ) 1550*cdf0e10cSrcweir { 1551*cdf0e10cSrcweir UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedText ); 1552*cdf0e10cSrcweir } 1553*cdf0e10cSrcweir 1554*cdf0e10cSrcweir ::rtl::OUString UnoControlFixedTextModel::getServiceName() throw(::com::sun::star::uno::RuntimeException) 1555*cdf0e10cSrcweir { 1556*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedTextModel ); 1557*cdf0e10cSrcweir } 1558*cdf0e10cSrcweir 1559*cdf0e10cSrcweir uno::Any UnoControlFixedTextModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const 1560*cdf0e10cSrcweir { 1561*cdf0e10cSrcweir if ( nPropId == BASEPROPERTY_DEFAULTCONTROL ) 1562*cdf0e10cSrcweir { 1563*cdf0e10cSrcweir uno::Any aAny; 1564*cdf0e10cSrcweir aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedText ); 1565*cdf0e10cSrcweir return aAny; 1566*cdf0e10cSrcweir } 1567*cdf0e10cSrcweir else if ( nPropId == BASEPROPERTY_BORDER ) 1568*cdf0e10cSrcweir { 1569*cdf0e10cSrcweir uno::Any aAny; 1570*cdf0e10cSrcweir aAny <<= (sal_Int16)0; 1571*cdf0e10cSrcweir return aAny; 1572*cdf0e10cSrcweir } 1573*cdf0e10cSrcweir 1574*cdf0e10cSrcweir return UnoControlModel::ImplGetDefaultValue( nPropId ); 1575*cdf0e10cSrcweir } 1576*cdf0e10cSrcweir 1577*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& UnoControlFixedTextModel::getInfoHelper() 1578*cdf0e10cSrcweir { 1579*cdf0e10cSrcweir static UnoPropertyArrayHelper* pHelper = NULL; 1580*cdf0e10cSrcweir if ( !pHelper ) 1581*cdf0e10cSrcweir { 1582*cdf0e10cSrcweir uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); 1583*cdf0e10cSrcweir pHelper = new UnoPropertyArrayHelper( aIDs ); 1584*cdf0e10cSrcweir } 1585*cdf0e10cSrcweir return *pHelper; 1586*cdf0e10cSrcweir } 1587*cdf0e10cSrcweir 1588*cdf0e10cSrcweir // beans::XMultiPropertySet 1589*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > UnoControlFixedTextModel::getPropertySetInfo( ) throw(uno::RuntimeException) 1590*cdf0e10cSrcweir { 1591*cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 1592*cdf0e10cSrcweir return xInfo; 1593*cdf0e10cSrcweir } 1594*cdf0e10cSrcweir 1595*cdf0e10cSrcweir 1596*cdf0e10cSrcweir // ---------------------------------------------------- 1597*cdf0e10cSrcweir // class UnoFixedTextControl 1598*cdf0e10cSrcweir // ---------------------------------------------------- 1599*cdf0e10cSrcweir UnoFixedTextControl::UnoFixedTextControl( const Reference< XMultiServiceFactory >& i_factory ) 1600*cdf0e10cSrcweir :UnoControlBase( i_factory ) 1601*cdf0e10cSrcweir { 1602*cdf0e10cSrcweir maComponentInfos.nWidth = 100; 1603*cdf0e10cSrcweir maComponentInfos.nHeight = 12; 1604*cdf0e10cSrcweir } 1605*cdf0e10cSrcweir 1606*cdf0e10cSrcweir ::rtl::OUString UnoFixedTextControl::GetComponentServiceName() 1607*cdf0e10cSrcweir { 1608*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "fixedtext" ); 1609*cdf0e10cSrcweir } 1610*cdf0e10cSrcweir 1611*cdf0e10cSrcweir // uno::XInterface 1612*cdf0e10cSrcweir uno::Any UnoFixedTextControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException) 1613*cdf0e10cSrcweir { 1614*cdf0e10cSrcweir uno::Any aRet = ::cppu::queryInterface( rType, 1615*cdf0e10cSrcweir SAL_STATIC_CAST( awt::XFixedText*, this ), 1616*cdf0e10cSrcweir SAL_STATIC_CAST( awt::XLayoutConstrains*, this ) ); 1617*cdf0e10cSrcweir return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType )); 1618*cdf0e10cSrcweir } 1619*cdf0e10cSrcweir 1620*cdf0e10cSrcweir // lang::XTypeProvider 1621*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( UnoFixedTextControl ) 1622*cdf0e10cSrcweir getCppuType( ( uno::Reference< awt::XFixedText>* ) NULL ), 1623*cdf0e10cSrcweir getCppuType( ( uno::Reference< awt::XLayoutConstrains>* ) NULL ), 1624*cdf0e10cSrcweir UnoControlBase::getTypes() 1625*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 1626*cdf0e10cSrcweir 1627*cdf0e10cSrcweir sal_Bool UnoFixedTextControl::isTransparent() throw(uno::RuntimeException) 1628*cdf0e10cSrcweir { 1629*cdf0e10cSrcweir return sal_True; 1630*cdf0e10cSrcweir } 1631*cdf0e10cSrcweir 1632*cdf0e10cSrcweir void UnoFixedTextControl::setText( const ::rtl::OUString& Text ) throw(uno::RuntimeException) 1633*cdf0e10cSrcweir { 1634*cdf0e10cSrcweir uno::Any aAny; 1635*cdf0e10cSrcweir aAny <<= Text; 1636*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True ); 1637*cdf0e10cSrcweir } 1638*cdf0e10cSrcweir 1639*cdf0e10cSrcweir ::rtl::OUString UnoFixedTextControl::getText() throw(uno::RuntimeException) 1640*cdf0e10cSrcweir { 1641*cdf0e10cSrcweir return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL ); 1642*cdf0e10cSrcweir } 1643*cdf0e10cSrcweir 1644*cdf0e10cSrcweir void UnoFixedTextControl::setAlignment( short nAlign ) throw(uno::RuntimeException) 1645*cdf0e10cSrcweir { 1646*cdf0e10cSrcweir uno::Any aAny; 1647*cdf0e10cSrcweir aAny <<= (sal_Int16)nAlign; 1648*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ), aAny, sal_True ); 1649*cdf0e10cSrcweir } 1650*cdf0e10cSrcweir 1651*cdf0e10cSrcweir short UnoFixedTextControl::getAlignment() throw(uno::RuntimeException) 1652*cdf0e10cSrcweir { 1653*cdf0e10cSrcweir short nAlign = 0; 1654*cdf0e10cSrcweir if ( mxModel.is() ) 1655*cdf0e10cSrcweir { 1656*cdf0e10cSrcweir uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ) ); 1657*cdf0e10cSrcweir aVal >>= nAlign; 1658*cdf0e10cSrcweir } 1659*cdf0e10cSrcweir return nAlign; 1660*cdf0e10cSrcweir } 1661*cdf0e10cSrcweir 1662*cdf0e10cSrcweir awt::Size UnoFixedTextControl::getMinimumSize( ) throw(uno::RuntimeException) 1663*cdf0e10cSrcweir { 1664*cdf0e10cSrcweir return Impl_getMinimumSize(); 1665*cdf0e10cSrcweir } 1666*cdf0e10cSrcweir 1667*cdf0e10cSrcweir awt::Size UnoFixedTextControl::getPreferredSize( ) throw(uno::RuntimeException) 1668*cdf0e10cSrcweir { 1669*cdf0e10cSrcweir return Impl_getPreferredSize(); 1670*cdf0e10cSrcweir } 1671*cdf0e10cSrcweir 1672*cdf0e10cSrcweir awt::Size UnoFixedTextControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException) 1673*cdf0e10cSrcweir { 1674*cdf0e10cSrcweir return Impl_calcAdjustedSize( rNewSize ); 1675*cdf0e10cSrcweir } 1676*cdf0e10cSrcweir 1677*cdf0e10cSrcweir // ---------------------------------------------------- 1678*cdf0e10cSrcweir // class UnoControlGroupBoxModel 1679*cdf0e10cSrcweir // ---------------------------------------------------- 1680*cdf0e10cSrcweir UnoControlGroupBoxModel::UnoControlGroupBoxModel( const Reference< XMultiServiceFactory >& i_factory ) 1681*cdf0e10cSrcweir :UnoControlModel( i_factory ) 1682*cdf0e10cSrcweir { 1683*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL ); 1684*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_ENABLED ); 1685*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE ); 1686*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR ); 1687*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_HELPTEXT ); 1688*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_HELPURL ); 1689*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_LABEL ); 1690*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_PRINTABLE ); 1691*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_WRITING_MODE ); 1692*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE ); 1693*cdf0e10cSrcweir } 1694*cdf0e10cSrcweir 1695*cdf0e10cSrcweir ::rtl::OUString UnoControlGroupBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException) 1696*cdf0e10cSrcweir { 1697*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( szServiceName_UnoControlGroupBoxModel ); 1698*cdf0e10cSrcweir } 1699*cdf0e10cSrcweir 1700*cdf0e10cSrcweir uno::Any UnoControlGroupBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const 1701*cdf0e10cSrcweir { 1702*cdf0e10cSrcweir if ( nPropId == BASEPROPERTY_DEFAULTCONTROL ) 1703*cdf0e10cSrcweir { 1704*cdf0e10cSrcweir uno::Any aAny; 1705*cdf0e10cSrcweir aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlGroupBox ); 1706*cdf0e10cSrcweir return aAny; 1707*cdf0e10cSrcweir } 1708*cdf0e10cSrcweir return UnoControlModel::ImplGetDefaultValue( nPropId ); 1709*cdf0e10cSrcweir } 1710*cdf0e10cSrcweir 1711*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& UnoControlGroupBoxModel::getInfoHelper() 1712*cdf0e10cSrcweir { 1713*cdf0e10cSrcweir static UnoPropertyArrayHelper* pHelper = NULL; 1714*cdf0e10cSrcweir if ( !pHelper ) 1715*cdf0e10cSrcweir { 1716*cdf0e10cSrcweir uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); 1717*cdf0e10cSrcweir pHelper = new UnoPropertyArrayHelper( aIDs ); 1718*cdf0e10cSrcweir } 1719*cdf0e10cSrcweir return *pHelper; 1720*cdf0e10cSrcweir } 1721*cdf0e10cSrcweir 1722*cdf0e10cSrcweir // beans::XMultiPropertySet 1723*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > UnoControlGroupBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException) 1724*cdf0e10cSrcweir { 1725*cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 1726*cdf0e10cSrcweir return xInfo; 1727*cdf0e10cSrcweir } 1728*cdf0e10cSrcweir 1729*cdf0e10cSrcweir // ---------------------------------------------------- 1730*cdf0e10cSrcweir // class UnoGroupBoxControl 1731*cdf0e10cSrcweir // ---------------------------------------------------- 1732*cdf0e10cSrcweir UnoGroupBoxControl::UnoGroupBoxControl( const Reference< XMultiServiceFactory >& i_factory ) 1733*cdf0e10cSrcweir :UnoControlBase( i_factory ) 1734*cdf0e10cSrcweir { 1735*cdf0e10cSrcweir maComponentInfos.nWidth = 100; 1736*cdf0e10cSrcweir maComponentInfos.nHeight = 100; 1737*cdf0e10cSrcweir } 1738*cdf0e10cSrcweir 1739*cdf0e10cSrcweir ::rtl::OUString UnoGroupBoxControl::GetComponentServiceName() 1740*cdf0e10cSrcweir { 1741*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "groupbox" ); 1742*cdf0e10cSrcweir } 1743*cdf0e10cSrcweir 1744*cdf0e10cSrcweir sal_Bool UnoGroupBoxControl::isTransparent() throw(uno::RuntimeException) 1745*cdf0e10cSrcweir { 1746*cdf0e10cSrcweir return sal_True; 1747*cdf0e10cSrcweir } 1748*cdf0e10cSrcweir 1749*cdf0e10cSrcweir // ===================================================================================================================== 1750*cdf0e10cSrcweir // = UnoControlListBoxModel_Data 1751*cdf0e10cSrcweir // ===================================================================================================================== 1752*cdf0e10cSrcweir struct ListItem 1753*cdf0e10cSrcweir { 1754*cdf0e10cSrcweir ::rtl::OUString ItemText; 1755*cdf0e10cSrcweir ::rtl::OUString ItemImageURL; 1756*cdf0e10cSrcweir Any ItemData; 1757*cdf0e10cSrcweir 1758*cdf0e10cSrcweir ListItem() 1759*cdf0e10cSrcweir :ItemText() 1760*cdf0e10cSrcweir ,ItemImageURL() 1761*cdf0e10cSrcweir ,ItemData() 1762*cdf0e10cSrcweir { 1763*cdf0e10cSrcweir } 1764*cdf0e10cSrcweir 1765*cdf0e10cSrcweir ListItem( const ::rtl::OUString& i_rItemText ) 1766*cdf0e10cSrcweir :ItemText( i_rItemText ) 1767*cdf0e10cSrcweir ,ItemImageURL() 1768*cdf0e10cSrcweir ,ItemData() 1769*cdf0e10cSrcweir { 1770*cdf0e10cSrcweir } 1771*cdf0e10cSrcweir }; 1772*cdf0e10cSrcweir 1773*cdf0e10cSrcweir typedef beans::Pair< ::rtl::OUString, ::rtl::OUString > UnoListItem; 1774*cdf0e10cSrcweir 1775*cdf0e10cSrcweir struct StripItemData : public ::std::unary_function< ListItem, UnoListItem > 1776*cdf0e10cSrcweir { 1777*cdf0e10cSrcweir UnoListItem operator()( const ListItem& i_rItem ) 1778*cdf0e10cSrcweir { 1779*cdf0e10cSrcweir return UnoListItem( i_rItem.ItemText, i_rItem.ItemImageURL ); 1780*cdf0e10cSrcweir } 1781*cdf0e10cSrcweir }; 1782*cdf0e10cSrcweir 1783*cdf0e10cSrcweir struct UnoControlListBoxModel_Data 1784*cdf0e10cSrcweir { 1785*cdf0e10cSrcweir UnoControlListBoxModel_Data( UnoControlListBoxModel& i_rAntiImpl ) 1786*cdf0e10cSrcweir :m_bSettingLegacyProperty( false ) 1787*cdf0e10cSrcweir ,m_rAntiImpl( i_rAntiImpl ) 1788*cdf0e10cSrcweir ,m_aListItems() 1789*cdf0e10cSrcweir { 1790*cdf0e10cSrcweir } 1791*cdf0e10cSrcweir 1792*cdf0e10cSrcweir sal_Int32 getItemCount() const { return sal_Int32( m_aListItems.size() ); } 1793*cdf0e10cSrcweir 1794*cdf0e10cSrcweir const ListItem& getItem( const sal_Int32 i_nIndex ) const 1795*cdf0e10cSrcweir { 1796*cdf0e10cSrcweir if ( ( i_nIndex < 0 ) || ( i_nIndex >= sal_Int32( m_aListItems.size() ) ) ) 1797*cdf0e10cSrcweir throw IndexOutOfBoundsException( ::rtl::OUString(), m_rAntiImpl ); 1798*cdf0e10cSrcweir return m_aListItems[ i_nIndex ]; 1799*cdf0e10cSrcweir } 1800*cdf0e10cSrcweir 1801*cdf0e10cSrcweir ListItem& getItem( const sal_Int32 i_nIndex ) 1802*cdf0e10cSrcweir { 1803*cdf0e10cSrcweir return const_cast< ListItem& >( static_cast< const UnoControlListBoxModel_Data* >( this )->getItem( i_nIndex ) ); 1804*cdf0e10cSrcweir } 1805*cdf0e10cSrcweir 1806*cdf0e10cSrcweir ListItem& insertItem( const sal_Int32 i_nIndex ) 1807*cdf0e10cSrcweir { 1808*cdf0e10cSrcweir if ( ( i_nIndex < 0 ) || ( i_nIndex > sal_Int32( m_aListItems.size() ) ) ) 1809*cdf0e10cSrcweir throw IndexOutOfBoundsException( ::rtl::OUString(), m_rAntiImpl ); 1810*cdf0e10cSrcweir return *m_aListItems.insert( m_aListItems.begin() + i_nIndex, ListItem() ); 1811*cdf0e10cSrcweir } 1812*cdf0e10cSrcweir 1813*cdf0e10cSrcweir Sequence< UnoListItem > getAllItems() const 1814*cdf0e10cSrcweir { 1815*cdf0e10cSrcweir Sequence< UnoListItem > aItems( sal_Int32( m_aListItems.size() ) ); 1816*cdf0e10cSrcweir ::std::transform( m_aListItems.begin(), m_aListItems.end(), aItems.getArray(), StripItemData() ); 1817*cdf0e10cSrcweir return aItems; 1818*cdf0e10cSrcweir } 1819*cdf0e10cSrcweir 1820*cdf0e10cSrcweir void copyItems( const UnoControlListBoxModel_Data& i_copySource ) 1821*cdf0e10cSrcweir { 1822*cdf0e10cSrcweir m_aListItems = i_copySource.m_aListItems; 1823*cdf0e10cSrcweir } 1824*cdf0e10cSrcweir 1825*cdf0e10cSrcweir void setAllItems( const ::std::vector< ListItem >& i_rItems ) 1826*cdf0e10cSrcweir { 1827*cdf0e10cSrcweir m_aListItems = i_rItems; 1828*cdf0e10cSrcweir } 1829*cdf0e10cSrcweir 1830*cdf0e10cSrcweir void removeItem( const sal_Int32 i_nIndex ) 1831*cdf0e10cSrcweir { 1832*cdf0e10cSrcweir if ( ( i_nIndex < 0 ) || ( i_nIndex >= sal_Int32( m_aListItems.size() ) ) ) 1833*cdf0e10cSrcweir throw IndexOutOfBoundsException( ::rtl::OUString(), m_rAntiImpl ); 1834*cdf0e10cSrcweir m_aListItems.erase( m_aListItems.begin() + i_nIndex ); 1835*cdf0e10cSrcweir } 1836*cdf0e10cSrcweir 1837*cdf0e10cSrcweir void removeAllItems() 1838*cdf0e10cSrcweir { 1839*cdf0e10cSrcweir ::std::vector< ListItem > aEmpty; 1840*cdf0e10cSrcweir m_aListItems.swap( aEmpty ); 1841*cdf0e10cSrcweir } 1842*cdf0e10cSrcweir 1843*cdf0e10cSrcweir public: 1844*cdf0e10cSrcweir bool m_bSettingLegacyProperty; 1845*cdf0e10cSrcweir 1846*cdf0e10cSrcweir private: 1847*cdf0e10cSrcweir UnoControlListBoxModel& m_rAntiImpl; 1848*cdf0e10cSrcweir ::std::vector< ListItem > m_aListItems; 1849*cdf0e10cSrcweir }; 1850*cdf0e10cSrcweir 1851*cdf0e10cSrcweir // ===================================================================================================================== 1852*cdf0e10cSrcweir // = UnoControlListBoxModel 1853*cdf0e10cSrcweir // ===================================================================================================================== 1854*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 1855*cdf0e10cSrcweir UnoControlListBoxModel::UnoControlListBoxModel( const Reference< XMultiServiceFactory >& i_factory, ConstructorMode const i_mode ) 1856*cdf0e10cSrcweir :UnoControlListBoxModel_Base( i_factory ) 1857*cdf0e10cSrcweir ,m_pData( new UnoControlListBoxModel_Data( *this ) ) 1858*cdf0e10cSrcweir ,m_aItemListListeners( GetMutex() ) 1859*cdf0e10cSrcweir { 1860*cdf0e10cSrcweir if ( i_mode == ConstructDefault ) 1861*cdf0e10cSrcweir { 1862*cdf0e10cSrcweir UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXListBox ); 1863*cdf0e10cSrcweir } 1864*cdf0e10cSrcweir } 1865*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 1866*cdf0e10cSrcweir UnoControlListBoxModel::UnoControlListBoxModel( const UnoControlListBoxModel& i_rSource ) 1867*cdf0e10cSrcweir :UnoControlListBoxModel_Base( i_rSource ) 1868*cdf0e10cSrcweir ,m_pData( new UnoControlListBoxModel_Data( *this ) ) 1869*cdf0e10cSrcweir ,m_aItemListListeners( GetMutex() ) 1870*cdf0e10cSrcweir { 1871*cdf0e10cSrcweir m_pData->copyItems( *i_rSource.m_pData ); 1872*cdf0e10cSrcweir } 1873*cdf0e10cSrcweir UnoControlListBoxModel::~UnoControlListBoxModel() 1874*cdf0e10cSrcweir { 1875*cdf0e10cSrcweir } 1876*cdf0e10cSrcweir IMPL_SERVICEINFO_DERIVED( UnoControlListBoxModel, UnoControlModel, szServiceName2_UnoControlListBoxModel ) 1877*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 1878*cdf0e10cSrcweir ::rtl::OUString UnoControlListBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException) 1879*cdf0e10cSrcweir { 1880*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( szServiceName_UnoControlListBoxModel ); 1881*cdf0e10cSrcweir } 1882*cdf0e10cSrcweir 1883*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 1884*cdf0e10cSrcweir uno::Any UnoControlListBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const 1885*cdf0e10cSrcweir { 1886*cdf0e10cSrcweir if ( nPropId == BASEPROPERTY_DEFAULTCONTROL ) 1887*cdf0e10cSrcweir { 1888*cdf0e10cSrcweir uno::Any aAny; 1889*cdf0e10cSrcweir aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlListBox ); 1890*cdf0e10cSrcweir return aAny; 1891*cdf0e10cSrcweir } 1892*cdf0e10cSrcweir return UnoControlModel::ImplGetDefaultValue( nPropId ); 1893*cdf0e10cSrcweir } 1894*cdf0e10cSrcweir 1895*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 1896*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& UnoControlListBoxModel::getInfoHelper() 1897*cdf0e10cSrcweir { 1898*cdf0e10cSrcweir static UnoPropertyArrayHelper* pHelper = NULL; 1899*cdf0e10cSrcweir if ( !pHelper ) 1900*cdf0e10cSrcweir { 1901*cdf0e10cSrcweir uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); 1902*cdf0e10cSrcweir pHelper = new UnoPropertyArrayHelper( aIDs ); 1903*cdf0e10cSrcweir } 1904*cdf0e10cSrcweir return *pHelper; 1905*cdf0e10cSrcweir } 1906*cdf0e10cSrcweir 1907*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 1908*cdf0e10cSrcweir // beans::XMultiPropertySet 1909*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > UnoControlListBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException) 1910*cdf0e10cSrcweir { 1911*cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 1912*cdf0e10cSrcweir return xInfo; 1913*cdf0e10cSrcweir } 1914*cdf0e10cSrcweir 1915*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 1916*cdf0e10cSrcweir namespace 1917*cdf0e10cSrcweir { 1918*cdf0e10cSrcweir struct CreateListItem : public ::std::unary_function< ::rtl::OUString, ListItem > 1919*cdf0e10cSrcweir { 1920*cdf0e10cSrcweir ListItem operator()( const ::rtl::OUString& i_rItemText ) 1921*cdf0e10cSrcweir { 1922*cdf0e10cSrcweir return ListItem( i_rItemText ); 1923*cdf0e10cSrcweir } 1924*cdf0e10cSrcweir }; 1925*cdf0e10cSrcweir } 1926*cdf0e10cSrcweir 1927*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 1928*cdf0e10cSrcweir void SAL_CALL UnoControlListBoxModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const uno::Any& rValue ) throw (uno::Exception) 1929*cdf0e10cSrcweir { 1930*cdf0e10cSrcweir UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue ); 1931*cdf0e10cSrcweir 1932*cdf0e10cSrcweir if ( nHandle == BASEPROPERTY_STRINGITEMLIST ) 1933*cdf0e10cSrcweir { 1934*cdf0e10cSrcweir // reset selection 1935*cdf0e10cSrcweir uno::Sequence<sal_Int16> aSeq; 1936*cdf0e10cSrcweir uno::Any aAny; 1937*cdf0e10cSrcweir aAny <<= aSeq; 1938*cdf0e10cSrcweir setDependentFastPropertyValue( BASEPROPERTY_SELECTEDITEMS, aAny ); 1939*cdf0e10cSrcweir 1940*cdf0e10cSrcweir if ( !m_pData->m_bSettingLegacyProperty ) 1941*cdf0e10cSrcweir { 1942*cdf0e10cSrcweir // synchronize the legacy StringItemList property with our list items 1943*cdf0e10cSrcweir Sequence< ::rtl::OUString > aStringItemList; 1944*cdf0e10cSrcweir Any aPropValue; 1945*cdf0e10cSrcweir getFastPropertyValue( aPropValue, BASEPROPERTY_STRINGITEMLIST ); 1946*cdf0e10cSrcweir OSL_VERIFY( aPropValue >>= aStringItemList ); 1947*cdf0e10cSrcweir 1948*cdf0e10cSrcweir ::std::vector< ListItem > aItems( aStringItemList.getLength() ); 1949*cdf0e10cSrcweir ::std::transform( 1950*cdf0e10cSrcweir aStringItemList.getConstArray(), 1951*cdf0e10cSrcweir aStringItemList.getConstArray() + aStringItemList.getLength(), 1952*cdf0e10cSrcweir aItems.begin(), 1953*cdf0e10cSrcweir CreateListItem() 1954*cdf0e10cSrcweir ); 1955*cdf0e10cSrcweir m_pData->setAllItems( aItems ); 1956*cdf0e10cSrcweir 1957*cdf0e10cSrcweir // since an XItemListListener does not have a "all items modified" or some such method, 1958*cdf0e10cSrcweir // we simulate this by notifying removal of all items, followed by insertion of all new 1959*cdf0e10cSrcweir // items 1960*cdf0e10cSrcweir lang::EventObject aEvent; 1961*cdf0e10cSrcweir aEvent.Source = *this; 1962*cdf0e10cSrcweir m_aItemListListeners.notifyEach( &XItemListListener::itemListChanged, aEvent ); 1963*cdf0e10cSrcweir // TODO: OPropertySetHelper calls into this method with the mutex locked ... 1964*cdf0e10cSrcweir // which is wrong for the above notifications ... 1965*cdf0e10cSrcweir } 1966*cdf0e10cSrcweir } 1967*cdf0e10cSrcweir } 1968*cdf0e10cSrcweir 1969*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 1970*cdf0e10cSrcweir void UnoControlListBoxModel::ImplNormalizePropertySequence( const sal_Int32 _nCount, sal_Int32* _pHandles, 1971*cdf0e10cSrcweir uno::Any* _pValues, sal_Int32* _pValidHandles ) const SAL_THROW(()) 1972*cdf0e10cSrcweir { 1973*cdf0e10cSrcweir // dependencies we know: 1974*cdf0e10cSrcweir // BASEPROPERTY_STRINGITEMLIST->BASEPROPERTY_SELECTEDITEMS 1975*cdf0e10cSrcweir ImplEnsureHandleOrder( _nCount, _pHandles, _pValues, BASEPROPERTY_STRINGITEMLIST, BASEPROPERTY_SELECTEDITEMS ); 1976*cdf0e10cSrcweir 1977*cdf0e10cSrcweir UnoControlModel::ImplNormalizePropertySequence( _nCount, _pHandles, _pValues, _pValidHandles ); 1978*cdf0e10cSrcweir } 1979*cdf0e10cSrcweir 1980*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 1981*cdf0e10cSrcweir ::sal_Int32 SAL_CALL UnoControlListBoxModel::getItemCount() throw (RuntimeException) 1982*cdf0e10cSrcweir { 1983*cdf0e10cSrcweir ::osl::MutexGuard aGuard( GetMutex() ); 1984*cdf0e10cSrcweir return m_pData->getItemCount(); 1985*cdf0e10cSrcweir } 1986*cdf0e10cSrcweir 1987*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 1988*cdf0e10cSrcweir void SAL_CALL UnoControlListBoxModel::insertItem( ::sal_Int32 i_nPosition, const ::rtl::OUString& i_rItemText, const ::rtl::OUString& i_rItemImageURL ) throw (IndexOutOfBoundsException, RuntimeException) 1989*cdf0e10cSrcweir { 1990*cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard( GetMutex() ); 1991*cdf0e10cSrcweir // SYNCHRONIZED -----> 1992*cdf0e10cSrcweir ListItem& rItem( m_pData->insertItem( i_nPosition ) ); 1993*cdf0e10cSrcweir rItem.ItemText = i_rItemText; 1994*cdf0e10cSrcweir rItem.ItemImageURL = i_rItemImageURL; 1995*cdf0e10cSrcweir 1996*cdf0e10cSrcweir impl_handleInsert( i_nPosition, i_rItemText, i_rItemImageURL, aGuard ); 1997*cdf0e10cSrcweir // <----- SYNCHRONIZED 1998*cdf0e10cSrcweir } 1999*cdf0e10cSrcweir 2000*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 2001*cdf0e10cSrcweir void SAL_CALL UnoControlListBoxModel::insertItemText( ::sal_Int32 i_nPosition, const ::rtl::OUString& i_rItemText ) throw (IndexOutOfBoundsException, RuntimeException) 2002*cdf0e10cSrcweir { 2003*cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard( GetMutex() ); 2004*cdf0e10cSrcweir // SYNCHRONIZED -----> 2005*cdf0e10cSrcweir ListItem& rItem( m_pData->insertItem( i_nPosition ) ); 2006*cdf0e10cSrcweir rItem.ItemText = i_rItemText; 2007*cdf0e10cSrcweir 2008*cdf0e10cSrcweir impl_handleInsert( i_nPosition, i_rItemText, ::boost::optional< ::rtl::OUString >(), aGuard ); 2009*cdf0e10cSrcweir // <----- SYNCHRONIZED 2010*cdf0e10cSrcweir } 2011*cdf0e10cSrcweir 2012*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 2013*cdf0e10cSrcweir void SAL_CALL UnoControlListBoxModel::insertItemImage( ::sal_Int32 i_nPosition, const ::rtl::OUString& i_rItemImageURL ) throw (IndexOutOfBoundsException, RuntimeException) 2014*cdf0e10cSrcweir { 2015*cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard( GetMutex() ); 2016*cdf0e10cSrcweir // SYNCHRONIZED -----> 2017*cdf0e10cSrcweir ListItem& rItem( m_pData->insertItem( i_nPosition ) ); 2018*cdf0e10cSrcweir rItem.ItemImageURL = i_rItemImageURL; 2019*cdf0e10cSrcweir 2020*cdf0e10cSrcweir impl_handleInsert( i_nPosition, ::boost::optional< ::rtl::OUString >(), i_rItemImageURL, aGuard ); 2021*cdf0e10cSrcweir // <----- SYNCHRONIZED 2022*cdf0e10cSrcweir } 2023*cdf0e10cSrcweir 2024*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 2025*cdf0e10cSrcweir void SAL_CALL UnoControlListBoxModel::removeItem( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException) 2026*cdf0e10cSrcweir { 2027*cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard( GetMutex() ); 2028*cdf0e10cSrcweir // SYNCHRONIZED -----> 2029*cdf0e10cSrcweir m_pData->removeItem( i_nPosition ); 2030*cdf0e10cSrcweir 2031*cdf0e10cSrcweir impl_handleRemove( i_nPosition, aGuard ); 2032*cdf0e10cSrcweir // <----- SYNCHRONIZED 2033*cdf0e10cSrcweir } 2034*cdf0e10cSrcweir 2035*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 2036*cdf0e10cSrcweir void SAL_CALL UnoControlListBoxModel::removeAllItems( ) throw (::com::sun::star::uno::RuntimeException) 2037*cdf0e10cSrcweir { 2038*cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard( GetMutex() ); 2039*cdf0e10cSrcweir // SYNCHRONIZED -----> 2040*cdf0e10cSrcweir m_pData->removeAllItems(); 2041*cdf0e10cSrcweir 2042*cdf0e10cSrcweir impl_handleRemove( -1, aGuard ); 2043*cdf0e10cSrcweir // <----- SYNCHRONIZED 2044*cdf0e10cSrcweir } 2045*cdf0e10cSrcweir 2046*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 2047*cdf0e10cSrcweir void SAL_CALL UnoControlListBoxModel::setItemText( ::sal_Int32 i_nPosition, const ::rtl::OUString& i_rItemText ) throw (IndexOutOfBoundsException, RuntimeException) 2048*cdf0e10cSrcweir { 2049*cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard( GetMutex() ); 2050*cdf0e10cSrcweir // SYNCHRONIZED -----> 2051*cdf0e10cSrcweir ListItem& rItem( m_pData->getItem( i_nPosition ) ); 2052*cdf0e10cSrcweir rItem.ItemText = i_rItemText; 2053*cdf0e10cSrcweir 2054*cdf0e10cSrcweir impl_handleModify( i_nPosition, i_rItemText, ::boost::optional< ::rtl::OUString >(), aGuard ); 2055*cdf0e10cSrcweir // <----- SYNCHRONIZED 2056*cdf0e10cSrcweir } 2057*cdf0e10cSrcweir 2058*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 2059*cdf0e10cSrcweir void SAL_CALL UnoControlListBoxModel::setItemImage( ::sal_Int32 i_nPosition, const ::rtl::OUString& i_rItemImageURL ) throw (IndexOutOfBoundsException, RuntimeException) 2060*cdf0e10cSrcweir { 2061*cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard( GetMutex() ); 2062*cdf0e10cSrcweir // SYNCHRONIZED -----> 2063*cdf0e10cSrcweir ListItem& rItem( m_pData->getItem( i_nPosition ) ); 2064*cdf0e10cSrcweir rItem.ItemImageURL = i_rItemImageURL; 2065*cdf0e10cSrcweir 2066*cdf0e10cSrcweir impl_handleModify( i_nPosition, ::boost::optional< ::rtl::OUString >(), i_rItemImageURL, aGuard ); 2067*cdf0e10cSrcweir // <----- SYNCHRONIZED 2068*cdf0e10cSrcweir } 2069*cdf0e10cSrcweir 2070*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 2071*cdf0e10cSrcweir void SAL_CALL UnoControlListBoxModel::setItemTextAndImage( ::sal_Int32 i_nPosition, const ::rtl::OUString& i_rItemText, const ::rtl::OUString& i_rItemImageURL ) throw (IndexOutOfBoundsException, RuntimeException) 2072*cdf0e10cSrcweir { 2073*cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard( GetMutex() ); 2074*cdf0e10cSrcweir // SYNCHRONIZED -----> 2075*cdf0e10cSrcweir ListItem& rItem( m_pData->getItem( i_nPosition ) ); 2076*cdf0e10cSrcweir rItem.ItemText = i_rItemText; 2077*cdf0e10cSrcweir rItem.ItemImageURL = i_rItemImageURL; 2078*cdf0e10cSrcweir 2079*cdf0e10cSrcweir impl_handleModify( i_nPosition, i_rItemText, i_rItemImageURL, aGuard ); 2080*cdf0e10cSrcweir // <----- SYNCHRONIZED 2081*cdf0e10cSrcweir } 2082*cdf0e10cSrcweir 2083*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 2084*cdf0e10cSrcweir void SAL_CALL UnoControlListBoxModel::setItemData( ::sal_Int32 i_nPosition, const Any& i_rDataValue ) throw (IndexOutOfBoundsException, RuntimeException) 2085*cdf0e10cSrcweir { 2086*cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard( GetMutex() ); 2087*cdf0e10cSrcweir ListItem& rItem( m_pData->getItem( i_nPosition ) ); 2088*cdf0e10cSrcweir rItem.ItemData = i_rDataValue; 2089*cdf0e10cSrcweir } 2090*cdf0e10cSrcweir 2091*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 2092*cdf0e10cSrcweir ::rtl::OUString SAL_CALL UnoControlListBoxModel::getItemText( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException) 2093*cdf0e10cSrcweir { 2094*cdf0e10cSrcweir ::osl::MutexGuard aGuard( GetMutex() ); 2095*cdf0e10cSrcweir const ListItem& rItem( m_pData->getItem( i_nPosition ) ); 2096*cdf0e10cSrcweir return rItem.ItemText; 2097*cdf0e10cSrcweir } 2098*cdf0e10cSrcweir 2099*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 2100*cdf0e10cSrcweir ::rtl::OUString SAL_CALL UnoControlListBoxModel::getItemImage( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException) 2101*cdf0e10cSrcweir { 2102*cdf0e10cSrcweir ::osl::MutexGuard aGuard( GetMutex() ); 2103*cdf0e10cSrcweir const ListItem& rItem( m_pData->getItem( i_nPosition ) ); 2104*cdf0e10cSrcweir return rItem.ItemImageURL; 2105*cdf0e10cSrcweir } 2106*cdf0e10cSrcweir 2107*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 2108*cdf0e10cSrcweir beans::Pair< ::rtl::OUString, ::rtl::OUString > SAL_CALL UnoControlListBoxModel::getItemTextAndImage( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException) 2109*cdf0e10cSrcweir { 2110*cdf0e10cSrcweir ::osl::MutexGuard aGuard( GetMutex() ); 2111*cdf0e10cSrcweir const ListItem& rItem( m_pData->getItem( i_nPosition ) ); 2112*cdf0e10cSrcweir return beans::Pair< ::rtl::OUString, ::rtl::OUString >( rItem.ItemText, rItem.ItemImageURL ); 2113*cdf0e10cSrcweir } 2114*cdf0e10cSrcweir 2115*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 2116*cdf0e10cSrcweir Any SAL_CALL UnoControlListBoxModel::getItemData( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException) 2117*cdf0e10cSrcweir { 2118*cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard( GetMutex() ); 2119*cdf0e10cSrcweir const ListItem& rItem( m_pData->getItem( i_nPosition ) ); 2120*cdf0e10cSrcweir return rItem.ItemData; 2121*cdf0e10cSrcweir } 2122*cdf0e10cSrcweir 2123*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 2124*cdf0e10cSrcweir Sequence< beans::Pair< ::rtl::OUString, ::rtl::OUString > > SAL_CALL UnoControlListBoxModel::getAllItems( ) throw (RuntimeException) 2125*cdf0e10cSrcweir { 2126*cdf0e10cSrcweir ::osl::MutexGuard aGuard( GetMutex() ); 2127*cdf0e10cSrcweir return m_pData->getAllItems(); 2128*cdf0e10cSrcweir } 2129*cdf0e10cSrcweir 2130*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 2131*cdf0e10cSrcweir void SAL_CALL UnoControlListBoxModel::addItemListListener( const uno::Reference< awt::XItemListListener >& i_Listener ) throw (uno::RuntimeException) 2132*cdf0e10cSrcweir { 2133*cdf0e10cSrcweir if ( i_Listener.is() ) 2134*cdf0e10cSrcweir m_aItemListListeners.addInterface( i_Listener ); 2135*cdf0e10cSrcweir } 2136*cdf0e10cSrcweir 2137*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 2138*cdf0e10cSrcweir void SAL_CALL UnoControlListBoxModel::removeItemListListener( const uno::Reference< awt::XItemListListener >& i_Listener ) throw (uno::RuntimeException) 2139*cdf0e10cSrcweir { 2140*cdf0e10cSrcweir if ( i_Listener.is() ) 2141*cdf0e10cSrcweir m_aItemListListeners.removeInterface( i_Listener ); 2142*cdf0e10cSrcweir } 2143*cdf0e10cSrcweir 2144*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 2145*cdf0e10cSrcweir void UnoControlListBoxModel::impl_getStringItemList( ::std::vector< ::rtl::OUString >& o_rStringItems ) const 2146*cdf0e10cSrcweir { 2147*cdf0e10cSrcweir Sequence< ::rtl::OUString > aStringItemList; 2148*cdf0e10cSrcweir Any aPropValue; 2149*cdf0e10cSrcweir getFastPropertyValue( aPropValue, BASEPROPERTY_STRINGITEMLIST ); 2150*cdf0e10cSrcweir OSL_VERIFY( aPropValue >>= aStringItemList ); 2151*cdf0e10cSrcweir 2152*cdf0e10cSrcweir o_rStringItems.resize( size_t( aStringItemList.getLength() ) ); 2153*cdf0e10cSrcweir ::std::copy( 2154*cdf0e10cSrcweir aStringItemList.getConstArray(), 2155*cdf0e10cSrcweir aStringItemList.getConstArray() + aStringItemList.getLength(), 2156*cdf0e10cSrcweir o_rStringItems.begin() 2157*cdf0e10cSrcweir ); 2158*cdf0e10cSrcweir } 2159*cdf0e10cSrcweir 2160*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 2161*cdf0e10cSrcweir void UnoControlListBoxModel::impl_setStringItemList_nolck( const ::std::vector< ::rtl::OUString >& i_rStringItems ) 2162*cdf0e10cSrcweir { 2163*cdf0e10cSrcweir Sequence< ::rtl::OUString > aStringItems( i_rStringItems.size() ); 2164*cdf0e10cSrcweir ::std::copy( 2165*cdf0e10cSrcweir i_rStringItems.begin(), 2166*cdf0e10cSrcweir i_rStringItems.end(), 2167*cdf0e10cSrcweir aStringItems.getArray() 2168*cdf0e10cSrcweir ); 2169*cdf0e10cSrcweir m_pData->m_bSettingLegacyProperty = true; 2170*cdf0e10cSrcweir try 2171*cdf0e10cSrcweir { 2172*cdf0e10cSrcweir setFastPropertyValue( BASEPROPERTY_STRINGITEMLIST, uno::makeAny( aStringItems ) ); 2173*cdf0e10cSrcweir } 2174*cdf0e10cSrcweir catch( const Exception& ) 2175*cdf0e10cSrcweir { 2176*cdf0e10cSrcweir m_pData->m_bSettingLegacyProperty = false; 2177*cdf0e10cSrcweir throw; 2178*cdf0e10cSrcweir } 2179*cdf0e10cSrcweir m_pData->m_bSettingLegacyProperty = false; 2180*cdf0e10cSrcweir } 2181*cdf0e10cSrcweir 2182*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 2183*cdf0e10cSrcweir void UnoControlListBoxModel::impl_handleInsert( const sal_Int32 i_nItemPosition, const ::boost::optional< ::rtl::OUString >& i_rItemText, 2184*cdf0e10cSrcweir const ::boost::optional< ::rtl::OUString >& i_rItemImageURL, ::osl::ClearableMutexGuard& i_rClearBeforeNotify ) 2185*cdf0e10cSrcweir { 2186*cdf0e10cSrcweir // SYNCHRONIZED -----> 2187*cdf0e10cSrcweir // sync with legacy StringItemList property 2188*cdf0e10cSrcweir ::std::vector< ::rtl::OUString > aStringItems; 2189*cdf0e10cSrcweir impl_getStringItemList( aStringItems ); 2190*cdf0e10cSrcweir OSL_ENSURE( size_t( i_nItemPosition ) <= aStringItems.size(), "UnoControlListBoxModel::impl_handleInsert" ); 2191*cdf0e10cSrcweir if ( size_t( i_nItemPosition ) <= aStringItems.size() ) 2192*cdf0e10cSrcweir { 2193*cdf0e10cSrcweir const ::rtl::OUString sItemText( !!i_rItemText ? *i_rItemText : ::rtl::OUString() ); 2194*cdf0e10cSrcweir aStringItems.insert( aStringItems.begin() + i_nItemPosition, sItemText ); 2195*cdf0e10cSrcweir } 2196*cdf0e10cSrcweir 2197*cdf0e10cSrcweir i_rClearBeforeNotify.clear(); 2198*cdf0e10cSrcweir // <----- SYNCHRONIZED 2199*cdf0e10cSrcweir impl_setStringItemList_nolck( aStringItems ); 2200*cdf0e10cSrcweir 2201*cdf0e10cSrcweir // notify ItemListListeners 2202*cdf0e10cSrcweir impl_notifyItemListEvent_nolck( i_nItemPosition, i_rItemText, i_rItemImageURL, &XItemListListener::listItemInserted ); 2203*cdf0e10cSrcweir } 2204*cdf0e10cSrcweir 2205*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 2206*cdf0e10cSrcweir void UnoControlListBoxModel::impl_handleRemove( const sal_Int32 i_nItemPosition, ::osl::ClearableMutexGuard& i_rClearBeforeNotify ) 2207*cdf0e10cSrcweir { 2208*cdf0e10cSrcweir // SYNCHRONIZED -----> 2209*cdf0e10cSrcweir const bool bAllItems = ( i_nItemPosition < 0 ); 2210*cdf0e10cSrcweir // sync with legacy StringItemList property 2211*cdf0e10cSrcweir ::std::vector< ::rtl::OUString > aStringItems; 2212*cdf0e10cSrcweir impl_getStringItemList( aStringItems ); 2213*cdf0e10cSrcweir if ( !bAllItems ) 2214*cdf0e10cSrcweir { 2215*cdf0e10cSrcweir OSL_ENSURE( size_t( i_nItemPosition ) < aStringItems.size(), "UnoControlListBoxModel::impl_handleRemove" ); 2216*cdf0e10cSrcweir if ( size_t( i_nItemPosition ) < aStringItems.size() ) 2217*cdf0e10cSrcweir { 2218*cdf0e10cSrcweir aStringItems.erase( aStringItems.begin() + i_nItemPosition ); 2219*cdf0e10cSrcweir } 2220*cdf0e10cSrcweir } 2221*cdf0e10cSrcweir else 2222*cdf0e10cSrcweir { 2223*cdf0e10cSrcweir aStringItems.resize(0); 2224*cdf0e10cSrcweir } 2225*cdf0e10cSrcweir 2226*cdf0e10cSrcweir i_rClearBeforeNotify.clear(); 2227*cdf0e10cSrcweir // <----- SYNCHRONIZED 2228*cdf0e10cSrcweir impl_setStringItemList_nolck( aStringItems ); 2229*cdf0e10cSrcweir 2230*cdf0e10cSrcweir // notify ItemListListeners 2231*cdf0e10cSrcweir if ( bAllItems ) 2232*cdf0e10cSrcweir { 2233*cdf0e10cSrcweir EventObject aEvent( *this ); 2234*cdf0e10cSrcweir m_aItemListListeners.notifyEach( &XItemListListener::allItemsRemoved, aEvent ); 2235*cdf0e10cSrcweir } 2236*cdf0e10cSrcweir else 2237*cdf0e10cSrcweir { 2238*cdf0e10cSrcweir impl_notifyItemListEvent_nolck( i_nItemPosition, ::boost::optional< ::rtl::OUString >(), ::boost::optional< ::rtl::OUString >(), 2239*cdf0e10cSrcweir &XItemListListener::listItemRemoved ); 2240*cdf0e10cSrcweir } 2241*cdf0e10cSrcweir } 2242*cdf0e10cSrcweir 2243*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 2244*cdf0e10cSrcweir void UnoControlListBoxModel::impl_handleModify( const sal_Int32 i_nItemPosition, const ::boost::optional< ::rtl::OUString >& i_rItemText, 2245*cdf0e10cSrcweir const ::boost::optional< ::rtl::OUString >& i_rItemImageURL, ::osl::ClearableMutexGuard& i_rClearBeforeNotify ) 2246*cdf0e10cSrcweir { 2247*cdf0e10cSrcweir // SYNCHRONIZED -----> 2248*cdf0e10cSrcweir if ( !!i_rItemText ) 2249*cdf0e10cSrcweir { 2250*cdf0e10cSrcweir // sync with legacy StringItemList property 2251*cdf0e10cSrcweir ::std::vector< ::rtl::OUString > aStringItems; 2252*cdf0e10cSrcweir impl_getStringItemList( aStringItems ); 2253*cdf0e10cSrcweir OSL_ENSURE( size_t( i_nItemPosition ) < aStringItems.size(), "UnoControlListBoxModel::impl_handleModify" ); 2254*cdf0e10cSrcweir if ( size_t( i_nItemPosition ) < aStringItems.size() ) 2255*cdf0e10cSrcweir { 2256*cdf0e10cSrcweir aStringItems[ i_nItemPosition] = *i_rItemText; 2257*cdf0e10cSrcweir } 2258*cdf0e10cSrcweir 2259*cdf0e10cSrcweir i_rClearBeforeNotify.clear(); 2260*cdf0e10cSrcweir // <----- SYNCHRONIZED 2261*cdf0e10cSrcweir impl_setStringItemList_nolck( aStringItems ); 2262*cdf0e10cSrcweir } 2263*cdf0e10cSrcweir else 2264*cdf0e10cSrcweir { 2265*cdf0e10cSrcweir i_rClearBeforeNotify.clear(); 2266*cdf0e10cSrcweir // <----- SYNCHRONIZED 2267*cdf0e10cSrcweir } 2268*cdf0e10cSrcweir 2269*cdf0e10cSrcweir // notify ItemListListeners 2270*cdf0e10cSrcweir impl_notifyItemListEvent_nolck( i_nItemPosition, i_rItemText, i_rItemImageURL, &XItemListListener::listItemModified ); 2271*cdf0e10cSrcweir } 2272*cdf0e10cSrcweir 2273*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 2274*cdf0e10cSrcweir void UnoControlListBoxModel::impl_notifyItemListEvent_nolck( const sal_Int32 i_nItemPosition, const ::boost::optional< ::rtl::OUString >& i_rItemText, 2275*cdf0e10cSrcweir const ::boost::optional< ::rtl::OUString >& i_rItemImageURL, 2276*cdf0e10cSrcweir void ( SAL_CALL XItemListListener::*NotificationMethod )( const ItemListEvent& ) ) 2277*cdf0e10cSrcweir { 2278*cdf0e10cSrcweir ItemListEvent aEvent; 2279*cdf0e10cSrcweir aEvent.Source = *this; 2280*cdf0e10cSrcweir aEvent.ItemPosition = i_nItemPosition; 2281*cdf0e10cSrcweir if ( !!i_rItemText ) 2282*cdf0e10cSrcweir { 2283*cdf0e10cSrcweir aEvent.ItemText.IsPresent = sal_True; 2284*cdf0e10cSrcweir aEvent.ItemText.Value = *i_rItemText; 2285*cdf0e10cSrcweir } 2286*cdf0e10cSrcweir if ( !!i_rItemImageURL ) 2287*cdf0e10cSrcweir { 2288*cdf0e10cSrcweir aEvent.ItemImageURL.IsPresent = sal_True; 2289*cdf0e10cSrcweir aEvent.ItemImageURL.Value = *i_rItemImageURL; 2290*cdf0e10cSrcweir } 2291*cdf0e10cSrcweir 2292*cdf0e10cSrcweir m_aItemListListeners.notifyEach( NotificationMethod, aEvent ); 2293*cdf0e10cSrcweir } 2294*cdf0e10cSrcweir 2295*cdf0e10cSrcweir // ---------------------------------------------------- 2296*cdf0e10cSrcweir // class UnoListBoxControl 2297*cdf0e10cSrcweir // ---------------------------------------------------- 2298*cdf0e10cSrcweir UnoListBoxControl::UnoListBoxControl( const Reference< XMultiServiceFactory >& i_factory ) 2299*cdf0e10cSrcweir :UnoListBoxControl_Base( i_factory ) 2300*cdf0e10cSrcweir ,maActionListeners( *this ) 2301*cdf0e10cSrcweir ,maItemListeners( *this ) 2302*cdf0e10cSrcweir { 2303*cdf0e10cSrcweir maComponentInfos.nWidth = 100; 2304*cdf0e10cSrcweir maComponentInfos.nHeight = 12; 2305*cdf0e10cSrcweir } 2306*cdf0e10cSrcweir 2307*cdf0e10cSrcweir ::rtl::OUString UnoListBoxControl::GetComponentServiceName() 2308*cdf0e10cSrcweir { 2309*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "listbox" ); 2310*cdf0e10cSrcweir } 2311*cdf0e10cSrcweir IMPL_SERVICEINFO_DERIVED( UnoListBoxControl, UnoControlBase, szServiceName2_UnoControlListBox ) 2312*cdf0e10cSrcweir 2313*cdf0e10cSrcweir void UnoListBoxControl::dispose() throw(uno::RuntimeException) 2314*cdf0e10cSrcweir { 2315*cdf0e10cSrcweir lang::EventObject aEvt; 2316*cdf0e10cSrcweir aEvt.Source = (::cppu::OWeakObject*)this; 2317*cdf0e10cSrcweir maActionListeners.disposeAndClear( aEvt ); 2318*cdf0e10cSrcweir maItemListeners.disposeAndClear( aEvt ); 2319*cdf0e10cSrcweir UnoControl::dispose(); 2320*cdf0e10cSrcweir } 2321*cdf0e10cSrcweir 2322*cdf0e10cSrcweir void UnoListBoxControl::ImplUpdateSelectedItemsProperty() 2323*cdf0e10cSrcweir { 2324*cdf0e10cSrcweir if ( getPeer().is() ) 2325*cdf0e10cSrcweir { 2326*cdf0e10cSrcweir uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY ); 2327*cdf0e10cSrcweir DBG_ASSERT( xListBox.is(), "XListBox?" ); 2328*cdf0e10cSrcweir 2329*cdf0e10cSrcweir uno::Sequence<sal_Int16> aSeq = xListBox->getSelectedItemsPos(); 2330*cdf0e10cSrcweir uno::Any aAny; 2331*cdf0e10cSrcweir aAny <<= aSeq; 2332*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SELECTEDITEMS ), aAny, sal_False ); 2333*cdf0e10cSrcweir } 2334*cdf0e10cSrcweir } 2335*cdf0e10cSrcweir 2336*cdf0e10cSrcweir void UnoListBoxControl::updateFromModel() 2337*cdf0e10cSrcweir { 2338*cdf0e10cSrcweir UnoControlBase::updateFromModel(); 2339*cdf0e10cSrcweir 2340*cdf0e10cSrcweir Reference< XItemListListener > xItemListListener( getPeer(), UNO_QUERY ); 2341*cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( xItemListListener.is(), "UnoListBoxControl::updateFromModel: a peer which is no ItemListListener?!" ); 2342*cdf0e10cSrcweir 2343*cdf0e10cSrcweir EventObject aEvent( getModel() ); 2344*cdf0e10cSrcweir xItemListListener->itemListChanged( aEvent ); 2345*cdf0e10cSrcweir 2346*cdf0e10cSrcweir // notify the change of the SelectedItems property, again. While our base class, in updateFromModel, 2347*cdf0e10cSrcweir // already did this, our peer(s) can only legitimately set the selection after they have the string 2348*cdf0e10cSrcweir // item list, which we just notified with the itemListChanged call. 2349*cdf0e10cSrcweir const ::rtl::OUString sSelectedItemsPropName( GetPropertyName( BASEPROPERTY_SELECTEDITEMS ) ); 2350*cdf0e10cSrcweir ImplSetPeerProperty( sSelectedItemsPropName, ImplGetPropertyValue( sSelectedItemsPropName ) ); 2351*cdf0e10cSrcweir } 2352*cdf0e10cSrcweir 2353*cdf0e10cSrcweir void UnoListBoxControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const uno::Any& rVal ) 2354*cdf0e10cSrcweir { 2355*cdf0e10cSrcweir if ( rPropName == GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) ) 2356*cdf0e10cSrcweir // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item 2357*cdf0e10cSrcweir // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes 2358*cdf0e10cSrcweir // will be forwarded to the peer, which will update itself accordingly. 2359*cdf0e10cSrcweir return; 2360*cdf0e10cSrcweir 2361*cdf0e10cSrcweir UnoControl::ImplSetPeerProperty( rPropName, rVal ); 2362*cdf0e10cSrcweir } 2363*cdf0e10cSrcweir 2364*cdf0e10cSrcweir void UnoListBoxControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException) 2365*cdf0e10cSrcweir { 2366*cdf0e10cSrcweir UnoControl::createPeer( rxToolkit, rParentPeer ); 2367*cdf0e10cSrcweir 2368*cdf0e10cSrcweir uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY ); 2369*cdf0e10cSrcweir xListBox->addItemListener( this ); 2370*cdf0e10cSrcweir 2371*cdf0e10cSrcweir if ( maActionListeners.getLength() ) 2372*cdf0e10cSrcweir xListBox->addActionListener( &maActionListeners ); 2373*cdf0e10cSrcweir } 2374*cdf0e10cSrcweir 2375*cdf0e10cSrcweir void UnoListBoxControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException) 2376*cdf0e10cSrcweir { 2377*cdf0e10cSrcweir maActionListeners.addInterface( l ); 2378*cdf0e10cSrcweir if( getPeer().is() && maActionListeners.getLength() == 1 ) 2379*cdf0e10cSrcweir { 2380*cdf0e10cSrcweir uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY ); 2381*cdf0e10cSrcweir xListBox->addActionListener( &maActionListeners ); 2382*cdf0e10cSrcweir } 2383*cdf0e10cSrcweir } 2384*cdf0e10cSrcweir 2385*cdf0e10cSrcweir void UnoListBoxControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException) 2386*cdf0e10cSrcweir { 2387*cdf0e10cSrcweir if( getPeer().is() && maActionListeners.getLength() == 1 ) 2388*cdf0e10cSrcweir { 2389*cdf0e10cSrcweir uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY ); 2390*cdf0e10cSrcweir xListBox->removeActionListener( &maActionListeners ); 2391*cdf0e10cSrcweir } 2392*cdf0e10cSrcweir maActionListeners.removeInterface( l ); 2393*cdf0e10cSrcweir } 2394*cdf0e10cSrcweir 2395*cdf0e10cSrcweir void UnoListBoxControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException) 2396*cdf0e10cSrcweir { 2397*cdf0e10cSrcweir maItemListeners.addInterface( l ); 2398*cdf0e10cSrcweir } 2399*cdf0e10cSrcweir 2400*cdf0e10cSrcweir void UnoListBoxControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException) 2401*cdf0e10cSrcweir { 2402*cdf0e10cSrcweir maItemListeners.removeInterface( l ); 2403*cdf0e10cSrcweir } 2404*cdf0e10cSrcweir 2405*cdf0e10cSrcweir void UnoListBoxControl::addItem( const ::rtl::OUString& aItem, sal_Int16 nPos ) throw(uno::RuntimeException) 2406*cdf0e10cSrcweir { 2407*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> aSeq( 1 ); 2408*cdf0e10cSrcweir aSeq.getArray()[0] = aItem; 2409*cdf0e10cSrcweir addItems( aSeq, nPos ); 2410*cdf0e10cSrcweir } 2411*cdf0e10cSrcweir 2412*cdf0e10cSrcweir void UnoListBoxControl::addItems( const uno::Sequence< ::rtl::OUString>& aItems, sal_Int16 nPos ) throw(uno::RuntimeException) 2413*cdf0e10cSrcweir { 2414*cdf0e10cSrcweir uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) ); 2415*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> aSeq; 2416*cdf0e10cSrcweir aVal >>= aSeq; 2417*cdf0e10cSrcweir sal_uInt16 nNewItems = (sal_uInt16)aItems.getLength(); 2418*cdf0e10cSrcweir sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength(); 2419*cdf0e10cSrcweir sal_uInt16 nNewLen = nOldLen + nNewItems; 2420*cdf0e10cSrcweir 2421*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> aNewSeq( nNewLen ); 2422*cdf0e10cSrcweir ::rtl::OUString* pNewData = aNewSeq.getArray(); 2423*cdf0e10cSrcweir ::rtl::OUString* pOldData = aSeq.getArray(); 2424*cdf0e10cSrcweir 2425*cdf0e10cSrcweir if ( ( nPos < 0 ) || ( nPos > nOldLen ) ) 2426*cdf0e10cSrcweir nPos = (sal_uInt16) nOldLen; 2427*cdf0e10cSrcweir 2428*cdf0e10cSrcweir sal_uInt16 n; 2429*cdf0e10cSrcweir // Items vor der Einfuege-Position 2430*cdf0e10cSrcweir for ( n = 0; n < nPos; n++ ) 2431*cdf0e10cSrcweir pNewData[n] = pOldData[n]; 2432*cdf0e10cSrcweir 2433*cdf0e10cSrcweir // Neue Items 2434*cdf0e10cSrcweir for ( n = 0; n < nNewItems; n++ ) 2435*cdf0e10cSrcweir pNewData[nPos+n] = aItems.getConstArray()[n]; 2436*cdf0e10cSrcweir 2437*cdf0e10cSrcweir // Rest der alten Items 2438*cdf0e10cSrcweir for ( n = nPos; n < nOldLen; n++ ) 2439*cdf0e10cSrcweir pNewData[nNewItems+n] = pOldData[n]; 2440*cdf0e10cSrcweir 2441*cdf0e10cSrcweir uno::Any aAny; 2442*cdf0e10cSrcweir aAny <<= aNewSeq; 2443*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, sal_True ); 2444*cdf0e10cSrcweir } 2445*cdf0e10cSrcweir 2446*cdf0e10cSrcweir void UnoListBoxControl::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(uno::RuntimeException) 2447*cdf0e10cSrcweir { 2448*cdf0e10cSrcweir uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) ); 2449*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> aSeq; 2450*cdf0e10cSrcweir aVal >>= aSeq; 2451*cdf0e10cSrcweir sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength(); 2452*cdf0e10cSrcweir if ( nOldLen && ( nPos < nOldLen ) ) 2453*cdf0e10cSrcweir { 2454*cdf0e10cSrcweir if ( nCount > ( nOldLen-nPos ) ) 2455*cdf0e10cSrcweir nCount = nOldLen-nPos; 2456*cdf0e10cSrcweir 2457*cdf0e10cSrcweir sal_uInt16 nNewLen = nOldLen - nCount; 2458*cdf0e10cSrcweir 2459*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> aNewSeq( nNewLen ); 2460*cdf0e10cSrcweir ::rtl::OUString* pNewData = aNewSeq.getArray(); 2461*cdf0e10cSrcweir ::rtl::OUString* pOldData = aSeq.getArray(); 2462*cdf0e10cSrcweir 2463*cdf0e10cSrcweir sal_uInt16 n; 2464*cdf0e10cSrcweir // Items vor der Entfern-Position 2465*cdf0e10cSrcweir for ( n = 0; n < nPos; n++ ) 2466*cdf0e10cSrcweir pNewData[n] = pOldData[n]; 2467*cdf0e10cSrcweir 2468*cdf0e10cSrcweir // Rest der Items 2469*cdf0e10cSrcweir for ( n = nPos; n < (nOldLen-nCount); n++ ) 2470*cdf0e10cSrcweir pNewData[n] = pOldData[n+nCount]; 2471*cdf0e10cSrcweir 2472*cdf0e10cSrcweir uno::Any aAny; 2473*cdf0e10cSrcweir aAny <<= aNewSeq; 2474*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, sal_True ); 2475*cdf0e10cSrcweir } 2476*cdf0e10cSrcweir } 2477*cdf0e10cSrcweir 2478*cdf0e10cSrcweir sal_Int16 UnoListBoxControl::getItemCount() throw(uno::RuntimeException) 2479*cdf0e10cSrcweir { 2480*cdf0e10cSrcweir uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) ); 2481*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> aSeq; 2482*cdf0e10cSrcweir aVal >>= aSeq; 2483*cdf0e10cSrcweir return (sal_Int16)aSeq.getLength(); 2484*cdf0e10cSrcweir } 2485*cdf0e10cSrcweir 2486*cdf0e10cSrcweir ::rtl::OUString UnoListBoxControl::getItem( sal_Int16 nPos ) throw(uno::RuntimeException) 2487*cdf0e10cSrcweir { 2488*cdf0e10cSrcweir ::rtl::OUString aItem; 2489*cdf0e10cSrcweir uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) ); 2490*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> aSeq; 2491*cdf0e10cSrcweir aVal >>= aSeq; 2492*cdf0e10cSrcweir if ( nPos < aSeq.getLength() ) 2493*cdf0e10cSrcweir aItem = aSeq.getConstArray()[nPos]; 2494*cdf0e10cSrcweir return aItem; 2495*cdf0e10cSrcweir } 2496*cdf0e10cSrcweir 2497*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> UnoListBoxControl::getItems() throw(uno::RuntimeException) 2498*cdf0e10cSrcweir { 2499*cdf0e10cSrcweir uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) ); 2500*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> aSeq; 2501*cdf0e10cSrcweir aVal >>= aSeq; 2502*cdf0e10cSrcweir return aSeq; 2503*cdf0e10cSrcweir } 2504*cdf0e10cSrcweir 2505*cdf0e10cSrcweir sal_Int16 UnoListBoxControl::getSelectedItemPos() throw(uno::RuntimeException) 2506*cdf0e10cSrcweir { 2507*cdf0e10cSrcweir sal_Int16 n = -1; 2508*cdf0e10cSrcweir if ( getPeer().is() ) 2509*cdf0e10cSrcweir { 2510*cdf0e10cSrcweir uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY ); 2511*cdf0e10cSrcweir n = xListBox->getSelectedItemPos(); 2512*cdf0e10cSrcweir } 2513*cdf0e10cSrcweir return n; 2514*cdf0e10cSrcweir } 2515*cdf0e10cSrcweir 2516*cdf0e10cSrcweir uno::Sequence<sal_Int16> UnoListBoxControl::getSelectedItemsPos() throw(uno::RuntimeException) 2517*cdf0e10cSrcweir { 2518*cdf0e10cSrcweir uno::Sequence<sal_Int16> aSeq; 2519*cdf0e10cSrcweir if ( getPeer().is() ) 2520*cdf0e10cSrcweir { 2521*cdf0e10cSrcweir uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY ); 2522*cdf0e10cSrcweir aSeq = xListBox->getSelectedItemsPos(); 2523*cdf0e10cSrcweir } 2524*cdf0e10cSrcweir return aSeq; 2525*cdf0e10cSrcweir } 2526*cdf0e10cSrcweir 2527*cdf0e10cSrcweir ::rtl::OUString UnoListBoxControl::getSelectedItem() throw(uno::RuntimeException) 2528*cdf0e10cSrcweir { 2529*cdf0e10cSrcweir ::rtl::OUString aItem; 2530*cdf0e10cSrcweir if ( getPeer().is() ) 2531*cdf0e10cSrcweir { 2532*cdf0e10cSrcweir uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY ); 2533*cdf0e10cSrcweir aItem = xListBox->getSelectedItem(); 2534*cdf0e10cSrcweir } 2535*cdf0e10cSrcweir return aItem; 2536*cdf0e10cSrcweir } 2537*cdf0e10cSrcweir 2538*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> UnoListBoxControl::getSelectedItems() throw(uno::RuntimeException) 2539*cdf0e10cSrcweir { 2540*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> aSeq; 2541*cdf0e10cSrcweir if ( getPeer().is() ) 2542*cdf0e10cSrcweir { 2543*cdf0e10cSrcweir uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY ); 2544*cdf0e10cSrcweir aSeq = xListBox->getSelectedItems(); 2545*cdf0e10cSrcweir } 2546*cdf0e10cSrcweir return aSeq; 2547*cdf0e10cSrcweir } 2548*cdf0e10cSrcweir 2549*cdf0e10cSrcweir void UnoListBoxControl::selectItemPos( sal_Int16 nPos, sal_Bool bSelect ) throw(uno::RuntimeException) 2550*cdf0e10cSrcweir { 2551*cdf0e10cSrcweir if ( getPeer().is() ) 2552*cdf0e10cSrcweir { 2553*cdf0e10cSrcweir uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY ); 2554*cdf0e10cSrcweir xListBox->selectItemPos( nPos, bSelect ); 2555*cdf0e10cSrcweir } 2556*cdf0e10cSrcweir ImplUpdateSelectedItemsProperty(); 2557*cdf0e10cSrcweir } 2558*cdf0e10cSrcweir 2559*cdf0e10cSrcweir void UnoListBoxControl::selectItemsPos( const uno::Sequence<sal_Int16>& aPositions, sal_Bool bSelect ) throw(uno::RuntimeException) 2560*cdf0e10cSrcweir { 2561*cdf0e10cSrcweir if ( getPeer().is() ) 2562*cdf0e10cSrcweir { 2563*cdf0e10cSrcweir uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY ); 2564*cdf0e10cSrcweir xListBox->selectItemsPos( aPositions, bSelect ); 2565*cdf0e10cSrcweir } 2566*cdf0e10cSrcweir ImplUpdateSelectedItemsProperty(); 2567*cdf0e10cSrcweir } 2568*cdf0e10cSrcweir 2569*cdf0e10cSrcweir void UnoListBoxControl::selectItem( const ::rtl::OUString& aItem, sal_Bool bSelect ) throw(uno::RuntimeException) 2570*cdf0e10cSrcweir { 2571*cdf0e10cSrcweir if ( getPeer().is() ) 2572*cdf0e10cSrcweir { 2573*cdf0e10cSrcweir uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY ); 2574*cdf0e10cSrcweir xListBox->selectItem( aItem, bSelect ); 2575*cdf0e10cSrcweir } 2576*cdf0e10cSrcweir ImplUpdateSelectedItemsProperty(); 2577*cdf0e10cSrcweir } 2578*cdf0e10cSrcweir 2579*cdf0e10cSrcweir void UnoListBoxControl::makeVisible( sal_Int16 nEntry ) throw(uno::RuntimeException) 2580*cdf0e10cSrcweir { 2581*cdf0e10cSrcweir if ( getPeer().is() ) 2582*cdf0e10cSrcweir { 2583*cdf0e10cSrcweir uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY ); 2584*cdf0e10cSrcweir xListBox->makeVisible( nEntry ); 2585*cdf0e10cSrcweir } 2586*cdf0e10cSrcweir } 2587*cdf0e10cSrcweir 2588*cdf0e10cSrcweir void UnoListBoxControl::setDropDownLineCount( sal_Int16 nLines ) throw(uno::RuntimeException) 2589*cdf0e10cSrcweir { 2590*cdf0e10cSrcweir uno::Any aAny; 2591*cdf0e10cSrcweir aAny <<= (sal_Int16)nLines; 2592*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT ), aAny, sal_True ); 2593*cdf0e10cSrcweir } 2594*cdf0e10cSrcweir 2595*cdf0e10cSrcweir sal_Int16 UnoListBoxControl::getDropDownLineCount() throw(uno::RuntimeException) 2596*cdf0e10cSrcweir { 2597*cdf0e10cSrcweir return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT ); 2598*cdf0e10cSrcweir } 2599*cdf0e10cSrcweir 2600*cdf0e10cSrcweir sal_Bool UnoListBoxControl::isMutipleMode() throw(uno::RuntimeException) 2601*cdf0e10cSrcweir { 2602*cdf0e10cSrcweir return ImplGetPropertyValue_BOOL( BASEPROPERTY_MULTISELECTION ); 2603*cdf0e10cSrcweir } 2604*cdf0e10cSrcweir 2605*cdf0e10cSrcweir void UnoListBoxControl::setMultipleMode( sal_Bool bMulti ) throw(uno::RuntimeException) 2606*cdf0e10cSrcweir { 2607*cdf0e10cSrcweir uno::Any aAny; 2608*cdf0e10cSrcweir aAny <<= bMulti; 2609*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTISELECTION ), aAny, sal_True ); 2610*cdf0e10cSrcweir } 2611*cdf0e10cSrcweir 2612*cdf0e10cSrcweir void UnoListBoxControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException) 2613*cdf0e10cSrcweir { 2614*cdf0e10cSrcweir ImplUpdateSelectedItemsProperty(); 2615*cdf0e10cSrcweir if ( maItemListeners.getLength() ) 2616*cdf0e10cSrcweir { 2617*cdf0e10cSrcweir try 2618*cdf0e10cSrcweir { 2619*cdf0e10cSrcweir maItemListeners.itemStateChanged( rEvent ); 2620*cdf0e10cSrcweir } 2621*cdf0e10cSrcweir catch( const Exception& e ) 2622*cdf0e10cSrcweir { 2623*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL == 0 2624*cdf0e10cSrcweir (void) e; // suppress warning 2625*cdf0e10cSrcweir #else 2626*cdf0e10cSrcweir ::rtl::OString sMessage( "UnoListBoxControl::itemStateChanged: caught an exception:\n" ); 2627*cdf0e10cSrcweir sMessage += ::rtl::OString( e.Message.getStr(), e.Message.getLength(), RTL_TEXTENCODING_ASCII_US ); 2628*cdf0e10cSrcweir OSL_ENSURE( sal_False, sMessage.getStr() ); 2629*cdf0e10cSrcweir #endif 2630*cdf0e10cSrcweir } 2631*cdf0e10cSrcweir } 2632*cdf0e10cSrcweir } 2633*cdf0e10cSrcweir 2634*cdf0e10cSrcweir awt::Size UnoListBoxControl::getMinimumSize( ) throw(uno::RuntimeException) 2635*cdf0e10cSrcweir { 2636*cdf0e10cSrcweir return Impl_getMinimumSize(); 2637*cdf0e10cSrcweir } 2638*cdf0e10cSrcweir 2639*cdf0e10cSrcweir awt::Size UnoListBoxControl::getPreferredSize( ) throw(uno::RuntimeException) 2640*cdf0e10cSrcweir { 2641*cdf0e10cSrcweir return Impl_getPreferredSize(); 2642*cdf0e10cSrcweir } 2643*cdf0e10cSrcweir 2644*cdf0e10cSrcweir awt::Size UnoListBoxControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException) 2645*cdf0e10cSrcweir { 2646*cdf0e10cSrcweir return Impl_calcAdjustedSize( rNewSize ); 2647*cdf0e10cSrcweir } 2648*cdf0e10cSrcweir 2649*cdf0e10cSrcweir awt::Size UnoListBoxControl::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(uno::RuntimeException) 2650*cdf0e10cSrcweir { 2651*cdf0e10cSrcweir return Impl_getMinimumSize( nCols, nLines ); 2652*cdf0e10cSrcweir } 2653*cdf0e10cSrcweir 2654*cdf0e10cSrcweir void UnoListBoxControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(uno::RuntimeException) 2655*cdf0e10cSrcweir { 2656*cdf0e10cSrcweir Impl_getColumnsAndLines( nCols, nLines ); 2657*cdf0e10cSrcweir } 2658*cdf0e10cSrcweir 2659*cdf0e10cSrcweir sal_Bool SAL_CALL UnoListBoxControl::setModel( const uno::Reference< awt::XControlModel >& i_rModel ) throw ( uno::RuntimeException ) 2660*cdf0e10cSrcweir { 2661*cdf0e10cSrcweir ::osl::MutexGuard aGuard( GetMutex() ); 2662*cdf0e10cSrcweir 2663*cdf0e10cSrcweir const Reference< XItemList > xOldItems( getModel(), UNO_QUERY ); 2664*cdf0e10cSrcweir OSL_ENSURE( xOldItems.is() || !getModel().is(), "UnoListBoxControl::setModel: illegal old model!" ); 2665*cdf0e10cSrcweir const Reference< XItemList > xNewItems( i_rModel, UNO_QUERY ); 2666*cdf0e10cSrcweir OSL_ENSURE( xNewItems.is() || !i_rModel.is(), "UnoListBoxControl::setModel: illegal new model!" ); 2667*cdf0e10cSrcweir 2668*cdf0e10cSrcweir if ( !UnoListBoxControl_Base::setModel( i_rModel ) ) 2669*cdf0e10cSrcweir return sal_False; 2670*cdf0e10cSrcweir 2671*cdf0e10cSrcweir if ( xOldItems.is() ) 2672*cdf0e10cSrcweir xOldItems->removeItemListListener( this ); 2673*cdf0e10cSrcweir if ( xNewItems.is() ) 2674*cdf0e10cSrcweir xNewItems->addItemListListener( this ); 2675*cdf0e10cSrcweir 2676*cdf0e10cSrcweir return sal_True; 2677*cdf0e10cSrcweir } 2678*cdf0e10cSrcweir 2679*cdf0e10cSrcweir void SAL_CALL UnoListBoxControl::listItemInserted( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException) 2680*cdf0e10cSrcweir { 2681*cdf0e10cSrcweir const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY ); 2682*cdf0e10cSrcweir OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoListBoxControl::listItemInserted: invalid peer!" ); 2683*cdf0e10cSrcweir if ( xPeerListener.is() ) 2684*cdf0e10cSrcweir xPeerListener->listItemInserted( i_rEvent ); 2685*cdf0e10cSrcweir } 2686*cdf0e10cSrcweir 2687*cdf0e10cSrcweir void SAL_CALL UnoListBoxControl::listItemRemoved( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException) 2688*cdf0e10cSrcweir { 2689*cdf0e10cSrcweir const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY ); 2690*cdf0e10cSrcweir OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoListBoxControl::listItemRemoved: invalid peer!" ); 2691*cdf0e10cSrcweir if ( xPeerListener.is() ) 2692*cdf0e10cSrcweir xPeerListener->listItemRemoved( i_rEvent ); 2693*cdf0e10cSrcweir } 2694*cdf0e10cSrcweir 2695*cdf0e10cSrcweir void SAL_CALL UnoListBoxControl::listItemModified( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException) 2696*cdf0e10cSrcweir { 2697*cdf0e10cSrcweir const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY ); 2698*cdf0e10cSrcweir OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoListBoxControl::listItemModified: invalid peer!" ); 2699*cdf0e10cSrcweir if ( xPeerListener.is() ) 2700*cdf0e10cSrcweir xPeerListener->listItemModified( i_rEvent ); 2701*cdf0e10cSrcweir } 2702*cdf0e10cSrcweir 2703*cdf0e10cSrcweir void SAL_CALL UnoListBoxControl::allItemsRemoved( const lang::EventObject& i_rEvent ) throw (uno::RuntimeException) 2704*cdf0e10cSrcweir { 2705*cdf0e10cSrcweir const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY ); 2706*cdf0e10cSrcweir OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoListBoxControl::allItemsRemoved: invalid peer!" ); 2707*cdf0e10cSrcweir if ( xPeerListener.is() ) 2708*cdf0e10cSrcweir xPeerListener->allItemsRemoved( i_rEvent ); 2709*cdf0e10cSrcweir } 2710*cdf0e10cSrcweir 2711*cdf0e10cSrcweir void SAL_CALL UnoListBoxControl::itemListChanged( const lang::EventObject& i_rEvent ) throw (uno::RuntimeException) 2712*cdf0e10cSrcweir { 2713*cdf0e10cSrcweir const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY ); 2714*cdf0e10cSrcweir OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoListBoxControl::itemListChanged: invalid peer!" ); 2715*cdf0e10cSrcweir if ( xPeerListener.is() ) 2716*cdf0e10cSrcweir xPeerListener->itemListChanged( i_rEvent ); 2717*cdf0e10cSrcweir } 2718*cdf0e10cSrcweir ActionListenerMultiplexer& UnoListBoxControl::getActionListeners() 2719*cdf0e10cSrcweir { 2720*cdf0e10cSrcweir return maActionListeners; 2721*cdf0e10cSrcweir } 2722*cdf0e10cSrcweir ItemListenerMultiplexer& UnoListBoxControl::getItemListeners() 2723*cdf0e10cSrcweir { 2724*cdf0e10cSrcweir return maItemListeners; 2725*cdf0e10cSrcweir } 2726*cdf0e10cSrcweir // ---------------------------------------------------- 2727*cdf0e10cSrcweir // class UnoControlComboBoxModel 2728*cdf0e10cSrcweir // ---------------------------------------------------- 2729*cdf0e10cSrcweir UnoControlComboBoxModel::UnoControlComboBoxModel( const Reference< XMultiServiceFactory >& i_factory ) 2730*cdf0e10cSrcweir :UnoControlListBoxModel( i_factory, ConstructWithoutProperties ) 2731*cdf0e10cSrcweir { 2732*cdf0e10cSrcweir UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXComboBox ); 2733*cdf0e10cSrcweir } 2734*cdf0e10cSrcweir 2735*cdf0e10cSrcweir IMPL_SERVICEINFO_DERIVED( UnoControlComboBoxModel, UnoControlModel, szServiceName2_UnoControlComboBoxModel ) 2736*cdf0e10cSrcweir 2737*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > UnoControlComboBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException) 2738*cdf0e10cSrcweir { 2739*cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 2740*cdf0e10cSrcweir return xInfo; 2741*cdf0e10cSrcweir } 2742*cdf0e10cSrcweir // --------------------------------------------------------------------------------------------------------------------- 2743*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& UnoControlComboBoxModel::getInfoHelper() 2744*cdf0e10cSrcweir { 2745*cdf0e10cSrcweir static UnoPropertyArrayHelper* pHelper = NULL; 2746*cdf0e10cSrcweir if ( !pHelper ) 2747*cdf0e10cSrcweir { 2748*cdf0e10cSrcweir uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); 2749*cdf0e10cSrcweir pHelper = new UnoPropertyArrayHelper( aIDs ); 2750*cdf0e10cSrcweir } 2751*cdf0e10cSrcweir return *pHelper; 2752*cdf0e10cSrcweir } 2753*cdf0e10cSrcweir 2754*cdf0e10cSrcweir 2755*cdf0e10cSrcweir ::rtl::OUString UnoControlComboBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException) 2756*cdf0e10cSrcweir { 2757*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( szServiceName_UnoControlComboBoxModel ); 2758*cdf0e10cSrcweir } 2759*cdf0e10cSrcweir void SAL_CALL UnoControlComboBoxModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const uno::Any& rValue ) throw (uno::Exception) 2760*cdf0e10cSrcweir { 2761*cdf0e10cSrcweir UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue ); 2762*cdf0e10cSrcweir 2763*cdf0e10cSrcweir if ( nHandle == BASEPROPERTY_STRINGITEMLIST && !m_pData->m_bSettingLegacyProperty) 2764*cdf0e10cSrcweir { 2765*cdf0e10cSrcweir // synchronize the legacy StringItemList property with our list items 2766*cdf0e10cSrcweir Sequence< ::rtl::OUString > aStringItemList; 2767*cdf0e10cSrcweir Any aPropValue; 2768*cdf0e10cSrcweir getFastPropertyValue( aPropValue, BASEPROPERTY_STRINGITEMLIST ); 2769*cdf0e10cSrcweir OSL_VERIFY( aPropValue >>= aStringItemList ); 2770*cdf0e10cSrcweir 2771*cdf0e10cSrcweir ::std::vector< ListItem > aItems( aStringItemList.getLength() ); 2772*cdf0e10cSrcweir ::std::transform( 2773*cdf0e10cSrcweir aStringItemList.getConstArray(), 2774*cdf0e10cSrcweir aStringItemList.getConstArray() + aStringItemList.getLength(), 2775*cdf0e10cSrcweir aItems.begin(), 2776*cdf0e10cSrcweir CreateListItem() 2777*cdf0e10cSrcweir ); 2778*cdf0e10cSrcweir m_pData->setAllItems( aItems ); 2779*cdf0e10cSrcweir 2780*cdf0e10cSrcweir // since an XItemListListener does not have a "all items modified" or some such method, 2781*cdf0e10cSrcweir // we simulate this by notifying removal of all items, followed by insertion of all new 2782*cdf0e10cSrcweir // items 2783*cdf0e10cSrcweir lang::EventObject aEvent; 2784*cdf0e10cSrcweir aEvent.Source = *this; 2785*cdf0e10cSrcweir m_aItemListListeners.notifyEach( &XItemListListener::itemListChanged, aEvent ); 2786*cdf0e10cSrcweir // TODO: OPropertySetHelper calls into this method with the mutex locked ... 2787*cdf0e10cSrcweir // which is wrong for the above notifications ... 2788*cdf0e10cSrcweir } 2789*cdf0e10cSrcweir } 2790*cdf0e10cSrcweir 2791*cdf0e10cSrcweir uno::Any UnoControlComboBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const 2792*cdf0e10cSrcweir { 2793*cdf0e10cSrcweir if ( nPropId == BASEPROPERTY_DEFAULTCONTROL ) 2794*cdf0e10cSrcweir { 2795*cdf0e10cSrcweir uno::Any aAny; 2796*cdf0e10cSrcweir aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlComboBox ); 2797*cdf0e10cSrcweir return aAny; 2798*cdf0e10cSrcweir } 2799*cdf0e10cSrcweir return UnoControlModel::ImplGetDefaultValue( nPropId ); 2800*cdf0e10cSrcweir } 2801*cdf0e10cSrcweir 2802*cdf0e10cSrcweir // ---------------------------------------------------- 2803*cdf0e10cSrcweir // class UnoComboBoxControl 2804*cdf0e10cSrcweir // ---------------------------------------------------- 2805*cdf0e10cSrcweir UnoComboBoxControl::UnoComboBoxControl( const Reference< XMultiServiceFactory >& i_factory ) 2806*cdf0e10cSrcweir :UnoEditControl( i_factory ) 2807*cdf0e10cSrcweir ,maActionListeners( *this ) 2808*cdf0e10cSrcweir ,maItemListeners( *this ) 2809*cdf0e10cSrcweir { 2810*cdf0e10cSrcweir maComponentInfos.nWidth = 100; 2811*cdf0e10cSrcweir maComponentInfos.nHeight = 12; 2812*cdf0e10cSrcweir } 2813*cdf0e10cSrcweir IMPL_SERVICEINFO_DERIVED( UnoComboBoxControl, UnoEditControl, szServiceName2_UnoControlComboBox ) 2814*cdf0e10cSrcweir 2815*cdf0e10cSrcweir ::rtl::OUString UnoComboBoxControl::GetComponentServiceName() 2816*cdf0e10cSrcweir { 2817*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "combobox" ); 2818*cdf0e10cSrcweir } 2819*cdf0e10cSrcweir 2820*cdf0e10cSrcweir void UnoComboBoxControl::dispose() throw(uno::RuntimeException) 2821*cdf0e10cSrcweir { 2822*cdf0e10cSrcweir lang::EventObject aEvt; 2823*cdf0e10cSrcweir aEvt.Source = (::cppu::OWeakObject*)this; 2824*cdf0e10cSrcweir maActionListeners.disposeAndClear( aEvt ); 2825*cdf0e10cSrcweir maItemListeners.disposeAndClear( aEvt ); 2826*cdf0e10cSrcweir UnoControl::dispose(); 2827*cdf0e10cSrcweir } 2828*cdf0e10cSrcweir uno::Any UnoComboBoxControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException) 2829*cdf0e10cSrcweir { 2830*cdf0e10cSrcweir uno::Any aRet = ::cppu::queryInterface( rType, 2831*cdf0e10cSrcweir SAL_STATIC_CAST( awt::XComboBox*, this ) ); 2832*cdf0e10cSrcweir if ( !aRet.hasValue() ) 2833*cdf0e10cSrcweir { 2834*cdf0e10cSrcweir aRet = ::cppu::queryInterface( rType, 2835*cdf0e10cSrcweir SAL_STATIC_CAST( awt::XItemListener*, this ) ); 2836*cdf0e10cSrcweir if ( !aRet.hasValue() ) 2837*cdf0e10cSrcweir { 2838*cdf0e10cSrcweir aRet = ::cppu::queryInterface( rType, 2839*cdf0e10cSrcweir SAL_STATIC_CAST( awt::XItemListListener*, this ) ); 2840*cdf0e10cSrcweir } 2841*cdf0e10cSrcweir } 2842*cdf0e10cSrcweir return (aRet.hasValue() ? aRet : UnoEditControl::queryAggregation( rType )); 2843*cdf0e10cSrcweir } 2844*cdf0e10cSrcweir // lang::XTypeProvider 2845*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( UnoComboBoxControl ) 2846*cdf0e10cSrcweir getCppuType( ( uno::Reference< awt::XComboBox>* ) NULL ), 2847*cdf0e10cSrcweir getCppuType( ( uno::Reference< awt::XItemListener>* ) NULL ), 2848*cdf0e10cSrcweir getCppuType( ( uno::Reference< awt::XItemListListener>* ) NULL ), 2849*cdf0e10cSrcweir UnoEditControl::getTypes() 2850*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 2851*cdf0e10cSrcweir 2852*cdf0e10cSrcweir void UnoComboBoxControl::updateFromModel() 2853*cdf0e10cSrcweir { 2854*cdf0e10cSrcweir UnoEditControl::updateFromModel(); 2855*cdf0e10cSrcweir 2856*cdf0e10cSrcweir Reference< XItemListListener > xItemListListener( getPeer(), UNO_QUERY ); 2857*cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( xItemListListener.is(), "UnoComboBoxControl::updateFromModel: a peer which is no ItemListListener?!" ); 2858*cdf0e10cSrcweir 2859*cdf0e10cSrcweir EventObject aEvent( getModel() ); 2860*cdf0e10cSrcweir xItemListListener->itemListChanged( aEvent ); 2861*cdf0e10cSrcweir } 2862*cdf0e10cSrcweir void UnoComboBoxControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const uno::Any& rVal ) 2863*cdf0e10cSrcweir { 2864*cdf0e10cSrcweir if ( rPropName == GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) ) 2865*cdf0e10cSrcweir // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item 2866*cdf0e10cSrcweir // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes 2867*cdf0e10cSrcweir // will be forwarded to the peer, which will update itself accordingly. 2868*cdf0e10cSrcweir return; 2869*cdf0e10cSrcweir 2870*cdf0e10cSrcweir UnoEditControl::ImplSetPeerProperty( rPropName, rVal ); 2871*cdf0e10cSrcweir } 2872*cdf0e10cSrcweir void UnoComboBoxControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException) 2873*cdf0e10cSrcweir { 2874*cdf0e10cSrcweir UnoEditControl::createPeer( rxToolkit, rParentPeer ); 2875*cdf0e10cSrcweir 2876*cdf0e10cSrcweir uno::Reference < awt::XComboBox > xComboBox( getPeer(), uno::UNO_QUERY ); 2877*cdf0e10cSrcweir if ( maActionListeners.getLength() ) 2878*cdf0e10cSrcweir xComboBox->addActionListener( &maActionListeners ); 2879*cdf0e10cSrcweir if ( maItemListeners.getLength() ) 2880*cdf0e10cSrcweir xComboBox->addItemListener( &maItemListeners ); 2881*cdf0e10cSrcweir } 2882*cdf0e10cSrcweir 2883*cdf0e10cSrcweir void UnoComboBoxControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException) 2884*cdf0e10cSrcweir { 2885*cdf0e10cSrcweir maActionListeners.addInterface( l ); 2886*cdf0e10cSrcweir if( getPeer().is() && maActionListeners.getLength() == 1 ) 2887*cdf0e10cSrcweir { 2888*cdf0e10cSrcweir uno::Reference < awt::XComboBox > xComboBox( getPeer(), uno::UNO_QUERY ); 2889*cdf0e10cSrcweir xComboBox->addActionListener( &maActionListeners ); 2890*cdf0e10cSrcweir } 2891*cdf0e10cSrcweir } 2892*cdf0e10cSrcweir 2893*cdf0e10cSrcweir void UnoComboBoxControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException) 2894*cdf0e10cSrcweir { 2895*cdf0e10cSrcweir if( getPeer().is() && maActionListeners.getLength() == 1 ) 2896*cdf0e10cSrcweir { 2897*cdf0e10cSrcweir uno::Reference < awt::XComboBox > xComboBox( getPeer(), uno::UNO_QUERY ); 2898*cdf0e10cSrcweir xComboBox->removeActionListener( &maActionListeners ); 2899*cdf0e10cSrcweir } 2900*cdf0e10cSrcweir maActionListeners.removeInterface( l ); 2901*cdf0e10cSrcweir } 2902*cdf0e10cSrcweir 2903*cdf0e10cSrcweir void UnoComboBoxControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException) 2904*cdf0e10cSrcweir { 2905*cdf0e10cSrcweir maItemListeners.addInterface( l ); 2906*cdf0e10cSrcweir if( getPeer().is() && maItemListeners.getLength() == 1 ) 2907*cdf0e10cSrcweir { 2908*cdf0e10cSrcweir uno::Reference < awt::XComboBox > xComboBox( getPeer(), uno::UNO_QUERY ); 2909*cdf0e10cSrcweir xComboBox->addItemListener( &maItemListeners ); 2910*cdf0e10cSrcweir } 2911*cdf0e10cSrcweir } 2912*cdf0e10cSrcweir 2913*cdf0e10cSrcweir void UnoComboBoxControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException) 2914*cdf0e10cSrcweir { 2915*cdf0e10cSrcweir if( getPeer().is() && maItemListeners.getLength() == 1 ) 2916*cdf0e10cSrcweir { 2917*cdf0e10cSrcweir uno::Reference < awt::XComboBox > xComboBox( getPeer(), uno::UNO_QUERY ); // MT: Mal alles so umstellen, schoener als Ref anlegen und query rufen 2918*cdf0e10cSrcweir xComboBox->removeItemListener( &maItemListeners ); 2919*cdf0e10cSrcweir } 2920*cdf0e10cSrcweir maItemListeners.removeInterface( l ); 2921*cdf0e10cSrcweir } 2922*cdf0e10cSrcweir void UnoComboBoxControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException) 2923*cdf0e10cSrcweir { 2924*cdf0e10cSrcweir if ( maItemListeners.getLength() ) 2925*cdf0e10cSrcweir { 2926*cdf0e10cSrcweir try 2927*cdf0e10cSrcweir { 2928*cdf0e10cSrcweir maItemListeners.itemStateChanged( rEvent ); 2929*cdf0e10cSrcweir } 2930*cdf0e10cSrcweir catch( const Exception& e ) 2931*cdf0e10cSrcweir { 2932*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL == 0 2933*cdf0e10cSrcweir (void) e; // suppress warning 2934*cdf0e10cSrcweir #else 2935*cdf0e10cSrcweir ::rtl::OString sMessage( "UnoComboBoxControl::itemStateChanged: caught an exception:\n" ); 2936*cdf0e10cSrcweir sMessage += ::rtl::OString( e.Message.getStr(), e.Message.getLength(), RTL_TEXTENCODING_ASCII_US ); 2937*cdf0e10cSrcweir OSL_ENSURE( sal_False, sMessage.getStr() ); 2938*cdf0e10cSrcweir #endif 2939*cdf0e10cSrcweir } 2940*cdf0e10cSrcweir } 2941*cdf0e10cSrcweir } 2942*cdf0e10cSrcweir sal_Bool SAL_CALL UnoComboBoxControl::setModel( const uno::Reference< awt::XControlModel >& i_rModel ) throw ( uno::RuntimeException ) 2943*cdf0e10cSrcweir { 2944*cdf0e10cSrcweir ::osl::MutexGuard aGuard( GetMutex() ); 2945*cdf0e10cSrcweir 2946*cdf0e10cSrcweir const Reference< XItemList > xOldItems( getModel(), UNO_QUERY ); 2947*cdf0e10cSrcweir OSL_ENSURE( xOldItems.is() || !getModel().is(), "UnoComboBoxControl::setModel: illegal old model!" ); 2948*cdf0e10cSrcweir const Reference< XItemList > xNewItems( i_rModel, UNO_QUERY ); 2949*cdf0e10cSrcweir OSL_ENSURE( xNewItems.is() || !i_rModel.is(), "UnoComboBoxControl::setModel: illegal new model!" ); 2950*cdf0e10cSrcweir 2951*cdf0e10cSrcweir if ( !UnoEditControl::setModel( i_rModel ) ) 2952*cdf0e10cSrcweir return sal_False; 2953*cdf0e10cSrcweir 2954*cdf0e10cSrcweir if ( xOldItems.is() ) 2955*cdf0e10cSrcweir xOldItems->removeItemListListener( this ); 2956*cdf0e10cSrcweir if ( xNewItems.is() ) 2957*cdf0e10cSrcweir xNewItems->addItemListListener( this ); 2958*cdf0e10cSrcweir 2959*cdf0e10cSrcweir return sal_True; 2960*cdf0e10cSrcweir } 2961*cdf0e10cSrcweir 2962*cdf0e10cSrcweir void SAL_CALL UnoComboBoxControl::listItemInserted( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException) 2963*cdf0e10cSrcweir { 2964*cdf0e10cSrcweir const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY ); 2965*cdf0e10cSrcweir OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::listItemInserted: invalid peer!" ); 2966*cdf0e10cSrcweir if ( xPeerListener.is() ) 2967*cdf0e10cSrcweir xPeerListener->listItemInserted( i_rEvent ); 2968*cdf0e10cSrcweir } 2969*cdf0e10cSrcweir 2970*cdf0e10cSrcweir void SAL_CALL UnoComboBoxControl::listItemRemoved( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException) 2971*cdf0e10cSrcweir { 2972*cdf0e10cSrcweir const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY ); 2973*cdf0e10cSrcweir OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::listItemRemoved: invalid peer!" ); 2974*cdf0e10cSrcweir if ( xPeerListener.is() ) 2975*cdf0e10cSrcweir xPeerListener->listItemRemoved( i_rEvent ); 2976*cdf0e10cSrcweir } 2977*cdf0e10cSrcweir 2978*cdf0e10cSrcweir void SAL_CALL UnoComboBoxControl::listItemModified( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException) 2979*cdf0e10cSrcweir { 2980*cdf0e10cSrcweir const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY ); 2981*cdf0e10cSrcweir OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::listItemModified: invalid peer!" ); 2982*cdf0e10cSrcweir if ( xPeerListener.is() ) 2983*cdf0e10cSrcweir xPeerListener->listItemModified( i_rEvent ); 2984*cdf0e10cSrcweir } 2985*cdf0e10cSrcweir 2986*cdf0e10cSrcweir void SAL_CALL UnoComboBoxControl::allItemsRemoved( const lang::EventObject& i_rEvent ) throw (uno::RuntimeException) 2987*cdf0e10cSrcweir { 2988*cdf0e10cSrcweir const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY ); 2989*cdf0e10cSrcweir OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::allItemsRemoved: invalid peer!" ); 2990*cdf0e10cSrcweir if ( xPeerListener.is() ) 2991*cdf0e10cSrcweir xPeerListener->allItemsRemoved( i_rEvent ); 2992*cdf0e10cSrcweir } 2993*cdf0e10cSrcweir 2994*cdf0e10cSrcweir void SAL_CALL UnoComboBoxControl::itemListChanged( const lang::EventObject& i_rEvent ) throw (uno::RuntimeException) 2995*cdf0e10cSrcweir { 2996*cdf0e10cSrcweir const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY ); 2997*cdf0e10cSrcweir OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::itemListChanged: invalid peer!" ); 2998*cdf0e10cSrcweir if ( xPeerListener.is() ) 2999*cdf0e10cSrcweir xPeerListener->itemListChanged( i_rEvent ); 3000*cdf0e10cSrcweir } 3001*cdf0e10cSrcweir ActionListenerMultiplexer& UnoComboBoxControl::getActionListeners() 3002*cdf0e10cSrcweir { 3003*cdf0e10cSrcweir return maActionListeners; 3004*cdf0e10cSrcweir } 3005*cdf0e10cSrcweir ItemListenerMultiplexer& UnoComboBoxControl::getItemListeners() 3006*cdf0e10cSrcweir { 3007*cdf0e10cSrcweir return maItemListeners; 3008*cdf0e10cSrcweir } 3009*cdf0e10cSrcweir 3010*cdf0e10cSrcweir void UnoComboBoxControl::addItem( const ::rtl::OUString& aItem, sal_Int16 nPos ) throw(uno::RuntimeException) 3011*cdf0e10cSrcweir { 3012*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> aSeq( 1 ); 3013*cdf0e10cSrcweir aSeq.getArray()[0] = aItem; 3014*cdf0e10cSrcweir addItems( aSeq, nPos ); 3015*cdf0e10cSrcweir } 3016*cdf0e10cSrcweir 3017*cdf0e10cSrcweir void UnoComboBoxControl::addItems( const uno::Sequence< ::rtl::OUString>& aItems, sal_Int16 nPos ) throw(uno::RuntimeException) 3018*cdf0e10cSrcweir { 3019*cdf0e10cSrcweir uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) ); 3020*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> aSeq; 3021*cdf0e10cSrcweir aVal >>= aSeq; 3022*cdf0e10cSrcweir sal_uInt16 nNewItems = (sal_uInt16)aItems.getLength(); 3023*cdf0e10cSrcweir sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength(); 3024*cdf0e10cSrcweir sal_uInt16 nNewLen = nOldLen + nNewItems; 3025*cdf0e10cSrcweir 3026*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> aNewSeq( nNewLen ); 3027*cdf0e10cSrcweir ::rtl::OUString* pNewData = aNewSeq.getArray(); 3028*cdf0e10cSrcweir const ::rtl::OUString* pOldData = aSeq.getConstArray(); 3029*cdf0e10cSrcweir 3030*cdf0e10cSrcweir if ( ( nPos < 0 ) || ( nPos > nOldLen ) ) 3031*cdf0e10cSrcweir nPos = (sal_uInt16) nOldLen; 3032*cdf0e10cSrcweir 3033*cdf0e10cSrcweir sal_uInt16 n; 3034*cdf0e10cSrcweir // Items vor der Einfuege-Position 3035*cdf0e10cSrcweir for ( n = 0; n < nPos; n++ ) 3036*cdf0e10cSrcweir pNewData[n] = pOldData[n]; 3037*cdf0e10cSrcweir 3038*cdf0e10cSrcweir // Neue Items 3039*cdf0e10cSrcweir for ( n = 0; n < nNewItems; n++ ) 3040*cdf0e10cSrcweir pNewData[nPos+n] = aItems.getConstArray()[n]; 3041*cdf0e10cSrcweir 3042*cdf0e10cSrcweir // Rest der alten Items 3043*cdf0e10cSrcweir for ( n = nPos; n < nOldLen; n++ ) 3044*cdf0e10cSrcweir pNewData[nNewItems+n] = pOldData[n]; 3045*cdf0e10cSrcweir 3046*cdf0e10cSrcweir uno::Any aAny; 3047*cdf0e10cSrcweir aAny <<= aNewSeq; 3048*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, sal_True ); 3049*cdf0e10cSrcweir } 3050*cdf0e10cSrcweir 3051*cdf0e10cSrcweir void UnoComboBoxControl::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(uno::RuntimeException) 3052*cdf0e10cSrcweir { 3053*cdf0e10cSrcweir uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) ); 3054*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> aSeq; 3055*cdf0e10cSrcweir aVal >>= aSeq; 3056*cdf0e10cSrcweir sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength(); 3057*cdf0e10cSrcweir if ( nOldLen && ( nPos < nOldLen ) ) 3058*cdf0e10cSrcweir { 3059*cdf0e10cSrcweir if ( nCount > ( nOldLen-nPos ) ) 3060*cdf0e10cSrcweir nCount = nOldLen-nPos; 3061*cdf0e10cSrcweir 3062*cdf0e10cSrcweir sal_uInt16 nNewLen = nOldLen - nCount; 3063*cdf0e10cSrcweir 3064*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> aNewSeq( nNewLen ); 3065*cdf0e10cSrcweir ::rtl::OUString* pNewData = aNewSeq.getArray(); 3066*cdf0e10cSrcweir ::rtl::OUString* pOldData = aSeq.getArray(); 3067*cdf0e10cSrcweir 3068*cdf0e10cSrcweir sal_uInt16 n; 3069*cdf0e10cSrcweir // Items vor der Entfern-Position 3070*cdf0e10cSrcweir for ( n = 0; n < nPos; n++ ) 3071*cdf0e10cSrcweir pNewData[n] = pOldData[n]; 3072*cdf0e10cSrcweir 3073*cdf0e10cSrcweir // Rest der Items 3074*cdf0e10cSrcweir for ( n = nPos; n < (nOldLen-nCount); n++ ) 3075*cdf0e10cSrcweir pNewData[n] = pOldData[n+nCount]; 3076*cdf0e10cSrcweir 3077*cdf0e10cSrcweir uno::Any aAny; 3078*cdf0e10cSrcweir aAny <<= aNewSeq; 3079*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, sal_True ); 3080*cdf0e10cSrcweir } 3081*cdf0e10cSrcweir } 3082*cdf0e10cSrcweir 3083*cdf0e10cSrcweir sal_Int16 UnoComboBoxControl::getItemCount() throw(uno::RuntimeException) 3084*cdf0e10cSrcweir { 3085*cdf0e10cSrcweir uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) ); 3086*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> aSeq; 3087*cdf0e10cSrcweir aVal >>= aSeq; 3088*cdf0e10cSrcweir return (sal_Int16)aSeq.getLength(); 3089*cdf0e10cSrcweir } 3090*cdf0e10cSrcweir 3091*cdf0e10cSrcweir ::rtl::OUString UnoComboBoxControl::getItem( sal_Int16 nPos ) throw(uno::RuntimeException) 3092*cdf0e10cSrcweir { 3093*cdf0e10cSrcweir ::rtl::OUString aItem; 3094*cdf0e10cSrcweir uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) ); 3095*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> aSeq; 3096*cdf0e10cSrcweir aVal >>= aSeq; 3097*cdf0e10cSrcweir if ( nPos < aSeq.getLength() ) 3098*cdf0e10cSrcweir aItem = aSeq.getConstArray()[nPos]; 3099*cdf0e10cSrcweir return aItem; 3100*cdf0e10cSrcweir } 3101*cdf0e10cSrcweir 3102*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> UnoComboBoxControl::getItems() throw(uno::RuntimeException) 3103*cdf0e10cSrcweir { 3104*cdf0e10cSrcweir uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) ); 3105*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> aSeq; 3106*cdf0e10cSrcweir aVal >>= aSeq; 3107*cdf0e10cSrcweir return aSeq; 3108*cdf0e10cSrcweir } 3109*cdf0e10cSrcweir 3110*cdf0e10cSrcweir void UnoComboBoxControl::setDropDownLineCount( sal_Int16 nLines ) throw(uno::RuntimeException) 3111*cdf0e10cSrcweir { 3112*cdf0e10cSrcweir uno::Any aAny; 3113*cdf0e10cSrcweir aAny <<= nLines; 3114*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT ), aAny, sal_True ); 3115*cdf0e10cSrcweir } 3116*cdf0e10cSrcweir 3117*cdf0e10cSrcweir sal_Int16 UnoComboBoxControl::getDropDownLineCount() throw(uno::RuntimeException) 3118*cdf0e10cSrcweir { 3119*cdf0e10cSrcweir return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT ); 3120*cdf0e10cSrcweir } 3121*cdf0e10cSrcweir 3122*cdf0e10cSrcweir 3123*cdf0e10cSrcweir // ---------------------------------------------------- 3124*cdf0e10cSrcweir // UnoSpinFieldControl 3125*cdf0e10cSrcweir // ---------------------------------------------------- 3126*cdf0e10cSrcweir UnoSpinFieldControl::UnoSpinFieldControl( const Reference< XMultiServiceFactory >& i_factory ) 3127*cdf0e10cSrcweir :UnoEditControl( i_factory ) 3128*cdf0e10cSrcweir ,maSpinListeners( *this ) 3129*cdf0e10cSrcweir { 3130*cdf0e10cSrcweir mbRepeat = sal_False; 3131*cdf0e10cSrcweir } 3132*cdf0e10cSrcweir 3133*cdf0e10cSrcweir // uno::XInterface 3134*cdf0e10cSrcweir uno::Any UnoSpinFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException) 3135*cdf0e10cSrcweir { 3136*cdf0e10cSrcweir uno::Any aRet = ::cppu::queryInterface( rType, 3137*cdf0e10cSrcweir SAL_STATIC_CAST( awt::XSpinField*, this ) ); 3138*cdf0e10cSrcweir return (aRet.hasValue() ? aRet : UnoEditControl::queryAggregation( rType )); 3139*cdf0e10cSrcweir } 3140*cdf0e10cSrcweir 3141*cdf0e10cSrcweir // lang::XTypeProvider 3142*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( UnoSpinFieldControl ) 3143*cdf0e10cSrcweir getCppuType( ( uno::Reference< awt::XSpinField>* ) NULL ), 3144*cdf0e10cSrcweir UnoEditControl::getTypes() 3145*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 3146*cdf0e10cSrcweir 3147*cdf0e10cSrcweir void UnoSpinFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException) 3148*cdf0e10cSrcweir { 3149*cdf0e10cSrcweir UnoEditControl::createPeer( rxToolkit, rParentPeer ); 3150*cdf0e10cSrcweir 3151*cdf0e10cSrcweir uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY ); 3152*cdf0e10cSrcweir xField->enableRepeat( mbRepeat ); 3153*cdf0e10cSrcweir if ( maSpinListeners.getLength() ) 3154*cdf0e10cSrcweir xField->addSpinListener( &maSpinListeners ); 3155*cdf0e10cSrcweir } 3156*cdf0e10cSrcweir 3157*cdf0e10cSrcweir // ::com::sun::star::awt::XSpinField 3158*cdf0e10cSrcweir void UnoSpinFieldControl::addSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener >& l ) throw(::com::sun::star::uno::RuntimeException) 3159*cdf0e10cSrcweir { 3160*cdf0e10cSrcweir maSpinListeners.addInterface( l ); 3161*cdf0e10cSrcweir if( getPeer().is() && maSpinListeners.getLength() == 1 ) 3162*cdf0e10cSrcweir { 3163*cdf0e10cSrcweir uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY ); 3164*cdf0e10cSrcweir xField->addSpinListener( &maSpinListeners ); 3165*cdf0e10cSrcweir } 3166*cdf0e10cSrcweir } 3167*cdf0e10cSrcweir 3168*cdf0e10cSrcweir void UnoSpinFieldControl::removeSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener >& l ) throw(::com::sun::star::uno::RuntimeException) 3169*cdf0e10cSrcweir { 3170*cdf0e10cSrcweir if( getPeer().is() && maSpinListeners.getLength() == 1 ) 3171*cdf0e10cSrcweir { 3172*cdf0e10cSrcweir uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY ); 3173*cdf0e10cSrcweir xField->removeSpinListener( &maSpinListeners ); 3174*cdf0e10cSrcweir } 3175*cdf0e10cSrcweir maSpinListeners.removeInterface( l ); 3176*cdf0e10cSrcweir } 3177*cdf0e10cSrcweir 3178*cdf0e10cSrcweir void UnoSpinFieldControl::up() throw(::com::sun::star::uno::RuntimeException) 3179*cdf0e10cSrcweir { 3180*cdf0e10cSrcweir uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY ); 3181*cdf0e10cSrcweir if ( xField.is() ) 3182*cdf0e10cSrcweir xField->up(); 3183*cdf0e10cSrcweir } 3184*cdf0e10cSrcweir 3185*cdf0e10cSrcweir void UnoSpinFieldControl::down() throw(::com::sun::star::uno::RuntimeException) 3186*cdf0e10cSrcweir { 3187*cdf0e10cSrcweir uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY ); 3188*cdf0e10cSrcweir if ( xField.is() ) 3189*cdf0e10cSrcweir xField->down(); 3190*cdf0e10cSrcweir } 3191*cdf0e10cSrcweir 3192*cdf0e10cSrcweir void UnoSpinFieldControl::first() throw(::com::sun::star::uno::RuntimeException) 3193*cdf0e10cSrcweir { 3194*cdf0e10cSrcweir uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY ); 3195*cdf0e10cSrcweir if ( xField.is() ) 3196*cdf0e10cSrcweir xField->first(); 3197*cdf0e10cSrcweir } 3198*cdf0e10cSrcweir 3199*cdf0e10cSrcweir void UnoSpinFieldControl::last() throw(::com::sun::star::uno::RuntimeException) 3200*cdf0e10cSrcweir { 3201*cdf0e10cSrcweir uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY ); 3202*cdf0e10cSrcweir if ( xField.is() ) 3203*cdf0e10cSrcweir xField->last(); 3204*cdf0e10cSrcweir } 3205*cdf0e10cSrcweir 3206*cdf0e10cSrcweir void UnoSpinFieldControl::enableRepeat( sal_Bool bRepeat ) throw(::com::sun::star::uno::RuntimeException) 3207*cdf0e10cSrcweir { 3208*cdf0e10cSrcweir mbRepeat = bRepeat; 3209*cdf0e10cSrcweir 3210*cdf0e10cSrcweir uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY ); 3211*cdf0e10cSrcweir if ( xField.is() ) 3212*cdf0e10cSrcweir xField->enableRepeat( bRepeat ); 3213*cdf0e10cSrcweir } 3214*cdf0e10cSrcweir 3215*cdf0e10cSrcweir // ---------------------------------------------------- 3216*cdf0e10cSrcweir // class UnoControlDateFieldModel 3217*cdf0e10cSrcweir // ---------------------------------------------------- 3218*cdf0e10cSrcweir UnoControlDateFieldModel::UnoControlDateFieldModel( const Reference< XMultiServiceFactory >& i_factory ) 3219*cdf0e10cSrcweir :UnoControlModel( i_factory ) 3220*cdf0e10cSrcweir { 3221*cdf0e10cSrcweir UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXDateField ); 3222*cdf0e10cSrcweir } 3223*cdf0e10cSrcweir 3224*cdf0e10cSrcweir ::rtl::OUString UnoControlDateFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException) 3225*cdf0e10cSrcweir { 3226*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( szServiceName_UnoControlDateFieldModel ); 3227*cdf0e10cSrcweir } 3228*cdf0e10cSrcweir 3229*cdf0e10cSrcweir uno::Any UnoControlDateFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const 3230*cdf0e10cSrcweir { 3231*cdf0e10cSrcweir if ( nPropId == BASEPROPERTY_DEFAULTCONTROL ) 3232*cdf0e10cSrcweir { 3233*cdf0e10cSrcweir uno::Any aAny; 3234*cdf0e10cSrcweir aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlDateField ); 3235*cdf0e10cSrcweir return aAny; 3236*cdf0e10cSrcweir } 3237*cdf0e10cSrcweir return UnoControlModel::ImplGetDefaultValue( nPropId ); 3238*cdf0e10cSrcweir } 3239*cdf0e10cSrcweir 3240*cdf0e10cSrcweir 3241*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& UnoControlDateFieldModel::getInfoHelper() 3242*cdf0e10cSrcweir { 3243*cdf0e10cSrcweir static UnoPropertyArrayHelper* pHelper = NULL; 3244*cdf0e10cSrcweir if ( !pHelper ) 3245*cdf0e10cSrcweir { 3246*cdf0e10cSrcweir uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); 3247*cdf0e10cSrcweir pHelper = new UnoPropertyArrayHelper( aIDs ); 3248*cdf0e10cSrcweir } 3249*cdf0e10cSrcweir return *pHelper; 3250*cdf0e10cSrcweir } 3251*cdf0e10cSrcweir 3252*cdf0e10cSrcweir // beans::XMultiPropertySet 3253*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > UnoControlDateFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException) 3254*cdf0e10cSrcweir { 3255*cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 3256*cdf0e10cSrcweir return xInfo; 3257*cdf0e10cSrcweir } 3258*cdf0e10cSrcweir 3259*cdf0e10cSrcweir 3260*cdf0e10cSrcweir 3261*cdf0e10cSrcweir // ---------------------------------------------------- 3262*cdf0e10cSrcweir // class UnoDateFieldControl 3263*cdf0e10cSrcweir // ---------------------------------------------------- 3264*cdf0e10cSrcweir UnoDateFieldControl::UnoDateFieldControl( const Reference< XMultiServiceFactory >& i_factory ) 3265*cdf0e10cSrcweir :UnoSpinFieldControl( i_factory ) 3266*cdf0e10cSrcweir { 3267*cdf0e10cSrcweir mnFirst = Date( 1, 1, 1900 ).GetDate(); 3268*cdf0e10cSrcweir mnLast = Date( 31, 12, 2200 ).GetDate(); 3269*cdf0e10cSrcweir mbLongFormat = 2; 3270*cdf0e10cSrcweir } 3271*cdf0e10cSrcweir 3272*cdf0e10cSrcweir ::rtl::OUString UnoDateFieldControl::GetComponentServiceName() 3273*cdf0e10cSrcweir { 3274*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "datefield" ); 3275*cdf0e10cSrcweir } 3276*cdf0e10cSrcweir 3277*cdf0e10cSrcweir // uno::XInterface 3278*cdf0e10cSrcweir uno::Any UnoDateFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException) 3279*cdf0e10cSrcweir { 3280*cdf0e10cSrcweir uno::Any aRet = ::cppu::queryInterface( rType, 3281*cdf0e10cSrcweir SAL_STATIC_CAST( awt::XDateField*, this ) ); 3282*cdf0e10cSrcweir return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType )); 3283*cdf0e10cSrcweir } 3284*cdf0e10cSrcweir 3285*cdf0e10cSrcweir // lang::XTypeProvider 3286*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( UnoDateFieldControl ) 3287*cdf0e10cSrcweir getCppuType( ( uno::Reference< awt::XDateField>* ) NULL ), 3288*cdf0e10cSrcweir UnoSpinFieldControl::getTypes() 3289*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 3290*cdf0e10cSrcweir 3291*cdf0e10cSrcweir void UnoDateFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException) 3292*cdf0e10cSrcweir { 3293*cdf0e10cSrcweir UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer ); 3294*cdf0e10cSrcweir 3295*cdf0e10cSrcweir uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY ); 3296*cdf0e10cSrcweir xField->setFirst( mnFirst ); 3297*cdf0e10cSrcweir xField->setLast( mnLast ); 3298*cdf0e10cSrcweir if ( mbLongFormat != 2 ) // not set 3299*cdf0e10cSrcweir xField->setLongFormat( mbLongFormat ); 3300*cdf0e10cSrcweir } 3301*cdf0e10cSrcweir 3302*cdf0e10cSrcweir 3303*cdf0e10cSrcweir void UnoDateFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException) 3304*cdf0e10cSrcweir { 3305*cdf0e10cSrcweir uno::Reference< awt::XVclWindowPeer > xPeer( getPeer(), uno::UNO_QUERY ); 3306*cdf0e10cSrcweir 3307*cdf0e10cSrcweir // also change the text property (#i25106#) 3308*cdf0e10cSrcweir if ( xPeer.is() ) 3309*cdf0e10cSrcweir { 3310*cdf0e10cSrcweir ::rtl::OUString sTextPropertyName = GetPropertyName( BASEPROPERTY_TEXT ); 3311*cdf0e10cSrcweir ImplSetPropertyValue( sTextPropertyName, xPeer->getProperty( sTextPropertyName ), sal_False ); 3312*cdf0e10cSrcweir } 3313*cdf0e10cSrcweir 3314*cdf0e10cSrcweir // re-calc the Date property 3315*cdf0e10cSrcweir uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY ); 3316*cdf0e10cSrcweir uno::Any aValue; 3317*cdf0e10cSrcweir if ( xField->isEmpty() ) 3318*cdf0e10cSrcweir { 3319*cdf0e10cSrcweir // the field says it's empty 3320*cdf0e10cSrcweir sal_Bool bEnforceFormat = sal_True; 3321*cdf0e10cSrcweir if ( xPeer.is() ) 3322*cdf0e10cSrcweir xPeer->getProperty( GetPropertyName( BASEPROPERTY_ENFORCE_FORMAT ) ) >>= bEnforceFormat; 3323*cdf0e10cSrcweir if ( !bEnforceFormat ) 3324*cdf0e10cSrcweir { 3325*cdf0e10cSrcweir // and it also says that it is currently accepting invalid inputs, without 3326*cdf0e10cSrcweir // forcing it to a valid date 3327*cdf0e10cSrcweir uno::Reference< awt::XTextComponent > xText( xPeer, uno::UNO_QUERY ); 3328*cdf0e10cSrcweir if ( xText.is() && xText->getText().getLength() ) 3329*cdf0e10cSrcweir // and in real, the text of the peer is *not* empty 3330*cdf0e10cSrcweir // -> simulate an invalid date, which is different from "no date" 3331*cdf0e10cSrcweir aValue <<= util::Date( 0, 0, 0 ); 3332*cdf0e10cSrcweir } 3333*cdf0e10cSrcweir } 3334*cdf0e10cSrcweir else 3335*cdf0e10cSrcweir aValue <<= xField->getDate(); 3336*cdf0e10cSrcweir 3337*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE ), aValue, sal_False ); 3338*cdf0e10cSrcweir 3339*cdf0e10cSrcweir // multiplex the event 3340*cdf0e10cSrcweir if ( GetTextListeners().getLength() ) 3341*cdf0e10cSrcweir GetTextListeners().textChanged( e ); 3342*cdf0e10cSrcweir } 3343*cdf0e10cSrcweir 3344*cdf0e10cSrcweir void UnoDateFieldControl::setDate( sal_Int32 Date ) throw(uno::RuntimeException) 3345*cdf0e10cSrcweir { 3346*cdf0e10cSrcweir uno::Any aAny; 3347*cdf0e10cSrcweir aAny <<= Date; 3348*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE ), aAny, sal_True ); 3349*cdf0e10cSrcweir } 3350*cdf0e10cSrcweir 3351*cdf0e10cSrcweir sal_Int32 UnoDateFieldControl::getDate() throw(uno::RuntimeException) 3352*cdf0e10cSrcweir { 3353*cdf0e10cSrcweir return ImplGetPropertyValue_INT32( BASEPROPERTY_DATE ); 3354*cdf0e10cSrcweir } 3355*cdf0e10cSrcweir 3356*cdf0e10cSrcweir void UnoDateFieldControl::setMin( sal_Int32 Date ) throw(uno::RuntimeException) 3357*cdf0e10cSrcweir { 3358*cdf0e10cSrcweir uno::Any aAny; 3359*cdf0e10cSrcweir aAny <<= Date; 3360*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMIN ), aAny, sal_True ); 3361*cdf0e10cSrcweir } 3362*cdf0e10cSrcweir 3363*cdf0e10cSrcweir sal_Int32 UnoDateFieldControl::getMin() throw(uno::RuntimeException) 3364*cdf0e10cSrcweir { 3365*cdf0e10cSrcweir return ImplGetPropertyValue_INT32( BASEPROPERTY_DATEMIN ); 3366*cdf0e10cSrcweir } 3367*cdf0e10cSrcweir 3368*cdf0e10cSrcweir void UnoDateFieldControl::setMax( sal_Int32 Date ) throw(uno::RuntimeException) 3369*cdf0e10cSrcweir { 3370*cdf0e10cSrcweir uno::Any aAny; 3371*cdf0e10cSrcweir aAny <<= Date; 3372*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMAX ), aAny, sal_True ); 3373*cdf0e10cSrcweir } 3374*cdf0e10cSrcweir 3375*cdf0e10cSrcweir sal_Int32 UnoDateFieldControl::getMax() throw(uno::RuntimeException) 3376*cdf0e10cSrcweir { 3377*cdf0e10cSrcweir return ImplGetPropertyValue_INT32( BASEPROPERTY_DATEMAX ); 3378*cdf0e10cSrcweir } 3379*cdf0e10cSrcweir 3380*cdf0e10cSrcweir void UnoDateFieldControl::setFirst( sal_Int32 Date ) throw(uno::RuntimeException) 3381*cdf0e10cSrcweir { 3382*cdf0e10cSrcweir mnFirst = Date; 3383*cdf0e10cSrcweir if ( getPeer().is() ) 3384*cdf0e10cSrcweir { 3385*cdf0e10cSrcweir uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY ); 3386*cdf0e10cSrcweir xField->setFirst( Date ); 3387*cdf0e10cSrcweir } 3388*cdf0e10cSrcweir } 3389*cdf0e10cSrcweir 3390*cdf0e10cSrcweir sal_Int32 UnoDateFieldControl::getFirst() throw(uno::RuntimeException) 3391*cdf0e10cSrcweir { 3392*cdf0e10cSrcweir return mnFirst; 3393*cdf0e10cSrcweir } 3394*cdf0e10cSrcweir 3395*cdf0e10cSrcweir void UnoDateFieldControl::setLast( sal_Int32 Date ) throw(uno::RuntimeException) 3396*cdf0e10cSrcweir { 3397*cdf0e10cSrcweir mnLast = Date; 3398*cdf0e10cSrcweir if ( getPeer().is() ) 3399*cdf0e10cSrcweir { 3400*cdf0e10cSrcweir uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY ); 3401*cdf0e10cSrcweir xField->setLast( Date ); 3402*cdf0e10cSrcweir } 3403*cdf0e10cSrcweir } 3404*cdf0e10cSrcweir 3405*cdf0e10cSrcweir sal_Int32 UnoDateFieldControl::getLast() throw(uno::RuntimeException) 3406*cdf0e10cSrcweir { 3407*cdf0e10cSrcweir return mnLast; 3408*cdf0e10cSrcweir } 3409*cdf0e10cSrcweir 3410*cdf0e10cSrcweir void UnoDateFieldControl::setLongFormat( sal_Bool bLong ) throw(uno::RuntimeException) 3411*cdf0e10cSrcweir { 3412*cdf0e10cSrcweir mbLongFormat = bLong; 3413*cdf0e10cSrcweir if ( getPeer().is() ) 3414*cdf0e10cSrcweir { 3415*cdf0e10cSrcweir uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY ); 3416*cdf0e10cSrcweir xField->setLongFormat( bLong ); 3417*cdf0e10cSrcweir } 3418*cdf0e10cSrcweir } 3419*cdf0e10cSrcweir 3420*cdf0e10cSrcweir sal_Bool UnoDateFieldControl::isLongFormat() throw(uno::RuntimeException) 3421*cdf0e10cSrcweir { 3422*cdf0e10cSrcweir return ( mbLongFormat != 2 ) ? mbLongFormat : sal_False; 3423*cdf0e10cSrcweir } 3424*cdf0e10cSrcweir 3425*cdf0e10cSrcweir void UnoDateFieldControl::setEmpty() throw(uno::RuntimeException) 3426*cdf0e10cSrcweir { 3427*cdf0e10cSrcweir if ( getPeer().is() ) 3428*cdf0e10cSrcweir { 3429*cdf0e10cSrcweir uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY ); 3430*cdf0e10cSrcweir xField->setEmpty(); 3431*cdf0e10cSrcweir } 3432*cdf0e10cSrcweir } 3433*cdf0e10cSrcweir 3434*cdf0e10cSrcweir sal_Bool UnoDateFieldControl::isEmpty() throw(uno::RuntimeException) 3435*cdf0e10cSrcweir { 3436*cdf0e10cSrcweir sal_Bool bEmpty = sal_False; 3437*cdf0e10cSrcweir if ( getPeer().is() ) 3438*cdf0e10cSrcweir { 3439*cdf0e10cSrcweir uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY ); 3440*cdf0e10cSrcweir bEmpty = xField->isEmpty(); 3441*cdf0e10cSrcweir } 3442*cdf0e10cSrcweir return bEmpty; 3443*cdf0e10cSrcweir } 3444*cdf0e10cSrcweir 3445*cdf0e10cSrcweir void UnoDateFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException) 3446*cdf0e10cSrcweir { 3447*cdf0e10cSrcweir uno::Any aAny; 3448*cdf0e10cSrcweir aAny <<= bStrict; 3449*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True ); 3450*cdf0e10cSrcweir } 3451*cdf0e10cSrcweir 3452*cdf0e10cSrcweir sal_Bool UnoDateFieldControl::isStrictFormat() throw(uno::RuntimeException) 3453*cdf0e10cSrcweir { 3454*cdf0e10cSrcweir return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT ); 3455*cdf0e10cSrcweir } 3456*cdf0e10cSrcweir 3457*cdf0e10cSrcweir // ---------------------------------------------------- 3458*cdf0e10cSrcweir // class UnoControlTimeFieldModel 3459*cdf0e10cSrcweir // ---------------------------------------------------- 3460*cdf0e10cSrcweir UnoControlTimeFieldModel::UnoControlTimeFieldModel( const Reference< XMultiServiceFactory >& i_factory ) 3461*cdf0e10cSrcweir :UnoControlModel( i_factory ) 3462*cdf0e10cSrcweir { 3463*cdf0e10cSrcweir UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXTimeField ); 3464*cdf0e10cSrcweir } 3465*cdf0e10cSrcweir 3466*cdf0e10cSrcweir ::rtl::OUString UnoControlTimeFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException) 3467*cdf0e10cSrcweir { 3468*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( szServiceName_UnoControlTimeFieldModel ); 3469*cdf0e10cSrcweir } 3470*cdf0e10cSrcweir 3471*cdf0e10cSrcweir uno::Any UnoControlTimeFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const 3472*cdf0e10cSrcweir { 3473*cdf0e10cSrcweir if ( nPropId == BASEPROPERTY_DEFAULTCONTROL ) 3474*cdf0e10cSrcweir { 3475*cdf0e10cSrcweir uno::Any aAny; 3476*cdf0e10cSrcweir aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlTimeField ); 3477*cdf0e10cSrcweir return aAny; 3478*cdf0e10cSrcweir } 3479*cdf0e10cSrcweir return UnoControlModel::ImplGetDefaultValue( nPropId ); 3480*cdf0e10cSrcweir } 3481*cdf0e10cSrcweir 3482*cdf0e10cSrcweir 3483*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& UnoControlTimeFieldModel::getInfoHelper() 3484*cdf0e10cSrcweir { 3485*cdf0e10cSrcweir static UnoPropertyArrayHelper* pHelper = NULL; 3486*cdf0e10cSrcweir if ( !pHelper ) 3487*cdf0e10cSrcweir { 3488*cdf0e10cSrcweir uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); 3489*cdf0e10cSrcweir pHelper = new UnoPropertyArrayHelper( aIDs ); 3490*cdf0e10cSrcweir } 3491*cdf0e10cSrcweir return *pHelper; 3492*cdf0e10cSrcweir } 3493*cdf0e10cSrcweir 3494*cdf0e10cSrcweir // beans::XMultiPropertySet 3495*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > UnoControlTimeFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException) 3496*cdf0e10cSrcweir { 3497*cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 3498*cdf0e10cSrcweir return xInfo; 3499*cdf0e10cSrcweir } 3500*cdf0e10cSrcweir 3501*cdf0e10cSrcweir 3502*cdf0e10cSrcweir 3503*cdf0e10cSrcweir // ---------------------------------------------------- 3504*cdf0e10cSrcweir // class UnoTimeFieldControl 3505*cdf0e10cSrcweir // ---------------------------------------------------- 3506*cdf0e10cSrcweir UnoTimeFieldControl::UnoTimeFieldControl( const Reference< XMultiServiceFactory >& i_factory ) 3507*cdf0e10cSrcweir :UnoSpinFieldControl( i_factory ) 3508*cdf0e10cSrcweir { 3509*cdf0e10cSrcweir mnFirst = Time( 0, 0 ).GetTime(); 3510*cdf0e10cSrcweir mnLast = Time( 23, 59, 59, 99 ).GetTime(); 3511*cdf0e10cSrcweir } 3512*cdf0e10cSrcweir 3513*cdf0e10cSrcweir ::rtl::OUString UnoTimeFieldControl::GetComponentServiceName() 3514*cdf0e10cSrcweir { 3515*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "timefield" ); 3516*cdf0e10cSrcweir } 3517*cdf0e10cSrcweir 3518*cdf0e10cSrcweir // uno::XInterface 3519*cdf0e10cSrcweir uno::Any UnoTimeFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException) 3520*cdf0e10cSrcweir { 3521*cdf0e10cSrcweir uno::Any aRet = ::cppu::queryInterface( rType, 3522*cdf0e10cSrcweir SAL_STATIC_CAST( awt::XTimeField*, this ) ); 3523*cdf0e10cSrcweir return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType )); 3524*cdf0e10cSrcweir } 3525*cdf0e10cSrcweir 3526*cdf0e10cSrcweir // lang::XTypeProvider 3527*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( UnoTimeFieldControl ) 3528*cdf0e10cSrcweir getCppuType( ( uno::Reference< awt::XTimeField>* ) NULL ), 3529*cdf0e10cSrcweir UnoSpinFieldControl::getTypes() 3530*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 3531*cdf0e10cSrcweir 3532*cdf0e10cSrcweir void UnoTimeFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException) 3533*cdf0e10cSrcweir { 3534*cdf0e10cSrcweir UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer ); 3535*cdf0e10cSrcweir 3536*cdf0e10cSrcweir uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY ); 3537*cdf0e10cSrcweir xField->setFirst( mnFirst ); 3538*cdf0e10cSrcweir xField->setLast( mnLast ); 3539*cdf0e10cSrcweir } 3540*cdf0e10cSrcweir 3541*cdf0e10cSrcweir void UnoTimeFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException) 3542*cdf0e10cSrcweir { 3543*cdf0e10cSrcweir // also change the text property (#i25106#) 3544*cdf0e10cSrcweir uno::Reference< awt::XVclWindowPeer > xPeer( getPeer(), uno::UNO_QUERY ); 3545*cdf0e10cSrcweir ::rtl::OUString sTextPropertyName = GetPropertyName( BASEPROPERTY_TEXT ); 3546*cdf0e10cSrcweir ImplSetPropertyValue( sTextPropertyName, xPeer->getProperty( sTextPropertyName ), sal_False ); 3547*cdf0e10cSrcweir 3548*cdf0e10cSrcweir // re-calc the Time property 3549*cdf0e10cSrcweir uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY ); 3550*cdf0e10cSrcweir uno::Any aValue; 3551*cdf0e10cSrcweir if ( !xField->isEmpty() ) 3552*cdf0e10cSrcweir aValue <<= xField->getTime(); 3553*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME ), aValue, sal_False ); 3554*cdf0e10cSrcweir 3555*cdf0e10cSrcweir // multiplex the event 3556*cdf0e10cSrcweir if ( GetTextListeners().getLength() ) 3557*cdf0e10cSrcweir GetTextListeners().textChanged( e ); 3558*cdf0e10cSrcweir } 3559*cdf0e10cSrcweir 3560*cdf0e10cSrcweir void UnoTimeFieldControl::setTime( sal_Int32 Time ) throw(uno::RuntimeException) 3561*cdf0e10cSrcweir { 3562*cdf0e10cSrcweir uno::Any aAny; 3563*cdf0e10cSrcweir aAny <<= Time; 3564*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME ), aAny, sal_True ); 3565*cdf0e10cSrcweir } 3566*cdf0e10cSrcweir 3567*cdf0e10cSrcweir sal_Int32 UnoTimeFieldControl::getTime() throw(uno::RuntimeException) 3568*cdf0e10cSrcweir { 3569*cdf0e10cSrcweir return ImplGetPropertyValue_INT32( BASEPROPERTY_TIME ); 3570*cdf0e10cSrcweir } 3571*cdf0e10cSrcweir 3572*cdf0e10cSrcweir void UnoTimeFieldControl::setMin( sal_Int32 Time ) throw(uno::RuntimeException) 3573*cdf0e10cSrcweir { 3574*cdf0e10cSrcweir uno::Any aAny; 3575*cdf0e10cSrcweir aAny <<= Time; 3576*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMIN ), aAny, sal_True ); 3577*cdf0e10cSrcweir } 3578*cdf0e10cSrcweir 3579*cdf0e10cSrcweir sal_Int32 UnoTimeFieldControl::getMin() throw(uno::RuntimeException) 3580*cdf0e10cSrcweir { 3581*cdf0e10cSrcweir return ImplGetPropertyValue_INT32( BASEPROPERTY_TIMEMIN ); 3582*cdf0e10cSrcweir } 3583*cdf0e10cSrcweir 3584*cdf0e10cSrcweir void UnoTimeFieldControl::setMax( sal_Int32 Time ) throw(uno::RuntimeException) 3585*cdf0e10cSrcweir { 3586*cdf0e10cSrcweir uno::Any aAny; 3587*cdf0e10cSrcweir aAny <<= Time; 3588*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMAX ), aAny, sal_True ); 3589*cdf0e10cSrcweir } 3590*cdf0e10cSrcweir 3591*cdf0e10cSrcweir sal_Int32 UnoTimeFieldControl::getMax() throw(uno::RuntimeException) 3592*cdf0e10cSrcweir { 3593*cdf0e10cSrcweir return ImplGetPropertyValue_INT32( BASEPROPERTY_TIMEMAX ); 3594*cdf0e10cSrcweir } 3595*cdf0e10cSrcweir 3596*cdf0e10cSrcweir void UnoTimeFieldControl::setFirst( sal_Int32 Time ) throw(uno::RuntimeException) 3597*cdf0e10cSrcweir { 3598*cdf0e10cSrcweir mnFirst = Time; 3599*cdf0e10cSrcweir if ( getPeer().is() ) 3600*cdf0e10cSrcweir { 3601*cdf0e10cSrcweir uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY ); 3602*cdf0e10cSrcweir xField->setFirst( mnFirst ); 3603*cdf0e10cSrcweir } 3604*cdf0e10cSrcweir } 3605*cdf0e10cSrcweir 3606*cdf0e10cSrcweir sal_Int32 UnoTimeFieldControl::getFirst() throw(uno::RuntimeException) 3607*cdf0e10cSrcweir { 3608*cdf0e10cSrcweir return mnFirst; 3609*cdf0e10cSrcweir } 3610*cdf0e10cSrcweir 3611*cdf0e10cSrcweir void UnoTimeFieldControl::setLast( sal_Int32 Time ) throw(uno::RuntimeException) 3612*cdf0e10cSrcweir { 3613*cdf0e10cSrcweir mnLast = Time; 3614*cdf0e10cSrcweir if ( getPeer().is() ) 3615*cdf0e10cSrcweir { 3616*cdf0e10cSrcweir uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY ); 3617*cdf0e10cSrcweir xField->setFirst( mnLast ); 3618*cdf0e10cSrcweir } 3619*cdf0e10cSrcweir } 3620*cdf0e10cSrcweir 3621*cdf0e10cSrcweir sal_Int32 UnoTimeFieldControl::getLast() throw(uno::RuntimeException) 3622*cdf0e10cSrcweir { 3623*cdf0e10cSrcweir return mnLast; 3624*cdf0e10cSrcweir } 3625*cdf0e10cSrcweir 3626*cdf0e10cSrcweir void UnoTimeFieldControl::setEmpty() throw(uno::RuntimeException) 3627*cdf0e10cSrcweir { 3628*cdf0e10cSrcweir if ( getPeer().is() ) 3629*cdf0e10cSrcweir { 3630*cdf0e10cSrcweir uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY ); 3631*cdf0e10cSrcweir xField->setEmpty(); 3632*cdf0e10cSrcweir } 3633*cdf0e10cSrcweir } 3634*cdf0e10cSrcweir 3635*cdf0e10cSrcweir sal_Bool UnoTimeFieldControl::isEmpty() throw(uno::RuntimeException) 3636*cdf0e10cSrcweir { 3637*cdf0e10cSrcweir sal_Bool bEmpty = sal_False; 3638*cdf0e10cSrcweir if ( getPeer().is() ) 3639*cdf0e10cSrcweir { 3640*cdf0e10cSrcweir uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY ); 3641*cdf0e10cSrcweir bEmpty = xField->isEmpty(); 3642*cdf0e10cSrcweir } 3643*cdf0e10cSrcweir return bEmpty; 3644*cdf0e10cSrcweir } 3645*cdf0e10cSrcweir 3646*cdf0e10cSrcweir void UnoTimeFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException) 3647*cdf0e10cSrcweir { 3648*cdf0e10cSrcweir uno::Any aAny; 3649*cdf0e10cSrcweir aAny <<= bStrict; 3650*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True ); 3651*cdf0e10cSrcweir } 3652*cdf0e10cSrcweir 3653*cdf0e10cSrcweir sal_Bool UnoTimeFieldControl::isStrictFormat() throw(uno::RuntimeException) 3654*cdf0e10cSrcweir { 3655*cdf0e10cSrcweir return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT ); 3656*cdf0e10cSrcweir } 3657*cdf0e10cSrcweir 3658*cdf0e10cSrcweir // ---------------------------------------------------- 3659*cdf0e10cSrcweir // class UnoControlNumericFieldModel 3660*cdf0e10cSrcweir // ---------------------------------------------------- 3661*cdf0e10cSrcweir UnoControlNumericFieldModel::UnoControlNumericFieldModel( const Reference< XMultiServiceFactory >& i_factory ) 3662*cdf0e10cSrcweir :UnoControlModel( i_factory ) 3663*cdf0e10cSrcweir { 3664*cdf0e10cSrcweir UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXNumericField ); 3665*cdf0e10cSrcweir } 3666*cdf0e10cSrcweir 3667*cdf0e10cSrcweir ::rtl::OUString UnoControlNumericFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException) 3668*cdf0e10cSrcweir { 3669*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( szServiceName_UnoControlNumericFieldModel ); 3670*cdf0e10cSrcweir } 3671*cdf0e10cSrcweir 3672*cdf0e10cSrcweir uno::Any UnoControlNumericFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const 3673*cdf0e10cSrcweir { 3674*cdf0e10cSrcweir if ( nPropId == BASEPROPERTY_DEFAULTCONTROL ) 3675*cdf0e10cSrcweir { 3676*cdf0e10cSrcweir uno::Any aAny; 3677*cdf0e10cSrcweir aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlNumericField ); 3678*cdf0e10cSrcweir return aAny; 3679*cdf0e10cSrcweir } 3680*cdf0e10cSrcweir return UnoControlModel::ImplGetDefaultValue( nPropId ); 3681*cdf0e10cSrcweir } 3682*cdf0e10cSrcweir 3683*cdf0e10cSrcweir 3684*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& UnoControlNumericFieldModel::getInfoHelper() 3685*cdf0e10cSrcweir { 3686*cdf0e10cSrcweir static UnoPropertyArrayHelper* pHelper = NULL; 3687*cdf0e10cSrcweir if ( !pHelper ) 3688*cdf0e10cSrcweir { 3689*cdf0e10cSrcweir uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); 3690*cdf0e10cSrcweir pHelper = new UnoPropertyArrayHelper( aIDs ); 3691*cdf0e10cSrcweir } 3692*cdf0e10cSrcweir return *pHelper; 3693*cdf0e10cSrcweir } 3694*cdf0e10cSrcweir 3695*cdf0e10cSrcweir // beans::XMultiPropertySet 3696*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > UnoControlNumericFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException) 3697*cdf0e10cSrcweir { 3698*cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 3699*cdf0e10cSrcweir return xInfo; 3700*cdf0e10cSrcweir } 3701*cdf0e10cSrcweir 3702*cdf0e10cSrcweir 3703*cdf0e10cSrcweir 3704*cdf0e10cSrcweir // ---------------------------------------------------- 3705*cdf0e10cSrcweir // class UnoNumericFieldControl 3706*cdf0e10cSrcweir // ---------------------------------------------------- 3707*cdf0e10cSrcweir UnoNumericFieldControl::UnoNumericFieldControl( const Reference< XMultiServiceFactory >& i_factory ) 3708*cdf0e10cSrcweir :UnoSpinFieldControl( i_factory ) 3709*cdf0e10cSrcweir { 3710*cdf0e10cSrcweir mnFirst = 0; 3711*cdf0e10cSrcweir mnLast = 0x7FFFFFFF; 3712*cdf0e10cSrcweir } 3713*cdf0e10cSrcweir 3714*cdf0e10cSrcweir ::rtl::OUString UnoNumericFieldControl::GetComponentServiceName() 3715*cdf0e10cSrcweir { 3716*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "numericfield" ); 3717*cdf0e10cSrcweir } 3718*cdf0e10cSrcweir 3719*cdf0e10cSrcweir // uno::XInterface 3720*cdf0e10cSrcweir uno::Any UnoNumericFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException) 3721*cdf0e10cSrcweir { 3722*cdf0e10cSrcweir uno::Any aRet = ::cppu::queryInterface( rType, 3723*cdf0e10cSrcweir SAL_STATIC_CAST( awt::XNumericField*, this ) ); 3724*cdf0e10cSrcweir return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType )); 3725*cdf0e10cSrcweir } 3726*cdf0e10cSrcweir 3727*cdf0e10cSrcweir // lang::XTypeProvider 3728*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( UnoNumericFieldControl ) 3729*cdf0e10cSrcweir getCppuType( ( uno::Reference< awt::XNumericField>* ) NULL ), 3730*cdf0e10cSrcweir UnoSpinFieldControl::getTypes() 3731*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 3732*cdf0e10cSrcweir 3733*cdf0e10cSrcweir void UnoNumericFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException) 3734*cdf0e10cSrcweir { 3735*cdf0e10cSrcweir UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer ); 3736*cdf0e10cSrcweir 3737*cdf0e10cSrcweir uno::Reference < awt::XNumericField > xField( getPeer(), uno::UNO_QUERY ); 3738*cdf0e10cSrcweir xField->setFirst( mnFirst ); 3739*cdf0e10cSrcweir xField->setLast( mnLast ); 3740*cdf0e10cSrcweir } 3741*cdf0e10cSrcweir 3742*cdf0e10cSrcweir 3743*cdf0e10cSrcweir void UnoNumericFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException) 3744*cdf0e10cSrcweir { 3745*cdf0e10cSrcweir uno::Reference < awt::XNumericField > xField( getPeer(), uno::UNO_QUERY ); 3746*cdf0e10cSrcweir uno::Any aAny; 3747*cdf0e10cSrcweir aAny <<= xField->getValue(); 3748*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, sal_False ); 3749*cdf0e10cSrcweir 3750*cdf0e10cSrcweir if ( GetTextListeners().getLength() ) 3751*cdf0e10cSrcweir GetTextListeners().textChanged( e ); 3752*cdf0e10cSrcweir } 3753*cdf0e10cSrcweir 3754*cdf0e10cSrcweir void UnoNumericFieldControl::setValue( double Value ) throw(uno::RuntimeException) 3755*cdf0e10cSrcweir { 3756*cdf0e10cSrcweir uno::Any aAny; 3757*cdf0e10cSrcweir aAny <<= Value; 3758*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, sal_True ); 3759*cdf0e10cSrcweir } 3760*cdf0e10cSrcweir 3761*cdf0e10cSrcweir double UnoNumericFieldControl::getValue() throw(uno::RuntimeException) 3762*cdf0e10cSrcweir { 3763*cdf0e10cSrcweir return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE ); 3764*cdf0e10cSrcweir } 3765*cdf0e10cSrcweir 3766*cdf0e10cSrcweir void UnoNumericFieldControl::setMin( double Value ) throw(uno::RuntimeException) 3767*cdf0e10cSrcweir { 3768*cdf0e10cSrcweir uno::Any aAny; 3769*cdf0e10cSrcweir aAny <<= Value; 3770*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE ), aAny, sal_True ); 3771*cdf0e10cSrcweir } 3772*cdf0e10cSrcweir 3773*cdf0e10cSrcweir double UnoNumericFieldControl::getMin() throw(uno::RuntimeException) 3774*cdf0e10cSrcweir { 3775*cdf0e10cSrcweir return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE ); 3776*cdf0e10cSrcweir } 3777*cdf0e10cSrcweir 3778*cdf0e10cSrcweir void UnoNumericFieldControl::setMax( double Value ) throw(uno::RuntimeException) 3779*cdf0e10cSrcweir { 3780*cdf0e10cSrcweir uno::Any aAny; 3781*cdf0e10cSrcweir aAny <<= Value; 3782*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE ), aAny, sal_True ); 3783*cdf0e10cSrcweir } 3784*cdf0e10cSrcweir 3785*cdf0e10cSrcweir double UnoNumericFieldControl::getMax() throw(uno::RuntimeException) 3786*cdf0e10cSrcweir { 3787*cdf0e10cSrcweir return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE ); 3788*cdf0e10cSrcweir } 3789*cdf0e10cSrcweir 3790*cdf0e10cSrcweir void UnoNumericFieldControl::setFirst( double Value ) throw(uno::RuntimeException) 3791*cdf0e10cSrcweir { 3792*cdf0e10cSrcweir mnFirst = Value; 3793*cdf0e10cSrcweir if ( getPeer().is() ) 3794*cdf0e10cSrcweir { 3795*cdf0e10cSrcweir uno::Reference < awt::XNumericField > xField( getPeer(), uno::UNO_QUERY ); 3796*cdf0e10cSrcweir xField->setFirst( mnFirst ); 3797*cdf0e10cSrcweir } 3798*cdf0e10cSrcweir } 3799*cdf0e10cSrcweir 3800*cdf0e10cSrcweir double UnoNumericFieldControl::getFirst() throw(uno::RuntimeException) 3801*cdf0e10cSrcweir { 3802*cdf0e10cSrcweir return mnFirst; 3803*cdf0e10cSrcweir } 3804*cdf0e10cSrcweir 3805*cdf0e10cSrcweir void UnoNumericFieldControl::setLast( double Value ) throw(uno::RuntimeException) 3806*cdf0e10cSrcweir { 3807*cdf0e10cSrcweir mnLast = Value; 3808*cdf0e10cSrcweir if ( getPeer().is() ) 3809*cdf0e10cSrcweir { 3810*cdf0e10cSrcweir uno::Reference < awt::XNumericField > xField( getPeer(), uno::UNO_QUERY ); 3811*cdf0e10cSrcweir xField->setLast( mnLast ); 3812*cdf0e10cSrcweir } 3813*cdf0e10cSrcweir } 3814*cdf0e10cSrcweir 3815*cdf0e10cSrcweir double UnoNumericFieldControl::getLast() throw(uno::RuntimeException) 3816*cdf0e10cSrcweir { 3817*cdf0e10cSrcweir return mnLast; 3818*cdf0e10cSrcweir } 3819*cdf0e10cSrcweir 3820*cdf0e10cSrcweir void UnoNumericFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException) 3821*cdf0e10cSrcweir { 3822*cdf0e10cSrcweir uno::Any aAny; 3823*cdf0e10cSrcweir aAny <<= bStrict; 3824*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True ); 3825*cdf0e10cSrcweir } 3826*cdf0e10cSrcweir 3827*cdf0e10cSrcweir sal_Bool UnoNumericFieldControl::isStrictFormat() throw(uno::RuntimeException) 3828*cdf0e10cSrcweir { 3829*cdf0e10cSrcweir return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT ); 3830*cdf0e10cSrcweir } 3831*cdf0e10cSrcweir 3832*cdf0e10cSrcweir void UnoNumericFieldControl::setSpinSize( double Digits ) throw(uno::RuntimeException) 3833*cdf0e10cSrcweir { 3834*cdf0e10cSrcweir uno::Any aAny; 3835*cdf0e10cSrcweir aAny <<= Digits; 3836*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE ), aAny, sal_True ); 3837*cdf0e10cSrcweir } 3838*cdf0e10cSrcweir 3839*cdf0e10cSrcweir double UnoNumericFieldControl::getSpinSize() throw(uno::RuntimeException) 3840*cdf0e10cSrcweir { 3841*cdf0e10cSrcweir return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE ); 3842*cdf0e10cSrcweir } 3843*cdf0e10cSrcweir 3844*cdf0e10cSrcweir void UnoNumericFieldControl::setDecimalDigits( sal_Int16 Digits ) throw(uno::RuntimeException) 3845*cdf0e10cSrcweir { 3846*cdf0e10cSrcweir uno::Any aAny; 3847*cdf0e10cSrcweir aAny <<= Digits; 3848*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY ), aAny, sal_True ); 3849*cdf0e10cSrcweir } 3850*cdf0e10cSrcweir 3851*cdf0e10cSrcweir sal_Int16 UnoNumericFieldControl::getDecimalDigits() throw(uno::RuntimeException) 3852*cdf0e10cSrcweir { 3853*cdf0e10cSrcweir return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY ); 3854*cdf0e10cSrcweir } 3855*cdf0e10cSrcweir 3856*cdf0e10cSrcweir // ---------------------------------------------------- 3857*cdf0e10cSrcweir // class UnoControlCurrencyFieldModel 3858*cdf0e10cSrcweir // ---------------------------------------------------- 3859*cdf0e10cSrcweir UnoControlCurrencyFieldModel::UnoControlCurrencyFieldModel( const Reference< XMultiServiceFactory >& i_factory ) 3860*cdf0e10cSrcweir :UnoControlModel( i_factory ) 3861*cdf0e10cSrcweir { 3862*cdf0e10cSrcweir UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCurrencyField ); 3863*cdf0e10cSrcweir } 3864*cdf0e10cSrcweir 3865*cdf0e10cSrcweir ::rtl::OUString UnoControlCurrencyFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException) 3866*cdf0e10cSrcweir { 3867*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( szServiceName_UnoControlCurrencyFieldModel ); 3868*cdf0e10cSrcweir } 3869*cdf0e10cSrcweir 3870*cdf0e10cSrcweir uno::Any UnoControlCurrencyFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const 3871*cdf0e10cSrcweir { 3872*cdf0e10cSrcweir if ( nPropId == BASEPROPERTY_DEFAULTCONTROL ) 3873*cdf0e10cSrcweir { 3874*cdf0e10cSrcweir uno::Any aAny; 3875*cdf0e10cSrcweir aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlCurrencyField ); 3876*cdf0e10cSrcweir return aAny; 3877*cdf0e10cSrcweir } 3878*cdf0e10cSrcweir if ( nPropId == BASEPROPERTY_CURSYM_POSITION ) 3879*cdf0e10cSrcweir { 3880*cdf0e10cSrcweir uno::Any aAny; 3881*cdf0e10cSrcweir aAny <<= (sal_Bool)sal_False; 3882*cdf0e10cSrcweir return aAny; 3883*cdf0e10cSrcweir } 3884*cdf0e10cSrcweir 3885*cdf0e10cSrcweir return UnoControlModel::ImplGetDefaultValue( nPropId ); 3886*cdf0e10cSrcweir } 3887*cdf0e10cSrcweir 3888*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& UnoControlCurrencyFieldModel::getInfoHelper() 3889*cdf0e10cSrcweir { 3890*cdf0e10cSrcweir static UnoPropertyArrayHelper* pHelper = NULL; 3891*cdf0e10cSrcweir if ( !pHelper ) 3892*cdf0e10cSrcweir { 3893*cdf0e10cSrcweir uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); 3894*cdf0e10cSrcweir pHelper = new UnoPropertyArrayHelper( aIDs ); 3895*cdf0e10cSrcweir } 3896*cdf0e10cSrcweir return *pHelper; 3897*cdf0e10cSrcweir } 3898*cdf0e10cSrcweir 3899*cdf0e10cSrcweir // beans::XMultiPropertySet 3900*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > UnoControlCurrencyFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException) 3901*cdf0e10cSrcweir { 3902*cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 3903*cdf0e10cSrcweir return xInfo; 3904*cdf0e10cSrcweir } 3905*cdf0e10cSrcweir 3906*cdf0e10cSrcweir // ---------------------------------------------------- 3907*cdf0e10cSrcweir // class UnoCurrencyFieldControl 3908*cdf0e10cSrcweir // ---------------------------------------------------- 3909*cdf0e10cSrcweir UnoCurrencyFieldControl::UnoCurrencyFieldControl( const Reference< XMultiServiceFactory >& i_factory ) 3910*cdf0e10cSrcweir :UnoSpinFieldControl( i_factory ) 3911*cdf0e10cSrcweir { 3912*cdf0e10cSrcweir mnFirst = 0; 3913*cdf0e10cSrcweir mnLast = 0x7FFFFFFF; 3914*cdf0e10cSrcweir } 3915*cdf0e10cSrcweir 3916*cdf0e10cSrcweir ::rtl::OUString UnoCurrencyFieldControl::GetComponentServiceName() 3917*cdf0e10cSrcweir { 3918*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "longcurrencyfield" ); 3919*cdf0e10cSrcweir } 3920*cdf0e10cSrcweir 3921*cdf0e10cSrcweir // uno::XInterface 3922*cdf0e10cSrcweir uno::Any UnoCurrencyFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException) 3923*cdf0e10cSrcweir { 3924*cdf0e10cSrcweir uno::Any aRet = ::cppu::queryInterface( rType, 3925*cdf0e10cSrcweir SAL_STATIC_CAST( awt::XCurrencyField*, this ) ); 3926*cdf0e10cSrcweir return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType )); 3927*cdf0e10cSrcweir } 3928*cdf0e10cSrcweir 3929*cdf0e10cSrcweir // lang::XTypeProvider 3930*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( UnoCurrencyFieldControl ) 3931*cdf0e10cSrcweir getCppuType( ( uno::Reference< awt::XCurrencyField>* ) NULL ), 3932*cdf0e10cSrcweir UnoSpinFieldControl::getTypes() 3933*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 3934*cdf0e10cSrcweir 3935*cdf0e10cSrcweir void UnoCurrencyFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException) 3936*cdf0e10cSrcweir { 3937*cdf0e10cSrcweir UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer ); 3938*cdf0e10cSrcweir 3939*cdf0e10cSrcweir uno::Reference < awt::XCurrencyField > xField( getPeer(), uno::UNO_QUERY ); 3940*cdf0e10cSrcweir xField->setFirst( mnFirst ); 3941*cdf0e10cSrcweir xField->setLast( mnLast ); 3942*cdf0e10cSrcweir } 3943*cdf0e10cSrcweir 3944*cdf0e10cSrcweir void UnoCurrencyFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException) 3945*cdf0e10cSrcweir { 3946*cdf0e10cSrcweir uno::Reference < awt::XCurrencyField > xField( getPeer(), uno::UNO_QUERY ); 3947*cdf0e10cSrcweir uno::Any aAny; 3948*cdf0e10cSrcweir aAny <<= xField->getValue(); 3949*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, sal_False ); 3950*cdf0e10cSrcweir 3951*cdf0e10cSrcweir if ( GetTextListeners().getLength() ) 3952*cdf0e10cSrcweir GetTextListeners().textChanged( e ); 3953*cdf0e10cSrcweir } 3954*cdf0e10cSrcweir 3955*cdf0e10cSrcweir void UnoCurrencyFieldControl::setValue( double Value ) throw(uno::RuntimeException) 3956*cdf0e10cSrcweir { 3957*cdf0e10cSrcweir uno::Any aAny; 3958*cdf0e10cSrcweir aAny <<= Value; 3959*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, sal_True ); 3960*cdf0e10cSrcweir } 3961*cdf0e10cSrcweir 3962*cdf0e10cSrcweir double UnoCurrencyFieldControl::getValue() throw(uno::RuntimeException) 3963*cdf0e10cSrcweir { 3964*cdf0e10cSrcweir return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE ); 3965*cdf0e10cSrcweir } 3966*cdf0e10cSrcweir 3967*cdf0e10cSrcweir void UnoCurrencyFieldControl::setMin( double Value ) throw(uno::RuntimeException) 3968*cdf0e10cSrcweir { 3969*cdf0e10cSrcweir uno::Any aAny; 3970*cdf0e10cSrcweir aAny <<= Value; 3971*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE ), aAny, sal_True ); 3972*cdf0e10cSrcweir } 3973*cdf0e10cSrcweir 3974*cdf0e10cSrcweir double UnoCurrencyFieldControl::getMin() throw(uno::RuntimeException) 3975*cdf0e10cSrcweir { 3976*cdf0e10cSrcweir return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE ); 3977*cdf0e10cSrcweir } 3978*cdf0e10cSrcweir 3979*cdf0e10cSrcweir void UnoCurrencyFieldControl::setMax( double Value ) throw(uno::RuntimeException) 3980*cdf0e10cSrcweir { 3981*cdf0e10cSrcweir uno::Any aAny; 3982*cdf0e10cSrcweir aAny <<= Value; 3983*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE ), aAny, sal_True ); 3984*cdf0e10cSrcweir } 3985*cdf0e10cSrcweir 3986*cdf0e10cSrcweir double UnoCurrencyFieldControl::getMax() throw(uno::RuntimeException) 3987*cdf0e10cSrcweir { 3988*cdf0e10cSrcweir return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE ); 3989*cdf0e10cSrcweir } 3990*cdf0e10cSrcweir 3991*cdf0e10cSrcweir void UnoCurrencyFieldControl::setFirst( double Value ) throw(uno::RuntimeException) 3992*cdf0e10cSrcweir { 3993*cdf0e10cSrcweir mnFirst = Value; 3994*cdf0e10cSrcweir if ( getPeer().is() ) 3995*cdf0e10cSrcweir { 3996*cdf0e10cSrcweir uno::Reference < awt::XCurrencyField > xField( getPeer(), uno::UNO_QUERY ); 3997*cdf0e10cSrcweir xField->setFirst( mnFirst ); 3998*cdf0e10cSrcweir } 3999*cdf0e10cSrcweir } 4000*cdf0e10cSrcweir 4001*cdf0e10cSrcweir double UnoCurrencyFieldControl::getFirst() throw(uno::RuntimeException) 4002*cdf0e10cSrcweir { 4003*cdf0e10cSrcweir return mnFirst; 4004*cdf0e10cSrcweir } 4005*cdf0e10cSrcweir 4006*cdf0e10cSrcweir void UnoCurrencyFieldControl::setLast( double Value ) throw(uno::RuntimeException) 4007*cdf0e10cSrcweir { 4008*cdf0e10cSrcweir mnLast = Value; 4009*cdf0e10cSrcweir if ( getPeer().is() ) 4010*cdf0e10cSrcweir { 4011*cdf0e10cSrcweir uno::Reference < awt::XCurrencyField > xField( getPeer(), uno::UNO_QUERY ); 4012*cdf0e10cSrcweir xField->setLast( mnLast ); 4013*cdf0e10cSrcweir } 4014*cdf0e10cSrcweir } 4015*cdf0e10cSrcweir 4016*cdf0e10cSrcweir double UnoCurrencyFieldControl::getLast() throw(uno::RuntimeException) 4017*cdf0e10cSrcweir { 4018*cdf0e10cSrcweir return mnLast; 4019*cdf0e10cSrcweir } 4020*cdf0e10cSrcweir 4021*cdf0e10cSrcweir void UnoCurrencyFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException) 4022*cdf0e10cSrcweir { 4023*cdf0e10cSrcweir uno::Any aAny; 4024*cdf0e10cSrcweir aAny <<= bStrict; 4025*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True ); 4026*cdf0e10cSrcweir } 4027*cdf0e10cSrcweir 4028*cdf0e10cSrcweir sal_Bool UnoCurrencyFieldControl::isStrictFormat() throw(uno::RuntimeException) 4029*cdf0e10cSrcweir { 4030*cdf0e10cSrcweir return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT ); 4031*cdf0e10cSrcweir } 4032*cdf0e10cSrcweir 4033*cdf0e10cSrcweir void UnoCurrencyFieldControl::setSpinSize( double Digits ) throw(uno::RuntimeException) 4034*cdf0e10cSrcweir { 4035*cdf0e10cSrcweir uno::Any aAny; 4036*cdf0e10cSrcweir aAny <<= Digits; 4037*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE ), aAny, sal_True ); 4038*cdf0e10cSrcweir } 4039*cdf0e10cSrcweir 4040*cdf0e10cSrcweir double UnoCurrencyFieldControl::getSpinSize() throw(uno::RuntimeException) 4041*cdf0e10cSrcweir { 4042*cdf0e10cSrcweir return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE ); 4043*cdf0e10cSrcweir } 4044*cdf0e10cSrcweir 4045*cdf0e10cSrcweir void UnoCurrencyFieldControl::setDecimalDigits( sal_Int16 Digits ) throw(uno::RuntimeException) 4046*cdf0e10cSrcweir { 4047*cdf0e10cSrcweir uno::Any aAny; 4048*cdf0e10cSrcweir aAny <<= Digits; 4049*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY ), aAny, sal_True ); 4050*cdf0e10cSrcweir } 4051*cdf0e10cSrcweir 4052*cdf0e10cSrcweir sal_Int16 UnoCurrencyFieldControl::getDecimalDigits() throw(uno::RuntimeException) 4053*cdf0e10cSrcweir { 4054*cdf0e10cSrcweir return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY ); 4055*cdf0e10cSrcweir } 4056*cdf0e10cSrcweir 4057*cdf0e10cSrcweir // ---------------------------------------------------- 4058*cdf0e10cSrcweir // class UnoControlPatternFieldModel 4059*cdf0e10cSrcweir // ---------------------------------------------------- 4060*cdf0e10cSrcweir UnoControlPatternFieldModel::UnoControlPatternFieldModel( const Reference< XMultiServiceFactory >& i_factory ) 4061*cdf0e10cSrcweir :UnoControlModel( i_factory ) 4062*cdf0e10cSrcweir { 4063*cdf0e10cSrcweir UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXPatternField ); 4064*cdf0e10cSrcweir } 4065*cdf0e10cSrcweir 4066*cdf0e10cSrcweir ::rtl::OUString UnoControlPatternFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException) 4067*cdf0e10cSrcweir { 4068*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( szServiceName_UnoControlPatternFieldModel ); 4069*cdf0e10cSrcweir } 4070*cdf0e10cSrcweir 4071*cdf0e10cSrcweir uno::Any UnoControlPatternFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const 4072*cdf0e10cSrcweir { 4073*cdf0e10cSrcweir if ( nPropId == BASEPROPERTY_DEFAULTCONTROL ) 4074*cdf0e10cSrcweir { 4075*cdf0e10cSrcweir uno::Any aAny; 4076*cdf0e10cSrcweir aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlPatternField ); 4077*cdf0e10cSrcweir return aAny; 4078*cdf0e10cSrcweir } 4079*cdf0e10cSrcweir return UnoControlModel::ImplGetDefaultValue( nPropId ); 4080*cdf0e10cSrcweir } 4081*cdf0e10cSrcweir 4082*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& UnoControlPatternFieldModel::getInfoHelper() 4083*cdf0e10cSrcweir { 4084*cdf0e10cSrcweir static UnoPropertyArrayHelper* pHelper = NULL; 4085*cdf0e10cSrcweir if ( !pHelper ) 4086*cdf0e10cSrcweir { 4087*cdf0e10cSrcweir uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); 4088*cdf0e10cSrcweir pHelper = new UnoPropertyArrayHelper( aIDs ); 4089*cdf0e10cSrcweir } 4090*cdf0e10cSrcweir return *pHelper; 4091*cdf0e10cSrcweir } 4092*cdf0e10cSrcweir 4093*cdf0e10cSrcweir // beans::XMultiPropertySet 4094*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > UnoControlPatternFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException) 4095*cdf0e10cSrcweir { 4096*cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 4097*cdf0e10cSrcweir return xInfo; 4098*cdf0e10cSrcweir } 4099*cdf0e10cSrcweir 4100*cdf0e10cSrcweir 4101*cdf0e10cSrcweir // ---------------------------------------------------- 4102*cdf0e10cSrcweir // class UnoPatternFieldControl 4103*cdf0e10cSrcweir // ---------------------------------------------------- 4104*cdf0e10cSrcweir UnoPatternFieldControl::UnoPatternFieldControl( const Reference< XMultiServiceFactory >& i_factory ) 4105*cdf0e10cSrcweir :UnoSpinFieldControl( i_factory ) 4106*cdf0e10cSrcweir { 4107*cdf0e10cSrcweir } 4108*cdf0e10cSrcweir 4109*cdf0e10cSrcweir ::rtl::OUString UnoPatternFieldControl::GetComponentServiceName() 4110*cdf0e10cSrcweir { 4111*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "patternfield" ); 4112*cdf0e10cSrcweir } 4113*cdf0e10cSrcweir 4114*cdf0e10cSrcweir void UnoPatternFieldControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const uno::Any& rVal ) 4115*cdf0e10cSrcweir { 4116*cdf0e10cSrcweir sal_uInt16 nType = GetPropertyId( rPropName ); 4117*cdf0e10cSrcweir if ( ( nType == BASEPROPERTY_TEXT ) || ( nType == BASEPROPERTY_EDITMASK ) || ( nType == BASEPROPERTY_LITERALMASK ) ) 4118*cdf0e10cSrcweir { 4119*cdf0e10cSrcweir // Die Masken koennen nicht nacheinander gesetzt werden. 4120*cdf0e10cSrcweir ::rtl::OUString Text = ImplGetPropertyValue_UString( BASEPROPERTY_TEXT ); 4121*cdf0e10cSrcweir ::rtl::OUString EditMask = ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK ); 4122*cdf0e10cSrcweir ::rtl::OUString LiteralMask = ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK ); 4123*cdf0e10cSrcweir 4124*cdf0e10cSrcweir uno::Reference < awt::XPatternField > xPF( getPeer(), uno::UNO_QUERY ); 4125*cdf0e10cSrcweir if (xPF.is()) 4126*cdf0e10cSrcweir { 4127*cdf0e10cSrcweir // same comment as in UnoControl::ImplSetPeerProperty - see there 4128*cdf0e10cSrcweir ::rtl::OUString sText( Text ); 4129*cdf0e10cSrcweir ImplCheckLocalize( sText ); 4130*cdf0e10cSrcweir xPF->setString( sText ); 4131*cdf0e10cSrcweir xPF->setMasks( EditMask, LiteralMask ); 4132*cdf0e10cSrcweir } 4133*cdf0e10cSrcweir } 4134*cdf0e10cSrcweir else 4135*cdf0e10cSrcweir UnoSpinFieldControl::ImplSetPeerProperty( rPropName, rVal ); 4136*cdf0e10cSrcweir } 4137*cdf0e10cSrcweir 4138*cdf0e10cSrcweir 4139*cdf0e10cSrcweir // uno::XInterface 4140*cdf0e10cSrcweir uno::Any UnoPatternFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException) 4141*cdf0e10cSrcweir { 4142*cdf0e10cSrcweir uno::Any aRet = ::cppu::queryInterface( rType, 4143*cdf0e10cSrcweir SAL_STATIC_CAST( awt::XPatternField*, this ) ); 4144*cdf0e10cSrcweir return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType )); 4145*cdf0e10cSrcweir } 4146*cdf0e10cSrcweir 4147*cdf0e10cSrcweir // lang::XTypeProvider 4148*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( UnoPatternFieldControl ) 4149*cdf0e10cSrcweir getCppuType( ( uno::Reference< awt::XPatternField>* ) NULL ), 4150*cdf0e10cSrcweir UnoSpinFieldControl::getTypes() 4151*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 4152*cdf0e10cSrcweir 4153*cdf0e10cSrcweir void UnoPatternFieldControl::setString( const ::rtl::OUString& rString ) throw(uno::RuntimeException) 4154*cdf0e10cSrcweir { 4155*cdf0e10cSrcweir setText( rString ); 4156*cdf0e10cSrcweir } 4157*cdf0e10cSrcweir 4158*cdf0e10cSrcweir ::rtl::OUString UnoPatternFieldControl::getString() throw(uno::RuntimeException) 4159*cdf0e10cSrcweir { 4160*cdf0e10cSrcweir return getText(); 4161*cdf0e10cSrcweir } 4162*cdf0e10cSrcweir 4163*cdf0e10cSrcweir void UnoPatternFieldControl::setMasks( const ::rtl::OUString& EditMask, const ::rtl::OUString& LiteralMask ) throw(uno::RuntimeException) 4164*cdf0e10cSrcweir { 4165*cdf0e10cSrcweir uno::Any aAny; 4166*cdf0e10cSrcweir aAny <<= EditMask; 4167*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_EDITMASK ), aAny, sal_True ); 4168*cdf0e10cSrcweir aAny <<= LiteralMask; 4169*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LITERALMASK ), aAny, sal_True ); 4170*cdf0e10cSrcweir } 4171*cdf0e10cSrcweir 4172*cdf0e10cSrcweir void UnoPatternFieldControl::getMasks( ::rtl::OUString& EditMask, ::rtl::OUString& LiteralMask ) throw(uno::RuntimeException) 4173*cdf0e10cSrcweir { 4174*cdf0e10cSrcweir EditMask = ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK ); 4175*cdf0e10cSrcweir LiteralMask = ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK ); 4176*cdf0e10cSrcweir } 4177*cdf0e10cSrcweir 4178*cdf0e10cSrcweir void UnoPatternFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException) 4179*cdf0e10cSrcweir { 4180*cdf0e10cSrcweir uno::Any aAny; 4181*cdf0e10cSrcweir aAny <<= bStrict; 4182*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True ); 4183*cdf0e10cSrcweir } 4184*cdf0e10cSrcweir 4185*cdf0e10cSrcweir sal_Bool UnoPatternFieldControl::isStrictFormat() throw(uno::RuntimeException) 4186*cdf0e10cSrcweir { 4187*cdf0e10cSrcweir return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT ); 4188*cdf0e10cSrcweir } 4189*cdf0e10cSrcweir 4190*cdf0e10cSrcweir 4191*cdf0e10cSrcweir // ---------------------------------------------------- 4192*cdf0e10cSrcweir // class UnoControlProgressBarModel 4193*cdf0e10cSrcweir // ---------------------------------------------------- 4194*cdf0e10cSrcweir UnoControlProgressBarModel::UnoControlProgressBarModel( const Reference< XMultiServiceFactory >& i_factory ) 4195*cdf0e10cSrcweir :UnoControlModel( i_factory ) 4196*cdf0e10cSrcweir { 4197*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR ); 4198*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_BORDER ); 4199*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR ); 4200*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL ); 4201*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_ENABLED ); 4202*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE ); 4203*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_FILLCOLOR ); 4204*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_HELPTEXT ); 4205*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_HELPURL ); 4206*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_PRINTABLE ); 4207*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE ); 4208*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MAX ); 4209*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MIN ); 4210*cdf0e10cSrcweir } 4211*cdf0e10cSrcweir 4212*cdf0e10cSrcweir ::rtl::OUString UnoControlProgressBarModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException) 4213*cdf0e10cSrcweir { 4214*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( szServiceName_UnoControlProgressBarModel ); 4215*cdf0e10cSrcweir } 4216*cdf0e10cSrcweir 4217*cdf0e10cSrcweir uno::Any UnoControlProgressBarModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const 4218*cdf0e10cSrcweir { 4219*cdf0e10cSrcweir if ( nPropId == BASEPROPERTY_DEFAULTCONTROL ) 4220*cdf0e10cSrcweir { 4221*cdf0e10cSrcweir uno::Any aAny; 4222*cdf0e10cSrcweir aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlProgressBar ); 4223*cdf0e10cSrcweir return aAny; 4224*cdf0e10cSrcweir } 4225*cdf0e10cSrcweir 4226*cdf0e10cSrcweir return UnoControlModel::ImplGetDefaultValue( nPropId ); 4227*cdf0e10cSrcweir } 4228*cdf0e10cSrcweir 4229*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& UnoControlProgressBarModel::getInfoHelper() 4230*cdf0e10cSrcweir { 4231*cdf0e10cSrcweir static UnoPropertyArrayHelper* pHelper = NULL; 4232*cdf0e10cSrcweir if ( !pHelper ) 4233*cdf0e10cSrcweir { 4234*cdf0e10cSrcweir uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); 4235*cdf0e10cSrcweir pHelper = new UnoPropertyArrayHelper( aIDs ); 4236*cdf0e10cSrcweir } 4237*cdf0e10cSrcweir return *pHelper; 4238*cdf0e10cSrcweir } 4239*cdf0e10cSrcweir 4240*cdf0e10cSrcweir // beans::XMultiPropertySet 4241*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > UnoControlProgressBarModel::getPropertySetInfo( ) throw(uno::RuntimeException) 4242*cdf0e10cSrcweir { 4243*cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 4244*cdf0e10cSrcweir return xInfo; 4245*cdf0e10cSrcweir } 4246*cdf0e10cSrcweir 4247*cdf0e10cSrcweir 4248*cdf0e10cSrcweir // ---------------------------------------------------- 4249*cdf0e10cSrcweir // class UnoProgressBarControl 4250*cdf0e10cSrcweir // ---------------------------------------------------- 4251*cdf0e10cSrcweir UnoProgressBarControl::UnoProgressBarControl( const Reference< XMultiServiceFactory >& i_factory ) 4252*cdf0e10cSrcweir :UnoControlBase( i_factory ) 4253*cdf0e10cSrcweir { 4254*cdf0e10cSrcweir } 4255*cdf0e10cSrcweir 4256*cdf0e10cSrcweir ::rtl::OUString UnoProgressBarControl::GetComponentServiceName() 4257*cdf0e10cSrcweir { 4258*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "ProgressBar" ); 4259*cdf0e10cSrcweir } 4260*cdf0e10cSrcweir 4261*cdf0e10cSrcweir // uno::XInterface 4262*cdf0e10cSrcweir uno::Any UnoProgressBarControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException) 4263*cdf0e10cSrcweir { 4264*cdf0e10cSrcweir uno::Any aRet = ::cppu::queryInterface( rType, 4265*cdf0e10cSrcweir SAL_STATIC_CAST( awt::XProgressBar*, this ) ); 4266*cdf0e10cSrcweir return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType )); 4267*cdf0e10cSrcweir } 4268*cdf0e10cSrcweir 4269*cdf0e10cSrcweir // lang::XTypeProvider 4270*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( UnoProgressBarControl ) 4271*cdf0e10cSrcweir getCppuType( ( uno::Reference< awt::XProgressBar>* ) NULL ), 4272*cdf0e10cSrcweir UnoControlBase::getTypes() 4273*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 4274*cdf0e10cSrcweir 4275*cdf0e10cSrcweir // ::com::sun::star::awt::XProgressBar 4276*cdf0e10cSrcweir void UnoProgressBarControl::setForegroundColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException) 4277*cdf0e10cSrcweir { 4278*cdf0e10cSrcweir uno::Any aAny; 4279*cdf0e10cSrcweir aAny <<= nColor; 4280*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_FILLCOLOR ), aAny, sal_True ); 4281*cdf0e10cSrcweir } 4282*cdf0e10cSrcweir 4283*cdf0e10cSrcweir void UnoProgressBarControl::setBackgroundColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException) 4284*cdf0e10cSrcweir { 4285*cdf0e10cSrcweir uno::Any aAny; 4286*cdf0e10cSrcweir aAny <<= nColor; 4287*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_BACKGROUNDCOLOR ), aAny, sal_True ); 4288*cdf0e10cSrcweir } 4289*cdf0e10cSrcweir 4290*cdf0e10cSrcweir void UnoProgressBarControl::setValue( sal_Int32 nValue ) throw(::com::sun::star::uno::RuntimeException) 4291*cdf0e10cSrcweir { 4292*cdf0e10cSrcweir uno::Any aAny; 4293*cdf0e10cSrcweir aAny <<= nValue; 4294*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE ), aAny, sal_True ); 4295*cdf0e10cSrcweir } 4296*cdf0e10cSrcweir 4297*cdf0e10cSrcweir void UnoProgressBarControl::setRange( sal_Int32 nMin, sal_Int32 nMax ) throw(::com::sun::star::uno::RuntimeException ) 4298*cdf0e10cSrcweir { 4299*cdf0e10cSrcweir uno::Any aMin; 4300*cdf0e10cSrcweir uno::Any aMax; 4301*cdf0e10cSrcweir 4302*cdf0e10cSrcweir if ( nMin < nMax ) 4303*cdf0e10cSrcweir { 4304*cdf0e10cSrcweir // take correct min and max 4305*cdf0e10cSrcweir aMin <<= nMin; 4306*cdf0e10cSrcweir aMax <<= nMax; 4307*cdf0e10cSrcweir } 4308*cdf0e10cSrcweir else 4309*cdf0e10cSrcweir { 4310*cdf0e10cSrcweir // change min and max 4311*cdf0e10cSrcweir aMin <<= nMax; 4312*cdf0e10cSrcweir aMax <<= nMin; 4313*cdf0e10cSrcweir } 4314*cdf0e10cSrcweir 4315*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MIN ), aMin, sal_True ); 4316*cdf0e10cSrcweir ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MAX ), aMax, sal_True ); 4317*cdf0e10cSrcweir } 4318*cdf0e10cSrcweir 4319*cdf0e10cSrcweir sal_Int32 UnoProgressBarControl::getValue() throw(::com::sun::star::uno::RuntimeException) 4320*cdf0e10cSrcweir { 4321*cdf0e10cSrcweir return ImplGetPropertyValue_INT32( BASEPROPERTY_PROGRESSVALUE ); 4322*cdf0e10cSrcweir } 4323*cdf0e10cSrcweir 4324*cdf0e10cSrcweir 4325*cdf0e10cSrcweir // ---------------------------------------------------- 4326*cdf0e10cSrcweir // class UnoControlFixedLineModel 4327*cdf0e10cSrcweir // ---------------------------------------------------- 4328*cdf0e10cSrcweir UnoControlFixedLineModel::UnoControlFixedLineModel( const Reference< XMultiServiceFactory >& i_factory ) 4329*cdf0e10cSrcweir :UnoControlModel( i_factory ) 4330*cdf0e10cSrcweir { 4331*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR ); 4332*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL ); 4333*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_ENABLED ); 4334*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE ); 4335*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR ); 4336*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_HELPTEXT ); 4337*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_HELPURL ); 4338*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_LABEL ); 4339*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_ORIENTATION ); 4340*cdf0e10cSrcweir ImplRegisterProperty( BASEPROPERTY_PRINTABLE ); 4341*cdf0e10cSrcweir } 4342*cdf0e10cSrcweir 4343*cdf0e10cSrcweir ::rtl::OUString UnoControlFixedLineModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException) 4344*cdf0e10cSrcweir { 4345*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedLineModel ); 4346*cdf0e10cSrcweir } 4347*cdf0e10cSrcweir 4348*cdf0e10cSrcweir uno::Any UnoControlFixedLineModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const 4349*cdf0e10cSrcweir { 4350*cdf0e10cSrcweir if ( nPropId == BASEPROPERTY_DEFAULTCONTROL ) 4351*cdf0e10cSrcweir { 4352*cdf0e10cSrcweir uno::Any aAny; 4353*cdf0e10cSrcweir aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedLine ); 4354*cdf0e10cSrcweir return aAny; 4355*cdf0e10cSrcweir } 4356*cdf0e10cSrcweir return UnoControlModel::ImplGetDefaultValue( nPropId ); 4357*cdf0e10cSrcweir } 4358*cdf0e10cSrcweir 4359*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& UnoControlFixedLineModel::getInfoHelper() 4360*cdf0e10cSrcweir { 4361*cdf0e10cSrcweir static UnoPropertyArrayHelper* pHelper = NULL; 4362*cdf0e10cSrcweir if ( !pHelper ) 4363*cdf0e10cSrcweir { 4364*cdf0e10cSrcweir uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); 4365*cdf0e10cSrcweir pHelper = new UnoPropertyArrayHelper( aIDs ); 4366*cdf0e10cSrcweir } 4367*cdf0e10cSrcweir return *pHelper; 4368*cdf0e10cSrcweir } 4369*cdf0e10cSrcweir 4370*cdf0e10cSrcweir // beans::XMultiPropertySet 4371*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > UnoControlFixedLineModel::getPropertySetInfo( ) throw(uno::RuntimeException) 4372*cdf0e10cSrcweir { 4373*cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 4374*cdf0e10cSrcweir return xInfo; 4375*cdf0e10cSrcweir } 4376*cdf0e10cSrcweir 4377*cdf0e10cSrcweir // ---------------------------------------------------- 4378*cdf0e10cSrcweir // class UnoFixedLineControl 4379*cdf0e10cSrcweir // ---------------------------------------------------- 4380*cdf0e10cSrcweir UnoFixedLineControl::UnoFixedLineControl( const Reference< XMultiServiceFactory >& i_factory ) 4381*cdf0e10cSrcweir :UnoControlBase( i_factory ) 4382*cdf0e10cSrcweir { 4383*cdf0e10cSrcweir maComponentInfos.nWidth = 100; // ?? 4384*cdf0e10cSrcweir maComponentInfos.nHeight = 100; // ?? 4385*cdf0e10cSrcweir } 4386*cdf0e10cSrcweir 4387*cdf0e10cSrcweir ::rtl::OUString UnoFixedLineControl::GetComponentServiceName() 4388*cdf0e10cSrcweir { 4389*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "FixedLine" ); 4390*cdf0e10cSrcweir } 4391*cdf0e10cSrcweir 4392*cdf0e10cSrcweir sal_Bool UnoFixedLineControl::isTransparent() throw(uno::RuntimeException) 4393*cdf0e10cSrcweir { 4394*cdf0e10cSrcweir return sal_True; 4395*cdf0e10cSrcweir } 4396*cdf0e10cSrcweir 4397