20#include <tdeparts/factory.h>
22#include <KoQueryTrader.h>
23#include <KoDocument.h>
26#include <kservicetype.h>
46KoDocumentEntry::KoDocumentEntry( KService::Ptr service )
47 : m_service( service )
53 KLibFactory* factory = KLibLoader::self()->
factory( TQFile::encodeName(m_service->library()) );
56 kdWarning(30003) << KLibLoader::self()->lastErrorMessage() << endl;
61 if ( factory->inherits(
"KParts::Factory" ) )
62 obj =
static_cast<KParts::Factory *
>(factory)->createPart( 0L,
"", parent,
name,
"KoDocument" );
64 kdWarning(30003) <<
"factory doesn't inherit KParts::Factory ! It is a " << factory->className() << endl;
65 obj = factory->create( parent,
name,
"KoDocument" );
68 if ( !obj || !obj->inherits(
"KoDocument" ) )
79 TQString constr = TQString::fromLatin1(
"[X-TDE-NativeMimeType] == '%1' or '%2' in [X-TDE-ExtraNativeMimeTypes]" ).arg( mimetype ).arg( mimetype );
81 TQValueList<KoDocumentEntry> vec =
query(
false,constr );
84 kdWarning(30003) <<
"Got no results with " << constr << endl;
86 TQString constr = TQString::fromLatin1(
"'%1' in ServiceTypes" ).arg( mimetype );
87 vec =
query( constr );
92 if ( KServiceType::serviceType( mimetype ) == 0L )
94 kdError(30003) <<
"Unknown KOffice MimeType " << mimetype <<
"." << endl;
95 kdError(30003) <<
"Check your installation (for instance, run 'tde-config --path mime' and check the result)." << endl;
98 kdError(30003) <<
"Found no KOffice part able to handle " << mimetype <<
"!" << endl;
99 kdError(30003) <<
"Check your installation (does the desktop file have X-TDE-NativeMimeType and KOfficePart, did you install KOffice in a different prefix than TDE, without adding the prefix to /etc/tderc ?)" << endl;
110 return query(
true,_constr);
116 TQValueList<KoDocumentEntry> lst;
118 if ( !_constr.isEmpty() ) {
123 constr +=
" exist Library";
126 TDETrader::OfferList offers = TDETrader::self()->query(
"KOfficePart", constr );
128 TDETrader::OfferList::ConstIterator it = offers.begin();
129 unsigned int max = offers.count();
130 for(
unsigned int i = 0; i < max; i++, ++it )
135 if ( (*it)->noDisplay() )
138 if ( (!_onlyDocEmb) || ((*it)->property(
"X-TDE-NOTKoDocumentEmbeddable").toString()!=
"1") )
147 if ( lst.count() > 1 && !_constr.isEmpty() )
148 kdWarning(30003) <<
"KoDocumentEntry::query " << constr <<
" got " << max <<
" offers!" << endl;
162KoFilterEntry::KoFilterEntry( KService::Ptr service )
163 : m_service( service )
165 import = service->property( "X-TDE-Import" ).toStringList();
166 export_ = service->property(
"X-TDE-Export" ).toStringList();
167 int w = service->property(
"X-TDE-Weight" ).toInt();
168 weight = w < 0 ? UINT_MAX : static_cast<unsigned int>( w );
169 available = service->property(
"X-TDE-Available" ).toString();
174 kdDebug(30500) <<
"KoFilterEntry::query( " << _constr <<
" )" << endl;
175 TQValueList<KoFilterEntry::Ptr> lst;
177 TDETrader::OfferList offers = TDETrader::self()->query(
"KOfficeFilter", _constr );
179 TDETrader::OfferList::ConstIterator it = offers.begin();
180 unsigned int max = offers.count();
182 for(
unsigned int i = 0; i < max; i++ )
197 KLibFactory* factory = KLibLoader::self()->factory( TQFile::encodeName( m_service->library() ) );
200 kdWarning(30003) << KLibLoader::self()->lastErrorMessage() << endl;
204 TQObject* obj = factory->create( parent, name,
"KoFilter" );
205 if ( !obj || !obj->inherits(
"KoFilter" ) )
KXMLGUIFactory * factory() const
Represents an available KOffice component that supports the document interface.
static KoDocumentEntry queryByMimeType(const TQString &mimetype)
This is a convenience function.
static TQValueList< KoDocumentEntry > query(const TQString &_constr=TQString())
This function will query tdesycoca to find all available components.
KoDocument * createDoc(KoDocument *parent=0, const char *name=0) const
Uses the factory of the component to create a document.
The KOffice document class.
This class represents a chain of plain KoFilter instances.
Represents an available filter.
static TQValueList< KoFilterEntry::Ptr > query(const TQString &_constr=TQString())
This function will query KDED to find all available filters.
The base class for import and export filters.
KoFilterChain * m_chain
Use this pointer to access all information about input/output during the conversion.