lib Library API Documentation

KoEmbeddingFilter Class Reference

The base class for all import filters embedding other filters. More...

#include <koFilter.h>

Inheritance diagram for KoEmbeddingFilter:

Inheritance graph
[legend]
Collaboration diagram for KoEmbeddingFilter:

Collaboration graph
[legend]
List of all members.

Public Member Functions

int lruPartIndex () const

Static Public Member Functions

QString mimeTypeByExtension (const QString &extension)

Protected Member Functions

 KoEmbeddingFilter ()
int embedPart (const QCString &from, QCString &to, KoFilter::ConversionStatus &status, const QString &key=QString::null)
void startInternalEmbedding (const QString &key, const QCString &mimeType)
void endInternalEmbedding ()
int internalPartReference (const QString &key) const
QCString internalPartMimeType (const QString &key) const

Friends

class KoFilterChain

Detailed Description

The base class for all import filters embedding other filters.

Right now we don't support embedding for export filters, but if there's a request for that feature please don't hesitate to contact Werner Trobin <trobin@kde.org>.

To make use of embedding features you have to know that there are two kinds of embedding for filters: embedding the output of a different filter (library) or embedding the output of several internal filters (no separate library). The first case is the simpler one. You just have to override savePartContents and call embedPart to trigger the embedding process. One example for such a filter is Kontour's MSOD (MS Office Drawing) filter.

The more complex case is embedding various streams from within the same filter library. This is neccesary for OLE like files (at least with the current design of the OLEFilter). In this case you have to use startInternalEmbedding and endInternalEmbedding accordingly. Try to use the previous method if possible.

If you're using this class you can also setup a signal/slot communication between parent and child filter. To make that work you simply have to define signals and slots along the following rules: Signals should be named "commSignal<name>" where <name> is the name of the signal, slots should be named "commSlot<name>". The connection will be done automatically if names and signatures are matching.

Author:
Werner Trobin

Definition at line 142 of file koFilter.h.


Constructor & Destructor Documentation

KoEmbeddingFilter::KoEmbeddingFilter  )  [protected]
 

Constructs a filter.

Note that the m_chain pointer is 0 inside the constructor. Most likely your constructor will be empty.

Definition at line 62 of file koFilter.cc.


Member Function Documentation

QString KoEmbeddingFilter::mimeTypeByExtension const QString extension  )  [static]
 

A static helper method to determine the mimetype via the file extension.

It allows to go from "wmf" to image/x-wmf and so on. Note that you should only pass the pure extension and not a whole pattern like "*.doc" or so.

Definition at line 52 of file koFilter.cc.

int KoEmbeddingFilter::embedPart const QCString from,
QCString to,
KoFilter::ConversionStatus status,
const QString key = QString::null
[protected]
 

Embed some document using an external filter (i.e.

a different filter library). This method works according to the template method pattern and calls savePartContents during execution. Call this method when you want to convert some data using one or more KOffice filters selected via the filter manager. This is the way to go when it comes to embedding unless you have very special requirements.

Parameters:
from The mimetype of the source data
to The mimetype of the destination part. If this field is set to "" the filter manager will try to find the best native KOffice mimetype. When the method returns this parameter will hold the string of the used mimetype.
status Returns the error status of the filter
key Optional key field to allow custom keys inside the part map (see internalPartReference). If this field is left empty we generate a key from the part number (e.g. 1 -> "1")
Returns:
The number of the part (can be used to refer to the part from within the embedding filter).

Definition at line 67 of file koFilter.cc.

References KoFilterManager::exp0rt().

void KoEmbeddingFilter::startInternalEmbedding const QString key,
const QCString mimeType
[protected]
 

Method to perform "internal" embedding of parts in olefilter-style.

This method can be used to signal the start of a new embedding level within your filter. Very evil, but what shall I say ;) Unless you really have to you should always use embedPart as it's easier to use and not as hacky.

Parameters:
key The key we use to store reference/mimetype of your new part
mimeType The mimetype of the part you're about to embed

Definition at line 89 of file koFilter.cc.

void KoEmbeddingFilter::endInternalEmbedding  )  [protected]
 

This method signals the end of an internal embedding session.

You have to call that exactly as often as you call startInternalEmbedding or you'll mess up the internal stack and your file will be invalid. Again: use embedPart if you can :-)

Definition at line 97 of file koFilter.cc.

int KoEmbeddingFilter::internalPartReference const QString key  )  const [protected]
 

Query the internal part map for the reference of the part matching the given key.

Note that you can use that plain simple int to refer to the respective part (when used as string).

Parameters:
key The key you would like to look up
Returns:
The reference or -1 if we didn't find a part with the given key

Definition at line 107 of file koFilter.cc.

QCString KoEmbeddingFilter::internalPartMimeType const QString key  )  const [protected]
 

Query the internal part map for the mimetype of the part matching the given key.

Parameters:
key The key you would like to look up
Returns:
The mimetype, might be empty if the part matching the given key doesn't exist.

Definition at line 115 of file koFilter.cc.


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Mar 11 11:48:47 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003