1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: updatehdl.cxx,v $
11 * This file is part of OpenOffice.org.
13 * OpenOffice.org is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU Lesser General Public License version 3
15 * only, as published by the Free Software Foundation.
17 * OpenOffice.org is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License version 3 for more details
21 * (a copy is included in the LICENSE file that accompanied this code).
23 * You should have received a copy of the GNU Lesser General Public License
24 * version 3 along with OpenOffice.org. If not, see
25 * <http://www.openoffice.org/license.html>
26 * for a copy of the LGPLv3 License.
28 ************************************************************************/
30 // MARKER(update_precomp.py): autogen include statement, do not remove
31 #include "precompiled_extensions.hxx"
33 #include "updatehdl.hxx"
34 #include "extensio.hrc"
36 #include "osl/diagnose.h"
37 #include "osl/thread.hxx"
38 #include "osl/file.hxx"
39 #include "rtl/ustring.hxx"
40 #include "rtl/bootstrap.hxx"
42 #include "com/sun/star/uno/Sequence.h"
44 #include <com/sun/star/style/VerticalAlignment.hpp>
46 #include "com/sun/star/awt/ActionEvent.hpp"
47 #include "com/sun/star/awt/PushButtonType.hpp"
48 #include "com/sun/star/awt/VclWindowPeerAttribute.hpp"
49 #include "com/sun/star/awt/WindowAttribute.hpp"
50 #include "com/sun/star/awt/XButton.hpp"
51 #include "com/sun/star/awt/XControl.hpp"
52 #include "com/sun/star/awt/XControlContainer.hpp"
53 #include "com/sun/star/awt/XMessageBox.hpp"
54 #include "com/sun/star/awt/XThrobber.hpp"
55 #include "com/sun/star/awt/XTopWindow.hpp"
56 #include "com/sun/star/awt/XVclWindowPeer.hpp"
57 #include "com/sun/star/awt/XWindow.hpp"
58 #include "com/sun/star/awt/XWindow2.hpp"
60 #include <com/sun/star/beans/PropertyValue.hpp>
61 #include "com/sun/star/beans/XPropertySet.hpp"
63 #include "com/sun/star/container/XNameContainer.hpp"
65 #include "com/sun/star/frame/XDesktop.hpp"
67 #include "com/sun/star/lang/XMultiServiceFactory.hpp"
68 #include "com/sun/star/task/InteractionRequestStringResolver.hpp"
70 #include <com/sun/star/resource/XResourceBundleLoader.hpp>
72 #include "updatehdl.hrc"
74 #define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
76 #define COMMAND_CLOSE UNISTRING("close")
78 #define CTRL_THROBBER UNISTRING("throbber")
79 #define CTRL_PROGRESS UNISTRING("progress")
81 #define TEXT_STATUS UNISTRING("text_status")
82 #define TEXT_PERCENT UNISTRING("text_percent")
83 #define TEXT_DESCRIPTION UNISTRING("text_description")
85 #define FIXED_LINE_MODEL UNISTRING("com.sun.star.awt.UnoControlFixedLineModel")
86 #define FIXED_TEXT_MODEL UNISTRING("com.sun.star.awt.UnoControlFixedTextModel")
87 #define EDIT_FIELD_MODEL UNISTRING("com.sun.star.awt.UnoControlEditModel")
88 #define BUTTON_MODEL UNISTRING("com.sun.star.awt.UnoControlButtonModel")
89 #define GROUP_BOX_MODEL UNISTRING("com.sun.star.awt.UnoControlGroupBoxModel")
91 using namespace com::sun::star
;
93 //--------------------------------------------------------------------
94 UpdateHandler::UpdateHandler( const uno::Reference
< uno::XComponentContext
> & rxContext
,
95 const rtl::Reference
< IActionListener
> & rxActionListener
) :
96 mxContext( rxContext
),
97 mxActionListener( rxActionListener
),
98 meCurState( UPDATESTATES_COUNT
),
99 meLastState( UPDATESTATES_COUNT
),
101 mnLastCtrlState( -1 ),
102 mbDownloadBtnHasDots( false ),
104 mbStringsLoaded( false ),
105 mbMinimized( false ),
106 mbListenerAdded(false)
110 //--------------------------------------------------------------------
111 UpdateHandler::~UpdateHandler()
115 mxInteractionHdl
= NULL
;
116 mxActionListener
= NULL
;
119 //--------------------------------------------------------------------
120 void UpdateHandler::enableControls( short nCtrlState
)
122 osl::MutexGuard
aGuard( maMutex
);
124 if ( nCtrlState
== mnLastCtrlState
)
129 short nCurStateVal
= nCtrlState
;
130 short nOldStateVal
= mnLastCtrlState
;
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
++ )
136 nCurStateVal
= (short)(nCtrlState
>> i
);
137 nOldStateVal
= (short)(mnLastCtrlState
>> i
);
138 if ( ( nCurStateVal
& 0x01 ) != ( nOldStateVal
& 0x01 ) )
140 bEnableControl
= ( ( nCurStateVal
& 0x01 ) == 0x01 );
141 setControlProperty( msButtonIDs
[i
], UNISTRING("Enabled"), uno::Any( bEnableControl
) );
145 mnLastCtrlState
= nCtrlState
;
148 //--------------------------------------------------------------------
149 void UpdateHandler::setDownloadBtnLabel( bool bAppendDots
)
151 osl::MutexGuard
aGuard( maMutex
);
153 if ( mbDownloadBtnHasDots
!= bAppendDots
)
155 rtl::OUString
aLabel( msDownload
);
158 aLabel
+= UNISTRING( "..." );
160 setControlProperty( msButtonIDs
[DOWNLOAD_BUTTON
], UNISTRING("Label"), uno::Any( aLabel
) );
161 setControlProperty( msButtonIDs
[DOWNLOAD_BUTTON
], UNISTRING("HelpURL"), uno::Any( UNISTRING( "HID:" ) + rtl::OUString::valueOf( (sal_Int32
) HID_CHECK_FOR_UPD_DOWNLOAD2
) ) );
163 mbDownloadBtnHasDots
= bAppendDots
;
167 //--------------------------------------------------------------------
168 void UpdateHandler::setState( UpdateState eState
)
170 osl::MutexGuard
aGuard( maMutex
);
174 if ( mxUpdDlg
.is() && mbVisible
)
175 updateState( meCurState
);
178 //--------------------------------------------------------------------
179 bool UpdateHandler::isVisible() const
181 if ( !mxUpdDlg
.is() ) return false;
183 uno::Reference
< awt::XWindow2
> xWindow( mxUpdDlg
, uno::UNO_QUERY
);
186 return xWindow
->isVisible();
191 //--------------------------------------------------------------------
192 void UpdateHandler::setVisible( bool bVisible
)
194 osl::MutexGuard
aGuard( maMutex
);
196 mbVisible
= bVisible
;
200 if ( !mxUpdDlg
.is() )
203 updateState( meCurState
);
205 uno::Reference
< awt::XWindow
> xWindow( mxUpdDlg
, uno::UNO_QUERY
);
208 xWindow
->setVisible( bVisible
);
210 uno::Reference
< awt::XTopWindow
> xTopWindow( mxUpdDlg
, uno::UNO_QUERY
);
211 if ( xTopWindow
.is() )
213 xTopWindow
->toFront();
214 if ( !mbListenerAdded
)
216 xTopWindow
->addTopWindowListener( this );
217 mbListenerAdded
= true;
221 else if ( mxUpdDlg
.is() )
223 uno::Reference
< awt::XWindow
> xWindow( mxUpdDlg
, uno::UNO_QUERY
);
226 xWindow
->setVisible( bVisible
);
230 //--------------------------------------------------------------------
231 void UpdateHandler::setProgress( sal_Int32 nPercent
)
233 if ( nPercent
!= mnPercent
)
235 osl::MutexGuard
aGuard( maMutex
);
237 mnPercent
= nPercent
;
238 setControlProperty( CTRL_PROGRESS
, UNISTRING("ProgressValue"), uno::Any( nPercent
) );
239 setControlProperty( TEXT_PERCENT
, UNISTRING("Text"), uno::Any( substVariables(msPercent
) ) );
243 //--------------------------------------------------------------------
244 void UpdateHandler::setErrorMessage( const rtl::OUString
& rErrorMsg
)
246 setControlProperty( TEXT_DESCRIPTION
, UNISTRING("Text"), uno::Any( rErrorMsg
) );
249 //--------------------------------------------------------------------
250 void UpdateHandler::setDownloadFile( const rtl::OUString
& rFilePath
)
252 sal_Int32 nLast
= rFilePath
.lastIndexOf( '/' );
255 msDownloadFile
= rFilePath
.copy( nLast
+1 );
256 const rtl::OUString aDownloadURL
= rFilePath
.copy( 0, nLast
);
257 osl::FileBase::getSystemPathFromFileURL( aDownloadURL
, msDownloadPath
);
261 //--------------------------------------------------------------------
262 rtl::OUString
UpdateHandler::getBubbleText( UpdateState eState
)
264 osl::MutexGuard
aGuard( maMutex
);
267 sal_Int32 nIndex
= (sal_Int32
) eState
;
271 if ( ( UPDATESTATE_UPDATE_AVAIL
<= nIndex
) && ( nIndex
< UPDATESTATES_COUNT
) )
272 sText
= substVariables( msBubbleTexts
[ nIndex
- UPDATESTATE_UPDATE_AVAIL
] );
277 //--------------------------------------------------------------------
278 rtl::OUString
UpdateHandler::getBubbleTitle( UpdateState eState
)
280 osl::MutexGuard
aGuard( maMutex
);
283 sal_Int32 nIndex
= (sal_Int32
) eState
;
287 if ( ( UPDATESTATE_UPDATE_AVAIL
<= nIndex
) && ( nIndex
< UPDATESTATES_COUNT
) )
288 sText
= substVariables( msBubbleTitles
[ nIndex
- UPDATESTATE_UPDATE_AVAIL
] );
293 //--------------------------------------------------------------------
294 rtl::OUString
UpdateHandler::getDefaultInstErrMsg()
296 osl::MutexGuard
aGuard( maMutex
);
300 return substVariables( msInstallError
);
304 //--------------------------------------------------------------------
305 void SAL_CALL
UpdateHandler::disposing( const lang::EventObject
& rEvt
)
306 throw( uno::RuntimeException
)
308 if ( rEvt
.Source
== mxUpdDlg
)
312 //--------------------------------------------------------------------
313 void SAL_CALL
UpdateHandler::actionPerformed( awt::ActionEvent
const & rEvent
)
314 throw( uno::RuntimeException
)
316 DialogControls eButton
= BUTTON_COUNT
;
317 for ( int i
= 0; i
< BUTTON_COUNT
; i
++ )
319 if ( rEvent
.ActionCommand
.equals( msButtonIDs
[i
] ) )
321 eButton
= (DialogControls
) i
;
326 if ( rEvent
.ActionCommand
.equals( COMMAND_CLOSE
) )
328 if ( ( mnLastCtrlState
& ( 1 << CLOSE_BUTTON
) ) == ( 1 << CLOSE_BUTTON
) )
329 eButton
= CLOSE_BUTTON
;
331 eButton
= CANCEL_BUTTON
;
339 if ( ( meCurState
== UPDATESTATE_DOWNLOADING
) ||
340 ( meCurState
== UPDATESTATE_DOWNLOAD_PAUSED
) ||
341 ( meCurState
== UPDATESTATE_ERROR_DOWNLOADING
) )
342 bCancel
= showWarning( msCancelMessage
);
346 mxActionListener
->cancel();
353 if ( meCurState
== UPDATESTATE_ERROR_CHECKING
)
354 mxActionListener
->closeAfterFailure();
356 case DOWNLOAD_BUTTON
:
357 mxActionListener
->download();
360 if ( showWarning( msInstallMessage
) )
361 mxActionListener
->install();
364 mxActionListener
->pause();
367 mxActionListener
->resume();
372 OSL_ENSURE( false, "UpdateHandler::actionPerformed: unknown command!" );
376 // XTopWindowListener
377 //--------------------------------------------------------------------
378 void SAL_CALL
UpdateHandler::windowOpened( const lang::EventObject
& )
379 throw( uno::RuntimeException
)
383 //--------------------------------------------------------------------
384 void SAL_CALL
UpdateHandler::windowClosing( const lang::EventObject
& e
)
385 throw( uno::RuntimeException
)
387 awt::ActionEvent aActionEvt
;
388 aActionEvt
.ActionCommand
= COMMAND_CLOSE
;
389 aActionEvt
.Source
= e
.Source
;
391 actionPerformed( aActionEvt
);
394 //--------------------------------------------------------------------
395 void SAL_CALL
UpdateHandler::windowClosed( const lang::EventObject
& )
396 throw( uno::RuntimeException
)
400 //--------------------------------------------------------------------
401 void SAL_CALL
UpdateHandler::windowMinimized( const lang::EventObject
& )
402 throw( uno::RuntimeException
)
407 //--------------------------------------------------------------------
408 void SAL_CALL
UpdateHandler::windowNormalized( const lang::EventObject
& )
409 throw( uno::RuntimeException
)
414 //--------------------------------------------------------------------
415 void SAL_CALL
UpdateHandler::windowActivated( const lang::EventObject
& )
416 throw( uno::RuntimeException
)
420 //--------------------------------------------------------------------
421 void SAL_CALL
UpdateHandler::windowDeactivated( const lang::EventObject
& )
422 throw( uno::RuntimeException
)
426 // XInteractionHandler
427 //------------------------------------------------------------------------------
428 void SAL_CALL
UpdateHandler::handle( uno::Reference
< task::XInteractionRequest
> const & rRequest
)
429 throw (uno::RuntimeException
)
431 if ( !mxInteractionHdl
.is() )
433 if( !mxContext
.is() )
434 throw uno::RuntimeException( UNISTRING( "UpdateHandler:: empty component context" ), *this );
436 uno::Reference
< lang::XMultiComponentFactory
> xServiceManager(mxContext
->getServiceManager());
438 if( !xServiceManager
.is() )
439 throw uno::RuntimeException( UNISTRING( "UpdateHandler: unable to obtain service manager from component context" ), *this );
441 mxInteractionHdl
= uno::Reference
<task::XInteractionHandler
> (
442 xServiceManager
->createInstanceWithContext(
443 UNISTRING( "com.sun.star.task.InteractionHandler" ),
445 uno::UNO_QUERY_THROW
);
446 if( !mxInteractionHdl
.is() )
447 throw uno::RuntimeException( UNISTRING( "UpdateHandler:: could not get default interaction handler" ), *this );
449 uno::Reference
< task::XInteractionRequestStringResolver
> xStrResolver
=
450 task::InteractionRequestStringResolver::create( mxContext
);
451 beans::Optional
< ::rtl::OUString
> aErrorText
= xStrResolver
->getStringFromInformationalRequest( rRequest
);
452 if ( aErrorText
.IsPresent
)
454 setControlProperty( TEXT_DESCRIPTION
, UNISTRING("Text"), uno::Any( aErrorText
.Value
) );
456 uno::Sequence
< uno::Reference
< task::XInteractionContinuation
> > xContinuations
= rRequest
->getContinuations();
457 if ( xContinuations
.getLength() == 1 )
459 if ( meCurState
== UPDATESTATE_CHECKING
)
460 setState( UPDATESTATE_ERROR_CHECKING
);
461 else if ( meCurState
== UPDATESTATE_DOWNLOADING
)
462 setState( UPDATESTATE_ERROR_DOWNLOADING
);
464 xContinuations
[0]->select();
467 mxInteractionHdl
->handle( rRequest
);
470 mxInteractionHdl
->handle( rRequest
);
473 //------------------------------------------------------------------------------
474 // XTerminateListener
475 //------------------------------------------------------------------------------
476 void SAL_CALL
UpdateHandler::queryTermination( const lang::EventObject
& )
477 throw ( frame::TerminationVetoException
, uno::RuntimeException
)
482 //------------------------------------------------------------------------------
483 void SAL_CALL
UpdateHandler::notifyTermination( const lang::EventObject
& )
484 throw ( uno::RuntimeException
)
486 osl::MutexGuard
aGuard( maMutex
);
490 uno::Reference
< awt::XTopWindow
> xTopWindow( mxUpdDlg
, uno::UNO_QUERY
);
491 if ( xTopWindow
.is() )
492 xTopWindow
->removeTopWindowListener( this );
494 uno::Reference
< lang::XComponent
> xComponent( mxUpdDlg
, uno::UNO_QUERY
);
495 if ( xComponent
.is() )
496 xComponent
->dispose();
502 //--------------------------------------------------------------------
503 //--------------------------------------------------------------------
504 //--------------------------------------------------------------------
505 void UpdateHandler::updateState( UpdateState eState
)
507 if ( meLastState
== eState
)
517 case UPDATESTATE_CHECKING
:
518 showControls( (1<<CANCEL_BUTTON
) + (1<<THROBBER_CTRL
) );
519 enableControls( 1<<CANCEL_BUTTON
);
520 setControlProperty( TEXT_STATUS
, UNISTRING("Text"), uno::Any( substVariables(msChecking
) ) );
521 setControlProperty( TEXT_DESCRIPTION
, UNISTRING("Text"), uno::Any( rtl::OUString() ) );
522 focusControl( CANCEL_BUTTON
);
524 case UPDATESTATE_ERROR_CHECKING
:
526 enableControls( 1 << CLOSE_BUTTON
);
527 setControlProperty( TEXT_STATUS
, UNISTRING("Text"), uno::Any( substVariables(msCheckingError
) ) );
528 focusControl( CLOSE_BUTTON
);
530 case UPDATESTATE_UPDATE_AVAIL
:
532 enableControls( ( 1 << CLOSE_BUTTON
) + ( 1 << DOWNLOAD_BUTTON
) );
533 setControlProperty( TEXT_STATUS
, UNISTRING("Text"), uno::Any( substVariables(msUpdFound
) ) );
535 sText
= substVariables(msDownloadWarning
);
536 if ( msDescriptionMsg
.getLength() )
537 sText
+= UNISTRING("\n\n") + msDescriptionMsg
;
538 setControlProperty( TEXT_DESCRIPTION
, UNISTRING("Text"), uno::Any( sText
) );
540 setDownloadBtnLabel( false );
541 focusControl( DOWNLOAD_BUTTON
);
543 case UPDATESTATE_UPDATE_NO_DOWNLOAD
:
545 enableControls( ( 1 << CLOSE_BUTTON
) + ( 1 << DOWNLOAD_BUTTON
) );
546 setControlProperty( TEXT_STATUS
, UNISTRING("Text"), uno::Any( substVariables(msUpdFound
) ) );
548 sText
= substVariables(msDownloadNotAvail
);
549 if ( msDescriptionMsg
.getLength() )
550 sText
+= UNISTRING("\n\n") + msDescriptionMsg
;
551 setControlProperty( TEXT_DESCRIPTION
, UNISTRING("Text"), uno::Any( sText
) );
553 setDownloadBtnLabel( true );
554 focusControl( DOWNLOAD_BUTTON
);
556 case UPDATESTATE_NO_UPDATE_AVAIL
:
557 case UPDATESTATE_EXT_UPD_AVAIL
: // will only be set, when there are no office updates avail
559 enableControls( 1 << CLOSE_BUTTON
);
560 setControlProperty( TEXT_STATUS
, UNISTRING("Text"), uno::Any( substVariables(msNoUpdFound
) ) );
561 setControlProperty( TEXT_DESCRIPTION
, UNISTRING("Text"), uno::Any( rtl::OUString() ) );
562 focusControl( CLOSE_BUTTON
);
564 case UPDATESTATE_DOWNLOADING
:
565 showControls( (1<<PROGRESS_CTRL
) + (1<<CANCEL_BUTTON
) + (1<<PAUSE_BUTTON
) + (1<<RESUME_BUTTON
) );
566 enableControls( (1<<CLOSE_BUTTON
) + (1<<CANCEL_BUTTON
) + (1<<PAUSE_BUTTON
) );
567 setControlProperty( TEXT_STATUS
, UNISTRING("Text"), uno::Any( substVariables(msDownloading
) ) );
568 setControlProperty( TEXT_PERCENT
, UNISTRING("Text"), uno::Any( substVariables(msPercent
) ) );
569 setControlProperty( TEXT_DESCRIPTION
, UNISTRING("Text"), uno::Any( substVariables(msDownloadWarning
) ) );
570 setControlProperty( CTRL_PROGRESS
, UNISTRING("ProgressValue"), uno::Any( mnPercent
) );
571 focusControl( CLOSE_BUTTON
);
573 case UPDATESTATE_DOWNLOAD_PAUSED
:
574 showControls( (1<<PROGRESS_CTRL
) + (1<<CANCEL_BUTTON
) + (1<<PAUSE_BUTTON
) + (1<<RESUME_BUTTON
) );
575 enableControls( (1<<CLOSE_BUTTON
) + (1<<CANCEL_BUTTON
) + (1<<RESUME_BUTTON
) );
576 setControlProperty( TEXT_STATUS
, UNISTRING("Text"), uno::Any( substVariables(msDownloadPause
) ) );
577 setControlProperty( TEXT_PERCENT
, UNISTRING("Text"), uno::Any( substVariables(msPercent
) ) );
578 setControlProperty( TEXT_DESCRIPTION
, UNISTRING("Text"), uno::Any( substVariables(msDownloadWarning
) ) );
579 setControlProperty( CTRL_PROGRESS
, UNISTRING("ProgressValue"), uno::Any( mnPercent
) );
580 focusControl( CLOSE_BUTTON
);
582 case UPDATESTATE_ERROR_DOWNLOADING
:
583 showControls( (1<<PROGRESS_CTRL
) + (1<<CANCEL_BUTTON
) + (1<<PAUSE_BUTTON
) + (1<<RESUME_BUTTON
) );
584 enableControls( (1<<CLOSE_BUTTON
) + (1<<CANCEL_BUTTON
) );
585 setControlProperty( TEXT_STATUS
, UNISTRING("Text"), uno::Any( substVariables(msDownloadError
) ) );
586 focusControl( CLOSE_BUTTON
);
588 case UPDATESTATE_DOWNLOAD_AVAIL
:
590 enableControls( (1<<CLOSE_BUTTON
) + (1<<INSTALL_BUTTON
) );
591 setControlProperty( TEXT_STATUS
, UNISTRING("Text"), uno::Any( substVariables(msReady2Install
) ) );
592 setControlProperty( TEXT_DESCRIPTION
, UNISTRING("Text"), uno::Any( substVariables(msDownloadDescr
) ) );
593 focusControl( INSTALL_BUTTON
);
595 case UPDATESTATE_AUTO_START
:
596 case UPDATESTATES_COUNT
:
597 //do nothing, only count!
601 meLastState
= eState
;
604 //--------------------------------------------------------------------
605 void UpdateHandler::searchAndReplaceAll( rtl::OUString
&rText
,
606 const rtl::OUString
&rWhat
,
607 const rtl::OUString
&rWith
) const
609 sal_Int32 nIndex
= rText
.indexOf( rWhat
);
611 while ( nIndex
!= -1 )
613 rText
= rText
.replaceAt( nIndex
, rWhat
.getLength(), rWith
);
614 nIndex
= rText
.indexOf( rWhat
, nIndex
);
618 //--------------------------------------------------------------------
619 rtl::OUString
UpdateHandler::loadString( const uno::Reference
< resource::XResourceBundle
> xBundle
,
620 sal_Int32 nResourceId
) const
622 rtl::OUString sString
;
623 rtl::OUString sKey
= UNISTRING( "string:" ) + rtl::OUString::valueOf( nResourceId
);
627 OSL_VERIFY( xBundle
->getByName( sKey
) >>= sString
);
629 catch( const uno::Exception
& )
631 OSL_ENSURE( false, "UpdateHandler::loadString: caught an exception!" );
632 sString
= UNISTRING("Missing ") + sKey
;
638 rtl::OUString
UpdateHandler::substVariables( const rtl::OUString
&rSource
) const
640 rtl::OUString
sString( rSource
);
642 searchAndReplaceAll( sString
, UNISTRING( "%NEXTVERSION" ), msNextVersion
);
643 searchAndReplaceAll( sString
, UNISTRING( "%DOWNLOAD_PATH" ), msDownloadPath
);
644 searchAndReplaceAll( sString
, UNISTRING( "%FILE_NAME" ), msDownloadFile
);
645 searchAndReplaceAll( sString
, UNISTRING( "%PERCENT" ), rtl::OUString::valueOf( mnPercent
) );
650 //--------------------------------------------------------------------
651 void UpdateHandler::loadStrings()
653 if ( mbStringsLoaded
)
656 mbStringsLoaded
= true;
658 uno::Reference
< resource::XResourceBundleLoader
> xLoader
;
661 uno::Any
aValue( mxContext
->getValueByName(
662 UNISTRING( "/singletons/com.sun.star.resource.OfficeResourceLoader" ) ) );
663 OSL_VERIFY( aValue
>>= xLoader
);
665 catch( const uno::Exception
& )
667 OSL_ENSURE( false, "UpdateHandler::loadStrings: could not create the resource loader!" );
670 if ( !xLoader
.is() ) return;
672 uno::Reference
< resource::XResourceBundle
> xBundle
;
676 xBundle
= xLoader
->loadBundle_Default( UNISTRING( "upd" ) );
678 catch( const resource::MissingResourceException
& )
680 OSL_ENSURE( false, "UpdateHandler::loadStrings: missing the resource bundle!" );
683 if ( !xBundle
.is() ) return;
685 msChecking
= loadString( xBundle
, RID_UPDATE_STR_CHECKING
);
686 msCheckingError
= loadString( xBundle
, RID_UPDATE_STR_CHECKING_ERR
);
687 msNoUpdFound
= loadString( xBundle
, RID_UPDATE_STR_NO_UPD_FOUND
);
689 msUpdFound
= loadString( xBundle
, RID_UPDATE_STR_UPD_FOUND
);
690 setFullVersion( msUpdFound
);
692 msDlgTitle
= loadString( xBundle
, RID_UPDATE_STR_DLG_TITLE
);
693 msDownloadPause
= loadString( xBundle
, RID_UPDATE_STR_DOWNLOAD_PAUSE
);
694 msDownloadError
= loadString( xBundle
, RID_UPDATE_STR_DOWNLOAD_ERR
);
695 msDownloadWarning
= loadString( xBundle
, RID_UPDATE_STR_DOWNLOAD_WARN
);
696 msDownloadDescr
= loadString( xBundle
, RID_UPDATE_STR_DOWNLOAD_DESCR
);
697 msDownloadNotAvail
= loadString( xBundle
, RID_UPDATE_STR_DOWNLOAD_UNAVAIL
);
698 msDownloading
= loadString( xBundle
, RID_UPDATE_STR_DOWNLOADING
);
699 msReady2Install
= loadString( xBundle
, RID_UPDATE_STR_READY_INSTALL
);
700 msCancelTitle
= loadString( xBundle
, RID_UPDATE_STR_CANCEL_TITLE
);
701 msCancelMessage
= loadString( xBundle
, RID_UPDATE_STR_CANCEL_DOWNLOAD
);
702 msInstallMessage
= loadString( xBundle
, RID_UPDATE_STR_BEGIN_INSTALL
);
703 msInstallNow
= loadString( xBundle
, RID_UPDATE_STR_INSTALL_NOW
);
704 msInstallLater
= loadString( xBundle
, RID_UPDATE_STR_INSTALL_LATER
);
705 msInstallError
= loadString( xBundle
, RID_UPDATE_STR_INSTALL_ERROR
);
706 msOverwriteWarning
= loadString( xBundle
, RID_UPDATE_STR_OVERWRITE_WARNING
);
707 msPercent
= loadString( xBundle
, RID_UPDATE_STR_PERCENT
);
709 msStatusFL
= loadString( xBundle
, RID_UPDATE_FT_STATUS
);
710 msDescription
= loadString( xBundle
, RID_UPDATE_FT_DESCRIPTION
);
712 msClose
= loadString( xBundle
, RID_UPDATE_BTN_CLOSE
);
713 msDownload
= loadString( xBundle
, RID_UPDATE_BTN_DOWNLOAD
);
714 msInstall
= loadString( xBundle
, RID_UPDATE_BTN_INSTALL
);
715 msPauseBtn
= loadString( xBundle
, RID_UPDATE_BTN_PAUSE
);
716 msResumeBtn
= loadString( xBundle
, RID_UPDATE_BTN_RESUME
);
717 msCancelBtn
= loadString( xBundle
, RID_UPDATE_BTN_CANCEL
);
719 // all update states before UPDATESTATE_UPDATE_AVAIL don't have a bubble
720 // so we can ignore them
721 for ( int i
=0; i
< (int)(UPDATESTATES_COUNT
- UPDATESTATE_UPDATE_AVAIL
); i
++ )
723 msBubbleTexts
[ i
] = loadString( xBundle
, RID_UPDATE_BUBBLE_TEXT_START
+ i
);
724 msBubbleTitles
[ i
] = loadString( xBundle
, RID_UPDATE_BUBBLE_T_TEXT_START
+ i
);
727 for ( int i
=0; i
< BUTTON_COUNT
; i
++ )
729 msButtonIDs
[ i
] = UNISTRING("BUTTON_") + rtl::OUString::valueOf( (sal_Int32
) i
);
734 //--------------------------------------------------------------------
735 void UpdateHandler::startThrobber( bool bStart
)
737 uno::Reference
< awt::XControlContainer
> xContainer( mxUpdDlg
, uno::UNO_QUERY
);
738 uno::Reference
< awt::XThrobber
> xThrobber( xContainer
->getControl( CTRL_THROBBER
), uno::UNO_QUERY
);
740 if ( xThrobber
.is() )
748 uno::Reference
< awt::XWindow
> xWindow( xContainer
->getControl( CTRL_THROBBER
), uno::UNO_QUERY
);
750 xWindow
->setVisible( bStart
);
753 //--------------------------------------------------------------------
754 void UpdateHandler::setControlProperty( const rtl::OUString
&rCtrlName
,
755 const rtl::OUString
&rPropName
,
756 const uno::Any
&rPropValue
)
758 if ( !mxUpdDlg
.is() ) return;
760 uno::Reference
< awt::XControlContainer
> xContainer( mxUpdDlg
, uno::UNO_QUERY
);
761 uno::Reference
< awt::XControl
> xControl( xContainer
->getControl( rCtrlName
), uno::UNO_QUERY_THROW
);
762 uno::Reference
< awt::XControlModel
> xControlModel( xControl
->getModel(), uno::UNO_QUERY_THROW
);
763 uno::Reference
< beans::XPropertySet
> xPropSet( xControlModel
, uno::UNO_QUERY_THROW
);
766 xPropSet
->setPropertyValue( rPropName
, rPropValue
);
768 catch( const beans::UnknownPropertyException
& )
770 OSL_ENSURE( false, "UpdateHandler::setControlProperty: caught an exception!" );
774 //--------------------------------------------------------------------
775 void UpdateHandler::showControl( const rtl::OUString
&rCtrlName
, bool bShow
)
777 uno::Reference
< awt::XControlContainer
> xContainer( mxUpdDlg
, uno::UNO_QUERY
);
779 if ( !xContainer
.is() )
781 OSL_ENSURE( false, "UpdateHandler::showControl: could not get control container!" );
785 uno::Reference
< awt::XWindow
> xWindow( xContainer
->getControl( rCtrlName
), uno::UNO_QUERY
);
787 xWindow
->setVisible( bShow
);
790 //--------------------------------------------------------------------
791 void UpdateHandler::focusControl( DialogControls eID
)
793 uno::Reference
< awt::XControlContainer
> xContainer( mxUpdDlg
, uno::UNO_QUERY
);
795 if ( !xContainer
.is() )
797 OSL_ENSURE( false, "UpdateHandler::focusControl: could not get control container!" );
801 OSL_ENSURE( (eID
< BUTTON_COUNT
), "UpdateHandler::focusControl: id to big!" );
803 uno::Reference
< awt::XWindow
> xWindow( xContainer
->getControl( msButtonIDs
[(short)eID
] ), uno::UNO_QUERY
);
808 //--------------------------------------------------------------------
809 void UpdateHandler::insertControlModel( uno::Reference
< awt::XControlModel
> & rxDialogModel
,
810 rtl::OUString
const & rServiceName
,
811 rtl::OUString
const & rControlName
,
812 awt::Rectangle
const & rPosSize
,
813 uno::Sequence
< beans::NamedValue
> const & rProps
)
815 uno::Reference
< lang::XMultiServiceFactory
> xFactory (rxDialogModel
, uno::UNO_QUERY_THROW
);
816 uno::Reference
< awt::XControlModel
> xModel (xFactory
->createInstance (rServiceName
), uno::UNO_QUERY_THROW
);
817 uno::Reference
< beans::XPropertySet
> xPropSet (xModel
, uno::UNO_QUERY_THROW
);
819 for (sal_Int32 i
= 0, n
= rProps
.getLength(); i
< n
; i
++)
821 xPropSet
->setPropertyValue (rProps
[i
].Name
, rProps
[i
].Value
);
824 // @see awt/UnoControlDialogElement.idl
825 xPropSet
->setPropertyValue( UNISTRING("Name"), uno::Any (rControlName
) );
826 xPropSet
->setPropertyValue( UNISTRING("PositionX"), uno::Any (rPosSize
.X
) );
827 xPropSet
->setPropertyValue( UNISTRING("PositionY"), uno::Any (rPosSize
.Y
) );
828 xPropSet
->setPropertyValue( UNISTRING("Height"), uno::Any (rPosSize
.Height
) );
829 xPropSet
->setPropertyValue( UNISTRING("Width"), uno::Any (rPosSize
.Width
) );
831 // insert by Name into DialogModel container
832 uno::Reference
< container::XNameContainer
> xContainer (rxDialogModel
, uno::UNO_QUERY_THROW
);
833 xContainer
->insertByName( rControlName
, uno::Any (uno::Reference
< uno::XInterface
>(xModel
, uno::UNO_QUERY
)));
836 //--------------------------------------------------------------------
837 void UpdateHandler::setFullVersion( rtl::OUString
& rString
)
839 if( !mxContext
.is() )
840 throw uno::RuntimeException( UNISTRING( "getProductName: empty component context" ), *this );
842 uno::Reference
< lang::XMultiComponentFactory
> xServiceManager( mxContext
->getServiceManager() );
844 if( !xServiceManager
.is() )
845 throw uno::RuntimeException( UNISTRING( "getProductName: unable to obtain service manager from component context" ), *this );
847 uno::Reference
< lang::XMultiServiceFactory
> xConfigurationProvider(
848 xServiceManager
->createInstanceWithContext( UNISTRING( "com.sun.star.configuration.ConfigurationProvider" ), mxContext
),
849 uno::UNO_QUERY_THROW
);
851 beans::PropertyValue aProperty
;
852 aProperty
.Name
= UNISTRING( "nodepath" );
853 aProperty
.Value
= uno::makeAny( UNISTRING("org.openoffice.Setup/Product") );
855 uno::Sequence
< uno::Any
> aArgumentList( 1 );
856 aArgumentList
[0] = uno::makeAny( aProperty
);
858 uno::Reference
< uno::XInterface
> xConfigAccess
;
859 xConfigAccess
= xConfigurationProvider
->createInstanceWithArguments( UNISTRING("com.sun.star.configuration.ConfigurationAccess"),
862 uno::Reference
< container::XNameAccess
> xNameAccess( xConfigAccess
, uno::UNO_QUERY_THROW
);
864 rtl::OUString aProductVersion
;
865 rtl::OUString aProductFullVersion
;
867 xNameAccess
->getByName(UNISTRING("ooSetupVersion")) >>= aProductVersion
;
868 aProductFullVersion
= aProductVersion
;
870 sal_Int32 nVerIndex
= rString
.indexOf( aProductVersion
);
871 if ( nVerIndex
!= -1 )
873 rtl::OUString aPackageVersion
= UNISTRING( "${$OOO_BASE_DIR/program/" SAL_CONFIGFILE("version") ":OOOPackageVersion}" );
874 rtl::Bootstrap::expandMacros( aPackageVersion
);
876 if ( aPackageVersion
.getLength() )
878 sal_Int32 nTokIndex
= 0;
879 rtl::OUString aVersionMinor
= aPackageVersion
.getToken( 1, '.', nTokIndex
);
880 rtl::OUString aVersionMicro
;
883 aVersionMicro
= aPackageVersion
.getToken( 0, '.', nTokIndex
);
885 if ( aVersionMinor
.getLength() == 0 )
886 aVersionMinor
= UNISTRING( "0" );
887 if ( aVersionMicro
.getLength() == 0 )
888 aVersionMicro
= UNISTRING( "0" );
890 sal_Int32 nIndex
= aProductFullVersion
.indexOf( '.' );
893 aProductFullVersion
+= UNISTRING( "." );
894 aProductFullVersion
+= aVersionMinor
;
898 nIndex
= aProductFullVersion
.indexOf( '.', nIndex
+1 );
902 aProductFullVersion
+= UNISTRING( "." );
903 aProductFullVersion
+= aVersionMicro
;
907 aProductFullVersion
= aProductFullVersion
.replaceAt( nIndex
+1, aProductFullVersion
.getLength()-nIndex
-1, aVersionMicro
);
910 rString
= rString
.replaceAt( nVerIndex
, aProductVersion
.getLength(), aProductFullVersion
);
914 //--------------------------------------------------------------------
915 bool UpdateHandler::showWarning( const rtl::OUString
&rWarningText
) const
919 uno::Reference
< awt::XControl
> xControl( mxUpdDlg
, uno::UNO_QUERY
);
920 if ( !xControl
.is() ) return bRet
;
922 uno::Reference
< awt::XWindowPeer
> xPeer
= xControl
->getPeer();
923 if ( !xPeer
.is() ) return bRet
;
925 uno::Reference
< awt::XToolkit
> xToolkit
= xPeer
->getToolkit();
926 if ( !xToolkit
.is() ) return bRet
;
928 awt::WindowDescriptor aDescriptor
;
930 sal_Int32 nWindowAttributes
= awt::WindowAttribute::BORDER
| awt::WindowAttribute::MOVEABLE
| awt::WindowAttribute::CLOSEABLE
;
931 nWindowAttributes
|= awt::VclWindowPeerAttribute::YES_NO
;
932 nWindowAttributes
|= awt::VclWindowPeerAttribute::DEF_NO
;
934 aDescriptor
.Type
= awt::WindowClass_MODALTOP
;
935 aDescriptor
.WindowServiceName
= UNISTRING( "warningbox" );
936 aDescriptor
.ParentIndex
= -1;
937 aDescriptor
.Parent
= xPeer
;
938 aDescriptor
.Bounds
= awt::Rectangle( 10, 10, 250, 150 );
939 aDescriptor
.WindowAttributes
= nWindowAttributes
;
941 uno::Reference
< awt::XMessageBox
> xMsgBox( xToolkit
->createWindow( aDescriptor
), uno::UNO_QUERY
);
945 // xMsgBox->setCaptionText( msCancelTitle );
946 xMsgBox
->setMessageText( rWarningText
);
947 nRet
= xMsgBox
->execute();
948 if ( nRet
== 2 ) // RET_YES == 2
952 uno::Reference
< lang::XComponent
> xComponent( xMsgBox
, uno::UNO_QUERY
);
953 if ( xComponent
.is() )
954 xComponent
->dispose();
959 //--------------------------------------------------------------------
960 bool UpdateHandler::showOverwriteWarning() const
962 return showWarning( msOverwriteWarning
);
965 //--------------------------------------------------------------------
966 #define BUTTON_HEIGHT 14
967 #define BUTTON_WIDTH 50
968 #define BUTTON_X_OFFSET 7
969 #define BUTTON_Y_OFFSET 3
970 #define LABEL_HEIGHT 10
972 #define DIALOG_WIDTH 300
973 #define DIALOG_BORDER 5
974 #define INNER_BORDER 3
975 #define TEXT_OFFSET 1
976 #define BOX_HEIGHT1 ( LABEL_HEIGHT + 3*BUTTON_HEIGHT + 2*BUTTON_Y_OFFSET + 2*INNER_BORDER )
977 #define BOX_HEIGHT2 50
978 #define EDIT_WIDTH ( DIALOG_WIDTH - 2 * DIALOG_BORDER )
979 #define BOX1_BTN_X ( DIALOG_BORDER + EDIT_WIDTH - BUTTON_WIDTH - INNER_BORDER )
980 #define BOX1_BTN_Y ( DIALOG_BORDER + LABEL_HEIGHT + INNER_BORDER)
981 #define THROBBER_WIDTH 14
982 #define THROBBER_HEIGHT 14
983 #define THROBBER_X_POS ( DIALOG_BORDER + 8 )
984 #define THROBBER_Y_POS ( DIALOG_BORDER + 23 )
985 #define BUTTON_BAR_HEIGHT 24
986 #define LABEL_OFFSET ( LABEL_HEIGHT + 4 )
987 #define DIALOG_HEIGHT ( BOX_HEIGHT1 + BOX_HEIGHT2 + LABEL_OFFSET + BUTTON_BAR_HEIGHT + 3 * DIALOG_BORDER )
988 #define LABEL_Y_POS ( 2 * DIALOG_BORDER + BOX_HEIGHT1 )
989 #define EDIT2_Y_POS ( LABEL_Y_POS + LABEL_HEIGHT )
990 #define BUTTON_BAR_Y_POS ( EDIT2_Y_POS + DIALOG_BORDER + BOX_HEIGHT2 )
991 #define BUTTON_Y_POS ( BUTTON_BAR_Y_POS + 8 )
992 #define CLOSE_BTN_X ( DIALOG_WIDTH - DIALOG_BORDER - BUTTON_WIDTH )
993 #define INSTALL_BTN_X ( CLOSE_BTN_X - 2 * BUTTON_X_OFFSET - BUTTON_WIDTH )
994 #define DOWNLOAD_BTN_X ( INSTALL_BTN_X - BUTTON_X_OFFSET - BUTTON_WIDTH )
995 #define PROGRESS_WIDTH 80
996 #define PROGRESS_HEIGHT 10
997 #define PROGRESS_X_POS ( DIALOG_BORDER + 8 )
998 #define PROGRESS_Y_POS ( DIALOG_BORDER + 2*LABEL_OFFSET )
1000 //--------------------------------------------------------------------
1001 void UpdateHandler::showControls( short nControls
)
1003 // The buttons from CANCEL_BUTTON to RESUME_BUTTON will be shown or
1006 for ( int i
= 0; i
<= (int)RESUME_BUTTON
; i
++ )
1008 nShiftMe
= (short)(nControls
>> i
);
1009 showControl( msButtonIDs
[i
], (bool)(nShiftMe
& 0x01) );
1012 nShiftMe
= (short)(nControls
>> THROBBER_CTRL
);
1013 startThrobber( (bool)(nShiftMe
& 0x01) );
1015 nShiftMe
= (short)(nControls
>> PROGRESS_CTRL
);
1016 showControl( CTRL_PROGRESS
, (bool)(nShiftMe
& 0x01) );
1017 showControl( TEXT_PERCENT
, (bool)(nShiftMe
& 0x01) );
1019 // Status text needs to be smaller, when there are buttons at the right side of the dialog
1020 if ( ( nControls
& ( (1<<CANCEL_BUTTON
) + (1<<PAUSE_BUTTON
) + (1<<RESUME_BUTTON
) ) ) != 0 )
1021 setControlProperty( TEXT_STATUS
, UNISTRING("Width"), uno::Any( sal_Int32(EDIT_WIDTH
- BUTTON_WIDTH
- 2*INNER_BORDER
- TEXT_OFFSET
) ) );
1023 setControlProperty( TEXT_STATUS
, UNISTRING("Width"), uno::Any( sal_Int32(EDIT_WIDTH
- 2*TEXT_OFFSET
) ) );
1025 // Status text needs to be taller, when we show the progress bar
1026 if ( ( nControls
& ( 1<<PROGRESS_CTRL
) ) != 0 )
1027 setControlProperty( TEXT_STATUS
, UNISTRING("Height"), uno::Any( sal_Int32(LABEL_HEIGHT
) ) );
1029 setControlProperty( TEXT_STATUS
, UNISTRING("Height"), uno::Any( sal_Int32(BOX_HEIGHT1
- 4*TEXT_OFFSET
- LABEL_HEIGHT
) ) );
1032 //--------------------------------------------------------------------
1033 void UpdateHandler::createDialog()
1035 uno::Reference
< lang::XMultiComponentFactory
> xServiceManager( mxContext
->getServiceManager() );
1037 if( xServiceManager
.is() )
1039 uno::Reference
< frame::XDesktop
> xDesktop(
1040 xServiceManager
->createInstanceWithContext( UNISTRING( "com.sun.star.frame.Desktop"), mxContext
),
1042 if ( xDesktop
.is() )
1043 xDesktop
->addTerminateListener( this );
1048 uno::Reference
< lang::XMultiComponentFactory
> xFactory( mxContext
->getServiceManager(), uno::UNO_QUERY_THROW
);
1049 uno::Reference
< awt::XControlModel
> xControlModel( xFactory
->createInstanceWithContext(
1050 UNISTRING("com.sun.star.awt.UnoControlDialogModel"),
1051 mxContext
), uno::UNO_QUERY_THROW
);
1053 // @see awt/UnoControlDialogModel.idl
1054 uno::Reference
< beans::XPropertySet
> xPropSet( xControlModel
, uno::UNO_QUERY_THROW
);
1056 xPropSet
->setPropertyValue( UNISTRING("Title"), uno::Any( msDlgTitle
) );
1057 xPropSet
->setPropertyValue( UNISTRING("Closeable"), uno::Any( true ) );
1058 xPropSet
->setPropertyValue( UNISTRING("Enabled"), uno::Any( true ) );
1059 xPropSet
->setPropertyValue( UNISTRING("Moveable"), uno::Any( true ) );
1060 xPropSet
->setPropertyValue( UNISTRING("Sizeable"), uno::Any( true ) );
1061 xPropSet
->setPropertyValue( UNISTRING("DesktopAsParent"), uno::Any( true ) );
1062 xPropSet
->setPropertyValue( UNISTRING("PositionX"), uno::Any(sal_Int32( 100 )) );
1063 xPropSet
->setPropertyValue( UNISTRING("PositionY"), uno::Any(sal_Int32( 100 )) );
1064 xPropSet
->setPropertyValue( UNISTRING("Width"), uno::Any(sal_Int32( DIALOG_WIDTH
)) );
1065 xPropSet
->setPropertyValue( UNISTRING("Height"), uno::Any(sal_Int32( DIALOG_HEIGHT
)) );
1066 xPropSet
->setPropertyValue( UNISTRING("HelpURL"), uno::Any( UNISTRING( "HID:" ) + rtl::OUString::valueOf( (sal_Int32
) HID_CHECK_FOR_UPD_DLG
) ) );
1068 { // Label (fixed text) <status>
1069 uno::Sequence
< beans::NamedValue
> aProps(1);
1071 setProperty( aProps
, 0, UNISTRING("Label"), uno::Any( msStatusFL
) );
1073 insertControlModel( xControlModel
, FIXED_TEXT_MODEL
, UNISTRING( "fixedLineStatus" ),
1074 awt::Rectangle( DIALOG_BORDER
+1, DIALOG_BORDER
, EDIT_WIDTH
-2, LABEL_HEIGHT
),
1077 { // box around <status> text
1078 uno::Sequence
< beans::NamedValue
> aProps
;
1080 insertControlModel( xControlModel
, GROUP_BOX_MODEL
, UNISTRING( "StatusBox" ),
1081 awt::Rectangle( DIALOG_BORDER
, DIALOG_BORDER
+ LABEL_HEIGHT
, EDIT_WIDTH
, BOX_HEIGHT1
- LABEL_HEIGHT
),
1084 { // Text (multiline edit) <status>
1085 uno::Sequence
< beans::NamedValue
> aProps(7);
1087 setProperty( aProps
, 0, UNISTRING("Text"), uno::Any( substVariables(msChecking
) ) );
1088 setProperty( aProps
, 1, UNISTRING("Border"), uno::Any( sal_Int16( 0 ) ) );
1089 setProperty( aProps
, 2, UNISTRING("PaintTransparent"), uno::Any( true ) );
1090 setProperty( aProps
, 3, UNISTRING("MultiLine"), uno::Any( true ) );
1091 setProperty( aProps
, 4, UNISTRING("ReadOnly"), uno::Any( true ) );
1092 setProperty( aProps
, 5, UNISTRING("AutoVScroll"), uno::Any( true ) );
1093 setProperty( aProps
, 6, UNISTRING("HelpURL"), uno::Any( UNISTRING( "HID:" ) + rtl::OUString::valueOf( (sal_Int32
) HID_CHECK_FOR_UPD_STATUS
) ) );
1095 insertControlModel( xControlModel
, EDIT_FIELD_MODEL
, TEXT_STATUS
,
1096 awt::Rectangle( DIALOG_BORDER
+ TEXT_OFFSET
,
1097 DIALOG_BORDER
+ LABEL_HEIGHT
+ TEXT_OFFSET
,
1098 EDIT_WIDTH
- 2*TEXT_OFFSET
,
1099 BOX_HEIGHT1
- 4*TEXT_OFFSET
- LABEL_HEIGHT
),
1102 { // Text (edit) <percent>
1103 uno::Sequence
< beans::NamedValue
> aProps(4);
1105 setProperty( aProps
, 0, UNISTRING("Text"), uno::Any( msPercent
) );
1106 setProperty( aProps
, 1, UNISTRING("Border"), uno::Any( sal_Int16( 0 ) ) );
1107 setProperty( aProps
, 2, UNISTRING("PaintTransparent"), uno::Any( true ) );
1108 setProperty( aProps
, 3, UNISTRING("ReadOnly"), uno::Any( true ) );
1110 insertControlModel( xControlModel
, EDIT_FIELD_MODEL
, TEXT_PERCENT
,
1111 awt::Rectangle( PROGRESS_X_POS
+ PROGRESS_WIDTH
+ DIALOG_BORDER
,
1113 EDIT_WIDTH
- PROGRESS_WIDTH
- BUTTON_WIDTH
- 2*DIALOG_BORDER
,
1118 uno::Sequence
< beans::NamedValue
> aProps(5);
1120 setProperty( aProps
, 0, UNISTRING("DefaultButton"), uno::Any( false ) );
1121 setProperty( aProps
, 1, UNISTRING("Enabled"), uno::Any( true ) );
1122 setProperty( aProps
, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD
) ) );
1123 setProperty( aProps
, 3, UNISTRING("Label"), uno::Any( msPauseBtn
) );
1124 setProperty( aProps
, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( "HID:" ) + rtl::OUString::valueOf( (sal_Int32
) HID_CHECK_FOR_UPD_PAUSE
) ) );
1126 insertControlModel ( xControlModel
, BUTTON_MODEL
, msButtonIDs
[PAUSE_BUTTON
],
1127 awt::Rectangle( BOX1_BTN_X
, BOX1_BTN_Y
, BUTTON_WIDTH
, BUTTON_HEIGHT
),
1131 uno::Sequence
< beans::NamedValue
> aProps(5);
1133 setProperty( aProps
, 0, UNISTRING("DefaultButton"), uno::Any( false ) );
1134 setProperty( aProps
, 1, UNISTRING("Enabled"), uno::Any( true ) );
1135 setProperty( aProps
, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD
) ) );
1136 setProperty( aProps
, 3, UNISTRING("Label"), uno::Any( msResumeBtn
) );
1137 setProperty( aProps
, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( "HID:" ) + rtl::OUString::valueOf( (sal_Int32
) HID_CHECK_FOR_UPD_RESUME
) ) );
1139 insertControlModel ( xControlModel
, BUTTON_MODEL
, msButtonIDs
[RESUME_BUTTON
],
1140 awt::Rectangle( BOX1_BTN_X
,
1141 BOX1_BTN_Y
+ BUTTON_Y_OFFSET
+ BUTTON_HEIGHT
,
1147 uno::Sequence
< beans::NamedValue
> aProps(5);
1149 setProperty( aProps
, 0, UNISTRING("DefaultButton"), uno::Any( false ) );
1150 setProperty( aProps
, 1, UNISTRING("Enabled"), uno::Any( true ) );
1151 setProperty( aProps
, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD
) ) );
1152 setProperty( aProps
, 3, UNISTRING("Label"), uno::Any( msCancelBtn
) );
1153 setProperty( aProps
, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( "HID:" ) + rtl::OUString::valueOf( (sal_Int32
) HID_CHECK_FOR_UPD_CANCEL
) ) );
1155 insertControlModel ( xControlModel
, BUTTON_MODEL
, msButtonIDs
[CANCEL_BUTTON
],
1156 awt::Rectangle( BOX1_BTN_X
,
1157 BOX1_BTN_Y
+ (2*(BUTTON_HEIGHT
+BUTTON_Y_OFFSET
)),
1162 { // Label (FixedText) <description>
1163 uno::Sequence
< beans::NamedValue
> aProps(1);
1165 setProperty( aProps
, 0, UNISTRING("Label"), uno::Any( msDescription
) );
1167 insertControlModel( xControlModel
, FIXED_TEXT_MODEL
, UNISTRING( "fixedTextDescription" ),
1168 awt::Rectangle( DIALOG_BORDER
+1, LABEL_Y_POS
, EDIT_WIDTH
-2, LABEL_HEIGHT
),
1171 { // box around <description> text
1172 uno::Sequence
< beans::NamedValue
> aProps
;
1174 insertControlModel( xControlModel
, GROUP_BOX_MODEL
, UNISTRING( "DescriptionBox" ),
1175 awt::Rectangle( DIALOG_BORDER
, EDIT2_Y_POS
, EDIT_WIDTH
, BOX_HEIGHT2
),
1178 { // Text (MultiLineEdit) <description>
1179 uno::Sequence
< beans::NamedValue
> aProps(7);
1181 setProperty( aProps
, 0, UNISTRING("Text"), uno::Any( rtl::OUString() ) );
1182 setProperty( aProps
, 1, UNISTRING("Border"), uno::Any( sal_Int16( 0 ) ) );
1183 setProperty( aProps
, 2, UNISTRING("PaintTransparent"), uno::Any( true ) );
1184 setProperty( aProps
, 3, UNISTRING("MultiLine"), uno::Any( true ) );
1185 setProperty( aProps
, 4, UNISTRING("ReadOnly"), uno::Any( true ) );
1186 setProperty( aProps
, 5, UNISTRING("AutoVScroll"), uno::Any( true ) );
1187 setProperty( aProps
, 6, UNISTRING("HelpURL"), uno::Any( UNISTRING( "HID:" ) + rtl::OUString::valueOf( (sal_Int32
) HID_CHECK_FOR_UPD_DESCRIPTION
) ) );
1189 insertControlModel( xControlModel
, EDIT_FIELD_MODEL
, TEXT_DESCRIPTION
,
1190 awt::Rectangle( DIALOG_BORDER
+ TEXT_OFFSET
,
1191 EDIT2_Y_POS
+ 2*TEXT_OFFSET
,
1192 EDIT_WIDTH
- 3*TEXT_OFFSET
,
1193 BOX_HEIGHT2
- 3*TEXT_OFFSET
),
1196 { // @see awt/UnoControlFixedLineModel.idl
1197 uno::Sequence
< beans::NamedValue
> aProps(1);
1199 setProperty( aProps
, 0, UNISTRING("Orientation"), uno::Any( sal_Int32( 0 ) ) );
1201 insertControlModel( xControlModel
, FIXED_LINE_MODEL
, UNISTRING("fixedLine"),
1202 awt::Rectangle( 0, BUTTON_BAR_Y_POS
, DIALOG_WIDTH
, 5 ),
1205 { // close button // @see awt/UnoControlButtonModel.idl
1206 uno::Sequence
< beans::NamedValue
> aProps(5);
1208 setProperty( aProps
, 0, UNISTRING("DefaultButton"), uno::Any( false ) );
1209 setProperty( aProps
, 1, UNISTRING("Enabled"), uno::Any( true ) );
1210 // [property] short PushButtonType
1211 // with own "ButtonActionListener"
1212 setProperty( aProps
, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD
) ) );
1213 // with default ActionListener => endDialog().
1214 // setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_CANCEL) ) );
1215 // [property] string Label // only if PushButtonType_STANDARD
1216 setProperty( aProps
, 3, UNISTRING("Label"), uno::Any( msClose
) );
1217 setProperty( aProps
, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( "HID:" ) + rtl::OUString::valueOf( (sal_Int32
) HID_CHECK_FOR_UPD_CLOSE
) ) );
1219 insertControlModel ( xControlModel
, BUTTON_MODEL
, msButtonIDs
[ CLOSE_BUTTON
],
1220 awt::Rectangle( CLOSE_BTN_X
, BUTTON_Y_POS
, BUTTON_WIDTH
, BUTTON_HEIGHT
),
1224 uno::Sequence
< beans::NamedValue
> aProps(5);
1226 setProperty( aProps
, 0, UNISTRING("DefaultButton"), uno::Any( false ) );
1227 setProperty( aProps
, 1, UNISTRING("Enabled"), uno::Any( true ) );
1228 setProperty( aProps
, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD
) ) );
1229 setProperty( aProps
, 3, UNISTRING("Label"), uno::Any( msInstall
) );
1230 setProperty( aProps
, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( "HID:" ) + rtl::OUString::valueOf( (sal_Int32
) HID_CHECK_FOR_UPD_INSTALL
) ) );
1232 insertControlModel ( xControlModel
, BUTTON_MODEL
, msButtonIDs
[INSTALL_BUTTON
],
1233 awt::Rectangle( INSTALL_BTN_X
, BUTTON_Y_POS
, BUTTON_WIDTH
, BUTTON_HEIGHT
),
1236 { // download button
1237 uno::Sequence
< beans::NamedValue
> aProps(5);
1239 setProperty( aProps
, 0, UNISTRING("DefaultButton"), uno::Any( false ) );
1240 setProperty( aProps
, 1, UNISTRING("Enabled"), uno::Any( true ) );
1241 setProperty( aProps
, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD
) ) );
1242 setProperty( aProps
, 3, UNISTRING("Label"), uno::Any( msDownload
) );
1243 setProperty( aProps
, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( "HID:" ) + rtl::OUString::valueOf( (sal_Int32
) HID_CHECK_FOR_UPD_DOWNLOAD
) ) );
1245 insertControlModel ( xControlModel
, BUTTON_MODEL
, msButtonIDs
[DOWNLOAD_BUTTON
],
1246 awt::Rectangle( DOWNLOAD_BTN_X
, BUTTON_Y_POS
, BUTTON_WIDTH
, BUTTON_HEIGHT
),
1250 uno::Sequence
< beans::NamedValue
> aProps(3);
1252 setProperty( aProps
, 0, UNISTRING("DefaultButton"), uno::Any( false ) );
1253 setProperty( aProps
, 1, UNISTRING("Enabled"), uno::Any( true ) );
1254 setProperty( aProps
, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_HELP
) ) );
1256 insertControlModel( xControlModel
, BUTTON_MODEL
, msButtonIDs
[HELP_BUTTON
],
1257 awt::Rectangle( DIALOG_BORDER
, BUTTON_Y_POS
, BUTTON_WIDTH
, BUTTON_HEIGHT
),
1260 { // @see awt/UnoControlThrobberModel.idl
1261 uno::Sequence
< beans::NamedValue
> aProps
;
1263 insertControlModel( xControlModel
, UNISTRING("com.sun.star.awt.UnoThrobberControlModel"), CTRL_THROBBER
,
1264 awt::Rectangle( THROBBER_X_POS
, THROBBER_Y_POS
, THROBBER_WIDTH
, THROBBER_HEIGHT
),
1267 { // @see awt/UnoControlProgressBarModel.idl
1268 uno::Sequence
< beans::NamedValue
> aProps(4);
1269 setProperty( aProps
, 0, UNISTRING("Enabled"), uno::Any( true ) );
1270 setProperty( aProps
, 1, UNISTRING("ProgressValue"), uno::Any( sal_Int32( 0 ) ) );
1271 setProperty( aProps
, 2, UNISTRING("ProgressValueMax"), uno::Any( sal_Int32( 100 ) ) );
1272 setProperty( aProps
, 3, UNISTRING("ProgressValueMin"), uno::Any( sal_Int32( 0 ) ) );
1274 insertControlModel( xControlModel
, UNISTRING("com.sun.star.awt.UnoControlProgressBarModel"), CTRL_PROGRESS
,
1275 awt::Rectangle( PROGRESS_X_POS
, PROGRESS_Y_POS
, PROGRESS_WIDTH
, PROGRESS_HEIGHT
),
1279 uno::Reference
< awt::XControl
> xControl(
1280 xFactory
->createInstanceWithContext( UNISTRING("com.sun.star.awt.UnoControlDialog"), mxContext
),
1281 uno::UNO_QUERY_THROW
);
1282 xControl
->setModel( xControlModel
);
1284 if ( mbVisible
== false )
1286 uno::Reference
< awt::XWindow
> xWindow( xControl
, uno::UNO_QUERY
);
1289 xWindow
->setVisible( false );
1292 xControl
->createPeer( NULL
, NULL
);
1294 uno::Reference
< awt::XControlContainer
> xContainer (xControl
, uno::UNO_QUERY
);
1295 for ( int i
= 0; i
< HELP_BUTTON
; i
++ )
1297 uno::Reference
< awt::XButton
> xButton ( xContainer
->getControl( msButtonIDs
[i
] ), uno::UNO_QUERY
);
1300 xButton
->setActionCommand( msButtonIDs
[i
] );
1301 xButton
->addActionListener( this );
1306 mxUpdDlg
.set( xControl
, uno::UNO_QUERY_THROW
);
1307 mnLastCtrlState
= -1;