Libraries Contained in a Document


OOo Basic defines the variables BasicLibraries and DialogLibraries to access libraries contained in a document. The behavior is the same as their GlobalScope counterparts except that they access the library container for the current document. Modify Listing 4 by removing all references to GlobalScope, and the macro acts on the current document.

Although the BasicLibraries and DialogLibraries variables provided by OOo Basic provide an excellent method of accessing dialogs and libraries contained in a document, you may find code that uses the deprecated method getLibraryContainer(). Each document supports the method getLibraryContainer(). The returned object supports the method getModuleContainer(), which returns the contained Basic modules, and the method getDialogContainer(), which in my testing always returns a null object. Table 3 shows how to obtain a module using old and new methods .

Table 3: Obtain the module aMod from the library TestLib contained in a document.

Using BasicLibraries

Using oDoc.getLibraryContainer()

 oLibs = BasicLibraries If oLibs. hasByName("TestLib") Then   oLib = oLibs.getByName("TestLib")   If oLib.hasByName("AMod") Then     oMod = oLib.getByName("AMod")   End If End If 
 oLibs = ThisComponent.getLibraryContainer() If oLibs.hasByName("TestLib") Then   oLib = oLibs.getByName("TestLib")   oMods = oLib.getModuleContainer()   If NOT IsNull(oMods) Then     If oMods.hasByName("AMod") Then       oMod = oMods.getByName("AMod")     End If   End If End If 



OpenOffice.org Macros Explained
OpenOffice.org Macros Explained
ISBN: 1930919514
EAN: 2147483647
Year: 2004
Pages: 203

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net