1 /******************************************************************************
3 * Copyright (C) 1997-2015 by Dimitri van Heesch.
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
25 static const int maxCmdLine = 40960;
27 QCString writePlantUMLSource(const QCString &outDir,const QCString &fileName,const QCString &content)
29 QCString baseName(4096);
30 static int umlindex=1;
32 if (fileName.isEmpty()) // generate name
34 baseName = outDir+"/inline_umlgraph_"+QCString().setNum(umlindex++);
36 else // user specified name
39 int i=baseName.findRev('.');
40 if (i!=-1) baseName = baseName.left(i);
41 baseName.prepend(outDir+"/");
43 QFile file(baseName+".pu");
44 if (!file.open(IO_WriteOnly))
46 err("Could not open file %s for writing\n",baseName.data());
48 QCString text = "@startuml\n";
51 file.writeBlock( text, text.length() );
56 void generatePlantUMLOutput(const char *baseName,const char *outDir,PlantUMLOutputFormat format)
58 static QCString plantumlJarPath = Config_getString(PLANTUML_JAR_PATH);
59 static QCString plantumlConfigFile = Config_getString(PLANTUML_CFG_FILE);
60 static QCString dotPath = Config_getString(DOT_PATH);
62 QCString pumlExe = "java";
63 QCString pumlArgs = "";
65 QStrList &pumlIncludePathList = Config_getList(PLANTUML_INCLUDE_PATH);
66 char *s=pumlIncludePathList.first();
69 pumlArgs += "-Dplantuml.include.path=\"";
71 s = pumlIncludePathList.next();
75 pumlArgs += portable_pathListSeparator();
77 s = pumlIncludePathList.next();
79 if (pumlIncludePathList.first()) pumlArgs += "\" ";
80 pumlArgs += "-Djava.awt.headless=true -jar \""+plantumlJarPath+"plantuml.jar\" ";
81 if (!plantumlConfigFile.isEmpty())
83 pumlArgs += "-config \"";
84 pumlArgs += plantumlConfigFile;
87 if (Config_getBool(HAVE_DOT) && !dotPath.isEmpty())
89 pumlArgs += "-graphvizdot \"";
92 pumlArgs += portable_commandExtension();
98 QCString imgName = baseName;
99 // The basename contains path, we need to strip the path from the filename in order
100 // to create the image file name which should be included in the index.qhp (Qt help index file).
102 if ((i=imgName.findRev('/'))!=-1) // strip path
104 imgName=imgName.right(imgName.length()-i-1);
124 pumlArgs+="-charset UTF-8 ";
126 //printf("*** running: %s %s outDir:%s %s\n",pumlExe.data(),pumlArgs.data(),outDir,baseName);
127 msg("Running PlantUML on generated file %s.pu\n",baseName);
128 portable_sysTimerStart();
129 if ((exitCode=portable_system(pumlExe,pumlArgs,TRUE))!=0)
131 err("Problems running PlantUML. Verify that the command 'java -jar \"%splantuml.jar\" -h' works from the command line. Exit code: %d\n",
132 plantumlJarPath.data(),exitCode);
134 else if (Config_getBool(DOT_CLEANUP))
136 QFile(QCString(baseName)+".pu").remove();
138 portable_sysTimerStop();
139 if ( (format==PUML_EPS) && (Config_getBool(USE_PDFLATEX)) )
141 QCString epstopdfArgs(maxCmdLine);
142 epstopdfArgs.sprintf("\"%s.eps\" --outfile=\"%s.pdf\"",baseName,baseName);
143 portable_sysTimerStart();
144 if ((exitCode=portable_system("epstopdf",epstopdfArgs))!=0)
146 err("Problems running epstopdf. Check your TeX installation! Exit code: %d\n",exitCode);
148 portable_sysTimerStop();
150 Doxygen::indexList->addImageFile(imgName);