Difference between revisions of "Documentation/Administration Guide/Using Custom Macros and Libraries"

From Apache OpenOffice Wiki
Jump to: navigation, search
(About {{OOo}} Basic Libraries and Modules)
m (About {{AOo}} Basic Libraries and Modules)
 
(45 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE: Using Custom {{OOo}} Basic Macros and Libraries}}
 
 
{{Documentation/AdminGuideTOC/v2
 
{{Documentation/AdminGuideTOC/v2
 
|ShowPrevNext=block
 
|ShowPrevNext=block
 
|ShowPrevPage=block
 
|ShowPrevPage=block
 
|ShowNextPage=block
 
|ShowNextPage=block
|PrevPage=Documentation/Administration Guide/Customizing
+
|PrevPage=Documentation/Administration Guide/Windows
 
|NextPage=Documentation/Administration Guide/Using Package Manager
 
|NextPage=Documentation/Administration Guide/Using Package Manager
 
}}
 
}}
 
+
{{DISPLAYTITLE: Custom {{AOo}} Basic Macros and Libraries}}
{{OOo}} Basic is a programming language that you can use to automate tasks in {{OOo}}.  
+
__NOTOC__
{{OOo}} Basic macros are stored in modules which in turn are stored in libraries.  
+
{{AOo}} Basic is a programming language you can use to automate tasks in {{AOo}}.  
Libraries also act as containers for dialog boxes that you create in {{OOo}} Basic.  
+
{{AOo}} Basic macros are stored in modules that in turn are stored in libraries.  
 +
Libraries also act as containers for dialog boxes you create in {{AOo}} Basic.  
 
You can store Basic libraries in any directory that a user can access.
 
You can store Basic libraries in any directory that a user can access.
  
==About {{OOo}} Basic Libraries and Modules==
+
{{Note|Use {{AOo}} extensions for packaging and deploying Basic Libraries.  The {{AOo}} Developer's Guide describes these [[Documentation/DevGuide/Extensions/Extensions|Extensions]] in detail.}}
 +
 
 +
==About {{AOo}} Basic Libraries and Modules==
  
The default {{OOo}} Basic libraries are located in the <tt>&lt;{{OOo}} installation&gt;/share/basic</tt>
+
The default {{AOo}} Basic libraries are located in the <tt>''install-dir''/share/basic</tt>
 
directory. A library contains the following files:
 
directory. A library contains the following files:
;<tt>script.xlb</tt>:An XML file that contains the names of the modules in the library.
+
;<tt>script.xlb</tt>:A XML file that contains the names of the modules in the library.
;<tt>dialog.xlb</tt>:An XML file that contains the names of dialog boxes in the library.
+
;<tt>dialog.xlb</tt>:A XML file that contains the names of dialog boxes in the library.
;<tt>*.xba</tt>:An XML file that stores the {{OOo}} Basic source code for a single {{OOo}} Basic module. The name of the file corresponds to the name of the module.
+
;<tt>*.xba</tt>:A XML file that stores the {{AOo}} Basic source code for a single {{AOo}} Basic module. The file name corresponds to the module name.
;<tt>*.xdl</tt>:An XML file that stores the dialog elements of a {{OOo}} Basic dialog. The name of the file corresponds to the name of the dialog.
+
;<tt>*.xdl</tt>:A XML file that stores the dialog elements of an {{AOo}} Basic dialog box. The file name corresponds to the dialog name.
;<tt>*.pba</tt>:A {{OOo}} Basic module which is protected with a password, that is, the source code is encrypted. The name of the file corresponds to the name of the module.
+
;<tt>*.pba</tt>:An {{AOo}} Basic module which is protected with a password, that is, the source code is encrypted. The file name corresponds to the module name.
  
==About {{OOo}} Basic Configuration Files==
+
==About {{AOo}} Basic Configuration Files==
  
 
The <tt>script.xlc</tt> and <tt>dialog.xlc</tt> configuration files list the location of  
 
The <tt>script.xlc</tt> and <tt>dialog.xlc</tt> configuration files list the location of  
{{OOo}} Basic libraries and dialogs. These files are in the <tt>&lt;{{OOo}}
+
{{AOo}} Basic libraries and dialog boxes. These files are located in the <tt>''install-dir''/user/basic/</tt> directory which also contains the default Standard  
installation&gt;/user/basic/</tt> directory which also contains the default Standard  
+
{{AOo}} Basic library as well as the user-defined libraries.
{{OOo}} Basic library as well as the user-defined libraries.
+
  
{{Documentation/Caution|
+
{{Warn|
 
You cannot change the location of the <tt>script.xlc</tt> and <tt>dialog.xlc</tt> configuration files.
 
You cannot change the location of the <tt>script.xlc</tt> and <tt>dialog.xlc</tt> configuration files.
 
}}
 
}}
  
 
The XML-based <tt>script.xlc</tt> file includes a list of all Basic libraries  
 
The XML-based <tt>script.xlc</tt> file includes a list of all Basic libraries  
that are available to {{OOo}}. The following tags are used:
+
that are available to {{AOo}}. The following tags are used:
  
;<tt>library<nowiki>:</nowiki>name</tt>:Specifies the name of the {{OOo}} Basic library
+
;<tt>library<nowiki>:</nowiki>name</tt>:Specifies the name of the {{AOo}} Basic library.
 
;<tt>xlink<nowiki>:</nowiki>href</tt>:Specifies the URL of the <tt>script.xlb</tt> file for the library. The URL must begin with the <tt>file:///</tt> notation.
 
;<tt>xlink<nowiki>:</nowiki>href</tt>:Specifies the URL of the <tt>script.xlb</tt> file for the library. The URL must begin with the <tt>file:///</tt> notation.
{{Documentation/Note|You do not need to specify a value for the <tt>xlink:href</tt> tag if the library is in the <tt> &lt;user installation directory&gt;/user/basic</tt> directory of the user installation.}}
+
{{Note|You do not need to specify a value for the <tt>xlink:href</tt> tag if the library is in the <tt>&lt;Apache OpenOffice installation directory&gt;/user/basic</tt> directory.}}
;<tt>xlink<nowiki>:</nowiki>type</tt>:This tag, which is required by the <tt>xlink:href</tt> tag, must be set to <tt>simple</tt>.
+
;<tt>xlink<nowiki>:</nowiki>type</tt>:This tag, required by the <tt>xlink:href</tt> tag, must be set to <tt>simple</tt>.
;<tt>library<nowiki>:</nowiki>link</tt>:Specifies that the entry is a link to a library that is not in the default library location. The default location for {{OOo}} Basic libraries is <tt>&lt;user installation directory&gt;/user/basic</tt>. If you only use the default location for the libraries, set the value of this tag to <tt>false</tt>. For all other libraries, set the value of this tag to <tt>true</tt>.
+
;<tt>library<nowiki>:</nowiki>link</tt>:Specifies that the entry is a link to a library that is not in the default library location. The default location for {{AOo}} Basic libraries is <tt>''install-dir''/user/basic</tt>. If you only use the default location for the libraries, set the value of this tag to <tt>false</tt>. For all other libraries, set the value of this tag to <tt>true</tt>.
 
;<tt>library<nowiki>:</nowiki>readonly</tt>:Specifies whether a library is read-only. Set the value of this tag to <tt>true</tt> for read-only access.
 
;<tt>library<nowiki>:</nowiki>readonly</tt>:Specifies whether a library is read-only. Set the value of this tag to <tt>true</tt> for read-only access.
  
 
The following XML code is for a <tt>script.xlc</tt> configuration file for  
 
The following XML code is for a <tt>script.xlc</tt> configuration file for  
{{OOo}} Basic libraries. The only difference between this file and a <tt>dialog.xlc</tt>  
+
{{AOo}} Basic libraries. The only difference between this file and a <tt>dialog.xlc</tt>  
 
file is that the <tt>xlink:href</tt> tag points to the <tt>script.xlb</tt> file  
 
file is that the <tt>xlink:href</tt> tag points to the <tt>script.xlb</tt> file  
 
of a library instead of the <tt>dialog.xlb</tt> file.
 
of a library instead of the <tt>dialog.xlb</tt> file.
  
<source lang="xml">
+
<syntaxhighlight lang="xml">
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?xml version="1.0" encoding="UTF-8"?>
 
<!DOCTYPE library:libraries PUBLIC  
 
<!DOCTYPE library:libraries PUBLIC  
Line 66: Line 67:
 
xlink:type="simple" library:link="true" library:readonly="false"/>
 
xlink:type="simple" library:link="true" library:readonly="false"/>
 
</library:libraries>
 
</library:libraries>
</source>
+
</syntaxhighlight>
''Sample {{OOo}} Basic Configuration File''
+
''Sample {{AOo}} Basic Configuration File''
  
==Distributing {{OOo}} Basic Libraries==
+
==Distributing {{AOo}} Basic Libraries==
  
You can make custom {{OOo}} Basic libraries available to existing {{OOo}} installations or new installations only.
+
You can make custom {{AOo}} Basic libraries available to either existing {{AOo}} installations or new installations only.
  
===To Make a Custom {{OOo}} Basic Library Available to All Users on a Network===
+
{{Note| The <tt>script.xlc</tt> and <tt>dialog.xlc</tt> configuration files are located in the following directories:
 +
* Solaris and Linux platforms: <tt>''install-dir''/usr/basic/</tt>
 +
* Windows: <tt>C:\Documents and Settings\''user-id''\Application Data\''install-dir''\user\basic\</tt>}}
  
Use {{OOo}} to create a custom library as well as the macros in the library.
+
===To Make a Custom {{AOo}} Basic Library Available to All Users on a Network===
 +
 
 +
Use {{AOo}} to create a custom library as well as the macros in the library.
  
 
<ol class="task">
 
<ol class="task">
 
<li>
 
<li>
As root, copy the custom library from the user installation where you created the library to the {{OOo}} server installation.<br>
+
As root, copy the custom library from the user installation where you created the library to the {{AOo}} server installation.<br>
<tt>cp -r &lt;{{OOo}} user installation directory&gt;/user/basic/custom library &lt;{{OOo}} installation directory&gt;/share/basic/</tt>
+
<tt>cp -r ''install-dir''/user/basic/custom library ''install-dir''/share/basic/</tt>
{{Documentation/Note|On Windows, the location of the custom library that you created is <tt>C:\Documents and Settings\user id\Application Data\{{OOo}} 2\user\basic\custom library</tt>}}
+
{{Note|On Windows, the location of the custom library you created is <tt>C:\Documents and Settings\''username''\Application Data\''installation-dir''\user\basic\custom library</tt>}}
 
</li>
 
</li>
 
<li>
 
<li>
In a text editor, open the <tt>script.xlc</tt> configuration file for the user installation and add a link to the <tt>script.xlb</tt> configuration file for the library.<br>
+
In the <tt>script.xlc</tt> configuration file for the user installation, add a link to the <tt>script.xlb</tt> configuration file for the library.<br>
  
 
Use the following syntax for the link:
 
Use the following syntax for the link:
  
<source lang="xml">
+
<syntaxhighlight lang="xml">
 
  <library:library library:name="Library Name"
 
  <library:library library:name="Library Name"
 
  xlink:href="$(USER)/basic/Library Name/script.xlb/"
 
  xlink:href="$(USER)/basic/Library Name/script.xlb/"
 
  xlink:type="simple" library:link="true" library:readonly="false"/>
 
  xlink:type="simple" library:link="true" library:readonly="false"/>
</source>
+
</syntaxhighlight>
 
+
* On Solaris and Linux, open the <tt>&lt;{{OOo}} user installation directory&gt;/user/basic/script.xlc</tt> configuration file.
+
* On Windows, open the <tt>C:\Documents and Settings\user id\Application Data\{{OOo}} 2\user\basic\script.xlc</tt> configuration file
+
 
</li>
 
</li>
 
<li>
 
<li>
In a text editor, open the <tt>dialog.xlc</tt> configuration file for the user installation and add a link to the <tt>script.xlb</tt> configuration file for the library.<br>
+
In the <tt>dialog.xlc</tt> configuration file for the user installation, add a link to the <tt>script.xlb</tt> configuration file for the library.<br>
  
 
Use the following syntax for the link:
 
Use the following syntax for the link:
  
<source lang="xml">
+
<syntaxhighlight lang="xml">
 
  <library:library library:name="Library Name"
 
  <library:library library:name="Library Name"
 
  xlink:href="$(USER)/basic/Library Name/dialog.xlb/"
 
  xlink:href="$(USER)/basic/Library Name/dialog.xlb/"
 
  xlink:type="simple" library:link="false"/>
 
  xlink:type="simple" library:link="false"/>
</source>
+
</syntaxhighlight>
 
+
* On Solaris and Linux, open the <tt>&lt;{{OOo}} user installation directory&gt;/user/basic/dialog.xlc</tt> configuration file.
+
* On Windows, open the <tt>C:\Documents and Settings\user id\Application Data\{{OOo}} 2\user\basic\dialog.xlc</tt> configuration file.
+
 
</li>
 
</li>
 
<li>
 
<li>
Restart {{OOo}} on the workstations.
+
Restart {{AOo}} on the workstations.
 
</li>
 
</li>
 
</ol>
 
</ol>
  
===To Make a Custom {{OOo}} Basic Library Available to a Single User===
+
===To Make a Custom {{AOo}} Basic Library Available to a Single User===
  
 
<ol class="task">
 
<ol class="task">
Line 122: Line 121:
 
Copy the custom library from the user installation where you created the library to the user installation where you want to deploy the library.
 
Copy the custom library from the user installation where you created the library to the user installation where you want to deploy the library.
  
* On Solaris and Linux, become root, and copy the library.<br><tt>cp -r &lt;{{OOo}} user installation directory&gt;/user/basic/custom library &lt;{{OOo}} user installation directory&gt;/user/basic/</tt>
+
* On the Solaris and Linux platforms, become root, and copy the library.
 +
  <pre>cp -r ''install-dir''/user/basic/custom library ''install-dir''/user/basic/</pre>
 
* On Windows, become a user with administrator privileges, and copy the library.<br>
 
* On Windows, become a user with administrator privileges, and copy the library.<br>
The file name path for the library is <tt>C:\Documents and Settings\user id\Application Data\{{OOo}} 2\user\basic\custom library</tt>
+
The file name path for the library is <tt>C:\Documents and Settings\''username''\Application Data\''install-dir''\user\basic\custom library</tt>
 
</li>
 
</li>
 
<li>
 
<li>
In a text editor, open the <tt>script.xlc</tt> configuration file for the user installation and add a link to the <tt>script.xlb</tt> configuration file for the library.<br>
+
In the <tt>script.xlc</tt> configuration file for the user installation, add a link to the <tt>script.xlb</tt> configuration file for the library.<br>
  
 
Use the following syntax for the link:
 
Use the following syntax for the link:
<source lang="xml">
+
<syntaxhighlight lang="xml">
 
  <library:library library:name="Library Name"
 
  <library:library library:name="Library Name"
 
  xlink:href="$(USER)/basic/Library Name/script.xlb/"
 
  xlink:href="$(USER)/basic/Library Name/script.xlb/"
 
  xlink:type="simple" library:link="true" library:readonly="false"/>
 
  xlink:type="simple" library:link="true" library:readonly="false"/>
</source>
+
</syntaxhighlight>
* On Solaris and Linux, open the <tt>&lt;{{OOo}} user installation directory&gt;/user/basic/script.xlc</tt> configuration file.
+
* On Windows, open the <tt>C:\Documents and Settings\user id\Application Data\{{OOo}} 2\user\basic\script.xlc</tt> configuration file.
+
 
</li>
 
</li>
 
<li>
 
<li>
In a text editor, open the <tt>dialog.xlc</tt> configuration file for the user installation and add a link to the <tt>script.xlb</tt> configuration file for the library.<br>
+
In the <tt>dialog.xlc</tt> configuration file for the user installation, add a link to the <tt>script.xlb</tt> configuration file for the library.<br>
  
 
Use the following syntax for the link:
 
Use the following syntax for the link:
<source lang="xml">
+
<syntaxhighlight lang="xml">
 
  <library:library library:name="Library Name"
 
  <library:library library:name="Library Name"
 
  xlink:href="$(USER)/basic/Library Name/dialog.xlb/"
 
  xlink:href="$(USER)/basic/Library Name/dialog.xlb/"
 
  xlink:type="simple" library:link="false"/>
 
  xlink:type="simple" library:link="false"/>
</source>
+
</syntaxhighlight>
* On Solaris and Linux, open the <tt>&lt;{{OOo}} user installation directory&gt;/user/basic/dialog.xlc</tt> configuration file.
+
* On Windows, open the <tt>C:\Documents and Settings\user id\Application Data\{{OOo}} 2\user\basic\dialog.xlc</tt> configuration file.
+
 
</li>
 
</li>
<li>Restart {{OOo}}.</li>
+
<li>Restart {{AOo}}.</li>
 
</ol>
 
</ol>
  
===To Install a Custom {{OOo}} Basic Library With a Macro===
+
===To Install a Custom {{AOo}} Basic Library With a Macro===
  
You can create a macros that installs a {{OOo}} Basic library from a {{OOo}} document.
+
You can create a macro that installs a {{AOo}} Basic library from an {{AOo}} document.
  
 
<ol class="task">
 
<ol class="task">
 
<li>
 
<li>
In Writer, create a custom {{OOo}} Basic library in a new document.
+
In Writer, create a custom {{AOo}} Basic library in a new document.
 
</li>
 
</li>
 
<li>
 
<li>
Line 168: Line 164:
 
</li>
 
</li>
 
<ol class="task" type="a">
 
<ol class="task" type="a">
<li>Choose '''Tools &rarr; Macros &rarr; Organize Macros &rarr; {{OOo}} Basic'''.  The '''{{OOo}} Basic Macros''' dialog box opens.</li>
+
<li>Choose {{menu|Tools|Macros|Organize Macros|OpenOffice Basic}}.  The '''{{AOo}} Basic Macros''' dialog box appears.</li>
 
<li>In the '''Macro from''' list, select your Writer document.</li>
 
<li>In the '''Macro from''' list, select your Writer document.</li>
<li>In the '''Macro name''' box, enter a name from the installation macro.</li>
+
<li>In the '''Macro name''' box, type a name from the installation macro.</li>
<li>Click the '''New''' button.  The '''BASIC''' IDE window opens.</li>
+
<li>Click the {{button|New}} button.  The '''BASIC''' IDE window appears.</li>
<li>Enter the following code:</li>
+
<li>Type the following code:</li>
  
<source lang="vb">
+
<syntaxhighlight lang="oobas">
 
  Sub AddBasicLibrary
 
  Sub AddBasicLibrary
 
   Dim SourceLibraryName As String, DestLibraryName As String
 
   Dim SourceLibraryName As String, DestLibraryName As String
Line 213: Line 209:
 
   Next iLib
 
   Next iLib
 
  End Sub
 
  End Sub
</source>
+
</syntaxhighlight>
  
 
<li>Replace the <tt>SrcLibraryName</tt> and <tt>DestLibraryName</tt> variables with the name of your library.</li>
 
<li>Replace the <tt>SrcLibraryName</tt> and <tt>DestLibraryName</tt> variables with the name of your library.</li>
Line 221: Line 217:
 
<li>Add a push button to the document.</li>
 
<li>Add a push button to the document.</li>
 
<ol class="task" type="a">
 
<ol class="task" type="a">
<li>On the '''Tools''' toolbar, open the '''Controls''' toolbar, and click the '''Push Button''' icon.</li>
+
<li>On the '''Form Controls''' toolbar, click the '''Push Button''' icon.</li>
 
<li>In your document, drag to draw the button.</li>
 
<li>In your document, drag to draw the button.</li>
 
</ol>
 
</ol>
Line 227: Line 223:
 
<li>Assign the installation macro to a button event.</li>
 
<li>Assign the installation macro to a button event.</li>
 
<ol class="task" type="a">
 
<ol class="task" type="a">
<li>Right-click the button, and choose '''Control'''.</li>
+
<li>Right-click the new button and choose '''Control'''.</li>
 
<li>Click the '''Events''' tab.</li>
 
<li>Click the '''Events''' tab.</li>
<li>Click the '''...''' next to a button event, for example, the '''Mouse button pressed''' event.</li>
+
<li>Click the ellipsis '''(…)''' next to a button event.  For example, the '''Mouse button pressed''' event might be used.</li>
<li>In the '''Assign Macro''' dialog box, click the '''Assign''' button.  The '''Macro Selector''' dialog box opens.</li>
+
<li>In the '''Assign Action''' dialog box, click the '''Macro''' button.  The '''Macro Selector''' dialog box appears.</li>
 
<li>In the '''Library''' list, select the library that contains the installation macro.</li>
 
<li>In the '''Library''' list, select the library that contains the installation macro.</li>
 
<li>In the '''Macro name''' list, select the installation macro.</li>
 
<li>In the '''Macro name''' list, select the installation macro.</li>
<li>Click the '''OK''' button.</li>
+
<li>Click {{button|OK}}.</li>
<li>In the '''Assign Macro''' dialog box, click the '''OK''' button.</li>
+
<li>In the '''Assign Macro''' dialog box, click {{button|OK}}.</li>
 
</ol>
 
</ol>
 
<li>Save the document.</li>
 
<li>Save the document.</li>
 
</ol>
 
</ol>
  
 +
{{InterWiki Languages AdminGuide|articletitle=Documentation/Administration Guide/Using Custom Macros and Libraries}}
 
{{PDL1}}
 
{{PDL1}}

Latest revision as of 16:01, 27 May 2021


Apache OpenOffice Basic is a programming language you can use to automate tasks in Apache OpenOffice. Apache OpenOffice Basic macros are stored in modules that in turn are stored in libraries. Libraries also act as containers for dialog boxes you create in Apache OpenOffice Basic. You can store Basic libraries in any directory that a user can access.

Documentation note.png Use Apache OpenOffice extensions for packaging and deploying Basic Libraries. The Apache OpenOffice Developer's Guide describes these Extensions in detail.

About Apache OpenOffice Basic Libraries and Modules

The default Apache OpenOffice Basic libraries are located in the install-dir/share/basic directory. A library contains the following files:

script.xlb
A XML file that contains the names of the modules in the library.
dialog.xlb
A XML file that contains the names of dialog boxes in the library.
*.xba
A XML file that stores the Apache OpenOffice Basic source code for a single Apache OpenOffice Basic module. The file name corresponds to the module name.
*.xdl
A XML file that stores the dialog elements of an Apache OpenOffice Basic dialog box. The file name corresponds to the dialog name.
*.pba
An Apache OpenOffice Basic module which is protected with a password, that is, the source code is encrypted. The file name corresponds to the module name.

About Apache OpenOffice Basic Configuration Files

The script.xlc and dialog.xlc configuration files list the location of Apache OpenOffice Basic libraries and dialog boxes. These files are located in the install-dir/user/basic/ directory which also contains the default Standard Apache OpenOffice Basic library as well as the user-defined libraries.

Documentation caution.png

You cannot change the location of the script.xlc and dialog.xlc configuration files.

The XML-based script.xlc file includes a list of all Basic libraries that are available to Apache OpenOffice. The following tags are used:

library:name
Specifies the name of the Apache OpenOffice Basic library.
xlink:href
Specifies the URL of the script.xlb file for the library. The URL must begin with the file:/// notation.
Documentation note.png You do not need to specify a value for the xlink:href tag if the library is in the <Apache OpenOffice installation directory>/user/basic directory.
xlink:type
This tag, required by the xlink:href tag, must be set to simple.
library:link
Specifies that the entry is a link to a library that is not in the default library location. The default location for Apache OpenOffice Basic libraries is install-dir/user/basic. If you only use the default location for the libraries, set the value of this tag to false. For all other libraries, set the value of this tag to true.
library:readonly
Specifies whether a library is read-only. Set the value of this tag to true for read-only access.

The following XML code is for a script.xlc configuration file for Apache OpenOffice Basic libraries. The only difference between this file and a dialog.xlc file is that the xlink:href tag points to the script.xlb file of a library instead of the dialog.xlb file.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library:libraries PUBLIC 
"-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "libraries.dtd">
 
<library:libraries 
xmlns:library="http://openoffice.org/2000/library" 
xmlns:xlink="http://www.w3.org/1999/xlink">
 
<library:library library:name="Standard" 
xlink:href="file:///.../user/basic/Standard/script.xlb/" 
xlink:type="simple" library:link="false"/>
 
<library:library library:name="FormWizard" 
xlink:href="file:///.../share/basic/FormWizard/script.xlb/" 
xlink:type="simple" library:link="true" library:readonly="false"/>
</library:libraries>

Sample Apache OpenOffice Basic Configuration File

Distributing Apache OpenOffice Basic Libraries

You can make custom Apache OpenOffice Basic libraries available to either existing Apache OpenOffice installations or new installations only.

Documentation note.png The script.xlc and dialog.xlc configuration files are located in the following directories:
  • Solaris and Linux platforms: install-dir/usr/basic/
  • Windows: C:\Documents and Settings\user-id\Application Data\install-dir\user\basic\

To Make a Custom Apache OpenOffice Basic Library Available to All Users on a Network

Use Apache OpenOffice to create a custom library as well as the macros in the library.

  1. As root, copy the custom library from the user installation where you created the library to the Apache OpenOffice server installation.
    cp -r install-dir/user/basic/custom library install-dir/share/basic/
    Documentation note.png On Windows, the location of the custom library you created is C:\Documents and Settings\username\Application Data\installation-dir\user\basic\custom library
  2. In the script.xlc configuration file for the user installation, add a link to the script.xlb configuration file for the library.
    Use the following syntax for the link:
     <library:library library:name="Library Name"
     xlink:href="$(USER)/basic/Library Name/script.xlb/"
     xlink:type="simple" library:link="true" library:readonly="false"/>
  3. In the dialog.xlc configuration file for the user installation, add a link to the script.xlb configuration file for the library.
    Use the following syntax for the link:
     <library:library library:name="Library Name"
     xlink:href="$(USER)/basic/Library Name/dialog.xlb/"
     xlink:type="simple" library:link="false"/>
  4. Restart Apache OpenOffice on the workstations.

To Make a Custom Apache OpenOffice Basic Library Available to a Single User

  1. Copy the custom library from the user installation where you created the library to the user installation where you want to deploy the library.
    • On the Solaris and Linux platforms, become root, and copy the library.
    cp -r ''install-dir''/user/basic/custom library ''install-dir''/user/basic/
    • On Windows, become a user with administrator privileges, and copy the library.

    The file name path for the library is C:\Documents and Settings\username\Application Data\install-dir\user\basic\custom library

  2. In the script.xlc configuration file for the user installation, add a link to the script.xlb configuration file for the library.
    Use the following syntax for the link:
     <library:library library:name="Library Name"
     xlink:href="$(USER)/basic/Library Name/script.xlb/"
     xlink:type="simple" library:link="true" library:readonly="false"/>
  3. In the dialog.xlc configuration file for the user installation, add a link to the script.xlb configuration file for the library.
    Use the following syntax for the link:
     <library:library library:name="Library Name"
     xlink:href="$(USER)/basic/Library Name/dialog.xlb/"
     xlink:type="simple" library:link="false"/>
  4. Restart Apache OpenOffice.

To Install a Custom Apache OpenOffice Basic Library With a Macro

You can create a macro that installs a Apache OpenOffice Basic library from an Apache OpenOffice document.

  1. In Writer, create a custom Apache OpenOffice Basic library in a new document.
  2. Save the document.
  3. Create an installation macro.
    1. Choose Tools → Macros → Organize Macros → OpenOffice Basic. The Apache OpenOffice Basic Macros dialog box appears.
    2. In the Macro from list, select your Writer document.
    3. In the Macro name box, type a name from the installation macro.
    4. Click the  New  button. The BASIC IDE window appears.
    5. Type the following code:
    6.  Sub AddBasicLibrary
        Dim SourceLibraryName As String, DestLibraryName As String
        Dim oSrcLib As Object, oDestLib As Object, iCounter As Integer
        Dim oLib As Object, oGlobalLib As Object
       
        ' set these 2 variables to your lib name
        SrcLibraryName = "TextLib" 
        ' The name of the library that contains the modules
        DestLibraryName = "NewLib" 
        ' This library will be created and is the 
        ' destination for the modules from the source document.
       
        oLib = BasicLibraries        ' For Basic libaries
        oGlobalLib = GlobalScope.BasicLibraries
        For iLib = 1 To 2 
          If oGlobalLib.hasByName( DestLibraryName ) = False Then
            oGlobalLib.createLibrary( DestLibraryName )
          End If
          If oLib.hasByName( SrcLibraryName ) Then
            oLib.loadLibrary( SrcLibraryName )
            oSrcLib = oLib.getByName( SrcLibraryName )
            sSrcModules = oSrcLib.getElementNames()
            iCounter = lBound( sSrcModules() )
       
            while( iCounter &lt;= uBound( sSrcModules() ) )
              oDestLib = oGlobalLib.getByName(DestLibraryName)
              If oDestLib.hasByName( sSrcModules(iCounter) ) = False Then
                oDestLib.insertByName( sSrcModules(iCounter),_
                oSrcLib.getByName( sSrcModules(iCounter) ) )
              End If
              iCounter = iCounter + 1
            wend
          End If
       
          oLib = DialogLibraries   ' The same for the Dialog libraries
          oGlobalLib = GlobalScope.DialogLibraries
        Next iLib
       End Sub
    7. Replace the SrcLibraryName and DestLibraryName variables with the name of your library.
    8. Close the BASIC IDE window.
  4. Add a push button to the document.
    1. On the Form Controls toolbar, click the Push Button icon.
    2. In your document, drag to draw the button.
  5. Assign the installation macro to a button event.
    1. Right-click the new button and choose Control.
    2. Click the Events tab.
    3. Click the ellipsis (…) next to a button event. For example, the Mouse button pressed event might be used.
    4. In the Assign Action dialog box, click the Macro button. The Macro Selector dialog box appears.
    5. In the Library list, select the library that contains the installation macro.
    6. In the Macro name list, select the installation macro.
    7. Click  OK .
    8. In the Assign Macro dialog box, click  OK .
  6. Save the document.
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages