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 "stringutil.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 545 of file dotfilepatcher.cpp.

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}
std::ifstream openInputStream(const QCString &name, bool binary=false, bool openAtEnd=false)
Definition portable.cpp:676
#define FALSE
Definition qcstring.h:34
bool literal_at(const char *data, const char(&str)[N])
returns TRUE iff data points to a substring that matches string literal str
Definition stringutil.h:98
bool found
Definition util.cpp:984

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

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 124 of file dotfilepatcher.cpp.

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}
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:55
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:6222
QCString externalLinkTarget(const bool parent)
Definition util.cpp:6178
void addHtmlExtensionIfMissing(QCString &fName)
Definition util.cpp:5399

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

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 83 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 108 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 30 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 34 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 38 of file dotfilepatcher.cpp.

Referenced by DotFilePatcher::run().

◆ svgZoomHeader2

const char svgZoomHeader2[]
static

Definition at line 48 of file dotfilepatcher.cpp.

Referenced by DotFilePatcher::run().