filters

document.cc

00001 /* This file is part of the KDE project
00002  * Copyright (C) 2003 Robert JACOLIN <rjacolin@ifrance.com>
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 <qdom.h>
00021 #include <qtextstream.h>
00022 
00023 #include "kdebug.h"
00024 #include <KoStore.h>
00025 #include "document.h"
00026 #include "latex.h"
00027 #include <param.h>
00028 #include <command.h>
00029 
00030 bool Document::analyse(QPtrList<Element>* root)
00031 {
00032     bool error = true;
00033     error &= analyseDocumentClass((Command*) Latex::instance()->getCommand(root, "documentclass"));
00034     
00035     /* Analyse body */
00036     _body.analyse(Latex::instance()->getEnv(root, "document"));
00037     return true;
00038 }
00039 
00040 bool Document::analyseDocumentClass(Command* documentclass)
00041 {
00042     kdWarning(documentclass != NULL) << "no documentclass found !" << endl;
00043     QPtrList<Param> params = documentclass->getOptions();
00044     Param* param;
00045     for ( param = params.first(); param; param = params.next() )
00046     {
00047         if(param->getKey() == "a4paper")
00048         {
00049         }
00050         else if(param->getKey() == "11pt")
00051         {
00052         }
00053     }
00054 }
00055 
00056 bool Document::generate(KoStore* store)
00057 {
00058     QDomDocument doc("KWORD");
00059     doc.appendChild(doc.createProcessingInstruction("xml", 
00060                 "version=\"1.0\" encoding=\"UTF-8\""));
00061     
00062     /* DOC */
00063   QDomElement root = doc.createElement("DOC");
00064     root.setAttribute("editor", "LaTex Import Filter");
00065     root.setAttribute("mime", "application/x-kword");
00066     root.setAttribute("syntaxVersion", "1");
00067   doc.appendChild(root);
00068     
00069     /* PAPER */
00070     
00071     /* ATTRIBUTES */
00072 
00073     /* FRAMESETS */
00074     QDomElement body = doc.createElement("FRAMESETS");
00075     root.appendChild(body);
00076 
00077     /* generate body */
00078     _body.generate(body, doc);
00079     
00080     kdDebug(30522) << "serialize" << endl;
00081     serialize(store, doc);
00082     return true;
00083 }
00084 
00085 void Document::serialize(KoStore* store, QDomDocument doc)
00086 {
00087     QCString str = doc.toCString();
00088     qWarning(str);
00089     if(store->open("root"))
00090     {
00091         store->write((const char *)str, str.length());
00092         store->close();
00093     }
00094 }
KDE Home | KDE Accessibility Home | Description of Access Keys