1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "updatehdl.hxx"
24 #include <osl/diagnose.h>
25 #include <osl/thread.hxx>
26 #include <osl/file.hxx>
27 #include <rtl/ustring.hxx>
28 #include <rtl/bootstrap.hxx>
30 #include <com/sun/star/uno/Sequence.h>
32 #include <com/sun/star/style/VerticalAlignment.hpp>
34 #include <com/sun/star/awt/ActionEvent.hpp>
35 #include <com/sun/star/awt/PushButtonType.hpp>
36 #include <com/sun/star/awt/UnoControlDialog.hpp>
37 #include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
38 #include <com/sun/star/awt/WindowAttribute.hpp>
39 #include <com/sun/star/awt/XButton.hpp>
40 #include <com/sun/star/awt/XControl.hpp>
41 #include <com/sun/star/awt/XControlContainer.hpp>
42 #include <com/sun/star/awt/XMessageBox.hpp>
43 #include <com/sun/star/awt/XAnimation.hpp>
44 #include <com/sun/star/awt/XTopWindow.hpp>
45 #include <com/sun/star/awt/XVclWindowPeer.hpp>
46 #include <com/sun/star/awt/XVclContainer.hpp>
47 #include <com/sun/star/awt/XWindow.hpp>
48 #include <com/sun/star/awt/XWindow2.hpp>
50 #include <com/sun/star/beans/PropertyValue.hpp>
51 #include <com/sun/star/beans/XPropertySet.hpp>
53 #include <com/sun/star/configuration/theDefaultProvider.hpp>
55 #include <com/sun/star/container/XNameContainer.hpp>
57 #include <com/sun/star/frame/Desktop.hpp>
58 #include <com/sun/star/frame/TerminationVetoException.hpp>
59 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
60 #include <com/sun/star/task/InteractionHandler.hpp>
61 #include <com/sun/star/task/InteractionRequestStringResolver.hpp>
63 #include <strings.hrc>
64 #include <unotools/resmgr.hxx>
65 #include <tools/urlobj.hxx>
66 #include <vcl/settings.hxx>
67 #include <vcl/svapp.hxx>
69 #define COMMAND_CLOSE "close"
71 #define CTRL_THROBBER "throbber"
72 #define CTRL_PROGRESS "progress"
74 #define TEXT_STATUS "text_status"
75 #define TEXT_PERCENT "text_percent"
76 #define TEXT_DESCRIPTION "text_description"
78 #define FIXED_LINE_MODEL "com.sun.star.awt.UnoControlFixedLineModel"
79 #define FIXED_TEXT_MODEL "com.sun.star.awt.UnoControlFixedTextModel"
80 #define EDIT_FIELD_MODEL "com.sun.star.awt.UnoControlEditModel"
81 #define BUTTON_MODEL "com.sun.star.awt.UnoControlButtonModel"
82 #define GROUP_BOX_MODEL "com.sun.star.awt.UnoControlGroupBoxModel"
84 using namespace com::sun::star
;
87 UpdateHandler::UpdateHandler( const uno::Reference
< uno::XComponentContext
> & rxContext
,
88 const rtl::Reference
< IActionListener
> & rxActionListener
) :
89 mxContext( rxContext
),
90 mxActionListener( rxActionListener
),
91 meCurState( UPDATESTATES_COUNT
),
92 meLastState( UPDATESTATES_COUNT
),
94 mnLastCtrlState( -1 ),
95 mbDownloadBtnHasDots( false ),
97 mbStringsLoaded( false ),
99 mbListenerAdded(false),
100 mbShowsMessageBox(false)
105 UpdateHandler::~UpdateHandler()
109 mxInteractionHdl
= nullptr;
110 mxActionListener
= nullptr;
114 void UpdateHandler::enableControls( short nCtrlState
)
116 osl::MutexGuard
aGuard( maMutex
);
118 if ( nCtrlState
== mnLastCtrlState
)
121 // the help button should always be the last button in the
122 // enum list and must never be disabled
123 for ( int i
=0; i
<HELP_BUTTON
; i
++ )
125 short nCurStateVal
= static_cast<short>(nCtrlState
>> i
);
126 short nOldStateVal
= static_cast<short>(mnLastCtrlState
>> i
);
127 if ( ( nCurStateVal
& 0x01 ) != ( nOldStateVal
& 0x01 ) )
129 bool bEnableControl
= ( ( nCurStateVal
& 0x01 ) == 0x01 );
130 setControlProperty( msButtonIDs
[i
], "Enabled", uno::Any( bEnableControl
) );
134 mnLastCtrlState
= nCtrlState
;
138 void UpdateHandler::setDownloadBtnLabel( bool bAppendDots
)
140 osl::MutexGuard
aGuard( maMutex
);
142 if ( mbDownloadBtnHasDots
!= bAppendDots
)
144 OUString
aLabel( msDownload
);
149 setControlProperty( msButtonIDs
[DOWNLOAD_BUTTON
], "Label", uno::Any( aLabel
) );
150 setControlProperty( msButtonIDs
[DOWNLOAD_BUTTON
], "HelpURL", uno::makeAny
<OUString
>( INET_HID_SCHEME HID_CHECK_FOR_UPD_DOWNLOAD2
) );
152 mbDownloadBtnHasDots
= bAppendDots
;
157 void UpdateHandler::setState( UpdateState eState
)
159 osl::MutexGuard
aGuard( maMutex
);
163 if ( mxUpdDlg
.is() && mbVisible
)
164 updateState( meCurState
);
168 bool UpdateHandler::isVisible() const
170 if ( !mxUpdDlg
.is() ) return false;
172 uno::Reference
< awt::XWindow2
> xWindow( mxUpdDlg
, uno::UNO_QUERY
);
175 return xWindow
->isVisible();
181 void UpdateHandler::setVisible( bool bVisible
)
183 osl::MutexGuard
aGuard( maMutex
);
185 mbVisible
= bVisible
;
189 if ( !mxUpdDlg
.is() )
192 // this should never happen, but if it happens we better return here
193 if ( !mxUpdDlg
.is() )
196 updateState( meCurState
);
198 uno::Reference
< awt::XWindow
> xWindow( mxUpdDlg
, uno::UNO_QUERY
);
201 xWindow
->setVisible( bVisible
);
203 uno::Reference
< awt::XTopWindow
> xTopWindow( mxUpdDlg
, uno::UNO_QUERY
);
204 if ( xTopWindow
.is() )
206 xTopWindow
->toFront();
207 if ( !mbListenerAdded
)
209 xTopWindow
->addTopWindowListener( this );
210 mbListenerAdded
= true;
214 else if ( mxUpdDlg
.is() )
216 uno::Reference
< awt::XWindow
> xWindow( mxUpdDlg
, uno::UNO_QUERY
);
219 xWindow
->setVisible( bVisible
);
224 void UpdateHandler::setProgress( sal_Int32 nPercent
)
226 if ( nPercent
> 100 )
228 else if ( nPercent
< 0 )
231 if ( nPercent
!= mnPercent
)
233 osl::MutexGuard
aGuard( maMutex
);
235 mnPercent
= nPercent
;
236 setControlProperty( CTRL_PROGRESS
, "ProgressValue", uno::Any( nPercent
) );
237 setControlProperty( TEXT_PERCENT
, "Text", uno::Any( substVariables(msPercent
) ) );
242 void UpdateHandler::setErrorMessage( const OUString
& rErrorMsg
)
244 setControlProperty( TEXT_DESCRIPTION
, "Text", uno::Any( rErrorMsg
) );
248 void UpdateHandler::setDownloadFile( const OUString
& rFilePath
)
250 sal_Int32 nLast
= rFilePath
.lastIndexOf( '/' );
253 msDownloadFile
= rFilePath
.copy( nLast
+1 );
254 const OUString aDownloadURL
= rFilePath
.copy( 0, nLast
);
255 osl::FileBase::getSystemPathFromFileURL( aDownloadURL
, msDownloadPath
);
260 OUString
UpdateHandler::getBubbleText( UpdateState eState
)
262 osl::MutexGuard
aGuard( maMutex
);
265 sal_Int32 nIndex
= static_cast<sal_Int32
>(eState
);
269 if ( ( UPDATESTATE_UPDATE_AVAIL
<= nIndex
) && ( nIndex
< UPDATESTATES_COUNT
) )
270 sText
= substVariables( msBubbleTexts
[ nIndex
- UPDATESTATE_UPDATE_AVAIL
] );
276 OUString
UpdateHandler::getBubbleTitle( UpdateState eState
)
278 osl::MutexGuard
aGuard( maMutex
);
281 sal_Int32 nIndex
= static_cast<sal_Int32
>(eState
);
285 if ( ( UPDATESTATE_UPDATE_AVAIL
<= nIndex
) && ( nIndex
< UPDATESTATES_COUNT
) )
286 sText
= substVariables( msBubbleTitles
[ nIndex
- UPDATESTATE_UPDATE_AVAIL
] );
292 OUString
UpdateHandler::getDefaultInstErrMsg()
294 osl::MutexGuard
aGuard( maMutex
);
298 return substVariables( msInstallError
);
303 void SAL_CALL
UpdateHandler::disposing( const lang::EventObject
& rEvt
)
305 if ( rEvt
.Source
== mxUpdDlg
)
310 void SAL_CALL
UpdateHandler::actionPerformed( awt::ActionEvent
const & rEvent
)
312 DialogControls eButton
= BUTTON_COUNT
;
313 for ( int i
= 0; i
< BUTTON_COUNT
; i
++ )
315 if ( rEvent
.ActionCommand
== msButtonIDs
[i
] )
317 eButton
= static_cast<DialogControls
>(i
);
322 if ( rEvent
.ActionCommand
== COMMAND_CLOSE
)
324 if ( ( mnLastCtrlState
& ( 1 << CLOSE_BUTTON
) ) == ( 1 << CLOSE_BUTTON
) )
325 eButton
= CLOSE_BUTTON
;
327 eButton
= CANCEL_BUTTON
;
335 if ( ( meCurState
== UPDATESTATE_DOWNLOADING
) ||
336 ( meCurState
== UPDATESTATE_DOWNLOAD_PAUSED
) ||
337 ( meCurState
== UPDATESTATE_ERROR_DOWNLOADING
) )
338 bCancel
= showWarning( msCancelMessage
);
342 mxActionListener
->cancel();
349 if ( meCurState
== UPDATESTATE_ERROR_CHECKING
)
350 mxActionListener
->closeAfterFailure();
352 case DOWNLOAD_BUTTON
:
353 mxActionListener
->download();
356 if ( showWarning( msInstallMessage
) )
357 mxActionListener
->install();
360 mxActionListener
->pause();
363 mxActionListener
->resume();
368 OSL_FAIL( "UpdateHandler::actionPerformed: unknown command!" );
372 // XTopWindowListener
374 void SAL_CALL
UpdateHandler::windowOpened( const lang::EventObject
& )
379 void SAL_CALL
UpdateHandler::windowClosing( const lang::EventObject
& e
)
381 awt::ActionEvent aActionEvt
;
382 aActionEvt
.ActionCommand
= COMMAND_CLOSE
;
383 aActionEvt
.Source
= e
.Source
;
385 actionPerformed( aActionEvt
);
389 void SAL_CALL
UpdateHandler::windowClosed( const lang::EventObject
& )
394 void SAL_CALL
UpdateHandler::windowMinimized( const lang::EventObject
& )
400 void SAL_CALL
UpdateHandler::windowNormalized( const lang::EventObject
& )
406 void SAL_CALL
UpdateHandler::windowActivated( const lang::EventObject
& )
411 void SAL_CALL
UpdateHandler::windowDeactivated( const lang::EventObject
& )
415 // XInteractionHandler
417 void SAL_CALL
UpdateHandler::handle( uno::Reference
< task::XInteractionRequest
> const & rRequest
)
419 if ( !mxInteractionHdl
.is() )
421 if( !mxContext
.is() )
422 throw uno::RuntimeException( "UpdateHandler:: empty component context", *this );
424 uno::Reference
< lang::XMultiComponentFactory
> xServiceManager(mxContext
->getServiceManager());
426 if( !xServiceManager
.is() )
427 throw uno::RuntimeException( "UpdateHandler: unable to obtain service manager from component context", *this );
429 mxInteractionHdl
.set(
430 task::InteractionHandler::createWithParent(mxContext
, nullptr),
431 uno::UNO_QUERY_THROW
);
433 uno::Reference
< task::XInteractionRequestStringResolver
> xStrResolver
=
434 task::InteractionRequestStringResolver::create( mxContext
);
435 beans::Optional
< OUString
> aErrorText
= xStrResolver
->getStringFromInformationalRequest( rRequest
);
436 if ( aErrorText
.IsPresent
)
438 setControlProperty( TEXT_DESCRIPTION
, "Text", uno::Any( aErrorText
.Value
) );
440 uno::Sequence
< uno::Reference
< task::XInteractionContinuation
> > xContinuations
= rRequest
->getContinuations();
441 if ( xContinuations
.getLength() == 1 )
443 if ( meCurState
== UPDATESTATE_CHECKING
)
444 setState( UPDATESTATE_ERROR_CHECKING
);
445 else if ( meCurState
== UPDATESTATE_DOWNLOADING
)
446 setState( UPDATESTATE_ERROR_DOWNLOADING
);
448 xContinuations
[0]->select();
451 mxInteractionHdl
->handle( rRequest
);
454 mxInteractionHdl
->handle( rRequest
);
458 // XTerminateListener
460 void SAL_CALL
UpdateHandler::queryTermination( const lang::EventObject
& )
462 if ( mbShowsMessageBox
)
464 uno::Reference
< awt::XTopWindow
> xTopWindow( mxUpdDlg
, uno::UNO_QUERY
);
465 if ( xTopWindow
.is() )
466 xTopWindow
->toFront();
468 throw frame::TerminationVetoException(
469 "The office cannot be closed while displaying a warning!",
470 static_cast<frame::XTerminateListener
*>(this));
477 void SAL_CALL
UpdateHandler::notifyTermination( const lang::EventObject
& )
479 osl::MutexGuard
aGuard( maMutex
);
483 uno::Reference
< awt::XTopWindow
> xTopWindow( mxUpdDlg
, uno::UNO_QUERY
);
484 if ( xTopWindow
.is() )
485 xTopWindow
->removeTopWindowListener( this );
487 uno::Reference
< lang::XComponent
> xComponent( mxUpdDlg
, uno::UNO_QUERY
);
488 if ( xComponent
.is() )
489 xComponent
->dispose();
496 void UpdateHandler::updateState( UpdateState eState
)
498 if ( meLastState
== eState
)
505 case UPDATESTATE_CHECKING
:
506 showControls( (1<<CANCEL_BUTTON
) + (1<<THROBBER_CTRL
) );
507 enableControls( 1<<CANCEL_BUTTON
);
508 setControlProperty( TEXT_STATUS
, "Text", uno::Any( substVariables(msChecking
) ) );
509 setControlProperty( TEXT_DESCRIPTION
, "Text", uno::Any( OUString() ) );
510 focusControl( CANCEL_BUTTON
);
512 case UPDATESTATE_ERROR_CHECKING
:
514 enableControls( 1 << CLOSE_BUTTON
);
515 setControlProperty( TEXT_STATUS
, "Text", uno::Any( substVariables(msCheckingError
) ) );
516 focusControl( CLOSE_BUTTON
);
518 case UPDATESTATE_UPDATE_AVAIL
:
520 enableControls( ( 1 << CLOSE_BUTTON
) + ( 1 << DOWNLOAD_BUTTON
) );
521 setControlProperty( TEXT_STATUS
, "Text", uno::Any( substVariables(msUpdFound
) ) );
523 sText
= substVariables(msDownloadWarning
);
524 if ( !msDescriptionMsg
.isEmpty() )
525 sText
+= "\n\n" + msDescriptionMsg
;
526 setControlProperty( TEXT_DESCRIPTION
, "Text", uno::Any( sText
) );
528 setDownloadBtnLabel( false );
529 focusControl( DOWNLOAD_BUTTON
);
531 case UPDATESTATE_UPDATE_NO_DOWNLOAD
:
533 enableControls( ( 1 << CLOSE_BUTTON
) + ( 1 << DOWNLOAD_BUTTON
) );
534 setControlProperty( TEXT_STATUS
, "Text", uno::Any( substVariables(msUpdFound
) ) );
536 sText
= substVariables(msDownloadNotAvail
);
537 if ( !msDescriptionMsg
.isEmpty() )
538 sText
+= "\n\n" + msDescriptionMsg
;
539 setControlProperty( TEXT_DESCRIPTION
, "Text", uno::Any( sText
) );
541 setDownloadBtnLabel( true );
542 focusControl( DOWNLOAD_BUTTON
);
544 case UPDATESTATE_NO_UPDATE_AVAIL
:
545 case UPDATESTATE_EXT_UPD_AVAIL
: // will only be set, when there are no office updates avail
547 enableControls( 1 << CLOSE_BUTTON
);
548 setControlProperty( TEXT_STATUS
, "Text", uno::Any( substVariables(msNoUpdFound
) ) );
549 setControlProperty( TEXT_DESCRIPTION
, "Text", uno::Any( OUString() ) );
550 focusControl( CLOSE_BUTTON
);
552 case UPDATESTATE_DOWNLOADING
:
553 showControls( (1<<PROGRESS_CTRL
) + (1<<CANCEL_BUTTON
) + (1<<PAUSE_BUTTON
) + (1<<RESUME_BUTTON
) );
554 enableControls( (1<<CLOSE_BUTTON
) + (1<<CANCEL_BUTTON
) + (1<<PAUSE_BUTTON
) );
555 setControlProperty( TEXT_STATUS
, "Text", uno::Any( substVariables(msDownloading
) ) );
556 setControlProperty( TEXT_PERCENT
, "Text", uno::Any( substVariables(msPercent
) ) );
557 setControlProperty( TEXT_DESCRIPTION
, "Text", uno::Any( substVariables(msDownloadWarning
) ) );
558 setControlProperty( CTRL_PROGRESS
, "ProgressValue", uno::Any( mnPercent
) );
559 focusControl( CLOSE_BUTTON
);
561 case UPDATESTATE_DOWNLOAD_PAUSED
:
562 showControls( (1<<PROGRESS_CTRL
) + (1<<CANCEL_BUTTON
) + (1<<PAUSE_BUTTON
) + (1<<RESUME_BUTTON
) );
563 enableControls( (1<<CLOSE_BUTTON
) + (1<<CANCEL_BUTTON
) + (1<<RESUME_BUTTON
) );
564 setControlProperty( TEXT_STATUS
, "Text", uno::Any( substVariables(msDownloadPause
) ) );
565 setControlProperty( TEXT_PERCENT
, "Text", uno::Any( substVariables(msPercent
) ) );
566 setControlProperty( TEXT_DESCRIPTION
, "Text", uno::Any( substVariables(msDownloadWarning
) ) );
567 setControlProperty( CTRL_PROGRESS
, "ProgressValue", uno::Any( mnPercent
) );
568 focusControl( CLOSE_BUTTON
);
570 case UPDATESTATE_ERROR_DOWNLOADING
:
571 showControls( (1<<PROGRESS_CTRL
) + (1<<CANCEL_BUTTON
) + (1<<PAUSE_BUTTON
) + (1<<RESUME_BUTTON
) );
572 enableControls( (1<<CLOSE_BUTTON
) + (1<<CANCEL_BUTTON
) );
573 setControlProperty( TEXT_STATUS
, "Text", uno::Any( substVariables(msDownloadError
) ) );
574 focusControl( CLOSE_BUTTON
);
576 case UPDATESTATE_DOWNLOAD_AVAIL
:
578 enableControls( (1<<CLOSE_BUTTON
) + (1<<INSTALL_BUTTON
) );
579 setControlProperty( TEXT_STATUS
, "Text", uno::Any( substVariables(msReady2Install
) ) );
580 setControlProperty( TEXT_DESCRIPTION
, "Text", uno::Any( substVariables(msDownloadDescr
) ) );
581 focusControl( INSTALL_BUTTON
);
583 case UPDATESTATE_AUTO_START
:
584 case UPDATESTATES_COUNT
:
585 //do nothing, only count!
589 meLastState
= eState
;
592 OUString
UpdateHandler::loadString(const std::locale
& rLocale
,
593 const char* pResourceId
)
595 return Translate::get(pResourceId
, rLocale
);
598 OUString
UpdateHandler::substVariables( const OUString
&rSource
) const
601 .replaceAll( "%NEXTVERSION", msNextVersion
)
602 .replaceAll( "%DOWNLOAD_PATH", msDownloadPath
)
603 .replaceAll( "%FILE_NAME", msDownloadFile
)
604 .replaceAll( "%PERCENT", OUString::number( mnPercent
) );
607 void UpdateHandler::loadStrings()
609 if ( mbStringsLoaded
)
612 mbStringsLoaded
= true;
614 std::locale loc
= Translate::Create("pcr");
616 msChecking
= loadString( loc
, RID_UPDATE_STR_CHECKING
);
617 msCheckingError
= loadString( loc
, RID_UPDATE_STR_CHECKING_ERR
);
618 msNoUpdFound
= loadString( loc
, RID_UPDATE_STR_NO_UPD_FOUND
);
620 msUpdFound
= loadString( loc
, RID_UPDATE_STR_UPD_FOUND
);
621 setFullVersion( msUpdFound
);
623 msDlgTitle
= loadString( loc
, RID_UPDATE_STR_DLG_TITLE
);
624 msDownloadPause
= loadString( loc
, RID_UPDATE_STR_DOWNLOAD_PAUSE
);
625 msDownloadError
= loadString( loc
, RID_UPDATE_STR_DOWNLOAD_ERR
);
626 msDownloadWarning
= loadString( loc
, RID_UPDATE_STR_DOWNLOAD_WARN
);
627 msDownloadDescr
= loadString( loc
, RID_UPDATE_STR_DOWNLOAD_DESCR
);
628 msDownloadNotAvail
= loadString( loc
, RID_UPDATE_STR_DOWNLOAD_UNAVAIL
);
629 msDownloading
= loadString( loc
, RID_UPDATE_STR_DOWNLOADING
);
630 msReady2Install
= loadString( loc
, RID_UPDATE_STR_READY_INSTALL
);
631 msCancelMessage
= loadString( loc
, RID_UPDATE_STR_CANCEL_DOWNLOAD
);
632 msInstallMessage
= loadString( loc
, RID_UPDATE_STR_BEGIN_INSTALL
);
633 msInstallError
= loadString( loc
, RID_UPDATE_STR_INSTALL_ERROR
);
634 msOverwriteWarning
= loadString( loc
, RID_UPDATE_STR_OVERWRITE_WARNING
);
635 msPercent
= loadString( loc
, RID_UPDATE_STR_PERCENT
);
636 msReloadWarning
= loadString( loc
, RID_UPDATE_STR_RELOAD_WARNING
);
637 msReloadReload
= loadString( loc
, RID_UPDATE_STR_RELOAD_RELOAD
);
638 msReloadContinue
= loadString( loc
, RID_UPDATE_STR_RELOAD_CONTINUE
);
640 msStatusFL
= loadString( loc
, RID_UPDATE_FT_STATUS
);
641 msDescription
= loadString( loc
, RID_UPDATE_FT_DESCRIPTION
);
643 msClose
= loadString( loc
, RID_UPDATE_BTN_CLOSE
);
644 msDownload
= loadString( loc
, RID_UPDATE_BTN_DOWNLOAD
);
645 msInstall
= loadString( loc
, RID_UPDATE_BTN_INSTALL
);
646 msPauseBtn
= loadString( loc
, RID_UPDATE_BTN_PAUSE
);
647 msResumeBtn
= loadString( loc
, RID_UPDATE_BTN_RESUME
);
648 msCancelBtn
= loadString( loc
, RID_UPDATE_BTN_CANCEL
);
650 std::pair
<const char*, const char*> RID_UPDATE_BUBBLE
[] =
652 { RID_UPDATE_BUBBLE_UPDATE_AVAIL
, RID_UPDATE_BUBBLE_T_UPDATE_AVAIL
},
653 { RID_UPDATE_BUBBLE_UPDATE_NO_DOWN
, RID_UPDATE_BUBBLE_T_UPDATE_NO_DOWN
},
654 { RID_UPDATE_BUBBLE_AUTO_START
, RID_UPDATE_BUBBLE_T_AUTO_START
},
655 { RID_UPDATE_BUBBLE_DOWNLOADING
, RID_UPDATE_BUBBLE_T_DOWNLOADING
},
656 { RID_UPDATE_BUBBLE_DOWNLOAD_PAUSED
, RID_UPDATE_BUBBLE_T_DOWNLOAD_PAUSED
},
657 { RID_UPDATE_BUBBLE_ERROR_DOWNLOADING
, RID_UPDATE_BUBBLE_T_ERROR_DOWNLOADING
},
658 { RID_UPDATE_BUBBLE_DOWNLOAD_AVAIL
, RID_UPDATE_BUBBLE_T_DOWNLOAD_AVAIL
},
659 { RID_UPDATE_BUBBLE_EXT_UPD_AVAIL
, RID_UPDATE_BUBBLE_T_EXT_UPD_AVAIL
}
662 static_assert(SAL_N_ELEMENTS(RID_UPDATE_BUBBLE
) == UPDATESTATES_COUNT
- UPDATESTATE_UPDATE_AVAIL
, "mismatch");
664 // all update states before UPDATESTATE_UPDATE_AVAIL don't have a bubble
665 // so we can ignore them
666 for (size_t i
= 0; i
< SAL_N_ELEMENTS(RID_UPDATE_BUBBLE
); ++i
)
668 msBubbleTexts
[i
] = loadString(loc
, RID_UPDATE_BUBBLE
[i
].first
);
669 msBubbleTitles
[i
] = loadString(loc
, RID_UPDATE_BUBBLE
[i
].second
);
672 for ( int i
=0; i
< BUTTON_COUNT
; i
++ )
674 msButtonIDs
[ i
] = "BUTTON_" + OUString::number( i
);
679 void UpdateHandler::startThrobber( bool bStart
)
681 uno::Reference
< awt::XControlContainer
> xContainer( mxUpdDlg
, uno::UNO_QUERY
);
682 uno::Reference
< awt::XAnimation
> xThrobber( xContainer
->getControl( CTRL_THROBBER
), uno::UNO_QUERY
);
684 if ( xThrobber
.is() )
687 xThrobber
->startAnimation();
689 xThrobber
->stopAnimation();
692 uno::Reference
< awt::XWindow
> xWindow( xContainer
->getControl( CTRL_THROBBER
), uno::UNO_QUERY
);
694 xWindow
->setVisible( bStart
);
698 void UpdateHandler::setControlProperty( const OUString
&rCtrlName
,
699 const OUString
&rPropName
,
700 const uno::Any
&rPropValue
)
702 if ( !mxUpdDlg
.is() ) return;
704 uno::Reference
< awt::XControlContainer
> xContainer( mxUpdDlg
, uno::UNO_QUERY
);
705 uno::Reference
< awt::XControl
> xControl( xContainer
->getControl( rCtrlName
), uno::UNO_SET_THROW
);
706 uno::Reference
< awt::XControlModel
> xControlModel( xControl
->getModel(), uno::UNO_SET_THROW
);
707 uno::Reference
< beans::XPropertySet
> xPropSet( xControlModel
, uno::UNO_QUERY_THROW
);
710 xPropSet
->setPropertyValue( rPropName
, rPropValue
);
712 catch( const beans::UnknownPropertyException
& )
714 OSL_FAIL( "UpdateHandler::setControlProperty: caught an exception!" );
719 void UpdateHandler::showControl( const OUString
&rCtrlName
, bool bShow
)
721 uno::Reference
< awt::XControlContainer
> xContainer( mxUpdDlg
, uno::UNO_QUERY
);
723 if ( !xContainer
.is() )
725 OSL_FAIL( "UpdateHandler::showControl: could not get control container!" );
729 uno::Reference
< awt::XWindow
> xWindow( xContainer
->getControl( rCtrlName
), uno::UNO_QUERY
);
731 xWindow
->setVisible( bShow
);
735 void UpdateHandler::focusControl( DialogControls eID
)
737 uno::Reference
< awt::XControlContainer
> xContainer( mxUpdDlg
, uno::UNO_QUERY
);
739 if ( !xContainer
.is() )
741 OSL_FAIL( "UpdateHandler::focusControl: could not get control container!" );
745 OSL_ENSURE( (eID
< BUTTON_COUNT
), "UpdateHandler::focusControl: id too big!" );
747 uno::Reference
< awt::XWindow
> xWindow( xContainer
->getControl( msButtonIDs
[static_cast<short>(eID
)] ), uno::UNO_QUERY
);
753 void UpdateHandler::insertControlModel( uno::Reference
< awt::XControlModel
> const & rxDialogModel
,
754 OUString
const & rServiceName
,
755 OUString
const & rControlName
,
756 awt::Rectangle
const & rPosSize
,
757 uno::Sequence
< beans::NamedValue
> const & rProps
)
759 uno::Reference
< lang::XMultiServiceFactory
> xFactory (rxDialogModel
, uno::UNO_QUERY_THROW
);
760 uno::Reference
< awt::XControlModel
> xModel (xFactory
->createInstance (rServiceName
), uno::UNO_QUERY_THROW
);
761 uno::Reference
< beans::XPropertySet
> xPropSet (xModel
, uno::UNO_QUERY_THROW
);
763 for (sal_Int32 i
= 0, n
= rProps
.getLength(); i
< n
; i
++)
765 xPropSet
->setPropertyValue (rProps
[i
].Name
, rProps
[i
].Value
);
768 // @see awt/UnoControlDialogElement.idl
769 xPropSet
->setPropertyValue( "Name", uno::Any (rControlName
) );
770 xPropSet
->setPropertyValue( "PositionX", uno::Any (rPosSize
.X
) );
771 xPropSet
->setPropertyValue( "PositionY", uno::Any (rPosSize
.Y
) );
772 xPropSet
->setPropertyValue( "Height", uno::Any (rPosSize
.Height
) );
773 xPropSet
->setPropertyValue( "Width", uno::Any (rPosSize
.Width
) );
775 // insert by Name into DialogModel container
776 uno::Reference
< container::XNameContainer
> xContainer (rxDialogModel
, uno::UNO_QUERY_THROW
);
777 xContainer
->insertByName( rControlName
, uno::Any (uno::Reference
< uno::XInterface
>(xModel
, uno::UNO_QUERY
)));
781 void UpdateHandler::setFullVersion( OUString
& rString
)
783 uno::Reference
< lang::XMultiServiceFactory
> xConfigurationProvider(
784 css::configuration::theDefaultProvider::get( mxContext
) );
786 beans::PropertyValue aProperty
;
787 aProperty
.Name
= "nodepath";
788 aProperty
.Value
<<= OUString("org.openoffice.Setup/Product");
790 uno::Sequence
< uno::Any
> aArgumentList( 1 );
791 aArgumentList
[0] <<= aProperty
;
793 uno::Reference
< uno::XInterface
> xConfigAccess
= xConfigurationProvider
->createInstanceWithArguments( "com.sun.star.configuration.ConfigurationAccess",
796 uno::Reference
< container::XNameAccess
> xNameAccess( xConfigAccess
, uno::UNO_QUERY_THROW
);
798 OUString aProductVersion
;
799 xNameAccess
->getByName("ooSetupVersion") >>= aProductVersion
;
800 OUString aProductFullVersion
;
801 xNameAccess
->getByName("ooSetupVersionAboutBox") >>= aProductFullVersion
;
802 rString
= rString
.replaceFirst( aProductVersion
, aProductFullVersion
);
806 bool UpdateHandler::showWarning( const OUString
&rWarningText
) const
810 uno::Reference
< awt::XControl
> xControl( mxUpdDlg
, uno::UNO_QUERY
);
811 if ( !xControl
.is() ) return bRet
;
813 uno::Reference
< awt::XWindowPeer
> xPeer
= xControl
->getPeer();
814 if ( !xPeer
.is() ) return bRet
;
816 uno::Reference
< awt::XToolkit
> xToolkit
= xPeer
->getToolkit();
817 if ( !xToolkit
.is() ) return bRet
;
819 awt::WindowDescriptor aDescriptor
;
821 sal_Int32 nWindowAttributes
= awt::WindowAttribute::BORDER
| awt::WindowAttribute::MOVEABLE
| awt::WindowAttribute::CLOSEABLE
;
822 nWindowAttributes
|= awt::VclWindowPeerAttribute::YES_NO
;
823 nWindowAttributes
|= awt::VclWindowPeerAttribute::DEF_NO
;
825 aDescriptor
.Type
= awt::WindowClass_MODALTOP
;
826 aDescriptor
.WindowServiceName
= "warningbox";
827 aDescriptor
.ParentIndex
= -1;
828 aDescriptor
.Parent
= xPeer
;
829 aDescriptor
.Bounds
= awt::Rectangle( 10, 10, 250, 150 );
830 aDescriptor
.WindowAttributes
= nWindowAttributes
;
832 uno::Reference
< awt::XMessageBox
> xMsgBox( xToolkit
->createWindow( aDescriptor
), uno::UNO_QUERY
);
835 mbShowsMessageBox
= true;
837 // xMsgBox->setCaptionText( msCancelTitle );
838 xMsgBox
->setMessageText( rWarningText
);
839 nRet
= xMsgBox
->execute();
840 if ( nRet
== 2 ) // RET_YES == 2
842 mbShowsMessageBox
= false;
845 uno::Reference
< lang::XComponent
> xComponent( xMsgBox
, uno::UNO_QUERY
);
846 if ( xComponent
.is() )
847 xComponent
->dispose();
853 bool UpdateHandler::showWarning( const OUString
&rWarningText
,
854 const OUString
&rBtnText_1
,
855 const OUString
&rBtnText_2
) const
859 uno::Reference
< awt::XControl
> xControl( mxUpdDlg
, uno::UNO_QUERY
);
860 if ( !xControl
.is() ) return bRet
;
862 uno::Reference
< awt::XWindowPeer
> xPeer
= xControl
->getPeer();
863 if ( !xPeer
.is() ) return bRet
;
865 uno::Reference
< awt::XToolkit
> xToolkit
= xPeer
->getToolkit();
866 if ( !xToolkit
.is() ) return bRet
;
868 awt::WindowDescriptor aDescriptor
;
870 sal_Int32 nWindowAttributes
= awt::WindowAttribute::BORDER
| awt::WindowAttribute::MOVEABLE
| awt::WindowAttribute::CLOSEABLE
;
871 nWindowAttributes
|= awt::VclWindowPeerAttribute::YES_NO
;
872 nWindowAttributes
|= awt::VclWindowPeerAttribute::DEF_NO
;
874 aDescriptor
.Type
= awt::WindowClass_MODALTOP
;
875 aDescriptor
.WindowServiceName
= "warningbox";
876 aDescriptor
.ParentIndex
= -1;
877 aDescriptor
.Parent
= xPeer
;
878 aDescriptor
.Bounds
= awt::Rectangle( 10, 10, 250, 150 );
879 aDescriptor
.WindowAttributes
= nWindowAttributes
;
881 uno::Reference
< awt::XMessageBox
> xMsgBox( xToolkit
->createWindow( aDescriptor
), uno::UNO_QUERY
);
884 uno::Reference
< awt::XVclContainer
> xMsgBoxCtrls( xMsgBox
, uno::UNO_QUERY
);
885 if ( xMsgBoxCtrls
.is() )
887 uno::Sequence
< uno::Reference
< awt::XWindow
> > xChildren
= xMsgBoxCtrls
->getWindows();
889 for ( long i
=0; i
< xChildren
.getLength(); i
++ )
891 uno::Reference
< awt::XVclWindowPeer
> xMsgBoxCtrl( xChildren
[i
], uno::UNO_QUERY
);
892 if ( xMsgBoxCtrl
.is() )
894 bool bIsDefault
= true;
895 uno::Any aValue
= xMsgBoxCtrl
->getProperty( "DefaultButton" );
896 aValue
>>= bIsDefault
;
898 xMsgBoxCtrl
->setProperty( "Text", uno::Any( rBtnText_1
) );
900 xMsgBoxCtrl
->setProperty( "Text", uno::Any( rBtnText_2
) );
906 // xMsgBox->setCaptionText( msCancelTitle );
907 mbShowsMessageBox
= true;
908 xMsgBox
->setMessageText( rWarningText
);
909 nRet
= xMsgBox
->execute();
910 if ( nRet
== 2 ) // RET_YES == 2
913 mbShowsMessageBox
= false;
916 uno::Reference
< lang::XComponent
> xComponent( xMsgBox
, uno::UNO_QUERY
);
917 if ( xComponent
.is() )
918 xComponent
->dispose();
924 bool UpdateHandler::showOverwriteWarning( const OUString
& rFileName
) const
928 .replaceAll( "%FILENAME", rFileName
)
929 .replaceAll( "%DOWNLOAD_PATH", msDownloadPath
)),
930 msReloadContinue
, msReloadReload
);
934 bool UpdateHandler::showOverwriteWarning() const
936 return showWarning( msOverwriteWarning
);
940 #define BUTTON_HEIGHT 14
941 #define BUTTON_WIDTH 50
942 #define BUTTON_X_OFFSET 7
943 #define BUTTON_Y_OFFSET 3
944 #define LABEL_HEIGHT 10
946 #define DIALOG_WIDTH 300
947 #define DIALOG_BORDER 5
948 #define INNER_BORDER 3
949 #define TEXT_OFFSET 1
950 #define BOX_HEIGHT1 ( LABEL_HEIGHT + 3*BUTTON_HEIGHT + 2*BUTTON_Y_OFFSET + 2*INNER_BORDER )
951 #define BOX_HEIGHT2 50
952 #define EDIT_WIDTH ( DIALOG_WIDTH - 2 * DIALOG_BORDER )
953 #define BOX1_BTN_X ( DIALOG_BORDER + EDIT_WIDTH - BUTTON_WIDTH - INNER_BORDER )
954 #define BOX1_BTN_Y ( DIALOG_BORDER + LABEL_HEIGHT + INNER_BORDER)
955 #define THROBBER_WIDTH 16
956 #define THROBBER_HEIGHT 16
957 #define THROBBER_X_POS ( DIALOG_BORDER + 8 )
958 #define THROBBER_Y_POS ( DIALOG_BORDER + 23 )
959 #define BUTTON_BAR_HEIGHT 24
960 #define LABEL_OFFSET ( LABEL_HEIGHT + 4 )
961 #define DIALOG_HEIGHT ( BOX_HEIGHT1 + BOX_HEIGHT2 + LABEL_OFFSET + BUTTON_BAR_HEIGHT + 3 * DIALOG_BORDER )
962 #define LABEL_Y_POS ( 2 * DIALOG_BORDER + BOX_HEIGHT1 )
963 #define EDIT2_Y_POS ( LABEL_Y_POS + LABEL_HEIGHT )
964 #define BUTTON_BAR_Y_POS ( EDIT2_Y_POS + DIALOG_BORDER + BOX_HEIGHT2 )
965 #define BUTTON_Y_POS ( BUTTON_BAR_Y_POS + 8 )
966 #define CLOSE_BTN_X ( DIALOG_WIDTH - DIALOG_BORDER - BUTTON_WIDTH )
967 #define INSTALL_BTN_X ( CLOSE_BTN_X - 2 * BUTTON_X_OFFSET - BUTTON_WIDTH )
968 #define DOWNLOAD_BTN_X ( INSTALL_BTN_X - BUTTON_X_OFFSET - BUTTON_WIDTH )
969 #define PROGRESS_WIDTH 80
970 #define PROGRESS_HEIGHT 10
971 #define PROGRESS_X_POS ( DIALOG_BORDER + 8 )
972 #define PROGRESS_Y_POS ( DIALOG_BORDER + 2*LABEL_OFFSET )
975 void UpdateHandler::showControls( short nControls
)
977 // The buttons from CANCEL_BUTTON to RESUME_BUTTON will be shown or
980 for ( int i
= 0; i
<= int(RESUME_BUTTON
); i
++ )
982 nShiftMe
= static_cast<short>(nControls
>> i
);
983 showControl( msButtonIDs
[i
], static_cast<bool>(nShiftMe
& 0x01) );
986 nShiftMe
= static_cast<short>(nControls
>> THROBBER_CTRL
);
987 startThrobber( static_cast<bool>(nShiftMe
& 0x01) );
989 nShiftMe
= static_cast<short>(nControls
>> PROGRESS_CTRL
);
990 showControl( CTRL_PROGRESS
, static_cast<bool>(nShiftMe
& 0x01) );
991 showControl( TEXT_PERCENT
, static_cast<bool>(nShiftMe
& 0x01) );
993 // Status text needs to be smaller, when there are buttons at the right side of the dialog
994 if ( ( nControls
& ( (1<<CANCEL_BUTTON
) + (1<<PAUSE_BUTTON
) + (1<<RESUME_BUTTON
) ) ) != 0 )
995 setControlProperty( TEXT_STATUS
, "Width", uno::Any( sal_Int32(EDIT_WIDTH
- BUTTON_WIDTH
- 2*INNER_BORDER
- TEXT_OFFSET
) ) );
997 setControlProperty( TEXT_STATUS
, "Width", uno::Any( sal_Int32(EDIT_WIDTH
- 2*TEXT_OFFSET
) ) );
999 // Status text needs to be taller, when we show the progress bar
1000 if ( ( nControls
& ( 1<<PROGRESS_CTRL
) ) != 0 )
1001 setControlProperty( TEXT_STATUS
, "Height", uno::Any( sal_Int32(LABEL_HEIGHT
) ) );
1003 setControlProperty( TEXT_STATUS
, "Height", uno::Any( sal_Int32(BOX_HEIGHT1
- 4*TEXT_OFFSET
- LABEL_HEIGHT
) ) );
1007 void UpdateHandler::createDialog()
1009 if ( !mxContext
.is() )
1011 OSL_ASSERT( false );
1015 if( mxContext
.is() )
1017 uno::Reference
< frame::XDesktop2
> xDesktop
= frame::Desktop::create( mxContext
);
1018 xDesktop
->addTerminateListener( this );
1023 uno::Reference
< lang::XMultiComponentFactory
> xFactory( mxContext
->getServiceManager(), uno::UNO_SET_THROW
);
1024 uno::Reference
< awt::XControlModel
> xControlModel( xFactory
->createInstanceWithContext(
1025 "com.sun.star.awt.UnoControlDialogModel",
1026 mxContext
), uno::UNO_QUERY_THROW
);
1028 // @see awt/UnoControlDialogModel.idl
1029 uno::Reference
< beans::XPropertySet
> xPropSet( xControlModel
, uno::UNO_QUERY_THROW
);
1031 xPropSet
->setPropertyValue( "Title", uno::Any( msDlgTitle
) );
1032 xPropSet
->setPropertyValue( "Closeable", uno::Any( true ) );
1033 xPropSet
->setPropertyValue( "Enabled", uno::Any( true ) );
1034 xPropSet
->setPropertyValue( "Moveable", uno::Any( true ) );
1035 xPropSet
->setPropertyValue( "Sizeable", uno::Any( true ) );
1036 xPropSet
->setPropertyValue( "DesktopAsParent", uno::Any( true ) );
1037 xPropSet
->setPropertyValue( "PositionX", uno::Any(sal_Int32( 100 )) );
1038 xPropSet
->setPropertyValue( "PositionY", uno::Any(sal_Int32( 100 )) );
1039 xPropSet
->setPropertyValue( "Width", uno::Any(sal_Int32( DIALOG_WIDTH
)) );
1040 xPropSet
->setPropertyValue( "Height", uno::Any(sal_Int32( DIALOG_HEIGHT
)) );
1041 xPropSet
->setPropertyValue( "HelpURL", uno::makeAny
<OUString
>( INET_HID_SCHEME HID_CHECK_FOR_UPD_DLG
) );
1043 { // Label (fixed text) <status>
1044 uno::Sequence
< beans::NamedValue
> aProps
{ { "Label", uno::Any( msStatusFL
) } };
1046 insertControlModel( xControlModel
, FIXED_TEXT_MODEL
, "fixedLineStatus",
1047 awt::Rectangle( DIALOG_BORDER
+1, DIALOG_BORDER
, EDIT_WIDTH
-2, LABEL_HEIGHT
),
1050 { // box around <status> text
1051 uno::Sequence
< beans::NamedValue
> aProps
;
1053 insertControlModel( xControlModel
, GROUP_BOX_MODEL
, "StatusBox",
1054 awt::Rectangle( DIALOG_BORDER
, DIALOG_BORDER
+ LABEL_HEIGHT
, EDIT_WIDTH
, BOX_HEIGHT1
- LABEL_HEIGHT
),
1057 { // Text (multiline edit) <status>
1058 uno::Sequence
< beans::NamedValue
> aProps
1060 { "Text", uno::Any( substVariables(msChecking
) ) },
1061 { "Border", uno::Any( sal_Int16( 0 ) ) },
1062 { "PaintTransparent", uno::Any( true ) },
1063 { "MultiLine", uno::Any( true ) },
1064 { "ReadOnly", uno::Any( true ) },
1065 { "AutoVScroll", uno::Any( true ) },
1066 { "HelpURL", uno::makeAny
<OUString
>( INET_HID_SCHEME HID_CHECK_FOR_UPD_STATUS
) }
1069 insertControlModel( xControlModel
, EDIT_FIELD_MODEL
, TEXT_STATUS
,
1070 awt::Rectangle( DIALOG_BORDER
+ TEXT_OFFSET
,
1071 DIALOG_BORDER
+ LABEL_HEIGHT
+ TEXT_OFFSET
,
1072 EDIT_WIDTH
- 2*TEXT_OFFSET
,
1073 BOX_HEIGHT1
- 4*TEXT_OFFSET
- LABEL_HEIGHT
),
1076 { // Text (edit) <percent>
1077 uno::Sequence
< beans::NamedValue
> aProps
1079 { "Text", uno::Any( msPercent
) },
1080 { "Border", uno::Any( sal_Int16( 0 ) ) },
1081 { "PaintTransparent", uno::Any( true ) },
1082 { "ReadOnly", uno::Any( true ) },
1085 insertControlModel( xControlModel
, EDIT_FIELD_MODEL
, TEXT_PERCENT
,
1086 awt::Rectangle( PROGRESS_X_POS
+ PROGRESS_WIDTH
+ DIALOG_BORDER
,
1088 EDIT_WIDTH
- PROGRESS_WIDTH
- BUTTON_WIDTH
- 2*DIALOG_BORDER
,
1093 uno::Sequence
< beans::NamedValue
> aProps
1095 { "DefaultButton", uno::Any( false ) },
1096 { "Enabled", uno::Any( true ) },
1097 { "PushButtonType", uno::Any( sal_Int16(awt::PushButtonType_STANDARD
) ) },
1098 { "Label", uno::Any( msPauseBtn
) },
1099 { "HelpURL", uno::makeAny
<OUString
>( INET_HID_SCHEME HID_CHECK_FOR_UPD_PAUSE
) }
1102 insertControlModel ( xControlModel
, BUTTON_MODEL
, msButtonIDs
[PAUSE_BUTTON
],
1103 awt::Rectangle( BOX1_BTN_X
, BOX1_BTN_Y
, BUTTON_WIDTH
, BUTTON_HEIGHT
),
1107 uno::Sequence
< beans::NamedValue
> aProps
1109 { "DefaultButton", uno::Any( false ) },
1110 { "Enabled", uno::Any( true ) },
1111 { "PushButtonType", uno::Any( sal_Int16(awt::PushButtonType_STANDARD
) ) },
1112 { "Label", uno::Any( msResumeBtn
) },
1113 { "HelpURL", uno::makeAny
<OUString
>( INET_HID_SCHEME HID_CHECK_FOR_UPD_RESUME
) }
1116 insertControlModel ( xControlModel
, BUTTON_MODEL
, msButtonIDs
[RESUME_BUTTON
],
1117 awt::Rectangle( BOX1_BTN_X
,
1118 BOX1_BTN_Y
+ BUTTON_Y_OFFSET
+ BUTTON_HEIGHT
,
1124 uno::Sequence
< beans::NamedValue
> aProps
1126 { "DefaultButton", uno::Any( false ) },
1127 { "Enabled", uno::Any( true ) },
1128 { "PushButtonType", uno::Any( sal_Int16(awt::PushButtonType_STANDARD
) ) },
1129 { "Label", uno::Any( msCancelBtn
) },
1130 { "HelpURL", uno::makeAny
<OUString
>( INET_HID_SCHEME HID_CHECK_FOR_UPD_CANCEL
) }
1133 insertControlModel ( xControlModel
, BUTTON_MODEL
, msButtonIDs
[CANCEL_BUTTON
],
1134 awt::Rectangle( BOX1_BTN_X
,
1135 BOX1_BTN_Y
+ (2*(BUTTON_HEIGHT
+BUTTON_Y_OFFSET
)),
1140 { // Label (FixedText) <description>
1141 uno::Sequence
< beans::NamedValue
> aProps
{ { "Label", uno::Any( msDescription
) } };
1143 insertControlModel( xControlModel
, FIXED_TEXT_MODEL
, "fixedTextDescription",
1144 awt::Rectangle( DIALOG_BORDER
+1, LABEL_Y_POS
, EDIT_WIDTH
-2, LABEL_HEIGHT
),
1147 { // box around <description> text
1148 uno::Sequence
< beans::NamedValue
> aProps
;
1150 insertControlModel( xControlModel
, GROUP_BOX_MODEL
, "DescriptionBox",
1151 awt::Rectangle( DIALOG_BORDER
, EDIT2_Y_POS
, EDIT_WIDTH
, BOX_HEIGHT2
),
1154 { // Text (MultiLineEdit) <description>
1155 uno::Sequence
< beans::NamedValue
> aProps
1157 { "Text", uno::Any( OUString() ) },
1158 { "Border", uno::Any( sal_Int16( 0 ) ) },
1159 { "PaintTransparent", uno::Any( true ) },
1160 { "MultiLine", uno::Any( true ) },
1161 { "ReadOnly", uno::Any( true ) },
1162 { "AutoVScroll", uno::Any( true ) },
1163 { "HelpURL", uno::makeAny
<OUString
>( INET_HID_SCHEME HID_CHECK_FOR_UPD_DESCRIPTION
) }
1166 insertControlModel( xControlModel
, EDIT_FIELD_MODEL
, TEXT_DESCRIPTION
,
1167 awt::Rectangle( DIALOG_BORDER
+ TEXT_OFFSET
,
1168 EDIT2_Y_POS
+ 2*TEXT_OFFSET
,
1169 EDIT_WIDTH
- 3*TEXT_OFFSET
,
1170 BOX_HEIGHT2
- 3*TEXT_OFFSET
),
1173 { // @see awt/UnoControlFixedLineModel.idl
1174 uno::Sequence
< beans::NamedValue
> aProps
{ { "Orientation", uno::Any( sal_Int32( 0 ) ) } };
1176 insertControlModel( xControlModel
, FIXED_LINE_MODEL
, "fixedLine",
1177 awt::Rectangle( 0, BUTTON_BAR_Y_POS
, DIALOG_WIDTH
, 5 ),
1180 { // close button // @see awt/UnoControlButtonModel.idl
1181 uno::Sequence
< beans::NamedValue
> aProps
1183 { "DefaultButton", uno::Any( false ) },
1184 { "Enabled", uno::Any( true ) },
1185 // [property] short PushButtonType
1186 // with own "ButtonActionListener"
1187 { "PushButtonType", uno::Any( sal_Int16(awt::PushButtonType_STANDARD
) ) },
1188 // with default ActionListener => endDialog().
1189 // setProperty( aProps, 2, "PushButtonType", uno::Any( sal_Int16(awt::PushButtonType_CANCEL) ) );
1190 // [property] string Label // only if PushButtonType_STANDARD
1191 { "Label", uno::Any( msClose
) },
1192 { "HelpURL", uno::makeAny
<OUString
>( INET_HID_SCHEME HID_CHECK_FOR_UPD_CLOSE
) }
1195 insertControlModel ( xControlModel
, BUTTON_MODEL
, msButtonIDs
[ CLOSE_BUTTON
],
1196 awt::Rectangle( CLOSE_BTN_X
, BUTTON_Y_POS
, BUTTON_WIDTH
, BUTTON_HEIGHT
),
1200 uno::Sequence
< beans::NamedValue
> aProps
1202 { "DefaultButton", uno::Any( false ) },
1203 { "Enabled", uno::Any( true ) },
1204 { "PushButtonType", uno::Any( sal_Int16(awt::PushButtonType_STANDARD
) ) },
1205 { "Label", uno::Any( msInstall
) },
1206 { "HelpURL", uno::makeAny
<OUString
>( INET_HID_SCHEME HID_CHECK_FOR_UPD_INSTALL
) }
1209 insertControlModel ( xControlModel
, BUTTON_MODEL
, msButtonIDs
[INSTALL_BUTTON
],
1210 awt::Rectangle( INSTALL_BTN_X
, BUTTON_Y_POS
, BUTTON_WIDTH
, BUTTON_HEIGHT
),
1213 { // download button
1214 uno::Sequence
< beans::NamedValue
> aProps
1216 { "DefaultButton", uno::Any( false ) },
1217 { "Enabled", uno::Any( true ) },
1218 { "PushButtonType", uno::Any( sal_Int16(awt::PushButtonType_STANDARD
) ) },
1219 { "Label", uno::Any( msDownload
) },
1220 { "HelpURL", uno::makeAny
<OUString
>( INET_HID_SCHEME HID_CHECK_FOR_UPD_DOWNLOAD
) }
1223 insertControlModel ( xControlModel
, BUTTON_MODEL
, msButtonIDs
[DOWNLOAD_BUTTON
],
1224 awt::Rectangle( DOWNLOAD_BTN_X
, BUTTON_Y_POS
, BUTTON_WIDTH
, BUTTON_HEIGHT
),
1228 uno::Sequence
< beans::NamedValue
> aProps
1230 { "DefaultButton", uno::Any( false ) },
1231 { "Enabled", uno::Any( true ) },
1232 { "PushButtonType", uno::Any( sal_Int16(awt::PushButtonType_HELP
) ) }
1235 insertControlModel( xControlModel
, BUTTON_MODEL
, msButtonIDs
[HELP_BUTTON
],
1236 awt::Rectangle( DIALOG_BORDER
, BUTTON_Y_POS
, BUTTON_WIDTH
, BUTTON_HEIGHT
),
1239 { // @see awt/UnoControlThrobberModel.idl
1240 uno::Sequence
< beans::NamedValue
> aProps
;
1242 insertControlModel( xControlModel
, "com.sun.star.awt.SpinningProgressControlModel", CTRL_THROBBER
,
1243 awt::Rectangle( THROBBER_X_POS
, THROBBER_Y_POS
, THROBBER_WIDTH
, THROBBER_HEIGHT
),
1246 { // @see awt/UnoControlProgressBarModel.idl
1247 uno::Sequence
< beans::NamedValue
> aProps
1249 { "Enabled", uno::Any( true ) },
1250 { "ProgressValue", uno::Any( sal_Int32( 0 ) ) },
1251 { "ProgressValueMax", uno::Any( sal_Int32( 100 ) ) },
1252 { "ProgressValueMin", uno::Any( sal_Int32( 0 ) ) },
1254 insertControlModel( xControlModel
, "com.sun.star.awt.UnoControlProgressBarModel", CTRL_PROGRESS
,
1255 awt::Rectangle( PROGRESS_X_POS
, PROGRESS_Y_POS
, PROGRESS_WIDTH
, PROGRESS_HEIGHT
),
1259 uno::Reference
< awt::XUnoControlDialog
> xControl
= awt::UnoControlDialog::create( mxContext
);
1260 xControl
->setModel( xControlModel
);
1264 xControl
->setVisible( false );
1267 xControl
->createPeer( nullptr, nullptr );
1269 for ( int i
= 0; i
< HELP_BUTTON
; i
++ )
1271 uno::Reference
< awt::XButton
> xButton ( xControl
->getControl( msButtonIDs
[i
] ), uno::UNO_QUERY
);
1274 xButton
->setActionCommand( msButtonIDs
[i
] );
1275 xButton
->addActionListener( this );
1280 mxUpdDlg
.set( xControl
, uno::UNO_QUERY_THROW
);
1281 mnLastCtrlState
= -1;
1284 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */