Doxygen
Loading...
Searching...
No Matches
dotfilepatcher.cpp File Reference
#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 dependency graph for dotfilepatcher.cpp:

Go to the source code of this file.

Functions

static QCString replaceRef (const QCString &buf, const QCString &relPath, bool urlOnly, const QCString &context, const QCString &target=QCString())
 
static bool readSVGSize (const QCString &fileName, int *width, int *height)
 
static void writeSVGNotSupported (TextStream &out)
 

Variables

static const char svgZoomHeader0 []
 
static const char svgZoomHeader0_noinit []
 
static const char svgZoomHeader1 []
 
static const char svgZoomHeader2 []
 
static const char svgZoomFooter1 []
 
static const char svgZoomFooter2 []
 

Function Documentation

◆ readSVGSize()

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

Definition at line 543 of file dotfilepatcher.cpp.

544{
545 bool found=FALSE;
546 std::ifstream f = Portable::openInputStream(fileName);
547 if (!f.is_open())
548 {
549 return false;
550 }
551 std::string line;
552 while (getline(f,line) && !found)
553 {
554 if (qstrncmp(line.c_str(),"<!--zoomable ",13)==0)
555 {
556 *width=-1;
557 *height=-1;
558 sscanf(line.c_str(),"<!--zoomable %d",height);
559 found=true;
560 }
561 else if (sscanf(line.c_str(),"<svg width=\"%dpt\" height=\"%dpt\"",width,height)==2)
562 {
563 found=true;
564 }
565 }
566 return true;
567}
std::ifstream openInputStream(const QCString &name, bool binary=false, bool openAtEnd=false)
Definition portable.cpp:676
int qstrncmp(const char *str1, const char *str2, size_t len)
Definition qcstring.h:75
#define FALSE
Definition qcstring.h:34
bool found
Definition util.cpp:984

References FALSE, found, Portable::openInputStream(), and qstrncmp().

Referenced by DotFilePatcher::writeSVGFigureLink().

◆ replaceRef()

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

Definition at line 123 of file dotfilepatcher.cpp.

125{
126 // search for href="...", store ... part in link
127 QCString href = "href";
128 //bool isXLink=FALSE;
129 int len = 6;
130 int indexS = buf.find("href=\""), indexE = 0;
131 bool targetAlreadySet = buf.find("target=")!=-1;
132 if (indexS>5 && buf.find("xlink:href=\"")!=-1) // XLink href (for SVG)
133 {
134 indexS-=6;
135 len+=6;
136 href.prepend("xlink:");
137 //isXLink=TRUE;
138 }
139 if (indexS>=0 && (indexE=buf.find('"',indexS+len))!=-1)
140 {
141 QCString link = buf.mid(indexS+len,indexE-indexS-len);
142 QCString result;
143 if (urlOnly) // for user defined dot graphs
144 {
145 if (link.startsWith("\\ref ") || link.startsWith("@ref ")) // \ref url
146 {
147 result=href+"=\"";
148 // fake ref node to resolve the url
149 auto parser { createDocParser() };
150 auto dfAst { createRef( *parser.get(), link.mid(5), context ) };
151 auto dfAstImpl = dynamic_cast<const DocNodeAST*>(dfAst.get());
152 const DocRef *df = std::get_if<DocRef>(&dfAstImpl->root);
153 result+=externalRef(relPath,df->ref(),TRUE);
154 if (!df->file().isEmpty())
155 {
156 QCString fn = df->file();
158 result += fn;
159 }
160 if (!df->anchor().isEmpty())
161 {
162 result += "#" + df->anchor();
163 }
164 result += "\"";
165 }
166 else
167 {
168 result = href+"=\"" + link + "\"";
169 }
170 }
171 else // ref$url (external ref via tag file), or $url (local ref)
172 {
173 int marker = link.find('$');
174 if (marker!=-1)
175 {
176 QCString ref = link.left(marker);
177 QCString url = link.mid(marker+1);
178 if (!ref.isEmpty())
179 {
180 result = externalLinkTarget(true);
181 if (!result.isEmpty())targetAlreadySet=true;
182 }
183 result+= href+"=\"";
184 result+=externalRef(relPath,ref,TRUE);
185 result+= url + "\"";
186 }
187 else // should not happen, but handle properly anyway
188 {
189 result = href+"=\"" + link + "\"";
190 }
191 }
192 if (!target.isEmpty() && !targetAlreadySet)
193 {
194 result+=" target=\""+target+"\"";
195 }
196 QCString leftPart = buf.left(indexS);
197 QCString rightPart = buf.mid(indexE+1);
198 //printf("replaceRef(\n'%s'\n)->\n'%s+%s+%s'\n",
199 // qPrint(buf),qPrint(leftPart),qPrint(result),qPrint(rightPart));
200 return leftPart + result + rightPart;
201 }
202 else
203 {
204 return buf;
205 }
206}
Class representing the abstract syntax tree of a documentation block.
Definition docnode.h:1460
Node representing a reference to some item.
Definition docnode.h:772
QCString anchor() const
Definition docnode.h:779
QCString file() const
Definition docnode.h:776
QCString ref() const
Definition docnode.h:778
This is an alternative implementation of QCString.
Definition qcstring.h:101
int find(char c, int index=0, bool cs=TRUE) const
Definition qcstring.cpp:43
QCString & prepend(const char *s)
Definition qcstring.h:407
bool startsWith(const char *s) const
Definition qcstring.h:492
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:226
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
QCString left(size_t len) const
Definition qcstring.h:214
IDocParserPtr createDocParser()
factory function to create a parser
Definition docparser.cpp:54
IDocNodeASTPtr createRef(IDocParser &parserIntf, const QCString &target, const QCString &context, const QCString &srcFile, int srcLine)
#define TRUE
Definition qcstring.h:37
QCString externalRef(const QCString &relPath, const QCString &ref, bool href)
Definition util.cpp:6066
QCString externalLinkTarget(const bool parent)
Definition util.cpp:6022
void addHtmlExtensionIfMissing(QCString &fName)
Definition util.cpp:5243

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()

static void writeSVGNotSupported ( TextStream & out)
static

Definition at line 569 of file dotfilepatcher.cpp.

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

Referenced by DotFilePatcher::writeSVGFigureLink().

Variable Documentation

◆ svgZoomFooter1

const char svgZoomFooter1[]
static
Initial value:
= 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 82 of file dotfilepatcher.cpp.

Referenced by DotFilePatcher::run().

◆ svgZoomFooter2

const char svgZoomFooter2[]
static
Initial value:
= 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 107 of file dotfilepatcher.cpp.

Referenced by DotFilePatcher::run().

◆ svgZoomHeader0

const char svgZoomHeader0[]
static
Initial value:
= 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 29 of file dotfilepatcher.cpp.

Referenced by DotFilePatcher::run().

◆ svgZoomHeader0_noinit

const char svgZoomHeader0_noinit[]
static
Initial value:
= 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 33 of file dotfilepatcher.cpp.

Referenced by DotFilePatcher::run().

◆ svgZoomHeader1

const char svgZoomHeader1[]
static
Initial value:
= 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 37 of file dotfilepatcher.cpp.

Referenced by DotFilePatcher::run().

◆ svgZoomHeader2

const char svgZoomHeader2[]
static

Definition at line 47 of file dotfilepatcher.cpp.

Referenced by DotFilePatcher::run().