version 1.132, 2002/05/29 13:18:17
|
version 1.133, 2002/05/31 15:57:59
|
Line 197 static void CSSParseError (char *msg, c
|
Line 197 static void CSSParseError (char *msg, c
|
return; |
return; |
} |
} |
|
|
if (DocURL != NULL) |
if (DocURL) |
{ |
{ |
fprintf (ErrFile, "*** Errors/warnings in %s\n", DocURL); |
fprintf (ErrFile, "*** Errors/warnings in %s\n", DocURL); |
/* set to NULL as long as the CSS file doesn't change */ |
/* set to NULL as long as the CSS file doesn't change */ |
Line 222 static char *SkipProperty (char *ptr)
|
Line 222 static char *SkipProperty (char *ptr)
|
char c; |
char c; |
|
|
deb = ptr; |
deb = ptr; |
while (*ptr != EOS && *ptr != ';' && *ptr != '}') |
while (*ptr != EOS && *ptr != ';' && *ptr != '}' && *ptr != '"') |
ptr++; |
{ |
|
if (*ptr == '"' && (ptr == deb || ptr[-1] != '\\')) |
|
{ |
|
/* skip to the end of the string "..." */ |
|
ptr++; |
|
while (*ptr != '"' && ptr[-1] != '\\') |
|
ptr++; |
|
} |
|
ptr++; |
|
} |
/* print the skipped property */ |
/* print the skipped property */ |
c = *ptr; |
c = *ptr; |
*ptr = EOS; |
*ptr = EOS; |
Line 244 static char *SkipValue (char *ptr, ThotB
|
Line 253 static char *SkipValue (char *ptr, ThotB
|
char c; |
char c; |
|
|
deb = ptr; |
deb = ptr; |
while (*ptr != EOS && *ptr != ';' && *ptr != '}') |
while (*ptr != EOS && *ptr != ';' && *ptr != '}' && *ptr != '"') |
ptr++; |
{ |
|
if (*ptr == '"' && (ptr == deb || ptr[-1] != '\\')) |
|
{ |
|
/* skip to the end of the string "..." */ |
|
ptr++; |
|
while (*ptr != '"' && ptr[-1] != '\\') |
|
ptr++; |
|
} |
|
ptr++; |
|
} |
/* print the skipped property */ |
/* print the skipped property */ |
c = *ptr; |
c = *ptr; |
*ptr = EOS; |
*ptr = EOS; |
Line 1744 static char *ParseCSSFontFamily (Element
|
Line 1762 static char *ParseCSSFontFamily (Element
|
if (font.typed_data.value != 0) |
if (font.typed_data.value != 0) |
{ |
{ |
cssRule = SkipBlanksAndComments (cssRule); |
cssRule = SkipBlanksAndComments (cssRule); |
cssRule = SkipValue (cssRule, FALSE); |
if (*cssRule == ',') |
|
{ |
|
cssRule++; |
|
cssRule = SkipValue (cssRule, FALSE); |
|
} |
/* install the new presentation */ |
/* install the new presentation */ |
if (DoApply) |
if (DoApply) |
{ |
{ |
Line 1982 static char *ParseCSSFont (Element eleme
|
Line 2004 static char *ParseCSSFont (Element eleme
|
; |
; |
else |
else |
{ |
{ |
while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',') |
while (*cssRule != ';' && *cssRule != EOS) |
{ |
{ |
ptr = cssRule; |
ptr = cssRule; |
skippedNL = NewLineSkipped; |
skippedNL = NewLineSkipped; |
Line 3329 static void ParseCSSRule (Element eleme
|
Line 3351 static void ParseCSSRule (Element eleme
|
while (*cssRule != EOS) |
while (*cssRule != EOS) |
{ |
{ |
cssRule = SkipBlanksAndComments (cssRule); |
cssRule = SkipBlanksAndComments (cssRule); |
if (*cssRule == '{') |
if (*cssRule < 0x41 || *cssRule > 0x7A || |
|
(*cssRule > 0x5A && *cssRule < 0x60)) |
{ |
{ |
cssRule++; |
cssRule++; |
CSSParseError ("Invalid character", "{"); |
CSSParseError ("Invalid character", "{"); |
Line 3955 static char *ParseGenericSelector (char
|
Line 3978 static char *ParseGenericSelector (char
|
char *pseudoclasses[MAX_ANCESTORS]; |
char *pseudoclasses[MAX_ANCESTORS]; |
char *attrs[MAX_ANCESTORS]; |
char *attrs[MAX_ANCESTORS]; |
char *attrvals[MAX_ANCESTORS]; |
char *attrvals[MAX_ANCESTORS]; |
|
AttrMatch attrmatch[MAX_ANCESTORS]; |
int i, j, k, max; |
int i, j, k, max; |
int att, maxAttr, kind; |
int att, maxAttr, kind; |
int specificity, xmlType; |
int specificity, xmlType; |
Line 3971 static char *ParseGenericSelector (char
|
Line 3995 static char *ParseGenericSelector (char
|
pseudoclasses[i] = NULL; |
pseudoclasses[i] = NULL; |
attrs[i] = NULL; |
attrs[i] = NULL; |
attrvals[i] = NULL; |
attrvals[i] = NULL; |
|
attrmatch[i] = Txtmatch; |
ctxt->name[i] = 0; |
ctxt->name[i] = 0; |
ctxt->names_nb[i] = 0; |
ctxt->names_nb[i] = 0; |
ctxt->attrType[i] = 0; |
ctxt->attrType[i] = 0; |
ctxt->attrLevel[i] = 0; |
ctxt->attrLevel[i] = 0; |
ctxt->attrText[i] = NULL; |
ctxt->attrText[i] = NULL; |
|
ctxt->attrMatch[1] = Txtmatch; |
} |
} |
ctxt->box = 0; |
ctxt->box = 0; |
ctxt->type = 0; |
ctxt->type = 0; |
Line 4095 static char *ParseGenericSelector (char
|
Line 4120 static char *ParseGenericSelector (char
|
selector++; |
selector++; |
while (*selector != EOS && *selector != ']' && |
while (*selector != EOS && *selector != ']' && |
*selector != '=' && *selector != '~' && |
*selector != '=' && *selector != '~' && |
*selector != '^') |
*selector != '|' && *selector != '^' && |
|
*selector != '!') |
*cur++ = *selector++; |
*cur++ = *selector++; |
|
/* check matching */ |
|
if (*selector == '~') |
|
{ |
|
attrmatch[0] = Txtword; |
|
selector++; |
|
} |
|
else if (*selector == '|') |
|
{ |
|
attrmatch[0] = Txtsubstring; |
|
selector++; |
|
} |
|
else |
|
attrmatch[0] = Txtmatch; |
/* close the word */ |
/* close the word */ |
*cur++ = EOS; |
*cur++ = EOS; |
/* point to the attribute in sel[] if it's valid name */ |
/* point to the attribute in sel[] if it's valid name */ |
Line 4132 static char *ParseGenericSelector (char
|
Line 4171 static char *ParseGenericSelector (char
|
DoApply = FALSE; |
DoApply = FALSE; |
} |
} |
else |
else |
*cur++ = *selector++; |
{ |
|
*cur++ = tolower (*selector); |
|
selector++; |
|
} |
} |
} |
/* there is a value */ |
/* there is a value */ |
if (*selector == '"') |
if (*selector == '"') |
Line 4146 static char *ParseGenericSelector (char
|
Line 4188 static char *ParseGenericSelector (char
|
/* end of the attribute */ |
/* end of the attribute */ |
if (*selector != ']') |
if (*selector != ']') |
{ |
{ |
if (*selector == '^') |
selector[1] = EOS; |
CSSParseError ("Not supported selector", "^"); |
CSSParseError ("Not supported selector", selector); |
else |
selector += 2; |
CSSParseError ("Invalid attribute", attrs[0]); |
|
DoApply = FALSE; |
DoApply = FALSE; |
} |
} |
else |
else |
Line 4192 static char *ParseGenericSelector (char
|
Line 4233 static char *ParseGenericSelector (char
|
names[i] = names[i - 1]; |
names[i] = names[i - 1]; |
ids[i] = ids[i - 1]; |
ids[i] = ids[i - 1]; |
classes[i] = classes[i - 1]; |
classes[i] = classes[i - 1]; |
|
pseudoclasses[i] = pseudoclasses[i - 1]; |
attrs[i] = attrs[i - 1]; |
attrs[i] = attrs[i - 1]; |
attrvals[i] = attrvals[i - 1]; |
attrvals[i] = attrvals[i - 1]; |
pseudoclasses[i] = pseudoclasses[i - 1]; |
attrmatch[i] = attrmatch[i - 1]; |
} |
} |
} |
} |
} |
} |
Line 4391 static char *ParseGenericSelector (char
|
Line 4433 static char *ParseGenericSelector (char
|
it's represented by the element type, not by an attribute */ |
it's represented by the element type, not by an attribute */ |
att = 0; |
att = 0; |
ctxt->attrType[j] = att; |
ctxt->attrType[j] = att; |
|
ctxt->attrMatch[j] = attrmatch[i]; |
attrType.AttrSSchema = ctxt->schema; |
attrType.AttrSSchema = ctxt->schema; |
attrType.AttrTypeNum = att; |
attrType.AttrTypeNum = att; |
if (i == 0 && att == 0 && ctxt->schema == NULL) |
if (i == 0 && att == 0 && ctxt->schema == NULL) |
Line 4782 void ApplyCSSRules (Element el, char *cs
|
Line 4825 void ApplyCSSRules (Element el, char *cs
|
This function uses the current css context or creates it. It's able |
This function uses the current css context or creates it. It's able |
to work on the given buffer or call GetNextChar to read the parsed |
to work on the given buffer or call GetNextChar to read the parsed |
file. |
file. |
|
The parameter url gives the URL of the style shheet parsed. |
Parameter numberOfLinesRead indicates the number of lines already |
Parameter numberOfLinesRead indicates the number of lines already |
read in the file. |
read in the file. |
Parameter withUndo indicates whether the changes made in the document |
Parameter withUndo indicates whether the changes made in the document |
structure and content have to be registered in the Undo queue or not |
structure and content have to be registered in the Undo queue or not |
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
char ReadCSSRules (Document docRef, CSSInfoPtr css, char *buffer, |
char ReadCSSRules (Document docRef, CSSInfoPtr css, char *buffer, char *url, |
int numberOfLinesRead, ThotBool withUndo) |
int numberOfLinesRead, ThotBool withUndo) |
{ |
{ |
DisplayMode dispMode; |
DisplayMode dispMode; |
char c; |
char c; |
char *cssRule, *base; |
char *cssRule, *base, *saveDocURL; |
int index; |
int index; |
int CSSindex; |
int CSSindex; |
int CSScomment; |
int CSScomment; |
Line 4832 char ReadCSSRules (Document docRef, CSSI
|
Line 4876 char ReadCSSRules (Document docRef, CSSI
|
|
|
/* register parsed CSS file and the document to which CSS are to be applied */ |
/* register parsed CSS file and the document to which CSS are to be applied */ |
ParsedDoc = docRef; |
ParsedDoc = docRef; |
if (css->url) |
if (url) |
DocURL = css->url; |
DocURL = url; |
else |
else |
/* the CSS source in within the document itself */ |
/* the CSS source in within the document itself */ |
DocURL = DocumentURLs[docRef]; |
DocURL = DocumentURLs[docRef]; |
Line 5016 char ReadCSSRules (Document docRef, CSSI
|
Line 5060 char ReadCSSRules (Document docRef, CSSI
|
cssRule++; |
cssRule++; |
if (quoted) |
if (quoted) |
cssRule--; |
cssRule--; |
*cssRule = EOS; |
|
if (TtaIsPrinting ()) |
|
base = strstr (&cssRule[1], "print"); |
|
else |
|
base = strstr (&cssRule[1], "screen"); |
|
if (base == NULL) |
|
base = strstr (&cssRule[1], "all"); |
|
if (base == NULL) |
|
ignoreImport = TRUE; |
|
if (!ignoreImport) |
|
LoadStyleSheet (base, docRef, NULL, css, |
|
css->media[docRef], |
|
css->category == CSS_USER_STYLE); |
|
} |
} |
} |
} |
else if (*cssRule == '"') |
else if (*cssRule == '"') |
Line 5043 char ReadCSSRules (Document docRef, CSSI
|
Line 5074 char ReadCSSRules (Document docRef, CSSI
|
base = cssRule; |
base = cssRule; |
while (*cssRule != EOS && *cssRule != '"') |
while (*cssRule != EOS && *cssRule != '"') |
cssRule++; |
cssRule++; |
*cssRule = EOS; |
} |
if (!ignoreImport) |
if (*cssRule != EOS) |
LoadStyleSheet (base, docRef, NULL, css, |
/* isolate the file name */ |
css->media[docRef], |
*cssRule = EOS; |
css->category == CSS_USER_STYLE); |
/* check if a media is defined */ |
|
cssRule++; |
|
cssRule = TtaSkipBlanks (cssRule); |
|
if (*cssRule != ';') |
|
{ |
|
if (TtaIsPrinting ()) |
|
ignoreImport = (strncasecmp (cssRule, "print", 5) && |
|
strncasecmp (cssRule, "all", 3)); |
|
else |
|
ignoreImport = (strncasecmp (cssRule, "screen", 6) && |
|
strncasecmp (cssRule, "all", 3)); |
|
} |
|
if (!ignoreImport) |
|
{ |
|
/* save the displayed URL when an error is reported */ |
|
saveDocURL = DocURL; |
|
LoadStyleSheet (base, docRef, NULL, css, |
|
css->media[docRef], |
|
css->category == CSS_USER_STYLE); |
|
/* restore the displayed URL when an error is reported */ |
|
DocURL = saveDocURL; |
} |
} |
/* restore the number of lines */ |
/* restore the number of lines */ |
LineNumber = newlines; |
LineNumber = newlines; |