26#include "fileheader.h"
39 _hasUnderline =
false;
40 _hasEnumerate =
false;
44 _processing = TP_NORMAL;
53 kdDebug(30522) <<
"FileHeader Destructor" << endl;
59void FileHeader::analysePaperParam(
const TQDomNode balise)
61 setFormat(getAttr(balise,
"format").toInt());
62 _width = getAttr(balise,
"width").toInt();
63 _height = getAttr(balise,
"height").toInt();
64 setOrientation(getAttr(balise,
"orientation").toInt());
65 setColumns(getAttr(balise,
"columns").toInt());
66 _columnSpacing = getAttr(balise,
"columnspacing").toInt();
67 setHeadType(getAttr(balise,
"hType").toInt());
68 setFootType(getAttr(balise,
"fType").toInt());
69 _headBody = getAttr(balise,
"spHeadBody").toInt();
70 _footBody = getAttr(balise,
"spFootBody").toInt();
77void FileHeader::analysePaper(
const TQDomNode balise)
79 analysePaperParam(balise);
83 TQDomNode fils = getChild(balise,
"PAPERSBORDERS");
84 _leftBorder = getAttr(fils,
"left").toInt();
85 _rightBorder = getAttr(fils,
"right").toInt();
86 _bottomBorder = getAttr(fils,
"bottom").toInt();
87 _topBorder = getAttr(fils,
"top").toInt();
93void FileHeader::analyseAttributs(
const TQDomNode balise)
95 setProcessing(getAttr(balise,
"processing").toInt());
96 setStandardPge(getAttr(balise,
"standardpage").toInt());
97 setTOC(getAttr(balise,
"hasTOC").toInt());
98 _hasHeader = getAttr(balise,
"hasHeader").toInt();
99 _hasFooter = getAttr(balise,
"hasFooter").toInt();
100 setUnit(getAttr(balise,
"unit").toInt());
106void FileHeader::generate(TQTextStream &out)
108 kdDebug(30522) <<
"GENERATION OF THE FILE HEADER" << endl;
109 if(Config::instance()->mustUseLatin1())
110 generateLatinPreambule(out);
111 else if(Config::instance()->mustUseUnicode())
112 generateUnicodePreambule(out);
114 generatePackage(out);
117 out <<
"%%%%%%%%%%%%%%%%%% END OF PREAMBLE %%%%%%%%%%%%%%%%%%" << endl << endl;
123void FileHeader::generatePaper(TQTextStream &out)
127 out <<
"% Format of paper" << endl;
128 kdDebug(30522) <<
"Generate custom size paper" << endl;
130 out <<
"\\setlength{\\paperwidth}{" << _width <<
"pt}" << endl;
131 out <<
"\\setlength{\\paperheight}{" << _height <<
"pt}" << endl;
133 out <<
"\\setlength{\\headsep}{" << _headBody <<
"pt}" << endl;
134 out <<
"\\setlength{\\footskip}{" << _footBody + _bottomBorder <<
"pt}" << endl;
136 out <<
"\\setlength{\\topmargin}{" << _topBorder <<
"pt}" << endl;
137 out <<
"\\setlength{\\textwidth}{" << _width - _rightBorder - _leftBorder <<
"pt}" << endl;
144void FileHeader::generateLatinPreambule(TQTextStream &out)
146 out <<
"%% Generated by KSpread. Don't modify this file but the file *.ksp." << endl;
147 out <<
"%% Send an email to rjacolin@ifrance.com for bugs, wishes, .... Thank you." << endl;
148 out <<
"%% Compile this file with : latex filename.tex" << endl;
149 out <<
"%% a dvi file will be generated." << endl;
150 out <<
"%% The file uses the latex style (not the kword style). " << endl;
151 out <<
"\\documentclass[";
164 out <<
"letterpaper, ";
167 out <<
"legalpaper, ";
179 out <<
"executivepaper, ";
182 if(getOrientation() == TO_LANDSCAPE)
183 out <<
"landscape, ";
193 out <<
"twocolumn, ";
199 out << Config::instance()->getDefaultFontSize() <<
"pt";
200 if(Config::instance()->getQuality() ==
"draft")
203 out << Config::instance()->getClass() <<
"}" << endl;
204 out <<
"\\usepackage[" << Config::instance()->getEncoding() <<
"]{inputenc}" << endl << endl;
210void FileHeader::generateUnicodePreambule(TQTextStream &out)
212 out <<
"%% Generated by KSpread. Don't modify this file but the file *.ksp." << endl;
213 out <<
"%% Send an email to rjacolin@ifrance.com for bugs, wishes, .... Thank you." << endl;
214 out <<
"%% Compile this file with : lambda filename.tex" << endl;
215 out <<
"%% a dvi file will be generated." << endl;
216 out <<
"%% Use odvips to convert it and to see it with gv" << endl;
217 out <<
"%% The file uses the latex style (not the kword style). " << endl;
218 out <<
"\\ocp\\TexUTF=inutf8" << endl;
219 out <<
"\\InputTranslation currentfile \\TexUTF" << endl;
220 out <<
"\\documentclass[";
233 out <<
"letterpaper, ";
236 out <<
"legalpaper, ";
248 out <<
"executivepaper, ";
251 if(getOrientation() == TO_LANDSCAPE)
252 out <<
"landscape, ";
262 out <<
"twocolumn, ";
268 out << Config::instance()->getDefaultFontSize() <<
"pt";
269 if(Config::instance()->getQuality() ==
"draft")
272 out << Config::instance()->getClass() <<
"}" << endl;
279void FileHeader::generatePackage(TQTextStream &out)
281 out <<
"% Package(s) to include" << endl;
282 if(Config::instance()->mustUseUnicode())
283 out <<
"\\usepackage{omega}" << endl;
285 out <<
"\\usepackage[a4paper]{geometry}" << endl;
286 if(hasFooter() || hasHeader())
287 out <<
"\\usepackage{fancyhdr}" << endl;
289 out <<
"\\usepackage{colortbl}" << endl;
291 out <<
"\\usepackage{ulem}" << endl;
293 out <<
"\\usepackage{enumerate}" << endl;
295 out <<
"\\usepackage{graphics}" << endl;
296 out <<
"\\usepackage{array}" << endl;
297 out <<
"\\usepackage{multirow}" << endl;
298 out <<
"\\usepackage{textcomp}" << endl;
299 out <<
"\\usepackage{rotating}" << endl;
301 TQStringList langs = Config::instance()->getLanguagesList();
302 if(langs.count() > 0)
304 out <<
"\\usepackage[" << langs.join(
", " ) <<
"]{babel}" << endl;
306 out <<
"\\usepackage{textcomp}" << endl;
309 if(langs.count() > 1)
310 out <<
"\\selectlanguage{" << Config::instance()->getDefaultLanguage()
311 <<
"}" << endl << endl;