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