diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/docparser.cpp | 5 | ||||
-rw-r--r-- | src/docparser.h | 1 | ||||
-rw-r--r-- | src/doctokenizer.l | 1 | ||||
-rw-r--r-- | src/htmldocvisitor.cpp | 89 | ||||
-rw-r--r-- | src/xmldocvisitor.cpp | 5 |
5 files changed, 75 insertions, 26 deletions
diff --git a/src/docparser.cpp b/src/docparser.cpp index 424bfdc..c91dcde 100644 --- a/src/docparser.cpp +++ b/src/docparser.cpp @@ -2981,6 +2981,11 @@ DocImage::DocImage(DocNode *parent,const HtmlAttribList &attribs,const QCString m_parent = parent; } +bool DocImage::isSVG() const +{ + return m_url.isEmpty() ? m_name.right(4)==".svg" : m_url.right(4)==".svg"; +} + void DocImage::parse() { defaultHandleTitleAndSize(CMD_IMAGE,this,m_children,m_width,m_height); diff --git a/src/docparser.h b/src/docparser.h index ca32b20..5d2cc89 100644 --- a/src/docparser.h +++ b/src/docparser.h @@ -768,6 +768,7 @@ class DocImage : public CompAccept<DocImage> QCString relPath() const { return m_relPath; } QCString url() const { return m_url; } bool isInlineImage() const { return m_inlineImage; } + bool isSVG() const; const HtmlAttribList &attribs() const { return m_attribs; } void parse(); diff --git a/src/doctokenizer.l b/src/doctokenizer.l index eb14470..90f9846 100644 --- a/src/doctokenizer.l +++ b/src/doctokenizer.l @@ -1008,6 +1008,7 @@ REFWORD_NOCV {FILEMASK}|{LABELID}|{REFWORD2_NOCV}|{REFWORD3}|{REFWORD4_NOCV} return 0; } <St_TitleV,St_TitleA>\n { + unput(*yytext); return 0; } diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp index 6386cb8..f89f79e 100644 --- a/src/htmldocvisitor.cpp +++ b/src/htmldocvisitor.cpp @@ -1610,17 +1610,9 @@ void HtmlDocVisitor::visitPre(DocImage *img) if (img->type()==DocImage::Html) { bool inlineImage = img->isInlineImage(); - bool typeSVG = FALSE; - + bool typeSVG = img->isSVG(); QCString url = img->url(); - if (url.isEmpty()) - { - typeSVG = (img->name().right(4)==".svg"); - } - else - { - typeSVG = (url.right(4)==".svg"); - } + if (!inlineImage) { forceEndParagraph(img); @@ -1642,41 +1634,70 @@ void HtmlDocVisitor::visitPre(DocImage *img) { sizeAttribs+=" height=\""+img->height()+"\""; } + // 16 cases: url.isEmpty() | typeSVG | inlineImage | img->hasCaption() if (url.isEmpty()) { if (typeSVG) { - m_t << "<object type=\"image/svg+xml\" data=\"" << img->relPath() << img->name() - << "\"" << sizeAttribs << htmlAttribsToString(img->attribs()) << ">" << baseName - << "</object>" << endl; + m_t << "<object type=\"image/svg+xml\" style=\"pointer-events: none;\" data=\"" << img->relPath() << img->name() + << "\"" << sizeAttribs << htmlAttribsToString(img->attribs()); + if (inlineImage) + { + // skip closing tag + } + else + { + m_t << "></object>" << endl; + } } else { m_t << "<img src=\"" << img->relPath() << img->name() << "\" alt=\"" - << baseName << "\"" << sizeAttribs << htmlAttribsToString(img->attribs()) - << (inlineImage ? " class=\"inline\"" : "/>\n"); + << baseName << "\"" << sizeAttribs << htmlAttribsToString(img->attribs()); + if (inlineImage) + { + m_t << " class=\"inline\""; + } + else + { + m_t << "/>\n"; + } } } else // link to URL { if (typeSVG) { - m_t << "<object type=\"image/svg+xml\" data=\"" << correctURL(url,img->relPath()) - << "\"" << sizeAttribs << htmlAttribsToString(img->attribs()) - << "></object>" << endl; + m_t << "<object type=\"image/svg+xml\" style=\"pointer-events: none;\" data=\"" << correctURL(url,img->relPath()) + << "\"" << sizeAttribs << htmlAttribsToString(img->attribs()); + if (inlineImage) + { + // skip closing > + } + else + { + m_t << "></object>" << endl; + } } else { m_t << "<img src=\"" << correctURL(url,img->relPath()) << "\"" - << sizeAttribs << htmlAttribsToString(img->attribs(), TRUE) - << (inlineImage ? " class=\"inline\"" : "/>\n"); + << sizeAttribs << htmlAttribsToString(img->attribs(), TRUE); + if (inlineImage) + { + m_t << " class=\"inline\""; // skip closing > + } + else + { + m_t << "/>\n"; + } } } if (img->hasCaption()) { if (inlineImage) { - m_t << " title=\""; + m_t << " title=\""; } else { @@ -1686,7 +1707,14 @@ void HtmlDocVisitor::visitPre(DocImage *img) } else if (inlineImage) { - m_t << "/>" << endl; + if (typeSVG) + { + m_t << "></object>"; + } + else + { + m_t << "/>"; + } } } else // other format -> skip @@ -1705,11 +1733,22 @@ void HtmlDocVisitor::visitPost(DocImage *img) if (img->hasCaption()) { if (inlineImage) - m_t << "\"/>\n "; - else + { + if (img->isSVG()) + { + m_t << "\"></object>"; + } + else + { + m_t << "\"/>"; + } + } + else // end <div class="caption"> + { m_t << "</div>"; + } } - if (!inlineImage) + if (!inlineImage) // end <div class="image"> { m_t << "</div>" << endl; forceStartParagraph(img); diff --git a/src/xmldocvisitor.cpp b/src/xmldocvisitor.cpp index a65695c..e464088 100644 --- a/src/xmldocvisitor.cpp +++ b/src/xmldocvisitor.cpp @@ -70,7 +70,10 @@ static void visitPreStart(FTextStream &t, const char *cmd, bool doCaption, { t << " height=\"" << convertToXML(height) << "\""; } - if (inlineImage) t << " inline=\"yes\">"; + if (inlineImage) + { + t << " inline=\"yes\""; + } if (doCaption) { t << " caption=\""; |