LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/desktop/source/deployment/gui - dp_gui_dialog2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 818 0.0 %
Date: 2013-07-09 Functions: 0 111 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10