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