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