Language

The Free and Open Productivity Suite
Released: Apache OpenOffice 4.1.15



>>


Type Detection

General

In version src619, the old filter and type detection has been moved from "install.ini" to the new configuration management. To do this, the information was translated into XML format while the principle structure was modified. Now you can use the complete process of the loading, displaying or storing documents as a modular system. It functions generically in many components and can easily be adapted to your needs through the addition of your own modules or the removal of others.

Note:
The processes described in the following sections are still in the development phase and may be subject to change. We will update this site in the event of changes.


Configuration

The new structure of the configuration is illustrated by the following figure:

configuration structure

As shown on the left, the file consists of four lists (called Sets) and two DEFAULT entries. The list items are described by the structures shown on the right to which the arrows point.


  • The most important component of the configuration is the Type.
    It describes the type of contents which can be represented in the Office. This is usually a document type. However, the results of active contents (e.g. macros) or DB contents can also be described here.

    • The internal name of a type must be unique and is also used as list entry. It cannot contain any special characters. For example, a valid name is "my_own_type_for_example_files".

    • The UIName is used to display UI names and is localized. That means you can choose an assignment between value and language for it. Thus, support of CJK versions is possible. All UniCode characters are permitted here.

    • MediaType describes the MIME type of the contents. The regulations of the XML format are the reason for the separation into MediaType and "internal type name". Since the latter is used as an entry in the type list – and thus corresponds to one XML tag - not all special characters can be used. As a by-product of this, the internal names can be altered at any time without effecting the process as such.

    • The ClipboardFormat is a unique description of this type for use in clipboards.

    • Important components of a type are the URLPatterns. They enable the support of your own URL pattern.
      e.g. in the Office: "private:factory/swriter" for opening an empty writer document

    • Most important, however, are the Extensions. They make the assignment of a type to a URL possible. In 90% of the cases, the flat detection depends on them alone.

    • Since file endings cannot always be assigned to a particular type, the Preferred flag was introduced. It indicates the preferred type for a group of types with the same extensions. Otherwise, the first match is the one that will be used.

    • Finally, one type can also be assigned an icon. To do this, the DocumentIconID is used as reference to a resource.



Especially interesting is the possibility of registering modules, suitable for a type, which are capable of taking over various tasks. The "Filters/", "DetectServices" and "FrameLoaders" lists were created for this purpose.


  • What are DetectServices?

    Due to the registered types, flat detection is already possible, i.e. the assignment of types (e.g. to a URL) only on the basis of configuration data. If, however, you imagine special cases (e.g. modifying the file extension of a Writer file from .sdw to .doc), it quickly becomes clear that you cannot always get a correct result with flat detection. To be certain to get correct results, you need deep detection, i.e. the file itself has to be examined. And that is exactly the function of DetectServices. They get all the information collected so far on a document and then decide which type to assign it to. In the new modular model, such a detector is meant as UNO service which registers itself in the Office and is requested by the generic type detection if necessary. Therefore you need two pieces of information:

    • The ServiceName - This must be a valid UNO service name. It is also an entry in the corresponding configuration list.
      Example: "com.company.devision.DetectService"

    • A list of Types able to be recognized by this service - You can also implement and register detectors for groups of types.


  • What are FrameLoaders?

    FrameLoaders are also UNO services, but ones that are supposed to "load" a detected type. A visual component is expected as the result. The component can be com.sun.star.awt.XWindow or, optionally, a view component com.sun.star.frame.XController.

    • The UIName permits a localized display in selection dialogs.

    • In this case as well, the list of Types corresponds to the registration as possible loader for groups of types.


  • What are Filters?

    These objects also represent a service. Their function is to import or export the contents of a type into a component. Accordingly, import filters are differentiated from export filters. The component must implement the com.sun.star.lan.XComponent interface. Further interfaces are determined by the respective document service. The use of a filter usually comes from a loader.

    • The Installed flag indicates the installation status of a filter. A filter is generally registered equally for all users. But even in a network installation you should be able to deactivate this for certain groups or single users.

    • Even a filter should be able to show a localized UIName in selection dialogs.

    • A filter must register itself for a Type that it can edit. Multiple assignments are not possible.

    • The DocumentService describes the component on which the filter operates. Depending upon the use, this is seen either as output or goal of the filter process. A UNO service name is expected.

    • The FilterService is the real UNO service name of the filter implementation.

    • The Flags describe the sort of filter. This is where, among other things, the organization into import and export filters takes place.
      Note: External filters must set the ThirdParty flag in order to be detected as such!
      Supported flags are:

Import

  0x00000001 h

Export

  0x00000002 h

Template

  0x00000004 h

Internal

  0x00000008 h

TemplatePath

  0x00000010 h

Own

  0x00000020 h

Alien

  0x00000040 h

UsesOptions

  0x00000080 h

Default

  0x00000100 h

NotInFileDialog

  0x00001000 h

NotInChooser

  0x00002000 h

Asynchron

  0x00004000 h

Readonly

  0x00010000 h

NotInstalled

  0x00020000 h

ConsultService

  0x00040000 h

ThirdParty

  0x00080000 h

Packed

  0x00100000 h

SilentExport

  0x00200000 h

Preferred

  0x10000000 h

    • Some filters need to be able to store more configuration data than usual. This can be realized with the UserData entry. The format of the string list is not restricted in any way.

    • FileFormatVersion indicates a certain version number of a document which can be edited by this filter.

    • A TemplateName ...



>>


author

   Andreas Schlüns

email

   andreas.schluens@germany.sun.com

last modification

   11.04.2001



Apache Software Foundation

Copyright & License | Privacy | Contact Us | Donate | Thanks

Apache, OpenOffice, OpenOffice.org and the seagull logo are registered trademarks of The Apache Software Foundation. The Apache feather logo is a trademark of The Apache Software Foundation. Other names appearing on the site may be trademarks of their respective owners.