Orb/Doxygen/src/xmldocvisitor.cpp
changeset 0 42188c7ea2d9
child 4 468f4c8d3d5b
equal deleted inserted replaced
-1:000000000000 0:42188c7ea2d9
       
     1 /******************************************************************************
       
     2  *
       
     3  * 
       
     4  *
       
     5  *
       
     6  * Copyright (C) 1997-2008 by Dimitri van Heesch.
       
     7  *
       
     8  * Permission to use, copy, modify, and distribute this software and its
       
     9  * documentation under the terms of the GNU General Public License is hereby 
       
    10  * granted. No representations are made about the suitability of this software 
       
    11  * for any purpose. It is provided "as is" without express or implied warranty.
       
    12  * See the GNU General Public License for more details.
       
    13  *
       
    14  * Documents produced by Doxygen are derivative works derived from the
       
    15  * input used in their production; they are not affected by this license.
       
    16  *
       
    17  */
       
    18 
       
    19 #include "xmldocvisitor.h"
       
    20 #include "docparser.h"
       
    21 #include "language.h"
       
    22 #include "doxygen.h"
       
    23 #include "outputgen.h"
       
    24 #include "xmlgen.h"
       
    25 #include "dot.h"
       
    26 #include "message.h"
       
    27 #include "util.h"
       
    28 #include <qfileinfo.h> 
       
    29 #include "parserintf.h"
       
    30 
       
    31 XmlDocVisitor::XmlDocVisitor(QTextStream &t,CodeOutputInterface &ci) 
       
    32   : DocVisitor(DocVisitor_XML), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE) 
       
    33 {
       
    34 }
       
    35 
       
    36   //--------------------------------------
       
    37   // visitor functions for leaf nodes
       
    38   //--------------------------------------
       
    39 
       
    40 void XmlDocVisitor::visit(DocWord *w)
       
    41 {
       
    42   if (m_hide) return;
       
    43   filter(w->word());
       
    44 }
       
    45 
       
    46 void XmlDocVisitor::visit(DocLinkedWord *w)
       
    47 {
       
    48   if (m_hide) return;
       
    49   startLink(w->ref(),w->file(),w->anchor());
       
    50   filter(w->word());
       
    51   endLink();
       
    52 }
       
    53 
       
    54 void XmlDocVisitor::visit(DocWhiteSpace *w)
       
    55 {
       
    56   if (m_hide) return;
       
    57   if (m_insidePre)
       
    58   {
       
    59     m_t << w->chars();
       
    60   }
       
    61   else
       
    62   {
       
    63     m_t << " ";
       
    64   }
       
    65 }
       
    66 
       
    67 void XmlDocVisitor::visit(DocSymbol *s)
       
    68 {
       
    69   if (m_hide) return;
       
    70   switch(s->symbol())
       
    71   {
       
    72     case DocSymbol::BSlash:  m_t << "\\"; break;
       
    73     case DocSymbol::At:      m_t << "@"; break;
       
    74     case DocSymbol::Less:    m_t << "&lt;"; break;
       
    75     case DocSymbol::Greater: m_t << "&gt;"; break;
       
    76     case DocSymbol::Amp:     m_t << "&amp;"; break;
       
    77     case DocSymbol::Dollar:  m_t << "$"; break;
       
    78     case DocSymbol::Hash:    m_t << "#"; break;
       
    79     case DocSymbol::Percent: m_t << "%"; break;
       
    80     case DocSymbol::Copy:    m_t << "<copy/>"; break;
       
    81     case DocSymbol::Tm:      m_t << "<trademark/>"; break;
       
    82     case DocSymbol::Reg:     m_t << "<registered/>"; break;
       
    83     case DocSymbol::Apos:    m_t << "'"; break;
       
    84     case DocSymbol::Quot:    m_t << "\""; break;
       
    85     case DocSymbol::Lsquo:   m_t << "<lsquo/>"; break;
       
    86     case DocSymbol::Rsquo:   m_t << "<rsquo/>"; break;
       
    87     case DocSymbol::Ldquo:   m_t << "<ldquo/>"; break;
       
    88     case DocSymbol::Rdquo:   m_t << "<rdquo/>"; break;
       
    89     case DocSymbol::Ndash:   m_t << "<ndash/>"; break;
       
    90     case DocSymbol::Mdash:   m_t << "<mdash/>"; break;
       
    91     case DocSymbol::Uml:     m_t << "<umlaut char=\"" << s->letter() << "\"/>"; break;
       
    92     case DocSymbol::Acute:   m_t << "<acute char=\"" << s->letter() << "\"/>"; break;
       
    93     case DocSymbol::Grave:   m_t << "<grave char=\"" << s->letter() << "\"/>"; break;
       
    94     case DocSymbol::Circ:    m_t << "<circ char=\"" << s->letter() << "\"/>"; break;
       
    95     case DocSymbol::Tilde:   m_t << "<tilde char=\"" << s->letter() << "\"/>"; break;
       
    96     case DocSymbol::Szlig:   m_t << "<szlig/>"; break;
       
    97     case DocSymbol::Cedil:   m_t << "<cedil char=\"" << s->letter() << "\"/>"; break;
       
    98     case DocSymbol::Ring:    m_t << "<ring char=\"" << s->letter() << "\"/>"; break;
       
    99     case DocSymbol::Slash:   m_t << "<slash char=\"" << s->letter() << "\"/>"; break;
       
   100     case DocSymbol::Nbsp:    m_t << "<nonbreakablespace/>"; break;
       
   101     case DocSymbol::Aelig:   m_t << "<aelig/>"; break;
       
   102     case DocSymbol::AElig:   m_t << "<AElig/>"; break;
       
   103     default:
       
   104                              err("Error: unknown symbol found\n");
       
   105   }
       
   106 }
       
   107 
       
   108 void XmlDocVisitor::visit(DocURL *u)
       
   109 {
       
   110   if (m_hide) return;
       
   111   m_t << "<ulink url=\""; 
       
   112   if (u->isEmail()) m_t << "mailto:";
       
   113   filter(u->url());
       
   114   m_t << "\">";
       
   115   filter(u->url());
       
   116   m_t << "</ulink>";
       
   117 }
       
   118 
       
   119 void XmlDocVisitor::visit(DocLineBreak *)
       
   120 {
       
   121   if (m_hide) return;
       
   122   m_t << "<linebreak/>\n";
       
   123 }
       
   124 
       
   125 void XmlDocVisitor::visit(DocHorRuler *)
       
   126 {
       
   127   if (m_hide) return;
       
   128   m_t << "<hruler/>\n";
       
   129 }
       
   130 
       
   131 void XmlDocVisitor::visit(DocStyleChange *s)
       
   132 {
       
   133   if (m_hide) return;
       
   134   switch (s->style())
       
   135   {
       
   136     case DocStyleChange::Bold:
       
   137       if (s->enable()) m_t << "<bold>";      else m_t << "</bold>";
       
   138       break;
       
   139     case DocStyleChange::Italic:
       
   140       if (s->enable()) m_t << "<emphasis>";     else m_t << "</emphasis>";
       
   141       break;
       
   142     case DocStyleChange::Code:
       
   143       if (s->enable()) m_t << "<computeroutput>";   else m_t << "</computeroutput>";
       
   144       break;
       
   145     case DocStyleChange::Subscript:
       
   146       if (s->enable()) m_t << "<subscript>";    else m_t << "</subscript>";
       
   147       break;
       
   148     case DocStyleChange::Superscript:
       
   149       if (s->enable()) m_t << "<superscript>";    else m_t << "</superscript>";
       
   150       break;
       
   151     case DocStyleChange::Center:
       
   152       if (s->enable()) m_t << "<center>"; else m_t << "</center>";
       
   153       break;
       
   154     case DocStyleChange::Small:
       
   155       if (s->enable()) m_t << "<small>";  else m_t << "</small>";
       
   156       break;
       
   157     case DocStyleChange::Preformatted:
       
   158       if (s->enable()) 
       
   159       {
       
   160         m_t << "<preformatted>";  
       
   161         m_insidePre=TRUE;
       
   162       }
       
   163       else 
       
   164       {
       
   165         m_t << "</preformatted>";
       
   166         m_insidePre=FALSE;
       
   167       }
       
   168       break;
       
   169     case DocStyleChange::Div:  /* HTML only */ break;
       
   170     case DocStyleChange::Span: /* HTML only */ break;
       
   171   }
       
   172 }
       
   173 
       
   174 void XmlDocVisitor::visit(DocVerbatim *s)
       
   175 {
       
   176   if (m_hide) return;
       
   177   switch(s->type())
       
   178   {
       
   179     case DocVerbatim::Code: // fall though
       
   180       m_t << "<programlisting>"; 
       
   181       Doxygen::parserManager->getParser(m_langExt)
       
   182                             ->parseCode(m_ci,s->context(),s->text().latin1(),
       
   183                                         s->isExample(),s->exampleFile());
       
   184       m_t << "</programlisting>"; 
       
   185       break;
       
   186     case DocVerbatim::Verbatim: 
       
   187       m_t << "<verbatim>";
       
   188       filter(s->text());
       
   189       m_t << "</verbatim>"; 
       
   190       break;
       
   191     case DocVerbatim::HtmlOnly: 
       
   192       m_t << "<htmlonly>";
       
   193       filter(s->text());
       
   194       m_t << "</htmlonly>";
       
   195       break;
       
   196     case DocVerbatim::ManOnly: 
       
   197       m_t << "<manonly>";
       
   198       filter(s->text());
       
   199       m_t << "</manonly>";
       
   200       break;
       
   201     case DocVerbatim::LatexOnly: 
       
   202       m_t << "<latexonly>";
       
   203       filter(s->text());
       
   204       m_t << "</latexonly>";
       
   205       break;
       
   206     case DocVerbatim::XmlOnly: 
       
   207       m_t << s->text();
       
   208       break;
       
   209     case DocVerbatim::Dot: 
       
   210       m_t << "<dot>";
       
   211       filter(s->text());
       
   212       m_t << "</dot>";
       
   213       break;
       
   214     case DocVerbatim::Msc: 
       
   215       m_t << "<msc>";
       
   216       filter(s->text());
       
   217       m_t << "</msc>";
       
   218       break;
       
   219   }
       
   220 }
       
   221 
       
   222 void XmlDocVisitor::visit(DocAnchor *anc)
       
   223 {
       
   224   if (m_hide) return;
       
   225   m_t << "<anchor id=\"" << anc->file() << "_1" << anc->anchor() << "\"/>";
       
   226 }
       
   227 
       
   228 void XmlDocVisitor::visit(DocInclude *inc)
       
   229 {
       
   230   if (m_hide) return;
       
   231   switch(inc->type())
       
   232   {
       
   233     case DocInclude::IncWithLines:
       
   234       { 
       
   235          m_t << "<programlisting>";
       
   236          QFileInfo cfi( inc->file() );
       
   237          FileDef fd( cfi.dirPath(), cfi.fileName() );
       
   238          Doxygen::parserManager->getParser(inc->extension())
       
   239                                ->parseCode(m_ci,inc->context(),
       
   240                                            inc->text().latin1(),
       
   241                                            inc->isExample(),
       
   242                                            inc->exampleFile(), &fd);
       
   243          m_t << "</programlisting>"; 
       
   244       }
       
   245       break;    
       
   246     case DocInclude::Include: 
       
   247       m_t << "<programlisting>";
       
   248       Doxygen::parserManager->getParser(inc->extension())
       
   249                             ->parseCode(m_ci,inc->context(),
       
   250                                         inc->text().latin1(),
       
   251                                         inc->isExample(),
       
   252                                         inc->exampleFile());
       
   253       m_t << "</programlisting>"; 
       
   254       break;
       
   255     case DocInclude::DontInclude: 
       
   256       break;
       
   257     case DocInclude::HtmlInclude: 
       
   258       m_t << "<htmlonly>";
       
   259       filter(inc->text());
       
   260       m_t << "</htmlonly>";
       
   261       break;
       
   262     case DocInclude::VerbInclude: 
       
   263       m_t << "<verbatim>";
       
   264       filter(inc->text());
       
   265       m_t << "</verbatim>"; 
       
   266       break;
       
   267   }
       
   268 }
       
   269 
       
   270 void XmlDocVisitor::visit(DocIncOperator *op)
       
   271 {
       
   272   //printf("DocIncOperator: type=%d first=%d, last=%d text=`%s'\n",
       
   273   //    op->type(),op->isFirst(),op->isLast(),op->text().data());
       
   274   if (op->isFirst()) 
       
   275   {
       
   276     if (!m_hide)
       
   277     {
       
   278       m_t << "<programlisting>";
       
   279     }
       
   280     pushEnabled();
       
   281     m_hide = TRUE;
       
   282   }
       
   283   if (op->type()!=DocIncOperator::Skip) 
       
   284   {
       
   285     popEnabled();
       
   286     if (!m_hide) 
       
   287     {
       
   288       Doxygen::parserManager->getParser(m_langExt)
       
   289                             ->parseCode(m_ci,op->context(),
       
   290                                         op->text().latin1(),op->isExample(),
       
   291                                         op->exampleFile());
       
   292     }
       
   293     pushEnabled();
       
   294     m_hide=TRUE;
       
   295   }
       
   296   if (op->isLast())  
       
   297   {
       
   298     popEnabled();
       
   299     if (!m_hide) m_t << "</programlisting>"; 
       
   300   }
       
   301   else
       
   302   {
       
   303     if (!m_hide) m_t << endl;
       
   304   }
       
   305 }
       
   306 
       
   307 void XmlDocVisitor::visit(DocFormula *f)
       
   308 {
       
   309   if (m_hide) return;
       
   310   m_t << "<formula id=\"" << f->id() << "\">";
       
   311   filter(f->text());
       
   312   m_t << "</formula>";
       
   313 }
       
   314 
       
   315 void XmlDocVisitor::visit(DocIndexEntry *ie)
       
   316 {
       
   317   if (m_hide) return;
       
   318   m_t << "<indexentry>"
       
   319            "<primaryie>";
       
   320   filter(ie->entry());
       
   321   m_t << "</primaryie>"
       
   322            "<secondaryie></secondaryie>"
       
   323          "</indexentry>";
       
   324 }
       
   325 
       
   326 void XmlDocVisitor::visit(DocSimpleSectSep *)
       
   327 {
       
   328   m_t << "<simplesectsep/>";
       
   329 }
       
   330 
       
   331 //--------------------------------------
       
   332 // visitor functions for compound nodes
       
   333 //--------------------------------------
       
   334 
       
   335 void XmlDocVisitor::visitPre(DocAutoList *l)
       
   336 {
       
   337   if (m_hide) return;
       
   338   if (l->isEnumList())
       
   339   {
       
   340     m_t << "<orderedlist>\n";
       
   341   }
       
   342   else
       
   343   {
       
   344     m_t << "<itemizedlist>\n";
       
   345   }
       
   346 }
       
   347 
       
   348 void XmlDocVisitor::visitPost(DocAutoList *l)
       
   349 {
       
   350   if (m_hide) return;
       
   351   if (l->isEnumList())
       
   352   {
       
   353     m_t << "</orderedlist>\n";
       
   354   }
       
   355   else
       
   356   {
       
   357     m_t << "</itemizedlist>\n";
       
   358   }
       
   359 }
       
   360 
       
   361 void XmlDocVisitor::visitPre(DocAutoListItem *)
       
   362 {
       
   363   if (m_hide) return;
       
   364   m_t << "<listitem>";
       
   365 }
       
   366 
       
   367 void XmlDocVisitor::visitPost(DocAutoListItem *) 
       
   368 {
       
   369   if (m_hide) return;
       
   370   m_t << "</listitem>";
       
   371 }
       
   372 
       
   373 void XmlDocVisitor::visitPre(DocPara *) 
       
   374 {
       
   375   if (m_hide) return;
       
   376   m_t << "<para>";
       
   377 }
       
   378 
       
   379 void XmlDocVisitor::visitPost(DocPara *)
       
   380 {
       
   381   if (m_hide) return;
       
   382   m_t << "</para>";
       
   383 }
       
   384 
       
   385 void XmlDocVisitor::visitPre(DocRoot *)
       
   386 {
       
   387   //m_t << "<hr><h4><font color=\"red\">New parser:</font></h4>\n";
       
   388 }
       
   389 
       
   390 void XmlDocVisitor::visitPost(DocRoot *)
       
   391 {
       
   392   //m_t << "<hr><h4><font color=\"red\">Old parser:</font></h4>\n";
       
   393 }
       
   394 
       
   395 void XmlDocVisitor::visitPre(DocSimpleSect *s)
       
   396 {
       
   397   if (m_hide) return;
       
   398   m_t << "<simplesect kind=\"";
       
   399   switch(s->type())
       
   400   {
       
   401     case DocSimpleSect::See: 
       
   402       m_t << "see"; break;
       
   403     case DocSimpleSect::Return: 
       
   404       m_t << "return"; break;
       
   405     case DocSimpleSect::Author: 
       
   406       m_t << "author"; break;
       
   407     case DocSimpleSect::Authors: 
       
   408       m_t << "authors"; break;
       
   409     case DocSimpleSect::Version: 
       
   410       m_t << "version"; break;
       
   411     case DocSimpleSect::Since: 
       
   412       m_t << "since"; break;
       
   413     case DocSimpleSect::Date: 
       
   414       m_t << "date"; break;
       
   415     case DocSimpleSect::Note: 
       
   416       m_t << "note"; break;
       
   417     case DocSimpleSect::Warning:
       
   418       m_t << "warning"; break;
       
   419     case DocSimpleSect::Pre:
       
   420       m_t << "pre"; break;
       
   421     case DocSimpleSect::Post:
       
   422       m_t << "post"; break;
       
   423     case DocSimpleSect::Invar:
       
   424       m_t << "invariant"; break;
       
   425     case DocSimpleSect::Remark:
       
   426       m_t << "remark"; break;
       
   427     case DocSimpleSect::Attention:
       
   428       m_t << "attention"; break;
       
   429     case DocSimpleSect::User: 
       
   430       m_t << "par"; break;
       
   431     case DocSimpleSect::Rcs: 
       
   432       m_t << "rcs"; break;
       
   433     case DocSimpleSect::Unknown:  break;
       
   434   }
       
   435   m_t << "\">";
       
   436 }
       
   437 
       
   438 void XmlDocVisitor::visitPost(DocSimpleSect *)
       
   439 {
       
   440   if (m_hide) return;
       
   441   m_t << "</simplesect>\n";
       
   442 }
       
   443 
       
   444 void XmlDocVisitor::visitPre(DocTitle *)
       
   445 {
       
   446   if (m_hide) return;
       
   447   m_t << "<title>";
       
   448 }
       
   449 
       
   450 void XmlDocVisitor::visitPost(DocTitle *)
       
   451 {
       
   452   if (m_hide) return;
       
   453   m_t << "</title>";
       
   454 }
       
   455 
       
   456 void XmlDocVisitor::visitPre(DocSimpleList *)
       
   457 {
       
   458   if (m_hide) return;
       
   459   m_t << "<itemizedlist>\n";
       
   460 }
       
   461 
       
   462 void XmlDocVisitor::visitPost(DocSimpleList *)
       
   463 {
       
   464   if (m_hide) return;
       
   465   m_t << "</itemizedlist>\n";
       
   466 }
       
   467 
       
   468 void XmlDocVisitor::visitPre(DocSimpleListItem *)
       
   469 {
       
   470   if (m_hide) return;
       
   471   m_t << "<listitem>";
       
   472 }
       
   473 
       
   474 void XmlDocVisitor::visitPost(DocSimpleListItem *) 
       
   475 {
       
   476   if (m_hide) return;
       
   477   m_t << "</listitem>\n";
       
   478 }
       
   479 
       
   480 void XmlDocVisitor::visitPre(DocSection *s)
       
   481 {
       
   482   if (m_hide) return;
       
   483   m_t << "<sect" << s->level() << " id=\"" << s->file();
       
   484   if (!s->anchor().isEmpty()) m_t << "_1" << s->anchor();
       
   485   m_t << "\">" << endl;
       
   486   m_t << "<title>";
       
   487   filter(s->title());
       
   488   m_t << "</title>" << endl;
       
   489 }
       
   490 
       
   491 void XmlDocVisitor::visitPost(DocSection *s) 
       
   492 {
       
   493   m_t << "</sect" << s->level() << ">\n";
       
   494 }
       
   495 
       
   496 void XmlDocVisitor::visitPre(DocHtmlList *s)
       
   497 {
       
   498   if (m_hide) return;
       
   499   if (s->type()==DocHtmlList::Ordered) 
       
   500     m_t << "<orderedlist>\n"; 
       
   501   else 
       
   502     m_t << "<itemizedlist>\n";
       
   503 }
       
   504 
       
   505 void XmlDocVisitor::visitPost(DocHtmlList *s) 
       
   506 {
       
   507   if (m_hide) return;
       
   508   if (s->type()==DocHtmlList::Ordered) 
       
   509     m_t << "</orderedlist>\n"; 
       
   510   else 
       
   511     m_t << "</itemizedlist>\n";
       
   512 }
       
   513 
       
   514 void XmlDocVisitor::visitPre(DocHtmlListItem *)
       
   515 {
       
   516   if (m_hide) return;
       
   517   m_t << "<listitem>\n";
       
   518 }
       
   519 
       
   520 void XmlDocVisitor::visitPost(DocHtmlListItem *) 
       
   521 {
       
   522   if (m_hide) return;
       
   523   m_t << "</listitem>\n";
       
   524 }
       
   525 
       
   526 void XmlDocVisitor::visitPre(DocHtmlDescList *)
       
   527 {
       
   528   if (m_hide) return;
       
   529   m_t << "<variablelist>\n";
       
   530 }
       
   531 
       
   532 void XmlDocVisitor::visitPost(DocHtmlDescList *) 
       
   533 {
       
   534   if (m_hide) return;
       
   535   m_t << "</variablelist>\n";
       
   536 }
       
   537 
       
   538 void XmlDocVisitor::visitPre(DocHtmlDescTitle *)
       
   539 {
       
   540   if (m_hide) return;
       
   541   m_t << "<varlistentry><term>";
       
   542 }
       
   543 
       
   544 void XmlDocVisitor::visitPost(DocHtmlDescTitle *) 
       
   545 {
       
   546   if (m_hide) return;
       
   547   m_t << "</term></varlistentry>\n";
       
   548 }
       
   549 
       
   550 void XmlDocVisitor::visitPre(DocHtmlDescData *)
       
   551 {
       
   552   if (m_hide) return;
       
   553   m_t << "<listitem>";
       
   554 }
       
   555 
       
   556 void XmlDocVisitor::visitPost(DocHtmlDescData *) 
       
   557 {
       
   558   if (m_hide) return;
       
   559   m_t << "</listitem>\n";
       
   560 }
       
   561 
       
   562 void XmlDocVisitor::visitPre(DocHtmlTable *t)
       
   563 {
       
   564   if (m_hide) return;
       
   565   m_t << "<table rows=\"" << t->numRows() 
       
   566       << "\" cols=\"" << t->numCols() << "\">" ;
       
   567 }
       
   568 
       
   569 void XmlDocVisitor::visitPost(DocHtmlTable *) 
       
   570 {
       
   571   if (m_hide) return;
       
   572   m_t << "</table>\n";
       
   573 }
       
   574 
       
   575 void XmlDocVisitor::visitPre(DocHtmlRow *)
       
   576 {
       
   577   if (m_hide) return;
       
   578   m_t << "<row>\n";
       
   579 }
       
   580 
       
   581 void XmlDocVisitor::visitPost(DocHtmlRow *) 
       
   582 {
       
   583   if (m_hide) return;
       
   584   m_t << "</row>\n";
       
   585 }
       
   586 
       
   587 void XmlDocVisitor::visitPre(DocHtmlCell *c)
       
   588 {
       
   589   if (m_hide) return;
       
   590   if (c->isHeading()) m_t << "<entry thead=\"yes\">"; else m_t << "<entry thead=\"no\">";
       
   591 }
       
   592 
       
   593 void XmlDocVisitor::visitPost(DocHtmlCell *) 
       
   594 {
       
   595   if (m_hide) return;
       
   596   m_t << "</entry>"; 
       
   597 }
       
   598 
       
   599 void XmlDocVisitor::visitPre(DocHtmlCaption *)
       
   600 {
       
   601   if (m_hide) return;
       
   602   m_t << "<caption>";
       
   603 }
       
   604 
       
   605 void XmlDocVisitor::visitPost(DocHtmlCaption *) 
       
   606 {
       
   607   if (m_hide) return;
       
   608   m_t << "</caption>\n";
       
   609 }
       
   610 
       
   611 void XmlDocVisitor::visitPre(DocInternal *)
       
   612 {
       
   613   if (m_hide) return;
       
   614   m_t << "<internal>";
       
   615 }
       
   616 
       
   617 void XmlDocVisitor::visitPost(DocInternal *) 
       
   618 {
       
   619   if (m_hide) return;
       
   620   m_t << "</internal>" << endl;
       
   621 }
       
   622 
       
   623 void XmlDocVisitor::visitPre(DocHRef *href)
       
   624 {
       
   625   if (m_hide) return;
       
   626   m_t << "<ulink url=\"" << href->url() << "\">";
       
   627 }
       
   628 
       
   629 void XmlDocVisitor::visitPost(DocHRef *) 
       
   630 {
       
   631   if (m_hide) return;
       
   632   m_t << "</ulink>";
       
   633 }
       
   634 
       
   635 void XmlDocVisitor::visitPre(DocHtmlHeader *header)
       
   636 {
       
   637   if (m_hide) return;
       
   638   m_t << "<heading level=\"" << header->level() << "\">";
       
   639 }
       
   640 
       
   641 void XmlDocVisitor::visitPost(DocHtmlHeader *) 
       
   642 {
       
   643   if (m_hide) return;
       
   644   m_t << "</heading>\n";
       
   645 }
       
   646 
       
   647 void XmlDocVisitor::visitPre(DocImage *img)
       
   648 {
       
   649   if (m_hide) return;
       
   650   m_t << "<image type=\"";
       
   651   switch(img->type())
       
   652   {
       
   653     case DocImage::Html:  m_t << "html"; break;
       
   654     case DocImage::Latex: m_t << "latex"; break;
       
   655     case DocImage::Rtf:   m_t << "rtf"; break;
       
   656   }
       
   657   m_t << "\"";
       
   658 
       
   659   QString baseName=img->name();
       
   660   int i;
       
   661   if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1)
       
   662   {
       
   663     baseName=baseName.right(baseName.length()-i-1);
       
   664   }
       
   665   m_t << " name=\"" << baseName << "\"";
       
   666   if (!img->width().isEmpty())
       
   667   {
       
   668     m_t << " width=\"";
       
   669     filter(img->width());
       
   670     m_t << "\"";
       
   671   }
       
   672   else if (!img->height().isEmpty())
       
   673   {
       
   674     m_t << " height=\"";
       
   675     filter(img->height());
       
   676     m_t << "\"";
       
   677   }
       
   678   m_t << ">";
       
   679 
       
   680   // copy the image to the output dir
       
   681   QFile inImage(img->name());
       
   682   QFile outImage(Config_getString("XML_OUTPUT")+"/"+baseName.ascii());
       
   683   if (inImage.open(IO_ReadOnly))
       
   684   {
       
   685     if (outImage.open(IO_WriteOnly))
       
   686     {
       
   687       char *buffer = new char[inImage.size()];
       
   688       inImage.readBlock(buffer,inImage.size());
       
   689       outImage.writeBlock(buffer,inImage.size());
       
   690       outImage.flush();
       
   691       delete[] buffer;
       
   692     }
       
   693   }
       
   694 }
       
   695 
       
   696 void XmlDocVisitor::visitPost(DocImage *) 
       
   697 {
       
   698   if (m_hide) return;
       
   699   m_t << "</image>" << endl;
       
   700 }
       
   701 
       
   702 void XmlDocVisitor::visitPre(DocDotFile *df)
       
   703 {
       
   704   if (m_hide) return;
       
   705   m_t << "<dotfile name=\"" << df->file() << "\">";
       
   706 }
       
   707 
       
   708 void XmlDocVisitor::visitPost(DocDotFile *) 
       
   709 {
       
   710   if (m_hide) return;
       
   711   m_t << "</dotfile>" << endl;
       
   712 }
       
   713 
       
   714 void XmlDocVisitor::visitPre(DocLink *lnk)
       
   715 {
       
   716   if (m_hide) return;
       
   717   startLink(lnk->ref(),lnk->file(),lnk->anchor());
       
   718 }
       
   719 
       
   720 void XmlDocVisitor::visitPost(DocLink *) 
       
   721 {
       
   722   if (m_hide) return;
       
   723   endLink();
       
   724 }
       
   725 
       
   726 void XmlDocVisitor::visitPre(DocRef *ref)
       
   727 {
       
   728   if (m_hide) return;
       
   729    if (!ref->file().isEmpty()) startLink(ref->ref(),ref->file(),ref->anchor());
       
   730   if (!ref->hasLinkText()) filter(ref->targetTitle());
       
   731 }
       
   732 
       
   733 void XmlDocVisitor::visitPost(DocRef *ref) 
       
   734 {
       
   735   if (m_hide) return;
       
   736   if (!ref->file().isEmpty()) endLink();
       
   737   //m_t << " ";
       
   738 }
       
   739 
       
   740 void XmlDocVisitor::visitPre(DocSecRefItem *ref)
       
   741 {
       
   742   if (m_hide) return;
       
   743   m_t << "<tocitem id=\"" << ref->file() << "_1" << ref->anchor() << "\">";
       
   744 }
       
   745 
       
   746 void XmlDocVisitor::visitPost(DocSecRefItem *) 
       
   747 {
       
   748   if (m_hide) return;
       
   749   m_t << "</tocitem>" << endl;
       
   750 }
       
   751 
       
   752 void XmlDocVisitor::visitPre(DocSecRefList *)
       
   753 {
       
   754   if (m_hide) return;
       
   755   m_t << "<toclist>" << endl;
       
   756 }
       
   757 
       
   758 void XmlDocVisitor::visitPost(DocSecRefList *) 
       
   759 {
       
   760   if (m_hide) return;
       
   761   m_t << "</toclist>" << endl;
       
   762 }
       
   763 
       
   764 //void XmlDocVisitor::visitPre(DocLanguage *l)
       
   765 //{
       
   766 //  if (m_hide) return;
       
   767 //  m_t << "<language langid=\"" << l->id() << "\">";
       
   768 //}
       
   769 //
       
   770 //void XmlDocVisitor::visitPost(DocLanguage *) 
       
   771 //{
       
   772 //  if (m_hide) return;
       
   773 //  m_t << "</language>" << endl;
       
   774 //}
       
   775 
       
   776 void XmlDocVisitor::visitPre(DocParamSect *s)
       
   777 {
       
   778   if (m_hide) return;
       
   779   m_t << "<parameterlist kind=\"";
       
   780   switch(s->type())
       
   781   {
       
   782     case DocParamSect::Param: 
       
   783       m_t << "param"; break;
       
   784     case DocParamSect::RetVal: 
       
   785       m_t << "retval"; break;
       
   786     case DocParamSect::Exception: 
       
   787       m_t << "exception"; break;
       
   788     case DocParamSect::TemplateParam: 
       
   789       m_t << "templateparam"; break;
       
   790     default:
       
   791       ASSERT(0);
       
   792   }
       
   793   m_t << "\">";
       
   794 }
       
   795 
       
   796 void XmlDocVisitor::visitPost(DocParamSect *)
       
   797 {
       
   798   if (m_hide) return;
       
   799   m_t << "</parameterlist>" << endl;
       
   800 }
       
   801 
       
   802 void XmlDocVisitor::visitPre(DocParamList *pl)
       
   803 {
       
   804   if (m_hide) return;
       
   805   m_t << "<parameteritem>" << endl;
       
   806   m_t << "<parameternamelist>" << endl;
       
   807   //QStrListIterator li(pl->parameters());
       
   808   //const char *s;
       
   809   QListIterator<DocNode> li(pl->parameters());
       
   810   DocNode *param;
       
   811   for (li.toFirst();(param=li.current());++li)
       
   812   {
       
   813     m_t << "<parametername";
       
   814     if (pl->direction()!=DocParamSect::Unspecified)
       
   815     {
       
   816       m_t << " direction=\"";
       
   817       if (pl->direction()==DocParamSect::In)
       
   818       {
       
   819         m_t << "in";
       
   820       }
       
   821       else if (pl->direction()==DocParamSect::Out)
       
   822       {
       
   823         m_t << "out";
       
   824       }
       
   825       else if (pl->direction()==DocParamSect::InOut)
       
   826       {
       
   827         m_t << "inout";
       
   828       }
       
   829       m_t << "\"";
       
   830     }
       
   831     m_t << ">";
       
   832     if (param->kind()==DocNode::Kind_Word)
       
   833     {
       
   834       visit((DocWord*)param); 
       
   835     }
       
   836     else if (param->kind()==DocNode::Kind_LinkedWord)
       
   837     {
       
   838       visit((DocLinkedWord*)param); 
       
   839     }
       
   840     m_t << "</parametername>" << endl;
       
   841   }
       
   842   m_t << "</parameternamelist>" << endl;
       
   843   m_t << "<parameterdescription>" << endl;
       
   844 }
       
   845 
       
   846 void XmlDocVisitor::visitPost(DocParamList *)
       
   847 {
       
   848   if (m_hide) return;
       
   849   m_t << "</parameterdescription>" << endl;
       
   850   m_t << "</parameteritem>" << endl;
       
   851 }
       
   852 
       
   853 void XmlDocVisitor::visitPre(DocXRefItem *x)
       
   854 {
       
   855   if (m_hide) return;
       
   856   m_t << "<xrefsect id=\"";
       
   857   m_t << x->file() << "_1" << x->anchor();
       
   858   m_t << "\">";
       
   859   m_t << "<xreftitle>";
       
   860   filter(x->title());
       
   861   m_t << "</xreftitle>";
       
   862   m_t << "<xrefdescription>";
       
   863 }
       
   864 
       
   865 void XmlDocVisitor::visitPost(DocXRefItem *)
       
   866 {
       
   867   if (m_hide) return;
       
   868   m_t << "</xrefdescription>";
       
   869   m_t << "</xrefsect>";
       
   870 }
       
   871 
       
   872 void XmlDocVisitor::visitPre(DocInternalRef *ref)
       
   873 {
       
   874   if (m_hide) return;
       
   875   startLink(0,ref->file(),ref->anchor());
       
   876 }
       
   877 
       
   878 void XmlDocVisitor::visitPost(DocInternalRef *) 
       
   879 {
       
   880   if (m_hide) return;
       
   881   endLink();
       
   882   m_t << " ";
       
   883 }
       
   884 
       
   885 void XmlDocVisitor::visitPre(DocCopy *c)
       
   886 {
       
   887   if (m_hide) return;
       
   888   m_t << "<copydoc link=\"" << convertToXML(c->link()) << "\">";
       
   889 }
       
   890 
       
   891 void XmlDocVisitor::visitPost(DocCopy *)
       
   892 {
       
   893   if (m_hide) return;
       
   894   m_t << "</copydoc>" << endl;
       
   895 }
       
   896 
       
   897 void XmlDocVisitor::visitPre(DocText *)
       
   898 {
       
   899 }
       
   900 
       
   901 void XmlDocVisitor::visitPost(DocText *)
       
   902 {
       
   903 }
       
   904 
       
   905 void XmlDocVisitor::filter(const char *str)
       
   906 { 
       
   907   m_t << convertToXML(str);
       
   908 }
       
   909 
       
   910 void XmlDocVisitor::startLink(const QString &ref,const QString &file,const QString &anchor)
       
   911 {
       
   912   m_t << "<ref refid=\"" << file;
       
   913   if (!anchor.isEmpty()) m_t << "_1" << anchor;
       
   914   m_t << "\" kindref=\"";
       
   915   if (!anchor.isEmpty()) m_t << "member"; else m_t << "compound";
       
   916   m_t << "\"";
       
   917   if (!ref.isEmpty()) m_t << " external=\"" << ref << "\"";
       
   918   m_t << ">";
       
   919 }
       
   920 
       
   921 void XmlDocVisitor::endLink()
       
   922 {
       
   923   m_t << "</ref>";
       
   924 }
       
   925 
       
   926 void XmlDocVisitor::pushEnabled()
       
   927 {
       
   928   m_enabled.push(new bool(m_hide));
       
   929 }
       
   930 
       
   931 void XmlDocVisitor::popEnabled()
       
   932 {
       
   933   bool *v=m_enabled.pop();
       
   934   ASSERT(v!=0);
       
   935   m_hide = *v;
       
   936   delete v;
       
   937 }
       
   938