summaryrefslogtreecommitdiffstats
path: root/filters/kword/latex/export/variablezone.cc
blob: b73788b3e016fd3efa4af055294f68e202b25fda (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/* MEMO: to see the unicode table
 * xset +fp /usr/X11R6/lib/X11/fonts/ucs/
 * xfd -fn '-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1'
 */
/*
** A program to convert the XML rendered by KWord into LATEX.
**
** Copyright (C) 2002 - 2003 Robert JACOLIN
**
** 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.
**
** To receive a copy of the GNU Library General Public License, write to the
** Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
**
*/

#include <kdebug.h>				/* for kdDebug() stream */

#include "variablezone.h"
#include "para.h"
#include "document.h"

/*******************************************/
/* VariableZone                            */
/*******************************************/
VariableZone::VariableZone(Para* para): VariableFormat(para)
{
	setPara(para);
	setSize(para->getSize());
	setWeight(para->getWeight());
	setItalic(para->isItalic());
	setUnderlined(para->getUnderlineType());
	setStrikeout(para->isStrikeout());
}

/*******************************************/
/* VariableZone                             */
/*******************************************/
VariableZone::VariableZone(TQString text, Para* para): VariableFormat(para)
{
	setTexte(text);
	/*setPara(para);
	setSize(para->getSize());
	setWeight(para->getWeight());
	setItalic(para->isItalic());
	setUnderlined(para->getUnderlineType());
	setStrikeout(para->isStrikeout());*/
}

/*******************************************/
/* ~VariableZone                           */
/*******************************************/
VariableZone::~VariableZone()
{
	kdDebug(30522) << "Destruction of an area" << endl;
}

/*******************************************/
/* analyse                                 */
/*******************************************/
/* Analyse a text format, get the text used*/
/* by this format.                         */
/*******************************************/
void VariableZone::analyse(const TQDomNode balise)
{
	kdDebug(30522) << "FORMAT" << endl;
	/* Get header information (size, position)
	 * Get infos. to format the text
	 */
	//if(balise != 0)
		analyseFormat(balise);
	
	/* Format the text */
	setTexte(getTexte().mid(getPos(), getLength()));
	
	kdDebug(30522) << getTexte().length() << endl;
	kdDebug(30522) << getTexte().latin1() << endl;
	kdDebug(30522) << "END FORMAT" << endl;
}

/*******************************************/
/* generate                                */
/*******************************************/
/* Generate the text formated (if needed). */
/*******************************************/
void VariableZone::generate(TQTextStream &out)
{

	if(useFormat())
		generate_format_begin(out);

	/* Display the text */
	kdDebug(30522) << "type : " << getType() << endl;
	if((getType() == VAR_DATE) && !isFix())
		out << "\\today" << endl;
	else if(getType() == VAR_FOOTNOTE)
	{
		if(getNotetype() == "footnote")
			out << "\\,\\footnote{";
		else if(getNotetype() == "endnote")
			out << "\\,\\endnote{";
		/* Get the footnote and generate it. */
		Element* footnote = getRoot()->searchFootnote(getFrameset());
		if(footnote != NULL)
		{
			footnote->generate(out);
		}
		Config::instance()->writeIndent(out);
		out << "}";
	}
	else if(getType() == VAR_NOTE)
	{
		out << "\\marginpar{\\scriptsize ";
		if(Config::instance()->mustUseLatin1())
			display(escapeLatin1(getNote()), out);
		else if(Config::instance()->mustUseUnicode())
			display(getNote(), out);
		out << "}" << endl;
	}
	else
	{
		if(Config::instance()->mustUseLatin1())
			display(escapeLatin1(getText()), out);
		else if(Config::instance()->mustUseUnicode())
			display(getText(), out);
	}
	if(useFormat())
		generate_format_end(out);
	
}