7 Using Writer2LaTeX from another application
7.2 Using Writer2LaTeX from a Basic macro
You can also access Writer2LaTeX through LO'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 LO. 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). In addition (XHTML export only), you can define a target template and an included style sheet.
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 1.1 (text document) | org.openoffice.da.writer2xhtml11 |
XHTML (spreadsheet) | org.openoffice.da.calc2xhtml |
XHTML 1.1 (spreadsheet) | org.openoffice.da.calc2xhtml11 |
XHTML + MathML | org.openoffice.da.writer2xhtml.mathml |
HTML5 (text document) | org.openoffice.da.writer2xhtml5 |
HTML5 (spreadsheet) | org.openoffice.da.calc2xhtml5 |
EPUB | org.openoffice.da.writer2xhtml.epub |
EPUB 3 | org.openoffice.da.writer2xhtml.epub3 |
This table lists the special properties available for the filter data (all are optional):
Property | Purpose |
ConfigURL | Sets the URL for the configuration to use |
TargetTemplateURL | Sets the URL for an XHTML template to use (XHTML and EPUB only) |
StyleSheetURL | Sets the URL for a CSS style sheet to include (EPUB only) |
ResourceURL | Sets the URL for a folder containing resources (images and fonts) referred in the style sheet (EPUB only). All files contained in this folder will be included with the style sheet in the same directory as the style sheet. The media type will be determined from the file extension. If you want to define the media type yourself, use the more complex property Resources. |
Resources | Sets a list of resources (images and fonts) referred in the style sheet (EPUB only). This property is a semicolon separated list. Each entry is of the form URL[[::file name]::mime type] where the parts in square brackets are optional. For example file://mycomputer/home/myself/images/bg.png::background.png::image/png to point to a png image which is referenced by the file name background.png in the style sheet. The resource file will be placed in the same directory as the style sheet. |
The URLs can contain variables such as $(user) for the user installation of LO. Thus for example “$(user)/myconfig.xml” can be used to point to a configuration within the user installation. See
http://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1util_1_1PathSubstitution.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 “*ultraclean.xml”.