Skip to main content

The dotfilepatcher.cpp File Reference

Included Headers

#include "dotfilepatcher.h" #include "dotrunner.h" #include "config.h" #include "message.h" #include "docparser.h" #include "docnode.h" #include "doxygen.h" #include "util.h" #include "dot.h" #include "dir.h" #include "portable.h" #include "stringutil.h"

Functions Index

static QCStringreplaceRef (const QCString &buf, const QCString &relPath, bool urlOnly, const QCString &context, const QCString &target=QCString())
static boolreadSVGSize (const QCString &fileName, int *width, int *height)
static voidwriteSVGNotSupported (TextStream &out)

Variables Index

static const charsvgZoomHeader0[] = ...
static const charsvgZoomHeader0_noinit[] = ...
static const charsvgZoomHeader1[] = ...
static const charsvgZoomHeader2[]
static const charsvgZoomFooter1[] = ...
static const charsvgZoomFooter2[] = ...

Functions

readSVGSize()

bool readSVGSize (const QCString & fileName, int * width, int * height)
static

Definition at line 545 of file dotfilepatcher.cpp.

545static bool readSVGSize(const QCString &fileName,int *width,int *height)
546{
547 bool found=FALSE;
548 std::ifstream f = Portable::openInputStream(fileName);
549 if (!f.is_open())
550 {
551 return false;
552 }
553 std::string line;
554 while (getline(f,line) && !found)
555 {
556 if (literal_at(line.c_str(),"<!--zoomable "))
557 {
558 *width=-1;
559 *height=-1;
560 sscanf(line.c_str(),"<!--zoomable %d",height);
561 found=true;
562 }
563 else if (sscanf(line.c_str(),"<svg width=\"%dpt\" height=\"%dpt\"",width,height)==2)
564 {
565 found=true;
566 }
567 else if (sscanf(line.c_str(),"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"%d\" height=\"%d\"",width,height)==2)
568 {
569 found=true;
570 }
571 }
572 return true;
573}

References FALSE, literal_at and Portable::openInputStream.

Referenced by DotFilePatcher::writeSVGFigureLink.

replaceRef()

QCString replaceRef (const QCString & buf, const QCString & relPath, bool urlOnly, const QCString & context, const QCString & target=QCString())
static

Definition at line 124 of file dotfilepatcher.cpp.

124static QCString replaceRef(const QCString &buf,const QCString &relPath,
125 bool urlOnly,const QCString &context,const QCString &target=QCString())
126{
127 // search for href="...", store ... part in link
128 QCString href = "href";
129 //bool isXLink=FALSE;
130 int len = 6;
131 int indexS = buf.find("href=\""), indexE = 0;
132 bool targetAlreadySet = buf.find("target=")!=-1;
133 if (indexS>5 && buf.find("xlink:href=\"")!=-1) // XLink href (for SVG)
134 {
135 indexS-=6;
136 len+=6;
137 href.prepend("xlink:");
138 //isXLink=TRUE;
139 }
140 if (indexS>=0 && (indexE=buf.find('"',indexS+len))!=-1)
141 {
142 QCString link = buf.mid(indexS+len,indexE-indexS-len);
143 QCString result;
144 if (urlOnly) // for user defined dot graphs
145 {
146 if (link.startsWith("\\ref ") || link.startsWith("@ref ")) // \ref url
147 {
148 result=href+"=\"";
149 // fake ref node to resolve the url
150 auto parser { createDocParser() };
151 auto dfAst { createRef( *parser.get(), link.mid(5), context ) };
152 auto dfAstImpl = dynamic_cast<const DocNodeAST*>(dfAst.get());
153 const DocRef *df = std::get_if<DocRef>(&dfAstImpl->root);
154 result+=externalRef(relPath,df->ref(),TRUE);
155 if (!df->file().isEmpty())
156 {
157 QCString fn = df->file();
159 result += fn;
160 }
161 if (!df->anchor().isEmpty())
162 {
163 result += "#" + df->anchor();
164 }
165 result += "\"";
166 }
167 else
168 {
169 result = href+"=\"" + link + "\"";
170 }
171 }
172 else // ref$url (external ref via tag file), or $url (local ref)
173 {
174 int marker = link.find('$');
175 if (marker!=-1)
176 {
177 QCString ref = link.left(marker);
178 QCString url = link.mid(marker+1);
179 if (!ref.isEmpty())
180 {
181 result = externalLinkTarget(true);
182 if (!result.isEmpty())targetAlreadySet=true;
183 }
184 result+= href+"=\"";
185 result+=externalRef(relPath,ref,TRUE);
186 result+= url + "\"";
187 }
188 else // should not happen, but handle properly anyway
189 {
190 result = href+"=\"" + link + "\"";
191 }
192 }
193 if (!target.isEmpty() && !targetAlreadySet)
194 {
195 result+=" target=\""+target+"\"";
196 }
197 QCString leftPart = buf.left(indexS);
198 QCString rightPart = buf.mid(indexE+1);
199 //printf("replaceRef(\n'%s'\n)->\n'%s+%s+%s'\n",
200 // qPrint(buf),qPrint(leftPart),qPrint(result),qPrint(rightPart));
201 return leftPart + result + rightPart;
202 }
203 else
204 {
205 return buf;
206 }
207}

References addHtmlExtensionIfMissing, DocRef::anchor, createDocParser, createRef, externalLinkTarget, externalRef, DocRef::file, QCString::find, QCString::isEmpty, QCString::left, QCString::mid, QCString::prepend, DocRef::ref, QCString::startsWith and TRUE.

Referenced by DotFilePatcher::convertMapFile and DotFilePatcher::run.

writeSVGNotSupported()

void writeSVGNotSupported (TextStream & out)
static

Definition at line 575 of file dotfilepatcher.cpp.

576{
577 out << "<p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p>";
578}

Referenced by DotFilePatcher::writeSVGFigureLink.

Variables

svgZoomFooter1

const char svgZoomFooter1[]
static
Initialiser
= R"svg( <g id="navigator" transform="translate(0 0)" fill="#404254"> <rect fill="#f2f5e9" fill-opacity="0.5" stroke="#606060" stroke-width=".5" x="0" y="0" width="60" height="60"/> <use id="zoomplus" xlink:href="#zoomPlus" x="17" y="9" onmousedown="handleZoom(evt,'in')"/> <use id="zoomminus" xlink:href="#zoomMin" x="42" y="9" onmousedown="handleZoom(evt,'out')"/> <use id="reset" xlink:href="#resetDef" x="30" y="36" onmousedown="handleReset()"/> <use id="arrowup" xlink:href="#arrowUp" x="0" y="0" onmousedown="handlePan(0,-1)"/> <use id="arrowright" xlink:href="#arrowRight" x="0" y="0" onmousedown="handlePan(1,0)"/> <use id="arrowdown" xlink:href="#arrowDown" x="0" y="0" onmousedown="handlePan(0,1)"/> <use id="arrowleft" xlink:href="#arrowLeft" x="0" y="0" onmousedown="handlePan(-1,0)"/> </g> <svg viewBox="0 0 15 15" width="100%" height="30px" preserveAspectRatio="xMaxYMin meet"> <g id="arrow_out" transform="scale(0.3 0.3)"> <a xlink:href="$orgname" target="_base"> <rect id="button" ry="5" rx="5" y="6" x="6" height="38" width="38" fill="#f2f5e9" fill-opacity="0.5" stroke="#606060" stroke-width="1.0"/> <path id="arrow" 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" style="fill:#404040;"/> </a> </g> </svg> )svg"

Definition at line 83 of file dotfilepatcher.cpp.

83static const char svgZoomFooter1[] = R"svg(

Referenced by DotFilePatcher::run.

svgZoomFooter2

const char svgZoomFooter2[]
static
Initialiser
= R"svg( <style type='text/css'> <![CDATA[ [data-mouse-over-selected='false'] { opacity: 0.7; } [data-mouse-over-selected='true'] { opacity: 1.0; } ]]> </style> <script type="application/ecmascript"><![CDATA[ document.addEventListener('DOMContentLoaded', (event) => { highlightEdges(); highlightAdjacentNodes(); }); ]]></script> </svg> )svg"

Definition at line 108 of file dotfilepatcher.cpp.

108static const char svgZoomFooter2[] = R"svg(

Referenced by DotFilePatcher::run.

svgZoomHeader0

const char svgZoomHeader0[]
static
Initialiser
= R"svg( <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)"> )svg"

Definition at line 30 of file dotfilepatcher.cpp.

30static const char svgZoomHeader0[] = R"svg(

Referenced by DotFilePatcher::run.

svgZoomHeader0_noinit

const char svgZoomHeader0_noinit[]
static
Initialiser
= R"svg( <svg id="main" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve"> )svg"

Definition at line 34 of file dotfilepatcher.cpp.

34static const char svgZoomHeader0_noinit[] = R"svg(

Referenced by DotFilePatcher::run.

svgZoomHeader1

const char svgZoomHeader1[]
static
Initialiser
= R"svg( <style type="text/css"><![CDATA[ .node, .edge {opacity: 0.7;} .node.selected, .edge.selected {opacity: 1;} .edge:hover path { stroke: red; } .edge:hover polygon { stroke: red; fill: red; } ]]></style> )svg"

Definition at line 38 of file dotfilepatcher.cpp.

38static const char svgZoomHeader1[] = R"svg(

Referenced by DotFilePatcher::run.

svgZoomHeader2

const char svgZoomHeader2[]
static

Definition at line 48 of file dotfilepatcher.cpp.

48static const char svgZoomHeader2[] = R"svg(

Referenced by DotFilePatcher::run.


Generated via doxygen2docusaurus by Doxygen 1.14.0.