19 #include <qfileinfo.h>
40 #define DBG_RTF(x) do {} while(0)
46 for (i=0; i<attrs.count(); ++i)
48 if (attrs.at(i)->name.lower()==
"align")
50 if (attrs.at(i)->value.lower()==
"center")
52 else if (attrs.at(i)->value.lower()==
"right")
63 m_hide(FALSE), m_indentLevel(0), m_lastIsPara(FALSE), m_langExt(langExt)
93 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocWord)}\n");
101 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocLinkedWord)}\n");
111 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocWhiteSpace)}\n");
126 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocSymbol)}\n");
142 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocURL)}\n");
172 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocLineBreak)}\n");
180 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocHorRuler)}\n");
181 m_t <<
"{\\pard\\widctlpar\\brdrb\\brdrs\\brdrw5\\brsp20 \\adjustright \\par}" <<
endl;
189 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocStyleChange)}\n");
236 QListIterator<DocNode> cli(children);
238 for (cli.toFirst();(n=cli.current());++cli) n->
accept(parent);
244 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocVerbatim)}\n");
283 static int dotindex = 1;
284 QCString fileName(4096);
286 fileName.sprintf(
"%s%d%s",
291 QFile file(fileName);
292 if (!file.open(IO_WriteOnly))
294 err(
"Could not open file %s for writing\n",fileName.data());
296 file.writeBlock( s->
text(), s->
text().length() );
308 static int mscindex = 1;
309 QCString baseName(4096);
311 baseName.sprintf(
"%s%d%s",
316 QFile file(baseName);
317 if (!file.open(IO_WriteOnly))
319 err(
"Could not open file %s for writing\n",baseName.data());
321 QCString text =
"msc {";
324 file.writeBlock( text, text.length() );
351 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocAnchor)}\n");
353 if (!anc->
file().isEmpty())
357 if (!anc->
file().isEmpty() && !anc->
anchor().isEmpty())
361 if (!anc->
anchor().isEmpty())
374 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocInclude)}\n");
382 QFileInfo cfi( inc->
file() );
383 FileDef fd( cfi.dirPath().utf8(), cfi.fileName().utf8() );
449 err(
"Internal inconsistency: found switch SnippetDoc / IncludeDoc in file: %s"
450 "Please create a bug report\n",__FILE__);
460 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocIncOperator)}\n");
506 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocFormula)}\n");
514 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocIndexEntry)}\n");
526 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocCite)}\n");
527 if (!cite->
file().isEmpty())
536 if (!cite->
file().isEmpty())
554 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocAutoList)}\n");
564 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocAutoList)}\n");
573 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocAutoListItem)}\n");
593 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocAutoListItem)}\n");
598 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocPara)}\n");
604 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocPara)}\n");
620 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocRoot)}\n");
628 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocRoot)}\n");
638 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocSimpleSect)}\n");
695 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocSimpleSect)}\n");
704 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocTitle)}\n");
710 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocTitle)}\n");
721 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocSimpleSect)}\n");
730 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocSimpleSect)}\n");
739 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocSimpleListItem)}\n");
748 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocSimpleListItem)}\n");
754 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocSection)}\n");
761 int level = QMIN(s->
level()+1,4);
762 heading.sprintf(
"Heading%d",level);
767 m_t << endl <<
"\\par" <<
"}" <<
endl;
768 m_t <<
"{\\tc\\tcl" << level <<
" \\v ";
777 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocSection)}\n");
785 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocHtmlList)}\n");
795 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocHtmlList)}\n");
803 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocHtmlListItem)}\n");
823 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocHtmlListItem)}\n");
829 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocHtmlDescList)}\n");
838 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocHtmlDescList)}\n");
847 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocHtmlDescTitle)}\n");
857 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocHtmlDescTitle)}\n");
866 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocHtmlDescData)}\n");
874 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocHtmlDescData)}\n");
884 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocHtmlTable)}\n");
892 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocHtmlTable)}\n");
893 m_t <<
"\\pard\\plain" <<
endl;
900 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocHtmlCaption)}\n");
905 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocHtmlCaption)}\n");
911 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocHtmlRow)}\n");
913 m_t <<
"\\trowd \\trgaph108\\trleft-108"
914 "\\trbrdrt\\brdrs\\brdrw10 "
915 "\\trbrdrl\\brdrs\\brdrw10 "
916 "\\trbrdrb\\brdrs\\brdrw10 "
917 "\\trbrdrr\\brdrs\\brdrw10 "
918 "\\trbrdrh\\brdrs\\brdrw10 "
919 "\\trbrdrv\\brdrs\\brdrw10 "<<
endl;
924 m_t <<
"\\clcbpat16";
926 m_t <<
"\\clvertalt\\clbrdrt\\brdrs\\brdrw10 "
927 "\\clbrdrl\\brdrs\\brdrw10 "
928 "\\clbrdrb\\brdrs\\brdrw10 "
929 "\\clbrdrr \\brdrs\\brdrw10 "
931 "\\cellx" << ((i+1)*columnWidth) <<
endl;
933 m_t <<
"\\pard \\widctlpar\\intbl\\adjustright" <<
endl;
940 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocHtmlRow)}\n");
942 m_t <<
"\\pard \\widctlpar\\intbl\\adjustright" <<
endl;
950 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocHtmlCell)}\n");
958 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocHtmlCell)}\n");
990 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocHRef)}\n");
995 "{ HYPERLINK \"" << href->
url() <<
"\" "
1012 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocHRef)}\n");
1029 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocHtmlHeader)}\n");
1033 int level = QMIN(header->
level()+2,4);
1034 heading.sprintf(
"Heading%d",level);
1038 m_t <<
"{\\tc\\tcl" << level <<
" ";
1045 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocHtmlHeader)}\n");
1054 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocImage)}\n");
1066 m_t <<
"\\pard \\qc { \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"";
1068 m_t <<
"\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}" <<
endl;
1072 m_t <<
"\\pard \\qc \\b";
1073 m_t <<
"{Image \\field\\flddirty{\\*\\fldinst { SEQ Image \\\\*Arabic }}{\\fldrslt {\\noproof 1}} ";
1086 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocImage)}\n");
1113 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocDotFile)}\n");
1119 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocDotFile)}\n");
1124 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocMscFile)}\n");
1130 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocMscFile)}\n");
1136 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocDiaFile)}\n");
1142 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocDiaFile)}\n");
1149 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocLink)}\n");
1156 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocLink)}\n");
1163 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocRef)}\n");
1180 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocRef)}\n");
1188 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocSecRefItem)}\n");
1193 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocSecRefItem)}\n");
1199 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocSecRefList)}\n");
1210 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocSecRefList)}\n");
1241 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocParamSect)}\n");
1258 m_t <<
"Template Parameters";
break;
1280 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocParamSect)}\n");
1295 static int columnPos[4][5] =
1296 { { 2, 25, 100, 100, 100 },
1297 { 3, 14, 35, 100, 100 },
1298 { 3, 25, 50, 100, 100 },
1299 { 4, 14, 35, 55, 100 },
1303 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocParamList)}\n");
1321 m_t <<
"\\trowd \\trgaph108\\trleft426\\tblind426"
1322 "\\trbrdrt\\brdrs\\brdrw10\\brdrcf15 "
1323 "\\trbrdrl\\brdrs\\brdrw10\\brdrcf15 "
1324 "\\trbrdrb\\brdrs\\brdrw10\\brdrcf15 "
1325 "\\trbrdrr\\brdrs\\brdrw10\\brdrcf15 "
1326 "\\trbrdrh\\brdrs\\brdrw10\\brdrcf15 "
1327 "\\trbrdrv\\brdrs\\brdrw10\\brdrcf15 "<<
endl;
1328 for (i=0;i<columnPos[config][0];i++)
1330 m_t <<
"\\clvertalt\\clbrdrt\\brdrs\\brdrw10\\brdrcf15 "
1331 "\\clbrdrl\\brdrs\\brdrw10\\brdrcf15 "
1332 "\\clbrdrb\\brdrs\\brdrw10\\brdrcf15 "
1333 "\\clbrdrr \\brdrs\\brdrw10\\brdrcf15 "
1335 "\\cellx" << (
rtf_pageWidth*columnPos[config][i+1]/100) << endl;
1337 m_t <<
"\\pard \\widctlpar\\intbl\\adjustright" <<
endl;
1379 for (li.toFirst();(type=li.current());++li)
1381 if (!first)
m_t <<
" | ";
else first=FALSE;
1409 for (li.toFirst();(param=li.current());++li)
1411 if (!first)
m_t <<
",";
else first=FALSE;
1433 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocParamList)}\n");
1463 if (x->
title().isEmpty())
return;
1464 bool anonymousEnum = x->
file()==
"@";
1465 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocXRefItem)}\n");
1477 if (!x->
file().isEmpty())
1481 if (!x->
file().isEmpty() && !x->
anchor().isEmpty())
1485 if (!x->
anchor().isEmpty())
1492 "{ HYPERLINK \\\\l \"" << refName <<
"\" "
1496 "{\\cs37\\ul\\cf2 ";
1517 if (x->
title().isEmpty())
return;
1518 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocXRefItem)}\n");
1528 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocInternalRef)}\n");
1535 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocInternalRef)}\n");
1543 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocCopy)}\n");
1549 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocCopy)}\n");
1555 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocText)}\n");
1561 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocText)}\n");
1567 DBG_RTF(
"{\\comment RTFDocVisitor::visitPre(DocHtmlBlockQuote)}\n");
1577 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocHtmlBlockQuote)}\n");
1616 const unsigned char *p=(
const unsigned char *)str;
1639 case '{':
m_t <<
"\\{";
break;
1640 case '}':
m_t <<
"\\}";
break;
1641 case '\\':
m_t <<
"\\\\";
break;
1642 case '\n':
if (verbatim)
1651 default:
m_t << (char)c;
1663 if (!file.isEmpty())
1667 if (!file.isEmpty() && anchor)
1676 m_t <<
"{\\field {\\*\\fldinst { HYPERLINK \\\\l \"";
1679 m_t <<
"}{\\fldrslt {\\cs37\\ul\\cf2 ";
1720 QCString baseName=filename;
1722 if ((i=baseName.findRev(
'/'))!=-1)
1724 baseName=baseName.right(baseName.length()-i-1);
1738 QCString baseName=fileName;
1740 if ((i=baseName.findRev(
'/'))!=-1)
1742 baseName=baseName.right(baseName.length()-i-1);
1751 QCString baseName=df->
file();
1753 if ((i=baseName.findRev(
'/'))!=-1)
1755 baseName=baseName.right(baseName.length()-i-1);
1764 QCString baseName=fileName;
1766 if ((i=baseName.findRev(
'/'))!=-1)
1768 baseName=baseName.right(baseName.length()-i-1);