LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/cui/source/options - optjava.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 593 0.0 %
Date: 2013-07-09 Functions: 0 69 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 "optjava.hxx"
      21             : #include <dialmgr.hxx>
      22             : 
      23             : #include <svtools/miscopt.hxx>
      24             : 
      25             : #include "optjava.hrc"
      26             : #include <cuires.hrc>
      27             : #include "helpid.hrc"
      28             : #include <vcl/svapp.hxx>
      29             : #include <vcl/help.hxx>
      30             : #include <tools/urlobj.hxx>
      31             : #include <vcl/msgbox.hxx>
      32             : #include <vcl/waitobj.hxx>
      33             : #include <unotools/pathoptions.hxx>
      34             : #include <svtools/imagemgr.hxx>
      35             : #include "svtools/restartdialog.hxx"
      36             : #include "svtools/treelistentry.hxx"
      37             : #include <sfx2/filedlghelper.hxx>
      38             : #include <comphelper/processfactory.hxx>
      39             : #include <comphelper/string.hxx>
      40             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      41             : #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
      42             : #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
      43             : #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
      44             : #include <com/sun/star/ui/dialogs/FolderPicker.hpp>
      45             : #include <com/sun/star/ucb/XContentProvider.hpp>
      46             : #ifdef SOLAR_JAVA
      47             : #include <jvmfwk/framework.h>
      48             : #endif
      49             : 
      50             : // define ----------------------------------------------------------------
      51             : 
      52             : #define CLASSPATH_DELIMITER SAL_PATHSEPARATOR
      53             : #define BUTTON_BORDER       2
      54             : #define RESET_TIMEOUT       300
      55             : 
      56             : using namespace ::com::sun::star::lang;
      57             : using namespace ::com::sun::star::ucb;
      58             : using namespace ::com::sun::star::ui::dialogs;
      59             : using namespace ::com::sun::star::uno;
      60             : 
      61             : // -----------------------------------------------------------------------
      62             : 
      63           0 : bool areListsEqual( const Sequence< OUString >& rListA, const Sequence< OUString >& rListB )
      64             : {
      65           0 :     bool bRet = true;
      66           0 :     const sal_Int32 nLen = rListA.getLength();
      67             : 
      68           0 :     if (  rListB.getLength() != nLen )
      69           0 :         bRet = false;
      70             :     else
      71             :     {
      72           0 :         const OUString* pStringA = rListA.getConstArray();
      73           0 :         const OUString* pStringB = rListB.getConstArray();
      74             : 
      75           0 :         for ( sal_Int32 i = 0; i < nLen; ++i )
      76             :         {
      77           0 :             if ( *pStringA++ != *pStringB++ )
      78             :             {
      79           0 :                 bRet = false;
      80           0 :                 break;
      81             :             }
      82             :         }
      83             :     }
      84             : 
      85           0 :     return bRet;
      86             : }
      87             : 
      88           0 : class SvxJavaListBox : public svx::SvxRadioButtonListBox
      89             : {
      90             : private:
      91             :     const OUString m_sAccessibilityText;
      92             : public:
      93           0 :     SvxJavaListBox(SvxSimpleTableContainer& rParent, const OUString &rAccessibilityText)
      94             :         : SvxRadioButtonListBox(rParent, 0)
      95           0 :         , m_sAccessibilityText(rAccessibilityText)
      96             :     {
      97           0 :     }
      98           0 :     void setColSizes()
      99             :     {
     100           0 :         HeaderBar &rBar = GetTheHeaderBar();
     101           0 :         if (rBar.GetItemCount() < 4)
     102           0 :             return;
     103           0 :         long nCheckWidth = std::max(GetControlColumnWidth() + 12,
     104           0 :             rBar.LogicToPixel(Size(15, 0), MAP_APPFONT).Width());
     105           0 :         long nVersionWidth = 12 +
     106           0 :             std::max(rBar.GetTextWidth(rBar.GetItemText(3)),
     107           0 :             GetTextWidth(OUString("0.0.0_00-icedtea")));
     108           0 :         long nFeatureWidth = 12 +
     109           0 :             std::max(rBar.GetTextWidth(rBar.GetItemText(4)),
     110           0 :             GetTextWidth(m_sAccessibilityText));
     111             :         long nVendorWidth =
     112           0 :             std::max(GetSizePixel().Width() - (nCheckWidth + nVersionWidth + nFeatureWidth),
     113           0 :             6 + std::max(rBar.GetTextWidth(rBar.GetItemText(2)),
     114           0 :             GetTextWidth(OUString("Sun Microsystems Inc."))));
     115           0 :         long aStaticTabs[]= { 4, 0, 0, 0, 0, 0 };
     116           0 :         aStaticTabs[2] = nCheckWidth;
     117           0 :         aStaticTabs[3] = aStaticTabs[2] + nVendorWidth;
     118           0 :         aStaticTabs[4] = aStaticTabs[3] + nVersionWidth;
     119           0 :         SvxSimpleTable::SetTabs(aStaticTabs, MAP_PIXEL);
     120             :     }
     121           0 :     virtual void Resize()
     122             :     {
     123           0 :         svx::SvxRadioButtonListBox::Resize();
     124           0 :         setColSizes();
     125           0 :     }
     126             : };
     127             : 
     128             : // class SvxJavaOptionsPage ----------------------------------------------
     129             : 
     130           0 : SvxJavaOptionsPage::SvxJavaOptionsPage( Window* pParent, const SfxItemSet& rSet )
     131             :     : SfxTabPage(pParent, "OptAdvancedPage", "cui/ui/optadvancedpage.ui", rSet)
     132             :     , m_pParamDlg(NULL)
     133             :     , m_pPathDlg(NULL)
     134             : #ifdef SOLAR_JAVA
     135             :     , m_parJavaInfo(NULL)
     136             :     , m_parParameters(NULL)
     137             :     , m_pClassPath(NULL)
     138             :     , m_nInfoSize(0)
     139             :     , m_nParamSize(0)
     140             : #endif
     141           0 :     , xDialogListener(new ::svt::DialogClosedListener())
     142             : {
     143           0 :     get(m_pJavaEnableCB, "javaenabled");
     144           0 :     get(m_pJavaBox, "javabox");
     145           0 :     get(m_pJavaPathText, "javapath");
     146           0 :     m_sInstallText = m_pJavaPathText->GetText();
     147           0 :     get(m_pAddBtn, "add");
     148           0 :     get(m_pParameterBtn, "parameters");
     149           0 :     get(m_pClassPathBtn, "classpath");
     150           0 :     get(m_pExperimentalCB, "experimental");
     151           0 :     get(m_pExpSidebarCB, "exp_sidebar");
     152           0 :     get(m_pMacroCB, "macrorecording");
     153           0 :     m_sAccessibilityText = get<FixedText>("a11y")->GetText();
     154           0 :     m_sAddDialogText = get<FixedText>("selectruntime")->GetText();
     155             : 
     156           0 :     SvxSimpleTableContainer *pJavaListContainer = get<SvxSimpleTableContainer>("javas");
     157           0 :     Size aControlSize(177, 60);
     158           0 :     aControlSize = LogicToPixel(aControlSize, MAP_APPFONT);
     159           0 :     pJavaListContainer->set_width_request(aControlSize.Width());
     160           0 :     pJavaListContainer->set_height_request(aControlSize.Height());
     161           0 :     m_pJavaList = new SvxJavaListBox(*pJavaListContainer, m_sAccessibilityText);
     162             : 
     163           0 :     long aStaticTabs[]= { 4, 0, 0, 0, 0 };
     164             : 
     165           0 :     m_pJavaList->SvxSimpleTable::SetTabs( aStaticTabs );
     166             : 
     167           0 :     OUStringBuffer sHeader;
     168           0 :     sHeader.append("\t").append(get<FixedText>("vendor")->GetText())
     169           0 :         .append("\t").append(get<FixedText>("version")->GetText())
     170           0 :         .append("\t").append(get<FixedText>("features")->GetText())
     171           0 :         .append("\t");
     172           0 :     m_pJavaList->InsertHeaderEntry(sHeader.makeStringAndClear(), HEADERBAR_APPEND, HIB_LEFT);
     173           0 :     m_pJavaList->setColSizes();
     174             : 
     175           0 :     m_pJavaEnableCB->SetClickHdl( LINK( this, SvxJavaOptionsPage, EnableHdl_Impl ) );
     176           0 :     m_pJavaList->SetCheckButtonHdl( LINK( this, SvxJavaOptionsPage, CheckHdl_Impl ) );
     177           0 :     m_pJavaList->SetSelectHdl( LINK( this, SvxJavaOptionsPage, SelectHdl_Impl ) );
     178           0 :     m_pAddBtn->SetClickHdl( LINK( this, SvxJavaOptionsPage, AddHdl_Impl ) );
     179           0 :     m_pParameterBtn->SetClickHdl( LINK( this, SvxJavaOptionsPage, ParameterHdl_Impl ) );
     180           0 :     m_pClassPathBtn->SetClickHdl( LINK( this, SvxJavaOptionsPage, ClassPathHdl_Impl ) );
     181           0 :     m_aResetTimer.SetTimeoutHdl( LINK( this, SvxJavaOptionsPage, ResetHdl_Impl ) );
     182           0 :     m_aResetTimer.SetTimeout( RESET_TIMEOUT );
     183             : 
     184           0 :     xDialogListener->SetDialogClosedLink( LINK( this, SvxJavaOptionsPage, DialogClosedHdl ) );
     185             : 
     186           0 :     EnableHdl_Impl(m_pJavaEnableCB);
     187             : #ifdef SOLAR_JAVA
     188           0 :     jfw_lock();
     189             : #else
     190             :     get<Window>("javaframe")->Disable();
     191             : #endif
     192           0 : }
     193             : 
     194             : // -----------------------------------------------------------------------
     195             : 
     196           0 : SvxJavaOptionsPage::~SvxJavaOptionsPage()
     197             : {
     198           0 :     delete m_pJavaList;
     199           0 :     delete m_pParamDlg;
     200           0 :     delete m_pPathDlg;
     201           0 :     ClearJavaInfo();
     202             : #ifdef SOLAR_JAVA
     203           0 :     std::vector< JavaInfo* >::iterator pIter;
     204           0 :     for ( pIter = m_aAddedInfos.begin(); pIter != m_aAddedInfos.end(); ++pIter )
     205             :     {
     206           0 :         JavaInfo* pInfo = *pIter;
     207           0 :         jfw_freeJavaInfo( pInfo );
     208             :     }
     209             : 
     210           0 :     jfw_unlock();
     211             : #endif
     212           0 : }
     213             : 
     214             : // -----------------------------------------------------------------------
     215             : 
     216           0 : IMPL_LINK_NOARG(SvxJavaOptionsPage, EnableHdl_Impl)
     217             : {
     218           0 :     sal_Bool bEnable = m_pJavaEnableCB->IsChecked();
     219           0 :     m_pJavaBox->Enable(bEnable);
     220           0 :     bEnable ? m_pJavaList->EnableTable() : m_pJavaList->DisableTable();
     221           0 :     return 0;
     222             : }
     223             : 
     224             : // -----------------------------------------------------------------------
     225             : 
     226           0 : IMPL_LINK( SvxJavaOptionsPage, CheckHdl_Impl, SvxSimpleTable *, pList )
     227             : {
     228           0 :     SvTreeListEntry* pEntry = pList ? m_pJavaList->GetEntry( m_pJavaList->GetCurMousePoint() )
     229           0 :                                 : m_pJavaList->FirstSelected();
     230           0 :     if ( pEntry )
     231           0 :         m_pJavaList->HandleEntryChecked( pEntry );
     232           0 :     return 0;
     233             : }
     234             : 
     235             : // -----------------------------------------------------------------------
     236             : 
     237           0 : IMPL_LINK_NOARG(SvxJavaOptionsPage, SelectHdl_Impl)
     238             : {
     239             :     // set installation directory info
     240           0 :     SvTreeListEntry* pEntry = m_pJavaList->FirstSelected();
     241             :     DBG_ASSERT( pEntry, "SvxJavaOptionsPage::SelectHdl_Impl(): no entry" );
     242           0 :     String* pLocation = static_cast< String* >( pEntry->GetUserData() );
     243             :     DBG_ASSERT( pLocation, "invalid location string" );
     244           0 :     String sInfo = m_sInstallText;
     245           0 :     if ( pLocation )
     246           0 :         sInfo += *pLocation;
     247           0 :     m_pJavaPathText->SetText(sInfo);
     248           0 :     return 0;
     249             : }
     250             : 
     251             : // -----------------------------------------------------------------------
     252             : 
     253           0 : IMPL_LINK_NOARG(SvxJavaOptionsPage, AddHdl_Impl)
     254             : {
     255             :     try
     256             :     {
     257           0 :         Reference < XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
     258           0 :         xFolderPicker = FolderPicker::create(xContext);
     259             : 
     260           0 :         String sWorkFolder = SvtPathOptions().GetWorkPath();
     261           0 :         xFolderPicker->setDisplayDirectory( sWorkFolder );
     262           0 :         xFolderPicker->setDescription( m_sAddDialogText );
     263             : 
     264           0 :         Reference< XAsynchronousExecutableDialog > xAsyncDlg( xFolderPicker, UNO_QUERY );
     265           0 :         if ( xAsyncDlg.is() )
     266           0 :             xAsyncDlg->startExecuteModal( xDialogListener.get() );
     267           0 :         else if ( xFolderPicker.is() && xFolderPicker->execute() == ExecutableDialogResults::OK )
     268           0 :             AddFolder( xFolderPicker->getDirectory() );
     269             :     }
     270           0 :     catch (const Exception&)
     271             :     {
     272             :         SAL_WARN( "cui.options", "SvxJavaOptionsPage::AddHdl_Impl(): caught exception" );
     273             :     }
     274             : 
     275           0 :     return 0;
     276             : }
     277             : 
     278             : // -----------------------------------------------------------------------
     279             : 
     280           0 : IMPL_LINK_NOARG(SvxJavaOptionsPage, ParameterHdl_Impl)
     281             : {
     282             : #ifdef SOLAR_JAVA
     283           0 :     Sequence< OUString > aParameterList;
     284           0 :     if ( !m_pParamDlg )
     285             :     {
     286           0 :         m_pParamDlg = new SvxJavaParameterDlg( this );
     287           0 :         javaFrameworkError eErr = jfw_getVMParameters( &m_parParameters, &m_nParamSize );
     288           0 :         if ( JFW_E_NONE == eErr && m_parParameters && m_nParamSize > 0 )
     289             :         {
     290           0 :             rtl_uString** pParamArr = m_parParameters;
     291           0 :             aParameterList.realloc( m_nParamSize );
     292           0 :             OUString* pParams = aParameterList.getArray();
     293           0 :             for ( sal_Int32 i = 0; i < m_nParamSize; ++i )
     294             :             {
     295           0 :                 rtl_uString* pParam = *pParamArr++;
     296           0 :                 pParams[i] = OUString( pParam );
     297             :             }
     298           0 :             m_pParamDlg->SetParameters( aParameterList );
     299             :         }
     300             :     }
     301             :     else
     302           0 :         aParameterList = m_pParamDlg->GetParameters();
     303             : 
     304           0 :     if ( m_pParamDlg->Execute() == RET_OK )
     305             :     {
     306           0 :         if ( !areListsEqual( aParameterList, m_pParamDlg->GetParameters() ) )
     307             :         {
     308           0 :             aParameterList = m_pParamDlg->GetParameters();
     309           0 :             sal_Bool bRunning = sal_False;
     310           0 :             javaFrameworkError eErr = jfw_isVMRunning( &bRunning );
     311             :             DBG_ASSERT( JFW_E_NONE == eErr,
     312             :                         "SvxJavaOptionsPage::ParameterHdl_Impl(): error in jfw_isVMRunning" );
     313             :             (void)eErr;
     314           0 :             if ( bRunning )
     315             :             {
     316           0 :                 WarningBox aWarnBox( this, CUI_RES( RID_SVX_MSGBOX_OPTIONS_RESTART ) );
     317           0 :                 aWarnBox.Execute();
     318             :             }
     319             :         }
     320             :     }
     321             :     else
     322           0 :         m_pParamDlg->SetParameters( aParameterList );
     323             : #endif
     324           0 :     return 0;
     325             : }
     326             : 
     327             : // -----------------------------------------------------------------------
     328             : 
     329           0 : IMPL_LINK_NOARG(SvxJavaOptionsPage, ClassPathHdl_Impl)
     330             : {
     331             : #ifdef SOLAR_JAVA
     332           0 :     String sClassPath;
     333             : 
     334           0 :     if ( !m_pPathDlg )
     335             :     {
     336           0 :           m_pPathDlg = new SvxJavaClassPathDlg( this );
     337           0 :         javaFrameworkError eErr = jfw_getUserClassPath( &m_pClassPath );
     338           0 :         if ( JFW_E_NONE == eErr && m_pClassPath )
     339             :         {
     340           0 :             sClassPath = String( OUString( m_pClassPath ) );
     341           0 :             m_pPathDlg->SetClassPath( sClassPath );
     342             :         }
     343             :     }
     344             :     else
     345           0 :         sClassPath = m_pPathDlg->GetClassPath();
     346             : 
     347           0 :     m_pPathDlg->SetFocus();
     348           0 :     if ( m_pPathDlg->Execute() == RET_OK )
     349             :     {
     350             : 
     351           0 :         if ( m_pPathDlg->GetClassPath() != sClassPath )
     352             :         {
     353           0 :             sClassPath = m_pPathDlg->GetClassPath();
     354           0 :             sal_Bool bRunning = sal_False;
     355           0 :             javaFrameworkError eErr = jfw_isVMRunning( &bRunning );
     356             :             DBG_ASSERT( JFW_E_NONE == eErr,
     357             :                         "SvxJavaOptionsPage::ParameterHdl_Impl(): error in jfw_isVMRunning" );
     358             :             (void)eErr;
     359           0 :             if ( bRunning )
     360             :             {
     361           0 :                 WarningBox aWarnBox( this, CUI_RES( RID_SVX_MSGBOX_OPTIONS_RESTART ) );
     362           0 :                 aWarnBox.Execute();
     363             :             }
     364             :         }
     365             :     }
     366             :     else
     367           0 :         m_pPathDlg->SetClassPath( sClassPath );
     368             : #endif
     369           0 :     return 0;
     370             : }
     371             : 
     372             : // -----------------------------------------------------------------------
     373             : 
     374           0 : IMPL_LINK_NOARG(SvxJavaOptionsPage, ResetHdl_Impl)
     375             : {
     376           0 :     LoadJREs();
     377           0 :     return 0;
     378             : }
     379             : 
     380             : // -----------------------------------------------------------------------
     381             : 
     382           0 : IMPL_LINK_NOARG(SvxJavaOptionsPage, StartFolderPickerHdl)
     383             : {
     384             :     try
     385             :     {
     386           0 :         Reference< XAsynchronousExecutableDialog > xAsyncDlg( xFolderPicker, UNO_QUERY );
     387           0 :         if ( xAsyncDlg.is() )
     388           0 :             xAsyncDlg->startExecuteModal( xDialogListener.get() );
     389           0 :         else if ( xFolderPicker.is() && xFolderPicker->execute() == ExecutableDialogResults::OK )
     390           0 :             AddFolder( xFolderPicker->getDirectory() );
     391             :     }
     392           0 :     catch ( Exception& )
     393             :     {
     394             :         SAL_WARN( "cui.options", "SvxJavaOptionsPage::StartFolderPickerHdl(): caught exception" );
     395             :     }
     396             : 
     397           0 :     return 0L;
     398             : }
     399             : 
     400             : // -----------------------------------------------------------------------
     401             : 
     402           0 : IMPL_LINK( SvxJavaOptionsPage, DialogClosedHdl, DialogClosedEvent*, pEvt )
     403             : {
     404           0 :     if ( RET_OK == pEvt->DialogResult )
     405             :     {
     406             :         DBG_ASSERT( xFolderPicker.is() == sal_True, "SvxJavaOptionsPage::DialogClosedHdl(): no folder picker" );
     407             : 
     408           0 :         AddFolder( xFolderPicker->getDirectory() );
     409             :     }
     410           0 :     return 0L;
     411             : }
     412             : 
     413             : // -----------------------------------------------------------------------
     414             : 
     415           0 : void SvxJavaOptionsPage::ClearJavaInfo()
     416             : {
     417             : #ifdef SOLAR_JAVA
     418           0 :     if ( m_parJavaInfo )
     419             :     {
     420           0 :         JavaInfo** parInfo = m_parJavaInfo;
     421           0 :         for ( sal_Int32 i = 0; i < m_nInfoSize; ++i )
     422             :         {
     423           0 :             JavaInfo* pInfo = *parInfo++;
     424           0 :             jfw_freeJavaInfo( pInfo );
     425             :         }
     426             : 
     427           0 :         rtl_freeMemory( m_parJavaInfo );
     428           0 :         m_parJavaInfo = NULL;
     429           0 :         m_nInfoSize = 0;
     430             :     }
     431             : #endif
     432           0 : }
     433             : 
     434             : // -----------------------------------------------------------------------
     435             : 
     436           0 : void SvxJavaOptionsPage::ClearJavaList()
     437             : {
     438           0 :     SvTreeListEntry* pEntry = m_pJavaList->First();
     439           0 :     while ( pEntry )
     440             :     {
     441           0 :         String* pLocation = static_cast< String* >( pEntry->GetUserData() );
     442           0 :         delete pLocation;
     443           0 :         pEntry = m_pJavaList->Next( pEntry );
     444             :     }
     445           0 :     m_pJavaList->Clear();
     446           0 : }
     447             : 
     448             : // -----------------------------------------------------------------------
     449             : 
     450           0 : void SvxJavaOptionsPage::LoadJREs()
     451             : {
     452             : #ifdef SOLAR_JAVA
     453           0 :     WaitObject aWaitObj(m_pJavaList);
     454           0 :     javaFrameworkError eErr = jfw_findAllJREs( &m_parJavaInfo, &m_nInfoSize );
     455           0 :     if ( JFW_E_NONE == eErr && m_parJavaInfo )
     456             :     {
     457           0 :         JavaInfo** parInfo = m_parJavaInfo;
     458           0 :         for ( sal_Int32 i = 0; i < m_nInfoSize; ++i )
     459             :         {
     460           0 :             JavaInfo* pInfo = *parInfo++;
     461           0 :             AddJRE( pInfo );
     462             :         }
     463             :     }
     464             : 
     465           0 :     std::vector< JavaInfo* >::iterator pIter;
     466           0 :     for ( pIter = m_aAddedInfos.begin(); pIter != m_aAddedInfos.end(); ++pIter )
     467             :     {
     468           0 :         JavaInfo* pInfo = *pIter;
     469           0 :         AddJRE( pInfo );
     470             :     }
     471             : 
     472           0 :     JavaInfo* pSelectedJava = NULL;
     473           0 :     eErr = jfw_getSelectedJRE( &pSelectedJava );
     474           0 :     if ( JFW_E_NONE == eErr && pSelectedJava )
     475             :     {
     476           0 :         JavaInfo** parInfo = m_parJavaInfo;
     477           0 :         for ( sal_Int32 i = 0; i < m_nInfoSize; ++i )
     478             :         {
     479           0 :             JavaInfo* pCmpInfo = *parInfo++;
     480           0 :             if ( jfw_areEqualJavaInfo( pCmpInfo, pSelectedJava ) )
     481             :             {
     482           0 :                 SvTreeListEntry* pEntry = m_pJavaList->GetEntry(i);
     483           0 :                 if ( pEntry )
     484           0 :                     m_pJavaList->HandleEntryChecked( pEntry );
     485           0 :                 break;
     486             :             }
     487             :         }
     488             :     }
     489             : 
     490           0 :     jfw_freeJavaInfo( pSelectedJava );
     491             : #endif
     492           0 : }
     493             : 
     494             : // -----------------------------------------------------------------------
     495             : 
     496           0 : void SvxJavaOptionsPage::AddJRE( JavaInfo* _pInfo )
     497             : {
     498             : #ifdef SOLAR_JAVA
     499           0 :     OUStringBuffer sEntry;
     500           0 :     sEntry.append('\t');
     501           0 :     sEntry.append(_pInfo->sVendor);
     502           0 :     sEntry.append('\t');
     503           0 :     sEntry.append(_pInfo->sVersion);
     504           0 :     sEntry.append('\t');
     505           0 :     if ( ( _pInfo->nFeatures & JFW_FEATURE_ACCESSBRIDGE ) == JFW_FEATURE_ACCESSBRIDGE )
     506           0 :         sEntry.append(m_sAccessibilityText);
     507           0 :     SvTreeListEntry* pEntry = m_pJavaList->InsertEntry(sEntry.makeStringAndClear());
     508           0 :     INetURLObject aLocObj( OUString( _pInfo->sLocation ) );
     509           0 :     String* pLocation = new String( aLocObj.getFSysPath( INetURLObject::FSYS_DETECT ) );
     510           0 :     pEntry->SetUserData( pLocation );
     511             : #else
     512             :     (void)_pInfo;
     513             : #endif
     514           0 : }
     515             : 
     516             : // -----------------------------------------------------------------------
     517             : 
     518           0 : void SvxJavaOptionsPage::HandleCheckEntry( SvTreeListEntry* _pEntry )
     519             : {
     520           0 :     m_pJavaList->Select( _pEntry, sal_True );
     521           0 :     SvButtonState eState = m_pJavaList->GetCheckButtonState( _pEntry );
     522             : 
     523           0 :     if ( SV_BUTTON_CHECKED == eState )
     524             :     {
     525             :         // we have radio button behavior -> so uncheck the other entries
     526           0 :         SvTreeListEntry* pEntry = m_pJavaList->First();
     527           0 :         while ( pEntry )
     528             :         {
     529           0 :             if ( pEntry != _pEntry )
     530           0 :                 m_pJavaList->SetCheckButtonState( pEntry, SV_BUTTON_UNCHECKED );
     531           0 :             pEntry = m_pJavaList->Next( pEntry );
     532             :         }
     533             :     }
     534             :     else
     535           0 :         m_pJavaList->SetCheckButtonState( _pEntry, SV_BUTTON_CHECKED );
     536           0 : }
     537             : 
     538             : // -----------------------------------------------------------------------
     539             : 
     540           0 : void SvxJavaOptionsPage::AddFolder( const OUString& _rFolder )
     541             : {
     542             : #ifdef SOLAR_JAVA
     543           0 :     bool bStartAgain = true;
     544           0 :     JavaInfo* pInfo = NULL;
     545           0 :     javaFrameworkError eErr = jfw_getJavaInfoByPath( _rFolder.pData, &pInfo );
     546           0 :     if ( JFW_E_NONE == eErr && pInfo )
     547             :     {
     548           0 :         sal_Int32 nPos = 0;
     549           0 :         bool bFound = false;
     550           0 :         JavaInfo** parInfo = m_parJavaInfo;
     551           0 :         for ( sal_Int32 i = 0; i < m_nInfoSize; ++i )
     552             :         {
     553           0 :             JavaInfo* pCmpInfo = *parInfo++;
     554           0 :             if ( jfw_areEqualJavaInfo( pCmpInfo, pInfo ) )
     555             :             {
     556           0 :                 bFound = true;
     557           0 :                 nPos = i;
     558           0 :                 break;
     559             :             }
     560             :         }
     561             : 
     562           0 :         if ( !bFound )
     563             :         {
     564           0 :             std::vector< JavaInfo* >::iterator pIter;
     565           0 :             for ( pIter = m_aAddedInfos.begin(); pIter != m_aAddedInfos.end(); ++pIter )
     566             :             {
     567           0 :                 JavaInfo* pCmpInfo = *pIter;
     568           0 :                 if ( jfw_areEqualJavaInfo( pCmpInfo, pInfo ) )
     569             :                 {
     570           0 :                     bFound = true;
     571           0 :                     break;
     572             :                 }
     573             :             }
     574             :         }
     575             : 
     576           0 :         if ( !bFound )
     577             :         {
     578           0 :             jfw_addJRELocation( pInfo->sLocation );
     579           0 :             AddJRE( pInfo );
     580           0 :             m_aAddedInfos.push_back( pInfo );
     581           0 :             nPos = m_pJavaList->GetEntryCount() - 1;
     582             :         }
     583             :         else
     584           0 :             jfw_freeJavaInfo( pInfo );
     585             : 
     586           0 :         SvTreeListEntry* pEntry = m_pJavaList->GetEntry( nPos );
     587           0 :         m_pJavaList->Select( pEntry );
     588           0 :         m_pJavaList->SetCheckButtonState( pEntry, SV_BUTTON_CHECKED );
     589           0 :         HandleCheckEntry( pEntry );
     590           0 :         bStartAgain = false;
     591             :     }
     592           0 :     else if ( JFW_E_NOT_RECOGNIZED == eErr )
     593             :     {
     594           0 :         ErrorBox aErrBox( this, CUI_RES( RID_SVXERR_JRE_NOT_RECOGNIZED ) );
     595           0 :         aErrBox.Execute();
     596             :     }
     597           0 :     else if ( JFW_E_FAILED_VERSION == eErr )
     598             :     {
     599           0 :         ErrorBox aErrBox( this, CUI_RES( RID_SVXERR_JRE_FAILED_VERSION ) );
     600           0 :         aErrBox.Execute();
     601             :     }
     602             : 
     603           0 :     if ( bStartAgain )
     604             :     {
     605           0 :         xFolderPicker->setDisplayDirectory( _rFolder );
     606           0 :         Application::PostUserEvent( LINK( this, SvxJavaOptionsPage, StartFolderPickerHdl ) );
     607             :     }
     608             : #else
     609             :     (void)_rFolder;
     610             : #endif
     611           0 : }
     612             : 
     613             : // -----------------------------------------------------------------------
     614             : 
     615           0 : SfxTabPage* SvxJavaOptionsPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
     616             : {
     617           0 :     return ( new SvxJavaOptionsPage( pParent, rAttrSet ) );
     618             : }
     619             : 
     620             : // -----------------------------------------------------------------------
     621             : 
     622           0 : sal_Bool SvxJavaOptionsPage::FillItemSet( SfxItemSet& /*rCoreSet*/ )
     623             : {
     624           0 :     sal_Bool bModified = sal_False;
     625             : 
     626           0 :     if ( m_pExperimentalCB->IsChecked() != m_pExperimentalCB->GetSavedValue() )
     627             :     {
     628           0 :         SvtMiscOptions aMiscOpt;
     629           0 :         aMiscOpt.SetExperimentalMode( m_pExperimentalCB->IsChecked() );
     630           0 :         bModified = sal_True;
     631             :     }
     632             : 
     633           0 :     if ( m_pExpSidebarCB->IsChecked() != m_pExpSidebarCB->GetSavedValue() )
     634             :     {
     635           0 :         SvtMiscOptions aMiscOpt;
     636           0 :         aMiscOpt.SetExperimentalSidebar( m_pExpSidebarCB->IsChecked() );
     637             : 
     638             :         svtools::executeRestartDialog(
     639             :             comphelper::getProcessComponentContext(), this,
     640           0 :             svtools::RESTART_REASON_MODIFIED_SIDEBAR);
     641             : 
     642           0 :         bModified = sal_True;
     643             :     }
     644             : 
     645           0 :     if ( m_pMacroCB->IsChecked() != m_pMacroCB->GetSavedValue() )
     646             :     {
     647           0 :         SvtMiscOptions aMiscOpt;
     648           0 :         aMiscOpt.SetMacroRecorderMode( m_pMacroCB->IsChecked() );
     649           0 :         bModified = sal_True;
     650             :     }
     651             : 
     652             : #ifdef SOLAR_JAVA
     653           0 :     javaFrameworkError eErr = JFW_E_NONE;
     654           0 :     if ( m_pParamDlg )
     655             :     {
     656           0 :         Sequence< OUString > aParamList = m_pParamDlg->GetParameters();
     657           0 :         sal_Int32 i, nSize = aParamList.getLength();
     658           0 :         rtl_uString** pParamArr = (rtl_uString**)rtl_allocateMemory( sizeof(rtl_uString*) * nSize );
     659           0 :         rtl_uString** pParamArrIter = pParamArr;
     660           0 :         const OUString* pList = aParamList.getConstArray();
     661           0 :         for ( i = 0; i < nSize; ++i )
     662           0 :             pParamArr[i] = pList[i].pData;
     663           0 :         eErr = jfw_setVMParameters( pParamArrIter, nSize );
     664             :         DBG_ASSERT( JFW_E_NONE == eErr,
     665             :                     "SvxJavaOptionsPage::FillItemSet(): error in jfw_setVMParameters" );
     666           0 :         pParamArrIter = pParamArr;
     667           0 :         rtl_freeMemory( pParamArr );
     668           0 :         bModified = sal_True;
     669             :     }
     670             : 
     671           0 :     if ( m_pPathDlg )
     672             :     {
     673           0 :         OUString sPath( m_pPathDlg->GetClassPath() );
     674           0 :         if ( m_pPathDlg->GetOldPath() != String( sPath ) )
     675             :         {
     676           0 :             eErr = jfw_setUserClassPath( sPath.pData );
     677             :             DBG_ASSERT( JFW_E_NONE == eErr,
     678             :                         "SvxJavaOptionsPage::FillItemSet(): error in jfw_setUserClassPath" );
     679           0 :             bModified = sal_True;
     680           0 :         }
     681             :     }
     682             : 
     683           0 :     sal_uLong nCount = m_pJavaList->GetEntryCount();
     684           0 :     for ( sal_uLong i = 0; i < nCount; ++i )
     685             :     {
     686           0 :         if ( m_pJavaList->GetCheckButtonState( m_pJavaList->GetEntry(i) ) == SV_BUTTON_CHECKED )
     687             :         {
     688           0 :             JavaInfo* pInfo = NULL;
     689           0 :             if ( i < static_cast< sal_uLong >( m_nInfoSize ) )
     690           0 :                 pInfo = m_parJavaInfo[i];
     691             :             else
     692           0 :                 pInfo = m_aAddedInfos[ i - m_nInfoSize ];
     693             : 
     694           0 :             JavaInfo* pSelectedJava = NULL;
     695           0 :             eErr = jfw_getSelectedJRE( &pSelectedJava );
     696           0 :             if ( JFW_E_NONE == eErr || JFW_E_INVALID_SETTINGS == eErr )
     697             :             {
     698           0 :                 if (pSelectedJava == NULL || !jfw_areEqualJavaInfo( pInfo, pSelectedJava ) )
     699             :                 {
     700           0 :                     sal_Bool bRunning = sal_False;
     701           0 :                     eErr = jfw_isVMRunning( &bRunning );
     702             :                     DBG_ASSERT( JFW_E_NONE == eErr,
     703             :                                 "SvxJavaOptionsPage::FillItemSet(): error in jfw_isVMRunning" );
     704           0 :                     if ( bRunning ||
     705           0 :                         ( ( pInfo->nRequirements & JFW_REQUIRE_NEEDRESTART ) == JFW_REQUIRE_NEEDRESTART ) )
     706             :                     {
     707             :                         svtools::executeRestartDialog(
     708             :                             comphelper::getProcessComponentContext(), this,
     709           0 :                             svtools::RESTART_REASON_JAVA);
     710             :                     }
     711             : 
     712           0 :                     eErr = jfw_setSelectedJRE( pInfo );
     713             :                     DBG_ASSERT( JFW_E_NONE == eErr,
     714             :                                 "SvxJavaOptionsPage::FillItemSet(): error in jfw_setSelectedJRE" );
     715           0 :                     bModified = sal_True;
     716             :                 }
     717             :             }
     718           0 :             jfw_freeJavaInfo( pSelectedJava );
     719           0 :             break;
     720             :         }
     721             :     }
     722             : 
     723           0 :     sal_Bool bEnabled = sal_False;
     724           0 :     eErr = jfw_getEnabled( &bEnabled );
     725             :     DBG_ASSERT( JFW_E_NONE == eErr,
     726             :                 "SvxJavaOptionsPage::FillItemSet(): error in jfw_getEnabled" );
     727           0 :     if ( bEnabled != m_pJavaEnableCB->IsChecked() )
     728             :     {
     729           0 :         eErr = jfw_setEnabled( m_pJavaEnableCB->IsChecked() );
     730             :         DBG_ASSERT( JFW_E_NONE == eErr,
     731             :                     "SvxJavaOptionsPage::FillItemSet(): error in jfw_setEnabled" );
     732           0 :         bModified = sal_True;
     733             :     }
     734             : #endif
     735             : 
     736           0 :     return bModified;
     737             : }
     738             : 
     739             : // -----------------------------------------------------------------------
     740             : 
     741           0 : void SvxJavaOptionsPage::Reset( const SfxItemSet& /*rSet*/ )
     742             : {
     743           0 :     ClearJavaInfo();
     744           0 :     ClearJavaList();
     745             : 
     746           0 :     SvtMiscOptions aMiscOpt;
     747             : 
     748             : #ifdef SOLAR_JAVA
     749           0 :     sal_Bool bEnabled = sal_False;
     750           0 :     javaFrameworkError eErr = jfw_getEnabled( &bEnabled );
     751           0 :     if ( eErr != JFW_E_NONE )
     752           0 :         bEnabled = sal_False;
     753           0 :     m_pJavaEnableCB->Check( bEnabled );
     754           0 :     EnableHdl_Impl(m_pJavaEnableCB);
     755             : #else
     756             :     m_pJavaEnableCB->Check( false );
     757             :     m_pJavaEnableCB->Disable();
     758             : #endif
     759             : 
     760           0 :     m_pExperimentalCB->Check( aMiscOpt.IsExperimentalMode() );
     761           0 :     m_pExperimentalCB->SaveValue();
     762           0 :     m_pExpSidebarCB->Check( aMiscOpt.IsExperimentalSidebar() );
     763           0 :     m_pExpSidebarCB->SaveValue();
     764           0 :     m_pMacroCB->Check( aMiscOpt.IsMacroRecorderMode() );
     765           0 :     m_pMacroCB->SaveValue();
     766             : 
     767           0 :     m_aResetTimer.Start();
     768           0 : }
     769             : 
     770             : // -----------------------------------------------------------------------
     771             : 
     772           0 : void SvxJavaOptionsPage::FillUserData()
     773             : {
     774           0 :     String aUserData;
     775           0 :     SetUserData( aUserData );
     776           0 : }
     777             : 
     778             : // class SvxJavaParameterDlg ---------------------------------------------
     779             : 
     780           0 : SvxJavaParameterDlg::SvxJavaParameterDlg( Window* pParent ) :
     781             : 
     782           0 :     ModalDialog( pParent, CUI_RES( RID_SVXDLG_JAVA_PARAMETER ) ),
     783             : 
     784           0 :     m_aParameterLabel   ( this, CUI_RES( FT_PARAMETER ) ),
     785           0 :     m_aParameterEdit    ( this, CUI_RES( ED_PARAMETER ) ),
     786           0 :     m_aAssignBtn        ( this, CUI_RES( PB_ASSIGN ) ),
     787           0 :     m_aAssignedLabel    ( this, CUI_RES( FT_ASSIGNED ) ),
     788           0 :     m_aAssignedList     ( this, CUI_RES( LB_ASSIGNED ) ),
     789           0 :     m_aExampleText      ( this, CUI_RES( FT_EXAMPLE ) ),
     790           0 :     m_aRemoveBtn        ( this, CUI_RES( PB_REMOVE ) ),
     791           0 :     m_aButtonsLine      ( this, CUI_RES( FL_BUTTONS ) ),
     792           0 :     m_aOKBtn            ( this, CUI_RES( PB_PARAMETER_OK ) ),
     793           0 :     m_aCancelBtn        ( this, CUI_RES( PB_PARAMETER_ESC ) ),
     794           0 :     m_aHelpBtn          ( this, CUI_RES( PB_PARAMETER_HLP ) )
     795             : 
     796             : {
     797           0 :     FreeResource();
     798             : 
     799           0 :     m_aParameterEdit.SetModifyHdl( LINK( this, SvxJavaParameterDlg, ModifyHdl_Impl ) );
     800           0 :     m_aAssignBtn.SetClickHdl( LINK( this, SvxJavaParameterDlg, AssignHdl_Impl ) );
     801           0 :     m_aRemoveBtn.SetClickHdl( LINK( this, SvxJavaParameterDlg, RemoveHdl_Impl ) );
     802           0 :     m_aAssignedList.SetSelectHdl( LINK( this, SvxJavaParameterDlg, SelectHdl_Impl ) );
     803           0 :     m_aAssignedList.SetDoubleClickHdl( LINK( this, SvxJavaParameterDlg, DblClickHdl_Impl ) );
     804             : 
     805           0 :     ModifyHdl_Impl( &m_aParameterEdit );
     806           0 :     EnableRemoveButton();
     807           0 : }
     808             : 
     809             : // -----------------------------------------------------------------------
     810             : 
     811           0 : SvxJavaParameterDlg::~SvxJavaParameterDlg()
     812             : {
     813           0 : }
     814             : 
     815             : // -----------------------------------------------------------------------
     816             : 
     817           0 : IMPL_LINK_NOARG(SvxJavaParameterDlg, ModifyHdl_Impl)
     818             : {
     819           0 :     OUString sParam = comphelper::string::strip(m_aParameterEdit.GetText(), ' ');
     820           0 :     m_aAssignBtn.Enable(!sParam.isEmpty());
     821             : 
     822           0 :     return 0;
     823             : }
     824             : 
     825             : // -----------------------------------------------------------------------
     826             : 
     827           0 : IMPL_LINK_NOARG(SvxJavaParameterDlg, AssignHdl_Impl)
     828             : {
     829           0 :     OUString sParam = comphelper::string::strip(m_aParameterEdit.GetText(), ' ');
     830           0 :     if (!sParam.isEmpty())
     831             :     {
     832           0 :         sal_uInt16 nPos = m_aAssignedList.GetEntryPos( sParam );
     833           0 :         if ( LISTBOX_ENTRY_NOTFOUND == nPos )
     834           0 :             nPos = m_aAssignedList.InsertEntry( sParam );
     835           0 :         m_aAssignedList.SelectEntryPos( nPos );
     836           0 :         m_aParameterEdit.SetText( String() );
     837           0 :         ModifyHdl_Impl( &m_aParameterEdit );
     838           0 :         EnableRemoveButton();
     839             :     }
     840             : 
     841           0 :     return 0;
     842             : }
     843             : 
     844             : // -----------------------------------------------------------------------
     845             : 
     846           0 : IMPL_LINK_NOARG(SvxJavaParameterDlg, SelectHdl_Impl)
     847             : {
     848           0 :     EnableRemoveButton();
     849           0 :     return 0;
     850             : }
     851             : 
     852             : // -----------------------------------------------------------------------
     853             : 
     854           0 : IMPL_LINK_NOARG(SvxJavaParameterDlg, DblClickHdl_Impl)
     855             : {
     856           0 :     sal_uInt16 nPos = m_aAssignedList.GetSelectEntryPos();
     857           0 :     if ( nPos != LISTBOX_ENTRY_NOTFOUND )
     858           0 :         m_aParameterEdit.SetText( m_aAssignedList.GetEntry( nPos ) );
     859           0 :     return 0;
     860             : }
     861             : 
     862             : // -----------------------------------------------------------------------
     863             : 
     864           0 : IMPL_LINK_NOARG(SvxJavaParameterDlg, RemoveHdl_Impl)
     865             : {
     866           0 :     sal_uInt16 nPos = m_aAssignedList.GetSelectEntryPos();
     867           0 :     if ( nPos != LISTBOX_ENTRY_NOTFOUND )
     868             :     {
     869           0 :         m_aAssignedList.RemoveEntry( nPos );
     870           0 :         sal_uInt16 nCount = m_aAssignedList.GetEntryCount();
     871           0 :         if ( nCount )
     872             :         {
     873           0 :             if ( nPos >= nCount )
     874           0 :                 nPos = ( nCount - 1 );
     875           0 :             m_aAssignedList.SelectEntryPos( nPos );
     876             :         }
     877             :     }
     878           0 :     EnableRemoveButton();
     879             : 
     880           0 :     return 0;
     881             : }
     882             : 
     883             : // -----------------------------------------------------------------------
     884             : 
     885           0 : short SvxJavaParameterDlg::Execute()
     886             : {
     887           0 :     m_aParameterEdit.GrabFocus();
     888           0 :     m_aAssignedList.SetNoSelection();
     889           0 :     return ModalDialog::Execute();
     890             : }
     891             : 
     892             : // -----------------------------------------------------------------------
     893             : 
     894           0 : Sequence< OUString > SvxJavaParameterDlg::GetParameters() const
     895             : {
     896           0 :     sal_uInt16 nCount = m_aAssignedList.GetEntryCount();
     897           0 :     Sequence< OUString > aParamList( nCount );
     898           0 :     OUString* pArray = aParamList.getArray();
     899           0 :      for ( sal_uInt16 i = 0; i < nCount; ++i )
     900           0 :          pArray[i] = OUString( m_aAssignedList.GetEntry(i) );
     901           0 :     return aParamList;
     902             : }
     903             : 
     904             : // -----------------------------------------------------------------------
     905             : 
     906           0 : void SvxJavaParameterDlg::SetParameters( Sequence< OUString >& rParams )
     907             : {
     908           0 :     m_aAssignedList.Clear();
     909           0 :     sal_uLong i, nCount = rParams.getLength();
     910           0 :     const OUString* pArray = rParams.getConstArray();
     911           0 :     for ( i = 0; i < nCount; ++i )
     912             :     {
     913           0 :         String sParam = String( *pArray++ );
     914           0 :         m_aAssignedList.InsertEntry( sParam );
     915           0 :     }
     916           0 : }
     917             : 
     918             : // class SvxJavaClassPathDlg ---------------------------------------------
     919             : 
     920           0 : SvxJavaClassPathDlg::SvxJavaClassPathDlg( Window* pParent ) :
     921             : 
     922           0 :     ModalDialog( pParent, CUI_RES( RID_SVXDLG_JAVA_CLASSPATH ) ),
     923             : 
     924           0 :     m_aPathLabel        ( this, CUI_RES( FT_PATH ) ),
     925           0 :     m_aPathList         ( this, CUI_RES( LB_PATH ) ),
     926           0 :     m_aAddArchiveBtn    ( this, CUI_RES( PB_ADDARCHIVE ) ),
     927           0 :     m_aAddPathBtn       ( this, CUI_RES( PB_ADDPATH ) ),
     928           0 :     m_aRemoveBtn        ( this, CUI_RES( PB_REMOVE_PATH ) ),
     929           0 :     m_aButtonsLine      ( this, CUI_RES( FL_PATH_BUTTONS ) ),
     930           0 :     m_aOKBtn            ( this, CUI_RES( PB_PATH_OK ) ),
     931           0 :     m_aCancelBtn        ( this, CUI_RES( PB_PATH_ESC ) ),
     932           0 :     m_aHelpBtn          ( this, CUI_RES( PB_PATH_HLP ) )
     933             : 
     934             : {
     935           0 :     FreeResource();
     936             : 
     937           0 :     m_aAddArchiveBtn.SetClickHdl( LINK( this, SvxJavaClassPathDlg, AddArchiveHdl_Impl ) );
     938           0 :     m_aAddPathBtn.SetClickHdl( LINK( this, SvxJavaClassPathDlg, AddPathHdl_Impl ) );
     939           0 :     m_aRemoveBtn.SetClickHdl( LINK( this, SvxJavaClassPathDlg, RemoveHdl_Impl ) );
     940           0 :     m_aPathList.SetSelectHdl( LINK( this, SvxJavaClassPathDlg, SelectHdl_Impl ) );
     941             : 
     942             :     // check if the buttons text are not too wide otherwise we have to stretch the buttons
     943             :     // and shrink the listbox
     944           0 :     long nTxtWidth1 = m_aAddArchiveBtn.GetTextWidth( m_aAddArchiveBtn.GetText() );
     945           0 :     long nTxtWidth2 = m_aAddPathBtn.GetTextWidth( m_aAddPathBtn.GetText() );
     946           0 :     Size aBtnSz = m_aAddArchiveBtn.GetSizePixel();
     947           0 :     if ( nTxtWidth1 > aBtnSz.Width() || nTxtWidth2 > aBtnSz.Width() )
     948             :     {
     949           0 :         long nW = ( nTxtWidth1 > aBtnSz.Width() ) ? nTxtWidth1 : nTxtWidth2;
     950           0 :         long nDelta = nW - aBtnSz.Width() + 2 * BUTTON_BORDER;
     951           0 :         aBtnSz.Width() += nDelta;
     952           0 :         Point aBtnPnt = m_aAddArchiveBtn.GetPosPixel();
     953           0 :         aBtnPnt.X() -= nDelta;
     954           0 :         m_aAddArchiveBtn.SetPosSizePixel( aBtnPnt, aBtnSz );
     955           0 :         aBtnPnt = m_aAddPathBtn.GetPosPixel();
     956           0 :         aBtnPnt.X() -= nDelta;
     957           0 :         m_aAddPathBtn.SetPosSizePixel( aBtnPnt, aBtnSz );
     958           0 :         aBtnPnt = m_aRemoveBtn.GetPosPixel();
     959           0 :         aBtnPnt.X() -= nDelta;
     960           0 :         m_aRemoveBtn.SetPosSizePixel( aBtnPnt, aBtnSz );
     961           0 :         Size aBoxSz = m_aPathList.GetSizePixel();
     962           0 :         aBoxSz.Width() -= nDelta;
     963           0 :         m_aPathList.SetSizePixel( aBoxSz );
     964             :     }
     965             : 
     966             :     // set initial focus to path list
     967           0 :     m_aPathList.GrabFocus();
     968           0 : }
     969             : 
     970             : // -----------------------------------------------------------------------
     971             : 
     972           0 : SvxJavaClassPathDlg::~SvxJavaClassPathDlg()
     973             : {
     974           0 :     sal_uInt16 i, nCount = m_aPathList.GetEntryCount();
     975           0 :     for ( i = 0; i < nCount; ++i )
     976           0 :         delete static_cast< String* >( m_aPathList.GetEntryData(i) );
     977           0 : }
     978             : 
     979             : // -----------------------------------------------------------------------
     980             : 
     981           0 : IMPL_LINK_NOARG(SvxJavaClassPathDlg, AddArchiveHdl_Impl)
     982             : {
     983           0 :     sfx2::FileDialogHelper aDlg( TemplateDescription::FILEOPEN_SIMPLE, 0 );
     984           0 :     aDlg.SetTitle( CUI_RES( RID_SVXSTR_ARCHIVE_TITLE ) );
     985           0 :     aDlg.AddFilter( CUI_RES( RID_SVXSTR_ARCHIVE_HEADLINE ), OUString("*.jar;*.zip") );
     986           0 :     String sFolder;
     987           0 :     if ( m_aPathList.GetSelectEntryCount() > 0 )
     988             :     {
     989           0 :         INetURLObject aObj( m_aPathList.GetSelectEntry(), INetURLObject::FSYS_DETECT );
     990           0 :         sFolder = aObj.GetMainURL( INetURLObject::NO_DECODE );
     991             :     }
     992             :     else
     993           0 :          sFolder = SvtPathOptions().GetWorkPath();
     994           0 :     aDlg.SetDisplayDirectory( sFolder );
     995           0 :     if ( aDlg.Execute() == ERRCODE_NONE )
     996             :     {
     997           0 :         String sURL = aDlg.GetPath();
     998           0 :         INetURLObject aURL( sURL );
     999           0 :         String sFile = aURL.getFSysPath( INetURLObject::FSYS_DETECT );
    1000           0 :         if ( !IsPathDuplicate( sURL ) )
    1001             :         {
    1002           0 :             sal_uInt16 nPos = m_aPathList.InsertEntry( sFile, SvFileInformationManager::GetImage( aURL, false ) );
    1003           0 :             m_aPathList.SelectEntryPos( nPos );
    1004             :         }
    1005             :         else
    1006             :         {
    1007           0 :             String sMsg( CUI_RES( RID_SVXSTR_MULTIFILE_DBL_ERR ) );
    1008           0 :             sMsg.SearchAndReplaceAscii( "%1", sFile );
    1009           0 :             ErrorBox( this, WB_OK, sMsg ).Execute();
    1010           0 :         }
    1011             :     }
    1012           0 :     EnableRemoveButton();
    1013           0 :     return 0;
    1014             : }
    1015             : 
    1016             : // -----------------------------------------------------------------------
    1017             : 
    1018           0 : IMPL_LINK_NOARG(SvxJavaClassPathDlg, AddPathHdl_Impl)
    1019             : {
    1020           0 :     Reference < XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
    1021           0 :     Reference < XFolderPicker2 > xFolderPicker = FolderPicker::create(xContext);;
    1022             : 
    1023           0 :     String sOldFolder;
    1024           0 :     if ( m_aPathList.GetSelectEntryCount() > 0 )
    1025             :     {
    1026           0 :         INetURLObject aObj( m_aPathList.GetSelectEntry(), INetURLObject::FSYS_DETECT );
    1027           0 :         sOldFolder = aObj.GetMainURL( INetURLObject::NO_DECODE );
    1028             :     }
    1029             :     else
    1030           0 :         sOldFolder = SvtPathOptions().GetWorkPath();
    1031           0 :     xFolderPicker->setDisplayDirectory( sOldFolder );
    1032           0 :     if ( xFolderPicker->execute() == ExecutableDialogResults::OK )
    1033             :     {
    1034           0 :         String sFolderURL( xFolderPicker->getDirectory() );
    1035           0 :         INetURLObject aURL( sFolderURL );
    1036           0 :         String sNewFolder = aURL.getFSysPath( INetURLObject::FSYS_DETECT );
    1037           0 :         if ( !IsPathDuplicate( sFolderURL ) )
    1038             :         {
    1039           0 :             sal_uInt16 nPos = m_aPathList.InsertEntry( sNewFolder, SvFileInformationManager::GetImage( aURL, false ) );
    1040           0 :             m_aPathList.SelectEntryPos( nPos );
    1041             :         }
    1042             :         else
    1043             :         {
    1044           0 :             String sMsg( CUI_RES( RID_SVXSTR_MULTIFILE_DBL_ERR ) );
    1045           0 :             sMsg.SearchAndReplaceAscii( "%1", sNewFolder );
    1046           0 :             ErrorBox( this, WB_OK, sMsg ).Execute();
    1047           0 :         }
    1048             :     }
    1049           0 :     EnableRemoveButton();
    1050           0 :     return 0;
    1051             : }
    1052             : 
    1053             : // -----------------------------------------------------------------------
    1054             : 
    1055           0 : IMPL_LINK_NOARG(SvxJavaClassPathDlg, RemoveHdl_Impl)
    1056             : {
    1057           0 :     sal_uInt16 nPos = m_aPathList.GetSelectEntryPos();
    1058           0 :     if ( nPos != LISTBOX_ENTRY_NOTFOUND )
    1059             :     {
    1060           0 :         m_aPathList.RemoveEntry( nPos );
    1061           0 :         sal_uInt16 nCount = m_aPathList.GetEntryCount();
    1062           0 :         if ( nCount )
    1063             :         {
    1064           0 :             if ( nPos >= nCount )
    1065           0 :                 nPos = ( nCount - 1 );
    1066           0 :             m_aPathList.SelectEntryPos( nPos );
    1067             :         }
    1068             :     }
    1069             : 
    1070           0 :     EnableRemoveButton();
    1071           0 :     return 0;
    1072             : }
    1073             : 
    1074             : // -----------------------------------------------------------------------
    1075             : 
    1076           0 : IMPL_LINK_NOARG(SvxJavaClassPathDlg, SelectHdl_Impl)
    1077             : {
    1078           0 :     EnableRemoveButton();
    1079           0 :     return 0;
    1080             : }
    1081             : 
    1082             : // -----------------------------------------------------------------------
    1083             : 
    1084           0 : bool SvxJavaClassPathDlg::IsPathDuplicate( const String& _rPath )
    1085             : {
    1086           0 :     bool bRet = false;
    1087           0 :     INetURLObject aFileObj( _rPath );
    1088           0 :     sal_uInt16 nCount = m_aPathList.GetEntryCount();
    1089           0 :     for ( sal_uInt16 i = 0; i < nCount; ++i )
    1090             :     {
    1091           0 :         INetURLObject aOtherObj( m_aPathList.GetEntry(i), INetURLObject::FSYS_DETECT );
    1092           0 :         if ( aOtherObj == aFileObj )
    1093             :         {
    1094           0 :             bRet = true;
    1095           0 :             break;
    1096             :         }
    1097           0 :     }
    1098             : 
    1099           0 :     return bRet;
    1100             : }
    1101             : 
    1102             : // -----------------------------------------------------------------------
    1103             : 
    1104           0 : String SvxJavaClassPathDlg::GetClassPath() const
    1105             : {
    1106           0 :     String sPath;
    1107           0 :     sal_uInt16 nCount = m_aPathList.GetEntryCount();
    1108           0 :     for ( sal_uInt16 i = 0; i < nCount; ++i )
    1109             :     {
    1110           0 :         if ( sPath.Len() > 0 )
    1111           0 :             sPath += CLASSPATH_DELIMITER;
    1112           0 :         String* pFullPath = static_cast< String* >( m_aPathList.GetEntryData(i) );
    1113           0 :         if ( pFullPath )
    1114           0 :             sPath += *pFullPath;
    1115             :         else
    1116           0 :             sPath += m_aPathList.GetEntry(i);
    1117             :     }
    1118           0 :     return sPath;
    1119             : }
    1120             : 
    1121             : // -----------------------------------------------------------------------
    1122             : 
    1123           0 : void SvxJavaClassPathDlg::SetClassPath( const String& _rPath )
    1124             : {
    1125           0 :     if ( m_sOldPath.Len() == 0 )
    1126           0 :         m_sOldPath = _rPath;
    1127           0 :     m_aPathList.Clear();
    1128             :     xub_StrLen i;
    1129           0 :     sal_Int32 nIdx = 0;
    1130           0 :     xub_StrLen nCount = comphelper::string::getTokenCount(_rPath, CLASSPATH_DELIMITER);
    1131           0 :     for ( i = 0; i < nCount; ++i )
    1132             :     {
    1133           0 :         String sToken = _rPath.GetToken( 0, CLASSPATH_DELIMITER, nIdx );
    1134           0 :         INetURLObject aURL( sToken, INetURLObject::FSYS_DETECT );
    1135           0 :         String sPath = aURL.getFSysPath( INetURLObject::FSYS_DETECT );
    1136           0 :         m_aPathList.InsertEntry( sPath, SvFileInformationManager::GetImage( aURL, false ) );
    1137           0 :     }
    1138             :     // select first entry
    1139           0 :     m_aPathList.SelectEntryPos(0);
    1140           0 :     SelectHdl_Impl( NULL );
    1141           0 : }
    1142             : 
    1143             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
    1144             : 
    1145             : 

Generated by: LCOV version 1.10