diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2013-10-06 19:28:00 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 2013-10-06 21:39:40 (GMT) |
commit | 4fc5b2b154331fbf35800935889f1d0372334f0a (patch) | |
tree | a87e075516435e0d855a4af6aecb356a517c4b33 /src | |
parent | 983507e0a65e5c2d51209740a89311e122e4f389 (diff) | |
download | Doxygen-4fc5b2b154331fbf35800935889f1d0372334f0a.zip Doxygen-4fc5b2b154331fbf35800935889f1d0372334f0a.tar.gz Doxygen-4fc5b2b154331fbf35800935889f1d0372334f0a.tar.bz2 |
Bug 707713 - Add support for dia diagrams
Diffstat (limited to 'src')
-rw-r--r-- | src/cmdmapper.cpp | 1 | ||||
-rw-r--r-- | src/cmdmapper.h | 3 | ||||
-rw-r--r-- | src/compound.xsd | 7 | ||||
-rw-r--r-- | src/config.l | 25 | ||||
-rw-r--r-- | src/config.xml | 19 | ||||
-rw-r--r-- | src/dia.cpp | 88 | ||||
-rw-r--r-- | src/dia.h | 30 | ||||
-rw-r--r-- | src/docbookvisitor.cpp | 87 | ||||
-rw-r--r-- | src/docbookvisitor.h | 6 | ||||
-rw-r--r-- | src/docparser.cpp | 113 | ||||
-rw-r--r-- | src/docparser.h | 28 | ||||
-rw-r--r-- | src/docvisitor.h | 3 | ||||
-rw-r--r-- | src/doxygen.cpp | 20 | ||||
-rw-r--r-- | src/doxygen.css | 5 | ||||
-rw-r--r-- | src/doxygen.h | 1 | ||||
-rw-r--r-- | src/htmldocvisitor.cpp | 42 | ||||
-rw-r--r-- | src/htmldocvisitor.h | 3 | ||||
-rw-r--r-- | src/latexdocvisitor.cpp | 104 | ||||
-rw-r--r-- | src/latexdocvisitor.h | 7 | ||||
-rw-r--r-- | src/libdoxygen.pro.in | 2 | ||||
-rw-r--r-- | src/mandocvisitor.cpp | 7 | ||||
-rw-r--r-- | src/mandocvisitor.h | 2 | ||||
-rw-r--r-- | src/msc.cpp | 8 | ||||
-rw-r--r-- | src/perlmodgen.cpp | 16 | ||||
-rw-r--r-- | src/printdocvisitor.h | 10 | ||||
-rw-r--r-- | src/rtfdocvisitor.cpp | 37 | ||||
-rw-r--r-- | src/rtfdocvisitor.h | 3 | ||||
-rw-r--r-- | src/textdocvisitor.h | 2 | ||||
-rw-r--r-- | src/xmldocvisitor.cpp | 13 | ||||
-rw-r--r-- | src/xmldocvisitor.h | 2 |
30 files changed, 684 insertions, 10 deletions
diff --git a/src/cmdmapper.cpp b/src/cmdmapper.cpp index f4fc7e4..c728be3 100644 --- a/src/cmdmapper.cpp +++ b/src/cmdmapper.cpp @@ -134,6 +134,7 @@ CommandMap cmdMap[] = { "endinternal", CMD_ENDINTERNAL }, { "parblock", CMD_PARBLOCK }, { "endparblock", CMD_ENDPARBLOCK }, + { "diafile", CMD_DIAFILE }, { 0, 0 }, }; diff --git a/src/cmdmapper.h b/src/cmdmapper.h index f6d5ee6..0017c02 100644 --- a/src/cmdmapper.h +++ b/src/cmdmapper.h @@ -123,7 +123,8 @@ enum CommandType CMD_ENDDBONLY = 93, CMD_ENDINTERNAL = 94, CMD_PARBLOCK = 95, - CMD_ENDPARBLOCK = 96 + CMD_ENDPARBLOCK = 96, + CMD_DIAFILE = 97 }; enum HtmlTagType diff --git a/src/compound.xsd b/src/compound.xsd index 6a747b6..c1eb0ab 100644 --- a/src/compound.xsd +++ b/src/compound.xsd @@ -386,6 +386,7 @@ <xsd:element name="rtfonly" type="xsd:string" /> <xsd:element name="latexonly" type="xsd:string" /> <xsd:element name="dot" type="xsd:string" /> + <xsd:element name="msc" type="xsd:string" /> <xsd:element name="anchor" type="docAnchorType" /> <xsd:element name="formula" type="docFormulaType" /> <xsd:element name="ref" type="docRefTextType" /> @@ -501,7 +502,9 @@ <xsd:element name="table" type="docTableType" /> <xsd:element name="heading" type="docHeadingType" /> <xsd:element name="image" type="docImageType" /> - <xsd:element name="dotfile" type="docDotFileType" /> + <xsd:element name="dotfile" type="docFileType" /> + <xsd:element name="mscfile" type="docFileType" /> + <xsd:element name="diafile" type="docFileType" /> <xsd:element name="toclist" type="docTocListType" /> <xsd:element name="language" type="docLanguageType" /> <xsd:element name="parameterlist" type="docParamListType" /> @@ -628,7 +631,7 @@ <xsd:attribute name="height" type="xsd:string" /> </xsd:complexType> - <xsd:complexType name="docDotFileType" mixed="true"> + <xsd:complexType name="docFileType" mixed="true"> <xsd:group ref="docTitleCmdGroup" minOccurs="0" maxOccurs="unbounded" /> <xsd:attribute name="name" type="xsd:string" /> </xsd:complexType> diff --git a/src/config.l b/src/config.l index 19f0267..cc0a2f8 100644 --- a/src/config.l +++ b/src/config.l @@ -1311,7 +1311,30 @@ void Config::check() mscgenPath=""; } - + // check dia path + QCString &diaPath = Config_getString("DIA_PATH"); + if (!diaPath.isEmpty()) + { + QFileInfo dp(diaPath+"/dia"+portable_commandExtension()); + if (!dp.exists() || !dp.isFile()) + { + config_err("Warning: dia could not be found at %s\n",diaPath.data()); + diaPath=""; + } + else + { + diaPath=dp.dirPath(TRUE).utf8()+"/"; +#if defined(_WIN32) // convert slashes + uint i=0,l=diaPath.length(); + for (i=0;i<l;i++) if (diaPath.at(i)=='/') diaPath.at(i)='\\'; +#endif + } + } + else // make sure the string is empty but not null! + { + diaPath=""; + } + // check input QStrList &inputSources=Config_getList("INPUT"); if (inputSources.count()==0) diff --git a/src/config.xml b/src/config.xml index 996279c..06654b9 100644 --- a/src/config.xml +++ b/src/config.xml @@ -3012,6 +3012,16 @@ where `loc1` and `loc2` can be relative or absolute paths or URLs. ]]> </docs> </option> + <option type='string' id='DIA_PATH' format='dir' defval=''> + <docs> +<![CDATA[ +You can include diagrams made with dia in doxygen documentation. Doxygen will then run +dia to produce the diagram and insert it in the documentation. The DIA_PATH tag allows +you to specify the directory where the dia binary resides. If left empty dia is assumed +to be found in the default search path. +]]> + </docs> + </option> <option type='bool' id='HIDE_UNDOC_RELATIONS' defval='1'> <docs> <![CDATA[ @@ -3246,6 +3256,15 @@ where `loc1` and `loc2` can be relative or absolute paths or URLs. ]]> </docs> </option> + <option type='list' id='DIAFILE_DIRS' format='dir'> + <docs> +<![CDATA[ + The \c DIAFILE_DIRS tag can be used to specify one or more directories that + contain dia files that are included in the documentation (see the + \ref cmdmscfile "\\diafile" command). +]]> + </docs> + </option> <option type='int' id='DOT_GRAPH_MAX_NODES' minval='0' maxval='10000' defval='50' depends='HAVE_DOT'> <docs> <![CDATA[ diff --git a/src/dia.cpp b/src/dia.cpp new file mode 100644 index 0000000..1032564 --- /dev/null +++ b/src/dia.cpp @@ -0,0 +1,88 @@ +/****************************************************************************** + * + * + * + * Copyright (C) 1997-2013 by Dimitri van Heesch. + * + * 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. + * + * Documents produced by Doxygen are derivative works derived from the + * input used in their production; they are not affected by this license. + * + */ + +#include "dia.h" +#include "portable.h" +#include "config.h" +#include "message.h" +#include "util.h" + +#include <qdir.h> + +static const int maxCmdLine = 40960; + +void writeDiaGraphFromFile(const char *inFile,const char *outDir, + const char *outFile,DiaOutputFormat format) +{ + QCString absOutFile = outDir; + absOutFile+=portable_pathSeparator(); + absOutFile+=outFile; + + // chdir to the output dir, so dot can find the font file. + QCString oldDir = QDir::currentDirPath().utf8(); + // go to the html output directory (i.e. path) + QDir::setCurrent(outDir); + //printf("Going to dir %s\n",QDir::currentDirPath().data()); + QCString diaExe = Config_getString("DIA_PATH")+"dia"+portable_commandExtension(); + QCString diaArgs; + QCString extension; + diaArgs+="-n "; + if (format==DIA_BITMAP) + { + diaArgs+="-t png-libart"; + extension=".png"; + } + else if (format==DIA_EPS) + { + diaArgs+="-t eps"; + extension=".eps"; + } + + diaArgs+=" -e \""; + diaArgs+=outFile; + diaArgs+=extension+"\""; + + diaArgs+=" \""; + diaArgs+=inFile; + diaArgs+="\""; + + int exitCode; + //printf("*** running: %s %s outDir:%s %s\n",diaExe.data(),diaArgs.data(),outDir,outFile); + portable_sysTimerStart(); + if ((exitCode=portable_system(diaExe,diaArgs,FALSE))!=0) + { + portable_sysTimerStop(); + goto error; + } + portable_sysTimerStop(); + if ( (format==DIA_EPS) && (Config_getBool("USE_PDFLATEX")) ) + { + QCString epstopdfArgs(maxCmdLine); + epstopdfArgs.sprintf("\"%s.eps\" --outfile=\"%s.pdf\"", + outFile,outFile); + portable_sysTimerStart(); + if (portable_system("epstopdf",epstopdfArgs)!=0) + { + err("Problems running epstopdf. Check your TeX installation!\n"); + } + portable_sysTimerStop(); + } + +error: + QDir::setCurrent(oldDir); +} + diff --git a/src/dia.h b/src/dia.h new file mode 100644 index 0000000..01d5962 --- /dev/null +++ b/src/dia.h @@ -0,0 +1,30 @@ +/****************************************************************************** + * + * + * + * Copyright (C) 1997-2013 by Dimitri van Heesch. + * + * 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. + * + * Documents produced by Doxygen are derivative works derived from the + * input used in their production; they are not affected by this license. + * + */ + +#ifndef _DIA_H +#define _DIA_H + +class QCString; +class FTextStream; + +enum DiaOutputFormat { DIA_BITMAP , DIA_EPS }; + +void writeDiaGraphFromFile(const char *inFile,const char *outDir, + const char *outFile,DiaOutputFormat format); + +#endif + diff --git a/src/docbookvisitor.cpp b/src/docbookvisitor.cpp index a70c58f..402f3c0 100644 --- a/src/docbookvisitor.cpp +++ b/src/docbookvisitor.cpp @@ -32,6 +32,7 @@ #include "config.h" #include "filedef.h" #include "msc.h" +#include "dia.h" DocbookDocVisitor::DocbookDocVisitor(FTextStream &t,CodeOutputInterface &ci) : DocVisitor(DocVisitor_Docbook), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE) @@ -1007,6 +1008,18 @@ void DocbookDocVisitor::visitPost(DocMscFile *df) if (m_hide) return; endMscFile(df->hasCaption()); } +void DocbookDocVisitor::visitPre(DocDiaFile *df) +{ + if (m_hide) return; + startDiaFile(df->file(),df->width(),df->height(),df->hasCaption()); +} + +void DocbookDocVisitor::visitPost(DocDiaFile *df) +{ + if (m_hide) return; + endDiaFile(df->hasCaption()); +} + void DocbookDocVisitor::visitPre(DocLink *lnk) { if (m_hide) return; @@ -1336,6 +1349,80 @@ void DocbookDocVisitor::endMscFile(bool hasCaption) m_t << "</para>" << endl; } +void DocbookDocVisitor::writeDiaFile(const QCString &baseName) +{ + QCString shortName = baseName; + int i; + if ((i=shortName.findRev('/'))!=-1) + { + shortName=shortName.right(shortName.length()-i-1); + } + QCString outDir = Config_getString("DOCBOOK_OUTPUT"); + writeDiaGraphFromFile(baseName+".dia",outDir,shortName,DIA_BITMAP); + m_t << " <imagedata"; + m_t << " align=\"center\" fileref=\"" << shortName << ".png" << "\">"; + m_t << "</imagedata>" << endl; +} + +void DocbookDocVisitor::startDiaFile(const QCString &fileName, + const QCString &width, + const QCString &height, + bool hasCaption + ) +{ + QCString baseName=fileName; + int i; + if ((i=baseName.findRev('/'))!=-1) + { + baseName=baseName.right(baseName.length()-i-1); + } + if ((i=baseName.find('.'))!=-1) + { + baseName=baseName.left(i); + } + baseName.prepend("msc_"); + QCString outDir = Config_getString("DOCBOOK_OUTPUT"); + writeDiaGraphFromFile(fileName,outDir,baseName,DIA_BITMAP); + m_t << "<para>" << endl; + m_t << " <figure>" << endl; + m_t << " <title></title>" << endl; + m_t << " <mediaobject>" << endl; + m_t << " <imageobject>" << endl; + m_t << " <imagedata"; + if (!width.isEmpty()) + { + m_t << " width=\""; + m_t << width; + m_t << "\""; + } + else if (!height.isEmpty()) + { + m_t << " depth=\""; + m_t << height; + m_t << "\""; + } + m_t << " align=\"center\" fileref=\"" << baseName << ".png" << "\">"; + m_t << "</imagedata>" << endl; + m_t << " </imageobject>" << endl; + if (hasCaption) + { + m_t << " <caption>" << endl; + } +} + +void DocbookDocVisitor::endDiaFile(bool hasCaption) +{ + if (m_hide) return; + m_t << "endl"; + if (hasCaption) + { + m_t << " </caption>" << endl; + } + m_t << " </mediaobject>" << endl; + m_t << " </figure>" << endl; + m_t << "</para>" << endl; +} + void DocbookDocVisitor::writeDotFile(const QCString &baseName) { QCString shortName = baseName; diff --git a/src/docbookvisitor.h b/src/docbookvisitor.h index 99bd6f3..a03e04a 100644 --- a/src/docbookvisitor.h +++ b/src/docbookvisitor.h @@ -103,6 +103,8 @@ class DocbookDocVisitor : public DocVisitor void visitPost(DocDotFile *); void visitPre(DocMscFile *); void visitPost(DocMscFile *); + void visitPre(DocDiaFile *); + void visitPost(DocDiaFile *); void visitPre(DocLink *); void visitPost(DocLink *); void visitPre(DocRef *); @@ -146,6 +148,10 @@ class DocbookDocVisitor : public DocVisitor const QCString &height, bool hasCaption); void endMscFile(bool hasCaption); void writeMscFile(const QCString &fileName); + void startDiaFile(const QCString &fileName,const QCString &width, + const QCString &height, bool hasCaption); + void endDiaFile(bool hasCaption); + void writeDiaFile(const QCString &fileName); void startDotFile(const QCString &fileName,const QCString &width, const QCString &height, bool hasCaption); void endDotFile(bool hasCaption); diff --git a/src/docparser.cpp b/src/docparser.cpp index 94de165..77b7bc0 100644 --- a/src/docparser.cpp +++ b/src/docparser.cpp @@ -2875,6 +2875,92 @@ void DocMscFile::parse() //--------------------------------------------------------------------------- +DocDiaFile::DocDiaFile(DocNode *parent,const QCString &name,const QCString &context) : + m_name(name), m_relPath(g_relPath), m_context(context) +{ + m_parent = parent; +} + +void DocDiaFile::parse() +{ + g_nodeStack.push(this); + DBG(("DocDiaFile::parse() start\n")); + + doctokenizerYYsetStateTitle(); + int tok; + while ((tok=doctokenizerYYlex())) + { + if (!defaultHandleToken(this,tok,m_children)) + { + switch (tok) + { + case TK_COMMAND: + warn_doc_error(g_fileName,doctokenizerYYlineno,"Illegal command %s as part of a \\diafile", + qPrint(g_token->name)); + break; + case TK_SYMBOL: + warn_doc_error(g_fileName,doctokenizerYYlineno,"Unsupported symbol %s found", + qPrint(g_token->name)); + break; + default: + warn_doc_error(g_fileName,doctokenizerYYlineno,"Unexpected token %s", + tokToString(tok)); + break; + } + } + } + tok=doctokenizerYYlex(); + while (tok==TK_WORD) // there are values following the title + { + if (g_token->name=="width") + { + m_width=g_token->chars; + } + else if (g_token->name=="height") + { + m_height=g_token->chars; + } + else + { + warn_doc_error(g_fileName,doctokenizerYYlineno,"Unknown option %s after image title", + qPrint(g_token->name)); + } + tok=doctokenizerYYlex(); + } + ASSERT(tok==0); + doctokenizerYYsetStatePara(); + handlePendingStyleCommands(this,m_children); + + bool ambig; + FileDef *fd = findFileDef(Doxygen::diaFileNameDict,m_name,ambig); + if (fd==0 && m_name.right(4)!=".dia") // try with .dia extension as well + { + fd = findFileDef(Doxygen::diaFileNameDict,m_name+".dia",ambig); + } + if (fd) + { + m_file = fd->absFilePath(); + } + else if (ambig) + { + warn_doc_error(g_fileName,doctokenizerYYlineno,"included dia file name %s is ambiguous.\n" + "Possible candidates:\n%s",qPrint(m_name), + qPrint(showFileDefMatches(Doxygen::exampleNameDict,m_name)) + ); + } + else + { + warn_doc_error(g_fileName,doctokenizerYYlineno,"included dia file %s is not found " + "in any of the paths specified via DIAFILE_DIRS!",qPrint(m_name)); + } + + DBG(("DocDiaFile::parse() end\n")); + DocNode *n=g_nodeStack.pop(); + ASSERT(n==this); +} + +//--------------------------------------------------------------------------- + DocVhdlFlow::DocVhdlFlow(DocNode *parent) { m_parent = parent; @@ -5105,6 +5191,30 @@ void DocPara::handleMscFile(const QCString &cmdName) df->parse(); } +void DocPara::handleDiaFile(const QCString &cmdName) +{ + int tok=doctokenizerYYlex(); + if (tok!=TK_WHITESPACE) + { + warn_doc_error(g_fileName,doctokenizerYYlineno,"expected whitespace after %s command", + qPrint(cmdName)); + return; + } + doctokenizerYYsetStateFile(); + tok=doctokenizerYYlex(); + doctokenizerYYsetStatePara(); + if (tok!=TK_WORD) + { + warn_doc_error(g_fileName,doctokenizerYYlineno,"unexpected token %s as the argument of %s", + tokToString(tok),qPrint(cmdName)); + return; + } + QCString name = g_token->name; + DocDiaFile *df = new DocDiaFile(this,name,g_context); + m_children.append(df); + df->parse(); +} + void DocPara::handleVhdlFlow() { DocVhdlFlow *vf = new DocVhdlFlow(this); @@ -5653,6 +5763,9 @@ int DocPara::handleCommand(const QCString &cmdName) case CMD_MSCFILE: handleMscFile(cmdName); break; + case CMD_DIAFILE: + handleDiaFile(cmdName); + break; case CMD_LINK: handleLink(cmdName,FALSE); break; diff --git a/src/docparser.h b/src/docparser.h index 6012db2..050c871 100644 --- a/src/docparser.h +++ b/src/docparser.h @@ -131,7 +131,8 @@ class DocNode Kind_MscFile = 48, Kind_HtmlBlockQuote = 49, Kind_VhdlFlow = 50, - Kind_ParBlock = 51 + Kind_ParBlock = 51, + Kind_DiaFile = 52 }; /*! Creates a new node */ DocNode() : m_parent(0), m_insidePre(FALSE) {} @@ -688,6 +689,30 @@ class DocMscFile : public CompAccept<DocMscFile>, public DocNode QCString m_context; }; +/** Node representing a dia file */ +class DocDiaFile : public CompAccept<DocDiaFile>, public DocNode +{ + public: + DocDiaFile(DocNode *parent,const QCString &name,const QCString &context); + void parse(); + Kind kind() const { return Kind_DiaFile; } + QCString name() const { return m_name; } + QCString file() const { return m_file; } + QCString relPath() const { return m_relPath; } + bool hasCaption() const { return !m_children.isEmpty(); } + QCString width() const { return m_width; } + QCString height() const { return m_height; } + QCString context() const { return m_context; } + void accept(DocVisitor *v) { CompAccept<DocDiaFile>::accept(this,v); } + private: + QCString m_name; + QCString m_file; + QCString m_relPath; + QCString m_width; + QCString m_height; + QCString m_context; +}; + /** Node representing a VHDL flow chart */ class DocVhdlFlow : public CompAccept<DocVhdlFlow>, public DocNode { @@ -1039,6 +1064,7 @@ class DocPara : public CompAccept<DocPara>, public DocNode void handleImage(const QCString &cmdName); void handleDotFile(const QCString &cmdName); void handleMscFile(const QCString &cmdName); + void handleDiaFile(const QCString &cmdName); void handleInclude(const QCString &cmdName,DocInclude::Type t); void handleLink(const QCString &cmdName,bool isJavaLink); void handleCite(); diff --git a/src/docvisitor.h b/src/docvisitor.h index 5caf414..d12295c 100644 --- a/src/docvisitor.h +++ b/src/docvisitor.h @@ -67,6 +67,7 @@ class DocHtmlHeader; class DocImage; class DocDotFile; class DocMscFile; +class DocDiaFile; class DocLink; class DocCite; class DocRef; @@ -166,6 +167,8 @@ class DocVisitor virtual void visitPost(DocDotFile *) = 0; virtual void visitPre(DocMscFile *) = 0; virtual void visitPost(DocMscFile *) = 0; + virtual void visitPre(DocDiaFile *) = 0; + virtual void visitPost(DocDiaFile *) = 0; virtual void visitPre(DocLink *) = 0; virtual void visitPost(DocLink *) = 0; virtual void visitPre(DocRef *) = 0; diff --git a/src/doxygen.cpp b/src/doxygen.cpp index 8473676..e766add 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -132,7 +132,8 @@ FileNameDict *Doxygen::includeNameDict = 0; // include names FileNameDict *Doxygen::exampleNameDict = 0; // examples FileNameDict *Doxygen::imageNameDict = 0; // images FileNameDict *Doxygen::dotFileNameDict = 0; // dot files -FileNameDict *Doxygen::mscFileNameDict = 0; // dot files +FileNameDict *Doxygen::mscFileNameDict = 0; // msc files +FileNameDict *Doxygen::diaFileNameDict = 0; // dia files StringDict Doxygen::namespaceAliasDict(257); // all namespace aliases StringDict Doxygen::tagDestinationDict(257); // all tag locations QDict<void> Doxygen::expandAsDefinedDict(257); // all macros that should be expanded @@ -196,6 +197,7 @@ void clearAll() Doxygen::imageNameDict->clear(); Doxygen::dotFileNameDict->clear(); Doxygen::mscFileNameDict->clear(); + Doxygen::diaFileNameDict->clear(); Doxygen::formulaDict->clear(); Doxygen::formulaNameDict->clear(); Doxygen::tagDestinationDict.clear(); @@ -262,6 +264,8 @@ void statistics() Doxygen::dotFileNameDict->statistics(); fprintf(stderr,"--- mscFileNameDict stats ----\n"); Doxygen::mscFileNameDict->statistics(); + fprintf(stderr,"--- diaFileNameDict stats ----\n"); + Doxygen::diaFileNameDict->statistics(); //fprintf(stderr,"--- g_excludeNameDict stats ----\n"); //g_excludeNameDict.statistics(); fprintf(stderr,"--- aliasDict stats ----\n"); @@ -9865,6 +9869,7 @@ void initDoxygen() Doxygen::imageNameDict->setAutoDelete(TRUE); Doxygen::dotFileNameDict = new FileNameDict(257); Doxygen::mscFileNameDict = new FileNameDict(257); + Doxygen::diaFileNameDict = new FileNameDict(257); Doxygen::memGrpInfoDict.setAutoDelete(TRUE); Doxygen::tagDestinationDict.setAutoDelete(TRUE); Doxygen::dirRelations.setAutoDelete(TRUE); @@ -9905,6 +9910,7 @@ void cleanUpDoxygen() delete Doxygen::imageNameDict; delete Doxygen::dotFileNameDict; delete Doxygen::mscFileNameDict; + delete Doxygen::diaFileNameDict; delete Doxygen::mainPage; delete Doxygen::pageSDict; delete Doxygen::exampleSDict; @@ -10546,6 +10552,18 @@ void searchInputFiles() } g_s.end(); + g_s.begin("Searching for dia files...\n"); + QStrList &diaFileList=Config_getList("DIAFILE_DIRS"); + s=diaFileList.first(); + while (s) + { + readFileOrDirectory(s,0,Doxygen::diaFileNameDict,0,0, + 0,0,0, + alwaysRecursive); + s=diaFileList.next(); + } + g_s.end(); + g_s.begin("Searching for files to exclude\n"); QStrList &excludeList = Config_getList("EXCLUDE"); s=excludeList.first(); diff --git a/src/doxygen.css b/src/doxygen.css index 2fa55fb..3c981f3 100644 --- a/src/doxygen.css +++ b/src/doxygen.css @@ -1069,6 +1069,11 @@ dl.section dd { text-align: center; } +.diagraph +{ + text-align: center; +} + .caption { font-weight: bold; diff --git a/src/doxygen.h b/src/doxygen.h index 4edf395..ff9c620 100644 --- a/src/doxygen.h +++ b/src/doxygen.h @@ -109,6 +109,7 @@ class Doxygen static FileNameDict *imageNameDict; static FileNameDict *dotFileNameDict; static FileNameDict *mscFileNameDict; + static FileNameDict *diaFileNameDict; static QStrList tagfileList; static MemberNameSDict *memberNameSDict; static MemberNameSDict *functionNameSDict; diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp index 8ee8c62..601b665 100644 --- a/src/htmldocvisitor.cpp +++ b/src/htmldocvisitor.cpp @@ -28,6 +28,7 @@ #include "htmlgen.h" #include "parserintf.h" #include "msc.h" +#include "dia.h" #include "util.h" #include "vhdldocgen.h" #include "filedef.h" @@ -1546,6 +1547,26 @@ void HtmlDocVisitor::visitPost(DocMscFile *df) m_t << "</div>" << endl; } +void HtmlDocVisitor::visitPre(DocDiaFile *df) +{ + if (m_hide) return; + m_t << "<div class=\"diagraph\">" << endl; + writeDiaFile(df->file(),df->relPath(),df->context()); + if (df->hasCaption()) + { + m_t << "<div class=\"caption\">" << endl; + } +} +void HtmlDocVisitor::visitPost(DocDiaFile *df) +{ + if (m_hide) return; + if (df->hasCaption()) + { + m_t << "</div>" << endl; + } + m_t << "</div>" << endl; +} + void HtmlDocVisitor::visitPre(DocLink *lnk) { if (m_hide) return; @@ -2011,6 +2032,27 @@ void HtmlDocVisitor::writeMscFile(const QCString &fileName, writeMscImageMapFromFile(m_t,fileName,outDir,relPath,baseName,context); } +void HtmlDocVisitor::writeDiaFile(const QCString &fileName, + const QCString &, + const QCString &) +{ + QCString baseName=fileName; + int i; + if ((i=baseName.findRev('/'))!=-1) // strip path + { + baseName=baseName.right(baseName.length()-i-1); + } + if ((i=baseName.find('.'))!=-1) // strip extension + { + baseName=baseName.left(i); + } + baseName.prepend("dia_"); + QCString outDir = Config_getString("HTML_OUTPUT"); + writeDiaGraphFromFile(fileName,outDir,baseName,DIA_BITMAP); + + m_t << "<img src=\"" << outDir << '/' << baseName << ".png" << "\" />" << endl; +} + /** Used for items found inside a paragraph, which due to XHTML restrictions * have to be outside of the paragraph. This method will forcefully end * the current paragraph and forceStartParagraph() will restart it. diff --git a/src/htmldocvisitor.h b/src/htmldocvisitor.h index f84ebb2..fd7c23a 100644 --- a/src/htmldocvisitor.h +++ b/src/htmldocvisitor.h @@ -108,6 +108,8 @@ class HtmlDocVisitor : public DocVisitor void visitPost(DocDotFile *); void visitPre(DocMscFile *); void visitPost(DocMscFile *); + void visitPre(DocDiaFile *); + void visitPost(DocDiaFile *); void visitPre(DocLink *); void visitPost(DocLink *); void visitPre(DocRef *); @@ -150,6 +152,7 @@ class HtmlDocVisitor : public DocVisitor void endLink(); void writeDotFile(const QCString &fileName,const QCString &relPath,const QCString &context); void writeMscFile(const QCString &fileName,const QCString &relPath,const QCString &context); + void writeDiaFile(const QCString &fileName,const QCString &relPath,const QCString &context); void pushEnabled(); void popEnabled(); diff --git a/src/latexdocvisitor.cpp b/src/latexdocvisitor.cpp index e9cf23a..e68a51b 100644 --- a/src/latexdocvisitor.cpp +++ b/src/latexdocvisitor.cpp @@ -27,6 +27,7 @@ #include "message.h" #include "parserintf.h" #include "msc.h" +#include "dia.h" #include "cite.h" #include "filedef.h" #include "config.h" @@ -1255,6 +1256,18 @@ void LatexDocVisitor::visitPost(DocMscFile *df) if (m_hide) return; endMscFile(df->hasCaption()); } + +void LatexDocVisitor::visitPre(DocDiaFile *df) +{ + if (m_hide) return; + startDiaFile(df->file(),df->width(),df->height(),df->hasCaption()); +} + +void LatexDocVisitor::visitPost(DocDiaFile *df) +{ + if (m_hide) return; + endDiaFile(df->hasCaption()); +} void LatexDocVisitor::visitPre(DocLink *lnk) { if (m_hide) return; @@ -1813,3 +1826,94 @@ void LatexDocVisitor::writeMscFile(const QCString &baseName) m_t << "\\end{DoxyImageNoCaption}\n"; } +void LatexDocVisitor::startDiaFile(const QCString &fileName, + const QCString &width, + const QCString &height, + bool hasCaption + ) +{ + QCString baseName=fileName; + int i; + if ((i=baseName.findRev('/'))!=-1) + { + baseName=baseName.right(baseName.length()-i-1); + } + if ((i=baseName.find('.'))!=-1) + { + baseName=baseName.left(i); + } + baseName.prepend("dia_"); + + QCString outDir = Config_getString("LATEX_OUTPUT"); + writeDiaGraphFromFile(fileName,outDir,baseName,DIA_EPS); + if (hasCaption) + { + m_t << "\n\\begin{DoxyImage}\n"; + } + else + { + m_t << "\n\\begin{DoxyImageNoCaption}\n" + " \\mbox{"; + } + m_t << "\\includegraphics"; + if (!width.isEmpty()) + { + m_t << "[width=" << width << "]"; + } + else if (!height.isEmpty()) + { + m_t << "[height=" << height << "]"; + } + else + { + m_t << "[width=\\textwidth,height=\\textheight/2,keepaspectratio=true]"; + } + m_t << "{" << baseName; + //if (Config_getBool("USE_PDFLATEX")) + //{ + // m_t << ".pdf"; + //} + //else + //{ + // m_t << ".eps"; + //} + m_t << "}"; + + if (hasCaption) + { + m_t << "\n\\caption{"; + } +} + +void LatexDocVisitor::endDiaFile(bool hasCaption) +{ + if (m_hide) return; + m_t << "}\n"; // end caption or mbox + if (hasCaption) + { + m_t << "\\end{DoxyImage}\n"; + } + else + { + m_t << "\\end{DoxyImageNoCaption}\n"; + } +} + + +void LatexDocVisitor::writeDiaFile(const QCString &baseName) +{ + QCString shortName = baseName; + int i; + if ((i=shortName.findRev('/'))!=-1) + { + shortName=shortName.right(shortName.length()-i-1); + } + QCString outDir = Config_getString("LATEX_OUTPUT"); + writeDiaGraphFromFile(baseName+".dia",outDir,shortName,DIA_EPS); + m_t << "\n\\begin{DoxyImageNoCaption}" + " \\mbox{\\includegraphics"; + m_t << "{" << shortName << "}"; + m_t << "}\n"; // end mbox + m_t << "\\end{DoxyImageNoCaption}\n"; +} + diff --git a/src/latexdocvisitor.h b/src/latexdocvisitor.h index 13217cf..4073b7f 100644 --- a/src/latexdocvisitor.h +++ b/src/latexdocvisitor.h @@ -110,6 +110,8 @@ class LatexDocVisitor : public DocVisitor void visitPost(DocDotFile *); void visitPre(DocMscFile *); void visitPost(DocMscFile *); + void visitPre(DocDiaFile *); + void visitPost(DocDiaFile *); void visitPre(DocLink *lnk); void visitPost(DocLink *); void visitPre(DocRef *ref); @@ -170,6 +172,11 @@ class LatexDocVisitor : public DocVisitor void endMscFile(bool hasCaption); void writeMscFile(const QCString &fileName); + void startDiaFile(const QCString &fileName,const QCString &width, + const QCString &height, bool hasCaption); + void endDiaFile(bool hasCaption); + void writeDiaFile(const QCString &fileName); + void pushEnabled(); void popEnabled(); diff --git a/src/libdoxygen.pro.in b/src/libdoxygen.pro.in index 4879d07..393f72d 100644 --- a/src/libdoxygen.pro.in +++ b/src/libdoxygen.pro.in @@ -93,6 +93,7 @@ HEADERS = arguments.h \ membername.h \ message.h \ msc.h \ + dia.h \ namespacedef.h \ navtree.css.h \ navtree.js.h \ @@ -204,6 +205,7 @@ SOURCES = arguments.cpp \ membername.cpp \ message.cpp \ msc.cpp \ + dia.cpp \ namespacedef.cpp \ objcache.cpp \ outputgen.cpp \ diff --git a/src/mandocvisitor.cpp b/src/mandocvisitor.cpp index 8ff7f54..238233c 100644 --- a/src/mandocvisitor.cpp +++ b/src/mandocvisitor.cpp @@ -775,6 +775,13 @@ void ManDocVisitor::visitPost(DocMscFile *) { } +void ManDocVisitor::visitPre(DocDiaFile *) +{ +} + +void ManDocVisitor::visitPost(DocDiaFile *) +{ +} void ManDocVisitor::visitPre(DocLink *) { diff --git a/src/mandocvisitor.h b/src/mandocvisitor.h index e34add2..7012152 100644 --- a/src/mandocvisitor.h +++ b/src/mandocvisitor.h @@ -107,6 +107,8 @@ class ManDocVisitor : public DocVisitor void visitPost(DocDotFile *); void visitPre(DocMscFile *); void visitPost(DocMscFile *); + void visitPre(DocDiaFile *); + void visitPost(DocDiaFile *); void visitPre(DocLink *lnk); void visitPost(DocLink *); void visitPre(DocRef *ref); diff --git a/src/msc.cpp b/src/msc.cpp index 91b1d05..069bcdd 100644 --- a/src/msc.cpp +++ b/src/msc.cpp @@ -22,13 +22,13 @@ #include "docparser.h" #include "doxygen.h" #include "util.h" +#include "ftextstream.h" -#include <qtextstream.h> #include <qdir.h> static const int maxCmdLine = 40960; -static bool convertMapFile(QTextStream &t,const char *mapName,const QCString relPath, +static bool convertMapFile(FTextStream &t,const char *mapName,const QCString relPath, const QCString &context) { QFile f(mapName); @@ -175,8 +175,8 @@ QCString getMscImageMapFromFile(const QCString& inFile, const QCString& outDir, } portable_sysTimerStop(); - QString result; - QTextOStream tmpout(&result); + QGString result; + FTextStream tmpout(&result); convertMapFile(tmpout, outFile, relPath, context); QDir().remove(outFile); diff --git a/src/perlmodgen.cpp b/src/perlmodgen.cpp index 4f555ce..81e41a8 100644 --- a/src/perlmodgen.cpp +++ b/src/perlmodgen.cpp @@ -364,6 +364,8 @@ public: void visitPost(DocDotFile *); void visitPre(DocMscFile *); void visitPost(DocMscFile *); + void visitPre(DocDiaFile *); + void visitPost(DocDiaFile *); void visitPre(DocLink *); void visitPost(DocLink *); void visitPre(DocRef *); @@ -1209,6 +1211,20 @@ void PerlModDocVisitor::visitPost(DocMscFile *) #endif } +void PerlModDocVisitor::visitPre(DocDiaFile *) +{ +#if 0 + m_output.add("<diafile name=\""); m_output.add(df->file()); m_output.add("\">"); +#endif +} + +void PerlModDocVisitor::visitPost(DocDiaFile *) +{ +#if 0 + m_output.add("</diafile>"); +#endif +} + void PerlModDocVisitor::visitPre(DocLink *lnk) { diff --git a/src/printdocvisitor.h b/src/printdocvisitor.h index 765a835..37929fc 100644 --- a/src/printdocvisitor.h +++ b/src/printdocvisitor.h @@ -597,6 +597,16 @@ class PrintDocVisitor : public DocVisitor indent_post(); printf("</mscfile>\n"); } + void visitPre(DocDiaFile *df) + { + indent_pre(); + printf("<diafile src=\"%s\">\n",df->name().data()); + } + void visitPost(DocDiaFile *) + { + indent_post(); + printf("</diafile>\n"); + } void visitPre(DocLink *lnk) { indent_pre(); diff --git a/src/rtfdocvisitor.cpp b/src/rtfdocvisitor.cpp index 3cf6a5e..5d73c57 100644 --- a/src/rtfdocvisitor.cpp +++ b/src/rtfdocvisitor.cpp @@ -29,6 +29,7 @@ #include <qfileinfo.h> #include "parserintf.h" #include "msc.h" +#include "dia.h" #include "filedef.h" #include "config.h" @@ -1245,6 +1246,22 @@ void RTFDocVisitor::visitPost(DocMscFile *) popEnabled(); } +void RTFDocVisitor::visitPre(DocDiaFile *df) +{ + DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocDiaFile)}\n"); + writeDiaFile(df->file()); + + // hide caption since it is not supported at the moment + pushEnabled(); + m_hide=TRUE; +} + +void RTFDocVisitor::visitPost(DocDiaFile *) +{ + DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocDiaFile)}\n"); + popEnabled(); +} + void RTFDocVisitor::visitPre(DocLink *lnk) { if (m_hide) return; @@ -1846,3 +1863,23 @@ void RTFDocVisitor::writeMscFile(const QCString &fileName) m_lastIsPara=TRUE; } +void RTFDocVisitor::writeDiaFile(const QCString &fileName) +{ + QCString baseName=fileName; + int i; + if ((i=baseName.findRev('/'))!=-1) + { + baseName=baseName.right(baseName.length()-i-1); + } + QCString outDir = Config_getString("RTF_OUTPUT"); + writeDiaGraphFromFile(fileName+".dia",outDir,baseName,DIA_BITMAP); + if (!m_lastIsPara) m_t << "\\par" << endl; + m_t << "{" << endl; + m_t << rtf_Style_Reset; + m_t << "\\pard \\qc {\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \""; + m_t << baseName << ".png"; + m_t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par" << endl; + m_t << "}" << endl; + m_lastIsPara=TRUE; +} + diff --git a/src/rtfdocvisitor.h b/src/rtfdocvisitor.h index 243268b..9572b73 100644 --- a/src/rtfdocvisitor.h +++ b/src/rtfdocvisitor.h @@ -107,6 +107,8 @@ class RTFDocVisitor : public DocVisitor void visitPost(DocDotFile *); void visitPre(DocMscFile *); void visitPost(DocMscFile *); + void visitPre(DocDiaFile *); + void visitPost(DocDiaFile *); void visitPre(DocLink *); void visitPost(DocLink *); void visitPre(DocRef *ref); @@ -152,6 +154,7 @@ class RTFDocVisitor : public DocVisitor void popEnabled(); void writeDotFile(const QCString &fileName); void writeMscFile(const QCString &fileName); + void writeDiaFile(const QCString &fileName); //-------------------------------------- // state variables diff --git a/src/textdocvisitor.h b/src/textdocvisitor.h index 743f69a..9045d21 100644 --- a/src/textdocvisitor.h +++ b/src/textdocvisitor.h @@ -106,6 +106,8 @@ class TextDocVisitor : public DocVisitor void visitPre(DocMscFile *) {} void visitPost(DocMscFile *) {} + void visitPre(DocDiaFile *) {} + void visitPost(DocDiaFile *) {} void visitPre(DocLink *) {} void visitPost(DocLink *) {} void visitPre(DocRef *) {} diff --git a/src/xmldocvisitor.cpp b/src/xmldocvisitor.cpp index 0c4b4d2..e38a204 100644 --- a/src/xmldocvisitor.cpp +++ b/src/xmldocvisitor.cpp @@ -836,6 +836,19 @@ void XmlDocVisitor::visitPost(DocMscFile *) if (m_hide) return; m_t << "</mscfile>" << endl; } + +void XmlDocVisitor::visitPre(DocDiaFile *df) +{ + if (m_hide) return; + m_t << "<diafile name=\"" << df->file() << "\">"; +} + +void XmlDocVisitor::visitPost(DocDiaFile *) +{ + if (m_hide) return; + m_t << "</diafile>" << endl; +} + void XmlDocVisitor::visitPre(DocLink *lnk) { if (m_hide) return; diff --git a/src/xmldocvisitor.h b/src/xmldocvisitor.h index 0d0eac9..6dc189c 100644 --- a/src/xmldocvisitor.h +++ b/src/xmldocvisitor.h @@ -109,6 +109,8 @@ class XmlDocVisitor : public DocVisitor void visitPre(DocMscFile *); void visitPost(DocMscFile *); + void visitPre(DocDiaFile *); + void visitPost(DocDiaFile *); void visitPre(DocLink *); void visitPost(DocLink *); void visitPre(DocRef *); |