diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/docbookvisitor.cpp | 11 | ||||
-rw-r--r-- | src/docbookvisitor.h | 4 | ||||
-rw-r--r-- | src/docparser.cpp | 49 | ||||
-rw-r--r-- | src/docparser.h | 4 | ||||
-rw-r--r-- | src/htmldocvisitor.cpp | 62 | ||||
-rw-r--r-- | src/latexdocvisitor.cpp | 59 | ||||
-rw-r--r-- | src/printdocvisitor.h | 2 | ||||
-rw-r--r-- | src/rtfdocvisitor.cpp | 61 | ||||
-rw-r--r-- | src/rtfdocvisitor.h | 10 | ||||
-rw-r--r-- | src/xmldocvisitor.cpp | 7 |
10 files changed, 198 insertions, 71 deletions
diff --git a/src/docbookvisitor.cpp b/src/docbookvisitor.cpp index 5696087..7a948ec 100644 --- a/src/docbookvisitor.cpp +++ b/src/docbookvisitor.cpp @@ -48,7 +48,8 @@ #define DB_VIS_C2(y) #define DB_VIS_C2a(x,y) #endif -void visitPreStart(FTextStream &t, const bool hasCaption, QCString name, QCString width, QCString height) + +void visitPreStart(FTextStream &t, bool hasCaption, QCString name, QCString width, QCString height, bool inlineImage) { QCString tmpStr; if (hasCaption) @@ -68,7 +69,7 @@ void visitPreStart(FTextStream &t, const bool hasCaption, QCString name, QCStri } else { - t << " width=\"50%\""; + if (!inlineImage) t << " width=\"50%\""; } if (!height.isEmpty()) { @@ -83,7 +84,7 @@ void visitPreStart(FTextStream &t, const bool hasCaption, QCString name, QCStri } } -void visitPostEnd(FTextStream &t, const bool hasCaption) +void visitPostEnd(FTextStream &t, bool hasCaption, bool inlineImage) { t << endl; if (hasCaption) @@ -1164,7 +1165,7 @@ DB_VIS_C { baseName=baseName.right(baseName.length()-i-1); } - visitPreStart(m_t, img -> hasCaption(), img->relPath() + baseName, img -> width(), img -> height()); + visitPreStart(m_t, img -> hasCaption(), img->relPath() + baseName, img -> width(), img -> height(),img -> isInlineImage()); } else { @@ -1179,7 +1180,7 @@ DB_VIS_C if (img->type()==DocImage::DocBook) { if (m_hide) return; - visitPostEnd(m_t, img -> hasCaption()); + visitPostEnd(m_t, img -> hasCaption(),img -> isInlineImage()); // copy the image to the output dir QCString baseName=img->name(); int i; diff --git a/src/docbookvisitor.h b/src/docbookvisitor.h index bf1c3b2..714b679 100644 --- a/src/docbookvisitor.h +++ b/src/docbookvisitor.h @@ -26,8 +26,8 @@ class FTextStream; class CodeOutputInterface; class QCString; -void visitPreStart(FTextStream &t, const bool hasCaption, QCString name, QCString width, QCString height); -void visitPostEnd(FTextStream &t, const bool hasCaption); +void visitPreStart(FTextStream &t, bool hasCaption, QCString name, QCString width, QCString height, bool inlineImage=FALSE); +void visitPostEnd(FTextStream &t, bool hasCaption, bool inlineImage = FALSE); /*! @brief Concrete visitor implementation for Docbook output. */ class DocbookDocVisitor : public DocVisitor diff --git a/src/docparser.cpp b/src/docparser.cpp index 02591e3..b414e8f 100644 --- a/src/docparser.cpp +++ b/src/docparser.cpp @@ -2978,10 +2978,10 @@ void DocVhdlFlow::parse() //--------------------------------------------------------------------------- DocImage::DocImage(DocNode *parent,const HtmlAttribList &attribs,const QCString &name, - Type t,const QCString &url) : - m_attribs(attribs), m_name(name), + Type t,const QCString &url, bool inlineImage) : + m_attribs(attribs), m_name(name), m_type(t), m_relPath(g_relPath), - m_url(url) + m_url(url), m_inlineImage(inlineImage) { m_parent = parent; } @@ -5061,13 +5061,50 @@ void DocPara::handleIncludeOperator(const QCString &cmdName,DocIncOperator::Type void DocPara::handleImage(const QCString &cmdName) { QCString saveCmdName = cmdName; + bool inlineImage = FALSE; int tok=doctokenizerYYlex(); if (tok!=TK_WHITESPACE) { - warn_doc_error(g_fileName,doctokenizerYYlineno,"expected whitespace after %s command", + if (tok==TK_WORD) + { + if (g_token->name == "{") + { + while ((tok=doctokenizerYYlex())==TK_WHITESPACE); + if (g_token->name != "}") // non-empty option string + { + if (g_token->name.lower() != "inline") + { + warn_doc_error(g_fileName,doctokenizerYYlineno,"currently only 'inline' suported as option of %s command", + qPrint(saveCmdName)); + } + else + { + inlineImage = TRUE; + } + while ((tok=doctokenizerYYlex())==TK_WHITESPACE); + } + if (!((tok==TK_WORD) && (g_token->name == "}"))) + { + warn_doc_error(g_fileName,doctokenizerYYlineno,"expected closing '}' at option of %s command", + qPrint(saveCmdName)); + return; + } + tok=doctokenizerYYlex(); + if (tok!=TK_WHITESPACE) + { + warn_doc_error(g_fileName,doctokenizerYYlineno,"expected whitespace after %s command with option", + qPrint(saveCmdName)); + return; + } + } + } + else + { + warn_doc_error(g_fileName,doctokenizerYYlineno,"expected whitespace after %s command", qPrint(saveCmdName)); - return; + return; + } } tok=doctokenizerYYlex(); if (tok!=TK_WORD && tok!=TK_LNKWORD) @@ -5106,7 +5143,7 @@ void DocPara::handleImage(const QCString &cmdName) return; } HtmlAttribList attrList; - DocImage *img = new DocImage(this,attrList,findAndCopyImage(g_token->name,t),t); + DocImage *img = new DocImage(this,attrList,findAndCopyImage(g_token->name,t),t,"",inlineImage); m_children.append(img); img->parse(); } diff --git a/src/docparser.h b/src/docparser.h index c107711..e98198d 100644 --- a/src/docparser.h +++ b/src/docparser.h @@ -756,7 +756,7 @@ class DocImage : public CompAccept<DocImage> public: enum Type { Html, Latex, Rtf, DocBook }; DocImage(DocNode *parent,const HtmlAttribList &attribs, - const QCString &name,Type t,const QCString &url=QCString()); + const QCString &name,Type t,const QCString &url=QCString(), bool inlineImage = TRUE); Kind kind() const { return Kind_Image; } Type type() const { return m_type; } QCString name() const { return m_name; } @@ -765,6 +765,7 @@ class DocImage : public CompAccept<DocImage> QCString height() const { return m_height; } QCString relPath() const { return m_relPath; } QCString url() const { return m_url; } + bool isInlineImage() const { return m_inlineImage; } const HtmlAttribList &attribs() const { return m_attribs; } void parse(); @@ -776,6 +777,7 @@ class DocImage : public CompAccept<DocImage> QCString m_height; QCString m_relPath; QCString m_url; + bool m_inlineImage; }; /** Node representing a dot file */ diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp index 0af5b16..ba10ca1 100644 --- a/src/htmldocvisitor.cpp +++ b/src/htmldocvisitor.cpp @@ -152,7 +152,7 @@ static bool mustBeOutsideParagraph(DocNode *n) return FALSE; } -static QString htmlAttribsToString(const HtmlAttribList &attribs, const bool img_tag = FALSE) +static QString htmlAttribsToString(const HtmlAttribList &attribs, bool img_tag = FALSE) { QString result; HtmlAttribListIterator li(attribs); @@ -1547,7 +1547,19 @@ void HtmlDocVisitor::visitPre(DocImage *img) { if (img->type()==DocImage::Html) { - forceEndParagraph(img); + bool inlineImage = img->isInlineImage(); + bool typeSVG = FALSE; + + QCString url = img->url(); + if (url.isEmpty()) + { + typeSVG = (img->name().right(4)==".svg"); + } + else + { + typeSVG = (url.right(4)==".svg"); + } + if (!inlineImage && !typeSVG) forceEndParagraph(img); if (m_hide) return; QString baseName=img->name(); int i; @@ -1555,8 +1567,7 @@ void HtmlDocVisitor::visitPre(DocImage *img) { baseName=baseName.right(baseName.length()-i-1); } - m_t << "<div class=\"image\">" << endl; - QCString url = img->url(); + if (!inlineImage && !typeSVG) m_t << "<div class=\"image\">" << endl; QCString sizeAttribs; if (!img->width().isEmpty()) { @@ -1578,7 +1589,7 @@ void HtmlDocVisitor::visitPre(DocImage *img) { m_t << "<img src=\"" << img->relPath() << img->name() << "\" alt=\"" << baseName << "\"" << sizeAttribs << htmlAttribsToString(img->attribs()) - << "/>" << endl; + << (inlineImage ? " class=\"inline\"" : "/>\n"); } } else @@ -1592,13 +1603,24 @@ void HtmlDocVisitor::visitPre(DocImage *img) { m_t << "<img src=\"" << correctURL(url,img->relPath()) << "\"" << sizeAttribs << htmlAttribsToString(img->attribs(), TRUE) - << "/>" << endl; + << (inlineImage ? " class=\"inline\"" : "/>\n"); } } if (img->hasCaption()) { - m_t << "<div class=\"caption\">" << endl; - m_t << getHtmlDirEmbedingChar(getTextDirByConfig(img)); + if (inlineImage) + { + m_t << " title=\""; + } + else + { + m_t << "<div class=\"caption\">" << endl; + m_t << getHtmlDirEmbedingChar(getTextDirByConfig(img)); + } + } + else if (inlineImage) + { + m_t << "/>" << endl; } } else // other format -> skip @@ -1613,12 +1635,30 @@ void HtmlDocVisitor::visitPost(DocImage *img) if (img->type()==DocImage::Html) { if (m_hide) return; + bool inlineImage = img->isInlineImage(); + bool typeSVG = FALSE; + QCString url = img->url(); + if (url.isEmpty()) + { + typeSVG = (img->name().right(4)==".svg"); + } + else + { + typeSVG = (url.right(4)==".svg"); + } + //if (!inlineImage && img->hasCaption()) if (img->hasCaption()) { - m_t << "</div>"; + if (inlineImage) + m_t << "\"/>\n "; + else + m_t << "</div>"; + } + if (!inlineImage && !typeSVG) + { + m_t << "</div>" << endl; + forceStartParagraph(img); } - m_t << "</div>" << endl; - forceStartParagraph(img); } else // other format { diff --git a/src/latexdocvisitor.cpp b/src/latexdocvisitor.cpp index 3a6efaa..7663572 100644 --- a/src/latexdocvisitor.cpp +++ b/src/latexdocvisitor.cpp @@ -49,16 +49,23 @@ static const char *getSectionName(int level) return secLabels[QMIN(maxLevels-1,l)]; } -static void visitPreStart(FTextStream &t, const bool hasCaption, QCString name, QCString width, QCString height) +static void visitPreStart(FTextStream &t, bool hasCaption, QCString name, QCString width, QCString height, bool inlineImage = FALSE) { - if (hasCaption) + if (inlineImage) { - t << "\n\\begin{DoxyImage}\n"; + t << "\n\\begin{DoxyInlineImage}\n"; } else { - t << "\n\\begin{DoxyImageNoCaption}\n" - " \\mbox{"; + if (hasCaption) + { + t << "\n\\begin{DoxyImage}\n"; + } + else + { + t << "\n\\begin{DoxyImageNoCaption}\n" + " \\mbox{"; + } } t << "\\includegraphics"; @@ -81,7 +88,14 @@ static void visitPreStart(FTextStream &t, const bool hasCaption, QCString name, if (width.isEmpty() && height.isEmpty()) { /* default setting */ - t << "[width=\\textwidth,height=\\textheight/2,keepaspectratio=true]"; + if (inlineImage) + { + t << "[height=\\baselineskip,keepaspectratio=true]"; + } + else + { + t << "[width=\\textwidth,height=\\textheight/2,keepaspectratio=true]"; + } } else { @@ -92,21 +106,36 @@ static void visitPreStart(FTextStream &t, const bool hasCaption, QCString name, if (hasCaption) { - t << "\n\\doxyfigcaption{"; + if (!inlineImage) + { + t << "\n\\doxyfigcaption{"; + } + else + { + t << "%"; // to catch the caption + } } } -static void visitPostEnd(FTextStream &t, const bool hasCaption) +static void visitPostEnd(FTextStream &t, bool hasCaption, bool inlineImage = FALSE) { - t << "}\n"; // end mbox or caption - if (hasCaption) + if (inlineImage) { - t << "\\end{DoxyImage}\n"; + t << "\n\\end{DoxyInlineImage}\n"; } - else{ - t << "\\end{DoxyImageNoCaption}\n"; + else + { + t << "}\n"; // end mbox or caption + if (hasCaption) + { + t << "\\end{DoxyImage}\n"; + } + else + { + t << "\\end{DoxyImageNoCaption}\n"; + } } } @@ -1338,7 +1367,7 @@ void LatexDocVisitor::visitPre(DocImage *img) gfxName=gfxName.left(gfxName.length()-4); } - visitPreStart(m_t,img->hasCaption(), gfxName, img->width(), img->height()); + visitPreStart(m_t,img->hasCaption(), gfxName, img->width(), img->height(), img->isInlineImage()); } else // other format -> skip { @@ -1352,7 +1381,7 @@ void LatexDocVisitor::visitPost(DocImage *img) if (img->type()==DocImage::Latex) { if (m_hide) return; - visitPostEnd(m_t,img->hasCaption()); + visitPostEnd(m_t,img->hasCaption(), img->isInlineImage()); } else // other format { diff --git a/src/printdocvisitor.h b/src/printdocvisitor.h index e95d72b..17d938e 100644 --- a/src/printdocvisitor.h +++ b/src/printdocvisitor.h @@ -510,7 +510,7 @@ class PrintDocVisitor : public DocVisitor case DocImage::Rtf: printf("rtf"); break; case DocImage::DocBook: printf("docbook"); break; } - printf("\" %s %s>\n",img->width().data(),img->height().data()); + printf("\" %s %s inline=\"%s\">\n",img->width().data(),img->height().data(),img->isInlineImage() ? "yes" : "no"); } void visitPost(DocImage *) { diff --git a/src/rtfdocvisitor.cpp b/src/rtfdocvisitor.cpp index c72c951..658950a 100644 --- a/src/rtfdocvisitor.cpp +++ b/src/rtfdocvisitor.cpp @@ -1137,27 +1137,37 @@ void RTFDocVisitor::visitPost(DocHtmlHeader *) void RTFDocVisitor::visitPre(DocImage *img) { DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocImage)}\n"); - includePicturePreRTF(img->name(), img->type()==DocImage::Rtf, img->hasCaption()); + includePicturePreRTF(img->name(), img->type()==DocImage::Rtf, img->hasCaption(), img->isInlineImage()); } - -void RTFDocVisitor::includePicturePreRTF(const QCString name, const bool isTypeRTF, const bool hasCaption) +void RTFDocVisitor::includePicturePreRTF(const QCString name, bool isTypeRTF, bool hasCaption, bool inlineImage) { if (isTypeRTF) { - m_t << "\\par" << endl; - m_t << "{" << endl; - m_t << rtf_Style_Reset << endl; - if (hasCaption || m_lastIsPara) m_t << "\\par" << endl; - m_t << "\\pard \\qc { \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \""; + if (!inlineImage) + { + m_t << "\\par" << endl; + m_t << "{" << endl; + m_t << rtf_Style_Reset << endl; + if (hasCaption || m_lastIsPara) m_t << "\\par" << endl; + m_t << "\\pard \\qc "; + } + m_t << "{ \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \""; m_t << name; m_t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}" << endl; - m_t << "\\par" << endl; - if (hasCaption) + if (!inlineImage) + { + m_t << "\\par" << endl; + if (hasCaption) + { + m_t << "\\pard \\qc \\b"; + m_t << "{Image \\field\\flddirty{\\*\\fldinst { SEQ Image \\\\*Arabic }}{\\fldrslt {\\noproof 1}} "; + } + m_lastIsPara=TRUE; + } + else { - m_t << "\\pard \\qc \\b"; - m_t << "{Image \\field\\flddirty{\\*\\fldinst { SEQ Image \\\\*Arabic }}{\\fldrslt {\\noproof 1}} "; + if (hasCaption) m_t << "{\\comment "; // to prevent caption to be shown } - m_lastIsPara=TRUE; } else // other format -> skip { @@ -1169,22 +1179,29 @@ void RTFDocVisitor::includePicturePreRTF(const QCString name, const bool isTypeR void RTFDocVisitor::visitPost(DocImage *img) { DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocImage)}\n"); - includePicturePostRTF(img->type()==DocImage::Rtf, img->hasCaption()); + includePicturePostRTF(img->type()==DocImage::Rtf, img->hasCaption(), img->isInlineImage()); } -void RTFDocVisitor::includePicturePostRTF(const bool isTypeRTF, const bool hasCaption) +void RTFDocVisitor::includePicturePostRTF(bool isTypeRTF, bool hasCaption, bool inlineImage) { if (isTypeRTF) { if (m_hide) return; - if (hasCaption) + if (inlineImage) { - m_t << "}" <<endl; - m_t << "\\par}" <<endl; + if (hasCaption) m_t << " }"; } else { - m_t << "}" <<endl; + if (hasCaption) + { + m_t << "}" <<endl; + m_t << "\\par}" <<endl; + } + else + { + m_t << "}" <<endl; + } } } else @@ -1800,7 +1817,7 @@ void RTFDocVisitor::writeDotFile(DocDotFile *df) { writeDotFile(df->file(), df->hasCaption()); } -void RTFDocVisitor::writeDotFile(const QCString &filename, const bool hasCaption) +void RTFDocVisitor::writeDotFile(const QCString &filename, bool hasCaption) { QCString baseName=filename; int i; @@ -1818,7 +1835,7 @@ void RTFDocVisitor::writeMscFile(DocMscFile *df) { writeMscFile(df->file(), df->hasCaption()); } -void RTFDocVisitor::writeMscFile(const QCString &fileName, const bool hasCaption) +void RTFDocVisitor::writeMscFile(const QCString &fileName, bool hasCaption) { QCString baseName=fileName; int i; @@ -1844,7 +1861,7 @@ void RTFDocVisitor::writeDiaFile(DocDiaFile *df) includePicturePreRTF(baseName + ".png", true, df->hasCaption()); } -void RTFDocVisitor::writePlantUMLFile(const QCString &fileName, const bool hasCaption) +void RTFDocVisitor::writePlantUMLFile(const QCString &fileName, bool hasCaption) { QCString baseName=fileName; int i; diff --git a/src/rtfdocvisitor.h b/src/rtfdocvisitor.h index ac78a85..b7cc3ea 100644 --- a/src/rtfdocvisitor.h +++ b/src/rtfdocvisitor.h @@ -153,14 +153,14 @@ class RTFDocVisitor : public DocVisitor void pushEnabled(); void popEnabled(); - void includePicturePreRTF(const QCString name, const bool isTypeRTF, const bool hasCaption); - void includePicturePostRTF(const bool isTypeRTF, const bool hasCaption); - void writeDotFile(const QCString &fileName, const bool hasCaption); + void includePicturePreRTF(const QCString name, bool isTypeRTF, bool hasCaption, bool inlineImage = FALSE); + void includePicturePostRTF(bool isTypeRTF, bool hasCaption, bool inlineImage = FALSE); + void writeDotFile(const QCString &fileName, bool hasCaption); void writeDotFile(DocDotFile *); - void writeMscFile(const QCString &fileName, const bool hasCaption); + void writeMscFile(const QCString &fileName, bool hasCaption); void writeMscFile(DocMscFile *); void writeDiaFile(DocDiaFile *); - void writePlantUMLFile(const QCString &fileName, const bool hasCaption); + void writePlantUMLFile(const QCString &fileName, bool hasCaption); //-------------------------------------- // state variables diff --git a/src/xmldocvisitor.cpp b/src/xmldocvisitor.cpp index 04d9d8e..4aa81ca 100644 --- a/src/xmldocvisitor.cpp +++ b/src/xmldocvisitor.cpp @@ -40,10 +40,10 @@ static void visitCaption(XmlDocVisitor *parent, QList<DocNode> children) for (cli.toFirst();(n=cli.current());++cli) n->accept(parent); } -static void visitPreStart(FTextStream &t, const char *cmd, const bool doCaption, +static void visitPreStart(FTextStream &t, const char *cmd, bool doCaption, XmlDocVisitor *parent, QList<DocNode> children, const QCString &name, bool writeType, DocImage::Type type, const QCString &width, - const QCString &height) + const QCString &height, bool inlineImage = FALSE) { t << "<" << cmd; if (writeType) @@ -70,6 +70,7 @@ static void visitPreStart(FTextStream &t, const char *cmd, const bool doCaption, { t << " height=\"" << convertToXML(height) << "\""; } + if (inlineImage) t << " inline=\"yes\">"; if (doCaption) { t << " caption=\""; @@ -788,7 +789,7 @@ void XmlDocVisitor::visitPre(DocImage *img) { baseName=baseName.right(baseName.length()-i-1); } - visitPreStart(m_t, "image", FALSE, this, img->children(), baseName, TRUE, img->type(), img->width(), img->height()); + visitPreStart(m_t, "image", FALSE, this, img->children(), baseName, TRUE, img->type(), img->width(), img->height(), img ->isInlineImage()); // copy the image to the output dir FileDef *fd; |