Difference between revisions of "Documentation/Administration Guide/Using Custom Macros and Libraries"
(→To Make a Custom {{OOo}} Basic Library Available to All Users on a Network) |
|||
Line 72: | Line 72: | ||
You can make custom {{OOo}} Basic libraries available to existing {{OOo}} installations or new installations only. | You can make custom {{OOo}} Basic libraries available to existing {{OOo}} installations or new installations only. | ||
− | |||
===To Make a Custom {{OOo}} Basic Library Available to All Users on a Network=== | ===To Make a Custom {{OOo}} Basic Library Available to All Users on a Network=== | ||
Line 131: | Line 130: | ||
Use the following syntax for the link: | Use the following syntax for the link: | ||
<source lang="xml"> | <source lang="xml"> | ||
− | + | <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> | </source> | ||
* On Solaris and Linux, open the <tt><{{OOo}} user installation directory>/user/basic/script.xlc</tt> configuration file. | * On Solaris and Linux, open the <tt><{{OOo}} user installation directory>/user/basic/script.xlc</tt> configuration file. | ||
Line 143: | Line 142: | ||
Use the following syntax for the link: | Use the following syntax for the link: | ||
<source lang="xml"> | <source lang="xml"> | ||
− | + | <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> | </source> | ||
* On Solaris and Linux, open the <tt><{{OOo}} user installation directory>/user/basic/dialog.xlc</tt> configuration file. | * On Solaris and Linux, open the <tt><{{OOo}} user installation directory>/user/basic/dialog.xlc</tt> configuration file. | ||
Line 168: | Line 167: | ||
</li> | </li> | ||
<ol class="task" type="a"> | <ol class="task" type="a"> | ||
− | + | <li>Choose '''Tools → Macros → Organize Macros → {{OOo}} Basic'''. The '''{{OOo}} Basic Macros''' dialog box opens.</li> | |
− | <li> | + | <li>In the '''Macro from''' list, select your Writer document.</li> |
− | Choose '''Tools → Macros → Organize Macros → {{OOo}} Basic''' | + | <li>In the '''Macro name''' box, enter a name from the installation macro.</li> |
− | + | <li>Click the '''New''' button. The '''BASIC''' IDE window opens.</li> | |
− | The '''{{OOo}} Basic Macros''' dialog box opens. | + | <li>Enter the following code:</li> |
− | </li> | + | <source lang="oobas"> |
− | <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> | + | |
− | Click the '''New''' button | + | |
− | + | ||
− | The '''BASIC''' IDE window opens. | + | |
− | </li> | + | |
− | <li> | + | |
− | + | ||
− | Enter the following code:</li> | + | |
− | + | ||
Sub AddBasicLibrary | Sub AddBasicLibrary | ||
Dim SourceLibraryName As String, DestLibraryName As String | Dim SourceLibraryName As String, DestLibraryName As String | ||
Line 227: | Line 211: | ||
Next iLib | Next iLib | ||
End Sub | End Sub | ||
− | + | <source> | |
− | <li> | + | <li>Replace the <tt>SrcLibraryName</tt> and <tt>DestLibraryName</tt> variables with the name of your library.</li> |
− | Replace the <tt>SrcLibraryName</tt> and <tt>DestLibraryName</tt> variables with the name of your library. | + | <li>Close the '''BASIC''' IDE window.</li> |
− | </li> | + | |
− | <li> | + | |
− | Close the '''BASIC''' IDE window. | + | |
− | </li> | + | |
</ol> | </ol> | ||
− | <li> | + | <li>Add a push button to the document.</li> |
− | Add a push button to the document. | + | |
− | </li> | + | |
<ol class="task" type="a"> | <ol class="task" type="a"> | ||
− | <li> | + | <li>On the '''Tools''' toolbar, open the '''Controls''' toolbar, and click the '''Push Button''' icon.</li> |
− | On the '''Tools''' toolbar, open the '''Controls''' toolbar, and click the '''Push Button''' icon. | + | <li>In your document, drag to draw the button.</li> |
− | </li> | + | |
− | <li> | + | |
− | In your document, drag to draw the button. | + | |
− | </li> | + | |
</ol> | </ol> | ||
− | <li> | + | <li>Assign the installation macro to a button event.</li> |
− | Assign the installation macro to a button event. | + | |
− | </li> | + | |
<ol class="task" type="a"> | <ol class="task" type="a"> | ||
− | <li> | + | <li>Right-click the button, and choose '''Control'''.</li> |
− | Right-click the button, and choose '''Control'''. | + | <li>Click the '''Events''' tab.</li> |
− | </li> | + | <li>Click the '''...''' next to a button event, for example, the '''Mouse button pressed''' event.</li> |
− | <li> | + | <li>In the '''Assign Macro''' dialog box, click the '''Assign''' button. The '''Macro Selector''' dialog box opens.</li> |
− | Click the '''Events''' tab. | + | <li>In the '''Library''' list, select the library that contains the installation macro.</li> |
− | </li> | + | <li>In the '''Macro name''' list, select the installation macro.</li> |
− | <li> | + | <li>Click the '''OK''' button.</li> |
− | Click the '''...''' next to a button event, for example, the '''Mouse button pressed''' event. | + | <li>In the '''Assign Macro''' dialog box, click the '''OK''' button.</li> |
− | </li> | + | |
− | <li> | + | |
− | In the '''Assign Macro''' dialog box, click the '''Assign''' button. | + | |
− | + | ||
− | The '''Macro Selector''' dialog box opens. | + | |
− | </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> | + | |
− | Click the '''OK''' button. | + | |
− | </li> | + | |
− | <li> | + | |
− | In the '''Assign Macro''' dialog box, click the '''OK''' button. | + | |
− | </li> | + | |
</ol> | </ol> | ||
− | <li> | + | <li>Save the document.</li> |
− | Save the document. | + | |
− | </li> | + | |
</ol> | </ol> | ||
{{PDL1}} | {{PDL1}} |
Revision as of 09:23, 22 February 2008
- Apache OpenOffice Basic Macros and Libraries
- Apache OpenOffice Extension Manager
- Adding Template Files to an Apache OpenOffice Installation
- Adding AutoText Files to an Apache OpenOffice Network Installation
- Deactivating the Apache OpenOffice Registration Wizard
- Accessing Email Clients
- Customizing the User Interface
- Restricting Functionality in Apache OpenOffice
- Accessing Apache OpenOffice User Profiles on an LDAP Server
Apache OpenOffice Basic is a programming language that you can use to automate tasks in Apache OpenOffice.
Apache OpenOffice Basic macros are stored in modules which in turn are stored in libraries.
Libraries also act as containers for dialog boxes that you create in Apache OpenOffice Basic.
You can store Basic libraries in any directory that a user can access.
Contents
About Apache OpenOffice Basic Libraries and Modules
The default Apache OpenOffice Basic libraries are located in the <Apache OpenOffice installation>/share/basic directory. A library contains the following files:
- script.xlb
- An XML file that contains the names of the modules in the library.
- dialog.xlb
- An XML file that contains the names OF dialog boxes in the library.
- *.xba
- An XML file that stores the Apache OpenOffice Basic source code for a single Apache OpenOffice Basic module. The name of the file corresponds to the name of the module.
- *.xdl
- An XML file that stores the dialog elements of a Apache OpenOffice Basic dialog. The name of the file corresponds to the name of the dialog.
- *.pba
- A Apache OpenOffice 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.
About Apache OpenOffice Basic Configuration Files
The script.xlc and dialog.xlc configuration files list the location of Apache OpenOffice Basic libraries and dialogs. These files are in the <Apache OpenOffice installation>/user/basic/ directory which also contains the default Standard Apache OpenOffice Basic library as well as the user-defined libraries.
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.
- xlink:type
- This tag, which is 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 <user installation directory>/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 existing Apache OpenOffice installations or new installations only.
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.
-
As root, copy the custom library from the user installation where you created the library to the Apache OpenOffice server installation.
cp -r <Apache OpenOffice user installation directory>/user/basic/custom library <Apache OpenOffice installation directory>/share/basic/ Template:Documentation/Note -
In a text editor, open the script.xlc configuration file for the user installation and 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"/>
- On Solaris and Linux, open the <Apache OpenOffice user installation directory>/user/basic/script.xlc configuration file.
- On Windows, open the C:\Documents and Settings\user id\Application Data\Apache OpenOffice 2\user\basic\script.xlc configuration file
-
In a text editor, open the dialog.xlc configuration file for the user installation and 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"/>
- On Solaris and Linux, open the <Apache OpenOffice user installation directory>/user/basic/dialog.xlc configuration file.
- On Windows, open the C:\Documents and Settings\user id\Application Data\Apache OpenOffice 2\user\basic\dialog.xlc configuration file.
- Restart Apache OpenOffice on the workstations.
To Make a Custom Apache OpenOffice Basic Library Available to a Single User
-
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.
cp -r <Apache OpenOffice user installation directory>/user/basic/custom library <Apache OpenOffice user installation directory>/user/basic/ - On Windows, become a user with administrator privileges, and copy the library.
- On Solaris and Linux, become root, and copy the library.
-
In a text editor, open the script.xlc configuration file for the user installation and 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"/>
- On Solaris and Linux, open the <Apache OpenOffice user installation directory>/user/basic/script.xlc configuration file.
- On Windows, open the C:\Documents and Settings\user id\Application Data\Apache OpenOffice 2\user\basic\script.xlc configuration file.
-
In a text editor, open the dialog.xlc configuration file for the user installation and 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"/>
- On Solaris and Linux, open the <Apache OpenOffice user installation directory>/user/basic/dialog.xlc configuration file.
- On Windows, open the C:\Documents and Settings\user id\Application Data\Apache OpenOffice 2\user\basic\dialog.xlc configuration file.
- Restart Apache OpenOffice.
To Install a Custom Apache OpenOffice Basic Library With a Macro
You can create a macros that installs a Apache OpenOffice Basic library from a Apache OpenOffice document.
- In Writer, create a custom Apache OpenOffice Basic library in a new document.
- Save the document.
- Create an installation macro.
- Choose Tools → Macros → Organize Macros → Apache OpenOffice Basic. The Apache OpenOffice Basic Macros dialog box opens.
- In the Macro from list, select your Writer document.
- In the Macro name box, enter a name from the installation macro.
- Click the New button. The BASIC IDE window opens.
- Enter the following code:
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 <= 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 <source> <li>Replace the <tt>SrcLibraryName</tt> and <tt>DestLibraryName</tt> variables with the name of your library.</li> <li>Close the '''BASIC''' IDE window.</li> </ol> <li>Add a push button to the document.</li> <ol class="task" type="a"> <li>On the '''Tools''' toolbar, open the '''Controls''' toolbar, and click the '''Push Button''' icon.</li> <li>In your document, drag to draw the button.</li> </ol> <li>Assign the installation macro to a button event.</li> <ol class="task" type="a"> <li>Right-click the button, and choose '''Control'''.</li> <li>Click the '''Events''' tab.</li> <li>Click the '''...''' next to a button event, for example, the '''Mouse button pressed''' event.</li> <li>In the '''Assign Macro''' dialog box, click the '''Assign''' button. The '''Macro Selector''' dialog box opens.</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>Click the '''OK''' button.</li> <li>In the '''Assign Macro''' dialog box, click the '''OK''' button.</li> </ol> <li>Save the document.</li> </ol> {{PDL1}}