diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2016-01-07 18:31:24 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 2016-01-07 18:31:24 (GMT) |
commit | 98d170c818333ef8a7fb6ae0fd3a0e589cc59a55 (patch) | |
tree | 4a7c4a8f7080e8514bf4ade5ed784405077f91ba /src | |
parent | 5dee6e8aab6f8c76203a3296ef374e035cf55d34 (diff) | |
parent | 0ec4637bc15d18563c74dc09d7c396cd54974484 (diff) | |
download | Doxygen-98d170c818333ef8a7fb6ae0fd3a0e589cc59a55.zip Doxygen-98d170c818333ef8a7fb6ae0fd3a0e589cc59a55.tar.gz Doxygen-98d170c818333ef8a7fb6ae0fd3a0e589cc59a55.tar.bz2 |
Merge branch 'master' of github.com:doxygen/doxygen
Diffstat (limited to 'src')
-rw-r--r-- | src/fortranscanner.l | 32 | ||||
-rw-r--r-- | src/rtfdocvisitor.cpp | 171 | ||||
-rw-r--r-- | src/rtfdocvisitor.h | 12 |
3 files changed, 123 insertions, 92 deletions
diff --git a/src/fortranscanner.l b/src/fortranscanner.l index bd1fe83..45e1686 100644 --- a/src/fortranscanner.l +++ b/src/fortranscanner.l @@ -214,7 +214,7 @@ static bool endScope(Entry *scope, bool isGlobalRoot=FALSE); //static bool isTypeName(QCString name); static void resolveModuleProcedures(QList<Entry> &moduleProcedures, Entry *current_root); static int getAmpersandAtTheStart(const char *buf, int length); -static int getAmpOrExclAtTheEnd(const char *buf, int length); +static int getAmpOrExclAtTheEnd(const char *buf, int length, char ch); static void truncatePrepass(int index); static void pushBuffer(QCString &buffer); static void popBuffer(); @@ -328,7 +328,7 @@ SCOPENAME ({ID}{BS}"::"{BS})* DBG_CTX((stderr, "---%s", yytext)); int indexStart = getAmpersandAtTheStart(yytext, (int)yyleng); - int indexEnd = getAmpOrExclAtTheEnd(yytext, (int)yyleng); + int indexEnd = getAmpOrExclAtTheEnd(yytext, (int)yyleng, '\0'); if (indexEnd>=0 && yytext[indexEnd]!='&') //we are only interested in amp indexEnd=-1; @@ -686,9 +686,12 @@ private { // in a scope of their own, even if multiple // are group in one INTERFACE/END INTERFACE block. // - last_entry->endBodyLine = yyLineNr - 1; if (ifType == IF_ABSTRACT || ifType == IF_SPECIFIC) + { endScope(current_root); + last_entry->endBodyLine = yyLineNr - 1; + } + current_root->endBodyLine = yyLineNr - 1; if (!endScope(current_root)) yyterminate(); @@ -1273,13 +1276,15 @@ static int getAmpersandAtTheStart(const char *buf, int length) } /* Returns ampersand index, comment start index or -1 if neither exist.*/ -static int getAmpOrExclAtTheEnd(const char *buf, int length) +static int getAmpOrExclAtTheEnd(const char *buf, int length, char ch) { // Avoid ampersands in string and comments int parseState = Start; char quoteSymbol = 0; int ampIndex = -1; int commentIndex = -1; + quoteSymbol = ch; + if (ch != '\0') parseState = String; for(int i=0; i<length && parseState!=Comment; i++) { @@ -1410,6 +1415,8 @@ static const char* prepassFixedForm(const char* contents) int column=0; int prevLineLength=0; int prevLineAmpOrExclIndex=-1; + char prevQuote = '\0'; + char thisQuote = '\0'; bool emptyLabel=TRUE; bool commented=FALSE; bool inSingle=FALSE; @@ -1429,11 +1436,12 @@ static const char* prepassFixedForm(const char* contents) switch(c) { case '\n': prevLineLength=column; - prevLineAmpOrExclIndex=getAmpOrExclAtTheEnd(&contents[i-prevLineLength+1], prevLineLength); + prevLineAmpOrExclIndex=getAmpOrExclAtTheEnd(&contents[i-prevLineLength+1], prevLineLength,prevQuote); column=0; emptyLabel=TRUE; commented=FALSE; newContents[j]=c; + prevQuote = thisQuote; break; case ' ': case '\t': @@ -1464,12 +1472,22 @@ static const char* prepassFixedForm(const char* contents) } else if (c == '\'') { - if (!inDouble) inSingle = !inSingle; + if (!inDouble) + { + inSingle = !inSingle; + if (inSingle) thisQuote = c; + else thisQuote = '\0'; + } break; } else if (c == '"') { - if (!inSingle) inDouble = !inDouble; + if (!inSingle) + { + inDouble = !inDouble; + if (inDouble) thisQuote = c; + else thisQuote = '\0'; + } break; } } diff --git a/src/rtfdocvisitor.cpp b/src/rtfdocvisitor.cpp index 2ea35cc..cb3b34c 100644 --- a/src/rtfdocvisitor.cpp +++ b/src/rtfdocvisitor.cpp @@ -231,6 +231,13 @@ void RTFDocVisitor::visit(DocStyleChange *s) } } +static void visitCaption(RTFDocVisitor *parent, QList<DocNode> children) +{ + QListIterator<DocNode> cli(children); + DocNode *n; + for (cli.toFirst();(n=cli.current());++cli) n->accept(parent); +} + void RTFDocVisitor::visit(DocVerbatim *s) { if (m_hide) return; @@ -288,9 +295,11 @@ void RTFDocVisitor::visit(DocVerbatim *s) } file.writeBlock( s->text(), s->text().length() ); file.close(); - m_t << "\\par{\\qc "; // center picture - writeDotFile(fileName); - m_t << "} "; + + writeDotFile(fileName, s->hasCaption()); + visitCaption(this, s->children()); + includePicturePostRTF(true, s->hasCaption()); + if (Config_getBool("DOT_CLEANUP")) file.remove(); } break; @@ -314,9 +323,11 @@ void RTFDocVisitor::visit(DocVerbatim *s) text+="}"; file.writeBlock( text, text.length() ); file.close(); - m_t << "\\par{\\qc "; // center picture - writeMscFile(baseName); - m_t << "} "; + + writeMscFile(baseName, s->hasCaption()); + visitCaption(this, s->children()); + includePicturePostRTF(true, s->hasCaption()); + if (Config_getBool("DOT_CLEANUP")) file.remove(); } break; @@ -325,9 +336,9 @@ void RTFDocVisitor::visit(DocVerbatim *s) static QCString rtfOutput = Config_getString("RTF_OUTPUT"); QCString baseName = writePlantUMLSource(rtfOutput,s->exampleFile(),s->text()); - m_t << "\\par{\\qc "; // center picture - writePlantUMLFile(baseName); - m_t << "} "; + writePlantUMLFile(baseName, s->hasCaption()); + visitCaption(this, s->children()); + includePicturePostRTF(true, s->hasCaption()); } break; } @@ -1022,76 +1033,95 @@ void RTFDocVisitor::visitPost(DocHtmlHeader *) void RTFDocVisitor::visitPre(DocImage *img) { DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocImage)}\n"); - if (img->type()==DocImage::Rtf) + includePicturePreRTF(img->name(), img->type()==DocImage::Rtf, img->hasCaption()); +} + +void RTFDocVisitor::includePicturePreRTF(const QCString name, const bool isTypeRTF, const bool hasCaption) +{ + if (isTypeRTF) { m_t << "\\par" << endl; m_t << "{" << endl; m_t << rtf_Style_Reset << endl; - m_t << "\\par\\pard \\qc {\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \""; - m_t << img->name(); - m_t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par" << endl; - m_t << "}" << endl; + if (hasCaption || m_lastIsPara) m_t << "\\par" << endl; + m_t << "\\pard \\qc { \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \""; + m_t << name; + m_t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}" << endl; + 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 // other format -> skip { + pushEnabled(); + m_hide=TRUE; } - // hide caption since it is not supported at the moment - pushEnabled(); - m_hide=TRUE; } -void RTFDocVisitor::visitPost(DocImage *) +void RTFDocVisitor::visitPost(DocImage *img) { DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocImage)}\n"); - popEnabled(); + includePicturePostRTF(img->type()==DocImage::Rtf, img->hasCaption()); +} + +void RTFDocVisitor::includePicturePostRTF(const bool isTypeRTF, const bool hasCaption) +{ + if (isTypeRTF) + { + if (m_hide) return; + if (hasCaption) + { + m_t << "}" <<endl; + m_t << "\\par}" <<endl; + } + else + { + m_t << "}" <<endl; + } + } + else + { + popEnabled(); + } } void RTFDocVisitor::visitPre(DocDotFile *df) { DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocDotFile)}\n"); - writeDotFile(df->file()); - - // hide caption since it is not supported at the moment - pushEnabled(); - m_hide=TRUE; + writeDotFile(df); } -void RTFDocVisitor::visitPost(DocDotFile *) +void RTFDocVisitor::visitPost(DocDotFile *df) { DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocDotFile)}\n"); - popEnabled(); + includePicturePostRTF(true, df->hasCaption()); } void RTFDocVisitor::visitPre(DocMscFile *df) { DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocMscFile)}\n"); - writeMscFile(df->file()); - - // hide caption since it is not supported at the moment - pushEnabled(); - m_hide=TRUE; + writeMscFile(df); } -void RTFDocVisitor::visitPost(DocMscFile *) +void RTFDocVisitor::visitPost(DocMscFile *df) { DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocMscFile)}\n"); - popEnabled(); + includePicturePostRTF(true, df->hasCaption()); } void RTFDocVisitor::visitPre(DocDiaFile *df) { DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocDiaFile)}\n"); - writeDiaFile(df->file()); - - // hide caption since it is not supported at the moment - pushEnabled(); - m_hide=TRUE; + writeDiaFile(df); } -void RTFDocVisitor::visitPost(DocDiaFile *) +void RTFDocVisitor::visitPost(DocDiaFile *df) { DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocDiaFile)}\n"); - popEnabled(); + includePicturePostRTF(true, df->hasCaption()); } void RTFDocVisitor::visitPre(DocLink *lnk) @@ -1662,28 +1692,29 @@ void RTFDocVisitor::popEnabled() delete v; } -void RTFDocVisitor::writeDotFile(const QCString &fileName) +void RTFDocVisitor::writeDotFile(DocDotFile *df) { - QCString baseName=fileName; + writeDotFile(df->file(), df->hasCaption()); +} +void RTFDocVisitor::writeDotFile(const QCString &filename, const bool hasCaption) +{ + QCString baseName=filename; int i; if ((i=baseName.findRev('/'))!=-1) { baseName=baseName.right(baseName.length()-i-1); } QCString outDir = Config_getString("RTF_OUTPUT"); - writeDotGraphFromFile(fileName,outDir,baseName,GOF_BITMAP); - if (!m_lastIsPara) m_t << "\\par" << endl; - m_t << "{" << endl; - m_t << rtf_Style_Reset; - m_t << "\\pard \\qc {\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \""; + writeDotGraphFromFile(filename,outDir,baseName,GOF_BITMAP); QCString imgExt = getDotImageExtension(); - m_t << baseName << "." << imgExt; - m_t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par" << endl; - m_t << "}" << endl; - m_lastIsPara=TRUE; + includePicturePreRTF(baseName + "." + imgExt, true, hasCaption); } -void RTFDocVisitor::writeMscFile(const QCString &fileName) +void RTFDocVisitor::writeMscFile(DocMscFile *df) +{ + writeMscFile(df->file(), df->hasCaption()); +} +void RTFDocVisitor::writeMscFile(const QCString &fileName, const bool hasCaption) { QCString baseName=fileName; int i; @@ -1693,37 +1724,23 @@ void RTFDocVisitor::writeMscFile(const QCString &fileName) } QCString outDir = Config_getString("RTF_OUTPUT"); writeMscGraphFromFile(fileName,outDir,baseName,MSC_BITMAP); - if (!m_lastIsPara) m_t << "\\par" << endl; - m_t << "{" << endl; - m_t << rtf_Style_Reset; - m_t << "\\pard \\qc {\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \""; - m_t << baseName << ".png"; - m_t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par" << endl; - m_t << "}" << endl; - m_lastIsPara=TRUE; + includePicturePreRTF(baseName + ".png", true, hasCaption); } -void RTFDocVisitor::writeDiaFile(const QCString &fileName) +void RTFDocVisitor::writeDiaFile(DocDiaFile *df) { - QCString baseName=fileName; + QCString baseName=df->file(); int i; if ((i=baseName.findRev('/'))!=-1) { baseName=baseName.right(baseName.length()-i-1); } QCString outDir = Config_getString("RTF_OUTPUT"); - writeDiaGraphFromFile(fileName,outDir,baseName,DIA_BITMAP); - if (!m_lastIsPara) m_t << "\\par" << endl; - m_t << "{" << endl; - m_t << rtf_Style_Reset; - m_t << "\\pard \\qc {\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \""; - m_t << baseName << ".png"; - m_t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par" << endl; - m_t << "}" << endl; - m_lastIsPara=TRUE; + writeDiaGraphFromFile(df->file(),outDir,baseName,DIA_BITMAP); + includePicturePreRTF(baseName + ".png", true, df->hasCaption()); } -void RTFDocVisitor::writePlantUMLFile(const QCString &fileName) +void RTFDocVisitor::writePlantUMLFile(const QCString &fileName, const bool hasCaption) { QCString baseName=fileName; int i; @@ -1733,13 +1750,5 @@ void RTFDocVisitor::writePlantUMLFile(const QCString &fileName) } QCString outDir = Config_getString("RTF_OUTPUT"); generatePlantUMLOutput(fileName,outDir,PUML_BITMAP); - if (!m_lastIsPara) m_t << "\\par" << endl; - m_t << "{" << endl; - m_t << rtf_Style_Reset; - m_t << "\\pard \\qc {\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \""; - m_t << baseName << ".png"; - m_t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par" << endl; - m_t << "}" << endl; - m_lastIsPara=TRUE; + includePicturePreRTF(baseName + ".png", true, hasCaption); } - diff --git a/src/rtfdocvisitor.h b/src/rtfdocvisitor.h index 0e759c1..1e927e7 100644 --- a/src/rtfdocvisitor.h +++ b/src/rtfdocvisitor.h @@ -152,10 +152,14 @@ class RTFDocVisitor : public DocVisitor void pushEnabled(); void popEnabled(); - void writeDotFile(const QCString &fileName); - void writeMscFile(const QCString &fileName); - void writeDiaFile(const QCString &fileName); - void writePlantUMLFile(const QCString &fileName); + 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 writeDotFile(DocDotFile *); + void writeMscFile(const QCString &fileName, const bool hasCaption); + void writeMscFile(DocMscFile *); + void writeDiaFile(DocDiaFile *); + void writePlantUMLFile(const QCString &fileName, const bool hasCaption); //-------------------------------------- // state variables |