dochandler.h 41.2 KB
Newer Older
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1 2
/******************************************************************************
 *
3
 * $Id$
Dimitri van Heesch's avatar
Dimitri van Heesch committed
4 5
 *
 *
6
 * Copyright (C) 1997-2013 by Dimitri van Heesch.
Dimitri van Heesch's avatar
Dimitri van Heesch committed
7 8 9 10 11 12 13 14 15
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation under the terms of the GNU General Public License is hereby 
 * granted. No representations are made about the suitability of this software 
 * for any purpose. It is provided "as is" without express or implied warranty.
 * See the GNU General Public License for more details.
 *
 */

Dimitri van Heesch's avatar
Dimitri van Heesch committed
16 17 18 19 20 21 22
#ifndef _DOCHANDLER_H
#define _DOCHANDLER_H

#include <qstring.h>
#include <qlist.h>
#include <qxml.h>

Dimitri van Heesch's avatar
Dimitri van Heesch committed
23
#include <doxmlintf.h>
24
#include "stringimpl.h"
Dimitri van Heesch's avatar
Dimitri van Heesch committed
25
#include "basehandler.h"
Dimitri van Heesch's avatar
Dimitri van Heesch committed
26
#include "baseiterator.h"
Dimitri van Heesch's avatar
Dimitri van Heesch committed
27

Dimitri van Heesch's avatar
Dimitri van Heesch committed
28
class ParagraphHandler;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
29
class DocInternalHandler;
30 31
class LinkedTextImpl;
class LinkedTextHandler;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
32 33 34

//-----------------------------------------------------------------------------

Dimitri van Heesch's avatar
Dimitri van Heesch committed
35 36 37 38 39 40 41 42 43 44 45 46 47
class DocImpl : public IDoc { public: virtual ~DocImpl() {} };

#define DEFINE_CLS_IMPL(cls) \
  class cls##Impl : public I##cls, public DocImpl { public: virtual ~cls##Impl() {} }

DEFINE_CLS_IMPL(DocMarkup);
DEFINE_CLS_IMPL(DocPara);
DEFINE_CLS_IMPL(DocText);
DEFINE_CLS_IMPL(DocMarkupModifier);
DEFINE_CLS_IMPL(DocItemizedList);
DEFINE_CLS_IMPL(DocOrderedList);
DEFINE_CLS_IMPL(DocListItem);
DEFINE_CLS_IMPL(DocParameterList);
48
DEFINE_CLS_IMPL(DocParameterItem);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
DEFINE_CLS_IMPL(DocParameter);
DEFINE_CLS_IMPL(DocTitle);
DEFINE_CLS_IMPL(DocSimpleSect);
DEFINE_CLS_IMPL(DocRef);
DEFINE_CLS_IMPL(DocVariableList);
DEFINE_CLS_IMPL(DocVariableListEntry);
DEFINE_CLS_IMPL(DocHRuler);
DEFINE_CLS_IMPL(DocLineBreak);
DEFINE_CLS_IMPL(DocULink);
DEFINE_CLS_IMPL(DocEMail);
DEFINE_CLS_IMPL(DocLink);
DEFINE_CLS_IMPL(DocProgramListing);
DEFINE_CLS_IMPL(DocCodeLine);
DEFINE_CLS_IMPL(DocHighlight);
DEFINE_CLS_IMPL(DocFormula);
DEFINE_CLS_IMPL(DocImage);
DEFINE_CLS_IMPL(DocDotFile);
DEFINE_CLS_IMPL(DocIndexEntry);
DEFINE_CLS_IMPL(DocTable);
DEFINE_CLS_IMPL(DocRow);
DEFINE_CLS_IMPL(DocEntry);
DEFINE_CLS_IMPL(DocSection);
71
DEFINE_CLS_IMPL(DocVerbatim);
72 73 74 75
DEFINE_CLS_IMPL(DocCopy);
DEFINE_CLS_IMPL(DocTocList);
DEFINE_CLS_IMPL(DocTocItem);
DEFINE_CLS_IMPL(DocAnchor);
76
DEFINE_CLS_IMPL(DocSymbol);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
77
DEFINE_CLS_IMPL(DocInternal);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
78 79 80 81
DEFINE_CLS_IMPL(DocRoot);

//-----------------------------------------------------------------------------

Dimitri van Heesch's avatar
Dimitri van Heesch committed
82 83 84 85

/*! \brief Node representing a piece of text.
 *
 */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
86
class TextNode : public DocTextImpl
Dimitri van Heesch's avatar
Dimitri van Heesch committed
87 88
{
  public:
89 90
    TextNode(const QString &t,int markup,int level) 
      : m_text(t), m_markup(markup), m_headingLevel(level) {}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
91 92 93
    virtual ~TextNode() {}

    // IDocText
Dimitri van Heesch's avatar
Dimitri van Heesch committed
94
    virtual Kind kind() const { return DocImpl::Text; }
95
    virtual const IString *text() const { return &m_text; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
96
    virtual int markup() const { return m_markup; }
97
    virtual int headingLevel() const { return m_headingLevel; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
98 99
  
  private:  
100
    StringImpl m_text;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
101
    int m_markup;
102
    int m_headingLevel;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
103 104
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
105 106 107 108 109
//-----------------------------------------------------------------------------

/*! \brief Node representing a change in the markup style.
 *
 */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
110
class MarkupModifierNode : public DocMarkupModifierImpl
Dimitri van Heesch's avatar
Dimitri van Heesch committed
111 112
{
  public:
113 114
    MarkupModifierNode(int markup,bool enabled,int level=0) 
      : m_markup(markup), m_enabled(enabled), m_headingLevel(level) {}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
115
    virtual ~MarkupModifierNode() {}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
116
  
Dimitri van Heesch's avatar
Dimitri van Heesch committed
117
    // IDocMarkupModifier
Dimitri van Heesch's avatar
Dimitri van Heesch committed
118
    virtual Kind kind() const { return DocImpl::MarkupModifier; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
119 120
    virtual bool enabled() const { return m_enabled; }
    virtual int markup() const { return m_markup; }
121
    virtual int headingLevel() const { return m_headingLevel; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
122

Dimitri van Heesch's avatar
Dimitri van Heesch committed
123 124 125
  private:
    int m_markup;
    bool m_enabled;
126
    int m_headingLevel;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
127 128
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
129 130 131 132 133 134

//-----------------------------------------------------------------------------

/*! \brief Handles markup commands in the XML input. 
 *
 */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
135 136 137
class MarkupHandler : public BaseFallBackHandler<MarkupHandler>
{
  public:
Dimitri van Heesch's avatar
Dimitri van Heesch committed
138
    MarkupHandler(QList<DocImpl> &children,QString &curString);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
139 140
    virtual ~MarkupHandler();
    int markup() const { return m_curMarkup; }
141
    int headingLevel() const { return m_headingLevel; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156

    virtual void startBold(const QXmlAttributes &attrib);
    virtual void endBold();
    virtual void startEmphasis(const QXmlAttributes &attrib);
    virtual void endEmphasis();
    virtual void startComputerOutput(const QXmlAttributes &attrib);
    virtual void endComputerOutput();
    virtual void startCenter(const QXmlAttributes &attrib);
    virtual void endCenter();
    virtual void startSmallFont(const QXmlAttributes &attrib);
    virtual void endSmallFont();
    virtual void startSubscript(const QXmlAttributes &attrib);
    virtual void endSubscript();
    virtual void startSuperscript(const QXmlAttributes &attrib);
    virtual void endSuperscript();
157 158 159 160 161 162 163 164 165 166 167 168 169 170
    virtual void startPreformatted(const QXmlAttributes &attrib);
    virtual void endPreformatted();
    virtual void startHeading1(const QXmlAttributes &attrib);
    virtual void endHeading1();
    virtual void startHeading2(const QXmlAttributes &attrib);
    virtual void endHeading2();
    virtual void startHeading3(const QXmlAttributes &attrib);
    virtual void endHeading3();
    virtual void startHeading4(const QXmlAttributes &attrib);
    virtual void endHeading4();
    virtual void startHeading5(const QXmlAttributes &attrib);
    virtual void endHeading5();
    virtual void startHeading6(const QXmlAttributes &attrib);
    virtual void endHeading6();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
171 172 173 174 175


  private:
    void addTextNode();

Dimitri van Heesch's avatar
Dimitri van Heesch committed
176 177
    QList<DocImpl>  &m_children;
    QString         &m_curString;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
178
    int             m_curMarkup;
179
    int             m_headingLevel;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
180 181
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
182 183 184 185 186 187 188 189 190 191 192 193 194 195
//-----------------------------------------------------------------------------

/*! \brief Node representing a paragraph of text and commands.
 *
 */
// children: itemizedlist, orderedlist, parameterlist, simplesect, ref,
//           variablelist, hruler, linebreak, ulink, email, link
//           programlisting, formula, image, dotfile, indexentry,
//           table
//
// children handled by MarkupHandler: 
//           bold, computeroutput, emphasis, center,
//           small, subscript, superscript. 
//
Dimitri van Heesch's avatar
Dimitri van Heesch committed
196
class ParagraphHandler : public DocParaImpl, 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
                         public BaseHandler<ParagraphHandler>
{
    friend class ParagraphIterator;

  public:
    virtual void startParagraph(const QXmlAttributes& attrib);
    virtual void endParagraph();
    virtual void startItemizedList(const QXmlAttributes& attrib);
    virtual void startOrderedList(const QXmlAttributes& attrib);
    virtual void startParameterList(const QXmlAttributes& attrib);
    virtual void startSimpleSect(const QXmlAttributes& attrib);
    virtual void startRef(const QXmlAttributes& attrib);
    virtual void startVariableList(const QXmlAttributes& attrib);
    virtual void startHRuler(const QXmlAttributes& attrib);
    virtual void startLineBreak(const QXmlAttributes& attrib);
    virtual void startULink(const QXmlAttributes& attrib);
    virtual void startEMail(const QXmlAttributes& attrib);
    virtual void startLink(const QXmlAttributes& attrib);
    virtual void startProgramListing(const QXmlAttributes& attrib);
    virtual void startFormula(const QXmlAttributes& attrib);
    virtual void startImage(const QXmlAttributes& attrib);
    virtual void startDotFile(const QXmlAttributes& attrib);
    virtual void startIndexEntry(const QXmlAttributes& attrib);
    virtual void startTable(const QXmlAttributes& attrib);
221
    virtual void startVerbatim(const QXmlAttributes& attrib);
222 223
    virtual void startHtmlOnly(const QXmlAttributes& attrib);
    virtual void startLatexOnly(const QXmlAttributes& attrib);
224 225 226 227 228 229 230 231 232 233
    virtual void startUmlaut(const QXmlAttributes& attrib);
    virtual void startAcute(const QXmlAttributes& attrib);
    virtual void startGrave(const QXmlAttributes& attrib);
    virtual void startCirc(const QXmlAttributes& attrib);
    virtual void startTilde(const QXmlAttributes& attrib);
    virtual void startSzlig(const QXmlAttributes& attrib);
    virtual void startCedil(const QXmlAttributes& attrib);
    virtual void startRing(const QXmlAttributes& attrib);
    virtual void startNbsp(const QXmlAttributes& attrib);
    virtual void startCopy(const QXmlAttributes& attrib);
234 235 236
    virtual void startAnchor(const QXmlAttributes& attrib);
    virtual void startCopyDoc(const QXmlAttributes& attrib);
    virtual void startTocList(const QXmlAttributes& attrib);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
237 238 239 240 241

    ParagraphHandler(IBaseHandler *parent);
    virtual ~ParagraphHandler();

    // IDocPara
Dimitri van Heesch's avatar
Dimitri van Heesch committed
242
    virtual Kind kind() const { return DocImpl::Para; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
243 244 245 246 247
    virtual IDocIterator *contents() const;

  private:
    void addTextNode();
    IBaseHandler   *m_parent;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
248
    QList<DocImpl>  m_children;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
249 250
    MarkupHandler  *m_markupHandler;
};
Dimitri van Heesch's avatar
Dimitri van Heesch committed
251

Dimitri van Heesch's avatar
Dimitri van Heesch committed
252
class ParagraphIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
253 254 255
{
  public:
    ParagraphIterator(const ParagraphHandler &handler) : 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
256
      BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {}
257 258
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
259 260 261 262 263
//-----------------------------------------------------------------------------

/*! \brief Node representing a list item.
 *
 */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
264
class ListItemHandler : public DocListItemImpl, public BaseHandler<ListItemHandler>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
265
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
266
    friend class ListItemIterator;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
267 268 269 270 271 272 273
  public:
    ListItemHandler(IBaseHandler *parent);
    virtual ~ListItemHandler();
    virtual void startListItem(const QXmlAttributes& attrib);
    virtual void endListItem();
    virtual void startParagraph(const QXmlAttributes& attrib);

Dimitri van Heesch's avatar
Dimitri van Heesch committed
274
    // IDocItem
Dimitri van Heesch's avatar
Dimitri van Heesch committed
275
    virtual Kind kind() const { return DocImpl::ListItem; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
276
    virtual IDocIterator *contents() const;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
277

Dimitri van Heesch's avatar
Dimitri van Heesch committed
278 279
  private:
    IBaseHandler   *m_parent;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
280
    QList<DocImpl>  m_children;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
281 282
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
283
class ListItemIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
284 285 286
{
  public:
    ListItemIterator(const ListItemHandler &handler) : 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
287
      BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
288 289
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
290 291 292 293 294 295

//-----------------------------------------------------------------------------

/*! \brief Node representing list of items.
 *
 */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
296
class OrderedListHandler : public DocOrderedListImpl, public BaseHandler<OrderedListHandler>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
297
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
298
    friend class OrderedListIterator;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
299
  public:
Dimitri van Heesch's avatar
Dimitri van Heesch committed
300 301 302 303 304
    OrderedListHandler(IBaseHandler *parent);
    virtual ~OrderedListHandler();
    virtual void startOrderedList(const QXmlAttributes& attrib);
    virtual void endOrderedList();
    virtual void startOrderedListItem(const QXmlAttributes& attrib);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
305

Dimitri van Heesch's avatar
Dimitri van Heesch committed
306
    // IDocOrderedList
Dimitri van Heesch's avatar
Dimitri van Heesch committed
307
    virtual Kind kind() const { return DocImpl::OrderedList; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
308
    virtual IDocIterator *elements() const;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
309

Dimitri van Heesch's avatar
Dimitri van Heesch committed
310 311
  private:
    IBaseHandler   *m_parent;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
312
    QList<DocImpl>  m_children;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
313 314
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
315
class OrderedListIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
316 317 318
{
  public:
    OrderedListIterator(const OrderedListHandler &handler) : 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
319
      BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
320 321
};

322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376
//-----------------------------------------------------------------------------

/*! \brief Node representing table of contents list.
 *
 */
class TocListHandler : public DocTocListImpl, public BaseHandler<TocListHandler>
{
    friend class TocListIterator;
  public:
    TocListHandler(IBaseHandler *parent);
    virtual ~TocListHandler();
    virtual void startTocList(const QXmlAttributes& attrib);
    virtual void endTocList();
    virtual void startTocItem(const QXmlAttributes& attrib);

    // IDocTocList
    virtual Kind kind() const { return DocImpl::TocList; }
    virtual IDocIterator *elements() const;

  private:
    IBaseHandler   *m_parent;
    QList<DocImpl>  m_children;
};

class TocListIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
{
  public:
    TocListIterator(const TocListHandler &handler) : 
      BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {}
};

//-----------------------------------------------------------------------------

/*! \brief Node representing a table of contents item.
 *
 */
class TocItemHandler : public DocTocItemImpl, public BaseHandler<TocItemHandler>
{
    friend class TocItemIterator;
  public:
    TocItemHandler(IBaseHandler *parent);
    virtual ~TocItemHandler();
    virtual void startTocItem(const QXmlAttributes& attrib);
    virtual void endTocItem();

    // IDocItem
    virtual Kind kind() const { return DocImpl::TocItem; }
    virtual const IString *id() const { return &m_id; }
    virtual const IString *title() const { return &m_title; }

  private:
    IBaseHandler   *m_parent;
    StringImpl      m_id;
    StringImpl      m_title;
};
Dimitri van Heesch's avatar
Dimitri van Heesch committed
377 378 379

//-----------------------------------------------------------------------------

Dimitri van Heesch's avatar
Dimitri van Heesch committed
380 381 382
/*! \brief Node representing list of items.
 *
 */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
383
class ItemizedListHandler : public DocItemizedListImpl, public BaseHandler<ItemizedListHandler>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
384 385 386 387 388 389 390 391 392 393
{
    friend class ItemizedListIterator;
  public:
    ItemizedListHandler(IBaseHandler *parent);
    virtual ~ItemizedListHandler();
    virtual void startItemizedList(const QXmlAttributes& attrib);
    virtual void endItemizedList();
    virtual void startItemizedListItem(const QXmlAttributes& attrib);

    // IDocItemizedList
Dimitri van Heesch's avatar
Dimitri van Heesch committed
394
    virtual Kind kind() const { return DocImpl::ItemizedList; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
395 396 397 398
    virtual IDocIterator *elements() const;

  private:
    IBaseHandler   *m_parent;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
399
    QList<DocImpl>  m_children;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
400 401
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
402
class ItemizedListIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
403 404 405
{
  public:
    ItemizedListIterator(const ItemizedListHandler &handler) : 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
406
      BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
407 408 409 410
};


//-----------------------------------------------------------------------------
Dimitri van Heesch's avatar
Dimitri van Heesch committed
411 412 413
/*! \brief Node representing a parameter.
 *
 */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
414
class ParameterHandler : public DocParameterImpl, 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
415 416 417 418 419
                         public BaseHandler<ParameterHandler>
{
  public:
    ParameterHandler(IBaseHandler *parent);
    virtual ~ParameterHandler();
420 421
    virtual void startParameterName(const QXmlAttributes& attrib);
    virtual void endParameterName();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
422

Dimitri van Heesch's avatar
Dimitri van Heesch committed
423
    // IDocParameter
Dimitri van Heesch's avatar
Dimitri van Heesch committed
424
    virtual Kind kind() const { return DocImpl::Parameter; }
425
    virtual const IString *name() const { return &m_name; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
426

Dimitri van Heesch's avatar
Dimitri van Heesch committed
427 428
  private:
    IBaseHandler     *m_parent;
429
    StringImpl        m_name;
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456
};

//-----------------------------------------------------------------------------

/* \brief Node representing a list of param names with a single description.
 *
 */
class ParameterItemHandler : public DocParameterItemImpl, 
                             public BaseHandler<ParameterItemHandler>
{
    friend class ParameterItemIterator;
  public:
    ParameterItemHandler(IBaseHandler *parent);
    virtual ~ParameterItemHandler();
    virtual void startParameterItem(const QXmlAttributes& attrib);
    virtual void endParameterItem();
    virtual void startParameterName(const QXmlAttributes& attrib);
    virtual void startParagraph(const QXmlAttributes& attrib);

    // IDocParameterItem
    virtual Kind kind() const { return DocImpl::ParameterItem; }
    virtual IDocIterator *paramNames() const;
    virtual IDocPara *description() const { return m_description; }

  private:
    IBaseHandler            *m_parent;
    QList<ParameterHandler>  m_parameters;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
457 458 459
    ParagraphHandler *m_description;
};

460 461 462 463 464 465 466
class ParameterItemIterator : public BaseIteratorVia<IDocIterator,IDoc,ParameterHandler,DocImpl>
{
  public:
    ParameterItemIterator(const ParameterItemHandler &handler) : 
      BaseIteratorVia<IDocIterator,IDoc,ParameterHandler,DocImpl>(handler.m_parameters) {}
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
467 468
//-----------------------------------------------------------------------------

469
/* \brief Node representing a parameter section.
Dimitri van Heesch's avatar
Dimitri van Heesch committed
470 471
 *
 */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
472
class ParameterListHandler : public DocParameterListImpl, 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
473 474
                             public BaseHandler<ParameterListHandler>
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
475
    friend class ParameterListIterator;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
476 477 478 479 480
  public:
    ParameterListHandler(IBaseHandler *parent);
    virtual ~ParameterListHandler();
    virtual void startParameterList(const QXmlAttributes& attrib);
    virtual void endParameterList();
481
    virtual void startParameterItem(const QXmlAttributes& attrib);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
482

Dimitri van Heesch's avatar
Dimitri van Heesch committed
483
    // IDocParameterList
Dimitri van Heesch's avatar
Dimitri van Heesch committed
484
    virtual Kind kind() const { return DocImpl::ParameterList; }
485
    virtual Types sectType() const { return m_type; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
486
    virtual IDocIterator *params() const;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
487

Dimitri van Heesch's avatar
Dimitri van Heesch committed
488 489
  private:
    IBaseHandler            *m_parent;
490
    QList<ParameterItemHandler>  m_paramItems;
491 492 493
    Types                    m_type;
};

494
class ParameterListIterator : public BaseIteratorVia<IDocIterator,IDoc,ParameterItemHandler,DocImpl>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
495 496 497
{
  public:
    ParameterListIterator(const ParameterListHandler &handler) : 
498
      BaseIteratorVia<IDocIterator,IDoc,ParameterItemHandler,DocImpl>(handler.m_paramItems) {}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
499 500
};

501 502
//-----------------------------------------------------------------------------

503 504 505
/* \brief Node representing a horizontal ruler
 *
 */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
506
class LineBreakHandler : public DocLineBreakImpl, public BaseHandler<LineBreakHandler>
507 508 509 510 511 512 513 514
{
  public:
    LineBreakHandler(IBaseHandler *parent);
    virtual ~LineBreakHandler();

    void startLineBreak(const QXmlAttributes& attrib);
    void endLineBreak();

Dimitri van Heesch's avatar
Dimitri van Heesch committed
515
    // IDocLineBreak
Dimitri van Heesch's avatar
Dimitri van Heesch committed
516
    virtual Kind kind() const { return DocImpl::LineBreak; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
517

518 519 520 521 522 523
  private:
    IBaseHandler   *m_parent;
};

//-----------------------------------------------------------------------------

Dimitri van Heesch's avatar
Dimitri van Heesch committed
524 525 526
/* \brief Node representing a link to section
 *
 */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
527
class LinkHandler : public DocLinkImpl, public BaseHandler<LinkHandler>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
528 529 530 531 532 533 534 535
{
  public:
    LinkHandler(IBaseHandler *parent);
    virtual ~LinkHandler();

    void startLink(const QXmlAttributes& attrib);
    void endLink();

Dimitri van Heesch's avatar
Dimitri van Heesch committed
536
    // IDocLink
Dimitri van Heesch's avatar
Dimitri van Heesch committed
537
    virtual Kind kind() const { return DocImpl::Link; }
538 539
    virtual const IString *refId() const { return &m_ref; }
    virtual const IString *text() const { return &m_text; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
540

Dimitri van Heesch's avatar
Dimitri van Heesch committed
541 542
  private:
    IBaseHandler   *m_parent;
543 544
    StringImpl      m_ref;
    StringImpl      m_text;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
545 546 547 548 549 550 551 552
};


//-----------------------------------------------------------------------------

/* \brief Node representing a link to an email address
 *
 */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
553
class EMailHandler : public DocEMailImpl, public BaseHandler<EMailHandler>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
554 555 556 557 558 559 560 561
{
  public:
    EMailHandler(IBaseHandler *parent);
    virtual ~EMailHandler();

    void startEMail(const QXmlAttributes& attrib);
    void endEMail();

Dimitri van Heesch's avatar
Dimitri van Heesch committed
562
    // IDocEMail
Dimitri van Heesch's avatar
Dimitri van Heesch committed
563
    virtual Kind kind() const { return DocImpl::EMail; }
564
    virtual const IString *address() const { return &m_address; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
565

Dimitri van Heesch's avatar
Dimitri van Heesch committed
566 567
  private:
    IBaseHandler   *m_parent;
568
    StringImpl      m_address;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
569 570 571 572 573 574 575 576
};


//-----------------------------------------------------------------------------

/* \brief Node representing a link to an URL
 *
 */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
577
class ULinkHandler : public DocULinkImpl, public BaseHandler<ULinkHandler>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
578 579 580 581 582 583 584 585
{
  public:
    ULinkHandler(IBaseHandler *parent);
    virtual ~ULinkHandler();

    void startULink(const QXmlAttributes& attrib);
    void endULink();

Dimitri van Heesch's avatar
Dimitri van Heesch committed
586
    // IDocULink
Dimitri van Heesch's avatar
Dimitri van Heesch committed
587
    virtual Kind kind() const { return DocImpl::ULink; }
588 589
    virtual const IString * url() const { return &m_url; }
    virtual const IString * text() const { return &m_text; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
590

Dimitri van Heesch's avatar
Dimitri van Heesch committed
591 592
  private:
    IBaseHandler   *m_parent;
593 594
    StringImpl      m_url;
    StringImpl      m_text;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
595 596 597 598
};

//-----------------------------------------------------------------------------

599 600 601
/* \brief Node representing a horizontal ruler
 *
 */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
602
class HRulerHandler : public DocHRulerImpl, public BaseHandler<HRulerHandler>
603 604 605 606 607 608 609 610
{
  public:
    HRulerHandler(IBaseHandler *parent);
    virtual ~HRulerHandler();

    void startHRuler(const QXmlAttributes& attrib);
    void endHRuler();

Dimitri van Heesch's avatar
Dimitri van Heesch committed
611
    // IDocHRuler
Dimitri van Heesch's avatar
Dimitri van Heesch committed
612
    virtual Kind kind() const { return DocImpl::HRuler; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
613

614 615 616 617 618 619 620 621 622
  private:
    IBaseHandler   *m_parent;
};

//-----------------------------------------------------------------------------

/* \brief Node representing a reference to another item
 *
 */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
623
class RefHandler : public DocRefImpl, public BaseHandler<RefHandler>
624 625 626 627 628 629
{
  public:
    RefHandler(IBaseHandler *parent);
    virtual ~RefHandler();
    void startRef(const QXmlAttributes& attrib);
    void endRef();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
630 631

    // IDocRef
Dimitri van Heesch's avatar
Dimitri van Heesch committed
632
    virtual Kind kind() const { return DocImpl::Ref; }
633
    virtual const IString *refId() const { return &m_refId; }
634
    virtual TargetKind targetKind() const { return m_targetKind; }
635 636
    virtual const IString *external() const { return &m_extId; }
    virtual const IString *text() const { return &m_linkText; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
637

638 639
  private:
    IBaseHandler   *m_parent;
640 641 642
    StringImpl      m_refId;
    StringImpl      m_extId;
    StringImpl      m_linkText;
643
    TargetKind      m_targetKind;
644 645 646 647 648 649 650 651 652 653 654
};

//-----------------------------------------------------------------------------

/* \brief Node representing the title of a section
 *
 */
// children: text, ref
// children handled by MarkupHandler: 
//           bold, computeroutput, emphasis, center,
//           small, subscript, superscript. 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
655
class TitleHandler : public DocTitleImpl, public BaseHandler<TitleHandler>
656
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
657
    friend class TitleIterator;
658 659 660 661 662 663 664
  public:
    TitleHandler(IBaseHandler *parent);
    virtual ~TitleHandler();
    virtual void startTitle(const QXmlAttributes& attrib);
    virtual void endTitle();
    virtual void startRef(const QXmlAttributes& attrib);
    void addTextNode();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
665 666

    // IDocTitle
Dimitri van Heesch's avatar
Dimitri van Heesch committed
667
    virtual Kind kind() const { return DocImpl::Title; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
668 669
    virtual IDocIterator *title() const;

670 671
  private:
    IBaseHandler   *m_parent;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
672
    QList<DocImpl>  m_children;
673 674 675
    MarkupHandler  *m_markupHandler;
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
676
class TitleIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
677 678 679
{
  public:
    TitleIterator(const TitleHandler &handler) : 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
680
      BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
681 682
};

683 684
//-----------------------------------------------------------------------------

685 686 687
/* \brief Node representing a simple section with an unnumbered header.
 *
 */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
688
// children: title, para
Dimitri van Heesch's avatar
Dimitri van Heesch committed
689
class SimpleSectHandler : public DocSimpleSectImpl, 
690 691 692 693 694 695 696
                          public BaseHandler<SimpleSectHandler>
{
  public:
    SimpleSectHandler(IBaseHandler *parent);
    virtual ~SimpleSectHandler();
    virtual void startSimpleSect(const QXmlAttributes& attrib);
    virtual void endSimpleSect();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
697 698
    virtual void startTitle(const QXmlAttributes& attrib);
    virtual void startParagraph(const QXmlAttributes& attrib);
699

Dimitri van Heesch's avatar
Dimitri van Heesch committed
700
    // IDocSimpleSect
Dimitri van Heesch's avatar
Dimitri van Heesch committed
701 702
    virtual Kind kind() const { return DocImpl::SimpleSect; }
    virtual Types type() const { return m_type; }
703
    virtual const IString *typeString() const { return &m_typeString; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
704 705
    virtual IDocTitle *title() const { return m_title; }
    virtual IDocPara *description() const { return m_paragraph; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
706

707 708
  private:
    IBaseHandler            *m_parent;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
709
    ParagraphHandler        *m_paragraph;
710
    Types                    m_type;
711
    StringImpl               m_typeString;
712 713 714 715 716
    TitleHandler            *m_title;
};

//-----------------------------------------------------------------------------

Dimitri van Heesch's avatar
Dimitri van Heesch committed
717 718 719
/* \brief Node representing an named item of a VariableList.
 *
 */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
720
class VariableListEntryHandler : public DocVariableListEntryImpl, 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
721
                                 public BaseHandler<VariableListEntryHandler>
722 723 724 725 726 727 728 729 730 731 732 733 734
{
  public:
    virtual void startVarListEntry(const QXmlAttributes& attrib);
    virtual void endVarListEntry();
    virtual void startListItem(const QXmlAttributes& attrib);
    virtual void endListItem();
    virtual void startTerm(const QXmlAttributes& attrib);
    virtual void endTerm();
    virtual void startParagraph(const QXmlAttributes& attrib);

    VariableListEntryHandler(IBaseHandler *parent);
    virtual ~VariableListEntryHandler();

Dimitri van Heesch's avatar
Dimitri van Heesch committed
735
    // IDocVariableListEntry
Dimitri van Heesch's avatar
Dimitri van Heesch committed
736
    virtual Kind kind() const { return DocImpl::VariableListEntry; }
737
    virtual ILinkedTextIterator *term() const;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
738
    virtual IDocPara *description() const { return m_description; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
739

740
  private:
741 742 743 744
    IBaseHandler*         m_parent;
    QList<LinkedTextImpl> m_term;
    ParagraphHandler*     m_description;
    LinkedTextHandler*    m_linkedTextHandler;
745 746 747 748 749 750 751 752
};

//-----------------------------------------------------------------------------

/*! \brief Node representing a list of named items.
 *
 */
// children: varlistentry, listitem
Dimitri van Heesch's avatar
Dimitri van Heesch committed
753
class VariableListHandler : public DocVariableListImpl, 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
754
                            public BaseHandler<VariableListHandler>
755
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
756 757
    friend class VariableListIterator;
    
758 759 760 761 762 763 764 765 766
  public:
    virtual void startVariableList(const QXmlAttributes& attrib);
    virtual void endVariableList();
    virtual void startVarListEntry(const QXmlAttributes& attrib);
    virtual void startListItem(const QXmlAttributes& attrib);
    
    VariableListHandler(IBaseHandler *parent);
    virtual ~VariableListHandler();

Dimitri van Heesch's avatar
Dimitri van Heesch committed
767
    // IDocVariableList
Dimitri van Heesch's avatar
Dimitri van Heesch committed
768
    virtual Kind kind() const { return DocImpl::VariableList; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
769
    virtual IDocIterator *entries() const;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
770

771 772 773 774
  private:
    IBaseHandler   *m_parent;
    QList<VariableListEntryHandler> m_entries;
    VariableListEntryHandler *m_curEntry;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
775 776
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
777
class VariableListIterator : public BaseIteratorVia<IDocIterator,IDoc,VariableListEntryHandler,DocImpl>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
778 779 780
{
  public:
    VariableListIterator(const VariableListHandler &handler) : 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
781
      BaseIteratorVia<IDocIterator,IDoc,VariableListEntryHandler,DocImpl>(handler.m_entries) {}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
782 783
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
784 785
//-----------------------------------------------------------------------------

786 787 788
/*! \brief Node representing a highlighted text fragment.
 *
 */
789
// children: ref
Dimitri van Heesch's avatar
Dimitri van Heesch committed
790
class HighlightHandler : public DocHighlightImpl, public BaseHandler<HighlightHandler>
791
{
792
    friend class HighlightIterator;
793 794 795 796 797
  public:
    HighlightHandler(IBaseHandler *parent);
    virtual ~HighlightHandler();
    void startHighlight(const QXmlAttributes& attrib);
    void endHighlight();
798
    virtual void startRef(const QXmlAttributes&);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
799
    virtual void startSpace(const QXmlAttributes&);
800

Dimitri van Heesch's avatar
Dimitri van Heesch committed
801
    // IDocHighlight
Dimitri van Heesch's avatar
Dimitri van Heesch committed
802
    virtual Kind kind() const { return DocImpl::Highlight; }
803 804
    virtual HighlightKind highlightKind() const { return m_hl; }
    virtual IDocIterator *codeElements() const;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
805

806
  private:
807 808
    void addTextNode();
    
809
    IBaseHandler   *m_parent;
810 811
    HighlightKind  m_hl;
    QString        m_hlString;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
812
    QList<DocImpl> m_children;
813 814
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
815
class HighlightIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
816 817 818
{
  public:
    HighlightIterator(const HighlightHandler &handler) : 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
819
      BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {}
820 821 822 823 824 825 826 827
};

//-----------------------------------------------------------------------------

/*! \brief Node representing a line of code.
 *
 */
// children: linenumber, highlight, anchor, ref
Dimitri van Heesch's avatar
Dimitri van Heesch committed
828
class CodeLineHandler : public DocCodeLineImpl, public BaseHandler<CodeLineHandler>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
829
{
830
    friend class CodeLineIterator;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
831 832 833 834 835 836
  public:

    virtual void startCodeLine(const QXmlAttributes&);
    virtual void endCodeLine();
    virtual void startLineNumber(const QXmlAttributes&);
    virtual void endLineNumber();
837 838
    virtual void startHighlight(const QXmlAttributes&);
    virtual void startRef(const QXmlAttributes&);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
839 840 841
    
    CodeLineHandler(IBaseHandler *parent);
    virtual ~CodeLineHandler();
842

Dimitri van Heesch's avatar
Dimitri van Heesch committed
843
    // IDocCodeLine
Dimitri van Heesch's avatar
Dimitri van Heesch committed
844
    virtual Kind kind() const { return DocImpl::CodeLine; }
845
    virtual int lineNumber() const { return m_lineNumber; }
846
    virtual const IString *refId() const { return &m_refId; }
847
    virtual IDocIterator *codeElements() const;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
848

Dimitri van Heesch's avatar
Dimitri van Heesch committed
849
  private:
850 851
    void addTextNode();

Dimitri van Heesch's avatar
Dimitri van Heesch committed
852 853
    IBaseHandler   *m_parent;
    int            m_lineNumber;
854
    StringImpl     m_refId;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
855
    QList<DocImpl> m_children;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
856 857
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
858
class CodeLineIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
859 860 861
{
  public:
    CodeLineIterator(const CodeLineHandler &handler) : 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
862
      BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {}
863 864
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
865 866 867 868 869
//-----------------------------------------------------------------------------

/*! \brief Node representing a program listing
 *
 */
870
// children: codeline, linenumber
Dimitri van Heesch's avatar
Dimitri van Heesch committed
871
class ProgramListingHandler : public DocProgramListingImpl, public BaseHandler<ProgramListingHandler>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
872
{
873
    friend class ProgramListingIterator;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
874 875 876 877 878 879 880 881
  public:
    virtual void startProgramListing(const QXmlAttributes& attrib);
    virtual void endProgramListing();
    virtual void startCodeLine(const QXmlAttributes&);
    virtual void startLineNumber(const QXmlAttributes&);

    ProgramListingHandler(IBaseHandler *parent);
    virtual ~ProgramListingHandler();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
882 883

    // IDocProgramListing
Dimitri van Heesch's avatar
Dimitri van Heesch committed
884
    virtual Kind kind() const { return DocImpl::ProgramListing; }
885
    virtual IDocIterator *codeLines() const;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
886

Dimitri van Heesch's avatar
Dimitri van Heesch committed
887
  private:
888 889
    IBaseHandler           *m_parent;
    QList<CodeLineHandler>  m_children;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
890 891 892 893 894
    bool m_hasLineNumber;
};

//-----------------------------------------------------------------------------

Dimitri van Heesch's avatar
Dimitri van Heesch committed
895
class ProgramListingIterator : public BaseIteratorVia<IDocIterator,IDoc,CodeLineHandler,DocImpl>
896 897 898
{
  public:
    ProgramListingIterator(const ProgramListingHandler &handler) : 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
899
      BaseIteratorVia<IDocIterator,IDoc,CodeLineHandler,DocImpl>(handler.m_children) {}
900 901 902 903
};

//-----------------------------------------------------------------------------

904 905 906 907
/*! \brief Node representing a formula.
 *
 */
// children: -
Dimitri van Heesch's avatar
Dimitri van Heesch committed
908
class FormulaHandler : public DocFormulaImpl, public BaseHandler<FormulaHandler>
909 910 911 912 913 914 915
{
  public:
    FormulaHandler(IBaseHandler *parent);
    virtual ~FormulaHandler();
    void startFormula(const QXmlAttributes& attrib);
    void endFormula();

Dimitri van Heesch's avatar
Dimitri van Heesch committed
916
    // IDocFormula
Dimitri van Heesch's avatar
Dimitri van Heesch committed
917
    virtual Kind kind() const { return DocImpl::Formula; }
918 919
    virtual const IString *id() const { return &m_id; }
    virtual const IString *text() const { return &m_text; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
920

921 922
  private:
    IBaseHandler  *m_parent;
923 924
    StringImpl     m_id;
    StringImpl     m_text;
925 926 927 928 929 930 931 932
};

//-----------------------------------------------------------------------------

/*! \brief Node representing an image.
 *
 */
// children: -
Dimitri van Heesch's avatar
Dimitri van Heesch committed
933
class ImageHandler : public DocImageImpl, public BaseHandler<ImageHandler>
934 935 936 937 938 939 940
{
  public:
    ImageHandler(IBaseHandler *parent);
    virtual ~ImageHandler();
    void startImage(const QXmlAttributes& attrib);
    void endImage();

Dimitri van Heesch's avatar
Dimitri van Heesch committed
941
    // IDocImage
Dimitri van Heesch's avatar
Dimitri van Heesch committed
942
    virtual Kind kind() const { return DocImpl::Image; }
943 944
    virtual const IString *name() const { return &m_name; }
    virtual const IString *caption() const { return &m_caption; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
945

946 947
  private:
    IBaseHandler  *m_parent;
948 949
    StringImpl     m_name;
    StringImpl     m_caption;
950 951
};

952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974

//-----------------------------------------------------------------------------
/*! \brief Node representing an anchor.
 *
 */
// children: -
class AnchorHandler : public DocAnchorImpl, public BaseHandler<AnchorHandler>
{
  public:
    AnchorHandler(IBaseHandler *parent);
    virtual ~AnchorHandler();
    void startAnchor(const QXmlAttributes& attrib);
    void endAnchor();

    // IDocAnchor
    virtual Kind kind() const { return DocImpl::Anchor; }
    virtual const IString *id() const { return &m_id; }

  private:
    IBaseHandler  *m_parent;
    StringImpl     m_id;
};

975 976 977 978 979 980
//-----------------------------------------------------------------------------

/*! \brief Node representing a dot file.
 *
 */
// children: -
Dimitri van Heesch's avatar
Dimitri van Heesch committed
981
class DotFileHandler : public DocDotFileImpl, public BaseHandler<DotFileHandler>
982 983 984 985 986 987 988
{
  public:
    DotFileHandler(IBaseHandler *parent);
    virtual ~DotFileHandler();
    void startDotFile(const QXmlAttributes& attrib);
    void endDotFile();

Dimitri van Heesch's avatar
Dimitri van Heesch committed
989
    // IDocDotFile
Dimitri van Heesch's avatar
Dimitri van Heesch committed
990
    virtual Kind kind() const { return DocImpl::DotFile; }
991 992
    virtual const IString *name() const { return &m_name; }
    virtual const IString *caption() const { return &m_caption; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
993

994 995
  private:
    IBaseHandler  *m_parent;
996 997
    StringImpl     m_name;
    StringImpl     m_caption;
998 999 1000 1001 1002 1003 1004 1005
};

//-----------------------------------------------------------------------------

/*! \brief Node representing an entry in the index.
 *
 */
// children: -
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1006
class IndexEntryHandler : public DocIndexEntryImpl, public BaseHandler<IndexEntryHandler>
1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017
{
  public:
    IndexEntryHandler(IBaseHandler *parent);
    virtual ~IndexEntryHandler();
    void startIndexEntry(const QXmlAttributes& attrib);
    void endIndexEntry();
    void startPrimaryIE(const QXmlAttributes& attrib);
    void endPrimaryIE();
    void startSecondaryIE(const QXmlAttributes& attrib);
    void endSecondaryIE();

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1018
    // IDocIndexEntry
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1019
    virtual Kind kind() const { return DocImpl::IndexEntry; }
1020 1021
    virtual const IString *primary() const { return &m_primary; }
    virtual const IString *secondary() const { return &m_secondary; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1022

1023 1024
  private:
    IBaseHandler  *m_parent;
1025 1026
    StringImpl     m_primary;
    StringImpl     m_secondary;
1027 1028 1029 1030
};

//-----------------------------------------------------------------------------

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1031 1032 1033 1034
/*! \brief Node representing an entry in the table entry.
 *
 */
// children: para
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1035
class EntryHandler : public DocEntryImpl, public BaseHandler<EntryHandler>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1036
{
1037
    friend class EntryIterator;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1038 1039 1040 1041 1042 1043 1044
  public:
    EntryHandler(IBaseHandler *parent);
    virtual ~EntryHandler();
    void startEntry(const QXmlAttributes& attrib);
    void endEntry();
    void startParagraph(const QXmlAttributes& attrib);

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1045
    // IDocEntry
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1046
    virtual Kind kind() const { return DocImpl::Entry; }
1047
    virtual IDocIterator *contents() const;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1048

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1049 1050
  private:
    IBaseHandler   *m_parent;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1051
    QList<DocImpl>  m_children;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1052 1053
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1054
class EntryIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
1055 1056 1057
{
  public:
    EntryIterator(const EntryHandler &handler) : 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1058
      BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {}
1059 1060
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1061 1062 1063 1064 1065 1066
//-----------------------------------------------------------------------------

/*! \brief Node representing an entry in the table row.
 *
 */
// children: entry
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1067
class RowHandler : public DocRowImpl, public BaseHandler<RowHandler>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1068
{
1069
    friend class RowIterator;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1070 1071 1072 1073 1074 1075 1076
  public:
    RowHandler(IBaseHandler *parent);
    virtual ~RowHandler();
    void startRow(const QXmlAttributes& attrib);
    void endRow();
    void startEntry(const QXmlAttributes& attrib);

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1077
    // IDocRow
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1078
    virtual Kind kind() const { return DocImpl::Row; }
1079
    virtual IDocIterator *entries() const;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1080

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1081 1082 1083 1084 1085
  private:
    IBaseHandler        *m_parent;
    QList<EntryHandler>  m_children;
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1086
class RowIterator : public BaseIteratorVia<IDocIterator,IDoc,EntryHandler,DocImpl>
1087 1088 1089
{
  public:
    RowIterator(const RowHandler &handler) : 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1090
      BaseIteratorVia<IDocIterator,IDoc,EntryHandler,DocImpl>(handler.m_children) {}
1091 1092
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1093 1094 1095 1096 1097
//-----------------------------------------------------------------------------

/*! \brief Node representing an entry in the table.
 *
 */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1098
// children: row, caption
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1099
class TableHandler : public DocTableImpl, public BaseHandler<TableHandler>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1100
{
1101
    friend class TableIterator;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1102 1103 1104 1105 1106 1107
  public:
    TableHandler(IBaseHandler *parent);
    virtual ~TableHandler();
    void startTable(const QXmlAttributes& attrib);
    void endTable();
    void startRow(const QXmlAttributes& attrib);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1108 1109
    void startCaption(const QXmlAttributes& attrib);
    void endCaption();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1110

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1111
    // IDocTable
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1112
    virtual Kind kind() const { return DocImpl::Table; }
1113 1114
    virtual IDocIterator *rows() const;
    virtual int numColumns() const { return m_numColumns; }
1115
    virtual const IString *caption() const { return &m_caption; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1116

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1117 1118 1119 1120
  private:
    IBaseHandler      *m_parent;
    QList<RowHandler>  m_children;
    int                m_numColumns;
1121
    StringImpl         m_caption;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1122 1123
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1124
class TableIterator : public BaseIteratorVia<IDocIterator,IDoc,RowHandler,DocImpl>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1125 1126
{
  public:
1127
    TableIterator(const TableHandler &handler) : 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1128
      BaseIteratorVia<IDocIterator,IDoc,RowHandler,DocImpl>(handler.m_children) {}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1129 1130
};

1131 1132
//-----------------------------------------------------------------------------

1133 1134
/*! \brief Node representing a copied piece of documentation.
 *
1135
 */
1136
class CopyHandler : public DocCopyImpl, public BaseHandler<CopyHandler>
1137
{
1138
    friend class CopyIterator;
1139
  public:
1140 1141 1142 1143 1144
    CopyHandler(IBaseHandler *parent);
    virtual ~CopyHandler();
    virtual void startCopy(const QXmlAttributes& attrib);
    virtual void endCopy();
    virtual void startParagraph(const QXmlAttributes& attrib);
1145

1146 1147
    // IDocCopy
    virtual Kind kind() const { return DocImpl::Copy; }
1148 1149 1150 1151 1152 1153 1154
    virtual IDocIterator *contents() const;

  private:
    IBaseHandler   *m_parent;
    QList<DocImpl>  m_children;
};

1155
class CopyIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
1156 1157
{
  public:
1158
    CopyIterator(const CopyHandler &handler) : 
1159 1160 1161
      BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {}
};

1162 1163 1164 1165 1166 1167 1168 1169 1170 1171
//-----------------------------------------------------------------------------

/*! \brief Node representing an preformatted section
 */
class VerbatimHandler : public DocVerbatimImpl, 
                        public BaseHandler<VerbatimHandler>
{
  public:
    VerbatimHandler(IBaseHandler *parent);
    virtual ~VerbatimHandler();
1172
    void startVerbatim(const QXmlAttributes& attrib,Types type);
1173 1174 1175 1176 1177
    void endVerbatim();

    // IDocVerbatim
    virtual Kind kind() const { return DocImpl::Verbatim; }
    virtual const IString *text() const { return &m_text; }
1178
    virtual Types type() const { return m_type; }
1179 1180

  private:
1181 1182 1183
    IBaseHandler *m_parent;
    StringImpl    m_text;
    Types         m_type;
1184 1185 1186
};


1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213
//-----------------------------------------------------------------------------

/*! \brief Node representing an special symbol.
 *
 */
// children: -
class SymbolHandler : public DocSymbolImpl, public BaseHandler<SymbolHandler>
{
  public:
    SymbolHandler(IBaseHandler *parent,Types type);
    virtual ~SymbolHandler();
    void startSymbol(const QXmlAttributes& attrib);
    void endSymbol();

    // IDocSymbol
    virtual Kind kind() const   { return DocImpl::Symbol; }
    virtual Types type() const  { return m_type; }
    virtual const IString *typeString() const { return &m_typeString; }
    virtual char letter() const { return m_letter; }

  private:
    IBaseHandler  *m_parent;
    char           m_letter;
    Types          m_type;
    StringImpl     m_typeString;
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1214 1215 1216 1217 1218 1219

//-----------------------------------------------------------------------------

/*! \brief Node representing a section.
 *
 */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1220
// children: title, para, sect(n+1)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1221
class DocSectionHandler : public DocSectionImpl, public BaseHandler<DocSectionHandler>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1222
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1223 1224
    friend class DocSectionParaIterator;
    friend class DocSectionSubIterator;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1225 1226 1227 1228 1229
  public:
    DocSectionHandler(IBaseHandler *parent,int level);
    virtual ~DocSectionHandler();
    virtual void startDocSection(const QXmlAttributes& attrib);
    virtual void endDocSection();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1230 1231 1232 1233
    virtual void startTitle(const QXmlAttributes& attrib);
    virtual void startSubSection(const QXmlAttributes& attrib);
    virtual void startParagraph(const QXmlAttributes& attrib);
    virtual void startInternal(const QXmlAttributes& attrib);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1234 1235

    // IDocSection
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1236
    virtual Kind kind() const { return DocImpl::Section; }
1237
    virtual const IString *id() const { return &m_id; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1238
    virtual int level() const { return m_level; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1239 1240 1241 1242
    virtual IDocTitle *title() const { return m_title; }
    virtual IDocIterator *paragraphs() const;
    virtual IDocIterator *subSections() const;
    virtual IDocInternal *internal() const;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1243 1244

  private:
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1245 1246 1247 1248 1249 1250 1251
    IBaseHandler    *m_parent;
    QList<DocImpl>   m_paragraphs;
    QList<DocImpl>   m_subsections;
    DocInternalHandler *m_internal;
    StringImpl       m_id;
    int              m_level;
    TitleHandler    *m_title;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1252 1253
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1254
class DocSectionParaIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1255 1256
{
  public:
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1257 1258 1259 1260 1261 1262 1263 1264 1265
    DocSectionParaIterator(const DocSectionHandler &handler) : 
      BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_paragraphs) {}
};

class DocSectionSubIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
{
  public:
    DocSectionSubIterator(const DocSectionHandler &handler) : 
      BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_subsections) {}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1266 1267
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308
//-----------------------------------------------------------------------------

class DocInternalHandler : public DocInternalImpl, public BaseHandler<DocInternalHandler>
{
  public:
    friend class DocInternalParaIterator;
    friend class DocInternalSubIterator;
    DocInternalHandler(IBaseHandler *parent,int level);
    virtual ~DocInternalHandler();
    virtual void startInternal(const QXmlAttributes& attrib);
    virtual void endInternal();
    virtual void startSubSection(const QXmlAttributes& attrib);
    virtual void startParagraph(const QXmlAttributes& attrib);

    // IDocInternal
    virtual Kind kind() const { return DocImpl::Internal; }
    virtual IDocIterator *paragraphs() const;
    virtual IDocIterator *subSections() const;

  private:
    IBaseHandler    *m_parent;
    QList<DocImpl>   m_paragraphs;
    QList<DocImpl>   m_subsections;
    int              m_level;
};

class DocInternalParaIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
{
  public:
    DocInternalParaIterator(const DocInternalHandler &handler) : 
      BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_paragraphs) {}
};

class DocInternalSubIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
{
  public:
    DocInternalSubIterator(const DocInternalHandler &handler) : 
      BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_subsections) {}
};


Dimitri van Heesch's avatar
Dimitri van Heesch committed
1309
//-----------------------------------------------------------------------------
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1310

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1311 1312 1313
/*! \brief Node representing a documentation block.
 *
 */
1314
// children: para, title, sect1, internal
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1315
class DocHandler : public DocRootImpl, public BaseHandler<DocHandler>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1316
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1317
    friend class DocIterator;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1318 1319 1320 1321
  public:
    virtual void startDoc(const QXmlAttributes& attrib);
    virtual void endDoc();
    virtual void startParagraph(const QXmlAttributes& attrib);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1322 1323
    virtual void startSect1(const QXmlAttributes& attrib);
    virtual void startTitle(const QXmlAttributes& attrib);
1324
    virtual void startInternal(const QXmlAttributes& attrib);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1325 1326 1327

    DocHandler(IBaseHandler *parent);
    virtual ~DocHandler();
1328
    
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1329
    // IDocRoot
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1330
    virtual Kind kind() const { return DocImpl::Root; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1331
    virtual IDocIterator *contents() const;
1332
    virtual IDocInternal *internal() const;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1333

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1334 1335
  private:
    IBaseHandler *m_parent;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1336
    QList<DocImpl> m_children;
1337
    DocInternalHandler *m_internal;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1338 1339
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1340
class DocIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1341 1342 1343
{
  public:
    DocIterator(const DocHandler &handler) : 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1344
      BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1345 1346
};

1347 1348
//-----------------------------------------------------------------------------

1349 1350 1351
void dochandler_init();
void dochandler_exit();

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1352
#endif