Annotation of Amaya/amaya/styleparser.c, revision 1.188
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.188 ! cheyroul 3014: css = NULL;
1.34 cvs 3015: el = callblock->el;
3016: tsch = callblock->tsch;
3017: context = &callblock->context.specific;
1.185 vatton 3018: if (doc)
3019: {
3020: /* avoid too many redisplay */
3021: dispMode = TtaGetDisplayMode (doc);
3022: if (dispMode == DisplayImmediately)
3023: TtaSetDisplayMode (doc, DeferredDisplay);
3024: }
3025: else
3026: {
3027: /* check if the CSS still exists */
3028: css = CSSList;
3029: while (css && css != callblock->css)
3030: css = css->NextCSS;
3031: if (css == NULL)
3032: tsch = NULL;
3033: }
1.34 cvs 3034:
1.185 vatton 3035: if (el || tsch)
3036: {
3037: /* Ok the image was fetched, finish the background-image handling */
3038: image.pointer = file;
3039: TtaSetStylePresentation (PRBackgroundPicture, el, tsch, context, image);
3040:
3041: /* enforce the showbox */
3042: value.typed_data.value = 1;
3043: value.typed_data.unit = UNIT_REL;
3044: value.typed_data.real = FALSE;
3045: TtaSetStylePresentation (PRShowBox, el, tsch, context, value);
3046:
3047: }
1.34 cvs 3048:
3049: TtaFreeMemory (callblock);
3050: /* restore the display mode */
1.185 vatton 3051: if (doc)
3052: {
3053: if (dispMode == DisplayImmediately)
3054: TtaSetDisplayMode (doc, dispMode);
3055: }
3056: else if (css)
3057: {
3058: for (doc = 1; doc < DocumentTableLength; doc++)
3059: if (css->documents[doc] && css->enabled[doc] &&
3060: /* don't manage a document used by make book */
3061: (DocumentMeta[doc] == NULL ||
3062: DocumentMeta[doc]->method != CE_MAKEBOOK))
3063: {
3064: /* Change the Display Mode to take into account the new presentation */
3065: dispMode = TtaGetDisplayMode (doc);
3066: if (dispMode == DisplayImmediately)
3067: TtaSetDisplayMode (doc, NoComputedDisplay);
3068: /* Restore the display mode */
3069: if (dispMode == DisplayImmediately)
3070: TtaSetDisplayMode (doc, dispMode);
3071: }
3072: }
1.1 cvs 3073: }
3074:
3075: /*----------------------------------------------------------------------
3076: GetCSSBackgroundURL searches a CSS BackgroundImage url within
3077: the styleString.
3078: Returns NULL or a new allocated url string.
3079: ----------------------------------------------------------------------*/
1.79 cvs 3080: char *GetCSSBackgroundURL (char *styleString)
1.1 cvs 3081: {
1.79 cvs 3082: char *b, *e, *ptr;
3083: int len;
1.1 cvs 3084:
3085: ptr = NULL;
1.82 cvs 3086: b = strstr (styleString, "url");
1.1 cvs 3087: if (b != NULL)
3088: {
3089: b += 3;
1.82 cvs 3090: b = SkipBlanksAndComments (b);
3091: if (*b == '(')
1.1 cvs 3092: {
3093: b++;
1.82 cvs 3094: b = SkipBlanksAndComments (b);
1.161 quint 3095: /*** Escaped quotes are not handled. See function SkipQuotedString */
1.82 cvs 3096: if (*b == '"')
1.1 cvs 3097: {
3098: b++;
3099: /* search the url end */
3100: e = b;
1.82 cvs 3101: while (*e != EOS && *e != '"')
1.1 cvs 3102: e++;
3103: }
1.161 quint 3104: else if (*b == '\'')
3105: {
3106: b++;
3107: /* search the url end */
3108: e = b;
3109: while (*e != EOS && *e != '\'')
3110: e++;
3111: }
1.1 cvs 3112: else
3113: {
3114: /* search the url end */
3115: e = b;
1.82 cvs 3116: while (*e != EOS && *e != ')')
1.1 cvs 3117: e++;
3118: }
1.82 cvs 3119: if (*e != EOS)
1.1 cvs 3120: {
3121: len = (int)(e - b);
1.82 cvs 3122: ptr = (char*) TtaGetMemory (len+1);
3123: strncpy (ptr, b, len);
3124: ptr[len] = EOS;
1.1 cvs 3125: }
3126: }
3127: }
3128: return (ptr);
3129: }
3130:
3131:
3132: /*----------------------------------------------------------------------
1.59 cvs 3133: ParseCSSBackgroundImage: parse a CSS BackgroundImage attribute string.
1.1 cvs 3134: ----------------------------------------------------------------------*/
1.79 cvs 3135: static char *ParseCSSBackgroundImage (Element element, PSchema tsch,
3136: PresentationContext context,
3137: char *cssRule, CSSInfoPtr css,
3138: ThotBool isHTML)
1.1 cvs 3139: {
1.149 vatton 3140: GenericContext ctxt = (GenericContext) context;
1.49 cvs 3141: Element el;
1.1 cvs 3142: BackgroundImageCallbackPtr callblock;
1.49 cvs 3143: PresentationValue image, value;
1.79 cvs 3144: char *url;
1.82 cvs 3145: char *bg_image;
1.79 cvs 3146: char saved;
3147: char *base;
3148: char tempname[MAX_LENGTH];
3149: char imgname[MAX_LENGTH];
1.148 vatton 3150:
1.163 quint 3151: if (element)
1.148 vatton 3152: el = element;
1.163 quint 3153: else
3154: /* default element for FetchImage */
3155: el = TtaGetMainRoot (context->doc);
3156:
1.1 cvs 3157: url = NULL;
1.82 cvs 3158: cssRule = SkipBlanksAndComments (cssRule);
1.161 quint 3159: if (!strncasecmp (cssRule, "none", 4))
3160: {
3161: image.pointer = NULL;
3162: TtaSetStylePresentation (PRBackgroundPicture, element, tsch, context,
3163: image);
3164: }
3165: else if (!strncasecmp (cssRule, "url", 3))
1.1 cvs 3166: {
3167: cssRule += 3;
1.82 cvs 3168: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 3169: if (*cssRule == '(')
3170: {
3171: cssRule++;
1.82 cvs 3172: cssRule = SkipBlanksAndComments (cssRule);
1.161 quint 3173: /*** Escaped quotes are not handled. See function SkipQuotedString */
1.1 cvs 3174: if (*cssRule == '"')
3175: {
3176: cssRule++;
3177: base = cssRule;
1.82 cvs 3178: while (*cssRule != EOS && *cssRule != '"')
1.1 cvs 3179: cssRule++;
3180: }
1.161 quint 3181: else if (*cssRule == '\'')
3182: {
3183: cssRule++;
3184: base = cssRule;
3185: while (*cssRule != EOS && *cssRule != '\'')
3186: cssRule++;
3187: }
1.1 cvs 3188: else
3189: {
3190: base = cssRule;
3191: while (*cssRule != EOS && *cssRule != ')')
3192: cssRule++;
3193: }
3194: saved = *cssRule;
1.82 cvs 3195: *cssRule = EOS;
3196: url = TtaStrdup (base);
1.1 cvs 3197: *cssRule = saved;
1.161 quint 3198: if (saved == '"' || saved == '\'')
3199: /* we need to skip the quote character and possinble spaces */
3200: {
3201: cssRule++;
3202: cssRule = SkipBlanksAndComments (cssRule);
3203: }
1.1 cvs 3204: }
3205: cssRule++;
3206:
3207: if (context->destroy)
3208: {
3209: /* remove the background image PRule */
3210: image.pointer = NULL;
3211: TtaSetStylePresentation (PRBackgroundPicture, element, tsch, context, image);
3212: if (TtaGetStylePresentation (PRFillPattern, element, tsch, context, &value) < 0)
3213: {
3214: /* there is no FillPattern rule -> remove ShowBox rule */
3215: value.typed_data.value = 1;
1.184 vatton 3216: value.typed_data.unit = UNIT_REL;
1.1 cvs 3217: value.typed_data.real = FALSE;
3218: TtaSetStylePresentation (PRShowBox, element, tsch, context, value);
3219: }
3220: }
3221: else if (url)
3222: {
1.30 cvs 3223: bg_image = TtaGetEnvString ("ENABLE_BG_IMAGES");
1.82 cvs 3224: if (bg_image == NULL || !strcasecmp (bg_image, "yes"))
1.161 quint 3225: /* background images are enabled */
1.1 cvs 3226: {
1.185 vatton 3227: callblock = (BackgroundImageCallbackPtr) TtaGetMemory (sizeof (BackgroundImageCallbackBlock));
1.1 cvs 3228: if (callblock != NULL)
3229: {
3230: callblock->el = element;
3231: callblock->tsch = tsch;
1.185 vatton 3232: callblock->css = css;
1.1 cvs 3233: if (element == NULL)
1.149 vatton 3234: memcpy (&callblock->context.generic, ctxt,
3235: sizeof (GenericContextBlock));
1.18 cvs 3236: else
1.149 vatton 3237: memcpy (&callblock->context.specific, context,
3238: sizeof(PresentationContextBlock));
1.18 cvs 3239:
3240: /* check if the image url is related to an external CSS */
1.182 vatton 3241: if (css)
1.18 cvs 3242: {
3243: NormalizeURL (url, 0, tempname, imgname, css->url);
3244: /* fetch and display background image of element */
1.181 vatton 3245: FetchImage (0, el, tempname, AMAYA_LOAD_IMAGE,
1.161 quint 3246: ParseCSSBackgroundImageCallback, callblock);
1.18 cvs 3247: }
3248: else
1.182 vatton 3249: FetchImage (context->doc, el, url, AMAYA_LOAD_IMAGE,
1.161 quint 3250: ParseCSSBackgroundImageCallback, callblock);
1.18 cvs 3251: }
3252: }
3253:
3254: if (url)
3255: TtaFreeMemory (url);
3256: }
3257: }
3258: return (cssRule);
3259: }
3260:
3261: /*----------------------------------------------------------------------
1.59 cvs 3262: ParseCSSBackgroundRepeat: parse a CSS BackgroundRepeat attribute string.
1.18 cvs 3263: ----------------------------------------------------------------------*/
1.79 cvs 3264: static char *ParseCSSBackgroundRepeat (Element element, PSchema tsch,
1.97 vatton 3265: PresentationContext context,
3266: char *cssRule, CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 3267: {
3268: PresentationValue repeat;
3269:
1.184 vatton 3270: repeat.typed_data.value = REALSIZE;
3271: repeat.typed_data.unit = UNIT_REL;
1.18 cvs 3272: repeat.typed_data.real = FALSE;
1.82 cvs 3273: cssRule = SkipBlanksAndComments (cssRule);
3274: if (!strncasecmp (cssRule, "no-repeat", 9))
1.184 vatton 3275: repeat.typed_data.value = REALSIZE;
1.82 cvs 3276: else if (!strncasecmp (cssRule, "repeat-y", 8))
1.184 vatton 3277: repeat.typed_data.value = VREPEAT;
1.82 cvs 3278: else if (!strncasecmp (cssRule, "repeat-x", 8))
1.184 vatton 3279: repeat.typed_data.value = HREPEAT;
1.82 cvs 3280: else if (!strncasecmp (cssRule, "repeat", 6))
1.184 vatton 3281: repeat.typed_data.value = REPEAT;
1.18 cvs 3282: else
3283: return (cssRule);
3284:
3285: /* install the new presentation */
1.116 vatton 3286: if (DoApply)
1.117 vatton 3287: {
3288: /* check if it's an important rule */
3289: if (tsch)
3290: cssRule = CheckImportantRule (cssRule, context);
3291: TtaSetStylePresentation (PRPictureMode, element, tsch, context, repeat);
3292: }
1.18 cvs 3293: cssRule = SkipWord (cssRule);
1.163 quint 3294: return (cssRule);
1.18 cvs 3295: }
3296:
3297: /*----------------------------------------------------------------------
1.59 cvs 3298: ParseCSSBackgroundAttachment: parse a CSS BackgroundAttachment
1.18 cvs 3299: attribute string.
3300: ----------------------------------------------------------------------*/
1.79 cvs 3301: static char *ParseCSSBackgroundAttachment (Element element, PSchema tsch,
3302: PresentationContext context,
3303: char *cssRule, CSSInfoPtr css,
3304: ThotBool isHTML)
1.18 cvs 3305: {
1.163 quint 3306: cssRule = SkipBlanksAndComments (cssRule);
3307: if (!strncasecmp (cssRule, "scroll", 6))
3308: cssRule = SkipWord (cssRule);
3309: else if (!strncasecmp (cssRule, "fixed", 5))
3310: cssRule = SkipWord (cssRule);
3311: return (cssRule);
1.1 cvs 3312: }
3313:
3314: /*----------------------------------------------------------------------
1.59 cvs 3315: ParseCSSBackgroundPosition: parse a CSS BackgroundPosition
1.1 cvs 3316: attribute string.
3317: ----------------------------------------------------------------------*/
1.79 cvs 3318: static char *ParseCSSBackgroundPosition (Element element, PSchema tsch,
3319: PresentationContext context,
3320: char *cssRule, CSSInfoPtr css,
3321: ThotBool isHTML)
1.1 cvs 3322: {
1.18 cvs 3323: PresentationValue repeat;
3324: ThotBool ok;
1.1 cvs 3325:
1.163 quint 3326: cssRule = SkipBlanksAndComments (cssRule);
3327: ok = TRUE;
3328: if (!strncasecmp (cssRule, "left", 4))
3329: cssRule = SkipWord (cssRule);
3330: else if (!strncasecmp (cssRule, "right", 5))
3331: cssRule = SkipWord (cssRule);
3332: else if (!strncasecmp (cssRule, "center", 6))
3333: cssRule = SkipWord (cssRule);
3334: else if (!strncasecmp (cssRule, "top", 3))
3335: cssRule = SkipWord (cssRule);
3336: else if (!strncasecmp (cssRule, "bottom", 6))
3337: cssRule = SkipWord (cssRule);
3338: else if (isdigit (*cssRule) || *cssRule == '.')
3339: cssRule = SkipWord (cssRule);
3340: else
3341: ok = FALSE;
3342:
3343: if (ok && DoApply)
1.148 vatton 3344: {
1.163 quint 3345: /* force realsize for the background image */
1.184 vatton 3346: repeat.typed_data.value = REALSIZE;
3347: repeat.typed_data.unit = UNIT_REL;
1.163 quint 3348: repeat.typed_data.real = FALSE;
3349: /* check if it's an important rule */
3350: if (tsch)
3351: cssRule = CheckImportantRule (cssRule, context);
3352: TtaSetStylePresentation (PRPictureMode, element, tsch, context, repeat);
1.148 vatton 3353: }
1.163 quint 3354: return (cssRule);
1.18 cvs 3355: }
3356:
3357: /*----------------------------------------------------------------------
1.59 cvs 3358: ParseCSSBackground: parse a CSS background attribute
1.18 cvs 3359: ----------------------------------------------------------------------*/
1.79 cvs 3360: static char *ParseCSSBackground (Element element, PSchema tsch,
3361: PresentationContext context, char *cssRule,
3362: CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 3363: {
1.79 cvs 3364: char *ptr;
1.93 vatton 3365: int skippedNL;
1.18 cvs 3366:
1.82 cvs 3367: cssRule = SkipBlanksAndComments (cssRule);
3368: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
1.18 cvs 3369: {
1.71 cvs 3370: /* perhaps a Background Image */
1.82 cvs 3371: if (!strncasecmp (cssRule, "url", 3))
1.63 cvs 3372: cssRule = ParseCSSBackgroundImage (element, tsch, context, cssRule,
3373: css, isHTML);
1.18 cvs 3374: /* perhaps a Background Attachment */
1.82 cvs 3375: else if (!strncasecmp (cssRule, "scroll", 6) ||
3376: !strncasecmp (cssRule, "fixed", 5))
1.63 cvs 3377: cssRule = ParseCSSBackgroundAttachment (element, tsch, context,
3378: cssRule, css, isHTML);
1.18 cvs 3379: /* perhaps a Background Repeat */
1.82 cvs 3380: else if (!strncasecmp (cssRule, "no-repeat", 9) ||
3381: !strncasecmp (cssRule, "repeat-y", 8) ||
3382: !strncasecmp (cssRule, "repeat-x", 8) ||
3383: !strncasecmp (cssRule, "repeat", 6))
3384: cssRule = ParseCSSBackgroundRepeat (element, tsch, context,
3385: cssRule, css, isHTML);
1.18 cvs 3386: /* perhaps a Background Position */
1.82 cvs 3387: else if (!strncasecmp (cssRule, "left", 4) ||
3388: !strncasecmp (cssRule, "right", 5) ||
3389: !strncasecmp (cssRule, "center", 6) ||
3390: !strncasecmp (cssRule, "top", 3) ||
3391: !strncasecmp (cssRule, "bottom", 6) ||
1.110 vatton 3392: isdigit (*cssRule) || *cssRule == '.')
1.63 cvs 3393: cssRule = ParseCSSBackgroundPosition (element, tsch, context,
3394: cssRule, css, isHTML);
1.18 cvs 3395: /* perhaps a Background Color */
3396: else
3397: {
1.93 vatton 3398: skippedNL = NewLineSkipped;
1.18 cvs 3399: /* check if the rule has been found */
3400: ptr = cssRule;
1.82 cvs 3401: cssRule = ParseCSSBackgroundColor (element, tsch, context,
3402: cssRule, css, isHTML);
1.43 cvs 3403: if (ptr == cssRule)
1.93 vatton 3404: {
3405: NewLineSkipped = skippedNL;
3406: /* rule not found */
3407: cssRule = SkipProperty (cssRule);
3408: }
1.18 cvs 3409: }
1.82 cvs 3410: cssRule = SkipBlanksAndComments (cssRule);
1.18 cvs 3411: }
3412: return (cssRule);
3413: }
3414:
1.59 cvs 3415: /*----------------------------------------------------------------------
1.60 cvs 3416: ParseCSSPageBreakBefore: parse a CSS page-break-before attribute
1.59 cvs 3417: ----------------------------------------------------------------------*/
1.79 cvs 3418: static char *ParseCSSPageBreakBefore (Element element, PSchema tsch,
3419: PresentationContext context, char *cssRule,
3420: CSSInfoPtr css, ThotBool isHTML)
1.59 cvs 3421: {
3422: PresentationValue page;
3423:
1.184 vatton 3424: page.typed_data.unit = UNIT_INVALID;
1.59 cvs 3425: page.typed_data.real = FALSE;
1.82 cvs 3426: cssRule = SkipBlanksAndComments (cssRule);
3427: if (!strncasecmp (cssRule, "auto", 4))
1.184 vatton 3428: page.typed_data.value = PageAuto;
1.82 cvs 3429: else if (!strncasecmp (cssRule, "always", 6))
1.59 cvs 3430: {
1.184 vatton 3431: page.typed_data.unit = UNIT_REL;
3432: page.typed_data.value = PageAlways;
1.59 cvs 3433: }
1.82 cvs 3434: else if (!strncasecmp (cssRule, "avoid", 5))
1.59 cvs 3435: {
1.184 vatton 3436: page.typed_data.unit = UNIT_REL;
3437: page.typed_data.value = PageAvoid;
1.59 cvs 3438: }
1.82 cvs 3439: else if (!strncasecmp (cssRule, "left", 4))
1.59 cvs 3440: {
1.184 vatton 3441: page.typed_data.unit = UNIT_REL;
3442: page.typed_data.value = PageLeft;
1.59 cvs 3443: }
1.82 cvs 3444: else if (!strncasecmp (cssRule, "right", 5))
1.59 cvs 3445: {
1.184 vatton 3446: page.typed_data.unit = UNIT_REL;
3447: page.typed_data.value = PageRight;
1.59 cvs 3448: }
1.82 cvs 3449: else if (!strncasecmp (cssRule, "inherit", 7))
1.59 cvs 3450: {
1.184 vatton 3451: /*page.typed_data.unit = UNIT_REL;*/
3452: page.typed_data.value = PageInherit;
1.59 cvs 3453: }
3454: cssRule = SkipWord (cssRule);
3455: /* install the new presentation */
1.184 vatton 3456: if (page.typed_data.unit == UNIT_REL &&
3457: page.typed_data.value == PageAlways && DoApply)
1.117 vatton 3458: {
3459: /* check if it's an important rule */
3460: if (tsch)
3461: cssRule = CheckImportantRule (cssRule, context);
3462: TtaSetStylePresentation (PRPageBefore, element, tsch, context, page);
3463: }
1.59 cvs 3464: return (cssRule);
3465: }
3466:
3467: /*----------------------------------------------------------------------
1.60 cvs 3468: ParseCSSPageBreakAfter: parse a CSS page-break-after attribute
1.59 cvs 3469: ----------------------------------------------------------------------*/
1.79 cvs 3470: static char *ParseCSSPageBreakAfter (Element element, PSchema tsch,
3471: PresentationContext context,
3472: char *cssRule, CSSInfoPtr css,
3473: ThotBool isHTML)
1.59 cvs 3474: {
3475: PresentationValue page;
3476:
1.184 vatton 3477: page.typed_data.unit = UNIT_INVALID;
1.59 cvs 3478: page.typed_data.real = FALSE;
1.82 cvs 3479: cssRule = SkipBlanksAndComments (cssRule);
3480: if (!strncasecmp (cssRule, "auto", 4))
1.184 vatton 3481: page.typed_data.value = PageAuto;
1.82 cvs 3482: else if (!strncasecmp (cssRule, "always", 6))
1.59 cvs 3483: {
1.184 vatton 3484: page.typed_data.unit = UNIT_REL;
3485: page.typed_data.value = PageAlways;
1.59 cvs 3486: }
1.82 cvs 3487: else if (!strncasecmp (cssRule, "avoid", 5))
1.59 cvs 3488: {
1.184 vatton 3489: page.typed_data.unit = UNIT_REL;
3490: page.typed_data.value = PageAvoid;
1.59 cvs 3491: }
1.82 cvs 3492: else if (!strncasecmp (cssRule, "left", 4))
1.59 cvs 3493: {
1.184 vatton 3494: page.typed_data.unit = UNIT_REL;
3495: page.typed_data.value = PageLeft;
1.59 cvs 3496: }
1.82 cvs 3497: else if (!strncasecmp (cssRule, "right", 5))
1.59 cvs 3498: {
1.184 vatton 3499: page.typed_data.unit = UNIT_REL;
3500: page.typed_data.value = PageRight;
1.59 cvs 3501: }
1.82 cvs 3502: else if (!strncasecmp (cssRule, "inherit", 7))
1.59 cvs 3503: {
1.184 vatton 3504: /*page.typed_data.unit = UNIT_REL;*/
3505: page.typed_data.value = PageInherit;
1.59 cvs 3506: }
3507: cssRule = SkipWord (cssRule);
3508: /* install the new presentation */
1.184 vatton 3509: /*if (page.typed_data.unit == UNIT_REL && DoApply)
1.117 vatton 3510: {
3511: if (tsch)
3512: cssRule = CheckImportantRule (cssRule, context);
3513: TtaSetStylePresentation (PRPageAfter, element, tsch, context, page);
3514: }*/
1.59 cvs 3515: return (cssRule);
3516: }
3517:
3518: /*----------------------------------------------------------------------
1.60 cvs 3519: ParseCSSPageBreakInside: parse a CSS page-break-inside attribute
1.59 cvs 3520: ----------------------------------------------------------------------*/
1.79 cvs 3521: static char *ParseCSSPageBreakInside (Element element, PSchema tsch,
3522: PresentationContext context,
3523: char *cssRule, CSSInfoPtr css,
3524: ThotBool isHTML)
1.59 cvs 3525: {
3526: PresentationValue page;
3527:
1.184 vatton 3528: page.typed_data.unit = UNIT_INVALID;
1.59 cvs 3529: page.typed_data.real = FALSE;
1.82 cvs 3530: cssRule = SkipBlanksAndComments (cssRule);
3531: if (!strncasecmp (cssRule, "auto", 4))
1.59 cvs 3532: {
1.184 vatton 3533: /*page.typed_data.unit = UNIT_REL;*/
3534: page.typed_data.value = PageAuto;
1.59 cvs 3535: }
1.82 cvs 3536: else if (!strncasecmp (cssRule, "avoid", 5))
1.59 cvs 3537: {
1.184 vatton 3538: page.typed_data.unit = UNIT_REL;
3539: page.typed_data.value = PageAvoid;
1.59 cvs 3540: }
1.82 cvs 3541: else if (!strncasecmp (cssRule, "inherit", 7))
1.59 cvs 3542: {
1.184 vatton 3543: /*page.typed_data.unit = UNIT_REL;*/
3544: page.typed_data.value = PageInherit;
1.59 cvs 3545: }
3546: cssRule = SkipWord (cssRule);
3547: /* install the new presentation */
1.184 vatton 3548: /*if (page.typed_data.unit == UNIT_REL &&
3549: page.typed_data.value == PageAvoid && DoApply)
1.117 vatton 3550: {
3551: if (tsch)
3552: cssRule = CheckImportantRule (cssRule, context);
3553: TtaSetStylePresentation (PRPageInside, element, tsch, context, page);
3554: }*/
1.59 cvs 3555: return (cssRule);
3556: }
1.18 cvs 3557:
3558:
1.60 cvs 3559: /*----------------------------------------------------------------------
1.117 vatton 3560: ParseSVGStrokeWidth: parse a SVG stroke-width property value.
1.60 cvs 3561: ----------------------------------------------------------------------*/
1.79 cvs 3562: static char *ParseSVGStrokeWidth (Element element, PSchema tsch,
3563: PresentationContext context, char *cssRule,
3564: CSSInfoPtr css, ThotBool isHTML)
1.60 cvs 3565: {
3566: PresentationValue width;
3567:
1.82 cvs 3568: cssRule = SkipBlanksAndComments (cssRule);
1.60 cvs 3569: width.typed_data.value = 0;
1.184 vatton 3570: width.typed_data.unit = UNIT_INVALID;
1.60 cvs 3571: width.typed_data.real = FALSE;
1.110 vatton 3572: if (isdigit (*cssRule) || *cssRule == '.')
1.166 vatton 3573: {
1.60 cvs 3574: cssRule = ParseCSSUnit (cssRule, &width);
1.184 vatton 3575: if (width.typed_data.unit == UNIT_BOX)
3576: width.typed_data.unit = UNIT_PX;
1.166 vatton 3577: }
1.184 vatton 3578: if (width.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 3579: {
3580: /* check if it's an important rule */
3581: if (tsch)
3582: cssRule = CheckImportantRule (cssRule, context);
3583: TtaSetStylePresentation (PRLineWeight, element, tsch, context, width);
3584: width.typed_data.value = 1;
1.184 vatton 3585: width.typed_data.unit = UNIT_REL;
1.117 vatton 3586: }
1.60 cvs 3587: return (cssRule);
3588: }
3589:
1.18 cvs 3590: /************************************************************************
3591: * *
3592: * FUNCTIONS STYLE DECLARATIONS *
3593: * *
3594: ************************************************************************/
3595: /*
1.59 cvs 3596: * NOTE: Long attribute name MUST be placed before shortened ones !
1.18 cvs 3597: * e.g. "FONT-SIZE" must be placed before "FONT"
3598: */
3599: static CSSProperty CSSProperties[] =
3600: {
1.82 cvs 3601: {"font-family", ParseCSSFontFamily},
3602: {"font-style", ParseCSSFontStyle},
3603: {"font-variant", ParseCSSFontVariant},
3604: {"font-weight", ParseCSSFontWeight},
3605: {"font-size", ParseCSSFontSize},
3606: {"font", ParseCSSFont},
3607:
3608: {"color", ParseCSSForeground},
3609: {"background-color", ParseCSSBackgroundColor},
3610: {"background-image", ParseCSSBackgroundImage},
3611: {"background-repeat", ParseCSSBackgroundRepeat},
3612: {"background-attachment", ParseCSSBackgroundAttachment},
3613: {"background-position", ParseCSSBackgroundPosition},
3614: {"background", ParseCSSBackground},
3615:
3616: {"word-spacing", ParseCSSWordSpacing},
3617: {"letter-spacing", ParseCSSLetterSpacing},
3618: {"text-decoration", ParseCSSTextDecoration},
3619: {"vertical-align", ParseCSSVerticalAlign},
3620: {"text-transform", ParseCSSTextTransform},
3621: {"text-align", ParseCSSTextAlign},
3622: {"text-indent", ParseCSSTextIndent},
1.162 quint 3623: {"line-height", ParseCSSLineHeight},
1.82 cvs 3624:
1.112 quint 3625: {"direction", ParseCSSDirection},
1.113 quint 3626: {"unicode-bidi", ParseCSSUnicodeBidi},
1.112 quint 3627:
1.82 cvs 3628: {"margin-top", ParseCSSMarginTop},
3629: {"margin-right", ParseCSSMarginRight},
3630: {"margin-bottom", ParseCSSMarginBottom},
3631: {"margin-left", ParseCSSMarginLeft},
3632: {"margin", ParseCSSMargin},
3633:
3634: {"padding-top", ParseCSSPaddingTop},
3635: {"padding-right", ParseCSSPaddingRight},
3636: {"padding-bottom", ParseCSSPaddingBottom},
3637: {"padding-left", ParseCSSPaddingLeft},
3638: {"padding", ParseCSSPadding},
3639:
3640: {"border-top-width", ParseCSSBorderTopWidth},
3641: {"border-right-width", ParseCSSBorderRightWidth},
3642: {"border-bottom-width", ParseCSSBorderBottomWidth},
3643: {"border-left-width", ParseCSSBorderLeftWidth},
3644: {"border-width", ParseCSSBorderWidth},
3645: {"border-top-color", ParseCSSBorderColorTop},
3646: {"border-right-color", ParseCSSBorderColorRight},
3647: {"border-bottom-color", ParseCSSBorderColorBottom},
3648: {"border-left-color", ParseCSSBorderColorLeft},
3649: {"border-color", ParseCSSBorderColor},
3650: {"border-top-style", ParseCSSBorderStyleTop},
3651: {"border-right-style", ParseCSSBorderStyleRight},
3652: {"border-bottom-style", ParseCSSBorderStyleBottom},
3653: {"border-left-style", ParseCSSBorderStyleLeft},
3654: {"border-style", ParseCSSBorderStyle},
3655: {"border-top", ParseCSSBorderTop},
3656: {"border-right", ParseCSSBorderRight},
3657: {"border-bottom", ParseCSSBorderBottom},
3658: {"border-left", ParseCSSBorderLeft},
3659: {"border", ParseCSSBorder},
3660:
3661: {"width", ParseCSSWidth},
3662: {"height", ParseCSSHeight},
3663: {"float", ParseCSSFloat},
3664: {"clear", ParseCSSClear},
1.184 vatton 3665: {"content", ParseCSSContent},
1.82 cvs 3666:
3667: {"display", ParseCSSDisplay},
3668: {"white-space", ParseCSSWhiteSpace},
3669:
3670: {"list-style-type", ParseCSSListStyleType},
3671: {"list-style-image", ParseCSSListStyleImage},
3672: {"list-style-position", ParseCSSListStylePosition},
3673: {"list-style", ParseCSSListStyle},
3674:
3675: {"page-break-before", ParseCSSPageBreakBefore},
3676: {"page-break-after", ParseCSSPageBreakAfter},
3677: {"page-break-inside", ParseCSSPageBreakInside},
1.60 cvs 3678:
3679: /* SVG extensions */
1.170 cheyroul 3680: {"stroke-opacity", ParseSVGStrokeOpacity},
1.82 cvs 3681: {"stroke-width", ParseSVGStrokeWidth},
3682: {"stroke", ParseSVGStroke},
1.170 cheyroul 3683:
3684: {"fill-opacity", ParseSVGFillOpacity},
1.155 cheyroul 3685: {"fill", ParseSVGFill},
1.170 cheyroul 3686:
1.155 cheyroul 3687: {"opacity", ParseSVGOpacity}
1.18 cvs 3688: };
1.155 cheyroul 3689:
1.18 cvs 3690: #define NB_CSSSTYLEATTRIBUTE (sizeof(CSSProperties) / sizeof(CSSProperty))
3691:
3692: /*----------------------------------------------------------------------
1.59 cvs 3693: ParseCSSRule: parse a CSS Style string
1.18 cvs 3694: we expect the input string describing the style to be of the
1.59 cvs 3695: form: PRORPERTY: DESCRIPTION [ ; PROPERTY: DESCRIPTION ] *
1.18 cvs 3696: but tolerate incorrect or incomplete input
3697: ----------------------------------------------------------------------*/
1.79 cvs 3698: static void ParseCSSRule (Element element, PSchema tsch,
3699: PresentationContext context, char *cssRule,
3700: CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 3701: {
1.34 cvs 3702: DisplayMode dispMode;
1.79 cvs 3703: char *p = NULL;
1.18 cvs 3704: int lg;
1.34 cvs 3705: unsigned int i;
1.76 cvs 3706: ThotBool found;
1.18 cvs 3707:
1.34 cvs 3708: /* avoid too many redisplay */
3709: dispMode = TtaGetDisplayMode (context->doc);
3710: if (dispMode == DisplayImmediately)
3711: TtaSetDisplayMode (context->doc, DeferredDisplay);
3712:
1.82 cvs 3713: while (*cssRule != EOS)
1.18 cvs 3714: {
1.82 cvs 3715: cssRule = SkipBlanksAndComments (cssRule);
1.153 vatton 3716: if (*cssRule < 0x41 || *cssRule > 0x7A ||
1.133 vatton 3717: (*cssRule > 0x5A && *cssRule < 0x60))
1.153 vatton 3718: cssRule++;
3719: else
1.89 cvs 3720: {
1.153 vatton 3721: found = FALSE;
3722: /* look for the type of property */
3723: for (i = 0; i < NB_CSSSTYLEATTRIBUTE && !found; i++)
1.18 cvs 3724: {
1.153 vatton 3725: lg = strlen (CSSProperties[i].name);
3726: if (!strncasecmp (cssRule, CSSProperties[i].name, lg))
3727: {
3728: p = cssRule + lg;
3729: found = TRUE;
3730: i--;
3731: }
1.18 cvs 3732: }
1.153 vatton 3733: if (i == NB_CSSSTYLEATTRIBUTE)
3734: cssRule = SkipProperty (cssRule);
3735: else
1.18 cvs 3736: {
1.153 vatton 3737: /* update index and skip the ":" indicator if present */
1.86 cvs 3738: p = SkipBlanksAndComments (p);
1.153 vatton 3739: if (*p == ':')
1.61 cvs 3740: {
1.153 vatton 3741: p++;
3742: p = SkipBlanksAndComments (p);
3743: /* try to parse the value associated with this property */
3744: if (CSSProperties[i].parsing_function != NULL)
3745: {
3746: p = CSSProperties[i].parsing_function (element, tsch, context,
3747: p, css, isHTML);
3748: /* update index and skip the ";" separator if present */
3749: cssRule = p;
3750: }
1.61 cvs 3751: }
1.153 vatton 3752: else
3753: cssRule = SkipProperty (cssRule);
1.18 cvs 3754: }
3755: }
3756: /* next property */
1.82 cvs 3757: cssRule = SkipBlanksAndComments (cssRule);
1.89 cvs 3758: if (*cssRule == '}')
3759: {
3760: cssRule++;
1.168 vatton 3761: CSSPrintError ("Invalid character", "}");
1.89 cvs 3762: cssRule = SkipBlanksAndComments (cssRule);
3763: }
1.155 cheyroul 3764: if (*cssRule == ',' ||
3765: *cssRule == ';')
1.18 cvs 3766: {
3767: cssRule++;
1.82 cvs 3768: cssRule = SkipBlanksAndComments (cssRule);
1.18 cvs 3769: }
3770: }
1.34 cvs 3771:
3772: /* restore the display mode */
3773: if (dispMode == DisplayImmediately)
3774: TtaSetDisplayMode (context->doc, dispMode);
1.18 cvs 3775: }
1.1 cvs 3776:
1.111 cvs 3777: /*----------------------------------------------------------------------
3778: AddBorderStyleValue
3779: -----------------------------------------------------------------------*/
3780: static void AddBorderStyleValue (char *buffer, int value)
3781: {
3782: switch (value)
3783: {
1.184 vatton 3784: case BorderStyleNone:
1.111 cvs 3785: strcat (buffer, "none");
3786: break;
1.184 vatton 3787: case BorderStyleHidden:
1.111 cvs 3788: strcat (buffer, "hidden");
3789: break;
1.184 vatton 3790: case BorderStyleDotted:
1.111 cvs 3791: strcat (buffer, "dotted");
3792: break;
1.184 vatton 3793: case BorderStyleDashed:
1.111 cvs 3794: strcat (buffer, "dashed");
3795: break;
1.184 vatton 3796: case BorderStyleSolid:
1.111 cvs 3797: strcat (buffer, "solid");
3798: break;
1.184 vatton 3799: case BorderStyleDouble:
1.111 cvs 3800: strcat (buffer, "double");
3801: break;
1.184 vatton 3802: case BorderStyleGroove:
1.111 cvs 3803: strcat (buffer, "groove");
3804: break;
1.184 vatton 3805: case BorderStyleRidge:
1.111 cvs 3806: strcat (buffer, "ridge");
3807: break;
1.184 vatton 3808: case BorderStyleInset:
1.111 cvs 3809: strcat (buffer, "inset");
3810: break;
1.184 vatton 3811: case BorderStyleOutset:
1.111 cvs 3812: strcat (buffer, "outset");
3813: break;
3814: }
3815: }
1.1 cvs 3816:
3817: /*----------------------------------------------------------------------
1.59 cvs 3818: PToCss: translate a PresentationSetting to the
1.18 cvs 3819: equivalent CSS string, and add it to the buffer given as the
1.67 cvs 3820: argument. It is used when extracting the CSS string from actual
3821: presentation.
3822: el is the element for which the style rule is generated
1.18 cvs 3823:
3824: All the possible values returned by the presentation drivers are
3825: described in thotlib/include/presentation.h
3826: -----------------------------------------------------------------------*/
1.79 cvs 3827: void PToCss (PresentationSetting settings, char *buffer, int len, Element el)
1.1 cvs 3828: {
1.76 cvs 3829: ElementType elType;
1.18 cvs 3830: float fval = 0;
3831: unsigned short red, green, blue;
3832: int add_unit = 0;
3833: unsigned int unit, i;
3834: ThotBool real = FALSE;
3835:
1.82 cvs 3836: buffer[0] = EOS;
1.18 cvs 3837: if (len < 40)
3838: return;
3839:
3840: unit = settings->value.typed_data.unit;
3841: if (settings->value.typed_data.real)
3842: {
3843: real = TRUE;
3844: fval = (float) settings->value.typed_data.value;
3845: fval /= 1000;
3846: }
1.1 cvs 3847:
1.18 cvs 3848: switch (settings->type)
1.1 cvs 3849: {
1.18 cvs 3850: case PRVisibility:
3851: break;
1.111 cvs 3852: case PRHeight:
3853: if (real)
3854: sprintf (buffer, "height: %g", fval);
3855: else
3856: sprintf (buffer, "height: %d", settings->value.typed_data.value);
3857: add_unit = 1;
3858: break;
3859: case PRWidth:
3860: if (real)
3861: sprintf (buffer, "width: %g", fval);
3862: else
3863: sprintf (buffer, "width: %d", settings->value.typed_data.value);
3864: add_unit = 1;
3865: break;
3866: case PRMarginTop:
3867: if (real)
3868: sprintf (buffer, "margin-top: %g", fval);
3869: else
3870: sprintf (buffer, "margin-top: %d",settings->value.typed_data.value);
3871: add_unit = 1;
3872: break;
3873: case PRMarginBottom:
3874: if (real)
3875: sprintf (buffer, "margin-bottom: %g", fval);
3876: else
3877: sprintf (buffer, "margin-bottom: %d",
3878: settings->value.typed_data.value);
3879: add_unit = 1;
3880: break;
3881: case PRMarginLeft:
3882: if (real)
3883: sprintf (buffer, "margin-left: %g", fval);
3884: else
1.164 quint 3885: sprintf (buffer, "margin-left: %d", settings->value.typed_data.value);
1.111 cvs 3886: add_unit = 1;
3887: break;
3888: case PRMarginRight:
3889: if (real)
3890: sprintf (buffer, "margin-right: %g", fval);
3891: else
1.164 quint 3892: sprintf (buffer, "margin-right: %d", settings->value.typed_data.value);
1.111 cvs 3893: add_unit = 1;
3894: break;
3895: case PRPaddingTop:
3896: if (real)
3897: sprintf (buffer, "padding-top: %g", fval);
3898: else
1.164 quint 3899: sprintf (buffer, "padding-top: %d", settings->value.typed_data.value);
1.111 cvs 3900: add_unit = 1;
3901: break;
3902: case PRPaddingBottom:
3903: if (real)
3904: sprintf (buffer, "padding-bottom: %g", fval);
3905: else
3906: sprintf (buffer, "padding-bottom: %d",
3907: settings->value.typed_data.value);
3908: add_unit = 1;
3909: break;
3910: case PRPaddingLeft:
3911: if (real)
3912: sprintf (buffer, "padding-left: %g", fval);
3913: else
1.164 quint 3914: sprintf (buffer, "padding-left: %d", settings->value.typed_data.value);
1.111 cvs 3915: add_unit = 1;
3916: break;
3917: case PRPaddingRight:
3918: if (real)
3919: sprintf (buffer, "padding-right: %g", fval);
3920: else
3921: sprintf (buffer, "padding-right: %d",
3922: settings->value.typed_data.value);
3923: add_unit = 1;
3924: break;
3925: case PRBorderTopWidth:
3926: if (real)
3927: sprintf (buffer, "border-top-width: %g", fval);
3928: else
3929: sprintf (buffer, "border-top-width: %d",
3930: settings->value.typed_data.value);
3931: add_unit = 1;
3932: break;
3933: case PRBorderBottomWidth:
3934: if (real)
3935: sprintf (buffer, "border-bottom-width: %g", fval);
3936: else
3937: sprintf (buffer, "border-bottom-width: %d",
3938: settings->value.typed_data.value);
3939: add_unit = 1;
3940: break;
3941: case PRBorderLeftWidth:
3942: if (real)
3943: sprintf (buffer, "border-left-width: %g", fval);
3944: else
3945: sprintf (buffer, "border-left-width: %d",
3946: settings->value.typed_data.value);
3947: add_unit = 1;
3948: break;
3949: case PRBorderRightWidth:
3950: if (real)
3951: sprintf (buffer, "border-right-width: %g", fval);
3952: else
3953: sprintf (buffer, "border-right-width: %d",
3954: settings->value.typed_data.value);
3955: add_unit = 1;
3956: break;
3957: case PRBorderTopColor:
3958: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
3959: elType = TtaGetElementType(el);
3960: sprintf (buffer, "border-top-color: #%02X%02X%02X", red, green, blue);
3961: break;
3962: case PRBorderRightColor:
3963: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
3964: elType = TtaGetElementType(el);
3965: sprintf (buffer, "border-right-color: #%02X%02X%02X", red, green, blue);
3966: break;
3967: case PRBorderBottomColor:
3968: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
3969: elType = TtaGetElementType(el);
3970: sprintf (buffer, "border-bottom-color: #%02X%02X%02X", red, green, blue);
1.18 cvs 3971: break;
1.111 cvs 3972: case PRBorderLeftColor:
3973: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
3974: elType = TtaGetElementType(el);
3975: sprintf (buffer, "border-left-color: #%02X%02X%02X", red, green, blue);
1.20 cvs 3976: break;
1.111 cvs 3977: case PRBorderTopStyle:
3978: strcpy (buffer, "border-top-style: ");
3979: AddBorderStyleValue (buffer, settings->value.typed_data.value);
3980: break;
3981: case PRBorderRightStyle:
3982: strcpy (buffer, "border-right-style: ");
3983: AddBorderStyleValue (buffer, settings->value.typed_data.value);
3984: break;
3985: case PRBorderBottomStyle:
3986: strcpy (buffer, "border-bottom-style: ");
3987: AddBorderStyleValue (buffer, settings->value.typed_data.value);
3988: break;
3989: case PRBorderLeftStyle:
3990: strcpy (buffer, "border-left-style: ");
3991: AddBorderStyleValue (buffer, settings->value.typed_data.value);
1.18 cvs 3992: break;
3993: case PRSize:
1.184 vatton 3994: if (unit == UNIT_REL)
1.18 cvs 3995: {
3996: if (real)
3997: {
1.82 cvs 3998: sprintf (buffer, "font-size: %g", fval);
1.18 cvs 3999: add_unit = 1;
4000: }
4001: else
4002: switch (settings->value.typed_data.value)
4003: {
4004: case 1:
1.82 cvs 4005: strcpy (buffer, "font-size: xx-small");
1.18 cvs 4006: break;
4007: case 2:
1.82 cvs 4008: strcpy (buffer, "font-size: x-small");
1.18 cvs 4009: break;
4010: case 3:
1.82 cvs 4011: strcpy (buffer, "font-size: small");
1.18 cvs 4012: break;
4013: case 4:
1.82 cvs 4014: strcpy (buffer, "font-size: medium");
1.18 cvs 4015: break;
4016: case 5:
1.82 cvs 4017: strcpy (buffer, "font-size: large");
1.18 cvs 4018: break;
4019: case 6:
1.82 cvs 4020: strcpy (buffer, "font-size: x-large");
1.18 cvs 4021: break;
4022: case 7:
4023: case 8:
4024: case 9:
4025: case 10:
4026: case 11:
4027: case 12:
1.82 cvs 4028: strcpy (buffer, "font-size: xx-large");
1.18 cvs 4029: break;
4030: }
4031: }
4032: else
4033: {
4034: if (real)
1.82 cvs 4035: sprintf (buffer, "font-size: %g", fval);
1.18 cvs 4036: else
1.82 cvs 4037: sprintf (buffer, "font-size: %d",
1.67 cvs 4038: settings->value.typed_data.value);
1.18 cvs 4039: add_unit = 1;
4040: }
4041: break;
1.111 cvs 4042: case PRStyle:
4043: switch (settings->value.typed_data.value)
4044: {
1.184 vatton 4045: case StyleRoman:
1.111 cvs 4046: strcpy (buffer, "font-style: normal");
4047: break;
1.184 vatton 4048: case StyleItalics:
1.111 cvs 4049: strcpy (buffer, "font-style: italic");
4050: break;
1.184 vatton 4051: case StyleOblique:
1.111 cvs 4052: strcpy (buffer, "font-style: oblique");
4053: break;
4054: }
4055: break;
4056: case PRWeight:
4057: switch (settings->value.typed_data.value)
4058: {
1.184 vatton 4059: case WeightBold:
1.111 cvs 4060: strcpy (buffer, "font-weight: bold");
4061: break;
1.184 vatton 4062: case WeightNormal:
1.111 cvs 4063: strcpy (buffer, "font-weight: normal");
4064: break;
4065: }
4066: break;
4067: case PRFont:
4068: switch (settings->value.typed_data.value)
4069: {
1.184 vatton 4070: case FontHelvetica:
1.111 cvs 4071: strcpy (buffer, "font-family: helvetica");
4072: break;
1.184 vatton 4073: case FontTimes:
1.111 cvs 4074: strcpy (buffer, "font-family: times");
4075: break;
1.184 vatton 4076: case FontCourier:
1.111 cvs 4077: strcpy (buffer, "font-family: courier");
4078: break;
4079: }
4080: break;
1.18 cvs 4081: case PRUnderline:
4082: switch (settings->value.typed_data.value)
4083: {
1.184 vatton 4084: case Underline:
1.82 cvs 4085: strcpy (buffer, "text-decoration: underline");
1.18 cvs 4086: break;
1.184 vatton 4087: case Overline:
1.82 cvs 4088: strcpy (buffer, "text-decoration: overline");
1.18 cvs 4089: break;
1.184 vatton 4090: case CrossOut:
1.82 cvs 4091: strcpy (buffer, "text-decoration: line-through");
1.18 cvs 4092: break;
4093: }
4094: break;
1.111 cvs 4095: case PRThickness:
4096: break;
1.18 cvs 4097: case PRIndent:
4098: if (real)
1.82 cvs 4099: sprintf (buffer, "text-indent: %g", fval);
1.18 cvs 4100: else
1.82 cvs 4101: sprintf (buffer, "text-indent: %d",
1.67 cvs 4102: settings->value.typed_data.value);
1.18 cvs 4103: add_unit = 1;
4104: break;
4105: case PRLineSpacing:
4106: if (real)
1.82 cvs 4107: sprintf (buffer, "line-height: %g", fval);
1.1 cvs 4108: else
1.82 cvs 4109: sprintf (buffer, "line-height: %d",
1.67 cvs 4110: settings->value.typed_data.value);
1.18 cvs 4111: add_unit = 1;
4112: break;
1.111 cvs 4113: case PRDepth:
4114: break;
1.18 cvs 4115: case PRAdjust:
4116: switch (settings->value.typed_data.value)
1.1 cvs 4117: {
1.184 vatton 4118: case AdjustLeft:
1.82 cvs 4119: strcpy (buffer, "text-align: left");
1.18 cvs 4120: break;
1.184 vatton 4121: case AdjustRight:
1.82 cvs 4122: strcpy (buffer, "text-align: right");
1.18 cvs 4123: break;
1.184 vatton 4124: case Centered:
1.82 cvs 4125: strcpy (buffer, "text-align: center");
1.18 cvs 4126: break;
1.184 vatton 4127: case LeftWithDots:
1.82 cvs 4128: strcpy (buffer, "text-align: left");
1.81 cvs 4129: break;
1.184 vatton 4130: case Justify:
1.82 cvs 4131: strcpy (buffer, "text-align: justify");
1.112 quint 4132: break;
4133: }
4134: break;
4135: case PRDirection:
4136: switch (settings->value.typed_data.value)
4137: {
1.184 vatton 4138: case LeftToRight:
1.112 quint 4139: strcpy (buffer, "direction: ltr");
4140: break;
1.184 vatton 4141: case RightToLeft:
1.112 quint 4142: strcpy (buffer, "direction: rtl");
1.113 quint 4143: break;
4144: }
4145: break;
4146: case PRUnicodeBidi:
4147: switch (settings->value.typed_data.value)
4148: {
1.184 vatton 4149: case Normal:
1.113 quint 4150: strcpy (buffer, "unicode-bidi: normal");
4151: break;
1.184 vatton 4152: case Embed:
1.113 quint 4153: strcpy (buffer, "unicode-bidi: embed");
4154: break;
1.184 vatton 4155: case Override:
1.113 quint 4156: strcpy (buffer, "unicode-bidi: bidi-override");
1.18 cvs 4157: break;
1.1 cvs 4158: }
1.18 cvs 4159: break;
1.111 cvs 4160: case PRLineStyle:
4161: break;
1.126 vatton 4162: case PRDisplay:
4163: switch (settings->value.typed_data.value)
4164: {
1.184 vatton 4165: case Inline:
1.126 vatton 4166: strcpy (buffer, "display: inline");
4167: break;
1.184 vatton 4168: case Block:
1.126 vatton 4169: strcpy (buffer, "display: block");
4170: break;
1.184 vatton 4171: case ListItem:
1.126 vatton 4172: strcpy (buffer, "display: list-item");
4173: break;
1.184 vatton 4174: case RunIn:
1.126 vatton 4175: strcpy (buffer, "display: runin");
4176: break;
1.184 vatton 4177: case Compact:
1.126 vatton 4178: strcpy (buffer, "display: compact");
4179: break;
1.184 vatton 4180: case Marker:
1.126 vatton 4181: strcpy (buffer, "display: marker");
4182: break;
4183: default:
4184: break;
4185: }
4186: break;
1.111 cvs 4187: case PRLineWeight:
4188: elType = TtaGetElementType(el);
4189: #ifdef _SVG
4190: if (!strcmp(TtaGetSSchemaName (elType.ElSSchema), "SVG"))
4191: #endif /* _SVG */
4192: {
4193: if (real)
4194: sprintf (buffer, "stroke-width: %g", fval);
4195: else
4196: sprintf (buffer, "stroke-width: %d",
4197: settings->value.typed_data.value);
4198: }
4199: add_unit = 1;
1.18 cvs 4200: break;
4201: case PRFillPattern:
4202: break;
4203: case PRBackground:
4204: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
1.76 cvs 4205: elType = TtaGetElementType(el);
1.100 vatton 4206: #ifdef _SVG
4207: if (strcmp(TtaGetSSchemaName (elType.ElSSchema), "SVG") == 0)
1.82 cvs 4208: sprintf (buffer, "fill: #%02X%02X%02X", red, green, blue);
1.67 cvs 4209: else
1.100 vatton 4210: #endif /* _SVG */
1.82 cvs 4211: sprintf (buffer, "background-color: #%02X%02X%02X", red, green,
1.67 cvs 4212: blue);
1.18 cvs 4213: break;
4214: case PRForeground:
4215: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
1.76 cvs 4216: elType = TtaGetElementType(el);
1.100 vatton 4217: #ifdef _SVG
4218: if (strcmp(TtaGetSSchemaName (elType.ElSSchema), "SVG") == 0)
1.82 cvs 4219: sprintf (buffer, "stroke: #%02X%02X%02X", red, green, blue);
1.67 cvs 4220: else
1.100 vatton 4221: #endif /* _SVG */
1.82 cvs 4222: sprintf (buffer, "color: #%02X%02X%02X", red, green, blue);
1.67 cvs 4223: break;
1.111 cvs 4224: case PRHyphenate:
1.18 cvs 4225: break;
1.111 cvs 4226: case PRVertOverflow:
1.18 cvs 4227: break;
1.111 cvs 4228: case PRHorizOverflow:
1.18 cvs 4229: break;
4230: case PRBackgroundPicture:
4231: if (settings->value.pointer != NULL)
1.82 cvs 4232: sprintf (buffer, "background-image: url(%s)",
1.67 cvs 4233: (char*)(settings->value.pointer));
1.1 cvs 4234: else
1.82 cvs 4235: sprintf (buffer, "background-image: none");
1.18 cvs 4236: break;
4237: case PRPictureMode:
4238: switch (settings->value.typed_data.value)
1.1 cvs 4239: {
1.184 vatton 4240: case REALSIZE:
1.82 cvs 4241: sprintf (buffer, "background-repeat: no-repeat");
1.18 cvs 4242: break;
1.184 vatton 4243: case REPEAT:
1.82 cvs 4244: sprintf (buffer, "background-repeat: repeat");
1.18 cvs 4245: break;
1.184 vatton 4246: case VREPEAT:
1.82 cvs 4247: sprintf (buffer, "background-repeat: repeat-y");
1.18 cvs 4248: break;
1.184 vatton 4249: case HREPEAT:
1.82 cvs 4250: sprintf (buffer, "background-repeat: repeat-x");
1.18 cvs 4251: break;
1.1 cvs 4252: }
1.18 cvs 4253: break;
4254: default:
4255: break;
1.1 cvs 4256: }
4257:
1.18 cvs 4258: if (add_unit)
1.1 cvs 4259: {
1.18 cvs 4260: /* add the unit string to the CSS string */
4261: for (i = 0; i < NB_UNITS; i++)
1.1 cvs 4262: {
1.18 cvs 4263: if (CSSUnitNames[i].unit == unit)
1.1 cvs 4264: {
1.82 cvs 4265: strcat (buffer, CSSUnitNames[i].sign);
1.18 cvs 4266: break;
1.1 cvs 4267: }
4268: }
4269: }
4270: }
4271:
4272: /*----------------------------------------------------------------------
1.59 cvs 4273: ParseHTMLSpecificStyle: parse and apply a CSS Style string.
1.18 cvs 4274: This function must be called when a specific style is applied to an
4275: element.
1.114 quint 4276: The parameter specificity is the specificity of the style, 0 if it is
4277: not really a CSS rule.
1.1 cvs 4278: ----------------------------------------------------------------------*/
1.79 cvs 4279: void ParseHTMLSpecificStyle (Element el, char *cssRule, Document doc,
1.114 quint 4280: int specificity, ThotBool destroy)
1.1 cvs 4281: {
4282: PresentationContext context;
4283: ElementType elType;
1.14 cvs 4284: ThotBool isHTML;
1.1 cvs 4285:
4286: /* A rule applying to BODY is really meant to address HTML */
4287: elType = TtaGetElementType (el);
1.89 cvs 4288:
1.86 cvs 4289: /* store the current line for eventually reported errors */
4290: LineNumber = TtaGetElementLineNumber (el);
1.89 cvs 4291: if (destroy)
4292: /* no reported errors */
4293: ParsedDoc = 0;
4294: else if (ParsedDoc != doc)
4295: {
4296: /* update the context for reported errors */
4297: ParsedDoc = doc;
4298: DocURL = DocumentURLs[doc];
4299: }
1.82 cvs 4300: isHTML = (strcmp (TtaGetSSchemaName (elType.ElSSchema), "HTML") == 0);
1.1 cvs 4301: /* create the context of the Specific presentation driver */
4302: context = TtaGetSpecificStyleContext (doc);
4303: if (context == NULL)
4304: return;
4305: context->type = elType.ElTypeNum;
1.114 quint 4306: context->cssSpecificity = specificity;
1.1 cvs 4307: context->destroy = destroy;
4308: /* Call the parser */
1.155 cheyroul 4309: ParseCSSRule (el, NULL,
4310: (PresentationContext) context,
4311: cssRule, NULL, isHTML);
1.1 cvs 4312: /* free the context */
4313: TtaFreeMemory(context);
4314: }
4315:
1.68 cvs 4316:
1.1 cvs 4317: /*----------------------------------------------------------------------
1.59 cvs 4318: ParseGenericSelector: Create a generic context for a given
1.1 cvs 4319: selector string. If the selector is made of multiple comma-
4320: separated selector items, it parses them one at a time and
4321: return the end of the selector string to be handled or NULL
4322: ----------------------------------------------------------------------*/
1.79 cvs 4323: static char *ParseGenericSelector (char *selector, char *cssRule,
4324: GenericContext ctxt, Document doc,
4325: CSSInfoPtr css)
4326: {
4327: ElementType elType;
4328: PSchema tsch;
1.119 vatton 4329: AttributeType attrType;
1.79 cvs 4330: char sel[MAX_ANCESTORS * 50];
1.118 vatton 4331: char *deb, *cur, c;
4332: char *schemaName, *mappedName;
1.79 cvs 4333: char *names[MAX_ANCESTORS];
4334: char *ids[MAX_ANCESTORS];
4335: char *classes[MAX_ANCESTORS];
4336: char *pseudoclasses[MAX_ANCESTORS];
4337: char *attrs[MAX_ANCESTORS];
4338: char *attrvals[MAX_ANCESTORS];
1.133 vatton 4339: AttrMatch attrmatch[MAX_ANCESTORS];
1.91 cvs 4340: int i, j, k, max;
1.125 vatton 4341: int att, maxAttr, kind;
1.118 vatton 4342: int specificity, xmlType;
1.79 cvs 4343: ThotBool isHTML;
1.183 vatton 4344: ThotBool level, quoted;
1.1 cvs 4345:
1.82 cvs 4346: sel[0] = EOS;
1.117 vatton 4347: specificity = 0;
1.1 cvs 4348: for (i = 0; i < MAX_ANCESTORS; i++)
4349: {
1.25 cvs 4350: names[i] = NULL;
4351: ids[i] = NULL;
4352: classes[i] = NULL;
4353: pseudoclasses[i] = NULL;
4354: attrs[i] = NULL;
4355: attrvals[i] = NULL;
1.133 vatton 4356: attrmatch[i] = Txtmatch;
1.25 cvs 4357: ctxt->name[i] = 0;
4358: ctxt->names_nb[i] = 0;
4359: ctxt->attrType[i] = 0;
1.129 vatton 4360: ctxt->attrLevel[i] = 0;
1.25 cvs 4361: ctxt->attrText[i] = NULL;
1.178 quint 4362: ctxt->attrMatch[i] = Txtmatch;
1.1 cvs 4363: }
1.25 cvs 4364: ctxt->box = 0;
4365: ctxt->type = 0;
1.114 quint 4366: /* the specificity of the rule depends on the selector */
4367: ctxt->cssSpecificity = 0;
1.25 cvs 4368:
1.82 cvs 4369: selector = SkipBlanksAndComments (selector);
1.27 cvs 4370: cur = &sel[0];
1.25 cvs 4371: max = 0; /* number of loops */
1.1 cvs 4372: while (1)
4373: {
1.85 cvs 4374: /* point to the following word in sel[] */
1.27 cvs 4375: deb = cur;
1.25 cvs 4376: /* copy an item of the selector into sel[] */
1.1 cvs 4377: /* put one word in the sel buffer */
1.82 cvs 4378: while (*selector != EOS && *selector != ',' &&
4379: *selector != '.' && *selector != ':' &&
1.118 vatton 4380: *selector != '#' && *selector != '[' &&
1.130 vatton 4381: *selector != '*' && *selector != '>' &&
1.118 vatton 4382: !TtaIsBlank (selector))
1.50 cvs 4383: *cur++ = *selector++;
1.82 cvs 4384: *cur++ = EOS; /* close the first string in sel[] */
4385: if (deb[0] != EOS)
1.117 vatton 4386: {
4387: names[0] = deb;
1.150 vatton 4388: if (!strcmp (names[0], "html"))
1.149 vatton 4389: /* give a greater priority to the backgoud color of html */
4390: specificity += 3;
4391: else
4392: specificity += 1;
1.117 vatton 4393: }
1.25 cvs 4394: else
1.27 cvs 4395: names[0] = NULL;
4396: classes[0] = NULL;
4397: pseudoclasses[0] = NULL;
4398: ids[0] = NULL;
4399: attrs[0] = NULL;
4400: attrvals[0] = NULL;
1.25 cvs 4401:
1.27 cvs 4402: /* now names[0] points to the beginning of the parsed item
1.25 cvs 4403: and cur to the next chain to be parsed */
1.129 vatton 4404: while (*selector == '.' || *selector == ':' ||
1.130 vatton 4405: *selector == '#' || *selector == '[' ||
1.183 vatton 4406: *selector == '*')
1.129 vatton 4407: {
1.85 cvs 4408: /* point to the following word in sel[] */
4409: deb = cur;
1.129 vatton 4410: if (*selector == '.')
4411: {
4412: selector++;
4413: while (*selector != EOS && *selector != ',' &&
4414: *selector != '.' && *selector != ':' &&
4415: !TtaIsBlank (selector))
4416: *cur++ = *selector++;
4417: /* close the word */
4418: *cur++ = EOS;
4419: /* point to the class in sel[] if it's valid name */
4420: if (deb[0] <= 64)
4421: {
1.168 vatton 4422: CSSPrintError ("Invalid class", deb);
1.116 vatton 4423: DoApply = FALSE;
1.129 vatton 4424: }
4425: else
4426: {
4427: classes[0] = deb;
1.178 quint 4428: /* a "class" attribute on an element may contain several
4429: words, one for each class it matches */
4430: attrmatch[0] = Txtword;
1.117 vatton 4431: specificity += 10;
1.129 vatton 4432: }
4433: }
4434: else if (*selector == ':')
4435: {
4436: selector++;
4437: while (*selector != EOS && *selector != ',' &&
4438: *selector != '.' && *selector != ':' &&
4439: !TtaIsBlank (selector))
4440: *cur++ = *selector++;
4441: /* close the word */
4442: *cur++ = EOS;
4443: /* point to the pseudoclass in sel[] if it's valid name */
4444: if (deb[0] <= 64)
4445: {
1.168 vatton 4446: CSSPrintError ("Invalid pseudoclass", deb);
1.129 vatton 4447: DoApply = FALSE;
4448: }
4449: else
4450: {
4451: if (!strcmp (deb, "first-letter") ||
4452: !strcmp (deb, "first-line") ||
4453: !strcmp (deb, "before") ||
4454: !strcmp (deb, "after"))
4455: /* not supported */
1.116 vatton 4456: DoApply = FALSE;
1.129 vatton 4457: else
4458: specificity += 10;
4459: pseudoclasses[0]= deb;
4460: }
4461: }
4462: else if (*selector == '#')
4463: {
4464: selector++;
4465: while (*selector != EOS && *selector != ',' &&
4466: *selector != '.' && *selector != ':' &&
4467: !TtaIsBlank (selector))
4468: *cur++ = *selector++;
4469: /* close the word */
4470: *cur++ = EOS;
4471: /* point to the attribute in sel[] if it's valid name */
4472: if (deb[0] <= 64)
4473: {
1.168 vatton 4474: CSSPrintError ("Invalid id", deb);
1.129 vatton 4475: DoApply = FALSE;
4476: }
4477: else
4478: {
4479: ids[0] = deb;
4480: specificity += 100;
4481: }
4482: }
4483: else if (*selector == '[')
4484: {
1.118 vatton 4485: selector++;
1.129 vatton 4486: while (*selector != EOS && *selector != ']' &&
1.131 vatton 4487: *selector != '=' && *selector != '~' &&
1.133 vatton 4488: *selector != '|' && *selector != '^' &&
4489: *selector != '!')
1.129 vatton 4490: *cur++ = *selector++;
1.133 vatton 4491: /* check matching */
4492: if (*selector == '~')
4493: {
4494: attrmatch[0] = Txtword;
4495: selector++;
4496: }
4497: else if (*selector == '|')
4498: {
4499: attrmatch[0] = Txtsubstring;
4500: selector++;
4501: }
4502: else
4503: attrmatch[0] = Txtmatch;
1.129 vatton 4504: /* close the word */
4505: *cur++ = EOS;
4506: /* point to the attribute in sel[] if it's valid name */
4507: if (deb[0] <= 64)
4508: {
1.168 vatton 4509: CSSPrintError ("Invalid attribute", deb);
1.129 vatton 4510: DoApply = FALSE;
4511: }
4512: else
4513: {
4514: attrs[0] = deb;
4515: specificity += 10;
4516: }
4517: if (*selector == '=')
4518: {
4519: /* look for a value "xxxx" */
4520: selector++;
4521: if (*selector != '"')
1.183 vatton 4522: quoted = FALSE;
1.129 vatton 4523: else
4524: {
1.183 vatton 4525: quoted = TRUE;
1.129 vatton 4526: /* we are now parsing the attribute value */
4527: selector++;
1.183 vatton 4528: }
4529: deb = cur;
4530: while ((quoted &&
4531: (*selector != '"' ||
4532: (*selector == '"' && selector[-1] == '\\'))) ||
4533: (!quoted && *selector != ']'))
4534: {
4535: if (*selector == EOS)
1.129 vatton 4536: {
1.183 vatton 4537: CSSPrintError ("Invalid attribute value", deb);
4538: DoApply = FALSE;
1.129 vatton 4539: }
1.183 vatton 4540: else
1.129 vatton 4541: {
1.183 vatton 4542: *cur++ = tolower (*selector);
1.129 vatton 4543: selector++;
4544: }
4545: }
1.183 vatton 4546: /* there is a value */
4547: if (quoted && *selector != '"')
4548: {
4549: selector++;
4550: quoted = FALSE;
4551: }
4552: if (*selector != ']')
4553: {
4554: CSSPrintError ("Invalid attribute value", deb);
4555: DoApply = FALSE;
4556: }
4557: else
4558: {
4559: *cur++ = EOS;
4560: attrvals[0] = deb;
4561: selector++;
4562: }
1.129 vatton 4563: }
4564: /* end of the attribute */
1.183 vatton 4565: else if (*selector != ']')
1.129 vatton 4566: {
1.133 vatton 4567: selector[1] = EOS;
1.183 vatton 4568: CSSPrintError ("Invalid attribute", selector);
1.133 vatton 4569: selector += 2;
1.129 vatton 4570: DoApply = FALSE;
4571: }
4572: else
4573: selector++;
1.130 vatton 4574: }
4575: else
4576: {
4577: /* not supported selector */
4578: while (*selector != EOS && *selector != ',' &&
4579: *selector != '.' && *selector != ':' &&
4580: !TtaIsBlank (selector))
4581: *cur++ = *selector++;
4582: /* close the word */
4583: *cur++ = EOS;
1.168 vatton 4584: CSSPrintError ("Not supported selector", deb);
1.130 vatton 4585: DoApply = FALSE;
1.129 vatton 4586: }
4587: }
1.1 cvs 4588:
1.82 cvs 4589: selector = SkipBlanksAndComments (selector);
1.25 cvs 4590: /* is it a multi-level selector? */
1.82 cvs 4591: if (*selector == EOS)
1.1 cvs 4592: /* end of the selector */
4593: break;
1.82 cvs 4594: else if (*selector == ',')
1.1 cvs 4595: {
4596: /* end of the current selector */
4597: selector++;
4598: break;
4599: }
1.25 cvs 4600: else
4601: {
1.143 vatton 4602: if (*selector == '>')
4603: {
4604: /* handle immediat parent as a simple parent */
4605: selector++;
4606: selector = SkipBlanksAndComments (selector);
4607: }
1.25 cvs 4608: /* shifts the list to make room for the new name */
4609: max++; /* a new level in ancestor tables */
4610: if (max == MAX_ANCESTORS)
4611: /* abort the CSS parsing */
4612: return (selector);
4613: for (i = max; i > 0; i--)
4614: {
4615: names[i] = names[i - 1];
4616: ids[i] = ids[i - 1];
4617: classes[i] = classes[i - 1];
1.133 vatton 4618: pseudoclasses[i] = pseudoclasses[i - 1];
1.25 cvs 4619: attrs[i] = attrs[i - 1];
4620: attrvals[i] = attrvals[i - 1];
1.133 vatton 4621: attrmatch[i] = attrmatch[i - 1];
1.25 cvs 4622: }
4623: }
1.1 cvs 4624: }
4625:
4626: /* Now set up the context block */
1.25 cvs 4627: i = 0;
4628: k = 0;
4629: j = 0;
1.35 cvs 4630: maxAttr = 0;
1.91 cvs 4631: /* default schema name */
1.119 vatton 4632: ctxt->schema = NULL;
1.122 vatton 4633: elType.ElSSchema = NULL;
4634: schemaName = TtaGetSSchemaName(TtaGetDocumentSSchema (doc));
1.119 vatton 4635: if (!strcmp (schemaName, "HTML"))
4636: xmlType = XHTML_TYPE;
4637: else if (!strcmp (schemaName, "MathML"))
4638: xmlType = MATH_TYPE;
4639: else if (!strcmp (schemaName, "SVG"))
4640: xmlType = SVG_TYPE;
4641: else if (!strcmp (schemaName, "XLink"))
4642: xmlType = XLINK_TYPE;
4643: else if (!strcmp (schemaName, "Annot"))
4644: xmlType = ANNOT_TYPE;
4645: else
4646: xmlType = XML_TYPE;
1.25 cvs 4647: while (i <= max)
4648: {
4649: if (names[i])
4650: {
1.118 vatton 4651: /* get the element type of this name in the current document */
4652: MapXMLElementType (xmlType, names[i], &elType, &mappedName, &c, &level, doc);
1.25 cvs 4653: if (i == 0)
4654: {
1.106 cvs 4655: if (elType.ElSSchema == NULL)
4656: {
1.119 vatton 4657: /* Search in the list of loaded schemas */
1.106 cvs 4658: TtaGetXmlElementType (names[i], &elType, NULL, doc);
1.119 vatton 4659: if (elType.ElSSchema)
4660: {
1.154 vatton 4661: /* the element type concerns an imported nature */
1.119 vatton 4662: schemaName = TtaGetSSchemaName(elType.ElSSchema);
4663: if (!strcmp (schemaName, "HTML"))
4664: xmlType = XHTML_TYPE;
4665: else if (!strcmp (schemaName, "MathML"))
4666: xmlType = MATH_TYPE;
4667: else if (!strcmp (schemaName, "SVG"))
4668: xmlType = SVG_TYPE;
4669: else if (!strcmp (schemaName, "XLink"))
4670: xmlType = XLINK_TYPE;
4671: else if (!strcmp (schemaName, "Annot"))
4672: xmlType = ANNOT_TYPE;
4673: else
4674: xmlType = XML_TYPE;
4675: }
1.118 vatton 4676: #ifdef XML_GENERIC
1.119 vatton 4677: else if (xmlType == XML_TYPE)
1.106 cvs 4678: {
4679: /* Creation of a new element type in the main schema */
4680: elType.ElSSchema = TtaGetDocumentSSchema (doc);
1.118 vatton 4681: TtaAppendXmlElement (names[i], &elType, &mappedName, doc);
1.106 cvs 4682: }
1.118 vatton 4683: #endif /* XML_GENERIC */
1.122 vatton 4684: else
4685: {
4686: if (xmlType != XHTML_TYPE)
4687: {
4688: MapXMLElementType (XHTML_TYPE, names[i], &elType,
4689: &mappedName, &c, &level, doc);
4690: if (elType.ElSSchema)
1.123 vatton 4691: elType.ElSSchema = GetXHTMLSSchema (doc);
1.122 vatton 4692: }
4693: if (elType.ElSSchema == NULL && xmlType != MATH_TYPE)
4694: {
4695: MapXMLElementType (MATH_TYPE, names[i], &elType,
4696: &mappedName, &c, &level, doc);
4697: if (elType.ElSSchema)
1.123 vatton 4698: elType.ElSSchema = GetMathMLSSchema (doc);
1.122 vatton 4699: }
4700: if (elType.ElSSchema == NULL && xmlType != SVG_TYPE)
4701: {
4702: MapXMLElementType (SVG_TYPE, names[i], &elType,
4703: &mappedName, &c, &level, doc);
4704: if (elType.ElSSchema)
1.123 vatton 4705: elType.ElSSchema = GetSVGSSchema (doc);
1.122 vatton 4706: }
4707: }
1.118 vatton 4708: }
1.119 vatton 4709:
1.118 vatton 4710: if (elType.ElSSchema == NULL)
4711: /* cannot apply these CSS rules */
4712: DoApply = FALSE;
4713: else
4714: {
4715: /* Store the element type */
4716: ctxt->type = elType.ElTypeNum;
4717: ctxt->name[0] = elType.ElTypeNum;
4718: ctxt->names_nb[0] = 0;
4719: ctxt->schema = elType.ElSSchema;
1.106 cvs 4720: }
1.25 cvs 4721: }
4722: else if (elType.ElTypeNum != 0)
4723: {
4724: /* look at the current context to see if the type is already
4725: stored */
1.121 vatton 4726: j = 1;
1.32 cvs 4727: while (j < k && ctxt->name[j] != elType.ElTypeNum)
1.25 cvs 4728: j++;
4729: if (j == k)
4730: {
4731: ctxt->name[j] = elType.ElTypeNum;
4732: if (j != 0)
1.121 vatton 4733: ctxt->names_nb[j] = 1;
1.25 cvs 4734: }
4735: else
4736: /* increment the number of ancestor levels */
4737: ctxt->names_nb[j]++;
4738: }
1.154 vatton 4739: #ifdef XML_GENERIC
4740: else if (xmlType == XML_TYPE)
4741: {
1.158 vatton 4742: TtaGetXmlElementType (names[i], &elType, NULL, doc);
4743: if (elType.ElTypeNum == 0)
4744: {
4745: /* Creation of a new element type in the main schema */
4746: elType.ElSSchema = TtaGetDocumentSSchema (doc);
4747: TtaAppendXmlElement (names[i], &elType, &mappedName, doc);
4748: }
1.154 vatton 4749: if (elType.ElTypeNum != 0)
4750: {
4751: /* look at the current context to see if the type is already
4752: stored */
4753: j = 1;
4754: while (j < k && ctxt->name[j] != elType.ElTypeNum)
4755: j++;
4756: if (j == k)
4757: {
4758: ctxt->name[j] = elType.ElTypeNum;
4759: if (j != 0)
4760: ctxt->names_nb[j] = 1;
4761: }
4762: else
4763: /* increment the number of ancestor levels */
4764: ctxt->names_nb[j]++;
4765: }
4766: }
4767: #endif /* XML_GENERIC */
1.25 cvs 4768: else
1.117 vatton 4769: j = k;
1.25 cvs 4770: }
1.117 vatton 4771: else
4772: j = k;
1.1 cvs 4773:
1.25 cvs 4774: /* store attributes information */
4775: if (classes[i])
4776: {
4777: ctxt->attrText[j] = classes[i];
1.119 vatton 4778: if (xmlType == SVG_TYPE)
1.100 vatton 4779: ctxt->attrType[j] = SVG_ATTR_class;
1.119 vatton 4780: else if (xmlType == MATH_TYPE)
1.91 cvs 4781: ctxt->attrType[j] = MathML_ATTR_class;
1.119 vatton 4782: else if (xmlType == XHTML_TYPE)
1.107 cvs 4783: ctxt->attrType[j] = HTML_ATTR_Class;
4784: else
1.119 vatton 4785: #ifdef XML_GENERIC
1.107 cvs 4786: ctxt->attrType[j] = XML_ATTR_class;
4787: #else /* XML_GENERIC */
1.91 cvs 4788: ctxt->attrType[j] = HTML_ATTR_Class;
1.107 cvs 4789: #endif /* XML_GENERIC */
1.157 vatton 4790: ctxt->attrMatch[j] = attrmatch[i];
1.79 cvs 4791: /* add a new entry */
1.80 cvs 4792: maxAttr = i + 1;
1.129 vatton 4793: /* update attrLevel */
4794: ctxt->attrLevel[j] = i;
4795: j++;
1.25 cvs 4796: }
1.79 cvs 4797: if (pseudoclasses[i])
1.25 cvs 4798: {
4799: ctxt->attrText[j] = pseudoclasses[i];
1.119 vatton 4800: if (xmlType == SVG_TYPE)
1.100 vatton 4801: ctxt->attrType[j] = SVG_ATTR_PseudoClass;
1.119 vatton 4802: else if (xmlType == MATH_TYPE)
1.91 cvs 4803: ctxt->attrType[j] = MathML_ATTR_PseudoClass;
1.119 vatton 4804: else if (xmlType == XHTML_TYPE)
1.107 cvs 4805: ctxt->attrType[j] = HTML_ATTR_PseudoClass;
4806: else
1.119 vatton 4807: #ifdef XML_GENERIC
1.107 cvs 4808: ctxt->attrType[j] = XML_ATTR_PseudoClass;
4809: #else /* XML_GENERIC */
1.91 cvs 4810: ctxt->attrType[j] = HTML_ATTR_PseudoClass;
1.107 cvs 4811: #endif /* XML_GENERIC */
1.157 vatton 4812: ctxt->attrMatch[j] = attrmatch[i];
1.79 cvs 4813: /* add a new entry */
1.80 cvs 4814: maxAttr = i + 1;
1.129 vatton 4815: /* update attrLevel */
4816: ctxt->attrLevel[j] = i;
4817: j++;
1.25 cvs 4818: }
1.79 cvs 4819: if (ids[i])
1.25 cvs 4820: {
4821: ctxt->attrText[j] = ids[i];
1.119 vatton 4822: if (xmlType == SVG_TYPE)
1.100 vatton 4823: ctxt->attrType[j] = SVG_ATTR_id;
1.119 vatton 4824: else if (xmlType == MATH_TYPE)
1.91 cvs 4825: ctxt->attrType[j] = MathML_ATTR_id;
1.119 vatton 4826: else if (xmlType == XHTML_TYPE)
1.107 cvs 4827: ctxt->attrType[j] = HTML_ATTR_ID;
4828: else
1.119 vatton 4829: #ifdef XML_GENERIC
1.107 cvs 4830: ctxt->attrType[j] = XML_ATTR_id;
4831: #else /* XML_GENERIC */
1.91 cvs 4832: ctxt->attrType[j] = HTML_ATTR_ID;
1.107 cvs 4833: #endif /* XML_GENERIC */
1.157 vatton 4834: ctxt->attrMatch[j] = attrmatch[i];
1.80 cvs 4835: /* add a new entry */
4836: maxAttr = i + 1;
1.129 vatton 4837: /* update attrLevel */
4838: ctxt->attrLevel[j] = i;
4839: j++;
1.25 cvs 4840: }
1.79 cvs 4841: if (attrs[i])
1.25 cvs 4842: {
1.125 vatton 4843: /* it's an attribute */
1.119 vatton 4844: MapXMLAttribute (xmlType, attrs[i], names[i], &level, doc, &att);
1.127 quint 4845: if (att == DummyAttribute && !strcmp (schemaName, "HTML"))
4846: /* it's the "type" attribute for an "input" element. In the tree
4847: it's represented by the element type, not by an attribute */
4848: att = 0;
1.119 vatton 4849: ctxt->attrType[j] = att;
1.133 vatton 4850: ctxt->attrMatch[j] = attrmatch[i];
1.125 vatton 4851: attrType.AttrSSchema = ctxt->schema;
4852: attrType.AttrTypeNum = att;
1.119 vatton 4853: if (i == 0 && att == 0 && ctxt->schema == NULL)
4854: {
1.125 vatton 4855: /* Not found -> search in the list of loaded schemas */
1.119 vatton 4856: attrType.AttrSSchema = NULL;
4857: TtaGetXmlAttributeType (attrs[i], &attrType, doc);
4858: ctxt->attrType[j] = attrType.AttrTypeNum;
4859: if (attrType.AttrSSchema)
1.125 vatton 4860: /* the element type concerns an imported nature */
4861: schemaName = TtaGetSSchemaName(attrType.AttrSSchema);
1.119 vatton 4862: #ifdef XML_GENERIC
4863: else if (xmlType == XML_TYPE)
4864: {
4865: /* The attribute is not yet present in the tree */
4866: /* Create a new global attribute */
4867: attrType.AttrSSchema = TtaGetDocumentSSchema (doc);
4868: TtaAppendXmlAttribute (attrs[i], &attrType, doc);
4869: }
4870: #endif /* XML_GENERIC */
4871:
4872: if (attrType.AttrSSchema == NULL)
4873: /* cannot apply these CSS rules */
4874: DoApply = FALSE;
1.136 quint 4875: else if (elType.ElSSchema)
4876: ctxt->schema = elType.ElSSchema;
1.119 vatton 4877: else
1.136 quint 4878: ctxt->schema = attrType.AttrSSchema;
1.119 vatton 4879: }
1.125 vatton 4880: /* check the attribute type */
4881: if (!strcmp (schemaName, "HTML"))
4882: xmlType = XHTML_TYPE;
4883: else if (!strcmp (schemaName, "MathML"))
4884: xmlType = MATH_TYPE;
4885: else if (!strcmp (schemaName, "SVG"))
4886: xmlType = SVG_TYPE;
4887: else if (!strcmp (schemaName, "XLink"))
4888: xmlType = XLINK_TYPE;
4889: else if (!strcmp (schemaName, "Annot"))
4890: xmlType = ANNOT_TYPE;
4891: else
4892: xmlType = XML_TYPE;
4893: kind = TtaGetAttributeKind (attrType);
4894: if (kind == 0 && attrvals[i])
4895: {
4896: /* enumerated value */
4897: MapXMLAttributeValue (xmlType, attrvals[i], attrType, &kind);
4898: /* store the attribute value */
4899: ctxt->attrText[j] = (char *) kind;
4900: }
4901: else
4902: ctxt->attrText[j] = attrvals[i];
1.80 cvs 4903: maxAttr = i + 1;
1.129 vatton 4904: /* update attrLevel */
4905: ctxt->attrLevel[j] = i;
4906: j++;
1.25 cvs 4907: }
4908: i++;
1.117 vatton 4909: /* add a new entry */
4910: k++;
1.129 vatton 4911: if (k < j)
4912: k = j;
1.119 vatton 4913: if (i == 1 && ctxt->schema == NULL)
4914: /* use the document schema */
4915: ctxt->schema = TtaGetDocumentSSchema (doc);
1.1 cvs 4916: }
1.117 vatton 4917: /* set the selector specificity */
4918: ctxt->cssSpecificity = specificity;
1.25 cvs 4919: /* sort the list of ancestors by name order */
4920: max = k;
4921: i = 1;
4922: while (i < max)
1.28 cvs 4923: {
4924: for (k = i + 1; k < max; k++)
4925: if (ctxt->name[i] > ctxt->name[k])
4926: {
4927: j = ctxt->name[i];
4928: ctxt->name[i] = ctxt->name[k];
4929: ctxt->name[k] = j;
4930: j = ctxt->names_nb[i];
4931: ctxt->names_nb[i] = ctxt->names_nb[k];
4932: ctxt->names_nb[k] = j;
4933: j = ctxt->attrType[i];
4934: ctxt->attrType[i] = ctxt->attrType[k];
4935: ctxt->attrType[k] = j;
4936: cur = ctxt->attrText[i];
4937: ctxt->attrText[i] = ctxt->attrText[k];
4938: ctxt->attrText[k] = cur;
4939: }
4940: i++;
4941: }
1.84 cvs 4942:
1.25 cvs 4943: /* Get the schema name of the main element */
1.119 vatton 4944: schemaName = TtaGetSSchemaName (ctxt->schema);
4945: isHTML = (strcmp (schemaName, "HTML") == 0);
4946: tsch = GetPExtension (doc, ctxt->schema, css);
4947: if (tsch && cssRule)
4948: ParseCSSRule (NULL, tsch, (PresentationContext) ctxt, cssRule, css, isHTML);
1.116 vatton 4949: /* future CSS rules should apply */
4950: DoApply = TRUE;
1.1 cvs 4951: return (selector);
4952: }
4953:
4954: /*----------------------------------------------------------------------
1.73 cvs 4955: ParseStyleDeclaration: parse a style declaration
4956: stored in the style element of a document
1.59 cvs 4957: We expect the style string to be of the form:
1.1 cvs 4958: [
4959: e.g: pinky, awful { color: pink, font-family: helvetica }
4960: ----------------------------------------------------------------------*/
1.79 cvs 4961: static void ParseStyleDeclaration (Element el, char *cssRule, Document doc,
4962: CSSInfoPtr css, ThotBool destroy)
1.1 cvs 4963: {
1.79 cvs 4964: GenericContext ctxt;
4965: char *decl_end;
4966: char *sel_end;
4967: char *selector;
1.1 cvs 4968:
4969: /* separate the selectors string */
1.82 cvs 4970: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 4971: decl_end = cssRule;
1.82 cvs 4972: while (*decl_end != EOS && *decl_end != '{')
1.1 cvs 4973: decl_end++;
1.82 cvs 4974: if (*decl_end == EOS)
1.86 cvs 4975: {
1.168 vatton 4976: CSSPrintError ("Invalid selector", cssRule);
1.86 cvs 4977: return;
4978: }
1.1 cvs 4979: /* verify and clean the selector string */
4980: sel_end = decl_end - 1;
1.82 cvs 4981: while (*sel_end == SPACE || *sel_end == BSPACE ||
4982: *sel_end == EOL || *sel_end == CR)
1.1 cvs 4983: sel_end--;
4984: sel_end++;
1.82 cvs 4985: *sel_end = EOS;
1.1 cvs 4986: selector = cssRule;
4987:
4988: /* now, deal with the content ... */
4989: decl_end++;
4990: cssRule = decl_end;
1.137 vatton 4991: decl_end = &cssRule[strlen (cssRule) - 1];
4992: if (*decl_end != '{')
4993: *decl_end = EOS;
1.1 cvs 4994: /*
4995: * parse the style attribute string and install the corresponding
4996: * presentation attributes on the new element
4997: */
4998: ctxt = TtaGetGenericStyleContext (doc);
4999: if (ctxt == NULL)
5000: return;
5001: ctxt->destroy = destroy;
5002:
1.82 cvs 5003: while ((selector != NULL) && (*selector != EOS))
1.25 cvs 5004: selector = ParseGenericSelector (selector, cssRule, ctxt, doc, css);
1.1 cvs 5005: TtaFreeMemory (ctxt);
5006: }
5007:
5008: /************************************************************************
5009: * *
5010: * EVALUATION FUNCTIONS / CASCADING AND OVERLOADING *
5011: * *
5012: ************************************************************************/
5013:
5014: /*----------------------------------------------------------------------
1.59 cvs 5015: IsImplicitClassName: return wether the Class name is an
1.1 cvs 5016: implicit one, eg "H1" or "H2 EM" meaning it's a GI name
5017: or an HTML context name.
5018: ----------------------------------------------------------------------*/
1.79 cvs 5019: int IsImplicitClassName (char *class, Document doc)
1.1 cvs 5020: {
1.79 cvs 5021: char name[200];
5022: char *cur = name;
5023: char *first;
5024: char save;
5025: SSchema schema;
1.1 cvs 5026:
5027: /* make a local copy */
1.82 cvs 5028: strncpy (name, class, 199);
1.1 cvs 5029: name[199] = 0;
5030:
5031: /* loop looking if each word is a GI */
5032: while (*cur != 0)
5033: {
5034: first = cur;
5035: cur = SkipWord (cur);
5036: save = *cur;
5037: *cur = 0;
5038: schema = NULL;
5039: if (MapGI (first, &schema, doc) == -1)
5040: {
5041: return (0);
5042: }
5043: *cur = save;
1.82 cvs 5044: cur = SkipBlanksAndComments (cur);
1.1 cvs 5045: }
5046: return (1);
5047: }
5048:
5049: /************************************************************************
5050: * *
1.114 quint 5051: * Functions needed for support of HTML: translate to CSS equivalent *
1.1 cvs 5052: * *
5053: ************************************************************************/
5054:
5055: /*----------------------------------------------------------------------
1.59 cvs 5056: HTMLSetBackgroundColor:
1.1 cvs 5057: ----------------------------------------------------------------------*/
1.79 cvs 5058: void HTMLSetBackgroundColor (Document doc, Element el, char *color)
1.1 cvs 5059: {
1.79 cvs 5060: char css_command[100];
1.1 cvs 5061:
1.82 cvs 5062: sprintf (css_command, "background-color: %s", color);
1.114 quint 5063: ParseHTMLSpecificStyle (el, css_command, doc, 0, FALSE);
1.1 cvs 5064: }
5065:
5066: /*----------------------------------------------------------------------
1.59 cvs 5067: HTMLSetForegroundColor:
1.1 cvs 5068: ----------------------------------------------------------------------*/
1.97 vatton 5069: void HTMLSetForegroundColor (Document doc, Element el, char *color)
1.1 cvs 5070: {
1.79 cvs 5071: char css_command[100];
1.1 cvs 5072:
1.82 cvs 5073: sprintf (css_command, "color: %s", color);
1.114 quint 5074: ParseHTMLSpecificStyle (el, css_command, doc, 0, FALSE);
1.1 cvs 5075: }
5076:
5077: /*----------------------------------------------------------------------
1.59 cvs 5078: HTMLResetBackgroundColor:
1.1 cvs 5079: ----------------------------------------------------------------------*/
1.97 vatton 5080: void HTMLResetBackgroundColor (Document doc, Element el)
1.1 cvs 5081: {
1.79 cvs 5082: char css_command[100];
1.1 cvs 5083:
1.82 cvs 5084: sprintf (css_command, "background: red");
1.114 quint 5085: ParseHTMLSpecificStyle (el, css_command, doc, 0, TRUE);
1.1 cvs 5086: }
5087:
5088: /*----------------------------------------------------------------------
1.59 cvs 5089: HTMLResetBackgroundImage:
1.1 cvs 5090: ----------------------------------------------------------------------*/
1.97 vatton 5091: void HTMLResetBackgroundImage (Document doc, Element el)
1.1 cvs 5092: {
1.79 cvs 5093: char css_command[1000];
1.1 cvs 5094:
1.82 cvs 5095: sprintf (css_command, "background-image: url(xx); background-repeat: repeat");
1.114 quint 5096: ParseHTMLSpecificStyle (el, css_command, doc, 0, TRUE);
1.1 cvs 5097: }
5098:
5099: /*----------------------------------------------------------------------
1.59 cvs 5100: HTMLResetForegroundColor:
1.1 cvs 5101: ----------------------------------------------------------------------*/
1.97 vatton 5102: void HTMLResetForegroundColor (Document doc, Element el)
1.1 cvs 5103: {
1.79 cvs 5104: char css_command[100];
1.1 cvs 5105:
1.36 cvs 5106: /* it's not necessary to well know the current color but it must be valid */
1.82 cvs 5107: sprintf (css_command, "color: red");
1.114 quint 5108: ParseHTMLSpecificStyle (el, css_command, doc, 0, TRUE);
1.1 cvs 5109: }
5110:
5111: /*----------------------------------------------------------------------
1.59 cvs 5112: HTMLSetAlinkColor:
1.1 cvs 5113: ----------------------------------------------------------------------*/
1.97 vatton 5114: void HTMLSetAlinkColor (Document doc, char *color)
1.1 cvs 5115: {
1.79 cvs 5116: char css_command[100];
1.1 cvs 5117:
1.82 cvs 5118: sprintf (css_command, "a:link { color: %s }", color);
1.1 cvs 5119: ApplyCSSRules (NULL, css_command, doc, FALSE);
5120: }
5121:
5122: /*----------------------------------------------------------------------
1.59 cvs 5123: HTMLSetAactiveColor:
1.1 cvs 5124: ----------------------------------------------------------------------*/
1.97 vatton 5125: void HTMLSetAactiveColor (Document doc, char *color)
1.1 cvs 5126: {
1.79 cvs 5127: char css_command[100];
1.1 cvs 5128:
1.82 cvs 5129: sprintf (css_command, "a:active { color: %s }", color);
1.1 cvs 5130: ApplyCSSRules (NULL, css_command, doc, FALSE);
5131: }
5132:
5133: /*----------------------------------------------------------------------
1.59 cvs 5134: HTMLSetAvisitedColor:
1.1 cvs 5135: ----------------------------------------------------------------------*/
1.79 cvs 5136: void HTMLSetAvisitedColor (Document doc, char *color)
1.1 cvs 5137: {
1.79 cvs 5138: char css_command[100];
1.1 cvs 5139:
1.82 cvs 5140: sprintf (css_command, "a:visited { color: %s }", color);
1.1 cvs 5141: ApplyCSSRules (NULL, css_command, doc, FALSE);
5142: }
5143:
5144: /*----------------------------------------------------------------------
1.59 cvs 5145: HTMLResetAlinkColor:
1.1 cvs 5146: ----------------------------------------------------------------------*/
5147: void HTMLResetAlinkColor (Document doc)
5148: {
1.79 cvs 5149: char css_command[100];
1.1 cvs 5150:
1.82 cvs 5151: sprintf (css_command, "a:link { color: red }");
1.1 cvs 5152: ApplyCSSRules (NULL, css_command, doc, TRUE);
5153: }
5154:
5155: /*----------------------------------------------------------------------
1.59 cvs 5156: HTMLResetAactiveColor:
1.1 cvs 5157: ----------------------------------------------------------------------*/
5158: void HTMLResetAactiveColor (Document doc)
5159: {
1.79 cvs 5160: char css_command[100];
1.1 cvs 5161:
1.82 cvs 5162: sprintf (css_command, "a:active { color: red }");
1.1 cvs 5163: ApplyCSSRules (NULL, css_command, doc, TRUE);
5164: }
5165:
5166: /*----------------------------------------------------------------------
1.59 cvs 5167: HTMLResetAvisitedColor:
1.1 cvs 5168: ----------------------------------------------------------------------*/
5169: void HTMLResetAvisitedColor (Document doc)
5170: {
1.79 cvs 5171: char css_command[100];
1.1 cvs 5172:
1.82 cvs 5173: sprintf (css_command, "a:visited { color: red }");
1.1 cvs 5174: ApplyCSSRules (NULL, css_command, doc, TRUE);
5175: }
5176:
5177: /*----------------------------------------------------------------------
1.73 cvs 5178: ApplyCSSRules: parse a CSS Style description stored in the
1.1 cvs 5179: header of a HTML document.
5180: ----------------------------------------------------------------------*/
1.79 cvs 5181: void ApplyCSSRules (Element el, char *cssRule, Document doc, ThotBool destroy)
1.1 cvs 5182: {
5183: CSSInfoPtr css;
5184:
1.144 quint 5185: css = SearchCSS (doc, NULL, el);
1.1 cvs 5186: if (css == NULL)
5187: /* create the document css */
1.144 quint 5188: css = AddCSS (doc, doc, CSS_DOCUMENT_STYLE, NULL, NULL, el);
1.1 cvs 5189: ParseStyleDeclaration (el, cssRule, doc, css, destroy);
5190: }
5191:
5192: /*----------------------------------------------------------------------
1.145 quint 5193: ReadCSSRules: is the front-end function called by the document parser
5194: when detecting a <style type="text/css"> indicating it's the
1.1 cvs 5195: beginning of a CSS fragment or when reading a file .css.
5196:
5197: The CSS parser has to handle <!-- ... --> constructs used to
5198: prevent prehistoric browser from displaying the CSS as a text
5199: content. It will stop on any sequence "<x" where x is different
5200: from ! and will return x as to the caller. Theorically x should
1.145 quint 5201: be equal to / for the </style> end of style.
1.1 cvs 5202: The parameter doc gives the document tree that contains CSS information.
5203: The parameter docRef gives the document to which CSS are to be applied.
5204: This function uses the current css context or creates it. It's able
1.23 cvs 5205: to work on the given buffer or call GetNextChar to read the parsed
1.1 cvs 5206: file.
1.133 vatton 5207: The parameter url gives the URL of the style shheet parsed.
1.86 cvs 5208: Parameter numberOfLinesRead indicates the number of lines already
5209: read in the file.
1.1 cvs 5210: Parameter withUndo indicates whether the changes made in the document
1.145 quint 5211: structure and content have to be registered in the Undo queue or not.
1.1 cvs 5212: ----------------------------------------------------------------------*/
1.133 vatton 5213: char ReadCSSRules (Document docRef, CSSInfoPtr css, char *buffer, char *url,
1.144 quint 5214: int numberOfLinesRead, ThotBool withUndo,
1.172 quint 5215: Element styleElement)
1.1 cvs 5216: {
1.6 cvs 5217: DisplayMode dispMode;
1.82 cvs 5218: char c;
1.138 vatton 5219: char *cssRule, *base, *saveDocURL, *ptr;
1.19 cvs 5220: int index;
1.1 cvs 5221: int CSSindex;
5222: int CSScomment;
5223: int import;
5224: int openRule;
1.93 vatton 5225: int newlines;
1.14 cvs 5226: ThotBool HTMLcomment;
1.102 vatton 5227: ThotBool toParse, eof, quoted;
1.36 cvs 5228: ThotBool ignoreMedia, media;
1.186 vatton 5229: ThotBool noRule, ignoreImport, skip;
1.175 vatton 5230: CSSInfoPtr refcss = NULL;
1.1 cvs 5231:
5232: CSScomment = MAX_CSS_LENGTH;
5233: HTMLcomment = FALSE;
5234: CSSindex = 0;
5235: toParse = FALSE;
5236: noRule = FALSE;
1.36 cvs 5237: media = FALSE;
1.88 cvs 5238: ignoreImport = FALSE;
1.1 cvs 5239: ignoreMedia = FALSE;
5240: import = MAX_CSS_LENGTH;
5241: eof = FALSE;
5242: openRule = 0;
1.82 cvs 5243: c = SPACE;
1.1 cvs 5244: index = 0;
1.134 vatton 5245: base = NULL;
1.135 vatton 5246: quoted = FALSE;
1.186 vatton 5247: skip = FALSE;
1.93 vatton 5248: /* number of new lines parsed */
5249: newlines = 0;
1.6 cvs 5250: /* avoid too many redisplay */
5251: dispMode = TtaGetDisplayMode (docRef);
5252: if (dispMode == DisplayImmediately)
5253: TtaSetDisplayMode (docRef, DeferredDisplay);
1.18 cvs 5254:
5255: /* look for the CSS context */
5256: if (css == NULL)
1.144 quint 5257: css = SearchCSS (docRef, NULL, styleElement);
1.18 cvs 5258: if (css == NULL)
1.144 quint 5259: css = AddCSS (docRef, docRef, CSS_DOCUMENT_STYLE, NULL, NULL,
5260: styleElement);
1.1 cvs 5261:
1.174 vatton 5262: /* look for the CSS descriptor that points to the extension schema */
5263: refcss = css;
5264: if (import)
1.173 cvs 5265: {
1.174 vatton 5266: while (refcss && refcss->category == CSS_IMPORT)
5267: refcss = refcss->NextCSS;
1.173 cvs 5268: }
5269:
1.144 quint 5270: /* register parsed CSS file and the document to which CSS are to be applied*/
1.86 cvs 5271: ParsedDoc = docRef;
1.133 vatton 5272: if (url)
5273: DocURL = url;
1.86 cvs 5274: else
5275: /* the CSS source in within the document itself */
5276: DocURL = DocumentURLs[docRef];
5277: LineNumber = numberOfLinesRead + 1;
1.93 vatton 5278: NewLineSkipped = 0;
1.82 cvs 5279: while (CSSindex < MAX_CSS_LENGTH && c != EOS && !eof)
5280: {
5281: c = buffer[index++];
5282: eof = (c == EOS);
5283: CSSbuffer[CSSindex] = c;
1.186 vatton 5284: if (skip)
5285: {
5286: if (c == '}')
5287: {
5288: /* end of the @font-face */
5289: skip = FALSE;
5290: import = MAX_CSS_LENGTH;
5291: noRule = TRUE;
5292: CSSindex = 0;
5293: }
5294: if (c == EOL)
5295: LineNumber++;
5296: c = CR;
5297: }
5298: else if (CSScomment == MAX_CSS_LENGTH ||
1.82 cvs 5299: c == '*' || c == '/' || c == '<')
5300: {
5301: /* we're not within a comment or we're parsing * or / */
5302: switch (c)
5303: {
5304: case '@': /* perhaps an import primitive */
1.135 vatton 5305: if (!quoted)
5306: import = CSSindex;
1.82 cvs 5307: break;
5308: case ';':
1.135 vatton 5309: if (!quoted && !media && import != MAX_CSS_LENGTH)
1.82 cvs 5310: {
5311: if (strncasecmp (&CSSbuffer[import+1], "import", 6))
5312: /* it's not an import */
5313: import = MAX_CSS_LENGTH;
5314: /* save the text */
5315: noRule = TRUE;
5316: }
5317: break;
5318: case '*':
1.135 vatton 5319: if (!quoted && CSScomment == MAX_CSS_LENGTH && CSSindex > 0 &&
1.82 cvs 5320: CSSbuffer[CSSindex - 1] == '/')
5321: /* start a comment */
5322: CSScomment = CSSindex - 1;
5323: break;
5324: case '/':
1.135 vatton 5325: if (!quoted && CSSindex > 1 && CSScomment != MAX_CSS_LENGTH &&
1.82 cvs 5326: CSSbuffer[CSSindex - 1] == '*')
5327: {
5328: /* close a comment:and ignore its contents */
5329: CSSindex = CSScomment - 1; /* will be incremented later */
5330: CSScomment = MAX_CSS_LENGTH;
1.93 vatton 5331: /* clean up the buffer */
1.103 vatton 5332: if (newlines && CSSindex > 0)
5333: while (CSSindex > 0 &&
5334: (CSSbuffer[CSSindex] == SPACE ||
5335: CSSbuffer[CSSindex] == BSPACE ||
5336: CSSbuffer[CSSindex] == EOL ||
5337: CSSbuffer[CSSindex] == TAB ||
5338: CSSbuffer[CSSindex] == __CR__))
1.93 vatton 5339: {
5340: if ( CSSbuffer[CSSindex] == EOL)
5341: {
5342: LineNumber ++;
5343: newlines --;
5344: }
5345: CSSindex--;
5346: }
1.82 cvs 5347: }
1.135 vatton 5348: else if (!quoted && CSScomment == MAX_CSS_LENGTH && CSSindex > 0 &&
1.82 cvs 5349: CSSbuffer[CSSindex - 1] == '<')
5350: {
5351: /* this is the closing tag ! */
5352: CSSindex -= 2; /* remove </ from the CSS string */
5353: noRule = TRUE;
5354: }
5355: break;
5356: case '<':
1.135 vatton 5357: if (!quoted && CSScomment == MAX_CSS_LENGTH)
1.82 cvs 5358: {
5359: /* only if we're not parsing a comment */
5360: c = buffer[index++];
5361: eof = (c == EOS);
5362: if (c == '!')
5363: {
5364: /* CSS within an HTML comment */
5365: HTMLcomment = TRUE;
5366: CSSindex++;
5367: CSSbuffer[CSSindex] = c;
5368: }
5369: else if (c == EOS)
5370: CSSindex++;
5371: }
5372: break;
5373: case '-':
1.135 vatton 5374: if (!quoted && CSSindex > 0 && CSSbuffer[CSSindex - 1] == '-' &&
1.82 cvs 5375: HTMLcomment)
5376: /* CSS within an HTML comment */
5377: noRule = TRUE;
5378: break;
5379: case '>':
1.135 vatton 5380: if (!quoted && HTMLcomment)
1.82 cvs 5381: noRule = TRUE;
5382: break;
5383: case ' ':
1.135 vatton 5384: if (!quoted && import != MAX_CSS_LENGTH && openRule == 0)
1.162 quint 5385: media = !strncasecmp (&CSSbuffer[import+1], "media", 5);
1.82 cvs 5386: break;
5387: case '{':
1.135 vatton 5388: if (!quoted)
1.82 cvs 5389: {
1.135 vatton 5390: openRule++;
5391: if (import != MAX_CSS_LENGTH && openRule == 1 && media)
5392: {
5393: /* is it the screen concerned? */
5394: CSSbuffer[CSSindex+1] = EOS;
5395: if (TtaIsPrinting ())
5396: base = strstr (&CSSbuffer[import], "print");
5397: else
5398: base = strstr (&CSSbuffer[import], "screen");
5399: if (base == NULL)
5400: base = strstr (&CSSbuffer[import], "all");
5401: if (base == NULL)
5402: ignoreMedia = TRUE;
5403: noRule = TRUE;
5404: }
1.186 vatton 5405: else if (import != MAX_CSS_LENGTH &&
5406: !strncasecmp (&CSSbuffer[import], "@font-face", 10))
5407: skip = TRUE;
1.135 vatton 5408: }
5409: break;
5410: case '}':
5411: if (!quoted)
5412: {
5413: openRule--;
5414: if (import != MAX_CSS_LENGTH && openRule == 0)
5415: {
5416: import = MAX_CSS_LENGTH;
5417: noRule = TRUE;
5418: ignoreMedia = FALSE;
5419: media = FALSE;
5420: }
1.82 cvs 5421: else
1.135 vatton 5422: toParse = TRUE;
1.82 cvs 5423: }
5424: break;
1.135 vatton 5425: case '"':
5426: if (quoted)
1.82 cvs 5427: {
1.135 vatton 5428: if (CSSbuffer[CSSindex - 1] != '\\')
5429: quoted = FALSE;
1.82 cvs 5430: }
5431: else
1.135 vatton 5432: quoted = TRUE;
1.82 cvs 5433: break;
5434: default:
1.86 cvs 5435: if (c == EOL)
1.93 vatton 5436: newlines++;
1.82 cvs 5437: break;
5438: }
5439: }
1.93 vatton 5440: else if (c == EOL)
5441: LineNumber++;
1.82 cvs 5442: if (c != CR)
5443: CSSindex++;
5444:
5445: if (CSSindex >= MAX_CSS_LENGTH && CSScomment < MAX_CSS_LENGTH)
5446: /* we're still parsing a comment: remove the text comment */
5447: CSSindex = CSScomment;
5448:
5449: if (CSSindex >= MAX_CSS_LENGTH || toParse || noRule)
5450: {
5451: CSSbuffer[CSSindex] = EOS;
5452: /* parse a not empty string */
5453: if (CSSindex > 0)
5454: {
1.50 cvs 5455: /* apply CSS rule if it's not just a saving of text */
5456: if (!noRule && !ignoreMedia)
1.88 cvs 5457: {
5458: /* future import rules must be ignored */
5459: ignoreImport = TRUE;
1.173 cvs 5460: ParseStyleDeclaration (NULL, CSSbuffer, docRef, refcss, FALSE);
1.93 vatton 5461: LineNumber += newlines;
5462: newlines = 0;
5463: NewLineSkipped = 0;
1.88 cvs 5464: }
1.82 cvs 5465: else if (import != MAX_CSS_LENGTH &&
5466: !strncasecmp (&CSSbuffer[import+1], "import", 6))
5467: {
5468: /* import section */
5469: cssRule = &CSSbuffer[import+7];
5470: cssRule = TtaSkipBlanks (cssRule);
1.93 vatton 5471: /* save the current line number */
5472: newlines += LineNumber;
1.82 cvs 5473: if (!strncasecmp (cssRule, "url", 3))
5474: {
1.50 cvs 5475: cssRule = &cssRule[3];
1.82 cvs 5476: cssRule = TtaSkipBlanks (cssRule);
5477: if (*cssRule == '(')
5478: {
5479: cssRule++;
5480: cssRule = TtaSkipBlanks (cssRule);
1.102 vatton 5481: quoted = (*cssRule == '"' || *cssRule == '\'');
5482: if (quoted)
5483: cssRule++;
1.82 cvs 5484: base = cssRule;
5485: while (*cssRule != EOS && *cssRule != ')')
5486: cssRule++;
1.102 vatton 5487: if (quoted)
1.167 vatton 5488: {
5489: /* isolate the file name */
5490: cssRule[-1] = EOS;
5491: quoted = FALSE;
5492: }
1.160 vatton 5493: *cssRule = EOS;
1.82 cvs 5494: }
5495: }
1.87 cvs 5496: else if (*cssRule == '"')
5497: {
1.88 cvs 5498: /*
5499: Do we have to accept single quotes?
5500: Double quotes are acceted here.
5501: Escaped quotes are not handled. See function SkipQuotedString
5502: */
1.87 cvs 5503: cssRule++;
5504: cssRule = TtaSkipBlanks (cssRule);
5505: base = cssRule;
1.179 vatton 5506: while (*cssRule != EOS &&
5507: (*cssRule != '"' ||
1.180 vatton 5508: (*cssRule == '"' && cssRule[-1] == '\\')))
1.87 cvs 5509: cssRule++;
1.160 vatton 5510: /* isolate the file name */
5511: *cssRule = EOS;
1.133 vatton 5512: }
5513: /* check if a media is defined */
5514: cssRule++;
5515: cssRule = TtaSkipBlanks (cssRule);
5516: if (*cssRule != ';')
5517: {
5518: if (TtaIsPrinting ())
5519: ignoreImport = (strncasecmp (cssRule, "print", 5) &&
5520: strncasecmp (cssRule, "all", 3));
5521: else
5522: ignoreImport = (strncasecmp (cssRule, "screen", 6) &&
5523: strncasecmp (cssRule, "all", 3));
5524: }
5525: if (!ignoreImport)
5526: {
5527: /* save the displayed URL when an error is reported */
5528: saveDocURL = DocURL;
1.138 vatton 5529: ptr = TtaStrdup (base);
5530: /* get the CSS URI in UTF-8 */
5531: ptr = ReallocUTF8String (ptr, docRef);
1.133 vatton 5532: LoadStyleSheet (base, docRef, NULL, css,
5533: css->media[docRef],
5534: css->category == CSS_USER_STYLE);
5535: /* restore the displayed URL when an error is reported */
5536: DocURL = saveDocURL;
1.138 vatton 5537: TtaFreeMemory (ptr);
1.82 cvs 5538: }
1.93 vatton 5539: /* restore the number of lines */
5540: LineNumber = newlines;
5541: newlines = 0;
1.82 cvs 5542: import = MAX_CSS_LENGTH;
5543: }
1.93 vatton 5544:
1.82 cvs 5545: }
5546: toParse = FALSE;
5547: noRule = FALSE;
5548: CSSindex = 0;
1.50 cvs 5549: }
1.82 cvs 5550: }
1.6 cvs 5551: /* restore the display mode */
5552: if (dispMode == DisplayImmediately)
1.82 cvs 5553: TtaSetDisplayMode (docRef, dispMode);
1.86 cvs 5554:
5555: /* Prepare the context for style attributes */
5556: DocURL = DocumentURLs[docRef];
5557: LineNumber = -1;
1.1 cvs 5558: return (c);
5559: }
1.89 cvs 5560:
Webmaster