diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2014-12-20 14:04:50 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 2014-12-20 14:04:50 (GMT) |
commit | 67e8d626fec0c4365106902dcd16b988b8cceb10 (patch) | |
tree | dab43c4c97739308cd75399c7c88cf0f954af6b5 /src/xmldocvisitor.cpp | |
parent | c09f84c27bd916342ca0e8fdcb5244cd902f8e09 (diff) | |
parent | 329a4ddc036ac9dfe72b11d62cb4043bc8488c20 (diff) | |
download | Doxygen-67e8d626fec0c4365106902dcd16b988b8cceb10.zip Doxygen-67e8d626fec0c4365106902dcd16b988b8cceb10.tar.gz Doxygen-67e8d626fec0c4365106902dcd16b988b8cceb10.tar.bz2 |
Merge branch 'feature/bug_size_latex' of https://github.com/albert-github/doxygen into albert-github-feature/bug_size_latex
Conflicts:
src/doctokenizer.h
src/latexgen.cpp
Diffstat (limited to 'src/xmldocvisitor.cpp')
-rw-r--r-- | src/xmldocvisitor.cpp | 122 |
1 files changed, 84 insertions, 38 deletions
diff --git a/src/xmldocvisitor.cpp b/src/xmldocvisitor.cpp index f2da28c..afab1d3 100644 --- a/src/xmldocvisitor.cpp +++ b/src/xmldocvisitor.cpp @@ -32,6 +32,74 @@ #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()) + { + tmpStr = width; + tmpStr = tmpStr.replace(QRegExp("min *width"),"minwidth"); + tmpStr = tmpStr.replace(QRegExp("max *width"),"maxwidth"); + tmpStr = tmpStr.replace(QRegExp("="),"=\""); + tmpStr = tmpStr.replace(QRegExp(","),"\" ") + "\""; + tmpStr = tmpStr.replace(QRegExp("\"\""),"\""); + tmpStr = tmpStr.replace(QRegExp("\\"),"\\\\"); + t << " " << tmpStr; + } + if (!height.isEmpty()) + { + tmpStr = height; + tmpStr = tmpStr.replace(QRegExp("min *height"),"minheight"); + tmpStr = tmpStr.replace(QRegExp("max *height"),"maxheight"); + tmpStr = tmpStr.replace(QRegExp("="),"=\""); + tmpStr = tmpStr.replace(QRegExp(","),"\" ") + "\""; + tmpStr = tmpStr.replace(QRegExp("\"\""),"\""); + tmpStr = tmpStr.replace(QRegExp("\\"),"\\\\"); + t << " " << tmpStr; + } + + 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 +267,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 +750,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 +757,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 +778,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) |