26#include "fileheader.h"
38 _hasUnderline =
false;
39 _hasEnumerate =
false;
43 _processing = TP_NORMAL;
52 kdDebug(30522) <<
"FileHeader Destructor" << endl;
58void FileHeader::analysePaperParam(
const TQDomNode balise)
60 setFormat(getAttr(balise,
"format").toInt());
61 _width = getAttr(balise,
"width").toInt();
62 _height = getAttr(balise,
"height").toInt();
63 setOrientation(getAttr(balise,
"orientation").toInt());
64 setColumns(getAttr(balise,
"columns").toInt());
65 _columnSpacing = getAttr(balise,
"columnspacing").toInt();
66 setHeadType(getAttr(balise,
"hType").toInt());
67 setFootType(getAttr(balise,
"fType").toInt());
68 _headBody = getAttr(balise,
"spHeadBody").toInt();
69 _footBody = getAttr(balise,
"spFootBody").toInt();
76void FileHeader::analysePaper(
const TQDomNode balise)
78 analysePaperParam(balise);
82 TQDomNode fils = getChild(balise,
"PAPERSBORDERS");
83 _leftBorder = getAttr(fils,
"left").toInt();
84 _rightBorder = getAttr(fils,
"right").toInt();
85 _bottomBorder = getAttr(fils,
"bottom").toInt();
86 _topBorder = getAttr(fils,
"top").toInt();
92void FileHeader::analyseAttributs(
const TQDomNode balise)
94 setProcessing(getAttr(balise,
"processing").toInt());
95 setStandardPge(getAttr(balise,
"standardpage").toInt());
96 setTOC(getAttr(balise,
"hasTOC").toInt());
97 _hasHeader = getAttr(balise,
"hasHeader").toInt();
98 _hasFooter = getAttr(balise,
"hasFooter").toInt();
99 setUnit(getAttr(balise,
"unit").toInt());
105void FileHeader::generate(TQTextStream &out)
107 kdDebug(30522) <<
"GENERATION OF THE FILE HEADER" << endl;
108 if(Config::instance()->mustUseLatin1())
109 generateLatinPreambule(out);
110 else if(Config::instance()->mustUseUnicode())
111 generateUnicodePreambule(out);
113 generatePackage(out);
116 out <<
"%%%%%%%%%%%%%%%%%% END OF PREAMBLE %%%%%%%%%%%%%%%%%%" << endl << endl;
122void FileHeader::generatePaper(TQTextStream &out)
126 out <<
"% Format of paper" << endl;
127 kdDebug(30522) <<
"Generate custom size paper" << endl;
129 out <<
"\\setlength{\\paperwidth}{" << _width <<
"pt}" << endl;
130 out <<
"\\setlength{\\paperheight}{" << _height <<
"pt}" << endl;
132 out <<
"\\setlength{\\headsep}{" << _headBody <<
"pt}" << endl;
133 out <<
"\\setlength{\\footskip}{" << _footBody + _bottomBorder <<
"pt}" << endl;
135 out <<
"\\setlength{\\topmargin}{" << _topBorder <<
"pt}" << endl;
136 out <<
"\\setlength{\\textwidth}{" << _width - _rightBorder - _leftBorder <<
"pt}" << endl;
143void FileHeader::generateLatinPreambule(TQTextStream &out)
145 out <<
"%% Generated by KWord. Don't modify this file but the file *.kwd." << endl;
146 out <<
"%% Send an email to rjacolin@ifrance.com for bugs, wishes, .... Thank you." << endl;
147 out <<
"%% Compile this file with : latex filename.tex" << endl;
148 out <<
"%% a dvi file will be generated." << endl;
149 out <<
"%% The file uses the latex style (not the kword style). " << endl;
150 out <<
"\\documentclass[";
163 out <<
"letterpaper, ";
166 out <<
"legalpaper, ";
178 out <<
"executivepaper, ";
181 if(getOrientation() == TO_LANDSCAPE)
182 out <<
"landscape, ";
192 out <<
"twocolumn, ";
201 out << Config::instance()->getDefaultFontSize() <<
"pt";
202 if(Config::instance()->getQuality() ==
"draft")
205 out << Config::instance()->getClass() <<
"}" << endl;
206 out <<
"\\usepackage[" << Config::instance()->getEncoding() <<
"]{inputenc}" << endl << endl;
212void FileHeader::generateUnicodePreambule(TQTextStream &out)
214 out <<
"%% Generated by KWord. Don't modify this file but the file *.kwd." << endl;
215 out <<
"%% Send an email to rjacolin@ifrance.com for bugs, wishes, .... Thank you." << endl;
216 out <<
"%% Compile this file with : lambda filename.tex" << endl;
217 out <<
"%% a dvi file will be generated." << endl;
218 out <<
"%% Use odvips to convert it and to see it with gv" << endl;
219 out <<
"%% The file uses the latex style (not the kword style). " << endl;
220 out <<
"\\ocp\\TexUTF=inutf8" << endl;
221 out <<
"\\InputTranslation currentfile \\TexUTF" << endl;
222 out <<
"\\documentclass[";
235 out <<
"letterpaper, ";
238 out <<
"legalpaper, ";
250 out <<
"executivepaper, ";
253 if(getOrientation() == TO_LANDSCAPE)
254 out <<
"landscape, ";
264 out <<
"twocolumn, ";
273 out << Config::instance()->getDefaultFontSize() <<
"pt";
274 if(Config::instance()->getQuality() ==
"draft")
277 out << Config::instance()->getClass() <<
"}" << endl;
284void FileHeader::generatePackage(TQTextStream &out)
286 out <<
"% Package(s) to include" << endl;
287 if(Config::instance()->mustUseUnicode())
288 out <<
"\\usepackage{omega}" << endl;
290 out <<
"\\usepackage[a4paper]{geometry}" << endl;
291 if(hasFooter() || hasHeader())
292 out <<
"\\usepackage{fancyhdr}" << endl;
294 out <<
"\\usepackage{color}" << endl;
296 out <<
"\\usepackage{ulem}" << endl;
298 out <<
"\\usepackage{enumerate}" << endl;
300 out <<
"\\usepackage{graphics}" << endl;
303 out <<
"\\usepackage{array}" << endl;
304 out <<
"\\usepackage{multirow}" << endl;
306 TQStringList langs = Config::instance()->getLanguagesList();
307 if(langs.count() > 0)
309 out <<
"\\usepackage[" << langs.join(
", " ) <<
"]{babel}" << endl;
311 out <<
"\\usepackage{textcomp}" << endl;
314 if(langs.count() > 1)
315 out <<
"\\selectlanguage{" << Config::instance()->getDefaultLanguage()
316 <<
"}" << endl << endl;