Library Management


This section deals with creating, transferring, and renaming libraries and modules. When considering library management, it is important to first understand some basics that have already been discussed:

  • A library container contains zero or more libraries.

  • Each library contains zero or more modules and dialogs.

  • Each module contains zero or more macros.

  • The application is a library container named "soffice". Libraries stored in the application are globally available to all macros.

  • Every document is a library container.

  • The library named Standard is special; it always exists and cannot be overwritten. I recommend against using the Standard library.

  • Always give meaningful names to the libraries and modules that you create. For example, Library 1 and Module4 are not meaningful names , although AXONInvoiceForm1 might be more descriptive and helpful.

How Libraries are Stored

OpenOffice.org libraries are stored as XML files that are easily editable using any text editor. In other words, it is easy for you to poke around and damage your files. Although manually editing your external libraries is generally considered foolish, I have had at least one instance where this was required, because OOo was unable to load a module that contained a syntax error.

Tip  

Manually editing OOo files is best left to advanced users. Beginning users may want to quickly skim through this material or skip to the next section.

Application Libraries

Each application library is stored in a single directory, and each module and dialog is contained in a single file. The Options dialog (Tools Options OpenOffice.org Paths) contains an entry that identifies where libraries are located. The global libraries that are included with OpenOffice.org are stored in a shared basic directory under the directory in which OOo is installed. Examples:

 C:\Program Files\openOffice.1.1.1\share\basic  'A Windows installation /usr/local/ppenOffice.org1.1.I/share/basic     'A Linux installation 

The libraries that you create are stored in different directories. On my Windows computer, I have a single- user installation, and on my Linux computer I have a multiple-person network installation. The choices that you make while installing OOo affect the location of your personal libraries. Here are two examples:

 C:\Program Files\OpenOffice.1.1.1\user\basic  'Windows user files /home/andy/openOffice.org1.1.1/user/basic     'Linux user files 

Listing the shared directory shows one file for each application library that is included with OOo. The user directory, however, is a bit more interesting (see Table 1 ).

Table 1: Files and some directories in my user/basic directory.

Entry

Description

dialog.xlc

XML file that references every dialog file known to this user in OpenOffice.org.

script.xlc

XML file that references every library file known to this user in OpenOffice.org.

Standard

Directory containing the Standard library.

Pitonyak

Directory containing a library with code that I created.

PitonyakDialogs

Directory containing a library with some code and a dialog.

Note  

Table 1 references the directories Pitonyak and PitonyakDialogs. The Pitonyak library and the PitonyakDialogs library are not related ; their names are similar because I lacked creativity and good sense when I named them. It is not true that the library PitonyakDialogs contains the dialogs for the Pitonyak library.

The files dialog.xlc and script.xlc contain a reference to all of the dialogs and libraries that are known to OOo. The visible libraries-as seen in the Macro dialog and the Macro Organizer dialog (see Figure 16 )-are built from the files dialog.xlc and script.xlc. If these two files are overwritten, OOo will not know about your personal libraries even if they exist.

click to expand
Figure 16: The Macro dialog and the Macro Organizer dialog show available libraries and modules.

The Macro Organizer dialog shows that the PitonyakDialogs library contains two code modules and one dialog. Table 2 contains a listing of the files in the PitonyakDialogs directory. Notice that each module and dialog in a library has a corresponding file.

Table 2: Files in the PitonyakDialogs library directory.

File

Description

dialog.xlb

References the dialogs contained in this library.

script.xlb

References the modules contained in this library.

Module1.xba

BASIC code in the module named Module1.

SimpleObjectBrowserCode.xba

BASIC code in the module named SimpleObjectBrowserCode.

SimpleObjectBrowser.xdl

A dialog in the module named SimpleObjectBrowser.

The files dialog.xlc and script.xlc in Table 1 reference the files dialog.xlb and script.xlb in Table 2. In general, none of these files should be manually modified, but in an emergency, they may be modified by hand to correct certain types of errors.

Document Libraries

An OpenOffice.org document, when saved to disk, is stored in the standard ZIP format. Any program that can view and extract ZIP files can be used to inspect an OOo document-however, some programs will require you to change the file extension to end with ZIP.

After unzipping an OOo document, you will find files that contain the primary content, styles, and settings. The extracted document also contains three directories. The META-INF directory references all of the other files, embedded pictures, code libraries, and dialogs. The Dialogs directory contains all of the embedded dialogs, and the Basic directory contains all of the embedded libraries. Notice that libraries contained in the "soffice" application-level container are stored in a slightly different configuration than the libraries contained in a document.

As an experiment, I took a document that contained numerous controls that called a specific library. I unzipped the document and then used a text-search tool to find all references to a specific library named CH03. After manually changing every occurrence of the text "CH03" to "CH04", I zipped the directory back into a single file, and OOo was able to read and use the file. I successfully changed the name of a contained library and every reference to the controls by editing the XML definitions.

Tip  

The point of this section is that, in an emergency, you can manually inspect a document's XML and potentially fix problems. This is usually NOT the best way to change the name of a document's libraries.

Using the Macro Organizer

The Macro Organizer (Tools Macros Macro Organizer) is able to satisfy most users' needs in regards to organizing modules and libraries. The Modules tab of the Macro Organizer dialog (see Figure 16) provides the capability to create and delete modules. The Macro Organizer dialog also has a Libraries tab (see Figure 17 ) used to create and delete libraries. The Libraries tab contains a drop-down box at the top that is used to select the library container. In other words, you can select a specific open document or the application library container named "soffice."

click to expand
Figure 17: Use the Macro Organizer to create, add, and delete libraries.
Note  

A document's name is the file name, unless the document title is set in the document's Properties dialog (File Properties Description). If the Title property is set, it is used as the document name in the window title, the Macro dialog, and the Macro Organizer dialog.




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