diff options
Diffstat (limited to 'src/rtfdocvisitor.cpp')
-rw-r--r-- | src/rtfdocvisitor.cpp | 260 |
1 files changed, 156 insertions, 104 deletions
diff --git a/src/rtfdocvisitor.cpp b/src/rtfdocvisitor.cpp index 2ea35cc..c85b638 100644 --- a/src/rtfdocvisitor.cpp +++ b/src/rtfdocvisitor.cpp @@ -140,7 +140,7 @@ void RTFDocVisitor::visit(DocURL *u) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visit(DocURL)}\n"); - if (Config_getBool("RTF_HYPERLINKS")) + if (Config_getBool(RTF_HYPERLINKS)) { m_t << "{\\field " "{\\*\\fldinst " @@ -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; @@ -277,7 +284,7 @@ void RTFDocVisitor::visit(DocVerbatim *s) QCString fileName(4096); fileName.sprintf("%s%d%s", - (Config_getString("RTF_OUTPUT")+"/inline_dotgraph_").data(), + (Config_getString(RTF_OUTPUT)+"/inline_dotgraph_").data(), dotindex++, ".dot" ); @@ -288,10 +295,12 @@ void RTFDocVisitor::visit(DocVerbatim *s) } file.writeBlock( s->text(), s->text().length() ); file.close(); - m_t << "\\par{\\qc "; // center picture - writeDotFile(fileName); - m_t << "} "; - if (Config_getBool("DOT_CLEANUP")) file.remove(); + + writeDotFile(fileName, s->hasCaption()); + visitCaption(this, s->children()); + includePicturePostRTF(true, s->hasCaption()); + + if (Config_getBool(DOT_CLEANUP)) file.remove(); } break; case DocVerbatim::Msc: @@ -300,7 +309,7 @@ void RTFDocVisitor::visit(DocVerbatim *s) QCString baseName(4096); baseName.sprintf("%s%d%s", - (Config_getString("RTF_OUTPUT")+"/inline_mscgraph_").data(), + (Config_getString(RTF_OUTPUT)+"/inline_mscgraph_").data(), mscindex++, ".msc" ); @@ -314,20 +323,22 @@ void RTFDocVisitor::visit(DocVerbatim *s) text+="}"; file.writeBlock( text, text.length() ); file.close(); - m_t << "\\par{\\qc "; // center picture - writeMscFile(baseName); - m_t << "} "; - if (Config_getBool("DOT_CLEANUP")) file.remove(); + + writeMscFile(baseName, s->hasCaption()); + visitCaption(this, s->children()); + includePicturePostRTF(true, s->hasCaption()); + + if (Config_getBool(DOT_CLEANUP)) file.remove(); } break; case DocVerbatim::PlantUML: { - static QCString rtfOutput = Config_getString("RTF_OUTPUT"); + 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; } @@ -375,7 +386,14 @@ void RTFDocVisitor::visit(DocInclude *inc) inc->text(), langExt, inc->isExample(), - inc->exampleFile(), &fd); + inc->exampleFile(), + &fd, // fileDef, + -1, // start line + -1, // end line + FALSE, // inline fragment + 0, // memberDef + TRUE // show line numbers + ); m_t << "\\par"; m_t << "}" << endl; } @@ -387,7 +405,14 @@ void RTFDocVisitor::visit(DocInclude *inc) Doxygen::parserManager->getParser(inc->extension()) ->parseCode(m_ci,inc->context(), inc->text(),langExt,inc->isExample(), - inc->exampleFile()); + inc->exampleFile(), + 0, // fileDef + -1, // startLine + -1, // endLine + TRUE, // inlineFragment + 0, // memberDef + FALSE // show line numbers + ); m_t << "\\par"; m_t << "}" << endl; break; @@ -419,6 +444,35 @@ void RTFDocVisitor::visit(DocInclude *inc) ); m_t << "}"; break; + case DocInclude::SnipWithLines: + { + QFileInfo cfi( inc->file() ); + FileDef fd( cfi.dirPath().utf8(), cfi.fileName().utf8() ); + m_t << "{" << endl; + if (!m_lastIsPara) m_t << "\\par" << endl; + m_t << rtf_Style_Reset << getStyle("CodeExample"); + Doxygen::parserManager->getParser(inc->extension()) + ->parseCode(m_ci, + inc->context(), + extractBlock(inc->text(),inc->blockId()), + langExt, + inc->isExample(), + inc->exampleFile(), + &fd, + lineBlock(inc->text(),inc->blockId()), + -1, // endLine + FALSE, // inlineFragment + 0, // memberDef + TRUE // show line number + ); + m_t << "}"; + } + break; + case DocInclude::SnippetDoc: + case DocInclude::IncludeDoc: + err("Internal inconsistency: found switch SnippetDoc / IncludeDoc in file: %s" + "Please create a bug report\n",__FILE__); + break; } m_lastIsPara=TRUE; } @@ -958,7 +1012,7 @@ void RTFDocVisitor::visitPre(DocHRef *href) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocHRef)}\n"); - if (Config_getBool("RTF_HYPERLINKS")) + if (Config_getBool(RTF_HYPERLINKS)) { m_t << "{\\field " "{\\*\\fldinst " @@ -980,7 +1034,7 @@ void RTFDocVisitor::visitPost(DocHRef *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHRef)}\n"); - if (Config_getBool("RTF_HYPERLINKS")) + if (Config_getBool(RTF_HYPERLINKS)) { m_t << "}" "}" @@ -1004,17 +1058,17 @@ void RTFDocVisitor::visitPre(DocHtmlHeader *header) heading.sprintf("Heading%d",level); // set style m_t << rtf_Style[heading]->reference; - // make table of contents entry - m_t << "{\\tc\\tcl \\v " << level << "}"; + // make open table of contents entry that will be closed in visitPost method + m_t << "{\\tc\\tcl" << level << " "; m_lastIsPara=FALSE; - } void RTFDocVisitor::visitPost(DocHtmlHeader *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlHeader)}\n"); - m_t << "\\par"; + // close open table of contens entry + m_t << "} \\par"; m_t << "}" << endl; // end section m_lastIsPara=TRUE; } @@ -1022,76 +1076,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) @@ -1168,7 +1241,7 @@ void RTFDocVisitor::visitPost(DocSecRefList *) //void RTFDocVisitor::visitPre(DocLanguage *l) //{ // DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocLanguage)}\n"); -// QCString langId = Config_getEnum("OUTPUT_LANGUAGE"); +// QCString langId = Config_getEnum(OUTPUT_LANGUAGE); // if (l->id().lower()!=langId.lower()) // { // pushEnabled(); @@ -1179,7 +1252,7 @@ void RTFDocVisitor::visitPost(DocSecRefList *) //void RTFDocVisitor::visitPost(DocLanguage *l) //{ // DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocLanguage)}\n"); -// QCString langId = Config_getEnum("OUTPUT_LANGUAGE"); +// QCString langId = Config_getEnum(OUTPUT_LANGUAGE); // if (l->id().lower()!=langId.lower()) // { // popEnabled(); @@ -1422,7 +1495,7 @@ void RTFDocVisitor::visitPre(DocXRefItem *x) m_t << "{"; // start param list //m_t << "{\\b "; // start bold m_t << "{" << rtf_Style["Heading5"]->reference << endl; - if (Config_getBool("RTF_HYPERLINKS") && !anonymousEnum) + if (Config_getBool(RTF_HYPERLINKS) && !anonymousEnum) { QCString refName; if (!x->file().isEmpty()) @@ -1608,7 +1681,7 @@ void RTFDocVisitor::filter(const char *str,bool verbatim) void RTFDocVisitor::startLink(const QCString &ref,const QCString &file,const QCString &anchor) { - if (ref.isEmpty() && Config_getBool("RTF_HYPERLINKS")) + if (ref.isEmpty() && Config_getBool(RTF_HYPERLINKS)) { QCString refName; if (!file.isEmpty()) @@ -1638,7 +1711,7 @@ void RTFDocVisitor::startLink(const QCString &ref,const QCString &file,const QCS void RTFDocVisitor::endLink(const QCString &ref) { - if (ref.isEmpty() && Config_getBool("RTF_HYPERLINKS")) + if (ref.isEmpty() && Config_getBool(RTF_HYPERLINKS)) { m_t << "}}}"; } @@ -1662,28 +1735,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 \""; + QCString outDir = Config_getString(RTF_OUTPUT); + 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; @@ -1691,39 +1765,25 @@ void RTFDocVisitor::writeMscFile(const QCString &fileName) { baseName=baseName.right(baseName.length()-i-1); } - QCString outDir = Config_getString("RTF_OUTPUT"); + 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; + QCString outDir = Config_getString(RTF_OUTPUT); + 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; @@ -1731,15 +1791,7 @@ void RTFDocVisitor::writePlantUMLFile(const QCString &fileName) { baseName=baseName.right(baseName.length()-i-1); } - QCString outDir = Config_getString("RTF_OUTPUT"); + 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); } - |