diff options
Diffstat (limited to 'src/rtfgen.cpp')
-rw-r--r-- | src/rtfgen.cpp | 160 |
1 files changed, 94 insertions, 66 deletions
diff --git a/src/rtfgen.cpp b/src/rtfgen.cpp index c249539..1dc7e87 100644 --- a/src/rtfgen.cpp +++ b/src/rtfgen.cpp @@ -31,6 +31,10 @@ #include "diagram.h" #include "language.h" #include "dot.h" +#include "version.h" + +//#define DBG_RTF(x) x; +#define DBG_RTF(x) const int indentLevels = 10; @@ -343,6 +347,22 @@ static const struct static QDict<char> Rtf_Style(257); +void RTFGenerator::writeStyleSheetFile(QFile &file) +{ + QTextStream t(&file); + t << "# Generated by doxygen " << versionString << "\n\n"; + t << "# This file describes styles used for generating RTF output.\n"; + t << "# All text after a hash (#) is considered a comment and will be ignored.\n"; + t << "# Remove a hash to activate a line.\n\n"; + + int i; + for (i=0;Rtf_Style_Default[i].name!=0;i++) + { + t << "# " << Rtf_Style_Default[i].name << " = " + << Rtf_Style_Default[i].value << endl; + } +} + static void loadStylesheet(const char *name) { QFile file(name); @@ -428,14 +448,14 @@ void RTFGenerator::beginRTFDocument() */ t <<"{\\rtf1\\ansi\\ansicpg1252\\uc1 \\deff0\\deflang1033\\deflangfe1033\n"; - t <<"{\\comment Begining font list}\n"; + DBG_RTF(t <<"{\\comment Begining font list}\n") t <<"{\\fonttbl "; t <<"{\\f0\\froman\\fcharset0\\fprq2{\\*\\panose 02020603050405020304}Times New Roman;}\n"; t <<"{\\f1\\fswiss\\fcharset0\\fprq2{\\*\\panose 020b0604020202020204}Arial;}\n"; t <<"{\\f2\\fmodern\\fcharset0\\fprq1{\\*\\panose 02070309020205020404}Courier New;}\n"; t <<"{\\f3\\froman\\fcharset2\\fprq2{\\*\\panose 05050102010706020507}Symbol;}\n"; t <<"}\n"; - t <<"{\\comment begin colors}\n"; + DBG_RTF(t <<"{\\comment begin colors}\n") t <<"{\\colortbl;"; t <<"\\red0\\green0\\blue0;"; t <<"\\red0\\green0\\blue255;"; @@ -454,7 +474,7 @@ void RTFGenerator::beginRTFDocument() t <<"\\red128\\green128\\blue128;"; t <<"\\red192\\green192\\blue192;}" << endl; - t <<"{\\comment Begining style list}\n"; + DBG_RTF(t <<"{\\comment Begining style list}\n") t <<"{\\stylesheet\n"; t <<"{\\widctlpar\\adjustright \\fs20\\cgrid \\snext0 Normal;}\n"; t <<"{" << Rtf_Style["Heading1"] <<"\\sbasedon0 \\snext0 heading 1;}\n"; @@ -507,13 +527,16 @@ void RTFGenerator::beginRTFDocument() << (QMIN(i+1,indentLevels-1)) << " \\sautoupd List Enum " << i << ";}\n"; } t <<"}" << endl; + // this comment is needed for postprocessing! t <<"{\\comment begin body}" << endl; } void RTFGenerator::beginRTFChapter() { - t <<"\n{\\comment Begin Chapter}\n" << Rtf_Style["Reset"]; + t <<"\n"; + DBG_RTF(t << "{\\comment Begin Chapter}\n") + t << Rtf_Style["Reset"]; // if we are compact, no extra page breaks... if (Config::compactRTFFlag) @@ -531,7 +554,9 @@ void RTFGenerator::beginRTFChapter() void RTFGenerator::beginRTFSection() { - t <<"\n{\\comment Begin Section}\n" << Rtf_Style["Reset"]; + t <<"\n"; + DBG_RTF(t << "{\\comment Begin Section}\n") + t << Rtf_Style["Reset"]; // if we are compact, no extra page breaks... if (Config::compactRTFFlag) @@ -603,7 +628,7 @@ void RTFGenerator::startIndexSection(IndexSections is) break; case isClassHierarchyIndex: //Hierarchical Index - t << "{\\comment start classhierarchy}\n"; + DBG_RTF(t << "{\\comment start classhierarchy}\n") beginRTFChapter(); break; case isCompoundIndex: @@ -718,24 +743,24 @@ void RTFGenerator::endIndexSection(IndexSections is) { t << " Doxygen}\n" "{\\creatim " << dateToRTFDateString() << "}\n" - "}{\\comment end of infoblock}\n"; - + "}"; + DBG_RTF(t << "{\\comment end of infoblock}\n") // setup for this section t << Rtf_Style["Reset"] <<"\n"; t <<"\\sectd\\pgnlcrm\n"; t <<"{\\footer "<<Rtf_Style["Footer"] << "{\\chpgn}}\n"; // the title entry - t << "{\\comment begin title page}\n"; + DBG_RTF(t << "{\\comment begin title page}\n") t << Rtf_Style["Reset"] << Rtf_Style["Title"] << endl; // set to title style t << "{\\field\\fldedit {\\*\\fldinst TITLE \\\\*MERGEFORMAT}{\\fldrslt TITLE}}\\par" << endl; t << Rtf_Style["Reset"] << Rtf_Style["SubTitle"] << endl; // set to subtitle style t << "{\\field\\fldedit {\\*\\fldinst AUTHOR \\\\*MERGEFORMAT}{\\fldrslt AUTHOR}}\\par" << endl; t << "{\\field\\fldedit {\\*\\fldinst CREATEDATE \\\\*MERGEFORMAT}" "{\\fldrslt CREATEDATE}}\\par"<<endl; - t << "{\\comment End title page}" << endl; + DBG_RTF(t << "{\\comment End title page}" << endl) // table of contents section - t << "{\\comment Table of contents}\n"; + DBG_RTF(t << "{\\comment Table of contents}\n") t << Rtf_Style["Reset"] << endl; t << "{\\field\\fldedit {\\*\\fldinst TOC \\\\f \\\\*MERGEFORMAT}{\\fldrslt Table of contents}}\\par\n"; t << Rtf_Style["Reset"] << endl; @@ -978,7 +1003,7 @@ void RTFGenerator::endIndexSection(IndexSections is) void RTFGenerator::lastIndexPage() { - t <<"{\\comment Begining Body of RTF Document}\n"; + DBG_RTF(t <<"{\\comment Begining Body of RTF Document}\n") // end page and setup for rest of document t <<"\\sect \\sbkpage \\pgnrestart\n"; t <<"\\sect \\sectd \\sbknone \\pgndec\n"; @@ -1007,7 +1032,7 @@ void RTFGenerator::writeString(const char *text) void RTFGenerator::startIndexList() { - t << "{\\comment (startIndexList)}" << endl; + DBG_RTF(t << "{\\comment (startIndexList)}" << endl) t << "{" << endl; incrementIndentLevel(); t << Rtf_Style["Reset"] << Rtf_LCList_DepthStyle() << endl; @@ -1017,7 +1042,7 @@ void RTFGenerator::startIndexList() void RTFGenerator::endIndexList() { - t << "{\\comment (endIndexList)}" << endl; + DBG_RTF(t << "{\\comment (endIndexList)}" << endl) newParagraph(); t << "}"; decrementIndentLevel(); @@ -1027,7 +1052,7 @@ void RTFGenerator::endIndexList() /*! start bullet list */ void RTFGenerator::startItemList() { - t << "{\\comment (startItemList level=" << m_listLevel << ") }" << endl; + DBG_RTF(t << "{\\comment (startItemList level=" << m_listLevel << ") }" << endl) t << "{"; incrementIndentLevel(); listItemInfo[m_listLevel].isEnum = FALSE; @@ -1038,7 +1063,7 @@ void RTFGenerator::startItemList() void RTFGenerator::endItemList() { newParagraph(); - t << "{\\comment (endItemList level=" << m_listLevel << ")}" << endl; + DBG_RTF(t << "{\\comment (endItemList level=" << m_listLevel << ")}" << endl) t << "}"; decrementIndentLevel(); m_omitParagraph=TRUE; @@ -1050,7 +1075,7 @@ void RTFGenerator::endItemList() /*! start enumeration list */ void RTFGenerator::startEnumList() // starts an enumeration list { - t << "{\\comment (startEnumList)}" << endl; + DBG_RTF(t << "{\\comment (startEnumList)}" << endl) t << "{" << endl; incrementIndentLevel(); listItemInfo[m_listLevel].isEnum = TRUE; @@ -1065,7 +1090,7 @@ void RTFGenerator::startEnumList() // starts an enumeration list void RTFGenerator::endEnumList() { newParagraph(); - t << "{\\comment (endEnumList)}" << endl; + DBG_RTF(t << "{\\comment (endEnumList)}" << endl) t << "}"; decrementIndentLevel(); m_omitParagraph=TRUE; @@ -1074,7 +1099,7 @@ void RTFGenerator::endEnumList() /*! write bullet or enum item */ void RTFGenerator::writeListItem() { - t << "{\\comment (writeListItem)}" << endl; + DBG_RTF(t << "{\\comment (writeListItem)}" << endl) newParagraph(); t << Rtf_Style["Reset"]; if (listItemInfo[m_listLevel].isEnum) @@ -1093,7 +1118,7 @@ void RTFGenerator::writeListItem() void RTFGenerator::writeIndexItem(const char *ref,const char *fn, const char *name) { - t << "{\\comment (writeIndexItem)}" << endl; + DBG_RTF(t << "{\\comment (writeIndexItem)}" << endl) //t << Rtf_LCList_DepthStyle() << endl; docify(name); if (!ref && fn) @@ -1152,7 +1177,7 @@ void RTFGenerator::writeMailLink(const char *url) void RTFGenerator::writeStartAnnoItem(const char *,const char *f, const char *path,const char *name) { - t << "{\\comment (writeStartAnnoItem)}" << endl; + DBG_RTF(t << "{\\comment (writeStartAnnoItem)}" << endl) t << "{\\b "; if (path) docify(path); if (f && Config::rtfHyperFlag) @@ -1175,7 +1200,7 @@ void RTFGenerator::writeStartAnnoItem(const char *,const char *f, void RTFGenerator::writeEndAnnoItem(const char *name) { - t << "{\\comment (writeEndAnnoItem)}" << endl; + DBG_RTF(t << "{\\comment (writeEndAnnoItem)}" << endl) if (name) { t << "\\tab "; @@ -1192,7 +1217,9 @@ void RTFGenerator::writeEndAnnoItem(const char *name) void RTFGenerator::startSubsection() { //beginRTFSubSection(); - t <<"\n{\\comment Begin SubSection}\n" << Rtf_Style["Reset"]; + t <<"\n"; + DBG_RTF(t << "{\\comment Begin SubSection}\n") + t << Rtf_Style["Reset"]; t << Rtf_Style["Heading3"] << "\n"; } @@ -1205,7 +1232,8 @@ void RTFGenerator::endSubsection() void RTFGenerator::startSubsubsection() { //beginRTFSubSubSection(); - t << "\n{\\comment Begin SubSubSection}\n"; + t << "\n"; + DBG_RTF(t << "{\\comment Begin SubSubSection}\n") t << "{" << endl; t << Rtf_Style["Reset"] << Rtf_Style["Heading4"] << "\n"; } @@ -1344,7 +1372,7 @@ void RTFGenerator::writeCodeLink(const char *ref,const char *f, void RTFGenerator::startTitleHead(const char *) { - t <<"{\\comment startTitleHead}" << endl; + DBG_RTF(t <<"{\\comment startTitleHead}" << endl) // beginRTFSection(); t << Rtf_Style["Reset"] << Rtf_Style["Heading2"] << endl; @@ -1352,7 +1380,7 @@ void RTFGenerator::startTitleHead(const char *) void RTFGenerator::endTitleHead(const char *fileName,const char *name) { - t <<"{\\comment endTitleHead}" << endl; + DBG_RTF(t <<"{\\comment endTitleHead}" << endl) t << "\\par " << Rtf_Style["Reset"] << endl; if (name) { @@ -1378,7 +1406,7 @@ void RTFGenerator::endTitleHead(const char *fileName,const char *name) void RTFGenerator::startTitle() { - t <<"{\\comment startTitle}" << endl; + DBG_RTF(t <<"{\\comment startTitle}" << endl) if (Config::compactRTFFlag) beginRTFSection(); else @@ -1387,7 +1415,7 @@ void RTFGenerator::startTitle() void RTFGenerator::startGroupHeader() { - t <<"{\\comment startGroupHeader}" << endl; + DBG_RTF(t <<"{\\comment startGroupHeader}" << endl) newParagraph(); t << Rtf_Style["Reset"]; t << Rtf_Style["Heading3"]; @@ -1396,7 +1424,7 @@ void RTFGenerator::startGroupHeader() void RTFGenerator::endGroupHeader() { - t <<"{\\comment endGroupHeader}" << endl; + DBG_RTF(t <<"{\\comment endGroupHeader}" << endl) newParagraph(); t << Rtf_Style["Reset"] << endl; } @@ -1406,7 +1434,7 @@ void RTFGenerator::startMemberDoc(const char *clname, const char *, const char *) { - t << "{\\comment startMemberDoc}" << endl; + DBG_RTF(t << "{\\comment startMemberDoc}" << endl) if (memname && memname[0]!='@') { addToIndex(memname,clname); @@ -1422,7 +1450,7 @@ void RTFGenerator::startMemberDoc(const char *clname, void RTFGenerator::endMemberDoc() { - t << "{\\comment endMemberDoc}" << endl; + DBG_RTF(t << "{\\comment endMemberDoc}" << endl) t << "}" << endl; //const char *style = styleStack.pop(); //printf("RTFGenerator::endMemberDoc() `%s'\n",style); @@ -1504,7 +1532,7 @@ void RTFGenerator::addToIndex(const char *s1,const char *s2) void RTFGenerator::startIndent() { incrementIndentLevel(); - t << "{\\comment (startIndent) }" << endl; + DBG_RTF(t << "{\\comment (startIndent) }" << endl) t << "{" << endl; t << Rtf_Style["Reset"] << Rtf_CList_DepthStyle() << endl; //styleStack.push(style); @@ -1520,14 +1548,14 @@ void RTFGenerator::endIndent() void RTFGenerator::startDescription() { - t << "{\\comment (startDescription)}" << endl; + DBG_RTF(t << "{\\comment (startDescription)}" << endl) t << "{" << endl; t << Rtf_Style["Reset"] << Rtf_CList_DepthStyle(); } void RTFGenerator::endDescription() { - t << "{\\comment (endDescription)}" << endl; + DBG_RTF(t << "{\\comment (endDescription)}" << endl) t << "}"; newParagraph(); } @@ -1535,20 +1563,20 @@ void RTFGenerator::endDescription() void RTFGenerator::startDescItem() { newParagraph(); - t << "{\\comment (startDescItem)}" << endl; + DBG_RTF(t << "{\\comment (startDescItem)}" << endl) t << "{\\b "; } void RTFGenerator::endDescItem() { - t << "{\\comment (endDescItem)}" << endl; + DBG_RTF(t << "{\\comment (endDescItem)}" << endl) t << "}" << endl; newParagraph(); } void RTFGenerator::startMemberDescription() { - t << "{\\comment (startMemberDescription)}" << endl; + DBG_RTF(t << "{\\comment (startMemberDescription)}" << endl) t << "{" << endl; incrementIndentLevel(); t << Rtf_Style["Reset"] << Rtf_CList_DepthStyle(); @@ -1557,7 +1585,7 @@ void RTFGenerator::startMemberDescription() void RTFGenerator::endMemberDescription() { - t << "{\\comment (endMemberDescription)}" << endl; + DBG_RTF(t << "{\\comment (endMemberDescription)}" << endl) endEmphasis(); newParagraph(); decrementIndentLevel(); @@ -1566,14 +1594,14 @@ void RTFGenerator::endMemberDescription() void RTFGenerator::startDescList() { - t << "{\\comment (startDescList)}" << endl; + DBG_RTF(t << "{\\comment (startDescList)}" << endl) t << "{"; newParagraph(); } void RTFGenerator::endDescTitle() { - t << "{\\comment (endDescTitle) }" << endl; + DBG_RTF(t << "{\\comment (endDescTitle) }" << endl) newParagraph(); //t << Rtf_Style["Reset"] << styleStack.top(); incrementIndentLevel(); @@ -1582,14 +1610,14 @@ void RTFGenerator::endDescTitle() void RTFGenerator::writeDescItem() { - t << "{\\comment (writeDescItem) }" << endl; + DBG_RTF(t << "{\\comment (writeDescItem) }" << endl) // incrementIndentLevel(); //t << Rtf_Style["Reset"] << Rtf_CList_DepthStyle(); } void RTFGenerator::endDescList() { - t << "{\\comment (endDescList)}" << endl; + DBG_RTF(t << "{\\comment (endDescList)}" << endl) newParagraph(); t << "}"; decrementIndentLevel(); @@ -1599,7 +1627,7 @@ void RTFGenerator::endDescList() void RTFGenerator::writeSection(const char *lab,const char *title,bool sub) { - t << "{\\comment (writeSection)}" << endl; + DBG_RTF(t << "{\\comment (writeSection)}" << endl) t << "{"; t<< Rtf_Style["Reset"]; if (sub) @@ -1732,7 +1760,7 @@ void RTFGenerator::endClassDiagram(ClassDiagram &d, const char *fileName,const char *) { newParagraph(); - t <<"{\\comment This would be an image map..." << endl; + DBG_RTF(t <<"{\\comment This would be an image map..." << endl) // create a gif file d.writeImageMap(t,dir,fileName); @@ -1755,13 +1783,13 @@ void RTFGenerator::writeFormula(const char *,const char *text) void RTFGenerator::startMemberItem(int) { - t <<"{\\comment startMemberItem }" << endl; + DBG_RTF(t <<"{\\comment startMemberItem }" << endl) t << Rtf_Style["Reset"] << Rtf_BList_DepthStyle() << endl; // set style to apropriate depth } void RTFGenerator::endMemberItem(bool) { - t <<"{\\comment endMemberItem }" << endl; + DBG_RTF(t <<"{\\comment endMemberItem }" << endl) newParagraph(); } @@ -1809,7 +1837,7 @@ void RTFGenerator::writeNonBreakableSpace() void RTFGenerator::startMemberList() { t << endl; - t << "{\\comment (startMemberList) }" << endl; + DBG_RTF(t << "{\\comment (startMemberList) }" << endl) t << "{" << endl; #ifdef DELETEDCODE if (!insideTabbing) @@ -1819,7 +1847,7 @@ void RTFGenerator::startMemberList() void RTFGenerator::endMemberList() { - t << "{\\comment (endMemberList) }" << endl; + DBG_RTF(t << "{\\comment (endMemberList) }" << endl) t << "}" << endl; #ifdef DELETEDCODE if (!insideTabbing) @@ -1841,7 +1869,7 @@ void RTFGenerator::writeImage(const char *,const char *,const char *) void RTFGenerator::startDescTable() { - t << "{\\comment (startDescTable) }" << endl; + DBG_RTF(t << "{\\comment (startDescTable) }" << endl) t << "{" << endl; //incrementIndentLevel(); //t << Rtf_Style["Reset"] << Rtf_CList_DepthStyle(); @@ -1850,7 +1878,7 @@ void RTFGenerator::startDescTable() void RTFGenerator::endDescTable() { //decrementIndentLevel(); - t << "{\\comment (endDescTable)}" << endl; + DBG_RTF(t << "{\\comment (endDescTable)}" << endl) t << "}" << endl; //t << Rtf_Style["Reset"] << styleStack.top(); } @@ -1858,25 +1886,25 @@ void RTFGenerator::endDescTable() void RTFGenerator::startDescTableTitle() { //t << Rtf_BList_DepthStyle() << endl; - t << "{\\comment (startDescTableTitle) }" << endl; + DBG_RTF(t << "{\\comment (startDescTableTitle) }" << endl) startBold(); } void RTFGenerator::endDescTableTitle() { - t << "{\\comment (endDescTableTitle) }" << endl; + DBG_RTF(t << "{\\comment (endDescTableTitle) }" << endl) endBold(); t << " "; } void RTFGenerator::startDescTableData() { - t << "{\\comment (startDescTableData) }" << endl; + DBG_RTF(t << "{\\comment (startDescTableData) }" << endl) } void RTFGenerator::endDescTableData() { - t << "{\\comment (endDescTableData) }" << endl; + DBG_RTF(t << "{\\comment (endDescTableData) }" << endl) newParagraph(); } @@ -1944,7 +1972,7 @@ const char * RTFGenerator::Rtf_Code_DepthStyle() void RTFGenerator::startTextBlock(bool dense) { - t << "{\\comment Start TextBlock}" << endl; + DBG_RTF(t << "{\\comment Start TextBlock}" << endl) t << "{" << endl; t << Rtf_Style["Reset"]; if (dense) // no spacing between "paragraphs" @@ -1961,7 +1989,7 @@ void RTFGenerator::endTextBlock() { newParagraph(); t << "}" << endl; - t << "{\\comment End TextBlock}" << endl; + DBG_RTF(t << "{\\comment End TextBlock}" << endl) m_omitParagraph = TRUE; } @@ -2123,9 +2151,9 @@ static bool PreProcessFile(QDir &d,QCString &infName, QTextStream &t, bool bIncl int startNamePos = lineBuf.find('"',pos)+1; int endNamePos = lineBuf.find('"',startNamePos); QCString fileName = lineBuf.mid(startNamePos,endNamePos-startNamePos); - t << "{\\comment begin include " << fileName << "}" << endl; + DBG_RTF(t << "{\\comment begin include " << fileName << "}" << endl) if (!PreProcessFile(d,fileName,t,FALSE)) return FALSE; - t << "{\\comment end include " << fileName << "}" << endl; + DBG_RTF(t << "{\\comment end include " << fileName << "}" << endl) } else { @@ -2162,7 +2190,7 @@ void RTFGenerator::startDotGraph() void RTFGenerator::endDotGraph(DotClassGraph &g) { newParagraph(); - t <<"{\\comment This would be an image map..." << endl; + DBG_RTF(t <<"{\\comment This would be an image map..." << endl) g.writeGraph(t,GIF,Config::rtfOutputDir); @@ -2184,7 +2212,7 @@ void RTFGenerator::startInclDepGraph() void RTFGenerator::endInclDepGraph(DotInclDepGraph &g) { newParagraph(); - t <<"{\\comment This would be an image map..." << endl; + DBG_RTF(t <<"{\\comment This would be an image map..." << endl) g.writeGraph(t,GIF,Config::rtfOutputDir); @@ -2251,7 +2279,7 @@ bool RTFGenerator::preProcessFileInplace(const char *path,const char *name) void RTFGenerator::startMemberGroupHeader(bool hasHeader) { - t << "{\\comment startMemberGroupHeader}" << endl; + DBG_RTF(t << "{\\comment startMemberGroupHeader}" << endl) t << "{" << endl; if (hasHeader) incrementIndentLevel(); t << Rtf_Style["Reset"] << Rtf_Style["GroupHeader"]; @@ -2259,33 +2287,33 @@ void RTFGenerator::startMemberGroupHeader(bool hasHeader) void RTFGenerator::endMemberGroupHeader() { - t << "{\\comment endMemberGroupHeader}" << endl; + DBG_RTF(t << "{\\comment endMemberGroupHeader}" << endl) newParagraph(); t << Rtf_Style["Reset"] << Rtf_CList_DepthStyle(); } void RTFGenerator::startMemberGroupDocs() { - t << "{\\comment startMemberGroupDocs}" << endl; + DBG_RTF(t << "{\\comment startMemberGroupDocs}" << endl) startEmphasis(); } void RTFGenerator::endMemberGroupDocs() { - t << "{\\comment endMemberGroupDocs}" << endl; + DBG_RTF(t << "{\\comment endMemberGroupDocs}" << endl) endEmphasis(); newParagraph(); } void RTFGenerator::startMemberGroup() { - t << "{\\comment startMemberGroup}" << endl; + DBG_RTF(t << "{\\comment startMemberGroup}" << endl) t << Rtf_Style["Reset"] << Rtf_BList_DepthStyle() << endl; } void RTFGenerator::endMemberGroup(bool hasHeader) { - t << "{\\comment endMemberGroup}" << endl; + DBG_RTF(t << "{\\comment endMemberGroup}" << endl) if (hasHeader) decrementIndentLevel(); t << "}"; } |