kword/latex/import/generator/document.cpp
1/* This file is part of the KDE project
2 * Copyright (C) 2003 Robert JACOLIN <rjacolin@ifrance.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#include <tqdom.h>
21#include <tqtextstream.h>
22
23#include "kdebug.h"
24#include <KoStore.h>
25#include "document.h"
26#include "latex.h"
27#include <param.h>
28#include <command.h>
29
30bool Document::analyse(TQPtrList<Element>* root)
31{
32 bool error = true;
33 error &= analyseDocumentClass((Command*) Latex::instance()->getCommand(root, "documentclass"));
34
35 /* Analyse body */
36 _body.analyse(Latex::instance()->getEnv(root, "document"));
37 return true;
38}
39
40bool Document::analyseDocumentClass(Command* documentclass)
41{
42 kdWarning(documentclass != NULL) << "no documentclass found !" << endl;
43 TQPtrList<Param> params = documentclass->getOptions();
44 Param* param;
45 for ( param = params.first(); param; param = params.next() )
46 {
47 if(param->getKey() == "a4paper")
48 {
49 }
50 else if(param->getKey() == "11pt")
51 {
52 }
53 }
54}
55
56bool Document::generate(KoStore* store)
57{
58 TQDomDocument doc("KWORD");
59 doc.appendChild(doc.createProcessingInstruction("xml",
60 "version=\"1.0\" encoding=\"UTF-8\""));
61
62 /* DOC */
63 TQDomElement root = doc.createElement("DOC");
64 root.setAttribute("editor", "LaTex Import Filter");
65 root.setAttribute("mime", "application/x-kword");
66 root.setAttribute("syntaxVersion", "1");
67 doc.appendChild(root);
68
69 /* PAPER */
70
71 /* ATTRIBUTES */
72
73 /* FRAMESETS */
74 TQDomElement body = doc.createElement("FRAMESETS");
75 root.appendChild(body);
76
77 /* generate body */
78 _body.generate(body, doc);
79
80 kdDebug(30522) << "serialize" << endl;
81 serialize(store, doc);
82 return true;
83}
84
85void Document::serialize(KoStore* store, TQDomDocument doc)
86{
87 TQCString str = doc.toCString();
88 tqWarning(str);
89 if(store->open("root"))
90 {
91 store->write((const char *)str, str.length());
92 store->close();
93 }
94}
bool analyse(Element *elt)
Analyse the latex tree and keep data.
Definition body.cpp:24
bool generate(TQDomElement &framesets, TQDomDocument &doc)
Generate a kword document.
Definition body.cpp:29
void serialize(KoStore *store, TQDomDocument tree)
Copy the DOM tree in a file.
bool analyseDocumentClass(Command *documentclass)
Analyse and get all information in a documentclass command.