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