summaryrefslogtreecommitdiffstats
path: root/src/xmldocvisitor.cpp
diff options
context:
space:
mode:
authoralbert-github <albert.tests@gmail.com>2014-11-28 13:44:07 (GMT)
committeralbert-github <albert.tests@gmail.com>2014-11-28 13:44:07 (GMT)
commit329a4ddc036ac9dfe72b11d62cb4043bc8488c20 (patch)
tree8ca50b460259cbadced0e68f100ba3fb620faed7 /src/xmldocvisitor.cpp
parent0fea3d4ca57187f271d7580ff16f32b7ab4657df (diff)
downloadDoxygen-329a4ddc036ac9dfe72b11d62cb4043bc8488c20.zip
Doxygen-329a4ddc036ac9dfe72b11d62cb4043bc8488c20.tar.gz
Doxygen-329a4ddc036ac9dfe72b11d62cb4043bc8488c20.tar.bz2
Limit images sizes and make more uniform (LaTeX)
This patch adjusts some problems regarding image sizes in LaTeX output of doxygen (a.o. Bug 738299 - When using msc or PlantUML, the default latex for the created image should include [width=\linewidth]) this has been done is such a way that all the "image" commands (i.e. image, dot, dotfile, msc, mscfile, diafile, startuml) operate in a similar way / have the same possibilities. - commands.doc Adjusted documentation to reflect changes. - cmdmapper.cpp - cmdmapper.h Added utility function to map command id back to command name - doctokenizer.h - doctokenizer.l Handle Caption and Size indication. Required also that some other rules had to be tightened a bit (like usage of {} in startuml and usage of "" for captions. This was already described in the documentation in this way). - docparser.cpp - docparser.h Created routine to uniformly handle the Caption and size indications and store them in a general way. - latexgen.cpp Replaced graphicx package by adjustbox package (includes graphicx) to support "min width" etc. - doxygen.sty templates\latex Added commands to make commands with and without caption behave similar. - docbookvisitor.cpp - docbookvisitor.h - htmldocvisitor.cpp - latexdocvisitor.cpp - latexdocvisitor.h - printdocvisitor.h - xmldocvisitor.cpp Created routine to uniformly handle the Caption and size indications in a general way. - indexpage.xml (testing\022) - indexpage.xml (testing\031) - class_receiver.xml (testing\037) - class_sender.xml (testing\037) Adjusted example output.
Diffstat (limited to 'src/xmldocvisitor.cpp')
-rw-r--r--src/xmldocvisitor.cpp115
1 files changed, 79 insertions, 36 deletions
diff --git a/src/xmldocvisitor.cpp b/src/xmldocvisitor.cpp
index f2da28c..66f455e 100644
--- a/src/xmldocvisitor.cpp
+++ b/src/xmldocvisitor.cpp
@@ -32,6 +32,71 @@
#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, QCString name, DocImage::Type type, QCString width, QCString height)
+{
+ QCString tmpStr;
+
+ t << "<" << cmd;
+ if (type != DocImage::None)
+ {
+ 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, const bool doCaption)
+{
+ t << "</" << cmd << ">" << endl;
+}
+
XmlDocVisitor::XmlDocVisitor(FTextStream &t,CodeOutputInterface &ci)
: DocVisitor(DocVisitor_XML), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE)
{
@@ -200,19 +265,19 @@ void XmlDocVisitor::visit(DocVerbatim *s)
m_t << "</docbookonly>";
break;
case DocVerbatim::Dot:
- m_t << "<dot>";
+ visitPreStart(m_t, "dot", s->hasCaption(), this, s->children(), QCString(""), DocImage::None, s->width(), s->height());
filter(s->text());
- m_t << "</dot>";
+ visitPostEnd(m_t, "dot", s->hasCaption());
break;
case DocVerbatim::Msc:
- m_t << "<msc>";
+ visitPreStart(m_t, "msc", s->hasCaption(), this, s->children(), QCString(""), DocImage::None, s->width(), s->height());
filter(s->text());
- m_t << "</msc>";
+ visitPostEnd(m_t, "msc", s->hasCaption());
break;
case DocVerbatim::PlantUML:
- m_t << "<plantuml>";
+ visitPreStart(m_t, "plantuml", s->hasCaption(), this, s->children(), QCString(""), DocImage::None, s->width(), s->height());
filter(s->text());
- m_t << "</plantuml>";
+ visitPostEnd(m_t, "plantuml", s->hasCaption());
break;
}
}
@@ -682,15 +747,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 +754,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, img->type(), img->width(), img->height());
// copy the image to the output dir
QFile inImage(img->name());
@@ -732,43 +775,43 @@ void XmlDocVisitor::visitPre(DocImage *img)
void XmlDocVisitor::visitPost(DocImage *)
{
if (m_hide) return;
- m_t << "</image>" << endl;
+ visitPostEnd(m_t, "image", FALSE);
}
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(), DocImage::None, df->width(), df->height());
}
void XmlDocVisitor::visitPost(DocDotFile *)
{
if (m_hide) return;
- m_t << "</dotfile>" << endl;
+ visitPostEnd(m_t, "dotfile", FALSE);
}
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(), DocImage::None, df->width(), df->height());
}
void XmlDocVisitor::visitPost(DocMscFile *)
{
if (m_hide) return;
- m_t << "</mscfile>" << endl;
+ visitPostEnd(m_t, "mscfile", FALSE);
}
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(), DocImage::None, df->width(), df->height());
}
void XmlDocVisitor::visitPost(DocDiaFile *)
{
if (m_hide) return;
- m_t << "</diafile>" << endl;
+ visitPostEnd(m_t, "diafile", FALSE);
}
void XmlDocVisitor::visitPre(DocLink *lnk)