summaryrefslogtreecommitdiffstats
path: root/filters/kword/latex/import/generator/document.cpp
blob: cb333d41fc6f920bdb9fd1c79d3d5e4e0c6fcbe5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* This file is part of the KDE project
 * Copyright (C) 2003 Robert JACOLIN <rjacolin@ifrance.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#include <tqdom.h>
#include <tqtextstream.h>

#include "kdebug.h"
#include <KoStore.h>
#include "document.h"
#include "latex.h"
#include <param.h>
#include <command.h>

bool Document::analyse(TQPtrList<Element>* root)
{
	bool error = true;
	error &= analyseDocumentClass((Command*) Latex::instance()->getCommand(root, "documentclass"));
	
	/* Analyse body */
	_body.analyse(Latex::instance()->getEnv(root, "document"));
	return true;
}

bool Document::analyseDocumentClass(Command* documentclass)
{
	kdWarning(documentclass != NULL) << "no documentclass found !" << endl;
	TQPtrList<Param> params = documentclass->getOptions();
	Param* param;
	for ( param = params.first(); param; param = params.next() )
	{
		if(param->getKey() == "a4paper")
		{
		}
		else if(param->getKey() == "11pt")
		{
		}
	}
}

bool Document::generate(KoStore* store)
{
	TQDomDocument doc("KWORD");
	doc.appendChild(doc.createProcessingInstruction("xml", 
				"version=\"1.0\" encoding=\"UTF-8\""));
	
	/* DOC */
  TQDomElement root = doc.createElement("DOC");
	root.setAttribute("editor", "LaTex Import Filter");
	root.setAttribute("mime", "application/x-kword");
	root.setAttribute("syntaxVersion", "1");
  doc.appendChild(root);
	
	/* PAPER */
	
	/* ATTRIBUTES */

	/* FRAMESETS */
	TQDomElement body = doc.createElement("FRAMESETS");
	root.appendChild(body);

	/* generate body */
	_body.generate(body, doc);
	
	kdDebug(30522) << "serialize" << endl;
	serialize(store, doc);
	return true;
}

void Document::serialize(KoStore* store, TQDomDocument doc)
{
	TQCString str = doc.toCString();
	tqWarning(str);
	if(store->open("root"))
	{
		store->write((const char *)str, str.length());
		store->close();
	}
}