My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
StyleData Struct Reference

#include <rtfstyle.h>

Public Member Functions

 StyleData (const char *reference, const char *definition)
 
 ~StyleData ()
 
bool setStyle (const char *s, const char *styleName)
 

Public Attributes

unsigned index
 
char * reference
 
char * definition
 

Static Public Attributes

static const QRegExp s_clause
 

Detailed Description

Definition at line 59 of file rtfstyle.h.

Constructor & Destructor Documentation

StyleData::StyleData ( const char *  reference,
const char *  definition 
)

Definition at line 341 of file rtfstyle.cpp.

References index, and s_clause.

{
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 ( )

Definition at line 356 of file rtfstyle.cpp.

References definition, and reference.

{
delete[] reference;
delete[] definition;
}

Member Function Documentation

bool StyleData::setStyle ( const char *  s,
const char *  styleName 
)

Definition at line 362 of file rtfstyle.cpp.

References definition, err(), index, reference, and s_clause.

Referenced by loadStylesheet().

{
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 == qstrncmp(end, "\\snext", 6))
break;
if (0 == qstrncmp(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;
}

Member Data Documentation

char* StyleData::definition

Definition at line 68 of file rtfstyle.h.

Referenced by RTFGenerator::beginRTFDocument(), setStyle(), and ~StyleData().

unsigned StyleData::index

Definition at line 66 of file rtfstyle.h.

Referenced by RTFGenerator::beginRTFDocument(), setStyle(), and StyleData().

char* StyleData::reference
const QRegExp StyleData::s_clause
static

Definition at line 74 of file rtfstyle.h.

Referenced by setStyle(), and StyleData().


The documentation for this struct was generated from the following files: