summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
authorThomas Benisch <tbe@openoffice.org>2001-09-03 10:56:10 +0000
committerThomas Benisch <tbe@openoffice.org>2001-09-03 10:56:10 +0000
commit7ae106bb38b0786757588199e63d94643bdbf8ec (patch)
tree10ae94369a1127662fbed63970ce60909316d1fe /basctl
parent3dfd05700cda93102ee457baf7ecf66bebf7ef3d (diff)
#91121# adapt library management in BasicIDE to library containers
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/basicide/baside2.cxx6
-rw-r--r--basctl/source/basicide/basides1.cxx50
-rw-r--r--basctl/source/basicide/basidesh.cxx107
-rw-r--r--basctl/source/basicide/basobj2.cxx332
-rw-r--r--basctl/source/basicide/basobj3.cxx160
-rw-r--r--basctl/source/basicide/bastype2.cxx159
-rw-r--r--basctl/source/basicide/bastype2.hxx7
-rw-r--r--basctl/source/basicide/iderdll.cxx23
-rw-r--r--basctl/source/basicide/macrodlg.cxx7
-rw-r--r--basctl/source/basicide/moduldl2.cxx68
-rw-r--r--basctl/source/basicide/moduldlg.cxx28
-rw-r--r--basctl/source/basicide/moduldlg.hxx7
12 files changed, 541 insertions, 413 deletions
diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx
index a09587b627eb..3fd47073c108 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: baside2.cxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: tbe $ $Date: 2001-08-29 12:15:59 $
+ * last change: $Author: tbe $ $Date: 2001-09-03 11:45:36 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -241,7 +241,7 @@ ModulWindow::ModulWindow( ModulWindowLayout* pParent, StarBASIC* pBas,
,m_pShell( pShell )
,m_aLibName( aLibName )
,m_aModName( aModName )
- ,m_aModule( aModule ) // not updated yet
+ ,m_aModule( aModule )
{
DBG_CTOR( ModulWindow, 0 );
nValid = VALIDWINDOW;
diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx
index 7d0a43fcb84d..1e318dd0d4e9 100644
--- a/basctl/source/basicide/basides1.cxx
+++ b/basctl/source/basicide/basides1.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: basides1.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: tbe $ $Date: 2001-08-29 12:18:32 $
+ * last change: $Author: tbe $ $Date: 2001-09-03 11:46:17 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -360,14 +360,27 @@ void __EXPORT BasicIDEShell::ExecuteGlobal( SfxRequest& rReq )
const SfxMacroInfoItem& rInfo = (const SfxMacroInfoItem&)rReq.GetArgs()->Get(SID_BASICIDE_ARG_MACROINFO );
BasicManager* pBasMgr = (BasicManager*)rInfo.GetBasicManager();
DBG_ASSERT( pBasMgr, "Nichts selektiert im Basic-Baum ?" );
+ SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr );
StartListening( *pBasMgr, TRUE /* Nur einmal anmelden */ );
- StarBASIC* pBasic = pBasMgr->GetLib( rInfo.GetLib() );
+ String aLibName( rInfo.GetLib() );
+ StarBASIC* pBasic = pBasMgr->GetLib( aLibName );
if ( !pBasic )
{
// LoadOnDemand
- USHORT nLib = pBasMgr->GetLibId( rInfo.GetLib() );
- pBasMgr->LoadLib( nLib );
- pBasic = pBasMgr->GetLib( nLib );
+ ::rtl::OUString aOULibName( aLibName );
+
+ // load module library (if not loaded)
+ Reference< script::XLibraryContainer > xModLibContainer = BasicIDE::GetModuleLibraryContainer( pShell );
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && !xModLibContainer->isLibraryLoaded( aOULibName ) )
+ xModLibContainer->loadLibrary( aOULibName );
+
+ // load dialog library (if not loaded)
+ Reference< script::XLibraryContainer > xDlgLibContainer = BasicIDE::GetDialogLibraryContainer( pShell );
+ if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && !xDlgLibContainer->isLibraryLoaded( aOULibName ) )
+ xDlgLibContainer->loadLibrary( aOULibName );
+
+ // get Basic
+ pBasic = pBasMgr->GetLib( aLibName );
}
if ( !pBasic )
pBasic = pBasMgr->GetLib( 0 );
@@ -382,8 +395,6 @@ void __EXPORT BasicIDEShell::ExecuteGlobal( SfxRequest& rReq )
{
if ( rInfo.GetModule().Len() || !pBasic->GetModules()->Count() )
{
- SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr );
- String aLibName = pBasic->GetName();
String aModName = rInfo.GetModule();
try
@@ -571,9 +582,22 @@ void __EXPORT BasicIDEShell::ExecuteGlobal( SfxRequest& rReq )
if ( !pLib && ( nSlot == SID_BASICIDE_LIBSELECTED ) )
{
// LoadOnDemand
- USHORT nLib = pMgr->GetLibId( aLib );
- pMgr->LoadLib( nLib );
- pLib = pMgr->GetLib( nLib );
+ SfxObjectShell* pShell = BasicIDE::FindDocShell( pMgr );
+ ::rtl::OUString aOULibName( aLib );
+
+ // load module library (if not loaded)
+ Reference< script::XLibraryContainer > xModLibContainer = BasicIDE::GetModuleLibraryContainer( pShell );
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && !xModLibContainer->isLibraryLoaded( aOULibName ) )
+ xModLibContainer->loadLibrary( aOULibName );
+
+ // load dialog library (if not loaded)
+ Reference< script::XLibraryContainer > xDlgLibContainer = BasicIDE::GetDialogLibraryContainer( pShell );
+ if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && !xDlgLibContainer->isLibraryLoaded( aOULibName ) )
+ xDlgLibContainer->loadLibrary( aOULibName );
+
+ // get Basic
+ pLib = pMgr->GetLib( aLib );
+
if ( !pLib )
{
ErrorBox( pCurWin, WB_OK|WB_DEF_OK, String( IDEResId( RID_STR_ERROROPENLIB ) ) ).Execute();
@@ -588,6 +612,9 @@ void __EXPORT BasicIDEShell::ExecuteGlobal( SfxRequest& rReq )
// Keine Abfrage, ob pCurBasic == pLib,
// falls welche ausgeblendet waren.
BOOL bSet = TRUE;
+
+ // TODO: check password
+ /* old code
if ( pLib )
{
USHORT nLib = pMgr->GetLibId( pLib );
@@ -597,6 +624,7 @@ void __EXPORT BasicIDEShell::ExecuteGlobal( SfxRequest& rReq )
bSet = QueryPassword( pMgr, nLib );
}
}
+ */
if ( bSet )
SetCurBasic( pLib );
else // alten Wert einstellen...
diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx
index b78436efd4bb..133b34bb9b30 100644
--- a/basctl/source/basicide/basidesh.cxx
+++ b/basctl/source/basicide/basidesh.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: basidesh.cxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: tbe $ $Date: 2001-08-01 09:29:45 $
+ * last change: $Author: tbe $ $Date: 2001-09-03 11:47:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -465,6 +465,19 @@ void __EXPORT BasicIDEShell::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId&,
{
StoreAllWindowData();
}
+
+ // TODO: move code from SFX_HINT_DYING to SFX_EVENT_CLOSEDOC?
+ // (in SFX_HINT_DYING the SfxObjectShell is already destroyed)
+ /*
+ if ( ((SfxEventHint&)rHint).GetEventId() == SFX_EVENT_CLOSEDOC )
+ {
+ if ( rBC.IsA( TYPE( SfxObjectShell ) ) )
+ {
+ SfxObjectShell* pShell = (SfxObjectShell*)&rBC;
+ BasicManager* pBasMgr = pShell->GetBasicManager();
+ }
+ }
+ */
}
if ( rHint.IsA( TYPE( SfxSimpleHint ) ) )
{
@@ -701,56 +714,72 @@ void BasicIDEShell::UpdateWindows()
if ( pDocShell )
StartListening( *pDocShell, TRUE );
- USHORT nLibs = pBasicMgr->GetLibCount();
- for ( USHORT nLib = 0; nLib < nLibs; nLib++ )
+ // libraries
+ Sequence< ::rtl::OUString > aLibNames = BasicIDE::GetLibraryNames( pDocShell );
+ sal_Int32 nLibCount = aLibNames.getLength();
+ const ::rtl::OUString* pLibNames = aLibNames.getConstArray();
+
+ for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
{
+ String aLibName = pLibNames[ i ];
+
+ // TODO: check password
+ /* old code
if ( !pBasicMgr->HasPassword( nLib ) ||
pBasicMgr->IsPasswordVerified( nLib ) )
{
- StarBASIC* pLib = pBasicMgr->GetLib( nLib );
- if ( pLib && ( !pCurBasic || ( pLib == pCurBasic ) ) )
- {
- ImplStartListening( pLib );
+ */
- LibInfo* pLibInf = IDE_DLL()->GetExtraData()->GetLibInfos().GetInfo( pLib );
+ StarBASIC* pLib = pBasicMgr->GetLib( aLibName );
- // modules
- for ( USHORT nMod = 0; nMod < pLib->GetModules()->Count(); nMod++ )
- {
- SbModule* pMod = (SbModule*)pLib->GetModules()->Get( nMod );
- if ( !FindBasWin( pLib, pMod->GetName(), FALSE ) )
- CreateBasWin( pLib, pMod->GetName() );
- if ( pLibInf && !pNextActiveModule &&
- ( pMod->GetName() == pLibInf->aCurrentModule ) )
- {
- pNextActiveModule = pMod;
- }
- }
+ if ( pLib && ( !pCurBasic || ( pLib == pCurBasic ) ) )
+ {
+ ImplStartListening( pLib );
- // dialogs
- try
+ LibInfo* pLibInf = IDE_DLL()->GetExtraData()->GetLibInfos().GetInfo( pLib );
+
+ // modules
+ try
+ {
+ Sequence< ::rtl::OUString > aModNames = BasicIDE::GetModuleNames( pDocShell, aLibName );
+ sal_Int32 nModCount = aModNames.getLength();
+ const ::rtl::OUString* pModNames = aModNames.getConstArray();
+
+ for ( sal_Int32 j = 0 ; j < nModCount ; j++ )
{
- Reference< container::XNameContainer > xLib = BasicIDE::GetDialogLibrary( pDocShell, pLib->GetName(), TRUE );
+ String aModName = pModNames[ j ];
+ if ( !FindBasWin( pLib, aModName, FALSE ) )
+ CreateBasWin( pLib, aModName );
- if( xLib.is() )
- {
- Sequence< OUString > aNames = xLib->getElementNames();
- sal_Int32 nNameCount = aNames.getLength();
- const OUString* pNames = aNames.getConstArray();
- for( sal_Int32 i = 0 ; i < nNameCount ; i++ )
- {
- OUString aDialogName = pNames[ i ];
- if ( !FindDlgWin( pLib, aDialogName, FALSE ) ) // this find only looks for non-suspended windows;
- CreateDlgWin( pLib, aDialogName ); // suspended windows are handled in CreateDlgWin
- }
- }
+ if ( pLibInf && !pNextActiveModule && ( aModName == pLibInf->aCurrentModule ) )
+ pNextActiveModule = pLib->FindModule( aModName );
}
- catch ( container::NoSuchElementException& e )
+ }
+ catch ( container::NoSuchElementException& e )
+ {
+ ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US );
+ DBG_ERROR( aBStr.GetBuffer() );
+ }
+
+ // dialogs
+ try
+ {
+ Sequence< ::rtl::OUString > aDlgNames = BasicIDE::GetDialogNames( pDocShell, aLibName );
+ sal_Int32 nDlgCount = aDlgNames.getLength();
+ const ::rtl::OUString* pDlgNames = aDlgNames.getConstArray();
+
+ for ( sal_Int32 j = 0 ; j < nDlgCount ; j++ )
{
- ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US );
- DBG_ERROR( aBStr.GetBuffer() );
+ String aDlgName = pDlgNames[ j ];
+ if ( !FindDlgWin( pLib, aDlgName, FALSE ) ) // this find only looks for non-suspended windows;
+ CreateDlgWin( pLib, aDlgName ); // suspended windows are handled in CreateDlgWin
}
}
+ catch ( container::NoSuchElementException& e )
+ {
+ ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US );
+ DBG_ERROR( aBStr.GetBuffer() );
+ }
}
}
}
diff --git a/basctl/source/basicide/basobj2.cxx b/basctl/source/basicide/basobj2.cxx
index d803d6429391..8a7208468623 100644
--- a/basctl/source/basicide/basobj2.cxx
+++ b/basctl/source/basicide/basobj2.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: basobj2.cxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: tbe $ $Date: 2001-08-29 12:19:54 $
+ * last change: $Author: tbe $ $Date: 2001-09-03 11:47:42 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -64,6 +64,9 @@
#pragma hdrstop
+#include <vector>
+#include <algorithm>
+
#ifndef _SBXCLASS_HXX //autogen
#include <svtools/sbx.hxx>
#endif
@@ -188,138 +191,47 @@ void BasicIDE::DecBasicDialogCount()
//----------------------------------------------------------------------------
-::rtl::OUString BasicIDE::ChooseMacro( BOOL bExecute, BOOL bChooseOnly, const ::rtl::OUString& rMacroDesc )
+Sequence< ::rtl::OUString > BasicIDE::GetLibraryNames( SfxObjectShell* pShell )
{
- BASIC_MOD()->Load();
-
- if ( rMacroDesc.getLength() )
- IDE_DLL()->GetExtraData()->GetLastMacro() = String( rMacroDesc );
-
- IDE_DLL()->GetExtraData()->ChoosingMacro() = TRUE;
- SFX_APP()->EnterBasicCall();
-
- String aScriptURL;
- BOOL bError = FALSE;
- SbMethod* pMethod = NULL;
-
- Window* pParent = Application::GetDefDialogParent();
-
- MacroChooser* pChooser = new MacroChooser( pParent, TRUE );
- if ( bChooseOnly || !SvtModuleOptions().IsBasicIDE() )
- pChooser->SetMode( MACROCHOOSER_CHOOSEONLY );
-
- short nRetValue = pChooser->Execute();
-
- IDE_DLL()->GetExtraData()->ChoosingMacro() = FALSE;
-
- switch ( nRetValue )
+ // create a sorted list of module library names
+ ::std::vector<String> aModLibList;
+ Reference< script::XLibraryContainer > xModLibContainer = GetModuleLibraryContainer( pShell );
+ if ( xModLibContainer.is() )
{
- case MACRO_OK_RUN:
- {
- pMethod = pChooser->GetMacro();
-
- if ( pMethod )
- {
- SbModule* pModule = pMethod->GetModule();
- DBG_ASSERT(pModule, "BasicIDE::ChooseMacro: No Module found!");
- if ( pModule )
- {
- StarBASIC* pBasic = (StarBASIC*)pModule->GetParent();
- DBG_ASSERT(pBasic, "BasicIDE::ChooseMacro: No Basic found!");
- if ( pBasic )
- {
- BasicManager* pBasMgr = BasicIDE::FindBasicManager( pBasic );
- DBG_ASSERT(pBasMgr, "BasicIDE::ChooseMacro: No BasicManager found!");
- if ( pBasMgr )
- {
- // language
- String aLanguage = String::CreateFromAscii("StarBasic");
-
- // macro
- String aMacro;
- aMacro += pBasic->GetName();
- aMacro += '.';
- aMacro += pModule->GetName();
- aMacro += '.';
- aMacro += pMethod->GetName();
-
- // location
- String aLocation;
- SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr );
- if ( pShell )
- {
- // document basic
- SfxObjectShell* pCurrShell = SfxObjectShell::Current();
- if ( pShell == pCurrShell )
- {
- aLocation = String::CreateFromAscii("document");
- }
- else
- {
- // error
- bError = TRUE;
- ErrorBox( NULL, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_ERRORCHOOSEMACRO ) ) ).Execute();
- }
- }
- else
- {
- // application basic
- aLocation = String::CreateFromAscii("application");
- }
-
- // script URL
- if ( !bError )
- {
- aScriptURL = String::CreateFromAscii("vnd.sun.star.script:");
- aScriptURL += String::CreateFromAscii("language=");
- aScriptURL += aLanguage;
- aScriptURL += String::CreateFromAscii(",macro=");
- aScriptURL += aMacro;
- aScriptURL += String::CreateFromAscii(",location=");
- aScriptURL += aLocation;
- }
- }
- }
- }
- }
-
- if ( pMethod && bExecute )
- {
- pMethod->AddRef(); // festhalten, bis Event abgearbeitet.
- Application::PostUserEvent( LINK( IDE_DLL()->GetExtraData(), BasicIDEData, ExecuteMacroEvent ), pMethod );
- }
- }
- break;
+ Sequence< ::rtl::OUString > aModLibNames = xModLibContainer->getElementNames();
+ sal_Int32 nModLibCount = aModLibNames.getLength();
+ const ::rtl::OUString* pModLibNames = aModLibNames.getConstArray();
+ for ( sal_Int32 i = 0 ; i < nModLibCount ; i++ )
+ aModLibList.push_back( pModLibNames[ i ] );
+ ::std::sort( aModLibList.begin() , aModLibList.end() , StringCompareLessThan );
}
- delete pChooser;
-
- SFX_APP()->LeaveBasicCall();
-
- return ::rtl::OUString( aScriptURL );
-}
-
-//----------------------------------------------------------------------------
-
-Sequence< ::rtl::OUString > BasicIDE::GetMethodsFromModule( SfxObjectShell* pShell, const String& rLibName, const String& rModName )
- throw(NoSuchElementException )
-{
- // get module
- ::rtl::OUString aOUSource = GetModule( pShell, rLibName, rModName );
-
- SbModuleRef xModule = new SbModule( rModName );
- xModule->SetSource( String( aOUSource ) );
- USHORT nCount = xModule->GetMethods()->Count();
- Sequence< ::rtl::OUString > aSeqMethods( nCount );
-
- for ( USHORT i = 0; i < nCount; i++ )
+ // create a sorted list of dialog library names
+ ::std::vector<String> aDlgLibList;
+ Reference< script::XLibraryContainer > xDlgLibContainer = GetDialogLibraryContainer( pShell );
+ if ( xDlgLibContainer.is() )
{
- SbMethod* pMethod = (SbMethod*)xModule->GetMethods()->Get( i );
- DBG_ASSERT( pMethod, "Method not found! (NULL)" );
- aSeqMethods.getArray()[ i ] = pMethod->GetName();
+ Sequence< ::rtl::OUString > aDlgLibNames = xDlgLibContainer->getElementNames();
+ sal_Int32 nDlgLibCount = aDlgLibNames.getLength();
+ const ::rtl::OUString* pDlgLibNames = aDlgLibNames.getConstArray();
+ for ( sal_Int32 i = 0 ; i < nDlgLibCount ; i++ )
+ aDlgLibList.push_back( pDlgLibNames[ i ] );
+ ::std::sort( aDlgLibList.begin() , aDlgLibList.end() , StringCompareLessThan );
}
- return aSeqMethods;
+ // merge both lists
+ ::std::vector<String> aLibList( aModLibList.size() + aDlgLibList.size() );
+ ::std::merge( aModLibList.begin(), aModLibList.end(), aDlgLibList.begin(), aDlgLibList.end(), aLibList.begin(), StringCompareLessThan );
+ ::std::vector<String>::iterator aIterEnd = ::std::unique( aLibList.begin(), aLibList.end() ); // move unique elements to the front
+ aLibList.erase( aIterEnd, aLibList.end() ); // remove duplicates
+
+ // copy to sequence
+ sal_Int32 nLibCount = aLibList.size();
+ Sequence< ::rtl::OUString > aSeqLibNames( nLibCount );
+ for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
+ aSeqLibNames.getArray()[ i ] = aLibList[ i ];
+
+ return aSeqLibNames;
}
//----------------------------------------------------------------------------
@@ -394,7 +306,7 @@ Reference< container::XNameContainer > BasicIDE::GetModuleLibrary( SfxObjectShel
//----------------------------------------------------------------------------
Reference< ::com::sun::star::container::XNameContainer > BasicIDE::CreateModuleLibrary( SfxObjectShell* pShell, const String& rLibName )
- throw(ElementExistException)
+ throw(ElementExistException)
{
// get library container
Reference< script::XLibraryContainer > xLibContainer = GetModuleLibraryContainer( pShell );
@@ -418,6 +330,34 @@ Reference< ::com::sun::star::container::XNameContainer > BasicIDE::CreateModuleL
//----------------------------------------------------------------------------
+Sequence< ::rtl::OUString > BasicIDE::GetModuleNames( SfxObjectShell* pShell, const String& rLibName )
+ throw(NoSuchElementException)
+{
+ Sequence< ::rtl::OUString > aSeqModNames;
+ Reference< container::XNameContainer > xLib = GetModuleLibrary( pShell, rLibName );
+ if( xLib.is() )
+ {
+ Sequence< ::rtl::OUString > aModNames = xLib->getElementNames();
+ sal_Int32 nModCount = aModNames.getLength();
+ const ::rtl::OUString* pModNames = aModNames.getConstArray();
+
+ // sort module names
+ ::std::vector<String> aModList( nModCount );
+ for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
+ aModList[ i ] = pModNames[ i ];
+ ::std::sort( aModList.begin() , aModList.end() , StringCompareLessThan );
+
+ // copy to sequence
+ aSeqModNames.realloc( nModCount );
+ for ( i = 0 ; i < nModCount ; i++ )
+ aSeqModNames.getArray()[ i ] = aModList[ i ];
+ }
+
+ return aSeqModNames;
+}
+
+//----------------------------------------------------------------------------
+
BOOL BasicIDE::HasModule( SfxObjectShell* pShell, const String& rLibName, const String& rModName )
{
BOOL bHasModule = FALSE;
@@ -664,3 +604,139 @@ void BasicIDE::UpdateModule( SfxObjectShell* pShell, const String& rLibName, con
}
//----------------------------------------------------------------------------
+
+::rtl::OUString BasicIDE::ChooseMacro( BOOL bExecute, BOOL bChooseOnly, const ::rtl::OUString& rMacroDesc )
+{
+ BASIC_MOD()->Load();
+
+ if ( rMacroDesc.getLength() )
+ IDE_DLL()->GetExtraData()->GetLastMacro() = String( rMacroDesc );
+
+ IDE_DLL()->GetExtraData()->ChoosingMacro() = TRUE;
+ SFX_APP()->EnterBasicCall();
+
+ String aScriptURL;
+ BOOL bError = FALSE;
+ SbMethod* pMethod = NULL;
+
+ Window* pParent = Application::GetDefDialogParent();
+
+ MacroChooser* pChooser = new MacroChooser( pParent, TRUE );
+ if ( bChooseOnly || !SvtModuleOptions().IsBasicIDE() )
+ pChooser->SetMode( MACROCHOOSER_CHOOSEONLY );
+
+ short nRetValue = pChooser->Execute();
+
+ IDE_DLL()->GetExtraData()->ChoosingMacro() = FALSE;
+
+ switch ( nRetValue )
+ {
+ case MACRO_OK_RUN:
+ {
+ pMethod = pChooser->GetMacro();
+
+ if ( pMethod )
+ {
+ SbModule* pModule = pMethod->GetModule();
+ DBG_ASSERT(pModule, "BasicIDE::ChooseMacro: No Module found!");
+ if ( pModule )
+ {
+ StarBASIC* pBasic = (StarBASIC*)pModule->GetParent();
+ DBG_ASSERT(pBasic, "BasicIDE::ChooseMacro: No Basic found!");
+ if ( pBasic )
+ {
+ BasicManager* pBasMgr = BasicIDE::FindBasicManager( pBasic );
+ DBG_ASSERT(pBasMgr, "BasicIDE::ChooseMacro: No BasicManager found!");
+ if ( pBasMgr )
+ {
+ // language
+ String aLanguage = String::CreateFromAscii("StarBasic");
+
+ // macro
+ String aMacro;
+ aMacro += pBasic->GetName();
+ aMacro += '.';
+ aMacro += pModule->GetName();
+ aMacro += '.';
+ aMacro += pMethod->GetName();
+
+ // location
+ String aLocation;
+ SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr );
+ if ( pShell )
+ {
+ // document basic
+ SfxObjectShell* pCurrShell = SfxObjectShell::Current();
+ if ( pShell == pCurrShell )
+ {
+ aLocation = String::CreateFromAscii("document");
+ }
+ else
+ {
+ // error
+ bError = TRUE;
+ ErrorBox( NULL, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_ERRORCHOOSEMACRO ) ) ).Execute();
+ }
+ }
+ else
+ {
+ // application basic
+ aLocation = String::CreateFromAscii("application");
+ }
+
+ // script URL
+ if ( !bError )
+ {
+ aScriptURL = String::CreateFromAscii("vnd.sun.star.script:");
+ aScriptURL += String::CreateFromAscii("language=");
+ aScriptURL += aLanguage;
+ aScriptURL += String::CreateFromAscii(",macro=");
+ aScriptURL += aMacro;
+ aScriptURL += String::CreateFromAscii(",location=");
+ aScriptURL += aLocation;
+ }
+ }
+ }
+ }
+ }
+
+ if ( pMethod && bExecute )
+ {
+ pMethod->AddRef(); // festhalten, bis Event abgearbeitet.
+ Application::PostUserEvent( LINK( IDE_DLL()->GetExtraData(), BasicIDEData, ExecuteMacroEvent ), pMethod );
+ }
+ }
+ break;
+ }
+
+ delete pChooser;
+
+ SFX_APP()->LeaveBasicCall();
+
+ return ::rtl::OUString( aScriptURL );
+}
+
+//----------------------------------------------------------------------------
+
+Sequence< ::rtl::OUString > BasicIDE::GetMethodNames( SfxObjectShell* pShell, const String& rLibName, const String& rModName )
+ throw(NoSuchElementException )
+{
+ // get module
+ ::rtl::OUString aOUSource = GetModule( pShell, rLibName, rModName );
+
+ SbModuleRef xModule = new SbModule( rModName );
+ xModule->SetSource( String( aOUSource ) );
+ USHORT nCount = xModule->GetMethods()->Count();
+ Sequence< ::rtl::OUString > aSeqMethods( nCount );
+
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ SbMethod* pMethod = (SbMethod*)xModule->GetMethods()->Get( i );
+ DBG_ASSERT( pMethod, "Method not found! (NULL)" );
+ aSeqMethods.getArray()[ i ] = pMethod->GetName();
+ }
+
+ return aSeqMethods;
+}
+
+//----------------------------------------------------------------------------
diff --git a/basctl/source/basicide/basobj3.cxx b/basctl/source/basicide/basobj3.cxx
index f957e665bef5..30e87bd5d39c 100644
--- a/basctl/source/basicide/basobj3.cxx
+++ b/basctl/source/basicide/basobj3.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: basobj3.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: tbe $ $Date: 2001-08-29 12:20:31 $
+ * last change: $Author: tbe $ $Date: 2001-09-03 11:48:16 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -292,6 +292,88 @@ Reference< ::com::sun::star::container::XNameContainer > BasicIDE::CreateDialogL
//----------------------------------------------------------------------------
+Sequence< ::rtl::OUString > BasicIDE::GetDialogNames( SfxObjectShell* pShell, const String& rLibName )
+ throw(NoSuchElementException)
+{
+ Sequence< ::rtl::OUString > aSeqDlgNames;
+ Reference< container::XNameContainer > xLib = GetDialogLibrary( pShell, rLibName );
+ if( xLib.is() )
+ {
+ Sequence< ::rtl::OUString > aDlgNames = xLib->getElementNames();
+ sal_Int32 nDlgCount = aDlgNames.getLength();
+ const ::rtl::OUString* pDlgNames = aDlgNames.getConstArray();
+
+ // sort dialog names
+ ::std::vector<String> aDlgList( nDlgCount );
+ for ( sal_Int32 i = 0 ; i < nDlgCount ; i++ )
+ aDlgList[ i ] = pDlgNames[ i ];
+ ::std::sort( aDlgList.begin() , aDlgList.end() , StringCompareLessThan );
+
+ // copy to sequence
+ aSeqDlgNames.realloc( nDlgCount );
+ for ( i = 0 ; i < nDlgCount ; i++ )
+ aSeqDlgNames.getArray()[ i ] = aDlgList[ i ];
+ }
+
+ return aSeqDlgNames;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL BasicIDE::HasDialog( SfxObjectShell* pShell, const String& rLibName, const String& rDlgName )
+{
+ BOOL bHasDialog = FALSE;
+
+ Reference< container::XNameContainer > xLib;
+ try
+ {
+ // get library
+ xLib = GetDialogLibrary( pShell, rLibName, TRUE );
+
+ // check if library has dialog
+ ::rtl::OUString aOUDlgName( rDlgName );
+ if( xLib.is() && xLib->hasByName( aOUDlgName ) )
+ {
+ bHasDialog = TRUE;
+ }
+ }
+ catch ( container::NoSuchElementException& e )
+ {
+ ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US );
+ DBG_ERROR( aBStr.GetBuffer() );
+ }
+
+ return bHasDialog;
+}
+
+//----------------------------------------------------------------------------
+
+Reference< io::XInputStreamProvider > BasicIDE::GetDialog( SfxObjectShell* pShell, const String& rLibName, const String& rDlgName )
+ throw(NoSuchElementException)
+{
+ // get library
+ Reference< container::XNameContainer > xLib = GetDialogLibrary( pShell, rLibName, TRUE );
+
+ // get dialog
+ Reference< io::XInputStreamProvider > xISP;
+ ::rtl::OUString aOUDlgName( rDlgName );
+ if( xLib.is() && xLib->hasByName( aOUDlgName ) )
+ {
+ Any aElement = xLib->getByName( aOUDlgName );
+ aElement >>= xISP;
+ }
+ else
+ {
+ throw NoSuchElementException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicIDE::GetDialog: NoSuchElementException!") ),
+ Reference<XInterface>() );
+ }
+
+ return xISP;
+}
+
+//----------------------------------------------------------------------------
+
String BasicIDE::CreateDialogName( SfxObjectShell* pShell, const String& rLibName )
{
String aDlgName;
@@ -503,60 +585,6 @@ void BasicIDE::InsertDialog( SfxObjectShell* pShell, const String& rLibName, con
//----------------------------------------------------------------------------
-BOOL BasicIDE::HasDialog( SfxObjectShell* pShell, const String& rLibName, const String& rDlgName )
-{
- BOOL bHasDialog = FALSE;
-
- Reference< container::XNameContainer > xLib;
- try
- {
- // get library
- xLib = GetDialogLibrary( pShell, rLibName, TRUE );
-
- // check if library has dialog
- ::rtl::OUString aOUDlgName( rDlgName );
- if( xLib.is() && xLib->hasByName( aOUDlgName ) )
- {
- bHasDialog = TRUE;
- }
- }
- catch ( container::NoSuchElementException& e )
- {
- ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US );
- DBG_ERROR( aBStr.GetBuffer() );
- }
-
- return bHasDialog;
-}
-
-//----------------------------------------------------------------------------
-
-Reference< io::XInputStreamProvider > BasicIDE::GetDialog( SfxObjectShell* pShell, const String& rLibName, const String& rDlgName )
- throw(NoSuchElementException)
-{
- // get library
- Reference< container::XNameContainer > xLib = GetDialogLibrary( pShell, rLibName, TRUE );
-
- // get dialog
- Reference< io::XInputStreamProvider > xISP;
- ::rtl::OUString aOUDlgName( rDlgName );
- if( xLib.is() && xLib->hasByName( aOUDlgName ) )
- {
- Any aElement = xLib->getByName( aOUDlgName );
- aElement >>= xISP;
- }
- else
- {
- throw NoSuchElementException(
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicIDE::GetDialog: NoSuchElementException!") ),
- Reference<XInterface>() );
- }
-
- return xISP;
-}
-
-//----------------------------------------------------------------------------
-
StarBASIC* BasicIDE::FindBasic( const SbxVariable* pVar )
{
const SbxVariable* pSbx = pVar;
@@ -575,10 +603,13 @@ BasicManager* BasicIDE::FindBasicManager( StarBASIC* pLib )
SfxObjectShell* pDocShell = 0;
while ( pBasicMgr )
{
- USHORT nLibs = pBasicMgr->GetLibCount();
- for ( USHORT nLib = 0; nLib < nLibs; nLib++ )
+ Sequence< ::rtl::OUString > aLibNames = GetLibraryNames( pDocShell );
+ sal_Int32 nLibCount = aLibNames.getLength();
+ const ::rtl::OUString* pLibNames = aLibNames.getConstArray();
+
+ for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
{
- StarBASIC* pL = pBasicMgr->GetLib( nLib );
+ StarBASIC* pL = pBasicMgr->GetLib( pLibNames[ i ] );
if ( pL == pLib )
return pBasicMgr;
}
@@ -849,11 +880,14 @@ SvStrings* BasicIDE::CreateBasicLibBoxEntries()
else
aBasMgr = Application::GetAppName();
- USHORT nLibs = pBasicMgr->GetLibCount();
- for ( USHORT nLib = 0; nLib < nLibs; nLib++ )
+ // get a sorted list of library names
+ Sequence< ::rtl::OUString > aLibNames = BasicIDE::GetLibraryNames( pDocShell );
+ sal_Int32 nLibCount = aLibNames.getLength();
+ const ::rtl::OUString* pLibNames = aLibNames.getConstArray();
+
+ for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
{
- // Auch nicht geladene Libs anbieten...
- String aLibName = pBasicMgr->GetLibName( nLib );
+ String aLibName = pLibNames[ i ];
String* pEntry = new String( CreateMgrAndLibStr( aBasMgr, aLibName ) );
pStrings->Insert( pEntry, pStrings->Count() );
}
diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx
index 2919e75aa15d..c3e54b3e4eef 100644
--- a/basctl/source/basicide/bastype2.cxx
+++ b/basctl/source/basicide/bastype2.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: bastype2.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: tbe $ $Date: 2001-08-29 12:21:24 $
+ * last change: $Author: tbe $ $Date: 2001-09-03 11:49:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,8 +59,6 @@
*
************************************************************************/
-#include <vector>
-#include <algorithm>
#include <ide_pch.hxx>
@@ -129,52 +127,25 @@ void BasicTreeListBox::ScanBasic( BasicManager* pBasMgr, const String& rName )
// level 2: libraries (Standard, ...)
- // create a sorted list of module library names
- ::std::vector<String> aModLibList;
- Reference< script::XLibraryContainer > xModLibContainer = BasicIDE::GetModuleLibraryContainer( pShell );
- if ( xModLibContainer.is() )
- {
- Sequence< ::rtl::OUString > aModLibNames = xModLibContainer->getElementNames();
- sal_Int32 nModLibCount = aModLibNames.getLength();
- const ::rtl::OUString* pModLibNames = aModLibNames.getConstArray();
- for ( sal_Int32 i = 0 ; i < nModLibCount ; i++ )
- aModLibList.push_back( pModLibNames[ i ] );
- ::std::sort( aModLibList.begin() , aModLibList.end() , StringCompareLessThan );
- }
-
- // create a sorted list of dialog library names
- ::std::vector<String> aDlgLibList;
- Reference< script::XLibraryContainer > xDlgLibContainer = BasicIDE::GetDialogLibraryContainer( pShell );
- if ( xDlgLibContainer.is() )
- {
- Sequence< ::rtl::OUString > aDlgLibNames = xDlgLibContainer->getElementNames();
- sal_Int32 nDlgLibCount = aDlgLibNames.getLength();
- const ::rtl::OUString* pDlgLibNames = aDlgLibNames.getConstArray();
- for ( sal_Int32 i = 0 ; i < nDlgLibCount ; i++ )
- aDlgLibList.push_back( pDlgLibNames[ i ] );
- ::std::sort( aDlgLibList.begin() , aDlgLibList.end() , StringCompareLessThan );
- }
-
- // merge both lists
- ::std::vector<String> aLibList( aModLibList.size() + aDlgLibList.size() );
- ::std::merge( aModLibList.begin(), aModLibList.end(), aDlgLibList.begin(), aDlgLibList.end(), aLibList.begin(), StringCompareLessThan );
- ::std::vector<String>::iterator aIterEnd = ::std::unique( aLibList.begin(), aLibList.end() ); // move unique elements to the front
- aLibList.erase( aIterEnd, aLibList.end() ); // remove duplicates
-
- sal_Int32 nLibCount = aLibList.size();
+ // get a sorted list of library names
+ Sequence< ::rtl::OUString > aLibNames = BasicIDE::GetLibraryNames( pShell );
+ sal_Int32 nLibCount = aLibNames.getLength();
+ const ::rtl::OUString* pLibNames = aLibNames.getConstArray();
for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
{
- String aLibName = aLibList[ i ];
+ String aLibName = pLibNames[ i ];
::rtl::OUString aOULibName( aLibName );
// check, if the module library is loaded
BOOL bModLibLoaded = FALSE;
+ Reference< script::XLibraryContainer > xModLibContainer = BasicIDE::GetModuleLibraryContainer( pShell );
if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryLoaded( aOULibName ) )
bModLibLoaded = TRUE;
// check, if the dialog library is loaded
BOOL bDlgLibLoaded = FALSE;
+ Reference< script::XLibraryContainer > xDlgLibContainer = BasicIDE::GetDialogLibraryContainer( pShell );
if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryLoaded( aOULibName ) )
bDlgLibLoaded = TRUE;
@@ -221,57 +192,39 @@ void BasicTreeListBox::ImpCreateLibSubEntries( SvLBoxEntry* pLibRootEntry, SfxOb
{
try
{
- // get library
- Reference< container::XNameContainer > xLib = BasicIDE::GetModuleLibrary( pShell, rLibName );
+ Image aModImage( aImages.GetImage( IMGID_MODULE ) );
- if( xLib.is() )
+ // get a sorted list of module names
+ Sequence< ::rtl::OUString > aModNames = BasicIDE::GetModuleNames( pShell, rLibName );
+ sal_Int32 nModCount = aModNames.getLength();
+ const ::rtl::OUString* pModNames = aModNames.getConstArray();
+
+ for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
{
- Sequence< ::rtl::OUString > aModNames = xLib->getElementNames();
- sal_Int32 nModCount = aModNames.getLength();
- const ::rtl::OUString* pModNames = aModNames.getConstArray();
-
- // sort module names
- ::std::vector<String> aModList(nModCount);
- for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
- aModList[ i ] = pModNames[ i ];
- ::std::sort( aModList.begin() , aModList.end() , StringCompareLessThan );
-
- Image aModImage( aImages.GetImage( IMGID_MODULE ) );
- for ( i = 0 ; i < nModCount ; i++ )
+ String aModName = pModNames[ i ];
+ SvLBoxEntry* pModuleEntry = FindEntry( pLibRootEntry, aModName, OBJTYPE_MODULE );
+ if ( !pModuleEntry )
{
- String aModName = aModList[ i ];
- SvLBoxEntry* pModuleEntry = FindEntry( pLibRootEntry, aModName, OBJTYPE_MODULE );
- if ( !pModuleEntry )
- {
- pModuleEntry = InsertEntry( aModName, aModImage, aModImage, pLibRootEntry, FALSE, LIST_APPEND );
- pModuleEntry->SetUserData( new BasicEntry( OBJTYPE_MODULE ) );
- }
+ pModuleEntry = InsertEntry( aModName, aModImage, aModImage, pLibRootEntry, FALSE, LIST_APPEND );
+ pModuleEntry->SetUserData( new BasicEntry( OBJTYPE_MODULE ) );
+ }
- // methods
- if ( nMode & BROWSEMODE_SUBS )
+ // methods
+ if ( nMode & BROWSEMODE_SUBS )
+ {
+ Sequence< ::rtl::OUString > aNames = BasicIDE::GetMethodNames( pShell, rLibName, aModName );
+ sal_Int32 nCount = aNames.getLength();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+
+ Image aImage( aImages.GetImage( IMGID_MACRO ) );
+ for ( sal_Int32 j = 0 ; j < nCount ; j++ )
{
- try
+ String aName = pNames[ j ];
+ SvLBoxEntry* pEntry = FindEntry( pModuleEntry, aName, OBJTYPE_METHOD );
+ if ( !pEntry )
{
- Sequence< ::rtl::OUString > aNames = BasicIDE::GetMethodsFromModule( pShell, rLibName, aModName );
- sal_Int32 nCount = aNames.getLength();
- const ::rtl::OUString* pNames = aNames.getConstArray();
-
- Image aImage( aImages.GetImage( IMGID_MACRO ) );
- for ( sal_Int32 j = 0 ; j < nCount ; j++ )
- {
- String aName = pNames[ j ];
- SvLBoxEntry* pEntry = FindEntry( pModuleEntry, aName, OBJTYPE_METHOD );
- if ( !pEntry )
- {
- pEntry = InsertEntry( aName, aImage, aImage, pModuleEntry, FALSE, LIST_APPEND );
- pEntry->SetUserData( new BasicEntry( OBJTYPE_METHOD ) );
- }
- }
- }
- catch ( container::NoSuchElementException& e )
- {
- ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US );
- DBG_ERROR( aBStr.GetBuffer() );
+ pEntry = InsertEntry( aName, aImage, aImage, pModuleEntry, FALSE, LIST_APPEND );
+ pEntry->SetUserData( new BasicEntry( OBJTYPE_METHOD ) );
}
}
}
@@ -294,31 +247,21 @@ void BasicTreeListBox::ImpCreateLibSubEntries( SvLBoxEntry* pLibRootEntry, SfxOb
{
try
{
- // get library
- Reference< container::XNameContainer > xLib = BasicIDE::GetDialogLibrary( pShell, rLibName );
+ Image aDlgImage( aImages.GetImage( IMGID_OBJECT ) );
+
+ // get a sorted list of dialog names
+ Sequence< ::rtl::OUString > aDlgNames = BasicIDE::GetDialogNames( pShell, rLibName );
+ sal_Int32 nDlgCount = aDlgNames.getLength();
+ const ::rtl::OUString* pDlgNames = aDlgNames.getConstArray();
- if( xLib.is() )
+ for ( sal_Int32 i = 0 ; i < nDlgCount ; i++ )
{
- Sequence< ::rtl::OUString > aDlgNames = xLib->getElementNames();
- sal_Int32 nDlgCount = aDlgNames.getLength();
- const ::rtl::OUString* pDlgNames = aDlgNames.getConstArray();
-
- // sort dialog names
- ::std::vector<String> aDlgList(nDlgCount);
- for ( sal_Int32 i = 0 ; i < nDlgCount ; i++ )
- aDlgList[ i ] = pDlgNames[ i ];
- ::std::sort( aDlgList.begin() , aDlgList.end() , StringCompareLessThan );
-
- Image aDlgImage( aImages.GetImage( IMGID_OBJECT ) );
- for ( i = 0 ; i < nDlgCount ; i++ )
+ String aDlgName = pDlgNames[ i ];
+ SvLBoxEntry* pDialogEntry = FindEntry( pLibRootEntry, aDlgName, OBJTYPE_OBJECT );
+ if ( !pDialogEntry )
{
- String aDlgName = aDlgList[ i ];
- SvLBoxEntry* pDialogEntry = FindEntry( pLibRootEntry, aDlgName, OBJTYPE_OBJECT );
- if ( !pDialogEntry )
- {
- pDialogEntry = InsertEntry( aDlgName, aDlgImage, aDlgImage, pLibRootEntry, TRUE, LIST_APPEND );
- pDialogEntry->SetUserData( new BasicEntry( OBJTYPE_OBJECT ) );
- }
+ pDialogEntry = InsertEntry( aDlgName, aDlgImage, aDlgImage, pLibRootEntry, TRUE, LIST_APPEND );
+ pDialogEntry->SetUserData( new BasicEntry( OBJTYPE_OBJECT ) );
}
}
}
@@ -450,6 +393,8 @@ long BasicTreeListBox::ExpandingHdl()
BasicManager* pBasicManager = GetSelectedSbx( aLib, aDummy1, aDummy2 );
if ( aLib.Len() && !aDummy1.Len() && !aDummy2.Len() )
{
+ // TODO: check password
+ /* old code
// Beim expandieren einer Lib pruefen, ob Passwortschutz!
USHORT nLib = pBasicManager->GetLibId( aLib );
if ( pBasicManager->HasPassword( nLib ) &&
@@ -457,6 +402,7 @@ long BasicTreeListBox::ExpandingHdl()
{
bOK = QueryPassword( pBasicManager, nLib );
}
+ */
}
}
return bOK;
@@ -470,11 +416,14 @@ BOOL BasicTreeListBox::IsEntryProtected( SvLBoxEntry* pEntry )
String aLib, aDummy1, aDummy2, aDummy3;
BasicManager* pBasicManager = GetSbx( pEntry, aLib, aDummy1, aDummy2, aDummy3 );
USHORT nLib = pBasicManager->GetLibId( aLib );
+ // TODO: check password
+ /* old code
if ( pBasicManager->HasPassword( nLib ) &&
!pBasicManager->IsPasswordVerified( nLib ) )
{
bProtected = TRUE;
}
+ */
}
return bProtected;
}
diff --git a/basctl/source/basicide/bastype2.hxx b/basctl/source/basicide/bastype2.hxx
index dc297578a096..028cf5217729 100644
--- a/basctl/source/basicide/bastype2.hxx
+++ b/basctl/source/basicide/bastype2.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: bastype2.hxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: tbe $ $Date: 2001-08-29 12:22:13 $
+ * last change: $Author: tbe $ $Date: 2001-09-03 11:49:48 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -113,9 +113,6 @@ protected:
void ImpCreateLibSubEntries( SvLBoxEntry* pLibRootEntry, SfxObjectShell* pShell, const String& rLibName );
- static BOOL StringCompareLessThan( const String& rStr1, const String& rStr2 )
- { return (rStr1.CompareIgnoreCaseToAscii( rStr2 ) == COMPARE_LESS); }
-
public:
BasicTreeListBox( Window* pParent, const ResId& rRes );
~BasicTreeListBox();
diff --git a/basctl/source/basicide/iderdll.cxx b/basctl/source/basicide/iderdll.cxx
index 3578f84c6e09..4a3912f14f01 100644
--- a/basctl/source/basicide/iderdll.cxx
+++ b/basctl/source/basicide/iderdll.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: iderdll.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: tbe $ $Date: 2001-07-25 11:40:36 $
+ * last change: $Author: tbe $ $Date: 2001-09-03 11:51:39 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -256,9 +256,10 @@ IMPL_LINK( BasicIDEData, GlobalBasicErrorHdl, StarBASIC *, pBasic )
if ( pBasicManager )
{
USHORT nLib = pBasicManager->GetLibId( pBasic );
- if ( !pBasicManager->HasPassword( nLib ) ||
- pBasicManager->IsPasswordVerified( nLib ) )
- {
+ // TODO: check password
+ //if ( !pBasicManager->HasPassword( nLib ) ||
+ // pBasicManager->IsPasswordVerified( nLib ) )
+ //{
pShell = IDE_DLL()->GetShell();
if ( !pShell )
{
@@ -271,7 +272,7 @@ IMPL_LINK( BasicIDEData, GlobalBasicErrorHdl, StarBASIC *, pBasic )
}
pShell = IDE_DLL()->GetShell();
}
- }
+ //}
}
}
@@ -292,14 +293,17 @@ IMPL_LINK( BasicIDEData, GlobalBasicBreakHdl, StarBASIC *, pBasic )
BasicManager* pBasicManager = BasicIDE::FindBasicManager( pBasic );
if ( pBasicManager )
{
+ // TODO: check password
+ /* old code
USHORT nLib = pBasicManager->GetLibId( pBasic );
// Hier lande ich zweimal, wenn Step into protected Basic
// => schlecht, wenn Passwortabfrage 2x, ausserdem sieht man in
// dem PasswordDlg nicht, fuer welche Lib...
// => An dieser Stelle keine Passwort-Abfrage starten
if ( !pBasicManager->HasPassword( nLib ) ||
- pBasicManager->IsPasswordVerified( nLib ) /* ||
- QueryPassword( pBasicManager, nLib ) */ )
+ pBasicManager->IsPasswordVerified( nLib )
+ //|| QueryPassword( pBasicManager, nLib )
+ )
{
return pShell->CallBasicBreakHdl( pBasic );
}
@@ -308,6 +312,9 @@ IMPL_LINK( BasicIDEData, GlobalBasicBreakHdl, StarBASIC *, pBasic )
// Ein Step-Out muesste mich aus den geschuetzten Bereich befoerdern...
return SbDEBUG_STEPOUT;
}
+ */
+ /* new code */
+ return pShell->CallBasicBreakHdl( pBasic );
}
}
diff --git a/basctl/source/basicide/macrodlg.cxx b/basctl/source/basicide/macrodlg.cxx
index 64ab4ba84849..97c51d8853ff 100644
--- a/basctl/source/basicide/macrodlg.cxx
+++ b/basctl/source/basicide/macrodlg.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: macrodlg.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: tbe $ $Date: 2001-08-29 12:23:52 $
+ * last change: $Author: tbe $ $Date: 2001-09-03 11:52:23 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -433,7 +433,8 @@ SbMethod* MacroChooser::CreateMacro()
pModule = (SbModule*)pBasic->GetModules()->Get( 0 );
SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr );
- if ( aLibName.Len() == 0 )
+
+ if ( aLibName != pBasic->GetName() )
aLibName = pBasic->GetName();
if ( aModName.Len() == 0 )
aModName = pModule ? pModule->GetName() : BasicIDE::CreateModuleName( pShell, aLibName );
diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx
index d8ea984967d4..774624307bce 100644
--- a/basctl/source/basicide/moduldl2.cxx
+++ b/basctl/source/basicide/moduldl2.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: moduldl2.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: tbe $ $Date: 2001-08-29 12:24:45 $
+ * last change: $Author: tbe $ $Date: 2001-09-03 11:54:32 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,8 +62,6 @@
#define GLOBALOVERFLOW
-#include <vector>
-#include <algorithm>
#include <ide_pch.hxx>
@@ -287,12 +285,36 @@ IMPL_LINK( LibPage, ButtonHdl, Button *, pButton )
BOOL bHadPassword = aLibBox.GetBasicManager()->HasPassword( nLib );
// Noch nicht geladen, falls gerade erst aktiviert.
// Wuerde sonst erst beim Beenden des Dlg's geschehen.
+ /* old code
if ( !aLibBox.GetBasicManager()->IsLibLoaded( nLib ) )
{
Application::EnterWait();
aLibBox.GetBasicManager()->LoadLib( nLib );
Application::LeaveWait();
}
+ */
+
+ SfxObjectShell* pShell = BasicIDE::FindDocShell( aLibBox.GetBasicManager() );
+ String aLibName( aLibBox.GetEntryText( pCurEntry, 0 ) );
+ ::rtl::OUString aOULibName( aLibName );
+
+ // load module library (if not loaded)
+ Reference< script::XLibraryContainer > xModLibContainer = BasicIDE::GetModuleLibraryContainer( pShell );
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && !xModLibContainer->isLibraryLoaded( aOULibName ) )
+ {
+ Application::EnterWait();
+ xModLibContainer->loadLibrary( aOULibName );
+ Application::LeaveWait();
+ }
+
+ // load dialog library (if not loaded)
+ Reference< script::XLibraryContainer > xDlgLibContainer = BasicIDE::GetDialogLibraryContainer( pShell );
+ if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && !xDlgLibContainer->isLibraryLoaded( aOULibName ) )
+ {
+ Application::EnterWait();
+ xDlgLibContainer->loadLibrary( aOULibName );
+ Application::LeaveWait();
+ }
SvxPasswordDialog* pDlg = new SvxPasswordDialog( this, TRUE );
String aPassword = pBasMgr->GetPassword( nLib );
@@ -684,41 +706,13 @@ void LibPage::SetCurLib()
aLibBox.Clear();
//Image aLockedImg( IDEResId( RID_IMG_LOCKED ) );
- // create a sorted list of module library names
- ::std::vector<String> aModLibList;
- Reference< script::XLibraryContainer > xModLibContainer = BasicIDE::GetModuleLibraryContainer( pShell );
- if ( xModLibContainer.is() )
- {
- Sequence< ::rtl::OUString > aModLibNames = xModLibContainer->getElementNames();
- sal_Int32 nModLibCount = aModLibNames.getLength();
- const ::rtl::OUString* pModLibNames = aModLibNames.getConstArray();
- for ( sal_Int32 i = 0 ; i < nModLibCount ; i++ )
- aModLibList.push_back( pModLibNames[ i ] );
- ::std::sort( aModLibList.begin() , aModLibList.end() , StringCompareLessThan );
- }
-
- // create a sorted list of dialog library names
- ::std::vector<String> aDlgLibList;
- Reference< script::XLibraryContainer > xDlgLibContainer = BasicIDE::GetDialogLibraryContainer( pShell );
- if ( xDlgLibContainer.is() )
- {
- Sequence< ::rtl::OUString > aDlgLibNames = xDlgLibContainer->getElementNames();
- sal_Int32 nDlgLibCount = aDlgLibNames.getLength();
- const ::rtl::OUString* pDlgLibNames = aDlgLibNames.getConstArray();
- for ( sal_Int32 i = 0 ; i < nDlgLibCount ; i++ )
- aDlgLibList.push_back( pDlgLibNames[ i ] );
- ::std::sort( aDlgLibList.begin() , aDlgLibList.end() , StringCompareLessThan );
- }
-
- // merge both lists
- ::std::vector<String> aLibList( aModLibList.size() + aDlgLibList.size() );
- ::std::merge( aModLibList.begin(), aModLibList.end(), aDlgLibList.begin(), aDlgLibList.end(), aLibList.begin(), StringCompareLessThan );
- ::std::vector<String>::iterator aIterEnd = ::std::unique( aLibList.begin(), aLibList.end() ); // move unique elements to the front
- aLibList.erase( aIterEnd, aLibList.end() ); // remove duplicates
+ // get a sorted list of library names
+ Sequence< ::rtl::OUString > aLibNames = BasicIDE::GetLibraryNames( pShell );
+ sal_Int32 nLibCount = aLibNames.getLength();
+ const ::rtl::OUString* pLibNames = aLibNames.getConstArray();
- sal_Int32 nLibCount = aLibList.size();
for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
- ImpInsertLibEntry( aLibList[ i ], i );
+ ImpInsertLibEntry( pLibNames[ i ], i );
aLibBox.SetCurEntry( aLibBox.GetEntry( 0 ) );
/*
diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx
index dbc1a4d6cd53..156c7ca46048 100644
--- a/basctl/source/basicide/moduldlg.cxx
+++ b/basctl/source/basicide/moduldlg.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: moduldlg.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: tbe $ $Date: 2001-08-29 12:25:29 $
+ * last change: $Author: tbe $ $Date: 2001-09-03 11:55:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -183,11 +183,13 @@ BOOL __EXPORT ExtBasicTreeListBox::NotifyAcceptDrop( SvLBoxEntry* pEntry )
// don't drop on a library, which is not loaded or password protected
if ( bValid && ( nDepth == 1 ) )
{
- String aLib = GetEntryText( pEntry );
- String aMgr = GetEntryText( GetParent( pEntry ) );
- BasicManager* pBasicManager = BasicIDE::FindBasicManager( aMgr );
- if ( pBasicManager )
+ String aLibName = GetEntryText( pEntry );
+ String aBasMgrName = GetEntryText( GetParent( pEntry ) );
+ BasicManager* pBasMgr = BasicIDE::FindBasicManager( aBasMgrName );
+ if ( pBasMgr )
{
+ // TODO: check password
+ /* old code
USHORT nLib = pBasicManager->GetLibId( aLib );
if ( !pBasicManager->IsLibLoaded( nLib ) || (
pBasicManager->HasPassword( nLib ) &&
@@ -195,6 +197,20 @@ BOOL __EXPORT ExtBasicTreeListBox::NotifyAcceptDrop( SvLBoxEntry* pEntry )
{
bValid = FALSE;
}
+ */
+
+ SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr );
+ ::rtl::OUString aOULibName( aLibName );
+
+ // check if module library is loaded
+ Reference< script::XLibraryContainer > xModLibContainer = BasicIDE::GetModuleLibraryContainer( pShell );
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && !xModLibContainer->isLibraryLoaded( aOULibName ) )
+ bValid = FALSE;
+
+ // check if dialog library is loaded
+ Reference< script::XLibraryContainer > xDlgLibContainer = BasicIDE::GetDialogLibraryContainer( pShell );
+ if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && !xDlgLibContainer->isLibraryLoaded( aOULibName ) )
+ bValid = FALSE;
}
else
bValid = FALSE;
diff --git a/basctl/source/basicide/moduldlg.hxx b/basctl/source/basicide/moduldlg.hxx
index ad66b0e5ca1f..92a20b15309c 100644
--- a/basctl/source/basicide/moduldlg.hxx
+++ b/basctl/source/basicide/moduldlg.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: moduldlg.hxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: tbe $ $Date: 2001-08-29 12:26:11 $
+ * last change: $Author: tbe $ $Date: 2001-09-03 11:56:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -328,9 +328,6 @@ protected:
TabDialog* pTabDlg;
- static BOOL StringCompareLessThan( const String& rStr1, const String& rStr2 )
- { return (rStr1.CompareIgnoreCaseToAscii( rStr2 ) == COMPARE_LESS); }
-
public:
LibPage( Window* pParent );