浏览该文件的文档.
29 "<svg id=\"main\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xml:space=\"preserve\" onload=\"init(evt)\">\n"
30 "<style type=\"text/css\"><![CDATA[\n"
31 ".edge:hover path { stroke: red; }\n"
32 ".edge:hover polygon { stroke: red; fill: red; }\n"
34 "<script type=\"text/javascript\"><![CDATA[\n"
35 "var edges = document.getElementsByTagName('g');\n"
36 "if (edges && edges.length) {\n"
37 " for (var i=0;i<edges.length;i++) {\n"
38 " if (edges[i].id.substr(0,4)=='edge') {\n"
39 " edges[i].setAttribute('class','edge');\n"
45 " <circle id=\"rim\" cx=\"0\" cy=\"0\" r=\"7\"/>\n"
46 " <circle id=\"rim2\" cx=\"0\" cy=\"0\" r=\"3.5\"/>\n"
47 " <g id=\"zoomPlus\">\n"
48 " <use xlink:href=\"#rim\" fill=\"#404040\">\n"
49 " <set attributeName=\"fill\" to=\"#808080\" begin=\"zoomplus.mouseover\" end=\"zoomplus.mouseout\"/>\n"
51 " <path d=\"M-4,0h8M0,-4v8\" fill=\"none\" stroke=\"white\" stroke-width=\"1.5\" pointer-events=\"none\"/>\n"
53 " <g id=\"zoomMin\">\n"
54 " <use xlink:href=\"#rim\" fill=\"#404040\">\n"
55 " <set attributeName=\"fill\" to=\"#808080\" begin=\"zoomminus.mouseover\" end=\"zoomminus.mouseout\"/>\n"
57 " <path d=\"M-4,0h8\" fill=\"none\" stroke=\"white\" stroke-width=\"1.5\" pointer-events=\"none\"/>\n"
59 " <g id=\"dirArrow\">\n"
60 " <path fill=\"none\" stroke=\"white\" stroke-width=\"1.5\" d=\"M0,-3.0v7 M-2.5,-0.5L0,-3.0L2.5,-0.5\"/>\n"
62 " <g id=\"resetDef\">\n"
63 " <use xlink:href=\"#rim2\" fill=\"#404040\">\n"
64 " <set attributeName=\"fill\" to=\"#808080\" begin=\"reset.mouseover\" end=\"reset.mouseout\"/>\n"
69 "<script type=\"text/javascript\">\n"
74 " <g id=\"navigator\" transform=\"translate(0 0)\" fill=\"#404254\">\n"
75 " <rect fill=\"#f2f5e9\" fill-opacity=\"0.5\" stroke=\"#606060\" stroke-width=\".5\" x=\"0\" y=\"0\" width=\"60\" height=\"60\"/>\n"
77 " <use id=\"zoomplus\" xlink:href=\"#zoomPlus\" x=\"17\" y=\"9\" onmousedown=\"handleZoom(evt,'in')\"/>\n"
79 " <use id=\"zoomminus\" xlink:href=\"#zoomMin\" x=\"42\" y=\"9\" onmousedown=\"handleZoom(evt,'out')\"/>\n"
81 " <use id=\"reset\" xlink:href=\"#resetDef\" x=\"30\" y=\"36\" onmousedown=\"handleReset()\"/>\n"
83 " <g id=\"arrowUp\" xlink:href=\"#dirArrow\" transform=\"translate(30 24)\" onmousedown=\"handlePan(0,-1)\">\n"
84 " <use xlink:href=\"#rim\" fill=\"#404040\">\n"
85 " <set attributeName=\"fill\" to=\"#808080\" begin=\"arrowUp.mouseover\" end=\"arrowUp.mouseout\"/>\n"
87 " <path fill=\"none\" stroke=\"white\" stroke-width=\"1.5\" d=\"M0,-3.0v7 M-2.5,-0.5L0,-3.0L2.5,-0.5\"/>\n"
90 " <g id=\"arrowRight\" xlink:href=\"#dirArrow\" transform=\"rotate(90) translate(36 -43)\" onmousedown=\"handlePan(1,0)\">\n"
91 " <use xlink:href=\"#rim\" fill=\"#404040\">\n"
92 " <set attributeName=\"fill\" to=\"#808080\" begin=\"arrowRight.mouseover\" end=\"arrowRight.mouseout\"/>\n"
94 " <path fill=\"none\" stroke=\"white\" stroke-width=\"1.5\" d=\"M0,-3.0v7 M-2.5,-0.5L0,-3.0L2.5,-0.5\"/>\n"
97 " <g id=\"arrowDown\" xlink:href=\"#dirArrow\" transform=\"rotate(180) translate(-30 -48)\" onmousedown=\"handlePan(0,1)\">\n"
98 " <use xlink:href=\"#rim\" fill=\"#404040\">\n"
99 " <set attributeName=\"fill\" to=\"#808080\" begin=\"arrowDown.mouseover\" end=\"arrowDown.mouseout\"/>\n"
101 " <path fill=\"none\" stroke=\"white\" stroke-width=\"1.5\" d=\"M0,-3.0v7 M-2.5,-0.5L0,-3.0L2.5,-0.5\"/>\n"
104 " <g id=\"arrowLeft\" xlink:href=\"#dirArrow\" transform=\"rotate(270) translate(-36 17)\" onmousedown=\"handlePan(-1,0)\">\n"
105 " <use xlink:href=\"#rim\" fill=\"#404040\">\n"
106 " <set attributeName=\"fill\" to=\"#808080\" begin=\"arrowLeft.mouseover\" end=\"arrowLeft.mouseout\"/>\n"
108 " <path fill=\"none\" stroke=\"white\" stroke-width=\"1.5\" d=\"M0,-3.0v7 M-2.5,-0.5L0,-3.0L2.5,-0.5\"/>\n"
112 " <svg viewBox=\"0 0 15 15\" width=\"100%\" height=\"30px\" preserveAspectRatio=\"xMaxYMin meet\">\n"
113 " <g id=\"arrow_out\" transform=\"scale(0.3 0.3)\">\n"
114 " <a xlink:href=\"$orgname\" target=\"_base\">\n"
115 " <rect id=\"button\" ry=\"5\" rx=\"5\" y=\"6\" x=\"6\" height=\"38\" width=\"38\"\n"
116 " fill=\"#f2f5e9\" fill-opacity=\"0.5\" stroke=\"#606060\" stroke-width=\"1.0\"/>\n"
117 " <path id=\"arrow\"\n"
118 " d=\"M 11.500037,31.436501 C 11.940474,20.09759 22.043105,11.32322 32.158766,21.979434 L 37.068811,17.246167 C 37.068811,17.246167 37.088388,32 37.088388,32 L 22.160133,31.978069 C 22.160133,31.978069 26.997745,27.140456 26.997745,27.140456 C 18.528582,18.264221 13.291696,25.230495 11.500037,31.436501 z\"\n"
119 " style=\"fill:#404040;\"/>\n"
133 int indexS = buf.
find(
"href=\""), indexE;
134 bool targetAlreadySet = buf.
find(
"target=")!=-1;
135 if (indexS>5 && buf.
find(
"xlink:href=\"")!=-1)
142 if (indexS>=0 && (indexE=buf.
find(
'"',indexS+len))!=-1)
144 QCString link = buf.
mid(indexS+len,indexE-indexS-len);
148 if (link.
left(5)==
"\\ref " || link.
left(5)==
"@ref ")
153 std::unique_ptr<DocRef> df {
createRef( *parser.get(), link.
mid(5), context ) };
155 if (!df->file().isEmpty())
157 if (!df->anchor().isEmpty())
158 result +=
"#" + df->anchor();
163 result = href+
"=\"" + link +
"\"";
168 int marker = link.
find(
'$');
176 if (!result.
isEmpty())targetAlreadySet=
true;
184 result = href+
"=\"" + link +
"\"";
187 if (!target.isEmpty() && !targetAlreadySet)
189 result+=
" target=\""+target+
"\"";
195 return leftPart + result + rightPart;
215 const QCString &relPath,
bool urlOnly,
218 std::ifstream f(mapName.
str(),std::ifstream::in);
221 err(
"problems opening map file %s for inclusion in the docs!\n"
222 "If you installed Graphviz/dot after a previous failing run, \n"
223 "try deleting the output directory and rerun doxygen.\n",
qPrint(mapName));
227 while (getline(f,line))
230 if (buf.
left(5)==
"<area")
234 int indexS = replBuf.
find(
"id=\""), indexE;
235 if (indexS>0 && (indexE=replBuf.
find(
'"',indexS+4))!=-1)
237 t << replBuf.
left(indexS-1) << replBuf.
right(replBuf.
length() - indexE - 1);
249 : m_patchFile(patchFile)
261 int id = (int)
m_maps.size();
262 m_maps.emplace_back(mapFile,relPath,urlOnly,context,label);
267 const QCString &figureName,
bool heightCheck)
269 int id = (int)
m_maps.size();
270 m_maps.emplace_back(figureName,
"",heightCheck,
"",baseName);
275 const QCString &context,
bool zoomable,
278 int id = (int)
m_maps.size();
279 m_maps.emplace_back(
"",relPath,urlOnly,context,
"",zoomable,graphId);
287 int id = (int)
m_maps.size();
288 m_maps.emplace_back(absImgName,relPath,
false,
"",baseName);
302 interactiveSVG_local = interactiveSVG_local && map.
zoomable;
311 if (!thisDir.
rename(patchFile,tmpName))
316 std::ifstream fi(tmpName, std::ifstream::in);
317 std::ofstream fo(patchFile, std::ofstream::out | std::ofstream::binary);
320 err(
"problem opening file %s for patching!\n",tmpName.c_str());
321 thisDir.
rename(tmpName,patchFile);
327 thisDir.
rename(tmpName,patchFile);
332 bool insideHeader=
FALSE;
333 bool replacedHeader=
FALSE;
334 bool foundSize=
FALSE;
337 static const reg::Ex reSVG(R
"([\[<]!-- SVG [0-9]+)");
338 static const reg::Ex reMAP(R
"(<!-- MAP [0-9]+)");
339 static const reg::Ex reFIG(R
"(% FIG [0-9]+)");
341 while (getline(fi,lineStr))
348 if (interactiveSVG_local)
350 if (line.
find(
"<svg")!=-1 && !replacedHeader)
353 count = sscanf(line.
data(),
"<svg width=\"%dpt\" height=\"%dpt\"",&width,&height);
355 foundSize = count==2 && (width>500 || height>450);
356 if (foundSize) insideHeader=
TRUE;
358 else if (insideHeader && !replacedHeader && line.
find(
"<title>")!=-1)
363 t <<
"<!--zoomable " << height <<
" -->\n";
365 t <<
"var viewWidth = " << width <<
";\n";
366 t <<
"var viewHeight = " << height <<
";\n";
369 t <<
"var sectionId = 'dynsection-" << graphId <<
"';\n";
372 t <<
"<script xlink:href=\"" << relPath <<
"svgpan.js\"/>\n";
373 t <<
"<svg id=\"graph\" class=\"graph\">\n";
374 t <<
"<g id=\"viewport\">\n";
380 if (!insideHeader || !foundSize)
393 int n = sscanf(line.
data()+i+1,
"!-- SVG %d",&mapId);
394 if (n==1 && mapId>=0 && mapId<(
int)
m_maps.size())
396 int e = std::max(line.
find(
"--]"),line.
find(
"-->"));
404 if (e!=-1) t << line.
mid(e+3);
416 int n = sscanf(line.
data()+i,
"<!-- MAP %d",&mapId);
417 if (n==1 && mapId>=0 && mapId<(
int)
m_maps.size())
440 int n = sscanf(line.
data()+i+2,
"FIG %d",&mapId);
442 if (n==1 && mapId>=0 && mapId<(
int)
m_maps.size())
449 err(
"problem writing FIG %d figure!\n",mapId);
466 if (
isSVGFile && interactiveSVG_local && replacedHeader)
474 fi.open(tmpName,std::ifstream::in);
475 fo.open(orgName.
str(),std::ofstream::out | std::ofstream::binary);
478 err(
"problem opening file %s for reading!\n",tmpName.c_str());
483 err(
"problem opening file %s for writing!\n",
qPrint(orgName));
487 while (getline(fi,lineStr))
489 std::string line = lineStr+
'\n';
509 std::ifstream f(fileName.
str(),std::ifstream::in);
515 while (getline(f,line) && !found)
517 if (
qstrncmp(line.c_str(),
"<!--zoomable ",13)==0)
521 sscanf(line.c_str(),
"<!--zoomable %d",height);
524 else if (sscanf(line.c_str(),
"<svg width=\"%dpt\" height=\"%dpt\"",width,height)==2)
534 out <<
"<p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p>";
542 int width=600,height=600;
549 if (height<=60) height=300;
else height+=300;
550 if (height>600) height=600;
551 out <<
"<div class=\"zoom\">";
554 out <<
"<iframe scrolling=\"no\" frameborder=\"0\" src=\""
555 << relPath << baseName <<
".svg\" width=\"100%\" height=\"" << height <<
"\">";
561 out <<
"<iframe scrolling=\"no\" frameborder=\"0\" src=\""
562 << relPath << baseName <<
".svg\" width=\""
563 << ((width*96+48)/72) <<
"\" height=\""
564 << ((height*96+48)/72) <<
"\">";
581 int width=400,height=550;
601 out <<
"\\nopagebreak\n"
602 "\\begin{figure}[H]\n"
605 if (width>maxWidth || height>maxHeight)
608 if (width*maxHeight>height*maxWidth)
610 out <<
"\\includegraphics[width=" << maxWidth <<
"pt]";
614 out <<
"\\includegraphics[height=" << maxHeight <<
"pt]";
619 out <<
"\\includegraphics[width=" << width <<
"pt]";
622 out <<
"{" << baseName <<
"}\n"
void setStream(std::ostream *s)
Sets or changes the std::ostream to write to.
bool remove(const std::string &path, bool acceptsAbsPath=true) const
Class representing a directory in the file system
uint length() const
Returns the length of the string, not counting the 0-terminator.
static bool readSVGSize(const QCString &fileName, int *width, int *height)
bool isEmpty() const
Returns TRUE iff the string is empty
static const char svgZoomFooter[]
static bool writeVecGfxFigure(TextStream &out, const QCString &baseName, const QCString &figureName)
int addMap(const QCString &mapFile, const QCString &relPath, bool urlOnly, const QCString &context, const QCString &label)
void err(const char *fmt,...)
Text streaming class that buffers data.
std::vector< Map > m_maps
int find(char c, int index=0, bool cs=TRUE) const
bool empty() const
Returns true iff the buffer is empty
void flush()
Flushes the buffer.
int qstrncmp(const char *str1, const char *str2, size_t len)
int addSVGObject(const QCString &baseName, const QCString &figureName, const QCString &relPath)
static bool readBoundingBox(const QCString &fileName, int *width, int *height, bool isEps)
QCString addHtmlExtensionIfMissing(const QCString &fName)
bool rename(const std::string &orgName, const std::string &newName, bool acceptsAbsPath=true) const
QCString left(size_t len) const
int addFigure(const QCString &baseName, const QCString &figureName, bool heightCheck)
static const char svgZoomHeader[]
QCString stripPath(const QCString &s)
static bool writeSVGFigureLink(TextStream &out, const QCString &relPath, const QCString &baseName, const QCString &absImgName)
Check if a reference to a SVG figure can be written and do so if possible.
static void writeSVGNotSupported(TextStream &out)
std::string str() const
Return the contents of the buffer as a std::string object
QCString externalLinkTarget(const bool parent)
DocRef * createRef(IDocParser &parserIntf, const QCString &target, const QCString &context)
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
#define Config_getBool(name)
DotFilePatcher(const QCString &patchFile)
Class representing a regular expression.
const char * qPrint(const char *s)
int addSVGConversion(const QCString &relPath, bool urlOnly, const QCString &context, bool zoomable, int graphId)
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string
static bool convertMapFile(TextStream &t, const QCString &mapName, const QCString &relPath, bool urlOnly=FALSE, const QCString &context=QCString())
QCString externalRef(const QCString &relPath, const QCString &ref, bool href)
static QCString replaceRef(const QCString &buf, const QCString &relPath, bool urlOnly, const QCString &context, const QCString &target=QCString())
A bunch of utility functions.
QCString right(size_t len) const
QCString & prepend(const char *s)
QCString correctId(const QCString &s)
int findIndex(const StringVector &sv, const std::string &s)
find the index of a string in a vector of strings, returns -1 if the string could not be found
std::unique_ptr< IDocParser > createDocParser()
This is an alternative implementation of QCString.