The Flat Xml Filter
====================


This sample provides a sample FlatXml filter for Openoffice. It have been developed to make use of the XmlFilterAdapter module. This code can also be used as a Skeleton implementation for developing a more complex filter.



How does the code work?
========================

  Firstly, the code has been developed to use the XmlFilterAdaptor module. For this reason, we must conform to the interfaces that the XmlFilterAdaptor is expecting. These interfaces are 

	com/sun/star/xml/XImportFilter
	com/sun/star/xml/XExportFilter	

Also, when we are exporting, we want the FlatXml filter to behave like a DocumentHandler, we must also implement the XDocumentHandler interface

	com/sun/star/xml/sax/XDocumentHandler 		

With these interfaces implemented, we can now start to get the code to work as a import and export filter.



How do I Build the code?
========================
	run:
		make solaris_workshopcxx //for Solaris 
		make win_microcxx 	 //for windows
		make linux_gcc		 //for linux
This will produce a FlatXml.so or FlatXml.dll library in the <platform>/lib directory.




How do I register this filter with OpenOffice?
==============================================

The Odk contains a program called "regcomp". This program queries a component (library or jar file) for information and then places this information into an OpenOffice installations "applicat.rdb". This database is used by OpenOffice to identify what components it has and where to find them. 

To register a component on Solaris or Linux:
----------------------------------------------------------
	regcomp -register -br <OOo installation dir>/program/applicat.rdb -r  <OOo installation dir>/program/applicat.rdb -c "file:///<Url of component>/<componentname>.so"

To register a component on windows:
----------------------------------
	regcomp -register -br <OOo installation dir>/program/applicat.rdb -r  <OOo installation dir>/program/applicat.rdb -c "file:///<Url of component>/<componentname>.dll"

To register a java based component (Jar file):
----------------------------------------------
	regcomp -register -br <OOo installation dir>/program/applicat.rdb -r  <OOo installation dir>/program/applicat.rdb -c "file:///<Url of component>/<componentname>.jar" -l com.sun.star.loader.Java2

(For more info on registering java components see http://udk.openoffice.org/java/man/register_java_components.html)





How do I access this filter from OpenOffice?
============================================ 

In an OpenOffice installation set, there is a file called TypeDetection.xml (usually located at <install dir>/share/config/registry/instance/org/openoffice/Office/TypeDetection.xml).
This file contains the definitions of all of the filters that staroffice uses to open and save files. Therefore, we must add an entry to this file in order to make our filters visible and usable within OpenOffice.

The TypeDetection.xml consists of <Type> definitions which describe a particular format and <Filter> definitions which define how a Type is opened and saved.

Firstly, make a backup of your TypeDetection.xml file.
When this has been done, cut and paste the following into the relevant sections in the TypeDetection.xml file.

	under Types:
	============
		 <Type cfg:name="writer_Flat_XML_File">
				<UIName cfg:type="string" cfg:localized="true">
					<cfg:value xml:lang="en-US">Flat XML File</cfg:value>
				</UIName>
				<Data cfg:type="string">1,,,,xml,20002,</Data>
		 </Type>

	under Filters:
	==============	
		<Filter cfg:name="Flat XML File">
				<Installed cfg:type="boolean">true</Installed>
				<UIName cfg:type="string" cfg:localized="true"				       <cfg:value xml:lang="en-US">Flat XML File</cfg:value></UIName>
				<Data cfg:type="string">0,writer_Flat_XML_File,com.sun.star.text.TextDocument,com.sun.star.comp.Writer.XmlFilterAdaptor,524355,com.sun.star.documentconversion.XFlatXml; ;com.sun.star.comp.Writer.XMLImporter;com.sun.star.comp.Writer.XMLExporter,0,,</Data>	
		</Filter>

This filter definition, will now open Flat Xml files with the extension .xml. 


Now What?
=========
When OpenOffice is restarted, a new filter type will be available in the Open and Save Dialog boxes. To save a file as Flat Xml, just go to the "Save As" menu item, and select  "Flat XML File" as the format. 





