diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2016-01-07 18:24:17 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 2016-01-07 18:24:17 (GMT) |
commit | 0ec4637bc15d18563c74dc09d7c396cd54974484 (patch) | |
tree | 3f61635d4a690d2a6823a73bb148925860d8cbfa | |
parent | 1cfdf7b2e95dc45cba86ddf5f011936586ddfdcf (diff) | |
parent | 07521a7f050607609b9d04e8f3c58ed4754c47c3 (diff) | |
download | Doxygen-0ec4637bc15d18563c74dc09d7c396cd54974484.zip Doxygen-0ec4637bc15d18563c74dc09d7c396cd54974484.tar.gz Doxygen-0ec4637bc15d18563c74dc09d7c396cd54974484.tar.bz2 |
Merge pull request #438 from albert-github/feature/bug_760086
Bug 760086 - Figure title needs to be on separate line in order for it to work
-rw-r--r-- | src/rtfdocvisitor.cpp | 171 | ||||
-rw-r--r-- | src/rtfdocvisitor.h | 12 |
2 files changed, 98 insertions, 85 deletions
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 |