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