Difference between revisions of "Documentation/DevGuide/OfficeDev/Properties of a Filter"
Line 85: | Line 85: | ||
| ''OWN'' | | ''OWN'' | ||
<code>0x00000020 h</code> | <code>0x00000020 h</code> | ||
− | | The filter is a native | + | | The filter is a native {{AOO}} format (ODF or otherwise). |
|- | |- | ||
| ''PREFERRED'' | | ''PREFERRED'' | ||
Line 97: | Line 97: | ||
| ''SUPPORTSSELECTION'' | | ''SUPPORTSSELECTION'' | ||
<code>0x00000400 h</code> | <code>0x00000400 h</code> | ||
− | | Filter can export only the selected part of a document. This information enables {{ | + | | Filter can export only the selected part of a document. This information enables {{AOo}} to enable a corresponding check box in the "File-Export" dialog. |
|- | |- | ||
| ''TEMPLATE'' | | ''TEMPLATE'' | ||
Line 123: | Line 123: | ||
===Sample configuration for an API based filter=== | ===Sample configuration for an API based filter=== | ||
− | + | <syntaxhighlight lang="xml"> | |
<!-- Filter section --> | <!-- Filter section --> | ||
<node oor:name="Text (encoded)" oor:op="replace"> | <node oor:name="Text (encoded)" oor:op="replace"> | ||
Line 138: | Line 138: | ||
<prop oor:name="DocumentService"><value>com.sun.star.text.TextDocument</value></prop> | <prop oor:name="DocumentService"><value>com.sun.star.text.TextDocument</value></prop> | ||
</node> | </node> | ||
− | + | </syntaxhighlight> | |
{{Note|This filter has a UIComponent that shows that this filter needs additional information to load a file properly (the encoding of it in case it can't be detected). It does not have a "FilterService" property because it is an internal, C++ based filter.}} | {{Note|This filter has a UIComponent that shows that this filter needs additional information to load a file properly (the encoding of it in case it can't be detected). It does not have a "FilterService" property because it is an internal, C++ based filter.}} | ||
Line 144: | Line 144: | ||
===Sample configuration for an XML based filter=== | ===Sample configuration for an XML based filter=== | ||
− | + | <syntaxhighlight lang="xml"> | |
<!-- Filter section --> | <!-- Filter section --> | ||
<node oor:name="PocketWord File" oor:op="replace"> | <node oor:name="PocketWord File" oor:op="replace"> | ||
Line 159: | Line 159: | ||
<prop oor:name="Flags"><value>IMPORT EXPORT ALIEN 3RDPARTYFILTER</value></prop> | <prop oor:name="Flags"><value>IMPORT EXPORT ALIEN 3RDPARTYFILTER</value></prop> | ||
</node> | </node> | ||
− | + | </syntaxhighlight> | |
{{Note|This filter uses the XMLFilterAdaptor service. The "UserData" property is a space-separated list where the first list element denotes the XMLImportFilter to be instantiated and the third one and fourth one are service names of DocumentHandlers for import and export. Further parameters depend on the XMLImportFilter used.}} | {{Note|This filter uses the XMLFilterAdaptor service. The "UserData" property is a space-separated list where the first list element denotes the XMLImportFilter to be instantiated and the third one and fourth one are service names of DocumentHandlers for import and export. Further parameters depend on the XMLImportFilter used.}} | ||
Line 165: | Line 165: | ||
===Sample configuration for an xslt based filter=== | ===Sample configuration for an xslt based filter=== | ||
− | + | <syntaxhighlight lang="xml"> | |
<!-- Filter section --> | <!-- Filter section --> | ||
<node oor:name="MediaWiki" oor:op="replace"> | <node oor:name="MediaWiki" oor:op="replace"> | ||
Line 179: | Line 179: | ||
<prop oor:name="Flags"><value>EXPORT ALIEN 3RDPARTYFILTER</value></prop> | <prop oor:name="Flags"><value>EXPORT ALIEN 3RDPARTYFILTER</value></prop> | ||
</node> | </node> | ||
− | + | </syntaxhighlight> | |
{{Note|This filter uses the XMLFilterAdaptor service. The "UserData" property is a space-separated list where the first list element denotes the XMLImportFilter to be instantiated and the third one and fourth one are service names of DocumentHandlers for import and export. Further parameters depend on the XMLImportFilter used. }} | {{Note|This filter uses the XMLFilterAdaptor service. The "UserData" property is a space-separated list where the first list element denotes the XMLImportFilter to be instantiated and the third one and fourth one are service names of DocumentHandlers for import and export. Further parameters depend on the XMLImportFilter used. }} | ||
Line 191: | Line 191: | ||
(6) relative or absolute path name to an importing style sheet | (6) relative or absolute path name to an importing style sheet | ||
− | {{Note|Older xslt based filters might have used the pre-ODF file format of {{ | + | {{Note|Older xslt based filters might have used the pre-ODF file format of {{AOo}}. They used importer and exporter class without "Oasis" in their names.}} |
{{PDL1}} | {{PDL1}} | ||
[[Category:Documentation/Developer's Guide/Office Development]] | [[Category:Documentation/Developer's Guide/Office Development]] |
Revision as of 12:18, 3 January 2021
Every filter inside OpenOffice.org is specified by the properties shown in the table below. These values are accessible at the previously mentioned service com.sun.star.document.FilterFactory using the interface com.sun.star.container.XNameAccess. Write access is not available here. All types are addressed by their internal names. The property names are identical to the configuration property names.
The documentation of the FilterFactory service currently is outdated. In case of conflicting information about the properties this page is right. An update will follow soon. |
A filter always is registered for only one type. A single filter implementation can handle several types but then must be registered multiple times. One type may handled by more than one filter.
Property Name | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Name
|
string. The internal name of the filter. This is only an API property, not a configuration property. In the configuration this is the name of the configuration node containing all the other properties. To avoid name clashes with other node names it should follow the rules outlined for extension identifiers. | ||||||||||||||||||||||||||||||
UIName
|
string. User friendly name of the type. It may be localized using the localization support of the configuration. All Unicode characters are permitted here. The UI names of filters are used in the various file dialog. | ||||||||||||||||||||||||||||||
Type
|
string. A filter is registered for the type it can handle. Multiple assignments are not allowed. Use multiple configuration entries to support more than one type with a single filter implementation. | ||||||||||||||||||||||||||||||
DocumentService
|
string. UNO service name describing the component on which the filter can operate. As an example, "com.sun.star.text.TextDocument " specifies the filter as working with text documents. An object of this type will be passed to the filter in its setTargetDocument() or setSourceDocument() methods.
| ||||||||||||||||||||||||||||||
FilterService
|
string. This is the UNO service or implementation name of the filter. Of course a service name can be used only if it is not the generic com.sun.star.document.ImportFilter or com.sun.star.document.ExportFilter. In case of XML based filters the service name always must be com.sun.star.comp.Writer.XMLFilterAdaptor . This filter will use the "UserData" property to find the XMLImporter or XMLExporter service it shall instantiate.
| ||||||||||||||||||||||||||||||
UIComponent
|
string. UNO service or implementation name of a UI component (usually a dialog) where users can parameterize the filtering process. As an example, the "Text - txt - csv (StarCalc) " filter needs information about the used column separators to load data. More about that in the chapter about filter options.
| ||||||||||||||||||||||||||||||
Flags
|
| ||||||||||||||||||||||||||||||
UserData
|
sequence<string>. Some filters need to store more configuration to work properly. The format of the string list is not restricted. An important example is the filter that implements the XMLFilterAdaptor service. It will get the service name of the XML based filter it must instantiate from the user data. In case this XML based filter is one of the XML adaptors for xslt files, the user data also must contain at least an absolute or relative file path point to the xslt file carrying out the transformation. | ||||||||||||||||||||||||||||||
FileFormatVersion
|
int. Indicates that a filter handles only a particular format version of the content type. If a filter implementation can handle several versions of a filter, several configuration entries have to be created. This is not necessary if the filter handles all possible versions and the different versions don't need to appear in the user interface. | ||||||||||||||||||||||||||||||
TemplateName
|
string. The name of a template file for styles the target document of an import filter shall use. If this property is set, the document merges the styles of this template with its default styles before the import starts. |
Besides these filter flags there are other flags existing that are used currently, but are not documented here. Use documented flags only. |
Sample configuration for an API based filter
<!-- Filter section --> <node oor:name="Text (encoded)" oor:op="replace"> <prop oor:name="UIName"> <value>Text (encoded)</value> </prop> <prop oor:name="Flags"><value>IMPORT EXPORT ALIEN</value></prop> <prop oor:name="UIComponent"><value>com.sun.star.comp.Writer.FilterOptionsDialog</value></prop> <prop oor:name="FilterService"/> <prop oor:name="UserData"><value>TEXT_DLG</value></prop> <prop oor:name="FileFormatVersion"><value>0</value></prop> <prop oor:name="Type"><value>writer_Text_encoded</value></prop> <prop oor:name="TemplateName"/> <prop oor:name="DocumentService"><value>com.sun.star.text.TextDocument</value></prop> </node>
Sample configuration for an XML based filter
<!-- Filter section --> <node oor:name="PocketWord File" oor:op="replace"> <prop oor:name="UIName"> <value>Pocket Word</value> </prop> <prop oor:name="Type"><value>writer_PocketWord_File</value></prop> <prop oor:name="FileFormatVersion"><value>0</value></prop> <prop oor:name="DocumentService"><value>com.sun.star.text.TextDocument</value></prop> <prop oor:name="FilterService"><value>com.sun.star.comp.Writer.XmlFilterAdaptor</value></prop> <prop oor:name="UIComponent"/> <prop oor:name="UserData"><value>com.sun.star.documentconversion.XMergeBridge classes/pocketword.jar com.sun.star.comp.Writer.XMLImporter com.sun.star.comp.Writer.XMLExporter staroffice/sxw application/x-pocket-word</value></prop> <prop oor:name="TemplateName"/> <prop oor:name="Flags"><value>IMPORT EXPORT ALIEN 3RDPARTYFILTER</value></prop> </node>
Sample configuration for an xslt based filter
<!-- Filter section --> <node oor:name="MediaWiki" oor:op="replace"> <prop oor:name="FileFormatVersion"><value>0</value></prop> <prop oor:name="Type"><value>MediaWiki</value></prop> <prop oor:name="DocumentService"><value>com.sun.star.text.TextDocument</value></prop> <prop oor:name="UIComponent"/> <prop oor:name="UserData"><value oor:separator=",">com.sun.star.documentconversion.XSLTFilter,,,com.sun.star.comp.Writer.XMLOasisExporter,,../share/xslt/wiki/odt2mediawiki.xsl</value></prop> <prop oor:name="FilterService"><value>com.sun.star.comp.Writer.XmlFilterAdaptor</value></prop> <prop oor:name="UIName"> <value xml:lang="x-default">MediaWiki</value> </prop> <prop oor:name="Flags"><value>EXPORT ALIEN 3RDPARTYFILTER</value></prop> </node>
Here the XMLFilter used is the com.sun.star.documentconversion.XSLTFilter that bridges to xslt files and basically can import and export if a suitable xslt is provided. It expects the following parameters in the user data ($(APP) stands for Writer,Calc,Draw,Impress,Chart,Math):
(1) service name of the XSLTFilter (3) implementation/service name of an importer class (com.sun.star.comp.$(APP).XMLOasisImporter) (4) implementation/service name of an exporter class (com.sun.star.comp.$(APP).XMLOasisExporter) (5) relative or absolute path name to an importing style sheet (6) relative or absolute path name to an importing style sheet
Older xslt based filters might have used the pre-ODF file format of Apache OpenOffice. They used importer and exporter class without "Oasis" in their names. |
Content on this page is licensed under the Public Documentation License (PDL). |