summaryrefslogtreecommitdiff
path: root/basctl/source/basicide/basobj3.cxx
diff options
context:
space:
mode:
authorAndreas Bregas <ab@openoffice.org>2001-03-28 10:27:57 +0000
committerAndreas Bregas <ab@openoffice.org>2001-03-28 10:27:57 +0000
commitd136d5ed1bc0ec43fbd30ffba4912312eddb3bbb (patch)
tree713a76bcdb7728a7487125cd062167a0db954844 /basctl/source/basicide/basobj3.cxx
parent8b6c235b8a3062f5658d4b16fe96922c7b671ca4 (diff)
New static method UpdateModuleInLibrary()
Diffstat (limited to 'basctl/source/basicide/basobj3.cxx')
-rw-r--r--basctl/source/basicide/basobj3.cxx64
1 files changed, 62 insertions, 2 deletions
diff --git a/basctl/source/basicide/basobj3.cxx b/basctl/source/basicide/basobj3.cxx
index 6b91fb0c2f48..ba95f10f6bf8 100644
--- a/basctl/source/basicide/basobj3.cxx
+++ b/basctl/source/basicide/basobj3.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: basobj3.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: ab $ $Date: 2000-12-05 08:46:58 $
+ * last change: $Author: ab $ $Date: 2001-03-28 11:27:57 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -79,6 +79,16 @@
#include <baside2.hxx>
+#ifndef _COM_SUN_STAR_SCRIPT_XLIBRYARYCONTAINER_HPP_
+#include <com/sun/star/script/XLibraryContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star;
+
// In bastype3.cxx:
USHORT GetDialogSbxId();
@@ -141,6 +151,7 @@ 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 );
@@ -257,7 +268,56 @@ StarBASIC* BasicIDE::FindBasic( const SbxVariable* pVar )
return (StarBASIC*)pSbx;
}
+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 )
{