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