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