28#include "fileheader.h"
30#include "variablezone.h"
35TQPtrStack<EType> Para::_historicList;
36int Para::_tabulation = 0;
58 kdDebug(30522) <<
"Destruction of a parag." << endl;
71 return _element->getSection();
84 return (EFormat) getAttr(balise,
"id").toInt();
99 kdDebug(30522) <<
" NB ZONE : " << _lines->count() << endl;
101 for(zone = _lines->first(); zone != 0; zone = _lines->next())
103 switch(zone->
getId())
106 nb = nb + ((
TextZone*) zone)->getSize();
133 kdDebug(30522) <<
"**** PARAGRAPH ****" << endl;
136 for(
int index = 0; index < getNbChild(balise); index++)
138 if(getChildName(balise, index).compare(
"TEXT")== 0)
140 _text = getData(balise, index);
141 kdDebug(30522) <<
"TEXT : " << _text << endl;
143 else if(getChildName(balise, index).compare(
"NAME")== 0)
145 analyseName(getChild(balise, index));
147 else if(getChildName(balise, index).compare(
"INFO")== 0)
149 analyseInfo(getChild(balise, index));
155 else if(getChildName(balise, index).compare(
"FORMATS")== 0)
158 kdDebug(30522) <<
"FORMATS" << endl;
159 analyseFormats(getChild(balise, index));
162 else if(getChildName(balise, index).compare(
"LAYOUT")== 0)
164 kdDebug(30522) <<
"LAYOUT" << endl;
165 analyseLayoutPara(getChild(balise, index));
168 kdDebug(30522) <<
" **** END PARAGRAPH ****" << endl;
177void Para::analyseName(
const TQDomNode balise)
181 _name =
new TQString(getAttr(balise,
"NAME"));
190void Para::analyseInfo(
const TQDomNode balise)
194 _info = (EP_INFO) getAttr(balise,
"INFO").toInt();
218void Para::analyseLayoutPara(
const TQDomNode balise)
223 for(
int index= 0; index < getNbChild(balise); index++)
225 if(getChildName(balise, index).compare(
"FORMAT")== 0)
229 if(_currentPos != _text.length())
231 zone =
new TextZone(_text,
this);
232 ((TextZone*) zone)->setPos(_currentPos);
233 ((TextZone*) zone)->setLength(_currentPos - _text.length());
234 ((TextZone*) zone)->analyse();
236 _lines =
new TQPtrList<Format>;
238 _lines->append(zone);
239 _currentPos = _currentPos + ((TextZone*) zone)->getLength();
255void Para::analyseFormats(
const TQDomNode balise)
257 for(
int index= 0; index < getNbChild(balise,
"FORMAT"); index++)
259 if(getChildName(balise, index).compare(
"FORMAT")== 0)
261 kdDebug(30522) <<
"A FORMAT !!!" << endl;
262 analyseFormat(getChild(balise, index));
265 kdDebug(30522) <<
" FORMAT UNUSEFULL HERE" << endl;
276void Para::analyseFormat(
const TQDomNode balise)
281 kdDebug(30522) <<
"ANALYSE FORMAT BODY" << endl;
284 case EF_ERROR: kdDebug(30522) <<
"Id format error" << endl;
287 zone =
new TextZone(_text,
this);
288 if(_currentPos != _text.length())
291 if(zone->getPos() != _currentPos)
294 _lines =
new TQPtrList<Format>;
296 zoneFirst =
new TextZone(_text,
this);
297 zoneFirst->setPos(_currentPos);
298 zoneFirst->setLength(zone->getPos() - _currentPos);
299 ((TextZone*) zoneFirst)->analyse();
302 _lines->append(zoneFirst);
303 _currentPos = _currentPos + ((TextZone*) zoneFirst)->getLength();
312 zone =
new VariableZone(
this);
316 zone =
new Footnote(
this);
320 zone =
new Anchor(
this);
324 kdDebug(30522) <<
"Format not yet supported" << endl;
327 if(zone->getPos() != _currentPos)
330 _lines =
new TQPtrList<Format>;
332 zoneFirst =
new TextZone(_text,
this);
333 zoneFirst->setPos(_currentPos);
334 zoneFirst->setLength(zone->getPos() - _currentPos);
335 ((TextZone*) zoneFirst)->analyse();
336 kdDebug(30522) <<
"pos courante : " << _currentPos << endl;
338 _lines->append(zoneFirst);
339 _currentPos = _currentPos + zoneFirst->getLength();
345 _lines =
new TQPtrList<Format>;
348 _lines->append(zone);
349 _currentPos = _currentPos + zone->getLength();
362 kdDebug(30522) <<
" GENERATION PARA" << endl;
372 out <<
"\\newpage" << endl;
378 out <<
"\\\\" << endl;
382 kdDebug(30522) <<
" NB ZONE : " << _lines->count() << endl;
384 for(zone = _lines->first(); zone != 0; zone = _lines->next())
398 if(isHardBreakAfter())
399 out <<
"\\newpage" << endl;
401 kdDebug(30522) <<
"PARA GENERATED" << endl;
409void Para::generateDebut(TQTextStream &out)
436 Config::instance()->indent();
440 Config::instance()->writeIndent(out);
444 Config::instance()->writeIndent(out);
449 kdDebug(30522) <<
"Begin new Env : " << getEnv() << endl;
451 Config::instance()->writeIndent(out);
455 case ENV_LEFT: out <<
"\\begin{flushleft}" << endl;
457 case ENV_RIGHT: out <<
"\\begin{flushright}" << endl;
459 case ENV_CENTER: out <<
"\\begin{center}" << endl;
461 case ENV_JUSTIFY: out << endl;
467 Config::instance()->indent();
478 EType *type_temp = 0;
480 Config::instance()->writeIndent(out);
482 switch(getCounterType())
487 out <<
"\\begin{enumerate}" << endl;
490 out <<
"\\begin{enumerate}[a]" << endl;
493 out <<
"\\begin{enumerate}[A]" << endl;
496 out <<
"\\begin{enumerate}[i]" << endl;
499 out <<
"\\begin{enumerate}[I]" << endl;
501 case TL_CUSTOM_SIMPLE:
502 out <<
"\\begin{enumerate}[" << convertSpecialChar(getCounterBullet()) <<
"]" << endl;
504 case TL_CUSTOM_COMPLEX:
505 out <<
"\\begin{enumerate}[" << convertSpecialChar(getCounterBullet()) <<
"]" << endl;
507 case TL_CIRCLE_BULLET:
508 out <<
"\\begin{itemize}" << endl;
510 case TL_SQUARE_BULLET:
511 out <<
"\\begin{itemize}" << endl;
514 out <<
"\\begin{itemize}" << endl;
517 out <<
"\\begin{itemize}[SPECIAL]" << endl;
520 Config::instance()->indent();
523 type_temp =
new EType(getCounterType());
524 kdDebug(30522) <<
" type list to open : " << *type_temp << endl;
525 _historicList.push(type_temp);
533void Para::generateFin(TQTextStream &out)
547 kdDebug(30522) <<
"end of an environment : " << getEnv() << endl;
549 Config::instance()->desindent();
555 Config::instance()->writeIndent(out);
556 out <<
"\\end{flushleft}";
560 Config::instance()->writeIndent(out);
561 out <<
"\\end{flushright}";
565 Config::instance()->writeIndent(out);
566 out <<
"\\end{center}";
574 Config::instance()->desindent();
588 if(((getCounterDepth() - 1) >= 0) && ((next!= 0 && !next->isEnum()) || next == 0))
593 kdDebug(30522) <<
"lists to close" << endl;
594 while(!_historicList.isEmpty())
596 EType *type_temp = 0;
597 type_temp = _historicList.pop();
614 kdDebug(30522) <<
" type list to close : " << type << endl;
619 Config::instance()->desindent();
620 Config::instance()->writeIndent(out);
632 case TL_CUSTOM_SIMPLE:
633 case TL_CUSTOM_COMPLEX:
634 out <<
"\\end{enumerate}" << endl;
636 case TL_CIRCLE_BULLET:
637 out <<
"\\end{itemize}" << endl;
639 case TL_SQUARE_BULLET:
641 out <<
"\\end{itemize}" << endl;
644 out <<
"no suported" << endl;
647 Config::instance()->writeIndent(out);
650 _historicList.remove();
651 kdDebug(30522) <<
"removed" << endl;
659 switch(getCounterDepth())
665 out <<
"\\subsection{";
668 out <<
"\\subsubsection{";
671 out <<
"\\paragraph{";
674 out <<
"\\subparagraph{";
677 out <<
"% section too deep" << endl;
void analyseLayout(const TQDomNode)
Helpfull functions.
bool isChapter() const
Accessors.
void analyse(const TQDomNode)
Modifiers.
SSect getFrameType() const
Para(TextFrame *textFrame=0)
Constructors.
void openList(TQTextStream &)
Write the markup to begin a list.
void generateBeginEnv(TQTextStream &)
If the paragraph has a different environment, change it.
void generate(TQTextStream &)
Write the paragraph in a file.
void generateEndEnv(TQTextStream &)
If the next paragraph has a different environment, close it.
int getNbCharPara() const
EFormat getTypeFormat(const TQDomNode) const
void closeList(TQTextStream &, Para *)
Write the markup to close a list.
void generateTitle(TQTextStream &)
If the paragraph is a title, generate the command.
This class hold 2 lists of paragraphs for the text and for the footnotes.
This class hold a zone of text with only one formating.