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