Writing the Filtering Component

From Apache OpenOffice Wiki
< Documentation‎ | DevGuide
Revision as of 12:16, 1 October 2008 by Mba (Talk | contribs)

Jump to: navigation, search



The filtering component must implement the following interfaces as described by the com.sun.star.xml.ImportFilter service and the com.sun.star.xml.ExportFilter service:

Importer:

com.sun.star.xml.XMLImportFilter

Exporter:

com.sun.star.xml.XMLExportFilter and com.sun.star.xml.sax.XDocumentHandler

XImportFilter

The service com.sun.star.xml.XMLImportFilter defines an interface with the following method:

  boolean importer(
  [in] sequence< com::sun::star::beans::PropertyValue > aSourceData,
  [in] com::sun::star::xml::sax::XDocumentHandler xDocHandler,
  [in] sequence< string > msUserData )

aSourceData is a MediaDescriptor, which can be used to obtain the following information:

  • An XInputStream
This is a stream that is attached to the source to be read. This can be a file, or some other data source.
  • Filename
This is the name of the file on the disk, that the input stream comes from.
  • Url
This is a url describing the location being read.

xDocHandler is a SAX event handler that can be used when parsing an XInputStream, which may or may not contain OpenOffice.org XML. Before this stream can be read by OpenOffice.org, it will need to be transformed into OpenOffice.org XML.

msUserData is an array of Strings, that contains the information supplied in the UserData section of the Filter definition in the TypeDetection.xcu file.

XExportFilter

The com.sun.star.xml.XExportFilter defines an interface with the following method:

  boolean exporter( 
  [in] sequence< com::sun::star::beans::PropertyValue > aSourceData,
  [in] sequence< string > msUserData )

aSourceData and msUserData contain the same type of information as in the importer, except that the MediaDescriptor contains an XOutputStream, which can be used to write to.

XDocumentHandler

When the export takes place, the new Filtering component must also be an XDocumentHandler, to allow the output based on SAX events to be filtered, if required. For this reason, an XDocumentHandler is not passed to the exporter, and any exporter that is used by the XML filter adaptor must implement the com.sun.star.xml.sax.XDocumentHandler interface.

Template:Documentation/Note

Content on this page is licensed under the Public Documentation License (PDL).
Personal tools