filters
document.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
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
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
00070
00071
00072
00073
00074 QDomElement body = doc.createElement("FRAMESETS");
00075 root.appendChild(body);
00076
00077
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 }
|