Commit 4fc5b2b1 authored by Dimitri van Heesch's avatar Dimitri van Heesch

Bug 707713 - Add support for dia diagrams

parent 983507e0
......@@ -65,6 +65,7 @@ documentation:
\refitem cmddefgroup \\defgroup
\refitem cmddeprecated \\deprecated
\refitem cmddetails \\details
\refitem cmddiafile \\diafile
\refitem cmddir \\dir
\refitem cmddocbookonly \\docbookonly
\refitem cmddontinclude \\dontinclude
......@@ -2517,6 +2518,24 @@ class Receiver
\sa section \ref cmdmsc "\\msc".
<hr>
\section cmddiafile \\diafile <file> ["caption"]
\addindex \\diafile
Inserts an image made in dia from \<file\> into the documentation.
The first argument specifies the file name of the image.
doxygen will look for files in the paths (or files) that you specified
after the \ref cfg_diafile_dirs "DIAFILE_DIRS" tag.
If the dia file is found it will be used as an input file dia.
The resulting image will be put into the correct output directory.
If the dia file name contains spaces you'll have to put quotes ("...") around it.
The second argument is optional and can be used to specify the caption
that is displayed below the image. This argument has to be specified
between quotes even if it does not contain any spaces. The quotes are
stripped before the caption is displayed.
<hr>
\section cmde \\e <word>
......
......@@ -88,6 +88,8 @@ followed by the descriptions of the tags grouped by category.
\refitem cfg_compact_rtf COMPACT_RTF
\refitem cfg_cpp_cli_support CPP_CLI_SUPPORT
\refitem cfg_create_subdirs CREATE_SUBDIRS
\refitem cfg_dia_path DIA_PATH
\refitem cfg_diafile_dirs DIAFILE_DIRS
\refitem cfg_directory_graph DIRECTORY_GRAPH
\refitem cfg_disable_index DISABLE_INDEX
\refitem cfg_distribute_group_doc DISTRIBUTE_GROUP_DOC
......@@ -3306,6 +3308,14 @@ The default value is: <code>YES</code>.
specify the directory where the \c mscgen tool resides. If left empty the tool is assumed to
be found in the default search path.
\anchor cfg_dia_path
<dt>\c DIA_PATH <dd>
\addindex DIA_PATH
You can include diagrams drawn in dia using the \ref cmddiafile "\\diafile" command.
Doxygen will run dia to produce the appropriate image and insert it in the documentation.
The <code>DIA_PATH</code> tag allows you to specify the directory where the \c dia
binary resides. If left empty the tool is assumed to be found in the default search path.
\anchor cfg_hide_undoc_relations
<dt>\c HIDE_UNDOC_RELATIONS <dd>
\addindex HIDE_UNDOC_RELATIONS
......@@ -3592,6 +3602,13 @@ This tag requires that the tag \ref cfg_have_dot "HAVE_DOT" is set to \c YES.
contain msc files that are included in the documentation (see the
\ref cmdmscfile "\\mscfile" command).
\anchor cfg_diafile_dirs
<dt>\c DIAFILE_DIRS <dd>
\addindex DIAFILE_DIRS
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 cmddiafile "\\diafile" command).
\anchor cfg_dot_graph_max_nodes
<dt>\c DOT_GRAPH_MAX_NODES <dd>
\addindex DOT_GRAPH_MAX_NODES
......
......@@ -134,6 +134,7 @@ CommandMap cmdMap[] =
{ "endinternal", CMD_ENDINTERNAL },
{ "parblock", CMD_PARBLOCK },
{ "endparblock", CMD_ENDPARBLOCK },
{ "diafile", CMD_DIAFILE },
{ 0, 0 },
};
......
......@@ -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
......
......@@ -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>
......
......@@ -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)
......
......@@ -3009,6 +3009,16 @@ where `loc1` and `loc2` can be relative or absolute paths or URLs.
produce the chart and insert it in the documentation. The <code>MSCGEN_PATH</code> tag allows you to
specify the directory where the \c mscgen tool resides. If left empty the tool is assumed to
be found in the default search path.
]]>
</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>
......@@ -3243,6 +3253,15 @@ where `loc1` and `loc2` can be relative or absolute paths or URLs.
The \c MSCFILE_DIRS tag can be used to specify one or more directories that
contain msc files that are included in the documentation (see the
\ref cmdmscfile "\\mscfile" command).
]]>
</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>
......
/******************************************************************************
*
*
*
* 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);
}
/******************************************************************************
*
*
*
* 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
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
......@@ -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();
......
......@@ -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;
......
......@@ -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();
......
......@@ -1069,6 +1069,11 @@ dl.section dd {
text-align: center;
}
.diagraph
{
text-align: center;
}
.caption
{
font-weight: bold;
......
......@@ -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;
......
......@@ -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.
......
......@@ -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();
......
......@@ -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";
}
......@@ -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();
......
......@@ -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 \
......
......@@ -775,6 +775,13 @@ void ManDocVisitor::visitPost(DocMscFile *)
{
}
void ManDocVisitor::visitPre(DocDiaFile *)
{
}
void ManDocVisitor::visitPost(DocDiaFile *)
{
}
void ManDocVisitor::visitPre(DocLink *)
{
......
......@@ -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);
......
......@@ -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);
......
......@@ -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)
{
......
......@@ -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();
......
......@@ -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;
}
......@@ -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
......
......@@ -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 *) {}
......
......@@ -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;
......
......@@ -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 *);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment