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