summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2019-01-08 21:00:16 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2019-01-08 21:00:16 (GMT)
commit16f12f29ef44cbab308c2a950bac68c0cd84fdf2 (patch)
treec7eb52e0614a2048aa7020494d6e2acec6f94a6e /src
parent6f39d4eea2d703e534992b72e2dd939abde45b33 (diff)
parent5021481aac33e51a4d94f4fea0fc745b4cbc8004 (diff)
downloadDoxygen-16f12f29ef44cbab308c2a950bac68c0cd84fdf2.zip
Doxygen-16f12f29ef44cbab308c2a950bac68c0cd84fdf2.tar.gz
Doxygen-16f12f29ef44cbab308c2a950bac68c0cd84fdf2.tar.bz2
Merge branch 'cheoljoo-run_java_once_3rd_trial'
Diffstat (limited to 'src')
-rw-r--r--src/debug.cpp1
-rw-r--r--src/debug.h3
-rw-r--r--src/docbookvisitor.cpp4
-rw-r--r--src/doxygen.cpp5
-rw-r--r--src/htmldocvisitor.cpp13
-rw-r--r--src/latexdocvisitor.cpp4
-rw-r--r--src/plantuml.cpp397
-rw-r--r--src/plantuml.h65
-rw-r--r--src/rtfdocvisitor.cpp4
-rw-r--r--src/vhdldocgen.cpp4
10 files changed, 417 insertions, 83 deletions
diff --git a/src/debug.cpp b/src/debug.cpp
index c81a1af..2f343ac 100644
--- a/src/debug.cpp
+++ b/src/debug.cpp
@@ -48,6 +48,7 @@ static LabelMap s_labels[] =
{ "markdown", Debug::Markdown },
{ "filteroutput", Debug::FilterOutput },
{ "lex", Debug::Lex },
+ { "plantuml", Debug::Plantuml },
{ 0, (Debug::DebugMask)0 }
};
diff --git a/src/debug.h b/src/debug.h
index 8a28c7a..9a2070c 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -37,7 +37,8 @@ class Debug
ExtCmd = 0x00000400,
Markdown = 0x00000800,
FilterOutput = 0x00001000,
- Lex = 0x00002000
+ Lex = 0x00002000,
+ Plantuml = 0x00004000
};
static void print(DebugMask mask,int prio,const char *fmt,...);
static int setFlag(const char *label);
diff --git a/src/docbookvisitor.cpp b/src/docbookvisitor.cpp
index 99df99c..3988390 100644
--- a/src/docbookvisitor.cpp
+++ b/src/docbookvisitor.cpp
@@ -353,7 +353,7 @@ DB_VIS_C
case DocVerbatim::PlantUML:
{
static QCString docbookOutput = Config_getString(DOCBOOK_OUTPUT);
- QCString baseName = writePlantUMLSource(docbookOutput,s->exampleFile(),s->text());
+ QCString baseName = PlantumlManager::instance()->writePlantUMLSource(docbookOutput,s->exampleFile(),s->text(),PlantumlManager::PUML_BITMAP);
QCString shortName = baseName;
int i;
if ((i=shortName.findRev('/'))!=-1)
@@ -1642,7 +1642,7 @@ DB_VIS_C
shortName=shortName.right(shortName.length()-i-1);
}
QCString outDir = Config_getString(DOCBOOK_OUTPUT);
- generatePlantUMLOutput(baseName,outDir,PUML_BITMAP);
+ PlantumlManager::instance()->generatePlantUMLOutput(baseName,outDir,PlantumlManager::PUML_BITMAP);
visitPreStart(m_t, s->children(), s->hasCaption(), s->relPath() + shortName + ".png", s->width(),s->height());
visitCaption(s->children());
visitPostEnd(m_t, s->hasCaption());
diff --git a/src/doxygen.cpp b/src/doxygen.cpp
index 2d55ae6..26f7637 100644
--- a/src/doxygen.cpp
+++ b/src/doxygen.cpp
@@ -104,6 +104,7 @@
#include "context.h"
#include "fileparser.h"
#include "emoji.h"
+#include "plantuml.h"
// provided by the generated file resources.cpp
extern void initResources();
@@ -11924,6 +11925,10 @@ void generateOutput()
g_s.end();
}
+ g_s.begin("Running plantuml with JAVA...\n");
+ PlantumlManager::instance()->run();
+ g_s.end();
+
if (Config_getBool(HAVE_DOT))
{
g_s.begin("Running dot...\n");
diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp
index 9f9e653..25166bc 100644
--- a/src/htmldocvisitor.cpp
+++ b/src/htmldocvisitor.cpp
@@ -591,9 +591,14 @@ void HtmlDocVisitor::visit(DocVerbatim *s)
case DocVerbatim::PlantUML:
{
forceEndParagraph(s);
-
static QCString htmlOutput = Config_getString(HTML_OUTPUT);
- QCString baseName = writePlantUMLSource(htmlOutput,s->exampleFile(),s->text());
+ QCString imgExt = getDotImageExtension();
+ PlantumlManager::OutputFormat format = PlantumlManager::PUML_BITMAP; // default : PUML_BITMAP
+ if (imgExt=="svg")
+ {
+ format = PlantumlManager::PUML_SVG;
+ }
+ QCString baseName = PlantumlManager::instance()->writePlantUMLSource(htmlOutput,s->exampleFile(),s->text(),format);
m_t << "<div class=\"plantumlgraph\">" << endl;
writePlantUMLFile(baseName,s->relPath(),s->context());
visitPreCaption(m_t, s);
@@ -2305,7 +2310,7 @@ void HtmlDocVisitor::writePlantUMLFile(const QCString &fileName,
QCString imgExt = getDotImageExtension();
if (imgExt=="svg")
{
- generatePlantUMLOutput(fileName,outDir,PUML_SVG);
+ PlantumlManager::instance()->generatePlantUMLOutput(fileName,outDir,PlantumlManager::PUML_SVG);
//m_t << "<iframe scrolling=\"no\" frameborder=\"0\" src=\"" << relPath << baseName << ".svg" << "\" />" << endl;
//m_t << "<p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p>";
//m_t << "</iframe>" << endl;
@@ -2313,7 +2318,7 @@ void HtmlDocVisitor::writePlantUMLFile(const QCString &fileName,
}
else
{
- generatePlantUMLOutput(fileName,outDir,PUML_BITMAP);
+ PlantumlManager::instance()->generatePlantUMLOutput(fileName,outDir,PlantumlManager::PUML_BITMAP);
m_t << "<img src=\"" << relPath << baseName << ".png" << "\" />" << endl;
}
}
diff --git a/src/latexdocvisitor.cpp b/src/latexdocvisitor.cpp
index 98324e3..463eedf 100644
--- a/src/latexdocvisitor.cpp
+++ b/src/latexdocvisitor.cpp
@@ -428,7 +428,7 @@ void LatexDocVisitor::visit(DocVerbatim *s)
case DocVerbatim::PlantUML:
{
QCString latexOutput = Config_getString(LATEX_OUTPUT);
- QCString baseName = writePlantUMLSource(latexOutput,s->exampleFile(),s->text());
+ QCString baseName = PlantumlManager::instance()->writePlantUMLSource(latexOutput,s->exampleFile(),s->text(),PlantumlManager::PUML_EPS);
writePlantUMLFile(baseName, s);
}
@@ -1927,7 +1927,7 @@ void LatexDocVisitor::writePlantUMLFile(const QCString &baseName, DocVerbatim *s
shortName=shortName.right(shortName.length()-i-1);
}
QCString outDir = Config_getString(LATEX_OUTPUT);
- generatePlantUMLOutput(baseName,outDir,PUML_EPS);
+ PlantumlManager::instance()->generatePlantUMLOutput(baseName,outDir,PlantumlManager::PUML_EPS);
visitPreStart(m_t, s->hasCaption(), shortName, s->width(), s->height());
visitCaption(this, s->children());
visitPostEnd(m_t, s->hasCaption());
diff --git a/src/plantuml.cpp b/src/plantuml.cpp
index ada035b..6966100 100644
--- a/src/plantuml.cpp
+++ b/src/plantuml.cpp
@@ -14,23 +14,32 @@
*/
#include "plantuml.h"
+#include "util.h"
#include "portable.h"
#include "config.h"
#include "doxygen.h"
#include "index.h"
#include "message.h"
+#include "debug.h"
#include <qdir.h>
+#include <qdict.h>
+#include <qlist.h>
-static const int maxCmdLine = 40960;
-QCString writePlantUMLSource(const QCString &outDir,const QCString &fileName,const QCString &content)
+QCString PlantumlManager::writePlantUMLSource(const QCString &outDir,const QCString &fileName,const QCString &content,OutputFormat format)
{
- QCString baseName(4096);
+ QCString baseName;
+ QCString puName;
+ QCString imgName;
static int umlindex=1;
+ Debug::print(Debug::Plantuml,0,"*** %s fileName: %s\n","writePlantUMLSource",qPrint(fileName));
+ Debug::print(Debug::Plantuml,0,"*** %s outDir: %s\n","writePlantUMLSource",qPrint(outDir));
+
if (fileName.isEmpty()) // generate name
{
+ puName = "inline_umlgraph_"+QCString().setNum(umlindex);
baseName = outDir+"/inline_umlgraph_"+QCString().setNum(umlindex++);
}
else // user specified name
@@ -38,29 +47,158 @@ QCString writePlantUMLSource(const QCString &outDir,const QCString &fileName,con
baseName = fileName;
int i=baseName.findRev('.');
if (i!=-1) baseName = baseName.left(i);
+ puName = baseName;
baseName.prepend(outDir+"/");
}
- QFile file(baseName+".pu");
- if (!file.open(IO_WriteOnly))
+
+ switch (format)
{
- err("Could not open file %s for writing\n",baseName.data());
+ case PUML_BITMAP:
+ imgName =puName+".png";
+ break;
+ case PUML_EPS:
+ imgName =puName+".eps";
+ break;
+ case PUML_SVG:
+ imgName =puName+".svg";
+ break;
}
- QCString text = "@startuml\n";
+
+ Debug::print(Debug::Plantuml,0,"*** %s baseName: %s\n","writePlantUMLSource",qPrint(baseName));
+ Debug::print(Debug::Plantuml,0,"*** %s puName: %s\n","writePlantUMLSource",qPrint(puName));
+ Debug::print(Debug::Plantuml,0,"*** %s imgName: %s\n","writePlantUMLSource",qPrint(imgName));
+
+ QCString text = "@startuml "+imgName+"\n";
text+=content;
text+="\n@enduml\n";
- file.writeBlock( text, text.length() );
- file.close();
+
+ QCString qcOutDir(outDir);
+ uint pos = qcOutDir.findRev("/");
+ QCString generateType(qcOutDir.right(qcOutDir.length() - (pos + 1)) );
+ Debug::print(Debug::Plantuml,0,"*** %s generateType: %s\n","writePlantUMLSource",qPrint(generateType));
+ PlantumlManager::instance()->insert(generateType,puName,format,text);
+ Debug::print(Debug::Plantuml,0,"*** %s generateType: %s\n","writePlantUMLSource",qPrint(generateType));
+
return baseName;
}
-void generatePlantUMLOutput(const char *baseName,const char *outDir,PlantUMLOutputFormat format)
+void PlantumlManager::generatePlantUMLOutput(const char *baseName,const char *outDir,OutputFormat format)
+{
+ QCString plantumlJarPath = Config_getString(PLANTUML_JAR_PATH);
+ QCString plantumlConfigFile = Config_getString(PLANTUML_CFG_FILE);
+ QCString dotPath = Config_getString(DOT_PATH);
+
+ QCString imgName = baseName;
+ // The basename contains path, we need to strip the path from the filename in order
+ // to create the image file name which should be included in the index.qhp (Qt help index file).
+ int i;
+ if ((i=imgName.findRev('/'))!=-1) // strip path
+ {
+ imgName=imgName.right(imgName.length()-i-1);
+ }
+ switch (format)
+ {
+ case PUML_BITMAP:
+ imgName+=".png";
+ break;
+ case PUML_EPS:
+ imgName+=".eps";
+ break;
+ case PUML_SVG:
+ imgName+=".svg";
+ break;
+ }
+
+ Doxygen::indexList->addImageFile(imgName);
+}
+
+//--------------------------------------------------------------------
+
+PlantumlManager *PlantumlManager::m_theInstance = 0;
+
+PlantumlManager *PlantumlManager::instance()
+{
+ if (!m_theInstance)
+ {
+ m_theInstance = new PlantumlManager;
+ QCString outputFilename = Config_getString(OUTPUT_DIRECTORY) + "/" + CACHE_FILENAME;
+ QFileInfo fi(outputFilename);
+ if (fi.exists())
+ {
+ m_theInstance->m_cachedPlantumlAllContent = fileToString(outputFilename);
+ }
+ else
+ {
+ m_theInstance->m_cachedPlantumlAllContent = "";
+ }
+ Debug::print(Debug::Plantuml,0,"*** instance() : m_cachedPlantumlAllContent = [%s]\n",qPrint(m_theInstance->m_cachedPlantumlAllContent));
+ m_theInstance->m_pngPlantumlContent.clear();
+ m_theInstance->m_svgPlantumlContent.clear();
+ m_theInstance->m_epsPlantumlContent.clear();
+ }
+ return m_theInstance;
+}
+
+PlantumlManager::PlantumlManager()
{
- static QCString plantumlJarPath = Config_getString(PLANTUML_JAR_PATH);
- static QCString plantumlConfigFile = Config_getString(PLANTUML_CFG_FILE);
- static QCString dotPath = Config_getString(DOT_PATH);
+}
+
+PlantumlManager::~PlantumlManager()
+{
+ {
+ QDictIterator< QList<QCString> > it( m_pngPlantumlFiles); // See QDictIterator
+ QList<QCString> *list;
+ for (it.toFirst();(list=it.current());++it)
+ {
+ (*list).clear();
+ }
+ m_pngPlantumlFiles.clear();
+ m_pngPlantumlContent.clear();
+ }
+ {
+ QDictIterator< QList<QCString> > it( m_epsPlantumlFiles); // See QDictIterator
+ QList<QCString> *list;
+ for (it.toFirst();(list=it.current());++it)
+ {
+ (*list).clear();
+ }
+ m_epsPlantumlFiles.clear();
+ m_epsPlantumlContent.clear();
+ }
+ {
+ QDictIterator< QList<QCString> > it( m_svgPlantumlFiles); // See QDictIterator
+ QList<QCString> *list;
+ for (it.toFirst();(list=it.current());++it)
+ {
+ (*list).clear();
+ }
+ m_svgPlantumlFiles.clear();
+ m_svgPlantumlContent.clear();
+ }
+}
+
+static void runPlantumlContent(const QDict< QList <QCString> > &plantumlFiles,
+ const QDict< QCString > &plantumlContent,
+ PlantumlManager::OutputFormat format)
+{
+ /* example : running: java -Djava.awt.headless=true
+ -jar "/usr/local/bin/plantuml.jar"
+ -o "test_doxygen/DOXYGEN_OUTPUT/html"
+ -tpng
+ "test_doxygen/DOXYGEN_OUTPUT/html/A.pu"
+ -charset UTF-8
+ outDir:test_doxygen/DOXYGEN_OUTPUT/html
+ test_doxygen/DOXYGEN_OUTPUT/html/A
+ */
+ int exitCode;
+ QCString plantumlJarPath = Config_getString(PLANTUML_JAR_PATH);
+ QCString plantumlConfigFile = Config_getString(PLANTUML_CFG_FILE);
+ QCString dotPath = Config_getString(DOT_PATH);
QCString pumlExe = "java";
QCString pumlArgs = "";
+ QCString pumlType = "";
+ QCString pumlOutDir = "";
QStrList &pumlIncludePathList = Config_getList(PLANTUML_INCLUDE_PATH);
char *s=pumlIncludePathList.first();
@@ -92,61 +230,210 @@ void generatePlantUMLOutput(const char *baseName,const char *outDir,PlantUMLOutp
pumlArgs += portable_commandExtension();
pumlArgs += "\" ";
}
- pumlArgs+="-o \"";
- pumlArgs+=outDir;
- pumlArgs+="\" ";
- QCString imgName = baseName;
- // The basename contains path, we need to strip the path from the filename in order
- // to create the image file name which should be included in the index.qhp (Qt help index file).
- int i;
- if ((i=imgName.findRev('/'))!=-1) // strip path
- {
- imgName=imgName.right(imgName.length()-i-1);
- }
switch (format)
{
- case PUML_BITMAP:
- pumlArgs+="-tpng";
- imgName+=".png";
+ case PlantumlManager::PUML_BITMAP:
+ pumlType="png";
break;
- case PUML_EPS:
- pumlArgs+="-teps";
- imgName+=".eps";
+ case PlantumlManager::PUML_EPS:
+ pumlType="eps";
break;
- case PUML_SVG:
- pumlArgs+="-tsvg";
- imgName+=".svg";
+ case PlantumlManager::PUML_SVG:
+ pumlType="svg";
break;
}
- pumlArgs+=" \"";
- pumlArgs+=baseName;
- pumlArgs+=".pu\" ";
- pumlArgs+="-charset UTF-8 ";
- int exitCode;
- //printf("*** running: %s %s outDir:%s %s\n",pumlExe.data(),pumlArgs.data(),outDir,baseName);
- msg("Running PlantUML on generated file %s.pu\n",baseName);
- portable_sysTimerStart();
- if ((exitCode=portable_system(pumlExe,pumlArgs,TRUE))!=0)
+
{
- err("Problems running PlantUML. Verify that the command 'java -jar \"%splantuml.jar\" -h' works from the command line. Exit code: %d\n",
- plantumlJarPath.data(),exitCode);
+ QDictIterator< QCString > it( plantumlContent); // See QDictIterator
+ QCString *nb;
+ for (it.toFirst();(nb=it.current());++it)
+ {
+ QCString pumlArguments(pumlArgs);
+ msg("Generating PlantUML %s Files in %s\n",qPrint(pumlType),qPrint(it.currentKey()));
+ pumlArguments+="-o \"";
+ pumlArguments+=Config_getString(OUTPUT_DIRECTORY);
+ pumlArguments+="/";
+ pumlArguments+=it.currentKey();
+ pumlArguments+="\" ";
+ pumlArguments+="-charset UTF-8 -t";
+ pumlArguments+=pumlType;
+ pumlArguments+=" ";
+
+ QCString puFileName("");
+ puFileName+=Config_getString(OUTPUT_DIRECTORY);
+ puFileName+="/";
+ puFileName+=it.currentKey();
+ puFileName+="/";
+ pumlOutDir=puFileName;
+ puFileName+="inline_umlgraph_";
+ puFileName+=pumlType;
+ puFileName+=it.currentKey();
+ puFileName+=".pu";
+
+ pumlArguments+="\"";
+ pumlArguments+=puFileName;
+ pumlArguments+="\" ";
+
+ QFile file(puFileName);
+ if (!file.open(IO_WriteOnly))
+ {
+ err("Could not open file %s for writing\n",puFileName.data());
+ }
+ file.writeBlock( *nb, nb->length() );
+ file.close();
+ Debug::print(Debug::Plantuml,0,"*** %s Running Plantuml arguments:%s\n","PlantumlManager::runPlantumlContent",qPrint(pumlArguments));
+
+ portable_sysTimerStart();
+ if ((exitCode=portable_system(pumlExe,pumlArguments,TRUE))!=0)
+ {
+ err("Problems running PlantUML. Verify that the command 'java -jar \"%splantuml.jar\" -h' works from the command line. Exit code: %d\n",
+ plantumlJarPath.data(),exitCode);
+ }
+ else if (Config_getBool(DOT_CLEANUP))
+ {
+ Debug::print(Debug::Plantuml,0,"*** %s Remove %s file\n","PlantumlManager::runPlantumlContent",qPrint(puFileName));
+ file.remove();
+ }
+ portable_sysTimerStop();
+
+ if ( (format==PlantumlManager::PUML_EPS) && (Config_getBool(USE_PDFLATEX)) )
+ {
+ Debug::print(Debug::Plantuml,0,"*** %s Running epstopdf\n","PlantumlManager::runPlantumlContent");
+ QList<QCString> *list = plantumlFiles[it.currentKey()];
+ if (list)
+ {
+ QListIterator<QCString> li(*list);
+ QCString *nb;
+ for (li.toFirst();(nb=li.current());++li)
+ {
+ const int maxCmdLine = 40960;
+ QCString epstopdfArgs(maxCmdLine);
+ epstopdfArgs.sprintf("\"%s%s.eps\" --outfile=\"%s%s.pdf\"",qPrint(pumlOutDir),qPrint(*nb),qPrint(pumlOutDir),qPrint(*nb));
+ portable_sysTimerStart();
+ if ((exitCode=portable_system("epstopdf",epstopdfArgs))!=0)
+ {
+ err("Problems running epstopdf. Check your TeX installation! Exit code: %d\n",exitCode);
+ }
+ portable_sysTimerStop();
+ }
+ }
+ }
+ }
}
- else if (Config_getBool(DOT_CLEANUP))
+}
+
+void PlantumlManager::run()
+{
+ Debug::print(Debug::Plantuml,0,"*** %s\n","PlantumlManager::run");
+ runPlantumlContent(m_pngPlantumlFiles, m_pngPlantumlContent, PUML_BITMAP);
+ runPlantumlContent(m_svgPlantumlFiles, m_svgPlantumlContent, PUML_SVG);
+ runPlantumlContent(m_epsPlantumlFiles, m_epsPlantumlContent, PUML_EPS);
+ QCString outputFilename = Config_getString(OUTPUT_DIRECTORY) + "/" + CACHE_FILENAME;
+ QFile file(outputFilename);
+ if (!file.open(IO_WriteOnly))
{
- QFile(QCString(baseName)+".pu").remove();
+ err("Could not open file %s for writing\n",CACHE_FILENAME);
}
- portable_sysTimerStop();
- if ( (format==PUML_EPS) && (Config_getBool(USE_PDFLATEX)) )
+ file.writeBlock( m_currentPlantumlAllContent, m_currentPlantumlAllContent.length() );
+ file.close();
+}
+
+static void print(const QDict< QList <QCString> > &plantumlFiles)
+{
+ if (Debug::isFlagSet(Debug::Plantuml))
{
- QCString epstopdfArgs(maxCmdLine);
- epstopdfArgs.sprintf("\"%s.eps\" --outfile=\"%s.pdf\"",baseName,baseName);
- portable_sysTimerStart();
- if ((exitCode=portable_system("epstopdf",epstopdfArgs))!=0)
+ QDictIterator< QList<QCString> > it( plantumlFiles); // See QDictIterator
+ QList<QCString> *list;
+ for (it.toFirst();(list=it.current());++it)
{
- err("Problems running epstopdf. Check your TeX installation! Exit code: %d\n",exitCode);
+ Debug::print(Debug::Plantuml,0,"*** %s PlantumlFiles key:%s size:%d\n","PlantumlManager::print Files",qPrint(it.currentKey()),(*list).count());
+ QListIterator<QCString> li(*list);
+ QCString *nb;
+ for (li.toFirst();(nb=li.current());++li)
+ {
+ Debug::print(Debug::Plantuml,0,"*** %s list:%s\n","PlantumlManager::print",qPrint(*nb));
+ }
}
- portable_sysTimerStop();
}
- Doxygen::indexList->addImageFile(imgName);
}
+static void print(const QDict<QCString> &plantumlContent)
+{
+ if (Debug::isFlagSet(Debug::Plantuml))
+ {
+ QDictIterator< QCString > it( plantumlContent); // See QDictIterator
+ QCString *nb;
+ for (it.toFirst();(nb=it.current());++it)
+ {
+ Debug::print(Debug::Plantuml,0,"*** %s PlantumlContent key:%s\n","PlantumlManager::print Content",qPrint(it.currentKey()));
+ Debug::print(Debug::Plantuml,0,"*** %s Content :%s\n","PlantumlManager::print",qPrint(*nb));
+ }
+ }
+}
+
+static void addPlantumlFiles(QDict< QList<QCString> > &plantumlFiles,
+ const QCString &key , const QCString &value)
+{
+ QList<QCString> *list = plantumlFiles.find(key);
+ if (list==0)
+ {
+ list = new QList<QCString>;
+ plantumlFiles.insert(key,list);
+ }
+ list->append(new QCString(value));
+}
+
+static void addPlantumlContent(QDict< QCString > &plantumlContent,
+ const QCString &key, const QCString &puContent)
+{
+ QCString* content = plantumlContent.find(key);
+ if (content == 0)
+ {
+ content = new QCString("");
+ plantumlContent.insert(key,content);
+ }
+ (*content)+=puContent;
+}
+
+
+
+void PlantumlManager::insert(const QCString &key, const QCString &value,
+ OutputFormat format,const QCString &puContent)
+{
+ int find;
+
+ Debug::print(Debug::Plantuml,0,"*** %s key:%s ,value:%s\n","PlantumlManager::insert",qPrint(key),qPrint(value));
+
+ m_currentPlantumlAllContent+=puContent;
+
+ find = m_cachedPlantumlAllContent.find(puContent);
+ Debug::print(Debug::Plantuml,0,"*** %s find: %d\n","PlantumlManager::addPlantumlContent",find);
+ if (find >=0)
+ { // matched in cache. so we skip to run java for this plantuml
+ return ;
+ }
+
+ switch (format)
+ {
+ case PUML_BITMAP:
+ addPlantumlFiles(m_pngPlantumlFiles,key,value);
+ print(m_pngPlantumlFiles);
+ addPlantumlContent(m_pngPlantumlContent,key,puContent);
+ print(m_pngPlantumlContent);
+ break;
+ case PUML_EPS:
+ addPlantumlFiles(m_epsPlantumlFiles,key,value);
+ print(m_epsPlantumlFiles);
+ addPlantumlContent(m_epsPlantumlContent,key,puContent);
+ print(m_epsPlantumlContent);
+ break;
+ case PUML_SVG:
+ addPlantumlFiles(m_svgPlantumlFiles,key,value);
+ print(m_svgPlantumlFiles);
+ addPlantumlContent(m_svgPlantumlContent,key,puContent);
+ print(m_svgPlantumlContent);
+ break;
+ }
+}
+
+//--------------------------------------------------------------------
diff --git a/src/plantuml.h b/src/plantuml.h
index 54ab8a2..6c99eba 100644
--- a/src/plantuml.h
+++ b/src/plantuml.h
@@ -16,25 +16,60 @@
#ifndef PLANTUML_H
#define PLANTUML_H
+#include <qdict.h>
+#include <qlist.h>
+
+#define CACHE_FILENAME "inline_umlgraph_cache_all.pu"
+#define DIVIDE_COUNT 4
+#define MIN_PLANTUML_COUNT 8
+
class QCString;
-/** Plant UML output image formats */
-enum PlantUMLOutputFormat { PUML_BITMAP, PUML_EPS, PUML_SVG };
+/** Singleton that manages plantuml relation actions */
+class PlantumlManager
+{
+ public:
+ /** Plant UML output image formats */
+ enum OutputFormat { PUML_BITMAP, PUML_EPS, PUML_SVG };
-/** Write a PlantUML compatible file.
- * @param[in] outDir the output directory to write the file to.
- * @param[in] fileName the name of the file. If empty a name will be chosen automatically.
- * @param[in] content the contents of the PlantUML file.
- * @returns The name of the generated file.
- */
-QCString writePlantUMLSource(const QCString &outDir,const QCString &fileName,const QCString &content);
+ static PlantumlManager *instance();
-/** Convert a PlantUML file to an image.
- * @param[in] baseName the name of the generated file (as returned by writePlantUMLSource())
- * @param[in] outDir the directory to write the resulting image into.
- * @param[in] format the image format to generate.
- */
-void generatePlantUMLOutput(const char *baseName,const char *outDir,PlantUMLOutputFormat format);
+ /** Run plant UML tool for all images */
+ void run();
+
+ /** Write a PlantUML compatible file.
+ * @param[in] outDir the output directory to write the file to.
+ * @param[in] fileName the name of the file. If empty a name will be chosen automatically.
+ * @param[in] content the contents of the PlantUML file.
+ * @param[in] format the image format to generate.
+ * @returns The name of the generated file.
+ */
+ QCString writePlantUMLSource(const QCString &outDir,const QCString &fileName,const QCString &content, OutputFormat format);
+
+ /** Convert a PlantUML file to an image.
+ * @param[in] baseName the name of the generated file (as returned by writePlantUMLSource())
+ * @param[in] outDir the directory to write the resulting image into.
+ * @param[in] format the image format to generate.
+ */
+ void generatePlantUMLOutput(const char *baseName,const char *outDir,OutputFormat format);
+
+ private:
+ PlantumlManager();
+ ~PlantumlManager();
+ void insert(const QCString &key,
+ const QCString &value,
+ OutputFormat format,
+ const QCString &puContent);
+ static PlantumlManager *m_theInstance;
+ QDict< QList<QCString> > m_pngPlantumlFiles;
+ QDict< QList<QCString> > m_svgPlantumlFiles;
+ QDict< QList<QCString> > m_epsPlantumlFiles;
+ QDict< QCString > m_pngPlantumlContent; // use circular queue for using multi-proecessor (multi threading)
+ QDict< QCString > m_svgPlantumlContent;
+ QDict< QCString > m_epsPlantumlContent;
+ QCString m_cachedPlantumlAllContent; // read from CACHE_FILENAME file
+ QCString m_currentPlantumlAllContent; // processing plantuml then write it into CACHE_FILENAME to reuse the next time as cache information
+};
#endif
diff --git a/src/rtfdocvisitor.cpp b/src/rtfdocvisitor.cpp
index f2edf8b..1e2bb89 100644
--- a/src/rtfdocvisitor.cpp
+++ b/src/rtfdocvisitor.cpp
@@ -383,7 +383,7 @@ void RTFDocVisitor::visit(DocVerbatim *s)
case DocVerbatim::PlantUML:
{
static QCString rtfOutput = Config_getString(RTF_OUTPUT);
- QCString baseName = writePlantUMLSource(rtfOutput,s->exampleFile(),s->text());
+ QCString baseName = PlantumlManager::instance()->writePlantUMLSource(rtfOutput,s->exampleFile(),s->text(),PlantumlManager::PUML_BITMAP);
writePlantUMLFile(baseName, s->hasCaption());
visitCaption(this, s->children());
@@ -1868,6 +1868,6 @@ void RTFDocVisitor::writePlantUMLFile(const QCString &fileName, bool hasCaption)
baseName=baseName.right(baseName.length()-i-1);
}
QCString outDir = Config_getString(RTF_OUTPUT);
- generatePlantUMLOutput(fileName,outDir,PUML_BITMAP);
+ PlantumlManager::instance()->generatePlantUMLOutput(fileName,outDir,PlantumlManager::PUML_BITMAP);
includePicturePreRTF(baseName + ".png", true, hasCaption);
}
diff --git a/src/vhdldocgen.cpp b/src/vhdldocgen.cpp
index b18bd3f..808b32b 100644
--- a/src/vhdldocgen.cpp
+++ b/src/vhdldocgen.cpp
@@ -3774,8 +3774,8 @@ void FlowChart::printUmlTree()
QCString n=convertNameToFileName();
QCString tmp=htmlOutDir;
- n=writePlantUMLSource(tmp,n,qcs);
- generatePlantUMLOutput(n.data(),tmp.data(),PUML_SVG);
+ n=PlantumlManager::instance()->writePlantUMLSource(tmp,n,qcs,PlantumlManager::PUML_SVG);
+ PlantumlManager::instance()->generatePlantUMLOutput(n.data(),tmp.data(),PlantumlManager::PUML_SVG);
}
QCString FlowChart::convertNameToFileName()