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