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