diff options
Diffstat (limited to 'src/xmldocvisitor.cpp')
-rw-r--r-- | src/xmldocvisitor.cpp | 107 |
1 files changed, 69 insertions, 38 deletions
diff --git a/src/xmldocvisitor.cpp b/src/xmldocvisitor.cpp index f2da28c..65711ab 100644 --- a/src/xmldocvisitor.cpp +++ b/src/xmldocvisitor.cpp @@ -32,6 +32,59 @@ #include "config.h" #include "htmlentity.h" +static void visitCaption(XmlDocVisitor *parent, QList<DocNode> children) +{ + QListIterator<DocNode> cli(children); + DocNode *n; + for (cli.toFirst();(n=cli.current());++cli) n->accept(parent); +} + +static void visitPreStart(FTextStream &t, const char *cmd, const bool doCaption, + XmlDocVisitor *parent, QList<DocNode> children, + const QCString &name, bool writeType, DocImage::Type type, const QCString &width, + const QCString &height) +{ + QCString tmpStr; + + t << "<" << cmd; + if (writeType) + { + t << " type=\""; + switch(type) + { + case DocImage::Html: t << "html"; break; + case DocImage::Latex: t << "latex"; break; + case DocImage::Rtf: t << "rtf"; break; + case DocImage::DocBook: t << "docbook"; break; + } + t << "\""; + } + if (!name.isEmpty()) + { + t << " name=\"" << name << "\""; + } + if (!width.isEmpty()) + { + t << " width=\"" << convertToXML(width) << "\""; + } + else if (!height.isEmpty()) + { + t << " height=\"" << convertToXML(height) << "\""; + } + if (doCaption) + { + t << " caption=\""; + visitCaption(parent, children); + t << "\""; + } + t << ">"; +} + +static void visitPostEnd(FTextStream &t, const char *cmd) +{ + t << "</" << cmd << ">" << endl; +} + XmlDocVisitor::XmlDocVisitor(FTextStream &t,CodeOutputInterface &ci) : DocVisitor(DocVisitor_XML), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE) { @@ -199,20 +252,20 @@ void XmlDocVisitor::visit(DocVerbatim *s) filter(s->text()); m_t << "</docbookonly>"; break; - case DocVerbatim::Dot: - m_t << "<dot>"; + case DocVerbatim::Dot: + visitPreStart(m_t, "dot", s->hasCaption(), this, s->children(), QCString(""), FALSE, DocImage::Html, s->width(), s->height()); filter(s->text()); - m_t << "</dot>"; + visitPostEnd(m_t, "dot"); break; - case DocVerbatim::Msc: - m_t << "<msc>"; + case DocVerbatim::Msc: + visitPreStart(m_t, "msc", s->hasCaption(), this, s->children(), QCString(""), FALSE, DocImage::Html, s->width(), s->height()); filter(s->text()); - m_t << "</msc>"; + visitPostEnd(m_t, "msc"); break; case DocVerbatim::PlantUML: - m_t << "<plantuml>"; + visitPreStart(m_t, "plantuml", s->hasCaption(), this, s->children(), QCString(""), FALSE, DocImage::Html, s->width(), s->height()); filter(s->text()); - m_t << "</plantuml>"; + visitPostEnd(m_t, "plantuml"); break; } } @@ -682,15 +735,6 @@ void XmlDocVisitor::visitPost(DocHtmlHeader *) void XmlDocVisitor::visitPre(DocImage *img) { if (m_hide) return; - m_t << "<image type=\""; - switch(img->type()) - { - case DocImage::Html: m_t << "html"; break; - case DocImage::Latex: m_t << "latex"; break; - case DocImage::Rtf: m_t << "rtf"; break; - case DocImage::DocBook: m_t << "docbook"; break; - } - m_t << "\""; QCString baseName=img->name(); int i; @@ -698,20 +742,7 @@ void XmlDocVisitor::visitPre(DocImage *img) { baseName=baseName.right(baseName.length()-i-1); } - m_t << " name=\"" << baseName << "\""; - if (!img->width().isEmpty()) - { - m_t << " width=\""; - filter(img->width()); - m_t << "\""; - } - else if (!img->height().isEmpty()) - { - m_t << " height=\""; - filter(img->height()); - m_t << "\""; - } - m_t << ">"; + visitPreStart(m_t, "image", FALSE, this, img->children(), baseName, TRUE, img->type(), img->width(), img->height()); // copy the image to the output dir QFile inImage(img->name()); @@ -732,43 +763,43 @@ void XmlDocVisitor::visitPre(DocImage *img) void XmlDocVisitor::visitPost(DocImage *) { if (m_hide) return; - m_t << "</image>" << endl; + visitPostEnd(m_t, "image"); } void XmlDocVisitor::visitPre(DocDotFile *df) { if (m_hide) return; - m_t << "<dotfile name=\"" << df->file() << "\">"; + visitPreStart(m_t, "dotfile", FALSE, this, df->children(), df->file(), FALSE, DocImage::Html, df->width(), df->height()); } void XmlDocVisitor::visitPost(DocDotFile *) { if (m_hide) return; - m_t << "</dotfile>" << endl; + visitPostEnd(m_t, "dotfile"); } void XmlDocVisitor::visitPre(DocMscFile *df) { if (m_hide) return; - m_t << "<mscfile name=\"" << df->file() << "\">"; + visitPreStart(m_t, "mscfile", FALSE, this, df->children(), df->file(), FALSE, DocImage::Html, df->width(), df->height()); } void XmlDocVisitor::visitPost(DocMscFile *) { if (m_hide) return; - m_t << "</mscfile>" << endl; + visitPostEnd(m_t, "mscfile"); } void XmlDocVisitor::visitPre(DocDiaFile *df) { if (m_hide) return; - m_t << "<diafile name=\"" << df->file() << "\">"; + visitPreStart(m_t, "diafile", FALSE, this, df->children(), df->file(), FALSE, DocImage::Html, df->width(), df->height()); } void XmlDocVisitor::visitPost(DocDiaFile *) { if (m_hide) return; - m_t << "</diafile>" << endl; + visitPostEnd(m_t, "diafile"); } void XmlDocVisitor::visitPre(DocLink *lnk) |