filters

layout.cpp
1/*
2** A program to convert the XML rendered by KWord into LATEX.
3**
4** Copyright (C) 2000 Robert JACOLIN
5**
6** This library is free software; you can redistribute it and/or
7** modify it under the terms of the GNU Library General Public
8** License as published by the Free Software Foundation; either
9** version 2 of the License, or (at your option) any later version.
10**
11** This library is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14** Library General Public License for more details.
15**
16** To receive a copy of the GNU Library General Public License, write to the
17** Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19**
20*/
21
22#include <stdlib.h> /* for atoi function */
23
24#include <kdebug.h> /* for kdDebug() stream */
25
26#include "fileheader.h" /* for _header use */
27#include "tqlayout.h"
28#include "layout.h"
29
30/* Static Datas */
31TQString Layout::_last_name;
32EType Layout::_last_counter;
33
34/*******************************************/
35/* Constructor */
36/*******************************************/
38{
39 _last_name = "STANDARD";
40 _last_counter = TL_NONE;
41 _env = ENV_LEFT;
42 _counterType = TL_NONE;
43 _counterDepth = 0;
44 _counterBullet = 0;
45 _counterStart = 0;
46 _numberingType = -1;
47 _useHardBreakAfter = false;
48 _useHardBreak = false;
49 _keepLinesTogether = false;
50}
51
52/*******************************************/
53/* analyseLAyout */
54/*******************************************/
55void Layout::analyseLayout(const TQDomNode balise)
56{
57 /* Markup type : FORMAT id="1" pos="0" len="17">...</FORMAT> */
58
59 /* No parameters for this markup */
60 kdDebug(30522) << "ANALYSE OF THE BEGINING OF A LAYOUT" << endl;
61
62 /* Analyse children markups */
63 for(int index= 0; index < getNbChild(balise); index++)
64 {
65 if(getChildName(balise, index).compare("NAME")== 0)
66 {
67 kdDebug(30522) << "NAME : " << endl;
68 analyseName(getChild(balise, index));
69 }
70 else if(getChildName(balise, index).compare("FOLLOWING")== 0)
71 {
72 kdDebug(30522) << "FOLLOWING : " << endl;
73 analyseFollowing(getChild(balise, index));
74 }
75 else if(getChildName(balise, index).compare("FLOW")== 0)
76 {
77 kdDebug(30522) << "FLOW : " << endl;
78 analyseEnv(getChild(balise, index));
79 }
80 else if(getChildName(balise, index).compare("PAGEBREAKING")== 0)
81 {
82 kdDebug(30522) << "PAGEBREAKING : " << endl;
83 analyseBreakLine(getChild(balise, index));
84 }
85 else if(getChildName(balise, index).compare("COUNTER")== 0)
86 {
87 kdDebug(30522) << "COUNTER : " << endl;
88 analyseCounter(getChild(balise, index));
89 }
90 else if(getChildName(balise, index).compare("FORMAT")== 0)
91 {
92 kdDebug(30522) << "FORMAT : " << endl;
93 analyseFormat(getChild(balise, index));
94 }
95 }
96 kdDebug(30522) << "END OF THE BEGINING OF A LAYOUT" << endl;
97}
98
99void Layout::analyseName(const TQDomNode balise)
100{
101 /* <NAME value="times"> */
102 kdDebug(30522) << "PARAM" << endl;
103 setName(getAttr(balise, "value"));
104}
105
106/*******************************************/
107/* analyseFollowing */
108/*******************************************/
109/* Get info about folowing. Ununsefull. */
110/*******************************************/
111void Layout::analyseFollowing(const TQDomNode balise)
112{
113 /* <FOLLOWING name="times"> */
114 kdDebug(30522) << "PARAM" << endl;
115 setFollowing(getAttr(balise, "name"));
116}
117
118/*******************************************/
119/* analyseEnv */
120/*******************************************/
121/* Get informations about environment. */
122/*******************************************/
123void Layout::analyseEnv(const TQDomNode balise)
124{
125 /* <FLOW align="0"> */
126 // ERROR: Enter first in flow ????
127 kdDebug(30522) << "PARAM" << endl;
128 if(getAttr(balise,"align").compare("justify")== 0)
129 setEnv(ENV_JUSTIFY);
130 else if(getAttr(balise, "align").compare("left")== 0)
131 setEnv(ENV_LEFT);
132 else if(getAttr(balise, "align").compare("right")== 0)
133 setEnv(ENV_RIGHT);
134 else if(getAttr(balise, "align").compare("center")== 0)
135 setEnv(ENV_CENTER);
136}
137
138void Layout::analyseBreakLine(const TQDomNode balise)
139{
140 /* <NAME hardFrameBreakAfter="true"> */
141 kdDebug(30522) << "PARAM" << endl;
142 if(getAttr(balise, "linesTogether") != 0)
143 keepLinesTogether();
144 else if(getAttr(balise, "hardFrameBreak") != 0)
145 useHardBreak();
146 else if(getAttr(balise, "hardFrameBreakAfter") != 0)
147 useHardBreakAfter();
148}
149
150/*******************************************/
151/* analyseCounter */
152/*******************************************/
153/* Get all informations about counter. */
154/* If I use a counter, I must include a tex*/
155/* package. */
156/*******************************************/
157void Layout::analyseCounter(const TQDomNode balise)
158{
159 /* <COUNTER type="1"> */
160 kdDebug(30522) << "PARAM" << endl;
161 setCounterType(getAttr(balise, "type").toInt());
162 if(getCounterType() > TL_ARABIC && getCounterType() < TL_DISC_BULLET)
163 {
164 kdDebug(30522) << getCounterType() << endl;
165 FileHeader::instance()->useEnumerate();
166 }
167 setCounterDepth(getAttr(balise, "depth").toInt());
168 setCounterBullet(getAttr(balise, "bullet").toInt());
169 setCounterStart(getAttr(balise, "start").toInt());
170 setNumberingType(getAttr(balise, "numberingtype").toInt());
171}
void analyseLayout(const TQDomNode)
Helpfull functions.
Definition layout.cpp:55
Layout()
Constructors.
Definition layout.cpp:37
void setName(TQString name)
Modifiers.
Definition layout.h:122