diff options
-rw-r--r-- | basctl/prj/d.lst | 3 | ||||
-rw-r--r-- | basctl/source/basicide/baside2.cxx | 13 | ||||
-rw-r--r-- | basctl/source/basicide/baside2.hxx | 17 | ||||
-rw-r--r-- | basctl/source/basicide/baside2b.cxx | 39 | ||||
-rw-r--r-- | basctl/source/basicide/basides1.cxx | 14 | ||||
-rw-r--r-- | basctl/source/basicide/basides2.cxx | 6 | ||||
-rw-r--r-- | basctl/source/basicide/basobj2.cxx | 90 | ||||
-rw-r--r-- | basctl/source/basicide/basobj3.cxx | 146 | ||||
-rw-r--r-- | basctl/source/basicide/bastype2.cxx | 129 | ||||
-rw-r--r-- | basctl/source/basicide/bastype2.hxx | 12 | ||||
-rw-r--r-- | basctl/source/basicide/bastype3.cxx | 84 | ||||
-rw-r--r-- | basctl/source/basicide/macrodlg.cxx | 11 | ||||
-rw-r--r-- | basctl/source/basicide/moduldl2.cxx | 343 | ||||
-rw-r--r-- | basctl/source/basicide/moduldlg.cxx | 58 | ||||
-rw-r--r-- | basctl/source/basicide/moduldlg.hxx | 33 |
15 files changed, 608 insertions, 390 deletions
diff --git a/basctl/prj/d.lst b/basctl/prj/d.lst index 19898c4f6069..26bafd3a3000 100644 --- a/basctl/prj/d.lst +++ b/basctl/prj/d.lst @@ -2,14 +2,11 @@ touch: ..\inc\hid.lst %_DEST%\bin%_EXT%\hid.lst ..\%__SRC%\inc\basslots.ilb %_DEST%\inc%_EXT%\basslots.ilb ..\%__SRC%\inc\\*.ilb* %_DEST%\inc%_EXT%\*.ilb* ..\%__SRC%\lib\lib*.* %_DEST%\lib%_EXT%\lib*.* -..\%__SRC%\slb\basctl.lib %_DEST%\lib%_EXT%\xbasctl.lib -..\%__SRC%\lib\basctl.lib %_DEST%\lib%_EXT%\basctl.lib ..\%__SRC%\bin\basctl*.dll %_DEST%\bin%_EXT%\basctl*.dll ..\%__SRC%\bin\basctl*.res %_DEST%\bin%_EXT%\basctl*.res ..\%__SRC%\misc\basctl*.map %_DEST%\bin%_EXT%\basctl*.map ..\%__SRC%\misc\basctl.csv %_DEST%\inc%_EXT%\basctl.csv ..\%__SRC%\misc\*.hid %_DEST%\bin%_EXT%\*.hid -..\%__SRC%\lib\basctl.lib %_DEST%\lib%_EXT%\basctl.lib ..\%__SRC%\slb\ybctl.lib %_DEST%\lib%_EXT%\ybctl.lib del %_DEST%\inc%_EXT%\baside.hxx diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index 67aa9bf6d0b6..a09587b627eb 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -2,9 +2,9 @@ * * $RCSfile: baside2.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: tbe $ $Date: 2001-07-25 14:51:32 $ + * last change: $Author: tbe $ $Date: 2001-08-29 12:15:59 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -873,6 +873,9 @@ void __EXPORT ModulWindow::UpdateData() // UpdateData wird gerufen, wenn sich der Source von aussen // geaendert hat. // => Keine Unterbrechungen erwuenscht! + + SetModule( ::rtl::OUString( xModule->GetSource() ) ); + if ( GetEditView() ) { TextSelection aSel = GetEditView()->GetSelection(); @@ -1153,7 +1156,7 @@ void __EXPORT ModulWindow::GoOnTop() IDE_DLL()->GetShell()->GetViewFrame()->ToTop(); } -String ModulWindow::GetModuleName() +String ModulWindow::GetSbModuleName() { String aModuleName; if ( xModule.Is() ) @@ -1165,7 +1168,7 @@ String ModulWindow::GetModuleName() String __EXPORT ModulWindow::GetTitle() { - return GetModuleName(); + return GetSbModuleName(); } @@ -1287,7 +1290,7 @@ String ModulWindow::CreateSbxDescription() { String aDescription = IDEBaseWindow::CreateSbxDescription(); aDescription += ';'; - aDescription += GetModule()->GetName(); + aDescription += GetSbModule()->GetName(); return aDescription; } diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index 98eeb61d73c6..61503671236e 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -2,9 +2,9 @@ * * $RCSfile: baside2.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: tbe $ $Date: 2001-08-15 13:54:43 $ + * last change: $Author: tbe $ $Date: 2001-08-29 12:16:57 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -410,9 +410,9 @@ public: virtual void SetReadOnly( BOOL bReadOnly ); - SbModule* GetModule() { return xModule; } - void SetModule( SbModule* pModule ) { xModule = pModule; } - String GetModuleName(); + SbModule* GetSbModule() { return xModule; } + void SetSbModule( SbModule* pModule ) { xModule = pModule; } + String GetSbModuleName(); BOOL CompileBasic(); BOOL BasicRun(); @@ -467,8 +467,11 @@ public: const String& GetLibName() const { return m_aLibName; } void SetLibName( const String& aLibName ) { m_aLibName = aLibName; } - const String& GetModName() const { return m_aModName; } - void SetModName( const String& aName ) { m_aModName = aName; } + const String& GetModuleName() const { return m_aModName; } + void SetModuleName( const String& aName ) { m_aModName = aName; } + + const ::rtl::OUString& GetModule() const { return m_aModule; } + void SetModule( const ::rtl::OUString& aModule ) { m_aModule = aModule; } }; class ModulWindowLayout: public Window diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 74aaabb4d9e4..e949fd60b911 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -2,9 +2,9 @@ * * $RCSfile: baside2b.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: tbe $ $Date: 2001-07-10 11:30:53 $ + * last change: $Author: tbe $ $Date: 2001-08-29 12:17:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -649,9 +649,34 @@ BOOL EditorWindow::SetSourceInBasic( BOOL bQuiet ) else if ( !StarBASIC::IsRunning() ) // Nicht zur Laufzeit! { String aSource( pEditEngine->GetText() ); - DBG_ASSERT( pModulWindow->GetModule(), "Kein Modul?!" ); - pModulWindow->GetModule()->SetSource( aSource ); - BasicIDE::UpdateModuleInLibrary( pModulWindow->GetModule() ); + DBG_ASSERT( pModulWindow->GetSbModule(), "Kein Modul?!" ); + pModulWindow->GetSbModule()->SetSource( aSource ); + pModulWindow->SetModule( ::rtl::OUString( aSource ) ); + + // update module in library + SbModule* pModule = pModulWindow->GetSbModule(); + DBG_ASSERT(pModule, "EditorWindow::SetSourceInBasic: No Module found!"); + if ( pModule ) + { + SbxObject* pParent = pModule->GetParent(); + StarBASIC* pBasic = PTR_CAST(StarBASIC,pParent); + DBG_ASSERT(pBasic, "EditorWindow::SetSourceInBasic: No Basic found!"); + if ( pBasic ) + { + BasicManager* pBasMgr = BasicIDE::FindBasicManager( pBasic ); + DBG_ASSERT(pBasMgr, "EditorWindow::SetSourceInBasic: No BasicManager found!"); + if ( pBasMgr ) + { + SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr ); + String aLibName = pBasic->GetName(); + String aModName = pModule->GetName(); + ::rtl::OUString aModule = pModule->GetSource(); + + BasicIDE::UpdateModule( pShell, aLibName, aModName, aModule ); + } + } + } + pEditEngine->SetModified( FALSE ); BasicIDE::MarkDocShellModified( pModulWindow->GetBasic() ); bChanged = TRUE; @@ -667,7 +692,7 @@ void EditorWindow::CreateEditEngine() return; #ifdef DEBUG - BOOL bModified = pModulWindow->GetModule()->IsModified(); + BOOL bModified = pModulWindow->GetSbModule()->IsModified(); #endif @@ -697,7 +722,7 @@ void EditorWindow::CreateEditEngine() aHighlighter.initialize( HIGHLIGHT_BASIC ); bDoSyntaxHighlight = FALSE; // Bei grossen Texten zu langsam... - String aSource( pModulWindow->GetModule()->GetSource() ); + String aSource( pModulWindow->GetSbModule()->GetSource() ); aSource.ConvertLineEnd( LINEEND_LF ); USHORT nLines = aSource.GetTokenCount( LINE_SEP ); diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index d5756b63fa91..7d0a43fcb84d 100644 --- a/basctl/source/basicide/basides1.cxx +++ b/basctl/source/basicide/basides1.cxx @@ -2,9 +2,9 @@ * * $RCSfile: basides1.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: tbe $ $Date: 2001-07-25 14:51:32 $ + * last change: $Author: tbe $ $Date: 2001-08-29 12:18:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -126,7 +126,7 @@ void __EXPORT BasicIDEShell::ExecuteCurrent( SfxRequest& rReq ) ModulWindow* pWin = (ModulWindow*)pCurWin; SfxObjectShell* pShell = pWin->GetShell(); String aLibName = pWin->GetLibName(); - String aName = pWin->GetModName(); + String aName = pWin->GetModuleName(); if ( QueryDelModule( aName, pCurWin ) ) { try @@ -492,7 +492,7 @@ void __EXPORT BasicIDEShell::ExecuteGlobal( SfxRequest& rReq ) DBG_ASSERT( nId, "No entry in Tabbar!" ); if ( nId ) { - pTabBar->SetPageText( nId, pEditWin->GetModName() ); + pTabBar->SetPageText( nId, pEditWin->GetModuleName() ); } } } @@ -986,7 +986,7 @@ void BasicIDEShell::SetCurWindow( IDEBaseWindow* pNewWin, BOOL bUpdateTabBar, BO { StarBASIC* pLib = ((ModulWindow*)pCurWin)->GetBasic(); LibInfo* pLibInf = IDE_DLL()->GetExtraData()->GetLibInfos().GetInfo( pLib, TRUE ); - pLibInf->aCurrentModule = ((ModulWindow*)pCurWin)->GetModule()->GetName(); + pLibInf->aCurrentModule = ((ModulWindow*)pCurWin)->GetSbModule()->GetName(); } } else @@ -1048,7 +1048,7 @@ IDEBaseWindow* BasicIDEShell::FindWindow( const SbxObject* pObj, BOOL bFindSuspe return pWin; else if ( pWin->IsA( TYPE( ModulWindow ) ) ) { - if ( ((ModulWindow*)pWin)->GetModule() == pObj ) + if ( ((ModulWindow*)pWin)->GetSbModule() == pObj ) return pWin; } else @@ -1074,7 +1074,7 @@ IDEBaseWindow* BasicIDEShell::FindWindow( SfxObjectShell* pShell, const String& { if ( ((ModulWindow*)pWin)->GetShell() == pShell && ((ModulWindow*)pWin)->GetLibName() == rLibName && - ((ModulWindow*)pWin)->GetModName() == rName && + ((ModulWindow*)pWin)->GetModuleName() == rName && nType == BASICIDE_TYPE_MODULE ) return pWin; } diff --git a/basctl/source/basicide/basides2.cxx b/basctl/source/basicide/basides2.cxx index 5633de74e5a7..68f147108d3f 100644 --- a/basctl/source/basicide/basides2.cxx +++ b/basctl/source/basicide/basides2.cxx @@ -2,9 +2,9 @@ * * $RCSfile: basides2.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: tbe $ $Date: 2001-06-28 15:26:41 $ + * last change: $Author: tbe $ $Date: 2001-08-29 12:19:15 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -305,7 +305,7 @@ ModulWindow* BasicIDEShell::FindBasWin( StarBASIC* pBasic, const String& rModNam { if ( ( !pWin->IsSuspended() || bFindSuspended ) && pWin->IsA( TYPE( ModulWindow ) ) ) { - String aMod( ((ModulWindow*)pWin)->GetModName() ); + String aMod( ((ModulWindow*)pWin)->GetModuleName() ); if ( !pBasic ) // nur irgendeins finden... pModWin = (ModulWindow*)pWin; else if ( ( pWin->GetBasic() == pBasic ) && ( aMod == rModName ) ) diff --git a/basctl/source/basicide/basobj2.cxx b/basctl/source/basicide/basobj2.cxx index 30ad5aa24f74..d803d6429391 100644 --- a/basctl/source/basicide/basobj2.cxx +++ b/basctl/source/basicide/basobj2.cxx @@ -2,9 +2,9 @@ * * $RCSfile: basobj2.cxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: tbe $ $Date: 2001-08-15 13:54:43 $ + * last change: $Author: tbe $ $Date: 2001-08-29 12:19:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -324,8 +324,7 @@ Sequence< ::rtl::OUString > BasicIDE::GetMethodsFromModule( SfxObjectShell* pShe //---------------------------------------------------------------------------- -Reference< container::XNameContainer > BasicIDE::GetModuleLibrary( SfxObjectShell* pShell, const String& rLibName, BOOL bLoadLibrary ) - throw(NoSuchElementException) +Reference< script::XLibraryContainer > BasicIDE::GetModuleLibraryContainer( SfxObjectShell* pShell ) { // get library container Reference< script::XLibraryContainer > xLibContainer; @@ -340,6 +339,36 @@ Reference< container::XNameContainer > BasicIDE::GetModuleLibrary( SfxObjectShel xLibContainer = Reference< script::XLibraryContainer >( SFX_APP()->GetBasicContainer(), UNO_QUERY ); } + return xLibContainer; +} + +//---------------------------------------------------------------------------- + +BOOL BasicIDE::HasModuleLibrary( SfxObjectShell* pShell, const String& rLibName ) +{ + BOOL bHasModuleLibrary = FALSE; + + // get library container + Reference< script::XLibraryContainer > xLibContainer = GetModuleLibraryContainer( pShell ); + + // check if library container has module library + ::rtl::OUString aOULibName( rLibName ); + if( xLibContainer.is() && xLibContainer->hasByName( aOULibName ) ) + { + bHasModuleLibrary = TRUE; + } + + return bHasModuleLibrary; +} + +//---------------------------------------------------------------------------- + +Reference< container::XNameContainer > BasicIDE::GetModuleLibrary( SfxObjectShell* pShell, const String& rLibName, BOOL bLoadLibrary ) + throw(NoSuchElementException) +{ + // get library container + Reference< script::XLibraryContainer > xLibContainer = GetModuleLibraryContainer( pShell ); + // get library Reference< container::XNameContainer > xLib; ::rtl::OUString aOULibName( rLibName ); @@ -364,6 +393,31 @@ Reference< container::XNameContainer > BasicIDE::GetModuleLibrary( SfxObjectShel //---------------------------------------------------------------------------- +Reference< ::com::sun::star::container::XNameContainer > BasicIDE::CreateModuleLibrary( SfxObjectShell* pShell, const String& rLibName ) + throw(ElementExistException) +{ + // get library container + Reference< script::XLibraryContainer > xLibContainer = GetModuleLibraryContainer( pShell ); + + // create module library + Reference< container::XNameContainer > xLib; + ::rtl::OUString aOULibName( rLibName ); + if( xLibContainer.is() && !xLibContainer->hasByName( aOULibName ) ) + { + xLib = xLibContainer->createLibrary( aOULibName ); + } + else + { + throw ElementExistException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicIDE::CreateModuleLibrary: ElementExistException!") ), + Reference<XInterface>() ); + } + + return xLib; +} + +//---------------------------------------------------------------------------- + BOOL BasicIDE::HasModule( SfxObjectShell* pShell, const String& rLibName, const String& rModName ) { BOOL bHasModule = FALSE; @@ -520,10 +574,10 @@ void BasicIDE::RenameModule( SfxObjectShell* pShell, const String& rLibName, con ModulWindow* pModWin = (ModulWindow*)pWin; // set new name in module window - pModWin->SetModName( rNewName ); + pModWin->SetModuleName( rNewName ); // set new module in module window - pModWin->SetModule( (SbModule*)pWin->GetBasic()->FindModule( rNewName ) ); + pModWin->SetSbModule( (SbModule*)pWin->GetBasic()->FindModule( rNewName ) ); // update tabwriter USHORT nId = (USHORT)(pIDEShell->GetIDEWindowTable()).GetKey( pWin ); @@ -586,3 +640,27 @@ void BasicIDE::InsertModule( SfxObjectShell* pShell, const String& rLibName, con } //---------------------------------------------------------------------------- + +void BasicIDE::UpdateModule( SfxObjectShell* pShell, const String& rLibName, const String& rModName, ::rtl::OUString& aModule ) + throw(NoSuchElementException) +{ + // get library + Reference< container::XNameContainer > xLib = GetModuleLibrary( pShell, rLibName, TRUE ); + + // update module in library + ::rtl::OUString aOUModName( rModName ); + if ( xLib.is() && xLib->hasByName( aOUModName ) ) + { + Any aElement; + aElement <<= aModule; + xLib->replaceByName( aOUModName, aElement ); + } + else + { + throw NoSuchElementException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicIDE::UpdateModule: NoSuchElementException!") ), + Reference<XInterface>() ); + } +} + +//---------------------------------------------------------------------------- diff --git a/basctl/source/basicide/basobj3.cxx b/basctl/source/basicide/basobj3.cxx index b73efbef6747..f957e665bef5 100644 --- a/basctl/source/basicide/basobj3.cxx +++ b/basctl/source/basicide/basobj3.cxx @@ -2,9 +2,9 @@ * * $RCSfile: basobj3.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: tbe $ $Date: 2001-07-27 18:03:04 $ + * last change: $Author: tbe $ $Date: 2001-08-29 12:20:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -164,25 +164,41 @@ SbMethod* BasicIDE::CreateMacro( SbModule* pModule, const String& rMacroName ) aSource += aSubStr; pModule->SetSource( aSource ); - BasicIDE::UpdateModuleInLibrary( pModule ); -// SbxObject* pObject = pModule->GetParent(); -// DBG_ASSERT( pObject->ISA( StarBASIC ), "Kein Basic! (GetParent)" ); -// ((StarBASIC*)pObject)->Compile( pModule ); + + // update module in library + SbxObject* pParent = pModule->GetParent(); + StarBASIC* pBasic = PTR_CAST(StarBASIC,pParent); + DBG_ASSERT(pBasic, "BasicIDE::CreateMacro: No Basic found!"); + if ( pBasic ) + { + BasicManager* pBasMgr = BasicIDE::FindBasicManager( pBasic ); + DBG_ASSERT(pBasMgr, "BasicIDE::CreateMacro: No BasicManager found!"); + if ( pBasMgr ) + { + SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr ); + String aLibName = pBasic->GetName(); + String aModName = pModule->GetName(); + ::rtl::OUString aModule = pModule->GetSource(); + + BasicIDE::UpdateModule( pShell, aLibName, aModName, aModule ); + } + } + SbMethod* pMethod = (SbMethod*)pModule->GetMethods()->Find( aMacroName, SbxCLASS_METHOD ); if( pDispatcher ) { pDispatcher->Execute( SID_BASICIDE_UPDATEALLMODULESOURCES ); } - SbxObject* pParent = pModule->GetParent(); - if ( pParent && pParent->ISA( StarBASIC ) ) - BasicIDE::MarkDocShellModified( (StarBASIC*)pParent ); + + if ( pBasic ) + BasicIDE::MarkDocShellModified( pBasic ); + return pMethod; } //---------------------------------------------------------------------------- -Reference< container::XNameContainer > BasicIDE::GetDialogLibrary( SfxObjectShell* pShell, const String& rLibName, BOOL bLoadLibrary ) - throw(NoSuchElementException) +Reference< script::XLibraryContainer > BasicIDE::GetDialogLibraryContainer( SfxObjectShell* pShell ) { // get library container Reference< script::XLibraryContainer > xLibContainer; @@ -197,6 +213,36 @@ Reference< container::XNameContainer > BasicIDE::GetDialogLibrary( SfxObjectShel xLibContainer = Reference< script::XLibraryContainer >( SFX_APP()->GetDialogContainer(), UNO_QUERY ); } + return xLibContainer; +} + +//---------------------------------------------------------------------------- + +BOOL BasicIDE::HasDialogLibrary( SfxObjectShell* pShell, const String& rLibName ) +{ + BOOL bHasDialogLibrary = FALSE; + + // get library container + Reference< script::XLibraryContainer > xLibContainer = GetDialogLibraryContainer( pShell ); + + // check if library container has dialog library + ::rtl::OUString aOULibName( rLibName ); + if( xLibContainer.is() && xLibContainer->hasByName( aOULibName ) ) + { + bHasDialogLibrary = TRUE; + } + + return bHasDialogLibrary; +} + +//---------------------------------------------------------------------------- + +Reference< container::XNameContainer > BasicIDE::GetDialogLibrary( SfxObjectShell* pShell, const String& rLibName, BOOL bLoadLibrary ) + throw(NoSuchElementException) +{ + // get library container + Reference< script::XLibraryContainer > xLibContainer = GetDialogLibraryContainer( pShell ); + // get library Reference< container::XNameContainer > xLib; ::rtl::OUString aOULibName( rLibName ); @@ -221,6 +267,31 @@ Reference< container::XNameContainer > BasicIDE::GetDialogLibrary( SfxObjectShel //---------------------------------------------------------------------------- +Reference< ::com::sun::star::container::XNameContainer > BasicIDE::CreateDialogLibrary( SfxObjectShell* pShell, const String& rLibName ) + throw(ElementExistException) +{ + // get library container + Reference< script::XLibraryContainer > xLibContainer = GetDialogLibraryContainer( pShell ); + + // create dialog library + Reference< container::XNameContainer > xLib; + ::rtl::OUString aOULibName( rLibName ); + if( xLibContainer.is() && !xLibContainer->hasByName( aOULibName ) ) + { + xLib = xLibContainer->createLibrary( aOULibName ); + } + else + { + throw ElementExistException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicIDE::CreateDialogLibrary: ElementExistException!") ), + Reference<XInterface>() ); + } + + return xLib; +} + +//---------------------------------------------------------------------------- + String BasicIDE::CreateDialogName( SfxObjectShell* pShell, const String& rLibName ) { String aDlgName; @@ -498,59 +569,6 @@ StarBASIC* BasicIDE::FindBasic( const SbxVariable* pVar ) //---------------------------------------------------------------------------- -void BasicIDE::UpdateModuleInLibrary( SbModule* pMod ) -{ - if( !pMod ) - return; - - SbxObject* pParent = pMod->GetParent(); - StarBASIC* pLib = PTR_CAST(StarBASIC,pParent); - if( !pLib ) - return; - - Reference< script::XLibraryContainer > xLibContainer; - BasicManager* pBasMgr = FindBasicManager( pLib ); - if ( pBasMgr ) - { - SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr ); - if ( pShell ) - { - xLibContainer = uno::Reference< script::XLibraryContainer > - ( pShell->GetBasicContainer(), uno::UNO_QUERY ); - } - else - { - xLibContainer = uno::Reference< script::XLibraryContainer > - ( SFX_APP()->GetBasicContainer(), uno::UNO_QUERY ); - } - } - - if( xLibContainer.is() ) - { - String aLibName = pLib->GetName(); - if( !xLibContainer->hasByName( aLibName ) ) - xLibContainer->createLibrary( aLibName ); - - Any aLibAny = xLibContainer->getByName( aLibName ); - Reference< container::XNameContainer > xLib; - aLibAny >>= xLib; - if( xLib.is() ) - { - ::rtl::OUString aModName = pMod->GetName(); - ::rtl::OUString aSource = pMod->GetSource(); - Any aSourceAny; - aSourceAny <<= aSource; - if( xLib->hasByName( aModName ) ) - xLib->replaceByName( aModName, aSourceAny ); - else - xLib->insertByName( aModName, aSourceAny ); - } - } - -} - -//---------------------------------------------------------------------------- - BasicManager* BasicIDE::FindBasicManager( StarBASIC* pLib ) { BasicManager* pBasicMgr = SFX_APP()->GetBasicManager(); diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx index 4a84b40aea55..2919e75aa15d 100644 --- a/basctl/source/basicide/bastype2.cxx +++ b/basctl/source/basicide/bastype2.cxx @@ -2,9 +2,9 @@ * * $RCSfile: bastype2.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: tbe $ $Date: 2001-06-22 14:45:07 $ + * last change: $Author: tbe $ $Date: 2001-08-29 12:21:24 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -108,14 +108,17 @@ BasicTreeListBox::~BasicTreeListBox() void BasicTreeListBox::ScanBasic( BasicManager* pBasMgr, const String& rName ) { - DBG_ASSERT( pBasMgr, "Wir scannen einen NULL-Pointer... (warum kein BasicManager?!)" ); + // can be called multiple times for updating! + + DBG_ASSERT( pBasMgr, "BasicTreeListBox::ScanBasic: No BasicManager!" ); + SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr ); // eigentlich prueffen, ob Basic bereits im Baum ?! SetUpdateMode( FALSE ); - // Erste Ebene: Welcher BasicManager ( App, Doc, ... ) - // 30.1.96: ScanBasic kann mehrfach zum Updateten aufgerufen werden - // => pruefen, ob Eintrag schon vorhanden. + // level 1: BasicManager (application, document, ...) + + // create tree list box entry SvLBoxEntry* pBasicManagerRootEntry = FindEntry( 0, rName, OBJTYPE_BASICMANAGER ); if ( !pBasicManagerRootEntry ) { @@ -124,68 +127,102 @@ void BasicTreeListBox::ScanBasic( BasicManager* pBasMgr, const String& rName ) pBasicManagerRootEntry->SetUserData( new BasicManagerEntry( pBasMgr ) ); } - Reference< script::XLibraryContainer > xLibContainer; - SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr ); - if ( pShell ) + // 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() ) { - xLibContainer = uno::Reference< script::XLibraryContainer > - ( pShell->GetBasicContainer(), uno::UNO_QUERY ); + 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 ); } - else + + // create a sorted list of dialog library names + ::std::vector<String> aDlgLibList; + Reference< script::XLibraryContainer > xDlgLibContainer = BasicIDE::GetDialogLibraryContainer( pShell ); + if ( xDlgLibContainer.is() ) { - xLibContainer = uno::Reference< script::XLibraryContainer > - ( SFX_APP()->GetBasicContainer(), uno::UNO_QUERY ); + 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 ); } - // Zweite Ebene: Libs ( Standard, ... ) - USHORT nLibs = pBasMgr->GetLibCount(); - for ( USHORT nLib = 0; nLib < nLibs; nLib++ ) + // 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(); + + for ( sal_Int32 i = 0 ; i < nLibCount ; i++ ) { - StarBASIC* pLib = pBasMgr->GetLib( nLib ); - String aLibName = pBasMgr->GetLibName( nLib ); + String aLibName = aLibList[ i ]; + ::rtl::OUString aOULibName( aLibName ); + + // check, if the module library is loaded + BOOL bModLibLoaded = FALSE; + if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryLoaded( aOULibName ) ) + bModLibLoaded = TRUE; - // New library container - if( xLibContainer.is() && xLibContainer->hasByName( aLibName ) && - !xLibContainer->isLibraryLoaded( aLibName ) ) + // check, if the dialog library is loaded + BOOL bDlgLibLoaded = FALSE; + if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryLoaded( aOULibName ) ) + bDlgLibLoaded = TRUE; + + BOOL bLoaded = bModLibLoaded || bDlgLibLoaded; + + // if only one of the libraries is loaded, load also the other + if ( bLoaded ) { - pLib = NULL; - } + if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && !xModLibContainer->isLibraryLoaded( aOULibName ) ) + xModLibContainer->loadLibrary( aOULibName ); - // Jetzt LoadOnDemand... -// if ( !pLib ) // Nicht geladen... -// continue; + if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && !xDlgLibContainer->isLibraryLoaded( aOULibName ) ) + xDlgLibContainer->loadLibrary( aOULibName ); + } + // create a tree list box entry SvLBoxEntry* pLibRootEntry = FindEntry( pBasicManagerRootEntry, aLibName, OBJTYPE_LIB ); if ( !pLibRootEntry ) { - Image aImage( aImages.GetImage( pLib ? IMGID_LIB : IMGID_LIBNOTLOADED ) ); + Image aImage( aImages.GetImage( bLoaded ? IMGID_LIB : IMGID_LIBNOTLOADED ) ); pLibRootEntry = InsertEntry( aLibName, aImage, aImage, - pBasicManagerRootEntry, pLib ? FALSE : TRUE , LIST_APPEND ); + pBasicManagerRootEntry, bLoaded ? FALSE : TRUE , LIST_APPEND ); pLibRootEntry->SetUserData( new BasicEntry( OBJTYPE_LIB ) ); } - if ( pLib ) - ImpCreateLibSubEntries( pLibRootEntry, pLib ); + // create the sub entries + if ( bLoaded ) + ImpCreateLibSubEntries( pLibRootEntry, pShell, aLibName ); } SetUpdateMode( TRUE ); } -void BasicTreeListBox::ImpCreateLibSubEntries( SvLBoxEntry* pLibRootEntry, StarBASIC* pLib ) +void BasicTreeListBox::ImpCreateLibSubEntries( SvLBoxEntry* pLibRootEntry, SfxObjectShell* pShell, const String& rLibName ) { + ::rtl::OUString aOULibName( rLibName ); + // modules - if ( pLib && ( nMode & BROWSEMODE_MODULES ) ) + if ( nMode & BROWSEMODE_MODULES ) { - BasicManager* pBasMgr = BasicIDE::FindBasicManager( pLib ); - if ( pBasMgr ) - { - SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr ); - String aLibName = pLib->GetName(); + Reference< script::XLibraryContainer > xModLibContainer = BasicIDE::GetModuleLibraryContainer( pShell ); + if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryLoaded( aOULibName ) ) + { try { // get library - Reference< container::XNameContainer > xLib = BasicIDE::GetModuleLibrary( pShell, aLibName ); + Reference< container::XNameContainer > xLib = BasicIDE::GetModuleLibrary( pShell, rLibName ); if( xLib.is() ) { @@ -215,7 +252,7 @@ void BasicTreeListBox::ImpCreateLibSubEntries( SvLBoxEntry* pLibRootEntry, StarB { try { - Sequence< ::rtl::OUString > aNames = BasicIDE::GetMethodsFromModule( pShell, aLibName, aModName ); + Sequence< ::rtl::OUString > aNames = BasicIDE::GetMethodsFromModule( pShell, rLibName, aModName ); sal_Int32 nCount = aNames.getLength(); const ::rtl::OUString* pNames = aNames.getConstArray(); @@ -249,18 +286,16 @@ void BasicTreeListBox::ImpCreateLibSubEntries( SvLBoxEntry* pLibRootEntry, StarB } // dialogs - if ( pLib && ( nMode & BROWSEMODE_OBJS ) ) + if ( nMode & BROWSEMODE_OBJS ) { - BasicManager* pBasMgr = BasicIDE::FindBasicManager( pLib ); - if ( pBasMgr ) - { - SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr ); - String aLibName = pLib->GetName(); + Reference< script::XLibraryContainer > xDlgLibContainer = BasicIDE::GetDialogLibraryContainer( pShell ); + if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryLoaded( aOULibName ) ) + { try { // get library - Reference< container::XNameContainer > xLib = BasicIDE::GetDialogLibrary( pShell, aLibName ); + Reference< container::XNameContainer > xLib = BasicIDE::GetDialogLibrary( pShell, rLibName ); if( xLib.is() ) { diff --git a/basctl/source/basicide/bastype2.hxx b/basctl/source/basicide/bastype2.hxx index 5467ef753e40..dc297578a096 100644 --- a/basctl/source/basicide/bastype2.hxx +++ b/basctl/source/basicide/bastype2.hxx @@ -2,9 +2,9 @@ * * $RCSfile: bastype2.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: tbe $ $Date: 2001-07-27 18:03:04 $ + * last change: $Author: tbe $ $Date: 2001-08-29 12:22:13 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -111,7 +111,10 @@ protected: SvLBoxEntry* FindEntry( SvLBoxEntry* pParent, const String& rText, BYTE nType ); virtual long ExpandingHdl(); - void ImpCreateLibSubEntries( SvLBoxEntry* pLibRootEntry, StarBASIC* pLib ); + 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 ); @@ -142,9 +145,6 @@ public: // new dialogs SbxItem GetSbxItem( SvLBoxEntry* pEntry ); - - static BOOL StringCompareLessThan( const String& rStr1, const String& rStr2 ) - { return (rStr1.CompareIgnoreCaseToAscii( rStr2 ) == COMPARE_LESS); } }; /**************************************** diff --git a/basctl/source/basicide/bastype3.cxx b/basctl/source/basicide/bastype3.cxx index a73b099650a9..e35f32a55d75 100644 --- a/basctl/source/basicide/bastype3.cxx +++ b/basctl/source/basicide/bastype3.cxx @@ -2,9 +2,9 @@ * * $RCSfile: bastype3.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: tbe $ $Date: 2001-07-27 18:03:04 $ + * last change: $Author: tbe $ $Date: 2001-08-29 12:23:06 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -103,35 +103,15 @@ void __EXPORT BasicTreeListBox::RequestingChilds( SvLBoxEntry* pEntry ) else if ( pUser->GetType() == OBJTYPE_LIB ) { String aLibName = GetEntryText( pEntry ); + ::rtl::OUString aOULibName( aLibName ); SvLBoxEntry* pParent = GetParent( pEntry ); pUser = (BasicEntry*)pParent->GetUserData(); DBG_ASSERT( pUser->GetType() == OBJTYPE_BASICMANAGER, "BasicManager?" ); BasicManager* pBasMgr = ((BasicManagerEntry*)pUser)->GetBasicManager(); - USHORT nLib = pBasMgr->GetLibId( aLibName ); - - // New library container - Reference< script::XLibraryContainer > xLibContainer; SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr ); - if ( pShell ) - { - xLibContainer = uno::Reference< script::XLibraryContainer > - ( pShell->GetBasicContainer(), uno::UNO_QUERY ); - } - else - { - xLibContainer = uno::Reference< script::XLibraryContainer > - ( SFX_APP()->GetBasicContainer(), uno::UNO_QUERY ); - } - - if( xLibContainer.is() && xLibContainer->hasByName( aLibName ) && - !xLibContainer->isLibraryLoaded( aLibName ) ) - { - EnterWait(); - xLibContainer->loadLibrary( aLibName ); - LeaveWait(); - } - + /* + // check password BOOL bOK = TRUE; if ( pBasMgr->HasPassword( nLib ) && !pBasMgr->IsPasswordVerified( nLib ) ) @@ -140,28 +120,54 @@ void __EXPORT BasicTreeListBox::RequestingChilds( SvLBoxEntry* pEntry ) } if ( bOK ) { - if ( !pBasMgr->IsLibLoaded( nLib ) ) - pBasMgr->LoadLib( nLib ); + */ - StarBASIC* pLib = pBasMgr->GetLib( nLib ); - if ( pLib ) + // load module library + BOOL bModLibLoaded = FALSE; + Reference< script::XLibraryContainer > xModLibContainer = BasicIDE::GetModuleLibraryContainer( pShell ); + if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) ) + { + if ( !xModLibContainer->isLibraryLoaded( aOULibName ) ) { - ImpCreateLibSubEntries( pEntry, pLib ); - - // Das Image austauschen... - Image aImage( aImages.GetImage( IMGID_LIB ) ); - SetExpandedEntryBmp( pEntry, aImage ); - SetCollapsedEntryBmp( pEntry, aImage ); + EnterWait(); + xModLibContainer->loadLibrary( aOULibName ); + LeaveWait(); } - else + bModLibLoaded = TRUE; + } + + // load dialog library + BOOL bDlgLibLoaded = FALSE; + Reference< script::XLibraryContainer > xDlgLibContainer = BasicIDE::GetDialogLibraryContainer( pShell ); + if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) ) + { + if ( !xDlgLibContainer->isLibraryLoaded( aOULibName ) ) { - // Lib konnte nicht geladen werden... - ErrorBox( this, WB_OK|WB_DEF_OK, String( IDEResId( RID_STR_ERROROPENLIB ) ) ).Execute(); + EnterWait(); + xDlgLibContainer->loadLibrary( aOULibName ); + LeaveWait(); } + bDlgLibLoaded = TRUE; + } + + if ( bModLibLoaded || bDlgLibLoaded ) + { + // create the sub entries + ImpCreateLibSubEntries( pEntry, pShell, aLibName ); + + // exchange image + Image aImage( aImages.GetImage( IMGID_LIB ) ); + SetExpandedEntryBmp( pEntry, aImage ); + SetCollapsedEntryBmp( pEntry, aImage ); + } + else + { + // library couldn't be loaded + ErrorBox( this, WB_OK|WB_DEF_OK, String( IDEResId( RID_STR_ERROROPENLIB ) ) ).Execute(); } } else - DBG_ERROR( "RequestingChilds: Was?" ); + DBG_ERROR( "BasicTreeListBox::RequestingChilds: Unknown Type!" ); } diff --git a/basctl/source/basicide/macrodlg.cxx b/basctl/source/basicide/macrodlg.cxx index d8b0561e6dcb..64ab4ba84849 100644 --- a/basctl/source/basicide/macrodlg.cxx +++ b/basctl/source/basicide/macrodlg.cxx @@ -2,9 +2,9 @@ * * $RCSfile: macrodlg.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: tbe $ $Date: 2001-07-25 14:51:32 $ + * last change: $Author: tbe $ $Date: 2001-08-29 12:23:52 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -402,6 +402,13 @@ void MacroChooser::DeleteMacro() pModule->GetMethods()->Remove( pMethod ); CutLines( aSource, nStart-1, nEnd-nStart+1, TRUE ); pModule->SetSource( aSource ); + + // update module in library + String aLibName = pBasic->GetName(); + String aModName = pModule->GetName(); + ::rtl::OUString aModule = pModule->GetSource(); + BasicIDE::UpdateModule( pShell, aLibName, aModName, aModule ); + SvLBoxEntry* pEntry = aMacroBox.FirstSelected(); DBG_ASSERT( pEntry, "DeleteMacro: Entry ?!" ); aMacroBox.GetModel()->Remove( pEntry ); diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx index d2ede3dba2ab..d8ea984967d4 100644 --- a/basctl/source/basicide/moduldl2.cxx +++ b/basctl/source/basicide/moduldl2.cxx @@ -2,9 +2,9 @@ * * $RCSfile: moduldl2.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: tbe $ $Date: 2001-07-05 09:20:52 $ + * last change: $Author: tbe $ $Date: 2001-08-29 12:24:45 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,6 +62,9 @@ #define GLOBALOVERFLOW +#include <vector> +#include <algorithm> + #include <ide_pch.hxx> #ifdef VCL @@ -146,7 +149,7 @@ LibPage::LibPage( Window * pParent ) : aLibBox.SetMode( LIBMODE_MANAGER ); aLibBox.EnableInplaceEditing( TRUE ); - aLibBox.SetCheckButtonHdl( LINK( this, LibPage, CheckBoxHdl ) ); + //aLibBox.SetCheckButtonHdl( LINK( this, LibPage, CheckBoxHdl ) ); aCloseButton.GrabFocus(); long aTabs[] = { 2, 30, 120 }; @@ -161,6 +164,7 @@ LibPage::LibPage( Window * pParent ) : void LibPage::CheckButtons() { + /* SvLBoxEntry* pCur = aLibBox.GetCurEntry(); BOOL bCurChecked = pCur ? aLibBox.IsChecked( aLibBox.GetModel()->GetAbsPos( pCur ) ) : FALSE; if ( bCurChecked ) @@ -181,17 +185,26 @@ void LibPage::CheckButtons() aDelButton.Enable(); else aDelButton.Disable(); -} + */ + // TODO: enable password button + SvLBoxEntry* pCur = aLibBox.GetCurEntry(); + if ( pCur ) + { + aPasswordButton.Disable(); + aInsertLibButton.Disable(); // TODO: enable aInsertLibButton + } +} +/* IMPL_LINK_INLINE_START( LibPage, CheckBoxHdl, SvTreeListBox *, EMPTYARG ) { CheckButtons(); return 0; } IMPL_LINK_INLINE_END( LibPage, CheckBoxHdl, SvTreeListBox *, EMPTYARG ) - +*/ void __EXPORT LibPage::ActivatePage() @@ -203,7 +216,7 @@ void __EXPORT LibPage::ActivatePage() void __EXPORT LibPage::DeactivatePage() { - ActivateCurrentLibSettings(); + //ActivateCurrentLibSettings(); } @@ -232,7 +245,7 @@ IMPL_LINK( LibPage, ButtonHdl, Button *, pButton ) { if ( pButton == &aEditButton ) { - ActivateCurrentLibSettings(); + //ActivateCurrentLibSettings(); SfxViewFrame* pCurFrame = SfxViewFrame::Current(); DBG_ASSERT( pCurFrame != NULL, "No current view frame!" ); SfxDispatcher* pDispatcher = pCurFrame ? pCurFrame->GetDispatcher() : NULL; @@ -259,7 +272,7 @@ IMPL_LINK( LibPage, ButtonHdl, Button *, pButton ) DeleteCurrent(); else if ( pButton == &aCloseButton ) { - ActivateCurrentLibSettings(); + //ActivateCurrentLibSettings(); EndTabDialog( 0 ); } else if ( pButton == &aPasswordButton ) @@ -295,7 +308,7 @@ IMPL_LINK( LibPage, ButtonHdl, Button *, pButton ) if ( bHadPassword != aLibBox.GetBasicManager()->HasPassword( nLib ) ) { aLibBox.GetModel()->Remove( pCurEntry ); - ImpInsertLibEntry( nLib ); + ImpInsertLibEntry( pBasMgr->GetLibName( nLib ), nLib ); aLibBox.GetBasicManager()->SetPasswordVerified( nLib ); } } @@ -309,6 +322,9 @@ void LibPage::NewLib() { BasicManager* pBasMgr = BasicIDE::FindBasicManager( aCurBasMgr ); DBG_ASSERT( pBasMgr, "BasMgr?!" ); + SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr ); + + // create library name String aLibName; String aLibStdName( String( RTL_CONSTASCII_USTRINGPARAM( "Library" ) ) ); //String aLibStdName( IDEResId( RID_STR_STDLIBNAME ) ); @@ -318,15 +334,14 @@ void LibPage::NewLib() { aLibName = aLibStdName; aLibName += String::CreateFromInt32( i ); - if ( !pBasMgr->HasLib( aLibName ) ) + if ( !BasicIDE::HasModuleLibrary( pShell, aLibName ) && !BasicIDE::HasDialogLibrary( pShell, aLibName ) ) bValid = TRUE; i++; } NewObjectDialog* pNewDlg = new NewObjectDialog( this, NEWOBJECTMODE_LIB ); pNewDlg->SetObjectName( aLibName ); - BOOL bEnableSepFile = ( pBasMgr->GetStorageName().Len() && ( pBasMgr == SFX_APP()->GetBasicManager() ) ); - pNewDlg->EnableSeparateFile( bEnableSepFile ); + if ( pNewDlg->Execute() ) { if ( pNewDlg->GetObjectName().Len() ) @@ -341,141 +356,59 @@ void LibPage::NewLib() ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_BADSBXNAME ) ) ).Execute(); } - else if ( pBasMgr->HasLib( aLibName ) ) + else if ( BasicIDE::HasModuleLibrary( pShell, aLibName ) || BasicIDE::HasDialogLibrary( pShell, aLibName ) ) { ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_SBXNAMEALLREADYUSED2 ) ) ).Execute(); } else { - BOOL bCreateLib = TRUE; - String aLibStorageName; - if ( pNewDlg->IsSeparateFile() ) + try { - INetURLObject aFileURL( pBasMgr->GetStorageName() , INetURLObject::FSYS_DETECT ); - String aExt = aFileURL.getExtension(); - aFileURL.setName( aLibName ); - aFileURL.setExtension( aExt ); - aLibStorageName = aFileURL.getFSysPath( INetURLObject::FSYS_DETECT ); - String aFileURLStr = aFileURL.GetMainURL(); - - Reference< XSimpleFileAccess > xSFI; - Reference< XMultiServiceFactory > xSMgr = getProcessServiceFactory(); - if( xSMgr.is() ) - { - xSFI = Reference< XSimpleFileAccess >( xSMgr->createInstance - ( OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY ); - } - if( xSFI.is() ) - { - sal_Bool bExists = sal_False; - try { bExists = xSFI->exists( aFileURLStr ); } - catch( Exception & ) {} - if( bExists ) - { - String aText( IDEResId( RID_STR_FILEEXISTS ) ); - aText.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "XX" ) ), aLibStorageName ); - ErrorBox( this, WB_OK | WB_DEF_OK, aText ).Execute(); - bCreateLib = FALSE; - } - } - } - - if ( bCreateLib ) - { - StarBASIC* pLib = pBasMgr->CreateLib( aLibName ); - - // get shell - SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr ); - - // get library container - Reference< script::XLibraryContainer > xBasicLibContainer; - Reference< script::XLibraryContainer > xDialogLibContainer; - if( pShell ) - { - // document - xBasicLibContainer = Reference< script::XLibraryContainer >( pShell->GetBasicContainer(), UNO_QUERY ); - xDialogLibContainer = Reference< script::XLibraryContainer >( pShell->GetDialogContainer(), UNO_QUERY ); - } - else - { - // application - xBasicLibContainer = Reference< script::XLibraryContainer >( SFX_APP()->GetBasicContainer(), UNO_QUERY ); - xDialogLibContainer = Reference< script::XLibraryContainer >( SFX_APP()->GetDialogContainer(), UNO_QUERY ); - } + // create module and dialog library + Reference< container::XNameContainer > xModLib = BasicIDE::CreateModuleLibrary( pShell, aLibName ); + Reference< container::XNameContainer > xDlgLib = BasicIDE::CreateDialogLibrary( pShell, aLibName ); + // check if libraries are loaded + /* + BOOL bLoaded = FALSE; ::rtl::OUString aOULibName( aLibName ); - - // create basic library - if( xBasicLibContainer.is() && !xBasicLibContainer->hasByName( aOULibName ) ) - xBasicLibContainer->createLibrary( aOULibName ); - - // create dialog library - if( xDialogLibContainer.is() && !xDialogLibContainer->hasByName( aOULibName ) ) - xDialogLibContainer->createLibrary( aOULibName ); - - SvLBoxEntry* pEntry = aLibBox.InsertEntry( aLibName ); - USHORT nPos = (USHORT)aLibBox.GetModel()->GetAbsPos( pEntry ); - USHORT nLib = pBasMgr->GetLibId( aLibName ); - aLibBox.CheckEntryPos( nPos, pBasMgr->IsLibLoaded( nLib ) ); - - if ( aLibStorageName.Len() ) + Reference< script::XLibraryContainer > xModuleLibContainer = BasicIDE::GetModuleLibraryContainer( pShell ); + Reference< script::XLibraryContainer > xDialogLibContainer = BasicIDE::GetDialogLibraryContainer( pShell ); + if ( xModuleLibContainer.is() && xModuleLibContainer->isLibraryLoaded( aOULibName ) && + xDialogLibContainer.is() && xDialogLibContainer->isLibraryLoaded( aOULibName ) ) { - INetURLObject aFileURL( aLibStorageName , INetURLObject::FSYS_DETECT ); - String aShortName = aFileURL.getName(); - - // conversion to 8.3 filename for FAT filesystem not implemented, because - // INetURLObject doesn't have a method corresponding to old DirEntry::MakeShortName - // - // old code for comparison: - /* - DirEntry aDirEntry( aLibStorageName ); - String aShortName = aDirEntry.GetName(); - - // Immer 8.3 - DirEntry aTempEntry( aDirEntry.GetPath() ); - if( aTempEntry.MakeShortName( aDirEntry.GetName(), FSYS_KIND_NONE, TRUE, FSYS_STYLE_FAT ) ) - { - aLibStorageName = aTempEntry.GetFull(); - aShortName = aTempEntry.GetName(); - } - */ - - pBasMgr->SetLibStorageName( nLib, aLibStorageName ); - aLibBox.SetEntryText( aShortName, pEntry, 1 ); - - // Sofort speichern, sonst erhaelt man ggf. spaeter - // nochmal den gleichen ShortName - pBasMgr->StoreLib( nLib ); + bLoaded = TRUE; } + */ - // Ein Modul anlegen: - try - { - String aModName = BasicIDE::CreateModuleName( pShell, aLibName ); - ::rtl::OUString aModule = BasicIDE::CreateModule( pShell, aLibName, aModName, TRUE ); - SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, pShell, aLibName, aModName, BASICIDE_TYPE_MODULE ); + SvLBoxEntry* pEntry = aLibBox.InsertEntry( aLibName ); + //USHORT nPos = (USHORT)aLibBox.GetModel()->GetAbsPos( pEntry ); + //aLibBox.CheckEntryPos( nPos, bLoaded ); - SfxViewFrame* pCurFrame = SfxViewFrame::Current(); - DBG_ASSERT( pCurFrame != NULL, "No current view frame!" ); - SfxDispatcher* pDispatcher = pCurFrame ? pCurFrame->GetDispatcher() : NULL; - if( pDispatcher ) - { - pDispatcher->Execute( SID_BASICIDE_SBXINSERTED, - SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L ); - } - } - catch ( container::ElementExistException& e ) - { - ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US ); - DBG_ERROR( aBStr.GetBuffer() ); - } - catch ( container::NoSuchElementException& e ) + // create a module + String aModName = BasicIDE::CreateModuleName( pShell, aLibName ); + ::rtl::OUString aModule = BasicIDE::CreateModule( pShell, aLibName, aModName, TRUE ); + SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, pShell, aLibName, aModName, BASICIDE_TYPE_MODULE ); + SfxViewFrame* pCurFrame = SfxViewFrame::Current(); + DBG_ASSERT( pCurFrame != NULL, "No current view frame!" ); + SfxDispatcher* pDispatcher = pCurFrame ? pCurFrame->GetDispatcher() : NULL; + if( pDispatcher ) { - ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US ); - DBG_ERROR( aBStr.GetBuffer() ); + pDispatcher->Execute( SID_BASICIDE_SBXINSERTED, + SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L ); } } + catch ( container::ElementExistException& e ) + { + ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US ); + DBG_ERROR( aBStr.GetBuffer() ); + } + catch ( container::NoSuchElementException& e ) + { + ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US ); + DBG_ERROR( aBStr.GetBuffer() ); + } } } delete pNewDlg; @@ -561,7 +494,7 @@ void LibPage::InsertLib() } SvLBoxEntry* pEntry = pLibDlg->GetLibBox().InsertEntry( rInf.GetName() ); USHORT nPos = (USHORT) pLibDlg->GetLibBox().GetModel()->GetAbsPos( pEntry ); - pLibDlg->GetLibBox().CheckEntryPos( nPos, TRUE); + //pLibDlg->GetLibBox().CheckEntryPos( nPos, TRUE); } } @@ -579,8 +512,8 @@ void LibPage::InsertLib() BOOL bReference = pLibDlg->IsReference(); for ( USHORT nLib = 0; nLib < pLibDlg->GetLibBox().GetEntryCount(); nLib++ ) { - if ( pLibDlg->GetLibBox().IsChecked( nLib ) ) - { + //if ( pLibDlg->GetLibBox().IsChecked( nLib ) ) + //{ SvLBoxEntry* pEntry = pLibDlg->GetLibBox().GetEntry( nLib ); DBG_ASSERT( pEntry, "Entry?!" ); String aName( pLibDlg->GetLibBox().GetEntryText( pEntry, 0 ) ); @@ -630,9 +563,9 @@ void LibPage::InsertLib() pBasMgr->SetLibStorageName( nLib, aFileURL.getFSysPath( INetURLObject::FSYS_DETECT ) ); } DBG_ASSERT( nLib != LIB_NOTFOUND, "Lib nicht eingefuegt?!" ); - ImpInsertLibEntry( nLib ); + ImpInsertLibEntry( pBasMgr->GetLibName( nLib ), nLib ); bChanges = TRUE; - } + //} } SvLBoxEntry* pFirstNew = aLibBox.GetEntry( nNewPos ); if ( pFirstNew ) @@ -658,13 +591,18 @@ void LibPage::DeleteCurrent() { BasicManager* pBasMgr = BasicIDE::FindBasicManager( aCurBasMgr ); DBG_ASSERT( pBasMgr, "BasMgr?!" ); + SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr ); SvLBoxEntry* pCurEntry = aLibBox.GetCurEntry(); DBG_ASSERT( pCurEntry && aLibBox.GetModel()->GetAbsPos( pCurEntry ), "Kann nicht loeschen!" ); String aLibName( aLibBox.GetEntryText( pCurEntry, 0 ) ); - USHORT nLib = pBasMgr->GetLibId( aLibName ); - if ( QueryDelLib( aLibName, pBasMgr->IsReference( nLib ), this ) ) + BOOL bReference = FALSE; + // TODO: check, if library is Reference/Link + // old code: + //USHORT nLib = pBasMgr->GetLibId( aLibName ); + //BOOL bReference = pBasMgr->IsReference( nLib ); + if ( QueryDelLib( aLibName, bReference, this ) ) { - // BasicIDE informieren, falls oben. + // inform BasicIDE String aLib( CreateMgrAndLibStr( aCurBasMgr, aLibName ) ); SfxStringItem aLibItem( SID_BASICIDE_ARG_LIBNAME, aLib ); SfxViewFrame* pCurFrame = SfxViewFrame::Current(); @@ -675,9 +613,18 @@ void LibPage::DeleteCurrent() pDispatcher->Execute( SID_BASICIDE_LIBREMOVED, SFX_CALLMODE_SYNCHRON, &aLibItem, 0L ); } - pBasMgr->RemoveLib( nLib, TRUE ); + + // remove library from module and dialog library containers + ::rtl::OUString aOULibName( aLibName ); + Reference< script::XLibraryContainer > xModLibContainer = BasicIDE::GetModuleLibraryContainer( pShell ); + if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) ) + xModLibContainer->removeLibrary( aOULibName ); + Reference< script::XLibraryContainer > xDlgLibContainer = BasicIDE::GetDialogLibraryContainer( pShell ); + if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) ) + xDlgLibContainer->removeLibrary( aOULibName ); + ((SvLBox&)aLibBox).GetModel()->Remove( pCurEntry ); - BasicIDE::MarkDocShellModified( pBasMgr->GetStdLib() ); + BasicIDE::MarkDocShellModified( pShell ); } } @@ -728,22 +675,64 @@ void LibPage::SetCurLib() String aSelected( aBasicsBox.GetSelectEntry() ); if ( aSelected != aCurBasMgr ) { - ActivateCurrentLibSettings(); + //ActivateCurrentLibSettings(); aCurBasMgr = aSelected; BasicManager* pBasMgr = BasicIDE::FindBasicManager( aCurBasMgr ); DBG_ASSERT( pBasMgr, "BasMgr?!" ); + SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr ); aLibBox.SetBasicManager( pBasMgr ); - USHORT nLibs = pBasMgr->GetLibCount(); aLibBox.Clear(); - Image aLockedImg( IDEResId( RID_IMG_LOCKED ) ); - for ( USHORT nLib = 0; nLib < nLibs; nLib++ ) - ImpInsertLibEntry( nLib ); + //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 + + sal_Int32 nLibCount = aLibList.size(); + for ( sal_Int32 i = 0 ; i < nLibCount ; i++ ) + ImpInsertLibEntry( aLibList[ i ], i ); + aLibBox.SetCurEntry( aLibBox.GetEntry( 0 ) ); + /* + String aStdLibName = String::CreateFromAscii("Standard"); + SvLBoxEntry* pEntry = aLibBox.FindEntry( aStdLibName ); + if ( !pEntry ) + pEntry = aLibBox.GetEntry( 0 ); + aLibBox.SetCurEntry( pEntry ); + */ } } - +/* void LibPage::ActivateCurrentLibSettings() { BasicManager* pBasMgr = BasicIDE::FindBasicManager( aCurBasMgr ); @@ -787,12 +776,15 @@ void LibPage::ActivateCurrentLibSettings() } } } +*/ -SvLBoxEntry* LibPage::ImpInsertLibEntry( USHORT nLib ) +SvLBoxEntry* LibPage::ImpInsertLibEntry( const String& rLibName, ULONG nPos ) { - BasicManager* pBasicManager = aLibBox.GetBasicManager(); - DBG_ASSERT( pBasicManager, "ImpInsertLibEntry: Kein BasicManager!" ); - BOOL bPassword = pBasicManager->HasPassword( nLib ); + //BasicManager* pBasicManager = aLibBox.GetBasicManager(); + //DBG_ASSERT( pBasicManager, "ImpInsertLibEntry: Kein BasicManager!" ); + + // TODO: check password + //BOOL bPassword = pBasicManager->HasPassword( nLib ); // if ( !pBasicManager->IsLibLoaded( nLib ) ) // { // // Lib muss geladen sein, wenn Passwortabfrage... @@ -800,6 +792,8 @@ SvLBoxEntry* LibPage::ImpInsertLibEntry( USHORT nLib ) // bPassword = pBasicManager->HasPassword( nLib ); // pBasicManager->UnloadLib( nLib ); // } + + /* if ( bPassword ) { Image aImg = Image( IDEResId( RID_IMG_LOCKED ) ); @@ -807,9 +801,12 @@ SvLBoxEntry* LibPage::ImpInsertLibEntry( USHORT nLib ) aLibBox.SetDefaultExpandedEntryBmp( aImg ); aLibBox.SetDefaultCollapsedEntryBmp( aImg ); } + */ - SvLBoxEntry* pNewEntry = aLibBox.InsertEntry( pBasicManager->GetLibName( nLib ), nLib ); + SvLBoxEntry* pNewEntry = aLibBox.InsertEntry( rLibName, nPos ); + // TODO: check, if library is reference/link + /* if ( pBasicManager->IsReference( nLib ) || pBasicManager->IsExtern( nLib ) ) { String aLibStorage = pBasicManager->GetLibStorageName( nLib ); @@ -828,15 +825,19 @@ SvLBoxEntry* LibPage::ImpInsertLibEntry( USHORT nLib ) aLibBox.SetEntryText( aLibStorage, pNewEntry, 1 ); } + */ + + //aLibBox.CheckEntryPos( nLib, pBasicManager->IsLibLoaded( nLib ) ); - aLibBox.CheckEntryPos( nLib, pBasicManager->IsLibLoaded( nLib ) ); + /* if ( bPassword ) { Image aImg; // Default zuruecksetzen aLibBox.SetDefaultExpandedEntryBmp( aImg ); aLibBox.SetDefaultCollapsedEntryBmp( aImg ); } + */ return pNewEntry; } @@ -857,9 +858,10 @@ BasicCheckBox::BasicCheckBox( Window* pParent, const ResId& rResId ) : __EXPORT BasicCheckBox::~BasicCheckBox() { - delete pCheckButton; + //delete pCheckButton; } +/* void __EXPORT BasicCheckBox::CheckButtonHdl() { SvLBoxEntry* pEntry = GetHdlEntry(); @@ -877,9 +879,11 @@ void __EXPORT BasicCheckBox::CheckButtonHdl() SelectEntryPos( nPos, TRUE ); } } +*/ void BasicCheckBox::Init() { + /* BasicCheckBoxBitmaps theBmps; pCheckButton = new SvLBoxButtonData; @@ -890,6 +894,7 @@ void BasicCheckBox::Init() pCheckButton->aBmps[SV_BMP_TRISTATE] = theBmps.GetTriStateBmp(); pCheckButton->aBmps[SV_BMP_HITRISTATE] = theBmps.GetHiTriStateBmp(); EnableCheckButton( pCheckButton ); + */ SetHighlightRange(); } @@ -934,7 +939,7 @@ ULONG BasicCheckBox::GetSelectEntryPos() const } - +/* ULONG BasicCheckBox::GetCheckedEntryCount() const { ULONG nCheckCount = 0; @@ -948,9 +953,9 @@ ULONG BasicCheckBox::GetCheckedEntryCount() const return nCheckCount; } +*/ - - +/* void BasicCheckBox::CheckEntryPos( ULONG nPos, BOOL bCheck ) { if ( nPos < GetEntryCount() ) @@ -964,16 +969,16 @@ void BasicCheckBox::CheckEntryPos( ULONG nPos, BOOL bCheck ) : SvButtonState(SV_BUTTON_UNCHECKED) ); } } +*/ - - +/* BOOL BasicCheckBox::IsChecked( ULONG nPos ) const { if ( nPos < GetEntryCount() ) return (GetCheckButtonState( GetEntry( nPos ) ) == SV_BUTTON_CHECKED); return FALSE; } - +*/ BOOL __EXPORT BasicCheckBox::EditingEntry( SvLBoxEntry* pEntry, Selection& ) { @@ -981,14 +986,19 @@ BOOL __EXPORT BasicCheckBox::EditingEntry( SvLBoxEntry* pEntry, Selection& ) return FALSE; DBG_ASSERT( pEntry, "Kein Eintrag?" ); - ULONG nAbsPos = GetModel()->GetAbsPos( pEntry ); - if ( nAbsPos == 0 ) + + // check, if Standard library + String aLibName = GetEntryText( pEntry, 0 ); + if ( aLibName.EqualsIgnoreCaseAscii( "Standard" ) ) { ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_CANNOTCHANGENAMESTDLIB ) ) ).Execute(); return FALSE; } + // TODO: check if library is reference/link + // Prueffen, ob Referenz... + /* USHORT nLib = pBasMgr->GetLibId( GetEntryText( pEntry, 0 ) ); DBG_ASSERT( nLib != LIB_NOTFOUND, "LibId ?!" ); if ( pBasMgr->IsReference( nLib ) ) @@ -996,11 +1006,11 @@ BOOL __EXPORT BasicCheckBox::EditingEntry( SvLBoxEntry* pEntry, Selection& ) ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_CANNOTCHANGENAMEREFLIB ) ) ).Execute(); return FALSE; } + */ return TRUE; } - BOOL __EXPORT BasicCheckBox::EditedEntry( SvLBoxEntry* pEntry, const String& rNewText ) { BOOL bValid = ( rNewText.Len() <= 30 ) && BasicIDE::IsValidSbxName( rNewText ); @@ -1032,8 +1042,7 @@ BOOL __EXPORT BasicCheckBox::EditedEntry( SvLBoxEntry* pEntry, const String& rNe return bValid; } - - +/* BasicCheckBoxBitmaps::BasicCheckBoxBitmaps() : Resource ( ResId( RID_RES_CHECKBITMAPS ) ), aUncheckedBmp ( ResId( CHKBTN_UNCHECKED ) ), @@ -1045,13 +1054,12 @@ BasicCheckBoxBitmaps::BasicCheckBoxBitmaps() : { FreeResource(); } - +*/ NewObjectDialog::NewObjectDialog( Window* pParent, USHORT nMode ) : ModalDialog( pParent, IDEResId( RID_DLG_NEWLIB ) ), aText( this, IDEResId( RID_FT_NEWLIB ) ), aEdit( this, IDEResId( RID_ED_LIBNAME ) ), - aCheckBox( this, IDEResId( RID_CHKB_EXTRAFILE ) ), aOKButton( this, IDEResId( RID_PB_OK ) ), aCancelButton( this, IDEResId( RID_PB_CANCEL ) ) { @@ -1060,7 +1068,6 @@ NewObjectDialog::NewObjectDialog( Window* pParent, USHORT nMode ) if ( nMode == NEWOBJECTMODE_LIB ) { - aCheckBox.Show(); SetText( String( IDEResId( RID_STR_NEWLIB ) ) ); } else if ( nMode == NEWOBJECTMODE_MOD ) diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx index 058248b70ce8..dbc1a4d6cd53 100644 --- a/basctl/source/basicide/moduldlg.cxx +++ b/basctl/source/basicide/moduldlg.cxx @@ -2,9 +2,9 @@ * * $RCSfile: moduldlg.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: tbe $ $Date: 2001-07-31 15:07:16 $ + * last change: $Author: tbe $ $Date: 2001-08-29 12:25:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -574,6 +574,17 @@ void ObjectPage::CheckButtons() SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry(); USHORT nDepth = pCurEntry ? aBasicBox.GetModel()->GetDepth( pCurEntry ) : 0; + if ( nDepth == 1 || nDepth == 2 ) + { + aNewModButton.Enable(); + aNewDlgButton.Enable(); + } + else + { + aNewModButton.Disable(); + aNewDlgButton.Disable(); + } + if ( nDepth == 2 ) aEditButton.Enable(); else @@ -700,13 +711,16 @@ IMPL_LINK( ObjectPage, ButtonHdl, Button *, pButton ) StarBASIC* ObjectPage::GetSelectedBasic() { - String aLib, aModOrDlg, aSub; - BasicManager* pBasMgr = aBasicBox.GetSelectedSbx( aLib, aModOrDlg, aSub ); + String aLibName, aModOrDlg, aSub; + BasicManager* pBasMgr = aBasicBox.GetSelectedSbx( aLibName, aModOrDlg, aSub ); DBG_ASSERT( pBasMgr, "Kein BasicManager!" ); - StarBASIC* pLib = aLib.Len() ? pBasMgr->GetLib( aLib ) : pBasMgr->GetLib( 0 ); - if ( !pLib && aLib.Len() ) + SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr ); + + /* old code + StarBASIC* pLib = aLibName.Len() ? pBasMgr->GetLib( aLibName ) : pBasMgr->GetLib( 0 ); + if ( !pLib && aLibName.Len() ) { - USHORT nLib = pBasMgr->GetLibId( aLib ); + USHORT nLib = pBasMgr->GetLibId( aLibName ); BOOL bOK = TRUE; if ( pBasMgr->HasPassword( nLib ) && !pBasMgr->IsPasswordVerified( nLib ) ) @@ -721,7 +735,35 @@ StarBASIC* ObjectPage::GetSelectedBasic() ErrorBox( this, WB_OK|WB_DEF_OK, String( IDEResId( RID_STR_ERROROPENLIB ) ) ).Execute(); } } - return pLib; + */ + + StarBASIC* pBasic = 0; + DBG_ASSERT( aLibName.Len(), "ObjectPage::GetSelectedBasic(): No library name!" ); + if ( aLibName.Len() ) + { + // TODO: check password + + + ::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 ) + ErrorBox( this, WB_OK|WB_DEF_OK, String( IDEResId( RID_STR_ERROROPENLIB ) ) ).Execute(); + + return pBasic; } /* diff --git a/basctl/source/basicide/moduldlg.hxx b/basctl/source/basicide/moduldlg.hxx index 98ba5c039d61..ad66b0e5ca1f 100644 --- a/basctl/source/basicide/moduldlg.hxx +++ b/basctl/source/basicide/moduldlg.hxx @@ -2,9 +2,9 @@ * * $RCSfile: moduldlg.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: tbe $ $Date: 2001-07-31 15:07:16 $ + * last change: $Author: tbe $ $Date: 2001-08-29 12:26:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -111,19 +111,12 @@ private: OKButton aOKButton; CancelButton aCancelButton; - // NEWOBJECTMODE_LIB - CheckBox aCheckBox; - public: - NewObjectDialog( Window* pParent, USHORT nMode ); ~NewObjectDialog(); String GetObjectName() const { return aEdit.GetText(); } void SetObjectName( const String& rName ) { aEdit.SetText( rName ); aEdit.SetSelection( Selection( 0, rName.Len() ) );} - - BOOL IsSeparateFile() const { return aCheckBox.IsChecked(); } - void EnableSeparateFile( BOOL bEnable ) { aCheckBox.Enable( bEnable ); } }; @@ -155,12 +148,12 @@ class BasicCheckBox : public SvTabListBox { private: USHORT nMode; - SvLBoxButtonData* pCheckButton; + //SvLBoxButtonData* pCheckButton; BasicManager* pBasMgr; void Init(); protected: - virtual void CheckButtonHdl(); + //virtual void CheckButtonHdl(); public: BasicCheckBox( Window* pParent, const ResId& rResId ); @@ -173,9 +166,9 @@ public: void SelectEntryPos( ULONG nPos, BOOL bSelect = TRUE ); ULONG GetSelectEntryPos() const; - ULONG GetCheckedEntryCount() const; - void CheckEntryPos( ULONG nPos, BOOL bCheck = TRUE ); - BOOL IsChecked( ULONG nPos ) const; + //ULONG GetCheckedEntryCount() const; + //void CheckEntryPos( ULONG nPos, BOOL bCheck = TRUE ); + //BOOL IsChecked( ULONG nPos ) const; virtual BOOL EditingEntry( SvLBoxEntry* pEntry, Selection& rSel ); virtual BOOL EditedEntry( SvLBoxEntry* pEntry, const String& rNewText ); @@ -188,6 +181,7 @@ public: }; +/* class BasicCheckBoxBitmaps : public Resource { private: @@ -208,7 +202,7 @@ public: const Bitmap& GetTriStateBmp () const { return aTriStateBmp; } const Bitmap& GetHiTriStateBmp () const { return aHiTriStateBmp; } }; - +*/ class LibDialog: public ModalDialog { @@ -318,7 +312,7 @@ protected: DECL_LINK( TreeListHighlightHdl, SvTreeListBox * ); DECL_LINK( BasicSelectHdl, ListBox * ); - DECL_LINK( CheckBoxHdl, SvTreeListBox * ); + //DECL_LINK( CheckBoxHdl, SvTreeListBox * ); DECL_LINK( ButtonHdl, Button * ); void CheckButtons(); void DeleteCurrent(); @@ -327,13 +321,16 @@ protected: void EndTabDialog( USHORT nRet ); void FillListBox(); void SetCurLib(); - SvLBoxEntry* ImpInsertLibEntry( USHORT nLib ); - void ActivateCurrentLibSettings(); + SvLBoxEntry* ImpInsertLibEntry( const String& rLibName, ULONG nPos ); + //void ActivateCurrentLibSettings(); // library preloading obsolete! virtual void ActivatePage(); virtual void DeactivatePage(); TabDialog* pTabDlg; + static BOOL StringCompareLessThan( const String& rStr1, const String& rStr2 ) + { return (rStr1.CompareIgnoreCaseToAscii( rStr2 ) == COMPARE_LESS); } + public: LibPage( Window* pParent ); |