diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2002-09-01 19:53:48 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 2002-09-01 19:53:48 (GMT) |
commit | fe35e3ac26cdbffce193076f33b32164989ace28 (patch) | |
tree | da974cfae9e6014de9194f883223647574559cba /src | |
parent | 6b47ce0c7beaaf8f88058953865e8425cb3ca272 (diff) | |
download | Doxygen-fe35e3ac26cdbffce193076f33b32164989ace28.zip Doxygen-fe35e3ac26cdbffce193076f33b32164989ace28.tar.gz Doxygen-fe35e3ac26cdbffce193076f33b32164989ace28.tar.bz2 |
Doxygen-1.2.17-20020901
Diffstat (limited to 'src')
-rw-r--r-- | src/defargs.l | 116 | ||||
-rw-r--r-- | src/doc.l | 8 | ||||
-rw-r--r-- | src/docparser.cpp | 3 | ||||
-rw-r--r-- | src/dot.cpp | 6 | ||||
-rw-r--r-- | src/doxygen.cpp | 233 | ||||
-rw-r--r-- | src/groupdef.cpp | 29 | ||||
-rw-r--r-- | src/groupdef.h | 2 | ||||
-rw-r--r-- | src/htmldocvisitor.cpp | 719 | ||||
-rw-r--r-- | src/htmldocvisitor.h | 713 | ||||
-rw-r--r-- | src/htmlgen.cpp | 1 | ||||
-rw-r--r-- | src/latexdocvisitor.cpp | 822 | ||||
-rw-r--r-- | src/latexdocvisitor.h | 816 | ||||
-rw-r--r-- | src/latexgen.cpp | 1 | ||||
-rw-r--r-- | src/libdoxygen.pro.in | 4 | ||||
-rw-r--r-- | src/memberdef.cpp | 15 | ||||
-rw-r--r-- | src/memberdef.h | 9 | ||||
-rw-r--r-- | src/page.h | 6 | ||||
-rw-r--r-- | src/rtfdocvisitor.cpp | 1013 | ||||
-rw-r--r-- | src/rtfdocvisitor.h | 150 | ||||
-rw-r--r-- | src/rtfgen.cpp | 849 | ||||
-rw-r--r-- | src/rtfgen.h | 24 | ||||
-rw-r--r-- | src/rtfstyle.cpp | 518 | ||||
-rw-r--r-- | src/rtfstyle.h | 80 | ||||
-rw-r--r-- | src/scanner.l | 45 | ||||
-rw-r--r-- | src/util.cpp | 54 | ||||
-rw-r--r-- | src/util.h | 3 |
26 files changed, 3987 insertions, 2252 deletions
diff --git a/src/defargs.l b/src/defargs.l index 5a0feaf..7cdd523 100644 --- a/src/defargs.l +++ b/src/defargs.l @@ -164,6 +164,9 @@ ID [a-z_A-Z][a-z_A-Z0-9]* g_curArgTypeName+=g_curArgName; BEGIN( ReadFuncArgType ); } +<ReadFuncArgType>"<="|">="|"->"|">>"|"<<" { // handle operators in defargs + g_curArgTypeName+=yytext; + } <ReadFuncArgType,ReadFuncArgDef>[({<] { if (YY_START==ReadFuncArgType) { @@ -175,10 +178,10 @@ ID [a-z_A-Z][a-z_A-Z0-9]* g_curArgDefValue+=*yytext; g_copyArgValue=&g_curArgDefValue; } - g_readArgContext = YY_START; + g_readArgContext = YY_START; if (*yytext=='(') { - g_argRoundCount=0; + g_argRoundCount=0; BEGIN( CopyArgRound ); } else if (*yytext=='{') @@ -249,67 +252,74 @@ ID [a-z_A-Z][a-z_A-Z0-9]* BEGIN( ReadDocBlock ); } <ReadFuncArgType,ReadFuncArgDef>[,)>] { - g_curArgTypeName=removeRedundantWhiteSpace(g_curArgTypeName); - g_curArgDefValue=g_curArgDefValue.stripWhiteSpace(); - //printf("curArgType=`%s' curArgDefVal=`%s'\n",g_curArgTypeName.data(),g_curArgDefValue.data()); - int l=g_curArgTypeName.length(); - if (l>0) + if (*yytext==')' && g_curArgTypeName.stripWhiteSpace().isEmpty()) + { + g_curArgTypeName+=*yytext; + } + else { - int i=l-1; - while (i>=0 && (isspace(g_curArgTypeName.at(i)) || g_curArgTypeName.at(i)=='.')) i--; - while (i>=0 && isId(g_curArgTypeName.at(i))) i--; - //printf("g_curArgTypeName=`%s' i=%d\n",g_curArgTypeName.data(),i); - Argument *a = new Argument; - a->attrib = g_curArgAttrib.copy(); - //printf("a->type=%s a->name=%s i=%d l=%d\n", - // a->type.data(),a->name.data(),i,l); - a->array.resize(0); - if (i==l-1 && g_curArgTypeName.at(i)==')') // function argument + g_curArgTypeName=removeRedundantWhiteSpace(g_curArgTypeName); + g_curArgDefValue=g_curArgDefValue.stripWhiteSpace(); + //printf("curArgType=`%s' curArgDefVal=`%s'\n",g_curArgTypeName.data(),g_curArgDefValue.data()); + int l=g_curArgTypeName.length(); + if (l>0) { - int bi=g_curArgTypeName.find('('); - int fi=bi-1; - //printf("func arg fi=%d\n",fi); - while (fi>=0 && isId(g_curArgTypeName.at(fi))) fi--; - if (fi>=0) + int i=l-1; + while (i>=0 && (isspace(g_curArgTypeName.at(i)) || g_curArgTypeName.at(i)=='.')) i--; + while (i>=0 && isId(g_curArgTypeName.at(i))) i--; + //printf("g_curArgTypeName=`%s' i=%d\n",g_curArgTypeName.data(),i); + Argument *a = new Argument; + a->attrib = g_curArgAttrib.copy(); + //printf("a->type=%s a->name=%s i=%d l=%d\n", + // a->type.data(),a->name.data(),i,l); + a->array.resize(0); + if (i==l-1 && g_curArgTypeName.at(i)==')') // function argument { - a->type = g_curArgTypeName.left(fi+1); - a->name = g_curArgTypeName.mid(fi+1,bi-fi-1); - a->array = g_curArgTypeName.right(l-bi); + int bi=g_curArgTypeName.find('('); + int fi=bi-1; + //printf("func arg fi=%d\n",fi); + while (fi>=0 && isId(g_curArgTypeName.at(fi))) fi--; + if (fi>=0) + { + a->type = g_curArgTypeName.left(fi+1); + a->name = g_curArgTypeName.mid(fi+1,bi-fi-1); + a->array = g_curArgTypeName.right(l-bi); + } + else + { + a->type = g_curArgTypeName; + } + } + else if (i>=0 && g_curArgTypeName.at(i)!=':') + { // type contains a name + a->type = removeRedundantWhiteSpace(g_curArgTypeName.left(i+1)); + a->name = g_curArgTypeName.right(l-i-1); } - else + else // assume only the type was specified, try to determine name later { - a->type = g_curArgTypeName; + a->type = removeRedundantWhiteSpace(g_curArgTypeName); } + //printf("a->type=%s a->name=%s a->array=%s\n",a->type.data(),a->name.data()); + a->array += removeRedundantWhiteSpace(g_curArgArray); + a->defval = g_curArgDefValue.copy(); + a->docs = g_curArgDocs.stripWhiteSpace(); + //printf("Argument `%s' `%s' adding docs=`%s'\n",a->type.data(),a->name.data(),a->docs.data()); + g_argList->append(a); } - else if (i>=0 && g_curArgTypeName.at(i)!=':') - { // type contains a name - a->type = removeRedundantWhiteSpace(g_curArgTypeName.left(i+1)); - a->name = g_curArgTypeName.right(l-i-1); + g_curArgAttrib.resize(0); + g_curArgTypeName.resize(0); + g_curArgDefValue.resize(0); + g_curArgArray.resize(0); + g_curArgDocs.resize(0); + if (*yytext==')') + { + BEGIN(FuncQual); + //printf(">>> end of argument list\n"); } - else // assume only the type was specified, try to determine name later + else { - a->type = removeRedundantWhiteSpace(g_curArgTypeName); + BEGIN( ReadFuncArgType ); } - //printf("a->type=%s a->name=%s a->array=%s\n",a->type.data(),a->name.data()); - a->array += removeRedundantWhiteSpace(g_curArgArray); - a->defval = g_curArgDefValue.copy(); - a->docs = g_curArgDocs.stripWhiteSpace(); - //printf("Argument `%s' `%s' adding docs=`%s'\n",a->type.data(),a->name.data(),a->docs.data()); - g_argList->append(a); - } - g_curArgAttrib.resize(0); - g_curArgTypeName.resize(0); - g_curArgDefValue.resize(0); - g_curArgArray.resize(0); - g_curArgDocs.resize(0); - if (*yytext==')') - { - BEGIN(FuncQual); - //printf(">>> end of argument list\n"); - } - else - { - BEGIN( ReadFuncArgType ); } } <ReadFuncArgType,ReadFuncArgPtr>{ID} { @@ -1130,8 +1130,10 @@ static int yyread(char *buf,int max_size) return c; } -//ATTR ((({BN}+[^\>]+)/">")?) + //LINKMASK [a-z_A-Z0-9:#.,~&*/\[\]<>()\-\+]+({B}*("const"|"volatile"))? + //ATTR ((({BN}+[^\>]+)/">")?) %} + CMD ("\\"|"@") BN [ \t\n\r] BL [ \t\r]*"\n" @@ -1200,7 +1202,7 @@ OPARG "("[a-z_A-Z0-9,\<\> \t\*\&]*")" OPNORM {OPNEW}|{OPDEL}|"+"|"-"|"*"|"/"|"%"|"^"|"&"|"|"|"~"|"!"|"="|"<"|">"|"+="|"-="|"*="|"/="|"%="|"^="|"&="|"|="|"<<"|">>"|"<<="|">>="|"=="|"!="|"<="|">="|"&&"|"||"|"++"|"--"|","|"->*"|"->"|"[]"|"()" OPCAST {B}+[^(\r\n.,]+ OPMASK ({B}*{OPNORM}({OPARG}?))|({OPCAST}{OPARG}) -LINKMASK [a-z_A-Z0-9:#.,~&*/\[\]<>()\-\+]+({B}*("const"|"volatile"))? +LINKMASK [^ \t\n\r\\@<&$]+("("[^\n)]*")")?({B}*("const"|"volatile"))? %option noyywrap @@ -1785,7 +1787,7 @@ LINKMASK [a-z_A-Z0-9:#.,~&*/\[\]<>()\-\+]+({B}*("const"|"volatile"))? if (inBlock()) endBlock(); inReturnBlock=TRUE; currentListIndent.push("P"); - outDoc->startSimpleSect(BaseOutputDocInterface::Return,0,0,theTranslator->trReturns()+":"); + outDoc->startSimpleSect(BaseOutputDocInterface::Return,0,0,theTranslator->trReturns()+": "); outDoc->writeDescItem(); } } diff --git a/src/docparser.cpp b/src/docparser.cpp index 9502eeb..5e4a79c 100644 --- a/src/docparser.cpp +++ b/src/docparser.cpp @@ -1392,6 +1392,7 @@ QCString DocLink::parse(bool isJavaLink) printf("Error: Unsupported symbol %s found at line %d\n", g_token->name.data(),doctokenizerYYlineno); break; + case TK_LNKWORD: case TK_WORD: if (isJavaLink) // special case to detect closing } { @@ -3894,7 +3895,7 @@ void DocRoot::parse() DocNode *validatingParseDoc(const char *fileName,int startLine, const char *context,const char *input) { - //printf("---------------- input --------------------\n%s\n----------- end input -------------------\n",input); + printf("---------------- input --------------------\n%s\n----------- end input -------------------\n",input); printf("========== validating %s at line %d\n",fileName,startLine); g_token = new TokenInfo; diff --git a/src/dot.cpp b/src/dot.cpp index 252f33e..b1d4c05 100644 --- a/src/dot.cpp +++ b/src/dot.cpp @@ -1793,8 +1793,10 @@ void writeDotGraphFromFile(const char *inFile,const char *outDir, QCString imgName = (QCString)outFile+"."+imgExt; if (format==BITMAP) { - dotArgs.sprintf("-T%s \"%s\" -o \"%s\"",imgExt.data(), - inFile,imgName.data()); + dotArgs.sprintf("-T%s \"%s\" -o \"%s\"", + imgExt.data(), + inFile, + imgName.data()); } else // format==EPS { diff --git a/src/doxygen.cpp b/src/doxygen.cpp index 75481c9..3756c21 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -200,11 +200,38 @@ static void addRelatedPage(Entry *root) if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict[g->groupname])) break; } //printf("addRelatedPage() %s gd=%p\n",root->name.data(),gd); - addRelatedPage(root->name,root->args,root->doc,root->anchors, + PageInfo *pi = addRelatedPage(root->name,root->args,root->doc,root->anchors, root->fileName,root->startLine, root->sli, gd,root->tagInfo ); + if (pi) + { + // see if the function is inside a namespace + Definition *ctx = 0; + + if (root->parent->section & Entry::COMPOUND_MASK ) // inside class + { + QCString fullName=removeRedundantWhiteSpace(root->parent->name); + fullName=stripAnonymousNamespaceScope(fullName); + fullName=stripTemplateSpecifiersFromScope(fullName); + ctx=getClass(fullName); + } + if (ctx==0 && root->parent->section == Entry::NAMESPACE_SEC ) // inside namespace + { + QCString nscope=removeAnonymousScopes(root->parent->name); + if (!nscope.isEmpty()) + { + ctx = getResolvedNamespace(nscope); + } + } + if (ctx==0) // inside file + { + bool ambig; + ctx=findFileDef(Doxygen::inputNameDict,root->fileName,ambig); + } + pi->context = ctx; + } } @@ -1919,7 +1946,6 @@ static void buildFunctionList(Entry *root) isMember=memIndex<ts || memIndex>te; } } - if (root->parent && !root->parent->name.isEmpty() && (root->parent->section & Entry::COMPOUND_MASK) && @@ -1967,7 +1993,8 @@ static void buildFunctionList(Entry *root) if (rnd) rnsName = rnd->name().copy(); NamespaceList *unl = fd ? fd->getUsedNamespaces() : 0; ClassList *ucl = fd ? fd->getUsedClasses() : 0; - //printf("matching arguments for %s\n",md->name().data()); + //printf("matching arguments for %s%s %s%s\n", + // md->name().data(),md->argsString(),rname.data(),argListToString(root->argList).data()); if ( matchArguments(md->argumentList(),root->argList,0,nsName,FALSE,unl,ucl) ) @@ -2060,7 +2087,6 @@ static void buildFunctionList(Entry *root) root->type,name,root->args,root->exception, root->protection,root->virt,root->stat,FALSE, MemberDef::Function,tArgList,root->argList); - //printf("new member %p\n",md); if (root->tagInfo) @@ -2297,100 +2323,112 @@ static void transferFunctionDocumentation() MemberName *mn; for (;(mn=mnli.current());++mnli) { - MemberDef *md,*mdef=0,*mdec=0; - MemberNameIterator mni(*mn); + //printf("memberName=%s count=%d\n",mn->memberName(),mn->count()); + MemberDef *mdef=0,*mdec=0; + MemberNameIterator mni1(*mn); /* find a matching function declaration and definition for this function */ - for (;(md=mni.current());++mni) - { - if (md->isPrototype()) - mdec=md; - else if (md->isVariable() && md->isExternal()) - mdec=md; - - if (md->isFunction() && !md->isStatic() && !md->isPrototype()) - mdef=md; - else if (md->isVariable() && !md->isExternal() && !md->isStatic()) - mdef=md; - } - //printf("mdef=(%p,%s) mdec=(%p,%s)\n", - // mdef, mdef ? mdef->name().data() : "", - // mdec, mdec ? mdec->name().data() : ""); - if (mdef && mdec && - matchArguments(mdef->argumentList(),mdec->argumentList()) - ) /* match found */ + for (;(mdec=mni1.current());++mni1) { - //printf("Found member %s: definition in %s (doc=`%s') and declaration in %s (doc=`%s')\n", - // mn->memberName(), - // mdef->getFileDef()->name().data(),mdef->documentation().data(), - // mdec->getFileDef()->name().data(),mdec->documentation().data() - // ); - - // first merge argument documentation - transferArgumentDocumentation(mdec->argumentList(),mdef->argumentList()); - - /* copy documentation between function definition and declaration */ - if (!mdec->briefDescription().isEmpty()) - { - mdef->setBriefDescription(mdec->briefDescription(),mdec->briefFile(),mdec->briefLine()); - } - else if (!mdef->briefDescription().isEmpty()) - { - mdec->setBriefDescription(mdef->briefDescription(),mdef->briefFile(),mdef->briefLine()); - } - if (!mdef->documentation().isEmpty()) - { - //printf("transfering docs mdef->mdec (%s->%s)\n",mdef->argsString(),mdec->argsString()); - mdec->setDocumentation(mdef->documentation(),mdef->docFile(),mdef->docLine()); - mdec->setDocsForDefinition(mdef->isDocsForDefinition()); - ArgumentList *mdefAl = new ArgumentList; - stringToArgumentList(mdef->argsString(),mdefAl); - if (mdef->argumentList()) - { - transferArgumentDocumentation(mdef->argumentList(),mdefAl); - } - mdec->setArgumentList(mdefAl); - } - else if (!mdec->documentation().isEmpty()) + if (mdec->isPrototype() || + (mdec->isVariable() && mdec->isExternal()) + ) + { + MemberNameIterator mni2(*mn); + for (;(mdef=mni2.current());++mni2) { - //printf("transfering docs mdec->mdef (%s->%s)\n",mdec->argsString(),mdef->argsString()); - mdef->setDocumentation(mdec->documentation(),mdec->docFile(),mdec->docLine()); - mdef->setDocsForDefinition(mdec->isDocsForDefinition()); - ArgumentList *mdecAl = new ArgumentList; - stringToArgumentList(mdec->argsString(),mdecAl); - if (mdec->argumentList()) + if ( + (mdef->isFunction() && !mdef->isStatic() && !mdef->isPrototype()) || + (mdef->isVariable() && !mdef->isExternal() && !mdef->isStatic()) + ) { - transferArgumentDocumentation(mdec->argumentList(),mdecAl); - } - mdef->setDeclArgumentList(mdecAl); - } - if (mdec->getStartBodyLine()!=-1 && mdef->getStartBodyLine()==-1) - { - mdef->setBodySegment(mdec->getStartBodyLine(),mdec->getEndBodyLine()); - mdef->setBodyDef(mdec->getBodyDef()); - mdef->setBodyMember(mdec); - } - else if (mdef->getStartBodyLine()!=-1 && mdec->getStartBodyLine()==-1) - { - mdec->setBodySegment(mdef->getStartBodyLine(),mdef->getEndBodyLine()); - mdec->setBodyDef(mdef->getBodyDef()); - mdec->setBodyMember(mdef); - } - mdec->mergeMemberSpecifiers(mdef->getMemberSpecifiers()); - mdef->mergeMemberSpecifiers(mdec->getMemberSpecifiers()); - + //printf("mdef=(%p,%s) mdec=(%p,%s)\n", + // mdef, mdef ? mdef->name().data() : "", + // mdec, mdec ? mdec->name().data() : ""); + if (mdef && mdec && + matchArguments(mdef->argumentList(),mdec->argumentList()) + ) /* match found */ + { + //printf("Found member %s: definition in %s (doc=`%s') and declaration in %s (doc=`%s')\n", + // mn->memberName(), + // mdef->getFileDef()->name().data(),mdef->documentation().data(), + // mdec->getFileDef()->name().data(),mdec->documentation().data() + // ); + + // first merge argument documentation + transferArgumentDocumentation(mdec->argumentList(),mdef->argumentList()); + + /* copy documentation between function definition and declaration */ + if (!mdec->briefDescription().isEmpty()) + { + mdef->setBriefDescription(mdec->briefDescription(),mdec->briefFile(),mdec->briefLine()); + } + else if (!mdef->briefDescription().isEmpty()) + { + mdec->setBriefDescription(mdef->briefDescription(),mdef->briefFile(),mdef->briefLine()); + } + if (!mdef->documentation().isEmpty()) + { + //printf("transfering docs mdef->mdec (%s->%s)\n",mdef->argsString(),mdec->argsString()); + mdec->setDocumentation(mdef->documentation(),mdef->docFile(),mdef->docLine()); + mdec->setDocsForDefinition(mdef->isDocsForDefinition()); + ArgumentList *mdefAl = new ArgumentList; + stringToArgumentList(mdef->argsString(),mdefAl); + if (mdef->argumentList()) + { + transferArgumentDocumentation(mdef->argumentList(),mdefAl); + } + mdec->setArgumentList(mdefAl); + } + else if (!mdec->documentation().isEmpty()) + { + //printf("transfering docs mdec->mdef (%s->%s)\n",mdec->argsString(),mdef->argsString()); + mdef->setDocumentation(mdec->documentation(),mdec->docFile(),mdec->docLine()); + mdef->setDocsForDefinition(mdec->isDocsForDefinition()); + ArgumentList *mdecAl = new ArgumentList; + stringToArgumentList(mdec->argsString(),mdecAl); + if (mdec->argumentList()) + { + transferArgumentDocumentation(mdec->argumentList(),mdecAl); + } + mdef->setDeclArgumentList(mdecAl); + } + if (mdec->getStartBodyLine()!=-1 && mdef->getStartBodyLine()==-1) + { + //printf("body mdec->mdef %d-%d\n",mdec->getStartBodyLine(),mdef->getEndBodyLine()); + mdef->setBodySegment(mdec->getStartBodyLine(),mdec->getEndBodyLine()); + mdef->setBodyDef(mdec->getBodyDef()); + mdef->setBodyMember(mdec); + } + else if (mdef->getStartBodyLine()!=-1 && mdec->getStartBodyLine()==-1) + { + //printf("body mdef->mdec %d-%d\n",mdef->getStartBodyLine(),mdec->getEndBodyLine()); + mdec->setBodySegment(mdef->getStartBodyLine(),mdef->getEndBodyLine()); + mdec->setBodyDef(mdef->getBodyDef()); + mdec->setBodyMember(mdef); + } + mdec->mergeMemberSpecifiers(mdef->getMemberSpecifiers()); + mdef->mergeMemberSpecifiers(mdec->getMemberSpecifiers()); + - // copy group info. - //if (mdec->getGroupDef()==0 && mdef->getGroupDef()!=0) - //{ - // mdef->setGroupDef(mdec->getGroupDef(),mdec->getGroupPri(),mdec->docFile(),mdec->docLine(),mdec->hasDocumentation()); - //} - //else if (mdef->getGroupDef()==0 && mdec->getGroupDef()!=0) - //{ - // mdec->setGroupDef(mdef->getGroupDef(),mdef->getGroupPri(),mdef->docFile(),mdef->docLine(),mdef->hasDocumentation()); - //} + // copy group info. + //if (mdec->getGroupDef()==0 && mdef->getGroupDef()!=0) + //{ + // mdef->setGroupDef(mdec->getGroupDef(),mdec->getGroupPri(),mdec->docFile(),mdec->docLine(),mdec->hasDocumentation()); + //} + //else if (mdef->getGroupDef()==0 && mdec->getGroupDef()!=0) + //{ + // mdec->setGroupDef(mdef->getGroupDef(),mdef->getGroupPri(),mdef->docFile(),mdef->docLine(),mdef->hasDocumentation()); + //} - mdec->setRefItems(mdef->specialListItems()); - mdef->setRefItems(mdec->specialListItems()); + mdec->setRefItems(mdef->specialListItems()); + mdef->setRefItems(mdec->specialListItems()); + + mdef->setMemberDeclaration(mdec); + mdec->setMemberDefinition(mdef); + } + } + } + } } } } @@ -5972,7 +6010,16 @@ static void generatePageDocs() outputList->endSection(si->label,si->type); } outputList->startTextBlock(); - parseDoc(*outputList,pi->defFileName,pi->defLine,0,0,pi->doc); + QCString scName; + if (pi->context && + (pi->context->definitionType()==Definition::TypeClass || + pi->context->definitionType()==Definition::TypeNamespace + ) + ) + { + scName=pi->context->name(); + } + parseDoc(*outputList,pi->defFileName,pi->defLine,scName,0,pi->doc); outputList->endTextBlock(); endFile(*outputList); //outputList->enable(OutputGenerator::Man); diff --git a/src/groupdef.cpp b/src/groupdef.cpp index b2d3691..2a83ae6 100644 --- a/src/groupdef.cpp +++ b/src/groupdef.cpp @@ -162,7 +162,7 @@ void GroupDef::addMembersToMemberGroup() } -void GroupDef::insertMember(MemberDef *md,bool docOnly) +bool GroupDef::insertMember(MemberDef *md,bool docOnly) { //printf("GroupDef(%s)::insertMember(%s)\n", title.data(), md->name().data()); MemberNameInfo *mni=0; @@ -173,10 +173,17 @@ void GroupDef::insertMember(MemberDef *md,bool docOnly) for ( ; (srcMi=srcMnii.current()) ; ++srcMnii ) { MemberDef *srcMd = srcMi->memberDef; - if (matchArguments(srcMd->argumentList(),md->argumentList()) && - srcMd->getOuterScope()==md->getOuterScope()) + + bool sameScope = srcMd->getOuterScope()==md->getOuterScope() || // same class or namespace + // both inside a file => definition and declaration do not have to be in the same file + (srcMd->getOuterScope()->definitionType()==Definition::TypeFile && + md->getOuterScope()->definitionType()==Definition::TypeFile); + + if (matchArguments(srcMd->argumentList(),md->argumentList()) && + sameScope + ) { - return; // member already added + return FALSE; // member already added } } mni->append(new MemberInfo(md,md->protection(),md->virtualness(),FALSE)); @@ -187,6 +194,7 @@ void GroupDef::insertMember(MemberDef *md,bool docOnly) mni->append(new MemberInfo(md,md->protection(),md->virtualness(),FALSE)); allMemberNameInfoSDict->append(mni->memberName(),mni); } + //printf("Added member!\n"); allMemberList->append(md); switch(md->memberType()) { @@ -241,7 +249,7 @@ void GroupDef::insertMember(MemberDef *md,bool docOnly) md->getClassDef() ? md->getClassDef()->name().data() : "", name().data()); } - //addMemberToGroup(md,groupId); + return TRUE; } void GroupDef::removeMember(MemberDef *md) @@ -723,10 +731,13 @@ void addMemberToGroups(Entry *root,MemberDef *md) if (insertit) { //printf("insertMember\n"); - fgd->insertMember(md); - md->setGroupDef(fgd,pri,root->fileName,root->startLine,root->doc.length() != 0); - ClassDef *cd = md->getClassDefOfAnonymousType(); - if (cd) cd->setGroupDefForAllMembers(fgd,pri,root->fileName,root->startLine,root->doc.length() != 0); + bool success = fgd->insertMember(md); + if (success) + { + md->setGroupDef(fgd,pri,root->fileName,root->startLine,root->doc.length() != 0); + ClassDef *cd = md->getClassDefOfAnonymousType(); + if (cd) cd->setGroupDefForAllMembers(fgd,pri,root->fileName,root->startLine,root->doc.length() != 0); + } } } } diff --git a/src/groupdef.h b/src/groupdef.h index a119d61..60dcba3 100644 --- a/src/groupdef.h +++ b/src/groupdef.h @@ -55,7 +55,7 @@ class GroupDef : public Definition void addParentGroup(const GroupDef *def); void addPage(PageInfo *def); // pages in this group void addExample(const PageInfo *def); // examples in this group - void insertMember(MemberDef *def,bool docOnly=FALSE); + bool insertMember(MemberDef *def,bool docOnly=FALSE); void removeMember(MemberDef *md); bool containsGroup(const GroupDef *def); // true if def is already a subgroup void writeDetailedDocumentation(OutputList &ol); diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp index 062f109..18bb3c9 100644 --- a/src/htmldocvisitor.cpp +++ b/src/htmldocvisitor.cpp @@ -17,6 +17,725 @@ */ #include "htmldocvisitor.h" +#include "docparser.h" +#include "language.h" +#include "doxygen.h" +#include "outputgen.h" +#include "code.h" +#include "dot.h" + +HtmlDocVisitor::HtmlDocVisitor(QTextStream &t,BaseCodeDocInterface &ci) + : m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE) +{ +} + + //-------------------------------------- + // visitor functions for leaf nodes + //-------------------------------------- + +void HtmlDocVisitor::HtmlDocVisitor::visit(DocWord *w) +{ + if (m_hide) return; + filter(w->word()); +} + +void HtmlDocVisitor::HtmlDocVisitor::visit(DocLinkedWord *w) +{ + if (m_hide) return; + startLink(w->ref(),w->file(),w->anchor()); + filter(w->word()); + endLink(); +} + +void HtmlDocVisitor::HtmlDocVisitor::visit(DocWhiteSpace *w) +{ + if (m_hide) return; + if (m_insidePre) + { + m_t << w->chars(); + } + else + { + m_t << " "; + } +} + +void HtmlDocVisitor::visit(DocSymbol *s) +{ + if (m_hide) return; + switch(s->symbol()) + { + case DocSymbol::BSlash: m_t << "\\"; break; + case DocSymbol::At: m_t << "@"; break; + case DocSymbol::Less: m_t << "<"; break; + case DocSymbol::Greater: m_t << ">"; break; + case DocSymbol::Amp: m_t << "&"; break; + case DocSymbol::Dollar: m_t << "$"; break; + case DocSymbol::Hash: m_t << "#"; break; + case DocSymbol::Percent: m_t << "%"; break; + case DocSymbol::Copy: m_t << "©"; break; + case DocSymbol::Apos: m_t << "'"; break; + case DocSymbol::Quot: m_t << "\""; break; + case DocSymbol::Uml: m_t << "&" << s->letter() << "uml;"; break; + case DocSymbol::Acute: m_t << "&" << s->letter() << "acute;"; break; + case DocSymbol::Grave: m_t << "&" << s->letter() << "grave;"; break; + case DocSymbol::Circ: m_t << "&" << s->letter() << "circ;"; break; + case DocSymbol::Tilde: m_t << "&" << s->letter() << "tilde;"; break; + case DocSymbol::Szlig: m_t << "ß"; break; + case DocSymbol::Cedil: m_t << "&" << s->letter() << "cedul;"; break; + case DocSymbol::Ring: m_t << "&" << s->letter() << "ring;"; break; + case DocSymbol::Nbsp: m_t << " "; break; + default: + printf("Error: unknown symbol found\n"); + } +} + +void HtmlDocVisitor::visit(DocURL *u) +{ + if (m_hide) return; + m_t << "<a href=\"" << u->url() << "\">" << u->url() << "</a>"; +} + +void HtmlDocVisitor::visit(DocLineBreak *) +{ + if (m_hide) return; + m_t << "<br>\n"; +} + +void HtmlDocVisitor::visit(DocHorRuler *) +{ + if (m_hide) return; + m_t << "<hr>\n"; +} + +void HtmlDocVisitor::visit(DocStyleChange *s) +{ + if (m_hide) return; + switch (s->style()) + { + case DocStyleChange::Bold: + if (s->enable()) m_t << "<b>"; else m_t << "</b> "; + break; + case DocStyleChange::Italic: + if (s->enable()) m_t << "<em>"; else m_t << "</em> "; + break; + case DocStyleChange::Code: + if (s->enable()) m_t << "<code>"; else m_t << "</code> "; + break; + case DocStyleChange::Subscript: + if (s->enable()) m_t << "<sub>"; else m_t << "</sub> "; + break; + case DocStyleChange::Superscript: + if (s->enable()) m_t << "<sup>"; else m_t << "</sup> "; + break; + case DocStyleChange::Center: + if (s->enable()) m_t << "<center>"; else m_t << "</center> "; + break; + case DocStyleChange::Small: + if (s->enable()) m_t << "<small>"; else m_t << "</small> "; + break; + } +} + +void HtmlDocVisitor::visit(DocVerbatim *s) +{ + if (m_hide) return; + switch(s->type()) + { + case DocVerbatim::Code: // fall though + m_t << "<div class=\"fragment\"><pre>"; + parseCode(m_ci,s->context(),s->text(),FALSE,0); + m_t << "</pre></div>"; + break; + case DocVerbatim::Verbatim: + m_t << "<div class=\"fragment\"><pre>"; + filter(s->text()); + m_t << "</pre></div>"; + break; + case DocVerbatim::HtmlOnly: + m_t << s->text(); + break; + case DocVerbatim::LatexOnly: + /* nothing */ + break; + } +} + +void HtmlDocVisitor::visit(DocAnchor *) +{ + if (m_hide) return; + m_t << "<a name=\"%s\"/></a>"; +} + +void HtmlDocVisitor::visit(DocInclude *inc) +{ + if (m_hide) return; + switch(inc->type()) + { + case DocInclude::Include: + m_t << "<div class=\"fragment\"><pre>"; + parseCode(m_ci,inc->context(),inc->text(),FALSE,0); + m_t << "</pre></div>"; + break; + case DocInclude::DontInclude: + break; + case DocInclude::HtmlInclude: + m_t << inc->text(); + break; + case DocInclude::VerbInclude: + m_t << "<div class=\"fragment\"><pre>"; + filter(inc->text()); + m_t << "</pre></div>"; + break; + } +} + +void HtmlDocVisitor::visit(DocIncOperator *op) +{ + //printf("DocIncOperator: type=%d first=%d, last=%d text=`%s'\n", + // op->type(),op->isFirst(),op->isLast(),op->text().data()); + if (op->isFirst()) + { + m_t << "<div class=\"fragment\"><pre>"; + m_hide = TRUE; + } + if (op->type()!=DocIncOperator::Skip) + { + parseCode(m_ci,op->context(),op->text(),FALSE,0); + } + if (op->isLast()) + { + m_hide = FALSE; + m_t << "</pre></div>"; + } + else + { + m_t << endl; + } +} + +void HtmlDocVisitor::visit(DocFormula *f) +{ + if (m_hide) return; + if (f->text().at(0)=='\\') m_t << "<p><center>" << endl; + m_t << "<img align="; +#if !defined(_WIN32) + m_t << "\"top\""; // assume Unix users use Netscape 4.x which does + // not seem to support align == "middle" :-(( +#else + m_t << "\"middle\""; // assume Windows users use IE or HtmlHelp which on + // displays formulas nicely with align == "middle" +#endif + m_t << " src=\"" << f->name() << ".png\">"; + if (f->text().at(0)=='\\') + m_t << endl << "</center><p>" << endl; + else + m_t << " "; +} + +//-------------------------------------- +// visitor functions for compound nodes +//-------------------------------------- + +void HtmlDocVisitor::visitPre(DocAutoList *l) +{ + if (l->isEnumList()) + { + m_t << "<ol>\n"; + } + else + { + m_t << "<ul>\n"; + } +} + +void HtmlDocVisitor::visitPost(DocAutoList *l) +{ + if (l->isEnumList()) + { + m_t << "</ol>\n"; + } + else + { + m_t << "</ul>\n"; + } +} + +void HtmlDocVisitor::visitPre(DocAutoListItem *) +{ + m_t << "<li>"; +} + +void HtmlDocVisitor::visitPost(DocAutoListItem *) +{ + m_t << "</li>"; +} + +void HtmlDocVisitor::visitPre(DocPara *) +{ +} + +void HtmlDocVisitor::visitPost(DocPara *p) +{ + if (!p->isLast() && // omit <p> for last paragraph + !(p->parent() && // and for parameter sections + p->parent()->kind()==DocNode::Kind_ParamSect + ) + ) m_t << "\n<p>\n"; +} + +void HtmlDocVisitor::visitPre(DocRoot *) +{ + //m_t << "<hr><h4><font color=\"red\">New parser:</font></h4>\n"; +} + +void HtmlDocVisitor::visitPost(DocRoot *) +{ + //m_t << "<hr><h4><font color=\"red\">Old parser:</font></h4>\n"; +} + +void HtmlDocVisitor::visitPre(DocSimpleSect *s) +{ + m_t << "<dl compact><dt><b>"; + switch(s->type()) + { + case DocSimpleSect::See: + m_t << theTranslator->trSeeAlso(); break; + case DocSimpleSect::Return: + m_t << theTranslator->trReturns(); break; + case DocSimpleSect::Author: + m_t << theTranslator->trAuthor(TRUE,TRUE); break; + case DocSimpleSect::Authors: + m_t << theTranslator->trAuthor(TRUE,FALSE); break; + case DocSimpleSect::Version: + m_t << theTranslator->trVersion(); break; + case DocSimpleSect::Since: + m_t << theTranslator->trSince(); break; + case DocSimpleSect::Date: + m_t << theTranslator->trDate(); break; + case DocSimpleSect::Note: + m_t << theTranslator->trNote(); break; + case DocSimpleSect::Warning: + m_t << theTranslator->trWarning(); break; + case DocSimpleSect::Pre: + m_t << theTranslator->trPrecondition(); break; + case DocSimpleSect::Post: + m_t << theTranslator->trPostcondition(); break; + case DocSimpleSect::Invar: + m_t << theTranslator->trInvariant(); break; + case DocSimpleSect::Remark: + m_t << theTranslator->trRemarks(); break; + case DocSimpleSect::Attention: + m_t << theTranslator->trAttention(); break; + case DocSimpleSect::User: break; + case DocSimpleSect::Unknown: break; + } + + // special case 1: user defined title + if (s->type()!=DocSimpleSect::User) + { + m_t << ":</b></dt><dd>"; + } +} + +void HtmlDocVisitor::visitPost(DocSimpleSect *) +{ + m_t << "</dd></dl>\n"; +} + +void HtmlDocVisitor::visitPre(DocTitle *) +{ +} + +void HtmlDocVisitor::visitPost(DocTitle *) +{ + m_t << "</b></dt><dd>"; +} + +void HtmlDocVisitor::visitPre(DocSimpleList *) +{ + m_t << "<ul>\n"; +} + +void HtmlDocVisitor::visitPost(DocSimpleList *) +{ + m_t << "</ul>\n"; +} + +void HtmlDocVisitor::visitPre(DocSimpleListItem *) +{ + m_t << "<li>"; +} + +void HtmlDocVisitor::visitPost(DocSimpleListItem *) +{ + m_t << "</li>\n"; +} + +void HtmlDocVisitor::visitPre(DocSection *s) +{ + m_t << "<h" << s->level()+1 << ">"; + m_t << "<a name=\"" << s->anchor(); + filter(s->title()); + m_t << "\"</a>" << endl; + m_t << "</h" << s->level()+1 << ">\n"; +} + +void HtmlDocVisitor::visitPost(DocSection *) +{ +} + +void HtmlDocVisitor::visitPre(DocHtmlList *s) +{ + if (s->type()==DocHtmlList::Ordered) + m_t << "<ol>\n"; + else + m_t << "<ul>\n"; +} + +void HtmlDocVisitor::visitPost(DocHtmlList *s) +{ + if (s->type()==DocHtmlList::Ordered) + m_t << "</ol>\n"; + else + m_t << "</ul>\n"; +} + +void HtmlDocVisitor::visitPre(DocHtmlListItem *) +{ + m_t << "<li>\n"; +} + +void HtmlDocVisitor::visitPost(DocHtmlListItem *) +{ + m_t << "</li>\n"; +} + +void HtmlDocVisitor::visitPre(DocHtmlPre *) +{ + m_t << "<pre>\n"; + m_insidePre=TRUE; +} + +void HtmlDocVisitor::visitPost(DocHtmlPre *) +{ + m_insidePre=FALSE; + m_t << "</pre>\n"; +} + +void HtmlDocVisitor::visitPre(DocHtmlDescList *) +{ + m_t << "<dl>\n"; +} + +void HtmlDocVisitor::visitPost(DocHtmlDescList *) +{ + m_t << "</dl>\n"; +} + +void HtmlDocVisitor::visitPre(DocHtmlDescTitle *) +{ + m_t << "<dt>"; +} + +void HtmlDocVisitor::visitPost(DocHtmlDescTitle *) +{ + m_t << "</dt>\n"; +} + +void HtmlDocVisitor::visitPre(DocHtmlDescData *) +{ + m_t << "<dd>"; +} + +void HtmlDocVisitor::visitPost(DocHtmlDescData *) +{ + m_t << "</dd>\n"; +} + +void HtmlDocVisitor::visitPre(DocHtmlTable *) +{ + m_t << "<table border=\"1\" cellspacing=\"3\" cellpadding=\"3\">\n"; +} + +void HtmlDocVisitor::visitPost(DocHtmlTable *) +{ + m_t << "</table>\n"; +} + +void HtmlDocVisitor::visitPre(DocHtmlRow *) +{ + m_t << "<tr>\n"; +} + +void HtmlDocVisitor::visitPost(DocHtmlRow *) +{ + m_t << "</tr>\n"; +} + +void HtmlDocVisitor::visitPre(DocHtmlCell *c) +{ + if (c->isHeading()) m_t << "<th>"; else m_t << "<td>"; +} + +void HtmlDocVisitor::visitPost(DocHtmlCell *c) +{ + if (c->isHeading()) m_t << "</th>"; else m_t << "</td>"; +} + +void HtmlDocVisitor::visitPre(DocHtmlCaption *) +{ + m_t << "<caption align=\"bottom\">"; +} + +void HtmlDocVisitor::visitPost(DocHtmlCaption *) +{ + m_t << "</caption>\n"; +} + +void HtmlDocVisitor::visitPre(DocIndexEntry *) +{ + m_hide = TRUE; +} + +void HtmlDocVisitor::visitPost(DocIndexEntry *) +{ + m_hide = FALSE; +} + +void HtmlDocVisitor::visitPre(DocInternal *) +{ + m_t << "<p><b>" << theTranslator->trForInternalUseOnly() << "</b></p>" << endl; + m_t << "<p>" << endl; +} + +void HtmlDocVisitor::visitPost(DocInternal *) +{ + m_t << "</p>" << endl; +} + +void HtmlDocVisitor::visitPre(DocHRef *href) +{ + m_t << "<a href=\"" << href->url() << "\">"; +} + +void HtmlDocVisitor::visitPost(DocHRef *) +{ + m_t << "</a>"; +} + +void HtmlDocVisitor::visitPre(DocHtmlHeader *header) +{ + m_t << "<h" << header->level() << ">"; +} + +void HtmlDocVisitor::visitPost(DocHtmlHeader *header) +{ + m_t << "</h" << header->level() << ">\n"; +} + +void HtmlDocVisitor::visitPre(DocImage *img) +{ + if (img->type()==DocImage::Html) + { + QCString baseName=img->name(); + int i; + if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1) + { + baseName=baseName.right(baseName.length()-i-1); + } + m_t << "<div align=\"center\">" << endl; + m_t << "<img src=\"" << img->name() << "\" alt=\"" + << baseName << "\">" << endl; + if (img->hasCaption()) + { + m_t << "<p><strong>"; + } + } + else // other format -> skip + { + m_hide=TRUE; + } +} + +void HtmlDocVisitor::visitPost(DocImage *img) +{ + if (img->type()==DocImage::Html) + { + if (img->hasCaption()) + { + m_t << "</strong></p>"; + } + m_t << "</div>" << endl; + } + else // other format + { + m_hide=FALSE; + } +} + +void HtmlDocVisitor::visitPre(DocDotFile *df) +{ + QCString baseName=df->file(); + int i; + if ((i=baseName.findRev('/'))!=-1) + { + baseName=baseName.right(baseName.length()-i-1); + } + QCString outDir = Config_getString("HTML_OUTPUT"); + writeDotGraphFromFile(df->file(),outDir,baseName,BITMAP); + m_t << "<div align=\"center\">" << endl; + m_t << "<img src=\"" << baseName << "." + << Config_getEnum("DOT_IMAGE_FORMAT") << "\" alt=\"" + << baseName << "\">" << endl; + if (df->hasCaption()) + { + m_t << "<p><strong>"; + } +} + +void HtmlDocVisitor::visitPost(DocDotFile *df) +{ + if (df->hasCaption()) + { + m_t << "</strong></p>" << endl; + } + m_t << "</div>" << endl; +} + +void HtmlDocVisitor::visitPre(DocLink *lnk) +{ + startLink(lnk->ref(),lnk->file(),lnk->anchor()); +} + +void HtmlDocVisitor::visitPost(DocLink *) +{ + endLink(); +} + +void HtmlDocVisitor::visitPre(DocRef *ref) +{ + startLink(ref->ref(),ref->file(),ref->anchor()); + if (!ref->hasLinkText()) filter(ref->targetTitle()); +} + +void HtmlDocVisitor::visitPost(DocRef *) +{ + endLink(); + m_t << " "; +} + +void HtmlDocVisitor::visitPre(DocSecRefItem *ref) +{ + QCString refName=ref->file(); + if (refName.right(Doxygen::htmlFileExtension.length())!=Doxygen::htmlFileExtension) + { + refName+=Doxygen::htmlFileExtension; + } + m_t << "<li><a href=\"" << refName << "#" << ref->anchor() << "\">"; + +} + +void HtmlDocVisitor::visitPost(DocSecRefItem *) +{ + m_t << "</a> "; +} + +void HtmlDocVisitor::visitPre(DocSecRefList *) +{ + m_t << "<multicol cols=3>" << endl; + m_t << "<ul>" << endl; +} + +void HtmlDocVisitor::visitPost(DocSecRefList *) +{ + m_t << "</ul>" << endl; + m_t << "</multicol>" << endl; +} + +void HtmlDocVisitor::visitPre(DocLanguage *) +{ +} + +void HtmlDocVisitor::visitPost(DocLanguage *) +{ +} + +void HtmlDocVisitor::visitPre(DocParamSect *s) +{ + m_t << "<dl compact><dt><b>"; + switch(s->type()) + { + case DocParamSect::Param: + m_t << theTranslator->trParameters(); break; + case DocParamSect::RetVal: + m_t << theTranslator->trReturnValues(); break; + case DocParamSect::Exception: + m_t << theTranslator->trExceptions(); break; + default: + ASSERT(0); + } + m_t << ":"; + m_t << "</b></dt><dd>" << endl; + m_t << " <table border=\"0\" cellspacing=\"2\" cellpadding=\"0\">" << endl; +} + +void HtmlDocVisitor::visitPost(DocParamSect *) +{ + m_t << " </table>" << endl; + m_t << "</dl>" << endl; +} + +void HtmlDocVisitor::visitPre(DocParamList *pl) +{ + m_t << " <tr><td valign=top><em>"; + QStrListIterator li(pl->parameters()); + const char *s; + bool first=TRUE; + for (li.toFirst();(s=li.current());++li) + { + if (!first) m_t << ","; else first=FALSE; + m_t << s; + } + m_t << "</em> </td><td>"; +} + +void HtmlDocVisitor::visitPost(DocParamList *) +{ + m_t << "</td></tr>" << endl; +} + +void HtmlDocVisitor::visitPre(DocXRefItem *x) +{ + m_t << "<dl compact><dt><b><a class=\"el\" href=\"" + << x->file() << Doxygen::htmlFileExtension << "#" << x->anchor() << "\">"; + filter(x->title()); + m_t << ":</a></b></dt><dd>"; +} + +void HtmlDocVisitor::visitPost(DocXRefItem *) +{ + m_t << "</dd></dl>" << endl; +} + +void HtmlDocVisitor::visitPre(DocInternalRef *ref) +{ + startLink(0,ref->file(),ref->anchor()); +} + +void HtmlDocVisitor::visitPost(DocInternalRef *) +{ + endLink(); + m_t << " "; +} + +void HtmlDocVisitor::visitPre(DocCopy *) +{ +} + +void HtmlDocVisitor::visitPost(DocCopy *) +{ +} void HtmlDocVisitor::filter(const char *str) { diff --git a/src/htmldocvisitor.h b/src/htmldocvisitor.h index 39956da..2be1fa5 100644 --- a/src/htmldocvisitor.h +++ b/src/htmldocvisitor.h @@ -20,646 +20,109 @@ #define _HTMLDOCVISITOR_H #include "docvisitor.h" -#include "docparser.h" -#include "language.h" -#include "doxygen.h" -#include "outputgen.h" -#include "code.h" -#include "dot.h" + +class QTextStream; +class BaseCodeDocInterface; +class QCString; /*! @brief Concrete visitor implementation for HTML output. */ class HtmlDocVisitor : public DocVisitor { public: - HtmlDocVisitor(QTextStream &t,BaseCodeDocInterface &ci) - : m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE) {} + HtmlDocVisitor(QTextStream &t,BaseCodeDocInterface &ci); //-------------------------------------- // visitor functions for leaf nodes //-------------------------------------- - void visit(DocWord *w) - { - if (m_hide) return; - filter(w->word()); - } - void visit(DocLinkedWord *w) - { - if (m_hide) return; - startLink(w->ref(),w->file(),w->anchor()); - filter(w->word()); - endLink(); - } - void visit(DocWhiteSpace *w) - { - if (m_hide) return; - if (m_insidePre) - { - m_t << w->chars(); - } - else - { - m_t << " "; - } - } - void visit(DocSymbol *s) - { - if (m_hide) return; - switch(s->symbol()) - { - case DocSymbol::BSlash: m_t << "\\"; break; - case DocSymbol::At: m_t << "@"; break; - case DocSymbol::Less: m_t << "<"; break; - case DocSymbol::Greater: m_t << ">"; break; - case DocSymbol::Amp: m_t << "&"; break; - case DocSymbol::Dollar: m_t << "$"; break; - case DocSymbol::Hash: m_t << "#"; break; - case DocSymbol::Percent: m_t << "%"; break; - case DocSymbol::Copy: m_t << "©"; break; - case DocSymbol::Apos: m_t << "'"; break; - case DocSymbol::Quot: m_t << "\""; break; - case DocSymbol::Uml: m_t << "&" << s->letter() << "uml;"; break; - case DocSymbol::Acute: m_t << "&" << s->letter() << "acute;"; break; - case DocSymbol::Grave: m_t << "&" << s->letter() << "grave;"; break; - case DocSymbol::Circ: m_t << "&" << s->letter() << "circ;"; break; - case DocSymbol::Tilde: m_t << "&" << s->letter() << "tilde;"; break; - case DocSymbol::Szlig: m_t << "ß"; break; - case DocSymbol::Cedil: m_t << "&" << s->letter() << "cedul;"; break; - case DocSymbol::Ring: m_t << "&" << s->letter() << "ring;"; break; - case DocSymbol::Nbsp: m_t << " "; break; - default: - printf("Error: unknown symbol found\n"); - } - } - void visit(DocURL *u) - { - if (m_hide) return; - m_t << "<a href=\"" << u->url() << "\">" << u->url() << "</a>"; - } - void visit(DocLineBreak *) - { - if (m_hide) return; - m_t << "<br>\n"; - } - void visit(DocHorRuler *) - { - if (m_hide) return; - m_t << "<hr>\n"; - } - void visit(DocStyleChange *s) - { - if (m_hide) return; - switch (s->style()) - { - case DocStyleChange::Bold: - if (s->enable()) m_t << "<b>"; else m_t << "</b> "; - break; - case DocStyleChange::Italic: - if (s->enable()) m_t << "<em>"; else m_t << "</em> "; - break; - case DocStyleChange::Code: - if (s->enable()) m_t << "<code>"; else m_t << "</code> "; - break; - case DocStyleChange::Subscript: - if (s->enable()) m_t << "<sub>"; else m_t << "</sub> "; - break; - case DocStyleChange::Superscript: - if (s->enable()) m_t << "<sup>"; else m_t << "</sup> "; - break; - case DocStyleChange::Center: - if (s->enable()) m_t << "<center>"; else m_t << "</center> "; - break; - case DocStyleChange::Small: - if (s->enable()) m_t << "<small>"; else m_t << "</small> "; - break; - } - } - void visit(DocVerbatim *s) - { - if (m_hide) return; - switch(s->type()) - { - case DocVerbatim::Code: // fall though - m_t << "<div class=\"fragment\"><pre>"; - parseCode(m_ci,s->context(),s->text(),FALSE,0); - m_t << "</pre></div>"; - break; - case DocVerbatim::Verbatim: - m_t << "<div class=\"fragment\"><pre>"; - filter(s->text()); - m_t << "</pre></div>"; - break; - case DocVerbatim::HtmlOnly: - m_t << s->text(); - break; - case DocVerbatim::LatexOnly: - /* nothing */ - break; - } - } - void visit(DocAnchor *) - { - if (m_hide) return; - m_t << "<a name=\"%s\"/></a>"; - } - void visit(DocInclude *inc) - { - if (m_hide) return; - switch(inc->type()) - { - case DocInclude::Include: - m_t << "<div class=\"fragment\"><pre>"; - parseCode(m_ci,inc->context(),inc->text(),FALSE,0); - m_t << "</pre></div>"; - break; - case DocInclude::DontInclude: - break; - case DocInclude::HtmlInclude: - m_t << inc->text(); - break; - case DocInclude::VerbInclude: - m_t << "<div class=\"fragment\"><pre>"; - filter(inc->text()); - m_t << "</pre></div>"; - break; - } - } - void visit(DocIncOperator *op) - { - //printf("DocIncOperator: type=%d first=%d, last=%d text=`%s'\n", - // op->type(),op->isFirst(),op->isLast(),op->text().data()); - if (op->isFirst()) - { - m_t << "<div class=\"fragment\"><pre>"; - m_hide = TRUE; - } - if (op->type()!=DocIncOperator::Skip) - { - parseCode(m_ci,op->context(),op->text(),FALSE,0); - } - if (op->isLast()) - { - m_hide = FALSE; - m_t << "</pre></div>"; - } - else - { - m_t << endl; - } - } - void visit(DocFormula *f) - { - if (m_hide) return; - if (f->text().at(0)=='\\') m_t << "<p><center>" << endl; - m_t << "<img align="; -#if !defined(_WIN32) - m_t << "\"top\""; // assume Unix users use Netscape 4.x which does - // not seem to support align == "middle" :-(( -#else - m_t << "\"middle\""; // assume Windows users use IE or HtmlHelp which on - // displays formulas nicely with align == "middle" -#endif - m_t << " src=\"" << f->name() << ".png\">"; - if (f->text().at(0)=='\\') - m_t << endl << "</center><p>" << endl; - else - m_t << " "; - } + void visit(DocWord *); + void visit(DocLinkedWord *); + void visit(DocWhiteSpace *); + void visit(DocSymbol *); + void visit(DocURL *); + void visit(DocLineBreak *); + void visit(DocHorRuler *); + void visit(DocStyleChange *); + void visit(DocVerbatim *); + void visit(DocAnchor *); + void visit(DocInclude *); + void visit(DocIncOperator *); + void visit(DocFormula *); //-------------------------------------- // visitor functions for compound nodes //-------------------------------------- - void visitPre(DocAutoList *l) - { - if (l->isEnumList()) - { - m_t << "<ol>\n"; - } - else - { - m_t << "<ul>\n"; - } - } - void visitPost(DocAutoList *l) - { - if (l->isEnumList()) - { - m_t << "</ol>\n"; - } - else - { - m_t << "</ul>\n"; - } - } - void visitPre(DocAutoListItem *) - { - m_t << "<li>"; - } - void visitPost(DocAutoListItem *) - { - m_t << "</li>"; - } - void visitPre(DocPara *) - { - } - void visitPost(DocPara *p) - { - if (!p->isLast() && // omit <p> for last paragraph - !(p->parent() && // and for parameter sections - p->parent()->kind()==DocNode::Kind_ParamSect - ) - ) m_t << "\n<p>\n"; - } - void visitPre(DocRoot *) - { - //m_t << "<hr><h4><font color=\"red\">New parser:</font></h4>\n"; - } - void visitPost(DocRoot *) - { - //m_t << "<hr><h4><font color=\"red\">Old parser:</font></h4>\n"; - } - void visitPre(DocSimpleSect *s) - { - m_t << "<dl compact><dt><b>"; - switch(s->type()) - { - case DocSimpleSect::See: - m_t << theTranslator->trSeeAlso(); break; - case DocSimpleSect::Return: - m_t << theTranslator->trReturns(); break; - case DocSimpleSect::Author: - m_t << theTranslator->trAuthor(TRUE,TRUE); break; - case DocSimpleSect::Authors: - m_t << theTranslator->trAuthor(TRUE,FALSE); break; - case DocSimpleSect::Version: - m_t << theTranslator->trVersion(); break; - case DocSimpleSect::Since: - m_t << theTranslator->trSince(); break; - case DocSimpleSect::Date: - m_t << theTranslator->trDate(); break; - case DocSimpleSect::Note: - m_t << theTranslator->trNote(); break; - case DocSimpleSect::Warning: - m_t << theTranslator->trWarning(); break; - case DocSimpleSect::Pre: - m_t << theTranslator->trPrecondition(); break; - case DocSimpleSect::Post: - m_t << theTranslator->trPostcondition(); break; - case DocSimpleSect::Invar: - m_t << theTranslator->trInvariant(); break; - case DocSimpleSect::Remark: - m_t << theTranslator->trRemarks(); break; - case DocSimpleSect::Attention: - m_t << theTranslator->trAttention(); break; - case DocSimpleSect::User: break; - case DocSimpleSect::Unknown: break; - } - - // special case 1: user defined title - if (s->type()!=DocSimpleSect::User) - { - m_t << ":</b></dt><dd>"; - } - } - void visitPost(DocSimpleSect *) - { - m_t << "</dd></dl>\n"; - } - void visitPre(DocTitle *) - { - } - void visitPost(DocTitle *) - { - m_t << "</b></dt><dd>"; - } - void visitPre(DocSimpleList *) - { - m_t << "<ul>\n"; - } - void visitPost(DocSimpleList *) - { - m_t << "</ul>\n"; - } - void visitPre(DocSimpleListItem *) - { - m_t << "<li>"; - } - void visitPost(DocSimpleListItem *) - { - m_t << "</li>\n"; - } - void visitPre(DocSection *s) - { - m_t << "<h" << s->level()+1 << ">"; - m_t << "<a name=\"" << s->anchor(); - filter(s->title()); - m_t << "\"</a>" << endl; - m_t << "</h" << s->level()+1 << ">\n"; - } - void visitPost(DocSection *) - { - } - void visitPre(DocHtmlList *s) - { - if (s->type()==DocHtmlList::Ordered) - m_t << "<ol>\n"; - else - m_t << "<ul>\n"; - } - void visitPost(DocHtmlList *s) - { - if (s->type()==DocHtmlList::Ordered) - m_t << "</ol>\n"; - else - m_t << "</ul>\n"; - } - void visitPre(DocHtmlListItem *) - { - m_t << "<li>\n"; - } - void visitPost(DocHtmlListItem *) - { - m_t << "</li>\n"; - } - void visitPre(DocHtmlPre *) - { - m_t << "<pre>\n"; - m_insidePre=TRUE; - } - void visitPost(DocHtmlPre *) - { - m_insidePre=FALSE; - m_t << "</pre>\n"; - } - void visitPre(DocHtmlDescList *) - { - m_t << "<dl>\n"; - } - void visitPost(DocHtmlDescList *) - { - m_t << "</dl>\n"; - } - void visitPre(DocHtmlDescTitle *) - { - m_t << "<dt>"; - } - void visitPost(DocHtmlDescTitle *) - { - m_t << "</dt>\n"; - } - void visitPre(DocHtmlDescData *) - { - m_t << "<dd>"; - } - void visitPost(DocHtmlDescData *) - { - m_t << "</dd>\n"; - } - void visitPre(DocHtmlTable *) - { - m_t << "<table border=\"1\" cellspacing=\"3\" cellpadding=\"3\">\n"; - } - void visitPost(DocHtmlTable *) - { - m_t << "</table>\n"; - } - void visitPre(DocHtmlRow *) - { - m_t << "<tr>\n"; - } - void visitPost(DocHtmlRow *) - { - m_t << "</tr>\n"; - } - void visitPre(DocHtmlCell *c) - { - if (c->isHeading()) m_t << "<th>"; else m_t << "<td>"; - } - void visitPost(DocHtmlCell *c) - { - if (c->isHeading()) m_t << "</th>"; else m_t << "</td>"; - } - void visitPre(DocHtmlCaption *) - { - m_t << "<caption align=\"bottom\">"; - } - void visitPost(DocHtmlCaption *) - { - m_t << "</caption>\n"; - } - void visitPre(DocIndexEntry *) - { - m_hide = TRUE; - } - void visitPost(DocIndexEntry *) - { - m_hide = FALSE; - } - void visitPre(DocInternal *) - { - m_t << "<p><b>" << theTranslator->trForInternalUseOnly() << "</b></p>" << endl; - m_t << "<p>" << endl; - } - void visitPost(DocInternal *) - { - m_t << "</p>" << endl; - } - void visitPre(DocHRef *href) - { - m_t << "<a href=\"" << href->url() << "\">"; - } - void visitPost(DocHRef *) - { - m_t << "</a>"; - } - void visitPre(DocHtmlHeader *header) - { - m_t << "<h" << header->level() << ">"; - } - void visitPost(DocHtmlHeader *header) - { - m_t << "</h" << header->level() << ">\n"; - } - void visitPre(DocImage *img) - { - if (img->type()==DocImage::Html) - { - QCString baseName=img->name(); - int i; - if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1) - { - baseName=baseName.right(baseName.length()-i-1); - } - m_t << "<div align=\"center\">" << endl; - m_t << "<img src=\"" << img->name() << "\" alt=\"" - << baseName << "\">" << endl; - if (img->hasCaption()) - { - m_t << "<p><strong>"; - } - } - else // other format -> skip - { - m_hide=TRUE; - } - } - void visitPost(DocImage *img) - { - if (img->type()==DocImage::Html) - { - if (img->hasCaption()) - { - m_t << "</strong></p>"; - } - m_t << "</div>" << endl; - } - else // other format - { - m_hide=FALSE; - } - } - void visitPre(DocDotFile *df) - { - QCString baseName=df->file(); - int i; - if ((i=baseName.findRev('/'))!=-1) - { - baseName=baseName.right(baseName.length()-i-1); - } - QCString outDir = Config_getString("HTML_OUTPUT"); - writeDotGraphFromFile(df->file(),outDir,baseName,BITMAP); - m_t << "<div align=\"center\">" << endl; - m_t << "<img src=\"" << baseName << "." - << Config_getEnum("DOT_IMAGE_FORMAT") << "\" alt=\"" - << baseName << "\">" << endl; - if (df->hasCaption()) - { - m_t << "<p><strong>"; - } - } - void visitPost(DocDotFile *df) - { - if (df->hasCaption()) - { - m_t << "</strong></p>" << endl; - } - m_t << "</div>" << endl; - } - void visitPre(DocLink *lnk) - { - startLink(lnk->ref(),lnk->file(),lnk->anchor()); - } - void visitPost(DocLink *) - { - endLink(); - } - void visitPre(DocRef *ref) - { - startLink(ref->ref(),ref->file(),ref->anchor()); - if (!ref->hasLinkText()) filter(ref->targetTitle()); - } - void visitPost(DocRef *) - { - endLink(); - m_t << " "; - } - void visitPre(DocSecRefItem *ref) - { - QCString refName=ref->file(); - if (refName.right(Doxygen::htmlFileExtension.length())!=Doxygen::htmlFileExtension) - { - refName+=Doxygen::htmlFileExtension; - } - m_t << "<li><a href=\"" << refName << "#" << ref->anchor() << "\">"; - - } - void visitPost(DocSecRefItem *) - { - m_t << "</a> "; - } - void visitPre(DocSecRefList *) - { - m_t << "<multicol cols=3>" << endl; - m_t << "<ul>" << endl; - } - void visitPost(DocSecRefList *) - { - m_t << "</ul>" << endl; - m_t << "</multicol>" << endl; - } - void visitPre(DocLanguage *) - { - } - void visitPost(DocLanguage *) - { - } - void visitPre(DocParamSect *s) - { - m_t << "<dl compact><dt><b>"; - switch(s->type()) - { - case DocParamSect::Param: - m_t << theTranslator->trParameters(); break; - case DocParamSect::RetVal: - m_t << theTranslator->trReturnValues(); break; - case DocParamSect::Exception: - m_t << theTranslator->trExceptions(); break; - default: - ASSERT(0); - } - m_t << ":"; - m_t << "</b></dt><dd>" << endl; - m_t << " <table border=\"0\" cellspacing=\"2\" cellpadding=\"0\">" << endl; - } - void visitPost(DocParamSect *) - { - m_t << " </table>" << endl; - m_t << "</dl>" << endl; - } - void visitPre(DocParamList *pl) - { - m_t << " <tr><td valign=top><em>"; - QStrListIterator li(pl->parameters()); - const char *s; - bool first=TRUE; - for (li.toFirst();(s=li.current());++li) - { - if (!first) m_t << ","; else first=FALSE; - m_t << s; - } - m_t << "</em> </td><td>"; - } - void visitPost(DocParamList *) - { - m_t << "</td></tr>" << endl; - } - void visitPre(DocXRefItem *x) - { - m_t << "<dl compact><dt><b><a class=\"el\" href=\"" - << x->file() << Doxygen::htmlFileExtension << "#" << x->anchor() << "\">"; - filter(x->title()); - m_t << ":</a></b></dt><dd>"; - } - void visitPost(DocXRefItem *) - { - m_t << "</dd></dl>" << endl; - } - void visitPre(DocInternalRef *ref) - { - startLink(0,ref->file(),ref->anchor()); - } - void visitPost(DocInternalRef *) - { - endLink(); - m_t << " "; - } - void visitPre(DocCopy *) - { - } - void visitPost(DocCopy *) - { - } + void visitPre(DocAutoList *); + void visitPost(DocAutoList *); + void visitPre(DocAutoListItem *); + void visitPost(DocAutoListItem *); + void visitPre(DocPara *) ; + void visitPost(DocPara *); + void visitPre(DocRoot *); + void visitPost(DocRoot *); + void visitPre(DocSimpleSect *); + void visitPost(DocSimpleSect *); + void visitPre(DocTitle *); + void visitPost(DocTitle *); + void visitPre(DocSimpleList *); + void visitPost(DocSimpleList *); + void visitPre(DocSimpleListItem *); + void visitPost(DocSimpleListItem *); + void visitPre(DocSection *); + void visitPost(DocSection *); + void visitPre(DocHtmlList *); + void visitPost(DocHtmlList *) ; + void visitPre(DocHtmlListItem *); + void visitPost(DocHtmlListItem *); + void visitPre(DocHtmlPre *); + void visitPost(DocHtmlPre *); + void visitPre(DocHtmlDescList *); + void visitPost(DocHtmlDescList *); + void visitPre(DocHtmlDescTitle *); + void visitPost(DocHtmlDescTitle *); + void visitPre(DocHtmlDescData *); + void visitPost(DocHtmlDescData *); + void visitPre(DocHtmlTable *); + void visitPost(DocHtmlTable *); + void visitPre(DocHtmlRow *); + void visitPost(DocHtmlRow *) ; + void visitPre(DocHtmlCell *); + void visitPost(DocHtmlCell *); + void visitPre(DocHtmlCaption *); + void visitPost(DocHtmlCaption *); + void visitPre(DocIndexEntry *); + void visitPost(DocIndexEntry *); + void visitPre(DocInternal *); + void visitPost(DocInternal *); + void visitPre(DocHRef *); + void visitPost(DocHRef *); + void visitPre(DocHtmlHeader *); + void visitPost(DocHtmlHeader *); + void visitPre(DocImage *); + void visitPost(DocImage *); + void visitPre(DocDotFile *); + void visitPost(DocDotFile *); + void visitPre(DocLink *); + void visitPost(DocLink *); + void visitPre(DocRef *); + void visitPost(DocRef *); + void visitPre(DocSecRefItem *); + void visitPost(DocSecRefItem *); + void visitPre(DocSecRefList *); + void visitPost(DocSecRefList *); + void visitPre(DocLanguage *); + void visitPost(DocLanguage *); + void visitPre(DocParamSect *); + void visitPost(DocParamSect *); + void visitPre(DocParamList *); + void visitPost(DocParamList *); + void visitPre(DocXRefItem *); + void visitPost(DocXRefItem *); + void visitPre(DocInternalRef *); + void visitPost(DocInternalRef *); + void visitPre(DocCopy *); + void visitPost(DocCopy *); private: diff --git a/src/htmlgen.cpp b/src/htmlgen.cpp index 61f2eef..f95d2d7 100644 --- a/src/htmlgen.cpp +++ b/src/htmlgen.cpp @@ -30,6 +30,7 @@ #include "dot.h" #include "language.h" #include "htmlhelp.h" +#include "docparser.h" #include "htmldocvisitor.h" // #define GROUP_COLOR "#ff8080" diff --git a/src/latexdocvisitor.cpp b/src/latexdocvisitor.cpp index ab310c8..c6a13ab 100644 --- a/src/latexdocvisitor.cpp +++ b/src/latexdocvisitor.cpp @@ -17,8 +17,830 @@ */ #include "latexdocvisitor.h" +#include "docparser.h" +#include "language.h" +#include "doxygen.h" +#include "outputgen.h" +#include "code.h" +#include "dot.h" #include "util.h" +LatexDocVisitor::LatexDocVisitor(QTextStream &t,BaseCodeDocInterface &ci) + : m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE) +{ +} + + //-------------------------------------- + // visitor functions for leaf nodes + //-------------------------------------- + +void LatexDocVisitor::visit(DocWord *w) +{ + if (m_hide) return; + filter(w->word()); +} + +void LatexDocVisitor::visit(DocLinkedWord *w) +{ + if (m_hide) return; + startLink(w->ref(),w->file(),w->anchor()); + filter(w->word()); + endLink(); +} + +void LatexDocVisitor::visit(DocWhiteSpace *w) +{ + if (m_hide) return; + if (m_insidePre) + { + m_t << w->chars(); + } + else + { + m_t << " "; + } +} + +void LatexDocVisitor::visit(DocSymbol *s) +{ + if (m_hide) return; + switch(s->symbol()) + { + case DocSymbol::BSlash: m_t << "$\\backslash$"; break; + case DocSymbol::At: m_t << "@"; break; + case DocSymbol::Less: m_t << "$<$"; break; + case DocSymbol::Greater: m_t << "$>$"; break; + case DocSymbol::Amp: m_t << "\\&"; break; + case DocSymbol::Dollar: m_t << "\\$"; break; + case DocSymbol::Hash: m_t << "\\#"; break; + case DocSymbol::Percent: m_t << "\\%"; break; + case DocSymbol::Copy: m_t << "\\copyright"; break; + case DocSymbol::Apos: m_t << "'"; break; + case DocSymbol::Quot: m_t << "''"; break; + case DocSymbol::Uml: + if (s->letter()=='i') + m_t << "\\\"{\\i}"; + else + m_t << "\\\"{" << s->letter() << "}"; + break; + case DocSymbol::Acute: + if (s->letter()=='i') + m_t << "\\'{\\i}"; + else + m_t << "\\'{" << s->letter() << "}"; + break; + case DocSymbol::Grave: + if (s->letter()=='i') + m_t << "\\`{\\i}"; + else + m_t << "\\`{" << s->letter() << "}"; + break; + case DocSymbol::Circ: + if (s->letter()=='i') + m_t << "\\^{\\i}"; + else + m_t << "\\^{" << s->letter() << "}"; + break; + case DocSymbol::Tilde: m_t << "\\~{" << s->letter() << "}"; break; + case DocSymbol::Szlig: m_t << "\"s"; break; + case DocSymbol::Cedil: m_t << "\\c{" << s->letter() << "}"; break; + case DocSymbol::Ring: m_t << "\\" << s->letter() << s->letter(); break; + case DocSymbol::Nbsp: m_t << "\\ "; break; + default: + printf("Error: unknown symbol found\n"); + } +} + +void LatexDocVisitor::visit(DocURL *u) +{ + if (m_hide) return; + if (Config_getBool("PDF_HYPERLINKS")) + { + m_t << "\\href{" << u->url() << "}"; + } + m_t << "{\\tt " << u->url() << "}"; +} + +void LatexDocVisitor::visit(DocLineBreak *) +{ + if (m_hide) return; + m_t << "\\par\n"; +} + +void LatexDocVisitor::visit(DocHorRuler *) +{ + if (m_hide) return; + m_t << "\n\n"; +} + +void LatexDocVisitor::visit(DocStyleChange *s) +{ + if (m_hide) return; + switch (s->style()) + { + case DocStyleChange::Bold: + if (s->enable()) m_t << "{\\bf "; else m_t << "} "; + break; + case DocStyleChange::Italic: + if (s->enable()) m_t << "{\\em "; else m_t << "} "; + break; + case DocStyleChange::Code: + if (s->enable()) m_t << "{\\tt "; else m_t << "} "; + break; + case DocStyleChange::Subscript: + if (s->enable()) m_t << "$_{\\mbox{"; else m_t << "}}$ "; + break; + case DocStyleChange::Superscript: + if (s->enable()) m_t << "$^{\\mbox{"; else m_t << "}}$ "; + break; + case DocStyleChange::Center: + if (s->enable()) m_t << "\\begin{center}"; else m_t << "\\end{center} "; + break; + case DocStyleChange::Small: + if (s->enable()) m_t << "\\footnotesize "; else m_t << "\\normalsize "; + break; + } +} + +void LatexDocVisitor::visit(DocVerbatim *s) +{ + if (m_hide) return; + switch(s->type()) + { + case DocVerbatim::Code: // fall though + m_t << "\n\n\\footnotesize\\begin{verbatim}"; + parseCode(m_ci,s->context(),s->text(),FALSE,0); + m_t << "\\end{verbatim}\\normalsize" << endl; + break; + case DocVerbatim::Verbatim: + m_t << "\n\n\\footnotesize\\begin{verbatim}"; + m_t << s->text(); + m_t << "\\end{verbatim}\\normalsize" << endl; + break; + case DocVerbatim::HtmlOnly: + /* nothing */ + break; + case DocVerbatim::LatexOnly: + m_t << s->text(); + break; + } +} + +void LatexDocVisitor::visit(DocAnchor *anc) +{ + if (m_hide) return; + m_t << "\\label{" << anc->anchor() << "}" << endl; + if (!anc->file().isEmpty() && Config_getBool("PDF_HYPERLINKS")) + { + m_t << "\\hypertarget{" << anc->file() << "_" << anc->anchor() + << "}{}" << endl; + } +} + +void LatexDocVisitor::visit(DocInclude *inc) +{ + if (m_hide) return; + switch(inc->type()) + { + case DocInclude::Include: + m_t << "\n\n\\footnotesize\\begin{verbatim}"; + parseCode(m_ci,inc->context(),inc->text(),FALSE,0); + m_t << "\\end{verbatim}\\normalsize" << endl; + break; + case DocInclude::DontInclude: + break; + case DocInclude::HtmlInclude: + break; + case DocInclude::VerbInclude: + m_t << "\n\n\\footnotesize\\begin{verbatim}"; + m_t << inc->text(); + m_t << "\\end{verbatim}\\normalsize" << endl; + break; + } +} + +void LatexDocVisitor::visit(DocIncOperator *op) +{ + //printf("DocIncOperator: type=%d first=%d, last=%d text=`%s'\n", + // op->type(),op->isFirst(),op->isLast(),op->text().data()); + if (op->isFirst()) + { + m_t << "\n\n\\footnotesize\\begin{verbatim}"; + m_hide = TRUE; + } + if (op->type()!=DocIncOperator::Skip) + { + parseCode(m_ci,op->context(),op->text(),FALSE,0); + } + if (op->isLast()) + { + m_hide = FALSE; + m_t << "\\end{verbatim}\\normalsize" << endl; + } + else + { + m_t << endl; + } +} + +void LatexDocVisitor::visit(DocFormula *f) +{ + if (m_hide) return; + m_t << f->text(); +} + +//-------------------------------------- +// visitor functions for compound nodes +//-------------------------------------- + +void LatexDocVisitor::visitPre(DocAutoList *l) +{ + if (l->isEnumList()) + { + m_t << "\\begin{enumerate}" << endl; + } + else + { + m_t << "\\begin{itemize}" << endl; + } +} + +void LatexDocVisitor::visitPost(DocAutoList *l) +{ + if (l->isEnumList()) + { + m_t << "\\end{enumerate}" << endl; + } + else + { + m_t << "\\end{itemize}" << endl; + } +} + +void LatexDocVisitor::visitPre(DocAutoListItem *) +{ + m_t << "\\item "; +} + +void LatexDocVisitor::visitPost(DocAutoListItem *) +{ +} + +void LatexDocVisitor::visitPre(DocPara *) +{ +} + +void LatexDocVisitor::visitPost(DocPara *p) +{ + if (!p->isLast() && // omit <p> for last paragraph + !(p->parent() && // and for parameter sections + p->parent()->kind()==DocNode::Kind_ParamSect + ) + ) m_t << endl << endl; +} + +void LatexDocVisitor::visitPre(DocRoot *) +{ +} + +void LatexDocVisitor::visitPost(DocRoot *) +{ +} + +void LatexDocVisitor::visitPre(DocSimpleSect *s) +{ + m_t << "\\begin{Desc}\n\\item["; + switch(s->type()) + { + case DocSimpleSect::See: + m_t << theTranslator->trSeeAlso(); break; + case DocSimpleSect::Return: + m_t << theTranslator->trReturns(); break; + case DocSimpleSect::Author: + m_t << theTranslator->trAuthor(TRUE,TRUE); break; + case DocSimpleSect::Authors: + m_t << theTranslator->trAuthor(TRUE,FALSE); break; + case DocSimpleSect::Version: + m_t << theTranslator->trVersion(); break; + case DocSimpleSect::Since: + m_t << theTranslator->trSince(); break; + case DocSimpleSect::Date: + m_t << theTranslator->trDate(); break; + case DocSimpleSect::Note: + m_t << theTranslator->trNote(); break; + case DocSimpleSect::Warning: + m_t << theTranslator->trWarning(); break; + case DocSimpleSect::Pre: + m_t << theTranslator->trPrecondition(); break; + case DocSimpleSect::Post: + m_t << theTranslator->trPostcondition(); break; + case DocSimpleSect::Invar: + m_t << theTranslator->trInvariant(); break; + case DocSimpleSect::Remark: + m_t << theTranslator->trRemarks(); break; + case DocSimpleSect::Attention: + m_t << theTranslator->trAttention(); break; + case DocSimpleSect::User: break; + case DocSimpleSect::Unknown: break; + } + + // special case 1: user defined title + if (s->type()!=DocSimpleSect::User) + { + m_t << ":]"; + } +} + +void LatexDocVisitor::visitPost(DocSimpleSect *) +{ + m_t << "\\end{Desc}" << endl; +} + +void LatexDocVisitor::visitPre(DocTitle *) +{ +} + +void LatexDocVisitor::visitPost(DocTitle *) +{ + m_t << "]"; +} + +void LatexDocVisitor::visitPre(DocSimpleList *) +{ + m_t << "\\begin{itemize}" << endl; +} + +void LatexDocVisitor::visitPost(DocSimpleList *) +{ + m_t << "\\end{itemize}" << endl; +} + +void LatexDocVisitor::visitPre(DocSimpleListItem *) +{ + m_t << "\\item "; +} + +void LatexDocVisitor::visitPost(DocSimpleListItem *) +{ +} + +void LatexDocVisitor::visitPre(DocSection *s) +{ + if (Config_getBool("PDF_HYPERLINKS")) + { + m_t << "\\hypertarget{" << s->file() << "_" << s->anchor() << "}{}"; + } + if (s->level()==1) + { + if (Config_getBool("COMPACT_LATEX")) + { + m_t << "\\subsubsection{"; + } + else + { + m_t << "\\subsection{"; + } + } + else if (s->level()==2) + { + if (Config_getBool("COMPACT_LATEX")) + { + m_t << "\\paragraph{"; + } + else + { + m_t << "\\subsubsection{"; + } + } + filter(s->title()); + m_t << "}\\label{" << s->anchor() << "}" << endl; +} + +void LatexDocVisitor::visitPost(DocSection *) +{ +} + +void LatexDocVisitor::visitPre(DocHtmlList *s) +{ + if (s->type()==DocHtmlList::Ordered) + m_t << "\\begin{enumerate}" << endl; + else + m_t << "\\begin{itemize}" << endl; +} + +void LatexDocVisitor::visitPost(DocHtmlList *s) +{ + if (s->type()==DocHtmlList::Ordered) + m_t << "\\end{enumerate}" << endl; + else + m_t << "\\end{itemize}" << endl; +} + +void LatexDocVisitor::visitPre(DocHtmlListItem *) +{ + m_t << "\\item "; +} + +void LatexDocVisitor::visitPost(DocHtmlListItem *) +{ +} + +void LatexDocVisitor::visitPre(DocHtmlPre *) +{ + m_t << "\\small\\begin{alltt}"; + m_insidePre=TRUE; +} + +void LatexDocVisitor::visitPost(DocHtmlPre *) +{ + m_insidePre=FALSE; + m_t << "\\end{alltt}\\normalsize " << endl; +} + +void LatexDocVisitor::visitPre(DocHtmlDescList *) +{ + m_t << "\\begin{description}" << endl; +} + +void LatexDocVisitor::visitPost(DocHtmlDescList *) +{ + m_t << "\\end{description}" << endl; +} + +void LatexDocVisitor::visitPre(DocHtmlDescTitle *) +{ + m_t << "\\item["; +} + +void LatexDocVisitor::visitPost(DocHtmlDescTitle *) +{ + m_t << "]"; +} + +void LatexDocVisitor::visitPre(DocHtmlDescData *) +{ +} + +void LatexDocVisitor::visitPost(DocHtmlDescData *) +{ +} + +void LatexDocVisitor::visitPre(DocHtmlTable *t) +{ + if (t->hasCaption()) + { + m_t << "\\begin{table}[h]"; + } + m_t << "\\begin{TabularC}{" << t->numCols() << "}\n\\hline\n"; +} + +void LatexDocVisitor::visitPost(DocHtmlTable *t) +{ + if (t->hasCaption()) + { + m_t << "\\end{table}\n"; + } + else + { + m_t << "\\\\\\hline\n\\end{TabularC}\n"; + } +} + +void LatexDocVisitor::visitPre(DocHtmlCaption *) +{ + m_t << "\\\\\\hline\n\\end{TabularC}\n\\centering\n\\caption{"; +} + +void LatexDocVisitor::visitPost(DocHtmlCaption *) +{ + m_t << "}\n"; +} + +void LatexDocVisitor::visitPre(DocHtmlRow *) +{ +} + +void LatexDocVisitor::visitPost(DocHtmlRow *) +{ + m_t << "\\\\\\hline\n"; +} + +void LatexDocVisitor::visitPre(DocHtmlCell *) +{ +} + +void LatexDocVisitor::visitPost(DocHtmlCell *c) +{ + if (!c->isLast()) m_t << "&"; +} + +void LatexDocVisitor::visitPre(DocIndexEntry *) +{ + m_hide = TRUE; +} + +void LatexDocVisitor::visitPost(DocIndexEntry *) +{ + m_hide = FALSE; +} + +void LatexDocVisitor::visitPre(DocInternal *) +{ + m_t << "\\begin{Desc}" << endl + << "\\item[" << theTranslator->trForInternalUseOnly() << "]" << endl; +} + +void LatexDocVisitor::visitPost(DocInternal *) +{ + m_t << "\\end{Desc}" << endl; +} + +void LatexDocVisitor::visitPre(DocHRef *href) +{ + if (Config_getBool("PDF_HYPERLINKS")) + { + m_t << "\\href{"; + m_t << href->url(); + m_t << "}"; + } + m_t << "{\\tt "; +} + +void LatexDocVisitor::visitPost(DocHRef *) +{ + m_t << "}"; +} + +void LatexDocVisitor::visitPre(DocHtmlHeader *header) +{ + if (Config_getBool("COMPACT_LATEX")) + { + switch(header->level()) + { + case 1: m_t << "\\subsection{"; break; + case 2: m_t << "\\subsubsection{"; break; + case 3: m_t << "\\paragraph{"; break; + } + } + else + { + switch(header->level()) + { + case 1: m_t << "\\section{"; break; + case 2: m_t << "\\subsection{"; break; + case 3: m_t << "\\subsubsection{"; break; + } + } +} + +void LatexDocVisitor::visitPost(DocHtmlHeader *) +{ + m_t << "}"; +} + +void LatexDocVisitor::visitPre(DocImage *img) +{ + if (img->type()==DocImage::Latex) + { + if (img->hasCaption()) + { + m_t << "\\begin{figure}[H]" << endl; + m_t << "\\begin{center}" << endl; + } + else + { + m_t << "\\mbox{"; + } + QCString gfxName = img->name(); + if (gfxName.right(4)==".eps" || gfxName.right(4)==".pdf") + { + gfxName=gfxName.left(gfxName.length()-4); + } + m_t << "\\includegraphics"; + if (!img->width().isEmpty()) + { + m_t << "[width=" << img->width() << "]"; + } + else if (!img->height().isEmpty()) + { + m_t << "[height=" << img->height() << "]"; + } + m_t << "{" << gfxName << "}"; + if (img->hasCaption()) + { + m_t << "\\caption{"; + } + } + else // other format -> skip + { + m_hide=TRUE; + } +} + +void LatexDocVisitor::visitPost(DocImage *img) +{ + if (img->type()==DocImage::Latex) + { + m_t << "}" << endl; // end mbox or caption + if (img->hasCaption()) + { + m_t << "\\end{center}" << endl; + m_t << "\\end{figure}" << endl; + } + } + else // other format + { + m_hide=FALSE; + } +} + +void LatexDocVisitor::visitPre(DocDotFile *df) +{ + QCString baseName=df->file(); + int i; + if ((i=baseName.findRev('/'))!=-1) + { + baseName=baseName.right(baseName.length()-i-1); + } + if (baseName.right(4)==".eps" || baseName.right(4)==".pdf") + { + baseName=baseName.left(baseName.length()-4); + } + QCString outDir = Config_getString("LATEX_OUTPUT"); + writeDotGraphFromFile(df->file(),outDir,baseName,EPS); + if (df->hasCaption()) + { + m_t << "\\begin{figure}[H]" << endl; + m_t << "\\begin{center}" << endl; + } + else + { + m_t << "\\mbox{"; + } + m_t << "\\includegraphics"; + if (!df->width().isEmpty()) + { + m_t << "[width=" << df->width() << "]"; + } + else if (!df->height().isEmpty()) + { + m_t << "[height=" << df->height() << "]"; + } + m_t << "{" << baseName << "}"; + + if (df->hasCaption()) + { + m_t << "\\caption{"; + } +} + +void LatexDocVisitor::visitPost(DocDotFile *df) +{ + m_t << "}" << endl; // end mbox or caption + if (df->hasCaption()) + { + m_t << "\\end{center}" << endl; + m_t << "\\end{figure}" << endl; + } +} + +void LatexDocVisitor::visitPre(DocLink *lnk) +{ + startLink(lnk->ref(),lnk->file(),lnk->anchor()); +} + +void LatexDocVisitor::visitPost(DocLink *) +{ + endLink(); +} + +void LatexDocVisitor::visitPre(DocRef *ref) +{ + startLink(ref->ref(),ref->file(),ref->anchor()); + if (!ref->hasLinkText()) filter(ref->targetTitle()); +} + +void LatexDocVisitor::visitPost(DocRef *) +{ + endLink(); + m_t << " "; +} + +void LatexDocVisitor::visitPre(DocSecRefItem *) +{ + m_t << "\\item \\contentsline{section}{"; +} + +void LatexDocVisitor::visitPost(DocSecRefItem *ref) +{ + m_t << "}{\\ref{" << ref->anchor() << "}}{}" << endl; +} + +void LatexDocVisitor::visitPre(DocSecRefList *) +{ + m_t << "\\footnotesize" << endl; + m_t << "\\begin{multicols}{2}" << endl; + m_t << "\\begin{CompactList}" << endl; +} + +void LatexDocVisitor::visitPost(DocSecRefList *) +{ + m_t << "\\end{CompactList}" << endl; + m_t << "\\end{multicols}" << endl; + m_t << "\\normalsize" << endl; +} + +void LatexDocVisitor::visitPre(DocLanguage *) +{ +} + +void LatexDocVisitor::visitPost(DocLanguage *) +{ +} + +void LatexDocVisitor::visitPre(DocParamSect *s) +{ + m_t << "\\begin{Desc}" << endl; + m_t << "\\item["; + switch(s->type()) + { + case DocParamSect::Param: + m_t << theTranslator->trParameters(); break; + case DocParamSect::RetVal: + m_t << theTranslator->trReturnValues(); break; + case DocParamSect::Exception: + m_t << theTranslator->trExceptions(); break; + default: + ASSERT(0); + } + m_t << ":]" << endl; + m_t << "\\begin{description}" << endl; +} + +void LatexDocVisitor::visitPost(DocParamSect *) +{ + m_t << "\\end{description}" << endl; + m_t << "\\end{Desc}" << endl; +} + +void LatexDocVisitor::visitPre(DocParamList *pl) +{ + m_t << "\\item[{\\em "; + QStrListIterator li(pl->parameters()); + const char *s; + bool first=TRUE; + for (li.toFirst();(s=li.current());++li) + { + if (!first) m_t << ","; else first=FALSE; + m_t << s; + } + m_t << "}]"; +} + +void LatexDocVisitor::visitPost(DocParamList *) +{ +} + +void LatexDocVisitor::visitPre(DocXRefItem *x) +{ + m_t << "\\begin{Desc}" << endl; + m_t << "\\item["; + if (Config_getBool("PDF_HYPERLINKS")) + { + m_t << "\\hyperlink{" << x->file() << "_" << x->anchor() << "}{"; + } + else + { + m_t << "{\\bf "; + } + filter(x->title()); + m_t << "}]"; +} + +void LatexDocVisitor::visitPost(DocXRefItem *) +{ + m_t << "\\end{Desc}" << endl; +} + +void LatexDocVisitor::visitPre(DocInternalRef *ref) +{ + startLink(0,ref->file(),ref->anchor()); +} + +void LatexDocVisitor::visitPost(DocInternalRef *) +{ + endLink(); + m_t << " "; +} + +void LatexDocVisitor::visitPre(DocCopy *) +{ +} + +void LatexDocVisitor::visitPost(DocCopy *) +{ +} + void LatexDocVisitor::filter(const char *str) { filterLatexString(m_t,str,FALSE,m_insidePre); diff --git a/src/latexdocvisitor.h b/src/latexdocvisitor.h index 0de6510..f3a724f 100644 --- a/src/latexdocvisitor.h +++ b/src/latexdocvisitor.h @@ -20,749 +20,109 @@ #define _LATEXDOCVISITOR_H #include "docvisitor.h" -#include "docparser.h" -#include "language.h" -#include "doxygen.h" -#include "outputgen.h" -#include "code.h" -#include "dot.h" + +class QTextStream; +class BaseCodeDocInterface; +class QCString; /*! @brief Concrete visitor implementation for LaTeX output. */ class LatexDocVisitor : public DocVisitor { public: - LatexDocVisitor(QTextStream &t,BaseCodeDocInterface &ci) - : m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE) {} + LatexDocVisitor(QTextStream &t,BaseCodeDocInterface &ci); //-------------------------------------- // visitor functions for leaf nodes //-------------------------------------- - void visit(DocWord *w) - { - if (m_hide) return; - filter(w->word()); - } - void visit(DocLinkedWord *w) - { - if (m_hide) return; - startLink(w->ref(),w->file(),w->anchor()); - filter(w->word()); - endLink(); - } - void visit(DocWhiteSpace *w) - { - if (m_hide) return; - if (m_insidePre) - { - m_t << w->chars(); - } - else - { - m_t << " "; - } - } - void visit(DocSymbol *s) - { - if (m_hide) return; - switch(s->symbol()) - { - case DocSymbol::BSlash: m_t << "$\\backslash$"; break; - case DocSymbol::At: m_t << "@"; break; - case DocSymbol::Less: m_t << "$<$"; break; - case DocSymbol::Greater: m_t << "$>$"; break; - case DocSymbol::Amp: m_t << "\\&"; break; - case DocSymbol::Dollar: m_t << "\\$"; break; - case DocSymbol::Hash: m_t << "\\#"; break; - case DocSymbol::Percent: m_t << "\\%"; break; - case DocSymbol::Copy: m_t << "\\copyright"; break; - case DocSymbol::Apos: m_t << "'"; break; - case DocSymbol::Quot: m_t << "''"; break; - case DocSymbol::Uml: - if (s->letter()=='i') - m_t << "\\\"{\\i}"; - else - m_t << "\\\"{" << s->letter() << "}"; - break; - case DocSymbol::Acute: - if (s->letter()=='i') - m_t << "\\'{\\i}"; - else - m_t << "\\'{" << s->letter() << "}"; - break; - case DocSymbol::Grave: - if (s->letter()=='i') - m_t << "\\`{\\i}"; - else - m_t << "\\`{" << s->letter() << "}"; - break; - case DocSymbol::Circ: - if (s->letter()=='i') - m_t << "\\^{\\i}"; - else - m_t << "\\^{" << s->letter() << "}"; - break; - case DocSymbol::Tilde: m_t << "\\~{" << s->letter() << "}"; - case DocSymbol::Szlig: m_t << "\"s"; break; - case DocSymbol::Cedil: m_t << "\\c{" << s->letter() << "}"; break; - case DocSymbol::Ring: m_t << "\\" << s->letter() << s->letter(); break; - case DocSymbol::Nbsp: m_t << "\\ "; break; - default: - printf("Error: unknown symbol found\n"); - } - } - void visit(DocURL *u) - { - if (m_hide) return; - if (Config_getBool("PDF_HYPERLINKS")) - { - m_t << "\\href{" << u->url() << "}"; - } - m_t << "{\\tt " << u->url() << "}"; - } - void visit(DocLineBreak *) - { - if (m_hide) return; - m_t << "\\par\n"; - } - void visit(DocHorRuler *) - { - if (m_hide) return; - m_t << "\n\n"; - } - void visit(DocStyleChange *s) - { - if (m_hide) return; - switch (s->style()) - { - case DocStyleChange::Bold: - if (s->enable()) m_t << "{\\bf "; else m_t << "} "; - break; - case DocStyleChange::Italic: - if (s->enable()) m_t << "{\\em "; else m_t << "} "; - break; - case DocStyleChange::Code: - if (s->enable()) m_t << "{\\tt "; else m_t << "} "; - break; - case DocStyleChange::Subscript: - if (s->enable()) m_t << "$_{\\mbox{"; else m_t << "}}$ "; - break; - case DocStyleChange::Superscript: - if (s->enable()) m_t << "$^{\\mbox{"; else m_t << "}}$ "; - break; - case DocStyleChange::Center: - if (s->enable()) m_t << "\\begin{center}"; else m_t << "\\end{center} "; - break; - case DocStyleChange::Small: - if (s->enable()) m_t << "\\footnotesize "; else m_t << "\\normalsize "; - break; - } - } - void visit(DocVerbatim *s) - { - if (m_hide) return; - switch(s->type()) - { - case DocVerbatim::Code: // fall though - m_t << "\n\n\\footnotesize\\begin{verbatim}"; - parseCode(m_ci,s->context(),s->text(),FALSE,0); - m_t << "\\end{verbatim}\\normalsize" << endl; - break; - case DocVerbatim::Verbatim: - m_t << "\n\n\\footnotesize\\begin{verbatim}"; - m_t << s->text(); - m_t << "\\end{verbatim}\\normalsize" << endl; - break; - case DocVerbatim::HtmlOnly: - /* nothing */ - break; - case DocVerbatim::LatexOnly: - m_t << s->text(); - break; - } - } - void visit(DocAnchor *anc) - { - if (m_hide) return; - m_t << "\\label{" << anc->anchor() << "}" << endl; - if (!anc->file().isEmpty() && Config_getBool("PDF_HYPERLINKS")) - { - m_t << "\\hypertarget{" << anc->file() << "_" << anc->anchor() - << "}{}" << endl; - } - } - void visit(DocInclude *inc) - { - if (m_hide) return; - switch(inc->type()) - { - case DocInclude::Include: - m_t << "\n\n\\footnotesize\\begin{verbatim}"; - parseCode(m_ci,inc->context(),inc->text(),FALSE,0); - m_t << "\\end{verbatim}\\normalsize" << endl; - break; - case DocInclude::DontInclude: - break; - case DocInclude::HtmlInclude: - break; - case DocInclude::VerbInclude: - m_t << "\n\n\\footnotesize\\begin{verbatim}"; - m_t << inc->text(); - m_t << "\\end{verbatim}\\normalsize" << endl; - break; - } - } - void visit(DocIncOperator *op) - { - //printf("DocIncOperator: type=%d first=%d, last=%d text=`%s'\n", - // op->type(),op->isFirst(),op->isLast(),op->text().data()); - if (op->isFirst()) - { - m_t << "\n\n\\footnotesize\\begin{verbatim}"; - m_hide = TRUE; - } - if (op->type()!=DocIncOperator::Skip) - { - parseCode(m_ci,op->context(),op->text(),FALSE,0); - } - if (op->isLast()) - { - m_hide = FALSE; - m_t << "\\end{verbatim}\\normalsize" << endl; - } - else - { - m_t << endl; - } - } - void visit(DocFormula *f) - { - if (m_hide) return; - m_t << f->text(); - } + void visit(DocWord *); + void visit(DocLinkedWord *); + void visit(DocWhiteSpace *); + void visit(DocSymbol *); + void visit(DocURL *); + void visit(DocLineBreak *); + void visit(DocHorRuler *); + void visit(DocStyleChange *); + void visit(DocVerbatim *); + void visit(DocAnchor *); + void visit(DocInclude *); + void visit(DocIncOperator *); + void visit(DocFormula *); //-------------------------------------- // visitor functions for compound nodes //-------------------------------------- - void visitPre(DocAutoList *l) - { - if (l->isEnumList()) - { - m_t << "\\begin{enumerate}" << endl; - } - else - { - m_t << "\\begin{itemize}" << endl; - } - } - void visitPost(DocAutoList *l) - { - if (l->isEnumList()) - { - m_t << "\\end{enumerate}" << endl; - } - else - { - m_t << "\\end{itemize}" << endl; - } - } - void visitPre(DocAutoListItem *) - { - m_t << "\\item "; - } - void visitPost(DocAutoListItem *) - { - } - void visitPre(DocPara *) - { - } - void visitPost(DocPara *p) - { - if (!p->isLast() && // omit <p> for last paragraph - !(p->parent() && // and for parameter sections - p->parent()->kind()==DocNode::Kind_ParamSect - ) - ) m_t << endl << endl; - } - void visitPre(DocRoot *) - { - } - void visitPost(DocRoot *) - { - } - void visitPre(DocSimpleSect *s) - { - m_t << "\\begin{Desc}\n\\item["; - switch(s->type()) - { - case DocSimpleSect::See: - m_t << theTranslator->trSeeAlso(); break; - case DocSimpleSect::Return: - m_t << theTranslator->trReturns(); break; - case DocSimpleSect::Author: - m_t << theTranslator->trAuthor(TRUE,TRUE); break; - case DocSimpleSect::Authors: - m_t << theTranslator->trAuthor(TRUE,FALSE); break; - case DocSimpleSect::Version: - m_t << theTranslator->trVersion(); break; - case DocSimpleSect::Since: - m_t << theTranslator->trSince(); break; - case DocSimpleSect::Date: - m_t << theTranslator->trDate(); break; - case DocSimpleSect::Note: - m_t << theTranslator->trNote(); break; - case DocSimpleSect::Warning: - m_t << theTranslator->trWarning(); break; - case DocSimpleSect::Pre: - m_t << theTranslator->trPrecondition(); break; - case DocSimpleSect::Post: - m_t << theTranslator->trPostcondition(); break; - case DocSimpleSect::Invar: - m_t << theTranslator->trInvariant(); break; - case DocSimpleSect::Remark: - m_t << theTranslator->trRemarks(); break; - case DocSimpleSect::Attention: - m_t << theTranslator->trAttention(); break; - case DocSimpleSect::User: break; - case DocSimpleSect::Unknown: break; - } - - // special case 1: user defined title - if (s->type()!=DocSimpleSect::User) - { - m_t << ":]"; - } - } - void visitPost(DocSimpleSect *) - { - m_t << "\\end{Desc}" << endl; - } - void visitPre(DocTitle *) - { - } - void visitPost(DocTitle *) - { - m_t << "]"; - } - void visitPre(DocSimpleList *) - { - m_t << "\\begin{itemize}" << endl; - } - void visitPost(DocSimpleList *) - { - m_t << "\\end{itemize}" << endl; - } - void visitPre(DocSimpleListItem *) - { - m_t << "\\item "; - } - void visitPost(DocSimpleListItem *) - { - } - void visitPre(DocSection *s) - { - if (Config_getBool("PDF_HYPERLINKS")) - { - m_t << "\\hypertarget{" << s->file() << "_" << s->anchor() << "}{}"; - } - if (s->level()==1) - { - if (Config_getBool("COMPACT_LATEX")) - { - m_t << "\\subsubsection{"; - } - else - { - m_t << "\\subsection{"; - } - } - else if (s->level()==2) - { - if (Config_getBool("COMPACT_LATEX")) - { - m_t << "\\paragraph{"; - } - else - { - m_t << "\\subsubsection{"; - } - } - filter(s->title()); - m_t << "}\\label{" << s->anchor() << "}" << endl; - } - void visitPost(DocSection *) - { - } - void visitPre(DocHtmlList *s) - { - if (s->type()==DocHtmlList::Ordered) - m_t << "\\begin{enumerate}" << endl; - else - m_t << "\\begin{itemize}" << endl; - } - void visitPost(DocHtmlList *s) - { - if (s->type()==DocHtmlList::Ordered) - m_t << "\\end{enumerate}" << endl; - else - m_t << "\\end{itemize}" << endl; - } - void visitPre(DocHtmlListItem *) - { - m_t << "\\item "; - } - void visitPost(DocHtmlListItem *) - { - } - void visitPre(DocHtmlPre *) - { - m_t << "\\small\\begin{alltt}"; - m_insidePre=TRUE; - } - void visitPost(DocHtmlPre *) - { - m_insidePre=FALSE; - m_t << "\\end{alltt}\\normalsize " << endl; - } - void visitPre(DocHtmlDescList *) - { - m_t << "\\begin{description}" << endl; - } - void visitPost(DocHtmlDescList *) - { - m_t << "\\end{description}" << endl; - } - void visitPre(DocHtmlDescTitle *) - { - m_t << "\\item["; - } - void visitPost(DocHtmlDescTitle *) - { - m_t << "]"; - } - void visitPre(DocHtmlDescData *) - { - } - void visitPost(DocHtmlDescData *) - { - } - void visitPre(DocHtmlTable *t) - { - if (t->hasCaption()) - { - m_t << "\\begin{table}[h]"; - } - m_t << "\\begin{TabularC}{" << t->numCols() << "}\n\\hline\n"; - } - void visitPost(DocHtmlTable *t) - { - if (t->hasCaption()) - { - m_t << "\\end{table}\n"; - } - else - { - m_t << "\\\\\\hline\n\\end{TabularC}\n"; - } - } - void visitPre(DocHtmlCaption *) - { - m_t << "\\\\\\hline\n\\end{TabularC}\n\\centering\n\\caption{"; - } - void visitPost(DocHtmlCaption *) - { - m_t << "}\n"; - } - void visitPre(DocHtmlRow *) - { - } - void visitPost(DocHtmlRow *) - { - m_t << "\\\\\\hline\n"; - } - void visitPre(DocHtmlCell *) - { - } - void visitPost(DocHtmlCell *c) - { - if (!c->isLast()) m_t << "&"; - } - void visitPre(DocIndexEntry *) - { - m_hide = TRUE; - } - void visitPost(DocIndexEntry *) - { - m_hide = FALSE; - } - void visitPre(DocInternal *) - { - m_t << "\\begin{Desc}" << endl - << "\\item[" << theTranslator->trForInternalUseOnly() << "]" << endl; - } - void visitPost(DocInternal *) - { - m_t << "\\end{Desc}" << endl; - } - void visitPre(DocHRef *href) - { - if (Config_getBool("PDF_HYPERLINKS")) - { - m_t << "\\href{"; - m_t << href->url(); - m_t << "}"; - } - m_t << "{\\tt "; - } - void visitPost(DocHRef *) - { - m_t << "}"; - } - void visitPre(DocHtmlHeader *header) - { - if (Config_getBool("COMPACT_LATEX")) - { - switch(header->level()) - { - case 1: m_t << "\\subsection{"; break; - case 2: m_t << "\\subsubsection{"; break; - case 3: m_t << "\\paragraph{"; break; - } - } - else - { - switch(header->level()) - { - case 1: m_t << "\\section{"; break; - case 2: m_t << "\\subsection{"; break; - case 3: m_t << "\\subsubsection{"; break; - } - } - } - void visitPost(DocHtmlHeader *) - { - m_t << "}"; - } - void visitPre(DocImage *img) - { - if (img->type()==DocImage::Latex) - { - if (img->hasCaption()) - { - m_t << "\\begin{figure}[H]" << endl; - m_t << "\\begin{center}" << endl; - } - else - { - m_t << "\\mbox{"; - } - QCString gfxName = img->name(); - if (gfxName.right(4)==".eps" || gfxName.right(4)==".pdf") - { - gfxName=gfxName.left(gfxName.length()-4); - } - m_t << "\\includegraphics"; - if (!img->width().isEmpty()) - { - m_t << "[width=" << img->width() << "]"; - } - else if (!img->height().isEmpty()) - { - m_t << "[height=" << img->height() << "]"; - } - m_t << "{" << gfxName << "}"; - if (img->hasCaption()) - { - m_t << "\\caption{"; - } - } - else // other format -> skip - { - m_hide=TRUE; - } - } - void visitPost(DocImage *img) - { - if (img->type()==DocImage::Latex) - { - m_t << "}" << endl; // end mbox or caption - if (img->hasCaption()) - { - m_t << "\\end{center}" << endl; - m_t << "\\end{figure}" << endl; - } - } - else // other format - { - m_hide=FALSE; - } - } - void visitPre(DocDotFile *df) - { - QCString baseName=df->file(); - int i; - if ((i=baseName.findRev('/'))!=-1) - { - baseName=baseName.right(baseName.length()-i-1); - } - if (baseName.right(4)==".eps" || baseName.right(4)==".pdf") - { - baseName=baseName.left(baseName.length()-4); - } - QCString outDir = Config_getString("LATEX_OUTPUT"); - writeDotGraphFromFile(df->file(),outDir,baseName,EPS); - if (df->hasCaption()) - { - m_t << "\\begin{figure}[H]" << endl; - m_t << "\\begin{center}" << endl; - } - else - { - m_t << "\\mbox{"; - } - m_t << "\\includegraphics"; - if (!df->width().isEmpty()) - { - m_t << "[width=" << df->width() << "]"; - } - else if (!df->height().isEmpty()) - { - m_t << "[height=" << df->height() << "]"; - } - m_t << "{" << baseName << "}"; - - if (df->hasCaption()) - { - m_t << "\\caption{"; - } - } - void visitPost(DocDotFile *df) - { - m_t << "}" << endl; // end mbox or caption - if (df->hasCaption()) - { - m_t << "\\end{center}" << endl; - m_t << "\\end{figure}" << endl; - } - } - void visitPre(DocLink *lnk) - { - startLink(lnk->ref(),lnk->file(),lnk->anchor()); - } - void visitPost(DocLink *) - { - endLink(); - } - void visitPre(DocRef *ref) - { - startLink(ref->ref(),ref->file(),ref->anchor()); - if (!ref->hasLinkText()) filter(ref->targetTitle()); - } - void visitPost(DocRef *) - { - endLink(); - m_t << " "; - } - void visitPre(DocSecRefItem *) - { - m_t << "\\item \\contentsline{section}{"; - } - void visitPost(DocSecRefItem *ref) - { - m_t << "}{\\ref{" << ref->anchor() << "}}{}" << endl; - } - void visitPre(DocSecRefList *) - { - m_t << "\\footnotesize" << endl; - m_t << "\\begin{multicols}{2}" << endl; - m_t << "\\begin{CompactList}" << endl; - } - void visitPost(DocSecRefList *) - { - m_t << "\\end{CompactList}" << endl; - m_t << "\\end{multicols}" << endl; - m_t << "\\normalsize" << endl; - } - void visitPre(DocLanguage *) - { - } - void visitPost(DocLanguage *) - { - } - void visitPre(DocParamSect *s) - { - m_t << "\\begin{Desc}" << endl; - m_t << "\\item["; - switch(s->type()) - { - case DocParamSect::Param: - m_t << theTranslator->trParameters(); break; - case DocParamSect::RetVal: - m_t << theTranslator->trReturnValues(); break; - case DocParamSect::Exception: - m_t << theTranslator->trExceptions(); break; - default: - ASSERT(0); - } - m_t << ":]" << endl; - m_t << "\\begin{description}" << endl; - } - void visitPost(DocParamSect *) - { - m_t << "\\end{description}" << endl; - m_t << "\\end{Desc}" << endl; - } - void visitPre(DocParamList *pl) - { - m_t << "\\item[{\\em "; - QStrListIterator li(pl->parameters()); - const char *s; - bool first=TRUE; - for (li.toFirst();(s=li.current());++li) - { - if (!first) m_t << ","; else first=FALSE; - m_t << s; - } - m_t << "}]"; - } - void visitPost(DocParamList *) - { - } - void visitPre(DocXRefItem *x) - { - m_t << "\\begin{Desc}" << endl; - m_t << "\\item["; - if (Config_getBool("PDF_HYPERLINKS")) - { - m_t << "\\hyperlink{" << x->file() << "_" << x->anchor() << "}{"; - } - else - { - m_t << "{\\bf "; - } - filter(x->title()); - m_t << "}]"; - } - void visitPost(DocXRefItem *) - { - m_t << "\\end{Desc}" << endl; - } - void visitPre(DocInternalRef *ref) - { - startLink(0,ref->file(),ref->anchor()); - } - void visitPost(DocInternalRef *) - { - endLink(); - m_t << " "; - } - void visitPre(DocCopy *) - { - } - void visitPost(DocCopy *) - { - } + void visitPre(DocAutoList *); + void visitPost(DocAutoList *); + void visitPre(DocAutoListItem *); + void visitPost(DocAutoListItem *); + void visitPre(DocPara *); + void visitPost(DocPara *); + void visitPre(DocRoot *); + void visitPost(DocRoot *); + void visitPre(DocSimpleSect *); + void visitPost(DocSimpleSect *); + void visitPre(DocTitle *); + void visitPost(DocTitle *); + void visitPre(DocSimpleList *); + void visitPost(DocSimpleList *); + void visitPre(DocSimpleListItem *); + void visitPost(DocSimpleListItem *); + void visitPre(DocSection *s); + void visitPost(DocSection *); + void visitPre(DocHtmlList *s); + void visitPost(DocHtmlList *s); + void visitPre(DocHtmlListItem *); + void visitPost(DocHtmlListItem *); + void visitPre(DocHtmlPre *); + void visitPost(DocHtmlPre *); + void visitPre(DocHtmlDescList *); + void visitPost(DocHtmlDescList *); + void visitPre(DocHtmlDescTitle *); + void visitPost(DocHtmlDescTitle *); + void visitPre(DocHtmlDescData *); + void visitPost(DocHtmlDescData *); + void visitPre(DocHtmlTable *t); + void visitPost(DocHtmlTable *t); + void visitPre(DocHtmlCaption *); + void visitPost(DocHtmlCaption *); + void visitPre(DocHtmlRow *); + void visitPost(DocHtmlRow *) ; + void visitPre(DocHtmlCell *); + void visitPost(DocHtmlCell *); + void visitPre(DocIndexEntry *); + void visitPost(DocIndexEntry *); + void visitPre(DocInternal *); + void visitPost(DocInternal *); + void visitPre(DocHRef *); + void visitPost(DocHRef *); + void visitPre(DocHtmlHeader *); + void visitPost(DocHtmlHeader *) ; + void visitPre(DocImage *); + void visitPost(DocImage *); + void visitPre(DocDotFile *); + void visitPost(DocDotFile *); + void visitPre(DocLink *lnk); + void visitPost(DocLink *); + void visitPre(DocRef *ref); + void visitPost(DocRef *); + void visitPre(DocSecRefItem *); + void visitPost(DocSecRefItem *); + void visitPre(DocSecRefList *); + void visitPost(DocSecRefList *); + void visitPre(DocLanguage *); + void visitPost(DocLanguage *); + void visitPre(DocParamSect *); + void visitPost(DocParamSect *); + void visitPre(DocParamList *); + void visitPost(DocParamList *); + void visitPre(DocXRefItem *); + void visitPost(DocXRefItem *); + void visitPre(DocInternalRef *); + void visitPost(DocInternalRef *); + void visitPre(DocCopy *); + void visitPost(DocCopy *); private: diff --git a/src/latexgen.cpp b/src/latexgen.cpp index d9f7b24..af236dc 100644 --- a/src/latexgen.cpp +++ b/src/latexgen.cpp @@ -29,6 +29,7 @@ #include "version.h" #include "dot.h" #include "page.h" +#include "docparser.h" #include "latexdocvisitor.h" //static QCString filterTitle(const char *s) diff --git a/src/libdoxygen.pro.in b/src/libdoxygen.pro.in index 700c9da..fbd3771 100644 --- a/src/libdoxygen.pro.in +++ b/src/libdoxygen.pro.in @@ -71,7 +71,9 @@ HEADERS = bufstr.h \ printdocvisitor.h \ qtbc.h \ reflist.h \ + rtfdocvisitor.h \ rtfgen.h \ + rtfstyle.h \ scanner.h \ searchindex.h \ section.h \ @@ -162,7 +164,9 @@ SOURCES = ce_lex.cpp \ pngenc.cpp \ pre.cpp \ reflist.cpp \ + rtfdocvisitor.cpp \ rtfgen.cpp \ + rtfstyle.cpp \ scanner.cpp \ searchindex.cpp \ suffixtree.cpp \ diff --git a/src/memberdef.cpp b/src/memberdef.cpp index 3127259..6932f7d 100644 --- a/src/memberdef.cpp +++ b/src/memberdef.cpp @@ -552,7 +552,14 @@ ClassDef *MemberDef::getClassDefOfAnonymousType() */ bool MemberDef::isBriefSectionVisible() const { - bool hasDocs = hasDocumentation(); + //printf("Member %s grpId=%d docs=%s file=%s args=%s\n", + // name().data(), + // grpId,grpId==-1?"<none>":Doxygen::memberDocDict[grpId]->data(), + // getFileDef()->name().data(), + // argsString()); + bool hasDocs = hasDocumentation() || + // part of a documented member group + (grpId!=-1 && !Doxygen::memberDocDict[grpId]->isEmpty()); // only include static members with file/namespace scope if // explicitly enabled in the config file @@ -609,6 +616,12 @@ bool MemberDef::isBriefSectionVisible() const !hasDocs ); + //printf("visibleIfStatic=%d visibleIfDocumented=%d visibleIfEnabled=%d" + // "visibleIfPrivate=%d visibleIfDocVirtual=%d visibltIfNotDefaultCDTor=%d " + // "visibleIfFriendCompound=%d\n",visibleIfStatic,visibleIfDocumented, + // visibleIfEnabled,visibleIfPrivate,visibleIfDocVirtual,visibleIfNotDefaultCDTor, + // visibleIfFriendCompound); + bool visible = visibleIfStatic && visibleIfDocumented && visibleIfEnabled && visibleIfPrivate && visibleIfDocVirtual && visibleIfNotDefaultCDTor && diff --git a/src/memberdef.h b/src/memberdef.h index 8dd36f3..8755f4e 100644 --- a/src/memberdef.h +++ b/src/memberdef.h @@ -245,6 +245,12 @@ class MemberDef : public Definition } void setBodyMember(MemberDef *md) { bodyMemb = md; } void setDocsForDefinition(bool b) { docsForDefinition = b; } + + // declaration <-> definition relation + void setMemberDefinition(MemberDef *md) { memDef=md; } + void setMemberDeclaration(MemberDef *md) { memDec=md; } + MemberDef *memberDefinition() const { return memDef; } + MemberDef *memberDeclaration() const { return memDec; } bool visited; @@ -270,8 +276,6 @@ class MemberDef : public Definition QCString init; // initializer int initLines; // number of lines in the initializer QCString decl; // member declaration in class - //QCString declFile; // file where the declaration was found - //int declLine; // line where the declaration was found QCString def; // member definition in code (fully qualified name) QCString anc; // HTML anchor name MemberDef *bodyMemb; // Member containing the definition @@ -281,7 +285,6 @@ class MemberDef : public Definition bool stat; // is it a static function? int memSpec; // The specifiers present for this member MemberType mtype; // returns the kind of member - //bool eUsed; // is the enumerate already placed in a list bool proto; // is it a prototype; bool docEnumValues; // is an enum with documented enum values. bool annScope; // member is part of an annoymous scope @@ -25,7 +25,8 @@ class PageInfo public: PageInfo(const char *f, int l,const char *n,const char *d,const char *t) : defFileName(f), defLine(l), name(n), - doc(d), title(t), sectionDict(0),specialListItems(0),m_inGroup(0) {} + doc(d), title(t), context(0), sectionDict(0),specialListItems(0),m_inGroup(0) + {} // where the page definition was found QCString defFileName; @@ -40,6 +41,9 @@ class PageInfo QCString reference; QCString fileName; + // class, file or namespace in which the page was found + Definition *context; + // functions to get a uniform interface with Definitions QCString getOutputFileBase() const { return fileName; } bool isReference() const { return !reference.isEmpty(); } diff --git a/src/rtfdocvisitor.cpp b/src/rtfdocvisitor.cpp new file mode 100644 index 0000000..4a4abb9 --- /dev/null +++ b/src/rtfdocvisitor.cpp @@ -0,0 +1,1013 @@ +/****************************************************************************** + * + * + * + * + * Copyright (C) 1997-2002 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + * Documents produced by Doxygen are derivative works derived from the + * input used in their production; they are not affected by this license. + * + */ + +#include "rtfdocvisitor.h" +#include "docparser.h" +#include "language.h" +#include "doxygen.h" +#include "outputgen.h" +#include "code.h" +#include "dot.h" +#include "util.h" +#include "rtfstyle.h" + +RTFDocVisitor::RTFDocVisitor(QTextStream &t,BaseCodeDocInterface &ci) + : m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE), m_indentLevel(0) +{ +} + +QCString RTFDocVisitor::getStyle(const char *name) +{ + QCString n; + n.sprintf("%s%d",name,m_indentLevel); + StyleData *sd = rtf_Style[n]; + ASSERT(sd!=0); + return sd->reference; +} + + //-------------------------------------- + // visitor functions for leaf nodes + //-------------------------------------- + +void RTFDocVisitor::visit(DocWord *w) +{ + if (m_hide) return; + filter(w->word()); +} + +void RTFDocVisitor::visit(DocLinkedWord *w) +{ + if (m_hide) return; + startLink(w->ref(),w->file(),w->anchor()); + filter(w->word()); + endLink(w->ref()); +} + +void RTFDocVisitor::visit(DocWhiteSpace *w) +{ + if (m_hide) return; + if (m_insidePre) + { + m_t << w->chars(); + } + else + { + m_t << " "; + } +} + +void RTFDocVisitor::visit(DocSymbol *s) +{ + if (m_hide) return; + switch(s->symbol()) + { + case DocSymbol::BSlash: m_t << "\\\\"; break; + case DocSymbol::At: m_t << "@"; break; + case DocSymbol::Less: m_t << "<"; break; + case DocSymbol::Greater: m_t << ">"; break; + case DocSymbol::Amp: m_t << "&"; break; + case DocSymbol::Dollar: m_t << "$"; break; + case DocSymbol::Hash: m_t << "#"; break; + case DocSymbol::Percent: m_t << "%"; break; + case DocSymbol::Copy: m_t << "\251"; break; + case DocSymbol::Apos: m_t << "'"; break; + case DocSymbol::Quot: m_t << "\""; break; + case DocSymbol::Uml: switch(s->letter()) + { + case 'A' : m_t << '\304'; break; + case 'E' : m_t << '\313'; break; + case 'I' : m_t << '\317'; break; + case 'O' : m_t << '\326'; break; + case 'U' : m_t << '\334'; break; + case 'Y' : m_t << 'Y'; break; + case 'a' : m_t << '\344'; break; + case 'e' : m_t << '\353'; break; + case 'i' : m_t << '\357'; break; + case 'o' : m_t << '\366'; break; + case 'u' : m_t << '\374'; break; + case 'y' : m_t << '\377'; break; + default: m_t << '?'; break; + } + break; + case DocSymbol::Acute: switch(s->letter()) + { + case 'A' : m_t << '\301'; break; + case 'E' : m_t << '\311'; break; + case 'I' : m_t << '\315'; break; + case 'O' : m_t << '\323'; break; + case 'U' : m_t << '\332'; break; + case 'Y' : m_t << '\335'; break; + case 'a' : m_t << '\341'; break; + case 'e' : m_t << '\351'; break; + case 'i' : m_t << '\355'; break; + case 'o' : m_t << '\363'; break; + case 'u' : m_t << '\372'; break; + case 'y' : m_t << '\375'; break; + default: m_t << '?'; break; + } + break; + case DocSymbol::Grave: switch(s->letter()) + { + case 'A' : m_t << '\300'; break; + case 'E' : m_t << '\310'; break; + case 'I' : m_t << '\314'; break; + case 'O' : m_t << '\322'; break; + case 'U' : m_t << '\331'; break; + case 'a' : m_t << '\340'; break; + case 'e' : m_t << '\350'; break; + case 'i' : m_t << '\354'; break; + case 'o' : m_t << '\362'; break; + case 'u' : m_t << '\371'; break; + default: m_t << '?'; break; + } + break; + case DocSymbol::Circ: switch(s->letter()) + { + case 'A' : m_t << '\302'; break; + case 'E' : m_t << '\312'; break; + case 'I' : m_t << '\316'; break; + case 'O' : m_t << '\324'; break; + case 'U' : m_t << '\333'; break; + case 'a' : m_t << '\342'; break; + case 'e' : m_t << '\352'; break; + case 'i' : m_t << '\356'; break; + case 'o' : m_t << '\364'; break; + case 'u' : m_t << '\373'; break; + default: m_t << '?'; break; + } + break; + case DocSymbol::Tilde: switch(s->letter()) + { + case 'A' : m_t << '\303'; break; + case 'N' : m_t << '\321'; break; + case 'O' : m_t << '\325'; break; + case 'a' : m_t << '\343'; break; + case 'n' : m_t << '\361'; break; + case 'o' : m_t << '\365'; break; + default: m_t << '?'; break; + } + break; + case DocSymbol::Cedil: switch(s->letter()) + { + case 'C' : m_t << '\307'; break; + case 'c' : m_t << '\347'; break; + default: m_t << '?'; break; + } + break; + case DocSymbol::Ring: switch(s->letter()) + { + case 'A' : m_t << '\305'; break; + case 'a' : m_t << '\345'; break; + default: m_t << '?'; break; + } + break; + case DocSymbol::Szlig: m_t << "\337"; break; + case DocSymbol::Nbsp: m_t << "\\~ "; break; + default: + printf("Error: unknown symbol found\n"); + } +} + +void RTFDocVisitor::visit(DocURL *u) +{ + if (m_hide) return; + if (Config_getBool("RTF_HYPERLINKS")) + { + m_t << "{\\field {\\*\\fldinst { HYPERLINK \\\\l \""; + m_t << u->url(); + m_t << "\" }{}"; + m_t << "}{\\fldrslt {\\cs37\\ul\\cf2 "; + filter(u->url()); + m_t << "}}}" << endl; + } + else + { + m_t << "{\\f2 "; + filter(u->url()); + m_t << "}"; + } +} + +void RTFDocVisitor::visit(DocLineBreak *) +{ + if (m_hide) return; + m_t << "\\par\n"; +} + +void RTFDocVisitor::visit(DocHorRuler *) +{ + if (m_hide) return; + m_t << "{\\pard\\widctlpar\\brdrb\\brdrs\\brdrw5\\brsp20 \\adjustright \\par}" << endl; +} + +void RTFDocVisitor::visit(DocStyleChange *s) +{ + if (m_hide) return; + switch (s->style()) + { + case DocStyleChange::Bold: + if (s->enable()) m_t << "{\\b "; else m_t << "} "; + break; + case DocStyleChange::Italic: + if (s->enable()) m_t << "{\\i "; else m_t << "} "; + break; + case DocStyleChange::Code: + if (s->enable()) m_t << "{\\f2 "; else m_t << "} "; + break; + case DocStyleChange::Subscript: + if (s->enable()) m_t << "{\\sub "; else m_t << "} "; + break; + case DocStyleChange::Superscript: + if (s->enable()) m_t << "{\\super "; else m_t << "} "; + break; + case DocStyleChange::Center: + if (s->enable()) m_t << "{\\qc "; else m_t << "} "; + break; + case DocStyleChange::Small: + if (s->enable()) m_t << "{\\sub "; else m_t << "} "; + break; + } +} + +void RTFDocVisitor::visit(DocVerbatim *s) +{ + if (m_hide) return; + switch(s->type()) + { + case DocVerbatim::Code: // fall though + m_t << "{" << endl; + m_t << "\\par" << endl; + m_t << rtf_Style_Reset << getStyle("CodeExample"); + parseCode(m_ci,s->context(),s->text(),FALSE,0); + m_t << "\\par" << endl; + m_t << "}" << endl; + break; + case DocVerbatim::Verbatim: + m_t << "{" << endl; + m_t << "\\par" << endl; + m_t << rtf_Style_Reset << getStyle("CodeExample"); + m_t << s->text(); + m_t << "\\par" << endl; + m_t << "}" << endl; + break; + case DocVerbatim::HtmlOnly: + /* nothing */ + break; + case DocVerbatim::LatexOnly: + /* nothing */ + break; + } +} + +void RTFDocVisitor::visit(DocAnchor *anc) +{ + if (m_hide) return; + m_t << "\\label{" << anc->anchor() << "}" << endl; + if (!anc->file().isEmpty() && Config_getBool("PDF_HYPERLINKS")) + { + m_t << "\\hypertarget{" << anc->file() << "_" << anc->anchor() + << "}{}" << endl; + } +} + +void RTFDocVisitor::visit(DocInclude *inc) +{ + if (m_hide) return; + switch(inc->type()) + { + case DocInclude::Include: + m_t << "\n\n\\footnotesize\\begin{verbatim}"; + parseCode(m_ci,inc->context(),inc->text(),FALSE,0); + m_t << "\\end{verbatim}\\normalsize" << endl; + break; + case DocInclude::DontInclude: + break; + case DocInclude::HtmlInclude: + break; + case DocInclude::VerbInclude: + m_t << "\n\n\\footnotesize\\begin{verbatim}"; + m_t << inc->text(); + m_t << "\\end{verbatim}\\normalsize" << endl; + break; + } +} + +void RTFDocVisitor::visit(DocIncOperator *op) +{ + //printf("DocIncOperator: type=%d first=%d, last=%d text=`%s'\n", + // op->type(),op->isFirst(),op->isLast(),op->text().data()); + if (op->isFirst()) + { + m_t << "\n\n\\footnotesize\\begin{verbatim}"; + m_hide = TRUE; + } + if (op->type()!=DocIncOperator::Skip) + { + parseCode(m_ci,op->context(),op->text(),FALSE,0); + } + if (op->isLast()) + { + m_hide = FALSE; + m_t << "\\end{verbatim}\\normalsize" << endl; + } + else + { + m_t << endl; + } +} + +void RTFDocVisitor::visit(DocFormula *f) +{ + if (m_hide) return; + m_t << f->text(); +} + +//-------------------------------------- +// visitor functions for compound nodes +//-------------------------------------- + +void RTFDocVisitor::visitPre(DocAutoList *l) +{ + if (l->isEnumList()) + { + m_t << "\\begin{enumerate}" << endl; + } + else + { + m_t << "\\begin{itemize}" << endl; + } +} + +void RTFDocVisitor::visitPost(DocAutoList *l) +{ + if (l->isEnumList()) + { + m_t << "\\end{enumerate}" << endl; + } + else + { + m_t << "\\end{itemize}" << endl; + } +} + +void RTFDocVisitor::visitPre(DocAutoListItem *) +{ + m_t << "\\item "; +} + +void RTFDocVisitor::visitPost(DocAutoListItem *) +{ +} + +void RTFDocVisitor::visitPre(DocPara *) +{ +} + +void RTFDocVisitor::visitPost(DocPara *p) +{ + if (!p->isLast() && // omit <p> for last paragraph + !(p->parent() && // and for parameter sections + p->parent()->kind()==DocNode::Kind_ParamSect + ) + ) m_t << endl << endl; +} + +void RTFDocVisitor::visitPre(DocRoot *) +{ +} + +void RTFDocVisitor::visitPost(DocRoot *) +{ +} + +void RTFDocVisitor::visitPre(DocSimpleSect *s) +{ + m_t << "\\begin{Desc}\n\\item["; + switch(s->type()) + { + case DocSimpleSect::See: + m_t << theTranslator->trSeeAlso(); break; + case DocSimpleSect::Return: + m_t << theTranslator->trReturns(); break; + case DocSimpleSect::Author: + m_t << theTranslator->trAuthor(TRUE,TRUE); break; + case DocSimpleSect::Authors: + m_t << theTranslator->trAuthor(TRUE,FALSE); break; + case DocSimpleSect::Version: + m_t << theTranslator->trVersion(); break; + case DocSimpleSect::Since: + m_t << theTranslator->trSince(); break; + case DocSimpleSect::Date: + m_t << theTranslator->trDate(); break; + case DocSimpleSect::Note: + m_t << theTranslator->trNote(); break; + case DocSimpleSect::Warning: + m_t << theTranslator->trWarning(); break; + case DocSimpleSect::Pre: + m_t << theTranslator->trPrecondition(); break; + case DocSimpleSect::Post: + m_t << theTranslator->trPostcondition(); break; + case DocSimpleSect::Invar: + m_t << theTranslator->trInvariant(); break; + case DocSimpleSect::Remark: + m_t << theTranslator->trRemarks(); break; + case DocSimpleSect::Attention: + m_t << theTranslator->trAttention(); break; + case DocSimpleSect::User: break; + case DocSimpleSect::Unknown: break; + } + + // special case 1: user defined title + if (s->type()!=DocSimpleSect::User) + { + m_t << ":]"; + } +} + +void RTFDocVisitor::visitPost(DocSimpleSect *) +{ + m_t << "\\end{Desc}" << endl; +} + +void RTFDocVisitor::visitPre(DocTitle *) +{ +} + +void RTFDocVisitor::visitPost(DocTitle *) +{ + m_t << "]"; +} + +void RTFDocVisitor::visitPre(DocSimpleList *) +{ + m_t << "\\begin{itemize}" << endl; +} + +void RTFDocVisitor::visitPost(DocSimpleList *) +{ + m_t << "\\end{itemize}" << endl; +} + +void RTFDocVisitor::visitPre(DocSimpleListItem *) +{ + m_t << "\\item "; +} + +void RTFDocVisitor::visitPost(DocSimpleListItem *) +{ +} + +void RTFDocVisitor::visitPre(DocSection *s) +{ + if (Config_getBool("PDF_HYPERLINKS")) + { + m_t << "\\hypertarget{" << s->file() << "_" << s->anchor() << "}{}"; + } + if (s->level()==1) + { + if (Config_getBool("COMPACT_LATEX")) + { + m_t << "\\subsubsection{"; + } + else + { + m_t << "\\subsection{"; + } + } + else if (s->level()==2) + { + if (Config_getBool("COMPACT_LATEX")) + { + m_t << "\\paragraph{"; + } + else + { + m_t << "\\subsubsection{"; + } + } + filter(s->title()); + m_t << "}\\label{" << s->anchor() << "}" << endl; +} + +void RTFDocVisitor::visitPost(DocSection *) +{ +} + +void RTFDocVisitor::visitPre(DocHtmlList *s) +{ + if (s->type()==DocHtmlList::Ordered) + m_t << "\\begin{enumerate}" << endl; + else + m_t << "\\begin{itemize}" << endl; +} + +void RTFDocVisitor::visitPost(DocHtmlList *s) +{ + if (s->type()==DocHtmlList::Ordered) + m_t << "\\end{enumerate}" << endl; + else + m_t << "\\end{itemize}" << endl; +} + +void RTFDocVisitor::visitPre(DocHtmlListItem *) +{ + m_t << "\\item "; +} + +void RTFDocVisitor::visitPost(DocHtmlListItem *) +{ +} + +void RTFDocVisitor::visitPre(DocHtmlPre *) +{ + m_t << "\\small\\begin{alltt}"; + m_insidePre=TRUE; +} + +void RTFDocVisitor::visitPost(DocHtmlPre *) +{ + m_insidePre=FALSE; + m_t << "\\end{alltt}\\normalsize " << endl; +} + +void RTFDocVisitor::visitPre(DocHtmlDescList *) +{ + m_t << "\\begin{description}" << endl; +} + +void RTFDocVisitor::visitPost(DocHtmlDescList *) +{ + m_t << "\\end{description}" << endl; +} + +void RTFDocVisitor::visitPre(DocHtmlDescTitle *) +{ + m_t << "\\item["; +} + +void RTFDocVisitor::visitPost(DocHtmlDescTitle *) +{ + m_t << "]"; +} + +void RTFDocVisitor::visitPre(DocHtmlDescData *) +{ +} + +void RTFDocVisitor::visitPost(DocHtmlDescData *) +{ +} + +void RTFDocVisitor::visitPre(DocHtmlTable *t) +{ + if (t->hasCaption()) + { + m_t << "\\begin{table}[h]"; + } + m_t << "\\begin{TabularC}{" << t->numCols() << "}\n\\hline\n"; +} + +void RTFDocVisitor::visitPost(DocHtmlTable *t) +{ + if (t->hasCaption()) + { + m_t << "\\end{table}\n"; + } + else + { + m_t << "\\\\\\hline\n\\end{TabularC}\n"; + } +} + +void RTFDocVisitor::visitPre(DocHtmlCaption *) +{ + m_t << "\\\\\\hline\n\\end{TabularC}\n\\centering\n\\caption{"; +} + +void RTFDocVisitor::visitPost(DocHtmlCaption *) +{ + m_t << "}\n"; +} + +void RTFDocVisitor::visitPre(DocHtmlRow *) +{ +} + +void RTFDocVisitor::visitPost(DocHtmlRow *) +{ + m_t << "\\\\\\hline\n"; +} + +void RTFDocVisitor::visitPre(DocHtmlCell *) +{ +} + +void RTFDocVisitor::visitPost(DocHtmlCell *c) +{ + if (!c->isLast()) m_t << "&"; +} + +void RTFDocVisitor::visitPre(DocIndexEntry *) +{ + m_hide = TRUE; +} + +void RTFDocVisitor::visitPost(DocIndexEntry *) +{ + m_hide = FALSE; +} + +void RTFDocVisitor::visitPre(DocInternal *) +{ + m_t << "\\begin{Desc}" << endl + << "\\item[" << theTranslator->trForInternalUseOnly() << "]" << endl; +} + +void RTFDocVisitor::visitPost(DocInternal *) +{ + m_t << "\\end{Desc}" << endl; +} + +void RTFDocVisitor::visitPre(DocHRef *href) +{ + if (Config_getBool("PDF_HYPERLINKS")) + { + m_t << "\\href{"; + m_t << href->url(); + m_t << "}"; + } + m_t << "{\\tt "; +} + +void RTFDocVisitor::visitPost(DocHRef *) +{ + m_t << "}"; +} + +void RTFDocVisitor::visitPre(DocHtmlHeader *header) +{ + if (Config_getBool("COMPACT_LATEX")) + { + switch(header->level()) + { + case 1: m_t << "\\subsection{"; break; + case 2: m_t << "\\subsubsection{"; break; + case 3: m_t << "\\paragraph{"; break; + } + } + else + { + switch(header->level()) + { + case 1: m_t << "\\section{"; break; + case 2: m_t << "\\subsection{"; break; + case 3: m_t << "\\subsubsection{"; break; + } + } +} + +void RTFDocVisitor::visitPost(DocHtmlHeader *) +{ + m_t << "}"; +} + +void RTFDocVisitor::visitPre(DocImage *img) +{ + if (img->type()==DocImage::Latex) + { + if (img->hasCaption()) + { + m_t << "\\begin{figure}[H]" << endl; + m_t << "\\begin{center}" << endl; + } + else + { + m_t << "\\mbox{"; + } + QCString gfxName = img->name(); + if (gfxName.right(4)==".eps" || gfxName.right(4)==".pdf") + { + gfxName=gfxName.left(gfxName.length()-4); + } + m_t << "\\includegraphics"; + if (!img->width().isEmpty()) + { + m_t << "[width=" << img->width() << "]"; + } + else if (!img->height().isEmpty()) + { + m_t << "[height=" << img->height() << "]"; + } + m_t << "{" << gfxName << "}"; + if (img->hasCaption()) + { + m_t << "\\caption{"; + } + } + else // other format -> skip + { + m_hide=TRUE; + } +} + +void RTFDocVisitor::visitPost(DocImage *img) +{ + if (img->type()==DocImage::Latex) + { + m_t << "}" << endl; // end mbox or caption + if (img->hasCaption()) + { + m_t << "\\end{center}" << endl; + m_t << "\\end{figure}" << endl; + } + } + else // other format + { + m_hide=FALSE; + } +} + +void RTFDocVisitor::visitPre(DocDotFile *df) +{ + QCString baseName=df->file(); + int i; + if ((i=baseName.findRev('/'))!=-1) + { + baseName=baseName.right(baseName.length()-i-1); + } + if (baseName.right(4)==".eps" || baseName.right(4)==".pdf") + { + baseName=baseName.left(baseName.length()-4); + } + QCString outDir = Config_getString("LATEX_OUTPUT"); + writeDotGraphFromFile(df->file(),outDir,baseName,EPS); + if (df->hasCaption()) + { + m_t << "\\begin{figure}[H]" << endl; + m_t << "\\begin{center}" << endl; + } + else + { + m_t << "\\mbox{"; + } + m_t << "\\includegraphics"; + if (!df->width().isEmpty()) + { + m_t << "[width=" << df->width() << "]"; + } + else if (!df->height().isEmpty()) + { + m_t << "[height=" << df->height() << "]"; + } + m_t << "{" << baseName << "}"; + + if (df->hasCaption()) + { + m_t << "\\caption{"; + } +} + +void RTFDocVisitor::visitPost(DocDotFile *df) +{ + m_t << "}" << endl; // end mbox or caption + if (df->hasCaption()) + { + m_t << "\\end{center}" << endl; + m_t << "\\end{figure}" << endl; + } +} + +void RTFDocVisitor::visitPre(DocLink *lnk) +{ + startLink(lnk->ref(),lnk->file(),lnk->anchor()); +} + +void RTFDocVisitor::visitPost(DocLink *lnk) +{ + endLink(lnk->ref()); +} + +void RTFDocVisitor::visitPre(DocRef *ref) +{ + startLink(ref->ref(),ref->file(),ref->anchor()); + if (!ref->hasLinkText()) filter(ref->targetTitle()); +} + +void RTFDocVisitor::visitPost(DocRef *ref) +{ + endLink(ref->ref()); + m_t << " "; +} + +void RTFDocVisitor::visitPre(DocSecRefItem *) +{ + m_t << "\\item \\contentsline{section}{"; +} + +void RTFDocVisitor::visitPost(DocSecRefItem *ref) +{ + m_t << "}{\\ref{" << ref->anchor() << "}}{}" << endl; +} + +void RTFDocVisitor::visitPre(DocSecRefList *) +{ + m_t << "\\footnotesize" << endl; + m_t << "\\begin{multicols}{2}" << endl; + m_t << "\\begin{CompactList}" << endl; +} + +void RTFDocVisitor::visitPost(DocSecRefList *) +{ + m_t << "\\end{CompactList}" << endl; + m_t << "\\end{multicols}" << endl; + m_t << "\\normalsize" << endl; +} + +void RTFDocVisitor::visitPre(DocLanguage *) +{ +} + +void RTFDocVisitor::visitPost(DocLanguage *) +{ +} + +void RTFDocVisitor::visitPre(DocParamSect *s) +{ + m_t << "\\begin{Desc}" << endl; + m_t << "\\item["; + switch(s->type()) + { + case DocParamSect::Param: + m_t << theTranslator->trParameters(); break; + case DocParamSect::RetVal: + m_t << theTranslator->trReturnValues(); break; + case DocParamSect::Exception: + m_t << theTranslator->trExceptions(); break; + default: + ASSERT(0); + } + m_t << ":]" << endl; + m_t << "\\begin{description}" << endl; +} + +void RTFDocVisitor::visitPost(DocParamSect *) +{ + m_t << "\\end{description}" << endl; + m_t << "\\end{Desc}" << endl; +} + +void RTFDocVisitor::visitPre(DocParamList *pl) +{ + m_t << "\\item[{\\em "; + QStrListIterator li(pl->parameters()); + const char *s; + bool first=TRUE; + for (li.toFirst();(s=li.current());++li) + { + if (!first) m_t << ","; else first=FALSE; + m_t << s; + } + m_t << "}]"; +} + +void RTFDocVisitor::visitPost(DocParamList *) +{ +} + +void RTFDocVisitor::visitPre(DocXRefItem *x) +{ + m_t << "\\begin{Desc}" << endl; + m_t << "\\item["; + if (Config_getBool("PDF_HYPERLINKS")) + { + m_t << "\\hyperlink{" << x->file() << "_" << x->anchor() << "}{"; + } + else + { + m_t << "{\\bf "; + } + filter(x->title()); + m_t << "}]"; +} + +void RTFDocVisitor::visitPost(DocXRefItem *) +{ + m_t << "\\end{Desc}" << endl; +} + +void RTFDocVisitor::visitPre(DocInternalRef *ref) +{ + startLink("",ref->file(),ref->anchor()); +} + +void RTFDocVisitor::visitPost(DocInternalRef *) +{ + endLink(""); + m_t << " "; +} + +void RTFDocVisitor::visitPre(DocCopy *) +{ +} + +void RTFDocVisitor::visitPost(DocCopy *) +{ +} + +static char* getMultiByte(int c) +{ + static char s[10]; + sprintf(s,"\\'%X",c); + return s; +} + +void RTFDocVisitor::filter(const char *str) +{ + if (str) + { + const unsigned char *p=(const unsigned char *)str; + unsigned char c; + unsigned char pc='\0'; + while (*p) + { + static bool MultiByte = FALSE; + c=*p++; + + if ( MultiByte ) + { + m_t << getMultiByte( c ); + MultiByte = FALSE; + continue; + } + if ( c >= 0x80 ) + { + MultiByte = TRUE; + m_t << getMultiByte( c ); + continue; + } + + switch (c) + { + case '{': m_t << "\\{"; break; + case '}': m_t << "\\}"; break; + case '\\': m_t << "\\\\"; break; + default: m_t << (char)c; + } + pc = c; + } + } +} + +void RTFDocVisitor::startLink(const QCString &ref,const QCString &file,const QCString &anchor) +{ + if (ref.isEmpty() && Config_getBool("RTF_HYPERLINKS")) + { + QCString refName; + if (!file.isEmpty()) + { + refName+=file; + } + if (anchor) + { + refName+='_'; + refName+=anchor; + } + + m_t << "{\\field {\\*\\fldinst { HYPERLINK \\\\l \""; + m_t << rtfFormatBmkStr(refName); + m_t << "\" }{}"; + m_t << "}{\\fldrslt {\\cs37\\ul\\cf2 "; + } + else + { + m_t << "{\\b "; + } +} + +void RTFDocVisitor::endLink(const QCString &ref) +{ + if (ref.isEmpty() && Config_getBool("RTF_HYPERLINKS")) + { + m_t << "}}}"; + } + else + { + m_t << "}"; + } +} + diff --git a/src/rtfdocvisitor.h b/src/rtfdocvisitor.h new file mode 100644 index 0000000..842cc84 --- /dev/null +++ b/src/rtfdocvisitor.h @@ -0,0 +1,150 @@ +/****************************************************************************** + * + * + * + * + * Copyright (C) 1997-2002 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + * Documents produced by Doxygen are derivative works derived from the + * input used in their production; they are not affected by this license. + * + */ + +#ifndef _RTFDOCVISITOR_H +#define _RTFDOCVISITOR_H + +#include "docvisitor.h" + +class QTextStream; +class BaseCodeDocInterface; +class QCString; + +/*! @brief Concrete visitor implementation for RTF output. */ +class RTFDocVisitor : public DocVisitor +{ + public: + RTFDocVisitor(QTextStream &t,BaseCodeDocInterface &ci); + + //-------------------------------------- + // visitor functions for leaf nodes + //-------------------------------------- + + void visit(DocWord *); + void visit(DocLinkedWord *); + void visit(DocWhiteSpace *); + void visit(DocSymbol *); + void visit(DocURL *); + void visit(DocLineBreak *); + void visit(DocHorRuler *); + void visit(DocStyleChange *); + void visit(DocVerbatim *); + void visit(DocAnchor *); + void visit(DocInclude *); + void visit(DocIncOperator *); + void visit(DocFormula *); + + //-------------------------------------- + // visitor functions for compound nodes + //-------------------------------------- + + void visitPre(DocAutoList *); + void visitPost(DocAutoList *); + void visitPre(DocAutoListItem *); + void visitPost(DocAutoListItem *); + void visitPre(DocPara *); + void visitPost(DocPara *); + void visitPre(DocRoot *); + void visitPost(DocRoot *); + void visitPre(DocSimpleSect *); + void visitPost(DocSimpleSect *); + void visitPre(DocTitle *); + void visitPost(DocTitle *); + void visitPre(DocSimpleList *); + void visitPost(DocSimpleList *); + void visitPre(DocSimpleListItem *); + void visitPost(DocSimpleListItem *); + void visitPre(DocSection *s); + void visitPost(DocSection *); + void visitPre(DocHtmlList *s); + void visitPost(DocHtmlList *s); + void visitPre(DocHtmlListItem *); + void visitPost(DocHtmlListItem *); + void visitPre(DocHtmlPre *); + void visitPost(DocHtmlPre *); + void visitPre(DocHtmlDescList *); + void visitPost(DocHtmlDescList *); + void visitPre(DocHtmlDescTitle *); + void visitPost(DocHtmlDescTitle *); + void visitPre(DocHtmlDescData *); + void visitPost(DocHtmlDescData *); + void visitPre(DocHtmlTable *t); + void visitPost(DocHtmlTable *t); + void visitPre(DocHtmlCaption *); + void visitPost(DocHtmlCaption *); + void visitPre(DocHtmlRow *); + void visitPost(DocHtmlRow *) ; + void visitPre(DocHtmlCell *); + void visitPost(DocHtmlCell *); + void visitPre(DocIndexEntry *); + void visitPost(DocIndexEntry *); + void visitPre(DocInternal *); + void visitPost(DocInternal *); + void visitPre(DocHRef *); + void visitPost(DocHRef *); + void visitPre(DocHtmlHeader *); + void visitPost(DocHtmlHeader *) ; + void visitPre(DocImage *); + void visitPost(DocImage *); + void visitPre(DocDotFile *); + void visitPost(DocDotFile *); + void visitPre(DocLink *lnk); + void visitPost(DocLink *); + void visitPre(DocRef *ref); + void visitPost(DocRef *); + void visitPre(DocSecRefItem *); + void visitPost(DocSecRefItem *); + void visitPre(DocSecRefList *); + void visitPost(DocSecRefList *); + void visitPre(DocLanguage *); + void visitPost(DocLanguage *); + void visitPre(DocParamSect *); + void visitPost(DocParamSect *); + void visitPre(DocParamList *); + void visitPost(DocParamList *); + void visitPre(DocXRefItem *); + void visitPost(DocXRefItem *); + void visitPre(DocInternalRef *); + void visitPost(DocInternalRef *); + void visitPre(DocCopy *); + void visitPost(DocCopy *); + + private: + + //-------------------------------------- + // helper functions + //-------------------------------------- + + void filter(const char *str); + void startLink(const QCString &ref,const QCString &file, + const QCString &anchor); + void endLink(const QCString &ref); + QCString getStyle(const char *name); + + //-------------------------------------- + // state variables + //-------------------------------------- + + QTextStream &m_t; + BaseCodeDocInterface &m_ci; + bool m_insidePre; + bool m_hide; + int m_indentLevel; +}; + +#endif diff --git a/src/rtfgen.cpp b/src/rtfgen.cpp index 8583856..2aaa3ab 100644 --- a/src/rtfgen.cpp +++ b/src/rtfgen.cpp @@ -33,6 +33,7 @@ #include "dot.h" #include "version.h" #include "page.h" +#include "rtfstyle.h" //#define DBG_RTF(x) x; #define DBG_RTF(x) @@ -40,64 +41,6 @@ // used for table column width calculation #define PAGEWIDTH 8748 -const int indentLevels = 10; - -struct RTFListItemInfo -{ - bool isEnum; - int number; -}; - -static RTFListItemInfo listItemInfo[indentLevels]; -static QCString title; -static QCString subject; -static QCString comments; -static QCString company; -static QCString logoFilename; -static QCString author; -static QCString manager; -static QCString documentType; -static QCString documentId; -static QCString keywords; - -static QCString g_nextTag( "AAAAAAAAAA" ); -static QDict<QCString> g_tagDict( 5003 ); - -static QCString formatBmkStr(const char *name) -{ - // To overcome the 40-character tag limitation, we - // substitute a short arbitrary string for the name - // supplied, and keep track of the correspondence - // between names and strings. - QCString key( name ); - QCString* tag = g_tagDict.find( key ); - if ( !tag ) - { - // This particular name has not yet been added - // to the list. Add it, associating it with the - // next tag value, and increment the next tag. - tag = new QCString( g_nextTag.copy() ); // Make sure to use a deep copy! - g_tagDict.insert( key, tag ); - - // This is the increment part - char* nxtTag = g_nextTag.data() + g_nextTag.length() - 1; - for ( unsigned int i = 0; i < g_nextTag.length(); ++i, --nxtTag ) - { - if ( ( ++(*nxtTag) ) > 'Z' ) - { - (*nxtTag) = 'A'; - } - else - { - // Since there was no carry, we can stop now - break; - } - } - } - - return *tag; -} - static QCString dateToRTFDateString() { const QDateTime &d = QDateTime::currentDateTime(); @@ -106,7 +49,7 @@ static QCString dateToRTFDateString() d.date().year(), d.date().month(), d.date().day(), d.time().hour(),d.time().minute(),d.time().second()); return result; -} +} RTFGenerator::RTFGenerator() : OutputGenerator() { @@ -143,307 +86,6 @@ OutputGenerator *RTFGenerator::copy() return result; } -static const char Rtf_Style_Reset[] = "\\pard\\plain "; - -struct Rtf_Style_Default -{ - const char *name; - const char *reference; - const char *definition; -}; - -static const struct Rtf_Style_Default Rtf_Style_Default[] = -{ - { "Heading1", - "\\s1\\sb240\\sa60\\keepn\\widctlpar\\adjustright \\b\\f1\\fs36\\kerning36\\cgrid ", - "\\sbasedon0 \\snext0 heading 1" - }, - { "Heading2", - "\\s2\\sb240\\sa60\\keepn\\widctlpar\\adjustright \\b\\f1\\fs28\\kerning28\\cgrid ", - "\\sbasedon0 \\snext0 heading 2" - }, - { "Heading3", - "\\s3\\sb240\\sa60\\keepn\\widctlpar\\adjustright \\b\\f1\\cgrid ", - "\\sbasedon0 \\snext0 heading 3" - }, - { "Heading4", - "\\s4\\sb240\\sa60\\keepn\\widctlpar\\adjustright \\b\\f1\\fs20\\cgrid ", - "\\sbasedon0 \\snext0 heading 4;}{\\*\\cs10 \\additive Default Paragraph Font" - }, - { "Title", - "\\s15\\qc\\sb240\\sa60\\widctlpar\\outlinelevel0\\adjustright \\b\\f1\\fs32\\kerning28\\cgrid ", - "\\sbasedon0 \\snext15 Title" - }, - { "SubTitle", - "\\s16\\qc\\sa60\\widctlpar\\outlinelevel1\\adjustright \\f1\\cgrid ", - "\\sbasedon0 \\snext16 Subtitle" - }, - { "BodyText", - "\\s17\\sa60\\sb30\\widctlpar\\qj \\fs22\\cgrid ", - "\\sbasedon0 \\snext17 BodyText" - }, - { "DenseText", - "\\s18\\widctlpar\\fs22\\cgrid ", - "\\sbasedon0 \\snext18 DenseText" - }, - { "Header", - "\\s28\\widctlpar\\tqc\\tx4320\\tqr\\tx8640\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext28 header" - }, - { "Footer", - "\\s29\\widctlpar\\tqc\\tx4320\\tqr\\tx8640\\qr\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext29 footer" - }, - { "GroupHeader", - "\\s30\\li360\\sa60\\sb120\\keepn\\widctlpar\\adjustright \\b\\f1\\fs20\\cgrid ", - "\\sbasedon0 \\snext30 GroupHeader" - }, - { "CodeExample0", - "\\s40\\li0\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ", - "\\sbasedon0 \\snext41 Code Example 0" - }, - { "CodeExample1", - "\\s41\\li360\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ", - "\\sbasedon0 \\snext42 Code Example 1" - }, - { "CodeExample2", - "\\s42\\li720\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ", - "\\sbasedon0 \\snext43 Code Example 2" - }, - { "CodeExample3", - "\\s43\\li1080\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ", - "\\sbasedon0 \\snext44 Code Example 3" - }, - { "CodeExample4", - "\\s44\\li1440\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ", - "\\sbasedon0 \\snext45 Code Example 4" - }, - { "CodeExample5", - "\\s45\\li1800\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ", - "\\sbasedon0 \\snext46 Code Example 5" - }, - { "CodeExample6", - "\\s46\\li2160\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ", - "\\sbasedon0 \\snext47 Code Example 6" - }, - { "CodeExample7", - "\\s47\\li2520\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ", - "\\sbasedon0 \\snext48 Code Example 7" - }, - { "CodeExample8", - "\\s48\\li2880\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ", - "\\sbasedon0 \\snext49 Code Example 8" - }, - { "CodeExample9", - "\\s49\\li3240\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ", - "\\sbasedon0 \\snext49 Code Example 9" - }, - { "ListContinue0", - "\\s50\\li0\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext51 List Continue 0" - }, - { "ListContinue1", - "\\s51\\li360\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext52 List Continue 1" - }, - { "ListContinue2", - "\\s52\\li720\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext53 List Continue 2" - }, - { "ListContinue3", - "\\s53\\li1080\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext54 List Continue 3" - }, - { "ListContinue4", - "\\s54\\li1440\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext55 List Continue 4" - }, - { "ListContinue5", - "\\s55\\li1800\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext56 List Continue 5" - }, - { "ListContinue6", - "\\s56\\li2160\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext57 List Continue 6" - }, - { "ListContinue7", - "\\s57\\li2520\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext58 List Continue 7" - }, - { "ListContinue8", - "\\s58\\li2880\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext59 List Continue 8" - }, - { "ListContinue9", - "\\s59\\li3240\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext59 List Continue 9" - }, - { "DescContinue0", - "\\s60\\li0\\widctlpar\\ql\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext61 DescContinue 0" - }, - { "DescContinue1", - "\\s61\\li360\\widctlpar\\ql\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext62 DescContinue 1" - }, - { "DescContinue2", - "\\s62\\li720\\widctlpar\\ql\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext63 DescContinue 2" - }, - { "DescContinue3", - "\\s63\\li1080\\widctlpar\\ql\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext64 DescContinue 3" - }, - { "DescContinue4", - "\\s64\\li1440\\widctlpar\\ql\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext65 DescContinue 4" - }, - { "DescContinue5", - "\\s65\\li1800\\widctlpar\\ql\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext66 DescContinue 5" - }, - { "DescContinue6", - "\\s66\\li2160\\widctlpar\\ql\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext67 DescContinue 6" - }, - { "DescContinue7", - "\\s67\\li2520\\widctlpar\\ql\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext68 DescContinue 7" - }, - { "DescContinue8", - "\\s68\\li2880\\widctlpar\\ql\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext69 DescContinue 8" - }, - { "DescContinue9", - "\\s69\\li3240\\widctlpar\\ql\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext69 DescContinue 9" - }, - { "LatexTOC0", - "\\s70\\li0\\sa30\\sb30\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext81 LatexTOC 0" - }, - { "LatexTOC1", - "\\s71\\li360\\sa27\\sb27\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext82 LatexTOC 1" - }, - { "LatexTOC2", - "\\s72\\li720\\sa24\\sb24\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext83 LatexTOC 2" - }, - { "LatexTOC3", - "\\s73\\li1080\\sa21\\sb21\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext84 LatexTOC 3" - }, - { "LatexTOC4", - "\\s74\\li1440\\sa18\\sb18\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext85 LatexTOC 4" - }, - { "LatexTOC5", - "\\s75\\li1800\\sa15\\sb15\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext86 LatexTOC 5" - }, - { "LatexTOC6", - "\\s76\\li2160\\sa12\\sb12\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext87 LatexTOC 6" - }, - { "LatexTOC7", - "\\s77\\li2520\\sa9\\sb9\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext88 LatexTOC 7" - }, - { "LatexTOC8", - "\\s78\\li2880\\sa6\\sb6\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext89 LatexTOC 8" - }, - { "LatexTOC9", - "\\s79\\li3240\\sa3\\sb3\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext89 LatexTOC 9" - }, - { "ListBullet0", - "\\s80\\fi-360\\li360\\widctlpar\\jclisttab\\tx360{\\*\\pn \\pnlvlbody\\ilvl0\\ls1\\pnrnot0\\pndec }\\ls1\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext81 \\sautoupd List Bullet 0" - }, - { "ListBullet1", - "\\s81\\fi-360\\li720\\widctlpar\\jclisttab\\tx720{\\*\\pn \\pnlvlbody\\ilvl0\\ls2\\pnrnot0\\pndec }\\ls2\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext82 \\sautoupd List Bullet 1" - }, - { "ListBullet2", - "\\s82\\fi-360\\li1080\\widctlpar\\jclisttab\\tx1080{\\*\\pn \\pnlvlbody\\ilvl0\\ls3\\pnrnot0\\pndec }\\ls3\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext83 \\sautoupd List Bullet 2" - }, - { "ListBullet3", - "\\s83\\fi-360\\li1440\\widctlpar\\jclisttab\\tx1440{\\*\\pn \\pnlvlbody\\ilvl0\\ls4\\pnrnot0\\pndec }\\ls4\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext84 \\sautoupd List Bullet 3" - }, - { "ListBullet4", - "\\s84\\fi-360\\li1800\\widctlpar\\jclisttab\\tx1800{\\*\\pn \\pnlvlbody\\ilvl0\\ls5\\pnrnot0\\pndec }\\ls5\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext85 \\sautoupd List Bullet 4" - }, - { "ListBullet5", - "\\s85\\fi-360\\li2160\\widctlpar\\jclisttab\\tx2160{\\*\\pn \\pnlvlbody\\ilvl0\\ls6\\pnrnot0\\pndec }\\ls6\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext86 \\sautoupd List Bullet 5" - }, - { "ListBullet6", - "\\s86\\fi-360\\li2520\\widctlpar\\jclisttab\\tx2520{\\*\\pn \\pnlvlbody\\ilvl0\\ls7\\pnrnot0\\pndec }\\ls7\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext87 \\sautoupd List Bullet 6" - }, - { "ListBullet7", - "\\s87\\fi-360\\li2880\\widctlpar\\jclisttab\\tx2880{\\*\\pn \\pnlvlbody\\ilvl0\\ls8\\pnrnot0\\pndec }\\ls8\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext88 \\sautoupd List Bullet 7" - }, - { "ListBullet8", - "\\s88\\fi-360\\li3240\\widctlpar\\jclisttab\\tx3240{\\*\\pn \\pnlvlbody\\ilvl0\\ls9\\pnrnot0\\pndec }\\ls9\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext89 \\sautoupd List Bullet 8" - }, - { "ListBullet9", - "\\s89\\fi-360\\li3600\\widctlpar\\jclisttab\\tx3600{\\*\\pn \\pnlvlbody\\ilvl0\\ls10\\pnrnot0\\pndec }\\ls10\\adjustright \\fs20\\cgrid ", - "\\sbasedon0 \\snext89 \\sautoupd List Bullet 9" - }, - { "ListEnum0", - "\\s90\\fi-360\\li360\\widctlpar\\fs20\\cgrid ", - "\\sbasedon0 \\snext91 \\sautoupd List Enum 0" - }, - { "ListEnum1", - "\\s91\\fi-360\\li720\\widctlpar\\fs20\\cgrid ", - "\\sbasedon0 \\snext92 \\sautoupd List Enum 1" - }, - { "ListEnum2", - "\\s92\\fi-360\\li1080\\widctlpar\\fs20\\cgrid ", - "\\sbasedon0 \\snext93 \\sautoupd List Enum 2" - }, - { "ListEnum3", - "\\s93\\fi-360\\li1440\\widctlpar\\fs20\\cgrid ", - "\\sbasedon0 \\snext94 \\sautoupd List Enum 3" - }, - { "ListEnum4", - "\\s94\\fi-360\\li1800\\widctlpar\\fs20\\cgrid ", - "\\sbasedon0 \\snext95 \\sautoupd List Enum 4" - }, - { "ListEnum5", - "\\s95\\fi-360\\li2160\\widctlpar\\fs20\\cgrid ", - "\\sbasedon0 \\snext96 \\sautoupd List Enum 5" - }, - { "ListEnum6", - "\\s96\\fi-360\\li2520\\widctlpar\\fs20\\cgrid ", - "\\sbasedon0 \\snext96 \\sautoupd List Enum 5" - }, - { "ListEnum7", - "\\s97\\fi-360\\li2880\\widctlpar\\fs20\\cgrid ", - "\\sbasedon0 \\snext98 \\sautoupd List Enum 7" - }, - { "ListEnum8", - "\\s98\\fi-360\\li3240\\widctlpar\\fs20\\cgrid ", - "\\sbasedon0 \\snext99 \\sautoupd List Enum 8" - }, - { "ListEnum9", - "\\s99\\fi-360\\li3600\\widctlpar\\fs20\\cgrid ", - "\\sbasedon0 \\snext99 \\sautoupd List Enum 9" - }, - { 0, - 0, - 0 - } -}; - void RTFGenerator::writeStyleSheetFile(QFile &file) { QTextStream t(&file); @@ -453,171 +95,14 @@ void RTFGenerator::writeStyleSheetFile(QFile &file) t << "# Remove a hash to activate a line.\n\n"; int i; - for (i=0;Rtf_Style_Default[i].reference!=0;i++) + for ( i=0 ; rtf_Style_Default[i].reference!=0 ; i++ ) { - t << "# " << Rtf_Style_Default[i].name << " = " - << Rtf_Style_Default[i].reference - << Rtf_Style_Default[i].definition << endl; + t << "# " << rtf_Style_Default[i].name << " = " + << rtf_Style_Default[i].reference + << rtf_Style_Default[i].definition << endl; } } -struct StyleData -{ - // elements of this type are stored in dictionary Rtf_Style - // - // to define a tag in the header reference + definition is required - // to use a tag in the body of the document only reference is required - - unsigned index; // index in style-sheet, i.e. number in s-clause - char* reference; // everything required to apply the style - char* definition; // aditional tags like \snext and style name - - StyleData(const char* reference, const char* definition); - ~StyleData(); - bool setStyle(const char* s, const char* styleName); - - static const QRegExp s_clause; -}; - -const QRegExp StyleData::s_clause("\\\\s[0-9]+\\s*"); - -StyleData::StyleData(const char* reference, const char* definition) -{ - int start = s_clause.match(reference); ASSERT(start >= 0); - reference += start; - index = (int)atol(reference + 2); ASSERT(index > 0); - - ASSERT(reference != 0); - size_t size = 1 + strlen(reference); - memcpy(this->reference = new char[size], reference, size); - - ASSERT(definition != 0); - size = 1 + strlen(definition); - memcpy(this->definition = new char[size], definition, size); -} - -StyleData::~StyleData() -{ - delete[] reference; - delete[] definition; -} - -bool StyleData::setStyle(const char* s, const char* styleName) -{ - static const QRegExp subgroup("^{[^}]*}\\s*"); - static const QRegExp any_clause("^\\\\[a-z][a-z0-9-]*\\s*"); - - int len = 0; // length of a particular RTF formatting control - int ref_len = 0; // length of the whole formatting section of a style - int start = s_clause.match(s, 0, &len); - if (start < 0) - { - err("Style sheet '%s' contains no '\\s' clause.\n{%s}\n", styleName, s); - return FALSE; - } - s += start; - index = (int)atol(s + 2); ASSERT(index > 0); - - // search for the end of pure formatting codes - const char* end = s + len; - ref_len = len; - bool haveNewDefinition = TRUE; - for(;;) - { - if (*end == '{') - { - // subgroups are used for \\additive - if (0 != subgroup.match(end, 0, &len)) - break; - else - { - end += len; - ref_len += len; - } - } - else if (*end == '\\') - { - if (0 == strncmp(end, "\\snext", 6)) - break; - if (0 == strncmp(end, "\\sbasedon", 9)) - break; - if (0 != any_clause.match(end, 0, &len)) - break; - end += len; - ref_len += len; - } - else if (*end == 0) - { // no style-definition part, keep default value - haveNewDefinition = FALSE; - break; - } - else // plain name without leading \\snext - break; - } - delete[] reference; - reference = new char[ref_len + 1]; - memcpy(reference, s, ref_len); - reference[ref_len] = 0; - if (haveNewDefinition) - { - delete[] definition; - size_t size = 1 + strlen(end); - definition = new char[size]; - memcpy(definition, end, size); - } - return TRUE; -} - -static void loadStylesheet(const char *name, QDict<StyleData>& dict) -{ - QFile file(name); - if (!file.open(IO_ReadOnly)) - { - err("Can't open RTF style sheet file %s. Using defaults.\n",name); - return; - } - msg("Loading RTF style sheet %s...\n",name); - - static const QRegExp separator("[ \t]*=[ \t]*"); - uint lineNr=1; - QTextStream t(&file); -#if QT_VERSION >= 200 - t.setEncoding(QTextStream::Latin1); -#endif - - while (!t.eof()) - { - QCString s(4096); // string buffer of max line length - s = t.readLine().stripWhiteSpace(); - if (s.length()==0 || s.at(0)=='#') continue; // skip blanks & comments - int sepLength; - int sepStart = separator.match(s,0,&sepLength); - if (sepStart<=0) // no valid assignment statement - { - warn(name,lineNr,"Assignment of style sheet name expected!\n"); - continue; - } - QCString key=s.left(sepStart); - if (dict[key]==0) // not a valid style sheet name - { - warn(name,lineNr,"Invalid style sheet name %s ignored.\n",key.data()); - continue; - } - StyleData* styleData = dict.find(key); - if (styleData == 0) - { - warn(name,lineNr,"Unknown style sheet name %s ignored.\n",key.data()); - continue; - } - s+=" "; // add command separator - styleData->setStyle(s.data() + sepStart + sepLength, key.data()); - lineNr++; - } -} - -static QDict<StyleData> Rtf_Style(257); - - void RTFGenerator::writeExtensionsFile(QFile &file) { QTextStream t(&file); @@ -670,52 +155,6 @@ void RTFGenerator::writeExtensionsFile(QFile &file) t << "#Keywords = \n\n"; } -static void loadExtensions(const char *name) -{ - QFile file(name); - if (!file.open(IO_ReadOnly)) - { - err("Can't open RTF extensions file %s. Using defaults.\n",name); - return; - } - msg("Loading RTF extensions %s...\n",name); - - static const QRegExp separator("[ \t]*=[ \t]*"); - uint lineNr=1; - QTextStream t(&file); -#if QT_VERSION >= 200 - t.setEncoding(QTextStream::Latin1); -#endif - - while (!t.eof()) - { - QCString s(4096); // string buffer of max line length - s = t.readLine().stripWhiteSpace(); - if (s.length()==0 || s.at(0)=='#') continue; // skip blanks & comments - int sepLength; - int sepStart = separator.match(s,0,&sepLength); - if (sepStart<=0) // no valid assignment statement - { - warn(name,lineNr,"Assignment of extension field expected!\n"); - continue; - } - QCString key=s.left(sepStart); - QCString data=s.data() + sepStart + sepLength; - - if (key == "Title") title = data.data(); - if (key == "Subject") subject = data.data(); - if (key == "Comments") comments = data.data(); - if (key == "Company") company = data.data(); - if (key == "LogoFilename") logoFilename = data.data(); - if (key == "Author") author = data.data(); - if (key == "Manager") manager = data.data(); - if (key == "DocumentType") documentType = data.data(); - if (key == "DocumentId") documentId = data.data(); - if (key == "Keywords") keywords = data.data(); - lineNr++; - } -} - void RTFGenerator::init() { @@ -726,18 +165,16 @@ void RTFGenerator::init() err("Could not create output directory %s\n",dir.data()); exit(1); } - Rtf_Style.setAutoDelete(TRUE); - - g_tagDict.setAutoDelete(TRUE); + rtf_Style.setAutoDelete(TRUE); - // first duplicate strings of Rtf_Style_Default - const struct Rtf_Style_Default* def = Rtf_Style_Default; + // first duplicate strings of rtf_Style_Default + const struct Rtf_Style_Default* def = rtf_Style_Default; while(def->reference != 0) { if (def->definition == 0) - err("Internal error: Rtf_Style_Default[%s] has no definition.\n", def->name); + err("Internal error: rtf_Style_Default[%s] has no definition.\n", def->name); StyleData* styleData = new StyleData(def->reference, def->definition); - Rtf_Style.insert(def->name, styleData); + rtf_Style.insert(def->name, styleData); def++; } @@ -745,7 +182,7 @@ void RTFGenerator::init() QCString &rtfStyleSheetFile = Config_getString("RTF_STYLESHEET_FILE"); if (!rtfStyleSheetFile.isEmpty()) { - loadStylesheet(rtfStyleSheetFile, Rtf_Style); + loadStylesheet(rtfStyleSheetFile, rtf_Style); } // If user has defined an extension file, load its contents. @@ -807,7 +244,7 @@ void RTFGenerator::beginRTFDocument() // sort styles ascending by \s-number via an intermediate QArray QArray<const StyleData*> array(128); array.fill(0); - QDictIterator<StyleData> iter(Rtf_Style); + QDictIterator<StyleData> iter(rtf_Style); const StyleData* style; for(; (style = iter.current()); ++iter) { @@ -847,40 +284,40 @@ void RTFGenerator::beginRTFChapter() { t <<"\n"; DBG_RTF(t << "{\\comment BeginRTFChapter}\n") - t << Rtf_Style_Reset; + t << rtf_Style_Reset; // if we are compact, no extra page breaks... if (Config_getBool("COMPACT_RTF")) { // t <<"\\sect\\sectd\\sbknone\n"; t <<"\\sect\\sbknone\n"; - RtfwriteRuler_thick(); + rtfwriteRuler_thick(); } else t <<"\\sect\\sbkpage\n"; //t <<"\\sect\\sectd\\sbkpage\n"; - t << Rtf_Style["Heading1"]->reference << "\n"; + t << rtf_Style["Heading1"]->reference << "\n"; } void RTFGenerator::beginRTFSection() { t <<"\n"; DBG_RTF(t << "{\\comment BeginRTFSection}\n") - t << Rtf_Style_Reset; + t << rtf_Style_Reset; // if we are compact, no extra page breaks... if (Config_getBool("COMPACT_RTF")) { // t <<"\\sect\\sectd\\sbknone\n"; t <<"\\sect\\sbknone\n"; - RtfwriteRuler_emboss(); + rtfwriteRuler_emboss(); } else t <<"\\sect\\sbkpage\n"; //t <<"\\sect\\sectd\\sbkpage\n"; - t << Rtf_Style["Heading2"]->reference << "\n"; + t << rtf_Style["Heading2"]->reference << "\n"; } void RTFGenerator::startFile(const char *name,const char *, @@ -929,13 +366,13 @@ void RTFGenerator::startIndexSection(IndexSections is) break; case isTitlePageAuthor: t << "}\n"; - if (subject) t << "{\\subject " << subject << "}\n"; - if (comments) t << "{\\comment " << comments << "}\n"; - if (company) t << "{\\company " << company << "}\n"; - if (author) t << "{\\author " << author << "}\n"; - if (manager) t << "{\\manager " << manager << "}\n"; - if (documentType) t << "{\\category " << documentType << "}\n"; - if (keywords) t << "{\\keywords " << keywords << "}\n"; + if (rtf_subject) t << "{\\subject " << rtf_subject << "}\n"; + if (rtf_comments) t << "{\\comment " << rtf_comments << "}\n"; + if (rtf_company) t << "{\\company " << rtf_company << "}\n"; + if (rtf_author) t << "{\\author " << rtf_author << "}\n"; + if (rtf_manager) t << "{\\manager " << rtf_manager << "}\n"; + if (rtf_documentType) t << "{\\category " << rtf_documentType << "}\n"; + if (rtf_keywords) t << "{\\keywords " << rtf_keywords << "}\n"; t << "{\\comment "; break; case isMainPage: @@ -1081,9 +518,9 @@ void RTFGenerator::endIndexSection(IndexSections is) switch (is) { case isTitlePageStart: - if (title) + if (rtf_title) // User has overridden document title in extensions file - t << "}" << title; + t << "}" << rtf_title; else t << "}" << Config_getString("PROJECT_NAME"); break; @@ -1093,42 +530,42 @@ void RTFGenerator::endIndexSection(IndexSections is) t << "{\\creatim " << dateToRTFDateString() << "}\n}"; DBG_RTF(t << "{\\comment end of infoblock}\n"); // setup for this section - t << Rtf_Style_Reset <<"\n"; + t << rtf_Style_Reset <<"\n"; t <<"\\sectd\\pgnlcrm\n"; - t <<"{\\footer "<<Rtf_Style["Footer"]->reference << "{\\chpgn}}\n"; + t <<"{\\footer "<<rtf_Style["Footer"]->reference << "{\\chpgn}}\n"; // the title entry DBG_RTF(t << "{\\comment begin title page}\n") - t << Rtf_Style_Reset << Rtf_Style["SubTitle"]->reference << endl; // set to title style + t << rtf_Style_Reset << rtf_Style["SubTitle"]->reference << endl; // set to title style t << "\\vertalc\\qc\\par\\par\\par\\par\\par\\par\\par\n"; - if (logoFilename) + if (rtf_logoFilename) { - t << "{\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE " << logoFilename; + t << "{\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE " << rtf_logoFilename; t << " \\\\d \\\\*MERGEFORMAT} {\\fldrslt IMAGE }}\\par\\par\n"; } - if (company) + if (rtf_company) { - t << company << "\\par\\par\n"; + t << rtf_company << "\\par\\par\n"; } - t << Rtf_Style_Reset << Rtf_Style["Title"]->reference << endl; // set to title style + t << rtf_Style_Reset << rtf_Style["Title"]->reference << endl; // set to title style t << "{\\field\\fldedit {\\*\\fldinst TITLE \\\\*MERGEFORMAT}{\\fldrslt TITLE}}\\par" << endl; - t << Rtf_Style_Reset << Rtf_Style["SubTitle"]->reference << endl; // set to title style + t << rtf_Style_Reset << rtf_Style["SubTitle"]->reference << endl; // set to title style t << "\\par\n"; - if (documentType) + if (rtf_documentType) { - t << documentType << "\\par\n"; + t << rtf_documentType << "\\par\n"; } - if (documentId) + if (rtf_documentId) { - t << documentId << "\\par\n"; + t << rtf_documentId << "\\par\n"; } t << "\\par\\par\\par\\par\\par\\par\\par\\par\\par\\par\\par\\par\n"; - t << Rtf_Style_Reset << Rtf_Style["SubTitle"]->reference << endl; // set to subtitle style + t << rtf_Style_Reset << rtf_Style["SubTitle"]->reference << endl; // set to subtitle style t << "{\\field\\fldedit {\\*\\fldinst AUTHOR \\\\*MERGEFORMAT}{\\fldrslt AUTHOR}}\\par" << endl; t << "Version " << Config_getString("PROJECT_NUMBER") << "\\par"; t << "{\\field\\fldedit {\\*\\fldinst CREATEDATE \\\\*MERGEFORMAT}" @@ -1139,16 +576,16 @@ void RTFGenerator::endIndexSection(IndexSections is) // table of contents section DBG_RTF(t << "{\\comment Table of contents}\n") t << "\\vertalt\n"; - t << Rtf_Style_Reset << endl; - t << Rtf_Style["Heading1"]->reference; + t << rtf_Style_Reset << endl; + t << rtf_Style["Heading1"]->reference; t << theTranslator->trRTFTableOfContents() << "\\par"<< endl; - t << Rtf_Style_Reset << "\\par" << endl; + t << rtf_Style_Reset << "\\par" << endl; t << "{\\field\\fldedit {\\*\\fldinst TOC \\\\f \\\\*MERGEFORMAT}{\\fldrslt Table of contents}}\\par\n"; - t << Rtf_Style_Reset << endl; + t << rtf_Style_Reset << endl; } break; case isMainPage: - t << "\\par " << Rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << endl; if (!Doxygen::mainPage || Doxygen::mainPage->title.isEmpty()) { t << "{\\tc \\v " << theTranslator->trMainPage() << "}"<< endl; @@ -1162,37 +599,37 @@ void RTFGenerator::endIndexSection(IndexSections is) t << ".rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; break; //case isPackageIndex: - // t << "\\par " << Rtf_Style_Reset << endl; + // t << "\\par " << rtf_Style_Reset << endl; // t << "{\\tc \\v " << theTranslator->trPackageList() << "}"<< endl; // t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \"packages.rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; // break; case isModuleIndex: - t << "\\par " << Rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << endl; t << "{\\tc \\v " << theTranslator->trModuleIndex() << "}"<< endl; t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \"modules.rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; break; case isNamespaceIndex: - t << "\\par " << Rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << endl; t << "{\\tc \\v " << theTranslator->trNamespaceIndex() << "}"<< endl; t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \"namespaces.rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; break; case isClassHierarchyIndex: - t << "\\par " << Rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << endl; t << "{\\tc \\v " << theTranslator->trHierarchicalIndex() << "}"<< endl; t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \"hierarchy.rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; break; case isCompoundIndex: - t << "\\par " << Rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << endl; t << "{\\tc \\v " << theTranslator->trCompoundIndex() << "}"<< endl; t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \"annotated.rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; break; case isFileIndex: - t << "\\par " << Rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << endl; t << "{\\tc \\v " << theTranslator->trFileIndex() << "}"<< endl; t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \"files.rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; break; case isPageIndex: - t << "\\par " << Rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << endl; t << "{\\tc \\v " << theTranslator->trPageIndex() << "}"<< endl; t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \"pages.rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; break; @@ -1203,7 +640,7 @@ void RTFGenerator::endIndexSection(IndexSections is) // t << "{\\tc \\v " << theTranslator->trPackageDocumentation() << "}"<< endl; // while (pd) // { - // t << "\\par " << Rtf_Style_Reset << endl; + // t << "\\par " << rtf_Style_Reset << endl; // t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \""; // t << pd->getOutputFileBase(); // t << ".rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; @@ -1221,7 +658,7 @@ void RTFGenerator::endIndexSection(IndexSections is) { if (!gd->isReference()) { - t << "\\par " << Rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << endl; t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \""; t << gd->getOutputFileBase(); t << ".rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; @@ -1238,7 +675,7 @@ void RTFGenerator::endIndexSection(IndexSections is) { if (nd->isLinkableInProject()) { - t << "\\par " << Rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << endl; t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \""; t << nd->getOutputFileBase(); t << ".rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; @@ -1249,7 +686,7 @@ void RTFGenerator::endIndexSection(IndexSections is) { if (nd->isLinkableInProject()) { - t << "\\par " << Rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << endl; beginRTFSection(); t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \""; t << nd->getOutputFileBase(); @@ -1270,7 +707,7 @@ void RTFGenerator::endIndexSection(IndexSections is) { if (cd->isLinkableInProject() && cd->templateMaster()==0) { - t << "\\par " << Rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << endl; t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \""; t << cd->getOutputFileBase(); t << ".rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; @@ -1281,7 +718,7 @@ void RTFGenerator::endIndexSection(IndexSections is) { if (cd->isLinkableInProject() && cd->templateMaster()==0) { - t << "\\par " << Rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << endl; beginRTFSection(); t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \""; t << cd->getOutputFileBase(); @@ -1305,7 +742,7 @@ void RTFGenerator::endIndexSection(IndexSections is) { if (isFirst) { - t << "\\par " << Rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << endl; t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \""; t << fd->getOutputFileBase(); t << ".rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; @@ -1313,7 +750,7 @@ void RTFGenerator::endIndexSection(IndexSections is) } else { - t << "\\par " << Rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << endl; beginRTFSection(); t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \""; t << fd->getOutputFileBase(); @@ -1334,14 +771,14 @@ void RTFGenerator::endIndexSection(IndexSections is) PageInfo *pi=pdi.toFirst(); if (pi) { - t << "\\par " << Rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << endl; t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \""; t << pi->getOutputFileBase(); t << ".rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; } for (++pdi;(pi=pdi.current());++pdi) { - t << "\\par " << Rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << endl; beginRTFSection(); t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \""; t << pi->getOutputFileBase(); @@ -1359,7 +796,7 @@ void RTFGenerator::endIndexSection(IndexSections is) { if (!pi->getGroupDef() && !pi->isReference()) { - if (first) t << "\\par " << Rtf_Style_Reset << endl; + if (first) t << "\\par " << rtf_Style_Reset << endl; t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \""; t << pi->getOutputFileBase(); t << ".rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; @@ -1370,9 +807,9 @@ void RTFGenerator::endIndexSection(IndexSections is) break; case isEndIndex: beginRTFChapter(); - t << Rtf_Style["Heading1"]->reference; + t << rtf_Style["Heading1"]->reference; t << theTranslator->trRTFGeneralIndex() << "\\par "<< endl; - t << Rtf_Style_Reset << endl; + t << rtf_Style_Reset << endl; t << "{\\tc \\v " << theTranslator->trRTFGeneralIndex() << "}" << endl; t << "{\\field\\fldedit {\\*\\fldinst INDEX \\\\c2 \\\\*MERGEFORMAT}{\\fldrslt INDEX}}\n"; @@ -1388,8 +825,8 @@ void RTFGenerator::lastIndexPage() t <<"\\sect \\sectd \\sbknone\n"; // set footer - t <<"{\\footer "<< Rtf_Style["Footer"]->reference << "{\\chpgn}}\n"; - //t << Rtf_Style["Heading1"]->reference << "\n"; + t <<"{\\footer "<< rtf_Style["Footer"]->reference << "{\\chpgn}}\n"; + //t << rtf_Style["Heading1"]->reference << "\n"; } @@ -1413,7 +850,7 @@ void RTFGenerator::startIndexList() DBG_RTF(t << "{\\comment (startIndexList)}" << endl) t << "{" << endl; incrementIndentLevel(); - t << Rtf_Style_Reset << Rtf_LCList_DepthStyle() << endl; + t << rtf_Style_Reset << rtf_LCList_DepthStyle() << endl; newParagraph(); m_omitParagraph = TRUE; } @@ -1471,16 +908,16 @@ void RTFGenerator::writeListItem() { DBG_RTF(t << "{\\comment (writeListItem)}" << endl) newParagraph(); - t << Rtf_Style_Reset; + t << rtf_Style_Reset; if (listItemInfo[m_listLevel].isEnum) { - t << Rtf_EList_DepthStyle() << endl; + t << rtf_EList_DepthStyle() << endl; t << listItemInfo[m_listLevel].number << ".\\tab "; listItemInfo[m_listLevel].number++; } else { - t << Rtf_BList_DepthStyle() << endl; + t << rtf_BList_DepthStyle() << endl; } m_omitParagraph = TRUE; } @@ -1489,12 +926,12 @@ void RTFGenerator::writeIndexItem(const char *ref,const char *fn, const char *name) { DBG_RTF(t << "{\\comment (writeIndexItem)}" << endl) - //t << Rtf_LCList_DepthStyle() << endl; + //t << rtf_LCList_DepthStyle() << endl; docify(name); if (!ref && fn) { t << "\\tab "; - WriteRTFReference(fn); + writeRTFReference(fn); t << endl; } else @@ -1556,7 +993,7 @@ void RTFGenerator::writeStartAnnoItem(const char *,const char *f, if (f && Config_getBool("RTF_HYPERLINKS")) { t << "{\\field {\\*\\fldinst { HYPERLINK \\\\l \""; - t << formatBmkStr(f); + t << rtfFormatBmkStr(f); t << "\" }{}"; t << "}{\\fldrslt {\\cs37\\ul\\cf2 "; @@ -1577,7 +1014,7 @@ void RTFGenerator::writeEndAnnoItem(const char *name) if (name) { t << "\\tab "; - WriteRTFReference(name); + writeRTFReference(name); t << endl; } else @@ -1611,7 +1048,7 @@ void RTFGenerator::endIndexValue(const char *name,bool hasBrief) if (name) { t << "\\tab "; - WriteRTFReference(name); + writeRTFReference(name); t << endl; } else @@ -1626,14 +1063,14 @@ void RTFGenerator::startSubsection() //beginRTFSubSection(); t <<"\n"; DBG_RTF(t << "{\\comment Begin SubSection}\n") - t << Rtf_Style_Reset; - t << Rtf_Style["Heading3"]->reference << "\n"; + t << rtf_Style_Reset; + t << rtf_Style["Heading3"]->reference << "\n"; } void RTFGenerator::endSubsection() { newParagraph(); - t << Rtf_Style_Reset << endl; + t << rtf_Style_Reset << endl; } void RTFGenerator::startSubsubsection() @@ -1642,7 +1079,7 @@ void RTFGenerator::startSubsubsection() t << "\n"; DBG_RTF(t << "{\\comment Begin SubSubSection}\n") t << "{" << endl; - t << Rtf_Style_Reset << Rtf_Style["Heading4"]->reference << "\n"; + t << rtf_Style_Reset << rtf_Style["Heading4"]->reference << "\n"; } void RTFGenerator::endSubsubsection() @@ -1735,7 +1172,7 @@ void RTFGenerator::startTextLink(const char *f,const char *anchor) } t << "{\\field {\\*\\fldinst { HYPERLINK \\\\l \""; - t << formatBmkStr(ref); + t << rtfFormatBmkStr(ref); t << "\" }{}"; t << "}{\\fldrslt {\\cs37\\ul\\cf2 "; } @@ -1766,7 +1203,7 @@ void RTFGenerator::writeObjectLink(const char *ref, const char *f, } t << "{\\field {\\*\\fldinst { HYPERLINK \\\\l \""; - t << formatBmkStr(refName); + t << rtfFormatBmkStr(refName); t << "\" }{}"; t << "}{\\fldrslt {\\cs37\\ul\\cf2 "; @@ -1800,7 +1237,7 @@ void RTFGenerator::endPageRef(const char *clname, const char *anchor) ref+='_'; ref+=anchor; } - WriteRTFReference(ref); + writeRTFReference(ref); endEmphasis(); t << ")"; } @@ -1822,7 +1259,7 @@ void RTFGenerator::writeCodeLink(const char *ref,const char *f, } t << "{\\field {\\*\\fldinst { HYPERLINK \\\\l \""; - t << formatBmkStr(refName); + t << rtfFormatBmkStr(refName); t << "\" }{}"; t << "}{\\fldrslt {\\cs37\\ul\\cf2 "; @@ -1841,13 +1278,13 @@ void RTFGenerator::startTitleHead(const char *) DBG_RTF(t <<"{\\comment startTitleHead}" << endl) // beginRTFSection(); - t << Rtf_Style_Reset << Rtf_Style["Heading2"]->reference << endl; + t << rtf_Style_Reset << rtf_Style["Heading2"]->reference << endl; } void RTFGenerator::endTitleHead(const char *fileName,const char *name) { DBG_RTF(t <<"{\\comment endTitleHead}" << endl) - t << "\\par " << Rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << endl; if (name) { // make table of contents entry @@ -1883,8 +1320,8 @@ void RTFGenerator::startGroupHeader() { DBG_RTF(t <<"{\\comment startGroupHeader}" << endl) newParagraph(); - t << Rtf_Style_Reset; - t << Rtf_Style["Heading3"]->reference; + t << rtf_Style_Reset; + t << rtf_Style["Heading3"]->reference; t << endl; } @@ -1892,7 +1329,7 @@ void RTFGenerator::endGroupHeader() { DBG_RTF(t <<"{\\comment endGroupHeader}" << endl) newParagraph(); - t << Rtf_Style_Reset << endl; + t << rtf_Style_Reset << endl; } void RTFGenerator::startMemberDoc(const char *clname, @@ -1906,10 +1343,10 @@ void RTFGenerator::startMemberDoc(const char *clname, addIndexItem(memname,clname); addIndexItem(clname,memname); } - t << Rtf_Style_Reset << Rtf_Style["Heading4"]->reference; - //styleStack.push(Rtf_Style_Heading4); + t << rtf_Style_Reset << rtf_Style["Heading4"]->reference; + //styleStack.push(rtf_Style_Heading4); t << "{" << endl; - //printf("RTFGenerator::startMemberDoc() `%s'\n",Rtf_Style["Heading4"]->reference); + //printf("RTFGenerator::startMemberDoc() `%s'\n",rtf_Style["Heading4"]->reference); startBold(); t << endl; } @@ -1920,7 +1357,7 @@ void RTFGenerator::endMemberDoc() t << "}" << endl; //const char *style = styleStack.pop(); //printf("RTFGenerator::endMemberDoc() `%s'\n",style); - //ASSERT(style==Rtf_Style["Heading4"]->reference); + //ASSERT(style==rtf_Style["Heading4"]->reference); endBold(); newParagraph(); } @@ -1946,10 +1383,10 @@ void RTFGenerator::endDoxyAnchor(const char *fName,const char *anchor) DBG_RTF(t << "{\\comment endDoxyAnchor}" << endl) t << "{\\bkmkstart "; - t << formatBmkStr(ref); + t << rtfFormatBmkStr(ref); t << "}" << endl; t << "{\\bkmkend "; - t << formatBmkStr(ref); + t << rtfFormatBmkStr(ref); t << "}" << endl; } @@ -1979,13 +1416,13 @@ void RTFGenerator::startIndent() incrementIndentLevel(); DBG_RTF(t << "{\\comment (startIndent) }" << endl) t << "{" << endl; - t << Rtf_Style_Reset << Rtf_CList_DepthStyle() << endl; + t << rtf_Style_Reset << rtf_CList_DepthStyle() << endl; //styleStack.push(style); } void RTFGenerator::endIndent() { - //const char *style = /* Rtf_CList_DepthStyle(); */ + //const char *style = /* rtf_CList_DepthStyle(); */ t << "}" << endl; decrementIndentLevel(); } @@ -1995,7 +1432,7 @@ void RTFGenerator::startDescription() { DBG_RTF(t << "{\\comment (startDescription)}" << endl) t << "{" << endl; - t << Rtf_Style_Reset << Rtf_CList_DepthStyle(); + t << rtf_Style_Reset << rtf_CList_DepthStyle(); } void RTFGenerator::endDescription() @@ -2024,7 +1461,7 @@ void RTFGenerator::startMemberDescription() DBG_RTF(t << "{\\comment (startMemberDescription)}" << endl) t << "{" << endl; incrementIndentLevel(); - t << Rtf_Style_Reset << Rtf_CList_DepthStyle(); + t << rtf_Style_Reset << rtf_CList_DepthStyle(); startEmphasis(); } @@ -2053,7 +1490,7 @@ void RTFGenerator::endDescTitle() t << "}"; newParagraph(); incrementIndentLevel(); - t << Rtf_Style_Reset << Rtf_DList_DepthStyle(); + t << rtf_Style_Reset << rtf_DList_DepthStyle(); } void RTFGenerator::writeDescItem() @@ -2075,7 +1512,7 @@ void RTFGenerator::startSection(const char *,const char *title,SectionInfo::Sect { DBG_RTF(t << "{\\comment (startSection)}" << endl) t << "{"; - t<< Rtf_Style_Reset; + t<< rtf_Style_Reset; int num=4; switch(type) { @@ -2087,7 +1524,7 @@ void RTFGenerator::startSection(const char *,const char *title,SectionInfo::Sect QCString heading; heading.sprintf("Heading%d",num); // set style - t << Rtf_Style[heading]->reference; + t << rtf_Style[heading]->reference; // make table of contents entry t << "{\\tc\\tcl" << num << " \\v "; docify(title); @@ -2117,7 +1554,7 @@ void RTFGenerator::writeSectionRef(const char *ref,const char *, endBold(); t << " ("; docify(theTranslator->trPageAbbreviation()); - WriteRTFReference(lab); + writeRTFReference(lab); t << ")" << endl; } } @@ -2127,7 +1564,7 @@ void RTFGenerator::writeSectionRefItem(const char *,const char *lab, { docify(title); t << "\\tab"; - WriteRTFReference(lab); + writeRTFReference(lab); t << endl; } @@ -2258,7 +1695,7 @@ void RTFGenerator::endClassDiagram(ClassDiagram &d, // display the file t << "{" << endl; - t << Rtf_Style_Reset << endl; + t << rtf_Style_Reset << endl; t << "\\par\\pard \\qc {\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE "; t << fileName << ".png"; t << " \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par" << endl; @@ -2273,7 +1710,7 @@ void RTFGenerator::writeFormula(const char *,const char *text) void RTFGenerator::startMemberItem(int) { DBG_RTF(t <<"{\\comment startMemberItem }" << endl) - t << Rtf_Style_Reset << Rtf_BList_DepthStyle() << endl; // set style to apropriate depth + t << rtf_Style_Reset << rtf_BList_DepthStyle() << endl; // set style to apropriate depth } void RTFGenerator::endMemberItem(bool) @@ -2299,14 +1736,14 @@ void RTFGenerator::writeAnchor(const char *fileName,const char *name) } DBG_RTF(t <<"{\\comment writeAncheor (" << anchor << ")}" << endl) - t << "{\\bkmkstart " << formatBmkStr(anchor) << "}" << endl; - t << "{\\bkmkend " << formatBmkStr(anchor) << "}" << endl; + t << "{\\bkmkstart " << rtfFormatBmkStr(anchor) << "}" << endl; + t << "{\\bkmkend " << rtfFormatBmkStr(anchor) << "}" << endl; } -void RTFGenerator::WriteRTFReference(const char *label) +void RTFGenerator::writeRTFReference(const char *label) { t << "{\\field\\fldedit {\\*\\fldinst PAGEREF "; - t << formatBmkStr(label); + t << rtfFormatBmkStr(label); t << " \\\\*MERGEFORMAT}{\\fldrslt pagenum}}"; } @@ -2314,8 +1751,8 @@ void RTFGenerator::startCodeFragment() { t << "{" << endl; newParagraph(); - t << Rtf_Style_Reset << Rtf_Code_DepthStyle(); - //styleStack.push(Rtf_Style_CodeExample); + t << rtf_Style_Reset << rtf_Code_DepthStyle(); + //styleStack.push(rtf_Style_CodeExample); } void RTFGenerator::endCodeFragment() @@ -2323,7 +1760,7 @@ void RTFGenerator::endCodeFragment() newParagraph(); //styleStack.pop(); //printf("RTFGenerator::endCodeFrament() top=%s\n",styleStack.top()); - //t << Rtf_Style_Reset << styleStack.top() << endl; + //t << rtf_Style_Reset << styleStack.top() << endl; DBG_RTF(t << "{\\comment (endCodeFragment) }" << endl) t << "}" << endl; m_omitParagraph = TRUE; @@ -2360,7 +1797,7 @@ void RTFGenerator::startImage(const char *name,const char *,bool) { newParagraph(); t << "{" << endl; - t << Rtf_Style_Reset << endl; + t << rtf_Style_Reset << endl; t << "\\par\\pard \\qc {\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE "; t << name; t << " \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par" << endl; @@ -2384,7 +1821,7 @@ void RTFGenerator::startDotFile(const char *name,bool) writeDotGraphFromFile(name,outDir,baseName,BITMAP); newParagraph(); t << "{" << endl; - t << Rtf_Style_Reset << endl; + t << rtf_Style_Reset << endl; t << "\\par\\pard \\qc {\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE "; t << outDir << "\\" << baseName; t << " \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par" << endl; @@ -2401,7 +1838,7 @@ void RTFGenerator::startDescTable() DBG_RTF(t << "{\\comment (startDescTable) }" << endl) //t << "{" << endl; //incrementIndentLevel(); - //t << Rtf_Style_Reset << Rtf_CList_DepthStyle(); + //t << rtf_Style_Reset << rtf_CList_DepthStyle(); } void RTFGenerator::endDescTable() @@ -2409,12 +1846,12 @@ void RTFGenerator::endDescTable() //decrementIndentLevel(); DBG_RTF(t << "{\\comment (endDescTable)}" << endl) //t << "}" << endl; - //t << Rtf_Style_Reset << styleStack.top(); + //t << rtf_Style_Reset << styleStack.top(); } void RTFGenerator::startDescTableTitle() { - //t << Rtf_BList_DepthStyle() << endl; + //t << rtf_BList_DepthStyle() << endl; DBG_RTF(t << "{\\comment (startDescTableTitle) }" << endl) startBold(); startEmphasis(); @@ -2464,57 +1901,57 @@ void RTFGenerator::decrementIndentLevel() } // a style for list formatted with "list continue" style -const char * RTFGenerator::Rtf_CList_DepthStyle() +const char * RTFGenerator::rtf_CList_DepthStyle() { QCString n=makeIndexName("ListContinue",m_listLevel); - return Rtf_Style[n]->reference; + return rtf_Style[n]->reference; } // a style for list formatted as a "latext style" table of contents -const char * RTFGenerator::Rtf_LCList_DepthStyle() +const char * RTFGenerator::rtf_LCList_DepthStyle() { QCString n=makeIndexName("LatexTOC",m_listLevel); - return Rtf_Style[n]->reference; + return rtf_Style[n]->reference; } // a style for list formatted as a "bullet" style -const char * RTFGenerator::Rtf_BList_DepthStyle() +const char * RTFGenerator::rtf_BList_DepthStyle() { QCString n=makeIndexName("ListBullet",m_listLevel); - return Rtf_Style[n]->reference; + return rtf_Style[n]->reference; } // a style for list formatted as a "enumeration" style -const char * RTFGenerator::Rtf_EList_DepthStyle() +const char * RTFGenerator::rtf_EList_DepthStyle() { QCString n=makeIndexName("ListEnum",m_listLevel); - return Rtf_Style[n]->reference; + return rtf_Style[n]->reference; } -const char * RTFGenerator::Rtf_DList_DepthStyle() +const char * RTFGenerator::rtf_DList_DepthStyle() { QCString n=makeIndexName("DescContinue",m_listLevel); - return Rtf_Style[n]->reference; + return rtf_Style[n]->reference; } -const char * RTFGenerator::Rtf_Code_DepthStyle() +const char * RTFGenerator::rtf_Code_DepthStyle() { QCString n=makeIndexName("CodeExample",m_listLevel); - return Rtf_Style[n]->reference; + return rtf_Style[n]->reference; } void RTFGenerator::startTextBlock(bool dense) { DBG_RTF(t << "{\\comment startTextBlock}" << endl) t << "{" << endl; - t << Rtf_Style_Reset; + t << rtf_Style_Reset; if (dense) // no spacing between "paragraphs" { - t << Rtf_Style["DenseText"]->reference; + t << rtf_Style["DenseText"]->reference; } else // some spacing { - t << Rtf_Style["BodyText"]->reference; + t << rtf_Style["BodyText"]->reference; } } @@ -2537,7 +1974,7 @@ void RTFGenerator::startMemberSubtitle() { DBG_RTF(t << "{\\comment startMemberSubtitle}" << endl) t << "{" << endl; - t << Rtf_Style_Reset << Rtf_CList_DepthStyle() << endl; + t << rtf_Style_Reset << rtf_CList_DepthStyle() << endl; } void RTFGenerator::endMemberSubtitle() @@ -2742,7 +2179,7 @@ void RTFGenerator::endDotGraph(DotClassGraph &g) // display the file t << "{" << endl; - t << Rtf_Style_Reset << endl; + t << rtf_Style_Reset << endl; t << "\\par\\pard \\qc {\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE "; t << fileName << "." << Config_getEnum("DOT_IMAGE_FORMAT"); t << " \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par" << endl; @@ -2761,7 +2198,7 @@ void RTFGenerator::endInclDepGraph(DotInclDepGraph &g) // display the file t << "{" << endl; - t << Rtf_Style_Reset << endl; + t << rtf_Style_Reset << endl; t << "\\par\\pard \\qc {\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE "; t << fileName << "." << Config_getEnum("DOT_IMAGE_FORMAT"); t << " \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par" << endl; @@ -2870,14 +2307,14 @@ void RTFGenerator::startMemberGroupHeader(bool hasHeader) DBG_RTF(t << "{\\comment startMemberGroupHeader}" << endl) t << "{" << endl; if (hasHeader) incrementIndentLevel(); - t << Rtf_Style_Reset << Rtf_Style["GroupHeader"]->reference; + t << rtf_Style_Reset << rtf_Style["GroupHeader"]->reference; } void RTFGenerator::endMemberGroupHeader() { DBG_RTF(t << "{\\comment endMemberGroupHeader}" << endl) newParagraph(); - t << Rtf_Style_Reset << Rtf_CList_DepthStyle(); + t << rtf_Style_Reset << rtf_CList_DepthStyle(); } void RTFGenerator::startMemberGroupDocs() @@ -2896,7 +2333,7 @@ void RTFGenerator::endMemberGroupDocs() void RTFGenerator::startMemberGroup() { DBG_RTF(t << "{\\comment startMemberGroup}" << endl) - t << Rtf_Style_Reset << Rtf_BList_DepthStyle() << endl; + t << rtf_Style_Reset << rtf_BList_DepthStyle() << endl; } void RTFGenerator::endMemberGroup(bool hasHeader) @@ -2925,7 +2362,7 @@ void RTFGenerator::startSimpleSect(SectionTypes,const char *file,const char *anc t << "}"; newParagraph(); incrementIndentLevel(); - t << Rtf_Style_Reset << Rtf_DList_DepthStyle(); + t << rtf_Style_Reset << rtf_DList_DepthStyle(); } void RTFGenerator::endSimpleSect() @@ -2949,7 +2386,7 @@ void RTFGenerator::startParamList(ParamListTypes,const char *title) t << "}"; newParagraph(); incrementIndentLevel(); - t << Rtf_Style_Reset << Rtf_DList_DepthStyle(); + t << rtf_Style_Reset << rtf_DList_DepthStyle(); } void RTFGenerator::endParamList() diff --git a/src/rtfgen.h b/src/rtfgen.h index 54dca5d..221135e 100644 --- a/src/rtfgen.h +++ b/src/rtfgen.h @@ -107,7 +107,7 @@ class RTFGenerator : public OutputGenerator //void memberGroupSeparator() {} void insertMemberAlign() {} - void writeRuler(){RtfwriteRuler_thin();}; + void writeRuler() { rtfwriteRuler_thin(); } void writeAnchor(const char *fileName,const char *name); void startCodeFragment(); @@ -262,12 +262,12 @@ class RTFGenerator : public OutputGenerator RTFGenerator(const RTFGenerator &); RTFGenerator &operator=(const RTFGenerator &); - const char *Rtf_BList_DepthStyle(); - const char *Rtf_CList_DepthStyle(); - const char *Rtf_EList_DepthStyle(); - const char *Rtf_LCList_DepthStyle(); - const char *Rtf_DList_DepthStyle(); - const char *Rtf_Code_DepthStyle(); + const char *rtf_BList_DepthStyle(); + const char *rtf_CList_DepthStyle(); + const char *rtf_EList_DepthStyle(); + const char *rtf_LCList_DepthStyle(); + const char *rtf_DList_DepthStyle(); + const char *rtf_Code_DepthStyle(); void incrementIndentLevel(); void decrementIndentLevel(); int col; @@ -280,11 +280,11 @@ class RTFGenerator : public OutputGenerator void beginRTFDocument(); void beginRTFChapter(); void beginRTFSection(); - void RtfwriteRuler_doubleline() { t << "{\\pard\\widctlpar\\brdrb\\brdrdb\\brdrw15\\brsp20 \\adjustright \\par}" << endl; }; - void RtfwriteRuler_emboss() { t << "{\\pard\\widctlpar\\brdrb\\brdremboss\\brdrw15\\brsp20 \\adjustright \\par}" << endl; }; - void RtfwriteRuler_thick() { t << "{\\pard\\widctlpar\\brdrb\\brdrs\\brdrw75\\brsp20 \\adjustright \\par}" << endl; }; - void RtfwriteRuler_thin() { t << "{\\pard\\widctlpar\\brdrb\\brdrs\\brdrw5\\brsp20 \\adjustright \\par}" << endl; }; - void WriteRTFReference(const char *label); + void rtfwriteRuler_doubleline() { t << "{\\pard\\widctlpar\\brdrb\\brdrdb\\brdrw15\\brsp20 \\adjustright \\par}" << endl; }; + void rtfwriteRuler_emboss() { t << "{\\pard\\widctlpar\\brdrb\\brdremboss\\brdrw15\\brsp20 \\adjustright \\par}" << endl; }; + void rtfwriteRuler_thick() { t << "{\\pard\\widctlpar\\brdrb\\brdrs\\brdrw75\\brsp20 \\adjustright \\par}" << endl; }; + void rtfwriteRuler_thin() { t << "{\\pard\\widctlpar\\brdrb\\brdrs\\brdrw5\\brsp20 \\adjustright \\par}" << endl; }; + void writeRTFReference(const char *label); char *getMultiByte(int c); }; diff --git a/src/rtfstyle.cpp b/src/rtfstyle.cpp new file mode 100644 index 0000000..017bdaf --- /dev/null +++ b/src/rtfstyle.cpp @@ -0,0 +1,518 @@ +/****************************************************************************** + * + * + * + * + * Copyright (C) 1997-2002 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + * Documents produced by Doxygen are derivative works derived from the + * input used in their production; they are not affected by this license. + * + */ + +#include "rtfstyle.h" + +#include <qfile.h> +#include <qtextstream.h> +#include <stdlib.h> + +#include "message.h" + + +RTFListItemInfo listItemInfo[indentLevels]; + +QCString rtf_title; +QCString rtf_subject; +QCString rtf_comments; +QCString rtf_company; +QCString rtf_logoFilename; +QCString rtf_author; +QCString rtf_manager; +QCString rtf_documentType; +QCString rtf_documentId; +QCString rtf_keywords; + +char rtf_Style_Reset[] = "\\pard\\plain "; + +Rtf_Style_Default rtf_Style_Default[] = +{ + { "Heading1", + "\\s1\\sb240\\sa60\\keepn\\widctlpar\\adjustright \\b\\f1\\fs36\\kerning36\\cgrid ", + "\\sbasedon0 \\snext0 heading 1" + }, + { "Heading2", + "\\s2\\sb240\\sa60\\keepn\\widctlpar\\adjustright \\b\\f1\\fs28\\kerning28\\cgrid ", + "\\sbasedon0 \\snext0 heading 2" + }, + { "Heading3", + "\\s3\\sb240\\sa60\\keepn\\widctlpar\\adjustright \\b\\f1\\cgrid ", + "\\sbasedon0 \\snext0 heading 3" + }, + { "Heading4", + "\\s4\\sb240\\sa60\\keepn\\widctlpar\\adjustright \\b\\f1\\fs20\\cgrid ", + "\\sbasedon0 \\snext0 heading 4;}{\\*\\cs10 \\additive Default Paragraph Font" + }, + { "Title", + "\\s15\\qc\\sb240\\sa60\\widctlpar\\outlinelevel0\\adjustright \\b\\f1\\fs32\\kerning28\\cgrid ", + "\\sbasedon0 \\snext15 Title" + }, + { "SubTitle", + "\\s16\\qc\\sa60\\widctlpar\\outlinelevel1\\adjustright \\f1\\cgrid ", + "\\sbasedon0 \\snext16 Subtitle" + }, + { "BodyText", + "\\s17\\sa60\\sb30\\widctlpar\\qj \\fs22\\cgrid ", + "\\sbasedon0 \\snext17 BodyText" + }, + { "DenseText", + "\\s18\\widctlpar\\fs22\\cgrid ", + "\\sbasedon0 \\snext18 DenseText" + }, + { "Header", + "\\s28\\widctlpar\\tqc\\tx4320\\tqr\\tx8640\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext28 header" + }, + { "Footer", + "\\s29\\widctlpar\\tqc\\tx4320\\tqr\\tx8640\\qr\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext29 footer" + }, + { "GroupHeader", + "\\s30\\li360\\sa60\\sb120\\keepn\\widctlpar\\adjustright \\b\\f1\\fs20\\cgrid ", + "\\sbasedon0 \\snext30 GroupHeader" + }, + { "CodeExample0", + "\\s40\\li0\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ", + "\\sbasedon0 \\snext41 Code Example 0" + }, + { "CodeExample1", + "\\s41\\li360\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ", + "\\sbasedon0 \\snext42 Code Example 1" + }, + { "CodeExample2", + "\\s42\\li720\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ", + "\\sbasedon0 \\snext43 Code Example 2" + }, + { "CodeExample3", + "\\s43\\li1080\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ", + "\\sbasedon0 \\snext44 Code Example 3" + }, + { "CodeExample4", + "\\s44\\li1440\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ", + "\\sbasedon0 \\snext45 Code Example 4" + }, + { "CodeExample5", + "\\s45\\li1800\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ", + "\\sbasedon0 \\snext46 Code Example 5" + }, + { "CodeExample6", + "\\s46\\li2160\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ", + "\\sbasedon0 \\snext47 Code Example 6" + }, + { "CodeExample7", + "\\s47\\li2520\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ", + "\\sbasedon0 \\snext48 Code Example 7" + }, + { "CodeExample8", + "\\s48\\li2880\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ", + "\\sbasedon0 \\snext49 Code Example 8" + }, + { "CodeExample9", + "\\s49\\li3240\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ", + "\\sbasedon0 \\snext49 Code Example 9" + }, + { "ListContinue0", + "\\s50\\li0\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext51 List Continue 0" + }, + { "ListContinue1", + "\\s51\\li360\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext52 List Continue 1" + }, + { "ListContinue2", + "\\s52\\li720\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext53 List Continue 2" + }, + { "ListContinue3", + "\\s53\\li1080\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext54 List Continue 3" + }, + { "ListContinue4", + "\\s54\\li1440\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext55 List Continue 4" + }, + { "ListContinue5", + "\\s55\\li1800\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext56 List Continue 5" + }, + { "ListContinue6", + "\\s56\\li2160\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext57 List Continue 6" + }, + { "ListContinue7", + "\\s57\\li2520\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext58 List Continue 7" + }, + { "ListContinue8", + "\\s58\\li2880\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext59 List Continue 8" + }, + { "ListContinue9", + "\\s59\\li3240\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext59 List Continue 9" + }, + { "DescContinue0", + "\\s60\\li0\\widctlpar\\ql\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext61 DescContinue 0" + }, + { "DescContinue1", + "\\s61\\li360\\widctlpar\\ql\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext62 DescContinue 1" + }, + { "DescContinue2", + "\\s62\\li720\\widctlpar\\ql\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext63 DescContinue 2" + }, + { "DescContinue3", + "\\s63\\li1080\\widctlpar\\ql\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext64 DescContinue 3" + }, + { "DescContinue4", + "\\s64\\li1440\\widctlpar\\ql\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext65 DescContinue 4" + }, + { "DescContinue5", + "\\s65\\li1800\\widctlpar\\ql\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext66 DescContinue 5" + }, + { "DescContinue6", + "\\s66\\li2160\\widctlpar\\ql\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext67 DescContinue 6" + }, + { "DescContinue7", + "\\s67\\li2520\\widctlpar\\ql\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext68 DescContinue 7" + }, + { "DescContinue8", + "\\s68\\li2880\\widctlpar\\ql\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext69 DescContinue 8" + }, + { "DescContinue9", + "\\s69\\li3240\\widctlpar\\ql\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext69 DescContinue 9" + }, + { "LatexTOC0", + "\\s70\\li0\\sa30\\sb30\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext81 LatexTOC 0" + }, + { "LatexTOC1", + "\\s71\\li360\\sa27\\sb27\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext82 LatexTOC 1" + }, + { "LatexTOC2", + "\\s72\\li720\\sa24\\sb24\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext83 LatexTOC 2" + }, + { "LatexTOC3", + "\\s73\\li1080\\sa21\\sb21\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext84 LatexTOC 3" + }, + { "LatexTOC4", + "\\s74\\li1440\\sa18\\sb18\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext85 LatexTOC 4" + }, + { "LatexTOC5", + "\\s75\\li1800\\sa15\\sb15\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext86 LatexTOC 5" + }, + { "LatexTOC6", + "\\s76\\li2160\\sa12\\sb12\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext87 LatexTOC 6" + }, + { "LatexTOC7", + "\\s77\\li2520\\sa9\\sb9\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext88 LatexTOC 7" + }, + { "LatexTOC8", + "\\s78\\li2880\\sa6\\sb6\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext89 LatexTOC 8" + }, + { "LatexTOC9", + "\\s79\\li3240\\sa3\\sb3\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext89 LatexTOC 9" + }, + { "ListBullet0", + "\\s80\\fi-360\\li360\\widctlpar\\jclisttab\\tx360{\\*\\pn \\pnlvlbody\\ilvl0\\ls1\\pnrnot0\\pndec }\\ls1\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext81 \\sautoupd List Bullet 0" + }, + { "ListBullet1", + "\\s81\\fi-360\\li720\\widctlpar\\jclisttab\\tx720{\\*\\pn \\pnlvlbody\\ilvl0\\ls2\\pnrnot0\\pndec }\\ls2\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext82 \\sautoupd List Bullet 1" + }, + { "ListBullet2", + "\\s82\\fi-360\\li1080\\widctlpar\\jclisttab\\tx1080{\\*\\pn \\pnlvlbody\\ilvl0\\ls3\\pnrnot0\\pndec }\\ls3\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext83 \\sautoupd List Bullet 2" + }, + { "ListBullet3", + "\\s83\\fi-360\\li1440\\widctlpar\\jclisttab\\tx1440{\\*\\pn \\pnlvlbody\\ilvl0\\ls4\\pnrnot0\\pndec }\\ls4\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext84 \\sautoupd List Bullet 3" + }, + { "ListBullet4", + "\\s84\\fi-360\\li1800\\widctlpar\\jclisttab\\tx1800{\\*\\pn \\pnlvlbody\\ilvl0\\ls5\\pnrnot0\\pndec }\\ls5\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext85 \\sautoupd List Bullet 4" + }, + { "ListBullet5", + "\\s85\\fi-360\\li2160\\widctlpar\\jclisttab\\tx2160{\\*\\pn \\pnlvlbody\\ilvl0\\ls6\\pnrnot0\\pndec }\\ls6\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext86 \\sautoupd List Bullet 5" + }, + { "ListBullet6", + "\\s86\\fi-360\\li2520\\widctlpar\\jclisttab\\tx2520{\\*\\pn \\pnlvlbody\\ilvl0\\ls7\\pnrnot0\\pndec }\\ls7\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext87 \\sautoupd List Bullet 6" + }, + { "ListBullet7", + "\\s87\\fi-360\\li2880\\widctlpar\\jclisttab\\tx2880{\\*\\pn \\pnlvlbody\\ilvl0\\ls8\\pnrnot0\\pndec }\\ls8\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext88 \\sautoupd List Bullet 7" + }, + { "ListBullet8", + "\\s88\\fi-360\\li3240\\widctlpar\\jclisttab\\tx3240{\\*\\pn \\pnlvlbody\\ilvl0\\ls9\\pnrnot0\\pndec }\\ls9\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext89 \\sautoupd List Bullet 8" + }, + { "ListBullet9", + "\\s89\\fi-360\\li3600\\widctlpar\\jclisttab\\tx3600{\\*\\pn \\pnlvlbody\\ilvl0\\ls10\\pnrnot0\\pndec }\\ls10\\adjustright \\fs20\\cgrid ", + "\\sbasedon0 \\snext89 \\sautoupd List Bullet 9" + }, + { "ListEnum0", + "\\s90\\fi-360\\li360\\widctlpar\\fs20\\cgrid ", + "\\sbasedon0 \\snext91 \\sautoupd List Enum 0" + }, + { "ListEnum1", + "\\s91\\fi-360\\li720\\widctlpar\\fs20\\cgrid ", + "\\sbasedon0 \\snext92 \\sautoupd List Enum 1" + }, + { "ListEnum2", + "\\s92\\fi-360\\li1080\\widctlpar\\fs20\\cgrid ", + "\\sbasedon0 \\snext93 \\sautoupd List Enum 2" + }, + { "ListEnum3", + "\\s93\\fi-360\\li1440\\widctlpar\\fs20\\cgrid ", + "\\sbasedon0 \\snext94 \\sautoupd List Enum 3" + }, + { "ListEnum4", + "\\s94\\fi-360\\li1800\\widctlpar\\fs20\\cgrid ", + "\\sbasedon0 \\snext95 \\sautoupd List Enum 4" + }, + { "ListEnum5", + "\\s95\\fi-360\\li2160\\widctlpar\\fs20\\cgrid ", + "\\sbasedon0 \\snext96 \\sautoupd List Enum 5" + }, + { "ListEnum6", + "\\s96\\fi-360\\li2520\\widctlpar\\fs20\\cgrid ", + "\\sbasedon0 \\snext96 \\sautoupd List Enum 5" + }, + { "ListEnum7", + "\\s97\\fi-360\\li2880\\widctlpar\\fs20\\cgrid ", + "\\sbasedon0 \\snext98 \\sautoupd List Enum 7" + }, + { "ListEnum8", + "\\s98\\fi-360\\li3240\\widctlpar\\fs20\\cgrid ", + "\\sbasedon0 \\snext99 \\sautoupd List Enum 8" + }, + { "ListEnum9", + "\\s99\\fi-360\\li3600\\widctlpar\\fs20\\cgrid ", + "\\sbasedon0 \\snext99 \\sautoupd List Enum 9" + }, + { 0, + 0, + 0 + } +}; + +const QRegExp StyleData::s_clause("\\\\s[0-9]+\\s*"); + +StyleData::StyleData(const char* reference, const char* definition) +{ + int start = s_clause.match(reference); ASSERT(start >= 0); + reference += start; + index = (int)atol(reference + 2); ASSERT(index > 0); + + ASSERT(reference != 0); + size_t size = 1 + strlen(reference); + memcpy(this->reference = new char[size], reference, size); + + ASSERT(definition != 0); + size = 1 + strlen(definition); + memcpy(this->definition = new char[size], definition, size); +} + +StyleData::~StyleData() +{ + delete[] reference; + delete[] definition; +} + +bool StyleData::setStyle(const char* s, const char* styleName) +{ + static const QRegExp subgroup("^{[^}]*}\\s*"); + static const QRegExp any_clause("^\\\\[a-z][a-z0-9-]*\\s*"); + + int len = 0; // length of a particular RTF formatting control + int ref_len = 0; // length of the whole formatting section of a style + int start = s_clause.match(s, 0, &len); + if (start < 0) + { + err("Style sheet '%s' contains no '\\s' clause.\n{%s}\n", styleName, s); + return FALSE; + } + s += start; + index = (int)atol(s + 2); ASSERT(index > 0); + + // search for the end of pure formatting codes + const char* end = s + len; + ref_len = len; + bool haveNewDefinition = TRUE; + for(;;) + { + if (*end == '{') + { + // subgroups are used for \\additive + if (0 != subgroup.match(end, 0, &len)) + break; + else + { + end += len; + ref_len += len; + } + } + else if (*end == '\\') + { + if (0 == strncmp(end, "\\snext", 6)) + break; + if (0 == strncmp(end, "\\sbasedon", 9)) + break; + if (0 != any_clause.match(end, 0, &len)) + break; + end += len; + ref_len += len; + } + else if (*end == 0) + { // no style-definition part, keep default value + haveNewDefinition = FALSE; + break; + } + else // plain name without leading \\snext + break; + } + delete[] reference; + reference = new char[ref_len + 1]; + memcpy(reference, s, ref_len); + reference[ref_len] = 0; + if (haveNewDefinition) + { + delete[] definition; + size_t size = 1 + strlen(end); + definition = new char[size]; + memcpy(definition, end, size); + } + return TRUE; +} + +void loadStylesheet(const char *name, QDict<StyleData>& dict) +{ + QFile file(name); + if (!file.open(IO_ReadOnly)) + { + err("Can't open RTF style sheet file %s. Using defaults.\n",name); + return; + } + msg("Loading RTF style sheet %s...\n",name); + + static const QRegExp separator("[ \t]*=[ \t]*"); + uint lineNr=1; + QTextStream t(&file); +#if QT_VERSION >= 200 + t.setEncoding(QTextStream::Latin1); +#endif + + while (!t.eof()) + { + QCString s(4096); // string buffer of max line length + s = t.readLine().stripWhiteSpace(); + if (s.length()==0 || s.at(0)=='#') continue; // skip blanks & comments + int sepLength; + int sepStart = separator.match(s,0,&sepLength); + if (sepStart<=0) // no valid assignment statement + { + warn(name,lineNr,"Assignment of style sheet name expected!\n"); + continue; + } + QCString key=s.left(sepStart); + if (dict[key]==0) // not a valid style sheet name + { + warn(name,lineNr,"Invalid style sheet name %s ignored.\n",key.data()); + continue; + } + StyleData* styleData = dict.find(key); + if (styleData == 0) + { + warn(name,lineNr,"Unknown style sheet name %s ignored.\n",key.data()); + continue; + } + s+=" "; // add command separator + styleData->setStyle(s.data() + sepStart + sepLength, key.data()); + lineNr++; + } +} + +QDict<StyleData> rtf_Style(257); + +void loadExtensions(const char *name) +{ + QFile file(name); + if (!file.open(IO_ReadOnly)) + { + err("Can't open RTF extensions file %s. Using defaults.\n",name); + return; + } + msg("Loading RTF extensions %s...\n",name); + + static const QRegExp separator("[ \t]*=[ \t]*"); + uint lineNr=1; + QTextStream t(&file); +#if QT_VERSION >= 200 + t.setEncoding(QTextStream::Latin1); +#endif + + while (!t.eof()) + { + QCString s(4096); // string buffer of max line length + s = t.readLine().stripWhiteSpace(); + if (s.length()==0 || s.at(0)=='#') continue; // skip blanks & comments + int sepLength; + int sepStart = separator.match(s,0,&sepLength); + if (sepStart<=0) // no valid assignment statement + { + warn(name,lineNr,"Assignment of extension field expected!\n"); + continue; + } + QCString key=s.left(sepStart); + QCString data=s.data() + sepStart + sepLength; + + if (key == "Title") rtf_title = data.data(); + if (key == "Subject") rtf_subject = data.data(); + if (key == "Comments") rtf_comments = data.data(); + if (key == "Company") rtf_company = data.data(); + if (key == "LogoFilename") rtf_logoFilename = data.data(); + if (key == "Author") rtf_author = data.data(); + if (key == "Manager") rtf_manager = data.data(); + if (key == "DocumentType") rtf_documentType = data.data(); + if (key == "DocumentId") rtf_documentId = data.data(); + if (key == "Keywords") rtf_keywords = data.data(); + lineNr++; + } +} + diff --git a/src/rtfstyle.h b/src/rtfstyle.h new file mode 100644 index 0000000..1fe353c --- /dev/null +++ b/src/rtfstyle.h @@ -0,0 +1,80 @@ +/****************************************************************************** + * + * + * + * + * Copyright (C) 1997-2002 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + * Documents produced by Doxygen are derivative works derived from the + * input used in their production; they are not affected by this license. + * + */ + +#ifndef RTFSTYLE_H +#define RTFSTYLE_H + +#include "qtbc.h" +#include <qregexp.h> +#include <qdict.h> + +extern QCString rtf_title; +extern QCString rtf_subject; +extern QCString rtf_comments; +extern QCString rtf_company; +extern QCString rtf_logoFilename; +extern QCString rtf_author; +extern QCString rtf_manager; +extern QCString rtf_documentType; +extern QCString rtf_documentId; +extern QCString rtf_keywords; + +struct RTFListItemInfo +{ + bool isEnum; + int number; +}; + +const int indentLevels = 10; + +extern RTFListItemInfo listItemInfo[indentLevels]; + +struct Rtf_Style_Default +{ + const char *name; + const char *reference; + const char *definition; +}; + +extern char rtf_Style_Reset[]; +extern Rtf_Style_Default rtf_Style_Default[]; + +struct StyleData +{ + // elements of this type are stored in dictionary Rtf_Style + // + // to define a tag in the header reference + definition is required + // to use a tag in the body of the document only reference is required + + unsigned index; // index in style-sheet, i.e. number in s-clause + char* reference; // everything required to apply the style + char* definition; // aditional tags like \snext and style name + + StyleData(const char* reference, const char* definition); + ~StyleData(); + bool setStyle(const char* s, const char* styleName); + + static const QRegExp s_clause; +}; + +extern QDict<StyleData> rtf_Style; + +void loadExtensions(const char *name); +void loadStylesheet(const char *name, QDict<StyleData>& dict); + +#endif diff --git a/src/scanner.l b/src/scanner.l index 17dd7be..c2710e4 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -282,6 +282,12 @@ static void addSection() { //printf("New section pageName=%s label=%s title=%s\n", // current->name.data(),sectionLabel.data(),sectionTitle.data()); + if (current->name.isEmpty() || current->section != Entry::PAGEDOC_SEC) + { + warn(yyFileName,yyLineNr,"Warning: found section or anchor with label `%s' " + "outside of \\page context!\n",sectionLabel.data()); + return; + } if (sectionLabel.isEmpty()) return; if (Doxygen::sectionDict.find(sectionLabel)==0) { @@ -3343,7 +3349,9 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) current->name = yytext; newDocState(); } -<NameSpaceDocArg1>"\\"{B}*"\n" { yyLineNr++; } +<NameSpaceDocArg1>"\\"{B}*"\n" { + yyLineNr++; + } <NameSpaceDocArg1>"\n" { warn(yyFileName,yyLineNr, "Warning: missing argument after " @@ -3355,7 +3363,9 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) current->name = yytext; newDocState(); } -<PackageDocArg1>"\\"{B}*"\n" { yyLineNr++; } +<PackageDocArg1>"\\"{B}*"\n" { + yyLineNr++; + } <PackageDocArg1>"\n" { warn(yyFileName,yyLineNr, "Warning: missing argument after " @@ -3376,7 +3386,9 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) prependScope(); BEGIN( ClassDocArg2 ); } -<ClassDocArg1>"\\"{B}*"\n" { yyLineNr++; } +<ClassDocArg1>"\\"{B}*"\n" { + yyLineNr++; + } <ClassDocArg1>"\n" { warn(yyFileName,yyLineNr, "Warning: missing argument after " @@ -3394,7 +3406,8 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) current->name=current->name.left(current->name.length()-5); BEGIN(GroupDocArg2); } -<GroupDocArg1>"\\"{B}*"\n" { yyLineNr++; } +<GroupDocArg1>"\\"{B}*"\n" { yyLineNr++; + } <GroupDocArg1>"\n" { warn(yyFileName,yyLineNr, "Warning: missing group name after %s", @@ -3408,7 +3421,8 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) yyLineNr--; unput('/');unput('*');unput('\n'); } -<GroupDocArg2>"\\"{B}*"\n" { yyLineNr++; } +<GroupDocArg2>"\\"{B}*"\n" { yyLineNr++; + } <GroupDocArg2>[^\n\*]+ { current->type += yytext; current->type = current->type.stripWhiteSpace(); @@ -3428,7 +3442,8 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) current->includeFile = stripQuotes(yytext); BEGIN( ClassDocArg3 ); } -<ClassDocArg2>"\\"{B}*"\n" { yyLineNr++; } +<ClassDocArg2>"\\"{B}*"\n" { yyLineNr++; + } <ClassDocArg2>"\n" { yyLineNr++; newDocState(); } @@ -3437,7 +3452,8 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) current->includeName = yytext; newDocState(); } -<ClassDocArg3>"\\"{B}*"\n" { yyLineNr++; } +<ClassDocArg3>"\\"{B}*"\n" { yyLineNr++; + } <ClassDocArg3>"\n" { yyLineNr++; newDocState(); } @@ -3445,7 +3461,8 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) current->name = stripQuotes(yytext); newDocState(); } -<FileDocArg1>"\\"{B}*"\n" { yyLineNr++; } +<FileDocArg1>"\\"{B}*"\n" { yyLineNr++; + } <FileDocArg1>"\n" { current->name = yyFileName; yyLineNr++; @@ -3455,7 +3472,9 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) current->name = stripQuotes(yytext); BEGIN( PageDocArg2 ); } -<PageDocArg1>"\\"{B}*"\n" { yyLineNr++; } +<PageDocArg1>"\\"{B}*"\n" { yyLineNr++; + current->doc+="\n"; + } <PageDocArg1>"\n" { warn(yyFileName,yyLineNr, "Warning: missing argument after " @@ -3476,11 +3495,14 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) prependScope(); newDocState(); } -<EnumDocArg1>"\\"{B}*"\n" { yyLineNr++; } +<EnumDocArg1>"\\"{B}*"\n" { yyLineNr++; + current->doc+="\n"; + } <EnumDocArg1>"\n" { warn(yyFileName,yyLineNr, "Warning: missing argument after \\enum." ); + current->doc+="\n"; yyLineNr++; BEGIN( Doc ); } @@ -3504,6 +3526,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) } <GroupHeader>\n { yyLineNr++; + current->doc+="\n"; //printf("Found memberGroup=`%s'\n",memberGroupHeader.data()); startGroupInDoc(); newDocState(); @@ -4255,7 +4278,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) } <Doc,JavaDoc,ClassDoc,PageDoc,ExampleDoc,ReadFormulaShort,ReadFormulaLong,ClassDocBrief,AfterDoc,AfterDocBrief>^{B}*(("//"{B}*)?)"*"+/[^/] <Doc,JavaDoc,ClassDoc,PageDoc,ExampleDoc,ReadFormulaShort,ReadFormulaLong,ClassDocBrief,AfterDoc,AfterDocBrief>^{B}*(("//"{B}*)?)"*"+{B}+ { - current->doc+=' '; + current->doc+=' '; } <Doc,ClassDoc,PageDoc,ExampleDoc,AfterDoc>"\\"[a-z_A-Z][a-z_A-Z0-9]*[\\] { // directory type of text diff --git a/src/util.cpp b/src/util.cpp index 9afb8ac..4efc7b9 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -2136,12 +2136,13 @@ bool getDefs(const QCString &scName,const QCString &memberName, } } } + //printf("found %d candidate members\n",members.count()); if (members.count()!=1 && !strcmp(args,"()")) { // no exact match found, but if args="()" an arbitrary // member will do md=mn->last(); - while (md) + while (md && md->isLinkable()) { //printf("Found member `%s'\n",md->name().data()); //printf("member is linkable md->name()=`%s'\n",md->name().data()); @@ -2363,6 +2364,7 @@ bool resolveRef(/* in */ const char *scName, GroupDef *gd = 0; // check if nameStr is a member or global. + //printf("getDefs(scope=%s,name=%s,args=%s\n",scopeStr.data(),nameStr.data(),argsStr.data()); if (getDefs(scopeStr,nameStr,argsStr, md,cd,fd,nd,gd, scopePos==0 && !memberScopeFirst, @@ -2378,6 +2380,8 @@ bool resolveRef(/* in */ const char *scName, else if (fd) *resContext=fd; else if (gd) *resContext=gd; else { *resContext=0; *resMember=0; return FALSE; } + //printf("member=%s (md=%p) anchor=%s linkable()=%d context=%s\n", + // md->name().data(),md,md->anchor().data(),md->isLinkable(),(*resContext)->name().data()); return TRUE; } else if (inSeeBlock && !nameStr.isEmpty() && (gd=Doxygen::groupSDict[nameStr])) @@ -2539,6 +2543,7 @@ bool resolveLink(/* in */ const char *scName, bool generateLink(OutputDocInterface &od,const char *clName, const char *lr,bool inSeeBlock,const char *lt) { + //printf("generateLink(clName=%s,lr=%s,lr=%s)\n",clName,lr,lt); Definition *compound; PageInfo *pageInfo; QCString anchor,linkText=lt; @@ -3386,7 +3391,7 @@ found: //---------------------------------------------------------------------------- -void addRelatedPage(const char *name,const QCString &ptitle, +PageInfo *addRelatedPage(const char *name,const QCString &ptitle, const QCString &doc,QList<QCString> *anchors, const char *fileName,int startLine, const QList<ListItemInfo> *sli, @@ -3474,6 +3479,7 @@ void addRelatedPage(const char *name,const QCString &ptitle, Doxygen::sectionDict.insert(pageName,si); } } + return pi; } //---------------------------------------------------------------------------- @@ -3902,3 +3908,47 @@ void filterLatexString(QTextStream &t,const char *str, } } } + + +QCString rtfFormatBmkStr(const char *name) +{ + static QCString g_nextTag( "AAAAAAAAAA" ); + static QDict<QCString> g_tagDict( 5003 ); + + g_tagDict.setAutoDelete(TRUE); + + // To overcome the 40-character tag limitation, we + // substitute a short arbitrary string for the name + // supplied, and keep track of the correspondence + // between names and strings. + QCString key( name ); + QCString* tag = g_tagDict.find( key ); + if ( !tag ) + { + // This particular name has not yet been added + // to the list. Add it, associating it with the + // next tag value, and increment the next tag. + tag = new QCString( g_nextTag.copy() ); // Make sure to use a deep copy! + g_tagDict.insert( key, tag ); + + // This is the increment part + char* nxtTag = g_nextTag.data() + g_nextTag.length() - 1; + for ( unsigned int i = 0; i < g_nextTag.length(); ++i, --nxtTag ) + { + if ( ( ++(*nxtTag) ) > 'Z' ) + { + (*nxtTag) = 'A'; + } + else + { + // Since there was no carry, we can stop now + break; + } + } + } + + return *tag; +} + + + @@ -190,7 +190,7 @@ int getScopeFragment(const QCString &s,int p,int *l); int filterCRLF(char *buf,int len); void addRefItem(const QList<ListItemInfo> *sli,const char *prefix, const char *name,const char *title,const char *args=0); -void addRelatedPage(const char *name,const QCString &ptitle, +PageInfo *addRelatedPage(const char *name,const QCString &ptitle, const QCString &doc,QList<QCString> *anchors, const char *fileName,int startLine, const QList<ListItemInfo> *sli, @@ -201,6 +201,7 @@ QCString escapeCharsInString(const char *name,bool allowDots); void addGroupListToTitle(OutputList &ol,Definition *d); void filterLatexString(QTextStream &t,const char *str, bool insideTabbing=FALSE,bool insidePre=FALSE); +QCString rtfFormatBmkStr(const char *name); #endif |