xref: /AOO41X/main/desktop/source/deployment/gui/dp_gui_dialog2.cxx (revision 8402cd44417f129945a876644c3077e66211c2c3)
1cdf0e10cSrcweir /*************************************************************************
2cdf0e10cSrcweir  *
3cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4cdf0e10cSrcweir  *
5cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6cdf0e10cSrcweir  *
7cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8cdf0e10cSrcweir  *
9cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10cdf0e10cSrcweir  *
11cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14cdf0e10cSrcweir  *
15cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20cdf0e10cSrcweir  *
21cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25cdf0e10cSrcweir  *
26cdf0e10cSrcweir  ************************************************************************/
27cdf0e10cSrcweir 
28cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29cdf0e10cSrcweir #include "precompiled_desktop.hxx"
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include "dp_gui.hrc"
32cdf0e10cSrcweir #include "svtools/controldims.hrc"
33cdf0e10cSrcweir #include "svtools/svtools.hrc"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include "dp_gui.h"
36cdf0e10cSrcweir #include "dp_gui_dialog2.hxx"
37cdf0e10cSrcweir #include "dp_gui_extlistbox.hxx"
38cdf0e10cSrcweir #include "dp_gui_shared.hxx"
39cdf0e10cSrcweir #include "dp_gui_theextmgr.hxx"
40cdf0e10cSrcweir #include "dp_gui_extensioncmdqueue.hxx"
41cdf0e10cSrcweir #include "dp_misc.h"
42cdf0e10cSrcweir #include "dp_ucb.h"
43cdf0e10cSrcweir #include "dp_update.hxx"
44cdf0e10cSrcweir #include "dp_identifier.hxx"
45cdf0e10cSrcweir #include "dp_descriptioninfoset.hxx"
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #include "vcl/ctrl.hxx"
48cdf0e10cSrcweir #include "vcl/menu.hxx"
49cdf0e10cSrcweir #include "vcl/msgbox.hxx"
50cdf0e10cSrcweir #include "vcl/scrbar.hxx"
51cdf0e10cSrcweir #include "vcl/svapp.hxx"
52cdf0e10cSrcweir 
53cdf0e10cSrcweir #include "vos/mutex.hxx"
54cdf0e10cSrcweir 
55cdf0e10cSrcweir #include "svtools/extensionlistbox.hxx"
56cdf0e10cSrcweir 
57cdf0e10cSrcweir #include "sfx2/sfxdlg.hxx"
58cdf0e10cSrcweir 
59cdf0e10cSrcweir #include "comphelper/anytostring.hxx"
60cdf0e10cSrcweir #include "cppuhelper/exc_hlp.hxx"
61cdf0e10cSrcweir #include "cppuhelper/bootstrap.hxx"
62cdf0e10cSrcweir 
63cdf0e10cSrcweir #include "comphelper/processfactory.hxx"
64cdf0e10cSrcweir #include "ucbhelper/content.hxx"
65cdf0e10cSrcweir #include "unotools/collatorwrapper.hxx"
66cdf0e10cSrcweir 
67cdf0e10cSrcweir #include "com/sun/star/beans/StringPair.hpp"
68cdf0e10cSrcweir 
69cdf0e10cSrcweir #include "com/sun/star/i18n/CollatorOptions.hpp"
70cdf0e10cSrcweir 
71cdf0e10cSrcweir #include "com/sun/star/system/SystemShellExecuteFlags.hpp"
72cdf0e10cSrcweir #include "com/sun/star/system/XSystemShellExecute.hpp"
73cdf0e10cSrcweir 
74cdf0e10cSrcweir #include "com/sun/star/ui/dialogs/ExecutableDialogResults.hpp"
75cdf0e10cSrcweir #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
76cdf0e10cSrcweir #include "com/sun/star/ui/dialogs/XFilePicker.hpp"
77cdf0e10cSrcweir #include "com/sun/star/ui/dialogs/XFilterManager.hpp"
78cdf0e10cSrcweir 
79cdf0e10cSrcweir #include "com/sun/star/uno/Any.hxx"
80cdf0e10cSrcweir #include "com/sun/star/uno/XComponentContext.hpp"
81cdf0e10cSrcweir 
82cdf0e10cSrcweir #include <map>
83cdf0e10cSrcweir #include <vector>
84cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
85cdf0e10cSrcweir 
86cdf0e10cSrcweir #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
87cdf0e10cSrcweir 
88cdf0e10cSrcweir using namespace ::com::sun::star;
89cdf0e10cSrcweir using namespace ::com::sun::star::system;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir using ::rtl::OUString;
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 
94cdf0e10cSrcweir namespace dp_gui {
95cdf0e10cSrcweir 
96cdf0e10cSrcweir #define TOP_OFFSET           5
97cdf0e10cSrcweir #define LINE_SIZE            4
98cdf0e10cSrcweir #define PROGRESS_WIDTH      60
99cdf0e10cSrcweir #define PROGRESS_HEIGHT     14
100cdf0e10cSrcweir 
101cdf0e10cSrcweir //------------------------------------------------------------------------------
102cdf0e10cSrcweir struct StrAllFiles : public rtl::StaticWithInit< const OUString, StrAllFiles >
103cdf0e10cSrcweir {
104cdf0e10cSrcweir     const OUString operator () () {
105cdf0e10cSrcweir         const ::vos::OGuard guard( Application::GetSolarMutex() );
106cdf0e10cSrcweir         ::std::auto_ptr< ResMgr > const resmgr( ResMgr::CreateResMgr( "fps_office" ) );
107cdf0e10cSrcweir         OSL_ASSERT( resmgr.get() != 0 );
108cdf0e10cSrcweir         String ret( ResId( STR_FILTERNAME_ALL, *resmgr.get() ) );
109cdf0e10cSrcweir         return ret;
110cdf0e10cSrcweir     }
111cdf0e10cSrcweir };
112cdf0e10cSrcweir 
113cdf0e10cSrcweir //------------------------------------------------------------------------------
114cdf0e10cSrcweir //                            ExtBoxWithBtns_Impl
115cdf0e10cSrcweir //------------------------------------------------------------------------------
116cdf0e10cSrcweir 
117cdf0e10cSrcweir enum MENU_COMMAND
118cdf0e10cSrcweir {
119cdf0e10cSrcweir     CMD_NONE    = 0,
120cdf0e10cSrcweir     CMD_REMOVE  = 1,
121cdf0e10cSrcweir     CMD_ENABLE,
122cdf0e10cSrcweir     CMD_DISABLE,
123cdf0e10cSrcweir     CMD_UPDATE,
124cdf0e10cSrcweir     CMD_SHOW_LICENSE
125cdf0e10cSrcweir };
126cdf0e10cSrcweir 
127cdf0e10cSrcweir class ExtBoxWithBtns_Impl : public ExtensionBox_Impl
128cdf0e10cSrcweir {
129cdf0e10cSrcweir     Size            m_aOutputSize;
130cdf0e10cSrcweir     bool            m_bInterfaceLocked;
131cdf0e10cSrcweir 
132cdf0e10cSrcweir     PushButton     *m_pOptionsBtn;
133cdf0e10cSrcweir     PushButton     *m_pEnableBtn;
134cdf0e10cSrcweir     PushButton     *m_pRemoveBtn;
135cdf0e10cSrcweir 
136cdf0e10cSrcweir     ExtMgrDialog   *m_pParent;
137cdf0e10cSrcweir 
138cdf0e10cSrcweir     void            SetButtonPos( const Rectangle& rRect );
139cdf0e10cSrcweir     void            SetButtonStatus( const TEntry_Impl pEntry );
140cdf0e10cSrcweir     bool            HandleTabKey( bool bReverse );
141cdf0e10cSrcweir     MENU_COMMAND    ShowPopupMenu( const Point &rPos, const long nPos );
142cdf0e10cSrcweir 
143cdf0e10cSrcweir     //-----------------
144cdf0e10cSrcweir     DECL_DLLPRIVATE_LINK( ScrollHdl, ScrollBar * );
145cdf0e10cSrcweir 
146cdf0e10cSrcweir     DECL_DLLPRIVATE_LINK( HandleOptionsBtn, void * );
147cdf0e10cSrcweir     DECL_DLLPRIVATE_LINK( HandleEnableBtn, void * );
148cdf0e10cSrcweir     DECL_DLLPRIVATE_LINK( HandleRemoveBtn, void * );
149cdf0e10cSrcweir     DECL_DLLPRIVATE_LINK( HandleHyperlink, svt::FixedHyperlink * );
150cdf0e10cSrcweir 
151cdf0e10cSrcweir public:
152cdf0e10cSrcweir                     ExtBoxWithBtns_Impl( ExtMgrDialog* pParent, TheExtensionManager *pManager );
153cdf0e10cSrcweir                    ~ExtBoxWithBtns_Impl();
154cdf0e10cSrcweir 
155cdf0e10cSrcweir     virtual void    MouseButtonDown( const MouseEvent& rMEvt );
156cdf0e10cSrcweir     virtual long    Notify( NotifyEvent& rNEvt );
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     const Size      GetMinOutputSizePixel() const;
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     virtual void    RecalcAll();
161cdf0e10cSrcweir     virtual void    selectEntry( const long nPos );
162cdf0e10cSrcweir     //-----------------
163cdf0e10cSrcweir     void            enableButtons( bool bEnable );
164cdf0e10cSrcweir };
165cdf0e10cSrcweir 
166cdf0e10cSrcweir //------------------------------------------------------------------------------
167cdf0e10cSrcweir ExtBoxWithBtns_Impl::ExtBoxWithBtns_Impl( ExtMgrDialog* pParent, TheExtensionManager *pManager ) :
168cdf0e10cSrcweir     ExtensionBox_Impl( pParent, pManager ),
169cdf0e10cSrcweir     m_bInterfaceLocked( false ),
170cdf0e10cSrcweir     m_pOptionsBtn( NULL ),
171cdf0e10cSrcweir     m_pEnableBtn( NULL ),
172cdf0e10cSrcweir     m_pRemoveBtn( NULL ),
173cdf0e10cSrcweir     m_pParent( pParent )
174cdf0e10cSrcweir {
175cdf0e10cSrcweir     m_pOptionsBtn = new PushButton( this, WB_TABSTOP );
176cdf0e10cSrcweir     m_pEnableBtn = new PushButton( this, WB_TABSTOP );
177cdf0e10cSrcweir     m_pRemoveBtn = new PushButton( this, WB_TABSTOP );
178cdf0e10cSrcweir 
179cdf0e10cSrcweir     SetHelpId( HID_EXTENSION_MANAGER_LISTBOX );
180cdf0e10cSrcweir     m_pOptionsBtn->SetHelpId( HID_EXTENSION_MANAGER_LISTBOX_OPTIONS );
181cdf0e10cSrcweir     m_pEnableBtn->SetHelpId( HID_EXTENSION_MANAGER_LISTBOX_DISABLE );
182cdf0e10cSrcweir     m_pRemoveBtn->SetHelpId( HID_EXTENSION_MANAGER_LISTBOX_REMOVE );
183cdf0e10cSrcweir 
184cdf0e10cSrcweir     m_pOptionsBtn->SetClickHdl( LINK( this, ExtBoxWithBtns_Impl, HandleOptionsBtn ) );
185cdf0e10cSrcweir     m_pEnableBtn->SetClickHdl( LINK( this, ExtBoxWithBtns_Impl, HandleEnableBtn ) );
186cdf0e10cSrcweir     m_pRemoveBtn->SetClickHdl( LINK( this, ExtBoxWithBtns_Impl, HandleRemoveBtn ) );
187cdf0e10cSrcweir 
188cdf0e10cSrcweir     m_pOptionsBtn->SetText( DialogHelper::getResourceString( RID_CTX_ITEM_OPTIONS ) );
189cdf0e10cSrcweir     m_pEnableBtn->SetText( DialogHelper::getResourceString( RID_CTX_ITEM_DISABLE ) );
190cdf0e10cSrcweir     m_pRemoveBtn->SetText( DialogHelper::getResourceString( RID_CTX_ITEM_REMOVE ) );
191cdf0e10cSrcweir 
192cdf0e10cSrcweir     Size aSize = LogicToPixel( Size( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ),
193cdf0e10cSrcweir                                MapMode( MAP_APPFONT ) );
194cdf0e10cSrcweir     m_pOptionsBtn->SetSizePixel( aSize );
195cdf0e10cSrcweir     m_pEnableBtn->SetSizePixel( aSize );
196cdf0e10cSrcweir     m_pRemoveBtn->SetSizePixel( aSize );
197cdf0e10cSrcweir 
198cdf0e10cSrcweir     SetExtraSize( aSize.Height() + 2 * TOP_OFFSET );
199cdf0e10cSrcweir 
200cdf0e10cSrcweir     SetScrollHdl( LINK( this, ExtBoxWithBtns_Impl, ScrollHdl ) );
201cdf0e10cSrcweir }
202cdf0e10cSrcweir 
203cdf0e10cSrcweir //------------------------------------------------------------------------------
204cdf0e10cSrcweir ExtBoxWithBtns_Impl::~ExtBoxWithBtns_Impl()
205cdf0e10cSrcweir {
206cdf0e10cSrcweir     delete m_pOptionsBtn;
207cdf0e10cSrcweir     delete m_pEnableBtn;
208cdf0e10cSrcweir     delete m_pRemoveBtn;
209cdf0e10cSrcweir }
210cdf0e10cSrcweir 
211cdf0e10cSrcweir //------------------------------------------------------------------------------
212cdf0e10cSrcweir //------------------------------------------------------------------------------
213cdf0e10cSrcweir //------------------------------------------------------------------------------
214cdf0e10cSrcweir const Size ExtBoxWithBtns_Impl::GetMinOutputSizePixel() const
215cdf0e10cSrcweir {
216cdf0e10cSrcweir     Size aMinSize( ExtensionBox_Impl::GetMinOutputSizePixel() );
217cdf0e10cSrcweir     long nHeight = aMinSize.Height();
218cdf0e10cSrcweir     nHeight += m_pOptionsBtn->GetSizePixel().Height();
219cdf0e10cSrcweir     nHeight +=  2 * TOP_OFFSET;
220cdf0e10cSrcweir     long nWidth = m_pOptionsBtn->GetSizePixel().Width();
221cdf0e10cSrcweir     nWidth *= 3;
222cdf0e10cSrcweir     nWidth += 5*TOP_OFFSET + 20;
223cdf0e10cSrcweir 
224cdf0e10cSrcweir     return Size( nWidth, nHeight );
225cdf0e10cSrcweir }
226cdf0e10cSrcweir 
227cdf0e10cSrcweir // -----------------------------------------------------------------------
228cdf0e10cSrcweir void ExtBoxWithBtns_Impl::RecalcAll()
229cdf0e10cSrcweir {
230cdf0e10cSrcweir     const sal_Int32 nActive = getSelIndex();
231cdf0e10cSrcweir 
232cdf0e10cSrcweir     if ( nActive != EXTENSION_LISTBOX_ENTRY_NOTFOUND )
233cdf0e10cSrcweir     {
234cdf0e10cSrcweir         SetButtonStatus( GetEntryData( nActive) );
235cdf0e10cSrcweir     }
236cdf0e10cSrcweir     else
237cdf0e10cSrcweir     {
238cdf0e10cSrcweir         m_pOptionsBtn->Hide();
239cdf0e10cSrcweir         m_pEnableBtn->Hide();
240cdf0e10cSrcweir         m_pRemoveBtn->Hide();
241cdf0e10cSrcweir     }
242cdf0e10cSrcweir 
243cdf0e10cSrcweir     ExtensionBox_Impl::RecalcAll();
244cdf0e10cSrcweir 
245cdf0e10cSrcweir     if ( nActive != EXTENSION_LISTBOX_ENTRY_NOTFOUND )
246cdf0e10cSrcweir         SetButtonPos( GetEntryRect( nActive ) );
247cdf0e10cSrcweir }
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 
250cdf0e10cSrcweir //------------------------------------------------------------------------------
251cdf0e10cSrcweir //This function may be called with nPos < 0
252cdf0e10cSrcweir void ExtBoxWithBtns_Impl::selectEntry( const long nPos )
253cdf0e10cSrcweir {
254cdf0e10cSrcweir     if ( HasActive() && ( nPos == getSelIndex() ) )
255cdf0e10cSrcweir         return;
256cdf0e10cSrcweir 
257cdf0e10cSrcweir     ExtensionBox_Impl::selectEntry( nPos );
258cdf0e10cSrcweir }
259cdf0e10cSrcweir 
260cdf0e10cSrcweir // -----------------------------------------------------------------------
261cdf0e10cSrcweir void ExtBoxWithBtns_Impl::SetButtonPos( const Rectangle& rRect )
262cdf0e10cSrcweir {
263cdf0e10cSrcweir     Size  aBtnSize( m_pOptionsBtn->GetSizePixel() );
264cdf0e10cSrcweir     Point aBtnPos( rRect.Left() + ICON_OFFSET,
265cdf0e10cSrcweir                    rRect.Bottom() - TOP_OFFSET - aBtnSize.Height() );
266cdf0e10cSrcweir 
267cdf0e10cSrcweir     m_pOptionsBtn->SetPosPixel( aBtnPos );
268cdf0e10cSrcweir     aBtnPos.X() = rRect.Right() - TOP_OFFSET - aBtnSize.Width();
269cdf0e10cSrcweir     m_pRemoveBtn->SetPosPixel( aBtnPos );
270cdf0e10cSrcweir     aBtnPos.X() -= ( TOP_OFFSET + aBtnSize.Width() );
271cdf0e10cSrcweir     m_pEnableBtn->SetPosPixel( aBtnPos );
272cdf0e10cSrcweir }
273cdf0e10cSrcweir 
274cdf0e10cSrcweir // -----------------------------------------------------------------------
275cdf0e10cSrcweir void ExtBoxWithBtns_Impl::SetButtonStatus( const TEntry_Impl pEntry )
276cdf0e10cSrcweir {
277cdf0e10cSrcweir     bool bShowOptionBtn = true;
278cdf0e10cSrcweir 
279cdf0e10cSrcweir     pEntry->m_bHasButtons = false;
280cdf0e10cSrcweir     if ( ( pEntry->m_eState == REGISTERED ) || ( pEntry->m_eState == NOT_AVAILABLE ) )
281cdf0e10cSrcweir     {
282cdf0e10cSrcweir         m_pEnableBtn->SetText( DialogHelper::getResourceString( RID_CTX_ITEM_DISABLE ) );
283cdf0e10cSrcweir         m_pEnableBtn->SetHelpId( HID_EXTENSION_MANAGER_LISTBOX_DISABLE );
284cdf0e10cSrcweir     }
285cdf0e10cSrcweir     else
286cdf0e10cSrcweir     {
287cdf0e10cSrcweir         m_pEnableBtn->SetText( DialogHelper::getResourceString( RID_CTX_ITEM_ENABLE ) );
288cdf0e10cSrcweir         m_pEnableBtn->SetHelpId( HID_EXTENSION_MANAGER_LISTBOX_ENABLE );
289cdf0e10cSrcweir         bShowOptionBtn = false;
290cdf0e10cSrcweir     }
291cdf0e10cSrcweir 
292cdf0e10cSrcweir     if ( ( !pEntry->m_bUser || ( pEntry->m_eState == NOT_AVAILABLE ) || pEntry->m_bMissingDeps )
293cdf0e10cSrcweir          && !pEntry->m_bMissingLic )
294cdf0e10cSrcweir         m_pEnableBtn->Hide();
295cdf0e10cSrcweir     else
296cdf0e10cSrcweir     {
297cdf0e10cSrcweir         m_pEnableBtn->Enable( !pEntry->m_bLocked );
298cdf0e10cSrcweir         m_pEnableBtn->Show();
299cdf0e10cSrcweir         pEntry->m_bHasButtons = true;
300cdf0e10cSrcweir     }
301cdf0e10cSrcweir 
302cdf0e10cSrcweir     if ( pEntry->m_bHasOptions && bShowOptionBtn )
303cdf0e10cSrcweir     {
304cdf0e10cSrcweir         m_pOptionsBtn->Enable( pEntry->m_bHasOptions );
305cdf0e10cSrcweir         m_pOptionsBtn->Show();
306cdf0e10cSrcweir         pEntry->m_bHasButtons = true;
307cdf0e10cSrcweir     }
308cdf0e10cSrcweir     else
309cdf0e10cSrcweir         m_pOptionsBtn->Hide();
310cdf0e10cSrcweir 
311cdf0e10cSrcweir     if ( pEntry->m_bUser || pEntry->m_bShared )
312cdf0e10cSrcweir     {
313cdf0e10cSrcweir         m_pRemoveBtn->Enable( !pEntry->m_bLocked );
314cdf0e10cSrcweir         m_pRemoveBtn->Show();
315cdf0e10cSrcweir         pEntry->m_bHasButtons = true;
316cdf0e10cSrcweir     }
317cdf0e10cSrcweir     else
318cdf0e10cSrcweir         m_pRemoveBtn->Hide();
319cdf0e10cSrcweir }
320cdf0e10cSrcweir 
321cdf0e10cSrcweir // -----------------------------------------------------------------------
322cdf0e10cSrcweir bool ExtBoxWithBtns_Impl::HandleTabKey( bool bReverse )
323cdf0e10cSrcweir {
324cdf0e10cSrcweir     sal_Int32 nIndex = getSelIndex();
325cdf0e10cSrcweir 
326cdf0e10cSrcweir     if ( nIndex == EXTENSION_LISTBOX_ENTRY_NOTFOUND )
327cdf0e10cSrcweir         return false;
328cdf0e10cSrcweir 
329cdf0e10cSrcweir     PushButton *pNext = NULL;
330cdf0e10cSrcweir 
331cdf0e10cSrcweir     if ( m_pOptionsBtn->HasFocus() ) {
332cdf0e10cSrcweir         if ( !bReverse && !GetEntryData( nIndex )->m_bLocked )
333cdf0e10cSrcweir             pNext = m_pEnableBtn;
334cdf0e10cSrcweir     }
335cdf0e10cSrcweir     else if ( m_pEnableBtn->HasFocus() ) {
336cdf0e10cSrcweir         if ( !bReverse )
337cdf0e10cSrcweir             pNext = m_pRemoveBtn;
338cdf0e10cSrcweir         else if ( GetEntryData( nIndex )->m_bHasOptions )
339cdf0e10cSrcweir             pNext = m_pOptionsBtn;
340cdf0e10cSrcweir     }
341cdf0e10cSrcweir     else if ( m_pRemoveBtn->HasFocus() ) {
342cdf0e10cSrcweir         if ( bReverse )
343cdf0e10cSrcweir             pNext = m_pEnableBtn;
344cdf0e10cSrcweir     }
345cdf0e10cSrcweir     else {
346cdf0e10cSrcweir         if ( !bReverse ) {
347cdf0e10cSrcweir             if ( GetEntryData( nIndex )->m_bHasOptions )
348cdf0e10cSrcweir                 pNext = m_pOptionsBtn;
349cdf0e10cSrcweir             else if ( ! GetEntryData( nIndex )->m_bLocked )
350cdf0e10cSrcweir                 pNext = m_pEnableBtn;
351cdf0e10cSrcweir         } else {
352cdf0e10cSrcweir             if ( ! GetEntryData( nIndex )->m_bLocked )
353cdf0e10cSrcweir                 pNext = m_pRemoveBtn;
354cdf0e10cSrcweir             else if ( GetEntryData( nIndex )->m_bHasOptions )
355cdf0e10cSrcweir                 pNext = m_pOptionsBtn;
356cdf0e10cSrcweir         }
357cdf0e10cSrcweir     }
358cdf0e10cSrcweir 
359cdf0e10cSrcweir     if ( pNext )
360cdf0e10cSrcweir     {
361cdf0e10cSrcweir         pNext->GrabFocus();
362cdf0e10cSrcweir         return true;
363cdf0e10cSrcweir     }
364cdf0e10cSrcweir     else
365cdf0e10cSrcweir         return false;
366cdf0e10cSrcweir }
367cdf0e10cSrcweir 
368cdf0e10cSrcweir // -----------------------------------------------------------------------
369cdf0e10cSrcweir MENU_COMMAND ExtBoxWithBtns_Impl::ShowPopupMenu( const Point & rPos, const long nPos )
370cdf0e10cSrcweir {
371cdf0e10cSrcweir     if ( nPos >= (long) getItemCount() )
372cdf0e10cSrcweir         return CMD_NONE;
373cdf0e10cSrcweir 
374cdf0e10cSrcweir     PopupMenu aPopup;
375cdf0e10cSrcweir 
376cdf0e10cSrcweir     aPopup.InsertItem( CMD_UPDATE, DialogHelper::getResourceString( RID_CTX_ITEM_CHECK_UPDATE ) );
377cdf0e10cSrcweir 
378cdf0e10cSrcweir     if ( ! GetEntryData( nPos )->m_bLocked )
379cdf0e10cSrcweir     {
380cdf0e10cSrcweir     	if ( GetEntryData( nPos )->m_bUser )
381cdf0e10cSrcweir     	{
382cdf0e10cSrcweir             if ( GetEntryData( nPos )->m_eState == REGISTERED )
383cdf0e10cSrcweir                 aPopup.InsertItem( CMD_DISABLE, DialogHelper::getResourceString( RID_CTX_ITEM_DISABLE ) );
384cdf0e10cSrcweir             else if ( GetEntryData( nPos )->m_eState != NOT_AVAILABLE )
385cdf0e10cSrcweir                 aPopup.InsertItem( CMD_ENABLE, DialogHelper::getResourceString( RID_CTX_ITEM_ENABLE ) );
386cdf0e10cSrcweir         }
387cdf0e10cSrcweir         aPopup.InsertItem( CMD_REMOVE, DialogHelper::getResourceString( RID_CTX_ITEM_REMOVE ) );
388cdf0e10cSrcweir     }
389cdf0e10cSrcweir 
390cdf0e10cSrcweir     if ( GetEntryData( nPos )->m_sLicenseText.Len() )
391cdf0e10cSrcweir         aPopup.InsertItem( CMD_SHOW_LICENSE, DialogHelper::getResourceString( RID_STR_SHOW_LICENSE_CMD ) );
392cdf0e10cSrcweir 
393cdf0e10cSrcweir     return (MENU_COMMAND) aPopup.Execute( this, rPos );
394cdf0e10cSrcweir }
395cdf0e10cSrcweir 
396cdf0e10cSrcweir //------------------------------------------------------------------------------
397cdf0e10cSrcweir void ExtBoxWithBtns_Impl::MouseButtonDown( const MouseEvent& rMEvt )
398cdf0e10cSrcweir {
399cdf0e10cSrcweir     if ( m_bInterfaceLocked )
400cdf0e10cSrcweir         return;
401cdf0e10cSrcweir 
402cdf0e10cSrcweir     const Point aMousePos( rMEvt.GetPosPixel() );
403cdf0e10cSrcweir     const long nPos = PointToPos( aMousePos );
404cdf0e10cSrcweir 
405cdf0e10cSrcweir     if ( rMEvt.IsRight() )
406cdf0e10cSrcweir     {
407cdf0e10cSrcweir         switch( ShowPopupMenu( aMousePos, nPos ) )
408cdf0e10cSrcweir         {
409cdf0e10cSrcweir             case CMD_NONE:      break;
410cdf0e10cSrcweir             case CMD_ENABLE:    m_pParent->enablePackage( GetEntryData( nPos )->m_xPackage, true );
411cdf0e10cSrcweir                                 break;
412cdf0e10cSrcweir             case CMD_DISABLE:   m_pParent->enablePackage( GetEntryData( nPos )->m_xPackage, false );
413cdf0e10cSrcweir                                 break;
414cdf0e10cSrcweir             case CMD_UPDATE:    m_pParent->updatePackage( GetEntryData( nPos )->m_xPackage );
415cdf0e10cSrcweir                                 break;
416cdf0e10cSrcweir             case CMD_REMOVE:    m_pParent->removePackage( GetEntryData( nPos )->m_xPackage );
417cdf0e10cSrcweir                                 break;
418cdf0e10cSrcweir             case CMD_SHOW_LICENSE:
419cdf0e10cSrcweir                 {
420cdf0e10cSrcweir                     ShowLicenseDialog aLicenseDlg( m_pParent, GetEntryData( nPos )->m_xPackage );
421cdf0e10cSrcweir                     aLicenseDlg.Execute();
422cdf0e10cSrcweir                     break;
423cdf0e10cSrcweir                 }
424cdf0e10cSrcweir         }
425cdf0e10cSrcweir     }
426cdf0e10cSrcweir     else if ( rMEvt.IsLeft() )
427cdf0e10cSrcweir     {
428cdf0e10cSrcweir         if ( rMEvt.IsMod1() && HasActive() )
429cdf0e10cSrcweir             selectEntry( EXTENSION_LISTBOX_ENTRY_NOTFOUND );   // Selecting an not existing entry will deselect the current one
430cdf0e10cSrcweir         else
431cdf0e10cSrcweir             selectEntry( nPos );
432cdf0e10cSrcweir     }
433cdf0e10cSrcweir }
434cdf0e10cSrcweir 
435cdf0e10cSrcweir //------------------------------------------------------------------------------
436cdf0e10cSrcweir long ExtBoxWithBtns_Impl::Notify( NotifyEvent& rNEvt )
437cdf0e10cSrcweir {
438cdf0e10cSrcweir     bool bHandled = false;
439cdf0e10cSrcweir 
440cdf0e10cSrcweir     if ( rNEvt.GetType() == EVENT_KEYINPUT )
441cdf0e10cSrcweir     {
442cdf0e10cSrcweir         const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
443cdf0e10cSrcweir         KeyCode         aKeyCode = pKEvt->GetKeyCode();
444cdf0e10cSrcweir         sal_uInt16          nKeyCode = aKeyCode.GetCode();
445cdf0e10cSrcweir 
446cdf0e10cSrcweir         if ( nKeyCode == KEY_TAB )
447cdf0e10cSrcweir             bHandled = HandleTabKey( aKeyCode.IsShift() );
448cdf0e10cSrcweir     }
449cdf0e10cSrcweir 
450cdf0e10cSrcweir     if ( !bHandled )
451cdf0e10cSrcweir         return ExtensionBox_Impl::Notify( rNEvt );
452cdf0e10cSrcweir     else
453cdf0e10cSrcweir         return true;
454cdf0e10cSrcweir }
455cdf0e10cSrcweir 
456cdf0e10cSrcweir //------------------------------------------------------------------------------
457cdf0e10cSrcweir void ExtBoxWithBtns_Impl::enableButtons( bool bEnable )
458cdf0e10cSrcweir {
459cdf0e10cSrcweir     m_bInterfaceLocked = ! bEnable;
460cdf0e10cSrcweir 
461cdf0e10cSrcweir     if ( bEnable )
462cdf0e10cSrcweir     {
463cdf0e10cSrcweir         sal_Int32 nIndex = getSelIndex();
464cdf0e10cSrcweir         if ( nIndex != EXTENSION_LISTBOX_ENTRY_NOTFOUND )
465cdf0e10cSrcweir             SetButtonStatus( GetEntryData( nIndex ) );
466cdf0e10cSrcweir     }
467cdf0e10cSrcweir     else
468cdf0e10cSrcweir     {
469cdf0e10cSrcweir         m_pOptionsBtn->Enable( false );
470cdf0e10cSrcweir         m_pRemoveBtn->Enable( false );
471cdf0e10cSrcweir         m_pEnableBtn->Enable( false );
472cdf0e10cSrcweir     }
473cdf0e10cSrcweir }
474cdf0e10cSrcweir 
475cdf0e10cSrcweir // -----------------------------------------------------------------------
476cdf0e10cSrcweir IMPL_LINK( ExtBoxWithBtns_Impl, ScrollHdl, ScrollBar*, pScrBar )
477cdf0e10cSrcweir {
478cdf0e10cSrcweir     long nDelta = pScrBar->GetDelta();
479cdf0e10cSrcweir 
480cdf0e10cSrcweir     Point aNewOptPt( m_pOptionsBtn->GetPosPixel() - Point( 0, nDelta ) );
481cdf0e10cSrcweir     Point aNewRemPt( m_pRemoveBtn->GetPosPixel() - Point( 0, nDelta ) );
482cdf0e10cSrcweir     Point aNewEnPt( m_pEnableBtn->GetPosPixel() - Point( 0, nDelta ) );
483cdf0e10cSrcweir 
484cdf0e10cSrcweir     DoScroll( nDelta );
485cdf0e10cSrcweir 
486cdf0e10cSrcweir     m_pOptionsBtn->SetPosPixel( aNewOptPt );
487cdf0e10cSrcweir     m_pRemoveBtn->SetPosPixel( aNewRemPt );
488cdf0e10cSrcweir     m_pEnableBtn->SetPosPixel( aNewEnPt );
489cdf0e10cSrcweir 
490cdf0e10cSrcweir     return 1;
491cdf0e10cSrcweir }
492cdf0e10cSrcweir 
493cdf0e10cSrcweir // -----------------------------------------------------------------------
494cdf0e10cSrcweir IMPL_LINK( ExtBoxWithBtns_Impl, HandleOptionsBtn, void*, EMPTYARG )
495cdf0e10cSrcweir {
496cdf0e10cSrcweir     const sal_Int32 nActive = getSelIndex();
497cdf0e10cSrcweir 
498cdf0e10cSrcweir     if ( nActive != EXTENSION_LISTBOX_ENTRY_NOTFOUND )
499cdf0e10cSrcweir     {
500cdf0e10cSrcweir         SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
501cdf0e10cSrcweir 
502cdf0e10cSrcweir         if ( pFact )
503cdf0e10cSrcweir         {
504cdf0e10cSrcweir             OUString sExtensionId = GetEntryData( nActive )->m_xPackage->getIdentifier().Value;
505cdf0e10cSrcweir             VclAbstractDialog* pDlg = pFact->CreateOptionsDialog( this, sExtensionId, rtl::OUString() );
506cdf0e10cSrcweir 
507cdf0e10cSrcweir             pDlg->Execute();
508cdf0e10cSrcweir 
509cdf0e10cSrcweir             delete pDlg;
510cdf0e10cSrcweir         }
511cdf0e10cSrcweir     }
512cdf0e10cSrcweir 
513cdf0e10cSrcweir     return 1;
514cdf0e10cSrcweir }
515cdf0e10cSrcweir 
516cdf0e10cSrcweir // -----------------------------------------------------------------------
517cdf0e10cSrcweir IMPL_LINK( ExtBoxWithBtns_Impl, HandleEnableBtn, void*, EMPTYARG )
518cdf0e10cSrcweir {
519cdf0e10cSrcweir     const sal_Int32 nActive = getSelIndex();
520cdf0e10cSrcweir 
521cdf0e10cSrcweir     if ( nActive != EXTENSION_LISTBOX_ENTRY_NOTFOUND )
522cdf0e10cSrcweir     {
523cdf0e10cSrcweir         TEntry_Impl pEntry = GetEntryData( nActive );
524cdf0e10cSrcweir 
525cdf0e10cSrcweir         if ( pEntry->m_bMissingLic )
526cdf0e10cSrcweir             m_pParent->acceptLicense( pEntry->m_xPackage );
527cdf0e10cSrcweir         else
528cdf0e10cSrcweir         {
529cdf0e10cSrcweir             const bool bEnable( pEntry->m_eState != REGISTERED );
530cdf0e10cSrcweir             m_pParent->enablePackage( pEntry->m_xPackage, bEnable );
531cdf0e10cSrcweir         }
532cdf0e10cSrcweir     }
533cdf0e10cSrcweir 
534cdf0e10cSrcweir     return 1;
535cdf0e10cSrcweir }
536cdf0e10cSrcweir 
537cdf0e10cSrcweir // -----------------------------------------------------------------------
538cdf0e10cSrcweir IMPL_LINK( ExtBoxWithBtns_Impl, HandleRemoveBtn, void*, EMPTYARG )
539cdf0e10cSrcweir {
540cdf0e10cSrcweir     const sal_Int32 nActive = getSelIndex();
541cdf0e10cSrcweir 
542cdf0e10cSrcweir     if ( nActive != EXTENSION_LISTBOX_ENTRY_NOTFOUND )
543cdf0e10cSrcweir     {
544cdf0e10cSrcweir         TEntry_Impl pEntry = GetEntryData( nActive );
545cdf0e10cSrcweir         m_pParent->removePackage( pEntry->m_xPackage );
546cdf0e10cSrcweir     }
547cdf0e10cSrcweir 
548cdf0e10cSrcweir     return 1;
549cdf0e10cSrcweir }
550cdf0e10cSrcweir 
551cdf0e10cSrcweir //------------------------------------------------------------------------------
552cdf0e10cSrcweir //                             DialogHelper
553cdf0e10cSrcweir //------------------------------------------------------------------------------
554cdf0e10cSrcweir DialogHelper::DialogHelper( const uno::Reference< uno::XComponentContext > &xContext,
555cdf0e10cSrcweir                             Dialog *pWindow ) :
556cdf0e10cSrcweir     m_pVCLWindow( pWindow ),
557cdf0e10cSrcweir     m_nEventID(   0 ),
558cdf0e10cSrcweir     m_bIsBusy(    false )
559cdf0e10cSrcweir {
560cdf0e10cSrcweir     m_xContext = xContext;
561cdf0e10cSrcweir }
562cdf0e10cSrcweir 
563cdf0e10cSrcweir //------------------------------------------------------------------------------
564cdf0e10cSrcweir DialogHelper::~DialogHelper()
565cdf0e10cSrcweir {
566cdf0e10cSrcweir     if ( m_nEventID )
567cdf0e10cSrcweir         Application::RemoveUserEvent( m_nEventID );
568cdf0e10cSrcweir }
569cdf0e10cSrcweir 
570cdf0e10cSrcweir //------------------------------------------------------------------------------
571cdf0e10cSrcweir ResId DialogHelper::getResId( sal_uInt16 nId )
572cdf0e10cSrcweir {
573cdf0e10cSrcweir     const ::vos::OGuard guard( Application::GetSolarMutex() );
574cdf0e10cSrcweir     return ResId( nId, *DeploymentGuiResMgr::get() );
575cdf0e10cSrcweir }
576cdf0e10cSrcweir 
577cdf0e10cSrcweir //------------------------------------------------------------------------------
578cdf0e10cSrcweir String DialogHelper::getResourceString( sal_uInt16 id )
579cdf0e10cSrcweir {
580cdf0e10cSrcweir     // init with non-acquired solar mutex:
581cdf0e10cSrcweir     BrandName::get();
582cdf0e10cSrcweir     const ::vos::OGuard guard( Application::GetSolarMutex() );
583cdf0e10cSrcweir     String ret( ResId( id, *DeploymentGuiResMgr::get() ) );
584cdf0e10cSrcweir     if (ret.SearchAscii( "%PRODUCTNAME" ) != STRING_NOTFOUND) {
585cdf0e10cSrcweir         ret.SearchAndReplaceAllAscii( "%PRODUCTNAME", BrandName::get() );
586cdf0e10cSrcweir     }
587cdf0e10cSrcweir     return ret;
588cdf0e10cSrcweir }
589cdf0e10cSrcweir 
590cdf0e10cSrcweir //------------------------------------------------------------------------------
591cdf0e10cSrcweir bool DialogHelper::IsSharedPkgMgr( const uno::Reference< deployment::XPackage > &xPackage )
592cdf0e10cSrcweir {
593cdf0e10cSrcweir     if ( xPackage->getRepositoryName().equals( OUSTR("shared") ) )
594cdf0e10cSrcweir         return true;
595cdf0e10cSrcweir     else
596cdf0e10cSrcweir         return false;
597cdf0e10cSrcweir }
598cdf0e10cSrcweir 
599cdf0e10cSrcweir //------------------------------------------------------------------------------
600cdf0e10cSrcweir bool DialogHelper::continueOnSharedExtension( const uno::Reference< deployment::XPackage > &xPackage,
601cdf0e10cSrcweir                                               Window *pParent,
602cdf0e10cSrcweir                                               const sal_uInt16 nResID,
603cdf0e10cSrcweir                                               bool &bHadWarning )
604cdf0e10cSrcweir {
605cdf0e10cSrcweir     if ( !bHadWarning && IsSharedPkgMgr( xPackage ) )
606cdf0e10cSrcweir     {
607cdf0e10cSrcweir         const ::vos::OGuard guard( Application::GetSolarMutex() );
608cdf0e10cSrcweir         WarningBox aInfoBox( pParent, getResId( nResID ) );
609cdf0e10cSrcweir         String aMsgText = aInfoBox.GetMessText();
610cdf0e10cSrcweir         aMsgText.SearchAndReplaceAllAscii( "%PRODUCTNAME", BrandName::get() );
611cdf0e10cSrcweir         aInfoBox.SetMessText( aMsgText );
612cdf0e10cSrcweir 
613cdf0e10cSrcweir         bHadWarning = true;
614cdf0e10cSrcweir 
615cdf0e10cSrcweir         if ( RET_OK == aInfoBox.Execute() )
616cdf0e10cSrcweir             return true;
617cdf0e10cSrcweir         else
618cdf0e10cSrcweir             return false;
619cdf0e10cSrcweir     }
620cdf0e10cSrcweir     else
621cdf0e10cSrcweir         return true;
622cdf0e10cSrcweir }
623cdf0e10cSrcweir 
624cdf0e10cSrcweir //------------------------------------------------------------------------------
625cdf0e10cSrcweir void DialogHelper::openWebBrowser( const OUString & sURL, const OUString &sTitle ) const
626cdf0e10cSrcweir {
627cdf0e10cSrcweir     if ( ! sURL.getLength() ) // Nothing to do, when the URL is empty
628cdf0e10cSrcweir         return;
629cdf0e10cSrcweir 
630cdf0e10cSrcweir     try
631cdf0e10cSrcweir     {
632cdf0e10cSrcweir         uno::Reference< XSystemShellExecute > xSystemShellExecute(
633cdf0e10cSrcweir             m_xContext->getServiceManager()->createInstanceWithContext( OUSTR( "com.sun.star.system.SystemShellExecute" ), m_xContext), uno::UNO_QUERY_THROW);
634cdf0e10cSrcweir         //throws css::lang::IllegalArgumentException, css::system::SystemShellExecuteException
635cdf0e10cSrcweir         xSystemShellExecute->execute( sURL, OUString(),  SystemShellExecuteFlags::DEFAULTS );
636cdf0e10cSrcweir     }
637cdf0e10cSrcweir     catch ( uno::Exception& )
638cdf0e10cSrcweir     {
639cdf0e10cSrcweir         uno::Any exc( ::cppu::getCaughtException() );
640cdf0e10cSrcweir         OUString msg( ::comphelper::anyToString( exc ) );
641cdf0e10cSrcweir         const ::vos::OGuard guard( Application::GetSolarMutex() );
642cdf0e10cSrcweir         ErrorBox aErrorBox( NULL, WB_OK, msg );
643cdf0e10cSrcweir         aErrorBox.SetText( sTitle );
644cdf0e10cSrcweir         aErrorBox.Execute();
645cdf0e10cSrcweir     }
646cdf0e10cSrcweir }
647cdf0e10cSrcweir 
648cdf0e10cSrcweir //------------------------------------------------------------------------------
649cdf0e10cSrcweir bool DialogHelper::installExtensionWarn( const OUString &rExtensionName ) const
650cdf0e10cSrcweir {
651cdf0e10cSrcweir     const ::vos::OGuard guard( Application::GetSolarMutex() );
652cdf0e10cSrcweir     WarningBox aInfo( m_pVCLWindow, getResId( RID_WARNINGBOX_INSTALL_EXTENSION ) );
653cdf0e10cSrcweir 
654cdf0e10cSrcweir     String sText( aInfo.GetMessText() );
655cdf0e10cSrcweir     sText.SearchAndReplaceAllAscii( "%NAME", rExtensionName );
656cdf0e10cSrcweir     aInfo.SetMessText( sText );
657cdf0e10cSrcweir 
658cdf0e10cSrcweir     return ( RET_OK == aInfo.Execute() );
659cdf0e10cSrcweir }
660cdf0e10cSrcweir 
661cdf0e10cSrcweir //------------------------------------------------------------------------------
662cdf0e10cSrcweir bool DialogHelper::installForAllUsers( bool &bInstallForAll ) const
663cdf0e10cSrcweir {
664cdf0e10cSrcweir     const ::vos::OGuard guard( Application::GetSolarMutex() );
665cdf0e10cSrcweir     QueryBox aQuery( m_pVCLWindow, getResId( RID_QUERYBOX_INSTALL_FOR_ALL ) );
666cdf0e10cSrcweir 
667cdf0e10cSrcweir     String sMsgText = aQuery.GetMessText();
668cdf0e10cSrcweir     sMsgText.SearchAndReplaceAllAscii( "%PRODUCTNAME", BrandName::get() );
669cdf0e10cSrcweir     aQuery.SetMessText( sMsgText );
670cdf0e10cSrcweir 
671cdf0e10cSrcweir     sal_uInt16 nYesBtnID = aQuery.GetButtonId( 0 );
672cdf0e10cSrcweir     sal_uInt16 nNoBtnID = aQuery.GetButtonId( 1 );
673cdf0e10cSrcweir 
674cdf0e10cSrcweir     if ( nYesBtnID != BUTTONDIALOG_BUTTON_NOTFOUND )
675cdf0e10cSrcweir         aQuery.SetButtonText( nYesBtnID, getResourceString( RID_STR_INSTALL_FOR_ME ) );
676cdf0e10cSrcweir     if ( nNoBtnID != BUTTONDIALOG_BUTTON_NOTFOUND )
677cdf0e10cSrcweir         aQuery.SetButtonText( nNoBtnID, getResourceString( RID_STR_INSTALL_FOR_ALL ) );
678cdf0e10cSrcweir 
679cdf0e10cSrcweir     short nRet = aQuery.Execute();
680cdf0e10cSrcweir 
681cdf0e10cSrcweir     if ( nRet == RET_CANCEL )
682cdf0e10cSrcweir         return false;
683cdf0e10cSrcweir 
684cdf0e10cSrcweir     bInstallForAll = ( nRet == RET_NO );
685cdf0e10cSrcweir     return true;
686cdf0e10cSrcweir }
687cdf0e10cSrcweir 
688cdf0e10cSrcweir //------------------------------------------------------------------------------
689cdf0e10cSrcweir void DialogHelper::PostUserEvent( const Link& rLink, void* pCaller )
690cdf0e10cSrcweir {
691cdf0e10cSrcweir     if ( m_nEventID )
692cdf0e10cSrcweir         Application::RemoveUserEvent( m_nEventID );
693cdf0e10cSrcweir 
694cdf0e10cSrcweir     m_nEventID = Application::PostUserEvent( rLink, pCaller );
695cdf0e10cSrcweir }
696cdf0e10cSrcweir 
697cdf0e10cSrcweir //------------------------------------------------------------------------------
698cdf0e10cSrcweir //                             ExtMgrDialog
699cdf0e10cSrcweir //------------------------------------------------------------------------------
700cdf0e10cSrcweir ExtMgrDialog::ExtMgrDialog( Window *pParent, TheExtensionManager *pManager ) :
701cdf0e10cSrcweir     ModelessDialog( pParent, getResId( RID_DLG_EXTENSION_MANAGER ) ),
702cdf0e10cSrcweir     DialogHelper( pManager->getContext(), (Dialog*) this ),
703cdf0e10cSrcweir     m_aAddBtn( this,        getResId( RID_EM_BTN_ADD ) ),
704cdf0e10cSrcweir     m_aUpdateBtn( this,     getResId( RID_EM_BTN_CHECK_UPDATES ) ),
705cdf0e10cSrcweir     m_aCloseBtn( this,      getResId( RID_EM_BTN_CLOSE ) ),
706cdf0e10cSrcweir     m_aHelpBtn( this,       getResId( RID_EM_BTN_HELP ) ),
707cdf0e10cSrcweir     m_aDivider( this ),
708cdf0e10cSrcweir     m_aGetExtensions( this, getResId( RID_EM_FT_GET_EXTENSIONS ) ),
709cdf0e10cSrcweir     m_aProgressText( this,  getResId( RID_EM_FT_PROGRESS ) ),
710cdf0e10cSrcweir     m_aProgressBar( this,   WB_BORDER + WB_3DLOOK ),
711cdf0e10cSrcweir     m_aCancelBtn( this,     getResId( RID_EM_BTN_CANCEL ) ),
712cdf0e10cSrcweir     m_sAddPackages(         getResourceString( RID_STR_ADD_PACKAGES ) ),
713cdf0e10cSrcweir     m_bHasProgress(         false ),
714cdf0e10cSrcweir     m_bProgressChanged(     false ),
715cdf0e10cSrcweir     m_bStartProgress(       false ),
716cdf0e10cSrcweir     m_bStopProgress(        false ),
717cdf0e10cSrcweir     m_bUpdateWarning(       false ),
718cdf0e10cSrcweir     m_bEnableWarning(       false ),
719cdf0e10cSrcweir     m_bDisableWarning(      false ),
720cdf0e10cSrcweir     m_bDeleteWarning(       false ),
721cdf0e10cSrcweir     m_nProgress(            0 ),
722cdf0e10cSrcweir     m_pManager( pManager )
723cdf0e10cSrcweir {
724cdf0e10cSrcweir     // free local resources (RID < 256):
725cdf0e10cSrcweir     FreeResource();
726cdf0e10cSrcweir 
727cdf0e10cSrcweir     m_pExtensionBox = new ExtBoxWithBtns_Impl( this, pManager );
728cdf0e10cSrcweir     m_pExtensionBox->SetHyperlinkHdl( LINK( this, ExtMgrDialog, HandleHyperlink ) );
729cdf0e10cSrcweir 
730cdf0e10cSrcweir     m_aAddBtn.SetClickHdl( LINK( this, ExtMgrDialog, HandleAddBtn ) );
731cdf0e10cSrcweir     m_aUpdateBtn.SetClickHdl( LINK( this, ExtMgrDialog, HandleUpdateBtn ) );
732cdf0e10cSrcweir     m_aGetExtensions.SetClickHdl( LINK( this, ExtMgrDialog, HandleHyperlink ) );
733cdf0e10cSrcweir     m_aCancelBtn.SetClickHdl( LINK( this, ExtMgrDialog, HandleCancelBtn ) );
734cdf0e10cSrcweir 
735cdf0e10cSrcweir     // resize update button
736cdf0e10cSrcweir     Size aBtnSize = m_aUpdateBtn.GetSizePixel();
737cdf0e10cSrcweir     String sTitle = m_aUpdateBtn.GetText();
738cdf0e10cSrcweir     long nWidth = m_aUpdateBtn.GetCtrlTextWidth( sTitle );
739cdf0e10cSrcweir     nWidth += 2 * m_aUpdateBtn.GetTextHeight();
740cdf0e10cSrcweir     if ( nWidth > aBtnSize.Width() )
741cdf0e10cSrcweir         m_aUpdateBtn.SetSizePixel( Size( nWidth, aBtnSize.Height() ) );
742cdf0e10cSrcweir 
743cdf0e10cSrcweir     // minimum size:
744cdf0e10cSrcweir     SetMinOutputSizePixel(
745cdf0e10cSrcweir         Size( // width:
746cdf0e10cSrcweir               (3 * m_aHelpBtn.GetSizePixel().Width()) +
747cdf0e10cSrcweir                    m_aUpdateBtn.GetSizePixel().Width() +
748cdf0e10cSrcweir               (5 * RSC_SP_DLG_INNERBORDER_LEFT ),
749cdf0e10cSrcweir               // height:
750cdf0e10cSrcweir               (1 * m_aHelpBtn.GetSizePixel().Height()) +
751cdf0e10cSrcweir               (1 * m_aGetExtensions.GetSizePixel().Height()) +
752cdf0e10cSrcweir               (1 * m_pExtensionBox->GetMinOutputSizePixel().Height()) +
753cdf0e10cSrcweir               (3 * RSC_SP_DLG_INNERBORDER_LEFT) ) );
754cdf0e10cSrcweir 
755cdf0e10cSrcweir     m_aDivider.Show();
756cdf0e10cSrcweir     m_aProgressBar.Hide();
757cdf0e10cSrcweir 
758cdf0e10cSrcweir     m_aUpdateBtn.Enable( false );
759cdf0e10cSrcweir 
760cdf0e10cSrcweir     m_aTimeoutTimer.SetTimeout( 500 ); // mSec
761cdf0e10cSrcweir     m_aTimeoutTimer.SetTimeoutHdl( LINK( this, ExtMgrDialog, TimeOutHdl ) );
762cdf0e10cSrcweir }
763cdf0e10cSrcweir 
764cdf0e10cSrcweir //------------------------------------------------------------------------------
765cdf0e10cSrcweir ExtMgrDialog::~ExtMgrDialog()
766cdf0e10cSrcweir {
767cdf0e10cSrcweir     m_aTimeoutTimer.Stop();
768cdf0e10cSrcweir     delete m_pExtensionBox;
769cdf0e10cSrcweir }
770cdf0e10cSrcweir 
771cdf0e10cSrcweir //------------------------------------------------------------------------------
772cdf0e10cSrcweir void ExtMgrDialog::setGetExtensionsURL( const ::rtl::OUString &rURL )
773cdf0e10cSrcweir {
774cdf0e10cSrcweir     m_aGetExtensions.SetURL( rURL );
775cdf0e10cSrcweir }
776cdf0e10cSrcweir 
777cdf0e10cSrcweir //------------------------------------------------------------------------------
778cdf0e10cSrcweir long ExtMgrDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage,
779cdf0e10cSrcweir                                      bool bLicenseMissing )
780cdf0e10cSrcweir {
781cdf0e10cSrcweir     m_aUpdateBtn.Enable( true );
782cdf0e10cSrcweir     return m_pExtensionBox->addEntry( xPackage, bLicenseMissing );
783cdf0e10cSrcweir }
784cdf0e10cSrcweir 
785cdf0e10cSrcweir //------------------------------------------------------------------------------
786cdf0e10cSrcweir void ExtMgrDialog::prepareChecking()
787cdf0e10cSrcweir {
788cdf0e10cSrcweir     m_pExtensionBox->prepareChecking();
789cdf0e10cSrcweir }
790cdf0e10cSrcweir 
791cdf0e10cSrcweir //------------------------------------------------------------------------------
792cdf0e10cSrcweir void ExtMgrDialog::checkEntries()
793cdf0e10cSrcweir {
794cdf0e10cSrcweir     const ::vos::OGuard guard( Application::GetSolarMutex() );
795cdf0e10cSrcweir     m_pExtensionBox->checkEntries();
796cdf0e10cSrcweir }
797cdf0e10cSrcweir 
798cdf0e10cSrcweir //------------------------------------------------------------------------------
799cdf0e10cSrcweir bool ExtMgrDialog::removeExtensionWarn( const OUString &rExtensionName ) const
800cdf0e10cSrcweir {
801cdf0e10cSrcweir     const ::vos::OGuard guard( Application::GetSolarMutex() );
802cdf0e10cSrcweir     WarningBox aInfo( const_cast< ExtMgrDialog* >(this), getResId( RID_WARNINGBOX_REMOVE_EXTENSION ) );
803cdf0e10cSrcweir 
804cdf0e10cSrcweir     String sText( aInfo.GetMessText() );
805cdf0e10cSrcweir     sText.SearchAndReplaceAllAscii( "%NAME", rExtensionName );
806cdf0e10cSrcweir     aInfo.SetMessText( sText );
807cdf0e10cSrcweir 
808cdf0e10cSrcweir     return ( RET_OK == aInfo.Execute() );
809cdf0e10cSrcweir }
810cdf0e10cSrcweir 
811cdf0e10cSrcweir //------------------------------------------------------------------------------
812cdf0e10cSrcweir bool ExtMgrDialog::enablePackage( const uno::Reference< deployment::XPackage > &xPackage,
813cdf0e10cSrcweir                                   bool bEnable )
814cdf0e10cSrcweir {
815cdf0e10cSrcweir     if ( !xPackage.is() )
816cdf0e10cSrcweir         return false;
817cdf0e10cSrcweir 
818cdf0e10cSrcweir     if ( bEnable )
819cdf0e10cSrcweir     {
820cdf0e10cSrcweir         if ( ! continueOnSharedExtension( xPackage, this, RID_WARNINGBOX_ENABLE_SHARED_EXTENSION, m_bEnableWarning ) )
821cdf0e10cSrcweir             return false;
822cdf0e10cSrcweir     }
823cdf0e10cSrcweir     else
824cdf0e10cSrcweir     {
825cdf0e10cSrcweir         if ( ! continueOnSharedExtension( xPackage, this, RID_WARNINGBOX_DISABLE_SHARED_EXTENSION, m_bDisableWarning ) )
826cdf0e10cSrcweir             return false;
827cdf0e10cSrcweir     }
828cdf0e10cSrcweir 
829cdf0e10cSrcweir     m_pManager->getCmdQueue()->enableExtension( xPackage, bEnable );
830cdf0e10cSrcweir 
831cdf0e10cSrcweir     return true;
832cdf0e10cSrcweir }
833cdf0e10cSrcweir 
834cdf0e10cSrcweir //------------------------------------------------------------------------------
835cdf0e10cSrcweir bool ExtMgrDialog::removePackage( const uno::Reference< deployment::XPackage > &xPackage )
836cdf0e10cSrcweir {
837cdf0e10cSrcweir     if ( !xPackage.is() )
838cdf0e10cSrcweir         return false;
839cdf0e10cSrcweir 
840cdf0e10cSrcweir     if ( !IsSharedPkgMgr( xPackage ) || m_bDeleteWarning )
841cdf0e10cSrcweir     {
842cdf0e10cSrcweir         if ( ! removeExtensionWarn( xPackage->getDisplayName() ) )
843cdf0e10cSrcweir             return false;
844cdf0e10cSrcweir     }
845cdf0e10cSrcweir 
846cdf0e10cSrcweir     if ( ! continueOnSharedExtension( xPackage, this, RID_WARNINGBOX_REMOVE_SHARED_EXTENSION, m_bDeleteWarning ) )
847cdf0e10cSrcweir         return false;
848cdf0e10cSrcweir 
849cdf0e10cSrcweir     m_pManager->getCmdQueue()->removeExtension( xPackage );
850cdf0e10cSrcweir 
851cdf0e10cSrcweir     return true;
852cdf0e10cSrcweir }
853cdf0e10cSrcweir 
854cdf0e10cSrcweir //------------------------------------------------------------------------------
855cdf0e10cSrcweir bool ExtMgrDialog::updatePackage( const uno::Reference< deployment::XPackage > &xPackage )
856cdf0e10cSrcweir {
857cdf0e10cSrcweir     if ( !xPackage.is() )
858cdf0e10cSrcweir         return false;
859cdf0e10cSrcweir 
860cdf0e10cSrcweir 	// get the extension with highest version
861cdf0e10cSrcweir 	uno::Sequence<uno::Reference<deployment::XPackage> > seqExtensions =
862cdf0e10cSrcweir 	m_pManager->getExtensionManager()->getExtensionsWithSameIdentifier(
863cdf0e10cSrcweir 		dp_misc::getIdentifier(xPackage), xPackage->getName(), uno::Reference<ucb::XCommandEnvironment>());
864cdf0e10cSrcweir 	uno::Reference<deployment::XPackage> extension =
865cdf0e10cSrcweir 		dp_misc::getExtensionWithHighestVersion(seqExtensions);
866cdf0e10cSrcweir 	OSL_ASSERT(extension.is());
867cdf0e10cSrcweir     std::vector< css::uno::Reference< css::deployment::XPackage > > vEntries;
868cdf0e10cSrcweir     vEntries.push_back(extension);
869cdf0e10cSrcweir 
870cdf0e10cSrcweir     m_pManager->getCmdQueue()->checkForUpdates( vEntries );
871cdf0e10cSrcweir 
872cdf0e10cSrcweir     return true;
873cdf0e10cSrcweir }
874cdf0e10cSrcweir 
875cdf0e10cSrcweir //------------------------------------------------------------------------------
876cdf0e10cSrcweir bool ExtMgrDialog::acceptLicense( const uno::Reference< deployment::XPackage > &xPackage )
877cdf0e10cSrcweir {
878cdf0e10cSrcweir     if ( !xPackage.is() )
879cdf0e10cSrcweir         return false;
880cdf0e10cSrcweir 
881cdf0e10cSrcweir     m_pManager->getCmdQueue()->acceptLicense( xPackage );
882cdf0e10cSrcweir 
883cdf0e10cSrcweir     return true;
884cdf0e10cSrcweir }
885cdf0e10cSrcweir 
886cdf0e10cSrcweir //------------------------------------------------------------------------------
887cdf0e10cSrcweir uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker()
888cdf0e10cSrcweir {
889cdf0e10cSrcweir     const uno::Any mode( static_cast< sal_Int16 >( ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE ) );
890cdf0e10cSrcweir     const uno::Reference< uno::XComponentContext > xContext( m_pManager->getContext() );
891cdf0e10cSrcweir     const uno::Reference< ui::dialogs::XFilePicker > xFilePicker(
892cdf0e10cSrcweir         xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
893cdf0e10cSrcweir             OUSTR("com.sun.star.ui.dialogs.FilePicker"),
894cdf0e10cSrcweir             uno::Sequence< uno::Any >( &mode, 1 ), xContext ), uno::UNO_QUERY_THROW );
895cdf0e10cSrcweir     xFilePicker->setTitle( m_sAddPackages );
896cdf0e10cSrcweir 
897cdf0e10cSrcweir     if ( m_sLastFolderURL.Len() )
898cdf0e10cSrcweir         xFilePicker->setDisplayDirectory( m_sLastFolderURL );
899cdf0e10cSrcweir 
900cdf0e10cSrcweir     // collect and set filter list:
901cdf0e10cSrcweir     typedef ::std::map< OUString, OUString > t_string2string;
902cdf0e10cSrcweir     t_string2string title2filter;
903cdf0e10cSrcweir     OUString sDefaultFilter( StrAllFiles::get() );
904cdf0e10cSrcweir 
905cdf0e10cSrcweir     const uno::Sequence< uno::Reference< deployment::XPackageTypeInfo > > packageTypes(
906cdf0e10cSrcweir         m_pManager->getExtensionManager()->getSupportedPackageTypes() );
907cdf0e10cSrcweir 
908cdf0e10cSrcweir     for ( sal_Int32 pos = 0; pos < packageTypes.getLength(); ++pos )
909cdf0e10cSrcweir     {
910cdf0e10cSrcweir         uno::Reference< deployment::XPackageTypeInfo > const & xPackageType = packageTypes[ pos ];
911cdf0e10cSrcweir         const OUString filter( xPackageType->getFileFilter() );
912cdf0e10cSrcweir         if (filter.getLength() > 0)
913cdf0e10cSrcweir         {
914cdf0e10cSrcweir             const OUString title( xPackageType->getShortDescription() );
915cdf0e10cSrcweir             const ::std::pair< t_string2string::iterator, bool > insertion(
916cdf0e10cSrcweir                 title2filter.insert( t_string2string::value_type( title, filter ) ) );
917cdf0e10cSrcweir             if ( ! insertion.second )
918cdf0e10cSrcweir             { // already existing, append extensions:
919cdf0e10cSrcweir                 ::rtl::OUStringBuffer buf;
920cdf0e10cSrcweir                 buf.append( insertion.first->second );
921cdf0e10cSrcweir                 buf.append( static_cast<sal_Unicode>(';') );
922cdf0e10cSrcweir                 buf.append( filter );
923cdf0e10cSrcweir                 insertion.first->second = buf.makeStringAndClear();
924cdf0e10cSrcweir             }
925cdf0e10cSrcweir             if ( xPackageType->getMediaType() == OUSTR( "application/vnd.sun.star.package-bundle" ) )
926cdf0e10cSrcweir                 sDefaultFilter = title;
927cdf0e10cSrcweir         }
928cdf0e10cSrcweir     }
929cdf0e10cSrcweir 
930cdf0e10cSrcweir     const uno::Reference< ui::dialogs::XFilterManager > xFilterManager( xFilePicker, uno::UNO_QUERY_THROW );
931cdf0e10cSrcweir     // All files at top:
932cdf0e10cSrcweir     xFilterManager->appendFilter( StrAllFiles::get(), OUSTR("*.*") );
933cdf0e10cSrcweir     // then supported ones:
934cdf0e10cSrcweir     t_string2string::const_iterator iPos( title2filter.begin() );
935cdf0e10cSrcweir     const t_string2string::const_iterator iEnd( title2filter.end() );
936cdf0e10cSrcweir     for ( ; iPos != iEnd; ++iPos ) {
937cdf0e10cSrcweir         try {
938cdf0e10cSrcweir             xFilterManager->appendFilter( iPos->first, iPos->second );
939cdf0e10cSrcweir         }
940cdf0e10cSrcweir         catch (lang::IllegalArgumentException & exc) {
941cdf0e10cSrcweir             OSL_ENSURE( 0, ::rtl::OUStringToOString(
942cdf0e10cSrcweir                             exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
943cdf0e10cSrcweir             (void) exc;
944cdf0e10cSrcweir         }
945cdf0e10cSrcweir     }
946cdf0e10cSrcweir     xFilterManager->setCurrentFilter( sDefaultFilter );
947cdf0e10cSrcweir 
948cdf0e10cSrcweir     if ( xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK )
949cdf0e10cSrcweir         return uno::Sequence<OUString>(); // cancelled
950cdf0e10cSrcweir 
951cdf0e10cSrcweir     m_sLastFolderURL = xFilePicker->getDisplayDirectory();
952cdf0e10cSrcweir     uno::Sequence< OUString > files( xFilePicker->getFiles() );
953cdf0e10cSrcweir     OSL_ASSERT( files.getLength() > 0 );
954cdf0e10cSrcweir     return files;
955cdf0e10cSrcweir }
956cdf0e10cSrcweir 
957cdf0e10cSrcweir //------------------------------------------------------------------------------
958cdf0e10cSrcweir IMPL_LINK( ExtMgrDialog, HandleCancelBtn, void*, EMPTYARG )
959cdf0e10cSrcweir {
960cdf0e10cSrcweir     // m_dialog->m_cmdEnv->m_aborted = true;
961cdf0e10cSrcweir     if ( m_xAbortChannel.is() )
962cdf0e10cSrcweir     {
963cdf0e10cSrcweir         try
964cdf0e10cSrcweir         {
965cdf0e10cSrcweir             m_xAbortChannel->sendAbort();
966cdf0e10cSrcweir         }
967cdf0e10cSrcweir         catch ( uno::RuntimeException & )
968cdf0e10cSrcweir         {
969cdf0e10cSrcweir             OSL_ENSURE( 0, "### unexpected RuntimeException!" );
970cdf0e10cSrcweir         }
971cdf0e10cSrcweir     }
972cdf0e10cSrcweir     return 1;
973cdf0e10cSrcweir }
974cdf0e10cSrcweir 
975cdf0e10cSrcweir // ------------------------------------------------------------------------------
976cdf0e10cSrcweir IMPL_LINK( ExtMgrDialog, startProgress, void*, _bLockInterface )
977cdf0e10cSrcweir {
978cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
979cdf0e10cSrcweir     bool bLockInterface = (bool) _bLockInterface;
980cdf0e10cSrcweir 
981cdf0e10cSrcweir     if ( m_bStartProgress && !m_bHasProgress )
982cdf0e10cSrcweir         m_aTimeoutTimer.Start();
983cdf0e10cSrcweir 
984cdf0e10cSrcweir     if ( m_bStopProgress )
985cdf0e10cSrcweir     {
986cdf0e10cSrcweir 		if ( m_aProgressBar.IsVisible() )
987cdf0e10cSrcweir 	        m_aProgressBar.SetValue( 100 );
988cdf0e10cSrcweir         m_xAbortChannel.clear();
989cdf0e10cSrcweir 
990cdf0e10cSrcweir         OSL_TRACE( " startProgress handler: stop\n" );
991cdf0e10cSrcweir     }
992cdf0e10cSrcweir     else
993cdf0e10cSrcweir     {
994cdf0e10cSrcweir         OSL_TRACE( " startProgress handler: start\n" );
995cdf0e10cSrcweir     }
996cdf0e10cSrcweir 
997cdf0e10cSrcweir     m_aCancelBtn.Enable( bLockInterface );
998cdf0e10cSrcweir     m_aAddBtn.Enable( !bLockInterface );
999cdf0e10cSrcweir     m_aUpdateBtn.Enable( !bLockInterface && m_pExtensionBox->getItemCount() );
1000cdf0e10cSrcweir     m_pExtensionBox->enableButtons( !bLockInterface );
1001cdf0e10cSrcweir 
1002cdf0e10cSrcweir     clearEventID();
1003cdf0e10cSrcweir 
1004cdf0e10cSrcweir     return 0;
1005cdf0e10cSrcweir }
1006cdf0e10cSrcweir 
1007cdf0e10cSrcweir // ------------------------------------------------------------------------------
1008cdf0e10cSrcweir void ExtMgrDialog::showProgress( bool _bStart )
1009cdf0e10cSrcweir {
1010cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
1011cdf0e10cSrcweir 
1012cdf0e10cSrcweir     bool bStart = _bStart;
1013cdf0e10cSrcweir 
1014cdf0e10cSrcweir     if ( bStart )
1015cdf0e10cSrcweir     {
1016cdf0e10cSrcweir         m_nProgress = 0;
1017cdf0e10cSrcweir         m_bStartProgress = true;
1018cdf0e10cSrcweir         OSL_TRACE( "showProgress start\n" );
1019cdf0e10cSrcweir     }
1020cdf0e10cSrcweir     else
1021cdf0e10cSrcweir     {
1022cdf0e10cSrcweir         m_nProgress = 100;
1023cdf0e10cSrcweir         m_bStopProgress = true;
1024cdf0e10cSrcweir         OSL_TRACE( "showProgress stop!\n" );
1025cdf0e10cSrcweir     }
1026cdf0e10cSrcweir 
1027cdf0e10cSrcweir     DialogHelper::PostUserEvent( LINK( this, ExtMgrDialog, startProgress ), (void*) bStart );
1028cdf0e10cSrcweir }
1029cdf0e10cSrcweir 
1030cdf0e10cSrcweir // -----------------------------------------------------------------------
1031cdf0e10cSrcweir void ExtMgrDialog::updateProgress( const long nProgress )
1032cdf0e10cSrcweir {
1033cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
1034cdf0e10cSrcweir 
1035cdf0e10cSrcweir     m_nProgress = nProgress;
1036cdf0e10cSrcweir }
1037cdf0e10cSrcweir 
1038cdf0e10cSrcweir // -----------------------------------------------------------------------
1039cdf0e10cSrcweir void ExtMgrDialog::updateProgress( const OUString &rText,
1040cdf0e10cSrcweir                                    const uno::Reference< task::XAbortChannel > &xAbortChannel)
1041cdf0e10cSrcweir {
1042cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
1043cdf0e10cSrcweir 
1044cdf0e10cSrcweir     m_xAbortChannel = xAbortChannel;
1045cdf0e10cSrcweir     m_sProgressText = rText;
1046cdf0e10cSrcweir     m_bProgressChanged = true;
1047cdf0e10cSrcweir }
1048cdf0e10cSrcweir 
1049cdf0e10cSrcweir //------------------------------------------------------------------------------
1050cdf0e10cSrcweir void ExtMgrDialog::updatePackageInfo( const uno::Reference< deployment::XPackage > &xPackage )
1051cdf0e10cSrcweir {
1052cdf0e10cSrcweir     m_pExtensionBox->updateEntry( xPackage );
1053cdf0e10cSrcweir }
1054cdf0e10cSrcweir 
1055cdf0e10cSrcweir // -----------------------------------------------------------------------
1056cdf0e10cSrcweir IMPL_LINK( ExtMgrDialog, HandleAddBtn, void*, EMPTYARG )
1057cdf0e10cSrcweir {
1058cdf0e10cSrcweir     setBusy( true );
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir     uno::Sequence< OUString > aFileList = raiseAddPicker();
1061cdf0e10cSrcweir 
1062cdf0e10cSrcweir     if ( aFileList.getLength() )
1063cdf0e10cSrcweir     {
1064cdf0e10cSrcweir         m_pManager->installPackage( aFileList[0] );
1065cdf0e10cSrcweir     }
1066cdf0e10cSrcweir 
1067cdf0e10cSrcweir     setBusy( false );
1068cdf0e10cSrcweir     return 1;
1069cdf0e10cSrcweir }
1070cdf0e10cSrcweir 
1071cdf0e10cSrcweir // -----------------------------------------------------------------------
1072cdf0e10cSrcweir IMPL_LINK( ExtMgrDialog, HandleUpdateBtn, void*, EMPTYARG )
1073cdf0e10cSrcweir {
1074cdf0e10cSrcweir     m_pManager->checkUpdates( false, true );
1075cdf0e10cSrcweir 
1076cdf0e10cSrcweir     return 1;
1077cdf0e10cSrcweir }
1078cdf0e10cSrcweir 
1079cdf0e10cSrcweir // -----------------------------------------------------------------------
1080cdf0e10cSrcweir IMPL_LINK( ExtMgrDialog, HandleHyperlink, svt::FixedHyperlink*, pHyperlink )
1081cdf0e10cSrcweir {
1082cdf0e10cSrcweir     openWebBrowser( pHyperlink->GetURL(), GetText() );
1083cdf0e10cSrcweir 
1084cdf0e10cSrcweir     return 1;
1085cdf0e10cSrcweir }
1086cdf0e10cSrcweir 
1087cdf0e10cSrcweir // -----------------------------------------------------------------------
1088cdf0e10cSrcweir IMPL_LINK( ExtMgrDialog, TimeOutHdl, Timer*, EMPTYARG )
1089cdf0e10cSrcweir {
1090cdf0e10cSrcweir     if ( m_bStopProgress )
1091cdf0e10cSrcweir     {
1092cdf0e10cSrcweir         m_bHasProgress = false;
1093cdf0e10cSrcweir         m_bStopProgress = false;
1094cdf0e10cSrcweir         m_aProgressText.Hide();
1095cdf0e10cSrcweir         m_aProgressBar.Hide();
1096cdf0e10cSrcweir         m_aCancelBtn.Hide();
1097cdf0e10cSrcweir     }
1098cdf0e10cSrcweir     else
1099cdf0e10cSrcweir     {
1100cdf0e10cSrcweir         if ( m_bProgressChanged )
1101cdf0e10cSrcweir         {
1102cdf0e10cSrcweir             m_bProgressChanged = false;
1103cdf0e10cSrcweir             m_aProgressText.SetText( m_sProgressText );
1104cdf0e10cSrcweir         }
1105cdf0e10cSrcweir 
1106cdf0e10cSrcweir         if ( m_bStartProgress )
1107cdf0e10cSrcweir         {
1108cdf0e10cSrcweir             m_bStartProgress = false;
1109cdf0e10cSrcweir             m_bHasProgress = true;
1110cdf0e10cSrcweir             m_aProgressBar.Show();
1111cdf0e10cSrcweir             m_aProgressText.Show();
1112cdf0e10cSrcweir             m_aCancelBtn.Enable();
1113cdf0e10cSrcweir             m_aCancelBtn.Show();
1114cdf0e10cSrcweir         }
1115cdf0e10cSrcweir 
1116cdf0e10cSrcweir 		if ( m_aProgressBar.IsVisible() )
1117cdf0e10cSrcweir 			m_aProgressBar.SetValue( (sal_uInt16) m_nProgress );
1118cdf0e10cSrcweir 
1119cdf0e10cSrcweir         m_aTimeoutTimer.Start();
1120cdf0e10cSrcweir     }
1121cdf0e10cSrcweir 
1122cdf0e10cSrcweir 	return 1;
1123cdf0e10cSrcweir }
1124cdf0e10cSrcweir 
1125cdf0e10cSrcweir //------------------------------------------------------------------------------
1126cdf0e10cSrcweir // VCL::Window / Dialog
1127cdf0e10cSrcweir void ExtMgrDialog::Resize()
1128cdf0e10cSrcweir {
1129cdf0e10cSrcweir     Size aTotalSize( GetOutputSizePixel() );
1130cdf0e10cSrcweir     Size aBtnSize( m_aHelpBtn.GetSizePixel() );
1131cdf0e10cSrcweir     Size aUpdBtnSize( m_aUpdateBtn.GetSizePixel() );
1132cdf0e10cSrcweir 
1133cdf0e10cSrcweir     Point aPos( RSC_SP_DLG_INNERBORDER_LEFT,
1134cdf0e10cSrcweir                 aTotalSize.Height() - RSC_SP_DLG_INNERBORDER_BOTTOM - aBtnSize.Height() );
1135cdf0e10cSrcweir 
1136cdf0e10cSrcweir     m_aHelpBtn.SetPosPixel( aPos );
1137cdf0e10cSrcweir 
1138cdf0e10cSrcweir     aPos.X() = aTotalSize.Width() - RSC_SP_DLG_INNERBORDER_RIGHT - aBtnSize.Width();
1139cdf0e10cSrcweir     m_aCloseBtn.SetPosPixel( aPos );
1140cdf0e10cSrcweir 
1141cdf0e10cSrcweir     aPos.X() -= ( RSC_SP_CTRL_X + aUpdBtnSize.Width() );
1142cdf0e10cSrcweir     m_aUpdateBtn.SetPosPixel( aPos );
1143cdf0e10cSrcweir 
1144cdf0e10cSrcweir     aPos.X() -= ( RSC_SP_CTRL_GROUP_Y + aBtnSize.Width() );
1145cdf0e10cSrcweir     m_aAddBtn.SetPosPixel( aPos );
1146cdf0e10cSrcweir 
1147cdf0e10cSrcweir     Size aDivSize( aTotalSize.Width(), LINE_SIZE );
1148cdf0e10cSrcweir     aPos = Point( 0, aPos.Y() - LINE_SIZE - RSC_SP_DLG_INNERBORDER_BOTTOM );
1149cdf0e10cSrcweir     m_aDivider.SetPosSizePixel( aPos, aDivSize );
1150cdf0e10cSrcweir 
1151cdf0e10cSrcweir     Size aFTSize( m_aGetExtensions.CalcMinimumSize() );
1152cdf0e10cSrcweir     aPos = Point( RSC_SP_DLG_INNERBORDER_LEFT, aPos.Y() - RSC_CD_FIXEDTEXT_HEIGHT - 2*RSC_SP_DLG_INNERBORDER_BOTTOM );
1153cdf0e10cSrcweir 
1154cdf0e10cSrcweir     m_aGetExtensions.SetPosSizePixel( aPos, aFTSize );
1155cdf0e10cSrcweir 
1156cdf0e10cSrcweir     aPos.X() = aTotalSize.Width() - RSC_SP_DLG_INNERBORDER_RIGHT - aBtnSize.Width();
1157cdf0e10cSrcweir     m_aCancelBtn.SetPosPixel( Point( aPos.X(), aPos.Y() - ((aBtnSize.Height()-aFTSize.Height())/2) ) );
1158cdf0e10cSrcweir 
1159cdf0e10cSrcweir     // Calc progress height
1160cdf0e10cSrcweir     long nProgressHeight = aFTSize.Height();
1161cdf0e10cSrcweir 
1162cdf0e10cSrcweir     if( IsNativeControlSupported( CTRL_PROGRESS, PART_ENTIRE_CONTROL ) )
1163cdf0e10cSrcweir     {
1164cdf0e10cSrcweir         ImplControlValue aValue;
1165cdf0e10cSrcweir         bool bNativeOK;
1166cdf0e10cSrcweir         Rectangle aControlRegion( Point( 0, 0 ), m_aProgressBar.GetSizePixel() );
1167cdf0e10cSrcweir         Rectangle aNativeControlRegion, aNativeContentRegion;
1168cdf0e10cSrcweir         if( (bNativeOK = GetNativeControlRegion( CTRL_PROGRESS, PART_ENTIRE_CONTROL, aControlRegion,
1169cdf0e10cSrcweir                                                  CTRL_STATE_ENABLED, aValue, rtl::OUString(),
1170cdf0e10cSrcweir                                                  aNativeControlRegion, aNativeContentRegion ) ) != sal_False )
1171cdf0e10cSrcweir         {
1172cdf0e10cSrcweir             nProgressHeight = aNativeControlRegion.GetHeight();
1173cdf0e10cSrcweir         }
1174cdf0e10cSrcweir     }
1175cdf0e10cSrcweir 
1176cdf0e10cSrcweir     if ( nProgressHeight < PROGRESS_HEIGHT )
1177cdf0e10cSrcweir         nProgressHeight = PROGRESS_HEIGHT;
1178cdf0e10cSrcweir 
1179cdf0e10cSrcweir     aPos.X() -= ( RSC_SP_CTRL_GROUP_Y + PROGRESS_WIDTH );
1180cdf0e10cSrcweir     m_aProgressBar.SetPosSizePixel( Point( aPos.X(), aPos.Y() - ((nProgressHeight-aFTSize.Height())/2) ),
1181cdf0e10cSrcweir                                     Size( PROGRESS_WIDTH, nProgressHeight ) );
1182cdf0e10cSrcweir 
1183cdf0e10cSrcweir     Rectangle aRect1( m_aGetExtensions.GetPosPixel(), m_aGetExtensions.GetSizePixel() );
1184cdf0e10cSrcweir     Rectangle aRect2( m_aProgressBar.GetPosPixel(), m_aProgressBar.GetSizePixel() );
1185cdf0e10cSrcweir 
1186cdf0e10cSrcweir     aFTSize.Width() = ( aRect2.Left() - aRect1.Right() ) - 2*RSC_SP_DLG_INNERBORDER_LEFT;
1187cdf0e10cSrcweir     aPos.X() = aRect1.Right() + RSC_SP_DLG_INNERBORDER_LEFT;
1188cdf0e10cSrcweir     m_aProgressText.SetPosSizePixel( aPos, aFTSize );
1189cdf0e10cSrcweir 
1190cdf0e10cSrcweir     Size aSize( aTotalSize.Width() - RSC_SP_DLG_INNERBORDER_LEFT - RSC_SP_DLG_INNERBORDER_RIGHT,
1191cdf0e10cSrcweir                 aTotalSize.Height() - 2*aBtnSize.Height() - LINE_SIZE -
1192cdf0e10cSrcweir                 RSC_SP_DLG_INNERBORDER_TOP - 3*RSC_SP_DLG_INNERBORDER_BOTTOM );
1193cdf0e10cSrcweir 
1194cdf0e10cSrcweir     m_pExtensionBox->SetSizePixel( aSize );
1195cdf0e10cSrcweir }
1196cdf0e10cSrcweir //------------------------------------------------------------------------------
1197cdf0e10cSrcweir // VCL::Window / Dialog
1198cdf0e10cSrcweir 
1199cdf0e10cSrcweir long ExtMgrDialog::Notify( NotifyEvent& rNEvt )
1200cdf0e10cSrcweir {
1201cdf0e10cSrcweir     bool bHandled = false;
1202cdf0e10cSrcweir 
1203cdf0e10cSrcweir     if ( rNEvt.GetType() == EVENT_KEYINPUT )
1204cdf0e10cSrcweir     {
1205cdf0e10cSrcweir         const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
1206cdf0e10cSrcweir         KeyCode         aKeyCode = pKEvt->GetKeyCode();
1207cdf0e10cSrcweir         sal_uInt16          nKeyCode = aKeyCode.GetCode();
1208cdf0e10cSrcweir 
1209cdf0e10cSrcweir         if ( nKeyCode == KEY_TAB )
1210cdf0e10cSrcweir         {
1211cdf0e10cSrcweir             if ( aKeyCode.IsShift() ) {
1212cdf0e10cSrcweir                 if ( m_aAddBtn.HasFocus() ) {
1213cdf0e10cSrcweir                     m_pExtensionBox->GrabFocus();
1214cdf0e10cSrcweir                     bHandled = true;
1215cdf0e10cSrcweir                 }
1216cdf0e10cSrcweir             } else {
1217cdf0e10cSrcweir                 if ( m_aGetExtensions.HasFocus() ) {
1218cdf0e10cSrcweir                     m_pExtensionBox->GrabFocus();
1219cdf0e10cSrcweir                     bHandled = true;
1220cdf0e10cSrcweir                 }
1221cdf0e10cSrcweir             }
1222cdf0e10cSrcweir         }
1223cdf0e10cSrcweir         if ( aKeyCode.GetGroup() == KEYGROUP_CURSOR )
1224cdf0e10cSrcweir             bHandled = m_pExtensionBox->Notify( rNEvt );
1225cdf0e10cSrcweir     }
1226cdf0e10cSrcweir // VCLEVENT_WINDOW_CLOSE
1227cdf0e10cSrcweir     if ( !bHandled )
1228cdf0e10cSrcweir         return ModelessDialog::Notify( rNEvt );
1229cdf0e10cSrcweir     else
1230cdf0e10cSrcweir         return true;
1231cdf0e10cSrcweir }
1232cdf0e10cSrcweir 
1233cdf0e10cSrcweir //------------------------------------------------------------------------------
1234cdf0e10cSrcweir sal_Bool ExtMgrDialog::Close()
1235cdf0e10cSrcweir {
1236cdf0e10cSrcweir     bool bRet = m_pManager->queryTermination();
1237cdf0e10cSrcweir     if ( bRet )
1238cdf0e10cSrcweir     {
1239cdf0e10cSrcweir         bRet = ModelessDialog::Close();
1240cdf0e10cSrcweir         m_pManager->terminateDialog();
1241cdf0e10cSrcweir     }
1242cdf0e10cSrcweir     return bRet;
1243cdf0e10cSrcweir }
1244cdf0e10cSrcweir 
1245cdf0e10cSrcweir //------------------------------------------------------------------------------
1246cdf0e10cSrcweir //                             UpdateRequiredDialog
1247cdf0e10cSrcweir //------------------------------------------------------------------------------
1248cdf0e10cSrcweir UpdateRequiredDialog::UpdateRequiredDialog( Window *pParent, TheExtensionManager *pManager ) :
1249cdf0e10cSrcweir     ModalDialog( pParent,   getResId( RID_DLG_UPDATE_REQUIRED ) ),
1250cdf0e10cSrcweir     DialogHelper( pManager->getContext(), (Dialog*) this ),
1251cdf0e10cSrcweir     m_aUpdateNeeded( this,  getResId( RID_EM_FT_MSG ) ),
1252cdf0e10cSrcweir     m_aUpdateBtn( this,     getResId( RID_EM_BTN_CHECK_UPDATES ) ),
1253cdf0e10cSrcweir     m_aCloseBtn( this,      getResId( RID_EM_BTN_CLOSE ) ),
1254cdf0e10cSrcweir     m_aHelpBtn( this,       getResId( RID_EM_BTN_HELP ) ),
1255cdf0e10cSrcweir     m_aCancelBtn( this,     getResId( RID_EM_BTN_CANCEL ) ),
1256cdf0e10cSrcweir     m_aDivider( this ),
1257cdf0e10cSrcweir     m_aProgressText( this,  getResId( RID_EM_FT_PROGRESS ) ),
1258cdf0e10cSrcweir     m_aProgressBar( this,   WB_BORDER + WB_3DLOOK ),
1259cdf0e10cSrcweir     m_sAddPackages(         getResourceString( RID_STR_ADD_PACKAGES ) ),
1260cdf0e10cSrcweir     m_sCloseText(           getResourceString( RID_STR_CLOSE_BTN ) ),
1261cdf0e10cSrcweir     m_bHasProgress(         false ),
1262cdf0e10cSrcweir     m_bProgressChanged(     false ),
1263cdf0e10cSrcweir     m_bStartProgress(       false ),
1264cdf0e10cSrcweir     m_bStopProgress(        false ),
1265cdf0e10cSrcweir     m_bUpdateWarning(       false ),
1266cdf0e10cSrcweir     m_bDisableWarning(      false ),
1267cdf0e10cSrcweir     m_bHasLockedEntries(    false ),
1268cdf0e10cSrcweir     m_nProgress(            0 ),
1269cdf0e10cSrcweir     m_pManager( pManager )
1270cdf0e10cSrcweir {
1271cdf0e10cSrcweir     // free local resources (RID < 256):
1272cdf0e10cSrcweir     FreeResource();
1273cdf0e10cSrcweir 
1274cdf0e10cSrcweir     m_pExtensionBox = new ExtensionBox_Impl( this, pManager );
1275cdf0e10cSrcweir     m_pExtensionBox->SetHyperlinkHdl( LINK( this, UpdateRequiredDialog, HandleHyperlink ) );
1276cdf0e10cSrcweir 
1277cdf0e10cSrcweir     m_aUpdateBtn.SetClickHdl( LINK( this, UpdateRequiredDialog, HandleUpdateBtn ) );
1278cdf0e10cSrcweir     m_aCloseBtn.SetClickHdl( LINK( this, UpdateRequiredDialog, HandleCloseBtn ) );
1279cdf0e10cSrcweir     m_aCancelBtn.SetClickHdl( LINK( this, UpdateRequiredDialog, HandleCancelBtn ) );
1280cdf0e10cSrcweir 
1281cdf0e10cSrcweir     String aText = m_aUpdateNeeded.GetText();
1282cdf0e10cSrcweir     aText.SearchAndReplaceAllAscii( "%PRODUCTNAME", BrandName::get() );
1283cdf0e10cSrcweir     m_aUpdateNeeded.SetText( aText );
1284cdf0e10cSrcweir 
1285cdf0e10cSrcweir     // resize update button
1286cdf0e10cSrcweir     Size aBtnSize = m_aUpdateBtn.GetSizePixel();
1287cdf0e10cSrcweir     String sTitle = m_aUpdateBtn.GetText();
1288cdf0e10cSrcweir     long nWidth = m_aUpdateBtn.GetCtrlTextWidth( sTitle );
1289cdf0e10cSrcweir     nWidth += 2 * m_aUpdateBtn.GetTextHeight();
1290cdf0e10cSrcweir     if ( nWidth > aBtnSize.Width() )
1291cdf0e10cSrcweir         m_aUpdateBtn.SetSizePixel( Size( nWidth, aBtnSize.Height() ) );
1292cdf0e10cSrcweir 
1293cdf0e10cSrcweir     // resize update button
1294cdf0e10cSrcweir     aBtnSize = m_aCloseBtn.GetSizePixel();
1295cdf0e10cSrcweir     sTitle = m_aCloseBtn.GetText();
1296cdf0e10cSrcweir     nWidth = m_aCloseBtn.GetCtrlTextWidth( sTitle );
1297cdf0e10cSrcweir     nWidth += 2 * m_aCloseBtn.GetTextHeight();
1298cdf0e10cSrcweir     if ( nWidth > aBtnSize.Width() )
1299cdf0e10cSrcweir         m_aCloseBtn.SetSizePixel( Size( nWidth, aBtnSize.Height() ) );
1300cdf0e10cSrcweir 
1301cdf0e10cSrcweir     // minimum size:
1302cdf0e10cSrcweir     SetMinOutputSizePixel(
1303cdf0e10cSrcweir         Size( // width:
1304cdf0e10cSrcweir               (5 * m_aHelpBtn.GetSizePixel().Width()) +
1305cdf0e10cSrcweir               (5 * RSC_SP_DLG_INNERBORDER_LEFT ),
1306cdf0e10cSrcweir               // height:
1307cdf0e10cSrcweir               (1 * m_aHelpBtn.GetSizePixel().Height()) +
1308cdf0e10cSrcweir               (1 * m_aUpdateNeeded.GetSizePixel().Height()) +
1309cdf0e10cSrcweir               (1 * m_pExtensionBox->GetMinOutputSizePixel().Height()) +
1310cdf0e10cSrcweir               (3 * RSC_SP_DLG_INNERBORDER_LEFT) ) );
1311cdf0e10cSrcweir 
1312cdf0e10cSrcweir     m_aDivider.Show();
1313cdf0e10cSrcweir     m_aProgressBar.Hide();
1314cdf0e10cSrcweir     m_aUpdateBtn.Enable( false );
1315cdf0e10cSrcweir     m_aCloseBtn.GrabFocus();
1316cdf0e10cSrcweir 
1317cdf0e10cSrcweir     m_aTimeoutTimer.SetTimeout( 50 ); // mSec
1318cdf0e10cSrcweir     m_aTimeoutTimer.SetTimeoutHdl( LINK( this, UpdateRequiredDialog, TimeOutHdl ) );
1319cdf0e10cSrcweir }
1320cdf0e10cSrcweir 
1321cdf0e10cSrcweir //------------------------------------------------------------------------------
1322cdf0e10cSrcweir UpdateRequiredDialog::~UpdateRequiredDialog()
1323cdf0e10cSrcweir {
1324cdf0e10cSrcweir     m_aTimeoutTimer.Stop();
1325cdf0e10cSrcweir 
1326cdf0e10cSrcweir     delete m_pExtensionBox;
1327cdf0e10cSrcweir }
1328cdf0e10cSrcweir 
1329cdf0e10cSrcweir //------------------------------------------------------------------------------
1330cdf0e10cSrcweir long UpdateRequiredDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage,
1331cdf0e10cSrcweir                                              bool bLicenseMissing )
1332cdf0e10cSrcweir {
1333cdf0e10cSrcweir     // We will only add entries to the list with unsatisfied dependencies
1334cdf0e10cSrcweir     if ( !bLicenseMissing && !checkDependencies( xPackage ) )
1335cdf0e10cSrcweir     {
1336cdf0e10cSrcweir         m_bHasLockedEntries |= m_pManager->isReadOnly( xPackage );
1337cdf0e10cSrcweir         m_aUpdateBtn.Enable( true );
1338cdf0e10cSrcweir         return m_pExtensionBox->addEntry( xPackage );
1339cdf0e10cSrcweir     }
1340cdf0e10cSrcweir     return 0;
1341cdf0e10cSrcweir }
1342cdf0e10cSrcweir 
1343cdf0e10cSrcweir //------------------------------------------------------------------------------
1344cdf0e10cSrcweir void UpdateRequiredDialog::prepareChecking()
1345cdf0e10cSrcweir {
1346cdf0e10cSrcweir     m_pExtensionBox->prepareChecking();
1347cdf0e10cSrcweir }
1348cdf0e10cSrcweir 
1349cdf0e10cSrcweir //------------------------------------------------------------------------------
1350cdf0e10cSrcweir void UpdateRequiredDialog::checkEntries()
1351cdf0e10cSrcweir {
1352cdf0e10cSrcweir     const ::vos::OGuard guard( Application::GetSolarMutex() );
1353cdf0e10cSrcweir     m_pExtensionBox->checkEntries();
1354cdf0e10cSrcweir 
1355cdf0e10cSrcweir     if ( ! hasActiveEntries() )
1356cdf0e10cSrcweir     {
1357cdf0e10cSrcweir         m_aCloseBtn.SetText( m_sCloseText );
1358cdf0e10cSrcweir         m_aCloseBtn.GrabFocus();
1359cdf0e10cSrcweir     }
1360cdf0e10cSrcweir }
1361cdf0e10cSrcweir 
1362cdf0e10cSrcweir //------------------------------------------------------------------------------
1363cdf0e10cSrcweir bool UpdateRequiredDialog::enablePackage( const uno::Reference< deployment::XPackage > &xPackage,
1364cdf0e10cSrcweir                                           bool bEnable )
1365cdf0e10cSrcweir {
1366cdf0e10cSrcweir     m_pManager->getCmdQueue()->enableExtension( xPackage, bEnable );
1367cdf0e10cSrcweir 
1368cdf0e10cSrcweir     return true;
1369cdf0e10cSrcweir }
1370cdf0e10cSrcweir 
1371cdf0e10cSrcweir //------------------------------------------------------------------------------
1372cdf0e10cSrcweir IMPL_LINK( UpdateRequiredDialog, HandleCancelBtn, void*, EMPTYARG )
1373cdf0e10cSrcweir {
1374cdf0e10cSrcweir     // m_dialog->m_cmdEnv->m_aborted = true;
1375cdf0e10cSrcweir     if ( m_xAbortChannel.is() )
1376cdf0e10cSrcweir     {
1377cdf0e10cSrcweir         try
1378cdf0e10cSrcweir         {
1379cdf0e10cSrcweir             m_xAbortChannel->sendAbort();
1380cdf0e10cSrcweir         }
1381cdf0e10cSrcweir         catch ( uno::RuntimeException & )
1382cdf0e10cSrcweir         {
1383cdf0e10cSrcweir             OSL_ENSURE( 0, "### unexpected RuntimeException!" );
1384cdf0e10cSrcweir         }
1385cdf0e10cSrcweir     }
1386cdf0e10cSrcweir     return 1;
1387cdf0e10cSrcweir }
1388cdf0e10cSrcweir 
1389cdf0e10cSrcweir // ------------------------------------------------------------------------------
1390cdf0e10cSrcweir IMPL_LINK( UpdateRequiredDialog, startProgress, void*, _bLockInterface )
1391cdf0e10cSrcweir {
1392cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
1393cdf0e10cSrcweir     bool bLockInterface = (bool) _bLockInterface;
1394cdf0e10cSrcweir 
1395cdf0e10cSrcweir     if ( m_bStartProgress && !m_bHasProgress )
1396cdf0e10cSrcweir         m_aTimeoutTimer.Start();
1397cdf0e10cSrcweir 
1398cdf0e10cSrcweir     if ( m_bStopProgress )
1399cdf0e10cSrcweir     {
1400cdf0e10cSrcweir 		if ( m_aProgressBar.IsVisible() )
1401cdf0e10cSrcweir 	        m_aProgressBar.SetValue( 100 );
1402cdf0e10cSrcweir         m_xAbortChannel.clear();
1403cdf0e10cSrcweir         OSL_TRACE( " startProgress handler: stop\n" );
1404cdf0e10cSrcweir     }
1405cdf0e10cSrcweir     else
1406cdf0e10cSrcweir     {
1407cdf0e10cSrcweir         OSL_TRACE( " startProgress handler: start\n" );
1408cdf0e10cSrcweir     }
1409cdf0e10cSrcweir 
1410cdf0e10cSrcweir     m_aCancelBtn.Enable( bLockInterface );
1411cdf0e10cSrcweir     m_aUpdateBtn.Enable( false );
1412cdf0e10cSrcweir     clearEventID();
1413cdf0e10cSrcweir 
1414cdf0e10cSrcweir     return 0;
1415cdf0e10cSrcweir }
1416cdf0e10cSrcweir 
1417cdf0e10cSrcweir // ------------------------------------------------------------------------------
1418cdf0e10cSrcweir void UpdateRequiredDialog::showProgress( bool _bStart )
1419cdf0e10cSrcweir {
1420cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
1421cdf0e10cSrcweir 
1422cdf0e10cSrcweir     bool bStart = _bStart;
1423cdf0e10cSrcweir 
1424cdf0e10cSrcweir     if ( bStart )
1425cdf0e10cSrcweir     {
1426cdf0e10cSrcweir         m_nProgress = 0;
1427cdf0e10cSrcweir         m_bStartProgress = true;
1428cdf0e10cSrcweir         OSL_TRACE( "showProgress start\n" );
1429cdf0e10cSrcweir     }
1430cdf0e10cSrcweir     else
1431cdf0e10cSrcweir     {
1432cdf0e10cSrcweir         m_nProgress = 100;
1433cdf0e10cSrcweir         m_bStopProgress = true;
1434cdf0e10cSrcweir         OSL_TRACE( "showProgress stop!\n" );
1435cdf0e10cSrcweir     }
1436cdf0e10cSrcweir 
1437cdf0e10cSrcweir     DialogHelper::PostUserEvent( LINK( this, UpdateRequiredDialog, startProgress ), (void*) bStart );
1438cdf0e10cSrcweir }
1439cdf0e10cSrcweir 
1440cdf0e10cSrcweir // -----------------------------------------------------------------------
1441cdf0e10cSrcweir void UpdateRequiredDialog::updateProgress( const long nProgress )
1442cdf0e10cSrcweir {
1443cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
1444cdf0e10cSrcweir 
1445cdf0e10cSrcweir     m_nProgress = nProgress;
1446cdf0e10cSrcweir }
1447cdf0e10cSrcweir 
1448cdf0e10cSrcweir // -----------------------------------------------------------------------
1449cdf0e10cSrcweir void UpdateRequiredDialog::updateProgress( const OUString &rText,
1450cdf0e10cSrcweir                                            const uno::Reference< task::XAbortChannel > &xAbortChannel)
1451cdf0e10cSrcweir {
1452cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
1453cdf0e10cSrcweir 
1454cdf0e10cSrcweir     m_xAbortChannel = xAbortChannel;
1455cdf0e10cSrcweir     m_sProgressText = rText;
1456cdf0e10cSrcweir     m_bProgressChanged = true;
1457cdf0e10cSrcweir }
1458cdf0e10cSrcweir 
1459cdf0e10cSrcweir //------------------------------------------------------------------------------
1460cdf0e10cSrcweir void UpdateRequiredDialog::updatePackageInfo( const uno::Reference< deployment::XPackage > &xPackage )
1461cdf0e10cSrcweir {
1462cdf0e10cSrcweir     // We will remove all updated packages with satisfied dependencies, but
1463cdf0e10cSrcweir     // we will show all disabled entries so the user sees the result
1464cdf0e10cSrcweir     // of the 'disable all' button
1465cdf0e10cSrcweir     if ( isEnabled( xPackage ) && checkDependencies( xPackage ) )
1466cdf0e10cSrcweir         m_pExtensionBox->removeEntry( xPackage );
1467cdf0e10cSrcweir     else
1468cdf0e10cSrcweir         m_pExtensionBox->updateEntry( xPackage );
1469cdf0e10cSrcweir 
1470cdf0e10cSrcweir     if ( ! hasActiveEntries() )
1471cdf0e10cSrcweir     {
1472cdf0e10cSrcweir         m_aCloseBtn.SetText( m_sCloseText );
1473cdf0e10cSrcweir         m_aCloseBtn.GrabFocus();
1474cdf0e10cSrcweir     }
1475cdf0e10cSrcweir }
1476cdf0e10cSrcweir 
1477cdf0e10cSrcweir // -----------------------------------------------------------------------
1478cdf0e10cSrcweir IMPL_LINK( UpdateRequiredDialog, HandleUpdateBtn, void*, EMPTYARG )
1479cdf0e10cSrcweir {
1480cdf0e10cSrcweir     ::osl::ClearableMutexGuard aGuard( m_aMutex );
1481cdf0e10cSrcweir 
1482cdf0e10cSrcweir     std::vector< uno::Reference< deployment::XPackage > > vUpdateEntries;
1483cdf0e10cSrcweir     sal_Int32 nCount = m_pExtensionBox->GetEntryCount();
1484cdf0e10cSrcweir 
1485cdf0e10cSrcweir     for ( sal_Int32 i = 0; i < nCount; ++i )
1486cdf0e10cSrcweir     {
1487cdf0e10cSrcweir         TEntry_Impl pEntry = m_pExtensionBox->GetEntryData( i );
1488cdf0e10cSrcweir         vUpdateEntries.push_back( pEntry->m_xPackage );
1489cdf0e10cSrcweir     }
1490cdf0e10cSrcweir 
1491cdf0e10cSrcweir     aGuard.clear();
1492cdf0e10cSrcweir 
1493cdf0e10cSrcweir     m_pManager->getCmdQueue()->checkForUpdates( vUpdateEntries );
1494cdf0e10cSrcweir 
1495cdf0e10cSrcweir     return 1;
1496cdf0e10cSrcweir }
1497cdf0e10cSrcweir 
1498cdf0e10cSrcweir // -----------------------------------------------------------------------
1499cdf0e10cSrcweir IMPL_LINK( UpdateRequiredDialog, HandleCloseBtn, void*, EMPTYARG )
1500cdf0e10cSrcweir {
1501cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
1502cdf0e10cSrcweir 
1503cdf0e10cSrcweir     if ( !isBusy() )
1504cdf0e10cSrcweir     {
1505cdf0e10cSrcweir         if ( m_bHasLockedEntries )
1506cdf0e10cSrcweir             EndDialog( -1 );
1507cdf0e10cSrcweir         else if ( hasActiveEntries() )
1508cdf0e10cSrcweir             disableAllEntries();
1509cdf0e10cSrcweir         else
1510cdf0e10cSrcweir             EndDialog( 0 );
1511cdf0e10cSrcweir     }
1512cdf0e10cSrcweir 
1513cdf0e10cSrcweir     return 1;
1514cdf0e10cSrcweir }
1515cdf0e10cSrcweir 
1516cdf0e10cSrcweir // -----------------------------------------------------------------------
1517cdf0e10cSrcweir IMPL_LINK( UpdateRequiredDialog, HandleHyperlink, svt::FixedHyperlink*, pHyperlink )
1518cdf0e10cSrcweir {
1519cdf0e10cSrcweir     openWebBrowser( pHyperlink->GetURL(), GetText() );
1520cdf0e10cSrcweir 
1521cdf0e10cSrcweir     return 1;
1522cdf0e10cSrcweir }
1523cdf0e10cSrcweir 
1524cdf0e10cSrcweir // -----------------------------------------------------------------------
1525cdf0e10cSrcweir IMPL_LINK( UpdateRequiredDialog, TimeOutHdl, Timer*, EMPTYARG )
1526cdf0e10cSrcweir {
1527cdf0e10cSrcweir     if ( m_bStopProgress )
1528cdf0e10cSrcweir     {
1529cdf0e10cSrcweir         m_bHasProgress = false;
1530cdf0e10cSrcweir         m_bStopProgress = false;
1531cdf0e10cSrcweir         m_aProgressText.Hide();
1532cdf0e10cSrcweir         m_aProgressBar.Hide();
1533cdf0e10cSrcweir         m_aCancelBtn.Hide();
1534cdf0e10cSrcweir     }
1535cdf0e10cSrcweir     else
1536cdf0e10cSrcweir     {
1537cdf0e10cSrcweir         if ( m_bProgressChanged )
1538cdf0e10cSrcweir         {
1539cdf0e10cSrcweir             m_bProgressChanged = false;
1540cdf0e10cSrcweir             m_aProgressText.SetText( m_sProgressText );
1541cdf0e10cSrcweir         }
1542cdf0e10cSrcweir 
1543cdf0e10cSrcweir         if ( m_bStartProgress )
1544cdf0e10cSrcweir         {
1545cdf0e10cSrcweir             m_bStartProgress = false;
1546cdf0e10cSrcweir             m_bHasProgress = true;
1547cdf0e10cSrcweir             m_aProgressBar.Show();
1548cdf0e10cSrcweir             m_aProgressText.Show();
1549cdf0e10cSrcweir             m_aCancelBtn.Enable();
1550cdf0e10cSrcweir             m_aCancelBtn.Show();
1551cdf0e10cSrcweir         }
1552cdf0e10cSrcweir 
1553cdf0e10cSrcweir 		if ( m_aProgressBar.IsVisible() )
1554cdf0e10cSrcweir 			m_aProgressBar.SetValue( (sal_uInt16) m_nProgress );
1555cdf0e10cSrcweir 
1556cdf0e10cSrcweir         m_aTimeoutTimer.Start();
1557cdf0e10cSrcweir     }
1558cdf0e10cSrcweir 
1559cdf0e10cSrcweir 	return 1;
1560cdf0e10cSrcweir }
1561cdf0e10cSrcweir 
1562cdf0e10cSrcweir //------------------------------------------------------------------------------
1563cdf0e10cSrcweir // VCL::Window / Dialog
1564cdf0e10cSrcweir void UpdateRequiredDialog::Resize()
1565cdf0e10cSrcweir {
1566cdf0e10cSrcweir     Size aTotalSize( GetOutputSizePixel() );
1567cdf0e10cSrcweir     Size aBtnSize( m_aHelpBtn.GetSizePixel() );
1568cdf0e10cSrcweir 
1569cdf0e10cSrcweir     Point aPos( RSC_SP_DLG_INNERBORDER_LEFT,
1570cdf0e10cSrcweir                 aTotalSize.Height() - RSC_SP_DLG_INNERBORDER_BOTTOM - aBtnSize.Height() );
1571cdf0e10cSrcweir 
1572cdf0e10cSrcweir     m_aHelpBtn.SetPosPixel( aPos );
1573cdf0e10cSrcweir 
1574cdf0e10cSrcweir     aPos.X() = aTotalSize.Width() - RSC_SP_DLG_INNERBORDER_RIGHT - m_aCloseBtn.GetSizePixel().Width();
1575cdf0e10cSrcweir     m_aCloseBtn.SetPosPixel( aPos );
1576cdf0e10cSrcweir 
1577cdf0e10cSrcweir     aPos.X() -= ( RSC_SP_CTRL_X + m_aUpdateBtn.GetSizePixel().Width() );
1578cdf0e10cSrcweir     m_aUpdateBtn.SetPosPixel( aPos );
1579cdf0e10cSrcweir 
1580cdf0e10cSrcweir     Size aDivSize( aTotalSize.Width(), LINE_SIZE );
1581cdf0e10cSrcweir     aPos = Point( 0, aPos.Y() - LINE_SIZE - RSC_SP_DLG_INNERBORDER_BOTTOM );
1582cdf0e10cSrcweir     m_aDivider.SetPosSizePixel( aPos, aDivSize );
1583cdf0e10cSrcweir 
1584cdf0e10cSrcweir     // Calc fixed text size
1585cdf0e10cSrcweir     aPos = Point( RSC_SP_DLG_INNERBORDER_LEFT, RSC_SP_DLG_INNERBORDER_TOP );
1586cdf0e10cSrcweir     Size aFTSize = m_aUpdateNeeded.CalcMinimumSize( aTotalSize.Width() - RSC_SP_DLG_INNERBORDER_RIGHT - RSC_SP_DLG_INNERBORDER_LEFT );
1587cdf0e10cSrcweir     m_aUpdateNeeded.SetPosSizePixel( aPos, aFTSize );
1588cdf0e10cSrcweir 
1589cdf0e10cSrcweir     // Calc list box size
1590cdf0e10cSrcweir     Size aSize( aTotalSize.Width() - RSC_SP_DLG_INNERBORDER_LEFT - RSC_SP_DLG_INNERBORDER_RIGHT,
1591cdf0e10cSrcweir                 aTotalSize.Height() - 2*aBtnSize.Height() - LINE_SIZE -
1592cdf0e10cSrcweir                 2*RSC_SP_DLG_INNERBORDER_TOP - 3*RSC_SP_DLG_INNERBORDER_BOTTOM - aFTSize.Height() );
1593cdf0e10cSrcweir     aPos.Y() += aFTSize.Height()+RSC_SP_DLG_INNERBORDER_TOP;
1594cdf0e10cSrcweir 
1595cdf0e10cSrcweir     m_pExtensionBox->SetPosSizePixel( aPos, aSize );
1596cdf0e10cSrcweir 
1597cdf0e10cSrcweir     aPos.X() = aTotalSize.Width() - RSC_SP_DLG_INNERBORDER_RIGHT - aBtnSize.Width();
1598cdf0e10cSrcweir     aPos.Y() += aSize.Height()+RSC_SP_DLG_INNERBORDER_TOP;
1599cdf0e10cSrcweir     m_aCancelBtn.SetPosPixel( aPos );
1600cdf0e10cSrcweir 
1601cdf0e10cSrcweir     // Calc progress height
1602cdf0e10cSrcweir     aFTSize = m_aProgressText.GetSizePixel();
1603cdf0e10cSrcweir     long nProgressHeight = aFTSize.Height();
1604cdf0e10cSrcweir 
1605cdf0e10cSrcweir     if( IsNativeControlSupported( CTRL_PROGRESS, PART_ENTIRE_CONTROL ) )
1606cdf0e10cSrcweir     {
1607cdf0e10cSrcweir         ImplControlValue aValue;
1608cdf0e10cSrcweir         bool bNativeOK;
1609cdf0e10cSrcweir         Rectangle aControlRegion( Point( 0, 0 ), m_aProgressBar.GetSizePixel() );
1610cdf0e10cSrcweir         Rectangle aNativeControlRegion, aNativeContentRegion;
1611cdf0e10cSrcweir         if( (bNativeOK = GetNativeControlRegion( CTRL_PROGRESS, PART_ENTIRE_CONTROL, aControlRegion,
1612cdf0e10cSrcweir                                                  CTRL_STATE_ENABLED, aValue, rtl::OUString(),
1613cdf0e10cSrcweir                                                  aNativeControlRegion, aNativeContentRegion ) ) != sal_False )
1614cdf0e10cSrcweir         {
1615cdf0e10cSrcweir             nProgressHeight = aNativeControlRegion.GetHeight();
1616cdf0e10cSrcweir         }
1617cdf0e10cSrcweir     }
1618cdf0e10cSrcweir 
1619cdf0e10cSrcweir     if ( nProgressHeight < PROGRESS_HEIGHT )
1620cdf0e10cSrcweir         nProgressHeight = PROGRESS_HEIGHT;
1621cdf0e10cSrcweir 
1622cdf0e10cSrcweir     aPos.X() -= ( RSC_SP_CTRL_GROUP_Y + PROGRESS_WIDTH );
1623cdf0e10cSrcweir     m_aProgressBar.SetPosSizePixel( Point( aPos.X(), aPos.Y() + ((aBtnSize.Height()-nProgressHeight)/2) ),
1624cdf0e10cSrcweir                                     Size( PROGRESS_WIDTH, nProgressHeight ) );
1625cdf0e10cSrcweir 
1626cdf0e10cSrcweir     aFTSize.Width() = aPos.X() - 2*RSC_SP_DLG_INNERBORDER_LEFT;
1627cdf0e10cSrcweir     aPos.X() = RSC_SP_DLG_INNERBORDER_LEFT;
1628cdf0e10cSrcweir     aPos.Y() += ( aBtnSize.Height() - aFTSize.Height() - 1 ) / 2;
1629cdf0e10cSrcweir     m_aProgressText.SetPosSizePixel( aPos, aFTSize );
1630cdf0e10cSrcweir }
1631cdf0e10cSrcweir 
1632cdf0e10cSrcweir //------------------------------------------------------------------------------
1633cdf0e10cSrcweir // VCL::Dialog
1634cdf0e10cSrcweir short UpdateRequiredDialog::Execute()
1635cdf0e10cSrcweir {
1636*8402cd44SMichael Stahl     //ToDo
1637*8402cd44SMichael Stahl     //I believe m_bHasLockedEntries was used to prevent showing extensions which cannot
1638*8402cd44SMichael Stahl     //be disabled because they are in a read only repository. However, disabling extensions
1639*8402cd44SMichael Stahl     //is now always possible because the registration data of all repositories
1640*8402cd44SMichael Stahl     //are in the user installation.
1641*8402cd44SMichael Stahl     //Therfore all extensions could be displayed and all the handling around m_bHasLockedEntries
1642*8402cd44SMichael Stahl     //could be removed.
1643cdf0e10cSrcweir     if ( m_bHasLockedEntries )
1644cdf0e10cSrcweir     {
1645cdf0e10cSrcweir         // Set other text, disable update btn, remove not shared entries from list;
1646cdf0e10cSrcweir         m_aUpdateNeeded.SetText( DialogHelper::getResourceString( RID_STR_NO_ADMIN_PRIVILEGE ) );
1647cdf0e10cSrcweir         m_aCloseBtn.SetText( DialogHelper::getResourceString( RID_STR_EXIT_BTN ) );
1648cdf0e10cSrcweir         m_aUpdateBtn.Enable( false );
1649cdf0e10cSrcweir         m_pExtensionBox->RemoveUnlocked();
1650cdf0e10cSrcweir         Resize();
1651cdf0e10cSrcweir     }
1652cdf0e10cSrcweir 
1653cdf0e10cSrcweir     return Dialog::Execute();
1654cdf0e10cSrcweir }
1655cdf0e10cSrcweir 
1656cdf0e10cSrcweir //------------------------------------------------------------------------------
1657cdf0e10cSrcweir // VCL::Dialog
1658cdf0e10cSrcweir sal_Bool UpdateRequiredDialog::Close()
1659cdf0e10cSrcweir {
1660cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
1661cdf0e10cSrcweir 
1662cdf0e10cSrcweir     if ( !isBusy() )
1663cdf0e10cSrcweir     {
1664cdf0e10cSrcweir         if ( m_bHasLockedEntries )
1665cdf0e10cSrcweir             EndDialog( -1 );
1666cdf0e10cSrcweir         else if ( hasActiveEntries() )
1667cdf0e10cSrcweir             disableAllEntries();
1668cdf0e10cSrcweir         else
1669cdf0e10cSrcweir             EndDialog( 0 );
1670cdf0e10cSrcweir     }
1671cdf0e10cSrcweir 
1672cdf0e10cSrcweir     return false;
1673cdf0e10cSrcweir }
1674cdf0e10cSrcweir 
1675cdf0e10cSrcweir //------------------------------------------------------------------------------
1676cdf0e10cSrcweir // Check dependencies of all packages
1677cdf0e10cSrcweir //------------------------------------------------------------------------------
1678cdf0e10cSrcweir bool UpdateRequiredDialog::isEnabled( const uno::Reference< deployment::XPackage > &xPackage ) const
1679cdf0e10cSrcweir {
1680cdf0e10cSrcweir     bool bRegistered = false;
1681cdf0e10cSrcweir     try {
1682cdf0e10cSrcweir         beans::Optional< beans::Ambiguous< sal_Bool > > option( xPackage->isRegistered( uno::Reference< task::XAbortChannel >(),
1683cdf0e10cSrcweir                                                                                         uno::Reference< ucb::XCommandEnvironment >() ) );
1684cdf0e10cSrcweir         if ( option.IsPresent )
1685cdf0e10cSrcweir         {
1686cdf0e10cSrcweir             ::beans::Ambiguous< sal_Bool > const & reg = option.Value;
1687cdf0e10cSrcweir             if ( reg.IsAmbiguous )
1688cdf0e10cSrcweir                 bRegistered = false;
1689cdf0e10cSrcweir             else
1690cdf0e10cSrcweir                 bRegistered = reg.Value ? true : false;
1691cdf0e10cSrcweir         }
1692cdf0e10cSrcweir         else
1693cdf0e10cSrcweir             bRegistered = false;
1694cdf0e10cSrcweir     }
1695cdf0e10cSrcweir     catch ( uno::RuntimeException & ) { throw; }
1696cdf0e10cSrcweir     catch ( uno::Exception & exc) {
1697cdf0e10cSrcweir         (void) exc;
1698cdf0e10cSrcweir         OSL_ENSURE( 0, ::rtl::OUStringToOString( exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
1699cdf0e10cSrcweir         bRegistered = false;
1700cdf0e10cSrcweir     }
1701cdf0e10cSrcweir 
1702cdf0e10cSrcweir     return bRegistered;
1703cdf0e10cSrcweir }
1704cdf0e10cSrcweir 
1705cdf0e10cSrcweir //------------------------------------------------------------------------------
1706*8402cd44SMichael Stahl //Checks the dependencies no matter if the extension is enabled or disabled!
1707cdf0e10cSrcweir bool UpdateRequiredDialog::checkDependencies( const uno::Reference< deployment::XPackage > &xPackage ) const
1708cdf0e10cSrcweir {
1709cdf0e10cSrcweir     bool bDependenciesValid = false;
1710cdf0e10cSrcweir     try {
1711cdf0e10cSrcweir         bDependenciesValid = xPackage->checkDependencies( uno::Reference< ucb::XCommandEnvironment >() );
1712cdf0e10cSrcweir     }
1713cdf0e10cSrcweir     catch ( deployment::DeploymentException & ) {}
1714*8402cd44SMichael Stahl     return bDependenciesValid;
1715cdf0e10cSrcweir }
1716cdf0e10cSrcweir 
1717cdf0e10cSrcweir //------------------------------------------------------------------------------
1718cdf0e10cSrcweir bool UpdateRequiredDialog::hasActiveEntries()
1719cdf0e10cSrcweir {
1720cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
1721cdf0e10cSrcweir 
1722cdf0e10cSrcweir     bool bRet = false;
1723cdf0e10cSrcweir     long nCount = m_pExtensionBox->GetEntryCount();
1724cdf0e10cSrcweir     for ( long nIndex = 0; nIndex < nCount; nIndex++ )
1725cdf0e10cSrcweir     {
1726cdf0e10cSrcweir         TEntry_Impl pEntry = m_pExtensionBox->GetEntryData( nIndex );
1727cdf0e10cSrcweir 
1728*8402cd44SMichael Stahl         if ( isEnabled(pEntry->m_xPackage) && !checkDependencies( pEntry->m_xPackage ) )
1729cdf0e10cSrcweir         {
1730cdf0e10cSrcweir             bRet = true;
1731cdf0e10cSrcweir             break;
1732cdf0e10cSrcweir         }
1733cdf0e10cSrcweir     }
1734cdf0e10cSrcweir 
1735cdf0e10cSrcweir     return bRet;
1736cdf0e10cSrcweir }
1737cdf0e10cSrcweir 
1738cdf0e10cSrcweir //------------------------------------------------------------------------------
1739cdf0e10cSrcweir void UpdateRequiredDialog::disableAllEntries()
1740cdf0e10cSrcweir {
1741cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
1742cdf0e10cSrcweir 
1743cdf0e10cSrcweir     setBusy( true );
1744cdf0e10cSrcweir 
1745cdf0e10cSrcweir     long nCount = m_pExtensionBox->GetEntryCount();
1746cdf0e10cSrcweir     for ( long nIndex = 0; nIndex < nCount; nIndex++ )
1747cdf0e10cSrcweir     {
1748cdf0e10cSrcweir         TEntry_Impl pEntry = m_pExtensionBox->GetEntryData( nIndex );
1749cdf0e10cSrcweir         enablePackage( pEntry->m_xPackage, false );
1750cdf0e10cSrcweir     }
1751cdf0e10cSrcweir 
1752cdf0e10cSrcweir     setBusy( false );
1753cdf0e10cSrcweir 
1754cdf0e10cSrcweir     if ( ! hasActiveEntries() )
1755cdf0e10cSrcweir         m_aCloseBtn.SetText( m_sCloseText );
1756cdf0e10cSrcweir }
1757cdf0e10cSrcweir 
1758cdf0e10cSrcweir //------------------------------------------------------------------------------
1759cdf0e10cSrcweir //                             ShowLicenseDialog
1760cdf0e10cSrcweir //------------------------------------------------------------------------------
1761cdf0e10cSrcweir ShowLicenseDialog::ShowLicenseDialog( Window * pParent,
1762cdf0e10cSrcweir                                       const uno::Reference< deployment::XPackage > &xPackage ) :
1763cdf0e10cSrcweir     ModalDialog( pParent, DialogHelper::getResId( RID_DLG_SHOW_LICENSE ) ),
1764cdf0e10cSrcweir     m_aLicenseText( this, DialogHelper::getResId( ML_LICENSE ) ),
1765cdf0e10cSrcweir     m_aCloseBtn( this,    DialogHelper::getResId( RID_EM_BTN_CLOSE ) )
1766cdf0e10cSrcweir {
1767cdf0e10cSrcweir     FreeResource();
1768cdf0e10cSrcweir 
1769cdf0e10cSrcweir     OUString aText = xPackage->getLicenseText();
1770cdf0e10cSrcweir     m_aLicenseText.SetText( aText );
1771cdf0e10cSrcweir }
1772cdf0e10cSrcweir 
1773cdf0e10cSrcweir //------------------------------------------------------------------------------
1774cdf0e10cSrcweir ShowLicenseDialog::~ShowLicenseDialog()
1775cdf0e10cSrcweir {}
1776cdf0e10cSrcweir 
1777cdf0e10cSrcweir //------------------------------------------------------------------------------
1778cdf0e10cSrcweir void ShowLicenseDialog::Resize()
1779cdf0e10cSrcweir {
1780cdf0e10cSrcweir     Size aTotalSize( GetOutputSizePixel() );
1781cdf0e10cSrcweir     Size aTextSize( aTotalSize.Width() - RSC_SP_DLG_INNERBORDER_LEFT - RSC_SP_DLG_INNERBORDER_RIGHT,
1782cdf0e10cSrcweir                     aTotalSize.Height() - RSC_SP_DLG_INNERBORDER_TOP - 2*RSC_SP_DLG_INNERBORDER_BOTTOM
1783cdf0e10cSrcweir                                         - m_aCloseBtn.GetSizePixel().Height() );
1784cdf0e10cSrcweir 
1785cdf0e10cSrcweir     m_aLicenseText.SetPosSizePixel( Point( RSC_SP_DLG_INNERBORDER_LEFT, RSC_SP_DLG_INNERBORDER_TOP ),
1786cdf0e10cSrcweir                                     aTextSize );
1787cdf0e10cSrcweir 
1788cdf0e10cSrcweir     Point aBtnPos( (aTotalSize.Width() - m_aCloseBtn.GetSizePixel().Width())/2,
1789cdf0e10cSrcweir                     aTotalSize.Height() - RSC_SP_DLG_INNERBORDER_BOTTOM
1790cdf0e10cSrcweir                                         - m_aCloseBtn.GetSizePixel().Height() );
1791cdf0e10cSrcweir     m_aCloseBtn.SetPosPixel( aBtnPos );
1792cdf0e10cSrcweir }
1793cdf0e10cSrcweir 
1794cdf0e10cSrcweir //=================================================================================
1795cdf0e10cSrcweir // UpdateRequiredDialogService
1796cdf0e10cSrcweir //=================================================================================
1797cdf0e10cSrcweir UpdateRequiredDialogService::UpdateRequiredDialogService( uno::Sequence< uno::Any > const&,
1798cdf0e10cSrcweir                                                           uno::Reference< uno::XComponentContext > const& xComponentContext )
1799cdf0e10cSrcweir     : m_xComponentContext( xComponentContext )
1800cdf0e10cSrcweir {
1801cdf0e10cSrcweir }
1802cdf0e10cSrcweir 
1803cdf0e10cSrcweir //------------------------------------------------------------------------------
1804cdf0e10cSrcweir // XExecutableDialog
1805cdf0e10cSrcweir //------------------------------------------------------------------------------
1806cdf0e10cSrcweir void UpdateRequiredDialogService::setTitle( OUString const & ) throw ( uno::RuntimeException )
1807cdf0e10cSrcweir {
1808cdf0e10cSrcweir }
1809cdf0e10cSrcweir 
1810cdf0e10cSrcweir //------------------------------------------------------------------------------
1811cdf0e10cSrcweir sal_Int16 UpdateRequiredDialogService::execute() throw ( uno::RuntimeException )
1812cdf0e10cSrcweir {
1813cdf0e10cSrcweir     ::rtl::Reference< ::dp_gui::TheExtensionManager > xManager( TheExtensionManager::get(
1814cdf0e10cSrcweir                                                               m_xComponentContext,
1815cdf0e10cSrcweir                                                               uno::Reference< awt::XWindow >(),
1816cdf0e10cSrcweir                                                               OUString() ) );
1817cdf0e10cSrcweir     xManager->createDialog( true );
1818cdf0e10cSrcweir     sal_Int16 nRet = xManager->execute();
1819cdf0e10cSrcweir 
1820cdf0e10cSrcweir     return nRet;
1821cdf0e10cSrcweir }
1822cdf0e10cSrcweir 
1823cdf0e10cSrcweir //------------------------------------------------------------------------------
1824cdf0e10cSrcweir //------------------------------------------------------------------------------
1825cdf0e10cSrcweir //------------------------------------------------------------------------------
1826cdf0e10cSrcweir SelectedPackage::~SelectedPackage() {}
1827cdf0e10cSrcweir 
1828cdf0e10cSrcweir } //namespace dp_gui
1829cdf0e10cSrcweir 
1830