Annotation of Amaya/amaya/styleparser.c, revision 1.194
1.1 cvs 1: /*
2: *
1.165 vatton 3: * (c) COPYRIGHT INRIA and W3C, 1996-2003
1.1 cvs 4: * Please first read the full copyright statement in file COPYRIGHT.
5: *
6: */
1.164 quint 7:
1.1 cvs 8: /*
1.164 quint 9: * Everything directly related to the CSS syntax should now hopefully
1.1 cvs 10: * be contained in this module.
11: *
12: * Author: I. Vatton
13: *
14: */
15:
16: /* Included headerfiles */
17: #define THOT_EXPORT extern
18: #include "amaya.h"
19: #include "css.h"
1.25 cvs 20: #include "fetchHTMLname.h"
1.100 vatton 21: #include "SVG.h"
1.107 cvs 22: #include "XML.h"
1.141 cvs 23: #include "document.h"
1.1 cvs 24:
25: typedef struct _BackgroundImageCallbackBlock
26: {
27: Element el;
28: PSchema tsch;
1.185 vatton 29: CSSInfoPtr css;
1.1 cvs 30: union
31: {
32: PresentationContextBlock specific;
33: GenericContextBlock generic;
34: } context;
35: }
36: BackgroundImageCallbackBlock, *BackgroundImageCallbackPtr;
37:
38: #include "AHTURLTools_f.h"
39: #include "HTMLpresentation_f.h"
40: #include "HTMLimage_f.h"
41: #include "UIcss_f.h"
42: #include "css_f.h"
1.24 cvs 43: #include "fetchHTMLname_f.h"
1.91 cvs 44: #include "fetchXMLname_f.h"
1.1 cvs 45: #include "html2thot_f.h"
1.91 cvs 46: #include "init_f.h"
1.1 cvs 47: #include "styleparser_f.h"
48:
49: #define MAX_BUFFER_LENGTH 200
50: /*
51: * A PropertyParser is a function used to parse the
52: * description substring associated to a given style attribute
1.59 cvs 53: * e.g.: "red" for a color attribute or "12pt bold helvetica"
1.1 cvs 54: * for a font attribute.
55: */
1.79 cvs 56: typedef char *(*PropertyParser) (Element element,
1.56 cvs 57: PSchema tsch,
58: PresentationContext context,
1.79 cvs 59: char *cssRule,
1.56 cvs 60: CSSInfoPtr css,
61: ThotBool isHTML);
1.1 cvs 62:
63: /* Description of the set of CSS properties supported */
64: typedef struct CSSProperty
65: {
1.79 cvs 66: char *name;
1.25 cvs 67: PropertyParser parsing_function;
1.1 cvs 68: }
69: CSSProperty;
70:
71: struct unit_def
72: {
1.79 cvs 73: char *sign;
1.1 cvs 74: unsigned int unit;
75: };
76:
77: static struct unit_def CSSUnitNames[] =
78: {
1.184 vatton 79: {"pt", UNIT_PT},
80: {"pc", UNIT_PC},
81: {"in", UNIT_IN},
82: {"cm", UNIT_CM},
83: {"mm", UNIT_MM},
84: {"em", UNIT_EM},
85: {"px", UNIT_PX},
86: {"ex", UNIT_XHEIGHT},
87: {"%", UNIT_PERCENT}
1.1 cvs 88: };
89:
90: #define NB_UNITS (sizeof(CSSUnitNames) / sizeof(struct unit_def))
1.86 cvs 91: static char *DocURL = NULL; /* The parsed CSS file */
92: static Document ParsedDoc; /* The document to which CSS are to be applied */
93: static int LineNumber = -1; /* The line where the error occurs */
1.93 vatton 94: static int NewLineSkipped = 0;
1.116 vatton 95: static ThotBool DoApply = TRUE;
1.1 cvs 96:
97: /*----------------------------------------------------------------------
98: SkipWord:
99: ----------------------------------------------------------------------*/
1.79 cvs 100: static char *SkipWord (char *ptr)
1.1 cvs 101: {
1.168 vatton 102: while (isalnum((int)*ptr) || *ptr == '-' || *ptr == '#' || *ptr == '%')
103: ptr++;
1.1 cvs 104: return (ptr);
105: }
106:
107: /*----------------------------------------------------------------------
1.13 cvs 108: SkipBlanksAndComments:
109: ----------------------------------------------------------------------*/
1.82 cvs 110: char *SkipBlanksAndComments (char *ptr)
1.13 cvs 111: {
1.93 vatton 112: /* skip spaces */
1.155 cheyroul 113: while (*ptr == SPACE ||
114: *ptr == BSPACE ||
115: *ptr == EOL ||
116: *ptr == TAB ||
117: *ptr == __CR__)
1.93 vatton 118: {
119: if (*ptr == EOL)
120: /* increment the number of newline skipped */
121: NewLineSkipped++;
122: ptr++;
123: }
1.155 cheyroul 124: while (ptr[0] == '/' &&
125: ptr[1] == '*')
1.13 cvs 126: {
127: /* look for the end of the comment */
128: ptr = &ptr[2];
129: while (ptr[0] != EOS && (ptr[0] != '*' || ptr[1] != '/'))
130: ptr++;
131: if (ptr[0] != EOS)
132: ptr = &ptr[2];
1.93 vatton 133: /* skip spaces */
134: while (*ptr == SPACE || *ptr == BSPACE || *ptr == EOL ||
135: *ptr == TAB || *ptr == __CR__)
136: {
137: if (*ptr == EOL)
138: /* increment the number of newline skipped */
139: NewLineSkipped++;
140: ptr++;
141: }
1.13 cvs 142: }
143: return (ptr);
144: }
145:
1.49 cvs 146: /*----------------------------------------------------------------------
1.161 quint 147: SkipQuotedString
1.1 cvs 148: ----------------------------------------------------------------------*/
1.79 cvs 149: static char *SkipQuotedString (char *ptr, char quote)
1.1 cvs 150: {
1.14 cvs 151: ThotBool stop;
1.1 cvs 152:
153: stop = FALSE;
154: while (!stop)
155: {
156: if (*ptr == quote)
157: {
158: ptr++;
159: stop = TRUE;
160: }
1.82 cvs 161: else if (*ptr == EOS)
1.1 cvs 162: stop = TRUE;
1.82 cvs 163: else if (*ptr == '\\')
1.1 cvs 164: /* escape character */
165: {
166: ptr++;
1.82 cvs 167: if ((*ptr >= '0' && *ptr <= '9') || (*ptr >= 'A' && *ptr <= 'F') ||
168: (*ptr >= 'a' && *ptr <= 'f'))
1.1 cvs 169: {
170: ptr++;
1.82 cvs 171: if ((*ptr >= '0' && *ptr <= '9') || (*ptr >= 'A' && *ptr <= 'F') ||
172: (*ptr >= 'a' && *ptr <= 'f'))
1.1 cvs 173: ptr++;
174: }
175: else
176: ptr++;
177: }
178: else
179: ptr++;
180: }
181: return (ptr);
182: }
183:
184: /*----------------------------------------------------------------------
1.168 vatton 185: CSSPrintError
1.86 cvs 186: print the error message msg on stderr.
187: When the line is 0 ask to expat the current line number
188: ----------------------------------------------------------------------*/
1.168 vatton 189: static void CSSPrintError (char *msg, char *value)
1.86 cvs 190: {
191: if (!TtaIsPrinting () && ParsedDoc > 0)
192: {
193: if (!ErrFile)
194: {
1.90 cvs 195: if (OpenParsingErrors (ParsedDoc) == FALSE)
1.86 cvs 196: return;
197: }
198:
1.133 vatton 199: if (DocURL)
1.86 cvs 200: {
1.94 cvs 201: fprintf (ErrFile, "*** Errors/warnings in %s\n", DocURL);
1.86 cvs 202: /* set to NULL as long as the CSS file doesn't change */
203: DocURL = NULL;
204: }
1.89 cvs 205: CSSErrorsFound = TRUE;
1.86 cvs 206: if (LineNumber < 0)
1.162 quint 207: fprintf (ErrFile, " In Style attribute, %s \"%s\"\n", msg, value);
1.86 cvs 208: else
1.162 quint 209: fprintf (ErrFile, " line %d: %s \"%s\"\n", LineNumber+NewLineSkipped,
1.93 vatton 210: msg, value);
1.86 cvs 211: }
212: }
213:
1.168 vatton 214: /*----------------------------------------------------------------------
215: CSSParseError
216: print the error message msg on stderr.
217: When the line is 0 ask to expat the current line number
218: ----------------------------------------------------------------------*/
219: static void CSSParseError (char *msg, char *value, char *endvalue)
220: {
221: char c = EOS;
222:
223: if (endvalue)
224: {
225: /* close the string here */
226: c = *endvalue;
227: *endvalue = EOS;
228: }
229: CSSPrintError (msg, value);
230: if (endvalue)
231: *endvalue = c;
232: }
233:
1.89 cvs 234:
1.86 cvs 235: /*----------------------------------------------------------------------
1.168 vatton 236: SkipProperty skips a property and display and error message
1.86 cvs 237: ----------------------------------------------------------------------*/
238: static char *SkipProperty (char *ptr)
239: {
240: char *deb;
241: char c;
242:
243: deb = ptr;
1.135 vatton 244: while (*ptr != EOS && *ptr != ';' && *ptr != '}')
1.133 vatton 245: {
1.194 ! vatton 246: if (*ptr == '"' && (ptr == deb || ptr[-1] != '\\'))
1.133 vatton 247: {
248: /* skip to the end of the string "..." */
249: ptr++;
1.194 ! vatton 250: while (*ptr != EOS &&
! 251: (*ptr != '"' || (*ptr == '"' && ptr[-1] == '\\')))
1.133 vatton 252: ptr++;
253: }
254: ptr++;
255: }
1.95 cvs 256: /* print the skipped property */
1.86 cvs 257: c = *ptr;
258: *ptr = EOS;
1.95 cvs 259: #ifdef CSS_WARNING
1.86 cvs 260: if (*deb != EOS)
1.168 vatton 261: CSSPrintError ("CSS property ignored", deb);
1.95 cvs 262: #endif /* CSS_WARNING */
1.86 cvs 263: *ptr = c;
264: return (ptr);
265: }
266:
267: /*----------------------------------------------------------------------
1.168 vatton 268: SkipValue
269: skips the value and display an error message if msg is not NULL
1.1 cvs 270: ----------------------------------------------------------------------*/
1.168 vatton 271: static char *SkipValue (char *msg, char *ptr)
1.1 cvs 272: {
1.86 cvs 273: char *deb;
274: char c;
275:
276: deb = ptr;
1.135 vatton 277: while (*ptr != EOS && *ptr != ';' && *ptr != '}')
1.133 vatton 278: {
279: if (*ptr == '"' && (ptr == deb || ptr[-1] != '\\'))
280: {
281: /* skip to the end of the string "..." */
282: ptr++;
1.184 vatton 283: while (*ptr != '"' || (ptr[0] == '"' && ptr[-1] == '\\'))
1.133 vatton 284: ptr++;
285: }
286: ptr++;
287: }
1.95 cvs 288: /* print the skipped property */
1.86 cvs 289: c = *ptr;
290: *ptr = EOS;
1.168 vatton 291: if (msg && *deb != EOS && *deb != ',')
292: CSSPrintError (msg, deb);
1.86 cvs 293: *ptr = c;
1.1 cvs 294: return (ptr);
295: }
296:
297: /*----------------------------------------------------------------------
1.64 cvs 298: ParseNumber:
299: parse a number and returns the corresponding value.
1.1 cvs 300: ----------------------------------------------------------------------*/
1.79 cvs 301: char *ParseNumber (char *cssRule, PresentationValue *pval)
1.1 cvs 302: {
303: int val = 0;
304: int minus = 0;
305: int valid = 0;
306: int f = 0;
1.14 cvs 307: ThotBool real = FALSE;
1.1 cvs 308:
1.184 vatton 309: pval->typed_data.unit = UNIT_REL;
1.1 cvs 310: pval->typed_data.real = FALSE;
1.82 cvs 311: cssRule = SkipBlanksAndComments (cssRule);
312: if (*cssRule == '-')
1.1 cvs 313: {
314: minus = 1;
315: cssRule++;
1.82 cvs 316: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 317: }
318:
1.82 cvs 319: if (*cssRule == '+')
1.1 cvs 320: {
321: cssRule++;
1.82 cvs 322: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 323: }
324:
1.82 cvs 325: while ((*cssRule >= '0') && (*cssRule <= '9'))
1.1 cvs 326: {
327: val *= 10;
1.82 cvs 328: val += *cssRule - '0';
1.1 cvs 329: cssRule++;
330: valid = 1;
331: }
332:
1.82 cvs 333: if (*cssRule == '.')
1.1 cvs 334: {
335: real = TRUE;
336: f = val;
337: val = 0;
338: cssRule++;
339: /* keep only 3 digits */
1.82 cvs 340: if (*cssRule >= '0' && *cssRule <= '9')
1.1 cvs 341: {
1.82 cvs 342: val = (*cssRule - '0') * 100;
1.1 cvs 343: cssRule++;
1.82 cvs 344: if (*cssRule >= '0' && *cssRule <= '9')
1.1 cvs 345: {
1.82 cvs 346: val += (*cssRule - '0') * 10;
1.1 cvs 347: cssRule++;
1.82 cvs 348: if ((*cssRule >= '0') && (*cssRule <= '9'))
1.1 cvs 349: {
1.82 cvs 350: val += *cssRule - '0';
1.1 cvs 351: cssRule++;
352: }
353: }
354:
1.82 cvs 355: while (*cssRule >= '0' && *cssRule <= '9')
1.1 cvs 356: cssRule++;
357: valid = 1;
358: }
359: }
360:
361: if (!valid)
362: {
1.184 vatton 363: pval->typed_data.unit = UNIT_INVALID;
1.1 cvs 364: pval->typed_data.value = 0;
365: }
366: else
367: {
368: pval->typed_data.real = real;
369: if (real)
370: {
371: if (minus)
372: pval->typed_data.value = -(f * 1000 + val);
373: else
374: pval->typed_data.value = f * 1000 + val;
375: }
376: else
377: {
378: if (minus)
379: pval->typed_data.value = -val;
380: else
381: pval->typed_data.value = val;
382: }
1.64 cvs 383: }
384: return (cssRule);
385: }
1.155 cheyroul 386: /*----------------------------------------------------------------------
387: ParseClampedUnit:
388: parse a CSS Unit substring and returns the corresponding
389: value and its unit.
390: [0,1]
391: or
392: [0,100] in %
393: ----------------------------------------------------------------------*/
394: char *ParseClampedUnit (char *text,
395: PresentationValue *pval)
396: {
1.170 cheyroul 397: float clamped_value;
398: int int_clamped_value;
1.155 cheyroul 399:
400: if (*(text + strlen (text) -1) == '%')
401: {
1.170 cheyroul 402: int_clamped_value = atoi (text);
403: if (int_clamped_value < 0 ||
404: int_clamped_value > 100)
405: int_clamped_value = 1000;
1.155 cheyroul 406: else
1.170 cheyroul 407: int_clamped_value = int_clamped_value * 10;
1.155 cheyroul 408: }
409: else
410: {
1.170 cheyroul 411: clamped_value = (float) atof (text);
412: if (clamped_value < 0.0
413: || clamped_value > 1.0)
414: int_clamped_value = 1000;
1.155 cheyroul 415: else
1.170 cheyroul 416: int_clamped_value = (int) (clamped_value * 1000);
1.155 cheyroul 417: }
1.184 vatton 418: pval->typed_data.unit = UNIT_REL;
1.170 cheyroul 419: pval->typed_data.value = int_clamped_value;
1.193 vatton 420: pval->typed_data.real = FALSE;
1.170 cheyroul 421: pval->data = int_clamped_value;
1.155 cheyroul 422: return (SkipWord (text));
423: }
1.64 cvs 424:
425: /*----------------------------------------------------------------------
426: ParseCSSUnit:
427: parse a CSS Unit substring and returns the corresponding
428: value and its unit.
429: ----------------------------------------------------------------------*/
1.82 cvs 430: char *ParseCSSUnit (char *cssRule, PresentationValue *pval)
1.64 cvs 431: {
432: unsigned int uni;
433:
1.184 vatton 434: pval->typed_data.unit = UNIT_REL;
1.64 cvs 435: cssRule = ParseNumber (cssRule, pval);
1.184 vatton 436: if (pval->typed_data.unit == UNIT_INVALID)
1.64 cvs 437: cssRule = SkipWord (cssRule);
438: else
439: {
1.82 cvs 440: cssRule = SkipBlanksAndComments (cssRule);
1.64 cvs 441: for (uni = 0; uni < NB_UNITS; uni++)
442: {
1.82 cvs 443: if (!strncasecmp (CSSUnitNames[uni].sign, cssRule,
444: strlen (CSSUnitNames[uni].sign)))
1.64 cvs 445: {
446: pval->typed_data.unit = CSSUnitNames[uni].unit;
1.82 cvs 447: return (cssRule + strlen (CSSUnitNames[uni].sign));
1.64 cvs 448: }
449: }
450: /* not in the list of predefined units */
1.184 vatton 451: pval->typed_data.unit = UNIT_BOX;
1.1 cvs 452: }
453: return (cssRule);
454: }
455:
1.43 cvs 456: /*----------------------------------------------------------------------
457: ParseBorderValue
458: ----------------------------------------------------------------------*/
1.79 cvs 459: static char *ParseBorderValue (char *cssRule, PresentationValue *border)
1.43 cvs 460: {
1.168 vatton 461: char *ptr;
462:
1.43 cvs 463: /* first parse the attribute string */
464: border->typed_data.value = 0;
1.184 vatton 465: border->typed_data.unit = UNIT_INVALID;
1.43 cvs 466: border->typed_data.real = FALSE;
1.82 cvs 467: if (!strncasecmp (cssRule, "thin", 4))
1.43 cvs 468: {
1.184 vatton 469: border->typed_data.unit = UNIT_PX;
1.43 cvs 470: border->typed_data.value = 1;
471: cssRule = SkipWord (cssRule);
472: }
1.82 cvs 473: else if (!strncasecmp (cssRule, "medium", 6))
1.43 cvs 474: {
1.184 vatton 475: border->typed_data.unit = UNIT_PX;
1.43 cvs 476: border->typed_data.value = 3;
477: cssRule = SkipWord (cssRule);
478: }
1.82 cvs 479: else if (!strncasecmp (cssRule, "thick", 5))
1.43 cvs 480: {
1.184 vatton 481: border->typed_data.unit = UNIT_PX;
1.43 cvs 482: border->typed_data.value = 5;
483: cssRule = SkipWord (cssRule);
484: }
1.110 vatton 485: else if (isdigit (*cssRule) || *cssRule == '.')
1.166 vatton 486: {
1.168 vatton 487: ptr = cssRule;
1.166 vatton 488: cssRule = ParseCSSUnit (cssRule, border);
1.168 vatton 489: if (border->typed_data.value == 0)
1.184 vatton 490: border->typed_data.unit = UNIT_PX;
491: else if (border->typed_data.unit == UNIT_INVALID ||
492: border->typed_data.unit == UNIT_BOX)
1.168 vatton 493: {
1.184 vatton 494: border->typed_data.unit = UNIT_INVALID;
1.168 vatton 495: border->typed_data.value = 0;
496: CSSParseError ("Invalid border-width value", ptr, cssRule);
497: }
1.166 vatton 498: }
1.43 cvs 499: return (cssRule);
500: }
501:
502: /*----------------------------------------------------------------------
503: ParseBorderStyle
504: ----------------------------------------------------------------------*/
1.79 cvs 505: static char *ParseBorderStyle (char *cssRule, PresentationValue *border)
1.43 cvs 506: {
507: /* first parse the attribute string */
508: border->typed_data.value = 0;
1.184 vatton 509: border->typed_data.unit = UNIT_PX;
1.43 cvs 510: border->typed_data.real = FALSE;
1.82 cvs 511: if (!strncasecmp (cssRule, "none", 4))
1.184 vatton 512: border->typed_data.value = BorderStyleNone;
1.82 cvs 513: else if (!strncasecmp (cssRule, "hidden", 6))
1.184 vatton 514: border->typed_data.value = BorderStyleHidden;
1.82 cvs 515: else if (!strncasecmp (cssRule, "dotted", 6))
1.184 vatton 516: border->typed_data.value = BorderStyleDotted;
1.82 cvs 517: else if (!strncasecmp (cssRule, "dashed", 6))
1.184 vatton 518: border->typed_data.value = BorderStyleDashed;
1.82 cvs 519: else if (!strncasecmp (cssRule, "solid", 5))
1.184 vatton 520: border->typed_data.value = BorderStyleSolid;
1.82 cvs 521: else if (!strncasecmp (cssRule, "double", 6))
1.184 vatton 522: border->typed_data.value = BorderStyleDouble;
1.82 cvs 523: else if (!strncasecmp (cssRule, "groove", 6))
1.184 vatton 524: border->typed_data.value = BorderStyleGroove;
1.82 cvs 525: else if (!strncasecmp (cssRule, "ridge", 5))
1.184 vatton 526: border->typed_data.value = BorderStyleRidge;
1.82 cvs 527: else if (!strncasecmp (cssRule, "inset", 5))
1.184 vatton 528: border->typed_data.value = BorderStyleInset;
1.82 cvs 529: else if (!strncasecmp (cssRule, "outset", 6))
1.184 vatton 530: border->typed_data.value = BorderStyleOutset;
1.43 cvs 531: else
1.44 cvs 532: {
533: /* invalid style */
1.184 vatton 534: border->typed_data.unit = UNIT_INVALID;
1.44 cvs 535: return (cssRule);
536: }
1.43 cvs 537: /* the value is parsed now */
538: cssRule = SkipWord (cssRule);
539: return (cssRule);
540: }
541:
542: /*----------------------------------------------------------------------
1.59 cvs 543: ParseCSSColor: parse a CSS color attribute string
1.43 cvs 544: we expect the input string describing the attribute to be
545: either a color name, a 3 tuple or an hexadecimal encoding.
546: The color used will be approximed from the current color
547: table
548: ----------------------------------------------------------------------*/
1.79 cvs 549: static char *ParseCSSColor (char *cssRule, PresentationValue * val)
1.43 cvs 550: {
1.79 cvs 551: char *ptr;
1.43 cvs 552: unsigned short redval = (unsigned short) -1;
553: unsigned short greenval = 0; /* composant of each RGB */
554: unsigned short blueval = 0; /* default to red if unknown ! */
555: int best = 0; /* best color in list found */
556:
1.82 cvs 557: cssRule = SkipBlanksAndComments (cssRule);
1.184 vatton 558: val->typed_data.unit = UNIT_INVALID;
1.43 cvs 559: val->typed_data.real = FALSE;
560: val->typed_data.value = 0;
1.57 cvs 561: ptr = TtaGiveRGB (cssRule, &redval, &greenval, &blueval);
1.135 vatton 562: if (!strncasecmp (cssRule, "inherit", 7))
563: {
564: cssRule = SkipWord (cssRule);
565: return (cssRule);
566: }
1.57 cvs 567: if (ptr == cssRule)
1.43 cvs 568: {
1.168 vatton 569: cssRule = SkipWord (cssRule);
570: CSSParseError ("Invalid color value", ptr, cssRule);
1.43 cvs 571: val->typed_data.value = 0;
1.184 vatton 572: val->typed_data.unit = UNIT_INVALID;
1.43 cvs 573: }
574: else
575: {
576: best = TtaGetThotColor (redval, greenval, blueval);
577: val->typed_data.value = best;
1.184 vatton 578: val->typed_data.unit = UNIT_REL;
1.57 cvs 579: cssRule = ptr;
1.43 cvs 580: }
581: val->typed_data.real = FALSE;
1.65 cvs 582: return (cssRule);
1.43 cvs 583: }
1.1 cvs 584:
585: /*----------------------------------------------------------------------
1.117 vatton 586: CheckImportantRule updates the field important of the context.
587: ----------------------------------------------------------------------*/
588: static char *CheckImportantRule (char *cssRule, PresentationContext context)
589: {
590: cssRule = SkipBlanksAndComments (cssRule);
1.120 vatton 591: if (*cssRule != '!')
592: context->important = FALSE;
593: else
1.117 vatton 594: {
1.120 vatton 595: cssRule++;
596: cssRule = SkipBlanksAndComments (cssRule);
597: if (!strncasecmp (cssRule, "important", 9))
598: {
599: context->important = TRUE;
600: cssRule += 9;
601: }
602: else
603: context->important = FALSE;
1.117 vatton 604: }
605: return (cssRule);
606: }
607:
608: /*----------------------------------------------------------------------
1.59 cvs 609: ParseCSSBorderTopWidth: parse a CSS BorderTopWidth
1.1 cvs 610: attribute string.
611: ----------------------------------------------------------------------*/
1.79 cvs 612: static char *ParseCSSBorderTopWidth (Element element, PSchema tsch,
613: PresentationContext context,
614: char *cssRule, CSSInfoPtr css,
615: ThotBool isHTML)
1.1 cvs 616: {
1.41 cvs 617: PresentationValue border;
618:
1.82 cvs 619: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 620: cssRule = ParseBorderValue (cssRule, &border);
1.184 vatton 621: if (border.typed_data.unit != UNIT_INVALID && DoApply)
1.44 cvs 622: {
1.117 vatton 623: /* check if it's an important rule */
624: if (tsch)
625: cssRule = CheckImportantRule (cssRule, context);
1.44 cvs 626: TtaSetStylePresentation (PRBorderTopWidth, element, tsch, context, border);
627: border.typed_data.value = 1;
1.184 vatton 628: border.typed_data.unit = UNIT_REL;
1.44 cvs 629: }
1.1 cvs 630: return (cssRule);
631: }
632:
633: /*----------------------------------------------------------------------
1.59 cvs 634: ParseCSSBorderBottomWidth: parse a CSS BorderBottomWidth
1.1 cvs 635: attribute string.
636: ----------------------------------------------------------------------*/
1.79 cvs 637: static char *ParseCSSBorderBottomWidth (Element element, PSchema tsch,
638: PresentationContext context,
639: char *cssRule, CSSInfoPtr css,
640: ThotBool isHTML)
1.1 cvs 641: {
1.41 cvs 642: PresentationValue border;
643:
1.82 cvs 644: cssRule = SkipBlanksAndComments (cssRule);
1.41 cvs 645: /* first parse the attribute string */
1.43 cvs 646: cssRule = ParseBorderValue (cssRule, &border);
1.184 vatton 647: if (border.typed_data.unit != UNIT_INVALID && DoApply)
1.44 cvs 648: {
1.117 vatton 649: /* check if it's an important rule */
650: if (tsch)
651: cssRule = CheckImportantRule (cssRule, context);
1.44 cvs 652: TtaSetStylePresentation (PRBorderBottomWidth, element, tsch, context, border);
653: border.typed_data.value = 1;
1.184 vatton 654: border.typed_data.unit = UNIT_REL;
1.44 cvs 655: }
1.1 cvs 656: return (cssRule);
657: }
658:
659: /*----------------------------------------------------------------------
1.59 cvs 660: ParseCSSBorderLeftWidth: parse a CSS BorderLeftWidth
1.1 cvs 661: attribute string.
662: ----------------------------------------------------------------------*/
1.79 cvs 663: static char *ParseCSSBorderLeftWidth (Element element, PSchema tsch,
664: PresentationContext context,
665: char *cssRule, CSSInfoPtr css,
666: ThotBool isHTML)
1.1 cvs 667: {
1.41 cvs 668: PresentationValue border;
669:
1.82 cvs 670: cssRule = SkipBlanksAndComments (cssRule);
1.41 cvs 671: /* first parse the attribute string */
1.43 cvs 672: cssRule = ParseBorderValue (cssRule, &border);
1.184 vatton 673: if (border.typed_data.unit != UNIT_INVALID && DoApply)
1.44 cvs 674: {
1.117 vatton 675: /* check if it's an important rule */
676: if (tsch)
677: cssRule = CheckImportantRule (cssRule, context);
1.44 cvs 678: TtaSetStylePresentation (PRBorderLeftWidth, element, tsch, context, border);
679: border.typed_data.value = 1;
1.184 vatton 680: border.typed_data.unit = UNIT_REL;
1.44 cvs 681: }
1.1 cvs 682: return (cssRule);
683: }
684:
685: /*----------------------------------------------------------------------
1.59 cvs 686: ParseCSSBorderRightWidth: parse a CSS BorderRightWidth
1.1 cvs 687: attribute string.
688: ----------------------------------------------------------------------*/
1.79 cvs 689: static char *ParseCSSBorderRightWidth (Element element, PSchema tsch,
690: PresentationContext context,
691: char *cssRule, CSSInfoPtr css,
692: ThotBool isHTML)
1.1 cvs 693: {
1.41 cvs 694: PresentationValue border;
695:
1.82 cvs 696: cssRule = SkipBlanksAndComments (cssRule);
1.41 cvs 697: /* first parse the attribute string */
1.43 cvs 698: cssRule = ParseBorderValue (cssRule, &border);
1.184 vatton 699: if (border.typed_data.unit != UNIT_INVALID && DoApply)
1.44 cvs 700: {
1.117 vatton 701: /* check if it's an important rule */
702: if (tsch)
703: cssRule = CheckImportantRule (cssRule, context);
1.44 cvs 704: TtaSetStylePresentation (PRBorderRightWidth, element, tsch, context, border);
705: border.typed_data.value = 1;
1.184 vatton 706: border.typed_data.unit = UNIT_REL;
1.44 cvs 707: }
1.1 cvs 708: return (cssRule);
709: }
710:
711: /*----------------------------------------------------------------------
1.59 cvs 712: ParseCSSBorderWidth: parse a CSS BorderWidth
1.1 cvs 713: attribute string.
714: ----------------------------------------------------------------------*/
1.79 cvs 715: static char *ParseCSSBorderWidth (Element element, PSchema tsch,
716: PresentationContext context,
717: char *cssRule, CSSInfoPtr css,
718: ThotBool isHTML)
1.1 cvs 719: {
1.79 cvs 720: char *ptrT, *ptrR, *ptrB, *ptrL;
1.93 vatton 721: int skippedNL;
1.41 cvs 722:
1.82 cvs 723: ptrT = SkipBlanksAndComments (cssRule);
1.42 cvs 724: /* First parse Border-Top */
725: ptrR = ParseCSSBorderTopWidth (element, tsch, context, ptrT, css, isHTML);
1.82 cvs 726: ptrR = SkipBlanksAndComments (ptrR);
727: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1.42 cvs 728: {
1.93 vatton 729: skippedNL = NewLineSkipped;
1.42 cvs 730: cssRule = ptrR;
731: /* apply the Border-Top to all */
732: ptrR = ParseCSSBorderRightWidth (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 733: NewLineSkipped = skippedNL;
1.42 cvs 734: ptrR = ParseCSSBorderBottomWidth (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 735: NewLineSkipped = skippedNL;
1.42 cvs 736: ptrR = ParseCSSBorderLeftWidth (element, tsch, context, ptrT, css, isHTML);
737: }
738: else
739: {
740: /* parse Border-Right */
741: ptrB = ParseCSSBorderRightWidth (element, tsch, context, ptrR, css, isHTML);
1.82 cvs 742: ptrB = SkipBlanksAndComments (ptrB);
743: if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
1.42 cvs 744: {
1.93 vatton 745: skippedNL = NewLineSkipped;
1.42 cvs 746: cssRule = ptrB;
747: /* apply the Border-Top to Border-Bottom */
748: ptrB = ParseCSSBorderBottomWidth (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 749: NewLineSkipped = skippedNL;
1.42 cvs 750: /* apply the Border-Right to Border-Left */
751: ptrB = ParseCSSBorderLeftWidth (element, tsch, context, ptrR, css, isHTML);
752: }
753: else
754: {
755: /* parse Border-Bottom */
756: ptrL = ParseCSSBorderBottomWidth (element, tsch, context, ptrB, css, isHTML);
1.82 cvs 757: ptrL = SkipBlanksAndComments (ptrL);
758: if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
1.42 cvs 759: {
760: cssRule = ptrL;
761: /* apply the Border-Right to Border-Left */
762: ptrL = ParseCSSBorderLeftWidth (element, tsch, context, ptrR, css, isHTML);
763: }
764: else
765: /* parse Border-Left */
766: cssRule = ParseCSSBorderLeftWidth (element, tsch, context, ptrL, css, isHTML);
1.82 cvs 767: cssRule = SkipBlanksAndComments (cssRule);
1.42 cvs 768: }
769: }
1.1 cvs 770: return (cssRule);
771: }
772:
773: /*----------------------------------------------------------------------
1.59 cvs 774: ParseCSSBorderColorTop: parse a CSS BorderColorTop
1.1 cvs 775: attribute string.
776: ----------------------------------------------------------------------*/
1.79 cvs 777: static char *ParseCSSBorderColorTop (Element element, PSchema tsch,
778: PresentationContext context,
779: char *cssRule, CSSInfoPtr css,
780: ThotBool isHTML)
1.1 cvs 781: {
1.117 vatton 782: PresentationValue best;
1.43 cvs 783:
1.117 vatton 784: cssRule = ParseCSSColor (cssRule, &best);
1.184 vatton 785: if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 786: {
787: /* check if it's an important rule */
788: if (tsch)
789: cssRule = CheckImportantRule (cssRule, context);
790: /* install the new presentation */
791: TtaSetStylePresentation (PRBorderTopColor, element, tsch, context, best);
792: }
793: return (cssRule);
1.1 cvs 794: }
795:
796: /*----------------------------------------------------------------------
1.59 cvs 797: ParseCSSBorderColorLeft: parse a CSS BorderColorLeft
1.42 cvs 798: attribute string.
799: ----------------------------------------------------------------------*/
1.79 cvs 800: static char *ParseCSSBorderColorLeft (Element element, PSchema tsch,
801: PresentationContext context,
802: char *cssRule, CSSInfoPtr css,
803: ThotBool isHTML)
1.42 cvs 804: {
1.117 vatton 805: PresentationValue best;
806:
807: cssRule = ParseCSSColor (cssRule, &best);
1.184 vatton 808: if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 809: {
810: /* check if it's an important rule */
811: if (tsch)
812: cssRule = CheckImportantRule (cssRule, context);
813: /* install the new presentation */
814: TtaSetStylePresentation (PRBorderLeftColor, element, tsch, context, best);
815: }
816: return (cssRule);
1.42 cvs 817: }
818:
819: /*----------------------------------------------------------------------
1.59 cvs 820: ParseCSSBorderColorBottom: parse a CSS BorderColorBottom
1.42 cvs 821: attribute string.
822: ----------------------------------------------------------------------*/
1.79 cvs 823: static char *ParseCSSBorderColorBottom (Element element, PSchema tsch,
824: PresentationContext context,
825: char *cssRule, CSSInfoPtr css,
826: ThotBool isHTML)
1.42 cvs 827: {
1.117 vatton 828: PresentationValue best;
1.43 cvs 829:
1.117 vatton 830: cssRule = ParseCSSColor (cssRule, &best);
1.184 vatton 831: if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 832: {
833: /* check if it's an important rule */
834: if (tsch)
835: cssRule = CheckImportantRule (cssRule, context);
836: /* install the new presentation */
837: TtaSetStylePresentation (PRBorderBottomColor, element, tsch, context, best);
838: }
1.65 cvs 839: return (cssRule);
1.42 cvs 840: }
841:
842: /*----------------------------------------------------------------------
1.59 cvs 843: ParseCSSBorderColorRight: parse a CSS BorderColorRight
1.1 cvs 844: attribute string.
845: ----------------------------------------------------------------------*/
1.79 cvs 846: static char *ParseCSSBorderColorRight (Element element, PSchema tsch,
847: PresentationContext context,
848: char *cssRule, CSSInfoPtr css,
849: ThotBool isHTML)
1.1 cvs 850: {
1.117 vatton 851: PresentationValue best;
1.43 cvs 852:
1.117 vatton 853: cssRule = ParseCSSColor (cssRule, &best);
1.184 vatton 854: if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 855: {
856: /* check if it's an important rule */
857: if (tsch)
858: cssRule = CheckImportantRule (cssRule, context);
859: /* install the new presentation */
860: TtaSetStylePresentation (PRBorderRightColor, element, tsch, context, best);
861: }
862: return (cssRule);
1.1 cvs 863: }
864:
865: /*----------------------------------------------------------------------
1.59 cvs 866: ParseCSSBorderColor: parse a CSS border-color
1.42 cvs 867: attribute string.
868: ----------------------------------------------------------------------*/
1.79 cvs 869: static char *ParseCSSBorderColor (Element element, PSchema tsch,
870: PresentationContext context,
871: char *cssRule, CSSInfoPtr css,
872: ThotBool isHTML)
1.42 cvs 873: {
1.79 cvs 874: char *ptrT, *ptrR, *ptrB, *ptrL;
1.93 vatton 875: int skippedNL;
1.42 cvs 876:
1.82 cvs 877: ptrT = SkipBlanksAndComments (cssRule);
1.42 cvs 878: /* First parse Border-Top */
1.43 cvs 879: ptrR = ParseCSSBorderColorTop (element, tsch, context, ptrT, css, isHTML);
1.82 cvs 880: ptrR = SkipBlanksAndComments (ptrR);
881: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1.42 cvs 882: {
1.93 vatton 883: skippedNL = NewLineSkipped;
1.42 cvs 884: cssRule = ptrR;
885: /* apply the Border-Top to all */
1.43 cvs 886: ptrR = ParseCSSBorderColorRight (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 887: NewLineSkipped = skippedNL;
1.43 cvs 888: ptrR = ParseCSSBorderColorBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 889: NewLineSkipped = skippedNL;
1.43 cvs 890: ptrR = ParseCSSBorderColorLeft (element, tsch, context, ptrT, css, isHTML);
1.42 cvs 891: }
892: else
893: {
894: /* parse Border-Right */
1.43 cvs 895: ptrB = ParseCSSBorderColorRight (element, tsch, context, ptrR, css, isHTML);
1.82 cvs 896: ptrB = SkipBlanksAndComments (ptrB);
897: if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
1.42 cvs 898: {
1.93 vatton 899: skippedNL = NewLineSkipped;
1.42 cvs 900: cssRule = ptrB;
901: /* apply the Border-Top to Border-Bottom */
1.43 cvs 902: ptrB = ParseCSSBorderColorBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 903: NewLineSkipped = skippedNL;
1.42 cvs 904: /* apply the Border-Right to Border-Left */
1.43 cvs 905: ptrB = ParseCSSBorderColorLeft (element, tsch, context, ptrR, css, isHTML);
1.42 cvs 906: }
907: else
908: {
1.93 vatton 909: skippedNL = NewLineSkipped;
1.42 cvs 910: /* parse Border-Bottom */
1.43 cvs 911: ptrL = ParseCSSBorderColorBottom (element, tsch, context, ptrB, css, isHTML);
1.93 vatton 912: NewLineSkipped = skippedNL;
1.82 cvs 913: ptrL = SkipBlanksAndComments (ptrL);
914: if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
1.42 cvs 915: {
916: cssRule = ptrL;
917: /* apply the Border-Right to Border-Left */
1.43 cvs 918: ptrL = ParseCSSBorderColorLeft (element, tsch, context, ptrR, css, isHTML);
1.42 cvs 919: }
920: else
921: /* parse Border-Left */
1.43 cvs 922: cssRule = ParseCSSBorderColorLeft (element, tsch, context, ptrL, css, isHTML);
1.82 cvs 923: cssRule = SkipBlanksAndComments (cssRule);
1.42 cvs 924: }
925: }
926: return (cssRule);
927: }
928:
929: /*----------------------------------------------------------------------
1.59 cvs 930: ParseCSSBorderStyleTop: parse a CSS BorderStyleTop
1.42 cvs 931: attribute string.
932: ----------------------------------------------------------------------*/
1.79 cvs 933: static char *ParseCSSBorderStyleTop (Element element, PSchema tsch,
934: PresentationContext context,
935: char *cssRule, CSSInfoPtr css,
936: ThotBool isHTML)
1.42 cvs 937: {
1.43 cvs 938: PresentationValue border;
939:
1.82 cvs 940: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 941: cssRule = ParseBorderStyle (cssRule, &border);
1.184 vatton 942: if (border.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 943: {
944: /* check if it's an important rule */
945: if (tsch)
946: cssRule = CheckImportantRule (cssRule, context);
947: TtaSetStylePresentation (PRBorderTopStyle, element, tsch, context, border);
948: }
1.42 cvs 949: return (cssRule);
950: }
951:
952: /*----------------------------------------------------------------------
1.59 cvs 953: ParseCSSBorderStyleLeft: parse a CSS BorderStyleLeft
1.42 cvs 954: attribute string.
955: ----------------------------------------------------------------------*/
1.79 cvs 956: static char *ParseCSSBorderStyleLeft (Element element, PSchema tsch,
957: PresentationContext context,
958: char *cssRule, CSSInfoPtr css,
959: ThotBool isHTML)
1.42 cvs 960: {
1.43 cvs 961: PresentationValue border;
962:
1.82 cvs 963: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 964: cssRule = ParseBorderStyle (cssRule, &border);
1.184 vatton 965: if (border.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 966: {
967: /* check if it's an important rule */
968: if (tsch)
969: cssRule = CheckImportantRule (cssRule, context);
970: TtaSetStylePresentation (PRBorderLeftStyle, element, tsch, context, border);
971: }
1.42 cvs 972: return (cssRule);
973: }
974:
975: /*----------------------------------------------------------------------
1.59 cvs 976: ParseCSSBorderStyleBottom: parse a CSS BorderStyleBottom
1.1 cvs 977: attribute string.
978: ----------------------------------------------------------------------*/
1.79 cvs 979: static char *ParseCSSBorderStyleBottom (Element element, PSchema tsch,
980: PresentationContext context,
981: char *cssRule, CSSInfoPtr css,
982: ThotBool isHTML)
1.1 cvs 983: {
1.43 cvs 984: PresentationValue border;
985:
1.82 cvs 986: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 987: cssRule = ParseBorderStyle (cssRule, &border);
1.184 vatton 988: if (border.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 989: {
990: /* check if it's an important rule */
991: if (tsch)
992: cssRule = CheckImportantRule (cssRule, context);
993: TtaSetStylePresentation (PRBorderBottomStyle, element, tsch, context, border);
994: }
1.1 cvs 995: return (cssRule);
996: }
997:
998: /*----------------------------------------------------------------------
1.59 cvs 999: ParseCSSBorderStyleRight: parse a CSS BorderStyleRight
1.1 cvs 1000: attribute string.
1001: ----------------------------------------------------------------------*/
1.79 cvs 1002: static char *ParseCSSBorderStyleRight (Element element, PSchema tsch,
1003: PresentationContext context,
1004: char *cssRule, CSSInfoPtr css,
1005: ThotBool isHTML)
1.1 cvs 1006: {
1.43 cvs 1007: PresentationValue border;
1008:
1.82 cvs 1009: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 1010: cssRule = ParseBorderStyle (cssRule, &border);
1.184 vatton 1011: if (border.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 1012: {
1013: /* check if it's an important rule */
1014: if (tsch)
1015: cssRule = CheckImportantRule (cssRule, context);
1016: TtaSetStylePresentation (PRBorderRightStyle, element, tsch, context, border);
1017: }
1.1 cvs 1018: return (cssRule);
1019: }
1020:
1021: /*----------------------------------------------------------------------
1.59 cvs 1022: ParseCSSBorderStyleStyle: parse a CSS border-style
1.1 cvs 1023: attribute string.
1024: ----------------------------------------------------------------------*/
1.79 cvs 1025: static char *ParseCSSBorderStyle (Element element, PSchema tsch,
1026: PresentationContext context,
1027: char *cssRule, CSSInfoPtr css,
1028: ThotBool isHTML)
1.1 cvs 1029: {
1.79 cvs 1030: char *ptrT, *ptrR, *ptrB, *ptrL;
1.93 vatton 1031: int skippedNL;
1.42 cvs 1032:
1.82 cvs 1033: ptrT = SkipBlanksAndComments (cssRule);
1.42 cvs 1034: /* First parse Border-Top */
1.43 cvs 1035: ptrR = ParseCSSBorderStyleTop (element, tsch, context, ptrT, css, isHTML);
1.82 cvs 1036: ptrR = SkipBlanksAndComments (ptrR);
1037: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1.42 cvs 1038: {
1.93 vatton 1039: skippedNL = NewLineSkipped;
1.42 cvs 1040: cssRule = ptrR;
1041: /* apply the Border-Top to all */
1.43 cvs 1042: ptrR = ParseCSSBorderStyleRight (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 1043: NewLineSkipped = skippedNL;
1.43 cvs 1044: ptrR = ParseCSSBorderStyleBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 1045: NewLineSkipped = skippedNL;
1.43 cvs 1046: ptrR = ParseCSSBorderStyleLeft (element, tsch, context, ptrT, css, isHTML);
1.42 cvs 1047: }
1048: else
1049: {
1050: /* parse Border-Right */
1.43 cvs 1051: ptrB = ParseCSSBorderStyleRight (element, tsch, context, ptrR, css, isHTML);
1.82 cvs 1052: ptrB = SkipBlanksAndComments (ptrB);
1053: if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
1.42 cvs 1054: {
1.93 vatton 1055: skippedNL = NewLineSkipped;
1.42 cvs 1056: cssRule = ptrB;
1057: /* apply the Border-Top to Border-Bottom */
1.43 cvs 1058: ptrB = ParseCSSBorderStyleBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 1059: NewLineSkipped = skippedNL;
1.42 cvs 1060: /* apply the Border-Right to Border-Left */
1.43 cvs 1061: ptrB = ParseCSSBorderStyleLeft (element, tsch, context, ptrR, css, isHTML);
1.42 cvs 1062: }
1063: else
1064: {
1065: /* parse Border-Bottom */
1.43 cvs 1066: ptrL = ParseCSSBorderStyleBottom (element, tsch, context, ptrB, css, isHTML);
1.82 cvs 1067: ptrL = SkipBlanksAndComments (ptrL);
1068: if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
1.42 cvs 1069: {
1070: cssRule = ptrL;
1071: /* apply the Border-Right to Border-Left */
1.43 cvs 1072: ptrL = ParseCSSBorderStyleLeft (element, tsch, context, ptrR, css, isHTML);
1.42 cvs 1073: }
1074: else
1075: /* parse Border-Left */
1.43 cvs 1076: cssRule = ParseCSSBorderStyleLeft (element, tsch, context, ptrL, css, isHTML);
1.82 cvs 1077: cssRule = SkipBlanksAndComments (cssRule);
1.42 cvs 1078: }
1079: }
1080: return (cssRule);
1081: }
1082:
1083: /*----------------------------------------------------------------------
1.59 cvs 1084: ParseCSSBorderTop: parse a CSS BorderTop
1.42 cvs 1085: attribute string.
1086: ----------------------------------------------------------------------*/
1.79 cvs 1087: static char *ParseCSSBorderTop (Element element, PSchema tsch,
1088: PresentationContext context, char *cssRule,
1089: CSSInfoPtr css, ThotBool isHTML)
1.42 cvs 1090: {
1.79 cvs 1091: char *ptr;
1.43 cvs 1092:
1.82 cvs 1093: cssRule = SkipBlanksAndComments (cssRule);
1094: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
1.43 cvs 1095: {
1096: ptr = cssRule;
1097: cssRule = ParseCSSBorderStyleTop (element, tsch, context, cssRule, css, isHTML);
1098: if (ptr == cssRule)
1099: cssRule = ParseCSSBorderTopWidth (element, tsch, context, cssRule, css, isHTML);
1100: if (ptr == cssRule)
1101: cssRule = ParseCSSBorderColorTop (element, tsch, context, cssRule, css, isHTML);
1102: if (ptr == cssRule)
1103: /* rule not found */
1.168 vatton 1104: cssRule = SkipValue ("Invalid border value", cssRule);
1.82 cvs 1105: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 1106: }
1.42 cvs 1107: return (cssRule);
1108: }
1109:
1110: /*----------------------------------------------------------------------
1.59 cvs 1111: ParseCSSBorderLeft: parse a CSS BorderLeft
1.42 cvs 1112: attribute string.
1113: ----------------------------------------------------------------------*/
1.79 cvs 1114: static char *ParseCSSBorderLeft (Element element, PSchema tsch,
1115: PresentationContext context, char *cssRule,
1116: CSSInfoPtr css, ThotBool isHTML)
1.42 cvs 1117: {
1.79 cvs 1118: char *ptr;
1.43 cvs 1119:
1.82 cvs 1120: cssRule = SkipBlanksAndComments (cssRule);
1121: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
1.43 cvs 1122: {
1123: ptr = cssRule;
1124: cssRule = ParseCSSBorderStyleLeft (element, tsch, context, cssRule, css, isHTML);
1125: if (ptr == cssRule)
1126: cssRule = ParseCSSBorderLeftWidth (element, tsch, context, cssRule, css, isHTML);
1127: if (ptr == cssRule)
1128: cssRule = ParseCSSBorderColorLeft (element, tsch, context, cssRule, css, isHTML);
1129: if (ptr == cssRule)
1130: /* rule not found */
1.168 vatton 1131: cssRule = SkipValue ("Invalid border value", cssRule);
1.82 cvs 1132: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 1133: }
1.1 cvs 1134: return (cssRule);
1135: }
1136:
1137: /*----------------------------------------------------------------------
1.59 cvs 1138: ParseCSSBorderBottom: parse a CSS BorderBottom
1.1 cvs 1139: attribute string.
1140: ----------------------------------------------------------------------*/
1.79 cvs 1141: static char *ParseCSSBorderBottom (Element element, PSchema tsch,
1142: PresentationContext context, char *cssRule,
1143: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1144: {
1.79 cvs 1145: char *ptr;
1.43 cvs 1146:
1.82 cvs 1147: cssRule = SkipBlanksAndComments (cssRule);
1148: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
1.43 cvs 1149: {
1150: ptr = cssRule;
1151: cssRule = ParseCSSBorderStyleBottom (element, tsch, context, cssRule, css, isHTML);
1152: if (ptr == cssRule)
1153: cssRule = ParseCSSBorderBottomWidth (element, tsch, context, cssRule, css, isHTML);
1154: if (ptr == cssRule)
1155: cssRule = ParseCSSBorderColorBottom (element, tsch, context, cssRule, css, isHTML);
1156: if (ptr == cssRule)
1157: /* rule not found */
1.168 vatton 1158: cssRule = SkipValue ("Invalid border value", cssRule);
1.82 cvs 1159: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 1160: }
1.1 cvs 1161: return (cssRule);
1162: }
1163:
1164: /*----------------------------------------------------------------------
1.59 cvs 1165: ParseCSSBorderRight: parse a CSS BorderRight
1.1 cvs 1166: attribute string.
1167: ----------------------------------------------------------------------*/
1.79 cvs 1168: static char *ParseCSSBorderRight (Element element, PSchema tsch,
1169: PresentationContext context, char *cssRule,
1170: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1171: {
1.79 cvs 1172: char *ptr;
1.43 cvs 1173:
1.82 cvs 1174: cssRule = SkipBlanksAndComments (cssRule);
1175: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
1.43 cvs 1176: {
1177: ptr = cssRule;
1178: cssRule = ParseCSSBorderStyleRight (element, tsch, context, cssRule, css, isHTML);
1179: if (ptr == cssRule)
1180: cssRule = ParseCSSBorderRightWidth (element, tsch, context, cssRule, css, isHTML);
1181: if (ptr == cssRule)
1182: cssRule = ParseCSSBorderColorRight (element, tsch, context, cssRule, css, isHTML);
1183: if (ptr == cssRule)
1184: /* rule not found */
1.168 vatton 1185: cssRule = SkipValue ("Invalid border value", cssRule);
1.82 cvs 1186: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 1187: }
1.1 cvs 1188: return (cssRule);
1189: }
1190:
1191: /*----------------------------------------------------------------------
1.59 cvs 1192: ParseCSSBorder: parse a CSS border
1.42 cvs 1193: attribute string.
1194: ----------------------------------------------------------------------*/
1.79 cvs 1195: static char *ParseCSSBorder (Element element, PSchema tsch,
1196: PresentationContext context, char *cssRule,
1197: CSSInfoPtr css, ThotBool isHTML)
1.42 cvs 1198: {
1.79 cvs 1199: char *ptrT, *ptrR;
1.93 vatton 1200: int skippedNL;
1.42 cvs 1201:
1.82 cvs 1202: ptrT = SkipBlanksAndComments (cssRule);
1.42 cvs 1203: /* First parse Border-Top */
1204: ptrR = ParseCSSBorderTop (element, tsch, context, ptrT, css, isHTML);
1.82 cvs 1205: ptrR = SkipBlanksAndComments (ptrR);
1206: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1.42 cvs 1207: {
1.93 vatton 1208: skippedNL = NewLineSkipped;
1.42 cvs 1209: cssRule = ptrR;
1210: /* apply the Border-Top to all */
1211: ptrR = ParseCSSBorderRight (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 1212: NewLineSkipped = skippedNL;
1.42 cvs 1213: ptrR = ParseCSSBorderBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 1214: NewLineSkipped = skippedNL;
1.42 cvs 1215: ptrR = ParseCSSBorderLeft (element, tsch, context, ptrT, css, isHTML);
1216: }
1217: return (cssRule);
1218: }
1219:
1220: /*----------------------------------------------------------------------
1.184 vatton 1221: ParseCSSFloat: parse a CSS float attribute string
1222: ----------------------------------------------------------------------*/
1223: static char *ParseCSSFloat (Element element, PSchema tsch,
1224: PresentationContext context, char *cssRule,
1225: CSSInfoPtr css, ThotBool isHTML)
1226: {
1227: PresentationValue pval;
1228: char *ptr;
1229:
1230: pval.typed_data.value = 0;
1.187 vatton 1231: pval.typed_data.unit = UNIT_BOX;
1.192 cvs 1232: pval.typed_data.real = FALSE;
1.190 vatton 1233: if (!strncasecmp (cssRule, "inherit", 7))
1234: {
1235: cssRule = SkipWord (cssRule);
1236: return (cssRule);
1237: }
1.184 vatton 1238: if (!strncasecmp (cssRule, "none", 4))
1239: pval.typed_data.value = FloatNone;
1240: else if (!strncasecmp (cssRule, "left", 4))
1241: pval.typed_data.value = FloatLeft;
1242: else if (!strncasecmp (cssRule, "right", 5))
1243: pval.typed_data.value = FloatRight;
1244:
1245: ptr = cssRule;
1246: cssRule = SkipWord (cssRule);
1247: if (pval.typed_data.value == 0)
1248: CSSParseError ("Invalid float value", ptr, cssRule);
1249: else
1250: {
1251: if (DoApply)
1252: {
1253: if (tsch)
1254: cssRule = CheckImportantRule (cssRule, context);
1255: TtaSetStylePresentation (PRFloat, element, tsch, context, pval);
1256: }
1257: }
1258: cssRule = SkipValue (NULL, cssRule);
1259: return (cssRule);
1260: }
1261:
1262: /*----------------------------------------------------------------------
1263: ParseCSSClear: parse a CSS clear rule
1.1 cvs 1264: ----------------------------------------------------------------------*/
1.79 cvs 1265: static char *ParseCSSClear (Element element, PSchema tsch,
1266: PresentationContext context, char *cssRule,
1267: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1268: {
1.184 vatton 1269: PresentationValue pval;
1270: char *ptr;
1271:
1272: pval.typed_data.value = 0;
1.187 vatton 1273: pval.typed_data.unit = UNIT_BOX;
1.193 vatton 1274: pval.typed_data.real = FALSE;
1.190 vatton 1275: if (!strncasecmp (cssRule, "inherit", 7))
1276: {
1277: cssRule = SkipWord (cssRule);
1278: return (cssRule);
1279: }
1.184 vatton 1280: if (!strncasecmp (cssRule, "none", 4))
1281: pval.typed_data.value = ClearNone;
1282: else if (!strncasecmp (cssRule, "left", 4))
1283: pval.typed_data.value = ClearLeft;
1284: else if (!strncasecmp (cssRule, "right", 5))
1285: pval.typed_data.value = ClearRight;
1286: else if (!strncasecmp (cssRule, "both", 4))
1287: pval.typed_data.value = ClearBoth;
1288:
1289: ptr = cssRule;
1290: cssRule = SkipWord (cssRule);
1291: if (pval.typed_data.value == 0)
1292: CSSParseError ("Invalid float value", ptr, cssRule);
1293: else
1294: {
1295: if (DoApply)
1296: {
1297: if (tsch)
1298: cssRule = CheckImportantRule (cssRule, context);
1299: TtaSetStylePresentation (PRClear, element, tsch, context, pval);
1300: }
1301: }
1302: cssRule = SkipValue (NULL, cssRule);
1303: return (cssRule);
1304: }
1305:
1306: /*----------------------------------------------------------------------
1307: ParseCSSContent: parse a CSS content value
1308: ----------------------------------------------------------------------*/
1309: static char *ParseCSSContent (Element element, PSchema tsch,
1310: PresentationContext context, char *cssRule,
1311: CSSInfoPtr css, ThotBool isHTML)
1312: {
1.168 vatton 1313: cssRule = SkipValue (NULL, cssRule);
1.1 cvs 1314: return (cssRule);
1315: }
1316:
1317: /*----------------------------------------------------------------------
1.59 cvs 1318: ParseCSSDisplay: parse a CSS display attribute string
1.1 cvs 1319: ----------------------------------------------------------------------*/
1.79 cvs 1320: static char *ParseCSSDisplay (Element element, PSchema tsch,
1321: PresentationContext context, char *cssRule,
1322: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1323: {
1.184 vatton 1324: PresentationValue pval;
1325: char *ptr;
1.1 cvs 1326:
1.184 vatton 1327: pval.typed_data.unit = UNIT_REL;
1328: pval.typed_data.real = FALSE;
1329: cssRule = SkipBlanksAndComments (cssRule);
1330: if (!strncasecmp (cssRule, "none", 4))
1331: {
1332: pval.typed_data.value = 0;
1333: if (DoApply)
1.117 vatton 1334: {
1335: if (tsch)
1336: cssRule = CheckImportantRule (cssRule, context);
1.116 vatton 1337: TtaSetStylePresentation (PRVisibility, element, tsch, context, pval);
1.117 vatton 1338: }
1.184 vatton 1339: cssRule = SkipWord (cssRule);
1340: }
1341: else
1342: {
1343: if (!strncasecmp (cssRule, "block", 5))
1344: pval.typed_data.value = Block;
1345: else if (!strncasecmp (cssRule, "inline", 6))
1346: pval.typed_data.value = Inline;
1347: else if (!strncasecmp (cssRule, "list-item", 9))
1348: pval.typed_data.value = ListItem;
1349: else if (!strncasecmp (cssRule, "run-in", 6))
1350: pval.typed_data.value = RunIn;
1351: else if (!strncasecmp (cssRule, "compact", 7))
1352: pval.typed_data.value = Compact;
1353: else if (!strncasecmp (cssRule, "marker", 6))
1354: pval.typed_data.value = Marker;
1355: else
1356: {
1357: if (strncasecmp (cssRule, "table-row-group", 15) &&
1358: strncasecmp (cssRule, "table-column-group", 18) &&
1359: strncasecmp (cssRule, "table-header-group", 5) &&
1360: strncasecmp (cssRule, "table-footer-group", 6) &&
1361: strncasecmp (cssRule, "table-row", 9) &&
1362: strncasecmp (cssRule, "table-column", 12) &&
1363: strncasecmp (cssRule, "table-cell", 10) &&
1364: strncasecmp (cssRule, "table-caption", 13) &&
1365: strncasecmp (cssRule, "table", 5) &&
1366: strncasecmp (cssRule, "inherit", 7))
1367: {
1368: ptr = cssRule;
1369: cssRule = SkipWord (cssRule);
1370: CSSParseError ("Invalid display value", ptr, cssRule);
1371: }
1372: return (cssRule);
1373: }
1374:
1375: if (DoApply)
1376: {
1377: if (tsch)
1378: cssRule = CheckImportantRule (cssRule, context);
1379: TtaSetStylePresentation (PRDisplay, element, tsch, context, pval);
1380: }
1381: cssRule = SkipWord (cssRule);
1382: }
1.1 cvs 1383: return (cssRule);
1384: }
1385:
1386: /*----------------------------------------------------------------------
1.59 cvs 1387: ParseCSSLetterSpacing: parse a CSS letter-spacing
1.1 cvs 1388: attribute string.
1389: ----------------------------------------------------------------------*/
1.79 cvs 1390: static char *ParseCSSLetterSpacing (Element element, PSchema tsch,
1391: PresentationContext context, char *cssRule,
1392: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1393: {
1.168 vatton 1394: cssRule = SkipValue (NULL, cssRule);
1.1 cvs 1395: return (cssRule);
1396: }
1397:
1398: /*----------------------------------------------------------------------
1.59 cvs 1399: ParseCSSListStyleType: parse a CSS list-style-type
1.1 cvs 1400: attribute string.
1401: ----------------------------------------------------------------------*/
1.79 cvs 1402: static char *ParseCSSListStyleType (Element element, PSchema tsch,
1403: PresentationContext context, char *cssRule,
1404: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1405: {
1.168 vatton 1406: cssRule = SkipValue (NULL, cssRule);
1.1 cvs 1407: return (cssRule);
1408: }
1409:
1410: /*----------------------------------------------------------------------
1.59 cvs 1411: ParseCSSListStyleImage: parse a CSS list-style-image
1.1 cvs 1412: attribute string.
1413: ----------------------------------------------------------------------*/
1.79 cvs 1414: static char *ParseCSSListStyleImage (Element element, PSchema tsch,
1415: PresentationContext context, char *cssRule,
1416: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1417: {
1.168 vatton 1418: cssRule = SkipValue (NULL, cssRule);
1.1 cvs 1419: return (cssRule);
1420: }
1421:
1422: /*----------------------------------------------------------------------
1.59 cvs 1423: ParseCSSListStylePosition: parse a CSS list-style-position
1.1 cvs 1424: attribute string.
1425: ----------------------------------------------------------------------*/
1.79 cvs 1426: static char *ParseCSSListStylePosition (Element element, PSchema tsch,
1427: PresentationContext context,
1428: char *cssRule, CSSInfoPtr css,
1429: ThotBool isHTML)
1.1 cvs 1430: {
1.168 vatton 1431: cssRule = SkipValue (NULL, cssRule);
1.1 cvs 1432: return (cssRule);
1433: }
1434:
1435: /*----------------------------------------------------------------------
1.59 cvs 1436: ParseCSSListStyle: parse a CSS list-style
1.1 cvs 1437: attribute string.
1438: ----------------------------------------------------------------------*/
1.79 cvs 1439: static char *ParseCSSListStyle (Element element, PSchema tsch,
1440: PresentationContext context, char *cssRule,
1441: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1442: {
1.168 vatton 1443: cssRule = SkipValue (NULL, cssRule);
1.1 cvs 1444: return (cssRule);
1445: }
1446:
1447: /*----------------------------------------------------------------------
1.59 cvs 1448: ParseCSSTextAlign: parse a CSS text-align
1.1 cvs 1449: attribute string.
1450: ----------------------------------------------------------------------*/
1.79 cvs 1451: static char *ParseCSSTextAlign (Element element, PSchema tsch,
1452: PresentationContext context, char *cssRule,
1453: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1454: {
1455: PresentationValue align;
1.168 vatton 1456: char *ptr;
1.1 cvs 1457:
1458: align.typed_data.value = 0;
1.184 vatton 1459: align.typed_data.unit = UNIT_REL;
1.1 cvs 1460: align.typed_data.real = FALSE;
1461:
1.82 cvs 1462: cssRule = SkipBlanksAndComments (cssRule);
1463: if (!strncasecmp (cssRule, "left", 4))
1.1 cvs 1464: {
1465: align.typed_data.value = AdjustLeft;
1466: cssRule = SkipWord (cssRule);
1467: }
1.82 cvs 1468: else if (!strncasecmp (cssRule, "right", 5))
1.1 cvs 1469: {
1470: align.typed_data.value = AdjustRight;
1471: cssRule = SkipWord (cssRule);
1472: }
1.82 cvs 1473: else if (!strncasecmp (cssRule, "center", 6))
1.1 cvs 1474: {
1475: align.typed_data.value = Centered;
1476: cssRule = SkipWord (cssRule);
1477: }
1.82 cvs 1478: else if (!strncasecmp (cssRule, "justify", 7))
1.1 cvs 1479: {
1.81 cvs 1480: align.typed_data.value = Justify;
1.1 cvs 1481: cssRule = SkipWord (cssRule);
1482: }
1483: else
1484: {
1.168 vatton 1485: ptr = cssRule;
1486: cssRule = SkipWord (cssRule);
1487: CSSParseError ("Invalid text-align value", ptr, cssRule);
1.1 cvs 1488: return (cssRule);
1489: }
1490:
1491: /*
1492: * install the new presentation.
1493: */
1.116 vatton 1494: if (align.typed_data.value && DoApply)
1.117 vatton 1495: {
1496: if (tsch)
1497: cssRule = CheckImportantRule (cssRule, context);
1498: TtaSetStylePresentation (PRAdjust, element, tsch, context, align);
1499: }
1.1 cvs 1500: return (cssRule);
1501: }
1502:
1503: /*----------------------------------------------------------------------
1.112 quint 1504: ParseCSSDirection: parse a CSS direction property
1505: ----------------------------------------------------------------------*/
1506: static char *ParseCSSDirection (Element element, PSchema tsch,
1507: PresentationContext context, char *cssRule,
1508: CSSInfoPtr css, ThotBool isHTML)
1509: {
1510: PresentationValue direction;
1.168 vatton 1511: char *ptr;
1.112 quint 1512:
1513: direction.typed_data.value = 0;
1.184 vatton 1514: direction.typed_data.unit = UNIT_REL;
1.112 quint 1515: direction.typed_data.real = FALSE;
1516:
1517: cssRule = SkipBlanksAndComments (cssRule);
1518: if (!strncasecmp (cssRule, "ltr", 3))
1519: {
1.184 vatton 1520: direction.typed_data.value = LeftToRight;
1.112 quint 1521: cssRule = SkipWord (cssRule);
1522: }
1523: else if (!strncasecmp (cssRule, "rtl", 3))
1524: {
1.184 vatton 1525: direction.typed_data.value = RightToLeft;
1.112 quint 1526: cssRule = SkipWord (cssRule);
1527: }
1528: else if (!strncasecmp (cssRule, "inherit", 7))
1529: {
1530: /* not implemented */
1531: cssRule = SkipWord (cssRule);
1532: return (cssRule);
1533: }
1534: else
1535: {
1.168 vatton 1536: ptr = cssRule;
1537: cssRule = SkipWord (cssRule);
1538: CSSParseError ("Invalid direction value", ptr, cssRule);
1.112 quint 1539: return (cssRule);
1540: }
1541:
1542: /*
1543: * install the new presentation.
1544: */
1.116 vatton 1545: if (direction.typed_data.value && DoApply)
1.117 vatton 1546: {
1547: if (tsch)
1548: cssRule = CheckImportantRule (cssRule, context);
1549: TtaSetStylePresentation (PRDirection, element, tsch, context, direction);
1550: }
1.112 quint 1551: return (cssRule);
1552: }
1553:
1554: /*----------------------------------------------------------------------
1.113 quint 1555: ParseCSSUnicodeBidi: parse a CSS unicode-bidi property
1556: ----------------------------------------------------------------------*/
1557: static char *ParseCSSUnicodeBidi (Element element, PSchema tsch,
1558: PresentationContext context, char *cssRule,
1559: CSSInfoPtr css, ThotBool isHTML)
1560: {
1561: PresentationValue bidi;
1.168 vatton 1562: char *ptr;
1.113 quint 1563:
1564: bidi.typed_data.value = 0;
1.184 vatton 1565: bidi.typed_data.unit = UNIT_REL;
1.113 quint 1566: bidi.typed_data.real = FALSE;
1567:
1568: cssRule = SkipBlanksAndComments (cssRule);
1569: if (!strncasecmp (cssRule, "normal", 6))
1570: {
1.184 vatton 1571: bidi.typed_data.value = Normal;
1.113 quint 1572: cssRule = SkipWord (cssRule);
1573: }
1574: else if (!strncasecmp (cssRule, "embed", 5))
1575: {
1.184 vatton 1576: bidi.typed_data.value = Embed;
1.113 quint 1577: cssRule = SkipWord (cssRule);
1578: }
1579: else if (!strncasecmp (cssRule, "override", 8))
1580: {
1.184 vatton 1581: bidi.typed_data.value = Override;
1.113 quint 1582: cssRule = SkipWord (cssRule);
1583: }
1584: else if (!strncasecmp (cssRule, "inherit", 7))
1585: {
1586: /* not implemented */
1587: cssRule = SkipWord (cssRule);
1588: return (cssRule);
1589: }
1590: else
1591: {
1.168 vatton 1592: ptr = cssRule;
1593: cssRule = SkipWord (cssRule);
1594: CSSParseError ("Invalid unicode-bidi value", ptr, cssRule);
1.113 quint 1595: return (cssRule);
1596: }
1597:
1598: /*
1599: * install the new presentation.
1600: */
1.116 vatton 1601: if (bidi.typed_data.value && DoApply)
1.117 vatton 1602: {
1603: if (tsch)
1604: cssRule = CheckImportantRule (cssRule, context);
1605: TtaSetStylePresentation (PRUnicodeBidi, element, tsch, context, bidi);
1606: }
1.113 quint 1607: return (cssRule);
1608: }
1609:
1610: /*----------------------------------------------------------------------
1.168 vatton 1611: ParseCSSTextIndent: parse a CSS text-indent
1.1 cvs 1612: attribute string.
1613: ----------------------------------------------------------------------*/
1.79 cvs 1614: static char *ParseCSSTextIndent (Element element, PSchema tsch,
1615: PresentationContext context, char *cssRule,
1616: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1617: {
1618: PresentationValue pval;
1.168 vatton 1619: char *ptr;
1.1 cvs 1620:
1.82 cvs 1621: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 1622: ptr = cssRule;
1.1 cvs 1623: cssRule = ParseCSSUnit (cssRule, &pval);
1.168 vatton 1624: if (pval.typed_data.value == 0)
1.184 vatton 1625: pval.typed_data.unit = UNIT_PX;
1626: else if (pval.typed_data.unit == UNIT_INVALID ||
1627: pval.typed_data.unit == UNIT_BOX)
1.168 vatton 1628: {
1629: CSSParseError ("Invalid text-indent value", ptr, cssRule);
1630: return (cssRule);
1631: }
1.1 cvs 1632: /* install the attribute */
1.116 vatton 1633: if (DoApply)
1.117 vatton 1634: {
1635: if (tsch)
1636: cssRule = CheckImportantRule (cssRule, context);
1637: TtaSetStylePresentation (PRIndent, element, tsch, context, pval);
1638: }
1.1 cvs 1639: return (cssRule);
1640: }
1641:
1642: /*----------------------------------------------------------------------
1.59 cvs 1643: ParseCSSTextTransform: parse a CSS text-transform
1.1 cvs 1644: attribute string.
1645: ----------------------------------------------------------------------*/
1.79 cvs 1646: static char *ParseCSSTextTransform (Element element, PSchema tsch,
1647: PresentationContext context, char *cssRule,
1648: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1649: {
1.168 vatton 1650: cssRule = SkipValue (NULL, cssRule);
1.1 cvs 1651: return (cssRule);
1652: }
1653:
1654: /*----------------------------------------------------------------------
1.59 cvs 1655: ParseCSSVerticalAlign: parse a CSS vertical-align
1.1 cvs 1656: attribute string.
1657: ----------------------------------------------------------------------*/
1.79 cvs 1658: static char *ParseCSSVerticalAlign (Element element, PSchema tsch,
1659: PresentationContext context, char *cssRule,
1660: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1661: {
1.168 vatton 1662: cssRule = SkipValue (NULL, cssRule);
1.1 cvs 1663: return (cssRule);
1664: }
1665:
1666: /*----------------------------------------------------------------------
1.59 cvs 1667: ParseCSSWhiteSpace: parse a CSS white-space
1.1 cvs 1668: attribute string.
1669: ----------------------------------------------------------------------*/
1.79 cvs 1670: static char *ParseCSSWhiteSpace (Element element, PSchema tsch,
1671: PresentationContext context, char *cssRule,
1672: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1673: {
1.82 cvs 1674: cssRule = SkipBlanksAndComments (cssRule);
1675: if (!strncasecmp (cssRule, "normal", 6))
1.1 cvs 1676: cssRule = SkipWord (cssRule);
1.82 cvs 1677: else if (!strncasecmp (cssRule, "pre", 3))
1.1 cvs 1678: cssRule = SkipWord (cssRule);
1679: else
1680: return (cssRule);
1681: return (cssRule);
1682: }
1683:
1684: /*----------------------------------------------------------------------
1.59 cvs 1685: ParseCSSWordSpacing: parse a CSS word-spacing
1.1 cvs 1686: attribute string.
1687: ----------------------------------------------------------------------*/
1.79 cvs 1688: static char *ParseCSSWordSpacing (Element element, PSchema tsch,
1689: PresentationContext context, char *cssRule,
1690: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1691: {
1.168 vatton 1692: cssRule = SkipValue (NULL, cssRule);
1.1 cvs 1693: return (cssRule);
1694: }
1695:
1696: /*----------------------------------------------------------------------
1.162 quint 1697: ParseCSSLineHeight: parse a CSS line-height property
1.25 cvs 1698: ----------------------------------------------------------------------*/
1.162 quint 1699: static char *ParseCSSLineHeight (Element element, PSchema tsch,
1.166 vatton 1700: PresentationContext context, char *cssRule,
1701: CSSInfoPtr css, ThotBool isHTML)
1.25 cvs 1702: {
1.162 quint 1703: PresentationValue pval;
1704: char *ptr;
1705:
1706: ptr = cssRule;
1707: if (!strncasecmp (cssRule, "normal", 6))
1708: {
1.184 vatton 1709: pval.typed_data.unit = UNIT_REL;
1.162 quint 1710: pval.typed_data.real = TRUE;
1711: pval.typed_data.value = 1100;
1712: cssRule = SkipWord (cssRule);
1713: }
1714: else if (!strncasecmp (cssRule, "inherit", 7))
1715: {
1716: cssRule = SkipWord (cssRule);
1717: return (cssRule);
1718: }
1719: else
1720: cssRule = ParseCSSUnit (cssRule, &pval);
1.25 cvs 1721:
1.184 vatton 1722: if (pval.typed_data.unit == UNIT_INVALID)
1.168 vatton 1723: CSSParseError ("Invalid line-height value", ptr, cssRule);
1.162 quint 1724: else if (DoApply)
1725: {
1.166 vatton 1726: /* install the new presentation */
1.184 vatton 1727: if (pval.typed_data.unit == UNIT_BOX)
1728: pval.typed_data.unit = UNIT_EM;
1.162 quint 1729: if (tsch)
1730: cssRule = CheckImportantRule (cssRule, context);
1731: TtaSetStylePresentation (PRLineSpacing, element, tsch, context, pval);
1732: }
1733: return (cssRule);
1.25 cvs 1734: }
1735:
1736: /*----------------------------------------------------------------------
1.59 cvs 1737: ParseCSSFontSize: parse a CSS font size attr string
1.1 cvs 1738: we expect the input string describing the attribute to be
1739: xx-small, x-small, small, medium, large, x-large, xx-large
1740: or an absolute size, or an imcrement relative to the parent
1741: ----------------------------------------------------------------------*/
1.79 cvs 1742: static char *ParseCSSFontSize (Element element, PSchema tsch,
1743: PresentationContext context, char *cssRule,
1744: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1745: {
1.171 quint 1746: ElementType elType;
1.1 cvs 1747: PresentationValue pval;
1.137 vatton 1748: char *ptr = NULL, *ptr1 = NULL;
1.14 cvs 1749: ThotBool real;
1.1 cvs 1750:
1751: pval.typed_data.real = FALSE;
1.82 cvs 1752: cssRule = SkipBlanksAndComments (cssRule);
1753: if (!strncasecmp (cssRule, "larger", 6))
1.1 cvs 1754: {
1.184 vatton 1755: pval.typed_data.unit = UNIT_PERCENT;
1.1 cvs 1756: pval.typed_data.value = 130;
1757: cssRule = SkipWord (cssRule);
1758: }
1.82 cvs 1759: else if (!strncasecmp (cssRule, "smaller", 7))
1.1 cvs 1760: {
1.184 vatton 1761: pval.typed_data.unit = UNIT_PERCENT;
1.1 cvs 1762: pval.typed_data.value = 80;
1763: cssRule = SkipWord (cssRule);
1764: }
1.82 cvs 1765: else if (!strncasecmp (cssRule, "xx-small", 8))
1.1 cvs 1766: {
1.184 vatton 1767: pval.typed_data.unit = UNIT_REL;
1.1 cvs 1768: pval.typed_data.value = 1;
1769: cssRule = SkipWord (cssRule);
1770: }
1.82 cvs 1771: else if (!strncasecmp (cssRule, "x-small", 7))
1.1 cvs 1772: {
1.184 vatton 1773: pval.typed_data.unit = UNIT_REL;
1.1 cvs 1774: pval.typed_data.value = 2;
1775: cssRule = SkipWord (cssRule);
1776: }
1.82 cvs 1777: else if (!strncasecmp (cssRule, "small", 5))
1.1 cvs 1778: {
1.184 vatton 1779: pval.typed_data.unit = UNIT_REL;
1.1 cvs 1780: pval.typed_data.value = 3;
1781: cssRule = SkipWord (cssRule);
1782: }
1.82 cvs 1783: else if (!strncasecmp (cssRule, "medium", 6))
1.1 cvs 1784: {
1.184 vatton 1785: pval.typed_data.unit = UNIT_REL;
1.1 cvs 1786: pval.typed_data.value = 4;
1787: cssRule = SkipWord (cssRule);
1788: }
1.82 cvs 1789: else if (!strncasecmp (cssRule, "large", 5))
1.1 cvs 1790: {
1.184 vatton 1791: pval.typed_data.unit = UNIT_REL;
1.1 cvs 1792: pval.typed_data.value = 5;
1793: cssRule = SkipWord (cssRule);
1794: }
1.82 cvs 1795: else if (!strncasecmp (cssRule, "x-large", 7))
1.1 cvs 1796: {
1.184 vatton 1797: pval.typed_data.unit = UNIT_REL;
1.1 cvs 1798: pval.typed_data.value = 6;
1799: cssRule = SkipWord (cssRule);
1800: }
1.82 cvs 1801: else if (!strncasecmp (cssRule, "xx-large", 8))
1.1 cvs 1802: {
1.184 vatton 1803: pval.typed_data.unit = UNIT_REL;
1.1 cvs 1804: pval.typed_data.value = 7;
1805: cssRule = SkipWord (cssRule);
1806: }
1.171 quint 1807: else if (!isdigit (*cssRule) && *cssRule != '.')
1808: return (cssRule);
1.1 cvs 1809: else
1810: {
1.25 cvs 1811: /* look for a '/' within the current cssRule */
1.137 vatton 1812: ptr1 = strchr (cssRule, ';');
1.82 cvs 1813: ptr = strchr (cssRule, '/');
1.137 vatton 1814: if (ptr && (ptr1 == NULL || ptr < ptr1))
1.25 cvs 1815: {
1816: /* keep the line spacing rule */
1.82 cvs 1817: ptr[0] = EOS;
1.25 cvs 1818: ptr = &ptr[1];
1819: }
1.137 vatton 1820: else
1821: ptr = NULL;
1.171 quint 1822:
1.1 cvs 1823: cssRule = ParseCSSUnit (cssRule, &pval);
1.171 quint 1824:
1.184 vatton 1825: if (pval.typed_data.unit == UNIT_BOX)
1.171 quint 1826: /* no unit specified */
1827: {
1828: elType = TtaGetElementType(element);
1829: if (!strcmp(TtaGetSSchemaName (elType.ElSSchema), "SVG"))
1830: /* we are working for an SVG element. No unit means pixels */
1.184 vatton 1831: pval.typed_data.unit = UNIT_PX;
1.171 quint 1832: }
1.168 vatton 1833: if (pval.typed_data.value != 0 &&
1.184 vatton 1834: (pval.typed_data.unit == UNIT_INVALID ||
1835: pval.typed_data.unit == UNIT_BOX ||
1.168 vatton 1836: pval.typed_data.value < 0))
1837: /* not a valid value */
1.1 cvs 1838: return (cssRule);
1.184 vatton 1839: else if (pval.typed_data.unit == UNIT_REL && pval.typed_data.value > 0)
1.1 cvs 1840: /* CSS relative sizes have to be higher than Thot ones */
1841: pval.typed_data.value += 1;
1842: else
1843: {
1844: real = pval.typed_data.real;
1.184 vatton 1845: if (pval.typed_data.unit == UNIT_EM)
1.1 cvs 1846: {
1847: if (real)
1848: {
1849: pval.typed_data.value /= 10;
1.11 cvs 1850: pval.typed_data.real = FALSE;
1.1 cvs 1851: real = FALSE;
1852: }
1853: else
1854: pval.typed_data.value *= 100;
1.184 vatton 1855: pval.typed_data.unit = UNIT_PERCENT;
1.1 cvs 1856: }
1.184 vatton 1857: else if (pval.typed_data.unit == UNIT_XHEIGHT)
1.146 quint 1858: {
1859: /* a font size expressed in ex is converted into a percentage.
1860: For example, "3ex" is converted into "180%", supposing
1861: that 1ex is approximately 0.6 times the height of the
1862: current font */
1863: if (real)
1864: {
1865: pval.typed_data.value *= 6;
1866: pval.typed_data.value /= 100;
1867: pval.typed_data.real = FALSE;
1868: real = FALSE;
1869: }
1870: else
1871: pval.typed_data.value *= 60;
1.184 vatton 1872: pval.typed_data.unit = UNIT_PERCENT;
1.146 quint 1873: }
1.1 cvs 1874: }
1875: }
1876:
1.25 cvs 1877: /* install the presentation style */
1.116 vatton 1878: if (DoApply)
1.117 vatton 1879: {
1880: if (tsch)
1881: cssRule = CheckImportantRule (cssRule, context);
1882: TtaSetStylePresentation (PRSize, element, tsch, context, pval);
1883: }
1884: if (ptr)
1.162 quint 1885: cssRule = ParseCSSLineHeight (element, tsch, context, ptr, css, isHTML);
1.1 cvs 1886: return (cssRule);
1887: }
1888:
1889: /*----------------------------------------------------------------------
1.59 cvs 1890: ParseCSSFontFamily: parse a CSS font family string
1.1 cvs 1891: we expect the input string describing the attribute to be
1892: a common generic font style name
1893: ----------------------------------------------------------------------*/
1.79 cvs 1894: static char *ParseCSSFontFamily (Element element, PSchema tsch,
1895: PresentationContext context, char *cssRule,
1896: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1897: {
1898: PresentationValue font;
1.79 cvs 1899: char quoteChar;
1.1 cvs 1900:
1901: font.typed_data.value = 0;
1.184 vatton 1902: font.typed_data.unit = UNIT_REL;
1.1 cvs 1903: font.typed_data.real = FALSE;
1.82 cvs 1904: cssRule = SkipBlanksAndComments (cssRule);
1905: if (*cssRule == '"' || *cssRule == '\'')
1.1 cvs 1906: {
1907: quoteChar = *cssRule;
1908: cssRule++;
1909: }
1910: else
1.82 cvs 1911: quoteChar = EOS;
1.1 cvs 1912:
1.92 cvs 1913: if (!strncasecmp (cssRule, "times", 5) &&
1914: (quoteChar == EOS || quoteChar == cssRule[5]))
1.86 cvs 1915: {
1.184 vatton 1916: font.typed_data.value = FontTimes;
1.86 cvs 1917: cssRule += 5;
1918: }
1.92 cvs 1919: else if (!strncasecmp (cssRule, "serif", 5) &&
1920: (quoteChar == EOS || quoteChar == cssRule[5]))
1.86 cvs 1921: {
1.184 vatton 1922: font.typed_data.value = FontTimes;
1.86 cvs 1923: cssRule += 5;
1.92 cvs 1924: if (quoteChar != EOS)
1925: cssRule++;
1.86 cvs 1926: }
1.92 cvs 1927: else if (!strncasecmp (cssRule, "helvetica", 9) &&
1928: (quoteChar == EOS || quoteChar == cssRule[9]))
1.86 cvs 1929: {
1.184 vatton 1930: font.typed_data.value = FontHelvetica;
1.86 cvs 1931: cssRule += 9;
1.92 cvs 1932: if (quoteChar != EOS)
1933: cssRule++;
1.86 cvs 1934: }
1.92 cvs 1935: else if (!strncasecmp (cssRule, "verdana", 7) &&
1936: (quoteChar == EOS || quoteChar == cssRule[7]))
1.86 cvs 1937: {
1.184 vatton 1938: font.typed_data.value = FontHelvetica;
1.86 cvs 1939: cssRule += 7;
1.92 cvs 1940: if (quoteChar != EOS)
1941: cssRule++;
1.86 cvs 1942: }
1.92 cvs 1943: else if (!strncasecmp (cssRule, "sans-serif", 10) &&
1944: (quoteChar == EOS || quoteChar == cssRule[10]))
1.86 cvs 1945: {
1.184 vatton 1946: font.typed_data.value = FontHelvetica;
1.86 cvs 1947: cssRule += 10;
1.92 cvs 1948: if (quoteChar != EOS)
1949: cssRule++;
1.86 cvs 1950: }
1.92 cvs 1951: else if (!strncasecmp (cssRule, "courier", 7) &&
1952: (quoteChar == EOS || quoteChar == cssRule[7]))
1.86 cvs 1953: {
1.184 vatton 1954: font.typed_data.value = FontCourier;
1.86 cvs 1955: cssRule += 7;
1.92 cvs 1956: if (quoteChar != EOS)
1957: cssRule++;
1.86 cvs 1958: }
1.92 cvs 1959: else if (!strncasecmp (cssRule, "monospace", 9) &&
1960: (quoteChar == EOS || quoteChar == cssRule[9]))
1.86 cvs 1961: {
1.184 vatton 1962: font.typed_data.value = FontCourier;
1.86 cvs 1963: cssRule += 9;
1.92 cvs 1964: if (quoteChar != EOS)
1965: cssRule++;
1.86 cvs 1966: }
1.1 cvs 1967: else
1968: /* unknown font name. Skip it */
1969: {
1.92 cvs 1970: if (quoteChar != EOS)
1.54 cvs 1971: cssRule = SkipQuotedString (cssRule, quoteChar);
1.86 cvs 1972: else
1.1 cvs 1973: cssRule = SkipWord (cssRule);
1.82 cvs 1974: cssRule = SkipBlanksAndComments (cssRule);
1975: if (*cssRule == ',')
1.1 cvs 1976: {
1.86 cvs 1977: cssRule++;
1978: cssRule = ParseCSSFontFamily (element, tsch, context, cssRule, css, isHTML);
1979: return (cssRule);
1.1 cvs 1980: }
1981: }
1982:
1983: if (font.typed_data.value != 0)
1984: {
1.93 vatton 1985: cssRule = SkipBlanksAndComments (cssRule);
1.133 vatton 1986: if (*cssRule == ',')
1987: {
1988: cssRule++;
1.168 vatton 1989: cssRule = SkipValue (NULL, cssRule);
1.133 vatton 1990: }
1.93 vatton 1991: /* install the new presentation */
1.116 vatton 1992: if (DoApply)
1.117 vatton 1993: {
1994: if (tsch)
1995: cssRule = CheckImportantRule (cssRule, context);
1996: TtaSetStylePresentation (PRFont, element, tsch, context, font);
1997: }
1.1 cvs 1998: }
1999: return (cssRule);
2000: }
2001:
2002: /*----------------------------------------------------------------------
1.59 cvs 2003: ParseCSSFontWeight: parse a CSS font weight string
1.1 cvs 2004: we expect the input string describing the attribute to be
1.20 cvs 2005: normal, bold, bolder, lighter, 100, 200, 300, ... 900, inherit.
1.1 cvs 2006: ----------------------------------------------------------------------*/
1.79 cvs 2007: static char *ParseCSSFontWeight (Element element, PSchema tsch,
2008: PresentationContext context, char *cssRule,
2009: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2010: {
1.20 cvs 2011: PresentationValue weight;
1.1 cvs 2012:
2013: weight.typed_data.value = 0;
1.184 vatton 2014: weight.typed_data.unit = UNIT_REL;
1.1 cvs 2015: weight.typed_data.real = FALSE;
1.82 cvs 2016: cssRule = SkipBlanksAndComments (cssRule);
2017: if (!strncasecmp (cssRule, "100", 3) && !isalpha (cssRule[3]))
1.1 cvs 2018: {
2019: weight.typed_data.value = -3;
2020: cssRule = SkipWord (cssRule);
2021: }
1.82 cvs 2022: else if (!strncasecmp (cssRule, "200", 3) && !isalpha (cssRule[3]))
1.1 cvs 2023: {
2024: weight.typed_data.value = -2;
2025: cssRule = SkipWord (cssRule);
2026: }
1.82 cvs 2027: else if (!strncasecmp (cssRule, "300", 3) && ! isalpha(cssRule[3]))
1.1 cvs 2028: {
2029: weight.typed_data.value = -1;
2030: cssRule = SkipWord (cssRule);
2031: }
1.82 cvs 2032: else if (!strncasecmp (cssRule, "normal", 6) || (!strncasecmp (cssRule, "400", 3) && !isalpha (cssRule[3])))
1.1 cvs 2033: {
2034: weight.typed_data.value = 0;
2035: cssRule = SkipWord (cssRule);
2036: }
1.82 cvs 2037: else if (!strncasecmp (cssRule, "500", 3) && !isalpha (cssRule[3]))
1.1 cvs 2038: {
2039: weight.typed_data.value = +1;
2040: cssRule = SkipWord (cssRule);
2041: }
1.82 cvs 2042: else if (!strncasecmp (cssRule, "600", 3) && !isalpha (cssRule[3]))
1.1 cvs 2043: {
2044: weight.typed_data.value = +2;
2045: cssRule = SkipWord (cssRule);
2046: }
1.82 cvs 2047: else if (!strncasecmp (cssRule, "bold", 4) || (!strncasecmp (cssRule, "700", 3) && !isalpha (cssRule[3])))
1.1 cvs 2048: {
2049: weight.typed_data.value = +3;
2050: cssRule = SkipWord (cssRule);
2051: }
1.82 cvs 2052: else if (!strncasecmp (cssRule, "800", 3) && !isalpha (cssRule[3]))
1.1 cvs 2053: {
2054: weight.typed_data.value = +4;
2055: cssRule = SkipWord (cssRule);
2056: }
1.82 cvs 2057: else if (!strncasecmp (cssRule, "900", 3) && !isalpha (cssRule[3]))
1.1 cvs 2058: {
2059: weight.typed_data.value = +5;
2060: cssRule = SkipWord (cssRule);
2061: }
1.82 cvs 2062: else if (!strncasecmp (cssRule, "inherit", 7) || !strncasecmp (cssRule, "bolder", 6) || !strncasecmp (cssRule, "lighter", 7))
1.1 cvs 2063: {
2064: /* not implemented */
2065: cssRule = SkipWord (cssRule);
2066: return (cssRule);
2067: }
2068: else
2069: return (cssRule);
2070:
2071: /*
1.20 cvs 2072: * Here we have to reduce since only two font weight values are supported
1.1 cvs 2073: * by the Thot presentation API.
2074: */
1.20 cvs 2075: if (weight.typed_data.value > 0)
1.184 vatton 2076: weight.typed_data.value = WeightBold;
1.20 cvs 2077: else
1.184 vatton 2078: weight.typed_data.value = WeightNormal;
1.1 cvs 2079:
2080: /* install the new presentation */
1.116 vatton 2081: if (DoApply)
1.117 vatton 2082: {
2083: if (tsch)
2084: cssRule = CheckImportantRule (cssRule, context);
2085: TtaSetStylePresentation (PRWeight, element, tsch, context, weight);
2086: }
1.1 cvs 2087: return (cssRule);
2088: }
2089:
2090: /*----------------------------------------------------------------------
1.59 cvs 2091: ParseCSSFontVariant: parse a CSS font variant string
1.1 cvs 2092: we expect the input string describing the attribute to be
2093: normal or small-caps
2094: ----------------------------------------------------------------------*/
1.79 cvs 2095: static char *ParseCSSFontVariant (Element element, PSchema tsch,
2096: PresentationContext context, char *cssRule,
2097: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2098: {
2099: PresentationValue style;
2100:
2101: style.typed_data.value = 0;
1.184 vatton 2102: style.typed_data.unit = UNIT_REL;
1.1 cvs 2103: style.typed_data.real = FALSE;
1.82 cvs 2104: cssRule = SkipBlanksAndComments (cssRule);
2105: if (!strncasecmp (cssRule, "small-caps", 10))
1.1 cvs 2106: {
2107: /* Not supported yet */
2108: cssRule = SkipWord (cssRule);
2109: }
1.82 cvs 2110: else if (!strncasecmp (cssRule, "normal", 6))
1.1 cvs 2111: {
2112: /* Not supported yet */
2113: cssRule = SkipWord (cssRule);
2114: }
1.82 cvs 2115: else if (!strncasecmp (cssRule, "inherit", 7))
1.1 cvs 2116: {
2117: /* Not supported yet */
2118: cssRule = SkipWord (cssRule);
2119: }
2120: else
2121: return (cssRule);
2122:
2123: return (cssRule);
2124: }
2125:
2126:
2127: /*----------------------------------------------------------------------
1.59 cvs 2128: ParseCSSFontStyle: parse a CSS font style string
1.1 cvs 2129: we expect the input string describing the attribute to be
2130: italic, oblique or normal
2131: ----------------------------------------------------------------------*/
1.79 cvs 2132: static char *ParseCSSFontStyle (Element element, PSchema tsch,
2133: PresentationContext context, char *cssRule,
2134: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2135: {
2136: PresentationValue style;
2137: PresentationValue size;
2138:
2139: style.typed_data.value = 0;
1.184 vatton 2140: style.typed_data.unit = UNIT_REL;
1.1 cvs 2141: style.typed_data.real = FALSE;
2142: size.typed_data.value = 0;
1.184 vatton 2143: size.typed_data.unit = UNIT_REL;
1.1 cvs 2144: size.typed_data.real = FALSE;
1.82 cvs 2145: cssRule = SkipBlanksAndComments (cssRule);
2146: if (!strncasecmp (cssRule, "italic", 6))
1.1 cvs 2147: {
1.184 vatton 2148: style.typed_data.value = StyleItalics;
1.1 cvs 2149: cssRule = SkipWord (cssRule);
2150: }
1.82 cvs 2151: else if (!strncasecmp (cssRule, "oblique", 7))
1.1 cvs 2152: {
1.184 vatton 2153: style.typed_data.value = StyleOblique;
1.1 cvs 2154: cssRule = SkipWord (cssRule);
2155: }
1.82 cvs 2156: else if (!strncasecmp (cssRule, "normal", 6))
1.1 cvs 2157: {
1.184 vatton 2158: style.typed_data.value = StyleRoman;
1.1 cvs 2159: cssRule = SkipWord (cssRule);
2160: }
1.108 cvs 2161: else if (!strncasecmp (cssRule, "inherit", 7))
2162: {
2163: /* not implemented */
2164: cssRule = SkipWord (cssRule);
2165: return (cssRule);
2166: }
1.1 cvs 2167: else
2168: {
2169: /* invalid font style */
1.108 cvs 2170: return (cssRule);
1.1 cvs 2171: }
2172:
2173: /*
2174: * install the new presentation.
2175: */
1.116 vatton 2176: if (style.typed_data.value != 0 && DoApply)
1.117 vatton 2177: {
2178: if (tsch)
2179: cssRule = CheckImportantRule (cssRule, context);
1.20 cvs 2180: TtaSetStylePresentation (PRStyle, element, tsch, context, style);
1.117 vatton 2181: }
1.116 vatton 2182: if (size.typed_data.value != 0 && DoApply)
1.1 cvs 2183: {
2184: PresentationValue previous_size;
2185:
2186: if (!TtaGetStylePresentation (PRSize, element, tsch, context, &previous_size))
2187: {
2188: /* !!!!!!!!!!!!!!!!!!!!!!!! Unite + relatif !!!!!!!!!!!!!!!! */
2189: size.typed_data.value += previous_size.typed_data.value;
2190: TtaSetStylePresentation (PRSize, element, tsch, context, size);
2191: }
2192: else
2193: {
2194: size.typed_data.value = 10;
2195: TtaSetStylePresentation (PRSize, element, tsch, context, size);
2196: }
2197: }
2198: return (cssRule);
2199: }
2200:
2201: /*----------------------------------------------------------------------
1.59 cvs 2202: ParseCSSFont: parse a CSS font attribute string
2203: we expect the input string describing the attribute to be
2204: !!!!!!
1.1 cvs 2205: ----------------------------------------------------------------------*/
1.79 cvs 2206: static char *ParseCSSFont (Element element, PSchema tsch,
2207: PresentationContext context, char *cssRule,
2208: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2209: {
1.79 cvs 2210: char *ptr;
1.93 vatton 2211: int skippedNL;
1.1 cvs 2212:
1.82 cvs 2213: cssRule = SkipBlanksAndComments (cssRule);
2214: if (!strncasecmp (cssRule, "caption", 7))
1.1 cvs 2215: ;
1.82 cvs 2216: else if (!strncasecmp (cssRule, "icon", 4))
1.1 cvs 2217: ;
1.82 cvs 2218: else if (!strncasecmp (cssRule, "menu", 4))
1.1 cvs 2219: ;
1.82 cvs 2220: else if (!strncasecmp (cssRule, "message-box", 11))
1.1 cvs 2221: ;
1.82 cvs 2222: else if (!strncasecmp (cssRule, "small-caption", 13))
1.1 cvs 2223: ;
1.82 cvs 2224: else if (!strncasecmp (cssRule, "status-bar", 10))
1.1 cvs 2225: ;
2226: else
1.43 cvs 2227: {
1.133 vatton 2228: while (*cssRule != ';' && *cssRule != EOS)
1.43 cvs 2229: {
1.72 cvs 2230: ptr = cssRule;
1.93 vatton 2231: skippedNL = NewLineSkipped;
1.72 cvs 2232: cssRule = ParseCSSFontStyle (element, tsch, context, cssRule, css, isHTML);
2233: if (ptr == cssRule)
1.93 vatton 2234: {
2235: NewLineSkipped = skippedNL;
2236: cssRule = ParseCSSFontVariant (element, tsch, context, cssRule, css, isHTML);
2237: }
1.72 cvs 2238: if (ptr == cssRule)
1.93 vatton 2239: {
2240: NewLineSkipped = skippedNL;
2241: cssRule = ParseCSSFontWeight (element, tsch, context, cssRule, css, isHTML);
2242: }
1.72 cvs 2243: if (ptr == cssRule)
1.93 vatton 2244: {
2245: NewLineSkipped = skippedNL;
2246: cssRule = ParseCSSFontSize (element, tsch, context, cssRule, css, isHTML);
2247: }
1.72 cvs 2248: if (ptr == cssRule)
1.93 vatton 2249: {
2250: NewLineSkipped = skippedNL;
2251: cssRule = ParseCSSFontFamily (element, tsch, context, cssRule, css, isHTML);
2252: }
1.99 vatton 2253: if (ptr == cssRule)
1.168 vatton 2254: cssRule = SkipValue ("Invalid font value", cssRule);
1.82 cvs 2255: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 2256: }
2257: }
2258: return (cssRule);
1.1 cvs 2259: }
2260:
2261: /*----------------------------------------------------------------------
1.59 cvs 2262: ParseCSSTextDecoration: parse a CSS text decor string
2263: we expect the input string describing the attribute to be
1.109 cvs 2264: underline, overline, line-through, blink or none.
1.1 cvs 2265: ----------------------------------------------------------------------*/
1.79 cvs 2266: static char *ParseCSSTextDecoration (Element element, PSchema tsch,
2267: PresentationContext context, char *cssRule,
2268: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2269: {
2270: PresentationValue decor;
1.168 vatton 2271: char *ptr;
1.1 cvs 2272:
2273: decor.typed_data.value = 0;
1.184 vatton 2274: decor.typed_data.unit = UNIT_REL;
1.1 cvs 2275: decor.typed_data.real = FALSE;
1.82 cvs 2276: cssRule = SkipBlanksAndComments (cssRule);
1.142 quint 2277: if (!strncasecmp (cssRule, "none", strlen ("none")))
2278: {
2279: decor.typed_data.value = NoUnderline;
2280: cssRule = SkipWord (cssRule);
2281: }
2282: else if (!strncasecmp (cssRule, "underline", strlen ("underline")))
1.1 cvs 2283: {
2284: decor.typed_data.value = Underline;
2285: cssRule = SkipWord (cssRule);
2286: }
1.82 cvs 2287: else if (!strncasecmp (cssRule, "overline", strlen ("overline")))
1.1 cvs 2288: {
2289: decor.typed_data.value = Overline;
2290: cssRule = SkipWord (cssRule);
2291: }
1.82 cvs 2292: else if (!strncasecmp (cssRule, "line-through", strlen ("line-through")))
1.1 cvs 2293: {
2294: decor.typed_data.value = CrossOut;
2295: cssRule = SkipWord (cssRule);
2296: }
1.82 cvs 2297: else if (!strncasecmp (cssRule, "blink", strlen ("blink")))
1.1 cvs 2298: {
1.109 cvs 2299: /* the blink text-decoration attribute is not supported */
1.1 cvs 2300: cssRule = SkipWord (cssRule);
2301: }
1.142 quint 2302: else if (!strncasecmp (cssRule, "inherit", 7))
1.1 cvs 2303: {
1.142 quint 2304: cssRule = SkipWord (cssRule);
2305: return (cssRule);
1.1 cvs 2306: }
2307: else
2308: {
1.168 vatton 2309: ptr = cssRule;
2310: cssRule = SkipWord (cssRule);
2311: CSSParseError ("Invalid text-decoration value", ptr, cssRule);
1.1 cvs 2312: return (cssRule);
2313: }
2314:
2315: /*
2316: * install the new presentation.
2317: */
1.116 vatton 2318: if (decor.typed_data.value && DoApply)
1.1 cvs 2319: {
1.117 vatton 2320: if (tsch)
2321: cssRule = CheckImportantRule (cssRule, context);
1.1 cvs 2322: TtaSetStylePresentation (PRUnderline, element, tsch, context, decor);
2323: }
2324: return (cssRule);
2325: }
2326:
2327: /*----------------------------------------------------------------------
1.59 cvs 2328: ParseCSSHeight: parse a CSS height attribute
1.1 cvs 2329: ----------------------------------------------------------------------*/
1.79 cvs 2330: static char *ParseCSSHeight (Element element, PSchema tsch,
1.93 vatton 2331: PresentationContext context, char *cssRule,
2332: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2333: {
1.117 vatton 2334: PresentationValue val;
1.168 vatton 2335: char *ptr;
1.93 vatton 2336:
1.117 vatton 2337: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2338: ptr = cssRule;
1.117 vatton 2339: /* first parse the attribute string */
1.164 quint 2340: if (!strncasecmp (cssRule, "auto", 4))
2341: {
1.184 vatton 2342: val.typed_data.unit = VALUE_AUTO;
1.164 quint 2343: val.typed_data.value = 0;
2344: val.typed_data.real = FALSE;
2345: cssRule = SkipWord (cssRule);
2346: }
1.117 vatton 2347: else
1.168 vatton 2348: cssRule = ParseCSSUnit (cssRule, &val);
2349: if (val.typed_data.value != 0 &&
1.184 vatton 2350: (val.typed_data.unit == UNIT_INVALID ||
2351: val.typed_data.unit == UNIT_BOX))
1.168 vatton 2352: CSSParseError ("height value", ptr, cssRule);
2353: else if (DoApply)
1.117 vatton 2354: {
1.164 quint 2355: if (tsch)
2356: cssRule = CheckImportantRule (cssRule, context);
2357: /* install the new presentation */
2358: TtaSetStylePresentation (PRHeight, element, tsch, context, val);
1.117 vatton 2359: }
2360: return (cssRule);
1.1 cvs 2361: }
2362:
2363: /*----------------------------------------------------------------------
1.59 cvs 2364: ParseCSSWidth: parse a CSS width attribute
1.1 cvs 2365: ----------------------------------------------------------------------*/
1.79 cvs 2366: static char *ParseCSSWidth (Element element, PSchema tsch,
1.78 cvs 2367: PresentationContext context,
1.79 cvs 2368: char *cssRule, CSSInfoPtr css,
1.78 cvs 2369: ThotBool isHTML)
1.1 cvs 2370: {
1.117 vatton 2371: PresentationValue val;
1.168 vatton 2372: char *ptr;
1.93 vatton 2373:
1.117 vatton 2374: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2375: ptr = cssRule;
1.117 vatton 2376: /* first parse the attribute string */
1.164 quint 2377: if (!strncasecmp (cssRule, "auto", 4))
2378: {
1.184 vatton 2379: val.typed_data.unit = VALUE_AUTO;
1.164 quint 2380: val.typed_data.value = 0;
2381: val.typed_data.real = FALSE;
2382: cssRule = SkipWord (cssRule);
2383: }
1.117 vatton 2384: else
1.164 quint 2385: cssRule = ParseCSSUnit (cssRule, &val);
1.168 vatton 2386: if (val.typed_data.value != 0 &&
1.184 vatton 2387: (val.typed_data.unit == UNIT_INVALID ||
2388: val.typed_data.unit == UNIT_BOX))
1.168 vatton 2389: CSSParseError ("Invalid width value", ptr, cssRule);
2390: else if (DoApply)
1.117 vatton 2391: {
1.164 quint 2392: if (tsch)
2393: cssRule = CheckImportantRule (cssRule, context);
2394: /* install the new presentation */
2395: TtaSetStylePresentation (PRWidth, element, tsch, context, val);
1.117 vatton 2396: }
2397: return (cssRule);
1.1 cvs 2398: }
2399:
2400: /*----------------------------------------------------------------------
1.59 cvs 2401: ParseCSSMarginTop: parse a CSS margin-top attribute
1.1 cvs 2402: ----------------------------------------------------------------------*/
1.79 cvs 2403: static char *ParseCSSMarginTop (Element element, PSchema tsch,
1.78 cvs 2404: PresentationContext context,
1.79 cvs 2405: char *cssRule, CSSInfoPtr css,
1.78 cvs 2406: ThotBool isHTML)
1.1 cvs 2407: {
2408: PresentationValue margin;
1.168 vatton 2409: char *ptr;
1.1 cvs 2410:
1.82 cvs 2411: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2412: ptr = cssRule;
1.1 cvs 2413: /* first parse the attribute string */
1.164 quint 2414: if (!strncasecmp (cssRule, "auto", 4))
2415: {
1.184 vatton 2416: margin.typed_data.unit = VALUE_AUTO;
1.164 quint 2417: margin.typed_data.value = 0;
2418: margin.typed_data.real = FALSE;
2419: cssRule = SkipWord (cssRule);
2420: }
2421: else
1.168 vatton 2422: cssRule = ParseCSSUnit (cssRule, &margin);
2423: if (margin.typed_data.value != 0 &&
1.184 vatton 2424: (margin.typed_data.unit == UNIT_INVALID ||
2425: margin.typed_data.unit == UNIT_BOX))
1.169 vatton 2426: CSSParseError ("Invalid margin-top value", ptr, cssRule);
1.168 vatton 2427: else if (DoApply)
1.117 vatton 2428: {
2429: if (tsch)
2430: cssRule = CheckImportantRule (cssRule, context);
2431: TtaSetStylePresentation (PRMarginTop, element, tsch, context, margin);
2432: }
1.1 cvs 2433: return (cssRule);
2434: }
2435:
2436: /*----------------------------------------------------------------------
1.59 cvs 2437: ParseCSSMarginBottom: parse a CSS margin-bottom attribute
1.1 cvs 2438: ----------------------------------------------------------------------*/
1.79 cvs 2439: static char *ParseCSSMarginBottom (Element element, PSchema tsch,
1.78 cvs 2440: PresentationContext context,
1.79 cvs 2441: char *cssRule, CSSInfoPtr css,
1.78 cvs 2442: ThotBool isHTML)
1.1 cvs 2443: {
2444: PresentationValue margin;
1.168 vatton 2445: char *ptr;
1.1 cvs 2446:
1.82 cvs 2447: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2448: ptr = cssRule;
1.1 cvs 2449: /* first parse the attribute string */
1.164 quint 2450: if (!strncasecmp (cssRule, "auto", 4))
2451: {
1.184 vatton 2452: margin.typed_data.unit = VALUE_AUTO;
1.164 quint 2453: margin.typed_data.value = 0;
2454: margin.typed_data.real = FALSE;
2455: cssRule = SkipWord (cssRule);
2456: }
2457: else
1.168 vatton 2458: cssRule = ParseCSSUnit (cssRule, &margin);
2459: if (margin.typed_data.value != 0 &&
1.184 vatton 2460: (margin.typed_data.unit == UNIT_INVALID ||
2461: margin.typed_data.unit == UNIT_BOX))
1.169 vatton 2462: CSSParseError ("Invalid margin-bottom value", ptr, cssRule);
1.168 vatton 2463: else if (DoApply)
1.117 vatton 2464: {
2465: if (tsch)
2466: cssRule = CheckImportantRule (cssRule, context);
2467: TtaSetStylePresentation (PRMarginBottom, element, tsch, context, margin);
2468: }
1.1 cvs 2469: return (cssRule);
2470: }
2471:
2472: /*----------------------------------------------------------------------
1.59 cvs 2473: ParseCSSMarginLeft: parse a CSS margin-left attribute string
1.1 cvs 2474: ----------------------------------------------------------------------*/
1.79 cvs 2475: static char *ParseCSSMarginLeft (Element element, PSchema tsch,
1.78 cvs 2476: PresentationContext context,
1.79 cvs 2477: char *cssRule, CSSInfoPtr css,
1.78 cvs 2478: ThotBool isHTML)
1.1 cvs 2479: {
2480: PresentationValue margin;
1.168 vatton 2481: char *ptr;
1.1 cvs 2482:
1.82 cvs 2483: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2484: ptr = cssRule;
1.1 cvs 2485: /* first parse the attribute string */
1.164 quint 2486: if (!strncasecmp (cssRule, "auto", 4))
2487: {
1.184 vatton 2488: margin.typed_data.unit = VALUE_AUTO;
1.164 quint 2489: margin.typed_data.value = 0;
2490: margin.typed_data.real = FALSE;
2491: cssRule = SkipWord (cssRule);
2492: }
2493: else
1.168 vatton 2494: cssRule = ParseCSSUnit (cssRule, &margin);
2495: if (margin.typed_data.value != 0 &&
1.184 vatton 2496: (margin.typed_data.unit == UNIT_INVALID ||
2497: margin.typed_data.unit == UNIT_BOX))
1.169 vatton 2498: CSSParseError ("Invalid margin-left value", ptr, cssRule);
1.168 vatton 2499: else if (DoApply)
1.184 vatton 2500: if (margin.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 2501: {
2502: if (tsch)
2503: cssRule = CheckImportantRule (cssRule, context);
2504: TtaSetStylePresentation (PRMarginLeft, element, tsch, context, margin);
2505: }
1.1 cvs 2506: return (cssRule);
2507: }
2508:
2509: /*----------------------------------------------------------------------
1.59 cvs 2510: ParseCSSMarginRight: parse a CSS margin-right attribute string
1.1 cvs 2511: ----------------------------------------------------------------------*/
1.79 cvs 2512: static char *ParseCSSMarginRight (Element element, PSchema tsch,
1.78 cvs 2513: PresentationContext context,
1.79 cvs 2514: char *cssRule, CSSInfoPtr css,
1.78 cvs 2515: ThotBool isHTML)
1.1 cvs 2516: {
2517: PresentationValue margin;
1.168 vatton 2518: char *ptr;
1.1 cvs 2519:
1.82 cvs 2520: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2521: ptr = cssRule;
1.1 cvs 2522: /* first parse the attribute string */
1.164 quint 2523: if (!strncasecmp (cssRule, "auto", 4))
2524: {
1.184 vatton 2525: margin.typed_data.unit = VALUE_AUTO;
1.164 quint 2526: margin.typed_data.value = 0;
2527: margin.typed_data.real = FALSE;
2528: cssRule = SkipWord (cssRule);
2529: }
2530: else
1.168 vatton 2531: cssRule = ParseCSSUnit (cssRule, &margin);
2532: if (margin.typed_data.value != 0 &&
1.184 vatton 2533: (margin.typed_data.unit == UNIT_INVALID ||
2534: margin.typed_data.unit == UNIT_BOX))
1.169 vatton 2535: CSSParseError ("Invalid margin-right value", ptr, cssRule);
1.168 vatton 2536: else if (DoApply)
1.117 vatton 2537: {
2538: if (tsch)
2539: cssRule = CheckImportantRule (cssRule, context);
2540: TtaSetStylePresentation (PRMarginRight, element, tsch, context, margin);
2541: }
1.1 cvs 2542: return (cssRule);
2543: }
2544:
2545: /*----------------------------------------------------------------------
1.59 cvs 2546: ParseCSSMargin: parse a CSS margin attribute string
1.1 cvs 2547: ----------------------------------------------------------------------*/
1.79 cvs 2548: static char *ParseCSSMargin (Element element, PSchema tsch,
1.78 cvs 2549: PresentationContext context,
1.79 cvs 2550: char *cssRule, CSSInfoPtr css,
1.78 cvs 2551: ThotBool isHTML)
1.1 cvs 2552: {
1.79 cvs 2553: char *ptrT, *ptrR, *ptrB, *ptrL;
1.93 vatton 2554: int skippedNL;
1.1 cvs 2555:
1.82 cvs 2556: ptrT = SkipBlanksAndComments (cssRule);
1.1 cvs 2557: /* First parse Margin-Top */
2558: ptrR = ParseCSSMarginTop (element, tsch, context, ptrT, css, isHTML);
1.82 cvs 2559: ptrR = SkipBlanksAndComments (ptrR);
2560: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1.1 cvs 2561: {
1.93 vatton 2562: skippedNL = NewLineSkipped;
1.1 cvs 2563: cssRule = ptrR;
2564: /* apply the Margin-Top to all */
2565: ptrR = ParseCSSMarginRight (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 2566: NewLineSkipped = skippedNL;
1.1 cvs 2567: ptrR = ParseCSSMarginBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 2568: NewLineSkipped = skippedNL;
1.1 cvs 2569: ptrR = ParseCSSMarginLeft (element, tsch, context, ptrT, css, isHTML);
2570: }
2571: else
2572: {
2573: /* parse Margin-Right */
2574: ptrB = ParseCSSMarginRight (element, tsch, context, ptrR, css, isHTML);
1.82 cvs 2575: ptrB = SkipBlanksAndComments (ptrB);
2576: if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
1.1 cvs 2577: {
1.93 vatton 2578: skippedNL = NewLineSkipped;
1.1 cvs 2579: cssRule = ptrB;
2580: /* apply the Margin-Top to Margin-Bottom */
2581: ptrB = ParseCSSMarginBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 2582: NewLineSkipped = skippedNL;
1.1 cvs 2583: /* apply the Margin-Right to Margin-Left */
2584: ptrB = ParseCSSMarginLeft (element, tsch, context, ptrR, css, isHTML);
2585: }
2586: else
2587: {
2588: /* parse Margin-Bottom */
2589: ptrL = ParseCSSMarginBottom (element, tsch, context, ptrB, css, isHTML);
1.82 cvs 2590: ptrL = SkipBlanksAndComments (ptrL);
2591: if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
1.1 cvs 2592: {
2593: cssRule = ptrL;
2594: /* apply the Margin-Right to Margin-Left */
2595: ptrL = ParseCSSMarginLeft (element, tsch, context, ptrR, css, isHTML);
2596: }
2597: else
2598: /* parse Margin-Left */
2599: cssRule = ParseCSSMarginLeft (element, tsch, context, ptrL, css, isHTML);
1.82 cvs 2600: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 2601: }
2602: }
2603: return (cssRule);
2604: }
2605:
2606: /*----------------------------------------------------------------------
1.59 cvs 2607: ParseCSSPaddingTop: parse a CSS PaddingTop attribute string
1.1 cvs 2608: ----------------------------------------------------------------------*/
1.79 cvs 2609: static char *ParseCSSPaddingTop (Element element, PSchema tsch,
1.78 cvs 2610: PresentationContext context,
1.79 cvs 2611: char *cssRule, CSSInfoPtr css,
1.78 cvs 2612: ThotBool isHTML)
1.1 cvs 2613: {
1.43 cvs 2614: PresentationValue padding;
1.168 vatton 2615: char *ptr;
1.43 cvs 2616:
1.82 cvs 2617: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2618: ptr = cssRule;
1.43 cvs 2619: /* first parse the attribute string */
2620: cssRule = ParseCSSUnit (cssRule, &padding);
1.168 vatton 2621: if (padding.typed_data.value != 0 &&
1.184 vatton 2622: (padding.typed_data.unit == UNIT_INVALID ||
2623: padding.typed_data.unit == UNIT_BOX))
1.168 vatton 2624: {
1.169 vatton 2625: CSSParseError ("Invalid padding-top value", ptr, cssRule);
1.168 vatton 2626: padding.typed_data.value = 0;
2627: }
2628: else if (DoApply)
1.117 vatton 2629: {
2630: if (tsch)
2631: cssRule = CheckImportantRule (cssRule, context);
2632: TtaSetStylePresentation (PRPaddingTop, element, tsch, context, padding);
2633: }
1.1 cvs 2634: return (cssRule);
2635: }
2636:
2637: /*----------------------------------------------------------------------
1.59 cvs 2638: ParseCSSPaddingBottom: parse a CSS PaddingBottom attribute string
1.1 cvs 2639: ----------------------------------------------------------------------*/
1.79 cvs 2640: static char *ParseCSSPaddingBottom (Element element, PSchema tsch,
1.78 cvs 2641: PresentationContext context,
1.79 cvs 2642: char *cssRule, CSSInfoPtr css,
1.78 cvs 2643: ThotBool isHTML)
1.1 cvs 2644: {
1.43 cvs 2645: PresentationValue padding;
1.168 vatton 2646: char *ptr;
1.43 cvs 2647:
1.82 cvs 2648: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2649: ptr = cssRule;
1.43 cvs 2650: /* first parse the attribute string */
2651: cssRule = ParseCSSUnit (cssRule, &padding);
1.168 vatton 2652: if (padding.typed_data.value == 0)
1.184 vatton 2653: padding.typed_data.unit = UNIT_EM;
1.168 vatton 2654: if (padding.typed_data.value != 0 &&
1.184 vatton 2655: (padding.typed_data.unit == UNIT_INVALID ||
2656: padding.typed_data.unit == UNIT_BOX))
1.168 vatton 2657: {
1.169 vatton 2658: CSSParseError ("Invalid padding-bottom value", ptr, cssRule);
1.168 vatton 2659: padding.typed_data.value = 0;
2660: }
2661: else if (DoApply)
1.117 vatton 2662: {
2663: if (tsch)
2664: cssRule = CheckImportantRule (cssRule, context);
2665: TtaSetStylePresentation (PRPaddingBottom, element, tsch, context, padding);
2666: }
1.1 cvs 2667: return (cssRule);
2668: }
2669:
2670: /*----------------------------------------------------------------------
1.59 cvs 2671: ParseCSSPaddingLeft: parse a CSS PaddingLeft attribute string.
1.1 cvs 2672: ----------------------------------------------------------------------*/
1.79 cvs 2673: static char *ParseCSSPaddingLeft (Element element, PSchema tsch,
1.78 cvs 2674: PresentationContext context,
1.79 cvs 2675: char *cssRule, CSSInfoPtr css,
1.78 cvs 2676: ThotBool isHTML)
1.1 cvs 2677: {
1.43 cvs 2678: PresentationValue padding;
1.168 vatton 2679: char *ptr;
1.43 cvs 2680:
1.82 cvs 2681: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2682: ptr = cssRule;
1.43 cvs 2683: /* first parse the attribute string */
2684: cssRule = ParseCSSUnit (cssRule, &padding);
1.168 vatton 2685: if (padding.typed_data.value == 0)
1.184 vatton 2686: padding.typed_data.unit = UNIT_EM;
1.168 vatton 2687: if (padding.typed_data.value != 0 &&
1.184 vatton 2688: (padding.typed_data.unit == UNIT_INVALID ||
2689: padding.typed_data.unit == UNIT_BOX))
1.168 vatton 2690: {
1.169 vatton 2691: CSSParseError ("Invalid padding-left value", ptr, cssRule);
1.168 vatton 2692: padding.typed_data.value = 0;
2693: }
2694: else if (DoApply)
1.117 vatton 2695: {
2696: if (tsch)
2697: cssRule = CheckImportantRule (cssRule, context);
1.43 cvs 2698: TtaSetStylePresentation (PRPaddingLeft, element, tsch, context, padding);
1.117 vatton 2699: }
1.1 cvs 2700: return (cssRule);
2701: }
2702:
2703: /*----------------------------------------------------------------------
1.59 cvs 2704: ParseCSSPaddingRight: parse a CSS PaddingRight attribute string.
1.1 cvs 2705: ----------------------------------------------------------------------*/
1.79 cvs 2706: static char *ParseCSSPaddingRight (Element element, PSchema tsch,
1.78 cvs 2707: PresentationContext context,
1.79 cvs 2708: char *cssRule, CSSInfoPtr css,
1.78 cvs 2709: ThotBool isHTML)
1.1 cvs 2710: {
1.43 cvs 2711: PresentationValue padding;
1.168 vatton 2712: char *ptr;
1.43 cvs 2713:
1.82 cvs 2714: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2715: ptr = cssRule;
1.43 cvs 2716: /* first parse the attribute string */
2717: cssRule = ParseCSSUnit (cssRule, &padding);
1.168 vatton 2718: if (padding.typed_data.value == 0)
1.184 vatton 2719: padding.typed_data.unit = UNIT_EM;
1.168 vatton 2720: if (padding.typed_data.value != 0 &&
1.184 vatton 2721: (padding.typed_data.unit == UNIT_INVALID ||
2722: padding.typed_data.unit == UNIT_BOX))
1.168 vatton 2723: {
1.169 vatton 2724: CSSParseError ("Invalid padding-right value", ptr, cssRule);
1.168 vatton 2725: padding.typed_data.value = 0;
2726: }
2727: else if (DoApply)
1.117 vatton 2728: {
2729: if (tsch)
2730: cssRule = CheckImportantRule (cssRule, context);
1.43 cvs 2731: TtaSetStylePresentation (PRPaddingRight, element, tsch, context, padding);
1.117 vatton 2732: }
1.1 cvs 2733: return (cssRule);
2734: }
2735:
2736: /*----------------------------------------------------------------------
1.59 cvs 2737: ParseCSSPadding: parse a CSS padding attribute string.
1.1 cvs 2738: ----------------------------------------------------------------------*/
1.79 cvs 2739: static char *ParseCSSPadding (Element element, PSchema tsch,
1.78 cvs 2740: PresentationContext context,
1.79 cvs 2741: char *cssRule, CSSInfoPtr css,
1.78 cvs 2742: ThotBool isHTML)
1.1 cvs 2743: {
1.79 cvs 2744: char *ptrT, *ptrR, *ptrB, *ptrL;
1.93 vatton 2745: int skippedNL;
1.43 cvs 2746:
1.82 cvs 2747: ptrT = SkipBlanksAndComments (cssRule);
1.43 cvs 2748: /* First parse Padding-Top */
2749: ptrR = ParseCSSPaddingTop (element, tsch, context, ptrT, css, isHTML);
1.82 cvs 2750: ptrR = SkipBlanksAndComments (ptrR);
2751: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1.43 cvs 2752: {
1.93 vatton 2753: skippedNL = NewLineSkipped;
1.43 cvs 2754: cssRule = ptrR;
2755: /* apply the Padding-Top to all */
2756: ptrR = ParseCSSPaddingRight (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 2757: NewLineSkipped = skippedNL;
1.43 cvs 2758: ptrR = ParseCSSPaddingBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 2759: NewLineSkipped = skippedNL;
1.43 cvs 2760: ptrR = ParseCSSPaddingLeft (element, tsch, context, ptrT, css, isHTML);
2761: }
2762: else
2763: {
2764: /* parse Padding-Right */
2765: ptrB = ParseCSSPaddingRight (element, tsch, context, ptrR, css, isHTML);
1.82 cvs 2766: ptrB = SkipBlanksAndComments (ptrB);
2767: if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
1.43 cvs 2768: {
1.93 vatton 2769: skippedNL = NewLineSkipped;
1.43 cvs 2770: cssRule = ptrB;
2771: /* apply the Padding-Top to Padding-Bottom */
2772: ptrB = ParseCSSPaddingBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 2773: NewLineSkipped = skippedNL;
1.43 cvs 2774: /* apply the Padding-Right to Padding-Left */
2775: ptrB = ParseCSSPaddingLeft (element, tsch, context, ptrR, css, isHTML);
2776: }
2777: else
2778: {
2779: /* parse Padding-Bottom */
2780: ptrL = ParseCSSPaddingBottom (element, tsch, context, ptrB, css, isHTML);
1.82 cvs 2781: ptrL = SkipBlanksAndComments (ptrL);
2782: if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
1.43 cvs 2783: {
2784: cssRule = ptrL;
2785: /* apply the Padding-Right to Padding-Left */
2786: ptrL = ParseCSSPaddingLeft (element, tsch, context, ptrR, css, isHTML);
2787: }
2788: else
2789: /* parse Padding-Left */
2790: cssRule = ParseCSSPaddingLeft (element, tsch, context, ptrL, css, isHTML);
1.82 cvs 2791: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 2792: }
2793: }
1.1 cvs 2794: return (cssRule);
2795: }
2796:
2797: /*----------------------------------------------------------------------
1.59 cvs 2798: ParseCSSForeground: parse a CSS foreground attribute
1.1 cvs 2799: ----------------------------------------------------------------------*/
1.79 cvs 2800: static char *ParseCSSForeground (Element element, PSchema tsch,
1.78 cvs 2801: PresentationContext context,
1.79 cvs 2802: char *cssRule,
1.78 cvs 2803: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2804: {
1.117 vatton 2805: PresentationValue best;
1.1 cvs 2806:
1.117 vatton 2807: cssRule = ParseCSSColor (cssRule, &best);
1.184 vatton 2808: if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 2809: {
2810: if (tsch)
2811: cssRule = CheckImportantRule (cssRule, context);
2812: /* install the new presentation */
2813: TtaSetStylePresentation (PRForeground, element, tsch, context, best);
2814: }
1.1 cvs 2815: return (cssRule);
2816: }
2817:
2818: /*----------------------------------------------------------------------
1.59 cvs 2819: ParseCSSBackgroundColor: parse a CSS background color attribute
1.1 cvs 2820: ----------------------------------------------------------------------*/
1.79 cvs 2821: static char *ParseCSSBackgroundColor (Element element, PSchema tsch,
1.78 cvs 2822: PresentationContext context,
1.79 cvs 2823: char *cssRule,
1.78 cvs 2824: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2825: {
2826: PresentationValue best;
2827:
1.184 vatton 2828: best.typed_data.unit = UNIT_INVALID;
1.1 cvs 2829: best.typed_data.real = FALSE;
1.82 cvs 2830: if (!strncasecmp (cssRule, "transparent", strlen ("transparent")))
1.1 cvs 2831: {
1.184 vatton 2832: best.typed_data.value = PATTERN_NONE;
2833: best.typed_data.unit = UNIT_REL;
1.116 vatton 2834: if (DoApply)
1.117 vatton 2835: {
2836: if (tsch)
2837: cssRule = CheckImportantRule (cssRule, context);
2838: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
2839: }
1.65 cvs 2840: cssRule = SkipWord (cssRule);
1.1 cvs 2841: }
2842: else
2843: {
2844: cssRule = ParseCSSColor (cssRule, &best);
1.184 vatton 2845: if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.1 cvs 2846: {
1.117 vatton 2847: if (tsch)
2848: cssRule = CheckImportantRule (cssRule, context);
1.1 cvs 2849: /* install the new presentation. */
2850: TtaSetStylePresentation (PRBackground, element, tsch, context, best);
1.59 cvs 2851: /* thot specificity: need to set fill pattern for background color */
1.184 vatton 2852: best.typed_data.value = PATTERN_BACKGROUND;
2853: best.typed_data.unit = UNIT_REL;
1.1 cvs 2854: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
2855: best.typed_data.value = 1;
1.184 vatton 2856: best.typed_data.unit = UNIT_REL;
1.1 cvs 2857: TtaSetStylePresentation (PRShowBox, element, tsch, context, best);
2858: }
2859: }
2860: return (cssRule);
2861: }
2862:
1.63 cvs 2863: /*----------------------------------------------------------------------
1.65 cvs 2864: ParseSVGStroke: parse a SVG stroke property
2865: ----------------------------------------------------------------------*/
1.79 cvs 2866: static char *ParseSVGStroke (Element element, PSchema tsch,
2867: PresentationContext context, char *cssRule,
2868: CSSInfoPtr css, ThotBool isHTML)
1.65 cvs 2869: {
2870: PresentationValue best;
2871:
1.184 vatton 2872: best.typed_data.unit = UNIT_INVALID;
1.65 cvs 2873: best.typed_data.real = FALSE;
1.82 cvs 2874: if (!strncasecmp (cssRule, "none", 4))
1.65 cvs 2875: {
2876: best.typed_data.value = -2; /* -2 means transparent */
1.184 vatton 2877: best.typed_data.unit = UNIT_REL;
1.116 vatton 2878: if (DoApply)
1.117 vatton 2879: {
2880: if (tsch)
2881: cssRule = CheckImportantRule (cssRule, context);
2882: TtaSetStylePresentation (PRForeground, element, tsch, context, best);
2883: }
1.65 cvs 2884: cssRule = SkipWord (cssRule);
2885: }
2886: else
2887: {
2888: cssRule = ParseCSSColor (cssRule, &best);
1.184 vatton 2889: if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 2890: {
2891: if (tsch)
2892: cssRule = CheckImportantRule (cssRule, context);
2893: /* install the new presentation */
2894: TtaSetStylePresentation (PRForeground, element, tsch, context, best);
2895: }
1.65 cvs 2896: }
2897: return (cssRule);
2898: }
2899:
2900: /*----------------------------------------------------------------------
1.63 cvs 2901: ParseSVGFill: parse a SVG fill property
2902: ----------------------------------------------------------------------*/
1.79 cvs 2903: static char *ParseSVGFill (Element element, PSchema tsch,
2904: PresentationContext context, char *cssRule,
2905: CSSInfoPtr css, ThotBool isHTML)
1.63 cvs 2906: {
2907: PresentationValue best;
2908:
1.184 vatton 2909: best.typed_data.unit = UNIT_INVALID;
1.63 cvs 2910: best.typed_data.real = FALSE;
1.82 cvs 2911: if (!strncasecmp (cssRule, "none", 4))
1.63 cvs 2912: {
1.184 vatton 2913: best.typed_data.value = PATTERN_NONE;
2914: best.typed_data.unit = UNIT_REL;
1.116 vatton 2915: if (DoApply)
1.117 vatton 2916: {
2917: if (tsch)
2918: cssRule = CheckImportantRule (cssRule, context);
2919: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
2920: }
1.65 cvs 2921: cssRule = SkipWord (cssRule);
1.63 cvs 2922: }
2923: else
2924: {
2925: cssRule = ParseCSSColor (cssRule, &best);
1.184 vatton 2926: if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.63 cvs 2927: {
1.117 vatton 2928: if (tsch)
2929: cssRule = CheckImportantRule (cssRule, context);
1.63 cvs 2930: /* install the new presentation. */
2931: TtaSetStylePresentation (PRBackground, element, tsch, context, best);
2932: /* thot specificity: need to set fill pattern for background color */
1.184 vatton 2933: best.typed_data.value = PATTERN_BACKGROUND;
2934: best.typed_data.unit = UNIT_REL;
1.63 cvs 2935: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
2936: }
2937: }
2938: return (cssRule);
2939: }
1.161 quint 2940:
1.155 cheyroul 2941: /*----------------------------------------------------------------------
2942: ParseSVGOpacity: parse a SVG fill property
2943: ----------------------------------------------------------------------*/
2944: static char *ParseSVGOpacity (Element element, PSchema tsch,
2945: PresentationContext context, char *cssRule,
2946: CSSInfoPtr css, ThotBool isHTML)
2947: {
2948: PresentationValue best;
1.63 cvs 2949:
1.184 vatton 2950: best.typed_data.unit = UNIT_INVALID;
1.155 cheyroul 2951: best.typed_data.real = FALSE;
2952: cssRule = ParseClampedUnit (cssRule, &best);
2953: if (DoApply)
2954: {
2955: if (tsch)
2956: cssRule = CheckImportantRule (cssRule, context);
2957: /* install the new presentation. */
2958: TtaSetStylePresentation (PROpacity, element,
2959: tsch, context, best);
2960: }
2961: return (cssRule);
2962: }
1.170 cheyroul 2963: /*----------------------------------------------------------------------
2964: ParseSVGOpacity: parse a SVG fill property
2965: ----------------------------------------------------------------------*/
2966: static char *ParseSVGStrokeOpacity (Element element, PSchema tsch,
2967: PresentationContext context, char *cssRule,
2968: CSSInfoPtr css, ThotBool isHTML)
2969: {
2970: PresentationValue best;
1.161 quint 2971:
1.184 vatton 2972: best.typed_data.unit = UNIT_INVALID;
1.170 cheyroul 2973: best.typed_data.real = FALSE;
2974: cssRule = ParseClampedUnit (cssRule, &best);
2975: if (DoApply)
2976: {
2977: if (tsch)
2978: cssRule = CheckImportantRule (cssRule, context);
2979: /* install the new presentation. */
2980: TtaSetStylePresentation (PRStrokeOpacity, element,
2981: tsch, context, best);
2982: }
2983: return (cssRule);
2984: }
2985: /*----------------------------------------------------------------------
2986: ParseSVGOpacity: parse a SVG fill property
2987: ----------------------------------------------------------------------*/
2988: static char *ParseSVGFillOpacity (Element element, PSchema tsch,
2989: PresentationContext context, char *cssRule,
2990: CSSInfoPtr css, ThotBool isHTML)
2991: {
2992: PresentationValue best;
2993:
1.184 vatton 2994: best.typed_data.unit = UNIT_INVALID;
1.170 cheyroul 2995: best.typed_data.real = FALSE;
2996: cssRule = ParseClampedUnit (cssRule, &best);
2997: if (DoApply)
2998: {
2999: if (tsch)
3000: cssRule = CheckImportantRule (cssRule, context);
3001: /* install the new presentation. */
3002: TtaSetStylePresentation (PRFillOpacity, element,
3003: tsch, context, best);
3004: }
3005: return (cssRule);
3006: }
1.1 cvs 3007: /*----------------------------------------------------------------------
1.59 cvs 3008: ParseCSSBackgroundImageCallback: Callback called asynchronously by
3009: FetchImage when a background image has been fetched.
1.1 cvs 3010: ----------------------------------------------------------------------*/
1.82 cvs 3011: void ParseCSSBackgroundImageCallback (Document doc, Element element,
3012: char *file, void *extra)
1.1 cvs 3013: {
1.82 cvs 3014: DisplayMode dispMode;
3015: BackgroundImageCallbackPtr callblock;
3016: Element el;
3017: PSchema tsch;
1.185 vatton 3018: CSSInfoPtr css;
1.82 cvs 3019: PresentationContext context;
3020: PresentationValue image;
3021: PresentationValue value;
1.1 cvs 3022:
1.82 cvs 3023: callblock = (BackgroundImageCallbackPtr) extra;
1.34 cvs 3024: if (callblock == NULL)
3025: return;
1.1 cvs 3026:
1.188 cheyroul 3027: css = NULL;
1.34 cvs 3028: el = callblock->el;
3029: tsch = callblock->tsch;
3030: context = &callblock->context.specific;
1.185 vatton 3031: if (doc)
3032: {
3033: /* avoid too many redisplay */
3034: dispMode = TtaGetDisplayMode (doc);
3035: if (dispMode == DisplayImmediately)
3036: TtaSetDisplayMode (doc, DeferredDisplay);
3037: }
3038: else
3039: {
3040: /* check if the CSS still exists */
3041: css = CSSList;
3042: while (css && css != callblock->css)
3043: css = css->NextCSS;
3044: if (css == NULL)
3045: tsch = NULL;
3046: }
1.34 cvs 3047:
1.185 vatton 3048: if (el || tsch)
3049: {
3050: /* Ok the image was fetched, finish the background-image handling */
1.193 vatton 3051: image.typed_data.unit = UNIT_REL;
3052: image.typed_data.real = FALSE;
1.185 vatton 3053: image.pointer = file;
3054: TtaSetStylePresentation (PRBackgroundPicture, el, tsch, context, image);
3055:
3056: /* enforce the showbox */
3057: value.typed_data.value = 1;
3058: value.typed_data.unit = UNIT_REL;
3059: value.typed_data.real = FALSE;
1.193 vatton 3060: TtaSetStylePresentation (PRShowBox, el, tsch, context, value);
1.185 vatton 3061: }
1.34 cvs 3062:
3063: TtaFreeMemory (callblock);
3064: /* restore the display mode */
1.185 vatton 3065: if (doc)
3066: {
3067: if (dispMode == DisplayImmediately)
3068: TtaSetDisplayMode (doc, dispMode);
3069: }
3070: else if (css)
3071: {
3072: for (doc = 1; doc < DocumentTableLength; doc++)
3073: if (css->documents[doc] && css->enabled[doc] &&
3074: /* don't manage a document used by make book */
3075: (DocumentMeta[doc] == NULL ||
3076: DocumentMeta[doc]->method != CE_MAKEBOOK))
3077: {
3078: /* Change the Display Mode to take into account the new presentation */
3079: dispMode = TtaGetDisplayMode (doc);
3080: if (dispMode == DisplayImmediately)
1.194 ! vatton 3081: {
! 3082: TtaSetDisplayMode (doc, NoComputedDisplay);
! 3083: /* Restore the display mode */
! 3084: TtaSetDisplayMode (doc, dispMode);
! 3085: }
1.185 vatton 3086: }
3087: }
1.1 cvs 3088: }
3089:
3090: /*----------------------------------------------------------------------
3091: GetCSSBackgroundURL searches a CSS BackgroundImage url within
3092: the styleString.
3093: Returns NULL or a new allocated url string.
3094: ----------------------------------------------------------------------*/
1.79 cvs 3095: char *GetCSSBackgroundURL (char *styleString)
1.1 cvs 3096: {
1.79 cvs 3097: char *b, *e, *ptr;
3098: int len;
1.1 cvs 3099:
3100: ptr = NULL;
1.82 cvs 3101: b = strstr (styleString, "url");
1.1 cvs 3102: if (b != NULL)
3103: {
3104: b += 3;
1.82 cvs 3105: b = SkipBlanksAndComments (b);
3106: if (*b == '(')
1.1 cvs 3107: {
3108: b++;
1.82 cvs 3109: b = SkipBlanksAndComments (b);
1.161 quint 3110: /*** Escaped quotes are not handled. See function SkipQuotedString */
1.82 cvs 3111: if (*b == '"')
1.1 cvs 3112: {
3113: b++;
3114: /* search the url end */
3115: e = b;
1.82 cvs 3116: while (*e != EOS && *e != '"')
1.1 cvs 3117: e++;
3118: }
1.161 quint 3119: else if (*b == '\'')
3120: {
3121: b++;
3122: /* search the url end */
3123: e = b;
3124: while (*e != EOS && *e != '\'')
3125: e++;
3126: }
1.1 cvs 3127: else
3128: {
3129: /* search the url end */
3130: e = b;
1.82 cvs 3131: while (*e != EOS && *e != ')')
1.1 cvs 3132: e++;
3133: }
1.82 cvs 3134: if (*e != EOS)
1.1 cvs 3135: {
3136: len = (int)(e - b);
1.82 cvs 3137: ptr = (char*) TtaGetMemory (len+1);
3138: strncpy (ptr, b, len);
3139: ptr[len] = EOS;
1.1 cvs 3140: }
3141: }
3142: }
3143: return (ptr);
3144: }
3145:
3146:
3147: /*----------------------------------------------------------------------
1.59 cvs 3148: ParseCSSBackgroundImage: parse a CSS BackgroundImage attribute string.
1.1 cvs 3149: ----------------------------------------------------------------------*/
1.79 cvs 3150: static char *ParseCSSBackgroundImage (Element element, PSchema tsch,
3151: PresentationContext context,
3152: char *cssRule, CSSInfoPtr css,
3153: ThotBool isHTML)
1.1 cvs 3154: {
1.149 vatton 3155: GenericContext ctxt = (GenericContext) context;
1.49 cvs 3156: Element el;
1.1 cvs 3157: BackgroundImageCallbackPtr callblock;
1.49 cvs 3158: PresentationValue image, value;
1.79 cvs 3159: char *url;
1.82 cvs 3160: char *bg_image;
1.79 cvs 3161: char saved;
3162: char *base;
3163: char tempname[MAX_LENGTH];
3164: char imgname[MAX_LENGTH];
1.148 vatton 3165:
1.163 quint 3166: if (element)
1.148 vatton 3167: el = element;
1.163 quint 3168: else
3169: /* default element for FetchImage */
3170: el = TtaGetMainRoot (context->doc);
3171:
1.1 cvs 3172: url = NULL;
1.82 cvs 3173: cssRule = SkipBlanksAndComments (cssRule);
1.161 quint 3174: if (!strncasecmp (cssRule, "none", 4))
3175: {
3176: image.pointer = NULL;
3177: TtaSetStylePresentation (PRBackgroundPicture, element, tsch, context,
3178: image);
3179: }
3180: else if (!strncasecmp (cssRule, "url", 3))
1.1 cvs 3181: {
3182: cssRule += 3;
1.82 cvs 3183: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 3184: if (*cssRule == '(')
3185: {
3186: cssRule++;
1.82 cvs 3187: cssRule = SkipBlanksAndComments (cssRule);
1.161 quint 3188: /*** Escaped quotes are not handled. See function SkipQuotedString */
1.1 cvs 3189: if (*cssRule == '"')
3190: {
3191: cssRule++;
3192: base = cssRule;
1.82 cvs 3193: while (*cssRule != EOS && *cssRule != '"')
1.1 cvs 3194: cssRule++;
3195: }
1.161 quint 3196: else if (*cssRule == '\'')
3197: {
3198: cssRule++;
3199: base = cssRule;
3200: while (*cssRule != EOS && *cssRule != '\'')
3201: cssRule++;
3202: }
1.1 cvs 3203: else
3204: {
3205: base = cssRule;
3206: while (*cssRule != EOS && *cssRule != ')')
3207: cssRule++;
3208: }
3209: saved = *cssRule;
1.82 cvs 3210: *cssRule = EOS;
3211: url = TtaStrdup (base);
1.1 cvs 3212: *cssRule = saved;
1.161 quint 3213: if (saved == '"' || saved == '\'')
3214: /* we need to skip the quote character and possinble spaces */
3215: {
3216: cssRule++;
3217: cssRule = SkipBlanksAndComments (cssRule);
3218: }
1.1 cvs 3219: }
3220: cssRule++;
3221:
3222: if (context->destroy)
3223: {
3224: /* remove the background image PRule */
3225: image.pointer = NULL;
3226: TtaSetStylePresentation (PRBackgroundPicture, element, tsch, context, image);
3227: if (TtaGetStylePresentation (PRFillPattern, element, tsch, context, &value) < 0)
3228: {
3229: /* there is no FillPattern rule -> remove ShowBox rule */
3230: value.typed_data.value = 1;
1.184 vatton 3231: value.typed_data.unit = UNIT_REL;
1.1 cvs 3232: value.typed_data.real = FALSE;
3233: TtaSetStylePresentation (PRShowBox, element, tsch, context, value);
3234: }
3235: }
3236: else if (url)
3237: {
1.30 cvs 3238: bg_image = TtaGetEnvString ("ENABLE_BG_IMAGES");
1.82 cvs 3239: if (bg_image == NULL || !strcasecmp (bg_image, "yes"))
1.161 quint 3240: /* background images are enabled */
1.1 cvs 3241: {
1.185 vatton 3242: callblock = (BackgroundImageCallbackPtr) TtaGetMemory (sizeof (BackgroundImageCallbackBlock));
1.191 vatton 3243: if (callblock)
1.1 cvs 3244: {
3245: callblock->el = element;
3246: callblock->tsch = tsch;
1.185 vatton 3247: callblock->css = css;
1.1 cvs 3248: if (element == NULL)
1.149 vatton 3249: memcpy (&callblock->context.generic, ctxt,
3250: sizeof (GenericContextBlock));
1.18 cvs 3251: else
1.149 vatton 3252: memcpy (&callblock->context.specific, context,
3253: sizeof(PresentationContextBlock));
1.18 cvs 3254:
3255: /* check if the image url is related to an external CSS */
1.182 vatton 3256: if (css)
1.18 cvs 3257: {
1.189 vatton 3258: if (css->url)
3259: /* the image concerns a CSS file */
3260: NormalizeURL (url, 0, tempname, imgname, css->url);
3261: else
3262: /* the image concerns a style element */
3263: NormalizeURL (url, context->doc, tempname, imgname, NULL);
1.18 cvs 3264: /* fetch and display background image of element */
1.181 vatton 3265: FetchImage (0, el, tempname, AMAYA_LOAD_IMAGE,
1.161 quint 3266: ParseCSSBackgroundImageCallback, callblock);
1.18 cvs 3267: }
3268: else
1.182 vatton 3269: FetchImage (context->doc, el, url, AMAYA_LOAD_IMAGE,
1.161 quint 3270: ParseCSSBackgroundImageCallback, callblock);
1.18 cvs 3271: }
3272: }
3273:
3274: if (url)
3275: TtaFreeMemory (url);
3276: }
3277: }
3278: return (cssRule);
3279: }
3280:
3281: /*----------------------------------------------------------------------
1.59 cvs 3282: ParseCSSBackgroundRepeat: parse a CSS BackgroundRepeat attribute string.
1.18 cvs 3283: ----------------------------------------------------------------------*/
1.79 cvs 3284: static char *ParseCSSBackgroundRepeat (Element element, PSchema tsch,
1.97 vatton 3285: PresentationContext context,
3286: char *cssRule, CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 3287: {
3288: PresentationValue repeat;
3289:
1.184 vatton 3290: repeat.typed_data.value = REALSIZE;
1.191 vatton 3291: repeat.typed_data.unit = UNIT_BOX;
1.18 cvs 3292: repeat.typed_data.real = FALSE;
1.82 cvs 3293: cssRule = SkipBlanksAndComments (cssRule);
3294: if (!strncasecmp (cssRule, "no-repeat", 9))
1.184 vatton 3295: repeat.typed_data.value = REALSIZE;
1.82 cvs 3296: else if (!strncasecmp (cssRule, "repeat-y", 8))
1.184 vatton 3297: repeat.typed_data.value = VREPEAT;
1.82 cvs 3298: else if (!strncasecmp (cssRule, "repeat-x", 8))
1.184 vatton 3299: repeat.typed_data.value = HREPEAT;
1.82 cvs 3300: else if (!strncasecmp (cssRule, "repeat", 6))
1.184 vatton 3301: repeat.typed_data.value = REPEAT;
1.18 cvs 3302: else
3303: return (cssRule);
3304:
3305: /* install the new presentation */
1.116 vatton 3306: if (DoApply)
1.117 vatton 3307: {
3308: /* check if it's an important rule */
3309: if (tsch)
3310: cssRule = CheckImportantRule (cssRule, context);
3311: TtaSetStylePresentation (PRPictureMode, element, tsch, context, repeat);
3312: }
1.18 cvs 3313: cssRule = SkipWord (cssRule);
1.163 quint 3314: return (cssRule);
1.18 cvs 3315: }
3316:
3317: /*----------------------------------------------------------------------
1.59 cvs 3318: ParseCSSBackgroundAttachment: parse a CSS BackgroundAttachment
1.18 cvs 3319: attribute string.
3320: ----------------------------------------------------------------------*/
1.79 cvs 3321: static char *ParseCSSBackgroundAttachment (Element element, PSchema tsch,
3322: PresentationContext context,
3323: char *cssRule, CSSInfoPtr css,
3324: ThotBool isHTML)
1.18 cvs 3325: {
1.163 quint 3326: cssRule = SkipBlanksAndComments (cssRule);
3327: if (!strncasecmp (cssRule, "scroll", 6))
3328: cssRule = SkipWord (cssRule);
3329: else if (!strncasecmp (cssRule, "fixed", 5))
3330: cssRule = SkipWord (cssRule);
3331: return (cssRule);
1.1 cvs 3332: }
3333:
3334: /*----------------------------------------------------------------------
1.59 cvs 3335: ParseCSSBackgroundPosition: parse a CSS BackgroundPosition
1.1 cvs 3336: attribute string.
3337: ----------------------------------------------------------------------*/
1.79 cvs 3338: static char *ParseCSSBackgroundPosition (Element element, PSchema tsch,
3339: PresentationContext context,
3340: char *cssRule, CSSInfoPtr css,
3341: ThotBool isHTML)
1.1 cvs 3342: {
1.18 cvs 3343: PresentationValue repeat;
3344: ThotBool ok;
1.1 cvs 3345:
1.163 quint 3346: cssRule = SkipBlanksAndComments (cssRule);
3347: ok = TRUE;
3348: if (!strncasecmp (cssRule, "left", 4))
3349: cssRule = SkipWord (cssRule);
3350: else if (!strncasecmp (cssRule, "right", 5))
3351: cssRule = SkipWord (cssRule);
3352: else if (!strncasecmp (cssRule, "center", 6))
3353: cssRule = SkipWord (cssRule);
3354: else if (!strncasecmp (cssRule, "top", 3))
3355: cssRule = SkipWord (cssRule);
3356: else if (!strncasecmp (cssRule, "bottom", 6))
3357: cssRule = SkipWord (cssRule);
3358: else if (isdigit (*cssRule) || *cssRule == '.')
1.191 vatton 3359: {
3360: cssRule = SkipWord (cssRule);
3361: }
1.163 quint 3362: else
3363: ok = FALSE;
3364:
3365: if (ok && DoApply)
1.148 vatton 3366: {
1.163 quint 3367: /* force realsize for the background image */
1.184 vatton 3368: repeat.typed_data.value = REALSIZE;
3369: repeat.typed_data.unit = UNIT_REL;
1.163 quint 3370: repeat.typed_data.real = FALSE;
3371: /* check if it's an important rule */
3372: if (tsch)
3373: cssRule = CheckImportantRule (cssRule, context);
1.191 vatton 3374: /*TtaSetStylePresentation (PRPictureMode, element, tsch, context, repeat);*/
1.148 vatton 3375: }
1.163 quint 3376: return (cssRule);
1.18 cvs 3377: }
3378:
3379: /*----------------------------------------------------------------------
1.59 cvs 3380: ParseCSSBackground: parse a CSS background attribute
1.18 cvs 3381: ----------------------------------------------------------------------*/
1.79 cvs 3382: static char *ParseCSSBackground (Element element, PSchema tsch,
3383: PresentationContext context, char *cssRule,
3384: CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 3385: {
1.79 cvs 3386: char *ptr;
1.93 vatton 3387: int skippedNL;
1.18 cvs 3388:
1.82 cvs 3389: cssRule = SkipBlanksAndComments (cssRule);
3390: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
1.18 cvs 3391: {
1.71 cvs 3392: /* perhaps a Background Image */
1.82 cvs 3393: if (!strncasecmp (cssRule, "url", 3))
1.63 cvs 3394: cssRule = ParseCSSBackgroundImage (element, tsch, context, cssRule,
3395: css, isHTML);
1.18 cvs 3396: /* perhaps a Background Attachment */
1.82 cvs 3397: else if (!strncasecmp (cssRule, "scroll", 6) ||
3398: !strncasecmp (cssRule, "fixed", 5))
1.63 cvs 3399: cssRule = ParseCSSBackgroundAttachment (element, tsch, context,
3400: cssRule, css, isHTML);
1.18 cvs 3401: /* perhaps a Background Repeat */
1.82 cvs 3402: else if (!strncasecmp (cssRule, "no-repeat", 9) ||
3403: !strncasecmp (cssRule, "repeat-y", 8) ||
3404: !strncasecmp (cssRule, "repeat-x", 8) ||
3405: !strncasecmp (cssRule, "repeat", 6))
3406: cssRule = ParseCSSBackgroundRepeat (element, tsch, context,
3407: cssRule, css, isHTML);
1.18 cvs 3408: /* perhaps a Background Position */
1.82 cvs 3409: else if (!strncasecmp (cssRule, "left", 4) ||
3410: !strncasecmp (cssRule, "right", 5) ||
3411: !strncasecmp (cssRule, "center", 6) ||
3412: !strncasecmp (cssRule, "top", 3) ||
3413: !strncasecmp (cssRule, "bottom", 6) ||
1.110 vatton 3414: isdigit (*cssRule) || *cssRule == '.')
1.63 cvs 3415: cssRule = ParseCSSBackgroundPosition (element, tsch, context,
3416: cssRule, css, isHTML);
1.18 cvs 3417: /* perhaps a Background Color */
3418: else
3419: {
1.93 vatton 3420: skippedNL = NewLineSkipped;
1.18 cvs 3421: /* check if the rule has been found */
3422: ptr = cssRule;
1.82 cvs 3423: cssRule = ParseCSSBackgroundColor (element, tsch, context,
3424: cssRule, css, isHTML);
1.43 cvs 3425: if (ptr == cssRule)
1.93 vatton 3426: {
3427: NewLineSkipped = skippedNL;
3428: /* rule not found */
3429: cssRule = SkipProperty (cssRule);
3430: }
1.18 cvs 3431: }
1.82 cvs 3432: cssRule = SkipBlanksAndComments (cssRule);
1.18 cvs 3433: }
3434: return (cssRule);
3435: }
3436:
1.59 cvs 3437: /*----------------------------------------------------------------------
1.60 cvs 3438: ParseCSSPageBreakBefore: parse a CSS page-break-before attribute
1.59 cvs 3439: ----------------------------------------------------------------------*/
1.79 cvs 3440: static char *ParseCSSPageBreakBefore (Element element, PSchema tsch,
3441: PresentationContext context, char *cssRule,
3442: CSSInfoPtr css, ThotBool isHTML)
1.59 cvs 3443: {
3444: PresentationValue page;
3445:
1.184 vatton 3446: page.typed_data.unit = UNIT_INVALID;
1.59 cvs 3447: page.typed_data.real = FALSE;
1.82 cvs 3448: cssRule = SkipBlanksAndComments (cssRule);
3449: if (!strncasecmp (cssRule, "auto", 4))
1.184 vatton 3450: page.typed_data.value = PageAuto;
1.82 cvs 3451: else if (!strncasecmp (cssRule, "always", 6))
1.59 cvs 3452: {
1.184 vatton 3453: page.typed_data.unit = UNIT_REL;
3454: page.typed_data.value = PageAlways;
1.59 cvs 3455: }
1.82 cvs 3456: else if (!strncasecmp (cssRule, "avoid", 5))
1.59 cvs 3457: {
1.184 vatton 3458: page.typed_data.unit = UNIT_REL;
3459: page.typed_data.value = PageAvoid;
1.59 cvs 3460: }
1.82 cvs 3461: else if (!strncasecmp (cssRule, "left", 4))
1.59 cvs 3462: {
1.184 vatton 3463: page.typed_data.unit = UNIT_REL;
3464: page.typed_data.value = PageLeft;
1.59 cvs 3465: }
1.82 cvs 3466: else if (!strncasecmp (cssRule, "right", 5))
1.59 cvs 3467: {
1.184 vatton 3468: page.typed_data.unit = UNIT_REL;
3469: page.typed_data.value = PageRight;
1.59 cvs 3470: }
1.82 cvs 3471: else if (!strncasecmp (cssRule, "inherit", 7))
1.59 cvs 3472: {
1.184 vatton 3473: /*page.typed_data.unit = UNIT_REL;*/
3474: page.typed_data.value = PageInherit;
1.59 cvs 3475: }
3476: cssRule = SkipWord (cssRule);
3477: /* install the new presentation */
1.184 vatton 3478: if (page.typed_data.unit == UNIT_REL &&
3479: page.typed_data.value == PageAlways && DoApply)
1.117 vatton 3480: {
3481: /* check if it's an important rule */
3482: if (tsch)
3483: cssRule = CheckImportantRule (cssRule, context);
3484: TtaSetStylePresentation (PRPageBefore, element, tsch, context, page);
3485: }
1.59 cvs 3486: return (cssRule);
3487: }
3488:
3489: /*----------------------------------------------------------------------
1.60 cvs 3490: ParseCSSPageBreakAfter: parse a CSS page-break-after attribute
1.59 cvs 3491: ----------------------------------------------------------------------*/
1.79 cvs 3492: static char *ParseCSSPageBreakAfter (Element element, PSchema tsch,
3493: PresentationContext context,
3494: char *cssRule, CSSInfoPtr css,
3495: ThotBool isHTML)
1.59 cvs 3496: {
3497: PresentationValue page;
3498:
1.184 vatton 3499: page.typed_data.unit = UNIT_INVALID;
1.59 cvs 3500: page.typed_data.real = FALSE;
1.82 cvs 3501: cssRule = SkipBlanksAndComments (cssRule);
3502: if (!strncasecmp (cssRule, "auto", 4))
1.184 vatton 3503: page.typed_data.value = PageAuto;
1.82 cvs 3504: else if (!strncasecmp (cssRule, "always", 6))
1.59 cvs 3505: {
1.184 vatton 3506: page.typed_data.unit = UNIT_REL;
3507: page.typed_data.value = PageAlways;
1.59 cvs 3508: }
1.82 cvs 3509: else if (!strncasecmp (cssRule, "avoid", 5))
1.59 cvs 3510: {
1.184 vatton 3511: page.typed_data.unit = UNIT_REL;
3512: page.typed_data.value = PageAvoid;
1.59 cvs 3513: }
1.82 cvs 3514: else if (!strncasecmp (cssRule, "left", 4))
1.59 cvs 3515: {
1.184 vatton 3516: page.typed_data.unit = UNIT_REL;
3517: page.typed_data.value = PageLeft;
1.59 cvs 3518: }
1.82 cvs 3519: else if (!strncasecmp (cssRule, "right", 5))
1.59 cvs 3520: {
1.184 vatton 3521: page.typed_data.unit = UNIT_REL;
3522: page.typed_data.value = PageRight;
1.59 cvs 3523: }
1.82 cvs 3524: else if (!strncasecmp (cssRule, "inherit", 7))
1.59 cvs 3525: {
1.184 vatton 3526: /*page.typed_data.unit = UNIT_REL;*/
3527: page.typed_data.value = PageInherit;
1.59 cvs 3528: }
3529: cssRule = SkipWord (cssRule);
3530: /* install the new presentation */
1.184 vatton 3531: /*if (page.typed_data.unit == UNIT_REL && DoApply)
1.117 vatton 3532: {
3533: if (tsch)
3534: cssRule = CheckImportantRule (cssRule, context);
3535: TtaSetStylePresentation (PRPageAfter, element, tsch, context, page);
3536: }*/
1.59 cvs 3537: return (cssRule);
3538: }
3539:
3540: /*----------------------------------------------------------------------
1.60 cvs 3541: ParseCSSPageBreakInside: parse a CSS page-break-inside attribute
1.59 cvs 3542: ----------------------------------------------------------------------*/
1.79 cvs 3543: static char *ParseCSSPageBreakInside (Element element, PSchema tsch,
3544: PresentationContext context,
3545: char *cssRule, CSSInfoPtr css,
3546: ThotBool isHTML)
1.59 cvs 3547: {
3548: PresentationValue page;
3549:
1.184 vatton 3550: page.typed_data.unit = UNIT_INVALID;
1.59 cvs 3551: page.typed_data.real = FALSE;
1.82 cvs 3552: cssRule = SkipBlanksAndComments (cssRule);
3553: if (!strncasecmp (cssRule, "auto", 4))
1.59 cvs 3554: {
1.184 vatton 3555: /*page.typed_data.unit = UNIT_REL;*/
3556: page.typed_data.value = PageAuto;
1.59 cvs 3557: }
1.82 cvs 3558: else if (!strncasecmp (cssRule, "avoid", 5))
1.59 cvs 3559: {
1.184 vatton 3560: page.typed_data.unit = UNIT_REL;
3561: page.typed_data.value = PageAvoid;
1.59 cvs 3562: }
1.82 cvs 3563: else if (!strncasecmp (cssRule, "inherit", 7))
1.59 cvs 3564: {
1.184 vatton 3565: /*page.typed_data.unit = UNIT_REL;*/
3566: page.typed_data.value = PageInherit;
1.59 cvs 3567: }
3568: cssRule = SkipWord (cssRule);
3569: /* install the new presentation */
1.184 vatton 3570: /*if (page.typed_data.unit == UNIT_REL &&
3571: page.typed_data.value == PageAvoid && DoApply)
1.117 vatton 3572: {
3573: if (tsch)
3574: cssRule = CheckImportantRule (cssRule, context);
3575: TtaSetStylePresentation (PRPageInside, element, tsch, context, page);
3576: }*/
1.59 cvs 3577: return (cssRule);
3578: }
1.18 cvs 3579:
3580:
1.60 cvs 3581: /*----------------------------------------------------------------------
1.117 vatton 3582: ParseSVGStrokeWidth: parse a SVG stroke-width property value.
1.60 cvs 3583: ----------------------------------------------------------------------*/
1.79 cvs 3584: static char *ParseSVGStrokeWidth (Element element, PSchema tsch,
3585: PresentationContext context, char *cssRule,
3586: CSSInfoPtr css, ThotBool isHTML)
1.60 cvs 3587: {
3588: PresentationValue width;
3589:
1.82 cvs 3590: cssRule = SkipBlanksAndComments (cssRule);
1.60 cvs 3591: width.typed_data.value = 0;
1.184 vatton 3592: width.typed_data.unit = UNIT_INVALID;
1.60 cvs 3593: width.typed_data.real = FALSE;
1.110 vatton 3594: if (isdigit (*cssRule) || *cssRule == '.')
1.166 vatton 3595: {
1.60 cvs 3596: cssRule = ParseCSSUnit (cssRule, &width);
1.184 vatton 3597: if (width.typed_data.unit == UNIT_BOX)
3598: width.typed_data.unit = UNIT_PX;
1.166 vatton 3599: }
1.184 vatton 3600: if (width.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 3601: {
3602: /* check if it's an important rule */
3603: if (tsch)
3604: cssRule = CheckImportantRule (cssRule, context);
3605: TtaSetStylePresentation (PRLineWeight, element, tsch, context, width);
3606: width.typed_data.value = 1;
1.184 vatton 3607: width.typed_data.unit = UNIT_REL;
1.117 vatton 3608: }
1.60 cvs 3609: return (cssRule);
3610: }
3611:
1.18 cvs 3612: /************************************************************************
3613: * *
3614: * FUNCTIONS STYLE DECLARATIONS *
3615: * *
3616: ************************************************************************/
3617: /*
1.59 cvs 3618: * NOTE: Long attribute name MUST be placed before shortened ones !
1.18 cvs 3619: * e.g. "FONT-SIZE" must be placed before "FONT"
3620: */
3621: static CSSProperty CSSProperties[] =
3622: {
1.82 cvs 3623: {"font-family", ParseCSSFontFamily},
3624: {"font-style", ParseCSSFontStyle},
3625: {"font-variant", ParseCSSFontVariant},
3626: {"font-weight", ParseCSSFontWeight},
3627: {"font-size", ParseCSSFontSize},
3628: {"font", ParseCSSFont},
3629:
3630: {"color", ParseCSSForeground},
3631: {"background-color", ParseCSSBackgroundColor},
3632: {"background-image", ParseCSSBackgroundImage},
3633: {"background-repeat", ParseCSSBackgroundRepeat},
3634: {"background-attachment", ParseCSSBackgroundAttachment},
3635: {"background-position", ParseCSSBackgroundPosition},
3636: {"background", ParseCSSBackground},
3637:
3638: {"word-spacing", ParseCSSWordSpacing},
3639: {"letter-spacing", ParseCSSLetterSpacing},
3640: {"text-decoration", ParseCSSTextDecoration},
3641: {"vertical-align", ParseCSSVerticalAlign},
3642: {"text-transform", ParseCSSTextTransform},
3643: {"text-align", ParseCSSTextAlign},
3644: {"text-indent", ParseCSSTextIndent},
1.162 quint 3645: {"line-height", ParseCSSLineHeight},
1.82 cvs 3646:
1.112 quint 3647: {"direction", ParseCSSDirection},
1.113 quint 3648: {"unicode-bidi", ParseCSSUnicodeBidi},
1.112 quint 3649:
1.82 cvs 3650: {"margin-top", ParseCSSMarginTop},
3651: {"margin-right", ParseCSSMarginRight},
3652: {"margin-bottom", ParseCSSMarginBottom},
3653: {"margin-left", ParseCSSMarginLeft},
3654: {"margin", ParseCSSMargin},
3655:
3656: {"padding-top", ParseCSSPaddingTop},
3657: {"padding-right", ParseCSSPaddingRight},
3658: {"padding-bottom", ParseCSSPaddingBottom},
3659: {"padding-left", ParseCSSPaddingLeft},
3660: {"padding", ParseCSSPadding},
3661:
3662: {"border-top-width", ParseCSSBorderTopWidth},
3663: {"border-right-width", ParseCSSBorderRightWidth},
3664: {"border-bottom-width", ParseCSSBorderBottomWidth},
3665: {"border-left-width", ParseCSSBorderLeftWidth},
3666: {"border-width", ParseCSSBorderWidth},
3667: {"border-top-color", ParseCSSBorderColorTop},
3668: {"border-right-color", ParseCSSBorderColorRight},
3669: {"border-bottom-color", ParseCSSBorderColorBottom},
3670: {"border-left-color", ParseCSSBorderColorLeft},
3671: {"border-color", ParseCSSBorderColor},
3672: {"border-top-style", ParseCSSBorderStyleTop},
3673: {"border-right-style", ParseCSSBorderStyleRight},
3674: {"border-bottom-style", ParseCSSBorderStyleBottom},
3675: {"border-left-style", ParseCSSBorderStyleLeft},
3676: {"border-style", ParseCSSBorderStyle},
3677: {"border-top", ParseCSSBorderTop},
3678: {"border-right", ParseCSSBorderRight},
3679: {"border-bottom", ParseCSSBorderBottom},
3680: {"border-left", ParseCSSBorderLeft},
3681: {"border", ParseCSSBorder},
3682:
3683: {"width", ParseCSSWidth},
3684: {"height", ParseCSSHeight},
3685: {"float", ParseCSSFloat},
3686: {"clear", ParseCSSClear},
1.184 vatton 3687: {"content", ParseCSSContent},
1.82 cvs 3688:
3689: {"display", ParseCSSDisplay},
3690: {"white-space", ParseCSSWhiteSpace},
3691:
3692: {"list-style-type", ParseCSSListStyleType},
3693: {"list-style-image", ParseCSSListStyleImage},
3694: {"list-style-position", ParseCSSListStylePosition},
3695: {"list-style", ParseCSSListStyle},
3696:
3697: {"page-break-before", ParseCSSPageBreakBefore},
3698: {"page-break-after", ParseCSSPageBreakAfter},
3699: {"page-break-inside", ParseCSSPageBreakInside},
1.60 cvs 3700:
3701: /* SVG extensions */
1.170 cheyroul 3702: {"stroke-opacity", ParseSVGStrokeOpacity},
1.82 cvs 3703: {"stroke-width", ParseSVGStrokeWidth},
3704: {"stroke", ParseSVGStroke},
1.170 cheyroul 3705:
3706: {"fill-opacity", ParseSVGFillOpacity},
1.155 cheyroul 3707: {"fill", ParseSVGFill},
1.170 cheyroul 3708:
1.155 cheyroul 3709: {"opacity", ParseSVGOpacity}
1.18 cvs 3710: };
1.155 cheyroul 3711:
1.18 cvs 3712: #define NB_CSSSTYLEATTRIBUTE (sizeof(CSSProperties) / sizeof(CSSProperty))
3713:
3714: /*----------------------------------------------------------------------
1.59 cvs 3715: ParseCSSRule: parse a CSS Style string
1.18 cvs 3716: we expect the input string describing the style to be of the
1.59 cvs 3717: form: PRORPERTY: DESCRIPTION [ ; PROPERTY: DESCRIPTION ] *
1.18 cvs 3718: but tolerate incorrect or incomplete input
3719: ----------------------------------------------------------------------*/
1.79 cvs 3720: static void ParseCSSRule (Element element, PSchema tsch,
3721: PresentationContext context, char *cssRule,
3722: CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 3723: {
1.34 cvs 3724: DisplayMode dispMode;
1.79 cvs 3725: char *p = NULL;
1.18 cvs 3726: int lg;
1.34 cvs 3727: unsigned int i;
1.76 cvs 3728: ThotBool found;
1.18 cvs 3729:
1.34 cvs 3730: /* avoid too many redisplay */
3731: dispMode = TtaGetDisplayMode (context->doc);
3732: if (dispMode == DisplayImmediately)
3733: TtaSetDisplayMode (context->doc, DeferredDisplay);
3734:
1.82 cvs 3735: while (*cssRule != EOS)
1.18 cvs 3736: {
1.82 cvs 3737: cssRule = SkipBlanksAndComments (cssRule);
1.153 vatton 3738: if (*cssRule < 0x41 || *cssRule > 0x7A ||
1.133 vatton 3739: (*cssRule > 0x5A && *cssRule < 0x60))
1.153 vatton 3740: cssRule++;
1.194 ! vatton 3741: else if (*cssRule != EOS)
1.89 cvs 3742: {
1.153 vatton 3743: found = FALSE;
3744: /* look for the type of property */
3745: for (i = 0; i < NB_CSSSTYLEATTRIBUTE && !found; i++)
1.18 cvs 3746: {
1.153 vatton 3747: lg = strlen (CSSProperties[i].name);
3748: if (!strncasecmp (cssRule, CSSProperties[i].name, lg))
3749: {
3750: p = cssRule + lg;
3751: found = TRUE;
3752: i--;
3753: }
1.18 cvs 3754: }
1.153 vatton 3755: if (i == NB_CSSSTYLEATTRIBUTE)
3756: cssRule = SkipProperty (cssRule);
3757: else
1.18 cvs 3758: {
1.153 vatton 3759: /* update index and skip the ":" indicator if present */
1.86 cvs 3760: p = SkipBlanksAndComments (p);
1.153 vatton 3761: if (*p == ':')
1.61 cvs 3762: {
1.153 vatton 3763: p++;
3764: p = SkipBlanksAndComments (p);
3765: /* try to parse the value associated with this property */
3766: if (CSSProperties[i].parsing_function != NULL)
3767: {
3768: p = CSSProperties[i].parsing_function (element, tsch, context,
3769: p, css, isHTML);
3770: /* update index and skip the ";" separator if present */
3771: cssRule = p;
3772: }
1.61 cvs 3773: }
1.153 vatton 3774: else
3775: cssRule = SkipProperty (cssRule);
1.18 cvs 3776: }
3777: }
3778: /* next property */
1.82 cvs 3779: cssRule = SkipBlanksAndComments (cssRule);
1.89 cvs 3780: if (*cssRule == '}')
3781: {
3782: cssRule++;
1.168 vatton 3783: CSSPrintError ("Invalid character", "}");
1.89 cvs 3784: cssRule = SkipBlanksAndComments (cssRule);
3785: }
1.155 cheyroul 3786: if (*cssRule == ',' ||
3787: *cssRule == ';')
1.18 cvs 3788: {
3789: cssRule++;
1.82 cvs 3790: cssRule = SkipBlanksAndComments (cssRule);
1.18 cvs 3791: }
3792: }
1.34 cvs 3793:
3794: /* restore the display mode */
3795: if (dispMode == DisplayImmediately)
3796: TtaSetDisplayMode (context->doc, dispMode);
1.18 cvs 3797: }
1.1 cvs 3798:
1.111 cvs 3799: /*----------------------------------------------------------------------
3800: AddBorderStyleValue
3801: -----------------------------------------------------------------------*/
3802: static void AddBorderStyleValue (char *buffer, int value)
3803: {
3804: switch (value)
3805: {
1.184 vatton 3806: case BorderStyleNone:
1.111 cvs 3807: strcat (buffer, "none");
3808: break;
1.184 vatton 3809: case BorderStyleHidden:
1.111 cvs 3810: strcat (buffer, "hidden");
3811: break;
1.184 vatton 3812: case BorderStyleDotted:
1.111 cvs 3813: strcat (buffer, "dotted");
3814: break;
1.184 vatton 3815: case BorderStyleDashed:
1.111 cvs 3816: strcat (buffer, "dashed");
3817: break;
1.184 vatton 3818: case BorderStyleSolid:
1.111 cvs 3819: strcat (buffer, "solid");
3820: break;
1.184 vatton 3821: case BorderStyleDouble:
1.111 cvs 3822: strcat (buffer, "double");
3823: break;
1.184 vatton 3824: case BorderStyleGroove:
1.111 cvs 3825: strcat (buffer, "groove");
3826: break;
1.184 vatton 3827: case BorderStyleRidge:
1.111 cvs 3828: strcat (buffer, "ridge");
3829: break;
1.184 vatton 3830: case BorderStyleInset:
1.111 cvs 3831: strcat (buffer, "inset");
3832: break;
1.184 vatton 3833: case BorderStyleOutset:
1.111 cvs 3834: strcat (buffer, "outset");
3835: break;
3836: }
3837: }
1.1 cvs 3838:
3839: /*----------------------------------------------------------------------
1.59 cvs 3840: PToCss: translate a PresentationSetting to the
1.18 cvs 3841: equivalent CSS string, and add it to the buffer given as the
1.67 cvs 3842: argument. It is used when extracting the CSS string from actual
3843: presentation.
3844: el is the element for which the style rule is generated
1.18 cvs 3845:
3846: All the possible values returned by the presentation drivers are
3847: described in thotlib/include/presentation.h
3848: -----------------------------------------------------------------------*/
1.79 cvs 3849: void PToCss (PresentationSetting settings, char *buffer, int len, Element el)
1.1 cvs 3850: {
1.76 cvs 3851: ElementType elType;
1.18 cvs 3852: float fval = 0;
3853: unsigned short red, green, blue;
3854: int add_unit = 0;
3855: unsigned int unit, i;
3856: ThotBool real = FALSE;
3857:
1.82 cvs 3858: buffer[0] = EOS;
1.18 cvs 3859: if (len < 40)
3860: return;
3861:
3862: unit = settings->value.typed_data.unit;
3863: if (settings->value.typed_data.real)
3864: {
3865: real = TRUE;
3866: fval = (float) settings->value.typed_data.value;
3867: fval /= 1000;
3868: }
1.1 cvs 3869:
1.18 cvs 3870: switch (settings->type)
1.1 cvs 3871: {
1.18 cvs 3872: case PRVisibility:
3873: break;
1.111 cvs 3874: case PRHeight:
3875: if (real)
3876: sprintf (buffer, "height: %g", fval);
3877: else
3878: sprintf (buffer, "height: %d", settings->value.typed_data.value);
3879: add_unit = 1;
3880: break;
3881: case PRWidth:
3882: if (real)
3883: sprintf (buffer, "width: %g", fval);
3884: else
3885: sprintf (buffer, "width: %d", settings->value.typed_data.value);
3886: add_unit = 1;
3887: break;
3888: case PRMarginTop:
3889: if (real)
3890: sprintf (buffer, "margin-top: %g", fval);
3891: else
3892: sprintf (buffer, "margin-top: %d",settings->value.typed_data.value);
3893: add_unit = 1;
3894: break;
3895: case PRMarginBottom:
3896: if (real)
3897: sprintf (buffer, "margin-bottom: %g", fval);
3898: else
3899: sprintf (buffer, "margin-bottom: %d",
3900: settings->value.typed_data.value);
3901: add_unit = 1;
3902: break;
3903: case PRMarginLeft:
3904: if (real)
3905: sprintf (buffer, "margin-left: %g", fval);
3906: else
1.164 quint 3907: sprintf (buffer, "margin-left: %d", settings->value.typed_data.value);
1.111 cvs 3908: add_unit = 1;
3909: break;
3910: case PRMarginRight:
3911: if (real)
3912: sprintf (buffer, "margin-right: %g", fval);
3913: else
1.164 quint 3914: sprintf (buffer, "margin-right: %d", settings->value.typed_data.value);
1.111 cvs 3915: add_unit = 1;
3916: break;
3917: case PRPaddingTop:
3918: if (real)
3919: sprintf (buffer, "padding-top: %g", fval);
3920: else
1.164 quint 3921: sprintf (buffer, "padding-top: %d", settings->value.typed_data.value);
1.111 cvs 3922: add_unit = 1;
3923: break;
3924: case PRPaddingBottom:
3925: if (real)
3926: sprintf (buffer, "padding-bottom: %g", fval);
3927: else
3928: sprintf (buffer, "padding-bottom: %d",
3929: settings->value.typed_data.value);
3930: add_unit = 1;
3931: break;
3932: case PRPaddingLeft:
3933: if (real)
3934: sprintf (buffer, "padding-left: %g", fval);
3935: else
1.164 quint 3936: sprintf (buffer, "padding-left: %d", settings->value.typed_data.value);
1.111 cvs 3937: add_unit = 1;
3938: break;
3939: case PRPaddingRight:
3940: if (real)
3941: sprintf (buffer, "padding-right: %g", fval);
3942: else
3943: sprintf (buffer, "padding-right: %d",
3944: settings->value.typed_data.value);
3945: add_unit = 1;
3946: break;
3947: case PRBorderTopWidth:
3948: if (real)
3949: sprintf (buffer, "border-top-width: %g", fval);
3950: else
3951: sprintf (buffer, "border-top-width: %d",
3952: settings->value.typed_data.value);
3953: add_unit = 1;
3954: break;
3955: case PRBorderBottomWidth:
3956: if (real)
3957: sprintf (buffer, "border-bottom-width: %g", fval);
3958: else
3959: sprintf (buffer, "border-bottom-width: %d",
3960: settings->value.typed_data.value);
3961: add_unit = 1;
3962: break;
3963: case PRBorderLeftWidth:
3964: if (real)
3965: sprintf (buffer, "border-left-width: %g", fval);
3966: else
3967: sprintf (buffer, "border-left-width: %d",
3968: settings->value.typed_data.value);
3969: add_unit = 1;
3970: break;
3971: case PRBorderRightWidth:
3972: if (real)
3973: sprintf (buffer, "border-right-width: %g", fval);
3974: else
3975: sprintf (buffer, "border-right-width: %d",
3976: settings->value.typed_data.value);
3977: add_unit = 1;
3978: break;
3979: case PRBorderTopColor:
3980: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
3981: elType = TtaGetElementType(el);
3982: sprintf (buffer, "border-top-color: #%02X%02X%02X", red, green, blue);
3983: break;
3984: case PRBorderRightColor:
3985: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
3986: elType = TtaGetElementType(el);
3987: sprintf (buffer, "border-right-color: #%02X%02X%02X", red, green, blue);
3988: break;
3989: case PRBorderBottomColor:
3990: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
3991: elType = TtaGetElementType(el);
3992: sprintf (buffer, "border-bottom-color: #%02X%02X%02X", red, green, blue);
1.18 cvs 3993: break;
1.111 cvs 3994: case PRBorderLeftColor:
3995: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
3996: elType = TtaGetElementType(el);
3997: sprintf (buffer, "border-left-color: #%02X%02X%02X", red, green, blue);
1.20 cvs 3998: break;
1.111 cvs 3999: case PRBorderTopStyle:
4000: strcpy (buffer, "border-top-style: ");
4001: AddBorderStyleValue (buffer, settings->value.typed_data.value);
4002: break;
4003: case PRBorderRightStyle:
4004: strcpy (buffer, "border-right-style: ");
4005: AddBorderStyleValue (buffer, settings->value.typed_data.value);
4006: break;
4007: case PRBorderBottomStyle:
4008: strcpy (buffer, "border-bottom-style: ");
4009: AddBorderStyleValue (buffer, settings->value.typed_data.value);
4010: break;
4011: case PRBorderLeftStyle:
4012: strcpy (buffer, "border-left-style: ");
4013: AddBorderStyleValue (buffer, settings->value.typed_data.value);
1.18 cvs 4014: break;
4015: case PRSize:
1.184 vatton 4016: if (unit == UNIT_REL)
1.18 cvs 4017: {
4018: if (real)
4019: {
1.82 cvs 4020: sprintf (buffer, "font-size: %g", fval);
1.18 cvs 4021: add_unit = 1;
4022: }
4023: else
4024: switch (settings->value.typed_data.value)
4025: {
4026: case 1:
1.82 cvs 4027: strcpy (buffer, "font-size: xx-small");
1.18 cvs 4028: break;
4029: case 2:
1.82 cvs 4030: strcpy (buffer, "font-size: x-small");
1.18 cvs 4031: break;
4032: case 3:
1.82 cvs 4033: strcpy (buffer, "font-size: small");
1.18 cvs 4034: break;
4035: case 4:
1.82 cvs 4036: strcpy (buffer, "font-size: medium");
1.18 cvs 4037: break;
4038: case 5:
1.82 cvs 4039: strcpy (buffer, "font-size: large");
1.18 cvs 4040: break;
4041: case 6:
1.82 cvs 4042: strcpy (buffer, "font-size: x-large");
1.18 cvs 4043: break;
4044: case 7:
4045: case 8:
4046: case 9:
4047: case 10:
4048: case 11:
4049: case 12:
1.82 cvs 4050: strcpy (buffer, "font-size: xx-large");
1.18 cvs 4051: break;
4052: }
4053: }
4054: else
4055: {
4056: if (real)
1.82 cvs 4057: sprintf (buffer, "font-size: %g", fval);
1.18 cvs 4058: else
1.82 cvs 4059: sprintf (buffer, "font-size: %d",
1.67 cvs 4060: settings->value.typed_data.value);
1.18 cvs 4061: add_unit = 1;
4062: }
4063: break;
1.111 cvs 4064: case PRStyle:
4065: switch (settings->value.typed_data.value)
4066: {
1.184 vatton 4067: case StyleRoman:
1.111 cvs 4068: strcpy (buffer, "font-style: normal");
4069: break;
1.184 vatton 4070: case StyleItalics:
1.111 cvs 4071: strcpy (buffer, "font-style: italic");
4072: break;
1.184 vatton 4073: case StyleOblique:
1.111 cvs 4074: strcpy (buffer, "font-style: oblique");
4075: break;
4076: }
4077: break;
4078: case PRWeight:
4079: switch (settings->value.typed_data.value)
4080: {
1.184 vatton 4081: case WeightBold:
1.111 cvs 4082: strcpy (buffer, "font-weight: bold");
4083: break;
1.184 vatton 4084: case WeightNormal:
1.111 cvs 4085: strcpy (buffer, "font-weight: normal");
4086: break;
4087: }
4088: break;
4089: case PRFont:
4090: switch (settings->value.typed_data.value)
4091: {
1.184 vatton 4092: case FontHelvetica:
1.111 cvs 4093: strcpy (buffer, "font-family: helvetica");
4094: break;
1.184 vatton 4095: case FontTimes:
1.111 cvs 4096: strcpy (buffer, "font-family: times");
4097: break;
1.184 vatton 4098: case FontCourier:
1.111 cvs 4099: strcpy (buffer, "font-family: courier");
4100: break;
4101: }
4102: break;
1.18 cvs 4103: case PRUnderline:
4104: switch (settings->value.typed_data.value)
4105: {
1.184 vatton 4106: case Underline:
1.82 cvs 4107: strcpy (buffer, "text-decoration: underline");
1.18 cvs 4108: break;
1.184 vatton 4109: case Overline:
1.82 cvs 4110: strcpy (buffer, "text-decoration: overline");
1.18 cvs 4111: break;
1.184 vatton 4112: case CrossOut:
1.82 cvs 4113: strcpy (buffer, "text-decoration: line-through");
1.18 cvs 4114: break;
4115: }
4116: break;
1.111 cvs 4117: case PRThickness:
4118: break;
1.18 cvs 4119: case PRIndent:
4120: if (real)
1.82 cvs 4121: sprintf (buffer, "text-indent: %g", fval);
1.18 cvs 4122: else
1.82 cvs 4123: sprintf (buffer, "text-indent: %d",
1.67 cvs 4124: settings->value.typed_data.value);
1.18 cvs 4125: add_unit = 1;
4126: break;
4127: case PRLineSpacing:
4128: if (real)
1.82 cvs 4129: sprintf (buffer, "line-height: %g", fval);
1.1 cvs 4130: else
1.82 cvs 4131: sprintf (buffer, "line-height: %d",
1.67 cvs 4132: settings->value.typed_data.value);
1.18 cvs 4133: add_unit = 1;
4134: break;
1.111 cvs 4135: case PRDepth:
4136: break;
1.18 cvs 4137: case PRAdjust:
4138: switch (settings->value.typed_data.value)
1.1 cvs 4139: {
1.184 vatton 4140: case AdjustLeft:
1.82 cvs 4141: strcpy (buffer, "text-align: left");
1.18 cvs 4142: break;
1.184 vatton 4143: case AdjustRight:
1.82 cvs 4144: strcpy (buffer, "text-align: right");
1.18 cvs 4145: break;
1.184 vatton 4146: case Centered:
1.82 cvs 4147: strcpy (buffer, "text-align: center");
1.18 cvs 4148: break;
1.184 vatton 4149: case LeftWithDots:
1.82 cvs 4150: strcpy (buffer, "text-align: left");
1.81 cvs 4151: break;
1.184 vatton 4152: case Justify:
1.82 cvs 4153: strcpy (buffer, "text-align: justify");
1.112 quint 4154: break;
4155: }
4156: break;
4157: case PRDirection:
4158: switch (settings->value.typed_data.value)
4159: {
1.184 vatton 4160: case LeftToRight:
1.112 quint 4161: strcpy (buffer, "direction: ltr");
4162: break;
1.184 vatton 4163: case RightToLeft:
1.112 quint 4164: strcpy (buffer, "direction: rtl");
1.113 quint 4165: break;
4166: }
4167: break;
4168: case PRUnicodeBidi:
4169: switch (settings->value.typed_data.value)
4170: {
1.184 vatton 4171: case Normal:
1.113 quint 4172: strcpy (buffer, "unicode-bidi: normal");
4173: break;
1.184 vatton 4174: case Embed:
1.113 quint 4175: strcpy (buffer, "unicode-bidi: embed");
4176: break;
1.184 vatton 4177: case Override:
1.113 quint 4178: strcpy (buffer, "unicode-bidi: bidi-override");
1.18 cvs 4179: break;
1.1 cvs 4180: }
1.18 cvs 4181: break;
1.111 cvs 4182: case PRLineStyle:
4183: break;
1.126 vatton 4184: case PRDisplay:
4185: switch (settings->value.typed_data.value)
4186: {
1.184 vatton 4187: case Inline:
1.126 vatton 4188: strcpy (buffer, "display: inline");
4189: break;
1.184 vatton 4190: case Block:
1.126 vatton 4191: strcpy (buffer, "display: block");
4192: break;
1.184 vatton 4193: case ListItem:
1.126 vatton 4194: strcpy (buffer, "display: list-item");
4195: break;
1.184 vatton 4196: case RunIn:
1.126 vatton 4197: strcpy (buffer, "display: runin");
4198: break;
1.184 vatton 4199: case Compact:
1.126 vatton 4200: strcpy (buffer, "display: compact");
4201: break;
1.184 vatton 4202: case Marker:
1.126 vatton 4203: strcpy (buffer, "display: marker");
4204: break;
4205: default:
4206: break;
4207: }
4208: break;
1.111 cvs 4209: case PRLineWeight:
4210: elType = TtaGetElementType(el);
4211: #ifdef _SVG
4212: if (!strcmp(TtaGetSSchemaName (elType.ElSSchema), "SVG"))
4213: #endif /* _SVG */
4214: {
4215: if (real)
4216: sprintf (buffer, "stroke-width: %g", fval);
4217: else
4218: sprintf (buffer, "stroke-width: %d",
4219: settings->value.typed_data.value);
4220: }
4221: add_unit = 1;
1.18 cvs 4222: break;
4223: case PRFillPattern:
4224: break;
4225: case PRBackground:
4226: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
1.76 cvs 4227: elType = TtaGetElementType(el);
1.100 vatton 4228: #ifdef _SVG
4229: if (strcmp(TtaGetSSchemaName (elType.ElSSchema), "SVG") == 0)
1.82 cvs 4230: sprintf (buffer, "fill: #%02X%02X%02X", red, green, blue);
1.67 cvs 4231: else
1.100 vatton 4232: #endif /* _SVG */
1.82 cvs 4233: sprintf (buffer, "background-color: #%02X%02X%02X", red, green,
1.67 cvs 4234: blue);
1.18 cvs 4235: break;
4236: case PRForeground:
4237: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
1.76 cvs 4238: elType = TtaGetElementType(el);
1.100 vatton 4239: #ifdef _SVG
4240: if (strcmp(TtaGetSSchemaName (elType.ElSSchema), "SVG") == 0)
1.82 cvs 4241: sprintf (buffer, "stroke: #%02X%02X%02X", red, green, blue);
1.67 cvs 4242: else
1.100 vatton 4243: #endif /* _SVG */
1.82 cvs 4244: sprintf (buffer, "color: #%02X%02X%02X", red, green, blue);
1.67 cvs 4245: break;
1.111 cvs 4246: case PRHyphenate:
1.18 cvs 4247: break;
1.111 cvs 4248: case PRVertOverflow:
1.18 cvs 4249: break;
1.111 cvs 4250: case PRHorizOverflow:
1.18 cvs 4251: break;
4252: case PRBackgroundPicture:
4253: if (settings->value.pointer != NULL)
1.82 cvs 4254: sprintf (buffer, "background-image: url(%s)",
1.67 cvs 4255: (char*)(settings->value.pointer));
1.1 cvs 4256: else
1.82 cvs 4257: sprintf (buffer, "background-image: none");
1.18 cvs 4258: break;
4259: case PRPictureMode:
4260: switch (settings->value.typed_data.value)
1.1 cvs 4261: {
1.184 vatton 4262: case REALSIZE:
1.82 cvs 4263: sprintf (buffer, "background-repeat: no-repeat");
1.18 cvs 4264: break;
1.184 vatton 4265: case REPEAT:
1.82 cvs 4266: sprintf (buffer, "background-repeat: repeat");
1.18 cvs 4267: break;
1.184 vatton 4268: case VREPEAT:
1.82 cvs 4269: sprintf (buffer, "background-repeat: repeat-y");
1.18 cvs 4270: break;
1.184 vatton 4271: case HREPEAT:
1.82 cvs 4272: sprintf (buffer, "background-repeat: repeat-x");
1.18 cvs 4273: break;
1.1 cvs 4274: }
1.18 cvs 4275: break;
4276: default:
4277: break;
1.1 cvs 4278: }
4279:
1.18 cvs 4280: if (add_unit)
1.1 cvs 4281: {
1.18 cvs 4282: /* add the unit string to the CSS string */
4283: for (i = 0; i < NB_UNITS; i++)
1.1 cvs 4284: {
1.18 cvs 4285: if (CSSUnitNames[i].unit == unit)
1.1 cvs 4286: {
1.82 cvs 4287: strcat (buffer, CSSUnitNames[i].sign);
1.18 cvs 4288: break;
1.1 cvs 4289: }
4290: }
4291: }
4292: }
4293:
4294: /*----------------------------------------------------------------------
1.59 cvs 4295: ParseHTMLSpecificStyle: parse and apply a CSS Style string.
1.18 cvs 4296: This function must be called when a specific style is applied to an
4297: element.
1.114 quint 4298: The parameter specificity is the specificity of the style, 0 if it is
4299: not really a CSS rule.
1.1 cvs 4300: ----------------------------------------------------------------------*/
1.79 cvs 4301: void ParseHTMLSpecificStyle (Element el, char *cssRule, Document doc,
1.114 quint 4302: int specificity, ThotBool destroy)
1.1 cvs 4303: {
4304: PresentationContext context;
4305: ElementType elType;
1.14 cvs 4306: ThotBool isHTML;
1.1 cvs 4307:
4308: /* A rule applying to BODY is really meant to address HTML */
4309: elType = TtaGetElementType (el);
1.89 cvs 4310:
1.86 cvs 4311: /* store the current line for eventually reported errors */
4312: LineNumber = TtaGetElementLineNumber (el);
1.89 cvs 4313: if (destroy)
4314: /* no reported errors */
4315: ParsedDoc = 0;
4316: else if (ParsedDoc != doc)
4317: {
4318: /* update the context for reported errors */
4319: ParsedDoc = doc;
4320: DocURL = DocumentURLs[doc];
4321: }
1.82 cvs 4322: isHTML = (strcmp (TtaGetSSchemaName (elType.ElSSchema), "HTML") == 0);
1.1 cvs 4323: /* create the context of the Specific presentation driver */
4324: context = TtaGetSpecificStyleContext (doc);
4325: if (context == NULL)
4326: return;
4327: context->type = elType.ElTypeNum;
1.114 quint 4328: context->cssSpecificity = specificity;
1.1 cvs 4329: context->destroy = destroy;
4330: /* Call the parser */
1.155 cheyroul 4331: ParseCSSRule (el, NULL,
4332: (PresentationContext) context,
4333: cssRule, NULL, isHTML);
1.1 cvs 4334: /* free the context */
4335: TtaFreeMemory(context);
4336: }
4337:
1.68 cvs 4338:
1.1 cvs 4339: /*----------------------------------------------------------------------
1.59 cvs 4340: ParseGenericSelector: Create a generic context for a given
1.1 cvs 4341: selector string. If the selector is made of multiple comma-
4342: separated selector items, it parses them one at a time and
4343: return the end of the selector string to be handled or NULL
4344: ----------------------------------------------------------------------*/
1.79 cvs 4345: static char *ParseGenericSelector (char *selector, char *cssRule,
4346: GenericContext ctxt, Document doc,
4347: CSSInfoPtr css)
4348: {
4349: ElementType elType;
4350: PSchema tsch;
1.119 vatton 4351: AttributeType attrType;
1.79 cvs 4352: char sel[MAX_ANCESTORS * 50];
1.118 vatton 4353: char *deb, *cur, c;
4354: char *schemaName, *mappedName;
1.79 cvs 4355: char *names[MAX_ANCESTORS];
4356: char *ids[MAX_ANCESTORS];
4357: char *classes[MAX_ANCESTORS];
4358: char *pseudoclasses[MAX_ANCESTORS];
4359: char *attrs[MAX_ANCESTORS];
4360: char *attrvals[MAX_ANCESTORS];
1.133 vatton 4361: AttrMatch attrmatch[MAX_ANCESTORS];
1.91 cvs 4362: int i, j, k, max;
1.125 vatton 4363: int att, maxAttr, kind;
1.118 vatton 4364: int specificity, xmlType;
1.79 cvs 4365: ThotBool isHTML;
1.183 vatton 4366: ThotBool level, quoted;
1.1 cvs 4367:
1.82 cvs 4368: sel[0] = EOS;
1.117 vatton 4369: specificity = 0;
1.1 cvs 4370: for (i = 0; i < MAX_ANCESTORS; i++)
4371: {
1.25 cvs 4372: names[i] = NULL;
4373: ids[i] = NULL;
4374: classes[i] = NULL;
4375: pseudoclasses[i] = NULL;
4376: attrs[i] = NULL;
4377: attrvals[i] = NULL;
1.133 vatton 4378: attrmatch[i] = Txtmatch;
1.25 cvs 4379: ctxt->name[i] = 0;
4380: ctxt->names_nb[i] = 0;
4381: ctxt->attrType[i] = 0;
1.129 vatton 4382: ctxt->attrLevel[i] = 0;
1.25 cvs 4383: ctxt->attrText[i] = NULL;
1.178 quint 4384: ctxt->attrMatch[i] = Txtmatch;
1.1 cvs 4385: }
1.25 cvs 4386: ctxt->box = 0;
4387: ctxt->type = 0;
1.114 quint 4388: /* the specificity of the rule depends on the selector */
4389: ctxt->cssSpecificity = 0;
1.25 cvs 4390:
1.82 cvs 4391: selector = SkipBlanksAndComments (selector);
1.27 cvs 4392: cur = &sel[0];
1.25 cvs 4393: max = 0; /* number of loops */
1.1 cvs 4394: while (1)
4395: {
1.85 cvs 4396: /* point to the following word in sel[] */
1.27 cvs 4397: deb = cur;
1.25 cvs 4398: /* copy an item of the selector into sel[] */
1.1 cvs 4399: /* put one word in the sel buffer */
1.82 cvs 4400: while (*selector != EOS && *selector != ',' &&
4401: *selector != '.' && *selector != ':' &&
1.118 vatton 4402: *selector != '#' && *selector != '[' &&
1.130 vatton 4403: *selector != '*' && *selector != '>' &&
1.118 vatton 4404: !TtaIsBlank (selector))
1.50 cvs 4405: *cur++ = *selector++;
1.82 cvs 4406: *cur++ = EOS; /* close the first string in sel[] */
4407: if (deb[0] != EOS)
1.117 vatton 4408: {
4409: names[0] = deb;
1.150 vatton 4410: if (!strcmp (names[0], "html"))
1.149 vatton 4411: /* give a greater priority to the backgoud color of html */
4412: specificity += 3;
4413: else
4414: specificity += 1;
1.117 vatton 4415: }
1.25 cvs 4416: else
1.27 cvs 4417: names[0] = NULL;
4418: classes[0] = NULL;
4419: pseudoclasses[0] = NULL;
4420: ids[0] = NULL;
4421: attrs[0] = NULL;
4422: attrvals[0] = NULL;
1.25 cvs 4423:
1.27 cvs 4424: /* now names[0] points to the beginning of the parsed item
1.25 cvs 4425: and cur to the next chain to be parsed */
1.129 vatton 4426: while (*selector == '.' || *selector == ':' ||
1.130 vatton 4427: *selector == '#' || *selector == '[' ||
1.183 vatton 4428: *selector == '*')
1.129 vatton 4429: {
1.85 cvs 4430: /* point to the following word in sel[] */
4431: deb = cur;
1.129 vatton 4432: if (*selector == '.')
4433: {
4434: selector++;
4435: while (*selector != EOS && *selector != ',' &&
4436: *selector != '.' && *selector != ':' &&
4437: !TtaIsBlank (selector))
4438: *cur++ = *selector++;
4439: /* close the word */
4440: *cur++ = EOS;
4441: /* point to the class in sel[] if it's valid name */
4442: if (deb[0] <= 64)
4443: {
1.168 vatton 4444: CSSPrintError ("Invalid class", deb);
1.116 vatton 4445: DoApply = FALSE;
1.129 vatton 4446: }
4447: else
4448: {
4449: classes[0] = deb;
1.178 quint 4450: /* a "class" attribute on an element may contain several
4451: words, one for each class it matches */
4452: attrmatch[0] = Txtword;
1.117 vatton 4453: specificity += 10;
1.129 vatton 4454: }
4455: }
4456: else if (*selector == ':')
4457: {
4458: selector++;
4459: while (*selector != EOS && *selector != ',' &&
4460: *selector != '.' && *selector != ':' &&
4461: !TtaIsBlank (selector))
4462: *cur++ = *selector++;
4463: /* close the word */
4464: *cur++ = EOS;
4465: /* point to the pseudoclass in sel[] if it's valid name */
4466: if (deb[0] <= 64)
4467: {
1.168 vatton 4468: CSSPrintError ("Invalid pseudoclass", deb);
1.129 vatton 4469: DoApply = FALSE;
4470: }
4471: else
4472: {
4473: if (!strcmp (deb, "first-letter") ||
4474: !strcmp (deb, "first-line") ||
4475: !strcmp (deb, "before") ||
4476: !strcmp (deb, "after"))
4477: /* not supported */
1.116 vatton 4478: DoApply = FALSE;
1.129 vatton 4479: else
4480: specificity += 10;
4481: pseudoclasses[0]= deb;
4482: }
4483: }
4484: else if (*selector == '#')
4485: {
4486: selector++;
4487: while (*selector != EOS && *selector != ',' &&
4488: *selector != '.' && *selector != ':' &&
4489: !TtaIsBlank (selector))
4490: *cur++ = *selector++;
4491: /* close the word */
4492: *cur++ = EOS;
4493: /* point to the attribute in sel[] if it's valid name */
4494: if (deb[0] <= 64)
4495: {
1.168 vatton 4496: CSSPrintError ("Invalid id", deb);
1.129 vatton 4497: DoApply = FALSE;
4498: }
4499: else
4500: {
4501: ids[0] = deb;
4502: specificity += 100;
4503: }
4504: }
4505: else if (*selector == '[')
4506: {
1.118 vatton 4507: selector++;
1.129 vatton 4508: while (*selector != EOS && *selector != ']' &&
1.131 vatton 4509: *selector != '=' && *selector != '~' &&
1.133 vatton 4510: *selector != '|' && *selector != '^' &&
4511: *selector != '!')
1.129 vatton 4512: *cur++ = *selector++;
1.133 vatton 4513: /* check matching */
4514: if (*selector == '~')
4515: {
4516: attrmatch[0] = Txtword;
4517: selector++;
4518: }
4519: else if (*selector == '|')
4520: {
4521: attrmatch[0] = Txtsubstring;
4522: selector++;
4523: }
4524: else
4525: attrmatch[0] = Txtmatch;
1.129 vatton 4526: /* close the word */
4527: *cur++ = EOS;
4528: /* point to the attribute in sel[] if it's valid name */
4529: if (deb[0] <= 64)
4530: {
1.168 vatton 4531: CSSPrintError ("Invalid attribute", deb);
1.129 vatton 4532: DoApply = FALSE;
4533: }
4534: else
4535: {
4536: attrs[0] = deb;
4537: specificity += 10;
4538: }
4539: if (*selector == '=')
4540: {
4541: /* look for a value "xxxx" */
4542: selector++;
4543: if (*selector != '"')
1.183 vatton 4544: quoted = FALSE;
1.129 vatton 4545: else
4546: {
1.183 vatton 4547: quoted = TRUE;
1.129 vatton 4548: /* we are now parsing the attribute value */
4549: selector++;
1.183 vatton 4550: }
4551: deb = cur;
4552: while ((quoted &&
4553: (*selector != '"' ||
4554: (*selector == '"' && selector[-1] == '\\'))) ||
4555: (!quoted && *selector != ']'))
4556: {
4557: if (*selector == EOS)
1.129 vatton 4558: {
1.183 vatton 4559: CSSPrintError ("Invalid attribute value", deb);
4560: DoApply = FALSE;
1.129 vatton 4561: }
1.183 vatton 4562: else
1.129 vatton 4563: {
1.183 vatton 4564: *cur++ = tolower (*selector);
1.129 vatton 4565: selector++;
4566: }
4567: }
1.183 vatton 4568: /* there is a value */
4569: if (quoted && *selector != '"')
4570: {
4571: selector++;
4572: quoted = FALSE;
4573: }
4574: if (*selector != ']')
4575: {
4576: CSSPrintError ("Invalid attribute value", deb);
4577: DoApply = FALSE;
4578: }
4579: else
4580: {
4581: *cur++ = EOS;
4582: attrvals[0] = deb;
4583: selector++;
4584: }
1.129 vatton 4585: }
4586: /* end of the attribute */
1.183 vatton 4587: else if (*selector != ']')
1.129 vatton 4588: {
1.133 vatton 4589: selector[1] = EOS;
1.183 vatton 4590: CSSPrintError ("Invalid attribute", selector);
1.133 vatton 4591: selector += 2;
1.129 vatton 4592: DoApply = FALSE;
4593: }
4594: else
4595: selector++;
1.130 vatton 4596: }
4597: else
4598: {
4599: /* not supported selector */
4600: while (*selector != EOS && *selector != ',' &&
4601: *selector != '.' && *selector != ':' &&
4602: !TtaIsBlank (selector))
4603: *cur++ = *selector++;
4604: /* close the word */
4605: *cur++ = EOS;
1.168 vatton 4606: CSSPrintError ("Not supported selector", deb);
1.130 vatton 4607: DoApply = FALSE;
1.129 vatton 4608: }
4609: }
1.1 cvs 4610:
1.82 cvs 4611: selector = SkipBlanksAndComments (selector);
1.25 cvs 4612: /* is it a multi-level selector? */
1.82 cvs 4613: if (*selector == EOS)
1.1 cvs 4614: /* end of the selector */
4615: break;
1.82 cvs 4616: else if (*selector == ',')
1.1 cvs 4617: {
4618: /* end of the current selector */
4619: selector++;
4620: break;
4621: }
1.25 cvs 4622: else
4623: {
1.143 vatton 4624: if (*selector == '>')
4625: {
4626: /* handle immediat parent as a simple parent */
4627: selector++;
4628: selector = SkipBlanksAndComments (selector);
4629: }
1.25 cvs 4630: /* shifts the list to make room for the new name */
4631: max++; /* a new level in ancestor tables */
4632: if (max == MAX_ANCESTORS)
4633: /* abort the CSS parsing */
4634: return (selector);
4635: for (i = max; i > 0; i--)
4636: {
4637: names[i] = names[i - 1];
4638: ids[i] = ids[i - 1];
4639: classes[i] = classes[i - 1];
1.133 vatton 4640: pseudoclasses[i] = pseudoclasses[i - 1];
1.25 cvs 4641: attrs[i] = attrs[i - 1];
4642: attrvals[i] = attrvals[i - 1];
1.133 vatton 4643: attrmatch[i] = attrmatch[i - 1];
1.25 cvs 4644: }
4645: }
1.1 cvs 4646: }
4647:
4648: /* Now set up the context block */
1.25 cvs 4649: i = 0;
4650: k = 0;
4651: j = 0;
1.35 cvs 4652: maxAttr = 0;
1.91 cvs 4653: /* default schema name */
1.119 vatton 4654: ctxt->schema = NULL;
1.122 vatton 4655: elType.ElSSchema = NULL;
4656: schemaName = TtaGetSSchemaName(TtaGetDocumentSSchema (doc));
1.119 vatton 4657: if (!strcmp (schemaName, "HTML"))
4658: xmlType = XHTML_TYPE;
4659: else if (!strcmp (schemaName, "MathML"))
4660: xmlType = MATH_TYPE;
4661: else if (!strcmp (schemaName, "SVG"))
4662: xmlType = SVG_TYPE;
4663: else if (!strcmp (schemaName, "XLink"))
4664: xmlType = XLINK_TYPE;
4665: else if (!strcmp (schemaName, "Annot"))
4666: xmlType = ANNOT_TYPE;
4667: else
4668: xmlType = XML_TYPE;
1.25 cvs 4669: while (i <= max)
4670: {
4671: if (names[i])
4672: {
1.118 vatton 4673: /* get the element type of this name in the current document */
4674: MapXMLElementType (xmlType, names[i], &elType, &mappedName, &c, &level, doc);
1.25 cvs 4675: if (i == 0)
4676: {
1.106 cvs 4677: if (elType.ElSSchema == NULL)
4678: {
1.119 vatton 4679: /* Search in the list of loaded schemas */
1.106 cvs 4680: TtaGetXmlElementType (names[i], &elType, NULL, doc);
1.119 vatton 4681: if (elType.ElSSchema)
4682: {
1.154 vatton 4683: /* the element type concerns an imported nature */
1.119 vatton 4684: schemaName = TtaGetSSchemaName(elType.ElSSchema);
4685: if (!strcmp (schemaName, "HTML"))
4686: xmlType = XHTML_TYPE;
4687: else if (!strcmp (schemaName, "MathML"))
4688: xmlType = MATH_TYPE;
4689: else if (!strcmp (schemaName, "SVG"))
4690: xmlType = SVG_TYPE;
4691: else if (!strcmp (schemaName, "XLink"))
4692: xmlType = XLINK_TYPE;
4693: else if (!strcmp (schemaName, "Annot"))
4694: xmlType = ANNOT_TYPE;
4695: else
4696: xmlType = XML_TYPE;
4697: }
1.118 vatton 4698: #ifdef XML_GENERIC
1.119 vatton 4699: else if (xmlType == XML_TYPE)
1.106 cvs 4700: {
4701: /* Creation of a new element type in the main schema */
4702: elType.ElSSchema = TtaGetDocumentSSchema (doc);
1.118 vatton 4703: TtaAppendXmlElement (names[i], &elType, &mappedName, doc);
1.106 cvs 4704: }
1.118 vatton 4705: #endif /* XML_GENERIC */
1.122 vatton 4706: else
4707: {
4708: if (xmlType != XHTML_TYPE)
4709: {
4710: MapXMLElementType (XHTML_TYPE, names[i], &elType,
4711: &mappedName, &c, &level, doc);
4712: if (elType.ElSSchema)
1.123 vatton 4713: elType.ElSSchema = GetXHTMLSSchema (doc);
1.122 vatton 4714: }
4715: if (elType.ElSSchema == NULL && xmlType != MATH_TYPE)
4716: {
4717: MapXMLElementType (MATH_TYPE, names[i], &elType,
4718: &mappedName, &c, &level, doc);
4719: if (elType.ElSSchema)
1.123 vatton 4720: elType.ElSSchema = GetMathMLSSchema (doc);
1.122 vatton 4721: }
4722: if (elType.ElSSchema == NULL && xmlType != SVG_TYPE)
4723: {
4724: MapXMLElementType (SVG_TYPE, names[i], &elType,
4725: &mappedName, &c, &level, doc);
4726: if (elType.ElSSchema)
1.123 vatton 4727: elType.ElSSchema = GetSVGSSchema (doc);
1.122 vatton 4728: }
4729: }
1.118 vatton 4730: }
1.119 vatton 4731:
1.118 vatton 4732: if (elType.ElSSchema == NULL)
4733: /* cannot apply these CSS rules */
4734: DoApply = FALSE;
4735: else
4736: {
4737: /* Store the element type */
4738: ctxt->type = elType.ElTypeNum;
4739: ctxt->name[0] = elType.ElTypeNum;
4740: ctxt->names_nb[0] = 0;
4741: ctxt->schema = elType.ElSSchema;
1.106 cvs 4742: }
1.25 cvs 4743: }
4744: else if (elType.ElTypeNum != 0)
4745: {
4746: /* look at the current context to see if the type is already
4747: stored */
1.121 vatton 4748: j = 1;
1.32 cvs 4749: while (j < k && ctxt->name[j] != elType.ElTypeNum)
1.25 cvs 4750: j++;
4751: if (j == k)
4752: {
4753: ctxt->name[j] = elType.ElTypeNum;
4754: if (j != 0)
1.121 vatton 4755: ctxt->names_nb[j] = 1;
1.25 cvs 4756: }
4757: else
4758: /* increment the number of ancestor levels */
4759: ctxt->names_nb[j]++;
4760: }
1.154 vatton 4761: #ifdef XML_GENERIC
4762: else if (xmlType == XML_TYPE)
4763: {
1.158 vatton 4764: TtaGetXmlElementType (names[i], &elType, NULL, doc);
4765: if (elType.ElTypeNum == 0)
4766: {
4767: /* Creation of a new element type in the main schema */
4768: elType.ElSSchema = TtaGetDocumentSSchema (doc);
4769: TtaAppendXmlElement (names[i], &elType, &mappedName, doc);
4770: }
1.154 vatton 4771: if (elType.ElTypeNum != 0)
4772: {
4773: /* look at the current context to see if the type is already
4774: stored */
4775: j = 1;
4776: while (j < k && ctxt->name[j] != elType.ElTypeNum)
4777: j++;
4778: if (j == k)
4779: {
4780: ctxt->name[j] = elType.ElTypeNum;
4781: if (j != 0)
4782: ctxt->names_nb[j] = 1;
4783: }
4784: else
4785: /* increment the number of ancestor levels */
4786: ctxt->names_nb[j]++;
4787: }
4788: }
4789: #endif /* XML_GENERIC */
1.25 cvs 4790: else
1.117 vatton 4791: j = k;
1.25 cvs 4792: }
1.117 vatton 4793: else
4794: j = k;
1.1 cvs 4795:
1.25 cvs 4796: /* store attributes information */
4797: if (classes[i])
4798: {
4799: ctxt->attrText[j] = classes[i];
1.119 vatton 4800: if (xmlType == SVG_TYPE)
1.100 vatton 4801: ctxt->attrType[j] = SVG_ATTR_class;
1.119 vatton 4802: else if (xmlType == MATH_TYPE)
1.91 cvs 4803: ctxt->attrType[j] = MathML_ATTR_class;
1.119 vatton 4804: else if (xmlType == XHTML_TYPE)
1.107 cvs 4805: ctxt->attrType[j] = HTML_ATTR_Class;
4806: else
1.119 vatton 4807: #ifdef XML_GENERIC
1.107 cvs 4808: ctxt->attrType[j] = XML_ATTR_class;
4809: #else /* XML_GENERIC */
1.91 cvs 4810: ctxt->attrType[j] = HTML_ATTR_Class;
1.107 cvs 4811: #endif /* XML_GENERIC */
1.157 vatton 4812: ctxt->attrMatch[j] = attrmatch[i];
1.79 cvs 4813: /* add a new entry */
1.80 cvs 4814: maxAttr = i + 1;
1.129 vatton 4815: /* update attrLevel */
4816: ctxt->attrLevel[j] = i;
4817: j++;
1.25 cvs 4818: }
1.79 cvs 4819: if (pseudoclasses[i])
1.25 cvs 4820: {
4821: ctxt->attrText[j] = pseudoclasses[i];
1.119 vatton 4822: if (xmlType == SVG_TYPE)
1.100 vatton 4823: ctxt->attrType[j] = SVG_ATTR_PseudoClass;
1.119 vatton 4824: else if (xmlType == MATH_TYPE)
1.91 cvs 4825: ctxt->attrType[j] = MathML_ATTR_PseudoClass;
1.119 vatton 4826: else if (xmlType == XHTML_TYPE)
1.107 cvs 4827: ctxt->attrType[j] = HTML_ATTR_PseudoClass;
4828: else
1.119 vatton 4829: #ifdef XML_GENERIC
1.107 cvs 4830: ctxt->attrType[j] = XML_ATTR_PseudoClass;
4831: #else /* XML_GENERIC */
1.91 cvs 4832: ctxt->attrType[j] = HTML_ATTR_PseudoClass;
1.107 cvs 4833: #endif /* XML_GENERIC */
1.157 vatton 4834: ctxt->attrMatch[j] = attrmatch[i];
1.79 cvs 4835: /* add a new entry */
1.80 cvs 4836: maxAttr = i + 1;
1.129 vatton 4837: /* update attrLevel */
4838: ctxt->attrLevel[j] = i;
4839: j++;
1.25 cvs 4840: }
1.79 cvs 4841: if (ids[i])
1.25 cvs 4842: {
4843: ctxt->attrText[j] = ids[i];
1.119 vatton 4844: if (xmlType == SVG_TYPE)
1.100 vatton 4845: ctxt->attrType[j] = SVG_ATTR_id;
1.119 vatton 4846: else if (xmlType == MATH_TYPE)
1.91 cvs 4847: ctxt->attrType[j] = MathML_ATTR_id;
1.119 vatton 4848: else if (xmlType == XHTML_TYPE)
1.107 cvs 4849: ctxt->attrType[j] = HTML_ATTR_ID;
4850: else
1.119 vatton 4851: #ifdef XML_GENERIC
1.107 cvs 4852: ctxt->attrType[j] = XML_ATTR_id;
4853: #else /* XML_GENERIC */
1.91 cvs 4854: ctxt->attrType[j] = HTML_ATTR_ID;
1.107 cvs 4855: #endif /* XML_GENERIC */
1.157 vatton 4856: ctxt->attrMatch[j] = attrmatch[i];
1.80 cvs 4857: /* add a new entry */
4858: maxAttr = i + 1;
1.129 vatton 4859: /* update attrLevel */
4860: ctxt->attrLevel[j] = i;
4861: j++;
1.25 cvs 4862: }
1.79 cvs 4863: if (attrs[i])
1.25 cvs 4864: {
1.125 vatton 4865: /* it's an attribute */
1.119 vatton 4866: MapXMLAttribute (xmlType, attrs[i], names[i], &level, doc, &att);
1.127 quint 4867: if (att == DummyAttribute && !strcmp (schemaName, "HTML"))
4868: /* it's the "type" attribute for an "input" element. In the tree
4869: it's represented by the element type, not by an attribute */
4870: att = 0;
1.119 vatton 4871: ctxt->attrType[j] = att;
1.133 vatton 4872: ctxt->attrMatch[j] = attrmatch[i];
1.125 vatton 4873: attrType.AttrSSchema = ctxt->schema;
4874: attrType.AttrTypeNum = att;
1.119 vatton 4875: if (i == 0 && att == 0 && ctxt->schema == NULL)
4876: {
1.125 vatton 4877: /* Not found -> search in the list of loaded schemas */
1.119 vatton 4878: attrType.AttrSSchema = NULL;
4879: TtaGetXmlAttributeType (attrs[i], &attrType, doc);
4880: ctxt->attrType[j] = attrType.AttrTypeNum;
4881: if (attrType.AttrSSchema)
1.125 vatton 4882: /* the element type concerns an imported nature */
4883: schemaName = TtaGetSSchemaName(attrType.AttrSSchema);
1.119 vatton 4884: #ifdef XML_GENERIC
4885: else if (xmlType == XML_TYPE)
4886: {
4887: /* The attribute is not yet present in the tree */
4888: /* Create a new global attribute */
4889: attrType.AttrSSchema = TtaGetDocumentSSchema (doc);
4890: TtaAppendXmlAttribute (attrs[i], &attrType, doc);
4891: }
4892: #endif /* XML_GENERIC */
4893:
4894: if (attrType.AttrSSchema == NULL)
4895: /* cannot apply these CSS rules */
4896: DoApply = FALSE;
1.136 quint 4897: else if (elType.ElSSchema)
4898: ctxt->schema = elType.ElSSchema;
1.119 vatton 4899: else
1.136 quint 4900: ctxt->schema = attrType.AttrSSchema;
1.119 vatton 4901: }
1.125 vatton 4902: /* check the attribute type */
4903: if (!strcmp (schemaName, "HTML"))
4904: xmlType = XHTML_TYPE;
4905: else if (!strcmp (schemaName, "MathML"))
4906: xmlType = MATH_TYPE;
4907: else if (!strcmp (schemaName, "SVG"))
4908: xmlType = SVG_TYPE;
4909: else if (!strcmp (schemaName, "XLink"))
4910: xmlType = XLINK_TYPE;
4911: else if (!strcmp (schemaName, "Annot"))
4912: xmlType = ANNOT_TYPE;
4913: else
4914: xmlType = XML_TYPE;
4915: kind = TtaGetAttributeKind (attrType);
4916: if (kind == 0 && attrvals[i])
4917: {
4918: /* enumerated value */
4919: MapXMLAttributeValue (xmlType, attrvals[i], attrType, &kind);
4920: /* store the attribute value */
4921: ctxt->attrText[j] = (char *) kind;
4922: }
4923: else
4924: ctxt->attrText[j] = attrvals[i];
1.80 cvs 4925: maxAttr = i + 1;
1.129 vatton 4926: /* update attrLevel */
4927: ctxt->attrLevel[j] = i;
4928: j++;
1.25 cvs 4929: }
4930: i++;
1.117 vatton 4931: /* add a new entry */
4932: k++;
1.129 vatton 4933: if (k < j)
4934: k = j;
1.119 vatton 4935: if (i == 1 && ctxt->schema == NULL)
4936: /* use the document schema */
4937: ctxt->schema = TtaGetDocumentSSchema (doc);
1.1 cvs 4938: }
1.117 vatton 4939: /* set the selector specificity */
4940: ctxt->cssSpecificity = specificity;
1.25 cvs 4941: /* sort the list of ancestors by name order */
4942: max = k;
4943: i = 1;
4944: while (i < max)
1.28 cvs 4945: {
4946: for (k = i + 1; k < max; k++)
4947: if (ctxt->name[i] > ctxt->name[k])
4948: {
4949: j = ctxt->name[i];
4950: ctxt->name[i] = ctxt->name[k];
4951: ctxt->name[k] = j;
4952: j = ctxt->names_nb[i];
4953: ctxt->names_nb[i] = ctxt->names_nb[k];
4954: ctxt->names_nb[k] = j;
4955: j = ctxt->attrType[i];
4956: ctxt->attrType[i] = ctxt->attrType[k];
4957: ctxt->attrType[k] = j;
4958: cur = ctxt->attrText[i];
4959: ctxt->attrText[i] = ctxt->attrText[k];
4960: ctxt->attrText[k] = cur;
4961: }
4962: i++;
4963: }
1.84 cvs 4964:
1.25 cvs 4965: /* Get the schema name of the main element */
1.119 vatton 4966: schemaName = TtaGetSSchemaName (ctxt->schema);
4967: isHTML = (strcmp (schemaName, "HTML") == 0);
4968: tsch = GetPExtension (doc, ctxt->schema, css);
4969: if (tsch && cssRule)
4970: ParseCSSRule (NULL, tsch, (PresentationContext) ctxt, cssRule, css, isHTML);
1.116 vatton 4971: /* future CSS rules should apply */
4972: DoApply = TRUE;
1.1 cvs 4973: return (selector);
4974: }
4975:
4976: /*----------------------------------------------------------------------
1.73 cvs 4977: ParseStyleDeclaration: parse a style declaration
4978: stored in the style element of a document
1.59 cvs 4979: We expect the style string to be of the form:
1.1 cvs 4980: [
4981: e.g: pinky, awful { color: pink, font-family: helvetica }
4982: ----------------------------------------------------------------------*/
1.79 cvs 4983: static void ParseStyleDeclaration (Element el, char *cssRule, Document doc,
4984: CSSInfoPtr css, ThotBool destroy)
1.1 cvs 4985: {
1.79 cvs 4986: GenericContext ctxt;
4987: char *decl_end;
4988: char *sel_end;
4989: char *selector;
1.1 cvs 4990:
4991: /* separate the selectors string */
1.82 cvs 4992: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 4993: decl_end = cssRule;
1.82 cvs 4994: while (*decl_end != EOS && *decl_end != '{')
1.1 cvs 4995: decl_end++;
1.82 cvs 4996: if (*decl_end == EOS)
1.86 cvs 4997: {
1.168 vatton 4998: CSSPrintError ("Invalid selector", cssRule);
1.86 cvs 4999: return;
5000: }
1.1 cvs 5001: /* verify and clean the selector string */
5002: sel_end = decl_end - 1;
1.82 cvs 5003: while (*sel_end == SPACE || *sel_end == BSPACE ||
5004: *sel_end == EOL || *sel_end == CR)
1.1 cvs 5005: sel_end--;
5006: sel_end++;
1.82 cvs 5007: *sel_end = EOS;
1.1 cvs 5008: selector = cssRule;
5009:
5010: /* now, deal with the content ... */
5011: decl_end++;
5012: cssRule = decl_end;
1.137 vatton 5013: decl_end = &cssRule[strlen (cssRule) - 1];
5014: if (*decl_end != '{')
5015: *decl_end = EOS;
1.1 cvs 5016: /*
5017: * parse the style attribute string and install the corresponding
5018: * presentation attributes on the new element
5019: */
5020: ctxt = TtaGetGenericStyleContext (doc);
5021: if (ctxt == NULL)
5022: return;
5023: ctxt->destroy = destroy;
5024:
1.82 cvs 5025: while ((selector != NULL) && (*selector != EOS))
1.25 cvs 5026: selector = ParseGenericSelector (selector, cssRule, ctxt, doc, css);
1.1 cvs 5027: TtaFreeMemory (ctxt);
5028: }
5029:
5030: /************************************************************************
5031: * *
5032: * EVALUATION FUNCTIONS / CASCADING AND OVERLOADING *
5033: * *
5034: ************************************************************************/
5035:
5036: /*----------------------------------------------------------------------
1.59 cvs 5037: IsImplicitClassName: return wether the Class name is an
1.1 cvs 5038: implicit one, eg "H1" or "H2 EM" meaning it's a GI name
5039: or an HTML context name.
5040: ----------------------------------------------------------------------*/
1.79 cvs 5041: int IsImplicitClassName (char *class, Document doc)
1.1 cvs 5042: {
1.79 cvs 5043: char name[200];
5044: char *cur = name;
5045: char *first;
5046: char save;
5047: SSchema schema;
1.1 cvs 5048:
5049: /* make a local copy */
1.82 cvs 5050: strncpy (name, class, 199);
1.1 cvs 5051: name[199] = 0;
5052:
5053: /* loop looking if each word is a GI */
5054: while (*cur != 0)
5055: {
5056: first = cur;
5057: cur = SkipWord (cur);
5058: save = *cur;
5059: *cur = 0;
5060: schema = NULL;
5061: if (MapGI (first, &schema, doc) == -1)
5062: {
5063: return (0);
5064: }
5065: *cur = save;
1.82 cvs 5066: cur = SkipBlanksAndComments (cur);
1.1 cvs 5067: }
5068: return (1);
5069: }
5070:
5071: /************************************************************************
5072: * *
1.114 quint 5073: * Functions needed for support of HTML: translate to CSS equivalent *
1.1 cvs 5074: * *
5075: ************************************************************************/
5076:
5077: /*----------------------------------------------------------------------
1.59 cvs 5078: HTMLSetBackgroundColor:
1.1 cvs 5079: ----------------------------------------------------------------------*/
1.79 cvs 5080: void HTMLSetBackgroundColor (Document doc, Element el, char *color)
1.1 cvs 5081: {
1.79 cvs 5082: char css_command[100];
1.1 cvs 5083:
1.82 cvs 5084: sprintf (css_command, "background-color: %s", color);
1.114 quint 5085: ParseHTMLSpecificStyle (el, css_command, doc, 0, FALSE);
1.1 cvs 5086: }
5087:
5088: /*----------------------------------------------------------------------
1.59 cvs 5089: HTMLSetForegroundColor:
1.1 cvs 5090: ----------------------------------------------------------------------*/
1.97 vatton 5091: void HTMLSetForegroundColor (Document doc, Element el, char *color)
1.1 cvs 5092: {
1.79 cvs 5093: char css_command[100];
1.1 cvs 5094:
1.82 cvs 5095: sprintf (css_command, "color: %s", color);
1.114 quint 5096: ParseHTMLSpecificStyle (el, css_command, doc, 0, FALSE);
1.1 cvs 5097: }
5098:
5099: /*----------------------------------------------------------------------
1.59 cvs 5100: HTMLResetBackgroundColor:
1.1 cvs 5101: ----------------------------------------------------------------------*/
1.97 vatton 5102: void HTMLResetBackgroundColor (Document doc, Element el)
1.1 cvs 5103: {
1.79 cvs 5104: char css_command[100];
1.1 cvs 5105:
1.82 cvs 5106: sprintf (css_command, "background: red");
1.114 quint 5107: ParseHTMLSpecificStyle (el, css_command, doc, 0, TRUE);
1.1 cvs 5108: }
5109:
5110: /*----------------------------------------------------------------------
1.59 cvs 5111: HTMLResetBackgroundImage:
1.1 cvs 5112: ----------------------------------------------------------------------*/
1.97 vatton 5113: void HTMLResetBackgroundImage (Document doc, Element el)
1.1 cvs 5114: {
1.79 cvs 5115: char css_command[1000];
1.1 cvs 5116:
1.82 cvs 5117: sprintf (css_command, "background-image: url(xx); background-repeat: repeat");
1.114 quint 5118: ParseHTMLSpecificStyle (el, css_command, doc, 0, TRUE);
1.1 cvs 5119: }
5120:
5121: /*----------------------------------------------------------------------
1.59 cvs 5122: HTMLResetForegroundColor:
1.1 cvs 5123: ----------------------------------------------------------------------*/
1.97 vatton 5124: void HTMLResetForegroundColor (Document doc, Element el)
1.1 cvs 5125: {
1.79 cvs 5126: char css_command[100];
1.1 cvs 5127:
1.36 cvs 5128: /* it's not necessary to well know the current color but it must be valid */
1.82 cvs 5129: sprintf (css_command, "color: red");
1.114 quint 5130: ParseHTMLSpecificStyle (el, css_command, doc, 0, TRUE);
1.1 cvs 5131: }
5132:
5133: /*----------------------------------------------------------------------
1.59 cvs 5134: HTMLSetAlinkColor:
1.1 cvs 5135: ----------------------------------------------------------------------*/
1.97 vatton 5136: void HTMLSetAlinkColor (Document doc, char *color)
1.1 cvs 5137: {
1.79 cvs 5138: char css_command[100];
1.1 cvs 5139:
1.82 cvs 5140: sprintf (css_command, "a:link { color: %s }", color);
1.1 cvs 5141: ApplyCSSRules (NULL, css_command, doc, FALSE);
5142: }
5143:
5144: /*----------------------------------------------------------------------
1.59 cvs 5145: HTMLSetAactiveColor:
1.1 cvs 5146: ----------------------------------------------------------------------*/
1.97 vatton 5147: void HTMLSetAactiveColor (Document doc, char *color)
1.1 cvs 5148: {
1.79 cvs 5149: char css_command[100];
1.1 cvs 5150:
1.82 cvs 5151: sprintf (css_command, "a:active { color: %s }", color);
1.1 cvs 5152: ApplyCSSRules (NULL, css_command, doc, FALSE);
5153: }
5154:
5155: /*----------------------------------------------------------------------
1.59 cvs 5156: HTMLSetAvisitedColor:
1.1 cvs 5157: ----------------------------------------------------------------------*/
1.79 cvs 5158: void HTMLSetAvisitedColor (Document doc, char *color)
1.1 cvs 5159: {
1.79 cvs 5160: char css_command[100];
1.1 cvs 5161:
1.82 cvs 5162: sprintf (css_command, "a:visited { color: %s }", color);
1.1 cvs 5163: ApplyCSSRules (NULL, css_command, doc, FALSE);
5164: }
5165:
5166: /*----------------------------------------------------------------------
1.59 cvs 5167: HTMLResetAlinkColor:
1.1 cvs 5168: ----------------------------------------------------------------------*/
5169: void HTMLResetAlinkColor (Document doc)
5170: {
1.79 cvs 5171: char css_command[100];
1.1 cvs 5172:
1.82 cvs 5173: sprintf (css_command, "a:link { color: red }");
1.1 cvs 5174: ApplyCSSRules (NULL, css_command, doc, TRUE);
5175: }
5176:
5177: /*----------------------------------------------------------------------
1.59 cvs 5178: HTMLResetAactiveColor:
1.1 cvs 5179: ----------------------------------------------------------------------*/
5180: void HTMLResetAactiveColor (Document doc)
5181: {
1.79 cvs 5182: char css_command[100];
1.1 cvs 5183:
1.82 cvs 5184: sprintf (css_command, "a:active { color: red }");
1.1 cvs 5185: ApplyCSSRules (NULL, css_command, doc, TRUE);
5186: }
5187:
5188: /*----------------------------------------------------------------------
1.59 cvs 5189: HTMLResetAvisitedColor:
1.1 cvs 5190: ----------------------------------------------------------------------*/
5191: void HTMLResetAvisitedColor (Document doc)
5192: {
1.79 cvs 5193: char css_command[100];
1.1 cvs 5194:
1.82 cvs 5195: sprintf (css_command, "a:visited { color: red }");
1.1 cvs 5196: ApplyCSSRules (NULL, css_command, doc, TRUE);
5197: }
5198:
5199: /*----------------------------------------------------------------------
1.73 cvs 5200: ApplyCSSRules: parse a CSS Style description stored in the
1.1 cvs 5201: header of a HTML document.
5202: ----------------------------------------------------------------------*/
1.79 cvs 5203: void ApplyCSSRules (Element el, char *cssRule, Document doc, ThotBool destroy)
1.1 cvs 5204: {
5205: CSSInfoPtr css;
5206:
1.144 quint 5207: css = SearchCSS (doc, NULL, el);
1.1 cvs 5208: if (css == NULL)
5209: /* create the document css */
1.144 quint 5210: css = AddCSS (doc, doc, CSS_DOCUMENT_STYLE, NULL, NULL, el);
1.1 cvs 5211: ParseStyleDeclaration (el, cssRule, doc, css, destroy);
5212: }
5213:
5214: /*----------------------------------------------------------------------
1.145 quint 5215: ReadCSSRules: is the front-end function called by the document parser
5216: when detecting a <style type="text/css"> indicating it's the
1.1 cvs 5217: beginning of a CSS fragment or when reading a file .css.
5218:
5219: The CSS parser has to handle <!-- ... --> constructs used to
5220: prevent prehistoric browser from displaying the CSS as a text
5221: content. It will stop on any sequence "<x" where x is different
5222: from ! and will return x as to the caller. Theorically x should
1.145 quint 5223: be equal to / for the </style> end of style.
1.1 cvs 5224: The parameter doc gives the document tree that contains CSS information.
5225: The parameter docRef gives the document to which CSS are to be applied.
5226: This function uses the current css context or creates it. It's able
1.23 cvs 5227: to work on the given buffer or call GetNextChar to read the parsed
1.1 cvs 5228: file.
1.133 vatton 5229: The parameter url gives the URL of the style shheet parsed.
1.86 cvs 5230: Parameter numberOfLinesRead indicates the number of lines already
5231: read in the file.
1.1 cvs 5232: Parameter withUndo indicates whether the changes made in the document
1.145 quint 5233: structure and content have to be registered in the Undo queue or not.
1.1 cvs 5234: ----------------------------------------------------------------------*/
1.133 vatton 5235: char ReadCSSRules (Document docRef, CSSInfoPtr css, char *buffer, char *url,
1.144 quint 5236: int numberOfLinesRead, ThotBool withUndo,
1.172 quint 5237: Element styleElement)
1.1 cvs 5238: {
1.6 cvs 5239: DisplayMode dispMode;
1.82 cvs 5240: char c;
1.138 vatton 5241: char *cssRule, *base, *saveDocURL, *ptr;
1.19 cvs 5242: int index;
1.1 cvs 5243: int CSSindex;
5244: int CSScomment;
5245: int import;
5246: int openRule;
1.93 vatton 5247: int newlines;
1.14 cvs 5248: ThotBool HTMLcomment;
1.102 vatton 5249: ThotBool toParse, eof, quoted;
1.36 cvs 5250: ThotBool ignoreMedia, media;
1.186 vatton 5251: ThotBool noRule, ignoreImport, skip;
1.175 vatton 5252: CSSInfoPtr refcss = NULL;
1.1 cvs 5253:
5254: CSScomment = MAX_CSS_LENGTH;
5255: HTMLcomment = FALSE;
5256: CSSindex = 0;
5257: toParse = FALSE;
5258: noRule = FALSE;
1.36 cvs 5259: media = FALSE;
1.88 cvs 5260: ignoreImport = FALSE;
1.1 cvs 5261: ignoreMedia = FALSE;
5262: import = MAX_CSS_LENGTH;
5263: eof = FALSE;
5264: openRule = 0;
1.82 cvs 5265: c = SPACE;
1.1 cvs 5266: index = 0;
1.134 vatton 5267: base = NULL;
1.135 vatton 5268: quoted = FALSE;
1.186 vatton 5269: skip = FALSE;
1.93 vatton 5270: /* number of new lines parsed */
5271: newlines = 0;
1.6 cvs 5272: /* avoid too many redisplay */
5273: dispMode = TtaGetDisplayMode (docRef);
5274: if (dispMode == DisplayImmediately)
5275: TtaSetDisplayMode (docRef, DeferredDisplay);
1.18 cvs 5276:
5277: /* look for the CSS context */
5278: if (css == NULL)
1.144 quint 5279: css = SearchCSS (docRef, NULL, styleElement);
1.18 cvs 5280: if (css == NULL)
1.144 quint 5281: css = AddCSS (docRef, docRef, CSS_DOCUMENT_STYLE, NULL, NULL,
5282: styleElement);
1.1 cvs 5283:
1.174 vatton 5284: /* look for the CSS descriptor that points to the extension schema */
5285: refcss = css;
5286: if (import)
1.173 cvs 5287: {
1.174 vatton 5288: while (refcss && refcss->category == CSS_IMPORT)
5289: refcss = refcss->NextCSS;
1.173 cvs 5290: }
5291:
1.144 quint 5292: /* register parsed CSS file and the document to which CSS are to be applied*/
1.86 cvs 5293: ParsedDoc = docRef;
1.133 vatton 5294: if (url)
5295: DocURL = url;
1.86 cvs 5296: else
5297: /* the CSS source in within the document itself */
5298: DocURL = DocumentURLs[docRef];
5299: LineNumber = numberOfLinesRead + 1;
1.93 vatton 5300: NewLineSkipped = 0;
1.82 cvs 5301: while (CSSindex < MAX_CSS_LENGTH && c != EOS && !eof)
5302: {
5303: c = buffer[index++];
5304: eof = (c == EOS);
5305: CSSbuffer[CSSindex] = c;
1.186 vatton 5306: if (skip)
5307: {
5308: if (c == '}')
5309: {
5310: /* end of the @font-face */
5311: skip = FALSE;
5312: import = MAX_CSS_LENGTH;
5313: noRule = TRUE;
5314: CSSindex = 0;
5315: }
5316: if (c == EOL)
5317: LineNumber++;
5318: c = CR;
5319: }
5320: else if (CSScomment == MAX_CSS_LENGTH ||
1.82 cvs 5321: c == '*' || c == '/' || c == '<')
5322: {
5323: /* we're not within a comment or we're parsing * or / */
5324: switch (c)
5325: {
5326: case '@': /* perhaps an import primitive */
1.135 vatton 5327: if (!quoted)
5328: import = CSSindex;
1.82 cvs 5329: break;
5330: case ';':
1.135 vatton 5331: if (!quoted && !media && import != MAX_CSS_LENGTH)
1.82 cvs 5332: {
5333: if (strncasecmp (&CSSbuffer[import+1], "import", 6))
5334: /* it's not an import */
5335: import = MAX_CSS_LENGTH;
5336: /* save the text */
5337: noRule = TRUE;
5338: }
5339: break;
5340: case '*':
1.135 vatton 5341: if (!quoted && CSScomment == MAX_CSS_LENGTH && CSSindex > 0 &&
1.82 cvs 5342: CSSbuffer[CSSindex - 1] == '/')
5343: /* start a comment */
5344: CSScomment = CSSindex - 1;
5345: break;
5346: case '/':
1.135 vatton 5347: if (!quoted && CSSindex > 1 && CSScomment != MAX_CSS_LENGTH &&
1.82 cvs 5348: CSSbuffer[CSSindex - 1] == '*')
5349: {
5350: /* close a comment:and ignore its contents */
5351: CSSindex = CSScomment - 1; /* will be incremented later */
5352: CSScomment = MAX_CSS_LENGTH;
1.93 vatton 5353: /* clean up the buffer */
1.103 vatton 5354: if (newlines && CSSindex > 0)
5355: while (CSSindex > 0 &&
5356: (CSSbuffer[CSSindex] == SPACE ||
5357: CSSbuffer[CSSindex] == BSPACE ||
5358: CSSbuffer[CSSindex] == EOL ||
5359: CSSbuffer[CSSindex] == TAB ||
5360: CSSbuffer[CSSindex] == __CR__))
1.93 vatton 5361: {
5362: if ( CSSbuffer[CSSindex] == EOL)
5363: {
5364: LineNumber ++;
5365: newlines --;
5366: }
5367: CSSindex--;
5368: }
1.82 cvs 5369: }
1.135 vatton 5370: else if (!quoted && CSScomment == MAX_CSS_LENGTH && CSSindex > 0 &&
1.82 cvs 5371: CSSbuffer[CSSindex - 1] == '<')
5372: {
5373: /* this is the closing tag ! */
5374: CSSindex -= 2; /* remove </ from the CSS string */
5375: noRule = TRUE;
5376: }
5377: break;
5378: case '<':
1.135 vatton 5379: if (!quoted && CSScomment == MAX_CSS_LENGTH)
1.82 cvs 5380: {
5381: /* only if we're not parsing a comment */
5382: c = buffer[index++];
5383: eof = (c == EOS);
5384: if (c == '!')
5385: {
5386: /* CSS within an HTML comment */
5387: HTMLcomment = TRUE;
5388: CSSindex++;
5389: CSSbuffer[CSSindex] = c;
5390: }
5391: else if (c == EOS)
5392: CSSindex++;
5393: }
5394: break;
5395: case '-':
1.135 vatton 5396: if (!quoted && CSSindex > 0 && CSSbuffer[CSSindex - 1] == '-' &&
1.82 cvs 5397: HTMLcomment)
5398: /* CSS within an HTML comment */
5399: noRule = TRUE;
5400: break;
5401: case '>':
1.135 vatton 5402: if (!quoted && HTMLcomment)
1.82 cvs 5403: noRule = TRUE;
5404: break;
5405: case ' ':
1.135 vatton 5406: if (!quoted && import != MAX_CSS_LENGTH && openRule == 0)
1.162 quint 5407: media = !strncasecmp (&CSSbuffer[import+1], "media", 5);
1.82 cvs 5408: break;
5409: case '{':
1.135 vatton 5410: if (!quoted)
1.82 cvs 5411: {
1.135 vatton 5412: openRule++;
5413: if (import != MAX_CSS_LENGTH && openRule == 1 && media)
5414: {
5415: /* is it the screen concerned? */
5416: CSSbuffer[CSSindex+1] = EOS;
5417: if (TtaIsPrinting ())
5418: base = strstr (&CSSbuffer[import], "print");
5419: else
5420: base = strstr (&CSSbuffer[import], "screen");
5421: if (base == NULL)
5422: base = strstr (&CSSbuffer[import], "all");
5423: if (base == NULL)
5424: ignoreMedia = TRUE;
5425: noRule = TRUE;
5426: }
1.186 vatton 5427: else if (import != MAX_CSS_LENGTH &&
5428: !strncasecmp (&CSSbuffer[import], "@font-face", 10))
5429: skip = TRUE;
1.135 vatton 5430: }
5431: break;
5432: case '}':
5433: if (!quoted)
5434: {
5435: openRule--;
5436: if (import != MAX_CSS_LENGTH && openRule == 0)
5437: {
5438: import = MAX_CSS_LENGTH;
5439: noRule = TRUE;
5440: ignoreMedia = FALSE;
5441: media = FALSE;
5442: }
1.82 cvs 5443: else
1.135 vatton 5444: toParse = TRUE;
1.82 cvs 5445: }
5446: break;
1.135 vatton 5447: case '"':
5448: if (quoted)
1.82 cvs 5449: {
1.135 vatton 5450: if (CSSbuffer[CSSindex - 1] != '\\')
5451: quoted = FALSE;
1.82 cvs 5452: }
5453: else
1.135 vatton 5454: quoted = TRUE;
1.82 cvs 5455: break;
5456: default:
1.86 cvs 5457: if (c == EOL)
1.93 vatton 5458: newlines++;
1.82 cvs 5459: break;
5460: }
5461: }
1.93 vatton 5462: else if (c == EOL)
5463: LineNumber++;
1.82 cvs 5464: if (c != CR)
5465: CSSindex++;
5466:
5467: if (CSSindex >= MAX_CSS_LENGTH && CSScomment < MAX_CSS_LENGTH)
5468: /* we're still parsing a comment: remove the text comment */
5469: CSSindex = CSScomment;
5470:
5471: if (CSSindex >= MAX_CSS_LENGTH || toParse || noRule)
5472: {
5473: CSSbuffer[CSSindex] = EOS;
5474: /* parse a not empty string */
5475: if (CSSindex > 0)
5476: {
1.50 cvs 5477: /* apply CSS rule if it's not just a saving of text */
5478: if (!noRule && !ignoreMedia)
1.88 cvs 5479: {
5480: /* future import rules must be ignored */
5481: ignoreImport = TRUE;
1.173 cvs 5482: ParseStyleDeclaration (NULL, CSSbuffer, docRef, refcss, FALSE);
1.93 vatton 5483: LineNumber += newlines;
5484: newlines = 0;
5485: NewLineSkipped = 0;
1.88 cvs 5486: }
1.82 cvs 5487: else if (import != MAX_CSS_LENGTH &&
5488: !strncasecmp (&CSSbuffer[import+1], "import", 6))
5489: {
5490: /* import section */
5491: cssRule = &CSSbuffer[import+7];
5492: cssRule = TtaSkipBlanks (cssRule);
1.93 vatton 5493: /* save the current line number */
5494: newlines += LineNumber;
1.82 cvs 5495: if (!strncasecmp (cssRule, "url", 3))
5496: {
1.50 cvs 5497: cssRule = &cssRule[3];
1.82 cvs 5498: cssRule = TtaSkipBlanks (cssRule);
5499: if (*cssRule == '(')
5500: {
5501: cssRule++;
5502: cssRule = TtaSkipBlanks (cssRule);
1.102 vatton 5503: quoted = (*cssRule == '"' || *cssRule == '\'');
5504: if (quoted)
5505: cssRule++;
1.82 cvs 5506: base = cssRule;
5507: while (*cssRule != EOS && *cssRule != ')')
5508: cssRule++;
1.102 vatton 5509: if (quoted)
1.167 vatton 5510: {
5511: /* isolate the file name */
5512: cssRule[-1] = EOS;
5513: quoted = FALSE;
5514: }
1.160 vatton 5515: *cssRule = EOS;
1.82 cvs 5516: }
5517: }
1.87 cvs 5518: else if (*cssRule == '"')
5519: {
1.88 cvs 5520: /*
5521: Do we have to accept single quotes?
5522: Double quotes are acceted here.
5523: Escaped quotes are not handled. See function SkipQuotedString
5524: */
1.87 cvs 5525: cssRule++;
5526: cssRule = TtaSkipBlanks (cssRule);
5527: base = cssRule;
1.179 vatton 5528: while (*cssRule != EOS &&
5529: (*cssRule != '"' ||
1.180 vatton 5530: (*cssRule == '"' && cssRule[-1] == '\\')))
1.87 cvs 5531: cssRule++;
1.160 vatton 5532: /* isolate the file name */
5533: *cssRule = EOS;
1.133 vatton 5534: }
5535: /* check if a media is defined */
5536: cssRule++;
5537: cssRule = TtaSkipBlanks (cssRule);
5538: if (*cssRule != ';')
5539: {
5540: if (TtaIsPrinting ())
5541: ignoreImport = (strncasecmp (cssRule, "print", 5) &&
5542: strncasecmp (cssRule, "all", 3));
5543: else
5544: ignoreImport = (strncasecmp (cssRule, "screen", 6) &&
5545: strncasecmp (cssRule, "all", 3));
5546: }
5547: if (!ignoreImport)
5548: {
5549: /* save the displayed URL when an error is reported */
5550: saveDocURL = DocURL;
1.138 vatton 5551: ptr = TtaStrdup (base);
5552: /* get the CSS URI in UTF-8 */
5553: ptr = ReallocUTF8String (ptr, docRef);
1.133 vatton 5554: LoadStyleSheet (base, docRef, NULL, css,
5555: css->media[docRef],
5556: css->category == CSS_USER_STYLE);
5557: /* restore the displayed URL when an error is reported */
5558: DocURL = saveDocURL;
1.138 vatton 5559: TtaFreeMemory (ptr);
1.82 cvs 5560: }
1.93 vatton 5561: /* restore the number of lines */
5562: LineNumber = newlines;
5563: newlines = 0;
1.82 cvs 5564: import = MAX_CSS_LENGTH;
5565: }
1.93 vatton 5566:
1.82 cvs 5567: }
5568: toParse = FALSE;
5569: noRule = FALSE;
5570: CSSindex = 0;
1.50 cvs 5571: }
1.82 cvs 5572: }
1.6 cvs 5573: /* restore the display mode */
5574: if (dispMode == DisplayImmediately)
1.82 cvs 5575: TtaSetDisplayMode (docRef, dispMode);
1.86 cvs 5576:
5577: /* Prepare the context for style attributes */
5578: DocURL = DocumentURLs[docRef];
5579: LineNumber = -1;
1.1 cvs 5580: return (c);
5581: }
1.89 cvs 5582:
Webmaster