F:/KPlato/koffice/libs/kofficecore/tests/filterchain_test.cpp

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2001 Werner Trobin <trobin@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include <KoFilterChain.h>
00021 #include <KoFilterManager.h>
00022 #include <kinstance.h>
00023 #include <kdebug.h>
00024 //Added by qt3to4:
00025 #include <Q3CString>
00026 
00027 int main( int /*argc*/, char ** /*argv*/ )
00028 {
00029     KInstance instance( "filterchain_test" );  // we need an instance when using the trader
00030     KOffice::Graph g( "application/x-kspread" );
00031     g.dump();
00032     g.setSourceMimeType( "application/x-kword" );
00033     g.dump();
00034 
00035     KoFilterManager *manager = new KoFilterManager( 0 );
00036     kDebug() << "Trying to build some filter chains..." << endl;
00037     Q3CString mimeType( "foo/bar" );
00038     KoFilterChain::Ptr chain = g.chain( manager, mimeType );
00039     if ( !chain )
00040         kDebug() << "Chain for 'foo/bar' is not available, OK" << endl;
00041     else {
00042         kError() << "Chain for 'foo/bar' is available!" << endl;
00043         chain->dump();
00044     }
00045 
00046     mimeType = "application/x-krita";
00047     chain = g.chain( manager, mimeType );
00048     if ( !chain )
00049         kDebug() << "Chain for 'application/x-krita' is not available, OK" << endl;
00050     else {
00051         kError() << "Chain 'application/x-krita' is available!" << endl;
00052         chain->dump();
00053     }
00054 
00055     mimeType = "text/x-csv";
00056     chain = g.chain( manager, mimeType );
00057     if ( !chain )
00058         kError() << "Chain for 'text/x-csv' is not available!" << endl;
00059     else {
00060         kDebug() << "Chain for 'text/x-csv' is available, OK" << endl;
00061         chain->dump();
00062     }
00063 
00064     // Try to find the closest KOffice part
00065     mimeType = "";
00066     chain = g.chain( manager, mimeType );
00067     if ( !chain )
00068         kDebug() << "It was already a KOffice part, OK" << endl;
00069     else
00070         kError() << "We really got a chain? ugh :}" << endl;
00071 
00072     g.setSourceMimeType( "text/x-csv" );
00073     mimeType = "";
00074     chain = g.chain( manager, mimeType );
00075     if ( !chain )
00076         kError() << "Hmm... why didn't we find a chain?" << endl;
00077     else {
00078         kDebug() << "Chain for 'text/x-csv' -> closest part is available ("
00079                   << mimeType << "), OK" << endl;
00080         chain->dump();
00081     }
00082 
00083     kDebug() << "Checking mimeFilter() for Import:" << endl;
00084     QStringList list = KoFilterManager::mimeFilter( "application/x-kword",  KoFilterManager::Import );
00085     QStringList::ConstIterator it = list.begin();
00086     QStringList::ConstIterator end = list.end();
00087     for ( ; it != end; ++it )
00088         kDebug() << "   " << *it << endl;
00089     kDebug() << "   " << list.count() << " entries." << endl;
00090 
00091     kDebug() << "Checking mimeFilter() for Export:" << endl;
00092     list = KoFilterManager::mimeFilter( "application/x-kword",  KoFilterManager::Export );
00093     it = list.begin();
00094     end = list.end();
00095     for ( ; it != end; ++it )
00096         kDebug() << "   " << *it << endl;
00097     kDebug() << "   " << list.count() << " entries." << endl;
00098 
00099     kDebug() << "Checking KoShell's mimeFilter():" << endl;
00100     list = KoFilterManager::mimeFilter();
00101     it = list.begin();
00102     end = list.end();
00103     for ( ; it != end; ++it )
00104         kDebug() << "   " << *it << endl;
00105     kDebug() << "   " << list.count() << " entries." << endl;
00106 
00107     delete manager;
00108     return 0;
00109 }

Généré le Wed Nov 22 23:41:04 2006 pour KPlato par  doxygen 1.5.1-p1