Functions | Variables
rtfstyle.cpp File Reference
#include "rtfstyle.h"
#include <qfile.h>
#include <qtextstream.h>
#include <stdlib.h>
#include "message.h"

Go to the source code of this file.

Functions

void loadStylesheet (const char *name, QDict< StyleData > &dict)
 
QDict< StyleDatartf_Style (257)
 
void loadExtensions (const char *name)
 

Variables

RTFListItemInfo rtf_listItemInfo [rtf_maxIndentLevels]
 
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 []
 

Function Documentation

void loadExtensions ( const char *  name)

Definition at line 475 of file rtfstyle.cpp.

476 {
477  QFile file(name);
478  if (!file.open(IO_ReadOnly))
479  {
480  err("Can't open RTF extensions file %s. Using defaults.\n",name);
481  return;
482  }
483  msg("Loading RTF extensions %s...\n",name);
484 
485  static const QRegExp separator("[ \t]*=[ \t]*");
486  uint lineNr=1;
487  QTextStream t(&file);
488  t.setEncoding(QTextStream::UnicodeUTF8);
489 
490  while (!t.eof())
491  {
492  QCString s(4096); // string buffer of max line length
493  s = t.readLine().stripWhiteSpace().utf8();
494  if (s.length()==0 || s.at(0)=='#') continue; // skip blanks & comments
495  int sepLength;
496  int sepStart = separator.match(s,0,&sepLength);
497  if (sepStart<=0) // no valid assignment statement
498  {
499  warn(name,lineNr,"Assignment of extension field expected!\n");
500  continue;
501  }
502  QCString key=s.left(sepStart);
503  QCString data=s.data() + sepStart + sepLength;
504 
505  if (key == "Title") rtf_title = data.data();
506  if (key == "Subject") rtf_subject = data.data();
507  if (key == "Comments") rtf_comments = data.data();
508  if (key == "Company") rtf_company = data.data();
509  if (key == "LogoFilename") rtf_logoFilename = data.data();
510  if (key == "Author") rtf_author = data.data();
511  if (key == "Manager") rtf_manager = data.data();
512  if (key == "DocumentType") rtf_documentType = data.data();
513  if (key == "DocumentId") rtf_documentId = data.data();
514  if (key == "Keywords") rtf_keywords = data.data();
515  lineNr++;
516  }
517 }
static QCString name
Definition: declinfo.cpp:673
QCString rtf_comments
Definition: rtfstyle.cpp:32
The QRegExp class provides pattern matching using regular expressions or wildcards.
Definition: qregexp.h:46
void msg(const char *fmt,...)
Definition: message.cpp:107
uint length() const
Definition: qcstring.h:195
QCString rtf_documentId
Definition: rtfstyle.cpp:38
char & at(uint i) const
Definition: qcstring.h:326
QCString rtf_documentType
Definition: rtfstyle.cpp:37
QCString rtf_manager
Definition: rtfstyle.cpp:36
QCString rtf_subject
Definition: rtfstyle.cpp:31
QCString left(uint len) const
Definition: qcstring.cpp:213
#define IO_ReadOnly
Definition: qiodevice.h:61
def key(type, name=None)
Definition: graph.py:13
QCString rtf_logoFilename
Definition: rtfstyle.cpp:34
QCString rtf_author
Definition: rtfstyle.cpp:35
const char * data() const
Definition: qcstring.h:207
void warn(const char *file, int line, const char *fmt,...)
Definition: message.cpp:183
QCString rtf_keywords
Definition: rtfstyle.cpp:39
void err(const char *fmt,...)
Definition: message.cpp:226
The QFile class is an I/O device that operates on files.
Definition: qfile.h:50
The QTextStream class provides basic functions for reading and writing text using a QIODevice...
Definition: qtextstream.h:53
QCString rtf_title
Definition: rtfstyle.cpp:30
unsigned uint
Definition: qglobal.h:351
QCString rtf_company
Definition: rtfstyle.cpp:33
static QCString * s
Definition: config.cpp:1042
void loadStylesheet ( const char *  name,
QDict< StyleData > &  dict 
)

Definition at line 428 of file rtfstyle.cpp.

429 {
430  QFile file(name);
431  if (!file.open(IO_ReadOnly))
432  {
433  err("Can't open RTF style sheet file %s. Using defaults.\n",name);
434  return;
435  }
436  msg("Loading RTF style sheet %s...\n",name);
437 
438  static const QRegExp separator("[ \t]*=[ \t]*");
439  uint lineNr=1;
440  QTextStream t(&file);
441  t.setEncoding(QTextStream::UnicodeUTF8);
442 
443  while (!t.eof())
444  {
445  QCString s(4096); // string buffer of max line length
446  s = t.readLine().stripWhiteSpace().utf8();
447  if (s.isEmpty() || s.at(0)=='#') continue; // skip blanks & comments
448  int sepLength;
449  int sepStart = separator.match(s,0,&sepLength);
450  if (sepStart<=0) // no valid assignment statement
451  {
452  warn(name,lineNr,"Assignment of style sheet name expected!\n");
453  continue;
454  }
455  QCString key=s.left(sepStart);
456  if (dict[key]==0) // not a valid style sheet name
457  {
458  warn(name,lineNr,"Invalid style sheet name %s ignored.\n",key.data());
459  continue;
460  }
461  StyleData* styleData = dict.find(key);
462  if (styleData == 0)
463  {
464  warn(name,lineNr,"Unknown style sheet name %s ignored.\n",key.data());
465  continue;
466  }
467  s+=" "; // add command separator
468  styleData->setStyle(s.data() + sepStart + sepLength, key.data());
469  lineNr++;
470  }
471 }
static QCString name
Definition: declinfo.cpp:673
bool isEmpty() const
Definition: qcstring.h:189
The QRegExp class provides pattern matching using regular expressions or wildcards.
Definition: qregexp.h:46
void msg(const char *fmt,...)
Definition: message.cpp:107
char & at(uint i) const
Definition: qcstring.h:326
bool setStyle(const char *s, const char *styleName)
Definition: rtfstyle.cpp:362
QCString left(uint len) const
Definition: qcstring.cpp:213
#define IO_ReadOnly
Definition: qiodevice.h:61
def key(type, name=None)
Definition: graph.py:13
const char * data() const
Definition: qcstring.h:207
void warn(const char *file, int line, const char *fmt,...)
Definition: message.cpp:183
void err(const char *fmt,...)
Definition: message.cpp:226
The QFile class is an I/O device that operates on files.
Definition: qfile.h:50
The QTextStream class provides basic functions for reading and writing text using a QIODevice...
Definition: qtextstream.h:53
unsigned uint
Definition: qglobal.h:351
static QCString * s
Definition: config.cpp:1042
QDict<StyleData> rtf_Style ( 257  )

Variable Documentation

QCString rtf_author

Definition at line 35 of file rtfstyle.cpp.

QCString rtf_comments

Definition at line 32 of file rtfstyle.cpp.

QCString rtf_company

Definition at line 33 of file rtfstyle.cpp.

QCString rtf_documentId

Definition at line 38 of file rtfstyle.cpp.

QCString rtf_documentType

Definition at line 37 of file rtfstyle.cpp.

QCString rtf_keywords

Definition at line 39 of file rtfstyle.cpp.

Definition at line 28 of file rtfstyle.cpp.

QCString rtf_logoFilename

Definition at line 34 of file rtfstyle.cpp.

QCString rtf_manager

Definition at line 36 of file rtfstyle.cpp.

Rtf_Style_Default rtf_Style_Default[]

Definition at line 43 of file rtfstyle.cpp.

char rtf_Style_Reset[] = "\\pard\\plain "

Definition at line 41 of file rtfstyle.cpp.

QCString rtf_subject

Definition at line 31 of file rtfstyle.cpp.

QCString rtf_title

Definition at line 30 of file rtfstyle.cpp.