rtfstyle.cpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  * $Id: $
00004  *
00005  *
00006  * Copyright (C) 1997-2008 by Dimitri van Heesch.
00007  *
00008  * Permission to use, copy, modify, and distribute this software and its
00009  * documentation under the terms of the GNU General Public License is hereby 
00010  * granted. No representations are made about the suitability of this software 
00011  * for any purpose. It is provided "as is" without express or implied warranty.
00012  * See the GNU General Public License for more details.
00013  *
00014  * Documents produced by Doxygen are derivative works derived from the
00015  * input used in their production; they are not affected by this license.
00016  *
00017  */
00018 
00019 #include "rtfstyle.h"
00020 
00021 #include <qfile.h>
00022 #include <qtextstream.h>
00023 #include <stdlib.h>
00024 
00025 #include "message.h"
00026 
00027 
00028 RTFListItemInfo rtf_listItemInfo[rtf_maxIndentLevels];
00029 
00030 QCString rtf_title;
00031 QCString rtf_subject;
00032 QCString rtf_comments;
00033 QCString rtf_company;
00034 QCString rtf_logoFilename;
00035 QCString rtf_author;
00036 QCString rtf_manager;
00037 QCString rtf_documentType;
00038 QCString rtf_documentId;
00039 QCString rtf_keywords;
00040 
00041 char rtf_Style_Reset[] = "\\pard\\plain ";
00042 
00043 Rtf_Style_Default rtf_Style_Default[] =
00044 {
00045   { "Heading1",
00046     "\\s1\\sb240\\sa60\\keepn\\widctlpar\\adjustright \\b\\f1\\fs36\\kerning36\\cgrid ",
00047     "\\sbasedon0 \\snext0 heading 1"
00048   },
00049   { "Heading2",
00050     "\\s2\\sb240\\sa60\\keepn\\widctlpar\\adjustright \\b\\f1\\fs28\\kerning28\\cgrid ",
00051     "\\sbasedon0 \\snext0 heading 2"
00052   },
00053   { "Heading3",
00054     "\\s3\\sb240\\sa60\\keepn\\widctlpar\\adjustright \\b\\f1\\cgrid ",
00055     "\\sbasedon0 \\snext0 heading 3"
00056   },
00057   { "Heading4",
00058     "\\s4\\sb240\\sa60\\keepn\\widctlpar\\adjustright \\b\\f1\\fs20\\cgrid ",
00059     "\\sbasedon0 \\snext0 heading 4;}{\\*\\cs10 \\additive Default Paragraph Font"
00060   },
00061   { "Heading5",
00062     "\\s5\\sb90\\sa30\\keepn\\widctlpar\\adjustright \\b\\f1\\fs20\\cgrid ",
00063     "\\sbasedon0 \\snext0 heading 5;}{\\*\\cs10 \\additive Default Paragraph Font"
00064   },
00065   { "Title",
00066     "\\s15\\qc\\sb240\\sa60\\widctlpar\\outlinelevel0\\adjustright \\b\\f1\\fs32\\kerning28\\cgrid ",
00067     "\\sbasedon0 \\snext15 Title"
00068   },
00069   { "SubTitle",
00070     "\\s16\\qc\\sa60\\widctlpar\\outlinelevel1\\adjustright \\f1\\cgrid ",
00071     "\\sbasedon0 \\snext16 Subtitle"
00072   },
00073   { "BodyText",
00074     "\\s17\\sa60\\sb30\\widctlpar\\qj \\fs22\\cgrid ",
00075     "\\sbasedon0 \\snext17 BodyText"
00076   },
00077   { "DenseText",
00078     "\\s18\\widctlpar\\fs22\\cgrid ",
00079     "\\sbasedon0 \\snext18 DenseText"
00080   },
00081   { "Header",
00082     "\\s28\\widctlpar\\tqc\\tx4320\\tqr\\tx8640\\adjustright \\fs20\\cgrid ",
00083     "\\sbasedon0 \\snext28 header"
00084   },
00085   { "Footer",
00086     "\\s29\\widctlpar\\tqc\\tx4320\\tqr\\tx8640\\qr\\adjustright \\fs20\\cgrid ",
00087     "\\sbasedon0 \\snext29 footer"
00088   },
00089   { "GroupHeader",
00090     "\\s30\\li360\\sa60\\sb120\\keepn\\widctlpar\\adjustright \\b\\f1\\fs20\\cgrid ",
00091     "\\sbasedon0 \\snext30 GroupHeader"
00092   },
00093   { "CodeExample0",
00094     "\\s40\\li0\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ",
00095     "\\sbasedon0 \\snext41 Code Example 0"
00096   },
00097   { "CodeExample1",
00098     "\\s41\\li360\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ",
00099     "\\sbasedon0 \\snext42 Code Example 1"
00100   },
00101   { "CodeExample2",
00102     "\\s42\\li720\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ",
00103     "\\sbasedon0 \\snext43 Code Example 2"
00104   },
00105   { "CodeExample3",
00106     "\\s43\\li1080\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ",
00107     "\\sbasedon0 \\snext44 Code Example 3"
00108   },
00109   { "CodeExample4",
00110     "\\s44\\li1440\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ",
00111     "\\sbasedon0 \\snext45 Code Example 4"
00112   },
00113   { "CodeExample5",
00114     "\\s45\\li1800\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ",
00115     "\\sbasedon0 \\snext46 Code Example 5"
00116   },
00117   { "CodeExample6",
00118     "\\s46\\li2160\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ",
00119     "\\sbasedon0 \\snext47 Code Example 6"
00120   },
00121   { "CodeExample7",
00122     "\\s47\\li2520\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ",
00123     "\\sbasedon0 \\snext48 Code Example 7"
00124   },
00125   { "CodeExample8",
00126     "\\s48\\li2880\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ",
00127     "\\sbasedon0 \\snext49 Code Example 8"
00128   },
00129   { "CodeExample9",
00130     "\\s49\\li3240\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ",
00131     "\\sbasedon0 \\snext49 Code Example 9"
00132   },
00133   { "ListContinue0",
00134     "\\s50\\li0\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ",
00135     "\\sbasedon0 \\snext51 List Continue 0"
00136   },
00137   { "ListContinue1",
00138     "\\s51\\li360\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ",
00139     "\\sbasedon0 \\snext52 List Continue 1"
00140   },
00141   { "ListContinue2",
00142     "\\s52\\li720\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ",
00143     "\\sbasedon0 \\snext53 List Continue 2"
00144   },
00145   { "ListContinue3",
00146     "\\s53\\li1080\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ",
00147     "\\sbasedon0 \\snext54 List Continue 3"
00148   },
00149   { "ListContinue4",
00150     "\\s54\\li1440\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ",
00151     "\\sbasedon0 \\snext55 List Continue 4"
00152   },
00153   { "ListContinue5",
00154     "\\s55\\li1800\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ",
00155     "\\sbasedon0 \\snext56 List Continue 5"
00156   },
00157   { "ListContinue6",
00158     "\\s56\\li2160\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ",
00159     "\\sbasedon0 \\snext57 List Continue 6"
00160   },
00161   { "ListContinue7",
00162     "\\s57\\li2520\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ",
00163     "\\sbasedon0 \\snext58 List Continue 7"
00164   },
00165   { "ListContinue8",
00166     "\\s58\\li2880\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ",
00167     "\\sbasedon0 \\snext59 List Continue 8"
00168   },
00169   { "ListContinue9",
00170     "\\s59\\li3240\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ",
00171     "\\sbasedon0 \\snext59 List Continue 9"
00172   },
00173   { "DescContinue0",
00174     "\\s60\\li0\\widctlpar\\ql\\adjustright \\fs20\\cgrid ",
00175     "\\sbasedon0 \\snext61 DescContinue 0"
00176   },
00177   { "DescContinue1",
00178     "\\s61\\li360\\widctlpar\\ql\\adjustright \\fs20\\cgrid ",
00179     "\\sbasedon0 \\snext62 DescContinue 1"
00180   },
00181   { "DescContinue2",
00182     "\\s62\\li720\\widctlpar\\ql\\adjustright \\fs20\\cgrid ",
00183     "\\sbasedon0 \\snext63 DescContinue 2"
00184   },
00185   { "DescContinue3",
00186     "\\s63\\li1080\\widctlpar\\ql\\adjustright \\fs20\\cgrid ",
00187     "\\sbasedon0 \\snext64 DescContinue 3"
00188   },
00189   { "DescContinue4",
00190     "\\s64\\li1440\\widctlpar\\ql\\adjustright \\fs20\\cgrid ",
00191     "\\sbasedon0 \\snext65 DescContinue 4"
00192   },
00193   { "DescContinue5",
00194     "\\s65\\li1800\\widctlpar\\ql\\adjustright \\fs20\\cgrid ",
00195     "\\sbasedon0 \\snext66 DescContinue 5"
00196   },
00197   { "DescContinue6",
00198     "\\s66\\li2160\\widctlpar\\ql\\adjustright \\fs20\\cgrid ",
00199     "\\sbasedon0 \\snext67 DescContinue 6"
00200   },
00201   { "DescContinue7",
00202     "\\s67\\li2520\\widctlpar\\ql\\adjustright \\fs20\\cgrid ",
00203     "\\sbasedon0 \\snext68 DescContinue 7"
00204   },
00205   { "DescContinue8",
00206     "\\s68\\li2880\\widctlpar\\ql\\adjustright \\fs20\\cgrid ",
00207     "\\sbasedon0 \\snext69 DescContinue 8"
00208   },
00209   { "DescContinue9",
00210     "\\s69\\li3240\\widctlpar\\ql\\adjustright \\fs20\\cgrid ",
00211     "\\sbasedon0 \\snext69 DescContinue 9"
00212   },
00213   { "LatexTOC0",
00214     "\\s70\\li0\\sa30\\sb30\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ",
00215     "\\sbasedon0 \\snext81 LatexTOC 0"
00216   },
00217   { "LatexTOC1",
00218     "\\s71\\li360\\sa27\\sb27\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ",
00219     "\\sbasedon0 \\snext82 LatexTOC 1"
00220   },
00221   { "LatexTOC2",
00222     "\\s72\\li720\\sa24\\sb24\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ",
00223     "\\sbasedon0 \\snext83 LatexTOC 2"
00224   },
00225   { "LatexTOC3",
00226     "\\s73\\li1080\\sa21\\sb21\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ",
00227     "\\sbasedon0 \\snext84 LatexTOC 3"
00228   },
00229   { "LatexTOC4",
00230     "\\s74\\li1440\\sa18\\sb18\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ",
00231     "\\sbasedon0 \\snext85 LatexTOC 4"
00232   },
00233   { "LatexTOC5",
00234     "\\s75\\li1800\\sa15\\sb15\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ",
00235     "\\sbasedon0 \\snext86 LatexTOC 5"
00236   },
00237   { "LatexTOC6",
00238     "\\s76\\li2160\\sa12\\sb12\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ",
00239     "\\sbasedon0 \\snext87 LatexTOC 6"
00240   },
00241   { "LatexTOC7",
00242     "\\s77\\li2520\\sa9\\sb9\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ",
00243     "\\sbasedon0 \\snext88 LatexTOC 7"
00244   },
00245   { "LatexTOC8",
00246     "\\s78\\li2880\\sa6\\sb6\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ",
00247     "\\sbasedon0 \\snext89 LatexTOC 8"
00248   },
00249   { "LatexTOC9",
00250     "\\s79\\li3240\\sa3\\sb3\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ",
00251     "\\sbasedon0 \\snext89 LatexTOC 9"
00252   },
00253   { "ListBullet0",
00254     "\\s80\\fi-360\\li360\\widctlpar\\jclisttab\\tx360{\\*\\pn \\pnlvlbody\\ilvl0\\ls1\\pnrnot0\\pndec }\\ls1\\adjustright \\fs20\\cgrid ",
00255     "\\sbasedon0 \\snext81 \\sautoupd List Bullet 0"
00256   },
00257   { "ListBullet1",
00258     "\\s81\\fi-360\\li720\\widctlpar\\jclisttab\\tx720{\\*\\pn \\pnlvlbody\\ilvl0\\ls2\\pnrnot0\\pndec }\\ls2\\adjustright \\fs20\\cgrid ",
00259     "\\sbasedon0 \\snext82 \\sautoupd List Bullet 1"
00260   },
00261   { "ListBullet2",
00262     "\\s82\\fi-360\\li1080\\widctlpar\\jclisttab\\tx1080{\\*\\pn \\pnlvlbody\\ilvl0\\ls3\\pnrnot0\\pndec }\\ls3\\adjustright \\fs20\\cgrid ",
00263     "\\sbasedon0 \\snext83 \\sautoupd List Bullet 2"
00264   },
00265   { "ListBullet3",
00266     "\\s83\\fi-360\\li1440\\widctlpar\\jclisttab\\tx1440{\\*\\pn \\pnlvlbody\\ilvl0\\ls4\\pnrnot0\\pndec }\\ls4\\adjustright \\fs20\\cgrid ",
00267     "\\sbasedon0 \\snext84 \\sautoupd List Bullet 3"
00268   },
00269   { "ListBullet4",
00270     "\\s84\\fi-360\\li1800\\widctlpar\\jclisttab\\tx1800{\\*\\pn \\pnlvlbody\\ilvl0\\ls5\\pnrnot0\\pndec }\\ls5\\adjustright \\fs20\\cgrid ",
00271     "\\sbasedon0 \\snext85 \\sautoupd List Bullet 4"
00272   },
00273   { "ListBullet5",
00274     "\\s85\\fi-360\\li2160\\widctlpar\\jclisttab\\tx2160{\\*\\pn \\pnlvlbody\\ilvl0\\ls6\\pnrnot0\\pndec }\\ls6\\adjustright \\fs20\\cgrid ",
00275     "\\sbasedon0 \\snext86 \\sautoupd List Bullet 5"
00276   },
00277   { "ListBullet6",
00278     "\\s86\\fi-360\\li2520\\widctlpar\\jclisttab\\tx2520{\\*\\pn \\pnlvlbody\\ilvl0\\ls7\\pnrnot0\\pndec }\\ls7\\adjustright \\fs20\\cgrid ",
00279     "\\sbasedon0 \\snext87 \\sautoupd List Bullet 6"
00280   },
00281   { "ListBullet7",
00282     "\\s87\\fi-360\\li2880\\widctlpar\\jclisttab\\tx2880{\\*\\pn \\pnlvlbody\\ilvl0\\ls8\\pnrnot0\\pndec }\\ls8\\adjustright \\fs20\\cgrid ",
00283     "\\sbasedon0 \\snext88 \\sautoupd List Bullet 7"
00284   },
00285   { "ListBullet8",
00286     "\\s88\\fi-360\\li3240\\widctlpar\\jclisttab\\tx3240{\\*\\pn \\pnlvlbody\\ilvl0\\ls9\\pnrnot0\\pndec }\\ls9\\adjustright \\fs20\\cgrid ",
00287     "\\sbasedon0 \\snext89 \\sautoupd List Bullet 8"
00288   },
00289   { "ListBullet9",
00290     "\\s89\\fi-360\\li3600\\widctlpar\\jclisttab\\tx3600{\\*\\pn \\pnlvlbody\\ilvl0\\ls10\\pnrnot0\\pndec }\\ls10\\adjustright \\fs20\\cgrid ",
00291     "\\sbasedon0 \\snext89 \\sautoupd List Bullet 9"
00292   },
00293   { "ListEnum0",
00294     "\\s90\\fi-360\\li360\\widctlpar\\fs20\\cgrid ",
00295     "\\sbasedon0 \\snext91 \\sautoupd List Enum 0"
00296   },
00297   { "ListEnum1",
00298     "\\s91\\fi-360\\li720\\widctlpar\\fs20\\cgrid ",
00299     "\\sbasedon0 \\snext92 \\sautoupd List Enum 1"
00300   },
00301   { "ListEnum2",
00302     "\\s92\\fi-360\\li1080\\widctlpar\\fs20\\cgrid ",
00303     "\\sbasedon0 \\snext93 \\sautoupd List Enum 2"
00304   },
00305   { "ListEnum3",
00306     "\\s93\\fi-360\\li1440\\widctlpar\\fs20\\cgrid ",
00307     "\\sbasedon0 \\snext94 \\sautoupd List Enum 3"
00308   },
00309   { "ListEnum4",
00310     "\\s94\\fi-360\\li1800\\widctlpar\\fs20\\cgrid ",
00311     "\\sbasedon0 \\snext95 \\sautoupd List Enum 4"
00312   },
00313   { "ListEnum5",
00314     "\\s95\\fi-360\\li2160\\widctlpar\\fs20\\cgrid ",
00315     "\\sbasedon0 \\snext96 \\sautoupd List Enum 5"
00316   },
00317   { "ListEnum6",
00318     "\\s96\\fi-360\\li2520\\widctlpar\\fs20\\cgrid ",
00319     "\\sbasedon0 \\snext96 \\sautoupd List Enum 5"
00320   },
00321   { "ListEnum7",
00322     "\\s97\\fi-360\\li2880\\widctlpar\\fs20\\cgrid ",
00323     "\\sbasedon0 \\snext98 \\sautoupd List Enum 7"
00324   },
00325   { "ListEnum8",
00326     "\\s98\\fi-360\\li3240\\widctlpar\\fs20\\cgrid ",
00327     "\\sbasedon0 \\snext99 \\sautoupd List Enum 8"
00328   },
00329   { "ListEnum9",
00330     "\\s99\\fi-360\\li3600\\widctlpar\\fs20\\cgrid ",
00331     "\\sbasedon0 \\snext99 \\sautoupd List Enum 9"
00332   },
00333   { 0,
00334     0,
00335     0
00336   }
00337 };
00338 
00339 const QRegExp StyleData::s_clause("\\\\s[0-9]+\\s*");
00340 
00341 StyleData::StyleData(const char* reference, const char* definition)
00342 {
00343   int start = s_clause.match(reference); ASSERT(start >= 0);
00344   reference += start;
00345   index = (int)atol(reference + 2); ASSERT(index > 0);
00346 
00347   ASSERT(reference != 0);
00348   size_t size = 1 + strlen(reference);
00349   memcpy(this->reference = new char[size], reference, size);
00350 
00351   ASSERT(definition != 0);
00352   size = 1 + strlen(definition);
00353   memcpy(this->definition = new char[size], definition, size);
00354 }
00355 
00356 StyleData::~StyleData()
00357 {
00358   delete[] reference;
00359   delete[] definition;
00360 }
00361 
00362 bool StyleData::setStyle(const char* s, const char* styleName)
00363 {
00364   static const QRegExp subgroup("^{[^}]*}\\s*");
00365   static const QRegExp any_clause("^\\\\[a-z][a-z0-9-]*\\s*");
00366 
00367   int len = 0;     // length of a particular RTF formatting control
00368   int ref_len = 0; // length of the whole formatting section of a style
00369   int start = s_clause.match(s, 0, &len);
00370   if (start < 0)
00371   {
00372     err("Style sheet '%s' contains no '\\s' clause.\n{%s}\n", styleName, s);
00373     return FALSE;
00374   }
00375   s += start;
00376   index = (int)atol(s + 2); ASSERT(index > 0);
00377 
00378   // search for the end of pure formatting codes
00379   const char* end = s + len;
00380   ref_len = len;
00381   bool haveNewDefinition = TRUE;
00382   for(;;)
00383   {
00384     if (*end == '{')
00385     {
00386       // subgroups are used for \\additive
00387       if (0 != subgroup.match(end, 0, &len))
00388         break;
00389       else
00390       {
00391         end += len;
00392         ref_len += len;
00393       }
00394     }
00395     else if (*end == '\\')
00396     {
00397       if (0 == strncmp(end, "\\snext", 6))
00398         break;
00399       if (0 == strncmp(end, "\\sbasedon", 9))
00400         break;
00401       if (0 != any_clause.match(end, 0, &len))
00402         break;
00403       end += len;
00404       ref_len += len;
00405     }
00406     else if (*end == 0)
00407     { // no style-definition part, keep default value
00408       haveNewDefinition = FALSE;
00409       break;
00410     }
00411     else // plain name without leading \\snext
00412       break;
00413   }
00414   delete[] reference;
00415   reference = new char[ref_len + 1];
00416   memcpy(reference, s, ref_len); 
00417   reference[ref_len] = 0;
00418   if (haveNewDefinition)
00419   {
00420     delete[] definition;
00421     size_t size = 1 + strlen(end);
00422     definition = new char[size];
00423     memcpy(definition, end, size);
00424   }
00425   return TRUE;
00426 }
00427 
00428 void loadStylesheet(const char *name, QDict<StyleData>& dict)
00429 {
00430   QFile file(name);
00431   if (!file.open(IO_ReadOnly))
00432   {
00433     err("Can't open RTF style sheet file %s. Using defaults.\n",name);
00434     return;
00435   }
00436   msg("Loading RTF style sheet %s...\n",name);
00437 
00438   static const QRegExp separator("[ \t]*=[ \t]*");
00439   uint lineNr=1;
00440   QTextStream t(&file);
00441   t.setEncoding(QTextStream::UnicodeUTF8);
00442 
00443   while (!t.eof())
00444   {
00445     QCString s(4096); // string buffer of max line length
00446     s = t.readLine().stripWhiteSpace();
00447     if (s.isEmpty() || s.at(0)=='#') continue; // skip blanks & comments
00448     int sepLength;
00449     int sepStart = separator.match(s,0,&sepLength);
00450     if (sepStart<=0) // no valid assignment statement
00451     {
00452       warn(name,lineNr,"Assignment of style sheet name expected!\n");
00453       continue;
00454     }
00455     QCString key=s.left(sepStart);
00456     if (dict[key]==0) // not a valid style sheet name
00457     {
00458       warn(name,lineNr,"Invalid style sheet name %s ignored.\n",key.data());
00459       continue;
00460     }
00461     StyleData* styleData = dict.find(key);
00462     if (styleData == 0)
00463     {
00464       warn(name,lineNr,"Unknown style sheet name %s ignored.\n",key.data());
00465       continue;
00466     }
00467     s+=" "; // add command separator
00468     styleData->setStyle(s.data() + sepStart + sepLength, key.data());
00469     lineNr++;
00470   }
00471 }
00472 
00473 QDict<StyleData> rtf_Style(257);
00474 
00475 void loadExtensions(const char *name)
00476 {
00477   QFile file(name);
00478   if (!file.open(IO_ReadOnly))
00479   {
00480     err("Can't open RTF extensions file %s. Using defaults.\n",name);
00481     return;
00482   }
00483   msg("Loading RTF extensions %s...\n",name);
00484 
00485   static const QRegExp separator("[ \t]*=[ \t]*");
00486   uint lineNr=1;
00487   QTextStream t(&file);
00488   t.setEncoding(QTextStream::UnicodeUTF8);
00489 
00490   while (!t.eof())
00491   {
00492     QCString s(4096); // string buffer of max line length
00493     s = t.readLine().stripWhiteSpace();
00494     if (s.length()==0 || s.at(0)=='#') continue; // skip blanks & comments
00495     int sepLength;
00496     int sepStart = separator.match(s,0,&sepLength);
00497     if (sepStart<=0) // no valid assignment statement
00498     {
00499       warn(name,lineNr,"Assignment of extension field expected!\n");
00500       continue;
00501     }
00502     QCString key=s.left(sepStart);
00503     QCString data=s.data() + sepStart + sepLength;
00504 
00505     if (key == "Title")           rtf_title            = data.data();
00506     if (key == "Subject")         rtf_subject          = data.data();
00507     if (key == "Comments")        rtf_comments         = data.data();
00508     if (key == "Company")         rtf_company          = data.data();
00509     if (key == "LogoFilename")    rtf_logoFilename     = data.data();
00510     if (key == "Author")          rtf_author           = data.data();
00511     if (key == "Manager")         rtf_manager          = data.data();
00512     if (key == "DocumentType")    rtf_documentType     = data.data();
00513     if (key == "DocumentId")      rtf_documentId       = data.data();
00514     if (key == "Keywords")        rtf_keywords         = data.data();
00515     lineNr++;
00516   }
00517 }
00518 



Generated on Mon Mar 31 10:58:43 2008 by  doxygen 1.5.1