6 Using Writer2LaTeX from another application
6.2 Using Writer2LaTeX from a Basic macro
You can also access Writer2LaTeX through OOo's api. Here's an example using a Basic macro, but the principle is the same for any other language with a UNO binding.
Writer2LaTeX is used as any other filter in OOo. Using the parameter FilterData, you can provide specific options for Writer2LaTeX: You can give an URL for a configuration file to use and/or you can provide values for simple options (the order does not matter, the configuration file is always read first).
This example exports a document to LaTeX using a specific configuration, but overriding the value of the option use_colortbl.
Dim sUrl As String
sUrl = <url to document>
Dim sConfigUrl As String
sConfigUrl = <url to config>
Dim oFilterData(1) As New com.sun.star.beans.PropertyValue
oFilterData(0).Name = "ConfigURL"
oFilterData(0).Value = sConfigUrl
oFilterData(1).Name = "use_colortbl"
oFilterData(1).Value = "true"
Dim oProps(2) As New com.sun.star.beans.PropertyValue
oProps(0).Name = "FilterName"
oProps(0).Value = "org.openoffice.da.writer2latex"
oProps(1).Name = "Overwrite"
oProps(1).Value = true
oProps(2).Name = "FilterData"
oProps(2).Value = oFilterData
ThisComponent.StoreToURL(sUrl, oProps())
The table lists the names of the filters provided by Writer2LaTeX:
Format |
FilterName |
LaTeX |
org.openoffice.da.writer2latex |
BibTeX |
org.openoffice.da.writer2bibtex |
xhtml (text document) |
org.openoffice.da.writer2xhtml |
xhtml (spreadsheet) |
org.openoffice.da.calc2xhtml |
xhtml + MathML |
org.openoffice.da.writer2xhtml.mathml |
xhtml + MathML using xsl |
org.openoffice.da.writer2xhtml.mathml.xsl |
The url for the configuration can contain variables such as $(user) for the user installation of OOo. Thus for example sConfigUrl = “$(user)/myconfig.xml” can be used to point to a configuration within the user installation. See
http://api.openoffice.org/docs/common/ref/com/sun/star/util/PathSubstitution.html
for a list of available variables.
As a special feature, you can require one of Writer2LaTeX's standard configurations. To do this, the URL should start with an asterisk, for example sConfigUrl = “*ultraclean.xml”.