LibreOffice Module extensions (master) 1
updatehdl.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include <sal/config.h>
23
24#include <string_view>
25
26#include <osl/mutex.hxx>
27#include <com/sun/star/uno/Any.h>
28#include <com/sun/star/uno/Reference.h>
29#include <com/sun/star/uno/XComponentContext.hpp>
30#include <com/sun/star/awt/Rectangle.hpp>
31#include <com/sun/star/awt/XActionListener.hpp>
32#include <com/sun/star/awt/XControlModel.hpp>
33#include <com/sun/star/awt/XDialog.hpp>
34#include <com/sun/star/awt/XTopWindowListener.hpp>
35#include <com/sun/star/beans/NamedValue.hpp>
36#include <com/sun/star/frame/XTerminateListener.hpp>
37#include <com/sun/star/task/XInteractionHandler.hpp>
39#include <unotools/resmgr.hxx>
40#include <rtl/ref.hxx>
41
42#include "actionlistener.hxx"
43
45{
55};
56
70};
71
72class UpdateHandler : public cppu::WeakImplHelper< css::awt::XActionListener,
73 css::awt::XTopWindowListener,
74 css::task::XInteractionHandler,
75 css::frame::XTerminateListener >
76{
77private:
78 css::uno::Reference< css::uno::XComponentContext > mxContext;
79 css::uno::Reference< css::awt::XDialog > mxUpdDlg;
80 css::uno::Reference< css::task::XInteractionHandler > mxInteractionHdl;
82
85 sal_Int32 mnPercent;
92 mutable bool mbShowsMessageBox;
93
94 osl::Mutex maMutex;
95
96 OUString msNextVersion;
100 OUString msChecking; // RID_UPDATE_STR_CHECKING
101 OUString msCheckingError; // RID_UPDATE_STR_CHECKING_ERR
102 OUString msNoUpdFound; // RID_UPDATE_STR_NO_UPD_FOUND
103 OUString msUpdFound; // RID_UPDATE_STR_UPD_FOUND
104 OUString msDlgTitle; // RID_UPDATE_STR_DLG_TITLE
105 OUString msDownloadPause; // RID_UPDATE_STR_DOWNLOAD_PAUSE
106 OUString msDownloadError; // RID_UPDATE_STR_DOWNLOAD_ERR
107 OUString msDownloadWarning; // RID_UPDATE_STR_DOWNLOAD_WARN
108 OUString msDownloadDescr; // RID_UPDATE_STR_DOWNLOAD_WARN
109 OUString msDownloadNotAvail; // RID_UPDATE_STR_DOWNLOAD_UNAVAIL
110 OUString msDownloading; // RID_UPDATE_STR_DOWNLOADING
111 OUString msReady2Install; // RID_UPDATE_STR_READY_INSTALL
112 OUString msCancelMessage; // RID_UPDATE_STR_CANCEL_DOWNLOAD
113 OUString msOverwriteWarning; // RID_UPDATE_STR_OVERWRITE_WARNING
114 OUString msPercent; // RID_UPDATE_STR_PERCENT
115 OUString msReloadWarning; // RID_UPDATE_STR_OVERWRITE_WARNING
116 OUString msReloadReload; // RID_UPDATE_STR_OVERWRITE_WARNING
117 OUString msReloadContinue; // RID_UPDATE_STR_OVERWRITE_WARNING
118 OUString msStatusFL; // RID_UPDATE_FT_STATUS
119 OUString msDescription; // RID_UPDATE_FT_DESCRIPTION
120 OUString msClose; // RID_UPDATE_BTN_CLOSE
121 OUString msDownload; // RID_UPDATE_BTN_DOWNLOAD
122 OUString msPauseBtn; // RID_UPDATE_BTN_PAUSE
123 OUString msResumeBtn; // RID_UPDATE_BTN_RESUME
124 OUString msCancelBtn; // RID_UPDATE_BTN_CANCEL
128
129 void createDialog();
130 void updateState( UpdateState eNewState );
131 void startThrobber( bool bStart = true );
132 void setControlProperty( const OUString &rCtrlName,
133 const OUString &rPropName,
134 const css::uno::Any &rPropValue );
135 void showControl( const OUString &rCtrlName, bool bShow = true );
136 void showControls( short nControls );
137 void focusControl( DialogControls eID );
138 void enableControls( short nCtrlState );
139 void setDownloadBtnLabel( bool bAppendDots );
140 void loadStrings();
141 static OUString loadString(const std::locale& rLocale,
142 TranslateId pResourceId);
143 OUString substVariables( const OUString &rSource ) const;
144 static void insertControlModel( css::uno::Reference< css::awt::XControlModel > const & rxDialogModel,
145 OUString const & rServiceName,
146 OUString const & rControlName,
147 css::awt::Rectangle const & rPosSize,
148 css::uno::Sequence< css::beans::NamedValue > const & rProps );
149
150 void setFullVersion( OUString& rString );
151
152public:
153 UpdateHandler( const css::uno::Reference< css::uno::XComponentContext > & rxContext,
154 const rtl::Reference< IActionListener > & rxActionListener );
155 virtual ~UpdateHandler() override;
156 UpdateHandler(const UpdateHandler&) = delete;
158
159 bool isVisible() const;
160 bool isMinimized() const { return mbMinimized; }
161 void setVisible( bool bVisible = true );
162 void setProgress( sal_Int32 nPercent );
163 void setNextVersion( const OUString &rNextVersion ) { msNextVersion = rNextVersion; }
164 void setDownloadPath( const OUString &rPath ) { msDownloadPath = rPath; }
165 void setDownloadFile( std::u16string_view rPath );
166 void setErrorMessage( const OUString &rErrorMsg );
167 void setDescription( const OUString &rDescription ){ msDescriptionMsg = rDescription; }
168
169 void setState( UpdateState eState );
170 OUString getBubbleText( UpdateState eState );
171 OUString getBubbleTitle( UpdateState eState );
172 bool showWarning( const OUString &rWarning ) const;
173 bool showWarning( const OUString &rWarning, const OUString& rBtnText_1, const OUString& rBtnText_2 ) const;
174 bool showOverwriteWarning( std::u16string_view rFileName ) const;
175 bool showOverwriteWarning() const;
176
177 // Allows runtime exceptions to be thrown by const methods
178 operator css::uno::Reference< css::uno::XInterface > () const
179 { return const_cast< cppu::OWeakObject * > (static_cast< cppu::OWeakObject const * > (this)); };
180
181 // XActionListener
182 virtual void SAL_CALL disposing( const css::lang::EventObject &rObj ) override;
183 virtual void SAL_CALL actionPerformed( css::awt::ActionEvent const & rEvent) override;
184
185 // XTopWindowListener
186 virtual void SAL_CALL windowOpened( const css::lang::EventObject& e ) override;
187 virtual void SAL_CALL windowClosing( const css::lang::EventObject& e ) override;
188 virtual void SAL_CALL windowClosed( const css::lang::EventObject& e ) override;
189 virtual void SAL_CALL windowMinimized( const css::lang::EventObject& e ) override;
190 virtual void SAL_CALL windowNormalized( const css::lang::EventObject& e ) override;
191 virtual void SAL_CALL windowActivated( const css::lang::EventObject& e ) override;
192 virtual void SAL_CALL windowDeactivated( const css::lang::EventObject& e ) override;
193
194 // XInteractionHandler
195 virtual void SAL_CALL handle( const css::uno::Reference< css::task::XInteractionRequest >& Request ) override;
196
197 // XTerminateListener
198 virtual void SAL_CALL queryTermination( const css::lang::EventObject& e ) override;
199 virtual void SAL_CALL notifyTermination( const css::lang::EventObject& e ) override;
200};
201
202/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString msDownloadPause
Definition: updatehdl.hxx:105
OUString getBubbleTitle(UpdateState eState)
Definition: updatehdl.cxx:274
css::uno::Reference< css::task::XInteractionHandler > mxInteractionHdl
Definition: updatehdl.hxx:80
bool isMinimized() const
Definition: updatehdl.hxx:160
void setDownloadPath(const OUString &rPath)
Definition: updatehdl.hxx:164
OUString msDownloadNotAvail
Definition: updatehdl.hxx:109
UpdateState meLastState
Definition: updatehdl.hxx:84
void createDialog()
Definition: updatehdl.cxx:986
OUString msDownloadFile
Definition: updatehdl.hxx:98
virtual ~UpdateHandler() override
Definition: updatehdl.cxx:103
OUString msCancelMessage
Definition: updatehdl.hxx:112
virtual void SAL_CALL windowDeactivated(const css::lang::EventObject &e) override
Definition: updatehdl.cxx:396
bool isVisible() const
Definition: updatehdl.cxx:166
void enableControls(short nCtrlState)
Definition: updatehdl.cxx:112
UpdateHandler & operator=(const UpdateHandler &)=delete
OUString substVariables(const OUString &rSource) const
Definition: updatehdl.cxx:581
virtual void SAL_CALL windowClosed(const css::lang::EventObject &e) override
Definition: updatehdl.cxx:374
OUString msUpdFound
Definition: updatehdl.hxx:103
void setErrorMessage(const OUString &rErrorMsg)
Definition: updatehdl.cxx:240
bool mbStringsLoaded
Definition: updatehdl.hxx:89
OUString msResumeBtn
Definition: updatehdl.hxx:123
void setDescription(const OUString &rDescription)
Definition: updatehdl.hxx:167
OUString msReloadReload
Definition: updatehdl.hxx:116
OUString msDescription
Definition: updatehdl.hxx:119
OUString msNoUpdFound
Definition: updatehdl.hxx:102
short mnLastCtrlState
Definition: updatehdl.hxx:86
OUString msBubbleTitles[UPDATESTATES_COUNT]
Definition: updatehdl.hxx:127
void updateState(UpdateState eNewState)
Definition: updatehdl.cxx:481
osl::Mutex maMutex
Definition: updatehdl.hxx:94
void loadStrings()
Definition: updatehdl.cxx:590
void setFullVersion(OUString &rString)
Definition: updatehdl.cxx:761
void setProgress(sal_Int32 nPercent)
Definition: updatehdl.cxx:222
rtl::Reference< IActionListener > mxActionListener
Definition: updatehdl.hxx:81
OUString msDownload
Definition: updatehdl.hxx:121
virtual void SAL_CALL notifyTermination(const css::lang::EventObject &e) override
Definition: updatehdl.cxx:462
static OUString loadString(const std::locale &rLocale, TranslateId pResourceId)
Definition: updatehdl.cxx:575
OUString msDownloadDescr
Definition: updatehdl.hxx:108
OUString msNextVersion
Definition: updatehdl.hxx:96
UpdateHandler(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const rtl::Reference< IActionListener > &rxActionListener)
UpdateHandler(const UpdateHandler &)=delete
void setVisible(bool bVisible=true)
Definition: updatehdl.cxx:179
void showControl(const OUString &rCtrlName, bool bShow=true)
Definition: updatehdl.cxx:699
void focusControl(DialogControls eID)
Definition: updatehdl.cxx:715
OUString msDownloading
Definition: updatehdl.hxx:110
OUString msDlgTitle
Definition: updatehdl.hxx:104
void setControlProperty(const OUString &rCtrlName, const OUString &rPropName, const css::uno::Any &rPropValue)
Definition: updatehdl.cxx:678
OUString msCheckingError
Definition: updatehdl.hxx:101
css::uno::Reference< css::awt::XDialog > mxUpdDlg
Definition: updatehdl.hxx:79
virtual void SAL_CALL actionPerformed(css::awt::ActionEvent const &rEvent) override
Definition: updatehdl.cxx:299
OUString msCancelBtn
Definition: updatehdl.hxx:124
virtual void SAL_CALL windowActivated(const css::lang::EventObject &e) override
Definition: updatehdl.cxx:391
void setState(UpdateState eState)
Definition: updatehdl.cxx:155
OUString msBubbleTexts[UPDATESTATES_COUNT]
Definition: updatehdl.hxx:126
bool showWarning(const OUString &rWarning) const
Definition: updatehdl.cxx:785
OUString msDownloadError
Definition: updatehdl.hxx:106
void showControls(short nControls)
Definition: updatehdl.cxx:954
virtual void SAL_CALL queryTermination(const css::lang::EventObject &e) override
Definition: updatehdl.cxx:445
bool mbMinimized
Definition: updatehdl.hxx:90
static void insertControlModel(css::uno::Reference< css::awt::XControlModel > const &rxDialogModel, OUString const &rServiceName, OUString const &rControlName, css::awt::Rectangle const &rPosSize, css::uno::Sequence< css::beans::NamedValue > const &rProps)
Definition: updatehdl.cxx:733
void startThrobber(bool bStart=true)
Definition: updatehdl.cxx:659
bool mbDownloadBtnHasDots
Definition: updatehdl.hxx:87
OUString msReloadWarning
Definition: updatehdl.hxx:115
OUString msDownloadWarning
Definition: updatehdl.hxx:107
OUString msDownloadPath
Definition: updatehdl.hxx:97
bool mbListenerAdded
Definition: updatehdl.hxx:91
OUString msButtonIDs[BUTTON_COUNT]
Definition: updatehdl.hxx:125
void setDownloadFile(std::u16string_view rPath)
Definition: updatehdl.cxx:246
OUString msPercent
Definition: updatehdl.hxx:114
virtual void SAL_CALL windowOpened(const css::lang::EventObject &e) override
Definition: updatehdl.cxx:359
virtual void SAL_CALL windowNormalized(const css::lang::EventObject &e) override
Definition: updatehdl.cxx:385
OUString msOverwriteWarning
Definition: updatehdl.hxx:113
OUString getBubbleText(UpdateState eState)
Definition: updatehdl.cxx:258
virtual void SAL_CALL windowClosing(const css::lang::EventObject &e) override
Definition: updatehdl.cxx:364
OUString msReloadContinue
Definition: updatehdl.hxx:117
UpdateState meCurState
Definition: updatehdl.hxx:83
OUString msStatusFL
Definition: updatehdl.hxx:118
virtual void SAL_CALL handle(const css::uno::Reference< css::task::XInteractionRequest > &Request) override
Definition: updatehdl.cxx:402
void setDownloadBtnLabel(bool bAppendDots)
Definition: updatehdl.cxx:136
OUString msChecking
Definition: updatehdl.hxx:100
bool mbShowsMessageBox
Definition: updatehdl.hxx:92
virtual void SAL_CALL disposing(const css::lang::EventObject &rObj) override
Definition: updatehdl.cxx:292
css::uno::Reference< css::uno::XComponentContext > mxContext
Definition: updatehdl.hxx:78
void setNextVersion(const OUString &rNextVersion)
Definition: updatehdl.hxx:163
virtual void SAL_CALL windowMinimized(const css::lang::EventObject &e) override
Definition: updatehdl.cxx:379
bool showOverwriteWarning() const
Definition: updatehdl.cxx:913
OUString msReady2Install
Definition: updatehdl.hxx:111
OUString msClose
Definition: updatehdl.hxx:120
OUString msPauseBtn
Definition: updatehdl.hxx:122
sal_Int32 mnPercent
Definition: updatehdl.hxx:85
OUString msDescriptionMsg
Definition: updatehdl.hxx:99
UpdateState
Definition: updatehdl.hxx:57
@ UPDATESTATE_UPDATE_NO_DOWNLOAD
Definition: updatehdl.hxx:62
@ UPDATESTATE_ERROR_DOWNLOADING
Definition: updatehdl.hxx:66
@ UPDATESTATE_CHECKING
Definition: updatehdl.hxx:58
@ UPDATESTATE_EXT_UPD_AVAIL
Definition: updatehdl.hxx:68
@ UPDATESTATE_AUTO_START
Definition: updatehdl.hxx:63
@ UPDATESTATE_DOWNLOAD_PAUSED
Definition: updatehdl.hxx:65
@ UPDATESTATE_ERROR_CHECKING
Definition: updatehdl.hxx:59
@ UPDATESTATE_DOWNLOAD_AVAIL
Definition: updatehdl.hxx:67
@ UPDATESTATES_COUNT
Definition: updatehdl.hxx:69
@ UPDATESTATE_NO_UPDATE_AVAIL
Definition: updatehdl.hxx:60
@ UPDATESTATE_UPDATE_AVAIL
Definition: updatehdl.hxx:61
@ UPDATESTATE_DOWNLOADING
Definition: updatehdl.hxx:64
DialogControls
Definition: updatehdl.hxx:45
@ CANCEL_BUTTON
Definition: updatehdl.hxx:46
@ DOWNLOAD_BUTTON
Definition: updatehdl.hxx:49
@ BUTTON_COUNT
Definition: updatehdl.hxx:52
@ CLOSE_BUTTON
Definition: updatehdl.hxx:50
@ PAUSE_BUTTON
Definition: updatehdl.hxx:47
@ HELP_BUTTON
Definition: updatehdl.hxx:51
@ THROBBER_CTRL
Definition: updatehdl.hxx:53
@ RESUME_BUTTON
Definition: updatehdl.hxx:48
@ PROGRESS_CTRL
Definition: updatehdl.hxx:54