1b0724fc6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3b0724fc6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4b0724fc6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5b0724fc6SAndrew Rist * distributed with this work for additional information 6b0724fc6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7b0724fc6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8b0724fc6SAndrew Rist * "License"); you may not use this file except in compliance 9b0724fc6SAndrew Rist * with the License. You may obtain a copy of the License at 10b0724fc6SAndrew Rist * 11b0724fc6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12b0724fc6SAndrew Rist * 13b0724fc6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14b0724fc6SAndrew Rist * software distributed under the License is distributed on an 15b0724fc6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16b0724fc6SAndrew Rist * KIND, either express or implied. See the License for the 17b0724fc6SAndrew Rist * specific language governing permissions and limitations 18b0724fc6SAndrew Rist * under the License. 19b0724fc6SAndrew Rist * 20b0724fc6SAndrew Rist *************************************************************/ 21b0724fc6SAndrew Rist 22b0724fc6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_toolkit.hxx" 26cdf0e10cSrcweir #include <toolkit/awt/vclxwindows.hxx> 27cdf0e10cSrcweir #include <com/sun/star/awt/ScrollBarOrientation.hpp> 28cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphicProvider.hpp> 29cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 30cdf0e10cSrcweir #include <toolkit/helper/macros.hxx> 31cdf0e10cSrcweir #include <toolkit/helper/property.hxx> 32cdf0e10cSrcweir #include <toolkit/helper/convert.hxx> 33cdf0e10cSrcweir #include <toolkit/helper/imagealign.hxx> 34cdf0e10cSrcweir #include <toolkit/helper/accessibilityclient.hxx> 35cdf0e10cSrcweir #include <toolkit/helper/fixedhyperbase.hxx> 36cdf0e10cSrcweir #include <toolkit/helper/tkresmgr.hxx> 37cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 38cdf0e10cSrcweir #include <com/sun/star/awt/VisualEffect.hpp> 39cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 40cdf0e10cSrcweir #include <com/sun/star/system/XSystemShellExecute.hpp> 41cdf0e10cSrcweir #include <com/sun/star/system/SystemShellExecuteFlags.hpp> 42cdf0e10cSrcweir #include <com/sun/star/resource/XStringResourceResolver.hpp> 43cdf0e10cSrcweir #include <com/sun/star/awt/ImageScaleMode.hpp> 44cdf0e10cSrcweir #include <com/sun/star/awt/XItemList.hpp> 45cdf0e10cSrcweir #include <comphelper/componentcontext.hxx> 46cdf0e10cSrcweir #include <comphelper/namedvaluecollection.hxx> 47cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 48cdf0e10cSrcweir 49cdf0e10cSrcweir #ifndef _SV_BUTTON_HXX 50cdf0e10cSrcweir #include <vcl/button.hxx> 51cdf0e10cSrcweir #endif 52cdf0e10cSrcweir #include <vcl/lstbox.hxx> 53cdf0e10cSrcweir #include <vcl/combobox.hxx> 54cdf0e10cSrcweir #include <vcl/field.hxx> 55cdf0e10cSrcweir #include <vcl/longcurr.hxx> 56cdf0e10cSrcweir #include <vcl/imgctrl.hxx> 57cdf0e10cSrcweir #include <vcl/dialog.hxx> 58cdf0e10cSrcweir #include <vcl/msgbox.hxx> 59cdf0e10cSrcweir #include <vcl/scrbar.hxx> 60cdf0e10cSrcweir #include <vcl/svapp.hxx> 61cdf0e10cSrcweir #include <vcl/tabpage.hxx> 62cdf0e10cSrcweir #include <vcl/tabctrl.hxx> 63cdf0e10cSrcweir #include <tools/diagnose_ex.h> 64cdf0e10cSrcweir 65cdf0e10cSrcweir #include <boost/bind.hpp> 66cdf0e10cSrcweir #include <boost/function.hpp> 67cdf0e10cSrcweir 68cdf0e10cSrcweir using ::com::sun::star::uno::Any; 69cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 70cdf0e10cSrcweir using ::com::sun::star::uno::makeAny; 71cdf0e10cSrcweir using ::com::sun::star::uno::RuntimeException; 72cdf0e10cSrcweir using ::com::sun::star::lang::EventObject; 73cdf0e10cSrcweir using ::com::sun::star::awt::ItemListEvent; 74cdf0e10cSrcweir using ::com::sun::star::awt::XItemList; 75cdf0e10cSrcweir using ::com::sun::star::graphic::XGraphic; 76cdf0e10cSrcweir using ::com::sun::star::graphic::XGraphicProvider; 77cdf0e10cSrcweir 78cdf0e10cSrcweir using namespace ::com::sun::star; 79cdf0e10cSrcweir using namespace ::com::sun::star::awt::VisualEffect; 80cdf0e10cSrcweir namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode; 81cdf0e10cSrcweir 82cdf0e10cSrcweir static double ImplCalcLongValue( double nValue, sal_uInt16 nDigits ) 83cdf0e10cSrcweir { 84cdf0e10cSrcweir double n = nValue; 85cdf0e10cSrcweir for ( sal_uInt16 d = 0; d < nDigits; d++ ) 86cdf0e10cSrcweir n *= 10; 87cdf0e10cSrcweir return n; 88cdf0e10cSrcweir } 89cdf0e10cSrcweir 90cdf0e10cSrcweir static double ImplCalcDoubleValue( double nValue, sal_uInt16 nDigits ) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir double n = nValue; 93cdf0e10cSrcweir for ( sal_uInt16 d = 0; d < nDigits; d++ ) 94cdf0e10cSrcweir n /= 10; 95cdf0e10cSrcweir return n; 96cdf0e10cSrcweir } 97cdf0e10cSrcweir 98cdf0e10cSrcweir namespace toolkit 99cdf0e10cSrcweir { 100cdf0e10cSrcweir /** sets the "face color" for button like controls (scroll bar, spin button) 101cdf0e10cSrcweir */ 102cdf0e10cSrcweir void setButtonLikeFaceColor( Window* _pWindow, const ::com::sun::star::uno::Any& _rColorValue ) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir AllSettings aSettings = _pWindow->GetSettings(); 105cdf0e10cSrcweir StyleSettings aStyleSettings = aSettings.GetStyleSettings(); 106cdf0e10cSrcweir 107cdf0e10cSrcweir if ( !_rColorValue.hasValue() ) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir const StyleSettings& aAppStyle = Application::GetSettings().GetStyleSettings(); 110cdf0e10cSrcweir aStyleSettings.SetFaceColor( aAppStyle.GetFaceColor( ) ); 111cdf0e10cSrcweir aStyleSettings.SetCheckedColor( aAppStyle.GetCheckedColor( ) ); 112cdf0e10cSrcweir aStyleSettings.SetLightBorderColor( aAppStyle.GetLightBorderColor() ); 113cdf0e10cSrcweir aStyleSettings.SetLightColor( aAppStyle.GetLightColor() ); 114cdf0e10cSrcweir aStyleSettings.SetShadowColor( aAppStyle.GetShadowColor() ); 115cdf0e10cSrcweir aStyleSettings.SetDarkShadowColor( aAppStyle.GetDarkShadowColor() ); 116cdf0e10cSrcweir } 117cdf0e10cSrcweir else 118cdf0e10cSrcweir { 119cdf0e10cSrcweir sal_Int32 nBackgroundColor = 0; 120cdf0e10cSrcweir _rColorValue >>= nBackgroundColor; 121cdf0e10cSrcweir aStyleSettings.SetFaceColor( nBackgroundColor ); 122cdf0e10cSrcweir 123cdf0e10cSrcweir // for the real background (everything except the buttons and the thumb), 124cdf0e10cSrcweir // use an average between the desired color and "white" 125cdf0e10cSrcweir Color aWhite( COL_WHITE ); 126cdf0e10cSrcweir Color aBackground( nBackgroundColor ); 127cdf0e10cSrcweir aBackground.SetRed( ( aBackground.GetRed() + aWhite.GetRed() ) / 2 ); 128cdf0e10cSrcweir aBackground.SetGreen( ( aBackground.GetGreen() + aWhite.GetGreen() ) / 2 ); 129cdf0e10cSrcweir aBackground.SetBlue( ( aBackground.GetBlue() + aWhite.GetBlue() ) / 2 ); 130cdf0e10cSrcweir aStyleSettings.SetCheckedColor( aBackground ); 131cdf0e10cSrcweir 132cdf0e10cSrcweir sal_Int32 nBackgroundLuminance = Color( nBackgroundColor ).GetLuminance(); 133cdf0e10cSrcweir sal_Int32 nWhiteLuminance = Color( COL_WHITE ).GetLuminance(); 134cdf0e10cSrcweir 135cdf0e10cSrcweir Color aLightShadow( nBackgroundColor ); 136cdf0e10cSrcweir aLightShadow.IncreaseLuminance( (sal_uInt8)( ( nWhiteLuminance - nBackgroundLuminance ) * 2 / 3 ) ); 137cdf0e10cSrcweir aStyleSettings.SetLightBorderColor( aLightShadow ); 138cdf0e10cSrcweir 139cdf0e10cSrcweir Color aLight( nBackgroundColor ); 140cdf0e10cSrcweir aLight.IncreaseLuminance( (sal_uInt8)( ( nWhiteLuminance - nBackgroundLuminance ) * 1 / 3 ) ); 141cdf0e10cSrcweir aStyleSettings.SetLightColor( aLight ); 142cdf0e10cSrcweir 143cdf0e10cSrcweir Color aShadow( nBackgroundColor ); 144cdf0e10cSrcweir aShadow.DecreaseLuminance( (sal_uInt8)( nBackgroundLuminance * 1 / 3 ) ); 145cdf0e10cSrcweir aStyleSettings.SetShadowColor( aShadow ); 146cdf0e10cSrcweir 147cdf0e10cSrcweir Color aDarkShadow( nBackgroundColor ); 148cdf0e10cSrcweir aDarkShadow.DecreaseLuminance( (sal_uInt8)( nBackgroundLuminance * 2 / 3 ) ); 149cdf0e10cSrcweir aStyleSettings.SetDarkShadowColor( aDarkShadow ); 150cdf0e10cSrcweir } 151cdf0e10cSrcweir 152cdf0e10cSrcweir aSettings.SetStyleSettings( aStyleSettings ); 153cdf0e10cSrcweir _pWindow->SetSettings( aSettings, sal_True ); 154cdf0e10cSrcweir } 155cdf0e10cSrcweir 156cdf0e10cSrcweir Any getButtonLikeFaceColor( const Window* _pWindow ) 157cdf0e10cSrcweir { 158cdf0e10cSrcweir sal_Int32 nBackgroundColor = _pWindow->GetSettings().GetStyleSettings().GetFaceColor().GetColor(); 159cdf0e10cSrcweir return makeAny( nBackgroundColor ); 160cdf0e10cSrcweir } 161cdf0e10cSrcweir 162cdf0e10cSrcweir static void adjustBooleanWindowStyle( const Any& _rValue, Window* _pWindow, WinBits _nBits, sal_Bool _bInverseSemantics ) 163cdf0e10cSrcweir { 164cdf0e10cSrcweir WinBits nStyle = _pWindow->GetStyle(); 165cdf0e10cSrcweir sal_Bool bValue( sal_False ); 166cdf0e10cSrcweir OSL_VERIFY( _rValue >>= bValue ); 167cdf0e10cSrcweir if ( bValue != _bInverseSemantics ) 168cdf0e10cSrcweir nStyle |= _nBits; 169cdf0e10cSrcweir else 170cdf0e10cSrcweir nStyle &= ~_nBits; 171cdf0e10cSrcweir _pWindow->SetStyle( nStyle ); 172cdf0e10cSrcweir } 173cdf0e10cSrcweir 174cdf0e10cSrcweir static void setVisualEffect( const Any& _rValue, Window* _pWindow ) 175cdf0e10cSrcweir { 176cdf0e10cSrcweir AllSettings aSettings = _pWindow->GetSettings(); 177cdf0e10cSrcweir StyleSettings aStyleSettings = aSettings.GetStyleSettings(); 178cdf0e10cSrcweir 179cdf0e10cSrcweir sal_Int16 nStyle = LOOK3D; 180cdf0e10cSrcweir OSL_VERIFY( _rValue >>= nStyle ); 181cdf0e10cSrcweir switch ( nStyle ) 182cdf0e10cSrcweir { 183cdf0e10cSrcweir case FLAT: 184cdf0e10cSrcweir aStyleSettings.SetOptions( aStyleSettings.GetOptions() & ~STYLE_OPTION_MONO ); 185cdf0e10cSrcweir break; 186cdf0e10cSrcweir case LOOK3D: 187cdf0e10cSrcweir default: 188cdf0e10cSrcweir aStyleSettings.SetOptions( aStyleSettings.GetOptions() | STYLE_OPTION_MONO ); 189cdf0e10cSrcweir } 190cdf0e10cSrcweir aSettings.SetStyleSettings( aStyleSettings ); 191cdf0e10cSrcweir _pWindow->SetSettings( aSettings ); 192cdf0e10cSrcweir } 193cdf0e10cSrcweir 194cdf0e10cSrcweir static Any getVisualEffect( Window* _pWindow ) 195cdf0e10cSrcweir { 196cdf0e10cSrcweir Any aEffect; 197cdf0e10cSrcweir 198cdf0e10cSrcweir StyleSettings aStyleSettings = _pWindow->GetSettings().GetStyleSettings(); 199cdf0e10cSrcweir if ( (aStyleSettings.GetOptions() & STYLE_OPTION_MONO) ) 200cdf0e10cSrcweir aEffect <<= (sal_Int16)FLAT; 201cdf0e10cSrcweir else 202cdf0e10cSrcweir aEffect <<= (sal_Int16)LOOK3D; 203cdf0e10cSrcweir return aEffect; 204cdf0e10cSrcweir } 205cdf0e10cSrcweir } 206cdf0e10cSrcweir 207cdf0e10cSrcweir // ---------------------------------------------------- 208cdf0e10cSrcweir // class VCLXGraphicControl 209cdf0e10cSrcweir // ---------------------------------------------------- 210cdf0e10cSrcweir 211cdf0e10cSrcweir void VCLXGraphicControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 212cdf0e10cSrcweir { 213cdf0e10cSrcweir VCLXWindow::ImplGetPropertyIds( rIds ); 214cdf0e10cSrcweir } 215cdf0e10cSrcweir 216cdf0e10cSrcweir void VCLXGraphicControl::ImplSetNewImage() 217cdf0e10cSrcweir { 218cdf0e10cSrcweir OSL_PRECOND( GetWindow(), "VCLXGraphicControl::ImplSetNewImage: window is required to be not-NULL!" ); 219cdf0e10cSrcweir Button* pButton = static_cast< Button* >( GetWindow() ); 220cdf0e10cSrcweir pButton->SetModeImage( GetImage() ); 221cdf0e10cSrcweir } 222cdf0e10cSrcweir 223cdf0e10cSrcweir void VCLXGraphicControl::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, short Flags ) throw(::com::sun::star::uno::RuntimeException) 224cdf0e10cSrcweir { 225cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 226cdf0e10cSrcweir 227cdf0e10cSrcweir if ( GetWindow() ) 228cdf0e10cSrcweir { 229cdf0e10cSrcweir Size aOldSize = GetWindow()->GetSizePixel(); 230cdf0e10cSrcweir VCLXWindow::setPosSize( X, Y, Width, Height, Flags ); 231cdf0e10cSrcweir if ( ( aOldSize.Width() != Width ) || ( aOldSize.Height() != Height ) ) 232cdf0e10cSrcweir ImplSetNewImage(); 233cdf0e10cSrcweir } 234cdf0e10cSrcweir } 235cdf0e10cSrcweir 236cdf0e10cSrcweir void VCLXGraphicControl::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 237cdf0e10cSrcweir { 238cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 239cdf0e10cSrcweir 240cdf0e10cSrcweir Button* pButton = static_cast< Button* >( GetWindow() ); 241cdf0e10cSrcweir if ( !pButton ) 242cdf0e10cSrcweir return; 243cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 244cdf0e10cSrcweir switch ( nPropType ) 245cdf0e10cSrcweir { 246cdf0e10cSrcweir case BASEPROPERTY_GRAPHIC: 247cdf0e10cSrcweir { 248cdf0e10cSrcweir Reference< XGraphic > xGraphic; 249cdf0e10cSrcweir OSL_VERIFY( Value >>= xGraphic ); 250cdf0e10cSrcweir maImage = Image( xGraphic ); 251cdf0e10cSrcweir ImplSetNewImage(); 252cdf0e10cSrcweir } 253cdf0e10cSrcweir break; 254cdf0e10cSrcweir 255cdf0e10cSrcweir case BASEPROPERTY_IMAGEALIGN: 256cdf0e10cSrcweir { 257cdf0e10cSrcweir WindowType eType = GetWindow()->GetType(); 258cdf0e10cSrcweir if ( ( eType == WINDOW_PUSHBUTTON ) 259cdf0e10cSrcweir || ( eType == WINDOW_RADIOBUTTON ) 260cdf0e10cSrcweir || ( eType == WINDOW_CHECKBOX ) 261cdf0e10cSrcweir ) 262cdf0e10cSrcweir { 263cdf0e10cSrcweir sal_Int16 nAlignment = sal_Int16(); 264cdf0e10cSrcweir if ( Value >>= nAlignment ) 265cdf0e10cSrcweir pButton->SetImageAlign( static_cast< ImageAlign >( nAlignment ) ); 266cdf0e10cSrcweir } 267cdf0e10cSrcweir } 268cdf0e10cSrcweir break; 269cdf0e10cSrcweir case BASEPROPERTY_IMAGEPOSITION: 270cdf0e10cSrcweir { 271cdf0e10cSrcweir WindowType eType = GetWindow()->GetType(); 272cdf0e10cSrcweir if ( ( eType == WINDOW_PUSHBUTTON ) 273cdf0e10cSrcweir || ( eType == WINDOW_RADIOBUTTON ) 274cdf0e10cSrcweir || ( eType == WINDOW_CHECKBOX ) 275cdf0e10cSrcweir ) 276cdf0e10cSrcweir { 277cdf0e10cSrcweir sal_Int16 nImagePosition = 2; 278cdf0e10cSrcweir OSL_VERIFY( Value >>= nImagePosition ); 279cdf0e10cSrcweir pButton->SetImageAlign( ::toolkit::translateImagePosition( nImagePosition ) ); 280cdf0e10cSrcweir } 281cdf0e10cSrcweir } 282cdf0e10cSrcweir break; 283cdf0e10cSrcweir default: 284cdf0e10cSrcweir VCLXWindow::setProperty( PropertyName, Value ); 285cdf0e10cSrcweir break; 286cdf0e10cSrcweir } 287cdf0e10cSrcweir } 288cdf0e10cSrcweir 289cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXGraphicControl::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) 290cdf0e10cSrcweir { 291cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 292cdf0e10cSrcweir 293cdf0e10cSrcweir ::com::sun::star::uno::Any aProp; 294cdf0e10cSrcweir if ( !GetWindow() ) 295cdf0e10cSrcweir return aProp; 296cdf0e10cSrcweir 297cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 298cdf0e10cSrcweir switch ( nPropType ) 299cdf0e10cSrcweir { 300cdf0e10cSrcweir case BASEPROPERTY_GRAPHIC: 301cdf0e10cSrcweir aProp <<= maImage.GetXGraphic(); 302cdf0e10cSrcweir break; 303cdf0e10cSrcweir case BASEPROPERTY_IMAGEALIGN: 304cdf0e10cSrcweir { 305cdf0e10cSrcweir WindowType eType = GetWindow()->GetType(); 306cdf0e10cSrcweir if ( ( eType == WINDOW_PUSHBUTTON ) 307cdf0e10cSrcweir || ( eType == WINDOW_RADIOBUTTON ) 308cdf0e10cSrcweir || ( eType == WINDOW_CHECKBOX ) 309cdf0e10cSrcweir ) 310cdf0e10cSrcweir { 311cdf0e10cSrcweir aProp <<= ::toolkit::getCompatibleImageAlign( static_cast< Button* >( GetWindow() )->GetImageAlign() ); 312cdf0e10cSrcweir } 313cdf0e10cSrcweir } 314cdf0e10cSrcweir break; 315cdf0e10cSrcweir case BASEPROPERTY_IMAGEPOSITION: 316cdf0e10cSrcweir { 317cdf0e10cSrcweir WindowType eType = GetWindow()->GetType(); 318cdf0e10cSrcweir if ( ( eType == WINDOW_PUSHBUTTON ) 319cdf0e10cSrcweir || ( eType == WINDOW_RADIOBUTTON ) 320cdf0e10cSrcweir || ( eType == WINDOW_CHECKBOX ) 321cdf0e10cSrcweir ) 322cdf0e10cSrcweir { 323cdf0e10cSrcweir aProp <<= ::toolkit::translateImagePosition( static_cast< Button* >( GetWindow() )->GetImageAlign() ); 324cdf0e10cSrcweir } 325cdf0e10cSrcweir } 326cdf0e10cSrcweir break; 327cdf0e10cSrcweir default: 328cdf0e10cSrcweir { 329cdf0e10cSrcweir aProp <<= VCLXWindow::getProperty( PropertyName ); 330cdf0e10cSrcweir } 331cdf0e10cSrcweir break; 332cdf0e10cSrcweir } 333cdf0e10cSrcweir return aProp; 334cdf0e10cSrcweir } 335cdf0e10cSrcweir 336cdf0e10cSrcweir //-------------------------------------------------------------------- 337cdf0e10cSrcweir // class VCLXButton 338cdf0e10cSrcweir // ---------------------------------------------------- 339cdf0e10cSrcweir 340cdf0e10cSrcweir void VCLXButton::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 341cdf0e10cSrcweir { 342cdf0e10cSrcweir PushPropertyIds( rIds, 343cdf0e10cSrcweir BASEPROPERTY_BACKGROUNDCOLOR, 344cdf0e10cSrcweir BASEPROPERTY_DEFAULTBUTTON, 345cdf0e10cSrcweir BASEPROPERTY_DEFAULTCONTROL, 346cdf0e10cSrcweir BASEPROPERTY_ENABLED, 347cdf0e10cSrcweir BASEPROPERTY_ENABLEVISIBLE, 348cdf0e10cSrcweir BASEPROPERTY_FONTDESCRIPTOR, 349cdf0e10cSrcweir BASEPROPERTY_GRAPHIC, 350cdf0e10cSrcweir BASEPROPERTY_HELPTEXT, 351cdf0e10cSrcweir BASEPROPERTY_HELPURL, 352cdf0e10cSrcweir BASEPROPERTY_IMAGEALIGN, 353cdf0e10cSrcweir BASEPROPERTY_IMAGEPOSITION, 354cdf0e10cSrcweir BASEPROPERTY_IMAGEURL, 355cdf0e10cSrcweir BASEPROPERTY_LABEL, 356cdf0e10cSrcweir BASEPROPERTY_PRINTABLE, 357cdf0e10cSrcweir BASEPROPERTY_PUSHBUTTONTYPE, 358cdf0e10cSrcweir BASEPROPERTY_REPEAT, 359cdf0e10cSrcweir BASEPROPERTY_REPEAT_DELAY, 360cdf0e10cSrcweir BASEPROPERTY_STATE, 361cdf0e10cSrcweir BASEPROPERTY_TABSTOP, 362cdf0e10cSrcweir BASEPROPERTY_TOGGLE, 363cdf0e10cSrcweir BASEPROPERTY_FOCUSONCLICK, 364cdf0e10cSrcweir BASEPROPERTY_MULTILINE, 365cdf0e10cSrcweir BASEPROPERTY_ALIGN, 366cdf0e10cSrcweir BASEPROPERTY_VERTICALALIGN, 367cdf0e10cSrcweir BASEPROPERTY_WRITING_MODE, 368cdf0e10cSrcweir BASEPROPERTY_CONTEXT_WRITING_MODE, 369cdf0e10cSrcweir BASEPROPERTY_REFERENCE_DEVICE, 370cdf0e10cSrcweir 0); 371cdf0e10cSrcweir VCLXGraphicControl::ImplGetPropertyIds( rIds ); 372cdf0e10cSrcweir } 373cdf0e10cSrcweir 374cdf0e10cSrcweir VCLXButton::VCLXButton() 375cdf0e10cSrcweir :maActionListeners( *this ) 376cdf0e10cSrcweir ,maItemListeners( *this ) 377cdf0e10cSrcweir { 378cdf0e10cSrcweir } 379cdf0e10cSrcweir 380cdf0e10cSrcweir VCLXButton::~VCLXButton() 381cdf0e10cSrcweir { 382cdf0e10cSrcweir } 383cdf0e10cSrcweir 384cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXButton::CreateAccessibleContext() 385cdf0e10cSrcweir { 386cdf0e10cSrcweir return getAccessibleFactory().createAccessibleContext( this ); 387cdf0e10cSrcweir } 388cdf0e10cSrcweir 389cdf0e10cSrcweir void VCLXButton::dispose() throw(::com::sun::star::uno::RuntimeException) 390cdf0e10cSrcweir { 391cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 392cdf0e10cSrcweir 393cdf0e10cSrcweir ::com::sun::star::lang::EventObject aObj; 394cdf0e10cSrcweir aObj.Source = (::cppu::OWeakObject*)this; 395cdf0e10cSrcweir maActionListeners.disposeAndClear( aObj ); 396cdf0e10cSrcweir maItemListeners.disposeAndClear( aObj ); 397cdf0e10cSrcweir VCLXGraphicControl::dispose(); 398cdf0e10cSrcweir } 399cdf0e10cSrcweir 400cdf0e10cSrcweir void VCLXButton::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )throw(::com::sun::star::uno::RuntimeException) 401cdf0e10cSrcweir { 402cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 403cdf0e10cSrcweir maActionListeners.addInterface( l ); 404cdf0e10cSrcweir } 405cdf0e10cSrcweir 406cdf0e10cSrcweir void VCLXButton::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException) 407cdf0e10cSrcweir { 408cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 409cdf0e10cSrcweir maActionListeners.removeInterface( l ); 410cdf0e10cSrcweir } 411cdf0e10cSrcweir 412cdf0e10cSrcweir void VCLXButton::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l )throw(::com::sun::star::uno::RuntimeException) 413cdf0e10cSrcweir { 414cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 415cdf0e10cSrcweir maItemListeners.addInterface( l ); 416cdf0e10cSrcweir } 417cdf0e10cSrcweir 418cdf0e10cSrcweir void VCLXButton::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException) 419cdf0e10cSrcweir { 420cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 421cdf0e10cSrcweir maItemListeners.removeInterface( l ); 422cdf0e10cSrcweir } 423cdf0e10cSrcweir 424cdf0e10cSrcweir void VCLXButton::setLabel( const ::rtl::OUString& rLabel ) throw(::com::sun::star::uno::RuntimeException) 425cdf0e10cSrcweir { 426cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 427cdf0e10cSrcweir 428cdf0e10cSrcweir Window* pWindow = GetWindow(); 429cdf0e10cSrcweir if ( pWindow ) 430cdf0e10cSrcweir pWindow->SetText( rLabel ); 431cdf0e10cSrcweir } 432cdf0e10cSrcweir 433cdf0e10cSrcweir void VCLXButton::setActionCommand( const ::rtl::OUString& rCommand ) throw(::com::sun::star::uno::RuntimeException) 434cdf0e10cSrcweir { 435cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 436cdf0e10cSrcweir 437cdf0e10cSrcweir maActionCommand = rCommand; 438cdf0e10cSrcweir } 439cdf0e10cSrcweir 440cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXButton::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException) 441cdf0e10cSrcweir { 442cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 443cdf0e10cSrcweir 444cdf0e10cSrcweir Size aSz; 445cdf0e10cSrcweir PushButton* pButton = (PushButton*) GetWindow(); 446cdf0e10cSrcweir if ( pButton ) 447cdf0e10cSrcweir aSz = pButton->CalcMinimumSize(); 448cdf0e10cSrcweir return AWTSize(aSz); 449cdf0e10cSrcweir } 450cdf0e10cSrcweir 451cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXButton::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException) 452cdf0e10cSrcweir { 453cdf0e10cSrcweir ::com::sun::star::awt::Size aSz = getMinimumSize(); 454cdf0e10cSrcweir aSz.Width += 16; 455cdf0e10cSrcweir aSz.Height += 10; 456cdf0e10cSrcweir return aSz; 457cdf0e10cSrcweir } 458cdf0e10cSrcweir 459cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXButton::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException) 460cdf0e10cSrcweir { 461cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 462cdf0e10cSrcweir 463cdf0e10cSrcweir Size aSz = VCLSize(rNewSize); 464cdf0e10cSrcweir PushButton* pButton = (PushButton*) GetWindow(); 465cdf0e10cSrcweir if ( pButton ) 466cdf0e10cSrcweir { 467cdf0e10cSrcweir Size aMinSz = pButton->CalcMinimumSize(); 468cdf0e10cSrcweir // Kein Text, also Image 469cdf0e10cSrcweir if ( !pButton->GetText().Len() ) 470cdf0e10cSrcweir { 471cdf0e10cSrcweir if ( aSz.Width() < aMinSz.Width() ) 472cdf0e10cSrcweir aSz.Width() = aMinSz.Width(); 473cdf0e10cSrcweir if ( aSz.Height() < aMinSz.Height() ) 474cdf0e10cSrcweir aSz.Height() = aMinSz.Height(); 475cdf0e10cSrcweir } 476cdf0e10cSrcweir else 477cdf0e10cSrcweir { 478cdf0e10cSrcweir if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) ) 479cdf0e10cSrcweir aSz.Height() = aMinSz.Height(); 480cdf0e10cSrcweir else 481cdf0e10cSrcweir aSz = aMinSz; 482cdf0e10cSrcweir } 483cdf0e10cSrcweir } 484cdf0e10cSrcweir return AWTSize(aSz); 485cdf0e10cSrcweir } 486cdf0e10cSrcweir 487cdf0e10cSrcweir void VCLXButton::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 488cdf0e10cSrcweir { 489cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 490cdf0e10cSrcweir 491cdf0e10cSrcweir Button* pButton = (Button*)GetWindow(); 492cdf0e10cSrcweir if ( pButton ) 493cdf0e10cSrcweir { 494cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 495cdf0e10cSrcweir switch ( nPropType ) 496cdf0e10cSrcweir { 497cdf0e10cSrcweir case BASEPROPERTY_FOCUSONCLICK: 498cdf0e10cSrcweir ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_NOPOINTERFOCUS, sal_True ); 499cdf0e10cSrcweir break; 500cdf0e10cSrcweir 501cdf0e10cSrcweir case BASEPROPERTY_TOGGLE: 502cdf0e10cSrcweir ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_TOGGLE, sal_False ); 503cdf0e10cSrcweir break; 504cdf0e10cSrcweir 505cdf0e10cSrcweir case BASEPROPERTY_DEFAULTBUTTON: 506cdf0e10cSrcweir { 507cdf0e10cSrcweir WinBits nStyle = pButton->GetStyle() | WB_DEFBUTTON; 508cdf0e10cSrcweir sal_Bool b = sal_Bool(); 509cdf0e10cSrcweir if ( ( Value >>= b ) && !b ) 510cdf0e10cSrcweir nStyle &= ~WB_DEFBUTTON; 511cdf0e10cSrcweir pButton->SetStyle( nStyle ); 512cdf0e10cSrcweir } 513cdf0e10cSrcweir break; 514cdf0e10cSrcweir case BASEPROPERTY_STATE: 515cdf0e10cSrcweir { 516cdf0e10cSrcweir if ( GetWindow()->GetType() == WINDOW_PUSHBUTTON ) 517cdf0e10cSrcweir { 518cdf0e10cSrcweir sal_Int16 n = sal_Int16(); 519cdf0e10cSrcweir if ( Value >>= n ) 520cdf0e10cSrcweir ((PushButton*)pButton)->SetState( (TriState)n ); 521cdf0e10cSrcweir } 522cdf0e10cSrcweir } 523cdf0e10cSrcweir break; 524cdf0e10cSrcweir default: 525cdf0e10cSrcweir { 526cdf0e10cSrcweir VCLXGraphicControl::setProperty( PropertyName, Value ); 527cdf0e10cSrcweir } 528cdf0e10cSrcweir } 529cdf0e10cSrcweir } 530cdf0e10cSrcweir } 531cdf0e10cSrcweir 532cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXButton::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) 533cdf0e10cSrcweir { 534cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 535cdf0e10cSrcweir 536cdf0e10cSrcweir ::com::sun::star::uno::Any aProp; 537cdf0e10cSrcweir Button* pButton = (Button*)GetWindow(); 538cdf0e10cSrcweir if ( pButton ) 539cdf0e10cSrcweir { 540cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 541cdf0e10cSrcweir switch ( nPropType ) 542cdf0e10cSrcweir { 543cdf0e10cSrcweir case BASEPROPERTY_FOCUSONCLICK: 544cdf0e10cSrcweir aProp <<= (sal_Bool)( ( pButton->GetStyle() & WB_NOPOINTERFOCUS ) == 0 ); 545cdf0e10cSrcweir break; 546cdf0e10cSrcweir 547cdf0e10cSrcweir case BASEPROPERTY_TOGGLE: 548cdf0e10cSrcweir aProp <<= (sal_Bool)( ( pButton->GetStyle() & WB_TOGGLE ) != 0 ); 549cdf0e10cSrcweir break; 550cdf0e10cSrcweir 551cdf0e10cSrcweir case BASEPROPERTY_DEFAULTBUTTON: 552cdf0e10cSrcweir { 553cdf0e10cSrcweir aProp <<= (sal_Bool) ( ( pButton->GetStyle() & WB_DEFBUTTON ) ? sal_True : sal_False ); 554cdf0e10cSrcweir } 555cdf0e10cSrcweir break; 556cdf0e10cSrcweir case BASEPROPERTY_STATE: 557cdf0e10cSrcweir { 558cdf0e10cSrcweir if ( GetWindow()->GetType() == WINDOW_PUSHBUTTON ) 559cdf0e10cSrcweir { 560cdf0e10cSrcweir aProp <<= (sal_Int16)((PushButton*)pButton)->GetState(); 561cdf0e10cSrcweir } 562cdf0e10cSrcweir } 563cdf0e10cSrcweir break; 564cdf0e10cSrcweir default: 565cdf0e10cSrcweir { 566cdf0e10cSrcweir aProp <<= VCLXGraphicControl::getProperty( PropertyName ); 567cdf0e10cSrcweir } 568cdf0e10cSrcweir } 569cdf0e10cSrcweir } 570cdf0e10cSrcweir return aProp; 571cdf0e10cSrcweir } 572cdf0e10cSrcweir 573cdf0e10cSrcweir void VCLXButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) 574cdf0e10cSrcweir { 575cdf0e10cSrcweir switch ( rVclWindowEvent.GetId() ) 576cdf0e10cSrcweir { 577cdf0e10cSrcweir case VCLEVENT_BUTTON_CLICK: 578cdf0e10cSrcweir { 579cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this ); 580cdf0e10cSrcweir // since we call listeners below, there is a potential that we will be destroyed 581cdf0e10cSrcweir // during the listener call. To prevent the resulting crashs, we keep us 582cdf0e10cSrcweir // alive as long as we're here 583cdf0e10cSrcweir // #20178# - 2003-10-01 - fs@openoffice.org 584cdf0e10cSrcweir 585cdf0e10cSrcweir if ( maActionListeners.getLength() ) 586cdf0e10cSrcweir { 587cdf0e10cSrcweir ::com::sun::star::awt::ActionEvent aEvent; 588cdf0e10cSrcweir aEvent.Source = (::cppu::OWeakObject*)this; 589cdf0e10cSrcweir aEvent.ActionCommand = maActionCommand; 590cdf0e10cSrcweir 591cdf0e10cSrcweir Callback aCallback = ::boost::bind( 592cdf0e10cSrcweir &ActionListenerMultiplexer::actionPerformed, 593cdf0e10cSrcweir &maActionListeners, 594cdf0e10cSrcweir aEvent 595cdf0e10cSrcweir ); 596cdf0e10cSrcweir ImplExecuteAsyncWithoutSolarLock( aCallback ); 597cdf0e10cSrcweir } 598cdf0e10cSrcweir } 599cdf0e10cSrcweir break; 600cdf0e10cSrcweir 601cdf0e10cSrcweir case VCLEVENT_PUSHBUTTON_TOGGLE: 602cdf0e10cSrcweir { 603cdf0e10cSrcweir PushButton& rButton = dynamic_cast< PushButton& >( *rVclWindowEvent.GetWindow() ); 604cdf0e10cSrcweir 605cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this ); 606cdf0e10cSrcweir if ( maItemListeners.getLength() ) 607cdf0e10cSrcweir { 608cdf0e10cSrcweir ::com::sun::star::awt::ItemEvent aEvent; 609cdf0e10cSrcweir aEvent.Source = (::cppu::OWeakObject*)this; 610cdf0e10cSrcweir aEvent.Selected = ( rButton.GetState() == STATE_CHECK ) ? 1 : 0; 611cdf0e10cSrcweir maItemListeners.itemStateChanged( aEvent ); 612cdf0e10cSrcweir } 613cdf0e10cSrcweir } 614cdf0e10cSrcweir break; 615cdf0e10cSrcweir 616cdf0e10cSrcweir default: 617cdf0e10cSrcweir VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent ); 618cdf0e10cSrcweir break; 619cdf0e10cSrcweir } 620cdf0e10cSrcweir } 621cdf0e10cSrcweir 622cdf0e10cSrcweir // ---------------------------------------------------- 623cdf0e10cSrcweir // class VCLXImageControl 624cdf0e10cSrcweir // ---------------------------------------------------- 625cdf0e10cSrcweir 626cdf0e10cSrcweir void VCLXImageControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 627cdf0e10cSrcweir { 628cdf0e10cSrcweir PushPropertyIds( rIds, 629cdf0e10cSrcweir BASEPROPERTY_BACKGROUNDCOLOR, 630cdf0e10cSrcweir BASEPROPERTY_BORDER, 631cdf0e10cSrcweir BASEPROPERTY_BORDERCOLOR, 632cdf0e10cSrcweir BASEPROPERTY_DEFAULTCONTROL, 633cdf0e10cSrcweir BASEPROPERTY_ENABLED, 634cdf0e10cSrcweir BASEPROPERTY_ENABLEVISIBLE, 635cdf0e10cSrcweir BASEPROPERTY_GRAPHIC, 636cdf0e10cSrcweir BASEPROPERTY_HELPTEXT, 637cdf0e10cSrcweir BASEPROPERTY_HELPURL, 638cdf0e10cSrcweir BASEPROPERTY_IMAGEURL, 639cdf0e10cSrcweir BASEPROPERTY_PRINTABLE, 640cdf0e10cSrcweir BASEPROPERTY_SCALEIMAGE, 641cdf0e10cSrcweir BASEPROPERTY_IMAGE_SCALE_MODE, 642cdf0e10cSrcweir BASEPROPERTY_TABSTOP, 643cdf0e10cSrcweir BASEPROPERTY_WRITING_MODE, 644cdf0e10cSrcweir BASEPROPERTY_CONTEXT_WRITING_MODE, 645cdf0e10cSrcweir 0); 646cdf0e10cSrcweir VCLXGraphicControl::ImplGetPropertyIds( rIds ); 647cdf0e10cSrcweir } 648cdf0e10cSrcweir 649cdf0e10cSrcweir VCLXImageControl::VCLXImageControl() 650cdf0e10cSrcweir { 651cdf0e10cSrcweir } 652cdf0e10cSrcweir 653cdf0e10cSrcweir VCLXImageControl::~VCLXImageControl() 654cdf0e10cSrcweir { 655cdf0e10cSrcweir } 656cdf0e10cSrcweir 657cdf0e10cSrcweir void VCLXImageControl::ImplSetNewImage() 658cdf0e10cSrcweir { 659cdf0e10cSrcweir OSL_PRECOND( GetWindow(), "VCLXImageControl::ImplSetNewImage: window is required to be not-NULL!" ); 660cdf0e10cSrcweir ImageControl* pControl = static_cast< ImageControl* >( GetWindow() ); 661cdf0e10cSrcweir pControl->SetImage( GetImage() ); 662cdf0e10cSrcweir } 663cdf0e10cSrcweir 664cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXImageControl::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException) 665cdf0e10cSrcweir { 666cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 667cdf0e10cSrcweir 668cdf0e10cSrcweir Size aSz = GetImage().GetSizePixel(); 669cdf0e10cSrcweir aSz = ImplCalcWindowSize( aSz ); 670cdf0e10cSrcweir 671cdf0e10cSrcweir return AWTSize(aSz); 672cdf0e10cSrcweir } 673cdf0e10cSrcweir 674cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXImageControl::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException) 675cdf0e10cSrcweir { 676cdf0e10cSrcweir return getMinimumSize(); 677cdf0e10cSrcweir } 678cdf0e10cSrcweir 679cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXImageControl::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException) 680cdf0e10cSrcweir { 681cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 682cdf0e10cSrcweir 683cdf0e10cSrcweir ::com::sun::star::awt::Size aSz = rNewSize; 684cdf0e10cSrcweir ::com::sun::star::awt::Size aMinSz = getMinimumSize(); 685cdf0e10cSrcweir if ( aSz.Width < aMinSz.Width ) 686cdf0e10cSrcweir aSz.Width = aMinSz.Width; 687cdf0e10cSrcweir if ( aSz.Height < aMinSz.Height ) 688cdf0e10cSrcweir aSz.Height = aMinSz.Height; 689cdf0e10cSrcweir return aSz; 690cdf0e10cSrcweir } 691cdf0e10cSrcweir 692cdf0e10cSrcweir void VCLXImageControl::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 693cdf0e10cSrcweir { 694cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 695cdf0e10cSrcweir 696cdf0e10cSrcweir ImageControl* pImageControl = (ImageControl*)GetWindow(); 697cdf0e10cSrcweir 698cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 699cdf0e10cSrcweir switch ( nPropType ) 700cdf0e10cSrcweir { 701cdf0e10cSrcweir case BASEPROPERTY_IMAGE_SCALE_MODE: 702cdf0e10cSrcweir { 703cdf0e10cSrcweir sal_Int16 nScaleMode( ImageScaleMode::Anisotropic ); 704cdf0e10cSrcweir if ( pImageControl && ( Value >>= nScaleMode ) ) 705cdf0e10cSrcweir { 706cdf0e10cSrcweir pImageControl->SetScaleMode( nScaleMode ); 707cdf0e10cSrcweir } 708cdf0e10cSrcweir } 709cdf0e10cSrcweir break; 710cdf0e10cSrcweir 711cdf0e10cSrcweir case BASEPROPERTY_SCALEIMAGE: 712cdf0e10cSrcweir { 713cdf0e10cSrcweir // this is for compatibility only, nowadays, the ImageScaleMode property should be used 714cdf0e10cSrcweir sal_Bool bScaleImage = sal_False; 715cdf0e10cSrcweir if ( pImageControl && ( Value >>= bScaleImage ) ) 716cdf0e10cSrcweir { 717cdf0e10cSrcweir pImageControl->SetScaleMode( bScaleImage ? ImageScaleMode::Anisotropic : ImageScaleMode::None ); 718cdf0e10cSrcweir } 719cdf0e10cSrcweir } 720cdf0e10cSrcweir break; 721cdf0e10cSrcweir 722cdf0e10cSrcweir default: 723cdf0e10cSrcweir VCLXGraphicControl::setProperty( PropertyName, Value ); 724cdf0e10cSrcweir break; 725cdf0e10cSrcweir } 726cdf0e10cSrcweir } 727cdf0e10cSrcweir 728cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXImageControl::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) 729cdf0e10cSrcweir { 730cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 731cdf0e10cSrcweir 732cdf0e10cSrcweir ::com::sun::star::uno::Any aProp; 733cdf0e10cSrcweir ImageControl* pImageControl = (ImageControl*)GetWindow(); 734cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 735cdf0e10cSrcweir 736cdf0e10cSrcweir switch ( nPropType ) 737cdf0e10cSrcweir { 738cdf0e10cSrcweir case BASEPROPERTY_IMAGE_SCALE_MODE: 739cdf0e10cSrcweir aProp <<= ( pImageControl ? pImageControl->GetScaleMode() : ImageScaleMode::Anisotropic ); 740cdf0e10cSrcweir break; 741cdf0e10cSrcweir 742cdf0e10cSrcweir case BASEPROPERTY_SCALEIMAGE: 743cdf0e10cSrcweir aProp <<= ( pImageControl && pImageControl->GetScaleMode() != ImageScaleMode::None ) ? sal_True : sal_False; 744cdf0e10cSrcweir break; 745cdf0e10cSrcweir 746cdf0e10cSrcweir default: 747cdf0e10cSrcweir aProp = VCLXGraphicControl::getProperty( PropertyName ); 748cdf0e10cSrcweir break; 749cdf0e10cSrcweir } 750cdf0e10cSrcweir return aProp; 751cdf0e10cSrcweir } 752cdf0e10cSrcweir 753cdf0e10cSrcweir // ---------------------------------------------------- 754cdf0e10cSrcweir // class VCLXCheckBox 755cdf0e10cSrcweir // ---------------------------------------------------- 756cdf0e10cSrcweir 757cdf0e10cSrcweir 758cdf0e10cSrcweir void VCLXCheckBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 759cdf0e10cSrcweir { 760cdf0e10cSrcweir PushPropertyIds( rIds, 761cdf0e10cSrcweir BASEPROPERTY_DEFAULTCONTROL, 762cdf0e10cSrcweir BASEPROPERTY_ENABLED, 763cdf0e10cSrcweir BASEPROPERTY_ENABLEVISIBLE, 764cdf0e10cSrcweir BASEPROPERTY_FONTDESCRIPTOR, 765cdf0e10cSrcweir BASEPROPERTY_GRAPHIC, 766cdf0e10cSrcweir BASEPROPERTY_HELPTEXT, 767cdf0e10cSrcweir BASEPROPERTY_HELPURL, 768cdf0e10cSrcweir BASEPROPERTY_IMAGEPOSITION, 769cdf0e10cSrcweir BASEPROPERTY_IMAGEURL, 770cdf0e10cSrcweir BASEPROPERTY_LABEL, 771cdf0e10cSrcweir BASEPROPERTY_PRINTABLE, 772cdf0e10cSrcweir BASEPROPERTY_STATE, 773cdf0e10cSrcweir BASEPROPERTY_TABSTOP, 774cdf0e10cSrcweir BASEPROPERTY_TRISTATE, 775cdf0e10cSrcweir BASEPROPERTY_VISUALEFFECT, 776cdf0e10cSrcweir BASEPROPERTY_MULTILINE, 777cdf0e10cSrcweir BASEPROPERTY_BACKGROUNDCOLOR, 778cdf0e10cSrcweir BASEPROPERTY_ALIGN, 779cdf0e10cSrcweir BASEPROPERTY_VERTICALALIGN, 780cdf0e10cSrcweir BASEPROPERTY_WRITING_MODE, 781cdf0e10cSrcweir BASEPROPERTY_CONTEXT_WRITING_MODE, 782cdf0e10cSrcweir BASEPROPERTY_REFERENCE_DEVICE, 783cdf0e10cSrcweir 0); 784cdf0e10cSrcweir VCLXGraphicControl::ImplGetPropertyIds( rIds ); 785cdf0e10cSrcweir } 786cdf0e10cSrcweir 787cdf0e10cSrcweir VCLXCheckBox::VCLXCheckBox() : maActionListeners( *this ), maItemListeners( *this ) 788cdf0e10cSrcweir { 789cdf0e10cSrcweir } 790cdf0e10cSrcweir 791cdf0e10cSrcweir // ::com::sun::star::uno::XInterface 792cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXCheckBox::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 793cdf0e10cSrcweir { 794cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 795cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XButton*, this ), 796cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XCheckBox*, this ) ); 797cdf0e10cSrcweir return (aRet.hasValue() ? aRet : VCLXGraphicControl::queryInterface( rType )); 798cdf0e10cSrcweir } 799cdf0e10cSrcweir 800cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 801cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXCheckBox ) 802cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XButton>* ) NULL ), 803cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XCheckBox>* ) NULL ), 804cdf0e10cSrcweir VCLXGraphicControl::getTypes() 805cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 806cdf0e10cSrcweir 807cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXCheckBox::CreateAccessibleContext() 808cdf0e10cSrcweir { 809cdf0e10cSrcweir return getAccessibleFactory().createAccessibleContext( this ); 810cdf0e10cSrcweir } 811cdf0e10cSrcweir 812cdf0e10cSrcweir void VCLXCheckBox::dispose() throw(::com::sun::star::uno::RuntimeException) 813cdf0e10cSrcweir { 814cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 815cdf0e10cSrcweir 816cdf0e10cSrcweir ::com::sun::star::lang::EventObject aObj; 817cdf0e10cSrcweir aObj.Source = (::cppu::OWeakObject*)this; 818cdf0e10cSrcweir maItemListeners.disposeAndClear( aObj ); 819cdf0e10cSrcweir VCLXGraphicControl::dispose(); 820cdf0e10cSrcweir } 821cdf0e10cSrcweir 822cdf0e10cSrcweir void VCLXCheckBox::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException) 823cdf0e10cSrcweir { 824cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 825cdf0e10cSrcweir maItemListeners.addInterface( l ); 826cdf0e10cSrcweir } 827cdf0e10cSrcweir 828cdf0e10cSrcweir void VCLXCheckBox::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException) 829cdf0e10cSrcweir { 830cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 831cdf0e10cSrcweir maItemListeners.removeInterface( l ); 832cdf0e10cSrcweir } 833cdf0e10cSrcweir 834cdf0e10cSrcweir void VCLXCheckBox::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )throw(::com::sun::star::uno::RuntimeException) 835cdf0e10cSrcweir { 836cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 837cdf0e10cSrcweir maActionListeners.addInterface( l ); 838cdf0e10cSrcweir } 839cdf0e10cSrcweir 840cdf0e10cSrcweir void VCLXCheckBox::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException) 841cdf0e10cSrcweir { 842cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 843cdf0e10cSrcweir maActionListeners.removeInterface( l ); 844cdf0e10cSrcweir } 845cdf0e10cSrcweir 846cdf0e10cSrcweir void VCLXCheckBox::setActionCommand( const ::rtl::OUString& rCommand ) throw(::com::sun::star::uno::RuntimeException) 847cdf0e10cSrcweir { 848cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 849cdf0e10cSrcweir maActionCommand = rCommand; 850cdf0e10cSrcweir } 851cdf0e10cSrcweir 852cdf0e10cSrcweir void VCLXCheckBox::setLabel( const ::rtl::OUString& rLabel ) throw(::com::sun::star::uno::RuntimeException) 853cdf0e10cSrcweir { 854cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 855cdf0e10cSrcweir 856cdf0e10cSrcweir Window* pWindow = GetWindow(); 857cdf0e10cSrcweir if ( pWindow ) 858cdf0e10cSrcweir pWindow->SetText( rLabel ); 859cdf0e10cSrcweir } 860cdf0e10cSrcweir 861cdf0e10cSrcweir void VCLXCheckBox::setState( short n ) throw(::com::sun::star::uno::RuntimeException) 862cdf0e10cSrcweir { 863cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 864cdf0e10cSrcweir 865cdf0e10cSrcweir CheckBox* pCheckBox = (CheckBox*)GetWindow(); 866cdf0e10cSrcweir if ( pCheckBox) 867cdf0e10cSrcweir { 868cdf0e10cSrcweir TriState eState; 869cdf0e10cSrcweir switch ( n ) 870cdf0e10cSrcweir { 871cdf0e10cSrcweir case 0: eState = STATE_NOCHECK; break; 872cdf0e10cSrcweir case 1: eState = STATE_CHECK; break; 873cdf0e10cSrcweir case 2: eState = STATE_DONTKNOW; break; 874cdf0e10cSrcweir default: eState = STATE_NOCHECK; 875cdf0e10cSrcweir } 876cdf0e10cSrcweir pCheckBox->SetState( eState ); 877cdf0e10cSrcweir 878cdf0e10cSrcweir // #105198# call C++ click listeners (needed for accessibility) 879cdf0e10cSrcweir // pCheckBox->GetClickHdl().Call( pCheckBox ); 880cdf0e10cSrcweir 881cdf0e10cSrcweir // #107218# Call same virtual methods and listeners like VCL would do after user interaction 882cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_True ); 883cdf0e10cSrcweir pCheckBox->Toggle(); 884cdf0e10cSrcweir pCheckBox->Click(); 885cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_False ); 886cdf0e10cSrcweir } 887cdf0e10cSrcweir } 888cdf0e10cSrcweir 889cdf0e10cSrcweir short VCLXCheckBox::getState() throw(::com::sun::star::uno::RuntimeException) 890cdf0e10cSrcweir { 891cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 892cdf0e10cSrcweir 893cdf0e10cSrcweir short nState = -1; 894cdf0e10cSrcweir CheckBox* pCheckBox = (CheckBox*)GetWindow(); 895cdf0e10cSrcweir if ( pCheckBox ) 896cdf0e10cSrcweir { 897cdf0e10cSrcweir switch ( pCheckBox->GetState() ) 898cdf0e10cSrcweir { 899cdf0e10cSrcweir case STATE_NOCHECK: nState = 0; break; 900cdf0e10cSrcweir case STATE_CHECK: nState = 1; break; 901cdf0e10cSrcweir case STATE_DONTKNOW: nState = 2; break; 902cdf0e10cSrcweir default: DBG_ERROR( "VCLXCheckBox::getState(): unknown TriState!" ); 903cdf0e10cSrcweir } 904cdf0e10cSrcweir } 905cdf0e10cSrcweir 906cdf0e10cSrcweir return nState; 907cdf0e10cSrcweir } 908cdf0e10cSrcweir 909cdf0e10cSrcweir void VCLXCheckBox::enableTriState( sal_Bool b ) throw(::com::sun::star::uno::RuntimeException) 910cdf0e10cSrcweir { 911cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 912cdf0e10cSrcweir 913cdf0e10cSrcweir CheckBox* pCheckBox = (CheckBox*)GetWindow(); 914cdf0e10cSrcweir if ( pCheckBox) 915cdf0e10cSrcweir pCheckBox->EnableTriState( b ); 916cdf0e10cSrcweir } 917cdf0e10cSrcweir 918cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXCheckBox::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException) 919cdf0e10cSrcweir { 920cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 921cdf0e10cSrcweir 922cdf0e10cSrcweir Size aSz; 923cdf0e10cSrcweir CheckBox* pCheckBox = (CheckBox*) GetWindow(); 924cdf0e10cSrcweir if ( pCheckBox ) 925cdf0e10cSrcweir aSz = pCheckBox->CalcMinimumSize(); 926cdf0e10cSrcweir return AWTSize(aSz); 927cdf0e10cSrcweir } 928cdf0e10cSrcweir 929cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXCheckBox::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException) 930cdf0e10cSrcweir { 931cdf0e10cSrcweir return getMinimumSize(); 932cdf0e10cSrcweir } 933cdf0e10cSrcweir 934cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXCheckBox::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException) 935cdf0e10cSrcweir { 936cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 937cdf0e10cSrcweir 938cdf0e10cSrcweir Size aSz = VCLSize(rNewSize); 939cdf0e10cSrcweir CheckBox* pCheckBox = (CheckBox*) GetWindow(); 940cdf0e10cSrcweir if ( pCheckBox ) 941cdf0e10cSrcweir { 942cdf0e10cSrcweir Size aMinSz = pCheckBox->CalcMinimumSize(); 943cdf0e10cSrcweir if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) ) 944cdf0e10cSrcweir aSz.Height() = aMinSz.Height(); 945cdf0e10cSrcweir else 946cdf0e10cSrcweir aSz = aMinSz; 947cdf0e10cSrcweir } 948cdf0e10cSrcweir return AWTSize(aSz); 949cdf0e10cSrcweir } 950cdf0e10cSrcweir 951cdf0e10cSrcweir void VCLXCheckBox::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 952cdf0e10cSrcweir { 953cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 954cdf0e10cSrcweir 955cdf0e10cSrcweir CheckBox* pCheckBox = (CheckBox*)GetWindow(); 956cdf0e10cSrcweir if ( pCheckBox ) 957cdf0e10cSrcweir { 958cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 959cdf0e10cSrcweir switch ( nPropType ) 960cdf0e10cSrcweir { 961cdf0e10cSrcweir case BASEPROPERTY_VISUALEFFECT: 962cdf0e10cSrcweir ::toolkit::setVisualEffect( Value, pCheckBox ); 963cdf0e10cSrcweir break; 964cdf0e10cSrcweir 965cdf0e10cSrcweir case BASEPROPERTY_TRISTATE: 966cdf0e10cSrcweir { 967cdf0e10cSrcweir sal_Bool b = sal_Bool(); 968cdf0e10cSrcweir if ( Value >>= b ) 969cdf0e10cSrcweir pCheckBox->EnableTriState( b ); 970cdf0e10cSrcweir } 971cdf0e10cSrcweir break; 972cdf0e10cSrcweir case BASEPROPERTY_STATE: 973cdf0e10cSrcweir { 974cdf0e10cSrcweir sal_Int16 n = sal_Int16(); 975cdf0e10cSrcweir if ( Value >>= n ) 976cdf0e10cSrcweir setState( n ); 977cdf0e10cSrcweir } 978cdf0e10cSrcweir break; 979cdf0e10cSrcweir default: 980cdf0e10cSrcweir { 981cdf0e10cSrcweir VCLXGraphicControl::setProperty( PropertyName, Value ); 982cdf0e10cSrcweir } 983cdf0e10cSrcweir } 984cdf0e10cSrcweir } 985cdf0e10cSrcweir } 986cdf0e10cSrcweir 987cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXCheckBox::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) 988cdf0e10cSrcweir { 989cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 990cdf0e10cSrcweir 991cdf0e10cSrcweir ::com::sun::star::uno::Any aProp; 992cdf0e10cSrcweir CheckBox* pCheckBox = (CheckBox*)GetWindow(); 993cdf0e10cSrcweir if ( pCheckBox ) 994cdf0e10cSrcweir { 995cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 996cdf0e10cSrcweir switch ( nPropType ) 997cdf0e10cSrcweir { 998cdf0e10cSrcweir case BASEPROPERTY_VISUALEFFECT: 999cdf0e10cSrcweir aProp = ::toolkit::getVisualEffect( pCheckBox ); 1000cdf0e10cSrcweir break; 1001cdf0e10cSrcweir case BASEPROPERTY_TRISTATE: 1002cdf0e10cSrcweir aProp <<= (sal_Bool)pCheckBox->IsTriStateEnabled(); 1003cdf0e10cSrcweir break; 1004cdf0e10cSrcweir case BASEPROPERTY_STATE: 1005cdf0e10cSrcweir aProp <<= (sal_Int16)pCheckBox->GetState(); 1006cdf0e10cSrcweir break; 1007cdf0e10cSrcweir default: 1008cdf0e10cSrcweir { 1009cdf0e10cSrcweir aProp <<= VCLXGraphicControl::getProperty( PropertyName ); 1010cdf0e10cSrcweir } 1011cdf0e10cSrcweir } 1012cdf0e10cSrcweir } 1013cdf0e10cSrcweir return aProp; 1014cdf0e10cSrcweir } 1015cdf0e10cSrcweir 1016cdf0e10cSrcweir void VCLXCheckBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) 1017cdf0e10cSrcweir { 1018cdf0e10cSrcweir switch ( rVclWindowEvent.GetId() ) 1019cdf0e10cSrcweir { 1020cdf0e10cSrcweir case VCLEVENT_CHECKBOX_TOGGLE: 1021cdf0e10cSrcweir { 1022cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this ); 1023cdf0e10cSrcweir // since we call listeners below, there is a potential that we will be destroyed 1024cdf0e10cSrcweir // in during the listener call. To prevent the resulting crashs, we keep us 1025cdf0e10cSrcweir // alive as long as we're here 1026cdf0e10cSrcweir // #20178# - 2003-10-01 - fs@openoffice.org 1027cdf0e10cSrcweir 1028cdf0e10cSrcweir CheckBox* pCheckBox = (CheckBox*)GetWindow(); 1029cdf0e10cSrcweir if ( pCheckBox ) 1030cdf0e10cSrcweir { 1031cdf0e10cSrcweir if ( maItemListeners.getLength() ) 1032cdf0e10cSrcweir { 1033cdf0e10cSrcweir ::com::sun::star::awt::ItemEvent aEvent; 1034cdf0e10cSrcweir aEvent.Source = (::cppu::OWeakObject*)this; 1035cdf0e10cSrcweir aEvent.Highlighted = sal_False; 1036cdf0e10cSrcweir aEvent.Selected = pCheckBox->GetState(); 1037cdf0e10cSrcweir maItemListeners.itemStateChanged( aEvent ); 1038cdf0e10cSrcweir } 1039cdf0e10cSrcweir if ( !IsSynthesizingVCLEvent() && maActionListeners.getLength() ) 1040cdf0e10cSrcweir { 1041cdf0e10cSrcweir ::com::sun::star::awt::ActionEvent aEvent; 1042cdf0e10cSrcweir aEvent.Source = (::cppu::OWeakObject*)this; 1043cdf0e10cSrcweir aEvent.ActionCommand = maActionCommand; 1044cdf0e10cSrcweir maActionListeners.actionPerformed( aEvent ); 1045cdf0e10cSrcweir } 1046cdf0e10cSrcweir } 1047cdf0e10cSrcweir } 1048cdf0e10cSrcweir break; 1049cdf0e10cSrcweir 1050cdf0e10cSrcweir default: 1051cdf0e10cSrcweir VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent ); 1052cdf0e10cSrcweir break; 1053cdf0e10cSrcweir } 1054cdf0e10cSrcweir } 1055cdf0e10cSrcweir 1056cdf0e10cSrcweir // ---------------------------------------------------- 1057cdf0e10cSrcweir // class VCLXRadioButton 1058cdf0e10cSrcweir // ---------------------------------------------------- 1059cdf0e10cSrcweir void VCLXRadioButton::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 1060cdf0e10cSrcweir { 1061cdf0e10cSrcweir PushPropertyIds( rIds, 1062cdf0e10cSrcweir BASEPROPERTY_DEFAULTCONTROL, 1063cdf0e10cSrcweir BASEPROPERTY_ENABLED, 1064cdf0e10cSrcweir BASEPROPERTY_ENABLEVISIBLE, 1065cdf0e10cSrcweir BASEPROPERTY_FONTDESCRIPTOR, 1066cdf0e10cSrcweir BASEPROPERTY_GRAPHIC, 1067cdf0e10cSrcweir BASEPROPERTY_HELPTEXT, 1068cdf0e10cSrcweir BASEPROPERTY_HELPURL, 1069cdf0e10cSrcweir BASEPROPERTY_IMAGEPOSITION, 1070cdf0e10cSrcweir BASEPROPERTY_IMAGEURL, 1071cdf0e10cSrcweir BASEPROPERTY_LABEL, 1072cdf0e10cSrcweir BASEPROPERTY_PRINTABLE, 1073cdf0e10cSrcweir BASEPROPERTY_STATE, 1074cdf0e10cSrcweir BASEPROPERTY_TABSTOP, 1075cdf0e10cSrcweir BASEPROPERTY_VISUALEFFECT, 1076cdf0e10cSrcweir BASEPROPERTY_MULTILINE, 1077cdf0e10cSrcweir BASEPROPERTY_BACKGROUNDCOLOR, 1078cdf0e10cSrcweir BASEPROPERTY_ALIGN, 1079cdf0e10cSrcweir BASEPROPERTY_VERTICALALIGN, 1080cdf0e10cSrcweir BASEPROPERTY_WRITING_MODE, 1081cdf0e10cSrcweir BASEPROPERTY_CONTEXT_WRITING_MODE, 1082cdf0e10cSrcweir BASEPROPERTY_REFERENCE_DEVICE, 1083cdf0e10cSrcweir 0); 1084cdf0e10cSrcweir VCLXGraphicControl::ImplGetPropertyIds( rIds ); 1085cdf0e10cSrcweir } 1086cdf0e10cSrcweir 1087cdf0e10cSrcweir 1088cdf0e10cSrcweir VCLXRadioButton::VCLXRadioButton() : maItemListeners( *this ), maActionListeners( *this ) 1089cdf0e10cSrcweir { 1090cdf0e10cSrcweir } 1091cdf0e10cSrcweir 1092cdf0e10cSrcweir // ::com::sun::star::uno::XInterface 1093cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXRadioButton::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 1094cdf0e10cSrcweir { 1095cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 1096cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XRadioButton*, this ), 1097cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XButton*, this ) ); 1098cdf0e10cSrcweir return (aRet.hasValue() ? aRet : VCLXGraphicControl::queryInterface( rType )); 1099cdf0e10cSrcweir } 1100cdf0e10cSrcweir 1101cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 1102cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXRadioButton ) 1103cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRadioButton>* ) NULL ), 1104cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XButton>* ) NULL ), 1105cdf0e10cSrcweir VCLXGraphicControl::getTypes() 1106cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 1107cdf0e10cSrcweir 1108cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXRadioButton::CreateAccessibleContext() 1109cdf0e10cSrcweir { 1110cdf0e10cSrcweir return getAccessibleFactory().createAccessibleContext( this ); 1111cdf0e10cSrcweir } 1112cdf0e10cSrcweir 1113cdf0e10cSrcweir void VCLXRadioButton::dispose() throw(::com::sun::star::uno::RuntimeException) 1114cdf0e10cSrcweir { 1115cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1116cdf0e10cSrcweir 1117cdf0e10cSrcweir ::com::sun::star::lang::EventObject aObj; 1118cdf0e10cSrcweir aObj.Source = (::cppu::OWeakObject*)this; 1119cdf0e10cSrcweir maItemListeners.disposeAndClear( aObj ); 1120cdf0e10cSrcweir VCLXGraphicControl::dispose(); 1121cdf0e10cSrcweir } 1122cdf0e10cSrcweir 1123cdf0e10cSrcweir void VCLXRadioButton::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 1124cdf0e10cSrcweir { 1125cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1126cdf0e10cSrcweir 1127cdf0e10cSrcweir RadioButton* pButton = (RadioButton*)GetWindow(); 1128cdf0e10cSrcweir if ( pButton ) 1129cdf0e10cSrcweir { 1130cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 1131cdf0e10cSrcweir switch ( nPropType ) 1132cdf0e10cSrcweir { 1133cdf0e10cSrcweir case BASEPROPERTY_VISUALEFFECT: 1134cdf0e10cSrcweir ::toolkit::setVisualEffect( Value, pButton ); 1135cdf0e10cSrcweir break; 1136cdf0e10cSrcweir 1137cdf0e10cSrcweir case BASEPROPERTY_STATE: 1138cdf0e10cSrcweir { 1139cdf0e10cSrcweir sal_Int16 n = sal_Int16(); 1140cdf0e10cSrcweir if ( Value >>= n ) 1141cdf0e10cSrcweir { 1142cdf0e10cSrcweir sal_Bool b = n ? sal_True : sal_False; 1143cdf0e10cSrcweir if ( pButton->IsRadioCheckEnabled() ) 1144cdf0e10cSrcweir pButton->Check( b ); 1145cdf0e10cSrcweir else 1146cdf0e10cSrcweir pButton->SetState( b ); 1147cdf0e10cSrcweir } 1148cdf0e10cSrcweir } 1149cdf0e10cSrcweir break; 1150cdf0e10cSrcweir case BASEPROPERTY_AUTOTOGGLE: 1151cdf0e10cSrcweir { 1152cdf0e10cSrcweir sal_Bool b = sal_Bool(); 1153cdf0e10cSrcweir if ( Value >>= b ) 1154cdf0e10cSrcweir pButton->EnableRadioCheck( b ); 1155cdf0e10cSrcweir } 1156cdf0e10cSrcweir break; 1157cdf0e10cSrcweir default: 1158cdf0e10cSrcweir { 1159cdf0e10cSrcweir VCLXGraphicControl::setProperty( PropertyName, Value ); 1160cdf0e10cSrcweir } 1161cdf0e10cSrcweir } 1162cdf0e10cSrcweir } 1163cdf0e10cSrcweir } 1164cdf0e10cSrcweir 1165cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXRadioButton::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) 1166cdf0e10cSrcweir { 1167cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1168cdf0e10cSrcweir 1169cdf0e10cSrcweir ::com::sun::star::uno::Any aProp; 1170cdf0e10cSrcweir RadioButton* pButton = (RadioButton*)GetWindow(); 1171cdf0e10cSrcweir if ( pButton ) 1172cdf0e10cSrcweir { 1173cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 1174cdf0e10cSrcweir switch ( nPropType ) 1175cdf0e10cSrcweir { 1176cdf0e10cSrcweir case BASEPROPERTY_VISUALEFFECT: 1177cdf0e10cSrcweir aProp = ::toolkit::getVisualEffect( pButton ); 1178cdf0e10cSrcweir break; 1179cdf0e10cSrcweir case BASEPROPERTY_STATE: 1180cdf0e10cSrcweir aProp <<= (sal_Int16) ( pButton->IsChecked() ? 1 : 0 ); 1181cdf0e10cSrcweir break; 1182cdf0e10cSrcweir case BASEPROPERTY_AUTOTOGGLE: 1183cdf0e10cSrcweir aProp <<= (sal_Bool) pButton->IsRadioCheckEnabled(); 1184cdf0e10cSrcweir break; 1185cdf0e10cSrcweir default: 1186cdf0e10cSrcweir { 1187cdf0e10cSrcweir aProp <<= VCLXGraphicControl::getProperty( PropertyName ); 1188cdf0e10cSrcweir } 1189cdf0e10cSrcweir } 1190cdf0e10cSrcweir } 1191cdf0e10cSrcweir return aProp; 1192cdf0e10cSrcweir } 1193cdf0e10cSrcweir 1194cdf0e10cSrcweir void VCLXRadioButton::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException) 1195cdf0e10cSrcweir { 1196cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1197cdf0e10cSrcweir maItemListeners.addInterface( l ); 1198cdf0e10cSrcweir } 1199cdf0e10cSrcweir 1200cdf0e10cSrcweir void VCLXRadioButton::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException) 1201cdf0e10cSrcweir { 1202cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1203cdf0e10cSrcweir maItemListeners.removeInterface( l ); 1204cdf0e10cSrcweir } 1205cdf0e10cSrcweir 1206cdf0e10cSrcweir void VCLXRadioButton::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )throw(::com::sun::star::uno::RuntimeException) 1207cdf0e10cSrcweir { 1208cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1209cdf0e10cSrcweir maActionListeners.addInterface( l ); 1210cdf0e10cSrcweir } 1211cdf0e10cSrcweir 1212cdf0e10cSrcweir void VCLXRadioButton::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException) 1213cdf0e10cSrcweir { 1214cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1215cdf0e10cSrcweir maActionListeners.removeInterface( l ); 1216cdf0e10cSrcweir } 1217cdf0e10cSrcweir 1218cdf0e10cSrcweir void VCLXRadioButton::setLabel( const ::rtl::OUString& rLabel ) throw(::com::sun::star::uno::RuntimeException) 1219cdf0e10cSrcweir { 1220cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1221cdf0e10cSrcweir 1222cdf0e10cSrcweir Window* pWindow = GetWindow(); 1223cdf0e10cSrcweir if ( pWindow ) 1224cdf0e10cSrcweir pWindow->SetText( rLabel ); 1225cdf0e10cSrcweir } 1226cdf0e10cSrcweir 1227cdf0e10cSrcweir void VCLXRadioButton::setActionCommand( const ::rtl::OUString& rCommand ) throw(::com::sun::star::uno::RuntimeException) 1228cdf0e10cSrcweir { 1229cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1230cdf0e10cSrcweir maActionCommand = rCommand; 1231cdf0e10cSrcweir } 1232cdf0e10cSrcweir 1233cdf0e10cSrcweir void VCLXRadioButton::setState( sal_Bool b ) throw(::com::sun::star::uno::RuntimeException) 1234cdf0e10cSrcweir { 1235cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1236cdf0e10cSrcweir 1237cdf0e10cSrcweir RadioButton* pRadioButton = (RadioButton*)GetWindow(); 1238cdf0e10cSrcweir if ( pRadioButton) 1239cdf0e10cSrcweir { 1240cdf0e10cSrcweir pRadioButton->Check( b ); 1241cdf0e10cSrcweir // #102717# item listeners are called, but not C++ click listeners in StarOffice code => call click hdl 1242cdf0e10cSrcweir // But this is needed in old code because Accessibility API uses it. 1243cdf0e10cSrcweir // pRadioButton->GetClickHdl().Call( pRadioButton ); 1244cdf0e10cSrcweir 1245cdf0e10cSrcweir // #107218# Call same virtual methods and listeners like VCL would do after user interaction 1246cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_True ); 1247cdf0e10cSrcweir pRadioButton->Click(); 1248cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_False ); 1249cdf0e10cSrcweir } 1250cdf0e10cSrcweir } 1251cdf0e10cSrcweir 1252cdf0e10cSrcweir sal_Bool VCLXRadioButton::getState() throw(::com::sun::star::uno::RuntimeException) 1253cdf0e10cSrcweir { 1254cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1255cdf0e10cSrcweir 1256cdf0e10cSrcweir RadioButton* pRadioButton = (RadioButton*)GetWindow(); 1257cdf0e10cSrcweir return pRadioButton ? pRadioButton->IsChecked() : sal_False; 1258cdf0e10cSrcweir } 1259cdf0e10cSrcweir 1260cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXRadioButton::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException) 1261cdf0e10cSrcweir { 1262cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1263cdf0e10cSrcweir 1264cdf0e10cSrcweir Size aSz; 1265cdf0e10cSrcweir RadioButton* pRadioButton = (RadioButton*) GetWindow(); 1266cdf0e10cSrcweir if ( pRadioButton ) 1267cdf0e10cSrcweir aSz = pRadioButton->CalcMinimumSize(); 1268cdf0e10cSrcweir return AWTSize(aSz); 1269cdf0e10cSrcweir } 1270cdf0e10cSrcweir 1271cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXRadioButton::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException) 1272cdf0e10cSrcweir { 1273cdf0e10cSrcweir return getMinimumSize(); 1274cdf0e10cSrcweir } 1275cdf0e10cSrcweir 1276cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXRadioButton::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException) 1277cdf0e10cSrcweir { 1278cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1279cdf0e10cSrcweir 1280cdf0e10cSrcweir Size aSz = VCLSize(rNewSize); 1281cdf0e10cSrcweir RadioButton* pRadioButton = (RadioButton*) GetWindow(); 1282cdf0e10cSrcweir if ( pRadioButton ) 1283cdf0e10cSrcweir { 1284cdf0e10cSrcweir Size aMinSz = pRadioButton->CalcMinimumSize(); 1285cdf0e10cSrcweir if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) ) 1286cdf0e10cSrcweir aSz.Height() = aMinSz.Height(); 1287cdf0e10cSrcweir else 1288cdf0e10cSrcweir aSz = aMinSz; 1289cdf0e10cSrcweir } 1290cdf0e10cSrcweir return AWTSize(aSz); 1291cdf0e10cSrcweir } 1292cdf0e10cSrcweir 1293cdf0e10cSrcweir void VCLXRadioButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) 1294cdf0e10cSrcweir { 1295cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this ); 1296cdf0e10cSrcweir // since we call listeners below, there is a potential that we will be destroyed 1297cdf0e10cSrcweir // in during the listener call. To prevent the resulting crashs, we keep us 1298cdf0e10cSrcweir // alive as long as we're here 1299cdf0e10cSrcweir // #20178# - 2003-10-01 - fs@openoffice.org 1300cdf0e10cSrcweir 1301cdf0e10cSrcweir switch ( rVclWindowEvent.GetId() ) 1302cdf0e10cSrcweir { 1303cdf0e10cSrcweir case VCLEVENT_BUTTON_CLICK: 1304cdf0e10cSrcweir if ( !IsSynthesizingVCLEvent() && maActionListeners.getLength() ) 1305cdf0e10cSrcweir { 1306cdf0e10cSrcweir ::com::sun::star::awt::ActionEvent aEvent; 1307cdf0e10cSrcweir aEvent.Source = (::cppu::OWeakObject*)this; 1308cdf0e10cSrcweir aEvent.ActionCommand = maActionCommand; 1309cdf0e10cSrcweir maActionListeners.actionPerformed( aEvent ); 1310cdf0e10cSrcweir } 1311cdf0e10cSrcweir ImplClickedOrToggled( sal_False ); 1312cdf0e10cSrcweir break; 1313cdf0e10cSrcweir 1314cdf0e10cSrcweir case VCLEVENT_RADIOBUTTON_TOGGLE: 1315cdf0e10cSrcweir ImplClickedOrToggled( sal_True ); 1316cdf0e10cSrcweir break; 1317cdf0e10cSrcweir 1318cdf0e10cSrcweir default: 1319cdf0e10cSrcweir VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent ); 1320cdf0e10cSrcweir break; 1321cdf0e10cSrcweir } 1322cdf0e10cSrcweir } 1323cdf0e10cSrcweir 1324cdf0e10cSrcweir void VCLXRadioButton::ImplClickedOrToggled( sal_Bool bToggled ) 1325cdf0e10cSrcweir { 1326cdf0e10cSrcweir // In the formulars, RadioChecked is not enabled, call itemStateChanged only for click 1327cdf0e10cSrcweir // In the dialog editor, RadioChecked is enabled, call itemStateChanged only for bToggled 1328cdf0e10cSrcweir RadioButton* pRadioButton = (RadioButton*)GetWindow(); 1329cdf0e10cSrcweir if ( pRadioButton && ( pRadioButton->IsRadioCheckEnabled() == bToggled ) && ( bToggled || pRadioButton->IsStateChanged() ) && maItemListeners.getLength() ) 1330cdf0e10cSrcweir { 1331cdf0e10cSrcweir ::com::sun::star::awt::ItemEvent aEvent; 1332cdf0e10cSrcweir aEvent.Source = (::cppu::OWeakObject*)this; 1333cdf0e10cSrcweir aEvent.Highlighted = sal_False; 1334cdf0e10cSrcweir aEvent.Selected = pRadioButton->IsChecked(); 1335cdf0e10cSrcweir maItemListeners.itemStateChanged( aEvent ); 1336cdf0e10cSrcweir } 1337cdf0e10cSrcweir } 1338cdf0e10cSrcweir 1339cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > VCLXRadioButton::getFirstActionListener () 1340cdf0e10cSrcweir { 1341cdf0e10cSrcweir if (!maItemListeners.getLength ()) 1342cdf0e10cSrcweir return ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > (); 1343cdf0e10cSrcweir return maActionListeners.getElements()[0]; 1344cdf0e10cSrcweir } 1345cdf0e10cSrcweir 1346cdf0e10cSrcweir // ---------------------------------------------------- 1347cdf0e10cSrcweir // class VCLXSpinField 1348cdf0e10cSrcweir // ---------------------------------------------------- 1349cdf0e10cSrcweir void VCLXSpinField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 1350cdf0e10cSrcweir { 1351cdf0e10cSrcweir PushPropertyIds( rIds, 1352cdf0e10cSrcweir BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, 1353cdf0e10cSrcweir 0 ); 1354cdf0e10cSrcweir VCLXEdit::ImplGetPropertyIds( rIds ); 1355cdf0e10cSrcweir } 1356cdf0e10cSrcweir 1357cdf0e10cSrcweir VCLXSpinField::VCLXSpinField() : maSpinListeners( *this ) 1358cdf0e10cSrcweir { 1359cdf0e10cSrcweir } 1360cdf0e10cSrcweir 1361cdf0e10cSrcweir // ::com::sun::star::uno::XInterface 1362cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXSpinField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 1363cdf0e10cSrcweir { 1364cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 1365cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XSpinField*, this ) ); 1366cdf0e10cSrcweir return (aRet.hasValue() ? aRet : VCLXEdit::queryInterface( rType )); 1367cdf0e10cSrcweir } 1368cdf0e10cSrcweir 1369cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 1370cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXSpinField ) 1371cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinField>* ) NULL ), 1372cdf0e10cSrcweir VCLXEdit::getTypes() 1373cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 1374cdf0e10cSrcweir 1375cdf0e10cSrcweir void VCLXSpinField::addSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener > & l ) throw(::com::sun::star::uno::RuntimeException) 1376cdf0e10cSrcweir { 1377cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1378cdf0e10cSrcweir maSpinListeners.addInterface( l ); 1379cdf0e10cSrcweir } 1380cdf0e10cSrcweir 1381cdf0e10cSrcweir void VCLXSpinField::removeSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener > & l ) throw(::com::sun::star::uno::RuntimeException) 1382cdf0e10cSrcweir { 1383cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1384cdf0e10cSrcweir maSpinListeners.removeInterface( l ); 1385cdf0e10cSrcweir } 1386cdf0e10cSrcweir 1387cdf0e10cSrcweir void VCLXSpinField::up() throw(::com::sun::star::uno::RuntimeException) 1388cdf0e10cSrcweir { 1389cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1390cdf0e10cSrcweir 1391cdf0e10cSrcweir SpinField* pSpinField = (SpinField*) GetWindow(); 1392cdf0e10cSrcweir if ( pSpinField ) 1393cdf0e10cSrcweir pSpinField->Up(); 1394cdf0e10cSrcweir } 1395cdf0e10cSrcweir 1396cdf0e10cSrcweir void VCLXSpinField::down() throw(::com::sun::star::uno::RuntimeException) 1397cdf0e10cSrcweir { 1398cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1399cdf0e10cSrcweir 1400cdf0e10cSrcweir SpinField* pSpinField = (SpinField*) GetWindow(); 1401cdf0e10cSrcweir if ( pSpinField ) 1402cdf0e10cSrcweir pSpinField->Down(); 1403cdf0e10cSrcweir } 1404cdf0e10cSrcweir 1405cdf0e10cSrcweir void VCLXSpinField::first() throw(::com::sun::star::uno::RuntimeException) 1406cdf0e10cSrcweir { 1407cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1408cdf0e10cSrcweir 1409cdf0e10cSrcweir SpinField* pSpinField = (SpinField*) GetWindow(); 1410cdf0e10cSrcweir if ( pSpinField ) 1411cdf0e10cSrcweir pSpinField->First(); 1412cdf0e10cSrcweir } 1413cdf0e10cSrcweir 1414cdf0e10cSrcweir void VCLXSpinField::last() throw(::com::sun::star::uno::RuntimeException) 1415cdf0e10cSrcweir { 1416cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1417cdf0e10cSrcweir 1418cdf0e10cSrcweir SpinField* pSpinField = (SpinField*) GetWindow(); 1419cdf0e10cSrcweir if ( pSpinField ) 1420cdf0e10cSrcweir pSpinField->Last(); 1421cdf0e10cSrcweir } 1422cdf0e10cSrcweir 1423cdf0e10cSrcweir void VCLXSpinField::enableRepeat( sal_Bool bRepeat ) throw(::com::sun::star::uno::RuntimeException) 1424cdf0e10cSrcweir { 1425cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1426cdf0e10cSrcweir 1427cdf0e10cSrcweir Window* pWindow = GetWindow(); 1428cdf0e10cSrcweir if ( pWindow ) 1429cdf0e10cSrcweir { 1430cdf0e10cSrcweir WinBits nStyle = pWindow->GetStyle(); 1431cdf0e10cSrcweir if ( bRepeat ) 1432cdf0e10cSrcweir nStyle |= WB_REPEAT; 1433cdf0e10cSrcweir else 1434cdf0e10cSrcweir nStyle &= ~WB_REPEAT; 1435cdf0e10cSrcweir pWindow->SetStyle( nStyle ); 1436cdf0e10cSrcweir } 1437cdf0e10cSrcweir } 1438cdf0e10cSrcweir 1439cdf0e10cSrcweir void VCLXSpinField::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) 1440cdf0e10cSrcweir { 1441cdf0e10cSrcweir switch ( rVclWindowEvent.GetId() ) 1442cdf0e10cSrcweir { 1443cdf0e10cSrcweir case VCLEVENT_SPINFIELD_UP: 1444cdf0e10cSrcweir case VCLEVENT_SPINFIELD_DOWN: 1445cdf0e10cSrcweir case VCLEVENT_SPINFIELD_FIRST: 1446cdf0e10cSrcweir case VCLEVENT_SPINFIELD_LAST: 1447cdf0e10cSrcweir { 1448cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this ); 1449cdf0e10cSrcweir // since we call listeners below, there is a potential that we will be destroyed 1450cdf0e10cSrcweir // in during the listener call. To prevent the resulting crashs, we keep us 1451cdf0e10cSrcweir // alive as long as we're here 1452cdf0e10cSrcweir // #20178# - 2003-10-01 - fs@openoffice.org 1453cdf0e10cSrcweir 1454cdf0e10cSrcweir if ( maSpinListeners.getLength() ) 1455cdf0e10cSrcweir { 1456cdf0e10cSrcweir ::com::sun::star::awt::SpinEvent aEvent; 1457cdf0e10cSrcweir aEvent.Source = (::cppu::OWeakObject*)this; 1458cdf0e10cSrcweir switch ( rVclWindowEvent.GetId() ) 1459cdf0e10cSrcweir { 1460cdf0e10cSrcweir case VCLEVENT_SPINFIELD_UP: maSpinListeners.up( aEvent ); 1461cdf0e10cSrcweir break; 1462cdf0e10cSrcweir case VCLEVENT_SPINFIELD_DOWN: maSpinListeners.down( aEvent ); 1463cdf0e10cSrcweir break; 1464cdf0e10cSrcweir case VCLEVENT_SPINFIELD_FIRST: maSpinListeners.first( aEvent ); 1465cdf0e10cSrcweir break; 1466cdf0e10cSrcweir case VCLEVENT_SPINFIELD_LAST: maSpinListeners.last( aEvent ); 1467cdf0e10cSrcweir break; 1468cdf0e10cSrcweir } 1469cdf0e10cSrcweir 1470cdf0e10cSrcweir } 1471cdf0e10cSrcweir } 1472cdf0e10cSrcweir break; 1473cdf0e10cSrcweir 1474cdf0e10cSrcweir default: 1475cdf0e10cSrcweir VCLXEdit::ProcessWindowEvent( rVclWindowEvent ); 1476cdf0e10cSrcweir break; 1477cdf0e10cSrcweir } 1478cdf0e10cSrcweir } 1479cdf0e10cSrcweir 1480cdf0e10cSrcweir 1481cdf0e10cSrcweir // ---------------------------------------------------- 1482cdf0e10cSrcweir // class VCLXListBox 1483cdf0e10cSrcweir // ---------------------------------------------------- 1484cdf0e10cSrcweir void VCLXListBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 1485cdf0e10cSrcweir { 1486cdf0e10cSrcweir PushPropertyIds( rIds, 1487cdf0e10cSrcweir BASEPROPERTY_BACKGROUNDCOLOR, 1488cdf0e10cSrcweir BASEPROPERTY_BORDER, 1489cdf0e10cSrcweir BASEPROPERTY_BORDERCOLOR, 1490cdf0e10cSrcweir BASEPROPERTY_DEFAULTCONTROL, 1491cdf0e10cSrcweir BASEPROPERTY_DROPDOWN, 1492cdf0e10cSrcweir BASEPROPERTY_ENABLED, 1493cdf0e10cSrcweir BASEPROPERTY_ENABLEVISIBLE, 1494cdf0e10cSrcweir BASEPROPERTY_FONTDESCRIPTOR, 1495cdf0e10cSrcweir BASEPROPERTY_HELPTEXT, 1496cdf0e10cSrcweir BASEPROPERTY_HELPURL, 1497cdf0e10cSrcweir BASEPROPERTY_LINECOUNT, 1498cdf0e10cSrcweir BASEPROPERTY_MULTISELECTION, 1499cdf0e10cSrcweir BASEPROPERTY_MULTISELECTION_SIMPLEMODE, 1500cdf0e10cSrcweir BASEPROPERTY_ITEM_SEPARATOR_POS, 1501cdf0e10cSrcweir BASEPROPERTY_PRINTABLE, 1502cdf0e10cSrcweir BASEPROPERTY_SELECTEDITEMS, 1503cdf0e10cSrcweir BASEPROPERTY_STRINGITEMLIST, 1504cdf0e10cSrcweir BASEPROPERTY_TABSTOP, 1505cdf0e10cSrcweir BASEPROPERTY_READONLY, 1506cdf0e10cSrcweir BASEPROPERTY_ALIGN, 1507cdf0e10cSrcweir BASEPROPERTY_WRITING_MODE, 1508cdf0e10cSrcweir BASEPROPERTY_CONTEXT_WRITING_MODE, 1509cdf0e10cSrcweir BASEPROPERTY_REFERENCE_DEVICE, 1510cdf0e10cSrcweir BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, 1511cdf0e10cSrcweir 0); 1512cdf0e10cSrcweir VCLXWindow::ImplGetPropertyIds( rIds ); 1513cdf0e10cSrcweir } 1514cdf0e10cSrcweir 1515cdf0e10cSrcweir 1516cdf0e10cSrcweir VCLXListBox::VCLXListBox() 1517cdf0e10cSrcweir : maActionListeners( *this ), 1518cdf0e10cSrcweir maItemListeners( *this ) 1519cdf0e10cSrcweir { 1520cdf0e10cSrcweir } 1521cdf0e10cSrcweir 1522cdf0e10cSrcweir void VCLXListBox::dispose() throw(::com::sun::star::uno::RuntimeException) 1523cdf0e10cSrcweir { 1524cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1525cdf0e10cSrcweir 1526cdf0e10cSrcweir ::com::sun::star::lang::EventObject aObj; 1527cdf0e10cSrcweir aObj.Source = (::cppu::OWeakObject*)this; 1528cdf0e10cSrcweir maItemListeners.disposeAndClear( aObj ); 1529cdf0e10cSrcweir maActionListeners.disposeAndClear( aObj ); 1530cdf0e10cSrcweir VCLXWindow::dispose(); 1531cdf0e10cSrcweir } 1532cdf0e10cSrcweir 1533cdf0e10cSrcweir void VCLXListBox::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException) 1534cdf0e10cSrcweir { 1535cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1536cdf0e10cSrcweir maItemListeners.addInterface( l ); 1537cdf0e10cSrcweir } 1538cdf0e10cSrcweir 1539cdf0e10cSrcweir void VCLXListBox::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException) 1540cdf0e10cSrcweir { 1541cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1542cdf0e10cSrcweir maItemListeners.removeInterface( l ); 1543cdf0e10cSrcweir } 1544cdf0e10cSrcweir 1545cdf0e10cSrcweir void VCLXListBox::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException) 1546cdf0e10cSrcweir { 1547cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1548cdf0e10cSrcweir maActionListeners.addInterface( l ); 1549cdf0e10cSrcweir } 1550cdf0e10cSrcweir 1551cdf0e10cSrcweir void VCLXListBox::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException) 1552cdf0e10cSrcweir { 1553cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1554cdf0e10cSrcweir maActionListeners.removeInterface( l ); 1555cdf0e10cSrcweir } 1556cdf0e10cSrcweir 1557cdf0e10cSrcweir void VCLXListBox::addItem( const ::rtl::OUString& aItem, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException) 1558cdf0e10cSrcweir { 1559cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1560cdf0e10cSrcweir 1561cdf0e10cSrcweir ListBox* pBox = (ListBox*) GetWindow(); 1562cdf0e10cSrcweir if ( pBox ) 1563cdf0e10cSrcweir pBox->InsertEntry( aItem, nPos ); 1564cdf0e10cSrcweir } 1565cdf0e10cSrcweir 1566cdf0e10cSrcweir void VCLXListBox::addItems( const ::com::sun::star::uno::Sequence< ::rtl::OUString>& aItems, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException) 1567cdf0e10cSrcweir { 1568cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1569cdf0e10cSrcweir 1570cdf0e10cSrcweir ListBox* pBox = (ListBox*) GetWindow(); 1571cdf0e10cSrcweir if ( pBox ) 1572cdf0e10cSrcweir { 1573cdf0e10cSrcweir sal_uInt16 nP = nPos; 1574cdf0e10cSrcweir const ::rtl::OUString* pItems = aItems.getConstArray(); 1575cdf0e10cSrcweir const ::rtl::OUString* pItemsEnd = aItems.getConstArray() + aItems.getLength(); 1576cdf0e10cSrcweir while ( pItems != pItemsEnd ) 1577cdf0e10cSrcweir { 1578cdf0e10cSrcweir if ( (sal_uInt16)nP == 0xFFFF ) 1579cdf0e10cSrcweir { 1580cdf0e10cSrcweir OSL_ENSURE( false, "VCLXListBox::addItems: too many entries!" ); 1581cdf0e10cSrcweir // skip remaining entries, list cannot hold them, anyway 1582cdf0e10cSrcweir break; 1583cdf0e10cSrcweir } 1584cdf0e10cSrcweir 1585cdf0e10cSrcweir pBox->InsertEntry( *pItems++, nP++ ); 1586cdf0e10cSrcweir } 1587cdf0e10cSrcweir } 1588cdf0e10cSrcweir } 1589cdf0e10cSrcweir 1590cdf0e10cSrcweir void VCLXListBox::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(::com::sun::star::uno::RuntimeException) 1591cdf0e10cSrcweir { 1592cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1593cdf0e10cSrcweir 1594cdf0e10cSrcweir ListBox* pBox = (ListBox*) GetWindow(); 1595cdf0e10cSrcweir if ( pBox ) 1596cdf0e10cSrcweir { 1597cdf0e10cSrcweir for ( sal_uInt16 n = nCount; n; ) 1598cdf0e10cSrcweir pBox->RemoveEntry( nPos + (--n) ); 1599cdf0e10cSrcweir } 1600cdf0e10cSrcweir } 1601cdf0e10cSrcweir 1602cdf0e10cSrcweir sal_Int16 VCLXListBox::getItemCount() throw(::com::sun::star::uno::RuntimeException) 1603cdf0e10cSrcweir { 1604cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1605cdf0e10cSrcweir 1606cdf0e10cSrcweir ListBox* pBox = (ListBox*) GetWindow(); 1607cdf0e10cSrcweir return pBox ? pBox->GetEntryCount() : 0; 1608cdf0e10cSrcweir } 1609cdf0e10cSrcweir 1610cdf0e10cSrcweir ::rtl::OUString VCLXListBox::getItem( sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException) 1611cdf0e10cSrcweir { 1612cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1613cdf0e10cSrcweir 1614cdf0e10cSrcweir String aItem; 1615cdf0e10cSrcweir ListBox* pBox = (ListBox*) GetWindow(); 1616cdf0e10cSrcweir if ( pBox ) 1617cdf0e10cSrcweir aItem = pBox->GetEntry( nPos ); 1618cdf0e10cSrcweir return aItem; 1619cdf0e10cSrcweir } 1620cdf0e10cSrcweir 1621cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString> VCLXListBox::getItems() throw(::com::sun::star::uno::RuntimeException) 1622cdf0e10cSrcweir { 1623cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1624cdf0e10cSrcweir 1625cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq; 1626cdf0e10cSrcweir ListBox* pBox = (ListBox*) GetWindow(); 1627cdf0e10cSrcweir if ( pBox ) 1628cdf0e10cSrcweir { 1629cdf0e10cSrcweir sal_uInt16 nEntries = pBox->GetEntryCount(); 1630cdf0e10cSrcweir aSeq = ::com::sun::star::uno::Sequence< ::rtl::OUString>( nEntries ); 1631cdf0e10cSrcweir for ( sal_uInt16 n = nEntries; n; ) 1632cdf0e10cSrcweir { 1633cdf0e10cSrcweir --n; 1634cdf0e10cSrcweir aSeq.getArray()[n] = ::rtl::OUString( pBox->GetEntry( n ) ); 1635cdf0e10cSrcweir } 1636cdf0e10cSrcweir } 1637cdf0e10cSrcweir return aSeq; 1638cdf0e10cSrcweir } 1639cdf0e10cSrcweir 1640cdf0e10cSrcweir sal_Int16 VCLXListBox::getSelectedItemPos() throw(::com::sun::star::uno::RuntimeException) 1641cdf0e10cSrcweir { 1642cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1643cdf0e10cSrcweir 1644cdf0e10cSrcweir ListBox* pBox = (ListBox*) GetWindow(); 1645cdf0e10cSrcweir return pBox ? pBox->GetSelectEntryPos() : 0; 1646cdf0e10cSrcweir } 1647cdf0e10cSrcweir 1648cdf0e10cSrcweir ::com::sun::star::uno::Sequence<sal_Int16> VCLXListBox::getSelectedItemsPos() throw(::com::sun::star::uno::RuntimeException) 1649cdf0e10cSrcweir { 1650cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1651cdf0e10cSrcweir 1652cdf0e10cSrcweir ::com::sun::star::uno::Sequence<sal_Int16> aSeq; 1653cdf0e10cSrcweir ListBox* pBox = (ListBox*) GetWindow(); 1654cdf0e10cSrcweir if ( pBox ) 1655cdf0e10cSrcweir { 1656cdf0e10cSrcweir sal_uInt16 nSelEntries = pBox->GetSelectEntryCount(); 1657cdf0e10cSrcweir aSeq = ::com::sun::star::uno::Sequence<sal_Int16>( nSelEntries ); 1658cdf0e10cSrcweir for ( sal_uInt16 n = 0; n < nSelEntries; n++ ) 1659cdf0e10cSrcweir aSeq.getArray()[n] = pBox->GetSelectEntryPos( n ); 1660cdf0e10cSrcweir } 1661cdf0e10cSrcweir return aSeq; 1662cdf0e10cSrcweir } 1663cdf0e10cSrcweir 1664cdf0e10cSrcweir ::rtl::OUString VCLXListBox::getSelectedItem() throw(::com::sun::star::uno::RuntimeException) 1665cdf0e10cSrcweir { 1666cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1667cdf0e10cSrcweir 1668cdf0e10cSrcweir String aItem; 1669cdf0e10cSrcweir ListBox* pBox = (ListBox*) GetWindow(); 1670cdf0e10cSrcweir if ( pBox ) 1671cdf0e10cSrcweir aItem = pBox->GetSelectEntry(); 1672cdf0e10cSrcweir return aItem; 1673cdf0e10cSrcweir } 1674cdf0e10cSrcweir 1675cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString> VCLXListBox::getSelectedItems() throw(::com::sun::star::uno::RuntimeException) 1676cdf0e10cSrcweir { 1677cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1678cdf0e10cSrcweir 1679cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq; 1680cdf0e10cSrcweir ListBox* pBox = (ListBox*) GetWindow(); 1681cdf0e10cSrcweir if ( pBox ) 1682cdf0e10cSrcweir { 1683cdf0e10cSrcweir sal_uInt16 nSelEntries = pBox->GetSelectEntryCount(); 1684cdf0e10cSrcweir aSeq = ::com::sun::star::uno::Sequence< ::rtl::OUString>( nSelEntries ); 1685cdf0e10cSrcweir for ( sal_uInt16 n = 0; n < nSelEntries; n++ ) 1686cdf0e10cSrcweir aSeq.getArray()[n] = ::rtl::OUString( pBox->GetSelectEntry( n ) ); 1687cdf0e10cSrcweir } 1688cdf0e10cSrcweir return aSeq; 1689cdf0e10cSrcweir } 1690cdf0e10cSrcweir 1691cdf0e10cSrcweir void VCLXListBox::selectItemPos( sal_Int16 nPos, sal_Bool bSelect ) throw(::com::sun::star::uno::RuntimeException) 1692cdf0e10cSrcweir { 1693cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1694cdf0e10cSrcweir 1695cdf0e10cSrcweir ListBox* pBox = (ListBox*) GetWindow(); 1696cdf0e10cSrcweir if ( pBox && ( pBox->IsEntryPosSelected( nPos ) != bSelect ) ) 1697cdf0e10cSrcweir { 1698cdf0e10cSrcweir pBox->SelectEntryPos( nPos, bSelect ); 1699cdf0e10cSrcweir 1700cdf0e10cSrcweir // VCL doesn't call select handler after API call. 1701cdf0e10cSrcweir // ImplCallItemListeners(); 1702cdf0e10cSrcweir 1703cdf0e10cSrcweir // #107218# Call same listeners like VCL would do after user interaction 1704cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_True ); 1705cdf0e10cSrcweir pBox->Select(); 1706cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_False ); 1707cdf0e10cSrcweir } 1708cdf0e10cSrcweir } 1709cdf0e10cSrcweir 1710cdf0e10cSrcweir void VCLXListBox::selectItemsPos( const ::com::sun::star::uno::Sequence<sal_Int16>& aPositions, sal_Bool bSelect ) throw(::com::sun::star::uno::RuntimeException) 1711cdf0e10cSrcweir { 1712cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1713cdf0e10cSrcweir 1714cdf0e10cSrcweir ListBox* pBox = (ListBox*) GetWindow(); 1715cdf0e10cSrcweir if ( pBox ) 1716cdf0e10cSrcweir { 1717cdf0e10cSrcweir sal_Bool bChanged = sal_False; 1718cdf0e10cSrcweir for ( sal_uInt16 n = (sal_uInt16)aPositions.getLength(); n; ) 1719cdf0e10cSrcweir { 1720cdf0e10cSrcweir sal_uInt16 nPos = (sal_uInt16) aPositions.getConstArray()[--n]; 1721cdf0e10cSrcweir if ( pBox->IsEntryPosSelected( nPos ) != bSelect ) 1722cdf0e10cSrcweir { 1723cdf0e10cSrcweir pBox->SelectEntryPos( nPos, bSelect ); 1724cdf0e10cSrcweir bChanged = sal_True; 1725cdf0e10cSrcweir } 1726cdf0e10cSrcweir } 1727cdf0e10cSrcweir 1728cdf0e10cSrcweir if ( bChanged ) 1729cdf0e10cSrcweir { 1730cdf0e10cSrcweir // VCL doesn't call select handler after API call. 1731cdf0e10cSrcweir // ImplCallItemListeners(); 1732cdf0e10cSrcweir 1733cdf0e10cSrcweir // #107218# Call same listeners like VCL would do after user interaction 1734cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_True ); 1735cdf0e10cSrcweir pBox->Select(); 1736cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_False ); 1737cdf0e10cSrcweir } 1738cdf0e10cSrcweir } 1739cdf0e10cSrcweir } 1740cdf0e10cSrcweir 1741cdf0e10cSrcweir void VCLXListBox::selectItem( const ::rtl::OUString& rItemText, sal_Bool bSelect ) throw(::com::sun::star::uno::RuntimeException) 1742cdf0e10cSrcweir { 1743cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1744cdf0e10cSrcweir 1745cdf0e10cSrcweir ListBox* pBox = (ListBox*) GetWindow(); 1746cdf0e10cSrcweir if ( pBox ) 1747cdf0e10cSrcweir { 1748cdf0e10cSrcweir String aItemText( rItemText ); 1749cdf0e10cSrcweir selectItemPos( pBox->GetEntryPos( aItemText ), bSelect ); 1750cdf0e10cSrcweir } 1751cdf0e10cSrcweir } 1752cdf0e10cSrcweir 1753cdf0e10cSrcweir 1754cdf0e10cSrcweir void VCLXListBox::setDropDownLineCount( sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException) 1755cdf0e10cSrcweir { 1756cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1757cdf0e10cSrcweir 1758cdf0e10cSrcweir ListBox* pBox = (ListBox*) GetWindow(); 1759cdf0e10cSrcweir if ( pBox ) 1760cdf0e10cSrcweir pBox->SetDropDownLineCount( nLines ); 1761cdf0e10cSrcweir } 1762cdf0e10cSrcweir 1763cdf0e10cSrcweir sal_Int16 VCLXListBox::getDropDownLineCount() throw(::com::sun::star::uno::RuntimeException) 1764cdf0e10cSrcweir { 1765cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1766cdf0e10cSrcweir 1767cdf0e10cSrcweir sal_Int16 nLines = 0; 1768cdf0e10cSrcweir ListBox* pBox = (ListBox*) GetWindow(); 1769cdf0e10cSrcweir if ( pBox ) 1770cdf0e10cSrcweir nLines = pBox->GetDropDownLineCount(); 1771cdf0e10cSrcweir return nLines; 1772cdf0e10cSrcweir } 1773cdf0e10cSrcweir 1774cdf0e10cSrcweir sal_Bool VCLXListBox::isMutipleMode() throw(::com::sun::star::uno::RuntimeException) 1775cdf0e10cSrcweir { 1776cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1777cdf0e10cSrcweir 1778cdf0e10cSrcweir sal_Bool bMulti = sal_False; 1779cdf0e10cSrcweir ListBox* pBox = (ListBox*) GetWindow(); 1780cdf0e10cSrcweir if ( pBox ) 1781cdf0e10cSrcweir bMulti = pBox->IsMultiSelectionEnabled(); 1782cdf0e10cSrcweir return bMulti; 1783cdf0e10cSrcweir } 1784cdf0e10cSrcweir 1785cdf0e10cSrcweir void VCLXListBox::setMultipleMode( sal_Bool bMulti ) throw(::com::sun::star::uno::RuntimeException) 1786cdf0e10cSrcweir { 1787cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1788cdf0e10cSrcweir 1789cdf0e10cSrcweir ListBox* pBox = (ListBox*) GetWindow(); 1790cdf0e10cSrcweir if ( pBox ) 1791cdf0e10cSrcweir pBox->EnableMultiSelection( bMulti ); 1792cdf0e10cSrcweir } 1793cdf0e10cSrcweir 1794cdf0e10cSrcweir void VCLXListBox::makeVisible( sal_Int16 nEntry ) throw(::com::sun::star::uno::RuntimeException) 1795cdf0e10cSrcweir { 1796cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1797cdf0e10cSrcweir 1798cdf0e10cSrcweir ListBox* pBox = (ListBox*) GetWindow(); 1799cdf0e10cSrcweir if ( pBox ) 1800cdf0e10cSrcweir pBox->SetTopEntry( nEntry ); 1801cdf0e10cSrcweir } 1802cdf0e10cSrcweir 1803cdf0e10cSrcweir void VCLXListBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) 1804cdf0e10cSrcweir { 1805cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this ); 1806cdf0e10cSrcweir // since we call listeners below, there is a potential that we will be destroyed 1807cdf0e10cSrcweir // in during the listener call. To prevent the resulting crashs, we keep us 1808cdf0e10cSrcweir // alive as long as we're here 1809cdf0e10cSrcweir // #20178# - 2003-10-01 - fs@openoffice.org 1810cdf0e10cSrcweir 1811cdf0e10cSrcweir switch ( rVclWindowEvent.GetId() ) 1812cdf0e10cSrcweir { 1813cdf0e10cSrcweir case VCLEVENT_LISTBOX_SELECT: 1814cdf0e10cSrcweir { 1815cdf0e10cSrcweir ListBox* pListBox = (ListBox*)GetWindow(); 1816cdf0e10cSrcweir 1817cdf0e10cSrcweir if( pListBox ) 1818cdf0e10cSrcweir { 1819cdf0e10cSrcweir sal_Bool bDropDown = ( pListBox->GetStyle() & WB_DROPDOWN ) ? sal_True : sal_False; 1820cdf0e10cSrcweir if ( bDropDown && !IsSynthesizingVCLEvent() && maActionListeners.getLength() ) 1821cdf0e10cSrcweir { 1822cdf0e10cSrcweir // Bei DropDown den ActionListener rufen... 1823cdf0e10cSrcweir ::com::sun::star::awt::ActionEvent aEvent; 1824cdf0e10cSrcweir aEvent.Source = (::cppu::OWeakObject*)this; 1825cdf0e10cSrcweir aEvent.ActionCommand = pListBox->GetSelectEntry(); 1826cdf0e10cSrcweir maActionListeners.actionPerformed( aEvent ); 1827cdf0e10cSrcweir } 1828cdf0e10cSrcweir 1829cdf0e10cSrcweir if ( maItemListeners.getLength() ) 1830cdf0e10cSrcweir { 1831cdf0e10cSrcweir ImplCallItemListeners(); 1832cdf0e10cSrcweir } 1833cdf0e10cSrcweir } 1834cdf0e10cSrcweir } 1835cdf0e10cSrcweir break; 1836cdf0e10cSrcweir 1837cdf0e10cSrcweir case VCLEVENT_LISTBOX_DOUBLECLICK: 1838cdf0e10cSrcweir if ( GetWindow() && maActionListeners.getLength() ) 1839cdf0e10cSrcweir { 1840cdf0e10cSrcweir ::com::sun::star::awt::ActionEvent aEvent; 1841cdf0e10cSrcweir aEvent.Source = (::cppu::OWeakObject*)this; 1842cdf0e10cSrcweir aEvent.ActionCommand = ((ListBox*)GetWindow())->GetSelectEntry(); 1843cdf0e10cSrcweir maActionListeners.actionPerformed( aEvent ); 1844cdf0e10cSrcweir } 1845cdf0e10cSrcweir break; 1846cdf0e10cSrcweir 1847cdf0e10cSrcweir default: 1848cdf0e10cSrcweir VCLXWindow::ProcessWindowEvent( rVclWindowEvent ); 1849cdf0e10cSrcweir break; 1850cdf0e10cSrcweir } 1851cdf0e10cSrcweir } 1852cdf0e10cSrcweir 1853cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXListBox::CreateAccessibleContext() 1854cdf0e10cSrcweir { 1855cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1856cdf0e10cSrcweir 1857cdf0e10cSrcweir return getAccessibleFactory().createAccessibleContext( this ); 1858cdf0e10cSrcweir } 1859cdf0e10cSrcweir 1860cdf0e10cSrcweir void VCLXListBox::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 1861cdf0e10cSrcweir { 1862cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1863cdf0e10cSrcweir 1864cdf0e10cSrcweir ListBox* pListBox = (ListBox*)GetWindow(); 1865cdf0e10cSrcweir if ( pListBox ) 1866cdf0e10cSrcweir { 1867cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 1868cdf0e10cSrcweir switch ( nPropType ) 1869cdf0e10cSrcweir { 1870cdf0e10cSrcweir case BASEPROPERTY_ITEM_SEPARATOR_POS: 1871cdf0e10cSrcweir { 1872cdf0e10cSrcweir sal_Int16 nSeparatorPos(0); 1873cdf0e10cSrcweir if ( Value >>= nSeparatorPos ) 1874cdf0e10cSrcweir pListBox->SetSeparatorPos( nSeparatorPos ); 1875cdf0e10cSrcweir } 1876cdf0e10cSrcweir break; 1877cdf0e10cSrcweir case BASEPROPERTY_READONLY: 1878cdf0e10cSrcweir { 1879cdf0e10cSrcweir sal_Bool b = sal_Bool(); 1880cdf0e10cSrcweir if ( Value >>= b ) 1881cdf0e10cSrcweir pListBox->SetReadOnly( b); 1882cdf0e10cSrcweir } 1883cdf0e10cSrcweir break; 1884cdf0e10cSrcweir case BASEPROPERTY_MULTISELECTION: 1885cdf0e10cSrcweir { 1886cdf0e10cSrcweir sal_Bool b = sal_Bool(); 1887cdf0e10cSrcweir if ( Value >>= b ) 1888cdf0e10cSrcweir pListBox->EnableMultiSelection( b ); 1889cdf0e10cSrcweir } 1890cdf0e10cSrcweir break; 1891cdf0e10cSrcweir case BASEPROPERTY_MULTISELECTION_SIMPLEMODE: 1892cdf0e10cSrcweir ::toolkit::adjustBooleanWindowStyle( Value, pListBox, WB_SIMPLEMODE, sal_False ); 1893cdf0e10cSrcweir break; 1894cdf0e10cSrcweir case BASEPROPERTY_LINECOUNT: 1895cdf0e10cSrcweir { 1896cdf0e10cSrcweir sal_Int16 n = sal_Int16(); 1897cdf0e10cSrcweir if ( Value >>= n ) 1898cdf0e10cSrcweir pListBox->SetDropDownLineCount( n ); 1899cdf0e10cSrcweir } 1900cdf0e10cSrcweir break; 1901cdf0e10cSrcweir case BASEPROPERTY_STRINGITEMLIST: 1902cdf0e10cSrcweir { 1903cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString> aItems; 1904cdf0e10cSrcweir if ( Value >>= aItems ) 1905cdf0e10cSrcweir { 1906cdf0e10cSrcweir pListBox->Clear(); 1907cdf0e10cSrcweir addItems( aItems, 0 ); 1908cdf0e10cSrcweir } 1909cdf0e10cSrcweir } 1910cdf0e10cSrcweir break; 1911cdf0e10cSrcweir case BASEPROPERTY_SELECTEDITEMS: 1912cdf0e10cSrcweir { 1913cdf0e10cSrcweir ::com::sun::star::uno::Sequence<sal_Int16> aItems; 1914cdf0e10cSrcweir if ( Value >>= aItems ) 1915cdf0e10cSrcweir { 1916cdf0e10cSrcweir for ( sal_uInt16 n = pListBox->GetEntryCount(); n; ) 1917cdf0e10cSrcweir pListBox->SelectEntryPos( --n, sal_False ); 1918cdf0e10cSrcweir 1919cdf0e10cSrcweir if ( aItems.getLength() ) 1920cdf0e10cSrcweir selectItemsPos( aItems, sal_True ); 1921cdf0e10cSrcweir else 1922cdf0e10cSrcweir pListBox->SetNoSelection(); 1923cdf0e10cSrcweir 1924cdf0e10cSrcweir if ( !pListBox->GetSelectEntryCount() ) 1925cdf0e10cSrcweir pListBox->SetTopEntry( 0 ); 1926cdf0e10cSrcweir } 1927cdf0e10cSrcweir } 1928cdf0e10cSrcweir break; 1929cdf0e10cSrcweir default: 1930cdf0e10cSrcweir { 1931cdf0e10cSrcweir VCLXWindow::setProperty( PropertyName, Value ); 1932cdf0e10cSrcweir } 1933cdf0e10cSrcweir } 1934cdf0e10cSrcweir } 1935cdf0e10cSrcweir } 1936cdf0e10cSrcweir 1937cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXListBox::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) 1938cdf0e10cSrcweir { 1939cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1940cdf0e10cSrcweir 1941cdf0e10cSrcweir ::com::sun::star::uno::Any aProp; 1942cdf0e10cSrcweir ListBox* pListBox = (ListBox*)GetWindow(); 1943cdf0e10cSrcweir if ( pListBox ) 1944cdf0e10cSrcweir { 1945cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 1946cdf0e10cSrcweir switch ( nPropType ) 1947cdf0e10cSrcweir { 1948cdf0e10cSrcweir case BASEPROPERTY_ITEM_SEPARATOR_POS: 1949cdf0e10cSrcweir aProp <<= sal_Int16( pListBox->GetSeparatorPos() ); 1950cdf0e10cSrcweir break; 1951cdf0e10cSrcweir case BASEPROPERTY_READONLY: 1952cdf0e10cSrcweir { 1953cdf0e10cSrcweir aProp <<= (sal_Bool) pListBox->IsReadOnly(); 1954cdf0e10cSrcweir } 1955cdf0e10cSrcweir break; 1956cdf0e10cSrcweir case BASEPROPERTY_MULTISELECTION: 1957cdf0e10cSrcweir { 1958cdf0e10cSrcweir aProp <<= (sal_Bool) pListBox->IsMultiSelectionEnabled(); 1959cdf0e10cSrcweir } 1960cdf0e10cSrcweir break; 1961cdf0e10cSrcweir case BASEPROPERTY_MULTISELECTION_SIMPLEMODE: 1962cdf0e10cSrcweir { 1963cdf0e10cSrcweir aProp <<= (sal_Bool)( ( pListBox->GetStyle() & WB_SIMPLEMODE ) == 0 ); 1964cdf0e10cSrcweir } 1965cdf0e10cSrcweir break; 1966cdf0e10cSrcweir case BASEPROPERTY_LINECOUNT: 1967cdf0e10cSrcweir { 1968cdf0e10cSrcweir aProp <<= (sal_Int16) pListBox->GetDropDownLineCount(); 1969cdf0e10cSrcweir } 1970cdf0e10cSrcweir break; 1971cdf0e10cSrcweir case BASEPROPERTY_STRINGITEMLIST: 1972cdf0e10cSrcweir { 1973cdf0e10cSrcweir sal_uInt16 nItems = pListBox->GetEntryCount(); 1974cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq( nItems ); 1975cdf0e10cSrcweir ::rtl::OUString* pStrings = aSeq.getArray(); 1976cdf0e10cSrcweir for ( sal_uInt16 n = 0; n < nItems; n++ ) 1977cdf0e10cSrcweir pStrings[n] = pListBox->GetEntry( n ); 1978cdf0e10cSrcweir aProp <<= aSeq; 1979cdf0e10cSrcweir 1980cdf0e10cSrcweir } 1981cdf0e10cSrcweir break; 1982cdf0e10cSrcweir default: 1983cdf0e10cSrcweir { 1984cdf0e10cSrcweir aProp <<= VCLXWindow::getProperty( PropertyName ); 1985cdf0e10cSrcweir } 1986cdf0e10cSrcweir } 1987cdf0e10cSrcweir } 1988cdf0e10cSrcweir return aProp; 1989cdf0e10cSrcweir } 1990cdf0e10cSrcweir 1991cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXListBox::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException) 1992cdf0e10cSrcweir { 1993cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1994cdf0e10cSrcweir 1995cdf0e10cSrcweir Size aSz; 1996cdf0e10cSrcweir ListBox* pListBox = (ListBox*) GetWindow(); 1997cdf0e10cSrcweir if ( pListBox ) 1998cdf0e10cSrcweir aSz = pListBox->CalcMinimumSize(); 1999cdf0e10cSrcweir return AWTSize(aSz); 2000cdf0e10cSrcweir } 2001cdf0e10cSrcweir 2002cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXListBox::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException) 2003cdf0e10cSrcweir { 2004cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2005cdf0e10cSrcweir 2006cdf0e10cSrcweir Size aSz; 2007cdf0e10cSrcweir ListBox* pListBox = (ListBox*) GetWindow(); 2008cdf0e10cSrcweir if ( pListBox ) 2009cdf0e10cSrcweir { 2010cdf0e10cSrcweir aSz = pListBox->CalcMinimumSize(); 2011cdf0e10cSrcweir if ( pListBox->GetStyle() & WB_DROPDOWN ) 2012cdf0e10cSrcweir aSz.Height() += 4; 2013cdf0e10cSrcweir } 2014cdf0e10cSrcweir return AWTSize(aSz); 2015cdf0e10cSrcweir } 2016cdf0e10cSrcweir 2017cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXListBox::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException) 2018cdf0e10cSrcweir { 2019cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2020cdf0e10cSrcweir 2021cdf0e10cSrcweir Size aSz = VCLSize(rNewSize); 2022cdf0e10cSrcweir ListBox* pListBox = (ListBox*) GetWindow(); 2023cdf0e10cSrcweir if ( pListBox ) 2024cdf0e10cSrcweir aSz = pListBox->CalcAdjustedSize( aSz ); 2025cdf0e10cSrcweir return AWTSize(aSz); 2026cdf0e10cSrcweir } 2027cdf0e10cSrcweir 2028cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXListBox::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException) 2029cdf0e10cSrcweir { 2030cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2031cdf0e10cSrcweir 2032cdf0e10cSrcweir Size aSz; 2033cdf0e10cSrcweir ListBox* pListBox = (ListBox*) GetWindow(); 2034cdf0e10cSrcweir if ( pListBox ) 2035cdf0e10cSrcweir aSz = pListBox->CalcSize( nCols, nLines ); 2036cdf0e10cSrcweir return AWTSize(aSz); 2037cdf0e10cSrcweir } 2038cdf0e10cSrcweir 2039cdf0e10cSrcweir void VCLXListBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException) 2040cdf0e10cSrcweir { 2041cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2042cdf0e10cSrcweir 2043cdf0e10cSrcweir nCols = nLines = 0; 2044cdf0e10cSrcweir ListBox* pListBox = (ListBox*) GetWindow(); 2045cdf0e10cSrcweir if ( pListBox ) 2046cdf0e10cSrcweir { 2047cdf0e10cSrcweir sal_uInt16 nC, nL; 2048cdf0e10cSrcweir pListBox->GetMaxVisColumnsAndLines( nC, nL ); 2049cdf0e10cSrcweir nCols = nC; 2050cdf0e10cSrcweir nLines = nL; 2051cdf0e10cSrcweir } 2052cdf0e10cSrcweir } 2053cdf0e10cSrcweir 2054cdf0e10cSrcweir void VCLXListBox::ImplCallItemListeners() 2055cdf0e10cSrcweir { 2056cdf0e10cSrcweir ListBox* pListBox = (ListBox*) GetWindow(); 2057cdf0e10cSrcweir if ( pListBox && maItemListeners.getLength() ) 2058cdf0e10cSrcweir { 2059cdf0e10cSrcweir ::com::sun::star::awt::ItemEvent aEvent; 2060cdf0e10cSrcweir aEvent.Source = (::cppu::OWeakObject*)this; 2061cdf0e10cSrcweir aEvent.Highlighted = sal_False; 2062cdf0e10cSrcweir 2063cdf0e10cSrcweir // Bei Mehrfachselektion 0xFFFF, sonst die ID 2064cdf0e10cSrcweir aEvent.Selected = (pListBox->GetSelectEntryCount() == 1 ) ? pListBox->GetSelectEntryPos() : 0xFFFF; 2065cdf0e10cSrcweir 2066cdf0e10cSrcweir maItemListeners.itemStateChanged( aEvent ); 2067cdf0e10cSrcweir } 2068cdf0e10cSrcweir } 2069cdf0e10cSrcweir namespace 2070cdf0e10cSrcweir { 2071cdf0e10cSrcweir Image lcl_getImageFromURL( const ::rtl::OUString& i_rImageURL ) 2072cdf0e10cSrcweir { 2073cdf0e10cSrcweir if ( !i_rImageURL.getLength() ) 2074cdf0e10cSrcweir return Image(); 2075cdf0e10cSrcweir 2076cdf0e10cSrcweir try 2077cdf0e10cSrcweir { 2078cdf0e10cSrcweir ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); 2079cdf0e10cSrcweir Reference< XGraphicProvider > xProvider; 2080cdf0e10cSrcweir if ( aContext.createComponent( "com.sun.star.graphic.GraphicProvider", xProvider ) ) 2081cdf0e10cSrcweir { 2082cdf0e10cSrcweir ::comphelper::NamedValueCollection aMediaProperties; 2083cdf0e10cSrcweir aMediaProperties.put( "URL", i_rImageURL ); 2084cdf0e10cSrcweir Reference< XGraphic > xGraphic = xProvider->queryGraphic( aMediaProperties.getPropertyValues() ); 2085cdf0e10cSrcweir return Image( xGraphic ); 2086cdf0e10cSrcweir } 2087cdf0e10cSrcweir } 2088cdf0e10cSrcweir catch( const uno::Exception& ) 2089cdf0e10cSrcweir { 2090cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 2091cdf0e10cSrcweir } 2092cdf0e10cSrcweir return Image(); 2093cdf0e10cSrcweir } 2094cdf0e10cSrcweir } 2095cdf0e10cSrcweir void SAL_CALL VCLXListBox::listItemInserted( const ItemListEvent& i_rEvent ) throw (RuntimeException) 2096cdf0e10cSrcweir { 2097cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2098cdf0e10cSrcweir 2099cdf0e10cSrcweir ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() ); 2100cdf0e10cSrcweir 2101cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemInserted: no ListBox?!" ); 2102cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= sal_Int32( pListBox->GetEntryCount() ) ), 2103cdf0e10cSrcweir "VCLXListBox::listItemInserted: illegal (inconsistent) item position!" ); 2104cdf0e10cSrcweir pListBox->InsertEntry( 2105cdf0e10cSrcweir i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : ::rtl::OUString(), 2106cdf0e10cSrcweir i_rEvent.ItemImageURL.IsPresent ? TkResMgr::getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(), 2107cdf0e10cSrcweir i_rEvent.ItemPosition ); 2108cdf0e10cSrcweir } 2109cdf0e10cSrcweir 2110cdf0e10cSrcweir void SAL_CALL VCLXListBox::listItemRemoved( const ItemListEvent& i_rEvent ) throw (RuntimeException) 2111cdf0e10cSrcweir { 2112cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2113cdf0e10cSrcweir 2114cdf0e10cSrcweir ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() ); 2115cdf0e10cSrcweir 2116cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemRemoved: no ListBox?!" ); 2117cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pListBox->GetEntryCount() ) ), 2118cdf0e10cSrcweir "VCLXListBox::listItemRemoved: illegal (inconsistent) item position!" ); 2119cdf0e10cSrcweir 2120cdf0e10cSrcweir pListBox->RemoveEntry( i_rEvent.ItemPosition ); 2121cdf0e10cSrcweir } 2122cdf0e10cSrcweir 2123cdf0e10cSrcweir void SAL_CALL VCLXListBox::listItemModified( const ItemListEvent& i_rEvent ) throw (RuntimeException) 2124cdf0e10cSrcweir { 2125cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2126cdf0e10cSrcweir 2127cdf0e10cSrcweir ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() ); 2128cdf0e10cSrcweir 2129cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" ); 2130cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pListBox->GetEntryCount() ) ), 2131cdf0e10cSrcweir "VCLXListBox::listItemModified: illegal (inconsistent) item position!" ); 2132cdf0e10cSrcweir 2133cdf0e10cSrcweir // VCL's ListBox does not support changing an entry's text or image, so remove and re-insert 2134cdf0e10cSrcweir 2135cdf0e10cSrcweir const ::rtl::OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : ::rtl::OUString( pListBox->GetEntry( i_rEvent.ItemPosition ) ); 2136cdf0e10cSrcweir const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? TkResMgr::getImageFromURL( i_rEvent.ItemImageURL.Value ) : pListBox->GetEntryImage( i_rEvent.ItemPosition ) ); 2137cdf0e10cSrcweir 2138cdf0e10cSrcweir pListBox->RemoveEntry( i_rEvent.ItemPosition ); 2139cdf0e10cSrcweir pListBox->InsertEntry( sNewText, aNewImage, i_rEvent.ItemPosition ); 2140cdf0e10cSrcweir } 2141cdf0e10cSrcweir 2142cdf0e10cSrcweir void SAL_CALL VCLXListBox::allItemsRemoved( const EventObject& i_rEvent ) throw (RuntimeException) 2143cdf0e10cSrcweir { 2144cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2145cdf0e10cSrcweir 2146cdf0e10cSrcweir ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() ); 2147cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" ); 2148cdf0e10cSrcweir 2149cdf0e10cSrcweir pListBox->Clear(); 2150cdf0e10cSrcweir 2151cdf0e10cSrcweir (void)i_rEvent; 2152cdf0e10cSrcweir } 2153cdf0e10cSrcweir 2154cdf0e10cSrcweir void SAL_CALL VCLXListBox::itemListChanged( const EventObject& i_rEvent ) throw (RuntimeException) 2155cdf0e10cSrcweir { 2156cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2157cdf0e10cSrcweir 2158cdf0e10cSrcweir ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() ); 2159cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" ); 2160cdf0e10cSrcweir 2161cdf0e10cSrcweir pListBox->Clear(); 2162cdf0e10cSrcweir 2163cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPropSet( i_rEvent.Source, uno::UNO_QUERY_THROW ); 2164cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), uno::UNO_QUERY_THROW ); 2165cdf0e10cSrcweir uno::Reference< resource::XStringResourceResolver > xStringResourceResolver; 2166cdf0e10cSrcweir if ( xPSI->hasPropertyByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ) ) ) ) 2167cdf0e10cSrcweir { 2168cdf0e10cSrcweir xStringResourceResolver.set( 2169cdf0e10cSrcweir xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ) ) ), 2170cdf0e10cSrcweir uno::UNO_QUERY 2171cdf0e10cSrcweir ); 2172cdf0e10cSrcweir } 2173cdf0e10cSrcweir 2174cdf0e10cSrcweir 2175cdf0e10cSrcweir Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW ); 2176cdf0e10cSrcweir uno::Sequence< beans::Pair< ::rtl::OUString, ::rtl::OUString > > aItems = xItemList->getAllItems(); 2177cdf0e10cSrcweir for ( sal_Int32 i=0; i<aItems.getLength(); ++i ) 2178cdf0e10cSrcweir { 2179cdf0e10cSrcweir ::rtl::OUString aLocalizationKey( aItems[i].First ); 2180cdf0e10cSrcweir if ( xStringResourceResolver.is() && aLocalizationKey.getLength() != 0 && aLocalizationKey[0] == '&' ) 2181cdf0e10cSrcweir { 2182cdf0e10cSrcweir aLocalizationKey = xStringResourceResolver->resolveString(aLocalizationKey.copy( 1 )); 2183cdf0e10cSrcweir } 2184cdf0e10cSrcweir pListBox->InsertEntry( aLocalizationKey, lcl_getImageFromURL( aItems[i].Second ) ); 2185cdf0e10cSrcweir } 2186cdf0e10cSrcweir } 2187cdf0e10cSrcweir 2188cdf0e10cSrcweir void SAL_CALL VCLXListBox::disposing( const EventObject& i_rEvent ) throw (RuntimeException) 2189cdf0e10cSrcweir { 2190cdf0e10cSrcweir // just disambiguate 2191cdf0e10cSrcweir VCLXWindow::disposing( i_rEvent ); 2192cdf0e10cSrcweir } 2193cdf0e10cSrcweir 2194cdf0e10cSrcweir // ---------------------------------------------------- 2195cdf0e10cSrcweir // class VCLXMessageBox 2196cdf0e10cSrcweir // ---------------------------------------------------- 2197cdf0e10cSrcweir 2198cdf0e10cSrcweir void VCLXMessageBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 2199cdf0e10cSrcweir { 2200cdf0e10cSrcweir VCLXTopWindow::ImplGetPropertyIds( rIds ); 2201cdf0e10cSrcweir } 2202cdf0e10cSrcweir 2203cdf0e10cSrcweir VCLXMessageBox::VCLXMessageBox() 2204cdf0e10cSrcweir { 2205cdf0e10cSrcweir } 2206cdf0e10cSrcweir 2207cdf0e10cSrcweir VCLXMessageBox::~VCLXMessageBox() 2208cdf0e10cSrcweir { 2209cdf0e10cSrcweir } 2210cdf0e10cSrcweir 2211cdf0e10cSrcweir // ::com::sun::star::uno::XInterface 2212cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXMessageBox::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 2213cdf0e10cSrcweir { 2214cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 2215cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XMessageBox*, this ) ); 2216cdf0e10cSrcweir return (aRet.hasValue() ? aRet : VCLXTopWindow::queryInterface( rType )); 2217cdf0e10cSrcweir } 2218cdf0e10cSrcweir 2219cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 2220cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXMessageBox ) 2221cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMessageBox>* ) NULL ), 2222cdf0e10cSrcweir VCLXTopWindow::getTypes() 2223cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 2224cdf0e10cSrcweir 2225cdf0e10cSrcweir void VCLXMessageBox::setCaptionText( const ::rtl::OUString& rText ) throw(::com::sun::star::uno::RuntimeException) 2226cdf0e10cSrcweir { 2227cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2228cdf0e10cSrcweir 2229cdf0e10cSrcweir Window* pWindow = GetWindow(); 2230cdf0e10cSrcweir if ( pWindow ) 2231cdf0e10cSrcweir pWindow->SetText( rText ); 2232cdf0e10cSrcweir } 2233cdf0e10cSrcweir 2234cdf0e10cSrcweir ::rtl::OUString VCLXMessageBox::getCaptionText() throw(::com::sun::star::uno::RuntimeException) 2235cdf0e10cSrcweir { 2236cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2237cdf0e10cSrcweir 2238cdf0e10cSrcweir String aText; 2239cdf0e10cSrcweir Window* pWindow = GetWindow(); 2240cdf0e10cSrcweir if ( pWindow ) 2241cdf0e10cSrcweir aText = pWindow->GetText(); 2242cdf0e10cSrcweir return aText; 2243cdf0e10cSrcweir } 2244cdf0e10cSrcweir 2245cdf0e10cSrcweir void VCLXMessageBox::setMessageText( const ::rtl::OUString& rText ) throw(::com::sun::star::uno::RuntimeException) 2246cdf0e10cSrcweir { 2247cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2248cdf0e10cSrcweir 2249cdf0e10cSrcweir MessBox* pBox = (MessBox*)GetWindow(); 2250cdf0e10cSrcweir if ( pBox ) 2251cdf0e10cSrcweir pBox->SetMessText( rText ); 2252cdf0e10cSrcweir } 2253cdf0e10cSrcweir 2254cdf0e10cSrcweir ::rtl::OUString VCLXMessageBox::getMessageText() throw(::com::sun::star::uno::RuntimeException) 2255cdf0e10cSrcweir { 2256cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2257cdf0e10cSrcweir 2258cdf0e10cSrcweir ::rtl::OUString aText; 2259cdf0e10cSrcweir MessBox* pBox = (MessBox*)GetWindow(); 2260cdf0e10cSrcweir if ( pBox ) 2261cdf0e10cSrcweir aText = pBox->GetMessText(); 2262cdf0e10cSrcweir return aText; 2263cdf0e10cSrcweir } 2264cdf0e10cSrcweir 2265cdf0e10cSrcweir sal_Int16 VCLXMessageBox::execute() throw(::com::sun::star::uno::RuntimeException) 2266cdf0e10cSrcweir { 2267cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2268cdf0e10cSrcweir 2269cdf0e10cSrcweir MessBox* pBox = (MessBox*)GetWindow(); 2270cdf0e10cSrcweir return pBox ? pBox->Execute() : 0; 2271cdf0e10cSrcweir } 2272cdf0e10cSrcweir 2273cdf0e10cSrcweir ::com::sun::star::awt::Size SAL_CALL VCLXMessageBox::getMinimumSize() throw(::com::sun::star::uno::RuntimeException) 2274cdf0e10cSrcweir { 2275cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2276cdf0e10cSrcweir return ::com::sun::star::awt::Size( 250, 100 ); 2277cdf0e10cSrcweir } 2278cdf0e10cSrcweir 2279cdf0e10cSrcweir // ---------------------------------------------------- 2280cdf0e10cSrcweir // class VCLXDialog 2281cdf0e10cSrcweir // ---------------------------------------------------- 2282cdf0e10cSrcweir void VCLXDialog::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 2283cdf0e10cSrcweir { 2284cdf0e10cSrcweir VCLXTopWindow::ImplGetPropertyIds( rIds ); 2285cdf0e10cSrcweir } 2286cdf0e10cSrcweir 2287cdf0e10cSrcweir VCLXDialog::VCLXDialog() 2288cdf0e10cSrcweir { 2289cdf0e10cSrcweir } 2290cdf0e10cSrcweir 2291cdf0e10cSrcweir VCLXDialog::~VCLXDialog() 2292cdf0e10cSrcweir { 2293cdf0e10cSrcweir #ifndef __SUNPRO_CC 2294cdf0e10cSrcweir OSL_TRACE ("%s", __FUNCTION__); 2295cdf0e10cSrcweir #endif 2296cdf0e10cSrcweir } 2297cdf0e10cSrcweir 2298cdf0e10cSrcweir // ::com::sun::star::uno::XInterface 2299cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXDialog::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 2300cdf0e10cSrcweir { 2301cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 2302cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XDialog2*, this ), 2303cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XDialog*, this ) ); 2304cdf0e10cSrcweir return (aRet.hasValue() ? aRet : VCLXTopWindow::queryInterface( rType )); 2305cdf0e10cSrcweir } 2306cdf0e10cSrcweir 2307cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 2308cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXDialog ) 2309cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDialog2>* ) NULL ), 2310cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDialog>* ) NULL ), 2311cdf0e10cSrcweir VCLXTopWindow::getTypes() 2312cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 2313cdf0e10cSrcweir 2314cdf0e10cSrcweir void SAL_CALL VCLXDialog::endDialog( ::sal_Int32 i_result ) throw (RuntimeException) 2315cdf0e10cSrcweir { 2316cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2317cdf0e10cSrcweir 2318cdf0e10cSrcweir Dialog* pDialog = dynamic_cast< Dialog* >( GetWindow() ); 2319cdf0e10cSrcweir if ( pDialog ) 2320cdf0e10cSrcweir pDialog->EndDialog( i_result ); 2321cdf0e10cSrcweir } 2322cdf0e10cSrcweir 2323cdf0e10cSrcweir void SAL_CALL VCLXDialog::setHelpId( const ::rtl::OUString& rId ) throw (RuntimeException) 2324cdf0e10cSrcweir { 2325cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2326cdf0e10cSrcweir 2327cdf0e10cSrcweir Window* pWindow = GetWindow(); 2328cdf0e10cSrcweir if ( pWindow ) 2329cdf0e10cSrcweir pWindow->SetHelpId( rtl::OUStringToOString( rId, RTL_TEXTENCODING_UTF8 ) ); 2330cdf0e10cSrcweir } 2331cdf0e10cSrcweir 2332cdf0e10cSrcweir void VCLXDialog::setTitle( const ::rtl::OUString& Title ) throw(::com::sun::star::uno::RuntimeException) 2333cdf0e10cSrcweir { 2334cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2335cdf0e10cSrcweir 2336cdf0e10cSrcweir Window* pWindow = GetWindow(); 2337cdf0e10cSrcweir if ( pWindow ) 2338cdf0e10cSrcweir pWindow->SetText( Title ); 2339cdf0e10cSrcweir } 2340cdf0e10cSrcweir 2341cdf0e10cSrcweir ::rtl::OUString VCLXDialog::getTitle() throw(::com::sun::star::uno::RuntimeException) 2342cdf0e10cSrcweir { 2343cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2344cdf0e10cSrcweir 2345cdf0e10cSrcweir ::rtl::OUString aTitle; 2346cdf0e10cSrcweir Window* pWindow = GetWindow(); 2347cdf0e10cSrcweir if ( pWindow ) 2348cdf0e10cSrcweir aTitle = pWindow->GetText(); 2349cdf0e10cSrcweir return aTitle; 2350cdf0e10cSrcweir } 2351cdf0e10cSrcweir 2352cdf0e10cSrcweir sal_Int16 VCLXDialog::execute() throw(::com::sun::star::uno::RuntimeException) 2353cdf0e10cSrcweir { 2354cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2355cdf0e10cSrcweir 2356cdf0e10cSrcweir sal_Int16 nRet = 0; 2357cdf0e10cSrcweir if ( GetWindow() ) 2358cdf0e10cSrcweir { 2359cdf0e10cSrcweir Dialog* pDlg = (Dialog*) GetWindow(); 2360cdf0e10cSrcweir Window* pParent = pDlg->GetWindow( WINDOW_PARENTOVERLAP ); 2361cdf0e10cSrcweir Window* pOldParent = NULL; 2362cdf0e10cSrcweir Window* pSetParent = NULL; 2363cdf0e10cSrcweir if ( pParent && !pParent->IsReallyVisible() ) 2364cdf0e10cSrcweir { 2365cdf0e10cSrcweir pOldParent = pDlg->GetParent(); 2366cdf0e10cSrcweir Window* pFrame = pDlg->GetWindow( WINDOW_FRAME ); 2367cdf0e10cSrcweir if( pFrame != pDlg ) 2368cdf0e10cSrcweir { 2369cdf0e10cSrcweir pDlg->SetParent( pFrame ); 2370cdf0e10cSrcweir pSetParent = pFrame; 2371cdf0e10cSrcweir } 2372cdf0e10cSrcweir } 2373cdf0e10cSrcweir 2374cdf0e10cSrcweir nRet = pDlg->Execute(); 2375cdf0e10cSrcweir 2376cdf0e10cSrcweir // set the parent back only in case no new parent was set from outside 2377cdf0e10cSrcweir // in other words, revert only own changes 2378cdf0e10cSrcweir if ( pOldParent && pDlg->GetParent() == pSetParent ) 2379cdf0e10cSrcweir pDlg->SetParent( pOldParent ); 2380cdf0e10cSrcweir } 2381cdf0e10cSrcweir return nRet; 2382cdf0e10cSrcweir } 2383cdf0e10cSrcweir 2384cdf0e10cSrcweir void VCLXDialog::endExecute() throw(::com::sun::star::uno::RuntimeException) 2385cdf0e10cSrcweir { 2386cdf0e10cSrcweir endDialog(0); 2387cdf0e10cSrcweir } 2388cdf0e10cSrcweir 2389cdf0e10cSrcweir void SAL_CALL VCLXDialog::draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::star::uno::RuntimeException) 2390cdf0e10cSrcweir { 2391cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2392cdf0e10cSrcweir Window* pWindow = GetWindow(); 2393cdf0e10cSrcweir 2394cdf0e10cSrcweir if ( pWindow ) 2395cdf0e10cSrcweir { 2396cdf0e10cSrcweir OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() ); 2397cdf0e10cSrcweir if ( !pDev ) 2398cdf0e10cSrcweir pDev = pWindow->GetParent(); 2399cdf0e10cSrcweir 2400cdf0e10cSrcweir Size aSize = pDev->PixelToLogic( pWindow->GetSizePixel() ); 2401cdf0e10cSrcweir Point aPos = pDev->PixelToLogic( Point( nX, nY ) ); 2402cdf0e10cSrcweir 2403cdf0e10cSrcweir pWindow->Draw( pDev, aPos, aSize, WINDOW_DRAW_NOCONTROLS ); 2404cdf0e10cSrcweir } 2405cdf0e10cSrcweir } 2406cdf0e10cSrcweir 2407cdf0e10cSrcweir ::com::sun::star::awt::DeviceInfo VCLXDialog::getInfo() throw(::com::sun::star::uno::RuntimeException) 2408cdf0e10cSrcweir { 2409cdf0e10cSrcweir ::com::sun::star::awt::DeviceInfo aInfo = VCLXDevice::getInfo(); 2410cdf0e10cSrcweir 2411cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2412cdf0e10cSrcweir Dialog* pDlg = (Dialog*) GetWindow(); 2413cdf0e10cSrcweir if ( pDlg ) 2414cdf0e10cSrcweir pDlg->GetDrawWindowBorder( aInfo.LeftInset, aInfo.TopInset, aInfo.RightInset, aInfo.BottomInset ); 2415cdf0e10cSrcweir 2416cdf0e10cSrcweir return aInfo; 2417cdf0e10cSrcweir } 2418cdf0e10cSrcweir 2419cdf0e10cSrcweir 2420cdf0e10cSrcweir void SAL_CALL VCLXDialog::setProperty( 2421cdf0e10cSrcweir const ::rtl::OUString& PropertyName, 2422cdf0e10cSrcweir const ::com::sun::star::uno::Any& Value ) 2423cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException) 2424cdf0e10cSrcweir { 2425cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2426cdf0e10cSrcweir 2427cdf0e10cSrcweir Dialog* pDialog = (Dialog*)GetWindow(); 2428cdf0e10cSrcweir if ( pDialog ) 2429cdf0e10cSrcweir { 2430cdf0e10cSrcweir sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID; 2431cdf0e10cSrcweir 2432cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 2433cdf0e10cSrcweir switch ( nPropType ) 2434cdf0e10cSrcweir { 2435cdf0e10cSrcweir case BASEPROPERTY_GRAPHIC: 2436cdf0e10cSrcweir { 2437cdf0e10cSrcweir Reference< XGraphic > xGraphic; 2438cdf0e10cSrcweir if (( Value >>= xGraphic ) && xGraphic.is() ) 2439cdf0e10cSrcweir { 2440cdf0e10cSrcweir Image aImage( xGraphic ); 2441cdf0e10cSrcweir 2442cdf0e10cSrcweir Wallpaper aWallpaper( aImage.GetBitmapEx()); 2443cdf0e10cSrcweir aWallpaper.SetStyle( WALLPAPER_SCALE ); 2444cdf0e10cSrcweir pDialog->SetBackground( aWallpaper ); 2445cdf0e10cSrcweir } 2446cdf0e10cSrcweir else if ( bVoid || !xGraphic.is() ) 2447cdf0e10cSrcweir { 2448cdf0e10cSrcweir Color aColor = pDialog->GetControlBackground().GetColor(); 2449cdf0e10cSrcweir if ( aColor == COL_AUTO ) 2450cdf0e10cSrcweir aColor = pDialog->GetSettings().GetStyleSettings().GetDialogColor(); 2451cdf0e10cSrcweir 2452cdf0e10cSrcweir Wallpaper aWallpaper( aColor ); 2453cdf0e10cSrcweir pDialog->SetBackground( aWallpaper ); 2454cdf0e10cSrcweir } 2455cdf0e10cSrcweir } 2456cdf0e10cSrcweir break; 2457cdf0e10cSrcweir 2458cdf0e10cSrcweir default: 2459cdf0e10cSrcweir { 2460cdf0e10cSrcweir VCLXWindow::setProperty( PropertyName, Value ); 2461cdf0e10cSrcweir } 2462cdf0e10cSrcweir } 2463cdf0e10cSrcweir } 2464cdf0e10cSrcweir } 2465cdf0e10cSrcweir 2466cdf0e10cSrcweir // ---------------------------------------------------- 2467cdf0e10cSrcweir // class VCLXTabPage 2468cdf0e10cSrcweir // ---------------------------------------------------- 2469cdf0e10cSrcweir VCLXTabPage::VCLXTabPage() 2470cdf0e10cSrcweir { 2471cdf0e10cSrcweir } 2472cdf0e10cSrcweir 2473cdf0e10cSrcweir VCLXTabPage::~VCLXTabPage() 2474cdf0e10cSrcweir { 2475cdf0e10cSrcweir } 2476cdf0e10cSrcweir 2477cdf0e10cSrcweir ::com::sun::star::uno::Any SAL_CALL VCLXTabPage::queryInterface(const ::com::sun::star::uno::Type & rType ) 2478cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException) 2479cdf0e10cSrcweir { 2480cdf0e10cSrcweir return VCLXContainer::queryInterface( rType ); 2481cdf0e10cSrcweir } 2482cdf0e10cSrcweir 2483cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 2484cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXTabPage ) 2485cdf0e10cSrcweir VCLXContainer::getTypes() 2486cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 2487cdf0e10cSrcweir 2488cdf0e10cSrcweir // ::com::sun::star::awt::XView 2489cdf0e10cSrcweir void SAL_CALL VCLXTabPage::draw( sal_Int32 nX, sal_Int32 nY ) 2490cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException) 2491cdf0e10cSrcweir { 2492cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2493cdf0e10cSrcweir Window* pWindow = GetWindow(); 2494cdf0e10cSrcweir 2495cdf0e10cSrcweir if ( pWindow ) 2496cdf0e10cSrcweir { 2497cdf0e10cSrcweir OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() ); 2498cdf0e10cSrcweir if ( !pDev ) 2499cdf0e10cSrcweir pDev = pWindow->GetParent(); 2500cdf0e10cSrcweir 2501cdf0e10cSrcweir Size aSize = pDev->PixelToLogic( pWindow->GetSizePixel() ); 2502cdf0e10cSrcweir Point aPos = pDev->PixelToLogic( Point( nX, nY ) ); 2503cdf0e10cSrcweir 2504cdf0e10cSrcweir pWindow->Draw( pDev, aPos, aSize, WINDOW_DRAW_NOCONTROLS ); 2505cdf0e10cSrcweir } 2506cdf0e10cSrcweir } 2507cdf0e10cSrcweir 2508cdf0e10cSrcweir // ::com::sun::star::awt::XDevice, 2509cdf0e10cSrcweir ::com::sun::star::awt::DeviceInfo SAL_CALL VCLXTabPage::getInfo() 2510cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException) 2511cdf0e10cSrcweir { 2512cdf0e10cSrcweir ::com::sun::star::awt::DeviceInfo aInfo = VCLXDevice::getInfo(); 2513cdf0e10cSrcweir return aInfo; 2514cdf0e10cSrcweir } 2515cdf0e10cSrcweir 2516cdf0e10cSrcweir void SAL_CALL VCLXTabPage::setProperty( 2517cdf0e10cSrcweir const ::rtl::OUString& PropertyName, 2518cdf0e10cSrcweir const ::com::sun::star::uno::Any& Value ) 2519cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException) 2520cdf0e10cSrcweir { 2521cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2522cdf0e10cSrcweir 2523cdf0e10cSrcweir TabPage* pTabPage = (TabPage*)GetWindow(); 2524cdf0e10cSrcweir if ( pTabPage ) 2525cdf0e10cSrcweir { 2526cdf0e10cSrcweir sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID; 2527cdf0e10cSrcweir 2528cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 2529cdf0e10cSrcweir switch ( nPropType ) 2530cdf0e10cSrcweir { 2531cdf0e10cSrcweir case BASEPROPERTY_GRAPHIC: 2532cdf0e10cSrcweir { 2533cdf0e10cSrcweir Reference< XGraphic > xGraphic; 2534cdf0e10cSrcweir if (( Value >>= xGraphic ) && xGraphic.is() ) 2535cdf0e10cSrcweir { 2536cdf0e10cSrcweir Image aImage( xGraphic ); 2537cdf0e10cSrcweir 2538cdf0e10cSrcweir Wallpaper aWallpaper( aImage.GetBitmapEx()); 2539cdf0e10cSrcweir aWallpaper.SetStyle( WALLPAPER_SCALE ); 2540cdf0e10cSrcweir pTabPage->SetBackground( aWallpaper ); 2541cdf0e10cSrcweir } 2542cdf0e10cSrcweir else if ( bVoid || !xGraphic.is() ) 2543cdf0e10cSrcweir { 2544cdf0e10cSrcweir Color aColor = pTabPage->GetControlBackground().GetColor(); 2545cdf0e10cSrcweir if ( aColor == COL_AUTO ) 2546cdf0e10cSrcweir aColor = pTabPage->GetSettings().GetStyleSettings().GetDialogColor(); 2547cdf0e10cSrcweir 2548cdf0e10cSrcweir Wallpaper aWallpaper( aColor ); 2549cdf0e10cSrcweir pTabPage->SetBackground( aWallpaper ); 2550cdf0e10cSrcweir } 2551cdf0e10cSrcweir } 2552cdf0e10cSrcweir break; 2553cdf0e10cSrcweir case BASEPROPERTY_TITLE: 2554cdf0e10cSrcweir { 2555cdf0e10cSrcweir ::rtl::OUString sTitle; 2556cdf0e10cSrcweir if ( Value >>= sTitle ) 2557cdf0e10cSrcweir { 2558cdf0e10cSrcweir pTabPage->SetText(sTitle); 2559cdf0e10cSrcweir } 2560cdf0e10cSrcweir } 2561cdf0e10cSrcweir break; 2562cdf0e10cSrcweir 2563cdf0e10cSrcweir default: 2564cdf0e10cSrcweir { 2565cdf0e10cSrcweir VCLXContainer::setProperty( PropertyName, Value ); 2566cdf0e10cSrcweir } 2567cdf0e10cSrcweir } 2568cdf0e10cSrcweir } 2569cdf0e10cSrcweir } 2570cdf0e10cSrcweir 2571cdf0e10cSrcweir // ---------------------------------------------------- 2572cdf0e10cSrcweir // class VCLXFixedHyperlink 2573cdf0e10cSrcweir // ---------------------------------------------------- 2574cdf0e10cSrcweir VCLXFixedHyperlink::VCLXFixedHyperlink() : 2575cdf0e10cSrcweir 2576cdf0e10cSrcweir maActionListeners( *this ) 2577cdf0e10cSrcweir 2578cdf0e10cSrcweir { 2579cdf0e10cSrcweir } 2580cdf0e10cSrcweir 2581cdf0e10cSrcweir VCLXFixedHyperlink::~VCLXFixedHyperlink() 2582cdf0e10cSrcweir { 2583cdf0e10cSrcweir } 2584cdf0e10cSrcweir 2585cdf0e10cSrcweir // ::com::sun::star::uno::XInterface 2586cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXFixedHyperlink::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 2587cdf0e10cSrcweir { 2588cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 2589cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XFixedHyperlink*, this ) ); 2590cdf0e10cSrcweir return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); 2591cdf0e10cSrcweir } 2592cdf0e10cSrcweir 2593cdf0e10cSrcweir void VCLXFixedHyperlink::dispose() throw(::com::sun::star::uno::RuntimeException) 2594cdf0e10cSrcweir { 2595cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2596cdf0e10cSrcweir 2597cdf0e10cSrcweir ::com::sun::star::lang::EventObject aObj; 2598cdf0e10cSrcweir aObj.Source = (::cppu::OWeakObject*)this; 2599cdf0e10cSrcweir maActionListeners.disposeAndClear( aObj ); 2600cdf0e10cSrcweir VCLXWindow::dispose(); 2601cdf0e10cSrcweir } 2602cdf0e10cSrcweir 2603cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 2604cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXFixedHyperlink ) 2605cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFixedHyperlink>* ) NULL ), 2606cdf0e10cSrcweir VCLXWindow::getTypes() 2607cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 2608cdf0e10cSrcweir 2609cdf0e10cSrcweir void VCLXFixedHyperlink::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) 2610cdf0e10cSrcweir { 2611cdf0e10cSrcweir switch ( rVclWindowEvent.GetId() ) 2612cdf0e10cSrcweir { 2613cdf0e10cSrcweir case VCLEVENT_BUTTON_CLICK: 2614cdf0e10cSrcweir { 2615cdf0e10cSrcweir if ( maActionListeners.getLength() ) 2616cdf0e10cSrcweir { 2617cdf0e10cSrcweir ::com::sun::star::awt::ActionEvent aEvent; 2618cdf0e10cSrcweir aEvent.Source = (::cppu::OWeakObject*)this; 2619cdf0e10cSrcweir maActionListeners.actionPerformed( aEvent ); 2620cdf0e10cSrcweir } 2621cdf0e10cSrcweir else 2622cdf0e10cSrcweir { 2623cdf0e10cSrcweir // open the URL 2624cdf0e10cSrcweir ::rtl::OUString sURL; 2625cdf0e10cSrcweir ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow(); 2626cdf0e10cSrcweir if ( pBase ) 2627cdf0e10cSrcweir sURL = pBase->GetURL(); 2628cdf0e10cSrcweir Reference< ::com::sun::star::system::XSystemShellExecute > xSystemShellExecute( 2629cdf0e10cSrcweir ::comphelper::getProcessServiceFactory()->createInstance( 2630cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "com.sun.star.system.SystemShellExecute" )), uno::UNO_QUERY ); 2631cdf0e10cSrcweir if ( sURL.getLength() > 0 && xSystemShellExecute.is() ) 2632cdf0e10cSrcweir { 2633cdf0e10cSrcweir try 2634cdf0e10cSrcweir { 2635cdf0e10cSrcweir // start browser 2636cdf0e10cSrcweir xSystemShellExecute->execute( 2637cdf0e10cSrcweir sURL, ::rtl::OUString(), ::com::sun::star::system::SystemShellExecuteFlags::DEFAULTS ); 2638cdf0e10cSrcweir } 2639cdf0e10cSrcweir catch( uno::Exception& ) 2640cdf0e10cSrcweir { 2641cdf0e10cSrcweir } 2642cdf0e10cSrcweir } 2643cdf0e10cSrcweir } 2644cdf0e10cSrcweir } 2645cdf0e10cSrcweir 2646cdf0e10cSrcweir default: 2647cdf0e10cSrcweir VCLXWindow::ProcessWindowEvent( rVclWindowEvent ); 2648cdf0e10cSrcweir break; 2649cdf0e10cSrcweir } 2650cdf0e10cSrcweir } 2651cdf0e10cSrcweir 2652cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXFixedHyperlink::CreateAccessibleContext() 2653cdf0e10cSrcweir { 2654cdf0e10cSrcweir return getAccessibleFactory().createAccessibleContext( this ); 2655cdf0e10cSrcweir } 2656cdf0e10cSrcweir 2657cdf0e10cSrcweir void VCLXFixedHyperlink::setText( const ::rtl::OUString& Text ) throw(::com::sun::star::uno::RuntimeException) 2658cdf0e10cSrcweir { 2659cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2660cdf0e10cSrcweir 2661cdf0e10cSrcweir ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow(); 2662cdf0e10cSrcweir if ( pBase ) 2663cdf0e10cSrcweir pBase->SetDescription( Text ); 2664cdf0e10cSrcweir } 2665cdf0e10cSrcweir 2666cdf0e10cSrcweir ::rtl::OUString VCLXFixedHyperlink::getText() throw(::com::sun::star::uno::RuntimeException) 2667cdf0e10cSrcweir { 2668cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2669cdf0e10cSrcweir 2670cdf0e10cSrcweir ::rtl::OUString aText; 2671cdf0e10cSrcweir Window* pWindow = GetWindow(); 2672cdf0e10cSrcweir if ( pWindow ) 2673cdf0e10cSrcweir aText = pWindow->GetText(); 2674cdf0e10cSrcweir return aText; 2675cdf0e10cSrcweir } 2676cdf0e10cSrcweir 2677cdf0e10cSrcweir void VCLXFixedHyperlink::setURL( const ::rtl::OUString& URL ) throw(::com::sun::star::uno::RuntimeException) 2678cdf0e10cSrcweir { 2679cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2680cdf0e10cSrcweir 2681cdf0e10cSrcweir ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow(); 2682cdf0e10cSrcweir if ( pBase ) 2683cdf0e10cSrcweir pBase->SetURL( URL ); 2684cdf0e10cSrcweir } 2685cdf0e10cSrcweir 2686cdf0e10cSrcweir ::rtl::OUString VCLXFixedHyperlink::getURL( ) throw(::com::sun::star::uno::RuntimeException) 2687cdf0e10cSrcweir { 2688cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2689cdf0e10cSrcweir 2690cdf0e10cSrcweir ::rtl::OUString aText; 2691cdf0e10cSrcweir ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow(); 2692cdf0e10cSrcweir if ( pBase ) 2693cdf0e10cSrcweir aText = pBase->GetURL(); 2694cdf0e10cSrcweir return aText; 2695cdf0e10cSrcweir } 2696cdf0e10cSrcweir 2697cdf0e10cSrcweir void VCLXFixedHyperlink::setAlignment( short nAlign ) throw(::com::sun::star::uno::RuntimeException) 2698cdf0e10cSrcweir { 2699cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2700cdf0e10cSrcweir 2701cdf0e10cSrcweir Window* pWindow = GetWindow(); 2702cdf0e10cSrcweir if ( pWindow ) 2703cdf0e10cSrcweir { 2704cdf0e10cSrcweir WinBits nNewBits = 0; 2705cdf0e10cSrcweir if ( nAlign == ::com::sun::star::awt::TextAlign::LEFT ) 2706cdf0e10cSrcweir nNewBits = WB_LEFT; 2707cdf0e10cSrcweir else if ( nAlign == ::com::sun::star::awt::TextAlign::CENTER ) 2708cdf0e10cSrcweir nNewBits = WB_CENTER; 2709cdf0e10cSrcweir else 2710cdf0e10cSrcweir nNewBits = WB_RIGHT; 2711cdf0e10cSrcweir 2712cdf0e10cSrcweir WinBits nStyle = pWindow->GetStyle(); 2713cdf0e10cSrcweir nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT); 2714cdf0e10cSrcweir pWindow->SetStyle( nStyle | nNewBits ); 2715cdf0e10cSrcweir } 2716cdf0e10cSrcweir } 2717cdf0e10cSrcweir 2718cdf0e10cSrcweir short VCLXFixedHyperlink::getAlignment() throw(::com::sun::star::uno::RuntimeException) 2719cdf0e10cSrcweir { 2720cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2721cdf0e10cSrcweir 2722cdf0e10cSrcweir short nAlign = 0; 2723cdf0e10cSrcweir Window* pWindow = GetWindow(); 2724cdf0e10cSrcweir if ( pWindow ) 2725cdf0e10cSrcweir { 2726cdf0e10cSrcweir WinBits nStyle = pWindow->GetStyle(); 2727cdf0e10cSrcweir if ( nStyle & WB_LEFT ) 2728cdf0e10cSrcweir nAlign = ::com::sun::star::awt::TextAlign::LEFT; 2729cdf0e10cSrcweir else if ( nStyle & WB_CENTER ) 2730cdf0e10cSrcweir nAlign = ::com::sun::star::awt::TextAlign::CENTER; 2731cdf0e10cSrcweir else 2732cdf0e10cSrcweir nAlign = ::com::sun::star::awt::TextAlign::RIGHT; 2733cdf0e10cSrcweir } 2734cdf0e10cSrcweir return nAlign; 2735cdf0e10cSrcweir } 2736cdf0e10cSrcweir 2737cdf0e10cSrcweir void VCLXFixedHyperlink::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )throw(::com::sun::star::uno::RuntimeException) 2738cdf0e10cSrcweir { 2739cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2740cdf0e10cSrcweir maActionListeners.addInterface( l ); 2741cdf0e10cSrcweir } 2742cdf0e10cSrcweir 2743cdf0e10cSrcweir void VCLXFixedHyperlink::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException) 2744cdf0e10cSrcweir { 2745cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2746cdf0e10cSrcweir maActionListeners.removeInterface( l ); 2747cdf0e10cSrcweir } 2748cdf0e10cSrcweir 2749cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXFixedHyperlink::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException) 2750cdf0e10cSrcweir { 2751cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2752cdf0e10cSrcweir 2753cdf0e10cSrcweir Size aSz; 2754cdf0e10cSrcweir FixedText* pFixedText = (FixedText*)GetWindow(); 2755cdf0e10cSrcweir if ( pFixedText ) 2756cdf0e10cSrcweir aSz = pFixedText->CalcMinimumSize(); 2757cdf0e10cSrcweir return AWTSize(aSz); 2758cdf0e10cSrcweir } 2759cdf0e10cSrcweir 2760cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXFixedHyperlink::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException) 2761cdf0e10cSrcweir { 2762cdf0e10cSrcweir return getMinimumSize(); 2763cdf0e10cSrcweir } 2764cdf0e10cSrcweir 2765cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXFixedHyperlink::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException) 2766cdf0e10cSrcweir { 2767cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2768cdf0e10cSrcweir 2769cdf0e10cSrcweir ::com::sun::star::awt::Size aSz = rNewSize; 2770cdf0e10cSrcweir ::com::sun::star::awt::Size aMinSz = getMinimumSize(); 2771cdf0e10cSrcweir if ( aSz.Height != aMinSz.Height ) 2772cdf0e10cSrcweir aSz.Height = aMinSz.Height; 2773cdf0e10cSrcweir 2774cdf0e10cSrcweir return aSz; 2775cdf0e10cSrcweir } 2776cdf0e10cSrcweir 2777cdf0e10cSrcweir void VCLXFixedHyperlink::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 2778cdf0e10cSrcweir { 2779cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2780cdf0e10cSrcweir 2781cdf0e10cSrcweir ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow(); 2782cdf0e10cSrcweir if ( pBase ) 2783cdf0e10cSrcweir { 2784cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 2785cdf0e10cSrcweir switch ( nPropType ) 2786cdf0e10cSrcweir { 2787cdf0e10cSrcweir case BASEPROPERTY_LABEL: 2788cdf0e10cSrcweir { 2789cdf0e10cSrcweir ::rtl::OUString sNewLabel; 2790cdf0e10cSrcweir if ( Value >>= sNewLabel ) 2791cdf0e10cSrcweir pBase->SetDescription( sNewLabel ); 2792cdf0e10cSrcweir break; 2793cdf0e10cSrcweir } 2794cdf0e10cSrcweir 2795cdf0e10cSrcweir case BASEPROPERTY_URL: 2796cdf0e10cSrcweir { 2797cdf0e10cSrcweir ::rtl::OUString sNewURL; 2798cdf0e10cSrcweir if ( Value >>= sNewURL ) 2799cdf0e10cSrcweir pBase->SetURL( sNewURL ); 2800cdf0e10cSrcweir break; 2801cdf0e10cSrcweir } 2802cdf0e10cSrcweir 2803cdf0e10cSrcweir default: 2804cdf0e10cSrcweir { 2805cdf0e10cSrcweir VCLXWindow::setProperty( PropertyName, Value ); 2806cdf0e10cSrcweir } 2807cdf0e10cSrcweir } 2808cdf0e10cSrcweir } 2809cdf0e10cSrcweir } 2810cdf0e10cSrcweir 2811cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXFixedHyperlink::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) 2812cdf0e10cSrcweir { 2813cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2814cdf0e10cSrcweir 2815cdf0e10cSrcweir ::com::sun::star::uno::Any aProp; 2816cdf0e10cSrcweir ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow(); 2817cdf0e10cSrcweir if ( pBase ) 2818cdf0e10cSrcweir { 2819cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 2820cdf0e10cSrcweir switch ( nPropType ) 2821cdf0e10cSrcweir { 2822cdf0e10cSrcweir case BASEPROPERTY_URL: 2823cdf0e10cSrcweir { 2824cdf0e10cSrcweir aProp = makeAny( ::rtl::OUString( pBase->GetURL() ) ); 2825cdf0e10cSrcweir break; 2826cdf0e10cSrcweir } 2827cdf0e10cSrcweir 2828cdf0e10cSrcweir default: 2829cdf0e10cSrcweir { 2830cdf0e10cSrcweir aProp <<= VCLXWindow::getProperty( PropertyName ); 2831cdf0e10cSrcweir } 2832cdf0e10cSrcweir } 2833cdf0e10cSrcweir } 2834cdf0e10cSrcweir return aProp; 2835cdf0e10cSrcweir } 2836cdf0e10cSrcweir 2837cdf0e10cSrcweir void VCLXFixedHyperlink::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 2838cdf0e10cSrcweir { 2839cdf0e10cSrcweir PushPropertyIds( rIds, 2840cdf0e10cSrcweir BASEPROPERTY_ALIGN, 2841cdf0e10cSrcweir BASEPROPERTY_BACKGROUNDCOLOR, 2842cdf0e10cSrcweir BASEPROPERTY_BORDER, 2843cdf0e10cSrcweir BASEPROPERTY_BORDERCOLOR, 2844cdf0e10cSrcweir BASEPROPERTY_DEFAULTCONTROL, 2845cdf0e10cSrcweir BASEPROPERTY_ENABLED, 2846cdf0e10cSrcweir BASEPROPERTY_ENABLEVISIBLE, 2847cdf0e10cSrcweir BASEPROPERTY_FONTDESCRIPTOR, 2848cdf0e10cSrcweir BASEPROPERTY_HELPTEXT, 2849cdf0e10cSrcweir BASEPROPERTY_HELPURL, 2850cdf0e10cSrcweir BASEPROPERTY_LABEL, 2851cdf0e10cSrcweir BASEPROPERTY_MULTILINE, 2852cdf0e10cSrcweir BASEPROPERTY_NOLABEL, 2853cdf0e10cSrcweir BASEPROPERTY_PRINTABLE, 2854cdf0e10cSrcweir BASEPROPERTY_TABSTOP, 2855cdf0e10cSrcweir BASEPROPERTY_VERTICALALIGN, 2856cdf0e10cSrcweir BASEPROPERTY_URL, 2857cdf0e10cSrcweir BASEPROPERTY_WRITING_MODE, 2858cdf0e10cSrcweir BASEPROPERTY_CONTEXT_WRITING_MODE, 2859cdf0e10cSrcweir 0); 2860cdf0e10cSrcweir VCLXWindow::ImplGetPropertyIds( rIds ); 2861cdf0e10cSrcweir } 2862cdf0e10cSrcweir 2863cdf0e10cSrcweir // ---------------------------------------------------- 2864cdf0e10cSrcweir // class VCLXFixedText 2865cdf0e10cSrcweir // ---------------------------------------------------- 2866cdf0e10cSrcweir void VCLXFixedText::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 2867cdf0e10cSrcweir { 2868cdf0e10cSrcweir PushPropertyIds( rIds, 2869cdf0e10cSrcweir BASEPROPERTY_ALIGN, 2870cdf0e10cSrcweir BASEPROPERTY_BACKGROUNDCOLOR, 2871cdf0e10cSrcweir BASEPROPERTY_BORDER, 2872cdf0e10cSrcweir BASEPROPERTY_BORDERCOLOR, 2873cdf0e10cSrcweir BASEPROPERTY_DEFAULTCONTROL, 2874cdf0e10cSrcweir BASEPROPERTY_ENABLED, 2875cdf0e10cSrcweir BASEPROPERTY_ENABLEVISIBLE, 2876cdf0e10cSrcweir BASEPROPERTY_FONTDESCRIPTOR, 2877cdf0e10cSrcweir BASEPROPERTY_HELPTEXT, 2878cdf0e10cSrcweir BASEPROPERTY_HELPURL, 2879cdf0e10cSrcweir BASEPROPERTY_LABEL, 2880cdf0e10cSrcweir BASEPROPERTY_MULTILINE, 2881cdf0e10cSrcweir BASEPROPERTY_NOLABEL, 2882cdf0e10cSrcweir BASEPROPERTY_PRINTABLE, 2883cdf0e10cSrcweir BASEPROPERTY_TABSTOP, 2884cdf0e10cSrcweir BASEPROPERTY_VERTICALALIGN, 2885cdf0e10cSrcweir BASEPROPERTY_WRITING_MODE, 2886cdf0e10cSrcweir BASEPROPERTY_CONTEXT_WRITING_MODE, 2887cdf0e10cSrcweir BASEPROPERTY_REFERENCE_DEVICE, 2888cdf0e10cSrcweir 0); 2889cdf0e10cSrcweir VCLXWindow::ImplGetPropertyIds( rIds ); 2890cdf0e10cSrcweir } 2891cdf0e10cSrcweir 2892cdf0e10cSrcweir VCLXFixedText::VCLXFixedText() 2893cdf0e10cSrcweir { 2894cdf0e10cSrcweir } 2895cdf0e10cSrcweir 2896cdf0e10cSrcweir VCLXFixedText::~VCLXFixedText() 2897cdf0e10cSrcweir { 2898cdf0e10cSrcweir } 2899cdf0e10cSrcweir 2900cdf0e10cSrcweir // ::com::sun::star::uno::XInterface 2901cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXFixedText::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 2902cdf0e10cSrcweir { 2903cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 2904cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XFixedText*, this ) ); 2905cdf0e10cSrcweir return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); 2906cdf0e10cSrcweir } 2907cdf0e10cSrcweir 2908cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 2909cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXFixedText ) 2910cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFixedText>* ) NULL ), 2911cdf0e10cSrcweir VCLXWindow::getTypes() 2912cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 2913cdf0e10cSrcweir 2914cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXFixedText::CreateAccessibleContext() 2915cdf0e10cSrcweir { 2916cdf0e10cSrcweir return getAccessibleFactory().createAccessibleContext( this ); 2917cdf0e10cSrcweir } 2918cdf0e10cSrcweir 2919cdf0e10cSrcweir void VCLXFixedText::setText( const ::rtl::OUString& Text ) throw(::com::sun::star::uno::RuntimeException) 2920cdf0e10cSrcweir { 2921cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2922cdf0e10cSrcweir 2923cdf0e10cSrcweir Window* pWindow = GetWindow(); 2924cdf0e10cSrcweir if ( pWindow ) 2925cdf0e10cSrcweir pWindow->SetText( Text ); 2926cdf0e10cSrcweir } 2927cdf0e10cSrcweir 2928cdf0e10cSrcweir ::rtl::OUString VCLXFixedText::getText() throw(::com::sun::star::uno::RuntimeException) 2929cdf0e10cSrcweir { 2930cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2931cdf0e10cSrcweir 2932cdf0e10cSrcweir ::rtl::OUString aText; 2933cdf0e10cSrcweir Window* pWindow = GetWindow(); 2934cdf0e10cSrcweir if ( pWindow ) 2935cdf0e10cSrcweir aText = pWindow->GetText(); 2936cdf0e10cSrcweir return aText; 2937cdf0e10cSrcweir } 2938cdf0e10cSrcweir 2939cdf0e10cSrcweir void VCLXFixedText::setAlignment( short nAlign ) throw(::com::sun::star::uno::RuntimeException) 2940cdf0e10cSrcweir { 2941cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2942cdf0e10cSrcweir 2943cdf0e10cSrcweir Window* pWindow = GetWindow(); 2944cdf0e10cSrcweir if ( pWindow ) 2945cdf0e10cSrcweir { 2946cdf0e10cSrcweir WinBits nNewBits = 0; 2947cdf0e10cSrcweir if ( nAlign == ::com::sun::star::awt::TextAlign::LEFT ) 2948cdf0e10cSrcweir nNewBits = WB_LEFT; 2949cdf0e10cSrcweir else if ( nAlign == ::com::sun::star::awt::TextAlign::CENTER ) 2950cdf0e10cSrcweir nNewBits = WB_CENTER; 2951cdf0e10cSrcweir else 2952cdf0e10cSrcweir nNewBits = WB_RIGHT; 2953cdf0e10cSrcweir 2954cdf0e10cSrcweir WinBits nStyle = pWindow->GetStyle(); 2955cdf0e10cSrcweir nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT); 2956cdf0e10cSrcweir pWindow->SetStyle( nStyle | nNewBits ); 2957cdf0e10cSrcweir } 2958cdf0e10cSrcweir } 2959cdf0e10cSrcweir 2960cdf0e10cSrcweir short VCLXFixedText::getAlignment() throw(::com::sun::star::uno::RuntimeException) 2961cdf0e10cSrcweir { 2962cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2963cdf0e10cSrcweir 2964cdf0e10cSrcweir short nAlign = 0; 2965cdf0e10cSrcweir Window* pWindow = GetWindow(); 2966cdf0e10cSrcweir if ( pWindow ) 2967cdf0e10cSrcweir { 2968cdf0e10cSrcweir WinBits nStyle = pWindow->GetStyle(); 2969cdf0e10cSrcweir if ( nStyle & WB_LEFT ) 2970cdf0e10cSrcweir nAlign = ::com::sun::star::awt::TextAlign::LEFT; 2971cdf0e10cSrcweir else if ( nStyle & WB_CENTER ) 2972cdf0e10cSrcweir nAlign = ::com::sun::star::awt::TextAlign::CENTER; 2973cdf0e10cSrcweir else 2974cdf0e10cSrcweir nAlign = ::com::sun::star::awt::TextAlign::RIGHT; 2975cdf0e10cSrcweir } 2976cdf0e10cSrcweir return nAlign; 2977cdf0e10cSrcweir } 2978cdf0e10cSrcweir 2979cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXFixedText::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException) 2980cdf0e10cSrcweir { 2981cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2982cdf0e10cSrcweir 2983cdf0e10cSrcweir Size aSz; 2984cdf0e10cSrcweir FixedText* pFixedText = (FixedText*)GetWindow(); 2985cdf0e10cSrcweir if ( pFixedText ) 2986cdf0e10cSrcweir aSz = pFixedText->CalcMinimumSize(); 2987cdf0e10cSrcweir return AWTSize(aSz); 2988cdf0e10cSrcweir } 2989cdf0e10cSrcweir 2990cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXFixedText::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException) 2991cdf0e10cSrcweir { 2992cdf0e10cSrcweir return getMinimumSize(); 2993cdf0e10cSrcweir } 2994cdf0e10cSrcweir 2995cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXFixedText::calcAdjustedSize( const ::com::sun::star::awt::Size& rMaxSize ) throw(::com::sun::star::uno::RuntimeException) 2996cdf0e10cSrcweir { 2997cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2998cdf0e10cSrcweir 2999cdf0e10cSrcweir Size aAdjustedSize( VCLUnoHelper::ConvertToVCLSize( rMaxSize ) ); 3000cdf0e10cSrcweir FixedText* pFixedText = (FixedText*)GetWindow(); 3001cdf0e10cSrcweir if ( pFixedText ) 3002cdf0e10cSrcweir aAdjustedSize = pFixedText->CalcMinimumSize( rMaxSize.Width ); 3003cdf0e10cSrcweir return VCLUnoHelper::ConvertToAWTSize( aAdjustedSize ); 3004cdf0e10cSrcweir } 3005cdf0e10cSrcweir 3006cdf0e10cSrcweir // ---------------------------------------------------- 3007cdf0e10cSrcweir // class VCLXScrollBar 3008cdf0e10cSrcweir // ---------------------------------------------------- 3009cdf0e10cSrcweir void VCLXScrollBar::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 3010cdf0e10cSrcweir { 3011cdf0e10cSrcweir PushPropertyIds( rIds, 3012cdf0e10cSrcweir BASEPROPERTY_BACKGROUNDCOLOR, 3013cdf0e10cSrcweir BASEPROPERTY_BLOCKINCREMENT, 3014cdf0e10cSrcweir BASEPROPERTY_BORDER, 3015cdf0e10cSrcweir BASEPROPERTY_BORDERCOLOR, 3016cdf0e10cSrcweir BASEPROPERTY_DEFAULTCONTROL, 3017cdf0e10cSrcweir BASEPROPERTY_ENABLED, 3018cdf0e10cSrcweir BASEPROPERTY_ENABLEVISIBLE, 3019cdf0e10cSrcweir BASEPROPERTY_HELPTEXT, 3020cdf0e10cSrcweir BASEPROPERTY_HELPURL, 3021cdf0e10cSrcweir BASEPROPERTY_LINEINCREMENT, 3022cdf0e10cSrcweir BASEPROPERTY_LIVE_SCROLL, 3023cdf0e10cSrcweir BASEPROPERTY_ORIENTATION, 3024cdf0e10cSrcweir BASEPROPERTY_PRINTABLE, 3025cdf0e10cSrcweir BASEPROPERTY_REPEAT_DELAY, 3026cdf0e10cSrcweir BASEPROPERTY_SCROLLVALUE, 3027cdf0e10cSrcweir BASEPROPERTY_SCROLLVALUE_MAX, 3028cdf0e10cSrcweir BASEPROPERTY_SCROLLVALUE_MIN, 3029cdf0e10cSrcweir BASEPROPERTY_SYMBOL_COLOR, 3030cdf0e10cSrcweir BASEPROPERTY_TABSTOP, 3031cdf0e10cSrcweir BASEPROPERTY_VISIBLESIZE, 3032cdf0e10cSrcweir BASEPROPERTY_WRITING_MODE, 3033cdf0e10cSrcweir BASEPROPERTY_CONTEXT_WRITING_MODE, 3034cdf0e10cSrcweir 0); 3035cdf0e10cSrcweir VCLXWindow::ImplGetPropertyIds( rIds ); 3036cdf0e10cSrcweir } 3037cdf0e10cSrcweir 3038cdf0e10cSrcweir VCLXScrollBar::VCLXScrollBar() : maAdjustmentListeners( *this ) 3039cdf0e10cSrcweir { 3040cdf0e10cSrcweir } 3041cdf0e10cSrcweir 3042cdf0e10cSrcweir // ::com::sun::star::uno::XInterface 3043cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXScrollBar::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 3044cdf0e10cSrcweir { 3045cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 3046cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XScrollBar*, this ) ); 3047cdf0e10cSrcweir return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); 3048cdf0e10cSrcweir } 3049cdf0e10cSrcweir 3050cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 3051cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXScrollBar ) 3052cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XScrollBar>* ) NULL ), 3053cdf0e10cSrcweir VCLXWindow::getTypes() 3054cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 3055cdf0e10cSrcweir 3056cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXScrollBar::CreateAccessibleContext() 3057cdf0e10cSrcweir { 3058cdf0e10cSrcweir return getAccessibleFactory().createAccessibleContext( this ); 3059cdf0e10cSrcweir } 3060cdf0e10cSrcweir 3061cdf0e10cSrcweir // ::com::sun::star::lang::XComponent 3062cdf0e10cSrcweir void VCLXScrollBar::dispose() throw(::com::sun::star::uno::RuntimeException) 3063cdf0e10cSrcweir { 3064cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3065cdf0e10cSrcweir 3066cdf0e10cSrcweir ::com::sun::star::lang::EventObject aObj; 3067cdf0e10cSrcweir aObj.Source = (::cppu::OWeakObject*)this; 3068cdf0e10cSrcweir maAdjustmentListeners.disposeAndClear( aObj ); 3069cdf0e10cSrcweir VCLXWindow::dispose(); 3070cdf0e10cSrcweir } 3071cdf0e10cSrcweir 3072cdf0e10cSrcweir // ::com::sun::star::awt::XScrollbar 3073cdf0e10cSrcweir void VCLXScrollBar::addAdjustmentListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XAdjustmentListener > & l ) throw(::com::sun::star::uno::RuntimeException) 3074cdf0e10cSrcweir { 3075cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3076cdf0e10cSrcweir maAdjustmentListeners.addInterface( l ); 3077cdf0e10cSrcweir } 3078cdf0e10cSrcweir 3079cdf0e10cSrcweir void VCLXScrollBar::removeAdjustmentListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XAdjustmentListener > & l ) throw(::com::sun::star::uno::RuntimeException) 3080cdf0e10cSrcweir { 3081cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3082cdf0e10cSrcweir maAdjustmentListeners.removeInterface( l ); 3083cdf0e10cSrcweir } 3084cdf0e10cSrcweir 3085cdf0e10cSrcweir void VCLXScrollBar::setValue( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException) 3086cdf0e10cSrcweir { 3087cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3088cdf0e10cSrcweir 3089cdf0e10cSrcweir ScrollBar* pScrollBar = (ScrollBar*) GetWindow(); 3090cdf0e10cSrcweir if ( pScrollBar ) 3091cdf0e10cSrcweir pScrollBar->DoScroll( n ); 3092cdf0e10cSrcweir } 3093cdf0e10cSrcweir 3094cdf0e10cSrcweir void VCLXScrollBar::setValues( sal_Int32 nValue, sal_Int32 nVisible, sal_Int32 nMax ) throw(::com::sun::star::uno::RuntimeException) 3095cdf0e10cSrcweir { 3096cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3097cdf0e10cSrcweir 3098cdf0e10cSrcweir ScrollBar* pScrollBar = (ScrollBar*) GetWindow(); 3099cdf0e10cSrcweir if ( pScrollBar ) 3100cdf0e10cSrcweir { 3101cdf0e10cSrcweir pScrollBar->SetVisibleSize( nVisible ); 3102cdf0e10cSrcweir pScrollBar->SetRangeMax( nMax ); 3103cdf0e10cSrcweir pScrollBar->DoScroll( nValue ); 3104cdf0e10cSrcweir } 3105cdf0e10cSrcweir } 3106cdf0e10cSrcweir 3107cdf0e10cSrcweir sal_Int32 VCLXScrollBar::getValue() throw(::com::sun::star::uno::RuntimeException) 3108cdf0e10cSrcweir { 3109cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3110cdf0e10cSrcweir 3111cdf0e10cSrcweir ScrollBar* pScrollBar = (ScrollBar*) GetWindow(); 3112cdf0e10cSrcweir return pScrollBar ? pScrollBar->GetThumbPos() : 0; 3113cdf0e10cSrcweir } 3114cdf0e10cSrcweir 3115cdf0e10cSrcweir void VCLXScrollBar::setMaximum( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException) 3116cdf0e10cSrcweir { 3117cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3118cdf0e10cSrcweir 3119cdf0e10cSrcweir ScrollBar* pScrollBar = (ScrollBar*) GetWindow(); 3120cdf0e10cSrcweir if ( pScrollBar ) 3121cdf0e10cSrcweir pScrollBar->SetRangeMax( n ); 3122cdf0e10cSrcweir } 3123cdf0e10cSrcweir 3124cdf0e10cSrcweir sal_Int32 VCLXScrollBar::getMaximum() throw(::com::sun::star::uno::RuntimeException) 3125cdf0e10cSrcweir { 3126cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3127cdf0e10cSrcweir 3128cdf0e10cSrcweir ScrollBar* pScrollBar = (ScrollBar*) GetWindow(); 3129cdf0e10cSrcweir return pScrollBar ? pScrollBar->GetRangeMax() : 0; 3130cdf0e10cSrcweir } 3131cdf0e10cSrcweir 3132cdf0e10cSrcweir void VCLXScrollBar::setMinimum( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException) 3133cdf0e10cSrcweir { 3134cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3135cdf0e10cSrcweir 3136cdf0e10cSrcweir ScrollBar* pScrollBar = static_cast< ScrollBar* >( GetWindow() ); 3137cdf0e10cSrcweir if ( pScrollBar ) 3138cdf0e10cSrcweir pScrollBar->SetRangeMin( n ); 3139cdf0e10cSrcweir } 3140cdf0e10cSrcweir 3141cdf0e10cSrcweir sal_Int32 VCLXScrollBar::getMinimum() throw(::com::sun::star::uno::RuntimeException) 3142cdf0e10cSrcweir { 3143cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3144cdf0e10cSrcweir 3145cdf0e10cSrcweir ScrollBar* pScrollBar = static_cast< ScrollBar* >( GetWindow() ); 3146cdf0e10cSrcweir return pScrollBar ? pScrollBar->GetRangeMin() : 0; 3147cdf0e10cSrcweir } 3148cdf0e10cSrcweir 3149cdf0e10cSrcweir void VCLXScrollBar::setLineIncrement( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException) 3150cdf0e10cSrcweir { 3151cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3152cdf0e10cSrcweir 3153cdf0e10cSrcweir ScrollBar* pScrollBar = (ScrollBar*) GetWindow(); 3154cdf0e10cSrcweir if ( pScrollBar ) 3155cdf0e10cSrcweir pScrollBar->SetLineSize( n ); 3156cdf0e10cSrcweir } 3157cdf0e10cSrcweir 3158cdf0e10cSrcweir sal_Int32 VCLXScrollBar::getLineIncrement() throw(::com::sun::star::uno::RuntimeException) 3159cdf0e10cSrcweir { 3160cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3161cdf0e10cSrcweir 3162cdf0e10cSrcweir ScrollBar* pScrollBar = (ScrollBar*) GetWindow(); 3163cdf0e10cSrcweir return pScrollBar ? pScrollBar->GetLineSize() : 0; 3164cdf0e10cSrcweir } 3165cdf0e10cSrcweir 3166cdf0e10cSrcweir void VCLXScrollBar::setBlockIncrement( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException) 3167cdf0e10cSrcweir { 3168cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3169cdf0e10cSrcweir 3170cdf0e10cSrcweir ScrollBar* pScrollBar = (ScrollBar*) GetWindow(); 3171cdf0e10cSrcweir if ( pScrollBar ) 3172cdf0e10cSrcweir pScrollBar->SetPageSize( n ); 3173cdf0e10cSrcweir } 3174cdf0e10cSrcweir 3175cdf0e10cSrcweir sal_Int32 VCLXScrollBar::getBlockIncrement() throw(::com::sun::star::uno::RuntimeException) 3176cdf0e10cSrcweir { 3177cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3178cdf0e10cSrcweir 3179cdf0e10cSrcweir ScrollBar* pScrollBar = (ScrollBar*) GetWindow(); 3180cdf0e10cSrcweir return pScrollBar ? pScrollBar->GetPageSize() : 0; 3181cdf0e10cSrcweir } 3182cdf0e10cSrcweir 3183cdf0e10cSrcweir void VCLXScrollBar::setVisibleSize( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException) 3184cdf0e10cSrcweir { 3185cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3186cdf0e10cSrcweir 3187cdf0e10cSrcweir ScrollBar* pScrollBar = (ScrollBar*) GetWindow(); 3188cdf0e10cSrcweir if ( pScrollBar ) 3189cdf0e10cSrcweir pScrollBar->SetVisibleSize( n ); 3190cdf0e10cSrcweir } 3191cdf0e10cSrcweir 3192cdf0e10cSrcweir sal_Int32 VCLXScrollBar::getVisibleSize() throw(::com::sun::star::uno::RuntimeException) 3193cdf0e10cSrcweir { 3194cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3195cdf0e10cSrcweir 3196cdf0e10cSrcweir ScrollBar* pScrollBar = (ScrollBar*) GetWindow(); 3197cdf0e10cSrcweir return pScrollBar ? pScrollBar->GetVisibleSize() : 0; 3198cdf0e10cSrcweir } 3199cdf0e10cSrcweir 3200cdf0e10cSrcweir void VCLXScrollBar::setOrientation( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException) 3201cdf0e10cSrcweir { 3202cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3203cdf0e10cSrcweir 3204cdf0e10cSrcweir Window* pWindow = GetWindow(); 3205cdf0e10cSrcweir if ( pWindow ) 3206cdf0e10cSrcweir { 3207cdf0e10cSrcweir WinBits nStyle = pWindow->GetStyle(); 3208cdf0e10cSrcweir nStyle &= ~(WB_HORZ|WB_VERT); 3209cdf0e10cSrcweir if ( n == ::com::sun::star::awt::ScrollBarOrientation::HORIZONTAL ) 3210cdf0e10cSrcweir nStyle |= WB_HORZ; 3211cdf0e10cSrcweir else 3212cdf0e10cSrcweir nStyle |= WB_VERT; 3213cdf0e10cSrcweir 3214cdf0e10cSrcweir pWindow->SetStyle( nStyle ); 3215cdf0e10cSrcweir pWindow->Resize(); 3216cdf0e10cSrcweir } 3217cdf0e10cSrcweir } 3218cdf0e10cSrcweir 3219cdf0e10cSrcweir sal_Int32 VCLXScrollBar::getOrientation() throw(::com::sun::star::uno::RuntimeException) 3220cdf0e10cSrcweir { 3221cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3222cdf0e10cSrcweir 3223cdf0e10cSrcweir sal_Int32 n = 0; 3224cdf0e10cSrcweir Window* pWindow = GetWindow(); 3225cdf0e10cSrcweir if ( pWindow ) 3226cdf0e10cSrcweir { 3227cdf0e10cSrcweir WinBits nStyle = pWindow->GetStyle(); 3228cdf0e10cSrcweir if ( nStyle & WB_HORZ ) 3229cdf0e10cSrcweir n = ::com::sun::star::awt::ScrollBarOrientation::HORIZONTAL; 3230cdf0e10cSrcweir else 3231cdf0e10cSrcweir n = ::com::sun::star::awt::ScrollBarOrientation::VERTICAL; 3232cdf0e10cSrcweir } 3233cdf0e10cSrcweir return n; 3234cdf0e10cSrcweir 3235cdf0e10cSrcweir } 3236cdf0e10cSrcweir 3237cdf0e10cSrcweir // ::com::sun::star::awt::VclWindowPeer 3238cdf0e10cSrcweir void VCLXScrollBar::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 3239cdf0e10cSrcweir { 3240cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3241cdf0e10cSrcweir 3242cdf0e10cSrcweir ScrollBar* pScrollBar = (ScrollBar*)GetWindow(); 3243cdf0e10cSrcweir if ( pScrollBar ) 3244cdf0e10cSrcweir { 3245cdf0e10cSrcweir sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID; 3246cdf0e10cSrcweir 3247cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 3248cdf0e10cSrcweir switch ( nPropType ) 3249cdf0e10cSrcweir { 3250cdf0e10cSrcweir case BASEPROPERTY_LIVE_SCROLL: 3251cdf0e10cSrcweir { 3252cdf0e10cSrcweir sal_Bool bDo = sal_False; 3253cdf0e10cSrcweir if ( !bVoid ) 3254cdf0e10cSrcweir { 3255cdf0e10cSrcweir OSL_VERIFY( Value >>= bDo ); 3256cdf0e10cSrcweir } 3257cdf0e10cSrcweir AllSettings aSettings( pScrollBar->GetSettings() ); 3258cdf0e10cSrcweir StyleSettings aStyle( aSettings.GetStyleSettings() ); 3259cdf0e10cSrcweir sal_uLong nDragOptions = aStyle.GetDragFullOptions(); 3260cdf0e10cSrcweir if ( bDo ) 3261cdf0e10cSrcweir nDragOptions |= DRAGFULL_OPTION_SCROLL; 3262cdf0e10cSrcweir else 3263cdf0e10cSrcweir nDragOptions &= ~DRAGFULL_OPTION_SCROLL; 3264cdf0e10cSrcweir aStyle.SetDragFullOptions( nDragOptions ); 3265cdf0e10cSrcweir aSettings.SetStyleSettings( aStyle ); 3266cdf0e10cSrcweir pScrollBar->SetSettings( aSettings ); 3267cdf0e10cSrcweir } 3268cdf0e10cSrcweir break; 3269cdf0e10cSrcweir 3270cdf0e10cSrcweir case BASEPROPERTY_SCROLLVALUE: 3271cdf0e10cSrcweir { 3272cdf0e10cSrcweir if ( !bVoid ) 3273cdf0e10cSrcweir { 3274cdf0e10cSrcweir sal_Int32 n = 0; 3275cdf0e10cSrcweir if ( Value >>= n ) 3276cdf0e10cSrcweir setValue( n ); 3277cdf0e10cSrcweir } 3278cdf0e10cSrcweir } 3279cdf0e10cSrcweir break; 3280cdf0e10cSrcweir case BASEPROPERTY_SCROLLVALUE_MAX: 3281cdf0e10cSrcweir case BASEPROPERTY_SCROLLVALUE_MIN: 3282cdf0e10cSrcweir { 3283cdf0e10cSrcweir if ( !bVoid ) 3284cdf0e10cSrcweir { 3285cdf0e10cSrcweir sal_Int32 n = 0; 3286cdf0e10cSrcweir if ( Value >>= n ) 3287cdf0e10cSrcweir { 3288cdf0e10cSrcweir if ( nPropType == BASEPROPERTY_SCROLLVALUE_MAX ) 3289cdf0e10cSrcweir setMaximum( n ); 3290cdf0e10cSrcweir else 3291cdf0e10cSrcweir setMinimum( n ); 3292cdf0e10cSrcweir } 3293cdf0e10cSrcweir } 3294cdf0e10cSrcweir } 3295cdf0e10cSrcweir break; 3296cdf0e10cSrcweir case BASEPROPERTY_LINEINCREMENT: 3297cdf0e10cSrcweir { 3298cdf0e10cSrcweir if ( !bVoid ) 3299cdf0e10cSrcweir { 3300cdf0e10cSrcweir sal_Int32 n = 0; 3301cdf0e10cSrcweir if ( Value >>= n ) 3302cdf0e10cSrcweir setLineIncrement( n ); 3303cdf0e10cSrcweir } 3304cdf0e10cSrcweir } 3305cdf0e10cSrcweir break; 3306cdf0e10cSrcweir case BASEPROPERTY_BLOCKINCREMENT: 3307cdf0e10cSrcweir { 3308cdf0e10cSrcweir if ( !bVoid ) 3309cdf0e10cSrcweir { 3310cdf0e10cSrcweir sal_Int32 n = 0; 3311cdf0e10cSrcweir if ( Value >>= n ) 3312cdf0e10cSrcweir setBlockIncrement( n ); 3313cdf0e10cSrcweir } 3314cdf0e10cSrcweir } 3315cdf0e10cSrcweir break; 3316cdf0e10cSrcweir case BASEPROPERTY_VISIBLESIZE: 3317cdf0e10cSrcweir { 3318cdf0e10cSrcweir if ( !bVoid ) 3319cdf0e10cSrcweir { 3320cdf0e10cSrcweir sal_Int32 n = 0; 3321cdf0e10cSrcweir if ( Value >>= n ) 3322cdf0e10cSrcweir setVisibleSize( n ); 3323cdf0e10cSrcweir } 3324cdf0e10cSrcweir } 3325cdf0e10cSrcweir break; 3326cdf0e10cSrcweir case BASEPROPERTY_ORIENTATION: 3327cdf0e10cSrcweir { 3328cdf0e10cSrcweir if ( !bVoid ) 3329cdf0e10cSrcweir { 3330cdf0e10cSrcweir sal_Int32 n = 0; 3331cdf0e10cSrcweir if ( Value >>= n ) 3332cdf0e10cSrcweir setOrientation( n ); 3333cdf0e10cSrcweir } 3334cdf0e10cSrcweir } 3335cdf0e10cSrcweir break; 3336cdf0e10cSrcweir 3337cdf0e10cSrcweir case BASEPROPERTY_BACKGROUNDCOLOR: 3338cdf0e10cSrcweir { 3339cdf0e10cSrcweir // the default implementation of the base class doesn't work here, since our 3340cdf0e10cSrcweir // interpretation for this property is slightly different 3341cdf0e10cSrcweir ::toolkit::setButtonLikeFaceColor( pScrollBar, Value); 3342cdf0e10cSrcweir } 3343cdf0e10cSrcweir break; 3344cdf0e10cSrcweir 3345cdf0e10cSrcweir default: 3346cdf0e10cSrcweir { 3347cdf0e10cSrcweir VCLXWindow::setProperty( PropertyName, Value ); 3348cdf0e10cSrcweir } 3349cdf0e10cSrcweir } 3350cdf0e10cSrcweir } 3351cdf0e10cSrcweir } 3352cdf0e10cSrcweir 3353cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXScrollBar::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) 3354cdf0e10cSrcweir { 3355cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3356cdf0e10cSrcweir 3357cdf0e10cSrcweir ::com::sun::star::uno::Any aProp; 3358cdf0e10cSrcweir ScrollBar* pScrollBar = (ScrollBar*)GetWindow(); 3359cdf0e10cSrcweir if ( pScrollBar ) 3360cdf0e10cSrcweir { 3361cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 3362cdf0e10cSrcweir 3363cdf0e10cSrcweir switch ( nPropType ) 3364cdf0e10cSrcweir { 3365cdf0e10cSrcweir case BASEPROPERTY_LIVE_SCROLL: 3366cdf0e10cSrcweir { 3367cdf0e10cSrcweir aProp <<= (sal_Bool)( 0 != ( pScrollBar->GetSettings().GetStyleSettings().GetDragFullOptions() & DRAGFULL_OPTION_SCROLL ) ); 3368cdf0e10cSrcweir } 3369cdf0e10cSrcweir break; 3370cdf0e10cSrcweir case BASEPROPERTY_SCROLLVALUE: 3371cdf0e10cSrcweir { 3372cdf0e10cSrcweir aProp <<= (sal_Int32) getValue(); 3373cdf0e10cSrcweir } 3374cdf0e10cSrcweir break; 3375cdf0e10cSrcweir case BASEPROPERTY_SCROLLVALUE_MAX: 3376cdf0e10cSrcweir { 3377cdf0e10cSrcweir aProp <<= (sal_Int32) getMaximum(); 3378cdf0e10cSrcweir } 3379cdf0e10cSrcweir break; 3380cdf0e10cSrcweir case BASEPROPERTY_SCROLLVALUE_MIN: 3381cdf0e10cSrcweir { 3382cdf0e10cSrcweir aProp <<= (sal_Int32) getMinimum(); 3383cdf0e10cSrcweir } 3384cdf0e10cSrcweir break; 3385cdf0e10cSrcweir case BASEPROPERTY_LINEINCREMENT: 3386cdf0e10cSrcweir { 3387cdf0e10cSrcweir aProp <<= (sal_Int32) getLineIncrement(); 3388cdf0e10cSrcweir } 3389cdf0e10cSrcweir break; 3390cdf0e10cSrcweir case BASEPROPERTY_BLOCKINCREMENT: 3391cdf0e10cSrcweir { 3392cdf0e10cSrcweir aProp <<= (sal_Int32) getBlockIncrement(); 3393cdf0e10cSrcweir } 3394cdf0e10cSrcweir break; 3395cdf0e10cSrcweir case BASEPROPERTY_VISIBLESIZE: 3396cdf0e10cSrcweir { 3397cdf0e10cSrcweir aProp <<= (sal_Int32) getVisibleSize(); 3398cdf0e10cSrcweir } 3399cdf0e10cSrcweir break; 3400cdf0e10cSrcweir case BASEPROPERTY_ORIENTATION: 3401cdf0e10cSrcweir { 3402cdf0e10cSrcweir aProp <<= (sal_Int32) getOrientation(); 3403cdf0e10cSrcweir } 3404cdf0e10cSrcweir break; 3405cdf0e10cSrcweir case BASEPROPERTY_BACKGROUNDCOLOR: 3406cdf0e10cSrcweir { 3407cdf0e10cSrcweir // the default implementation of the base class doesn't work here, since our 3408cdf0e10cSrcweir // interpretation for this property is slightly different 3409cdf0e10cSrcweir aProp = ::toolkit::getButtonLikeFaceColor( pScrollBar ); 3410cdf0e10cSrcweir } 3411cdf0e10cSrcweir break; 3412cdf0e10cSrcweir 3413cdf0e10cSrcweir default: 3414cdf0e10cSrcweir { 3415cdf0e10cSrcweir aProp <<= VCLXWindow::getProperty( PropertyName ); 3416cdf0e10cSrcweir } 3417cdf0e10cSrcweir } 3418cdf0e10cSrcweir } 3419cdf0e10cSrcweir return aProp; 3420cdf0e10cSrcweir } 3421cdf0e10cSrcweir 3422cdf0e10cSrcweir void VCLXScrollBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) 3423cdf0e10cSrcweir { 3424cdf0e10cSrcweir switch ( rVclWindowEvent.GetId() ) 3425cdf0e10cSrcweir { 3426cdf0e10cSrcweir case VCLEVENT_SCROLLBAR_SCROLL: 3427cdf0e10cSrcweir { 3428cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this ); 3429cdf0e10cSrcweir // since we call listeners below, there is a potential that we will be destroyed 3430cdf0e10cSrcweir // in during the listener call. To prevent the resulting crashs, we keep us 3431cdf0e10cSrcweir // alive as long as we're here 3432cdf0e10cSrcweir // #20178# - 2003-10-01 - fs@openoffice.org 3433cdf0e10cSrcweir 3434cdf0e10cSrcweir if ( maAdjustmentListeners.getLength() ) 3435cdf0e10cSrcweir { 3436cdf0e10cSrcweir ScrollBar* pScrollBar = (ScrollBar*)GetWindow(); 3437cdf0e10cSrcweir 3438cdf0e10cSrcweir if( pScrollBar ) 3439cdf0e10cSrcweir { 3440cdf0e10cSrcweir ::com::sun::star::awt::AdjustmentEvent aEvent; 3441cdf0e10cSrcweir aEvent.Source = (::cppu::OWeakObject*)this; 3442cdf0e10cSrcweir aEvent.Value = pScrollBar->GetThumbPos(); 3443cdf0e10cSrcweir 3444cdf0e10cSrcweir // set adjustment type 3445cdf0e10cSrcweir ScrollType aType = pScrollBar->GetType(); 3446cdf0e10cSrcweir if ( aType == SCROLL_LINEUP || aType == SCROLL_LINEDOWN ) 3447cdf0e10cSrcweir { 3448cdf0e10cSrcweir aEvent.Type = ::com::sun::star::awt::AdjustmentType_ADJUST_LINE; 3449cdf0e10cSrcweir } 3450cdf0e10cSrcweir else if ( aType == SCROLL_PAGEUP || aType == SCROLL_PAGEDOWN ) 3451cdf0e10cSrcweir { 3452cdf0e10cSrcweir aEvent.Type = ::com::sun::star::awt::AdjustmentType_ADJUST_PAGE; 3453cdf0e10cSrcweir } 3454cdf0e10cSrcweir else if ( aType == SCROLL_DRAG ) 3455cdf0e10cSrcweir { 3456cdf0e10cSrcweir aEvent.Type = ::com::sun::star::awt::AdjustmentType_ADJUST_ABS; 3457cdf0e10cSrcweir } 3458cdf0e10cSrcweir 3459cdf0e10cSrcweir maAdjustmentListeners.adjustmentValueChanged( aEvent ); 3460cdf0e10cSrcweir } 3461cdf0e10cSrcweir } 3462cdf0e10cSrcweir } 3463cdf0e10cSrcweir break; 3464cdf0e10cSrcweir 3465cdf0e10cSrcweir default: 3466cdf0e10cSrcweir VCLXWindow::ProcessWindowEvent( rVclWindowEvent ); 3467cdf0e10cSrcweir break; 3468cdf0e10cSrcweir } 3469cdf0e10cSrcweir } 3470cdf0e10cSrcweir 3471cdf0e10cSrcweir ::com::sun::star::awt::Size SAL_CALL VCLXScrollBar::implGetMinimumSize( Window* p ) throw(::com::sun::star::uno::RuntimeException) 3472cdf0e10cSrcweir { 3473cdf0e10cSrcweir long n = p->GetSettings().GetStyleSettings().GetScrollBarSize(); 3474cdf0e10cSrcweir return ::com::sun::star::awt::Size( n, n ); 3475cdf0e10cSrcweir } 3476cdf0e10cSrcweir 3477cdf0e10cSrcweir ::com::sun::star::awt::Size SAL_CALL VCLXScrollBar::getMinimumSize() throw(::com::sun::star::uno::RuntimeException) 3478cdf0e10cSrcweir { 3479cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3480cdf0e10cSrcweir return implGetMinimumSize( GetWindow() ); 3481cdf0e10cSrcweir } 3482cdf0e10cSrcweir 3483cdf0e10cSrcweir 3484cdf0e10cSrcweir // ---------------------------------------------------- 3485cdf0e10cSrcweir // class VCLXEdit 3486cdf0e10cSrcweir // ---------------------------------------------------- 3487cdf0e10cSrcweir 3488cdf0e10cSrcweir void VCLXEdit::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 3489cdf0e10cSrcweir { 3490cdf0e10cSrcweir PushPropertyIds( rIds, 3491cdf0e10cSrcweir BASEPROPERTY_ALIGN, 3492cdf0e10cSrcweir BASEPROPERTY_BACKGROUNDCOLOR, 3493cdf0e10cSrcweir BASEPROPERTY_BORDER, 3494cdf0e10cSrcweir BASEPROPERTY_BORDERCOLOR, 3495cdf0e10cSrcweir BASEPROPERTY_DEFAULTCONTROL, 3496cdf0e10cSrcweir BASEPROPERTY_ECHOCHAR, 3497cdf0e10cSrcweir BASEPROPERTY_ENABLED, 3498cdf0e10cSrcweir BASEPROPERTY_ENABLEVISIBLE, 3499cdf0e10cSrcweir BASEPROPERTY_FONTDESCRIPTOR, 3500cdf0e10cSrcweir BASEPROPERTY_HARDLINEBREAKS, 3501cdf0e10cSrcweir BASEPROPERTY_HELPTEXT, 3502cdf0e10cSrcweir BASEPROPERTY_HELPURL, 3503cdf0e10cSrcweir BASEPROPERTY_HSCROLL, 3504cdf0e10cSrcweir BASEPROPERTY_LINE_END_FORMAT, 3505cdf0e10cSrcweir BASEPROPERTY_MAXTEXTLEN, 3506cdf0e10cSrcweir BASEPROPERTY_MULTILINE, 3507cdf0e10cSrcweir BASEPROPERTY_PRINTABLE, 3508cdf0e10cSrcweir BASEPROPERTY_READONLY, 3509cdf0e10cSrcweir BASEPROPERTY_TABSTOP, 3510cdf0e10cSrcweir BASEPROPERTY_TEXT, 3511cdf0e10cSrcweir BASEPROPERTY_VSCROLL, 3512cdf0e10cSrcweir BASEPROPERTY_HIDEINACTIVESELECTION, 3513cdf0e10cSrcweir BASEPROPERTY_PAINTTRANSPARENT, 3514cdf0e10cSrcweir BASEPROPERTY_AUTOHSCROLL, 3515cdf0e10cSrcweir BASEPROPERTY_AUTOVSCROLL, 3516cdf0e10cSrcweir BASEPROPERTY_VERTICALALIGN, 3517cdf0e10cSrcweir BASEPROPERTY_WRITING_MODE, 3518cdf0e10cSrcweir BASEPROPERTY_CONTEXT_WRITING_MODE, 3519cdf0e10cSrcweir 0); 3520cdf0e10cSrcweir VCLXWindow::ImplGetPropertyIds( rIds ); 3521cdf0e10cSrcweir } 3522cdf0e10cSrcweir 3523cdf0e10cSrcweir VCLXEdit::VCLXEdit() : maTextListeners( *this ) 3524cdf0e10cSrcweir { 3525cdf0e10cSrcweir } 3526cdf0e10cSrcweir 3527cdf0e10cSrcweir // ::com::sun::star::uno::XInterface 3528cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXEdit::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 3529cdf0e10cSrcweir { 3530cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 3531cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XTextComponent*, this ), 3532cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XTextEditField*, this ), 3533cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XTextLayoutConstrains*, this ) ); 3534cdf0e10cSrcweir return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); 3535cdf0e10cSrcweir } 3536cdf0e10cSrcweir 3537cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 3538cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXEdit ) 3539cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent>* ) NULL ), 3540cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextEditField>* ) NULL ), 3541cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextLayoutConstrains>* ) NULL ), 3542cdf0e10cSrcweir VCLXWindow::getTypes() 3543cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 3544cdf0e10cSrcweir 3545cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXEdit::CreateAccessibleContext() 3546cdf0e10cSrcweir { 3547cdf0e10cSrcweir return getAccessibleFactory().createAccessibleContext( this ); 3548cdf0e10cSrcweir } 3549cdf0e10cSrcweir 3550cdf0e10cSrcweir void VCLXEdit::dispose() throw(::com::sun::star::uno::RuntimeException) 3551cdf0e10cSrcweir { 3552cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3553cdf0e10cSrcweir 3554cdf0e10cSrcweir ::com::sun::star::lang::EventObject aObj; 3555cdf0e10cSrcweir aObj.Source = (::cppu::OWeakObject*)this; 3556cdf0e10cSrcweir maTextListeners.disposeAndClear( aObj ); 3557cdf0e10cSrcweir VCLXWindow::dispose(); 3558cdf0e10cSrcweir } 3559cdf0e10cSrcweir 3560cdf0e10cSrcweir void VCLXEdit::addTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException) 3561cdf0e10cSrcweir { 3562cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3563cdf0e10cSrcweir GetTextListeners().addInterface( l ); 3564cdf0e10cSrcweir } 3565cdf0e10cSrcweir 3566cdf0e10cSrcweir void VCLXEdit::removeTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException) 3567cdf0e10cSrcweir { 3568cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3569cdf0e10cSrcweir GetTextListeners().removeInterface( l ); 3570cdf0e10cSrcweir } 3571cdf0e10cSrcweir 3572cdf0e10cSrcweir void VCLXEdit::setText( const ::rtl::OUString& aText ) throw(::com::sun::star::uno::RuntimeException) 3573cdf0e10cSrcweir { 3574cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3575cdf0e10cSrcweir 3576cdf0e10cSrcweir Edit* pEdit = (Edit*)GetWindow(); 3577cdf0e10cSrcweir if ( pEdit ) 3578cdf0e10cSrcweir { 3579cdf0e10cSrcweir pEdit->SetText( aText ); 3580cdf0e10cSrcweir 3581cdf0e10cSrcweir // #107218# Call same listeners like VCL would do after user interaction 3582cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_True ); 3583cdf0e10cSrcweir pEdit->SetModifyFlag(); 3584cdf0e10cSrcweir pEdit->Modify(); 3585cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_False ); 3586cdf0e10cSrcweir } 3587cdf0e10cSrcweir } 3588cdf0e10cSrcweir 3589cdf0e10cSrcweir void VCLXEdit::insertText( const ::com::sun::star::awt::Selection& rSel, const ::rtl::OUString& aText ) throw(::com::sun::star::uno::RuntimeException) 3590cdf0e10cSrcweir { 3591cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3592cdf0e10cSrcweir 3593cdf0e10cSrcweir Edit* pEdit = (Edit*)GetWindow(); 3594cdf0e10cSrcweir if ( pEdit ) 3595cdf0e10cSrcweir { 3596cdf0e10cSrcweir pEdit->SetSelection( Selection( rSel.Min, rSel.Max ) ); 3597cdf0e10cSrcweir pEdit->ReplaceSelected( aText ); 3598cdf0e10cSrcweir 3599cdf0e10cSrcweir // #107218# Call same listeners like VCL would do after user interaction 3600cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_True ); 3601cdf0e10cSrcweir pEdit->SetModifyFlag(); 3602cdf0e10cSrcweir pEdit->Modify(); 3603cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_False ); 3604cdf0e10cSrcweir } 3605cdf0e10cSrcweir } 3606cdf0e10cSrcweir 3607cdf0e10cSrcweir ::rtl::OUString VCLXEdit::getText() throw(::com::sun::star::uno::RuntimeException) 3608cdf0e10cSrcweir { 3609cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3610cdf0e10cSrcweir 3611cdf0e10cSrcweir ::rtl::OUString aText; 3612cdf0e10cSrcweir Window* pWindow = GetWindow(); 3613cdf0e10cSrcweir if ( pWindow ) 3614cdf0e10cSrcweir aText = pWindow->GetText(); 3615cdf0e10cSrcweir return aText; 3616cdf0e10cSrcweir } 3617cdf0e10cSrcweir 3618cdf0e10cSrcweir ::rtl::OUString VCLXEdit::getSelectedText() throw(::com::sun::star::uno::RuntimeException) 3619cdf0e10cSrcweir { 3620cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3621cdf0e10cSrcweir 3622cdf0e10cSrcweir ::rtl::OUString aText; 3623cdf0e10cSrcweir Edit* pEdit = (Edit*) GetWindow(); 3624cdf0e10cSrcweir if ( pEdit) 3625cdf0e10cSrcweir aText = pEdit->GetSelected(); 3626cdf0e10cSrcweir return aText; 3627cdf0e10cSrcweir 3628cdf0e10cSrcweir } 3629cdf0e10cSrcweir 3630cdf0e10cSrcweir void VCLXEdit::setSelection( const ::com::sun::star::awt::Selection& aSelection ) throw(::com::sun::star::uno::RuntimeException) 3631cdf0e10cSrcweir { 3632cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3633cdf0e10cSrcweir 3634cdf0e10cSrcweir Edit* pEdit = (Edit*) GetWindow(); 3635cdf0e10cSrcweir if ( pEdit ) 3636cdf0e10cSrcweir pEdit->SetSelection( Selection( aSelection.Min, aSelection.Max ) ); 3637cdf0e10cSrcweir } 3638cdf0e10cSrcweir 3639cdf0e10cSrcweir ::com::sun::star::awt::Selection VCLXEdit::getSelection() throw(::com::sun::star::uno::RuntimeException) 3640cdf0e10cSrcweir { 3641cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3642cdf0e10cSrcweir 3643cdf0e10cSrcweir Selection aSel; 3644cdf0e10cSrcweir Edit* pEdit = (Edit*) GetWindow(); 3645cdf0e10cSrcweir if ( pEdit ) 3646cdf0e10cSrcweir aSel = pEdit->GetSelection(); 3647cdf0e10cSrcweir return ::com::sun::star::awt::Selection( aSel.Min(), aSel.Max() ); 3648cdf0e10cSrcweir } 3649cdf0e10cSrcweir 3650cdf0e10cSrcweir sal_Bool VCLXEdit::isEditable() throw(::com::sun::star::uno::RuntimeException) 3651cdf0e10cSrcweir { 3652cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3653cdf0e10cSrcweir 3654cdf0e10cSrcweir Edit* pEdit = (Edit*) GetWindow(); 3655cdf0e10cSrcweir return ( pEdit && !pEdit->IsReadOnly() && pEdit->IsEnabled() ) ? sal_True : sal_False; 3656cdf0e10cSrcweir } 3657cdf0e10cSrcweir 3658cdf0e10cSrcweir void VCLXEdit::setEditable( sal_Bool bEditable ) throw(::com::sun::star::uno::RuntimeException) 3659cdf0e10cSrcweir { 3660cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3661cdf0e10cSrcweir 3662cdf0e10cSrcweir Edit* pEdit = (Edit*) GetWindow(); 3663cdf0e10cSrcweir if ( pEdit ) 3664cdf0e10cSrcweir pEdit->SetReadOnly( !bEditable ); 3665cdf0e10cSrcweir } 3666cdf0e10cSrcweir 3667cdf0e10cSrcweir 3668cdf0e10cSrcweir void VCLXEdit::setMaxTextLen( sal_Int16 nLen ) throw(::com::sun::star::uno::RuntimeException) 3669cdf0e10cSrcweir { 3670cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3671cdf0e10cSrcweir 3672cdf0e10cSrcweir Edit* pEdit = (Edit*) GetWindow(); 3673cdf0e10cSrcweir if ( pEdit ) 3674cdf0e10cSrcweir pEdit->SetMaxTextLen( nLen ); 3675cdf0e10cSrcweir } 3676cdf0e10cSrcweir 3677cdf0e10cSrcweir sal_Int16 VCLXEdit::getMaxTextLen() throw(::com::sun::star::uno::RuntimeException) 3678cdf0e10cSrcweir { 3679cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3680cdf0e10cSrcweir 3681cdf0e10cSrcweir Edit* pEdit = (Edit*) GetWindow(); 3682cdf0e10cSrcweir return pEdit ? pEdit->GetMaxTextLen() : 0; 3683cdf0e10cSrcweir } 3684cdf0e10cSrcweir 3685cdf0e10cSrcweir void VCLXEdit::setEchoChar( sal_Unicode cEcho ) throw(::com::sun::star::uno::RuntimeException) 3686cdf0e10cSrcweir { 3687cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3688cdf0e10cSrcweir 3689cdf0e10cSrcweir Edit* pEdit = (Edit*) GetWindow(); 3690cdf0e10cSrcweir if ( pEdit ) 3691cdf0e10cSrcweir pEdit->SetEchoChar( cEcho ); 3692cdf0e10cSrcweir } 3693cdf0e10cSrcweir 3694cdf0e10cSrcweir void VCLXEdit::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 3695cdf0e10cSrcweir { 3696cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3697cdf0e10cSrcweir 3698cdf0e10cSrcweir Edit* pEdit = (Edit*)GetWindow(); 3699cdf0e10cSrcweir if ( pEdit ) 3700cdf0e10cSrcweir { 3701cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 3702cdf0e10cSrcweir switch ( nPropType ) 3703cdf0e10cSrcweir { 3704cdf0e10cSrcweir case BASEPROPERTY_HIDEINACTIVESELECTION: 3705cdf0e10cSrcweir ::toolkit::adjustBooleanWindowStyle( Value, pEdit, WB_NOHIDESELECTION, sal_True ); 3706cdf0e10cSrcweir if ( pEdit->GetSubEdit() ) 3707cdf0e10cSrcweir ::toolkit::adjustBooleanWindowStyle( Value, pEdit->GetSubEdit(), WB_NOHIDESELECTION, sal_True ); 3708cdf0e10cSrcweir break; 3709cdf0e10cSrcweir 3710cdf0e10cSrcweir case BASEPROPERTY_READONLY: 3711cdf0e10cSrcweir { 3712cdf0e10cSrcweir sal_Bool b = sal_Bool(); 3713cdf0e10cSrcweir if ( Value >>= b ) 3714cdf0e10cSrcweir pEdit->SetReadOnly( b ); 3715cdf0e10cSrcweir } 3716cdf0e10cSrcweir break; 3717cdf0e10cSrcweir case BASEPROPERTY_ECHOCHAR: 3718cdf0e10cSrcweir { 3719cdf0e10cSrcweir sal_Int16 n = sal_Int16(); 3720cdf0e10cSrcweir if ( Value >>= n ) 3721cdf0e10cSrcweir pEdit->SetEchoChar( n ); 3722cdf0e10cSrcweir } 3723cdf0e10cSrcweir break; 3724cdf0e10cSrcweir case BASEPROPERTY_MAXTEXTLEN: 3725cdf0e10cSrcweir { 3726cdf0e10cSrcweir sal_Int16 n = sal_Int16(); 3727cdf0e10cSrcweir if ( Value >>= n ) 3728cdf0e10cSrcweir pEdit->SetMaxTextLen( n ); 3729cdf0e10cSrcweir } 3730cdf0e10cSrcweir break; 3731cdf0e10cSrcweir default: 3732cdf0e10cSrcweir { 3733cdf0e10cSrcweir VCLXWindow::setProperty( PropertyName, Value ); 3734cdf0e10cSrcweir } 3735cdf0e10cSrcweir } 3736cdf0e10cSrcweir } 3737cdf0e10cSrcweir } 3738cdf0e10cSrcweir 3739cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXEdit::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) 3740cdf0e10cSrcweir { 3741cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3742cdf0e10cSrcweir 3743cdf0e10cSrcweir ::com::sun::star::uno::Any aProp; 3744cdf0e10cSrcweir Edit* pEdit = (Edit*)GetWindow(); 3745cdf0e10cSrcweir if ( pEdit ) 3746cdf0e10cSrcweir { 3747cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 3748cdf0e10cSrcweir switch ( nPropType ) 3749cdf0e10cSrcweir { 3750cdf0e10cSrcweir case BASEPROPERTY_HIDEINACTIVESELECTION: 3751cdf0e10cSrcweir aProp <<= (sal_Bool)( ( pEdit->GetStyle() & WB_NOHIDESELECTION ) == 0 ); 3752cdf0e10cSrcweir break; 3753cdf0e10cSrcweir case BASEPROPERTY_READONLY: 3754cdf0e10cSrcweir aProp <<= (sal_Bool) pEdit->IsReadOnly(); 3755cdf0e10cSrcweir break; 3756cdf0e10cSrcweir case BASEPROPERTY_ECHOCHAR: 3757cdf0e10cSrcweir aProp <<= (sal_Int16) pEdit->GetEchoChar(); 3758cdf0e10cSrcweir break; 3759cdf0e10cSrcweir case BASEPROPERTY_MAXTEXTLEN: 3760cdf0e10cSrcweir aProp <<= (sal_Int16) pEdit->GetMaxTextLen(); 3761cdf0e10cSrcweir break; 3762cdf0e10cSrcweir default: 3763cdf0e10cSrcweir { 3764cdf0e10cSrcweir aProp = VCLXWindow::getProperty( PropertyName ); 3765cdf0e10cSrcweir } 3766cdf0e10cSrcweir } 3767cdf0e10cSrcweir } 3768cdf0e10cSrcweir return aProp; 3769cdf0e10cSrcweir } 3770cdf0e10cSrcweir 3771cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXEdit::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException) 3772cdf0e10cSrcweir { 3773cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3774cdf0e10cSrcweir 3775cdf0e10cSrcweir Size aSz; 3776cdf0e10cSrcweir Edit* pEdit = (Edit*) GetWindow(); 3777cdf0e10cSrcweir if ( pEdit ) 3778cdf0e10cSrcweir aSz = pEdit->CalcMinimumSize(); 3779cdf0e10cSrcweir return AWTSize(aSz); 3780cdf0e10cSrcweir } 3781cdf0e10cSrcweir 3782cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXEdit::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException) 3783cdf0e10cSrcweir { 3784cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3785cdf0e10cSrcweir 3786cdf0e10cSrcweir Size aSz; 3787cdf0e10cSrcweir Edit* pEdit = (Edit*) GetWindow(); 3788cdf0e10cSrcweir if ( pEdit ) 3789cdf0e10cSrcweir { 3790cdf0e10cSrcweir aSz = pEdit->CalcMinimumSize(); 3791cdf0e10cSrcweir aSz.Height() += 4; 3792cdf0e10cSrcweir } 3793cdf0e10cSrcweir return AWTSize(aSz); 3794cdf0e10cSrcweir } 3795cdf0e10cSrcweir 3796cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXEdit::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException) 3797cdf0e10cSrcweir { 3798cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3799cdf0e10cSrcweir 3800cdf0e10cSrcweir ::com::sun::star::awt::Size aSz = rNewSize; 3801cdf0e10cSrcweir ::com::sun::star::awt::Size aMinSz = getMinimumSize(); 3802cdf0e10cSrcweir if ( aSz.Height != aMinSz.Height ) 3803cdf0e10cSrcweir aSz.Height = aMinSz.Height; 3804cdf0e10cSrcweir 3805cdf0e10cSrcweir return aSz; 3806cdf0e10cSrcweir } 3807cdf0e10cSrcweir 3808cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXEdit::getMinimumSize( sal_Int16 nCols, sal_Int16 ) throw(::com::sun::star::uno::RuntimeException) 3809cdf0e10cSrcweir { 3810cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3811cdf0e10cSrcweir 3812cdf0e10cSrcweir Size aSz; 3813cdf0e10cSrcweir Edit* pEdit = (Edit*) GetWindow(); 3814cdf0e10cSrcweir if ( pEdit ) 3815cdf0e10cSrcweir { 3816cdf0e10cSrcweir if ( nCols ) 3817cdf0e10cSrcweir aSz = pEdit->CalcSize( nCols ); 3818cdf0e10cSrcweir else 3819cdf0e10cSrcweir aSz = pEdit->CalcMinimumSize(); 3820cdf0e10cSrcweir } 3821cdf0e10cSrcweir return AWTSize(aSz); 3822cdf0e10cSrcweir } 3823cdf0e10cSrcweir 3824cdf0e10cSrcweir void VCLXEdit::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException) 3825cdf0e10cSrcweir { 3826cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3827cdf0e10cSrcweir 3828cdf0e10cSrcweir nLines = 1; 3829cdf0e10cSrcweir nCols = 0; 3830cdf0e10cSrcweir Edit* pEdit = (Edit*) GetWindow(); 3831cdf0e10cSrcweir if ( pEdit ) 3832cdf0e10cSrcweir nCols = pEdit->GetMaxVisChars(); 3833cdf0e10cSrcweir } 3834cdf0e10cSrcweir 3835cdf0e10cSrcweir void VCLXEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) 3836cdf0e10cSrcweir { 3837cdf0e10cSrcweir switch ( rVclWindowEvent.GetId() ) 3838cdf0e10cSrcweir { 3839cdf0e10cSrcweir case VCLEVENT_EDIT_MODIFY: 3840cdf0e10cSrcweir { 3841cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this ); 3842cdf0e10cSrcweir // since we call listeners below, there is a potential that we will be destroyed 3843cdf0e10cSrcweir // during the listener call. To prevent the resulting crashs, we keep us 3844cdf0e10cSrcweir // alive as long as we're here 3845cdf0e10cSrcweir // #20178# - 2003-10-01 - fs@openoffice.org 3846cdf0e10cSrcweir 3847cdf0e10cSrcweir if ( GetTextListeners().getLength() ) 3848cdf0e10cSrcweir { 3849cdf0e10cSrcweir ::com::sun::star::awt::TextEvent aEvent; 3850cdf0e10cSrcweir aEvent.Source = (::cppu::OWeakObject*)this; 3851cdf0e10cSrcweir GetTextListeners().textChanged( aEvent ); 3852cdf0e10cSrcweir } 3853cdf0e10cSrcweir } 3854cdf0e10cSrcweir break; 3855cdf0e10cSrcweir 3856cdf0e10cSrcweir default: 3857cdf0e10cSrcweir VCLXWindow::ProcessWindowEvent( rVclWindowEvent ); 3858cdf0e10cSrcweir break; 3859cdf0e10cSrcweir } 3860cdf0e10cSrcweir } 3861cdf0e10cSrcweir 3862cdf0e10cSrcweir // ---------------------------------------------------- 3863cdf0e10cSrcweir // class VCLXComboBox 3864cdf0e10cSrcweir // ---------------------------------------------------- 3865cdf0e10cSrcweir 3866cdf0e10cSrcweir void VCLXComboBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 3867cdf0e10cSrcweir { 3868cdf0e10cSrcweir PushPropertyIds( rIds, 3869cdf0e10cSrcweir BASEPROPERTY_AUTOCOMPLETE, 3870cdf0e10cSrcweir BASEPROPERTY_BACKGROUNDCOLOR, 3871cdf0e10cSrcweir BASEPROPERTY_BORDER, 3872cdf0e10cSrcweir BASEPROPERTY_BORDERCOLOR, 3873cdf0e10cSrcweir BASEPROPERTY_DEFAULTCONTROL, 3874cdf0e10cSrcweir BASEPROPERTY_DROPDOWN, 3875cdf0e10cSrcweir BASEPROPERTY_ENABLED, 3876cdf0e10cSrcweir BASEPROPERTY_ENABLEVISIBLE, 3877cdf0e10cSrcweir BASEPROPERTY_FONTDESCRIPTOR, 3878cdf0e10cSrcweir BASEPROPERTY_HELPTEXT, 3879cdf0e10cSrcweir BASEPROPERTY_HELPURL, 3880cdf0e10cSrcweir BASEPROPERTY_LINECOUNT, 3881cdf0e10cSrcweir BASEPROPERTY_MAXTEXTLEN, 3882cdf0e10cSrcweir BASEPROPERTY_PRINTABLE, 3883cdf0e10cSrcweir BASEPROPERTY_READONLY, 3884cdf0e10cSrcweir BASEPROPERTY_STRINGITEMLIST, 3885cdf0e10cSrcweir BASEPROPERTY_TABSTOP, 3886cdf0e10cSrcweir BASEPROPERTY_TEXT, 3887cdf0e10cSrcweir BASEPROPERTY_HIDEINACTIVESELECTION, 3888cdf0e10cSrcweir BASEPROPERTY_ALIGN, 3889cdf0e10cSrcweir BASEPROPERTY_WRITING_MODE, 3890cdf0e10cSrcweir BASEPROPERTY_CONTEXT_WRITING_MODE, 3891cdf0e10cSrcweir BASEPROPERTY_REFERENCE_DEVICE, 3892cdf0e10cSrcweir BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, 3893cdf0e10cSrcweir 0); 3894cdf0e10cSrcweir // no, don't call VCLXEdit here - it has properties which we do *not* want to have at at combo box 3895cdf0e10cSrcweir // #i92690# / 2008-08-12 / frank.schoenheit@sun.com 3896cdf0e10cSrcweir // VCLXEdit::ImplGetPropertyIds( rIds ); 3897cdf0e10cSrcweir VCLXWindow::ImplGetPropertyIds( rIds ); 3898cdf0e10cSrcweir } 3899cdf0e10cSrcweir 3900cdf0e10cSrcweir VCLXComboBox::VCLXComboBox() 3901cdf0e10cSrcweir : maActionListeners( *this ), maItemListeners( *this ) 3902cdf0e10cSrcweir { 3903cdf0e10cSrcweir } 3904cdf0e10cSrcweir 3905cdf0e10cSrcweir VCLXComboBox::~VCLXComboBox() 3906cdf0e10cSrcweir { 3907cdf0e10cSrcweir #ifndef __SUNPRO_CC 3908cdf0e10cSrcweir OSL_TRACE ("%s", __FUNCTION__); 3909cdf0e10cSrcweir #endif 3910cdf0e10cSrcweir } 3911cdf0e10cSrcweir 3912cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXComboBox::CreateAccessibleContext() 3913cdf0e10cSrcweir { 3914cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3915cdf0e10cSrcweir 3916cdf0e10cSrcweir return getAccessibleFactory().createAccessibleContext( this ); 3917cdf0e10cSrcweir } 3918cdf0e10cSrcweir 3919cdf0e10cSrcweir void VCLXComboBox::dispose() throw(::com::sun::star::uno::RuntimeException) 3920cdf0e10cSrcweir { 3921cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3922cdf0e10cSrcweir 3923cdf0e10cSrcweir ::com::sun::star::lang::EventObject aObj; 3924cdf0e10cSrcweir aObj.Source = (::cppu::OWeakObject*)this; 3925cdf0e10cSrcweir maItemListeners.disposeAndClear( aObj ); 3926cdf0e10cSrcweir maActionListeners.disposeAndClear( aObj ); 3927cdf0e10cSrcweir VCLXEdit::dispose(); 3928cdf0e10cSrcweir } 3929cdf0e10cSrcweir 3930cdf0e10cSrcweir 3931cdf0e10cSrcweir void VCLXComboBox::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException) 3932cdf0e10cSrcweir { 3933cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3934cdf0e10cSrcweir maItemListeners.addInterface( l ); 3935cdf0e10cSrcweir } 3936cdf0e10cSrcweir 3937cdf0e10cSrcweir void VCLXComboBox::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException) 3938cdf0e10cSrcweir { 3939cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3940cdf0e10cSrcweir maItemListeners.removeInterface( l ); 3941cdf0e10cSrcweir } 3942cdf0e10cSrcweir 3943cdf0e10cSrcweir void VCLXComboBox::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException) 3944cdf0e10cSrcweir { 3945cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3946cdf0e10cSrcweir maActionListeners.addInterface( l ); 3947cdf0e10cSrcweir } 3948cdf0e10cSrcweir 3949cdf0e10cSrcweir void VCLXComboBox::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException) 3950cdf0e10cSrcweir { 3951cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3952cdf0e10cSrcweir maActionListeners.removeInterface( l ); 3953cdf0e10cSrcweir } 3954cdf0e10cSrcweir 3955cdf0e10cSrcweir void VCLXComboBox::addItem( const ::rtl::OUString& aItem, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException) 3956cdf0e10cSrcweir { 3957cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3958cdf0e10cSrcweir 3959cdf0e10cSrcweir ComboBox* pBox = (ComboBox*) GetWindow(); 3960cdf0e10cSrcweir if ( pBox ) 3961cdf0e10cSrcweir pBox->InsertEntry( aItem, nPos ); 3962cdf0e10cSrcweir } 3963cdf0e10cSrcweir 3964cdf0e10cSrcweir void VCLXComboBox::addItems( const ::com::sun::star::uno::Sequence< ::rtl::OUString>& aItems, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException) 3965cdf0e10cSrcweir { 3966cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3967cdf0e10cSrcweir 3968cdf0e10cSrcweir ComboBox* pBox = (ComboBox*) GetWindow(); 3969cdf0e10cSrcweir if ( pBox ) 3970cdf0e10cSrcweir { 3971cdf0e10cSrcweir sal_uInt16 nP = nPos; 3972cdf0e10cSrcweir for ( sal_uInt16 n = 0; n < aItems.getLength(); n++ ) 3973cdf0e10cSrcweir { 3974cdf0e10cSrcweir pBox->InsertEntry( aItems.getConstArray()[n], nP ); 3975cdf0e10cSrcweir if ( nP == 0xFFFF ) 3976cdf0e10cSrcweir { 3977cdf0e10cSrcweir OSL_ENSURE( false, "VCLXComboBox::addItems: too many entries!" ); 3978cdf0e10cSrcweir // skip remaining entries, list cannot hold them, anyway 3979cdf0e10cSrcweir break; 3980cdf0e10cSrcweir } 3981cdf0e10cSrcweir } 3982cdf0e10cSrcweir } 3983cdf0e10cSrcweir } 3984cdf0e10cSrcweir 3985cdf0e10cSrcweir void VCLXComboBox::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(::com::sun::star::uno::RuntimeException) 3986cdf0e10cSrcweir { 3987cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 3988cdf0e10cSrcweir 3989cdf0e10cSrcweir ComboBox* pBox = (ComboBox*) GetWindow(); 3990cdf0e10cSrcweir if ( pBox ) 3991cdf0e10cSrcweir { 3992cdf0e10cSrcweir for ( sal_uInt16 n = nCount; n; ) 3993cdf0e10cSrcweir pBox->RemoveEntry( nPos + (--n) ); 3994cdf0e10cSrcweir } 3995cdf0e10cSrcweir } 3996cdf0e10cSrcweir 3997cdf0e10cSrcweir sal_Int16 VCLXComboBox::getItemCount() throw(::com::sun::star::uno::RuntimeException) 3998cdf0e10cSrcweir { 3999cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4000cdf0e10cSrcweir 4001cdf0e10cSrcweir ComboBox* pBox = (ComboBox*) GetWindow(); 4002cdf0e10cSrcweir return pBox ? pBox->GetEntryCount() : 0; 4003cdf0e10cSrcweir } 4004cdf0e10cSrcweir 4005cdf0e10cSrcweir ::rtl::OUString VCLXComboBox::getItem( sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException) 4006cdf0e10cSrcweir { 4007cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4008cdf0e10cSrcweir 4009cdf0e10cSrcweir ::rtl::OUString aItem; 4010cdf0e10cSrcweir ComboBox* pBox = (ComboBox*) GetWindow(); 4011cdf0e10cSrcweir if ( pBox ) 4012cdf0e10cSrcweir aItem = pBox->GetEntry( nPos ); 4013cdf0e10cSrcweir return aItem; 4014cdf0e10cSrcweir } 4015cdf0e10cSrcweir 4016cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString> VCLXComboBox::getItems() throw(::com::sun::star::uno::RuntimeException) 4017cdf0e10cSrcweir { 4018cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4019cdf0e10cSrcweir 4020cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq; 4021cdf0e10cSrcweir ComboBox* pBox = (ComboBox*) GetWindow(); 4022cdf0e10cSrcweir if ( pBox ) 4023cdf0e10cSrcweir { 4024cdf0e10cSrcweir sal_uInt16 nEntries = pBox->GetEntryCount(); 4025cdf0e10cSrcweir aSeq = ::com::sun::star::uno::Sequence< ::rtl::OUString>( nEntries ); 4026cdf0e10cSrcweir for ( sal_uInt16 n = nEntries; n; ) 4027cdf0e10cSrcweir { 4028cdf0e10cSrcweir --n; 4029cdf0e10cSrcweir aSeq.getArray()[n] = pBox->GetEntry( n ); 4030cdf0e10cSrcweir } 4031cdf0e10cSrcweir } 4032cdf0e10cSrcweir return aSeq; 4033cdf0e10cSrcweir } 4034cdf0e10cSrcweir 4035cdf0e10cSrcweir void VCLXComboBox::setDropDownLineCount( sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException) 4036cdf0e10cSrcweir { 4037cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4038cdf0e10cSrcweir 4039cdf0e10cSrcweir ComboBox* pBox = (ComboBox*) GetWindow(); 4040cdf0e10cSrcweir if ( pBox ) 4041cdf0e10cSrcweir pBox->SetDropDownLineCount( nLines ); 4042cdf0e10cSrcweir } 4043cdf0e10cSrcweir 4044cdf0e10cSrcweir sal_Int16 VCLXComboBox::getDropDownLineCount() throw(::com::sun::star::uno::RuntimeException) 4045cdf0e10cSrcweir { 4046cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4047cdf0e10cSrcweir 4048cdf0e10cSrcweir sal_Int16 nLines = 0; 4049cdf0e10cSrcweir ComboBox* pBox = (ComboBox*) GetWindow(); 4050cdf0e10cSrcweir if ( pBox ) 4051cdf0e10cSrcweir nLines = pBox->GetDropDownLineCount(); 4052cdf0e10cSrcweir return nLines; 4053cdf0e10cSrcweir } 4054cdf0e10cSrcweir 4055cdf0e10cSrcweir void VCLXComboBox::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 4056cdf0e10cSrcweir { 4057cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4058cdf0e10cSrcweir 4059cdf0e10cSrcweir ComboBox* pComboBox = (ComboBox*)GetWindow(); 4060cdf0e10cSrcweir if ( pComboBox ) 4061cdf0e10cSrcweir { 4062cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 4063cdf0e10cSrcweir switch ( nPropType ) 4064cdf0e10cSrcweir { 4065cdf0e10cSrcweir case BASEPROPERTY_LINECOUNT: 4066cdf0e10cSrcweir { 4067cdf0e10cSrcweir sal_Int16 n = sal_Int16(); 4068cdf0e10cSrcweir if ( Value >>= n ) 4069cdf0e10cSrcweir pComboBox->SetDropDownLineCount( n ); 4070cdf0e10cSrcweir } 4071cdf0e10cSrcweir break; 4072cdf0e10cSrcweir case BASEPROPERTY_AUTOCOMPLETE: 4073cdf0e10cSrcweir { 4074cdf0e10cSrcweir sal_Int16 n = sal_Int16(); 4075cdf0e10cSrcweir if ( Value >>= n ) 4076cdf0e10cSrcweir pComboBox->EnableAutocomplete( n != 0 ); 4077cdf0e10cSrcweir } 4078cdf0e10cSrcweir break; 4079cdf0e10cSrcweir case BASEPROPERTY_STRINGITEMLIST: 4080cdf0e10cSrcweir { 4081cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString> aItems; 4082cdf0e10cSrcweir if ( Value >>= aItems ) 4083cdf0e10cSrcweir { 4084cdf0e10cSrcweir pComboBox->Clear(); 4085cdf0e10cSrcweir addItems( aItems, 0 ); 4086cdf0e10cSrcweir } 4087cdf0e10cSrcweir } 4088cdf0e10cSrcweir break; 4089cdf0e10cSrcweir default: 4090cdf0e10cSrcweir { 4091cdf0e10cSrcweir VCLXEdit::setProperty( PropertyName, Value ); 4092cdf0e10cSrcweir 4093cdf0e10cSrcweir // #109385# SetBorderStyle is not virtual 4094cdf0e10cSrcweir if ( nPropType == BASEPROPERTY_BORDER ) 4095cdf0e10cSrcweir { 4096cdf0e10cSrcweir sal_uInt16 nBorder = sal_uInt16(); 4097cdf0e10cSrcweir if ( (Value >>= nBorder) && nBorder != 0 ) 4098cdf0e10cSrcweir pComboBox->SetBorderStyle( nBorder ); 4099cdf0e10cSrcweir } 4100cdf0e10cSrcweir } 4101cdf0e10cSrcweir } 4102cdf0e10cSrcweir } 4103cdf0e10cSrcweir } 4104cdf0e10cSrcweir 4105cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXComboBox::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) 4106cdf0e10cSrcweir { 4107cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4108cdf0e10cSrcweir 4109cdf0e10cSrcweir ::com::sun::star::uno::Any aProp; 4110cdf0e10cSrcweir ComboBox* pComboBox = (ComboBox*)GetWindow(); 4111cdf0e10cSrcweir if ( pComboBox ) 4112cdf0e10cSrcweir { 4113cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 4114cdf0e10cSrcweir switch ( nPropType ) 4115cdf0e10cSrcweir { 4116cdf0e10cSrcweir case BASEPROPERTY_LINECOUNT: 4117cdf0e10cSrcweir { 4118cdf0e10cSrcweir aProp <<= (sal_Int16) pComboBox->GetDropDownLineCount(); 4119cdf0e10cSrcweir } 4120cdf0e10cSrcweir break; 4121cdf0e10cSrcweir case BASEPROPERTY_AUTOCOMPLETE: 4122cdf0e10cSrcweir { 4123cdf0e10cSrcweir aProp <<= (sal_Bool) pComboBox->IsAutocompleteEnabled(); 4124cdf0e10cSrcweir } 4125cdf0e10cSrcweir break; 4126cdf0e10cSrcweir case BASEPROPERTY_STRINGITEMLIST: 4127cdf0e10cSrcweir { 4128cdf0e10cSrcweir sal_uInt16 nItems = pComboBox->GetEntryCount(); 4129cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq( nItems ); 4130cdf0e10cSrcweir ::rtl::OUString* pStrings = aSeq.getArray(); 4131cdf0e10cSrcweir for ( sal_uInt16 n = 0; n < nItems; n++ ) 4132cdf0e10cSrcweir pStrings[n] = pComboBox->GetEntry( n ); 4133cdf0e10cSrcweir aProp <<= aSeq; 4134cdf0e10cSrcweir 4135cdf0e10cSrcweir } 4136cdf0e10cSrcweir break; 4137cdf0e10cSrcweir default: 4138cdf0e10cSrcweir { 4139cdf0e10cSrcweir aProp <<= VCLXEdit::getProperty( PropertyName ); 4140cdf0e10cSrcweir } 4141cdf0e10cSrcweir } 4142cdf0e10cSrcweir } 4143cdf0e10cSrcweir return aProp; 4144cdf0e10cSrcweir } 4145cdf0e10cSrcweir 4146cdf0e10cSrcweir void VCLXComboBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) 4147cdf0e10cSrcweir { 4148cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this ); 4149cdf0e10cSrcweir // since we call listeners below, there is a potential that we will be destroyed 4150cdf0e10cSrcweir // during the listener call. To prevent the resulting crashs, we keep us 4151cdf0e10cSrcweir // alive as long as we're here 4152cdf0e10cSrcweir // #20178# - 2003-10-01 - fs@openoffice.org 4153cdf0e10cSrcweir 4154cdf0e10cSrcweir switch ( rVclWindowEvent.GetId() ) 4155cdf0e10cSrcweir { 4156cdf0e10cSrcweir case VCLEVENT_COMBOBOX_SELECT: 4157cdf0e10cSrcweir if ( maItemListeners.getLength() ) 4158cdf0e10cSrcweir { 4159cdf0e10cSrcweir ComboBox* pComboBox = (ComboBox*)GetWindow(); 4160cdf0e10cSrcweir if( pComboBox ) 4161cdf0e10cSrcweir { 4162cdf0e10cSrcweir if ( !pComboBox->IsTravelSelect() ) 4163cdf0e10cSrcweir { 4164cdf0e10cSrcweir ::com::sun::star::awt::ItemEvent aEvent; 4165cdf0e10cSrcweir aEvent.Source = (::cppu::OWeakObject*)this; 4166cdf0e10cSrcweir aEvent.Highlighted = sal_False; 4167cdf0e10cSrcweir 4168cdf0e10cSrcweir // Bei Mehrfachselektion 0xFFFF, sonst die ID 4169cdf0e10cSrcweir aEvent.Selected = pComboBox->GetEntryPos( pComboBox->GetText() ); 4170cdf0e10cSrcweir 4171cdf0e10cSrcweir maItemListeners.itemStateChanged( aEvent ); 4172cdf0e10cSrcweir } 4173cdf0e10cSrcweir } 4174cdf0e10cSrcweir } 4175cdf0e10cSrcweir break; 4176cdf0e10cSrcweir 4177cdf0e10cSrcweir case VCLEVENT_COMBOBOX_DOUBLECLICK: 4178cdf0e10cSrcweir if ( maActionListeners.getLength() ) 4179cdf0e10cSrcweir { 4180cdf0e10cSrcweir ::com::sun::star::awt::ActionEvent aEvent; 4181cdf0e10cSrcweir aEvent.Source = (::cppu::OWeakObject*)this; 4182cdf0e10cSrcweir // aEvent.ActionCommand = ...; 4183cdf0e10cSrcweir maActionListeners.actionPerformed( aEvent ); 4184cdf0e10cSrcweir } 4185cdf0e10cSrcweir break; 4186cdf0e10cSrcweir 4187cdf0e10cSrcweir default: 4188cdf0e10cSrcweir VCLXEdit::ProcessWindowEvent( rVclWindowEvent ); 4189cdf0e10cSrcweir break; 4190cdf0e10cSrcweir } 4191cdf0e10cSrcweir } 4192cdf0e10cSrcweir 4193cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXComboBox::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException) 4194cdf0e10cSrcweir { 4195cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4196cdf0e10cSrcweir 4197cdf0e10cSrcweir Size aSz; 4198cdf0e10cSrcweir ComboBox* pComboBox = (ComboBox*) GetWindow(); 4199cdf0e10cSrcweir if ( pComboBox ) 4200cdf0e10cSrcweir aSz = pComboBox->CalcMinimumSize(); 4201cdf0e10cSrcweir return AWTSize(aSz); 4202cdf0e10cSrcweir } 4203cdf0e10cSrcweir 4204cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXComboBox::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException) 4205cdf0e10cSrcweir { 4206cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4207cdf0e10cSrcweir 4208cdf0e10cSrcweir Size aSz; 4209cdf0e10cSrcweir ComboBox* pComboBox = (ComboBox*) GetWindow(); 4210cdf0e10cSrcweir if ( pComboBox ) 4211cdf0e10cSrcweir { 4212cdf0e10cSrcweir aSz = pComboBox->CalcMinimumSize(); 4213cdf0e10cSrcweir if ( pComboBox->GetStyle() & WB_DROPDOWN ) 4214cdf0e10cSrcweir aSz.Height() += 4; 4215cdf0e10cSrcweir } 4216cdf0e10cSrcweir return AWTSize(aSz); 4217cdf0e10cSrcweir } 4218cdf0e10cSrcweir 4219cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXComboBox::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException) 4220cdf0e10cSrcweir { 4221cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4222cdf0e10cSrcweir 4223cdf0e10cSrcweir Size aSz = VCLSize(rNewSize); 4224cdf0e10cSrcweir ComboBox* pComboBox = (ComboBox*) GetWindow(); 4225cdf0e10cSrcweir if ( pComboBox ) 4226cdf0e10cSrcweir aSz = pComboBox->CalcAdjustedSize( aSz ); 4227cdf0e10cSrcweir return AWTSize(aSz); 4228cdf0e10cSrcweir } 4229cdf0e10cSrcweir 4230cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXComboBox::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException) 4231cdf0e10cSrcweir { 4232cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4233cdf0e10cSrcweir 4234cdf0e10cSrcweir Size aSz; 4235cdf0e10cSrcweir ComboBox* pComboBox = (ComboBox*) GetWindow(); 4236cdf0e10cSrcweir if ( pComboBox ) 4237cdf0e10cSrcweir aSz = pComboBox->CalcSize( nCols, nLines ); 4238cdf0e10cSrcweir return AWTSize(aSz); 4239cdf0e10cSrcweir } 4240cdf0e10cSrcweir 4241cdf0e10cSrcweir void VCLXComboBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException) 4242cdf0e10cSrcweir { 4243cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4244cdf0e10cSrcweir 4245cdf0e10cSrcweir nCols = nLines = 0; 4246cdf0e10cSrcweir ComboBox* pComboBox = (ComboBox*) GetWindow(); 4247cdf0e10cSrcweir if ( pComboBox ) 4248cdf0e10cSrcweir { 4249cdf0e10cSrcweir sal_uInt16 nC, nL; 4250cdf0e10cSrcweir pComboBox->GetMaxVisColumnsAndLines( nC, nL ); 4251cdf0e10cSrcweir nCols = nC; 4252cdf0e10cSrcweir nLines = nL; 4253cdf0e10cSrcweir } 4254cdf0e10cSrcweir } 4255cdf0e10cSrcweir void SAL_CALL VCLXComboBox::listItemInserted( const ItemListEvent& i_rEvent ) throw (RuntimeException) 4256cdf0e10cSrcweir { 4257cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4258cdf0e10cSrcweir 4259cdf0e10cSrcweir ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() ); 4260cdf0e10cSrcweir 4261cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemInserted: no ComboBox?!" ); 4262cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= sal_Int32( pComboBox->GetEntryCount() ) ), 4263cdf0e10cSrcweir "VCLXComboBox::listItemInserted: illegal (inconsistent) item position!" ); 4264cdf0e10cSrcweir pComboBox->InsertEntry( 4265cdf0e10cSrcweir i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : ::rtl::OUString(), 4266cdf0e10cSrcweir i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(), 4267cdf0e10cSrcweir i_rEvent.ItemPosition ); 4268cdf0e10cSrcweir } 4269cdf0e10cSrcweir 4270cdf0e10cSrcweir void SAL_CALL VCLXComboBox::listItemRemoved( const ItemListEvent& i_rEvent ) throw (RuntimeException) 4271cdf0e10cSrcweir { 4272cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4273cdf0e10cSrcweir 4274cdf0e10cSrcweir ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() ); 4275cdf0e10cSrcweir 4276cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemRemoved: no ComboBox?!" ); 4277cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pComboBox->GetEntryCount() ) ), 4278cdf0e10cSrcweir "VCLXComboBox::listItemRemoved: illegal (inconsistent) item position!" ); 4279cdf0e10cSrcweir 4280cdf0e10cSrcweir pComboBox->RemoveEntry( i_rEvent.ItemPosition ); 4281cdf0e10cSrcweir } 4282cdf0e10cSrcweir 4283cdf0e10cSrcweir void SAL_CALL VCLXComboBox::listItemModified( const ItemListEvent& i_rEvent ) throw (RuntimeException) 4284cdf0e10cSrcweir { 4285cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4286cdf0e10cSrcweir 4287cdf0e10cSrcweir ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() ); 4288cdf0e10cSrcweir 4289cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" ); 4290cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pComboBox->GetEntryCount() ) ), 4291cdf0e10cSrcweir "VCLXComboBox::listItemModified: illegal (inconsistent) item position!" ); 4292cdf0e10cSrcweir 4293cdf0e10cSrcweir // VCL's ComboBox does not support changing an entry's text or image, so remove and re-insert 4294cdf0e10cSrcweir 4295cdf0e10cSrcweir const ::rtl::OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : ::rtl::OUString( pComboBox->GetEntry( i_rEvent.ItemPosition ) ); 4296cdf0e10cSrcweir const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : pComboBox->GetEntryImage( i_rEvent.ItemPosition ) ); 4297cdf0e10cSrcweir 4298cdf0e10cSrcweir pComboBox->RemoveEntry( i_rEvent.ItemPosition ); 4299cdf0e10cSrcweir pComboBox->InsertEntry( sNewText, aNewImage, i_rEvent.ItemPosition ); 4300cdf0e10cSrcweir } 4301cdf0e10cSrcweir 4302cdf0e10cSrcweir void SAL_CALL VCLXComboBox::allItemsRemoved( const EventObject& i_rEvent ) throw (RuntimeException) 4303cdf0e10cSrcweir { 4304cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4305cdf0e10cSrcweir 4306cdf0e10cSrcweir ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() ); 4307cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" ); 4308cdf0e10cSrcweir 4309cdf0e10cSrcweir pComboBox->Clear(); 4310cdf0e10cSrcweir 4311cdf0e10cSrcweir (void)i_rEvent; 4312cdf0e10cSrcweir } 4313cdf0e10cSrcweir 4314cdf0e10cSrcweir void SAL_CALL VCLXComboBox::itemListChanged( const EventObject& i_rEvent ) throw (RuntimeException) 4315cdf0e10cSrcweir { 4316cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4317cdf0e10cSrcweir 4318cdf0e10cSrcweir ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() ); 4319cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" ); 4320cdf0e10cSrcweir 4321cdf0e10cSrcweir pComboBox->Clear(); 4322cdf0e10cSrcweir 4323cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPropSet( i_rEvent.Source, uno::UNO_QUERY_THROW ); 4324cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), uno::UNO_QUERY_THROW ); 4325cdf0e10cSrcweir // bool localize = xPSI->hasPropertyByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ) ) ); 4326cdf0e10cSrcweir uno::Reference< resource::XStringResourceResolver > xStringResourceResolver; 4327cdf0e10cSrcweir if ( xPSI->hasPropertyByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ) ) ) ) 4328cdf0e10cSrcweir { 4329cdf0e10cSrcweir xStringResourceResolver.set( 4330cdf0e10cSrcweir xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ) ) ), 4331cdf0e10cSrcweir uno::UNO_QUERY 4332cdf0e10cSrcweir ); 4333cdf0e10cSrcweir } 4334cdf0e10cSrcweir 4335cdf0e10cSrcweir 4336cdf0e10cSrcweir Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW ); 4337cdf0e10cSrcweir uno::Sequence< beans::Pair< ::rtl::OUString, ::rtl::OUString > > aItems = xItemList->getAllItems(); 4338cdf0e10cSrcweir for ( sal_Int32 i=0; i<aItems.getLength(); ++i ) 4339cdf0e10cSrcweir { 4340cdf0e10cSrcweir ::rtl::OUString aLocalizationKey( aItems[i].First ); 4341cdf0e10cSrcweir if ( xStringResourceResolver.is() && aLocalizationKey.getLength() != 0 && aLocalizationKey[0] == '&' ) 4342cdf0e10cSrcweir { 4343cdf0e10cSrcweir aLocalizationKey = xStringResourceResolver->resolveString(aLocalizationKey.copy( 1 )); 4344cdf0e10cSrcweir } 4345cdf0e10cSrcweir pComboBox->InsertEntry( aLocalizationKey, lcl_getImageFromURL( aItems[i].Second ) ); 4346cdf0e10cSrcweir } 4347cdf0e10cSrcweir } 4348cdf0e10cSrcweir void SAL_CALL VCLXComboBox::disposing( const EventObject& i_rEvent ) throw (RuntimeException) 4349cdf0e10cSrcweir { 4350cdf0e10cSrcweir // just disambiguate 4351cdf0e10cSrcweir VCLXEdit::disposing( i_rEvent ); 4352cdf0e10cSrcweir } 4353cdf0e10cSrcweir 4354cdf0e10cSrcweir // ---------------------------------------------------- 4355cdf0e10cSrcweir // class VCLXFormattedSpinField 4356cdf0e10cSrcweir // ---------------------------------------------------- 4357cdf0e10cSrcweir void VCLXFormattedSpinField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 4358cdf0e10cSrcweir { 4359cdf0e10cSrcweir // Interestingly in the UnoControl API this is 4360cdf0e10cSrcweir // - not derived from XEdit ultimately, (correct ?) - so cut this here ... 4361cdf0e10cSrcweir // VCLXSpinField::ImplGetPropertyIds( rIds ); 4362cdf0e10cSrcweir VCLXWindow::ImplGetPropertyIds( rIds ); 4363cdf0e10cSrcweir } 4364cdf0e10cSrcweir 4365cdf0e10cSrcweir VCLXFormattedSpinField::VCLXFormattedSpinField() 4366cdf0e10cSrcweir { 4367cdf0e10cSrcweir } 4368cdf0e10cSrcweir 4369cdf0e10cSrcweir VCLXFormattedSpinField::~VCLXFormattedSpinField() 4370cdf0e10cSrcweir { 4371cdf0e10cSrcweir } 4372cdf0e10cSrcweir 4373cdf0e10cSrcweir void VCLXFormattedSpinField::setStrictFormat( sal_Bool bStrict ) 4374cdf0e10cSrcweir { 4375cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4376cdf0e10cSrcweir 4377cdf0e10cSrcweir FormatterBase* pFormatter = GetFormatter(); 4378cdf0e10cSrcweir if ( pFormatter ) 4379cdf0e10cSrcweir pFormatter->SetStrictFormat( bStrict ); 4380cdf0e10cSrcweir } 4381cdf0e10cSrcweir 4382cdf0e10cSrcweir sal_Bool VCLXFormattedSpinField::isStrictFormat() 4383cdf0e10cSrcweir { 4384cdf0e10cSrcweir FormatterBase* pFormatter = GetFormatter(); 4385cdf0e10cSrcweir return pFormatter ? pFormatter->IsStrictFormat() : sal_False; 4386cdf0e10cSrcweir } 4387cdf0e10cSrcweir 4388cdf0e10cSrcweir 4389cdf0e10cSrcweir void VCLXFormattedSpinField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 4390cdf0e10cSrcweir { 4391cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4392cdf0e10cSrcweir 4393cdf0e10cSrcweir FormatterBase* pFormatter = GetFormatter(); 4394cdf0e10cSrcweir if ( pFormatter ) 4395cdf0e10cSrcweir { 4396cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 4397cdf0e10cSrcweir switch ( nPropType ) 4398cdf0e10cSrcweir { 4399cdf0e10cSrcweir case BASEPROPERTY_SPIN: 4400cdf0e10cSrcweir { 4401cdf0e10cSrcweir sal_Bool b = sal_Bool(); 4402cdf0e10cSrcweir if ( Value >>= b ) 4403cdf0e10cSrcweir { 4404cdf0e10cSrcweir WinBits nStyle = GetWindow()->GetStyle() | WB_SPIN; 4405cdf0e10cSrcweir if ( !b ) 4406cdf0e10cSrcweir nStyle &= ~WB_SPIN; 4407cdf0e10cSrcweir GetWindow()->SetStyle( nStyle ); 4408cdf0e10cSrcweir } 4409cdf0e10cSrcweir } 4410cdf0e10cSrcweir break; 4411cdf0e10cSrcweir case BASEPROPERTY_STRICTFORMAT: 4412cdf0e10cSrcweir { 4413cdf0e10cSrcweir sal_Bool b = sal_Bool(); 4414cdf0e10cSrcweir if ( Value >>= b ) 4415cdf0e10cSrcweir { 4416cdf0e10cSrcweir pFormatter->SetStrictFormat( b ); 4417cdf0e10cSrcweir } 4418cdf0e10cSrcweir } 4419cdf0e10cSrcweir break; 4420cdf0e10cSrcweir default: 4421cdf0e10cSrcweir { 4422cdf0e10cSrcweir VCLXSpinField::setProperty( PropertyName, Value ); 4423cdf0e10cSrcweir } 4424cdf0e10cSrcweir } 4425cdf0e10cSrcweir } 4426cdf0e10cSrcweir } 4427cdf0e10cSrcweir 4428cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXFormattedSpinField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) 4429cdf0e10cSrcweir { 4430cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4431cdf0e10cSrcweir 4432cdf0e10cSrcweir ::com::sun::star::uno::Any aProp; 4433cdf0e10cSrcweir FormatterBase* pFormatter = GetFormatter(); 4434cdf0e10cSrcweir if ( pFormatter ) 4435cdf0e10cSrcweir { 4436cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 4437cdf0e10cSrcweir switch ( nPropType ) 4438cdf0e10cSrcweir { 4439cdf0e10cSrcweir case BASEPROPERTY_TABSTOP: 4440cdf0e10cSrcweir { 4441cdf0e10cSrcweir aProp <<= (sal_Bool) ( ( GetWindow()->GetStyle() & WB_SPIN ) ? sal_True : sal_False ); 4442cdf0e10cSrcweir } 4443cdf0e10cSrcweir break; 4444cdf0e10cSrcweir case BASEPROPERTY_STRICTFORMAT: 4445cdf0e10cSrcweir { 4446cdf0e10cSrcweir aProp <<= (sal_Bool) pFormatter->IsStrictFormat(); 4447cdf0e10cSrcweir } 4448cdf0e10cSrcweir break; 4449cdf0e10cSrcweir default: 4450cdf0e10cSrcweir { 4451cdf0e10cSrcweir aProp <<= VCLXSpinField::getProperty( PropertyName ); 4452cdf0e10cSrcweir } 4453cdf0e10cSrcweir } 4454cdf0e10cSrcweir } 4455cdf0e10cSrcweir return aProp; 4456cdf0e10cSrcweir } 4457cdf0e10cSrcweir 4458cdf0e10cSrcweir 4459cdf0e10cSrcweir // ---------------------------------------------------- 4460cdf0e10cSrcweir // class VCLXDateField 4461cdf0e10cSrcweir // ---------------------------------------------------- 4462cdf0e10cSrcweir 4463cdf0e10cSrcweir void VCLXDateField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 4464cdf0e10cSrcweir { 4465cdf0e10cSrcweir PushPropertyIds( rIds, 4466cdf0e10cSrcweir BASEPROPERTY_ALIGN, 4467cdf0e10cSrcweir BASEPROPERTY_BACKGROUNDCOLOR, 4468cdf0e10cSrcweir BASEPROPERTY_BORDER, 4469cdf0e10cSrcweir BASEPROPERTY_BORDERCOLOR, 4470cdf0e10cSrcweir BASEPROPERTY_DATE, 4471cdf0e10cSrcweir BASEPROPERTY_DATEMAX, 4472cdf0e10cSrcweir BASEPROPERTY_DATEMIN, 4473cdf0e10cSrcweir BASEPROPERTY_DATESHOWCENTURY, 4474cdf0e10cSrcweir BASEPROPERTY_DEFAULTCONTROL, 4475cdf0e10cSrcweir BASEPROPERTY_DROPDOWN, 4476cdf0e10cSrcweir BASEPROPERTY_ENABLED, 4477cdf0e10cSrcweir BASEPROPERTY_ENABLEVISIBLE, 4478cdf0e10cSrcweir BASEPROPERTY_EXTDATEFORMAT, 4479cdf0e10cSrcweir BASEPROPERTY_FONTDESCRIPTOR, 4480cdf0e10cSrcweir BASEPROPERTY_HELPTEXT, 4481cdf0e10cSrcweir BASEPROPERTY_HELPURL, 4482cdf0e10cSrcweir BASEPROPERTY_PRINTABLE, 4483cdf0e10cSrcweir BASEPROPERTY_READONLY, 4484cdf0e10cSrcweir BASEPROPERTY_REPEAT, 4485cdf0e10cSrcweir BASEPROPERTY_REPEAT_DELAY, 4486cdf0e10cSrcweir BASEPROPERTY_SPIN, 4487cdf0e10cSrcweir BASEPROPERTY_STRICTFORMAT, 4488cdf0e10cSrcweir BASEPROPERTY_TABSTOP, 4489cdf0e10cSrcweir BASEPROPERTY_ENFORCE_FORMAT, 4490cdf0e10cSrcweir BASEPROPERTY_TEXT, 4491cdf0e10cSrcweir BASEPROPERTY_HIDEINACTIVESELECTION, 4492cdf0e10cSrcweir BASEPROPERTY_VERTICALALIGN, 4493cdf0e10cSrcweir BASEPROPERTY_WRITING_MODE, 4494cdf0e10cSrcweir BASEPROPERTY_CONTEXT_WRITING_MODE, 4495cdf0e10cSrcweir BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, 4496cdf0e10cSrcweir 0); 4497cdf0e10cSrcweir VCLXFormattedSpinField::ImplGetPropertyIds( rIds ); 4498cdf0e10cSrcweir } 4499cdf0e10cSrcweir 4500cdf0e10cSrcweir VCLXDateField::VCLXDateField() 4501cdf0e10cSrcweir { 4502cdf0e10cSrcweir } 4503cdf0e10cSrcweir 4504cdf0e10cSrcweir VCLXDateField::~VCLXDateField() 4505cdf0e10cSrcweir { 4506cdf0e10cSrcweir } 4507cdf0e10cSrcweir 4508*ff7e158dSSteve Yin //IAccessibility2 Implementation 2009----- 4509*ff7e158dSSteve Yin //change the window type here to match the role 4510*ff7e158dSSteve Yin ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXDateField::CreateAccessibleContext() 4511*ff7e158dSSteve Yin { 4512*ff7e158dSSteve Yin Window* pWindow = GetWindow(); 4513*ff7e158dSSteve Yin if ( pWindow ) 4514*ff7e158dSSteve Yin { 4515*ff7e158dSSteve Yin pWindow->SetType( WINDOW_DATEFIELD ); 4516*ff7e158dSSteve Yin } 4517*ff7e158dSSteve Yin return getAccessibleFactory().createAccessibleContext( this ); 4518*ff7e158dSSteve Yin } 4519*ff7e158dSSteve Yin //-----IAccessibility2 Implementation 2009 4520*ff7e158dSSteve Yin 4521cdf0e10cSrcweir // ::com::sun::star::uno::XInterface 4522cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXDateField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 4523cdf0e10cSrcweir { 4524cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 4525cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XDateField*, this ) ); 4526cdf0e10cSrcweir return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType )); 4527cdf0e10cSrcweir } 4528cdf0e10cSrcweir 4529cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 4530cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXDateField ) 4531cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDateField>* ) NULL ), 4532cdf0e10cSrcweir VCLXFormattedSpinField::getTypes() 4533cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 4534cdf0e10cSrcweir 4535cdf0e10cSrcweir void VCLXDateField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 4536cdf0e10cSrcweir { 4537cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4538cdf0e10cSrcweir 4539cdf0e10cSrcweir if ( GetWindow() ) 4540cdf0e10cSrcweir { 4541cdf0e10cSrcweir sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID; 4542cdf0e10cSrcweir 4543cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 4544cdf0e10cSrcweir switch ( nPropType ) 4545cdf0e10cSrcweir { 4546cdf0e10cSrcweir case BASEPROPERTY_DATE: 4547cdf0e10cSrcweir { 4548cdf0e10cSrcweir if ( bVoid ) 4549cdf0e10cSrcweir { 4550cdf0e10cSrcweir ((DateField*)GetWindow())->EnableEmptyFieldValue( sal_True ); 4551cdf0e10cSrcweir ((DateField*)GetWindow())->SetEmptyFieldValue(); 4552cdf0e10cSrcweir } 4553cdf0e10cSrcweir else 4554cdf0e10cSrcweir { 4555cdf0e10cSrcweir sal_Int32 n = 0; 4556cdf0e10cSrcweir if ( Value >>= n ) 4557cdf0e10cSrcweir setDate( n ); 4558cdf0e10cSrcweir } 4559cdf0e10cSrcweir } 4560cdf0e10cSrcweir break; 4561cdf0e10cSrcweir case BASEPROPERTY_DATEMIN: 4562cdf0e10cSrcweir { 4563cdf0e10cSrcweir sal_Int32 n = 0; 4564cdf0e10cSrcweir if ( Value >>= n ) 4565cdf0e10cSrcweir setMin( n ); 4566cdf0e10cSrcweir } 4567cdf0e10cSrcweir break; 4568cdf0e10cSrcweir case BASEPROPERTY_DATEMAX: 4569cdf0e10cSrcweir { 4570cdf0e10cSrcweir sal_Int32 n = 0; 4571cdf0e10cSrcweir if ( Value >>= n ) 4572cdf0e10cSrcweir setMax( n ); 4573cdf0e10cSrcweir } 4574cdf0e10cSrcweir break; 4575cdf0e10cSrcweir case BASEPROPERTY_EXTDATEFORMAT: 4576cdf0e10cSrcweir { 4577cdf0e10cSrcweir sal_Int16 n = sal_Int16(); 4578cdf0e10cSrcweir if ( Value >>= n ) 4579cdf0e10cSrcweir ((DateField*)GetWindow())->SetExtDateFormat( (ExtDateFieldFormat) n ); 4580cdf0e10cSrcweir } 4581cdf0e10cSrcweir break; 4582cdf0e10cSrcweir case BASEPROPERTY_DATESHOWCENTURY: 4583cdf0e10cSrcweir { 4584cdf0e10cSrcweir sal_Bool b = sal_Bool(); 4585cdf0e10cSrcweir if ( Value >>= b ) 4586cdf0e10cSrcweir ((DateField*)GetWindow())->SetShowDateCentury( b ); 4587cdf0e10cSrcweir } 4588cdf0e10cSrcweir break; 4589cdf0e10cSrcweir case BASEPROPERTY_ENFORCE_FORMAT: 4590cdf0e10cSrcweir { 4591cdf0e10cSrcweir sal_Bool bEnforce( sal_True ); 4592cdf0e10cSrcweir OSL_VERIFY( Value >>= bEnforce ); 4593cdf0e10cSrcweir static_cast< DateField* >( GetWindow() )->EnforceValidValue( bEnforce ); 4594cdf0e10cSrcweir } 4595cdf0e10cSrcweir break; 4596cdf0e10cSrcweir default: 4597cdf0e10cSrcweir { 4598cdf0e10cSrcweir VCLXFormattedSpinField::setProperty( PropertyName, Value ); 4599cdf0e10cSrcweir } 4600cdf0e10cSrcweir } 4601cdf0e10cSrcweir } 4602cdf0e10cSrcweir } 4603cdf0e10cSrcweir 4604cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXDateField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) 4605cdf0e10cSrcweir { 4606cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4607cdf0e10cSrcweir 4608cdf0e10cSrcweir ::com::sun::star::uno::Any aProp; 4609cdf0e10cSrcweir FormatterBase* pFormatter = GetFormatter(); 4610cdf0e10cSrcweir if ( pFormatter ) 4611cdf0e10cSrcweir { 4612cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 4613cdf0e10cSrcweir switch ( nPropType ) 4614cdf0e10cSrcweir { 4615cdf0e10cSrcweir case BASEPROPERTY_DATE: 4616cdf0e10cSrcweir { 4617cdf0e10cSrcweir aProp <<= (sal_Int32) getDate(); 4618cdf0e10cSrcweir } 4619cdf0e10cSrcweir break; 4620cdf0e10cSrcweir case BASEPROPERTY_DATEMIN: 4621cdf0e10cSrcweir { 4622cdf0e10cSrcweir aProp <<= (sal_Int32) getMin(); 4623cdf0e10cSrcweir } 4624cdf0e10cSrcweir break; 4625cdf0e10cSrcweir case BASEPROPERTY_DATEMAX: 4626cdf0e10cSrcweir { 4627cdf0e10cSrcweir aProp <<= (sal_Int32) getMax(); 4628cdf0e10cSrcweir } 4629cdf0e10cSrcweir break; 4630cdf0e10cSrcweir case BASEPROPERTY_DATESHOWCENTURY: 4631cdf0e10cSrcweir { 4632cdf0e10cSrcweir aProp <<= ((DateField*)GetWindow())->IsShowDateCentury(); 4633cdf0e10cSrcweir } 4634cdf0e10cSrcweir break; 4635cdf0e10cSrcweir case BASEPROPERTY_ENFORCE_FORMAT: 4636cdf0e10cSrcweir { 4637cdf0e10cSrcweir aProp <<= (sal_Bool)static_cast< DateField* >( GetWindow() )->IsEnforceValidValue( ); 4638cdf0e10cSrcweir } 4639cdf0e10cSrcweir break; 4640cdf0e10cSrcweir default: 4641cdf0e10cSrcweir { 4642cdf0e10cSrcweir aProp <<= VCLXFormattedSpinField::getProperty( PropertyName ); 4643cdf0e10cSrcweir } 4644cdf0e10cSrcweir } 4645cdf0e10cSrcweir } 4646cdf0e10cSrcweir return aProp; 4647cdf0e10cSrcweir } 4648cdf0e10cSrcweir 4649cdf0e10cSrcweir 4650cdf0e10cSrcweir void VCLXDateField::setDate( sal_Int32 nDate ) throw(::com::sun::star::uno::RuntimeException) 4651cdf0e10cSrcweir { 4652cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4653cdf0e10cSrcweir 4654cdf0e10cSrcweir DateField* pDateField = (DateField*) GetWindow(); 4655cdf0e10cSrcweir if ( pDateField ) 4656cdf0e10cSrcweir { 4657cdf0e10cSrcweir pDateField->SetDate( nDate ); 4658cdf0e10cSrcweir 4659cdf0e10cSrcweir // #107218# Call same listeners like VCL would do after user interaction 4660cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_True ); 4661cdf0e10cSrcweir pDateField->SetModifyFlag(); 4662cdf0e10cSrcweir pDateField->Modify(); 4663cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_False ); 4664cdf0e10cSrcweir } 4665cdf0e10cSrcweir } 4666cdf0e10cSrcweir 4667cdf0e10cSrcweir sal_Int32 VCLXDateField::getDate() throw(::com::sun::star::uno::RuntimeException) 4668cdf0e10cSrcweir { 4669cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4670cdf0e10cSrcweir 4671cdf0e10cSrcweir sal_Int32 nDate = 0; 4672cdf0e10cSrcweir DateField* pDateField = (DateField*) GetWindow(); 4673cdf0e10cSrcweir if ( pDateField ) 4674cdf0e10cSrcweir nDate = pDateField->GetDate().GetDate(); 4675cdf0e10cSrcweir 4676cdf0e10cSrcweir return nDate; 4677cdf0e10cSrcweir } 4678cdf0e10cSrcweir 4679cdf0e10cSrcweir void VCLXDateField::setMin( sal_Int32 nDate ) throw(::com::sun::star::uno::RuntimeException) 4680cdf0e10cSrcweir { 4681cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4682cdf0e10cSrcweir 4683cdf0e10cSrcweir DateField* pDateField = (DateField*) GetWindow(); 4684cdf0e10cSrcweir if ( pDateField ) 4685cdf0e10cSrcweir pDateField->SetMin( nDate ); 4686cdf0e10cSrcweir } 4687cdf0e10cSrcweir 4688cdf0e10cSrcweir sal_Int32 VCLXDateField::getMin() throw(::com::sun::star::uno::RuntimeException) 4689cdf0e10cSrcweir { 4690cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4691cdf0e10cSrcweir 4692cdf0e10cSrcweir sal_Int32 nDate = 0; 4693cdf0e10cSrcweir DateField* pDateField = (DateField*) GetWindow(); 4694cdf0e10cSrcweir if ( pDateField ) 4695cdf0e10cSrcweir nDate = pDateField->GetMin().GetDate(); 4696cdf0e10cSrcweir 4697cdf0e10cSrcweir return nDate; 4698cdf0e10cSrcweir } 4699cdf0e10cSrcweir 4700cdf0e10cSrcweir void VCLXDateField::setMax( sal_Int32 nDate ) throw(::com::sun::star::uno::RuntimeException) 4701cdf0e10cSrcweir { 4702cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4703cdf0e10cSrcweir 4704cdf0e10cSrcweir DateField* pDateField = (DateField*) GetWindow(); 4705cdf0e10cSrcweir if ( pDateField ) 4706cdf0e10cSrcweir pDateField->SetMax( nDate ); 4707cdf0e10cSrcweir } 4708cdf0e10cSrcweir 4709cdf0e10cSrcweir sal_Int32 VCLXDateField::getMax() throw(::com::sun::star::uno::RuntimeException) 4710cdf0e10cSrcweir { 4711cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4712cdf0e10cSrcweir 4713cdf0e10cSrcweir sal_Int32 nDate = 0; 4714cdf0e10cSrcweir DateField* pDateField = (DateField*) GetWindow(); 4715cdf0e10cSrcweir if ( pDateField ) 4716cdf0e10cSrcweir nDate = pDateField->GetMax().GetDate(); 4717cdf0e10cSrcweir 4718cdf0e10cSrcweir return nDate; 4719cdf0e10cSrcweir } 4720cdf0e10cSrcweir 4721cdf0e10cSrcweir void VCLXDateField::setFirst( sal_Int32 nDate ) throw(::com::sun::star::uno::RuntimeException) 4722cdf0e10cSrcweir { 4723cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4724cdf0e10cSrcweir 4725cdf0e10cSrcweir DateField* pDateField = (DateField*) GetWindow(); 4726cdf0e10cSrcweir if ( pDateField ) 4727cdf0e10cSrcweir pDateField->SetFirst( nDate ); 4728cdf0e10cSrcweir } 4729cdf0e10cSrcweir 4730cdf0e10cSrcweir sal_Int32 VCLXDateField::getFirst() throw(::com::sun::star::uno::RuntimeException) 4731cdf0e10cSrcweir { 4732cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4733cdf0e10cSrcweir 4734cdf0e10cSrcweir sal_Int32 nDate = 0; 4735cdf0e10cSrcweir DateField* pDateField = (DateField*) GetWindow(); 4736cdf0e10cSrcweir if ( pDateField ) 4737cdf0e10cSrcweir nDate = pDateField->GetFirst().GetDate(); 4738cdf0e10cSrcweir 4739cdf0e10cSrcweir return nDate; 4740cdf0e10cSrcweir } 4741cdf0e10cSrcweir 4742cdf0e10cSrcweir void VCLXDateField::setLast( sal_Int32 nDate ) throw(::com::sun::star::uno::RuntimeException) 4743cdf0e10cSrcweir { 4744cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4745cdf0e10cSrcweir 4746cdf0e10cSrcweir DateField* pDateField = (DateField*) GetWindow(); 4747cdf0e10cSrcweir if ( pDateField ) 4748cdf0e10cSrcweir pDateField->SetLast( nDate ); 4749cdf0e10cSrcweir } 4750cdf0e10cSrcweir 4751cdf0e10cSrcweir sal_Int32 VCLXDateField::getLast() throw(::com::sun::star::uno::RuntimeException) 4752cdf0e10cSrcweir { 4753cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4754cdf0e10cSrcweir 4755cdf0e10cSrcweir sal_Int32 nDate = 0; 4756cdf0e10cSrcweir DateField* pDateField = (DateField*) GetWindow(); 4757cdf0e10cSrcweir if ( pDateField ) 4758cdf0e10cSrcweir nDate = pDateField->GetLast().GetDate(); 4759cdf0e10cSrcweir 4760cdf0e10cSrcweir return nDate; 4761cdf0e10cSrcweir } 4762cdf0e10cSrcweir 4763cdf0e10cSrcweir void VCLXDateField::setLongFormat( sal_Bool bLong ) throw(::com::sun::star::uno::RuntimeException) 4764cdf0e10cSrcweir { 4765cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4766cdf0e10cSrcweir 4767cdf0e10cSrcweir DateField* pDateField = (DateField*) GetWindow(); 4768cdf0e10cSrcweir if ( pDateField ) 4769cdf0e10cSrcweir pDateField->SetLongFormat( bLong ); 4770cdf0e10cSrcweir } 4771cdf0e10cSrcweir 4772cdf0e10cSrcweir sal_Bool VCLXDateField::isLongFormat() throw(::com::sun::star::uno::RuntimeException) 4773cdf0e10cSrcweir { 4774cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4775cdf0e10cSrcweir 4776cdf0e10cSrcweir DateField* pDateField = (DateField*) GetWindow(); 4777cdf0e10cSrcweir return pDateField ? pDateField->IsLongFormat() : sal_False; 4778cdf0e10cSrcweir } 4779cdf0e10cSrcweir 4780cdf0e10cSrcweir void VCLXDateField::setEmpty() throw(::com::sun::star::uno::RuntimeException) 4781cdf0e10cSrcweir { 4782cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4783cdf0e10cSrcweir 4784cdf0e10cSrcweir DateField* pDateField = (DateField*) GetWindow(); 4785cdf0e10cSrcweir if ( pDateField ) 4786cdf0e10cSrcweir { 4787cdf0e10cSrcweir pDateField->SetEmptyDate(); 4788cdf0e10cSrcweir 4789cdf0e10cSrcweir // #107218# Call same listeners like VCL would do after user interaction 4790cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_True ); 4791cdf0e10cSrcweir pDateField->SetModifyFlag(); 4792cdf0e10cSrcweir pDateField->Modify(); 4793cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_False ); 4794cdf0e10cSrcweir } 4795cdf0e10cSrcweir } 4796cdf0e10cSrcweir 4797cdf0e10cSrcweir sal_Bool VCLXDateField::isEmpty() throw(::com::sun::star::uno::RuntimeException) 4798cdf0e10cSrcweir { 4799cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4800cdf0e10cSrcweir 4801cdf0e10cSrcweir DateField* pDateField = (DateField*) GetWindow(); 4802cdf0e10cSrcweir return pDateField ? pDateField->IsEmptyDate() : sal_False; 4803cdf0e10cSrcweir } 4804cdf0e10cSrcweir 4805cdf0e10cSrcweir void VCLXDateField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException) 4806cdf0e10cSrcweir { 4807cdf0e10cSrcweir VCLXFormattedSpinField::setStrictFormat( bStrict ); 4808cdf0e10cSrcweir } 4809cdf0e10cSrcweir 4810cdf0e10cSrcweir sal_Bool VCLXDateField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException) 4811cdf0e10cSrcweir { 4812cdf0e10cSrcweir return VCLXFormattedSpinField::isStrictFormat(); 4813cdf0e10cSrcweir } 4814cdf0e10cSrcweir 4815cdf0e10cSrcweir 4816cdf0e10cSrcweir // ---------------------------------------------------- 4817cdf0e10cSrcweir // class VCLXTimeField 4818cdf0e10cSrcweir // ---------------------------------------------------- 4819cdf0e10cSrcweir 4820cdf0e10cSrcweir void VCLXTimeField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 4821cdf0e10cSrcweir { 4822cdf0e10cSrcweir PushPropertyIds( rIds, 4823cdf0e10cSrcweir BASEPROPERTY_ALIGN, 4824cdf0e10cSrcweir BASEPROPERTY_BACKGROUNDCOLOR, 4825cdf0e10cSrcweir BASEPROPERTY_BORDER, 4826cdf0e10cSrcweir BASEPROPERTY_BORDERCOLOR, 4827cdf0e10cSrcweir BASEPROPERTY_DEFAULTCONTROL, 4828cdf0e10cSrcweir BASEPROPERTY_ENABLED, 4829cdf0e10cSrcweir BASEPROPERTY_ENABLEVISIBLE, 4830cdf0e10cSrcweir BASEPROPERTY_EXTTIMEFORMAT, 4831cdf0e10cSrcweir BASEPROPERTY_FONTDESCRIPTOR, 4832cdf0e10cSrcweir BASEPROPERTY_HELPTEXT, 4833cdf0e10cSrcweir BASEPROPERTY_HELPURL, 4834cdf0e10cSrcweir BASEPROPERTY_PRINTABLE, 4835cdf0e10cSrcweir BASEPROPERTY_READONLY, 4836cdf0e10cSrcweir BASEPROPERTY_REPEAT, 4837cdf0e10cSrcweir BASEPROPERTY_REPEAT_DELAY, 4838cdf0e10cSrcweir BASEPROPERTY_SPIN, 4839cdf0e10cSrcweir BASEPROPERTY_STRICTFORMAT, 4840cdf0e10cSrcweir BASEPROPERTY_TABSTOP, 4841cdf0e10cSrcweir BASEPROPERTY_TIME, 4842cdf0e10cSrcweir BASEPROPERTY_TIMEMAX, 4843cdf0e10cSrcweir BASEPROPERTY_TIMEMIN, 4844cdf0e10cSrcweir BASEPROPERTY_ENFORCE_FORMAT, 4845cdf0e10cSrcweir BASEPROPERTY_TEXT, 4846cdf0e10cSrcweir BASEPROPERTY_HIDEINACTIVESELECTION, 4847cdf0e10cSrcweir BASEPROPERTY_VERTICALALIGN, 4848cdf0e10cSrcweir BASEPROPERTY_WRITING_MODE, 4849cdf0e10cSrcweir BASEPROPERTY_CONTEXT_WRITING_MODE, 4850cdf0e10cSrcweir BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, 4851cdf0e10cSrcweir 0); 4852cdf0e10cSrcweir VCLXFormattedSpinField::ImplGetPropertyIds( rIds ); 4853cdf0e10cSrcweir } 4854cdf0e10cSrcweir 4855cdf0e10cSrcweir VCLXTimeField::VCLXTimeField() 4856cdf0e10cSrcweir { 4857cdf0e10cSrcweir } 4858cdf0e10cSrcweir 4859cdf0e10cSrcweir VCLXTimeField::~VCLXTimeField() 4860cdf0e10cSrcweir { 4861cdf0e10cSrcweir } 4862*ff7e158dSSteve Yin //IAccessibility2 Implementation 2009----- 4863*ff7e158dSSteve Yin //change the window type here to match the role 4864*ff7e158dSSteve Yin ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXTimeField::CreateAccessibleContext() 4865*ff7e158dSSteve Yin { 4866*ff7e158dSSteve Yin Window* pWindow = GetWindow(); 4867*ff7e158dSSteve Yin if ( pWindow ) 4868*ff7e158dSSteve Yin { 4869*ff7e158dSSteve Yin pWindow->SetType( WINDOW_TIMEFIELD ); 4870*ff7e158dSSteve Yin } 4871*ff7e158dSSteve Yin return getAccessibleFactory().createAccessibleContext( this ); 4872*ff7e158dSSteve Yin } 4873*ff7e158dSSteve Yin //-----IAccessibility2 Implementation 2009 4874cdf0e10cSrcweir 4875cdf0e10cSrcweir // ::com::sun::star::uno::XInterface 4876cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXTimeField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 4877cdf0e10cSrcweir { 4878cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 4879cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XTimeField*, this ) ); 4880cdf0e10cSrcweir return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType )); 4881cdf0e10cSrcweir } 4882cdf0e10cSrcweir 4883cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 4884cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXTimeField ) 4885cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTimeField>* ) NULL ), 4886cdf0e10cSrcweir VCLXFormattedSpinField::getTypes() 4887cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 4888cdf0e10cSrcweir 4889cdf0e10cSrcweir void VCLXTimeField::setTime( sal_Int32 nTime ) throw(::com::sun::star::uno::RuntimeException) 4890cdf0e10cSrcweir { 4891cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4892cdf0e10cSrcweir 4893cdf0e10cSrcweir TimeField* pTimeField = (TimeField*) GetWindow(); 4894cdf0e10cSrcweir if ( pTimeField ) 4895cdf0e10cSrcweir { 4896cdf0e10cSrcweir pTimeField->SetTime( nTime ); 4897cdf0e10cSrcweir 4898cdf0e10cSrcweir // #107218# Call same listeners like VCL would do after user interaction 4899cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_True ); 4900cdf0e10cSrcweir pTimeField->SetModifyFlag(); 4901cdf0e10cSrcweir pTimeField->Modify(); 4902cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_False ); 4903cdf0e10cSrcweir } 4904cdf0e10cSrcweir } 4905cdf0e10cSrcweir 4906cdf0e10cSrcweir sal_Int32 VCLXTimeField::getTime() throw(::com::sun::star::uno::RuntimeException) 4907cdf0e10cSrcweir { 4908cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4909cdf0e10cSrcweir 4910cdf0e10cSrcweir sal_Int32 nTime = 0; 4911cdf0e10cSrcweir TimeField* pTimeField = (TimeField*) GetWindow(); 4912cdf0e10cSrcweir if ( pTimeField ) 4913cdf0e10cSrcweir nTime = pTimeField->GetTime().GetTime(); 4914cdf0e10cSrcweir 4915cdf0e10cSrcweir return nTime; 4916cdf0e10cSrcweir } 4917cdf0e10cSrcweir 4918cdf0e10cSrcweir void VCLXTimeField::setMin( sal_Int32 nTime ) throw(::com::sun::star::uno::RuntimeException) 4919cdf0e10cSrcweir { 4920cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4921cdf0e10cSrcweir 4922cdf0e10cSrcweir TimeField* pTimeField = (TimeField*) GetWindow(); 4923cdf0e10cSrcweir if ( pTimeField ) 4924cdf0e10cSrcweir pTimeField->SetMin( nTime ); 4925cdf0e10cSrcweir } 4926cdf0e10cSrcweir 4927cdf0e10cSrcweir sal_Int32 VCLXTimeField::getMin() throw(::com::sun::star::uno::RuntimeException) 4928cdf0e10cSrcweir { 4929cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4930cdf0e10cSrcweir 4931cdf0e10cSrcweir sal_Int32 nTime = 0; 4932cdf0e10cSrcweir TimeField* pTimeField = (TimeField*) GetWindow(); 4933cdf0e10cSrcweir if ( pTimeField ) 4934cdf0e10cSrcweir nTime = pTimeField->GetMin().GetTime(); 4935cdf0e10cSrcweir 4936cdf0e10cSrcweir return nTime; 4937cdf0e10cSrcweir } 4938cdf0e10cSrcweir 4939cdf0e10cSrcweir void VCLXTimeField::setMax( sal_Int32 nTime ) throw(::com::sun::star::uno::RuntimeException) 4940cdf0e10cSrcweir { 4941cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4942cdf0e10cSrcweir 4943cdf0e10cSrcweir TimeField* pTimeField = (TimeField*) GetWindow(); 4944cdf0e10cSrcweir if ( pTimeField ) 4945cdf0e10cSrcweir pTimeField->SetMax( nTime ); 4946cdf0e10cSrcweir } 4947cdf0e10cSrcweir 4948cdf0e10cSrcweir sal_Int32 VCLXTimeField::getMax() throw(::com::sun::star::uno::RuntimeException) 4949cdf0e10cSrcweir { 4950cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4951cdf0e10cSrcweir 4952cdf0e10cSrcweir sal_Int32 nTime = 0; 4953cdf0e10cSrcweir TimeField* pTimeField = (TimeField*) GetWindow(); 4954cdf0e10cSrcweir if ( pTimeField ) 4955cdf0e10cSrcweir nTime = pTimeField->GetMax().GetTime(); 4956cdf0e10cSrcweir 4957cdf0e10cSrcweir return nTime; 4958cdf0e10cSrcweir } 4959cdf0e10cSrcweir 4960cdf0e10cSrcweir void VCLXTimeField::setFirst( sal_Int32 nTime ) throw(::com::sun::star::uno::RuntimeException) 4961cdf0e10cSrcweir { 4962cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4963cdf0e10cSrcweir 4964cdf0e10cSrcweir TimeField* pTimeField = (TimeField*) GetWindow(); 4965cdf0e10cSrcweir if ( pTimeField ) 4966cdf0e10cSrcweir pTimeField->SetFirst( nTime ); 4967cdf0e10cSrcweir } 4968cdf0e10cSrcweir 4969cdf0e10cSrcweir sal_Int32 VCLXTimeField::getFirst() throw(::com::sun::star::uno::RuntimeException) 4970cdf0e10cSrcweir { 4971cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4972cdf0e10cSrcweir 4973cdf0e10cSrcweir sal_Int32 nTime = 0; 4974cdf0e10cSrcweir TimeField* pTimeField = (TimeField*) GetWindow(); 4975cdf0e10cSrcweir if ( pTimeField ) 4976cdf0e10cSrcweir nTime = pTimeField->GetFirst().GetTime(); 4977cdf0e10cSrcweir 4978cdf0e10cSrcweir return nTime; 4979cdf0e10cSrcweir } 4980cdf0e10cSrcweir 4981cdf0e10cSrcweir void VCLXTimeField::setLast( sal_Int32 nTime ) throw(::com::sun::star::uno::RuntimeException) 4982cdf0e10cSrcweir { 4983cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4984cdf0e10cSrcweir 4985cdf0e10cSrcweir TimeField* pTimeField = (TimeField*) GetWindow(); 4986cdf0e10cSrcweir if ( pTimeField ) 4987cdf0e10cSrcweir pTimeField->SetLast( nTime ); 4988cdf0e10cSrcweir } 4989cdf0e10cSrcweir 4990cdf0e10cSrcweir sal_Int32 VCLXTimeField::getLast() throw(::com::sun::star::uno::RuntimeException) 4991cdf0e10cSrcweir { 4992cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 4993cdf0e10cSrcweir 4994cdf0e10cSrcweir sal_Int32 nTime = 0; 4995cdf0e10cSrcweir TimeField* pTimeField = (TimeField*) GetWindow(); 4996cdf0e10cSrcweir if ( pTimeField ) 4997cdf0e10cSrcweir nTime = pTimeField->GetLast().GetTime(); 4998cdf0e10cSrcweir 4999cdf0e10cSrcweir return nTime; 5000cdf0e10cSrcweir } 5001cdf0e10cSrcweir 5002cdf0e10cSrcweir void VCLXTimeField::setEmpty() throw(::com::sun::star::uno::RuntimeException) 5003cdf0e10cSrcweir { 5004cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5005cdf0e10cSrcweir 5006cdf0e10cSrcweir TimeField* pTimeField = (TimeField*) GetWindow(); 5007cdf0e10cSrcweir if ( pTimeField ) 5008cdf0e10cSrcweir pTimeField->SetEmptyTime(); 5009cdf0e10cSrcweir } 5010cdf0e10cSrcweir 5011cdf0e10cSrcweir sal_Bool VCLXTimeField::isEmpty() throw(::com::sun::star::uno::RuntimeException) 5012cdf0e10cSrcweir { 5013cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5014cdf0e10cSrcweir 5015cdf0e10cSrcweir TimeField* pTimeField = (TimeField*) GetWindow(); 5016cdf0e10cSrcweir return pTimeField ? pTimeField->IsEmptyTime() : sal_False; 5017cdf0e10cSrcweir } 5018cdf0e10cSrcweir 5019cdf0e10cSrcweir void VCLXTimeField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException) 5020cdf0e10cSrcweir { 5021cdf0e10cSrcweir VCLXFormattedSpinField::setStrictFormat( bStrict ); 5022cdf0e10cSrcweir } 5023cdf0e10cSrcweir 5024cdf0e10cSrcweir sal_Bool VCLXTimeField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException) 5025cdf0e10cSrcweir { 5026cdf0e10cSrcweir return VCLXFormattedSpinField::isStrictFormat(); 5027cdf0e10cSrcweir } 5028cdf0e10cSrcweir 5029cdf0e10cSrcweir 5030cdf0e10cSrcweir void VCLXTimeField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 5031cdf0e10cSrcweir { 5032cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5033cdf0e10cSrcweir 5034cdf0e10cSrcweir if ( GetWindow() ) 5035cdf0e10cSrcweir { 5036cdf0e10cSrcweir sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID; 5037cdf0e10cSrcweir 5038cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 5039cdf0e10cSrcweir switch ( nPropType ) 5040cdf0e10cSrcweir { 5041cdf0e10cSrcweir case BASEPROPERTY_TIME: 5042cdf0e10cSrcweir { 5043cdf0e10cSrcweir if ( bVoid ) 5044cdf0e10cSrcweir { 5045cdf0e10cSrcweir ((TimeField*)GetWindow())->EnableEmptyFieldValue( sal_True ); 5046cdf0e10cSrcweir ((TimeField*)GetWindow())->SetEmptyFieldValue(); 5047cdf0e10cSrcweir } 5048cdf0e10cSrcweir else 5049cdf0e10cSrcweir { 5050cdf0e10cSrcweir sal_Int32 n = 0; 5051cdf0e10cSrcweir if ( Value >>= n ) 5052cdf0e10cSrcweir setTime( n ); 5053cdf0e10cSrcweir } 5054cdf0e10cSrcweir } 5055cdf0e10cSrcweir break; 5056cdf0e10cSrcweir case BASEPROPERTY_TIMEMIN: 5057cdf0e10cSrcweir { 5058cdf0e10cSrcweir sal_Int32 n = 0; 5059cdf0e10cSrcweir if ( Value >>= n ) 5060cdf0e10cSrcweir setMin( n ); 5061cdf0e10cSrcweir } 5062cdf0e10cSrcweir break; 5063cdf0e10cSrcweir case BASEPROPERTY_TIMEMAX: 5064cdf0e10cSrcweir { 5065cdf0e10cSrcweir sal_Int32 n = 0; 5066cdf0e10cSrcweir if ( Value >>= n ) 5067cdf0e10cSrcweir setMax( n ); 5068cdf0e10cSrcweir } 5069cdf0e10cSrcweir break; 5070cdf0e10cSrcweir case BASEPROPERTY_EXTTIMEFORMAT: 5071cdf0e10cSrcweir { 5072cdf0e10cSrcweir sal_Int16 n = sal_Int16(); 5073cdf0e10cSrcweir if ( Value >>= n ) 5074cdf0e10cSrcweir ((TimeField*)GetWindow())->SetExtFormat( (ExtTimeFieldFormat) n ); 5075cdf0e10cSrcweir } 5076cdf0e10cSrcweir break; 5077cdf0e10cSrcweir case BASEPROPERTY_ENFORCE_FORMAT: 5078cdf0e10cSrcweir { 5079cdf0e10cSrcweir sal_Bool bEnforce( sal_True ); 5080cdf0e10cSrcweir OSL_VERIFY( Value >>= bEnforce ); 5081cdf0e10cSrcweir static_cast< TimeField* >( GetWindow() )->EnforceValidValue( bEnforce ); 5082cdf0e10cSrcweir } 5083cdf0e10cSrcweir break; 5084cdf0e10cSrcweir default: 5085cdf0e10cSrcweir { 5086cdf0e10cSrcweir VCLXFormattedSpinField::setProperty( PropertyName, Value ); 5087cdf0e10cSrcweir } 5088cdf0e10cSrcweir } 5089cdf0e10cSrcweir } 5090cdf0e10cSrcweir } 5091cdf0e10cSrcweir 5092cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXTimeField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) 5093cdf0e10cSrcweir { 5094cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5095cdf0e10cSrcweir 5096cdf0e10cSrcweir ::com::sun::star::uno::Any aProp; 5097cdf0e10cSrcweir if ( GetWindow() ) 5098cdf0e10cSrcweir { 5099cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 5100cdf0e10cSrcweir switch ( nPropType ) 5101cdf0e10cSrcweir { 5102cdf0e10cSrcweir case BASEPROPERTY_TIME: 5103cdf0e10cSrcweir { 5104cdf0e10cSrcweir aProp <<= (sal_Int32) getTime(); 5105cdf0e10cSrcweir } 5106cdf0e10cSrcweir break; 5107cdf0e10cSrcweir case BASEPROPERTY_TIMEMIN: 5108cdf0e10cSrcweir { 5109cdf0e10cSrcweir aProp <<= (sal_Int32) getMin(); 5110cdf0e10cSrcweir } 5111cdf0e10cSrcweir break; 5112cdf0e10cSrcweir case BASEPROPERTY_TIMEMAX: 5113cdf0e10cSrcweir { 5114cdf0e10cSrcweir aProp <<= (sal_Int32) getMax(); 5115cdf0e10cSrcweir } 5116cdf0e10cSrcweir break; 5117cdf0e10cSrcweir case BASEPROPERTY_ENFORCE_FORMAT: 5118cdf0e10cSrcweir { 5119cdf0e10cSrcweir aProp <<= (sal_Bool)static_cast< TimeField* >( GetWindow() )->IsEnforceValidValue( ); 5120cdf0e10cSrcweir } 5121cdf0e10cSrcweir break; 5122cdf0e10cSrcweir default: 5123cdf0e10cSrcweir { 5124cdf0e10cSrcweir aProp <<= VCLXFormattedSpinField::getProperty( PropertyName ); 5125cdf0e10cSrcweir } 5126cdf0e10cSrcweir } 5127cdf0e10cSrcweir } 5128cdf0e10cSrcweir return aProp; 5129cdf0e10cSrcweir } 5130cdf0e10cSrcweir 5131cdf0e10cSrcweir // ---------------------------------------------------- 5132cdf0e10cSrcweir // class VCLXNumericField 5133cdf0e10cSrcweir // ---------------------------------------------------- 5134cdf0e10cSrcweir 5135cdf0e10cSrcweir void VCLXNumericField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 5136cdf0e10cSrcweir { 5137cdf0e10cSrcweir PushPropertyIds( rIds, 5138cdf0e10cSrcweir BASEPROPERTY_ALIGN, 5139cdf0e10cSrcweir BASEPROPERTY_BACKGROUNDCOLOR, 5140cdf0e10cSrcweir BASEPROPERTY_BORDER, 5141cdf0e10cSrcweir BASEPROPERTY_BORDERCOLOR, 5142cdf0e10cSrcweir BASEPROPERTY_DECIMALACCURACY, 5143cdf0e10cSrcweir BASEPROPERTY_DEFAULTCONTROL, 5144cdf0e10cSrcweir BASEPROPERTY_ENABLED, 5145cdf0e10cSrcweir BASEPROPERTY_ENABLEVISIBLE, 5146cdf0e10cSrcweir BASEPROPERTY_FONTDESCRIPTOR, 5147cdf0e10cSrcweir BASEPROPERTY_HELPTEXT, 5148cdf0e10cSrcweir BASEPROPERTY_HELPURL, 5149cdf0e10cSrcweir BASEPROPERTY_NUMSHOWTHOUSANDSEP, 5150cdf0e10cSrcweir BASEPROPERTY_PRINTABLE, 5151cdf0e10cSrcweir BASEPROPERTY_READONLY, 5152cdf0e10cSrcweir BASEPROPERTY_REPEAT, 5153cdf0e10cSrcweir BASEPROPERTY_REPEAT_DELAY, 5154cdf0e10cSrcweir BASEPROPERTY_SPIN, 5155cdf0e10cSrcweir BASEPROPERTY_STRICTFORMAT, 5156cdf0e10cSrcweir BASEPROPERTY_TABSTOP, 5157cdf0e10cSrcweir BASEPROPERTY_VALUEMAX_DOUBLE, 5158cdf0e10cSrcweir BASEPROPERTY_VALUEMIN_DOUBLE, 5159cdf0e10cSrcweir BASEPROPERTY_VALUESTEP_DOUBLE, 5160cdf0e10cSrcweir BASEPROPERTY_VALUE_DOUBLE, 5161cdf0e10cSrcweir BASEPROPERTY_ENFORCE_FORMAT, 5162cdf0e10cSrcweir BASEPROPERTY_HIDEINACTIVESELECTION, 5163cdf0e10cSrcweir BASEPROPERTY_VERTICALALIGN, 5164cdf0e10cSrcweir BASEPROPERTY_WRITING_MODE, 5165cdf0e10cSrcweir BASEPROPERTY_CONTEXT_WRITING_MODE, 5166cdf0e10cSrcweir BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, 5167cdf0e10cSrcweir 0); 5168cdf0e10cSrcweir VCLXFormattedSpinField::ImplGetPropertyIds( rIds ); 5169cdf0e10cSrcweir } 5170cdf0e10cSrcweir 5171cdf0e10cSrcweir VCLXNumericField::VCLXNumericField() 5172cdf0e10cSrcweir { 5173cdf0e10cSrcweir } 5174cdf0e10cSrcweir 5175cdf0e10cSrcweir VCLXNumericField::~VCLXNumericField() 5176cdf0e10cSrcweir { 5177cdf0e10cSrcweir } 5178cdf0e10cSrcweir 5179cdf0e10cSrcweir // ::com::sun::star::uno::XInterface 5180cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXNumericField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 5181cdf0e10cSrcweir { 5182cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 5183cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XNumericField*, this ) ); 5184cdf0e10cSrcweir return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType )); 5185cdf0e10cSrcweir } 5186cdf0e10cSrcweir 5187cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 5188cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXNumericField ) 5189cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XNumericField>* ) NULL ), 5190cdf0e10cSrcweir VCLXFormattedSpinField::getTypes() 5191cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 5192cdf0e10cSrcweir 5193cdf0e10cSrcweir void VCLXNumericField::setValue( double Value ) throw(::com::sun::star::uno::RuntimeException) 5194cdf0e10cSrcweir { 5195cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5196cdf0e10cSrcweir 5197cdf0e10cSrcweir NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter(); 5198cdf0e10cSrcweir if ( pNumericFormatter ) 5199cdf0e10cSrcweir { 5200cdf0e10cSrcweir // z.B. 105, 2 Digits => 1,05 5201cdf0e10cSrcweir // ein float 1,05 muss also eine 105 einstellen... 5202cdf0e10cSrcweir pNumericFormatter->SetValue( 5203cdf0e10cSrcweir (long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) ); 5204cdf0e10cSrcweir 5205cdf0e10cSrcweir // #107218# Call same listeners like VCL would do after user interaction 5206cdf0e10cSrcweir Edit* pEdit = (Edit*)GetWindow(); 5207cdf0e10cSrcweir if ( pEdit ) 5208cdf0e10cSrcweir { 5209cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_True ); 5210cdf0e10cSrcweir pEdit->SetModifyFlag(); 5211cdf0e10cSrcweir pEdit->Modify(); 5212cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_False ); 5213cdf0e10cSrcweir } 5214cdf0e10cSrcweir } 5215cdf0e10cSrcweir } 5216cdf0e10cSrcweir 5217cdf0e10cSrcweir double VCLXNumericField::getValue() throw(::com::sun::star::uno::RuntimeException) 5218cdf0e10cSrcweir { 5219cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5220cdf0e10cSrcweir 5221cdf0e10cSrcweir NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter(); 5222cdf0e10cSrcweir return pNumericFormatter 5223cdf0e10cSrcweir ? ImplCalcDoubleValue( (double)pNumericFormatter->GetValue(), pNumericFormatter->GetDecimalDigits() ) 5224cdf0e10cSrcweir : 0; 5225cdf0e10cSrcweir } 5226cdf0e10cSrcweir 5227cdf0e10cSrcweir void VCLXNumericField::setMin( double Value ) throw(::com::sun::star::uno::RuntimeException) 5228cdf0e10cSrcweir { 5229cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5230cdf0e10cSrcweir 5231cdf0e10cSrcweir NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter(); 5232cdf0e10cSrcweir if ( pNumericFormatter ) 5233cdf0e10cSrcweir pNumericFormatter->SetMin( 5234cdf0e10cSrcweir (long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) ); 5235cdf0e10cSrcweir } 5236cdf0e10cSrcweir 5237cdf0e10cSrcweir double VCLXNumericField::getMin() throw(::com::sun::star::uno::RuntimeException) 5238cdf0e10cSrcweir { 5239cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5240cdf0e10cSrcweir 5241cdf0e10cSrcweir NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter(); 5242cdf0e10cSrcweir return pNumericFormatter 5243cdf0e10cSrcweir ? ImplCalcDoubleValue( (double)pNumericFormatter->GetMin(), pNumericFormatter->GetDecimalDigits() ) 5244cdf0e10cSrcweir : 0; 5245cdf0e10cSrcweir } 5246cdf0e10cSrcweir 5247cdf0e10cSrcweir void VCLXNumericField::setMax( double Value ) throw(::com::sun::star::uno::RuntimeException) 5248cdf0e10cSrcweir { 5249cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5250cdf0e10cSrcweir 5251cdf0e10cSrcweir NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter(); 5252cdf0e10cSrcweir if ( pNumericFormatter ) 5253cdf0e10cSrcweir pNumericFormatter->SetMax( 5254cdf0e10cSrcweir (long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) ); 5255cdf0e10cSrcweir } 5256cdf0e10cSrcweir 5257cdf0e10cSrcweir double VCLXNumericField::getMax() throw(::com::sun::star::uno::RuntimeException) 5258cdf0e10cSrcweir { 5259cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5260cdf0e10cSrcweir 5261cdf0e10cSrcweir NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter(); 5262cdf0e10cSrcweir return pNumericFormatter 5263cdf0e10cSrcweir ? ImplCalcDoubleValue( (double)pNumericFormatter->GetMax(), pNumericFormatter->GetDecimalDigits() ) 5264cdf0e10cSrcweir : 0; 5265cdf0e10cSrcweir } 5266cdf0e10cSrcweir 5267cdf0e10cSrcweir void VCLXNumericField::setFirst( double Value ) throw(::com::sun::star::uno::RuntimeException) 5268cdf0e10cSrcweir { 5269cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5270cdf0e10cSrcweir 5271cdf0e10cSrcweir NumericField* pNumericField = (NumericField*) GetWindow(); 5272cdf0e10cSrcweir if ( pNumericField ) 5273cdf0e10cSrcweir pNumericField->SetFirst( 5274cdf0e10cSrcweir (long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) ); 5275cdf0e10cSrcweir } 5276cdf0e10cSrcweir 5277cdf0e10cSrcweir double VCLXNumericField::getFirst() throw(::com::sun::star::uno::RuntimeException) 5278cdf0e10cSrcweir { 5279cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5280cdf0e10cSrcweir 5281cdf0e10cSrcweir NumericField* pNumericField = (NumericField*) GetWindow(); 5282cdf0e10cSrcweir return pNumericField 5283cdf0e10cSrcweir ? ImplCalcDoubleValue( (double)pNumericField->GetFirst(), pNumericField->GetDecimalDigits() ) 5284cdf0e10cSrcweir : 0; 5285cdf0e10cSrcweir } 5286cdf0e10cSrcweir 5287cdf0e10cSrcweir void VCLXNumericField::setLast( double Value ) throw(::com::sun::star::uno::RuntimeException) 5288cdf0e10cSrcweir { 5289cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5290cdf0e10cSrcweir 5291cdf0e10cSrcweir NumericField* pNumericField = (NumericField*) GetWindow(); 5292cdf0e10cSrcweir if ( pNumericField ) 5293cdf0e10cSrcweir pNumericField->SetLast( 5294cdf0e10cSrcweir (long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) ); 5295cdf0e10cSrcweir } 5296cdf0e10cSrcweir 5297cdf0e10cSrcweir double VCLXNumericField::getLast() throw(::com::sun::star::uno::RuntimeException) 5298cdf0e10cSrcweir { 5299cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5300cdf0e10cSrcweir 5301cdf0e10cSrcweir NumericField* pNumericField = (NumericField*) GetWindow(); 5302cdf0e10cSrcweir return pNumericField 5303cdf0e10cSrcweir ? ImplCalcDoubleValue( (double)pNumericField->GetLast(), pNumericField->GetDecimalDigits() ) 5304cdf0e10cSrcweir : 0; 5305cdf0e10cSrcweir } 5306cdf0e10cSrcweir 5307cdf0e10cSrcweir void VCLXNumericField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException) 5308cdf0e10cSrcweir { 5309cdf0e10cSrcweir VCLXFormattedSpinField::setStrictFormat( bStrict ); 5310cdf0e10cSrcweir } 5311cdf0e10cSrcweir 5312cdf0e10cSrcweir sal_Bool VCLXNumericField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException) 5313cdf0e10cSrcweir { 5314cdf0e10cSrcweir return VCLXFormattedSpinField::isStrictFormat(); 5315cdf0e10cSrcweir } 5316cdf0e10cSrcweir 5317cdf0e10cSrcweir 5318cdf0e10cSrcweir void VCLXNumericField::setSpinSize( double Value ) throw(::com::sun::star::uno::RuntimeException) 5319cdf0e10cSrcweir { 5320cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5321cdf0e10cSrcweir 5322cdf0e10cSrcweir NumericField* pNumericField = (NumericField*) GetWindow(); 5323cdf0e10cSrcweir if ( pNumericField ) 5324cdf0e10cSrcweir pNumericField->SetSpinSize( 5325cdf0e10cSrcweir (long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) ); 5326cdf0e10cSrcweir } 5327cdf0e10cSrcweir 5328cdf0e10cSrcweir double VCLXNumericField::getSpinSize() throw(::com::sun::star::uno::RuntimeException) 5329cdf0e10cSrcweir { 5330cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5331cdf0e10cSrcweir 5332cdf0e10cSrcweir NumericField* pNumericField = (NumericField*) GetWindow(); 5333cdf0e10cSrcweir return pNumericField 5334cdf0e10cSrcweir ? ImplCalcDoubleValue( (double)pNumericField->GetSpinSize(), pNumericField->GetDecimalDigits() ) 5335cdf0e10cSrcweir : 0; 5336cdf0e10cSrcweir } 5337cdf0e10cSrcweir 5338cdf0e10cSrcweir void VCLXNumericField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException) 5339cdf0e10cSrcweir { 5340cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5341cdf0e10cSrcweir 5342cdf0e10cSrcweir NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter(); 5343cdf0e10cSrcweir if ( pNumericFormatter ) 5344cdf0e10cSrcweir { 5345cdf0e10cSrcweir double n = getValue(); 5346cdf0e10cSrcweir pNumericFormatter->SetDecimalDigits( Value ); 5347cdf0e10cSrcweir setValue( n ); 5348cdf0e10cSrcweir } 5349cdf0e10cSrcweir } 5350cdf0e10cSrcweir 5351cdf0e10cSrcweir sal_Int16 VCLXNumericField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException) 5352cdf0e10cSrcweir { 5353cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5354cdf0e10cSrcweir 5355cdf0e10cSrcweir NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter(); 5356cdf0e10cSrcweir return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0; 5357cdf0e10cSrcweir } 5358cdf0e10cSrcweir 5359cdf0e10cSrcweir void VCLXNumericField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 5360cdf0e10cSrcweir { 5361cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5362cdf0e10cSrcweir 5363cdf0e10cSrcweir if ( GetWindow() ) 5364cdf0e10cSrcweir { 5365cdf0e10cSrcweir sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID; 5366cdf0e10cSrcweir 5367cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 5368cdf0e10cSrcweir switch ( nPropType ) 5369cdf0e10cSrcweir { 5370cdf0e10cSrcweir case BASEPROPERTY_VALUE_DOUBLE: 5371cdf0e10cSrcweir { 5372cdf0e10cSrcweir if ( bVoid ) 5373cdf0e10cSrcweir { 5374cdf0e10cSrcweir ((NumericField*)GetWindow())->EnableEmptyFieldValue( sal_True ); 5375cdf0e10cSrcweir ((NumericField*)GetWindow())->SetEmptyFieldValue(); 5376cdf0e10cSrcweir } 5377cdf0e10cSrcweir else 5378cdf0e10cSrcweir { 5379cdf0e10cSrcweir double d = 0; 5380cdf0e10cSrcweir if ( Value >>= d ) 5381cdf0e10cSrcweir setValue( d ); 5382cdf0e10cSrcweir } 5383cdf0e10cSrcweir } 5384cdf0e10cSrcweir break; 5385cdf0e10cSrcweir case BASEPROPERTY_VALUEMIN_DOUBLE: 5386cdf0e10cSrcweir { 5387cdf0e10cSrcweir double d = 0; 5388cdf0e10cSrcweir if ( Value >>= d ) 5389cdf0e10cSrcweir setMin( d ); 5390cdf0e10cSrcweir } 5391cdf0e10cSrcweir break; 5392cdf0e10cSrcweir case BASEPROPERTY_VALUEMAX_DOUBLE: 5393cdf0e10cSrcweir { 5394cdf0e10cSrcweir double d = 0; 5395cdf0e10cSrcweir if ( Value >>= d ) 5396cdf0e10cSrcweir setMax( d ); 5397cdf0e10cSrcweir } 5398cdf0e10cSrcweir break; 5399cdf0e10cSrcweir case BASEPROPERTY_VALUESTEP_DOUBLE: 5400cdf0e10cSrcweir { 5401cdf0e10cSrcweir double d = 0; 5402cdf0e10cSrcweir if ( Value >>= d ) 5403cdf0e10cSrcweir setSpinSize( d ); 5404cdf0e10cSrcweir } 5405cdf0e10cSrcweir break; 5406cdf0e10cSrcweir case BASEPROPERTY_DECIMALACCURACY: 5407cdf0e10cSrcweir { 5408cdf0e10cSrcweir sal_Int16 n = sal_Int16(); 5409cdf0e10cSrcweir if ( Value >>= n ) 5410cdf0e10cSrcweir setDecimalDigits( n ); 5411cdf0e10cSrcweir } 5412cdf0e10cSrcweir break; 5413cdf0e10cSrcweir case BASEPROPERTY_NUMSHOWTHOUSANDSEP: 5414cdf0e10cSrcweir { 5415cdf0e10cSrcweir sal_Bool b = sal_Bool(); 5416cdf0e10cSrcweir if ( Value >>= b ) 5417cdf0e10cSrcweir ((NumericField*)GetWindow())->SetUseThousandSep( b ); 5418cdf0e10cSrcweir } 5419cdf0e10cSrcweir break; 5420cdf0e10cSrcweir default: 5421cdf0e10cSrcweir { 5422cdf0e10cSrcweir VCLXFormattedSpinField::setProperty( PropertyName, Value ); 5423cdf0e10cSrcweir } 5424cdf0e10cSrcweir } 5425cdf0e10cSrcweir } 5426cdf0e10cSrcweir } 5427cdf0e10cSrcweir 5428cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXNumericField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) 5429cdf0e10cSrcweir { 5430cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5431cdf0e10cSrcweir 5432cdf0e10cSrcweir ::com::sun::star::uno::Any aProp; 5433cdf0e10cSrcweir FormatterBase* pFormatter = GetFormatter(); 5434cdf0e10cSrcweir if ( pFormatter ) 5435cdf0e10cSrcweir { 5436cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 5437cdf0e10cSrcweir switch ( nPropType ) 5438cdf0e10cSrcweir { 5439cdf0e10cSrcweir case BASEPROPERTY_VALUE_DOUBLE: 5440cdf0e10cSrcweir { 5441cdf0e10cSrcweir aProp <<= (double) getValue(); 5442cdf0e10cSrcweir } 5443cdf0e10cSrcweir break; 5444cdf0e10cSrcweir case BASEPROPERTY_VALUEMIN_DOUBLE: 5445cdf0e10cSrcweir { 5446cdf0e10cSrcweir aProp <<= (double) getMin(); 5447cdf0e10cSrcweir } 5448cdf0e10cSrcweir break; 5449cdf0e10cSrcweir case BASEPROPERTY_VALUEMAX_DOUBLE: 5450cdf0e10cSrcweir { 5451cdf0e10cSrcweir aProp <<= (double) getMax(); 5452cdf0e10cSrcweir } 5453cdf0e10cSrcweir break; 5454cdf0e10cSrcweir case BASEPROPERTY_VALUESTEP_DOUBLE: 5455cdf0e10cSrcweir { 5456cdf0e10cSrcweir aProp <<= (double) getSpinSize(); 5457cdf0e10cSrcweir } 5458cdf0e10cSrcweir break; 5459cdf0e10cSrcweir case BASEPROPERTY_NUMSHOWTHOUSANDSEP: 5460cdf0e10cSrcweir { 5461cdf0e10cSrcweir aProp <<= (sal_Bool) ((NumericField*)GetWindow())->IsUseThousandSep(); 5462cdf0e10cSrcweir } 5463cdf0e10cSrcweir break; 5464cdf0e10cSrcweir default: 5465cdf0e10cSrcweir { 5466cdf0e10cSrcweir aProp <<= VCLXFormattedSpinField::getProperty( PropertyName ); 5467cdf0e10cSrcweir } 5468cdf0e10cSrcweir } 5469cdf0e10cSrcweir } 5470cdf0e10cSrcweir return aProp; 5471cdf0e10cSrcweir } 5472cdf0e10cSrcweir 5473cdf0e10cSrcweir 5474cdf0e10cSrcweir // ---------------------------------------------------- 5475cdf0e10cSrcweir // class VCLXMetricField 5476cdf0e10cSrcweir // ---------------------------------------------------- 5477cdf0e10cSrcweir 5478cdf0e10cSrcweir void VCLXMetricField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 5479cdf0e10cSrcweir { 5480cdf0e10cSrcweir PushPropertyIds( rIds, 5481cdf0e10cSrcweir BASEPROPERTY_ALIGN, 5482cdf0e10cSrcweir BASEPROPERTY_BACKGROUNDCOLOR, 5483cdf0e10cSrcweir BASEPROPERTY_BORDER, 5484cdf0e10cSrcweir BASEPROPERTY_BORDERCOLOR, 5485cdf0e10cSrcweir BASEPROPERTY_DECIMALACCURACY, 5486cdf0e10cSrcweir BASEPROPERTY_DEFAULTCONTROL, 5487cdf0e10cSrcweir BASEPROPERTY_ENABLED, 5488cdf0e10cSrcweir BASEPROPERTY_ENABLEVISIBLE, 5489cdf0e10cSrcweir BASEPROPERTY_FONTDESCRIPTOR, 5490cdf0e10cSrcweir BASEPROPERTY_HELPTEXT, 5491cdf0e10cSrcweir BASEPROPERTY_HELPURL, 5492cdf0e10cSrcweir BASEPROPERTY_NUMSHOWTHOUSANDSEP, 5493cdf0e10cSrcweir BASEPROPERTY_PRINTABLE, 5494cdf0e10cSrcweir BASEPROPERTY_READONLY, 5495cdf0e10cSrcweir BASEPROPERTY_REPEAT, 5496cdf0e10cSrcweir BASEPROPERTY_REPEAT_DELAY, 5497cdf0e10cSrcweir BASEPROPERTY_SPIN, 5498cdf0e10cSrcweir BASEPROPERTY_STRICTFORMAT, 5499cdf0e10cSrcweir BASEPROPERTY_TABSTOP, 5500cdf0e10cSrcweir BASEPROPERTY_ENFORCE_FORMAT, 5501cdf0e10cSrcweir BASEPROPERTY_HIDEINACTIVESELECTION, 5502cdf0e10cSrcweir BASEPROPERTY_UNIT, 5503cdf0e10cSrcweir BASEPROPERTY_CUSTOMUNITTEXT, 5504cdf0e10cSrcweir BASEPROPERTY_WRITING_MODE, 5505cdf0e10cSrcweir BASEPROPERTY_CONTEXT_WRITING_MODE, 5506cdf0e10cSrcweir BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, 5507cdf0e10cSrcweir 0); 5508cdf0e10cSrcweir VCLXFormattedSpinField::ImplGetPropertyIds( rIds ); 5509cdf0e10cSrcweir } 5510cdf0e10cSrcweir 5511cdf0e10cSrcweir VCLXMetricField::VCLXMetricField() 5512cdf0e10cSrcweir { 5513cdf0e10cSrcweir } 5514cdf0e10cSrcweir 5515cdf0e10cSrcweir VCLXMetricField::~VCLXMetricField() 5516cdf0e10cSrcweir { 5517cdf0e10cSrcweir } 5518cdf0e10cSrcweir 5519cdf0e10cSrcweir MetricFormatter *VCLXMetricField::GetMetricFormatter() throw(::com::sun::star::uno::RuntimeException) 5520cdf0e10cSrcweir { 5521cdf0e10cSrcweir MetricFormatter *pFormatter = (MetricFormatter *) GetFormatter(); 5522cdf0e10cSrcweir if (!pFormatter) 5523cdf0e10cSrcweir throw ::com::sun::star::uno::RuntimeException(); 5524cdf0e10cSrcweir return pFormatter; 5525cdf0e10cSrcweir } 5526cdf0e10cSrcweir 5527cdf0e10cSrcweir MetricField *VCLXMetricField::GetMetricField() throw(::com::sun::star::uno::RuntimeException) 5528cdf0e10cSrcweir { 5529cdf0e10cSrcweir MetricField *pField = (MetricField *) GetWindow(); 5530cdf0e10cSrcweir if (!pField) 5531cdf0e10cSrcweir throw ::com::sun::star::uno::RuntimeException(); 5532cdf0e10cSrcweir return pField; 5533cdf0e10cSrcweir } 5534cdf0e10cSrcweir 5535cdf0e10cSrcweir // ::com::sun::star::uno::XInterface 5536cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXMetricField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 5537cdf0e10cSrcweir { 5538cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 5539cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XMetricField*, this ) ); 5540cdf0e10cSrcweir return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType )); 5541cdf0e10cSrcweir } 5542cdf0e10cSrcweir 5543cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 5544cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXMetricField ) 5545cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMetricField>* ) NULL ), 5546cdf0e10cSrcweir VCLXFormattedSpinField::getTypes() 5547cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 5548cdf0e10cSrcweir 5549cdf0e10cSrcweir // FIXME: later ... 5550cdf0e10cSrcweir #define MetricUnitUnoToVcl(a) ((FieldUnit)(a)) 5551cdf0e10cSrcweir 5552cdf0e10cSrcweir #define METRIC_MAP_PAIR(method,parent) \ 5553cdf0e10cSrcweir sal_Int64 VCLXMetricField::get##method( sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException) \ 5554cdf0e10cSrcweir { \ 5555cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); \ 5556cdf0e10cSrcweir return GetMetric##parent()->Get##method( MetricUnitUnoToVcl( nUnit ) ); \ 5557cdf0e10cSrcweir } \ 5558cdf0e10cSrcweir void VCLXMetricField::set##method( sal_Int64 nValue, sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException) \ 5559cdf0e10cSrcweir { \ 5560cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); \ 5561cdf0e10cSrcweir GetMetric##parent()->Set##method( nValue, MetricUnitUnoToVcl( nUnit ) ); \ 5562cdf0e10cSrcweir } 5563cdf0e10cSrcweir 5564cdf0e10cSrcweir METRIC_MAP_PAIR(Min, Formatter) 5565cdf0e10cSrcweir METRIC_MAP_PAIR(Max, Formatter) 5566cdf0e10cSrcweir METRIC_MAP_PAIR(First, Field) 5567cdf0e10cSrcweir METRIC_MAP_PAIR(Last, Field) 5568cdf0e10cSrcweir 5569cdf0e10cSrcweir #undef METRIC_MAP_PAIR 5570cdf0e10cSrcweir 5571cdf0e10cSrcweir ::sal_Int64 VCLXMetricField::getValue( ::sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException) 5572cdf0e10cSrcweir { 5573cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5574cdf0e10cSrcweir return GetMetricFormatter()->GetValue( MetricUnitUnoToVcl( nUnit ) ); 5575cdf0e10cSrcweir } 5576cdf0e10cSrcweir 5577cdf0e10cSrcweir ::sal_Int64 VCLXMetricField::getCorrectedValue( ::sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException) 5578cdf0e10cSrcweir { 5579cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5580cdf0e10cSrcweir return GetMetricFormatter()->GetCorrectedValue( MetricUnitUnoToVcl( nUnit ) ); 5581cdf0e10cSrcweir } 5582cdf0e10cSrcweir 5583cdf0e10cSrcweir // FIXME: acute cut/paste evilness - move this to the parent Edit class ? 5584cdf0e10cSrcweir void VCLXMetricField::CallListeners() 5585cdf0e10cSrcweir { 5586cdf0e10cSrcweir // #107218# Call same listeners like VCL would do after user interaction 5587cdf0e10cSrcweir Edit* pEdit = (Edit*)GetWindow(); 5588cdf0e10cSrcweir if ( pEdit ) 5589cdf0e10cSrcweir { 5590cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_True ); 5591cdf0e10cSrcweir pEdit->SetModifyFlag(); 5592cdf0e10cSrcweir pEdit->Modify(); 5593cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_False ); 5594cdf0e10cSrcweir } 5595cdf0e10cSrcweir } 5596cdf0e10cSrcweir 5597cdf0e10cSrcweir void VCLXMetricField::setValue( ::sal_Int64 Value, ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException) 5598cdf0e10cSrcweir { 5599cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5600cdf0e10cSrcweir GetMetricFormatter()->SetValue( Value, MetricUnitUnoToVcl( Unit ) ); 5601cdf0e10cSrcweir CallListeners(); 5602cdf0e10cSrcweir } 5603cdf0e10cSrcweir 5604cdf0e10cSrcweir void VCLXMetricField::setUserValue( ::sal_Int64 Value, ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException) 5605cdf0e10cSrcweir { 5606cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5607cdf0e10cSrcweir GetMetricFormatter()->SetUserValue( Value, MetricUnitUnoToVcl( Unit ) ); 5608cdf0e10cSrcweir CallListeners(); 5609cdf0e10cSrcweir } 5610cdf0e10cSrcweir 5611cdf0e10cSrcweir void VCLXMetricField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException) 5612cdf0e10cSrcweir { 5613cdf0e10cSrcweir VCLXFormattedSpinField::setStrictFormat( bStrict ); 5614cdf0e10cSrcweir } 5615cdf0e10cSrcweir 5616cdf0e10cSrcweir sal_Bool VCLXMetricField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException) 5617cdf0e10cSrcweir { 5618cdf0e10cSrcweir return VCLXFormattedSpinField::isStrictFormat(); 5619cdf0e10cSrcweir } 5620cdf0e10cSrcweir 5621cdf0e10cSrcweir void VCLXMetricField::setSpinSize( sal_Int64 Value ) throw(::com::sun::star::uno::RuntimeException) 5622cdf0e10cSrcweir { 5623cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5624cdf0e10cSrcweir GetMetricField()->SetSpinSize( Value ); 5625cdf0e10cSrcweir } 5626cdf0e10cSrcweir 5627cdf0e10cSrcweir sal_Int64 VCLXMetricField::getSpinSize() throw(::com::sun::star::uno::RuntimeException) 5628cdf0e10cSrcweir { 5629cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5630cdf0e10cSrcweir return GetMetricField()->GetSpinSize(); 5631cdf0e10cSrcweir } 5632cdf0e10cSrcweir 5633cdf0e10cSrcweir void VCLXMetricField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException) 5634cdf0e10cSrcweir { 5635cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5636cdf0e10cSrcweir GetMetricFormatter()->SetDecimalDigits( Value ); 5637cdf0e10cSrcweir } 5638cdf0e10cSrcweir 5639cdf0e10cSrcweir sal_Int16 VCLXMetricField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException) 5640cdf0e10cSrcweir { 5641cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5642cdf0e10cSrcweir 5643cdf0e10cSrcweir NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter(); 5644cdf0e10cSrcweir return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0; 5645cdf0e10cSrcweir } 5646cdf0e10cSrcweir 5647cdf0e10cSrcweir void VCLXMetricField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 5648cdf0e10cSrcweir { 5649cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5650cdf0e10cSrcweir 5651cdf0e10cSrcweir if ( GetWindow() ) 5652cdf0e10cSrcweir { 5653cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 5654cdf0e10cSrcweir switch ( nPropType ) 5655cdf0e10cSrcweir { 5656cdf0e10cSrcweir case BASEPROPERTY_DECIMALACCURACY: 5657cdf0e10cSrcweir { 5658cdf0e10cSrcweir sal_Int16 n = 0; 5659cdf0e10cSrcweir if ( Value >>= n ) 5660cdf0e10cSrcweir setDecimalDigits( n ); 5661cdf0e10cSrcweir break; 5662cdf0e10cSrcweir } 5663cdf0e10cSrcweir case BASEPROPERTY_NUMSHOWTHOUSANDSEP: 5664cdf0e10cSrcweir { 5665cdf0e10cSrcweir sal_Bool b = sal_False; 5666cdf0e10cSrcweir if ( Value >>= b ) 5667cdf0e10cSrcweir ((NumericField*)GetWindow())->SetUseThousandSep( b ); 5668cdf0e10cSrcweir } 5669cdf0e10cSrcweir break; 5670cdf0e10cSrcweir case BASEPROPERTY_UNIT: 5671cdf0e10cSrcweir { 5672cdf0e10cSrcweir sal_uInt16 nVal = 0; 5673cdf0e10cSrcweir if ( Value >>= nVal ) 5674cdf0e10cSrcweir ((MetricField*)GetWindow())->SetUnit( (FieldUnit) nVal ); 5675cdf0e10cSrcweir break; 5676cdf0e10cSrcweir } 5677cdf0e10cSrcweir case BASEPROPERTY_CUSTOMUNITTEXT: 5678cdf0e10cSrcweir { 5679cdf0e10cSrcweir rtl::OUString aStr; 5680cdf0e10cSrcweir if ( Value >>= aStr ) 5681cdf0e10cSrcweir ((MetricField*)GetWindow())->SetCustomUnitText( aStr ); 5682cdf0e10cSrcweir break; 5683cdf0e10cSrcweir } 5684cdf0e10cSrcweir default: 5685cdf0e10cSrcweir { 5686cdf0e10cSrcweir VCLXFormattedSpinField::setProperty( PropertyName, Value ); 5687cdf0e10cSrcweir break; 5688cdf0e10cSrcweir } 5689cdf0e10cSrcweir } 5690cdf0e10cSrcweir } 5691cdf0e10cSrcweir } 5692cdf0e10cSrcweir 5693cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXMetricField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) 5694cdf0e10cSrcweir { 5695cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5696cdf0e10cSrcweir 5697cdf0e10cSrcweir ::com::sun::star::uno::Any aProp; 5698cdf0e10cSrcweir FormatterBase* pFormatter = GetFormatter(); 5699cdf0e10cSrcweir if ( pFormatter ) 5700cdf0e10cSrcweir { 5701cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 5702cdf0e10cSrcweir switch ( nPropType ) 5703cdf0e10cSrcweir { 5704cdf0e10cSrcweir case BASEPROPERTY_NUMSHOWTHOUSANDSEP: 5705cdf0e10cSrcweir aProp <<= (sal_Bool) ((NumericField*)GetWindow())->IsUseThousandSep(); 5706cdf0e10cSrcweir break; 5707cdf0e10cSrcweir case BASEPROPERTY_UNIT: 5708cdf0e10cSrcweir aProp <<= (sal_uInt16) ((MetricField*)GetWindow())->GetUnit(); 5709cdf0e10cSrcweir break; 5710cdf0e10cSrcweir case BASEPROPERTY_CUSTOMUNITTEXT: 5711cdf0e10cSrcweir aProp <<= rtl::OUString (((MetricField*)GetWindow())->GetCustomUnitText()); 5712cdf0e10cSrcweir break; 5713cdf0e10cSrcweir default: 5714cdf0e10cSrcweir { 5715cdf0e10cSrcweir aProp <<= VCLXFormattedSpinField::getProperty( PropertyName ); 5716cdf0e10cSrcweir break; 5717cdf0e10cSrcweir } 5718cdf0e10cSrcweir } 5719cdf0e10cSrcweir } 5720cdf0e10cSrcweir return aProp; 5721cdf0e10cSrcweir } 5722cdf0e10cSrcweir 5723cdf0e10cSrcweir 5724cdf0e10cSrcweir // ---------------------------------------------------- 5725cdf0e10cSrcweir // class VCLXCurrencyField 5726cdf0e10cSrcweir // ---------------------------------------------------- 5727cdf0e10cSrcweir 5728cdf0e10cSrcweir void VCLXCurrencyField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 5729cdf0e10cSrcweir { 5730cdf0e10cSrcweir PushPropertyIds( rIds, 5731cdf0e10cSrcweir BASEPROPERTY_ALIGN, 5732cdf0e10cSrcweir BASEPROPERTY_BACKGROUNDCOLOR, 5733cdf0e10cSrcweir BASEPROPERTY_BORDER, 5734cdf0e10cSrcweir BASEPROPERTY_BORDERCOLOR, 5735cdf0e10cSrcweir BASEPROPERTY_CURRENCYSYMBOL, 5736cdf0e10cSrcweir BASEPROPERTY_CURSYM_POSITION, 5737cdf0e10cSrcweir BASEPROPERTY_DECIMALACCURACY, 5738cdf0e10cSrcweir BASEPROPERTY_DEFAULTCONTROL, 5739cdf0e10cSrcweir BASEPROPERTY_ENABLED, 5740cdf0e10cSrcweir BASEPROPERTY_ENABLEVISIBLE, 5741cdf0e10cSrcweir BASEPROPERTY_FONTDESCRIPTOR, 5742cdf0e10cSrcweir BASEPROPERTY_HELPTEXT, 5743cdf0e10cSrcweir BASEPROPERTY_HELPURL, 5744cdf0e10cSrcweir BASEPROPERTY_NUMSHOWTHOUSANDSEP, 5745cdf0e10cSrcweir BASEPROPERTY_PRINTABLE, 5746cdf0e10cSrcweir BASEPROPERTY_READONLY, 5747cdf0e10cSrcweir BASEPROPERTY_REPEAT, 5748cdf0e10cSrcweir BASEPROPERTY_REPEAT_DELAY, 5749cdf0e10cSrcweir BASEPROPERTY_SPIN, 5750cdf0e10cSrcweir BASEPROPERTY_STRICTFORMAT, 5751cdf0e10cSrcweir BASEPROPERTY_TABSTOP, 5752cdf0e10cSrcweir BASEPROPERTY_VALUEMAX_DOUBLE, 5753cdf0e10cSrcweir BASEPROPERTY_VALUEMIN_DOUBLE, 5754cdf0e10cSrcweir BASEPROPERTY_VALUESTEP_DOUBLE, 5755cdf0e10cSrcweir BASEPROPERTY_VALUE_DOUBLE, 5756cdf0e10cSrcweir BASEPROPERTY_ENFORCE_FORMAT, 5757cdf0e10cSrcweir BASEPROPERTY_HIDEINACTIVESELECTION, 5758cdf0e10cSrcweir BASEPROPERTY_VERTICALALIGN, 5759cdf0e10cSrcweir BASEPROPERTY_WRITING_MODE, 5760cdf0e10cSrcweir BASEPROPERTY_CONTEXT_WRITING_MODE, 5761cdf0e10cSrcweir BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, 5762cdf0e10cSrcweir 0); 5763cdf0e10cSrcweir VCLXFormattedSpinField::ImplGetPropertyIds( rIds ); 5764cdf0e10cSrcweir } 5765cdf0e10cSrcweir 5766cdf0e10cSrcweir VCLXCurrencyField::VCLXCurrencyField() 5767cdf0e10cSrcweir { 5768cdf0e10cSrcweir } 5769cdf0e10cSrcweir 5770cdf0e10cSrcweir VCLXCurrencyField::~VCLXCurrencyField() 5771cdf0e10cSrcweir { 5772cdf0e10cSrcweir } 5773cdf0e10cSrcweir 5774cdf0e10cSrcweir // ::com::sun::star::uno::XInterface 5775cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXCurrencyField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 5776cdf0e10cSrcweir { 5777cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 5778cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XCurrencyField*, this ) ); 5779cdf0e10cSrcweir return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType )); 5780cdf0e10cSrcweir } 5781cdf0e10cSrcweir 5782cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 5783cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXCurrencyField ) 5784cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XCurrencyField>* ) NULL ), 5785cdf0e10cSrcweir VCLXFormattedSpinField::getTypes() 5786cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 5787cdf0e10cSrcweir 5788cdf0e10cSrcweir void VCLXCurrencyField::setValue( double Value ) throw(::com::sun::star::uno::RuntimeException) 5789cdf0e10cSrcweir { 5790cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5791cdf0e10cSrcweir 5792cdf0e10cSrcweir LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter(); 5793cdf0e10cSrcweir if ( pCurrencyFormatter ) 5794cdf0e10cSrcweir { 5795cdf0e10cSrcweir // z.B. 105, 2 Digits => 1,05 5796cdf0e10cSrcweir // ein float 1,05 muss also eine 105 einstellen... 5797cdf0e10cSrcweir pCurrencyFormatter->SetValue( 5798cdf0e10cSrcweir ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) ); 5799cdf0e10cSrcweir 5800cdf0e10cSrcweir // #107218# Call same listeners like VCL would do after user interaction 5801cdf0e10cSrcweir Edit* pEdit = (Edit*)GetWindow(); 5802cdf0e10cSrcweir if ( pEdit ) 5803cdf0e10cSrcweir { 5804cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_True ); 5805cdf0e10cSrcweir pEdit->SetModifyFlag(); 5806cdf0e10cSrcweir pEdit->Modify(); 5807cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_False ); 5808cdf0e10cSrcweir } 5809cdf0e10cSrcweir } 5810cdf0e10cSrcweir } 5811cdf0e10cSrcweir 5812cdf0e10cSrcweir double VCLXCurrencyField::getValue() throw(::com::sun::star::uno::RuntimeException) 5813cdf0e10cSrcweir { 5814cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5815cdf0e10cSrcweir 5816cdf0e10cSrcweir LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter(); 5817cdf0e10cSrcweir return pCurrencyFormatter 5818cdf0e10cSrcweir ? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetValue(), pCurrencyFormatter->GetDecimalDigits() ) 5819cdf0e10cSrcweir : 0; 5820cdf0e10cSrcweir } 5821cdf0e10cSrcweir 5822cdf0e10cSrcweir void VCLXCurrencyField::setMin( double Value ) throw(::com::sun::star::uno::RuntimeException) 5823cdf0e10cSrcweir { 5824cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5825cdf0e10cSrcweir 5826cdf0e10cSrcweir LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter(); 5827cdf0e10cSrcweir if ( pCurrencyFormatter ) 5828cdf0e10cSrcweir pCurrencyFormatter->SetMin( 5829cdf0e10cSrcweir ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) ); 5830cdf0e10cSrcweir } 5831cdf0e10cSrcweir 5832cdf0e10cSrcweir double VCLXCurrencyField::getMin() throw(::com::sun::star::uno::RuntimeException) 5833cdf0e10cSrcweir { 5834cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5835cdf0e10cSrcweir 5836cdf0e10cSrcweir LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter(); 5837cdf0e10cSrcweir return pCurrencyFormatter 5838cdf0e10cSrcweir ? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetMin(), pCurrencyFormatter->GetDecimalDigits() ) 5839cdf0e10cSrcweir : 0; 5840cdf0e10cSrcweir } 5841cdf0e10cSrcweir 5842cdf0e10cSrcweir void VCLXCurrencyField::setMax( double Value ) throw(::com::sun::star::uno::RuntimeException) 5843cdf0e10cSrcweir { 5844cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5845cdf0e10cSrcweir 5846cdf0e10cSrcweir LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter(); 5847cdf0e10cSrcweir if ( pCurrencyFormatter ) 5848cdf0e10cSrcweir pCurrencyFormatter->SetMax( 5849cdf0e10cSrcweir ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) ); 5850cdf0e10cSrcweir } 5851cdf0e10cSrcweir 5852cdf0e10cSrcweir double VCLXCurrencyField::getMax() throw(::com::sun::star::uno::RuntimeException) 5853cdf0e10cSrcweir { 5854cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5855cdf0e10cSrcweir 5856cdf0e10cSrcweir LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter(); 5857cdf0e10cSrcweir return pCurrencyFormatter 5858cdf0e10cSrcweir ? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetMax(), pCurrencyFormatter->GetDecimalDigits() ) 5859cdf0e10cSrcweir : 0; 5860cdf0e10cSrcweir } 5861cdf0e10cSrcweir 5862cdf0e10cSrcweir void VCLXCurrencyField::setFirst( double Value ) throw(::com::sun::star::uno::RuntimeException) 5863cdf0e10cSrcweir { 5864cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5865cdf0e10cSrcweir 5866cdf0e10cSrcweir LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow(); 5867cdf0e10cSrcweir if ( pCurrencyField ) 5868cdf0e10cSrcweir pCurrencyField->SetFirst( 5869cdf0e10cSrcweir ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) ); 5870cdf0e10cSrcweir } 5871cdf0e10cSrcweir 5872cdf0e10cSrcweir double VCLXCurrencyField::getFirst() throw(::com::sun::star::uno::RuntimeException) 5873cdf0e10cSrcweir { 5874cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5875cdf0e10cSrcweir 5876cdf0e10cSrcweir LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow(); 5877cdf0e10cSrcweir return pCurrencyField 5878cdf0e10cSrcweir ? ImplCalcDoubleValue( (double)pCurrencyField->GetFirst(), pCurrencyField->GetDecimalDigits() ) 5879cdf0e10cSrcweir : 0; 5880cdf0e10cSrcweir } 5881cdf0e10cSrcweir 5882cdf0e10cSrcweir void VCLXCurrencyField::setLast( double Value ) throw(::com::sun::star::uno::RuntimeException) 5883cdf0e10cSrcweir { 5884cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5885cdf0e10cSrcweir 5886cdf0e10cSrcweir LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow(); 5887cdf0e10cSrcweir if ( pCurrencyField ) 5888cdf0e10cSrcweir pCurrencyField->SetLast( 5889cdf0e10cSrcweir ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) ); 5890cdf0e10cSrcweir } 5891cdf0e10cSrcweir 5892cdf0e10cSrcweir double VCLXCurrencyField::getLast() throw(::com::sun::star::uno::RuntimeException) 5893cdf0e10cSrcweir { 5894cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5895cdf0e10cSrcweir 5896cdf0e10cSrcweir LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow(); 5897cdf0e10cSrcweir return pCurrencyField 5898cdf0e10cSrcweir ? ImplCalcDoubleValue( (double)pCurrencyField->GetLast(), pCurrencyField->GetDecimalDigits() ) 5899cdf0e10cSrcweir : 0; 5900cdf0e10cSrcweir } 5901cdf0e10cSrcweir 5902cdf0e10cSrcweir void VCLXCurrencyField::setSpinSize( double Value ) throw(::com::sun::star::uno::RuntimeException) 5903cdf0e10cSrcweir { 5904cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5905cdf0e10cSrcweir 5906cdf0e10cSrcweir LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow(); 5907cdf0e10cSrcweir if ( pCurrencyField ) 5908cdf0e10cSrcweir pCurrencyField->SetSpinSize( 5909cdf0e10cSrcweir ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) ); 5910cdf0e10cSrcweir } 5911cdf0e10cSrcweir 5912cdf0e10cSrcweir double VCLXCurrencyField::getSpinSize() throw(::com::sun::star::uno::RuntimeException) 5913cdf0e10cSrcweir { 5914cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5915cdf0e10cSrcweir 5916cdf0e10cSrcweir LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow(); 5917cdf0e10cSrcweir return pCurrencyField 5918cdf0e10cSrcweir ? ImplCalcDoubleValue( (double)pCurrencyField->GetSpinSize(), pCurrencyField->GetDecimalDigits() ) 5919cdf0e10cSrcweir : 0; 5920cdf0e10cSrcweir } 5921cdf0e10cSrcweir 5922cdf0e10cSrcweir void VCLXCurrencyField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException) 5923cdf0e10cSrcweir { 5924cdf0e10cSrcweir VCLXFormattedSpinField::setStrictFormat( bStrict ); 5925cdf0e10cSrcweir } 5926cdf0e10cSrcweir 5927cdf0e10cSrcweir sal_Bool VCLXCurrencyField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException) 5928cdf0e10cSrcweir { 5929cdf0e10cSrcweir return VCLXFormattedSpinField::isStrictFormat(); 5930cdf0e10cSrcweir } 5931cdf0e10cSrcweir 5932cdf0e10cSrcweir 5933cdf0e10cSrcweir void VCLXCurrencyField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException) 5934cdf0e10cSrcweir { 5935cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5936cdf0e10cSrcweir 5937cdf0e10cSrcweir LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter(); 5938cdf0e10cSrcweir if ( pCurrencyFormatter ) 5939cdf0e10cSrcweir { 5940cdf0e10cSrcweir double n = getValue(); 5941cdf0e10cSrcweir pCurrencyFormatter->SetDecimalDigits( Value ); 5942cdf0e10cSrcweir setValue( n ); 5943cdf0e10cSrcweir } 5944cdf0e10cSrcweir } 5945cdf0e10cSrcweir 5946cdf0e10cSrcweir sal_Int16 VCLXCurrencyField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException) 5947cdf0e10cSrcweir { 5948cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5949cdf0e10cSrcweir 5950cdf0e10cSrcweir LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter(); 5951cdf0e10cSrcweir return pCurrencyFormatter ? pCurrencyFormatter->GetDecimalDigits() : 0; 5952cdf0e10cSrcweir } 5953cdf0e10cSrcweir 5954cdf0e10cSrcweir void VCLXCurrencyField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 5955cdf0e10cSrcweir { 5956cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 5957cdf0e10cSrcweir 5958cdf0e10cSrcweir if ( GetWindow() ) 5959cdf0e10cSrcweir { 5960cdf0e10cSrcweir sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID; 5961cdf0e10cSrcweir 5962cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 5963cdf0e10cSrcweir switch ( nPropType ) 5964cdf0e10cSrcweir { 5965cdf0e10cSrcweir case BASEPROPERTY_VALUE_DOUBLE: 5966cdf0e10cSrcweir { 5967cdf0e10cSrcweir if ( bVoid ) 5968cdf0e10cSrcweir { 5969cdf0e10cSrcweir ((LongCurrencyField*)GetWindow())->EnableEmptyFieldValue( sal_True ); 5970cdf0e10cSrcweir ((LongCurrencyField*)GetWindow())->SetEmptyFieldValue(); 5971cdf0e10cSrcweir } 5972cdf0e10cSrcweir else 5973cdf0e10cSrcweir { 5974cdf0e10cSrcweir double d = 0; 5975cdf0e10cSrcweir if ( Value >>= d ) 5976cdf0e10cSrcweir setValue( d ); 5977cdf0e10cSrcweir } 5978cdf0e10cSrcweir } 5979cdf0e10cSrcweir break; 5980cdf0e10cSrcweir case BASEPROPERTY_VALUEMIN_DOUBLE: 5981cdf0e10cSrcweir { 5982cdf0e10cSrcweir double d = 0; 5983cdf0e10cSrcweir if ( Value >>= d ) 5984cdf0e10cSrcweir setMin( d ); 5985cdf0e10cSrcweir } 5986cdf0e10cSrcweir break; 5987cdf0e10cSrcweir case BASEPROPERTY_VALUEMAX_DOUBLE: 5988cdf0e10cSrcweir { 5989cdf0e10cSrcweir double d = 0; 5990cdf0e10cSrcweir if ( Value >>= d ) 5991cdf0e10cSrcweir setMax( d ); 5992cdf0e10cSrcweir } 5993cdf0e10cSrcweir break; 5994cdf0e10cSrcweir case BASEPROPERTY_VALUESTEP_DOUBLE: 5995cdf0e10cSrcweir { 5996cdf0e10cSrcweir double d = 0; 5997cdf0e10cSrcweir if ( Value >>= d ) 5998cdf0e10cSrcweir setSpinSize( d ); 5999cdf0e10cSrcweir } 6000cdf0e10cSrcweir break; 6001cdf0e10cSrcweir case BASEPROPERTY_DECIMALACCURACY: 6002cdf0e10cSrcweir { 6003cdf0e10cSrcweir sal_Int16 n = sal_Int16(); 6004cdf0e10cSrcweir if ( Value >>= n ) 6005cdf0e10cSrcweir setDecimalDigits( n ); 6006cdf0e10cSrcweir } 6007cdf0e10cSrcweir break; 6008cdf0e10cSrcweir case BASEPROPERTY_CURRENCYSYMBOL: 6009cdf0e10cSrcweir { 6010cdf0e10cSrcweir ::rtl::OUString aString; 6011cdf0e10cSrcweir if ( Value >>= aString ) 6012cdf0e10cSrcweir ((LongCurrencyField*)GetWindow())->SetCurrencySymbol( aString ); 6013cdf0e10cSrcweir } 6014cdf0e10cSrcweir break; 6015cdf0e10cSrcweir case BASEPROPERTY_NUMSHOWTHOUSANDSEP: 6016cdf0e10cSrcweir { 6017cdf0e10cSrcweir sal_Bool b = sal_Bool(); 6018cdf0e10cSrcweir if ( Value >>= b ) 6019cdf0e10cSrcweir ((LongCurrencyField*)GetWindow())->SetUseThousandSep( b ); 6020cdf0e10cSrcweir } 6021cdf0e10cSrcweir break; 6022cdf0e10cSrcweir default: 6023cdf0e10cSrcweir { 6024cdf0e10cSrcweir VCLXFormattedSpinField::setProperty( PropertyName, Value ); 6025cdf0e10cSrcweir } 6026cdf0e10cSrcweir } 6027cdf0e10cSrcweir } 6028cdf0e10cSrcweir } 6029cdf0e10cSrcweir 6030cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXCurrencyField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) 6031cdf0e10cSrcweir { 6032cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 6033cdf0e10cSrcweir 6034cdf0e10cSrcweir ::com::sun::star::uno::Any aProp; 6035cdf0e10cSrcweir FormatterBase* pFormatter = GetFormatter(); 6036cdf0e10cSrcweir if ( pFormatter ) 6037cdf0e10cSrcweir { 6038cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 6039cdf0e10cSrcweir switch ( nPropType ) 6040cdf0e10cSrcweir { 6041cdf0e10cSrcweir case BASEPROPERTY_VALUE_DOUBLE: 6042cdf0e10cSrcweir { 6043cdf0e10cSrcweir aProp <<= (double) getValue(); 6044cdf0e10cSrcweir } 6045cdf0e10cSrcweir break; 6046cdf0e10cSrcweir case BASEPROPERTY_VALUEMIN_DOUBLE: 6047cdf0e10cSrcweir { 6048cdf0e10cSrcweir aProp <<= (double) getMin(); 6049cdf0e10cSrcweir } 6050cdf0e10cSrcweir break; 6051cdf0e10cSrcweir case BASEPROPERTY_VALUEMAX_DOUBLE: 6052cdf0e10cSrcweir { 6053cdf0e10cSrcweir aProp <<= (double) getMax(); 6054cdf0e10cSrcweir } 6055cdf0e10cSrcweir break; 6056cdf0e10cSrcweir case BASEPROPERTY_VALUESTEP_DOUBLE: 6057cdf0e10cSrcweir { 6058cdf0e10cSrcweir aProp <<= (double) getSpinSize(); 6059cdf0e10cSrcweir } 6060cdf0e10cSrcweir break; 6061cdf0e10cSrcweir case BASEPROPERTY_CURRENCYSYMBOL: 6062cdf0e10cSrcweir { 6063cdf0e10cSrcweir aProp <<= ::rtl::OUString( ((LongCurrencyField*)GetWindow())->GetCurrencySymbol() ); 6064cdf0e10cSrcweir } 6065cdf0e10cSrcweir break; 6066cdf0e10cSrcweir case BASEPROPERTY_NUMSHOWTHOUSANDSEP: 6067cdf0e10cSrcweir { 6068cdf0e10cSrcweir aProp <<= (sal_Bool) ((LongCurrencyField*)GetWindow())->IsUseThousandSep(); 6069cdf0e10cSrcweir } 6070cdf0e10cSrcweir break; 6071cdf0e10cSrcweir default: 6072cdf0e10cSrcweir { 6073cdf0e10cSrcweir aProp <<= VCLXFormattedSpinField::getProperty( PropertyName ); 6074cdf0e10cSrcweir } 6075cdf0e10cSrcweir } 6076cdf0e10cSrcweir } 6077cdf0e10cSrcweir return aProp; 6078cdf0e10cSrcweir } 6079cdf0e10cSrcweir 6080cdf0e10cSrcweir // ---------------------------------------------------- 6081cdf0e10cSrcweir // class VCLXPatternField 6082cdf0e10cSrcweir // ---------------------------------------------------- 6083cdf0e10cSrcweir 6084cdf0e10cSrcweir void VCLXPatternField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 6085cdf0e10cSrcweir { 6086cdf0e10cSrcweir PushPropertyIds( rIds, 6087cdf0e10cSrcweir BASEPROPERTY_ALIGN, 6088cdf0e10cSrcweir BASEPROPERTY_BACKGROUNDCOLOR, 6089cdf0e10cSrcweir BASEPROPERTY_BORDER, 6090cdf0e10cSrcweir BASEPROPERTY_BORDERCOLOR, 6091cdf0e10cSrcweir BASEPROPERTY_DEFAULTCONTROL, 6092cdf0e10cSrcweir BASEPROPERTY_EDITMASK, 6093cdf0e10cSrcweir BASEPROPERTY_ENABLED, 6094cdf0e10cSrcweir BASEPROPERTY_ENABLEVISIBLE, 6095cdf0e10cSrcweir BASEPROPERTY_FONTDESCRIPTOR, 6096cdf0e10cSrcweir BASEPROPERTY_HELPTEXT, 6097cdf0e10cSrcweir BASEPROPERTY_HELPURL, 6098cdf0e10cSrcweir BASEPROPERTY_LITERALMASK, 6099cdf0e10cSrcweir BASEPROPERTY_MAXTEXTLEN, 6100cdf0e10cSrcweir BASEPROPERTY_PRINTABLE, 6101cdf0e10cSrcweir BASEPROPERTY_READONLY, 6102cdf0e10cSrcweir BASEPROPERTY_STRICTFORMAT, 6103cdf0e10cSrcweir BASEPROPERTY_TABSTOP, 6104cdf0e10cSrcweir BASEPROPERTY_TEXT, 6105cdf0e10cSrcweir BASEPROPERTY_HIDEINACTIVESELECTION, 6106cdf0e10cSrcweir BASEPROPERTY_VERTICALALIGN, 6107cdf0e10cSrcweir BASEPROPERTY_WRITING_MODE, 6108cdf0e10cSrcweir BASEPROPERTY_CONTEXT_WRITING_MODE, 6109cdf0e10cSrcweir BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, 6110cdf0e10cSrcweir 0); 6111cdf0e10cSrcweir VCLXFormattedSpinField::ImplGetPropertyIds( rIds ); 6112cdf0e10cSrcweir } 6113cdf0e10cSrcweir 6114cdf0e10cSrcweir VCLXPatternField::VCLXPatternField() 6115cdf0e10cSrcweir { 6116cdf0e10cSrcweir } 6117cdf0e10cSrcweir 6118cdf0e10cSrcweir VCLXPatternField::~VCLXPatternField() 6119cdf0e10cSrcweir { 6120cdf0e10cSrcweir } 6121cdf0e10cSrcweir 6122cdf0e10cSrcweir // ::com::sun::star::uno::XInterface 6123cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXPatternField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 6124cdf0e10cSrcweir { 6125cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 6126cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XPatternField*, this ) ); 6127cdf0e10cSrcweir return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType )); 6128cdf0e10cSrcweir } 6129cdf0e10cSrcweir 6130cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 6131cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXPatternField ) 6132cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPatternField>* ) NULL ), 6133cdf0e10cSrcweir VCLXFormattedSpinField::getTypes() 6134cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 6135cdf0e10cSrcweir 6136cdf0e10cSrcweir void VCLXPatternField::setMasks( const ::rtl::OUString& EditMask, const ::rtl::OUString& LiteralMask ) throw(::com::sun::star::uno::RuntimeException) 6137cdf0e10cSrcweir { 6138cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 6139cdf0e10cSrcweir 6140cdf0e10cSrcweir PatternField* pPatternField = (PatternField*) GetWindow(); 6141cdf0e10cSrcweir if ( pPatternField ) 6142cdf0e10cSrcweir { 6143cdf0e10cSrcweir pPatternField->SetMask( ByteString( UniString( EditMask ), RTL_TEXTENCODING_ASCII_US ), LiteralMask ); 6144cdf0e10cSrcweir } 6145cdf0e10cSrcweir } 6146cdf0e10cSrcweir 6147cdf0e10cSrcweir void VCLXPatternField::getMasks( ::rtl::OUString& EditMask, ::rtl::OUString& LiteralMask ) throw(::com::sun::star::uno::RuntimeException) 6148cdf0e10cSrcweir { 6149cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 6150cdf0e10cSrcweir 6151cdf0e10cSrcweir PatternField* pPatternField = (PatternField*) GetWindow(); 6152cdf0e10cSrcweir if ( pPatternField ) 6153cdf0e10cSrcweir { 6154cdf0e10cSrcweir EditMask = String( pPatternField->GetEditMask(), RTL_TEXTENCODING_ASCII_US ); 6155cdf0e10cSrcweir LiteralMask = pPatternField->GetLiteralMask(); 6156cdf0e10cSrcweir } 6157cdf0e10cSrcweir } 6158cdf0e10cSrcweir 6159cdf0e10cSrcweir void VCLXPatternField::setString( const ::rtl::OUString& Str ) throw(::com::sun::star::uno::RuntimeException) 6160cdf0e10cSrcweir { 6161cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 6162cdf0e10cSrcweir 6163cdf0e10cSrcweir PatternField* pPatternField = (PatternField*) GetWindow(); 6164cdf0e10cSrcweir if ( pPatternField ) 6165cdf0e10cSrcweir { 6166cdf0e10cSrcweir pPatternField->SetString( Str ); 6167cdf0e10cSrcweir } 6168cdf0e10cSrcweir } 6169cdf0e10cSrcweir 6170cdf0e10cSrcweir ::rtl::OUString VCLXPatternField::getString() throw(::com::sun::star::uno::RuntimeException) 6171cdf0e10cSrcweir { 6172cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 6173cdf0e10cSrcweir 6174cdf0e10cSrcweir ::rtl::OUString aString; 6175cdf0e10cSrcweir PatternField* pPatternField = (PatternField*) GetWindow(); 6176cdf0e10cSrcweir if ( pPatternField ) 6177cdf0e10cSrcweir aString = pPatternField->GetString(); 6178cdf0e10cSrcweir return aString; 6179cdf0e10cSrcweir } 6180cdf0e10cSrcweir 6181cdf0e10cSrcweir void VCLXPatternField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException) 6182cdf0e10cSrcweir { 6183cdf0e10cSrcweir VCLXFormattedSpinField::setStrictFormat( bStrict ); 6184cdf0e10cSrcweir } 6185cdf0e10cSrcweir 6186cdf0e10cSrcweir sal_Bool VCLXPatternField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException) 6187cdf0e10cSrcweir { 6188cdf0e10cSrcweir return VCLXFormattedSpinField::isStrictFormat(); 6189cdf0e10cSrcweir } 6190cdf0e10cSrcweir 6191cdf0e10cSrcweir void VCLXPatternField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 6192cdf0e10cSrcweir { 6193cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 6194cdf0e10cSrcweir 6195cdf0e10cSrcweir if ( GetWindow() ) 6196cdf0e10cSrcweir { 6197cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 6198cdf0e10cSrcweir switch ( nPropType ) 6199cdf0e10cSrcweir { 6200cdf0e10cSrcweir case BASEPROPERTY_EDITMASK: 6201cdf0e10cSrcweir case BASEPROPERTY_LITERALMASK: 6202cdf0e10cSrcweir { 6203cdf0e10cSrcweir ::rtl::OUString aString; 6204cdf0e10cSrcweir if ( Value >>= aString ) 6205cdf0e10cSrcweir { 6206cdf0e10cSrcweir ::rtl::OUString aEditMask, aLiteralMask; 6207cdf0e10cSrcweir getMasks( aEditMask, aLiteralMask ); 6208cdf0e10cSrcweir if ( nPropType == BASEPROPERTY_EDITMASK ) 6209cdf0e10cSrcweir aEditMask = aString; 6210cdf0e10cSrcweir else 6211cdf0e10cSrcweir aLiteralMask = aString; 6212cdf0e10cSrcweir setMasks( aEditMask, aLiteralMask ); 6213cdf0e10cSrcweir } 6214cdf0e10cSrcweir } 6215cdf0e10cSrcweir break; 6216cdf0e10cSrcweir default: 6217cdf0e10cSrcweir { 6218cdf0e10cSrcweir VCLXFormattedSpinField::setProperty( PropertyName, Value ); 6219cdf0e10cSrcweir } 6220cdf0e10cSrcweir } 6221cdf0e10cSrcweir } 6222cdf0e10cSrcweir } 6223cdf0e10cSrcweir 6224cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXPatternField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) 6225cdf0e10cSrcweir { 6226cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 6227cdf0e10cSrcweir 6228cdf0e10cSrcweir ::com::sun::star::uno::Any aProp; 6229cdf0e10cSrcweir if ( GetWindow() ) 6230cdf0e10cSrcweir { 6231cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 6232cdf0e10cSrcweir switch ( nPropType ) 6233cdf0e10cSrcweir { 6234cdf0e10cSrcweir case BASEPROPERTY_EDITMASK: 6235cdf0e10cSrcweir case BASEPROPERTY_LITERALMASK: 6236cdf0e10cSrcweir { 6237cdf0e10cSrcweir ::rtl::OUString aEditMask, aLiteralMask; 6238cdf0e10cSrcweir getMasks( aEditMask, aLiteralMask ); 6239cdf0e10cSrcweir if ( nPropType == BASEPROPERTY_EDITMASK ) 6240cdf0e10cSrcweir aProp <<= aEditMask; 6241cdf0e10cSrcweir else 6242cdf0e10cSrcweir aProp <<= aLiteralMask; 6243cdf0e10cSrcweir } 6244cdf0e10cSrcweir break; 6245cdf0e10cSrcweir default: 6246cdf0e10cSrcweir { 6247cdf0e10cSrcweir aProp <<= VCLXFormattedSpinField::getProperty( PropertyName ); 6248cdf0e10cSrcweir } 6249cdf0e10cSrcweir } 6250cdf0e10cSrcweir } 6251cdf0e10cSrcweir return aProp; 6252cdf0e10cSrcweir } 6253cdf0e10cSrcweir 6254cdf0e10cSrcweir // ---------------------------------------------------- 6255cdf0e10cSrcweir // class VCLXToolBox 6256cdf0e10cSrcweir // ---------------------------------------------------- 6257cdf0e10cSrcweir VCLXToolBox::VCLXToolBox() 6258cdf0e10cSrcweir { 6259cdf0e10cSrcweir } 6260cdf0e10cSrcweir 6261cdf0e10cSrcweir VCLXToolBox::~VCLXToolBox() 6262cdf0e10cSrcweir { 6263cdf0e10cSrcweir } 6264cdf0e10cSrcweir 6265cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXToolBox::CreateAccessibleContext() 6266cdf0e10cSrcweir { 6267cdf0e10cSrcweir return getAccessibleFactory().createAccessibleContext( this ); 6268cdf0e10cSrcweir } 6269cdf0e10cSrcweir 6270