1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_extensions.hxx" 26 27 #include "updatehdl.hxx" 28 #include "update.hrc" 29 30 #include "osl/diagnose.h" 31 #include "osl/thread.hxx" 32 #include "osl/file.hxx" 33 #include "rtl/ustring.hxx" 34 #include "rtl/bootstrap.hxx" 35 36 #include "com/sun/star/uno/Sequence.h" 37 38 #include <com/sun/star/style/VerticalAlignment.hpp> 39 40 #include "com/sun/star/awt/ActionEvent.hpp" 41 #include "com/sun/star/awt/PushButtonType.hpp" 42 #include "com/sun/star/awt/VclWindowPeerAttribute.hpp" 43 #include "com/sun/star/awt/WindowAttribute.hpp" 44 #include "com/sun/star/awt/XButton.hpp" 45 #include "com/sun/star/awt/XControl.hpp" 46 #include "com/sun/star/awt/XControlContainer.hpp" 47 #include "com/sun/star/awt/XMessageBox.hpp" 48 #include "com/sun/star/awt/XAnimation.hpp" 49 #include "com/sun/star/awt/XTopWindow.hpp" 50 #include "com/sun/star/awt/XVclWindowPeer.hpp" 51 #include "com/sun/star/awt/XVclContainer.hpp" 52 #include "com/sun/star/awt/XWindow.hpp" 53 #include "com/sun/star/awt/XWindow2.hpp" 54 55 #include <com/sun/star/beans/PropertyValue.hpp> 56 #include "com/sun/star/beans/XPropertySet.hpp" 57 58 #include "com/sun/star/container/XNameContainer.hpp" 59 60 #include "com/sun/star/frame/XDesktop.hpp" 61 62 #include "com/sun/star/lang/XMultiServiceFactory.hpp" 63 #include "com/sun/star/task/InteractionRequestStringResolver.hpp" 64 65 #include <com/sun/star/resource/XResourceBundleLoader.hpp> 66 67 #include "updatehdl.hrc" 68 #include <tools/urlobj.hxx> 69 70 #include <vcl/svapp.hxx> 71 #include <vos/mutex.hxx> 72 73 #define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) 74 75 #define COMMAND_CLOSE UNISTRING("close") 76 77 #define CTRL_THROBBER UNISTRING("throbber") 78 #define CTRL_PROGRESS UNISTRING("progress") 79 80 #define TEXT_STATUS UNISTRING("text_status") 81 #define TEXT_PERCENT UNISTRING("text_percent") 82 #define TEXT_DESCRIPTION UNISTRING("text_description") 83 84 #define FIXED_LINE_MODEL UNISTRING("com.sun.star.awt.UnoControlFixedLineModel") 85 #define FIXED_TEXT_MODEL UNISTRING("com.sun.star.awt.UnoControlFixedTextModel") 86 #define EDIT_FIELD_MODEL UNISTRING("com.sun.star.awt.UnoControlEditModel") 87 #define BUTTON_MODEL UNISTRING("com.sun.star.awt.UnoControlButtonModel") 88 #define GROUP_BOX_MODEL UNISTRING("com.sun.star.awt.UnoControlGroupBoxModel") 89 90 using namespace com::sun::star; 91 92 //-------------------------------------------------------------------- 93 UpdateHandler::UpdateHandler( const uno::Reference< uno::XComponentContext > & rxContext, 94 const rtl::Reference< IActionListener > & rxActionListener ) : 95 mxContext( rxContext ), 96 mxActionListener( rxActionListener ), 97 meCurState( UPDATESTATES_COUNT ), 98 meLastState( UPDATESTATES_COUNT ), 99 mnPercent( 0 ), 100 mnLastCtrlState( -1 ), 101 mbDownloadBtnHasDots( false ), 102 mbVisible( false ), 103 mbStringsLoaded( false ), 104 mbMinimized( false ), 105 mbListenerAdded(false), 106 mbShowsMessageBox(false) 107 { 108 } 109 110 //-------------------------------------------------------------------- 111 UpdateHandler::~UpdateHandler() 112 { 113 mxContext = NULL; 114 mxUpdDlg = NULL; 115 mxInteractionHdl = NULL; 116 mxActionListener = NULL; 117 } 118 119 //-------------------------------------------------------------------- 120 void UpdateHandler::enableControls( short nCtrlState ) 121 { 122 osl::MutexGuard aGuard( maMutex ); 123 124 if ( nCtrlState == mnLastCtrlState ) 125 return; 126 127 bool bEnableControl; 128 129 short nCurStateVal = nCtrlState; 130 short nOldStateVal = mnLastCtrlState; 131 132 // the help button should always be the last button in the 133 // enum list und must never be disabled 134 for ( int i=0; i<HELP_BUTTON; i++ ) 135 { 136 nCurStateVal = (short)(nCtrlState >> i); 137 nOldStateVal = (short)(mnLastCtrlState >> i); 138 if ( ( nCurStateVal & 0x01 ) != ( nOldStateVal & 0x01 ) ) 139 { 140 bEnableControl = ( ( nCurStateVal & 0x01 ) == 0x01 ); 141 setControlProperty( msButtonIDs[i], UNISTRING("Enabled"), uno::Any( bEnableControl ) ); 142 } 143 } 144 145 mnLastCtrlState = nCtrlState; 146 } 147 148 //-------------------------------------------------------------------- 149 void UpdateHandler::setDownloadBtnLabel( bool bAppendDots ) 150 { 151 osl::MutexGuard aGuard( maMutex ); 152 153 if ( mbDownloadBtnHasDots != bAppendDots ) 154 { 155 rtl::OUString aLabel( msDownload ); 156 157 if ( bAppendDots ) 158 aLabel += UNISTRING( "..." ); 159 160 setControlProperty( msButtonIDs[DOWNLOAD_BUTTON], UNISTRING("Label"), uno::Any( aLabel ) ); 161 setControlProperty( msButtonIDs[DOWNLOAD_BUTTON], UNISTRING("HelpURL"), uno::Any( UNISTRING( INET_HID_SCHEME ) + rtl::OUString::createFromAscii( HID_CHECK_FOR_UPD_DOWNLOAD2 ) ) ); 162 163 mbDownloadBtnHasDots = bAppendDots; 164 } 165 } 166 167 //-------------------------------------------------------------------- 168 void UpdateHandler::setState( UpdateState eState ) 169 { 170 osl::MutexGuard aGuard( maMutex ); 171 172 meCurState = eState; 173 174 if ( mxUpdDlg.is() && mbVisible ) 175 updateState( meCurState ); 176 } 177 178 //-------------------------------------------------------------------- 179 bool UpdateHandler::isVisible() const 180 { 181 if ( !mxUpdDlg.is() ) return false; 182 183 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 184 uno::Reference< awt::XWindow2 > xWindow( mxUpdDlg, uno::UNO_QUERY ); 185 186 if ( xWindow.is() ) 187 return xWindow->isVisible(); 188 else 189 return false; 190 } 191 192 //-------------------------------------------------------------------- 193 void UpdateHandler::setVisible( bool bVisible ) 194 { 195 osl::MutexGuard aGuard( maMutex ); 196 197 mbVisible = bVisible; 198 199 if ( bVisible ) 200 { 201 if ( !mxUpdDlg.is() ) 202 createDialog(); 203 204 // this should never happen, but if it happens we better return here 205 if ( !mxUpdDlg.is() ) 206 return; 207 208 updateState( meCurState ); 209 210 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 211 uno::Reference< awt::XWindow > xWindow( mxUpdDlg, uno::UNO_QUERY ); 212 213 if ( xWindow.is() ) 214 xWindow->setVisible( bVisible ); 215 216 uno::Reference< awt::XTopWindow > xTopWindow( mxUpdDlg, uno::UNO_QUERY ); 217 if ( xTopWindow.is() ) 218 { 219 xTopWindow->toFront(); 220 if ( !mbListenerAdded ) 221 { 222 xTopWindow->addTopWindowListener( this ); 223 mbListenerAdded = true; 224 } 225 } 226 } 227 else if ( mxUpdDlg.is() ) 228 { 229 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 230 uno::Reference< awt::XWindow > xWindow( mxUpdDlg, uno::UNO_QUERY ); 231 232 if ( xWindow.is() ) 233 xWindow->setVisible( bVisible ); 234 } 235 } 236 237 //-------------------------------------------------------------------- 238 void UpdateHandler::setProgress( sal_Int32 nPercent ) 239 { 240 if ( nPercent > 100 ) 241 nPercent = 100; 242 else if ( nPercent < 0 ) 243 nPercent = 0; 244 245 if ( nPercent != mnPercent ) 246 { 247 osl::MutexGuard aGuard( maMutex ); 248 249 mnPercent = nPercent; 250 setControlProperty( CTRL_PROGRESS, UNISTRING("ProgressValue"), uno::Any( nPercent ) ); 251 setControlProperty( TEXT_PERCENT, UNISTRING("Text"), uno::Any( substVariables(msPercent) ) ); 252 } 253 } 254 255 //-------------------------------------------------------------------- 256 void UpdateHandler::setErrorMessage( const rtl::OUString& rErrorMsg ) 257 { 258 setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( rErrorMsg ) ); 259 } 260 261 //-------------------------------------------------------------------- 262 void UpdateHandler::setDownloadFile( const rtl::OUString& rFilePath ) 263 { 264 sal_Int32 nLast = rFilePath.lastIndexOf( '/' ); 265 if ( nLast != -1 ) 266 { 267 msDownloadFile = rFilePath.copy( nLast+1 ); 268 const rtl::OUString aDownloadURL = rFilePath.copy( 0, nLast ); 269 osl::FileBase::getSystemPathFromFileURL( aDownloadURL, msDownloadPath ); 270 } 271 } 272 273 //-------------------------------------------------------------------- 274 rtl::OUString UpdateHandler::getBubbleText( UpdateState eState ) 275 { 276 osl::MutexGuard aGuard( maMutex ); 277 278 rtl::OUString sText; 279 sal_Int32 nIndex = (sal_Int32) eState; 280 281 loadStrings(); 282 283 if ( ( UPDATESTATE_UPDATE_AVAIL <= nIndex ) && ( nIndex < UPDATESTATES_COUNT ) ) 284 sText = substVariables( msBubbleTexts[ nIndex - UPDATESTATE_UPDATE_AVAIL ] ); 285 286 return sText; 287 } 288 289 //-------------------------------------------------------------------- 290 rtl::OUString UpdateHandler::getBubbleTitle( UpdateState eState ) 291 { 292 osl::MutexGuard aGuard( maMutex ); 293 294 rtl::OUString sText; 295 sal_Int32 nIndex = (sal_Int32) eState; 296 297 loadStrings(); 298 299 if ( ( UPDATESTATE_UPDATE_AVAIL <= nIndex ) && ( nIndex < UPDATESTATES_COUNT ) ) 300 sText = substVariables( msBubbleTitles[ nIndex - UPDATESTATE_UPDATE_AVAIL] ); 301 302 return sText; 303 } 304 305 //-------------------------------------------------------------------- 306 rtl::OUString UpdateHandler::getDefaultInstErrMsg() 307 { 308 osl::MutexGuard aGuard( maMutex ); 309 310 loadStrings(); 311 312 return substVariables( msInstallError ); 313 } 314 315 // XActionListener 316 //-------------------------------------------------------------------- 317 void SAL_CALL UpdateHandler::disposing( const lang::EventObject& rEvt ) 318 throw( uno::RuntimeException ) 319 { 320 if ( rEvt.Source == mxUpdDlg ) 321 mxUpdDlg.clear(); 322 } 323 324 //-------------------------------------------------------------------- 325 void SAL_CALL UpdateHandler::actionPerformed( awt::ActionEvent const & rEvent ) 326 throw( uno::RuntimeException ) 327 { 328 DialogControls eButton = BUTTON_COUNT; 329 for ( int i = 0; i < BUTTON_COUNT; i++ ) 330 { 331 if ( rEvent.ActionCommand.equals( msButtonIDs[i] ) ) 332 { 333 eButton = (DialogControls) i; 334 break; 335 } 336 } 337 338 if ( rEvent.ActionCommand.equals( COMMAND_CLOSE ) ) 339 { 340 if ( ( mnLastCtrlState & ( 1 << CLOSE_BUTTON ) ) == ( 1 << CLOSE_BUTTON ) ) 341 eButton = CLOSE_BUTTON; 342 else 343 eButton = CANCEL_BUTTON; 344 } 345 346 switch ( eButton ) { 347 case CANCEL_BUTTON: 348 { 349 bool bCancel = true; 350 351 if ( ( meCurState == UPDATESTATE_DOWNLOADING ) || 352 ( meCurState == UPDATESTATE_DOWNLOAD_PAUSED ) || 353 ( meCurState == UPDATESTATE_ERROR_DOWNLOADING ) ) 354 bCancel = showWarning( msCancelMessage ); 355 356 if ( bCancel ) 357 { 358 mxActionListener->cancel(); 359 setVisible( false ); 360 } 361 break; 362 } 363 case CLOSE_BUTTON: 364 setVisible( false ); 365 if ( meCurState == UPDATESTATE_ERROR_CHECKING ) 366 mxActionListener->closeAfterFailure(); 367 break; 368 case DOWNLOAD_BUTTON: 369 mxActionListener->download(); 370 break; 371 case INSTALL_BUTTON: 372 if ( showWarning( msInstallMessage ) ) 373 mxActionListener->install(); 374 break; 375 case PAUSE_BUTTON: 376 mxActionListener->pause(); 377 break; 378 case RESUME_BUTTON: 379 mxActionListener->resume(); 380 break; 381 case HELP_BUTTON: 382 break; 383 default: 384 OSL_ENSURE( false, "UpdateHandler::actionPerformed: unknown command!" ); 385 } 386 } 387 388 // XTopWindowListener 389 //-------------------------------------------------------------------- 390 void SAL_CALL UpdateHandler::windowOpened( const lang::EventObject& ) 391 throw( uno::RuntimeException ) 392 { 393 } 394 395 //-------------------------------------------------------------------- 396 void SAL_CALL UpdateHandler::windowClosing( const lang::EventObject& e ) 397 throw( uno::RuntimeException ) 398 { 399 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 400 awt::ActionEvent aActionEvt; 401 aActionEvt.ActionCommand = COMMAND_CLOSE; 402 aActionEvt.Source = e.Source; 403 404 actionPerformed( aActionEvt ); 405 } 406 407 //-------------------------------------------------------------------- 408 void SAL_CALL UpdateHandler::windowClosed( const lang::EventObject& ) 409 throw( uno::RuntimeException ) 410 { 411 } 412 413 //-------------------------------------------------------------------- 414 void SAL_CALL UpdateHandler::windowMinimized( const lang::EventObject& ) 415 throw( uno::RuntimeException ) 416 { 417 mbMinimized = true; 418 } 419 420 //-------------------------------------------------------------------- 421 void SAL_CALL UpdateHandler::windowNormalized( const lang::EventObject& ) 422 throw( uno::RuntimeException ) 423 { 424 mbMinimized = false; 425 } 426 427 //-------------------------------------------------------------------- 428 void SAL_CALL UpdateHandler::windowActivated( const lang::EventObject& ) 429 throw( uno::RuntimeException ) 430 { 431 } 432 433 //-------------------------------------------------------------------- 434 void SAL_CALL UpdateHandler::windowDeactivated( const lang::EventObject& ) 435 throw( uno::RuntimeException ) 436 { 437 } 438 439 // XInteractionHandler 440 //------------------------------------------------------------------------------ 441 void SAL_CALL UpdateHandler::handle( uno::Reference< task::XInteractionRequest > const & rRequest) 442 throw (uno::RuntimeException) 443 { 444 if ( !mxInteractionHdl.is() ) 445 { 446 if( !mxContext.is() ) 447 throw uno::RuntimeException( UNISTRING( "UpdateHandler:: empty component context" ), *this ); 448 449 uno::Reference< lang::XMultiComponentFactory > xServiceManager(mxContext->getServiceManager()); 450 451 if( !xServiceManager.is() ) 452 throw uno::RuntimeException( UNISTRING( "UpdateHandler: unable to obtain service manager from component context" ), *this ); 453 454 mxInteractionHdl = uno::Reference<task::XInteractionHandler> ( 455 xServiceManager->createInstanceWithContext( 456 UNISTRING( "com.sun.star.task.InteractionHandler" ), 457 mxContext), 458 uno::UNO_QUERY_THROW); 459 if( !mxInteractionHdl.is() ) 460 throw uno::RuntimeException( UNISTRING( "UpdateHandler:: could not get default interaction handler" ), *this ); 461 } 462 uno::Reference< task::XInteractionRequestStringResolver > xStrResolver = 463 task::InteractionRequestStringResolver::create( mxContext ); 464 beans::Optional< ::rtl::OUString > aErrorText = xStrResolver->getStringFromInformationalRequest( rRequest ); 465 if ( aErrorText.IsPresent ) 466 { 467 setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( aErrorText.Value ) ); 468 469 uno::Sequence< uno::Reference< task::XInteractionContinuation > > xContinuations = rRequest->getContinuations(); 470 if ( xContinuations.getLength() == 1 ) 471 { 472 if ( meCurState == UPDATESTATE_CHECKING ) 473 setState( UPDATESTATE_ERROR_CHECKING ); 474 else if ( meCurState == UPDATESTATE_DOWNLOADING ) 475 setState( UPDATESTATE_ERROR_DOWNLOADING ); 476 477 xContinuations[0]->select(); 478 } 479 else 480 mxInteractionHdl->handle( rRequest ); 481 } 482 else 483 mxInteractionHdl->handle( rRequest ); 484 } 485 486 //------------------------------------------------------------------------------ 487 // XTerminateListener 488 //------------------------------------------------------------------------------ 489 void SAL_CALL UpdateHandler::queryTermination( const lang::EventObject& ) 490 throw ( frame::TerminationVetoException, uno::RuntimeException ) 491 { 492 if ( mbShowsMessageBox ) 493 { 494 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 495 uno::Reference< awt::XTopWindow > xTopWindow( mxUpdDlg, uno::UNO_QUERY ); 496 if ( xTopWindow.is() ) 497 xTopWindow->toFront(); 498 499 throw frame::TerminationVetoException( 500 UNISTRING("The office cannot be closed while displaying a warning!"), 501 uno::Reference<XInterface>(static_cast<frame::XTerminateListener*>(this), uno::UNO_QUERY)); 502 } 503 else 504 setVisible( false ); 505 } 506 507 //------------------------------------------------------------------------------ 508 void SAL_CALL UpdateHandler::notifyTermination( const lang::EventObject& ) 509 throw ( uno::RuntimeException ) 510 { 511 osl::MutexGuard aGuard( maMutex ); 512 513 if ( mxUpdDlg.is() ) 514 { 515 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 516 uno::Reference< awt::XTopWindow > xTopWindow( mxUpdDlg, uno::UNO_QUERY ); 517 if ( xTopWindow.is() ) 518 xTopWindow->removeTopWindowListener( this ); 519 520 uno::Reference< lang::XComponent > xComponent( mxUpdDlg, uno::UNO_QUERY ); 521 if ( xComponent.is() ) 522 xComponent->dispose(); 523 524 mxUpdDlg.clear(); 525 } 526 } 527 528 //-------------------------------------------------------------------- 529 //-------------------------------------------------------------------- 530 //-------------------------------------------------------------------- 531 void UpdateHandler::updateState( UpdateState eState ) 532 { 533 if ( meLastState == eState ) 534 return; 535 536 if ( isVisible() ) 537 {} // ToTop(); 538 539 rtl::OUString sText; 540 541 switch ( eState ) 542 { 543 case UPDATESTATE_CHECKING: 544 showControls( (1<<CANCEL_BUTTON) + (1<<THROBBER_CTRL) ); 545 enableControls( 1<<CANCEL_BUTTON ); 546 setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msChecking) ) ); 547 setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( rtl::OUString() ) ); 548 focusControl( CANCEL_BUTTON ); 549 break; 550 case UPDATESTATE_ERROR_CHECKING: 551 showControls( 0 ); 552 enableControls( 1 << CLOSE_BUTTON ); 553 setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msCheckingError) ) ); 554 focusControl( CLOSE_BUTTON ); 555 break; 556 case UPDATESTATE_UPDATE_AVAIL: 557 showControls( 0 ); 558 enableControls( ( 1 << CLOSE_BUTTON ) + ( 1 << DOWNLOAD_BUTTON ) ); 559 setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msUpdFound) ) ); 560 561 sText = substVariables(msDownloadWarning); 562 if ( msDescriptionMsg.getLength() ) 563 sText += UNISTRING("\n\n") + msDescriptionMsg; 564 setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( sText ) ); 565 566 setDownloadBtnLabel( false ); 567 focusControl( DOWNLOAD_BUTTON ); 568 break; 569 case UPDATESTATE_UPDATE_NO_DOWNLOAD: 570 showControls( 0 ); 571 enableControls( ( 1 << CLOSE_BUTTON ) + ( 1 << DOWNLOAD_BUTTON ) ); 572 setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msUpdFound) ) ); 573 574 sText = substVariables(msDownloadNotAvail); 575 if ( msDescriptionMsg.getLength() ) 576 sText += UNISTRING("\n\n") + msDescriptionMsg; 577 setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( sText ) ); 578 579 setDownloadBtnLabel( true ); 580 focusControl( DOWNLOAD_BUTTON ); 581 break; 582 case UPDATESTATE_NO_UPDATE_AVAIL: 583 case UPDATESTATE_EXT_UPD_AVAIL: // will only be set, when there are no office updates avail 584 showControls( 0 ); 585 enableControls( 1 << CLOSE_BUTTON ); 586 setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msNoUpdFound) ) ); 587 setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( rtl::OUString() ) ); 588 focusControl( CLOSE_BUTTON ); 589 break; 590 case UPDATESTATE_DOWNLOADING: 591 showControls( (1<<PROGRESS_CTRL) + (1<<CANCEL_BUTTON) + (1<<PAUSE_BUTTON) + (1<<RESUME_BUTTON) ); 592 enableControls( (1<<CLOSE_BUTTON) + (1<<CANCEL_BUTTON) + (1<<PAUSE_BUTTON) ); 593 setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msDownloading) ) ); 594 setControlProperty( TEXT_PERCENT, UNISTRING("Text"), uno::Any( substVariables(msPercent) ) ); 595 setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( substVariables(msDownloadWarning) ) ); 596 setControlProperty( CTRL_PROGRESS, UNISTRING("ProgressValue"), uno::Any( mnPercent ) ); 597 focusControl( CLOSE_BUTTON ); 598 break; 599 case UPDATESTATE_DOWNLOAD_PAUSED: 600 showControls( (1<<PROGRESS_CTRL) + (1<<CANCEL_BUTTON) + (1<<PAUSE_BUTTON) + (1<<RESUME_BUTTON) ); 601 enableControls( (1<<CLOSE_BUTTON) + (1<<CANCEL_BUTTON) + (1<<RESUME_BUTTON) ); 602 setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msDownloadPause) ) ); 603 setControlProperty( TEXT_PERCENT, UNISTRING("Text"), uno::Any( substVariables(msPercent) ) ); 604 setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( substVariables(msDownloadWarning) ) ); 605 setControlProperty( CTRL_PROGRESS, UNISTRING("ProgressValue"), uno::Any( mnPercent ) ); 606 focusControl( CLOSE_BUTTON ); 607 break; 608 case UPDATESTATE_ERROR_DOWNLOADING: 609 showControls( (1<<PROGRESS_CTRL) + (1<<CANCEL_BUTTON) + (1<<PAUSE_BUTTON) + (1<<RESUME_BUTTON) ); 610 enableControls( (1<<CLOSE_BUTTON) + (1<<CANCEL_BUTTON) ); 611 setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msDownloadError) ) ); 612 focusControl( CLOSE_BUTTON ); 613 break; 614 case UPDATESTATE_DOWNLOAD_AVAIL: 615 showControls( 0 ); 616 enableControls( (1<<CLOSE_BUTTON) + (1<<INSTALL_BUTTON) ); 617 setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msReady2Install) ) ); 618 setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( substVariables(msDownloadDescr) ) ); 619 focusControl( INSTALL_BUTTON ); 620 break; 621 case UPDATESTATE_AUTO_START: 622 case UPDATESTATES_COUNT: 623 //do nothing, only count! 624 break; 625 } 626 627 meLastState = eState; 628 } 629 630 //-------------------------------------------------------------------- 631 void UpdateHandler::searchAndReplaceAll( rtl::OUString &rText, 632 const rtl::OUString &rWhat, 633 const rtl::OUString &rWith ) const 634 { 635 sal_Int32 nIndex = rText.indexOf( rWhat ); 636 637 while ( nIndex != -1 ) 638 { 639 rText = rText.replaceAt( nIndex, rWhat.getLength(), rWith ); 640 nIndex = rText.indexOf( rWhat, nIndex ); 641 } 642 } 643 644 //-------------------------------------------------------------------- 645 rtl::OUString UpdateHandler::loadString( const uno::Reference< resource::XResourceBundle > xBundle, 646 sal_Int32 nResourceId ) const 647 { 648 rtl::OUString sString; 649 rtl::OUString sKey = UNISTRING( "string:" ) + rtl::OUString::valueOf( nResourceId ); 650 651 try 652 { 653 OSL_VERIFY( xBundle->getByName( sKey ) >>= sString ); 654 } 655 catch( const uno::Exception& ) 656 { 657 OSL_ENSURE( false, "UpdateHandler::loadString: caught an exception!" ); 658 sString = UNISTRING("Missing ") + sKey; 659 } 660 661 return sString; 662 } 663 664 rtl::OUString UpdateHandler::substVariables( const rtl::OUString &rSource ) const 665 { 666 rtl::OUString sString( rSource ); 667 668 searchAndReplaceAll( sString, UNISTRING( "%NEXTVERSION" ), msNextVersion ); 669 searchAndReplaceAll( sString, UNISTRING( "%DOWNLOAD_PATH" ), msDownloadPath ); 670 searchAndReplaceAll( sString, UNISTRING( "%FILE_NAME" ), msDownloadFile ); 671 searchAndReplaceAll( sString, UNISTRING( "%PERCENT" ), rtl::OUString::valueOf( mnPercent ) ); 672 673 return sString; 674 } 675 676 //-------------------------------------------------------------------- 677 void UpdateHandler::loadStrings() 678 { 679 if ( mbStringsLoaded ) 680 return; 681 else 682 mbStringsLoaded = true; 683 684 uno::Reference< resource::XResourceBundleLoader > xLoader; 685 try 686 { 687 uno::Any aValue( mxContext->getValueByName( 688 UNISTRING( "/singletons/com.sun.star.resource.OfficeResourceLoader" ) ) ); 689 OSL_VERIFY( aValue >>= xLoader ); 690 } 691 catch( const uno::Exception& ) 692 { 693 OSL_ENSURE( false, "UpdateHandler::loadStrings: could not create the resource loader!" ); 694 } 695 696 if ( !xLoader.is() ) return; 697 698 uno::Reference< resource::XResourceBundle > xBundle; 699 700 try 701 { 702 xBundle = xLoader->loadBundle_Default( UNISTRING( "upd" ) ); 703 } 704 catch( const resource::MissingResourceException& ) 705 { 706 OSL_ENSURE( false, "UpdateHandler::loadStrings: missing the resource bundle!" ); 707 } 708 709 if ( !xBundle.is() ) return; 710 711 msChecking = loadString( xBundle, RID_UPDATE_STR_CHECKING ); 712 msCheckingError = loadString( xBundle, RID_UPDATE_STR_CHECKING_ERR ); 713 msNoUpdFound = loadString( xBundle, RID_UPDATE_STR_NO_UPD_FOUND ); 714 715 msUpdFound = loadString( xBundle, RID_UPDATE_STR_UPD_FOUND ); 716 setFullVersion( msUpdFound ); 717 718 msDlgTitle = loadString( xBundle, RID_UPDATE_STR_DLG_TITLE ); 719 msDownloadPause = loadString( xBundle, RID_UPDATE_STR_DOWNLOAD_PAUSE ); 720 msDownloadError = loadString( xBundle, RID_UPDATE_STR_DOWNLOAD_ERR ); 721 msDownloadWarning = loadString( xBundle, RID_UPDATE_STR_DOWNLOAD_WARN ); 722 msDownloadDescr = loadString( xBundle, RID_UPDATE_STR_DOWNLOAD_DESCR ); 723 msDownloadNotAvail = loadString( xBundle, RID_UPDATE_STR_DOWNLOAD_UNAVAIL ); 724 msDownloading = loadString( xBundle, RID_UPDATE_STR_DOWNLOADING ); 725 msReady2Install = loadString( xBundle, RID_UPDATE_STR_READY_INSTALL ); 726 msCancelTitle = loadString( xBundle, RID_UPDATE_STR_CANCEL_TITLE ); 727 msCancelMessage = loadString( xBundle, RID_UPDATE_STR_CANCEL_DOWNLOAD ); 728 msInstallMessage = loadString( xBundle, RID_UPDATE_STR_BEGIN_INSTALL ); 729 msInstallNow = loadString( xBundle, RID_UPDATE_STR_INSTALL_NOW ); 730 msInstallLater = loadString( xBundle, RID_UPDATE_STR_INSTALL_LATER ); 731 msInstallError = loadString( xBundle, RID_UPDATE_STR_INSTALL_ERROR ); 732 msOverwriteWarning = loadString( xBundle, RID_UPDATE_STR_OVERWRITE_WARNING ); 733 msPercent = loadString( xBundle, RID_UPDATE_STR_PERCENT ); 734 msReloadWarning = loadString( xBundle, RID_UPDATE_STR_RELOAD_WARNING ); 735 msReloadReload = loadString( xBundle, RID_UPDATE_STR_RELOAD_RELOAD ); 736 msReloadContinue = loadString( xBundle, RID_UPDATE_STR_RELOAD_CONTINUE ); 737 738 msStatusFL = loadString( xBundle, RID_UPDATE_FT_STATUS ); 739 msDescription = loadString( xBundle, RID_UPDATE_FT_DESCRIPTION ); 740 741 msClose = loadString( xBundle, RID_UPDATE_BTN_CLOSE ); 742 msDownload = loadString( xBundle, RID_UPDATE_BTN_DOWNLOAD ); 743 msInstall = loadString( xBundle, RID_UPDATE_BTN_INSTALL ); 744 msPauseBtn = loadString( xBundle, RID_UPDATE_BTN_PAUSE ); 745 msResumeBtn = loadString( xBundle, RID_UPDATE_BTN_RESUME ); 746 msCancelBtn = loadString( xBundle, RID_UPDATE_BTN_CANCEL ); 747 748 // all update states before UPDATESTATE_UPDATE_AVAIL don't have a bubble 749 // so we can ignore them 750 for ( int i=0; i < (int)(UPDATESTATES_COUNT - UPDATESTATE_UPDATE_AVAIL); i++ ) 751 { 752 msBubbleTexts[ i ] = loadString( xBundle, RID_UPDATE_BUBBLE_TEXT_START + i ); 753 msBubbleTitles[ i ] = loadString( xBundle, RID_UPDATE_BUBBLE_T_TEXT_START + i ); 754 } 755 756 for ( int i=0; i < BUTTON_COUNT; i++ ) 757 { 758 msButtonIDs[ i ] = UNISTRING("BUTTON_") + rtl::OUString::valueOf( (sal_Int32) i ); 759 } 760 } 761 762 763 //-------------------------------------------------------------------- 764 void UpdateHandler::startThrobber( bool bStart ) 765 { 766 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 767 uno::Reference< awt::XControlContainer > xContainer( mxUpdDlg, uno::UNO_QUERY ); 768 uno::Reference< awt::XAnimation > xThrobber( xContainer->getControl( CTRL_THROBBER ), uno::UNO_QUERY ); 769 770 if ( xThrobber.is() ) 771 { 772 if ( bStart ) 773 xThrobber->startAnimation(); 774 else 775 xThrobber->stopAnimation(); 776 } 777 778 uno::Reference< awt::XWindow > xWindow( xContainer->getControl( CTRL_THROBBER ), uno::UNO_QUERY ); 779 if (xWindow.is() ) 780 xWindow->setVisible( bStart ); 781 } 782 783 //-------------------------------------------------------------------- 784 void UpdateHandler::setControlProperty( const rtl::OUString &rCtrlName, 785 const rtl::OUString &rPropName, 786 const uno::Any &rPropValue ) 787 { 788 if ( !mxUpdDlg.is() ) return; 789 790 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 791 uno::Reference< awt::XControlContainer > xContainer( mxUpdDlg, uno::UNO_QUERY ); 792 uno::Reference< awt::XControl > xControl( xContainer->getControl( rCtrlName ), uno::UNO_QUERY_THROW ); 793 uno::Reference< awt::XControlModel > xControlModel( xControl->getModel(), uno::UNO_QUERY_THROW ); 794 uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY_THROW ); 795 796 try { 797 xPropSet->setPropertyValue( rPropName, rPropValue ); 798 } 799 catch( const beans::UnknownPropertyException& ) 800 { 801 OSL_ENSURE( false, "UpdateHandler::setControlProperty: caught an exception!" ); 802 } 803 } 804 805 //-------------------------------------------------------------------- 806 void UpdateHandler::showControl( const rtl::OUString &rCtrlName, bool bShow ) 807 { 808 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 809 uno::Reference< awt::XControlContainer > xContainer( mxUpdDlg, uno::UNO_QUERY ); 810 811 if ( !xContainer.is() ) 812 { 813 OSL_ENSURE( false, "UpdateHandler::showControl: could not get control container!" ); 814 return; 815 } 816 817 uno::Reference< awt::XWindow > xWindow( xContainer->getControl( rCtrlName ), uno::UNO_QUERY ); 818 if ( xWindow.is() ) 819 xWindow->setVisible( bShow ); 820 } 821 822 //-------------------------------------------------------------------- 823 void UpdateHandler::focusControl( DialogControls eID ) 824 { 825 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 826 uno::Reference< awt::XControlContainer > xContainer( mxUpdDlg, uno::UNO_QUERY ); 827 828 if ( !xContainer.is() ) 829 { 830 OSL_ENSURE( false, "UpdateHandler::focusControl: could not get control container!" ); 831 return; 832 } 833 834 OSL_ENSURE( (eID < BUTTON_COUNT), "UpdateHandler::focusControl: id to big!" ); 835 836 uno::Reference< awt::XWindow > xWindow( xContainer->getControl( msButtonIDs[(short)eID] ), uno::UNO_QUERY ); 837 if ( xWindow.is() ) 838 xWindow->setFocus(); 839 } 840 841 //-------------------------------------------------------------------- 842 // Requires the Solar Mutex to be locked 843 void UpdateHandler::insertControlModel( uno::Reference< awt::XControlModel > & rxDialogModel, 844 rtl::OUString const & rServiceName, 845 rtl::OUString const & rControlName, 846 awt::Rectangle const & rPosSize, 847 uno::Sequence< beans::NamedValue > const & rProps ) 848 { 849 uno::Reference< lang::XMultiServiceFactory > xFactory (rxDialogModel, uno::UNO_QUERY_THROW); 850 uno::Reference< awt::XControlModel > xModel (xFactory->createInstance (rServiceName), uno::UNO_QUERY_THROW); 851 uno::Reference< beans::XPropertySet > xPropSet (xModel, uno::UNO_QUERY_THROW); 852 853 for (sal_Int32 i = 0, n = rProps.getLength(); i < n; i++) 854 { 855 xPropSet->setPropertyValue (rProps[i].Name, rProps[i].Value); 856 } 857 858 // @see awt/UnoControlDialogElement.idl 859 xPropSet->setPropertyValue( UNISTRING("Name"), uno::Any (rControlName) ); 860 xPropSet->setPropertyValue( UNISTRING("PositionX"), uno::Any (rPosSize.X) ); 861 xPropSet->setPropertyValue( UNISTRING("PositionY"), uno::Any (rPosSize.Y) ); 862 xPropSet->setPropertyValue( UNISTRING("Height"), uno::Any (rPosSize.Height) ); 863 xPropSet->setPropertyValue( UNISTRING("Width"), uno::Any (rPosSize.Width) ); 864 865 // insert by Name into DialogModel container 866 uno::Reference< container::XNameContainer > xContainer (rxDialogModel, uno::UNO_QUERY_THROW); 867 xContainer->insertByName( rControlName, uno::Any (uno::Reference< uno::XInterface >(xModel, uno::UNO_QUERY))); 868 } 869 870 //-------------------------------------------------------------------- 871 void UpdateHandler::setFullVersion( rtl::OUString& rString ) 872 { 873 if( !mxContext.is() ) 874 throw uno::RuntimeException( UNISTRING( "getProductName: empty component context" ), *this ); 875 876 uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager() ); 877 878 if( !xServiceManager.is() ) 879 throw uno::RuntimeException( UNISTRING( "getProductName: unable to obtain service manager from component context" ), *this ); 880 881 uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider( 882 xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.configuration.ConfigurationProvider" ), mxContext ), 883 uno::UNO_QUERY_THROW); 884 885 beans::PropertyValue aProperty; 886 aProperty.Name = UNISTRING( "nodepath" ); 887 aProperty.Value = uno::makeAny( UNISTRING("org.openoffice.Setup/Product") ); 888 889 uno::Sequence< uno::Any > aArgumentList( 1 ); 890 aArgumentList[0] = uno::makeAny( aProperty ); 891 892 uno::Reference< uno::XInterface > xConfigAccess; 893 xConfigAccess = xConfigurationProvider->createInstanceWithArguments( UNISTRING("com.sun.star.configuration.ConfigurationAccess"), 894 aArgumentList ); 895 896 uno::Reference< container::XNameAccess > xNameAccess( xConfigAccess, uno::UNO_QUERY_THROW ); 897 898 rtl::OUString aProductVersion; 899 rtl::OUString aProductFullVersion; 900 901 xNameAccess->getByName(UNISTRING("ooSetupVersion")) >>= aProductVersion; 902 aProductFullVersion = aProductVersion; 903 904 sal_Int32 nVerIndex = rString.indexOf( aProductVersion ); 905 if ( nVerIndex != -1 ) 906 { 907 rtl::OUString aPackageVersion = UNISTRING( "${$OOO_BASE_DIR/program/" SAL_CONFIGFILE("version") ":OOOPackageVersion}" ); 908 rtl::Bootstrap::expandMacros( aPackageVersion ); 909 910 if ( aPackageVersion.getLength() ) 911 { 912 sal_Int32 nTokIndex = 0; 913 rtl::OUString aVersionMinor = aPackageVersion.getToken( 1, '.', nTokIndex ); 914 rtl::OUString aVersionMicro; 915 916 if ( nTokIndex > 0 ) 917 aVersionMicro = aPackageVersion.getToken( 0, '.', nTokIndex ); 918 919 if ( aVersionMinor.getLength() == 0 ) 920 aVersionMinor = UNISTRING( "0" ); 921 if ( aVersionMicro.getLength() == 0 ) 922 aVersionMicro = UNISTRING( "0" ); 923 924 sal_Int32 nIndex = aProductFullVersion.indexOf( '.' ); 925 if ( nIndex == -1 ) 926 { 927 aProductFullVersion += UNISTRING( "." ); 928 aProductFullVersion += aVersionMinor; 929 } 930 else 931 { 932 nIndex = aProductFullVersion.indexOf( '.', nIndex+1 ); 933 } 934 if ( nIndex == -1 ) 935 { 936 aProductFullVersion += UNISTRING( "." ); 937 aProductFullVersion += aVersionMicro; 938 } 939 else 940 { 941 aProductFullVersion = aProductFullVersion.replaceAt( nIndex+1, aProductFullVersion.getLength()-nIndex-1, aVersionMicro ); 942 } 943 } 944 rString = rString.replaceAt( nVerIndex, aProductVersion.getLength(), aProductFullVersion ); 945 } 946 } 947 948 //-------------------------------------------------------------------- 949 bool UpdateHandler::showWarning( const rtl::OUString &rWarningText ) const 950 { 951 bool bRet = false; 952 953 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 954 uno::Reference< awt::XControl > xControl( mxUpdDlg, uno::UNO_QUERY ); 955 if ( !xControl.is() ) return bRet; 956 957 uno::Reference< awt::XWindowPeer > xPeer = xControl->getPeer(); 958 if ( !xPeer.is() ) return bRet; 959 960 uno::Reference< awt::XToolkit > xToolkit = xPeer->getToolkit(); 961 if ( !xToolkit.is() ) return bRet; 962 963 awt::WindowDescriptor aDescriptor; 964 965 sal_Int32 nWindowAttributes = awt::WindowAttribute::BORDER | awt::WindowAttribute::MOVEABLE | awt::WindowAttribute::CLOSEABLE; 966 nWindowAttributes |= awt::VclWindowPeerAttribute::YES_NO; 967 nWindowAttributes |= awt::VclWindowPeerAttribute::DEF_NO; 968 969 aDescriptor.Type = awt::WindowClass_MODALTOP; 970 aDescriptor.WindowServiceName = UNISTRING( "warningbox" ); 971 aDescriptor.ParentIndex = -1; 972 aDescriptor.Parent = xPeer; 973 aDescriptor.Bounds = awt::Rectangle( 10, 10, 250, 150 ); 974 aDescriptor.WindowAttributes = nWindowAttributes; 975 976 uno::Reference< awt::XMessageBox > xMsgBox( xToolkit->createWindow( aDescriptor ), uno::UNO_QUERY ); 977 if ( xMsgBox.is() ) 978 { 979 mbShowsMessageBox = true; 980 sal_Int16 nRet; 981 // xMsgBox->setCaptionText( msCancelTitle ); 982 xMsgBox->setMessageText( rWarningText ); 983 nRet = xMsgBox->execute(); 984 if ( nRet == 2 ) // RET_YES == 2 985 bRet = true; 986 mbShowsMessageBox = false; 987 } 988 989 uno::Reference< lang::XComponent > xComponent( xMsgBox, uno::UNO_QUERY ); 990 if ( xComponent.is() ) 991 xComponent->dispose(); 992 993 return bRet; 994 } 995 996 //-------------------------------------------------------------------- 997 bool UpdateHandler::showWarning( const rtl::OUString &rWarningText, 998 const rtl::OUString &rBtnText_1, 999 const rtl::OUString &rBtnText_2 ) const 1000 { 1001 bool bRet = false; 1002 1003 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1004 uno::Reference< awt::XControl > xControl( mxUpdDlg, uno::UNO_QUERY ); 1005 if ( !xControl.is() ) return bRet; 1006 1007 uno::Reference< awt::XWindowPeer > xPeer = xControl->getPeer(); 1008 if ( !xPeer.is() ) return bRet; 1009 1010 uno::Reference< awt::XToolkit > xToolkit = xPeer->getToolkit(); 1011 if ( !xToolkit.is() ) return bRet; 1012 1013 awt::WindowDescriptor aDescriptor; 1014 1015 sal_Int32 nWindowAttributes = awt::WindowAttribute::BORDER | awt::WindowAttribute::MOVEABLE | awt::WindowAttribute::CLOSEABLE; 1016 nWindowAttributes |= awt::VclWindowPeerAttribute::YES_NO; 1017 nWindowAttributes |= awt::VclWindowPeerAttribute::DEF_NO; 1018 1019 aDescriptor.Type = awt::WindowClass_MODALTOP; 1020 aDescriptor.WindowServiceName = UNISTRING( "warningbox" ); 1021 aDescriptor.ParentIndex = -1; 1022 aDescriptor.Parent = xPeer; 1023 aDescriptor.Bounds = awt::Rectangle( 10, 10, 250, 150 ); 1024 aDescriptor.WindowAttributes = nWindowAttributes; 1025 1026 uno::Reference< awt::XMessageBox > xMsgBox( xToolkit->createWindow( aDescriptor ), uno::UNO_QUERY ); 1027 if ( xMsgBox.is() ) 1028 { 1029 uno::Reference< awt::XVclContainer > xMsgBoxCtrls( xMsgBox, uno::UNO_QUERY ); 1030 if ( xMsgBoxCtrls.is() ) 1031 { 1032 uno::Sequence< uno::Reference< awt::XWindow > > xChildren = xMsgBoxCtrls->getWindows(); 1033 1034 for ( long i=0; i < xChildren.getLength(); i++ ) 1035 { 1036 uno::Reference< awt::XVclWindowPeer > xMsgBoxCtrl( xChildren[i], uno::UNO_QUERY ); 1037 if ( xMsgBoxCtrl.is() ) 1038 { 1039 bool bIsDefault = true; 1040 uno::Any aValue = xMsgBoxCtrl->getProperty( UNISTRING("DefaultButton") ); 1041 aValue >>= bIsDefault; 1042 if ( bIsDefault ) 1043 xMsgBoxCtrl->setProperty( UNISTRING("Text"), uno::Any( rBtnText_1 ) ); 1044 else 1045 xMsgBoxCtrl->setProperty( UNISTRING("Text"), uno::Any( rBtnText_2 ) ); 1046 } 1047 } 1048 } 1049 1050 sal_Int16 nRet; 1051 // xMsgBox->setCaptionText( msCancelTitle ); 1052 mbShowsMessageBox = true; 1053 xMsgBox->setMessageText( rWarningText ); 1054 nRet = xMsgBox->execute(); 1055 if ( nRet == 2 ) // RET_YES == 2 1056 bRet = true; 1057 1058 mbShowsMessageBox = false; 1059 } 1060 1061 uno::Reference< lang::XComponent > xComponent( xMsgBox, uno::UNO_QUERY ); 1062 if ( xComponent.is() ) 1063 xComponent->dispose(); 1064 1065 return bRet; 1066 } 1067 1068 //-------------------------------------------------------------------- 1069 bool UpdateHandler::showOverwriteWarning( const rtl::OUString& rFileName ) const 1070 { 1071 rtl::OUString aMsg( msReloadWarning ); 1072 searchAndReplaceAll( aMsg, UNISTRING( "%FILENAME" ), rFileName ); 1073 searchAndReplaceAll( aMsg, UNISTRING( "%DOWNLOAD_PATH" ), msDownloadPath ); 1074 return showWarning( aMsg, msReloadContinue, msReloadReload ); 1075 } 1076 1077 //-------------------------------------------------------------------- 1078 bool UpdateHandler::showOverwriteWarning() const 1079 { 1080 return showWarning( msOverwriteWarning ); 1081 } 1082 1083 //-------------------------------------------------------------------- 1084 #define BUTTON_HEIGHT 14 1085 #define BUTTON_WIDTH 50 1086 #define BUTTON_X_OFFSET 7 1087 #define BUTTON_Y_OFFSET 3 1088 #define LABEL_HEIGHT 10 1089 1090 #define DIALOG_WIDTH 300 1091 #define DIALOG_BORDER 5 1092 #define INNER_BORDER 3 1093 #define TEXT_OFFSET 1 1094 #define BOX_HEIGHT1 ( LABEL_HEIGHT + 3*BUTTON_HEIGHT + 2*BUTTON_Y_OFFSET + 2*INNER_BORDER ) 1095 #define BOX_HEIGHT2 50 1096 #define EDIT_WIDTH ( DIALOG_WIDTH - 2 * DIALOG_BORDER ) 1097 #define BOX1_BTN_X ( DIALOG_BORDER + EDIT_WIDTH - BUTTON_WIDTH - INNER_BORDER ) 1098 #define BOX1_BTN_Y ( DIALOG_BORDER + LABEL_HEIGHT + INNER_BORDER) 1099 #define THROBBER_WIDTH 16 1100 #define THROBBER_HEIGHT 16 1101 #define THROBBER_X_POS ( DIALOG_BORDER + 8 ) 1102 #define THROBBER_Y_POS ( DIALOG_BORDER + 23 ) 1103 #define BUTTON_BAR_HEIGHT 24 1104 #define LABEL_OFFSET ( LABEL_HEIGHT + 4 ) 1105 #define DIALOG_HEIGHT ( BOX_HEIGHT1 + BOX_HEIGHT2 + LABEL_OFFSET + BUTTON_BAR_HEIGHT + 3 * DIALOG_BORDER ) 1106 #define LABEL_Y_POS ( 2 * DIALOG_BORDER + BOX_HEIGHT1 ) 1107 #define EDIT2_Y_POS ( LABEL_Y_POS + LABEL_HEIGHT ) 1108 #define BUTTON_BAR_Y_POS ( EDIT2_Y_POS + DIALOG_BORDER + BOX_HEIGHT2 ) 1109 #define BUTTON_Y_POS ( BUTTON_BAR_Y_POS + 8 ) 1110 #define CLOSE_BTN_X ( DIALOG_WIDTH - DIALOG_BORDER - BUTTON_WIDTH ) 1111 #define INSTALL_BTN_X ( CLOSE_BTN_X - 2 * BUTTON_X_OFFSET - BUTTON_WIDTH ) 1112 #define DOWNLOAD_BTN_X ( INSTALL_BTN_X - BUTTON_X_OFFSET - BUTTON_WIDTH ) 1113 #define PROGRESS_WIDTH 80 1114 #define PROGRESS_HEIGHT 10 1115 #define PROGRESS_X_POS ( DIALOG_BORDER + 8 ) 1116 #define PROGRESS_Y_POS ( DIALOG_BORDER + 2*LABEL_OFFSET ) 1117 1118 //-------------------------------------------------------------------- 1119 void UpdateHandler::showControls( short nControls ) 1120 { 1121 // The buttons from CANCEL_BUTTON to RESUME_BUTTON will be shown or 1122 // hidden on demand 1123 short nShiftMe; 1124 for ( int i = 0; i <= (int)RESUME_BUTTON; i++ ) 1125 { 1126 nShiftMe = (short)(nControls >> i); 1127 showControl( msButtonIDs[i], (bool)(nShiftMe & 0x01) ); 1128 } 1129 1130 nShiftMe = (short)(nControls >> THROBBER_CTRL); 1131 startThrobber( (bool)(nShiftMe & 0x01) ); 1132 1133 nShiftMe = (short)(nControls >> PROGRESS_CTRL); 1134 showControl( CTRL_PROGRESS, (bool)(nShiftMe & 0x01) ); 1135 showControl( TEXT_PERCENT, (bool)(nShiftMe & 0x01) ); 1136 1137 // Status text needs to be smaller, when there are buttons at the right side of the dialog 1138 if ( ( nControls & ( (1<<CANCEL_BUTTON) + (1<<PAUSE_BUTTON) + (1<<RESUME_BUTTON) ) ) != 0 ) 1139 setControlProperty( TEXT_STATUS, UNISTRING("Width"), uno::Any( sal_Int32(EDIT_WIDTH - BUTTON_WIDTH - 2*INNER_BORDER - TEXT_OFFSET ) ) ); 1140 else 1141 setControlProperty( TEXT_STATUS, UNISTRING("Width"), uno::Any( sal_Int32(EDIT_WIDTH - 2*TEXT_OFFSET ) ) ); 1142 1143 // Status text needs to be taller, when we show the progress bar 1144 if ( ( nControls & ( 1<<PROGRESS_CTRL ) ) != 0 ) 1145 setControlProperty( TEXT_STATUS, UNISTRING("Height"), uno::Any( sal_Int32(LABEL_HEIGHT) ) ); 1146 else 1147 setControlProperty( TEXT_STATUS, UNISTRING("Height"), uno::Any( sal_Int32(BOX_HEIGHT1 - 4*TEXT_OFFSET - LABEL_HEIGHT ) ) ); 1148 } 1149 1150 //-------------------------------------------------------------------- 1151 void UpdateHandler::createDialog() 1152 { 1153 if ( !mxContext.is() ) 1154 { 1155 OSL_ASSERT( false ); 1156 return; 1157 } 1158 1159 uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager() ); 1160 1161 if( xServiceManager.is() ) 1162 { 1163 uno::Reference< frame::XDesktop > xDesktop( 1164 xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.frame.Desktop"), mxContext ), 1165 uno::UNO_QUERY ); 1166 if ( xDesktop.is() ) 1167 xDesktop->addTerminateListener( this ); 1168 } 1169 1170 loadStrings(); 1171 1172 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1173 uno::Reference< lang::XMultiComponentFactory > xFactory( mxContext->getServiceManager(), uno::UNO_QUERY_THROW ); 1174 uno::Reference< awt::XControlModel > xControlModel( xFactory->createInstanceWithContext( 1175 UNISTRING("com.sun.star.awt.UnoControlDialogModel"), 1176 mxContext), uno::UNO_QUERY_THROW ); 1177 { 1178 // @see awt/UnoControlDialogModel.idl 1179 uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY_THROW ); 1180 1181 xPropSet->setPropertyValue( UNISTRING("Title"), uno::Any( msDlgTitle ) ); 1182 xPropSet->setPropertyValue( UNISTRING("Closeable"), uno::Any( true ) ); 1183 xPropSet->setPropertyValue( UNISTRING("Enabled"), uno::Any( true ) ); 1184 xPropSet->setPropertyValue( UNISTRING("Moveable"), uno::Any( true ) ); 1185 xPropSet->setPropertyValue( UNISTRING("Sizeable"), uno::Any( true ) ); 1186 xPropSet->setPropertyValue( UNISTRING("DesktopAsParent"), uno::Any( true ) ); 1187 xPropSet->setPropertyValue( UNISTRING("PositionX"), uno::Any(sal_Int32( 100 )) ); 1188 xPropSet->setPropertyValue( UNISTRING("PositionY"), uno::Any(sal_Int32( 100 )) ); 1189 xPropSet->setPropertyValue( UNISTRING("Width"), uno::Any(sal_Int32( DIALOG_WIDTH )) ); 1190 xPropSet->setPropertyValue( UNISTRING("Height"), uno::Any(sal_Int32( DIALOG_HEIGHT )) ); 1191 xPropSet->setPropertyValue( UNISTRING("HelpURL"), uno::Any( UNISTRING( INET_HID_SCHEME ) + rtl::OUString::createFromAscii( HID_CHECK_FOR_UPD_DLG ) ) ); 1192 } 1193 { // Label (fixed text) <status> 1194 uno::Sequence< beans::NamedValue > aProps(1); 1195 1196 setProperty( aProps, 0, UNISTRING("Label"), uno::Any( msStatusFL ) ); 1197 1198 insertControlModel( xControlModel, FIXED_TEXT_MODEL, UNISTRING( "fixedLineStatus" ), 1199 awt::Rectangle( DIALOG_BORDER+1, DIALOG_BORDER, EDIT_WIDTH-2, LABEL_HEIGHT ), 1200 aProps ); 1201 } 1202 { // box around <status> text 1203 uno::Sequence< beans::NamedValue > aProps; 1204 1205 insertControlModel( xControlModel, GROUP_BOX_MODEL, UNISTRING( "StatusBox" ), 1206 awt::Rectangle( DIALOG_BORDER, DIALOG_BORDER + LABEL_HEIGHT, EDIT_WIDTH, BOX_HEIGHT1 - LABEL_HEIGHT ), 1207 aProps ); 1208 } 1209 { // Text (multiline edit) <status> 1210 uno::Sequence< beans::NamedValue > aProps(7); 1211 1212 setProperty( aProps, 0, UNISTRING("Text"), uno::Any( substVariables(msChecking) ) ); 1213 setProperty( aProps, 1, UNISTRING("Border"), uno::Any( sal_Int16( 0 ) ) ); 1214 setProperty( aProps, 2, UNISTRING("PaintTransparent"), uno::Any( true ) ); 1215 setProperty( aProps, 3, UNISTRING("MultiLine"), uno::Any( true ) ); 1216 setProperty( aProps, 4, UNISTRING("ReadOnly"), uno::Any( true ) ); 1217 setProperty( aProps, 5, UNISTRING("AutoVScroll"), uno::Any( true ) ); 1218 setProperty( aProps, 6, UNISTRING("HelpURL"), uno::Any( UNISTRING( INET_HID_SCHEME ) + rtl::OUString::createFromAscii( HID_CHECK_FOR_UPD_STATUS ) ) ); 1219 1220 insertControlModel( xControlModel, EDIT_FIELD_MODEL, TEXT_STATUS, 1221 awt::Rectangle( DIALOG_BORDER + TEXT_OFFSET, 1222 DIALOG_BORDER + LABEL_HEIGHT + TEXT_OFFSET, 1223 EDIT_WIDTH - 2*TEXT_OFFSET, 1224 BOX_HEIGHT1 - 4*TEXT_OFFSET - LABEL_HEIGHT ), 1225 aProps ); 1226 } 1227 { // Text (edit) <percent> 1228 uno::Sequence< beans::NamedValue > aProps(4); 1229 1230 setProperty( aProps, 0, UNISTRING("Text"), uno::Any( msPercent ) ); 1231 setProperty( aProps, 1, UNISTRING("Border"), uno::Any( sal_Int16( 0 ) ) ); 1232 setProperty( aProps, 2, UNISTRING("PaintTransparent"), uno::Any( true ) ); 1233 setProperty( aProps, 3, UNISTRING("ReadOnly"), uno::Any( true ) ); 1234 1235 insertControlModel( xControlModel, EDIT_FIELD_MODEL, TEXT_PERCENT, 1236 awt::Rectangle( PROGRESS_X_POS + PROGRESS_WIDTH + DIALOG_BORDER, 1237 PROGRESS_Y_POS, 1238 EDIT_WIDTH - PROGRESS_WIDTH - BUTTON_WIDTH - 2*DIALOG_BORDER, 1239 LABEL_HEIGHT ), 1240 aProps ); 1241 } 1242 { // pause button 1243 uno::Sequence< beans::NamedValue > aProps(5); 1244 1245 setProperty( aProps, 0, UNISTRING("DefaultButton"), uno::Any( false ) ); 1246 setProperty( aProps, 1, UNISTRING("Enabled"), uno::Any( true ) ); 1247 setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD) ) ); 1248 setProperty( aProps, 3, UNISTRING("Label"), uno::Any( msPauseBtn ) ); 1249 setProperty( aProps, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( INET_HID_SCHEME ) + rtl::OUString::createFromAscii( HID_CHECK_FOR_UPD_PAUSE ) ) ); 1250 1251 insertControlModel ( xControlModel, BUTTON_MODEL, msButtonIDs[PAUSE_BUTTON], 1252 awt::Rectangle( BOX1_BTN_X, BOX1_BTN_Y, BUTTON_WIDTH, BUTTON_HEIGHT ), 1253 aProps ); 1254 } 1255 { // resume button 1256 uno::Sequence< beans::NamedValue > aProps(5); 1257 1258 setProperty( aProps, 0, UNISTRING("DefaultButton"), uno::Any( false ) ); 1259 setProperty( aProps, 1, UNISTRING("Enabled"), uno::Any( true ) ); 1260 setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD) ) ); 1261 setProperty( aProps, 3, UNISTRING("Label"), uno::Any( msResumeBtn ) ); 1262 setProperty( aProps, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( INET_HID_SCHEME ) + rtl::OUString::createFromAscii( HID_CHECK_FOR_UPD_RESUME ) ) ); 1263 1264 insertControlModel ( xControlModel, BUTTON_MODEL, msButtonIDs[RESUME_BUTTON], 1265 awt::Rectangle( BOX1_BTN_X, 1266 BOX1_BTN_Y + BUTTON_Y_OFFSET + BUTTON_HEIGHT, 1267 BUTTON_WIDTH, 1268 BUTTON_HEIGHT ), 1269 aProps ); 1270 } 1271 { // abort button 1272 uno::Sequence< beans::NamedValue > aProps(5); 1273 1274 setProperty( aProps, 0, UNISTRING("DefaultButton"), uno::Any( false ) ); 1275 setProperty( aProps, 1, UNISTRING("Enabled"), uno::Any( true ) ); 1276 setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD) ) ); 1277 setProperty( aProps, 3, UNISTRING("Label"), uno::Any( msCancelBtn ) ); 1278 setProperty( aProps, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( INET_HID_SCHEME ) + rtl::OUString::createFromAscii( HID_CHECK_FOR_UPD_CANCEL ) ) ); 1279 1280 insertControlModel ( xControlModel, BUTTON_MODEL, msButtonIDs[CANCEL_BUTTON], 1281 awt::Rectangle( BOX1_BTN_X, 1282 BOX1_BTN_Y + (2*(BUTTON_HEIGHT+BUTTON_Y_OFFSET)), 1283 BUTTON_WIDTH, 1284 BUTTON_HEIGHT ), 1285 aProps ); 1286 } 1287 { // Label (FixedText) <description> 1288 uno::Sequence< beans::NamedValue > aProps(1); 1289 1290 setProperty( aProps, 0, UNISTRING("Label"), uno::Any( msDescription ) ); 1291 1292 insertControlModel( xControlModel, FIXED_TEXT_MODEL, UNISTRING( "fixedTextDescription" ), 1293 awt::Rectangle( DIALOG_BORDER+1, LABEL_Y_POS, EDIT_WIDTH-2, LABEL_HEIGHT ), 1294 aProps ); 1295 } 1296 { // box around <description> text 1297 uno::Sequence< beans::NamedValue > aProps; 1298 1299 insertControlModel( xControlModel, GROUP_BOX_MODEL, UNISTRING( "DescriptionBox" ), 1300 awt::Rectangle( DIALOG_BORDER, EDIT2_Y_POS, EDIT_WIDTH, BOX_HEIGHT2 ), 1301 aProps ); 1302 } 1303 { // Text (MultiLineEdit) <description> 1304 uno::Sequence< beans::NamedValue > aProps(7); 1305 1306 setProperty( aProps, 0, UNISTRING("Text"), uno::Any( rtl::OUString() ) ); 1307 setProperty( aProps, 1, UNISTRING("Border"), uno::Any( sal_Int16( 0 ) ) ); 1308 setProperty( aProps, 2, UNISTRING("PaintTransparent"), uno::Any( true ) ); 1309 setProperty( aProps, 3, UNISTRING("MultiLine"), uno::Any( true ) ); 1310 setProperty( aProps, 4, UNISTRING("ReadOnly"), uno::Any( true ) ); 1311 setProperty( aProps, 5, UNISTRING("AutoVScroll"), uno::Any( true ) ); 1312 setProperty( aProps, 6, UNISTRING("HelpURL"), uno::Any( UNISTRING( INET_HID_SCHEME ) + rtl::OUString::createFromAscii( HID_CHECK_FOR_UPD_DESCRIPTION ) ) ); 1313 1314 insertControlModel( xControlModel, EDIT_FIELD_MODEL, TEXT_DESCRIPTION, 1315 awt::Rectangle( DIALOG_BORDER + TEXT_OFFSET, 1316 EDIT2_Y_POS + 2*TEXT_OFFSET, 1317 EDIT_WIDTH - 3*TEXT_OFFSET, 1318 BOX_HEIGHT2 - 3*TEXT_OFFSET ), 1319 aProps ); 1320 } 1321 { // @see awt/UnoControlFixedLineModel.idl 1322 uno::Sequence< beans::NamedValue > aProps(1); 1323 1324 setProperty( aProps, 0, UNISTRING("Orientation"), uno::Any( sal_Int32( 0 ) ) ); 1325 1326 insertControlModel( xControlModel, FIXED_LINE_MODEL, UNISTRING("fixedLine"), 1327 awt::Rectangle( 0, BUTTON_BAR_Y_POS, DIALOG_WIDTH, 5 ), 1328 aProps ); 1329 } 1330 { // close button // @see awt/UnoControlButtonModel.idl 1331 uno::Sequence< beans::NamedValue > aProps(5); 1332 1333 setProperty( aProps, 0, UNISTRING("DefaultButton"), uno::Any( false ) ); 1334 setProperty( aProps, 1, UNISTRING("Enabled"), uno::Any( true ) ); 1335 // [property] short PushButtonType 1336 // with own "ButtonActionListener" 1337 setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD) ) ); 1338 // with default ActionListener => endDialog(). 1339 // setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_CANCEL) ) ); 1340 // [property] string Label // only if PushButtonType_STANDARD 1341 setProperty( aProps, 3, UNISTRING("Label"), uno::Any( msClose ) ); 1342 setProperty( aProps, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( INET_HID_SCHEME ) + rtl::OUString::createFromAscii( HID_CHECK_FOR_UPD_CLOSE ) ) ); 1343 1344 insertControlModel ( xControlModel, BUTTON_MODEL, msButtonIDs[ CLOSE_BUTTON ], 1345 awt::Rectangle( CLOSE_BTN_X, BUTTON_Y_POS, BUTTON_WIDTH, BUTTON_HEIGHT ), 1346 aProps ); 1347 } 1348 { // install button 1349 uno::Sequence< beans::NamedValue > aProps(5); 1350 1351 setProperty( aProps, 0, UNISTRING("DefaultButton"), uno::Any( false ) ); 1352 setProperty( aProps, 1, UNISTRING("Enabled"), uno::Any( true ) ); 1353 setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD) ) ); 1354 setProperty( aProps, 3, UNISTRING("Label"), uno::Any( msInstall ) ); 1355 setProperty( aProps, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( INET_HID_SCHEME ) + rtl::OUString::createFromAscii( HID_CHECK_FOR_UPD_INSTALL ) ) ); 1356 1357 insertControlModel ( xControlModel, BUTTON_MODEL, msButtonIDs[INSTALL_BUTTON], 1358 awt::Rectangle( INSTALL_BTN_X, BUTTON_Y_POS, BUTTON_WIDTH, BUTTON_HEIGHT ), 1359 aProps ); 1360 } 1361 { // download button 1362 uno::Sequence< beans::NamedValue > aProps(5); 1363 1364 setProperty( aProps, 0, UNISTRING("DefaultButton"), uno::Any( false ) ); 1365 setProperty( aProps, 1, UNISTRING("Enabled"), uno::Any( true ) ); 1366 setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD) ) ); 1367 setProperty( aProps, 3, UNISTRING("Label"), uno::Any( msDownload ) ); 1368 setProperty( aProps, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( INET_HID_SCHEME ) + rtl::OUString::createFromAscii( HID_CHECK_FOR_UPD_DOWNLOAD ) ) ); 1369 1370 insertControlModel ( xControlModel, BUTTON_MODEL, msButtonIDs[DOWNLOAD_BUTTON], 1371 awt::Rectangle( DOWNLOAD_BTN_X, BUTTON_Y_POS, BUTTON_WIDTH, BUTTON_HEIGHT ), 1372 aProps ); 1373 } 1374 { // help button 1375 uno::Sequence< beans::NamedValue > aProps(3); 1376 1377 setProperty( aProps, 0, UNISTRING("DefaultButton"), uno::Any( false ) ); 1378 setProperty( aProps, 1, UNISTRING("Enabled"), uno::Any( true ) ); 1379 setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_HELP) ) ); 1380 1381 insertControlModel( xControlModel, BUTTON_MODEL, msButtonIDs[HELP_BUTTON], 1382 awt::Rectangle( DIALOG_BORDER, BUTTON_Y_POS, BUTTON_WIDTH, BUTTON_HEIGHT ), 1383 aProps ); 1384 } 1385 { // @see awt/UnoControlThrobberModel.idl 1386 uno::Sequence< beans::NamedValue > aProps; 1387 1388 insertControlModel( xControlModel, UNISTRING("com.sun.star.awt.SpinningProgressControlModel"), CTRL_THROBBER, 1389 awt::Rectangle( THROBBER_X_POS, THROBBER_Y_POS, THROBBER_WIDTH, THROBBER_HEIGHT), 1390 aProps ); 1391 } 1392 { // @see awt/UnoControlProgressBarModel.idl 1393 uno::Sequence< beans::NamedValue > aProps(4); 1394 setProperty( aProps, 0, UNISTRING("Enabled"), uno::Any( true ) ); 1395 setProperty( aProps, 1, UNISTRING("ProgressValue"), uno::Any( sal_Int32( 0 ) ) ); 1396 setProperty( aProps, 2, UNISTRING("ProgressValueMax"), uno::Any( sal_Int32( 100 ) ) ); 1397 setProperty( aProps, 3, UNISTRING("ProgressValueMin"), uno::Any( sal_Int32( 0 ) ) ); 1398 1399 insertControlModel( xControlModel, UNISTRING("com.sun.star.awt.UnoControlProgressBarModel"), CTRL_PROGRESS, 1400 awt::Rectangle( PROGRESS_X_POS, PROGRESS_Y_POS, PROGRESS_WIDTH, PROGRESS_HEIGHT ), 1401 aProps); 1402 } 1403 1404 uno::Reference< awt::XControl > xControl( 1405 xFactory->createInstanceWithContext( UNISTRING("com.sun.star.awt.UnoControlDialog"), mxContext), 1406 uno::UNO_QUERY_THROW ); 1407 xControl->setModel( xControlModel ); 1408 1409 if ( mbVisible == false ) 1410 { 1411 uno::Reference< awt::XWindow > xWindow( xControl, uno::UNO_QUERY ); 1412 1413 if ( xWindow.is() ) 1414 xWindow->setVisible( false ); 1415 } 1416 1417 xControl->createPeer( NULL, NULL ); 1418 { 1419 uno::Reference< awt::XControlContainer > xContainer (xControl, uno::UNO_QUERY); 1420 for ( int i = 0; i < HELP_BUTTON; i++ ) 1421 { 1422 uno::Reference< awt::XButton > xButton ( xContainer->getControl( msButtonIDs[i] ), uno::UNO_QUERY); 1423 if (xButton.is()) 1424 { 1425 xButton->setActionCommand( msButtonIDs[i] ); 1426 xButton->addActionListener( this ); 1427 } 1428 } 1429 } 1430 1431 mxUpdDlg.set( xControl, uno::UNO_QUERY_THROW ); 1432 mnLastCtrlState = -1; 1433 } 1434