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

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2005 David Faure <faure@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 version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016  * Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #include <KoXmlReader.h>
00020 #include <KoOasisStore.h>
00021 #include <KoDom.h>
00022 #include <kdebug.h>
00023 #include <assert.h>
00024 //Added by qt3to4:
00025 #include <Q3CString>
00026 
00027 void testMimeForPath( KoXmlDocument& doc )
00028 {
00029     QString mime = KoOasisStore::mimeForPath( doc, "Object 1" );
00030     kDebug() << k_funcinfo << mime << endl;
00031     assert( !mime.isNull() );
00032     assert( !mime.isEmpty() );
00033     assert( mime == "application/vnd.oasis.opendocument.text" );
00034     kDebug() << "testMimeForPath OK" << endl;
00035 }
00036 
00037 int main( int, char** ) {
00038 
00039     const Q3CString xml = "\
00040 <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
00041 <manifest:manifest xmlns:manifest=\"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0\">\n\
00042  <manifest:file-entry manifest:media-type=\"application/vnd.oasis.opendocument.text\" manifest:full-path=\"/\"/>\n\
00043  <manifest:file-entry manifest:media-type=\"text/xml\" manifest:full-path=\"content.xml\"/>\n\
00044  <manifest:file-entry manifest:media-type=\"application/vnd.oasis.opendocument.text\" manifest:full-path=\"Object 1\"/>\n\
00045 </manifest:manifest> \
00046 ";
00047 
00048     KoXmlDocument doc;
00049     QString errorMsg;
00050     int errorLine, errorColumn;
00051     bool ok = doc.setContent( xml, true /* namespace processing */, &errorMsg, &errorLine, &errorColumn );
00052     if ( !ok ) {
00053         kError() << "Parsing error! Aborting!" << endl
00054             << " In line: " << errorLine << ", column: " << errorColumn << endl
00055             << " Error message: " << errorMsg << endl;
00056         return 1;
00057     }
00058 
00059     testMimeForPath( doc );
00060     return 0;
00061 }

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