1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dp_gui_dialog2.hxx,v $
11 * $Revision: 1.4.74.3 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #ifndef INCLUDED_DP_GUI_DIALOG2_HXX
33 #define INCLUDED_DP_GUI_DIALOG2_HXX
35 #include "vcl/dialog.hxx"
36 #include "vcl/button.hxx"
37 #include "vcl/fixed.hxx"
38 #include "vcl/timer.hxx"
40 #include "svtools/fixedhyper.hxx"
41 #include "svtools/prgsbar.hxx"
43 #include "osl/conditn.hxx"
44 #include "osl/mutex.hxx"
46 #include "rtl/ref.hxx"
47 #include "rtl/ustring.hxx"
49 #include "cppuhelper/implbase1.hxx"
51 #include "com/sun/star/awt/XWindow.hpp"
52 #include "com/sun/star/deployment/XPackage.hpp"
53 #include "com/sun/star/deployment/XPackageManager.hpp"
54 #include "com/sun/star/uno/XComponentContext.hpp"
55 #include "com/sun/star/ui/dialogs/XExecutableDialog.hpp"
56 #include "com/sun/star/util/XModifyListener.hpp"
60 //==============================================================================
61 class ExtBoxWithBtns_Impl
;
62 class ExtensionBox_Impl
;
63 class TheExtensionManager
;
65 //==============================================================================
68 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> m_xContext
;
74 DialogHelper( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> &,
76 virtual ~DialogHelper();
78 void openWebBrowser( const ::rtl::OUString
& sURL
, const ::rtl::OUString
& sTitle
) const;
79 Dialog
* getWindow() const { return m_pVCLWindow
; };
80 void PostUserEvent( const Link
& rLink
, void* pCaller
);
81 void clearEventID() { m_nEventID
= 0; }
83 virtual void showProgress( bool bStart
) = 0;
84 virtual void updateProgress( const ::rtl::OUString
&rText
,
85 const ::com::sun::star::uno::Reference
< ::com::sun::star::task::XAbortChannel
> &xAbortChannel
) = 0;
86 virtual void updateProgress( const long nProgress
) = 0;
88 virtual void updatePackageInfo( const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackage
> &xPackage
) = 0;
89 virtual long addPackageToList( const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackage
> &,
90 const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackageManager
> & ) = 0;
92 virtual void prepareChecking( const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackageManager
> &xPackageManager
) = 0;
93 virtual void checkEntries() = 0;
95 static ResId
getResId( USHORT nId
);
96 static String
getResourceString( USHORT id
);
97 static bool IsSharedPkgMgr( const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackageManager
> &);
98 static bool continueOnSharedExtension( const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackageManager
> &,
103 void setBusy( const bool bBusy
) { m_bIsBusy
= bBusy
; }
104 bool isBusy() const { return m_bIsBusy
; }
105 bool installExtensionWarn( const ::rtl::OUString
&rExtensionURL
) const;
106 bool installForAllUsers( bool &bInstallForAll
) const;
109 //==============================================================================
110 class ExtMgrDialog
: public ModelessDialog
,
113 ExtBoxWithBtns_Impl
*m_pExtensionBox
;
114 PushButton m_aAddBtn
;
115 PushButton m_aUpdateBtn
;
116 OKButton m_aCloseBtn
;
117 HelpButton m_aHelpBtn
;
118 FixedLine m_aDivider
;
119 svt::FixedHyperlink m_aGetExtensions
;
120 FixedText m_aProgressText
;
121 ProgressBar m_aProgressBar
;
122 CancelButton m_aCancelBtn
;
123 const String m_sAddPackages
;
124 String m_sProgressText
;
125 String m_sLastFolderURL
;
126 ::osl::Mutex m_aMutex
;
128 bool m_bProgressChanged
;
129 bool m_bStartProgress
;
130 bool m_bStopProgress
;
131 bool m_bUpdateWarning
;
132 bool m_bEnableWarning
;
133 bool m_bDisableWarning
;
134 bool m_bDeleteWarning
;
136 Timer m_aTimeoutTimer
;
137 TheExtensionManager
*m_pManager
;
139 ::com::sun::star::uno::Reference
< ::com::sun::star::task::XAbortChannel
> m_xAbortChannel
;
141 bool removeExtensionWarn( const ::rtl::OUString
&rExtensionTitle
) const;
143 DECL_DLLPRIVATE_LINK( HandleAddBtn
, void * );
144 DECL_DLLPRIVATE_LINK( HandleUpdateBtn
, void * );
145 DECL_DLLPRIVATE_LINK( HandleCancelBtn
, void * );
146 DECL_DLLPRIVATE_LINK( HandleHyperlink
, svt::FixedHyperlink
* );
147 DECL_DLLPRIVATE_LINK( TimeOutHdl
, Timer
* );
148 DECL_DLLPRIVATE_LINK( startProgress
, void * );
151 ExtMgrDialog( Window
* pParent
, TheExtensionManager
*pManager
);
152 virtual ~ExtMgrDialog();
154 virtual void Resize();
155 virtual long Notify( NotifyEvent
& rNEvt
);
156 virtual BOOL
Close();
158 virtual void showProgress( bool bStart
);
159 virtual void updateProgress( const ::rtl::OUString
&rText
,
160 const ::com::sun::star::uno::Reference
< ::com::sun::star::task::XAbortChannel
> &xAbortChannel
);
161 virtual void updateProgress( const long nProgress
);
163 virtual void updatePackageInfo( const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackage
> &xPackage
);
165 void setGetExtensionsURL( const ::rtl::OUString
&rURL
);
166 void selectEntry( long nPos
);
167 virtual long addPackageToList( const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackage
> &,
168 const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackageManager
> & );
169 bool enablePackage( const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackageManager
> &xPackageManager
,
170 const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackage
> &xPackage
,
172 bool removePackage( const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackageManager
> &xPackageManager
,
173 const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackage
> &xPackage
);
174 bool updatePackage( const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackageManager
> &xPackageManager
,
175 const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackage
> &xPackage
);
177 virtual void prepareChecking( const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackageManager
> &xPackageManager
);
178 virtual void checkEntries();
180 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> raiseAddPicker( const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackageManager
> &xPackageManager
);
183 //==============================================================================
184 class UpdateRequiredDialog
: public ModalDialog
,
187 ExtensionBox_Impl
*m_pExtensionBox
;
188 FixedText m_aUpdateNeeded
;
189 PushButton m_aUpdateBtn
;
190 PushButton m_aCloseBtn
;
191 HelpButton m_aHelpBtn
;
192 CancelButton m_aCancelBtn
;
193 FixedLine m_aDivider
;
194 FixedText m_aProgressText
;
195 ProgressBar m_aProgressBar
;
196 const String m_sAddPackages
;
197 const String m_sCloseText
;
198 String m_sProgressText
;
199 ::osl::Mutex m_aMutex
;
201 bool m_bProgressChanged
;
202 bool m_bStartProgress
;
203 bool m_bStopProgress
;
204 bool m_bUpdateWarning
;
205 bool m_bDisableWarning
;
206 bool m_bHasLockedEntries
;
208 Timer m_aTimeoutTimer
;
209 TheExtensionManager
*m_pManager
;
211 ::com::sun::star::uno::Reference
< ::com::sun::star::task::XAbortChannel
> m_xAbortChannel
;
213 DECL_DLLPRIVATE_LINK( HandleUpdateBtn
, void * );
214 DECL_DLLPRIVATE_LINK( HandleCloseBtn
, void * );
215 DECL_DLLPRIVATE_LINK( HandleCancelBtn
, void * );
216 DECL_DLLPRIVATE_LINK( TimeOutHdl
, Timer
* );
217 DECL_DLLPRIVATE_LINK( startProgress
, void * );
218 DECL_DLLPRIVATE_LINK( HandleHyperlink
, svt::FixedHyperlink
* );
220 bool isEnabled( const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackage
> &xPackage
) const;
221 bool checkDependencies( const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackage
> &xPackage
) const;
222 bool hasActiveEntries();
223 void disableAllEntries();
226 UpdateRequiredDialog( Window
* pParent
, TheExtensionManager
*pManager
);
227 virtual ~UpdateRequiredDialog();
229 virtual short Execute();
230 virtual void Resize();
231 virtual BOOL
Close();
232 // virtual long Notify( NotifyEvent& rNEvt );
234 virtual void showProgress( bool bStart
);
235 virtual void updateProgress( const ::rtl::OUString
&rText
,
236 const ::com::sun::star::uno::Reference
< ::com::sun::star::task::XAbortChannel
> &xAbortChannel
);
237 virtual void updateProgress( const long nProgress
);
239 virtual void updatePackageInfo( const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackage
> &xPackage
);
241 void selectEntry( long nPos
);
242 virtual long addPackageToList( const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackage
> &,
243 const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackageManager
> & );
244 bool enablePackage( const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackageManager
> &xPackageManager
,
245 const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackage
> &xPackage
,
247 bool updatePackage( const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackageManager
> &xPackageManager
,
248 const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackage
> &xPackage
);
250 virtual void prepareChecking( const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackageManager
> &xPackageManager
);
251 virtual void checkEntries();
253 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> raiseAddPicker( const ::com::sun::star::uno::Reference
< ::com::sun::star::deployment::XPackageManager
> &xPackageManager
);
255 bool installForAllUsers( bool &bInstallForAll
) const;
256 bool installExtensionWarn( const ::rtl::OUString
&rExtensionURL
) const;
259 //==============================================================================
260 class UpdateRequiredDialogService
: public ::cppu::WeakImplHelper1
< ::com::sun::star::ui::dialogs::XExecutableDialog
>
262 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> const m_xComponentContext
;
263 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> m_xParent
;
264 ::rtl::OUString m_sInitialTitle
;
267 UpdateRequiredDialogService( ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> const & args
,
268 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> const & xComponentContext
);
271 virtual void SAL_CALL
setTitle( rtl::OUString
const & title
) throw ( ::com::sun::star::uno::RuntimeException
);
272 virtual sal_Int16 SAL_CALL
execute() throw ( ::com::sun::star::uno::RuntimeException
);
275 } // namespace dp_gui