diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2021-04-11 19:22:59 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2021-04-22 17:34:13 (GMT) |
commit | 592aaa4f17d73ec8c475df0f44efaea8cc4d575c (patch) | |
tree | 3cfd68cec756661045ee25c906a8d8f4bddf7a6a /src/rtfgen.cpp | |
parent | 98c67549bc3cd855873e0ef5eeab7c6410699d78 (diff) | |
download | Doxygen-592aaa4f17d73ec8c475df0f44efaea8cc4d575c.zip Doxygen-592aaa4f17d73ec8c475df0f44efaea8cc4d575c.tar.gz Doxygen-592aaa4f17d73ec8c475df0f44efaea8cc4d575c.tar.bz2 |
Refactoring: remove implicit conversion from QCString to const char *
This commit changes the following in relation to string use
- The implicit convert from 'QCString' to 'const char *' is removed
- Strings parameters use 'const QCString &' as much as possible in favor
over 'const char *'
- 'if (s)' where s is a QCString has been replaced by 'if(!s.isEmpty())'
- data() now always returns a valid C-string and not a 0-pointer.
- when passing a string 's' to printf and related functions 'qPrint(s)' is
used instead of 's.data()'
- for empty string arguments 'QCString()' is used instead of '0'
- The copy() operation has been removed
- Where possible 'qstrcmp(a,b)==0' has been replaces by 'a==b' and
'qstrcmp(a,b)<0' has been replaced by 'a<b'
- Parameters of string type that were default initialized with '= 0' are
no initialized with '= QCString()'
Diffstat (limited to 'src/rtfgen.cpp')
-rw-r--r-- | src/rtfgen.cpp | 283 |
1 files changed, 146 insertions, 137 deletions
diff --git a/src/rtfgen.cpp b/src/rtfgen.cpp index 032d568..8e01a38 100644 --- a/src/rtfgen.cpp +++ b/src/rtfgen.cpp @@ -172,7 +172,7 @@ void RTFGenerator::init() Dir d(dir.str()); if (!d.exists() && !d.mkdir(dir.str())) { - term("Could not create output directory %s\n",dir.data()); + term("Could not create output directory %s\n",qPrint(dir)); } // first duplicate strings of rtf_Style_Default @@ -207,7 +207,7 @@ void RTFGenerator::init() createSubDirs(d); } -static QCString makeIndexName(const char *s,int i) +static QCString makeIndexName(const QCString &s,int i) { QCString result=s; result+=(char)(i+'0'); @@ -368,7 +368,7 @@ void RTFGenerator::beginRTFSection() m_t << rtf_Style["Heading2"].reference() << "\n"; } -void RTFGenerator::startFile(const char *name,const char *,const char *,int) +void RTFGenerator::startFile(const QCString &name,const QCString &,const QCString &,int) { //setEncoding(QCString().sprintf("CP%s",theTranslator->trRTFansicp())); QCString fileName=name; @@ -418,13 +418,13 @@ void RTFGenerator::startIndexSection(IndexSections is) break; case isTitlePageAuthor: m_t << "}\n"; - if (rtf_subject) m_t << "{\\subject " << rtf_subject << "}\n"; - if (rtf_comments) m_t << "{\\comment " << rtf_comments << "}\n"; - if (rtf_company) m_t << "{\\company " << rtf_company << "}\n"; - if (rtf_author) m_t << "{\\author " << rtf_author << "}\n"; - if (rtf_manager) m_t << "{\\manager " << rtf_manager << "}\n"; - if (rtf_documentType) m_t << "{\\category " << rtf_documentType << "}\n"; - if (rtf_keywords) m_t << "{\\keywords " << rtf_keywords << "}\n"; + if (!rtf_subject.isEmpty()) m_t << "{\\subject " << rtf_subject << "}\n"; + if (!rtf_comments.isEmpty()) m_t << "{\\comment " << rtf_comments << "}\n"; + if (!rtf_company.isEmpty()) m_t << "{\\company " << rtf_company << "}\n"; + if (!rtf_author.isEmpty()) m_t << "{\\author " << rtf_author << "}\n"; + if (!rtf_manager.isEmpty()) m_t << "{\\manager " << rtf_manager << "}\n"; + if (!rtf_documentType.isEmpty()) m_t << "{\\category " << rtf_documentType << "}\n"; + if (!rtf_keywords.isEmpty()) m_t << "{\\keywords " << rtf_keywords << "}\n"; m_t << "{\\comment "; break; case isMainPage: @@ -594,7 +594,7 @@ void RTFGenerator::endIndexSection(IndexSections is) switch (is) { case isTitlePageStart: - if (rtf_title) + if (!rtf_title.isEmpty()) // User has overridden document title in extensions file m_t << "}" << rtf_title; else @@ -616,46 +616,51 @@ void RTFGenerator::endIndexSection(IndexSections is) m_t << rtf_Style_Reset << rtf_Style["SubTitle"].reference() << "\n"; // set to title style m_t << "\\vertalc\\qc\\par\\par\\par\\par\\par\\par\\par\n"; - if (rtf_logoFilename) + if (!rtf_logoFilename.isEmpty()) { m_t << "{\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"" << rtf_logoFilename; m_t << "\" \\\\d \\\\*MERGEFORMAT} {\\fldrslt IMAGE }}\\par\\par\n"; } - if (rtf_company) + if (!rtf_company.isEmpty()) { m_t << rtf_company << "\\par\\par\n"; } m_t << rtf_Style_Reset << rtf_Style["Title"].reference() << "\n"; // set to title style - if (rtf_title) + if (!rtf_title.isEmpty()) + { // User has overridden document title in extensions file m_t << "{\\field\\fldedit {\\*\\fldinst TITLE \\\\*MERGEFORMAT}{\\fldrslt " << rtf_title << "}}\\par\n"; + } else { DocText *root = validatingParseText(projectName); m_t << "{\\field\\fldedit {\\*\\fldinst TITLE \\\\*MERGEFORMAT}{\\fldrslt "; writeDoc(root,0,0,0); m_t << "}}\\par\n"; - } m_t << rtf_Style_Reset << rtf_Style["SubTitle"].reference() << "\n"; // set to title style m_t << "\\par\n"; - if (rtf_documentType) + if (!rtf_documentType.isEmpty()) { m_t << rtf_documentType << "\\par\n"; } - if (rtf_documentId) + if (!rtf_documentId.isEmpty()) { m_t << rtf_documentId << "\\par\n"; } m_t << "\\par\\par\\par\\par\\par\\par\\par\\par\\par\\par\\par\\par\n"; m_t << rtf_Style_Reset << rtf_Style["SubTitle"].reference() << "\n"; // set to subtitle style - if (rtf_author) + if (!rtf_author.isEmpty()) + { m_t << "{\\field\\fldedit {\\*\\fldinst AUTHOR \\\\*MERGEFORMAT}{\\fldrslt "<< rtf_author << " }}\\par\n"; + } else + { m_t << "{\\field\\fldedit {\\*\\fldinst AUTHOR \\\\*MERGEFORMAT}{\\fldrslt AUTHOR}}\\par\n"; + } m_t << theTranslator->trVersion() << " " << Config_getString(PROJECT_NUMBER) << "\\par"; m_t << "{\\field\\fldedit {\\*\\fldinst CREATEDATE \\\\*MERGEFORMAT}" @@ -953,7 +958,7 @@ void RTFGenerator::endIndexSection(IndexSections is) } } -void RTFGenerator::writePageLink(const char *name,bool first) +void RTFGenerator::writePageLink(const QCString &name,bool first) { if (first) m_t << "\\par " << rtf_Style_Reset << "\n"; m_t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \""; @@ -977,14 +982,14 @@ void RTFGenerator::writeStyleInfo(int) { } -void RTFGenerator::lineBreak(const char *) +void RTFGenerator::lineBreak(const QCString &) { DBG_RTF(m_t << "{\\comment (lineBreak)}" << "\n") m_t << "\\par\n"; m_omitParagraph = TRUE; } -void RTFGenerator::writeString(const char *text) +void RTFGenerator::writeString(const QCString &text) { m_t << text; } @@ -1075,7 +1080,7 @@ void RTFGenerator::endItemListItem() DBG_RTF(m_t << "{\\comment (endItemListItem)}\n") } -void RTFGenerator::startIndexItem(const char *,const char *) +void RTFGenerator::startIndexItem(const QCString &,const QCString &) { DBG_RTF(m_t << "{\\comment (startIndexItem)}\n") @@ -1086,10 +1091,10 @@ void RTFGenerator::startIndexItem(const char *,const char *) } } -void RTFGenerator::endIndexItem(const char *ref,const char *fn) +void RTFGenerator::endIndexItem(const QCString &ref,const QCString &fn) { DBG_RTF(m_t << "{\\comment (endIndexItem)}\n") - if (!ref && fn) + if (ref.isEmpty() && !fn.isEmpty()) { m_t << "\\tab "; writeRTFReference(fn); @@ -1102,14 +1107,14 @@ void RTFGenerator::endIndexItem(const char *ref,const char *fn) m_omitParagraph = TRUE; } -//void RTFGenerator::writeIndexFileItem(const char *,const char *text) +//void RTFGenerator::writeIndexFileItem(const QCString &,const QCString &text) //{ // m_t << "\\item\\contentsline{section}{"; // docify(text); // m_t << "}{\\pageref{" << texm_t << "}}\n"; //} -void RTFGenerator::startHtmlLink(const char *url) +void RTFGenerator::startHtmlLink(const QCString &url) { if (Config_getBool(RTF_HYPERLINKS)) @@ -1137,20 +1142,20 @@ void RTFGenerator::endHtmlLink() } } -//void RTFGenerator::writeMailLink(const char *url) +//void RTFGenerator::writeMailLink(const QCString &url) //{ // startTypewriter(); // docify(url); // endTypewriter(); //} -void RTFGenerator::writeStartAnnoItem(const char *,const char *f, - const char *path,const char *name) +void RTFGenerator::writeStartAnnoItem(const QCString &,const QCString &f, + const QCString &path,const QCString &name) { DBG_RTF(m_t << "{\\comment (writeStartAnnoItem)}\n") m_t << "{\\b "; - if (path) docify(path); - if (f && Config_getBool(RTF_HYPERLINKS)) + if (!path.isEmpty()) docify(path); + if (!f.isEmpty() && Config_getBool(RTF_HYPERLINKS)) { m_t << "{\\field {\\*\\fldinst { HYPERLINK \\\\l \""; m_t << rtfFormatBmkStr(f); @@ -1168,10 +1173,10 @@ void RTFGenerator::writeStartAnnoItem(const char *,const char *f, m_t << "} "; } -void RTFGenerator::writeEndAnnoItem(const char *name) +void RTFGenerator::writeEndAnnoItem(const QCString &name) { DBG_RTF(m_t << "{\\comment (writeEndAnnoItem)}\n") - if (name) + if (!name.isEmpty()) { m_t << "\\tab "; writeRTFReference(name); @@ -1202,12 +1207,12 @@ void RTFGenerator::startIndexValue(bool hasBrief) if (hasBrief) m_t << "("; } -void RTFGenerator::endIndexValue(const char *name,bool hasBrief) +void RTFGenerator::endIndexValue(const QCString &name,bool hasBrief) { DBG_RTF(m_t << "{\\comment (endIndexValue)}\n") if (hasBrief) m_t << ")"; m_t << "} "; - if (name) + if (!name.isEmpty()) { m_t << "\\tab "; writeRTFReference(name); @@ -1252,8 +1257,8 @@ void RTFGenerator::endSubsubsection() } -//void RTFGenerator::writeClassLink(const char *,const char *, -// const char *,const char *name) +//void RTFGenerator::writeClassLink(const QCString &,const QCString &, +// const QCString &,const QCString &name) //{ // m_t << "{\\bf "; // docify(name); @@ -1327,16 +1332,16 @@ void RTFGenerator::endSubsubsection() // m_t << " \\cell }"; //} // -void RTFGenerator::startTextLink(const char *f,const char *anchor) +void RTFGenerator::startTextLink(const QCString &f,const QCString &anchor) { if (Config_getBool(RTF_HYPERLINKS)) { QCString ref; - if (f) + if (!f.isEmpty()) { ref+=f; } - if (anchor) + if (!anchor.isEmpty()) { ref+='_'; ref+=anchor; @@ -1357,17 +1362,17 @@ void RTFGenerator::endTextLink() } } -void RTFGenerator::writeObjectLink(const char *ref, const char *f, - const char *anchor, const char *text) +void RTFGenerator::writeObjectLink(const QCString &ref, const QCString &f, + const QCString &anchor, const QCString &text) { - if (!ref && Config_getBool(RTF_HYPERLINKS)) + if (ref.isEmpty() && Config_getBool(RTF_HYPERLINKS)) { QCString refName; - if (f) + if (!f.isEmpty()) { refName+=f; } - if (anchor) + if (!anchor.isEmpty()) { refName+='_'; refName+=anchor; @@ -1396,14 +1401,14 @@ void RTFGenerator::startPageRef() startEmphasis(); } -void RTFGenerator::endPageRef(const char *clname, const char *anchor) +void RTFGenerator::endPageRef(const QCString &clname, const QCString &anchor) { QCString ref; - if (clname) + if (!clname.isEmpty()) { ref+=clname; } - if (anchor) + if (!anchor.isEmpty()) { ref+='_'; ref+=anchor; @@ -1413,18 +1418,18 @@ void RTFGenerator::endPageRef(const char *clname, const char *anchor) m_t << ")"; } -void RTFGenerator::writeCodeLink(const char *ref,const char *f, - const char *anchor,const char *name, - const char *) +void RTFGenerator::writeCodeLink(const QCString &ref,const QCString &f, + const QCString &anchor,const QCString &name, + const QCString &) { - if (!ref && Config_getBool(RTF_HYPERLINKS)) + if (ref.isEmpty() && Config_getBool(RTF_HYPERLINKS)) { QCString refName; - if (f) + if (!f.isEmpty()) { refName+=f; } - if (anchor) + if (!anchor.isEmpty()) { refName+='_'; refName+=anchor; @@ -1445,7 +1450,7 @@ void RTFGenerator::writeCodeLink(const char *ref,const char *f, } } -void RTFGenerator::startTitleHead(const char *) +void RTFGenerator::startTitleHead(const QCString &) { DBG_RTF(m_t << "{\\comment startTitleHead}\n") @@ -1453,11 +1458,11 @@ void RTFGenerator::startTitleHead(const char *) m_t << rtf_Style_Reset << rtf_Style["Heading2"].reference() << "\n"; } -void RTFGenerator::endTitleHead(const char *fileName,const char *name) +void RTFGenerator::endTitleHead(const QCString &fileName,const QCString &name) { DBG_RTF(m_t << "{\\comment endTitleHead}\n") m_t << "\\par " << rtf_Style_Reset << "\n"; - if (name) + if (!name.isEmpty()) { // make table of contents entry m_t << "{\\tc\\tcl2 \\v "; @@ -1465,7 +1470,7 @@ void RTFGenerator::endTitleHead(const char *fileName,const char *name) m_t << "}\n"; // make an index entry - addIndexItem(name,0); + addIndexItem(name,QCString()); //if (name) //{ @@ -1474,7 +1479,7 @@ void RTFGenerator::endTitleHead(const char *fileName,const char *name) // //if (Config_getBool(RTF_HYPERLINKS) && fileName) //{ - writeAnchor(fileName,0); + writeAnchor(fileName,QCString()); //} } } @@ -1515,16 +1520,16 @@ void RTFGenerator::endGroupHeader(int) m_t << rtf_Style_Reset << "\n"; } -void RTFGenerator::startMemberDoc(const char *clname, - const char *memname, - const char *, - const char *, +void RTFGenerator::startMemberDoc(const QCString &clname, + const QCString &memname, + const QCString &, + const QCString &, int, int, bool showInline) { DBG_RTF(m_t << "{\\comment startMemberDoc}\n") - if (memname && memname[0]!='@') + if (!memname.isEmpty() && memname[0]!='@') { addIndexItem(memname,clname); addIndexItem(clname,memname); @@ -1540,7 +1545,7 @@ void RTFGenerator::startMemberDoc(const char *clname, void RTFGenerator::endMemberDoc(bool) { DBG_RTF(m_t << "{\\comment endMemberDoc}\n") - //const char *style = styleStack.pop(); + //const QCString &style = styleStack.pop(); //printf("RTFGenerator::endMemberDoc() '%s'\n",style); //ASSERT(style==rtf_Style["Heading4"].reference()); endBold(); @@ -1548,22 +1553,22 @@ void RTFGenerator::endMemberDoc(bool) newParagraph(); } -void RTFGenerator::startDoxyAnchor(const char *,const char *, - const char *,const char *, - const char * +void RTFGenerator::startDoxyAnchor(const QCString &,const QCString &, + const QCString &,const QCString &, + const QCString & ) { DBG_RTF(m_t << "{\\comment startDoxyAnchor}\n") } -void RTFGenerator::endDoxyAnchor(const char *fName,const char *anchor) +void RTFGenerator::endDoxyAnchor(const QCString &fName,const QCString &anchor) { QCString ref; - if (fName) + if (!fName.isEmpty()) { ref+=fName; } - if (anchor) + if (!anchor.isEmpty()) { ref+='_'; ref+=anchor; @@ -1579,18 +1584,18 @@ void RTFGenerator::endDoxyAnchor(const char *fName,const char *anchor) } -//void RTFGenerator::writeLatexLabel(const char *clName,const char *anchor) +//void RTFGenerator::writeLatexLabel(const QCString &clName,const QCString &anchor) //{ // writeDoxyAnchor(0,clName,anchor,0); //} -void RTFGenerator::addIndexItem(const char *s1,const char *s2) +void RTFGenerator::addIndexItem(const QCString &s1,const QCString &s2) { - if (s1) + if (!s1.isEmpty()) { m_t << "{\\xe \\v "; docify(s1); - if (s2) + if (!s2.isEmpty()) { m_t << "\\:"; docify(s2); @@ -1642,7 +1647,7 @@ void RTFGenerator::endDescItem() newParagraph(); } -void RTFGenerator::startMemberDescription(const char *,const char *,bool) +void RTFGenerator::startMemberDescription(const QCString &,const QCString &,bool) { DBG_RTF(m_t << "{\\comment (startMemberDescription)}\n") m_t << "{\n"; @@ -1701,7 +1706,7 @@ void RTFGenerator::endDescForItem() //} -void RTFGenerator::startSection(const char *,const char *title,SectionType type) +void RTFGenerator::startSection(const QCString &,const QCString &title,SectionType type) { DBG_RTF(m_t << "{\\comment (startSection)}\n") m_t << "{"; @@ -1726,18 +1731,18 @@ void RTFGenerator::startSection(const char *,const char *title,SectionType type) m_t << "}\n"; } -void RTFGenerator::endSection(const char *lab,SectionType) +void RTFGenerator::endSection(const QCString &lab,SectionType) { DBG_RTF(m_t << "{\\comment (endSection)}\n") // make bookmark m_omitParagraph=FALSE; newParagraph(); - writeAnchor(0,lab); + writeAnchor(QCString(),lab); m_t << "}"; } -//void RTFGenerator::writeSectionRef(const char *ref,const char *, -// const char *lab,const char *title) +//void RTFGenerator::writeSectionRef(const QCString &ref,const QCString &, +// const QCString &lab,const QCString &title) //{ // if (ref) // { @@ -1755,8 +1760,8 @@ void RTFGenerator::endSection(const char *lab,SectionType) // } //} // -//void RTFGenerator::writeSectionRefItem(const char *,const char *lab, -// const char *title) +//void RTFGenerator::writeSectionRefItem(const QCString &,const QCString &lab, +// const QCString &title) //{ // docify(title); // m_t << "\\tab"; @@ -1764,8 +1769,8 @@ void RTFGenerator::endSection(const char *lab,SectionType) // m_t << "\n"; //} // -//void RTFGenerator::writeSectionRefAnchor(const char *name,const char *lab, -// const char *title) +//void RTFGenerator::writeSectionRefAnchor(const QCString &name,const QCString &lab, +// const QCString &title) //{ // writeSectionRef(name,lab,title); //} @@ -1778,11 +1783,11 @@ void RTFGenerator::endSection(const char *lab,SectionType) // return s; //} -void RTFGenerator::docify(const char *str) +void RTFGenerator::docify(const QCString &str) { - if (str) + if (!str.isEmpty()) { - const unsigned char *p=(const unsigned char *)str; + const unsigned char *p=(const unsigned char *)str.data(); unsigned char c; //unsigned char pc='\0'; while (*p) @@ -1823,14 +1828,14 @@ void RTFGenerator::docify(const char *str) } } -void RTFGenerator::codify(const char *str) +void RTFGenerator::codify(const QCString &str) { // note that RTF does not have a "verbatim", so "\n" means // nothing... add a "newParagraph()"; //static char spaces[]=" "; - if (str) + if (!str.isEmpty()) { - const unsigned char *p=(const unsigned char *)str; + const unsigned char *p=(const unsigned char *)str.data(); unsigned char c; int spacesToNextTabStop; @@ -1872,7 +1877,7 @@ void RTFGenerator::startClassDiagram() } void RTFGenerator::endClassDiagram(const ClassDiagram &d, - const char *fileName,const char *) + const QCString &fileName,const QCString &) { newParagraph(); @@ -1888,12 +1893,12 @@ void RTFGenerator::endClassDiagram(const ClassDiagram &d, m_t << "}\n"; } -//void RTFGenerator::writeFormula(const char *,const char *text) +//void RTFGenerator::writeFormula(const QCString &,const QCString &text) //{ // m_t << text; //} -void RTFGenerator::startMemberItem(const char *,int,const char *) +void RTFGenerator::startMemberItem(const QCString &,int,const QCString &) { DBG_RTF(m_t << "{\\comment startMemberItem }\n") m_t << rtf_Style_Reset << rtf_BList_DepthStyle() << "\n"; // set style to appropriate depth @@ -1905,18 +1910,18 @@ void RTFGenerator::endMemberItem() newParagraph(); } -void RTFGenerator::writeAnchor(const char *fileName,const char *name) +void RTFGenerator::writeAnchor(const QCString &fileName,const QCString &name) { QCString anchor; - if (fileName) + if (!fileName.isEmpty()) { anchor+=fileName; } - if (fileName && name) + if (!fileName.isEmpty() && !name.isEmpty()) { anchor+='_'; } - if (name) + if (!name.isEmpty()) { anchor+=name; } @@ -1926,21 +1931,21 @@ void RTFGenerator::writeAnchor(const char *fileName,const char *name) m_t << "{\\bkmkend " << rtfFormatBmkStr(anchor) << "}\n"; } -void RTFGenerator::writeRTFReference(const char *label) +void RTFGenerator::writeRTFReference(const QCString &label) { m_t << "{\\field\\fldedit {\\*\\fldinst PAGEREF "; m_t << rtfFormatBmkStr(label); m_t << " \\\\*MERGEFORMAT}{\\fldrslt pagenum}}"; } -void RTFGenerator::startCodeFragment(const char *) +void RTFGenerator::startCodeFragment(const QCString &) { DBG_RTF(m_t << "{\\comment (startCodeFragment) }\n") m_t << "{\n"; m_t << rtf_Style_Reset << rtf_Code_DepthStyle(); } -void RTFGenerator::endCodeFragment(const char *) +void RTFGenerator::endCodeFragment(const QCString &) { endCodeLine(); @@ -1976,7 +1981,7 @@ void RTFGenerator::endMemberList() #endif } -//void RTFGenerator::startImage(const char *name,const char *,bool) +//void RTFGenerator::startImage(const QCString &name,const QCString &,bool) //{ // newParagraph(); // m_t << "{\n"; @@ -1992,7 +1997,7 @@ void RTFGenerator::endMemberList() // // not yet implemented //} // -//void RTFGenerator::startDotFile(const char *name,bool) +//void RTFGenerator::startDotFile(const QCString &name,bool) //{ // QCString baseName=name; // int i; @@ -2016,7 +2021,7 @@ void RTFGenerator::endMemberList() // // not yet implemented //} // -void RTFGenerator::startDescTable(const char *title) +void RTFGenerator::startDescTable(const QCString &title) { DBG_RTF(m_t << "{\\comment (startDescTable) }\n") m_t << "{\\par\n"; @@ -2105,40 +2110,40 @@ void RTFGenerator::decrementIndentLevel() } // a style for list formatted with "list continue" style -const char * RTFGenerator::rtf_CList_DepthStyle() +QCString RTFGenerator::rtf_CList_DepthStyle() { QCString n=makeIndexName("ListContinue",m_listLevel); return rtf_Style[n.str()].reference(); } // a style for list formatted as a "latext style" table of contents -const char * RTFGenerator::rtf_LCList_DepthStyle() +QCString RTFGenerator::rtf_LCList_DepthStyle() { QCString n=makeIndexName("LatexTOC",m_listLevel); return rtf_Style[n.str()].reference(); } // a style for list formatted as a "bullet" style -const char * RTFGenerator::rtf_BList_DepthStyle() +QCString RTFGenerator::rtf_BList_DepthStyle() { QCString n=makeIndexName("ListBullet",m_listLevel); return rtf_Style[n.str()].reference(); } // a style for list formatted as a "enumeration" style -const char * RTFGenerator::rtf_EList_DepthStyle() +QCString RTFGenerator::rtf_EList_DepthStyle() { QCString n=makeIndexName("ListEnum",m_listLevel); return rtf_Style[n.str()].reference(); } -const char * RTFGenerator::rtf_DList_DepthStyle() +QCString RTFGenerator::rtf_DList_DepthStyle() { QCString n=makeIndexName("DescContinue",m_listLevel); return rtf_Style[n.str()].reference(); } -const char * RTFGenerator::rtf_Code_DepthStyle() +QCString RTFGenerator::rtf_Code_DepthStyle() { QCString n=makeIndexName("CodeExample",m_listLevel); return rtf_Style[n.str()].reference(); @@ -2177,7 +2182,7 @@ void RTFGenerator::newParagraph() m_omitParagraph = FALSE; } -void RTFGenerator::startParagraph(const char *txt) +void RTFGenerator::startParagraph(const QCString &txt) { DBG_RTF(m_t << "{\\comment startParagraph}\n") newParagraph(); @@ -2349,24 +2354,24 @@ bool isLeadBytes(int c) // note: function is not reentrant! -static void encodeForOutput(TextStream &t,const char *s) +static void encodeForOutput(TextStream &t,const QCString &s) { if (s==0) return; QCString encoding; bool converted=FALSE; - int l = qstrlen(s); + int l = (int)s.length(); static std::vector<char> enc; if (l*4>(int)enc.size()) enc.resize(l*4); // worst case - encoding.sprintf("CP%s",theTranslator->trRTFansicp().data()); + encoding.sprintf("CP%s",qPrint(theTranslator->trRTFansicp())); if (!encoding.isEmpty()) { // convert from UTF-8 back to the output encoding - void *cd = portable_iconv_open(encoding,"UTF-8"); + void *cd = portable_iconv_open(encoding.data(),"UTF-8"); if (cd!=(void *)(-1)) { size_t iLeft=l; size_t oLeft=enc.size(); - char *inputPtr = (char*)s; + char *inputPtr = (char*)s.data(); char *outputPtr = &enc[0]; if (!portable_iconv(cd, &inputPtr, &iLeft, &outputPtr, &oLeft)) { @@ -2378,7 +2383,7 @@ static void encodeForOutput(TextStream &t,const char *s) } if (!converted) // if we did not convert anything, copy as is. { - memcpy(enc.data(),s,l); + memcpy(enc.data(),s.data(),l); enc.resize(l); } uint i; @@ -2581,12 +2586,12 @@ void RTFGenerator::endDirDepGraph(DotDirDeps &g) /** Tests the integrity of the result by counting brackets. * */ -void testRTFOutput(const char *name) +void testRTFOutput(const QCString &name) { int bcount=0; int line=1; int c; - std::ifstream f(name,std::ifstream::in); + std::ifstream f(name.data(),std::ifstream::in); if (f.is_open()) { while ((c=f.get())!=-1) @@ -2619,20 +2624,20 @@ void testRTFOutput(const char *name) err: err("RTF integrity test failed at line %d of %s due to a bracket mismatch.\n" " Please try to create a small code example that produces this error \n" - " and send that to doxygen@gmail.com.\n",line,name); + " and send that to doxygen@gmail.com.\n",line,qPrint(name)); } /** * This is an API to a VERY brittle RTF preprocessor that combines nested * RTF files. This version replaces the infile with the new file */ -bool RTFGenerator::preProcessFileInplace(const char *path,const char *name) +bool RTFGenerator::preProcessFileInplace(const QCString &path,const QCString &name) { - Dir d(path); + Dir d(path.str()); // store the original directory if (!d.exists()) { - err("Output dir %s does not exist!\n",path); + err("Output dir %s does not exist!\n",qPrint(path)); return FALSE; } std::string oldDir = Dir::currentDirPath(); @@ -2641,8 +2646,8 @@ bool RTFGenerator::preProcessFileInplace(const char *path,const char *name) Dir::setCurrent(d.absPath()); Dir thisDir; - QCString combinedName = (QCString)path+"/combined.rtf"; - QCString mainRTFName = (QCString)path+"/"+name; + QCString combinedName = path+"/combined.rtf"; + QCString mainRTFName = path+"/"+name; std::ofstream f(combinedName.str(),std::ofstream::out | std::ofstream::binary); if (!f.is_open()) @@ -2741,7 +2746,7 @@ void RTFGenerator::endExamples() m_t << "}"; } -void RTFGenerator::startParamList(ParamListTypes,const char *title) +void RTFGenerator::startParamList(ParamListTypes,const QCString &title) { DBG_RTF(m_t << "{\\comment (startParamList)}\n") m_t << "{"; // ends at endParamList @@ -2765,10 +2770,10 @@ void RTFGenerator::endParamList() m_t << "}"; } -void RTFGenerator::startParameterType(bool first,const char *key) +void RTFGenerator::startParameterType(bool first,const QCString &key) { DBG_RTF(m_t << "{\\comment (startParameterType)}\n") - if (!first && key) + if (!first && !key.isEmpty()) { m_t << " " << key << " "; } @@ -2780,13 +2785,17 @@ void RTFGenerator::endParameterType() m_t << " "; } -void RTFGenerator::exceptionEntry(const char* prefix,bool closeBracket) +void RTFGenerator::exceptionEntry(const QCString &prefix,bool closeBracket) { DBG_RTF(m_t << "{\\comment (exceptionEntry)}\n") - if (prefix) - m_t << " " << prefix << "("; + if (!prefix.isEmpty()) + { + m_t << " " << prefix << "("; + } else if (closeBracket) - m_t << ")"; + { + m_t << ")"; + } m_t << " "; } @@ -2853,7 +2862,7 @@ void RTFGenerator::postProcess(QByteArray &a) } #endif -void RTFGenerator::startConstraintList(const char *header) +void RTFGenerator::startConstraintList(const QCString &header) { DBG_RTF(m_t << "{\\comment (startConstraintList)}\n") m_t << "{"; // ends at endConstraintList @@ -3024,7 +3033,7 @@ void RTFGenerator::endInlineMemberDoc() m_t << "\\cell }{\\row }\n"; } -void RTFGenerator::writeLineNumber(const char *ref,const char *fileName,const char *anchor,int l) +void RTFGenerator::writeLineNumber(const QCString &ref,const QCString &fileName,const QCString &anchor,int l) { bool rtfHyperlinks = Config_getBool(RTF_HYPERLINKS); @@ -3033,7 +3042,7 @@ void RTFGenerator::writeLineNumber(const char *ref,const char *fileName,const ch lineNumber.sprintf("%05d",l); if (m_prettyCode) { - if (fileName && !m_sourceFileName.isEmpty() && rtfHyperlinks) + if (!fileName.isEmpty() && !m_sourceFileName.isEmpty() && rtfHyperlinks) { QCString lineAnchor; lineAnchor.sprintf("_l%05d",l); @@ -3068,7 +3077,7 @@ void RTFGenerator::startLabels() { } -void RTFGenerator::writeLabel(const char *l,bool isLast) +void RTFGenerator::writeLabel(const QCString &l,bool isLast) { m_t << "{\\f2 [" << l << "]}"; if (!isLast) m_t << ", "; @@ -3078,7 +3087,7 @@ void RTFGenerator::endLabels() { } -void RTFGenerator::startFontClass(const char *name) +void RTFGenerator::startFontClass(const QCString &name) { int cod = 2; QCString qname(name); |