Annotation of Amaya/amaya/styleparser.c, revision 1.105
1.1 cvs 1: /*
2: *
1.78 cvs 3: * (c) COPYRIGHT MIT and INRIA, 1996-2001
1.1 cvs 4: * Please first read the full copyright statement in file COPYRIGHT.
5: *
6: */
1.53 cvs 7:
1.1 cvs 8: /*
9: * Everything directly linked to the CSS syntax should now hopefully
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.1 cvs 22:
23: typedef struct _BackgroundImageCallbackBlock
24: {
25: Element el;
26: PSchema tsch;
27: union
28: {
29: PresentationContextBlock specific;
30: GenericContextBlock generic;
31: } context;
32: }
33: BackgroundImageCallbackBlock, *BackgroundImageCallbackPtr;
34:
35: #include "AHTURLTools_f.h"
36: #include "HTMLpresentation_f.h"
37: #include "HTMLimage_f.h"
38: #include "UIcss_f.h"
39: #include "css_f.h"
1.24 cvs 40: #include "fetchHTMLname_f.h"
1.91 cvs 41: #include "fetchXMLname_f.h"
1.1 cvs 42: #include "html2thot_f.h"
1.91 cvs 43: #include "init_f.h"
1.1 cvs 44: #include "styleparser_f.h"
45:
46: #define MAX_BUFFER_LENGTH 200
47: /*
48: * A PropertyParser is a function used to parse the
49: * description substring associated to a given style attribute
1.59 cvs 50: * e.g.: "red" for a color attribute or "12pt bold helvetica"
1.1 cvs 51: * for a font attribute.
52: */
1.79 cvs 53: typedef char *(*PropertyParser) (Element element,
1.56 cvs 54: PSchema tsch,
55: PresentationContext context,
1.79 cvs 56: char *cssRule,
1.56 cvs 57: CSSInfoPtr css,
58: ThotBool isHTML);
1.1 cvs 59:
60: /* Description of the set of CSS properties supported */
61: typedef struct CSSProperty
62: {
1.79 cvs 63: char *name;
1.25 cvs 64: PropertyParser parsing_function;
1.1 cvs 65: }
66: CSSProperty;
67:
68: struct unit_def
69: {
1.79 cvs 70: char *sign;
1.1 cvs 71: unsigned int unit;
72: };
73:
74: static struct unit_def CSSUnitNames[] =
75: {
1.82 cvs 76: {"pt", STYLE_UNIT_PT},
77: {"pc", STYLE_UNIT_PC},
78: {"in", STYLE_UNIT_IN},
79: {"cm", STYLE_UNIT_CM},
80: {"mm", STYLE_UNIT_MM},
81: {"em", STYLE_UNIT_EM},
82: {"px", STYLE_UNIT_PX},
83: {"ex", STYLE_UNIT_XHEIGHT},
84: {"%", STYLE_UNIT_PERCENT}
1.1 cvs 85: };
86:
87: #define NB_UNITS (sizeof(CSSUnitNames) / sizeof(struct unit_def))
1.86 cvs 88: static char *DocURL = NULL; /* The parsed CSS file */
89: static Document ParsedDoc; /* The document to which CSS are to be applied */
90: static int LineNumber = -1; /* The line where the error occurs */
1.93 vatton 91: static int NewLineSkipped = 0;
1.1 cvs 92:
93: /*----------------------------------------------------------------------
94: SkipWord:
95: ----------------------------------------------------------------------*/
1.79 cvs 96: static char *SkipWord (char *ptr)
1.1 cvs 97: {
1.50 cvs 98: # ifdef _WINDOWS
99: /* iswalnum is supposed to be supported by the i18n veriosn of libc
100: use it when available */
1.82 cvs 101: while (iswalnum (*ptr) || *ptr == '-' || *ptr == '%')
1.50 cvs 102: # else /* !_WINDOWS */
1.82 cvs 103: while (isalnum((int)*ptr) || *ptr == '-' || *ptr == '%')
1.50 cvs 104: # endif /* !_WINDOWS */
105: ptr++;
1.1 cvs 106: return (ptr);
107: }
108:
109: /*----------------------------------------------------------------------
1.13 cvs 110: SkipBlanksAndComments:
111: ----------------------------------------------------------------------*/
1.82 cvs 112: char *SkipBlanksAndComments (char *ptr)
1.13 cvs 113: {
1.93 vatton 114: /* skip spaces */
115: while (*ptr == SPACE || *ptr == BSPACE || *ptr == EOL ||
116: *ptr == TAB || *ptr == __CR__)
117: {
118: if (*ptr == EOL)
119: /* increment the number of newline skipped */
120: NewLineSkipped++;
121: ptr++;
122: }
1.13 cvs 123: while (ptr[0] == '/' && ptr[1] == '*')
124: {
125: /* look for the end of the comment */
126: ptr = &ptr[2];
127: while (ptr[0] != EOS && (ptr[0] != '*' || ptr[1] != '/'))
128: ptr++;
129: if (ptr[0] != EOS)
130: ptr = &ptr[2];
1.93 vatton 131: /* skip spaces */
132: while (*ptr == SPACE || *ptr == BSPACE || *ptr == EOL ||
133: *ptr == TAB || *ptr == __CR__)
134: {
135: if (*ptr == EOL)
136: /* increment the number of newline skipped */
137: NewLineSkipped++;
138: ptr++;
139: }
1.13 cvs 140: }
141: return (ptr);
142: }
143:
1.49 cvs 144:
145: /*----------------------------------------------------------------------
1.1 cvs 146: SkipQuotedString:
147: ----------------------------------------------------------------------*/
1.79 cvs 148: static char *SkipQuotedString (char *ptr, char quote)
1.1 cvs 149: {
1.14 cvs 150: ThotBool stop;
1.1 cvs 151:
152: stop = FALSE;
153: while (!stop)
154: {
155: if (*ptr == quote)
156: {
157: ptr++;
158: stop = TRUE;
159: }
1.82 cvs 160: else if (*ptr == EOS)
1.1 cvs 161: stop = TRUE;
1.82 cvs 162: else if (*ptr == '\\')
1.1 cvs 163: /* escape character */
164: {
165: ptr++;
1.82 cvs 166: if ((*ptr >= '0' && *ptr <= '9') || (*ptr >= 'A' && *ptr <= 'F') ||
167: (*ptr >= 'a' && *ptr <= 'f'))
1.1 cvs 168: {
169: ptr++;
1.82 cvs 170: if ((*ptr >= '0' && *ptr <= '9') || (*ptr >= 'A' && *ptr <= 'F') ||
171: (*ptr >= 'a' && *ptr <= 'f'))
1.1 cvs 172: ptr++;
173: }
174: else
175: ptr++;
176: }
177: else
178: ptr++;
179: }
180: return (ptr);
181: }
182:
183: /*----------------------------------------------------------------------
1.86 cvs 184: CSSParseError
185: print the error message msg on stderr.
186: When the line is 0 ask to expat the current line number
187: ----------------------------------------------------------------------*/
188: static void CSSParseError (char *msg, char *value)
189: {
190: if (!TtaIsPrinting () && ParsedDoc > 0)
191: {
192: if (!ErrFile)
193: {
1.90 cvs 194: if (OpenParsingErrors (ParsedDoc) == FALSE)
1.86 cvs 195: return;
196: }
197:
198: if (DocURL != NULL)
199: {
1.94 cvs 200: fprintf (ErrFile, "*** Errors/warnings in %s\n", DocURL);
1.86 cvs 201: /* set to NULL as long as the CSS file doesn't change */
202: DocURL = NULL;
203: }
1.89 cvs 204: CSSErrorsFound = TRUE;
1.86 cvs 205: if (LineNumber < 0)
1.99 vatton 206: fprintf (ErrFile, " In Style attribute %s %s\"\n", msg, value);
1.86 cvs 207: else
1.99 vatton 208: fprintf (ErrFile, " line %d: %s %s\"\n", LineNumber + NewLineSkipped,
1.93 vatton 209: msg, value);
1.86 cvs 210: }
211: }
212:
1.89 cvs 213:
1.86 cvs 214: /*----------------------------------------------------------------------
215: SkipProperty:
216: ----------------------------------------------------------------------*/
217: static char *SkipProperty (char *ptr)
218: {
219: char *deb;
220: char c;
221:
222: deb = ptr;
223: while (*ptr != EOS && *ptr != ';' && *ptr != '}')
224: ptr++;
1.95 cvs 225: /* print the skipped property */
1.86 cvs 226: c = *ptr;
227: *ptr = EOS;
1.95 cvs 228: #ifdef CSS_WARNING
1.86 cvs 229: if (*deb != EOS)
1.99 vatton 230: CSSParseError ("CSS property ignored \"", deb);
1.95 cvs 231: #endif /* CSS_WARNING */
1.86 cvs 232: *ptr = c;
233: return (ptr);
234: }
235:
236: /*----------------------------------------------------------------------
1.1 cvs 237: SkipProperty:
238: ----------------------------------------------------------------------*/
1.99 vatton 239: static char *SkipValue (char *ptr, ThotBool error)
1.1 cvs 240: {
1.86 cvs 241: char *deb;
242: char c;
243:
244: deb = ptr;
1.82 cvs 245: while (*ptr != EOS && *ptr != ';' && *ptr != '}')
1.1 cvs 246: ptr++;
1.95 cvs 247: /* print the skipped property */
1.86 cvs 248: c = *ptr;
249: *ptr = EOS;
1.99 vatton 250: if (*deb != EOS && *deb != ',')
251: {
252: if (error)
253: CSSParseError ("invalid CSS value \"", deb);
1.95 cvs 254: #ifdef CSS_WARNING
1.99 vatton 255: else
256: CSSParseError ("CSS value ignored \"", deb);
1.95 cvs 257: #endif /* CSS_WARNING */
1.99 vatton 258: }
1.86 cvs 259: *ptr = c;
1.1 cvs 260: return (ptr);
261: }
262:
263: /*----------------------------------------------------------------------
1.64 cvs 264: ParseNumber:
265: parse a number and returns the corresponding value.
1.1 cvs 266: ----------------------------------------------------------------------*/
1.79 cvs 267: char *ParseNumber (char *cssRule, PresentationValue *pval)
1.1 cvs 268: {
269: int val = 0;
270: int minus = 0;
271: int valid = 0;
272: int f = 0;
1.14 cvs 273: ThotBool real = FALSE;
1.1 cvs 274:
275: pval->typed_data.unit = STYLE_UNIT_REL;
276: pval->typed_data.real = FALSE;
1.82 cvs 277: cssRule = SkipBlanksAndComments (cssRule);
278: if (*cssRule == '-')
1.1 cvs 279: {
280: minus = 1;
281: cssRule++;
1.82 cvs 282: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 283: }
284:
1.82 cvs 285: if (*cssRule == '+')
1.1 cvs 286: {
287: cssRule++;
1.82 cvs 288: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 289: }
290:
1.82 cvs 291: while ((*cssRule >= '0') && (*cssRule <= '9'))
1.1 cvs 292: {
293: val *= 10;
1.82 cvs 294: val += *cssRule - '0';
1.1 cvs 295: cssRule++;
296: valid = 1;
297: }
298:
1.82 cvs 299: if (*cssRule == '.')
1.1 cvs 300: {
301: real = TRUE;
302: f = val;
303: val = 0;
304: cssRule++;
305: /* keep only 3 digits */
1.82 cvs 306: if (*cssRule >= '0' && *cssRule <= '9')
1.1 cvs 307: {
1.82 cvs 308: val = (*cssRule - '0') * 100;
1.1 cvs 309: cssRule++;
1.82 cvs 310: if (*cssRule >= '0' && *cssRule <= '9')
1.1 cvs 311: {
1.82 cvs 312: val += (*cssRule - '0') * 10;
1.1 cvs 313: cssRule++;
1.82 cvs 314: if ((*cssRule >= '0') && (*cssRule <= '9'))
1.1 cvs 315: {
1.82 cvs 316: val += *cssRule - '0';
1.1 cvs 317: cssRule++;
318: }
319: }
320:
1.82 cvs 321: while (*cssRule >= '0' && *cssRule <= '9')
1.1 cvs 322: cssRule++;
323: valid = 1;
324: }
325: }
326:
327: if (!valid)
328: {
329: pval->typed_data.unit = STYLE_UNIT_INVALID;
330: pval->typed_data.value = 0;
331: }
332: else
333: {
334: pval->typed_data.real = real;
335: if (real)
336: {
337: if (minus)
338: pval->typed_data.value = -(f * 1000 + val);
339: else
340: pval->typed_data.value = f * 1000 + val;
341: }
342: else
343: {
344: if (minus)
345: pval->typed_data.value = -val;
346: else
347: pval->typed_data.value = val;
348: }
1.64 cvs 349: }
350: return (cssRule);
351: }
352:
353: /*----------------------------------------------------------------------
354: ParseCSSUnit:
355: parse a CSS Unit substring and returns the corresponding
356: value and its unit.
357: ----------------------------------------------------------------------*/
1.82 cvs 358: char *ParseCSSUnit (char *cssRule, PresentationValue *pval)
1.64 cvs 359: {
360: unsigned int uni;
361:
362: pval->typed_data.unit = STYLE_UNIT_REL;
363: cssRule = ParseNumber (cssRule, pval);
364: if (pval->typed_data.unit == STYLE_UNIT_INVALID)
365: cssRule = SkipWord (cssRule);
366: else
367: {
1.82 cvs 368: cssRule = SkipBlanksAndComments (cssRule);
1.64 cvs 369: for (uni = 0; uni < NB_UNITS; uni++)
370: {
1.82 cvs 371: if (!strncasecmp (CSSUnitNames[uni].sign, cssRule,
372: strlen (CSSUnitNames[uni].sign)))
1.64 cvs 373: {
374: pval->typed_data.unit = CSSUnitNames[uni].unit;
1.82 cvs 375: return (cssRule + strlen (CSSUnitNames[uni].sign));
1.64 cvs 376: }
377: }
378: /* not in the list of predefined units */
379: pval->typed_data.unit = STYLE_UNIT_PX;
1.1 cvs 380: }
381: return (cssRule);
382: }
383:
1.43 cvs 384: /*----------------------------------------------------------------------
385: ParseBorderValue
386: ----------------------------------------------------------------------*/
1.79 cvs 387: static char *ParseBorderValue (char *cssRule, PresentationValue *border)
1.43 cvs 388: {
389: /* first parse the attribute string */
390: border->typed_data.value = 0;
1.44 cvs 391: border->typed_data.unit = STYLE_UNIT_INVALID;
1.43 cvs 392: border->typed_data.real = FALSE;
1.82 cvs 393: if (!strncasecmp (cssRule, "thin", 4))
1.43 cvs 394: {
1.44 cvs 395: border->typed_data.unit = STYLE_UNIT_PX;
1.43 cvs 396: border->typed_data.value = 1;
397: cssRule = SkipWord (cssRule);
398: }
1.82 cvs 399: else if (!strncasecmp (cssRule, "medium", 6))
1.43 cvs 400: {
1.44 cvs 401: border->typed_data.unit = STYLE_UNIT_PX;
1.43 cvs 402: border->typed_data.value = 3;
403: cssRule = SkipWord (cssRule);
404: }
1.82 cvs 405: else if (!strncasecmp (cssRule, "thick", 5))
1.43 cvs 406: {
1.44 cvs 407: border->typed_data.unit = STYLE_UNIT_PX;
1.43 cvs 408: border->typed_data.value = 5;
409: cssRule = SkipWord (cssRule);
410: }
1.82 cvs 411: else if (isdigit (*cssRule))
1.43 cvs 412: cssRule = ParseCSSUnit (cssRule, border);
413: return (cssRule);
414: }
415:
416: /*----------------------------------------------------------------------
417: ParseBorderStyle
418: ----------------------------------------------------------------------*/
1.79 cvs 419: static char *ParseBorderStyle (char *cssRule, PresentationValue *border)
1.43 cvs 420: {
421: /* first parse the attribute string */
422: border->typed_data.value = 0;
423: border->typed_data.unit = STYLE_UNIT_PX;
424: border->typed_data.real = FALSE;
1.82 cvs 425: if (!strncasecmp (cssRule, "none", 4))
1.43 cvs 426: border->typed_data.value = STYLE_BORDERNONE;
1.82 cvs 427: else if (!strncasecmp (cssRule, "hidden", 6))
1.43 cvs 428: border->typed_data.value = STYLE_BORDERHIDDEN;
1.82 cvs 429: else if (!strncasecmp (cssRule, "dotted", 6))
1.43 cvs 430: border->typed_data.value = STYLE_BORDERDOTTED;
1.82 cvs 431: else if (!strncasecmp (cssRule, "dashed", 6))
1.43 cvs 432: border->typed_data.value = STYLE_BORDERDASHED;
1.82 cvs 433: else if (!strncasecmp (cssRule, "solid", 5))
1.43 cvs 434: border->typed_data.value = STYLE_BORDERSOLID;
1.82 cvs 435: else if (!strncasecmp (cssRule, "double", 6))
1.43 cvs 436: border->typed_data.value = STYLE_BORDERDOUBLE;
1.82 cvs 437: else if (!strncasecmp (cssRule, "groove", 6))
1.43 cvs 438: border->typed_data.value = STYLE_BORDERGROOVE;
1.82 cvs 439: else if (!strncasecmp (cssRule, "ridge", 5))
1.43 cvs 440: border->typed_data.value = STYLE_BORDERRIDGE;
1.82 cvs 441: else if (!strncasecmp (cssRule, "inset", 5))
1.43 cvs 442: border->typed_data.value = STYLE_BORDERINSET;
1.82 cvs 443: else if (!strncasecmp (cssRule, "outset", 6))
1.43 cvs 444: border->typed_data.value = STYLE_BORDEROUTSET;
445: else
1.44 cvs 446: {
447: /* invalid style */
448: border->typed_data.unit = STYLE_UNIT_INVALID;
449: return (cssRule);
450: }
1.43 cvs 451: /* the value is parsed now */
452: cssRule = SkipWord (cssRule);
453: return (cssRule);
454: }
455:
456: /*----------------------------------------------------------------------
1.59 cvs 457: ParseCSSColor: parse a CSS color attribute string
1.43 cvs 458: we expect the input string describing the attribute to be
459: either a color name, a 3 tuple or an hexadecimal encoding.
460: The color used will be approximed from the current color
461: table
462: ----------------------------------------------------------------------*/
1.79 cvs 463: static char *ParseCSSColor (char *cssRule, PresentationValue * val)
1.43 cvs 464: {
1.79 cvs 465: char *ptr;
1.43 cvs 466: unsigned short redval = (unsigned short) -1;
467: unsigned short greenval = 0; /* composant of each RGB */
468: unsigned short blueval = 0; /* default to red if unknown ! */
469: int best = 0; /* best color in list found */
470:
1.82 cvs 471: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 472: val->typed_data.unit = STYLE_UNIT_INVALID;
473: val->typed_data.real = FALSE;
474: val->typed_data.value = 0;
1.57 cvs 475: ptr = TtaGiveRGB (cssRule, &redval, &greenval, &blueval);
476: if (ptr == cssRule)
1.43 cvs 477: {
1.99 vatton 478: cssRule = SkipValue (cssRule, TRUE);
1.43 cvs 479: val->typed_data.value = 0;
480: val->typed_data.unit = STYLE_UNIT_INVALID;
481: }
482: else
483: {
484: best = TtaGetThotColor (redval, greenval, blueval);
485: val->typed_data.value = best;
486: val->typed_data.unit = STYLE_UNIT_REL;
1.57 cvs 487: cssRule = ptr;
1.43 cvs 488: }
489: val->typed_data.real = FALSE;
1.65 cvs 490: return (cssRule);
1.43 cvs 491: }
1.1 cvs 492:
493: /*----------------------------------------------------------------------
1.59 cvs 494: ParseCSSBorderTopWidth: parse a CSS BorderTopWidth
1.1 cvs 495: attribute string.
496: ----------------------------------------------------------------------*/
1.79 cvs 497: static char *ParseCSSBorderTopWidth (Element element, PSchema tsch,
498: PresentationContext context,
499: char *cssRule, CSSInfoPtr css,
500: ThotBool isHTML)
1.1 cvs 501: {
1.41 cvs 502: PresentationValue border;
503:
1.82 cvs 504: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 505: cssRule = ParseBorderValue (cssRule, &border);
506: if (border.typed_data.unit != STYLE_UNIT_INVALID)
1.44 cvs 507: {
508: TtaSetStylePresentation (PRBorderTopWidth, element, tsch, context, border);
509: border.typed_data.value = 1;
510: border.typed_data.unit = STYLE_UNIT_REL;
511: }
1.1 cvs 512: return (cssRule);
513: }
514:
515: /*----------------------------------------------------------------------
1.59 cvs 516: ParseCSSBorderBottomWidth: parse a CSS BorderBottomWidth
1.1 cvs 517: attribute string.
518: ----------------------------------------------------------------------*/
1.79 cvs 519: static char *ParseCSSBorderBottomWidth (Element element, PSchema tsch,
520: PresentationContext context,
521: char *cssRule, CSSInfoPtr css,
522: ThotBool isHTML)
1.1 cvs 523: {
1.41 cvs 524: PresentationValue border;
525:
1.82 cvs 526: cssRule = SkipBlanksAndComments (cssRule);
1.41 cvs 527: /* first parse the attribute string */
1.43 cvs 528: cssRule = ParseBorderValue (cssRule, &border);
529: if (border.typed_data.unit != STYLE_UNIT_INVALID)
1.44 cvs 530: {
531: TtaSetStylePresentation (PRBorderBottomWidth, element, tsch, context, border);
532: border.typed_data.value = 1;
533: border.typed_data.unit = STYLE_UNIT_REL;
534: }
1.1 cvs 535: return (cssRule);
536: }
537:
538: /*----------------------------------------------------------------------
1.59 cvs 539: ParseCSSBorderLeftWidth: parse a CSS BorderLeftWidth
1.1 cvs 540: attribute string.
541: ----------------------------------------------------------------------*/
1.79 cvs 542: static char *ParseCSSBorderLeftWidth (Element element, PSchema tsch,
543: PresentationContext context,
544: char *cssRule, CSSInfoPtr css,
545: ThotBool isHTML)
1.1 cvs 546: {
1.41 cvs 547: PresentationValue border;
548:
1.82 cvs 549: cssRule = SkipBlanksAndComments (cssRule);
1.41 cvs 550: /* first parse the attribute string */
1.43 cvs 551: cssRule = ParseBorderValue (cssRule, &border);
552: if (border.typed_data.unit != STYLE_UNIT_INVALID)
1.44 cvs 553: {
554: TtaSetStylePresentation (PRBorderLeftWidth, element, tsch, context, border);
555: border.typed_data.value = 1;
556: border.typed_data.unit = STYLE_UNIT_REL;
557: }
1.1 cvs 558: return (cssRule);
559: }
560:
561: /*----------------------------------------------------------------------
1.59 cvs 562: ParseCSSBorderRightWidth: parse a CSS BorderRightWidth
1.1 cvs 563: attribute string.
564: ----------------------------------------------------------------------*/
1.79 cvs 565: static char *ParseCSSBorderRightWidth (Element element, PSchema tsch,
566: PresentationContext context,
567: char *cssRule, CSSInfoPtr css,
568: ThotBool isHTML)
1.1 cvs 569: {
1.41 cvs 570: PresentationValue border;
571:
1.82 cvs 572: cssRule = SkipBlanksAndComments (cssRule);
1.41 cvs 573: /* first parse the attribute string */
1.43 cvs 574: cssRule = ParseBorderValue (cssRule, &border);
575: if (border.typed_data.unit != STYLE_UNIT_INVALID)
1.44 cvs 576: {
577: TtaSetStylePresentation (PRBorderRightWidth, element, tsch, context, border);
578: border.typed_data.value = 1;
579: border.typed_data.unit = STYLE_UNIT_REL;
580: }
1.1 cvs 581: return (cssRule);
582: }
583:
584: /*----------------------------------------------------------------------
1.59 cvs 585: ParseCSSBorderWidth: parse a CSS BorderWidth
1.1 cvs 586: attribute string.
587: ----------------------------------------------------------------------*/
1.79 cvs 588: static char *ParseCSSBorderWidth (Element element, PSchema tsch,
589: PresentationContext context,
590: char *cssRule, CSSInfoPtr css,
591: ThotBool isHTML)
1.1 cvs 592: {
1.79 cvs 593: char *ptrT, *ptrR, *ptrB, *ptrL;
1.93 vatton 594: int skippedNL;
1.41 cvs 595:
1.82 cvs 596: ptrT = SkipBlanksAndComments (cssRule);
1.42 cvs 597: /* First parse Border-Top */
598: ptrR = ParseCSSBorderTopWidth (element, tsch, context, ptrT, css, isHTML);
1.82 cvs 599: ptrR = SkipBlanksAndComments (ptrR);
600: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1.42 cvs 601: {
1.93 vatton 602: skippedNL = NewLineSkipped;
1.42 cvs 603: cssRule = ptrR;
604: /* apply the Border-Top to all */
605: ptrR = ParseCSSBorderRightWidth (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 606: NewLineSkipped = skippedNL;
1.42 cvs 607: ptrR = ParseCSSBorderBottomWidth (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 608: NewLineSkipped = skippedNL;
1.42 cvs 609: ptrR = ParseCSSBorderLeftWidth (element, tsch, context, ptrT, css, isHTML);
610: }
611: else
612: {
613: /* parse Border-Right */
614: ptrB = ParseCSSBorderRightWidth (element, tsch, context, ptrR, css, isHTML);
1.82 cvs 615: ptrB = SkipBlanksAndComments (ptrB);
616: if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
1.42 cvs 617: {
1.93 vatton 618: skippedNL = NewLineSkipped;
1.42 cvs 619: cssRule = ptrB;
620: /* apply the Border-Top to Border-Bottom */
621: ptrB = ParseCSSBorderBottomWidth (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 622: NewLineSkipped = skippedNL;
1.42 cvs 623: /* apply the Border-Right to Border-Left */
624: ptrB = ParseCSSBorderLeftWidth (element, tsch, context, ptrR, css, isHTML);
625: }
626: else
627: {
628: /* parse Border-Bottom */
629: ptrL = ParseCSSBorderBottomWidth (element, tsch, context, ptrB, css, isHTML);
1.82 cvs 630: ptrL = SkipBlanksAndComments (ptrL);
631: if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
1.42 cvs 632: {
633: cssRule = ptrL;
634: /* apply the Border-Right to Border-Left */
635: ptrL = ParseCSSBorderLeftWidth (element, tsch, context, ptrR, css, isHTML);
636: }
637: else
638: /* parse Border-Left */
639: cssRule = ParseCSSBorderLeftWidth (element, tsch, context, ptrL, css, isHTML);
1.82 cvs 640: cssRule = SkipBlanksAndComments (cssRule);
1.42 cvs 641: }
642: }
1.1 cvs 643: return (cssRule);
644: }
645:
646: /*----------------------------------------------------------------------
1.59 cvs 647: ParseCSSBorderColorTop: parse a CSS BorderColorTop
1.1 cvs 648: attribute string.
649: ----------------------------------------------------------------------*/
1.79 cvs 650: static char *ParseCSSBorderColorTop (Element element, PSchema tsch,
651: PresentationContext context,
652: char *cssRule, CSSInfoPtr css,
653: ThotBool isHTML)
1.1 cvs 654: {
1.43 cvs 655: PresentationValue best;
656:
657: cssRule = ParseCSSColor (cssRule, &best);
658: if (best.typed_data.unit != STYLE_UNIT_INVALID)
659: /* install the new presentation */
660: TtaSetStylePresentation (PRBorderTopColor, element, tsch, context, best);
1.65 cvs 661: return (cssRule);
1.1 cvs 662: }
663:
664: /*----------------------------------------------------------------------
1.59 cvs 665: ParseCSSBorderColorLeft: parse a CSS BorderColorLeft
1.42 cvs 666: attribute string.
667: ----------------------------------------------------------------------*/
1.79 cvs 668: static char *ParseCSSBorderColorLeft (Element element, PSchema tsch,
669: PresentationContext context,
670: char *cssRule, CSSInfoPtr css,
671: ThotBool isHTML)
1.42 cvs 672: {
1.43 cvs 673: PresentationValue best;
674:
675: cssRule = ParseCSSColor (cssRule, &best);
676: if (best.typed_data.unit != STYLE_UNIT_INVALID)
677: /* install the new presentation */
678: TtaSetStylePresentation (PRBorderLeftColor, element, tsch, context, best);
1.65 cvs 679: return (cssRule);
1.42 cvs 680: }
681:
682: /*----------------------------------------------------------------------
1.59 cvs 683: ParseCSSBorderColorBottom: parse a CSS BorderColorBottom
1.42 cvs 684: attribute string.
685: ----------------------------------------------------------------------*/
1.79 cvs 686: static char *ParseCSSBorderColorBottom (Element element, PSchema tsch,
687: PresentationContext context,
688: char *cssRule, CSSInfoPtr css,
689: ThotBool isHTML)
1.42 cvs 690: {
1.43 cvs 691: PresentationValue best;
692:
693: cssRule = ParseCSSColor (cssRule, &best);
694: if (best.typed_data.unit != STYLE_UNIT_INVALID)
695: /* install the new presentation */
696: TtaSetStylePresentation (PRBorderBottomColor, element, tsch, context, best);
1.65 cvs 697: return (cssRule);
1.42 cvs 698: }
699:
700: /*----------------------------------------------------------------------
1.59 cvs 701: ParseCSSBorderColorRight: parse a CSS BorderColorRight
1.1 cvs 702: attribute string.
703: ----------------------------------------------------------------------*/
1.79 cvs 704: static char *ParseCSSBorderColorRight (Element element, PSchema tsch,
705: PresentationContext context,
706: char *cssRule, CSSInfoPtr css,
707: ThotBool isHTML)
1.1 cvs 708: {
1.43 cvs 709: PresentationValue best;
710:
711: cssRule = ParseCSSColor (cssRule, &best);
712: if (best.typed_data.unit != STYLE_UNIT_INVALID)
713: /* install the new presentation */
714: TtaSetStylePresentation (PRBorderRightColor, element, tsch, context, best);
1.65 cvs 715: return (cssRule);
1.1 cvs 716: }
717:
718: /*----------------------------------------------------------------------
1.59 cvs 719: ParseCSSBorderColor: parse a CSS border-color
1.42 cvs 720: attribute string.
721: ----------------------------------------------------------------------*/
1.79 cvs 722: static char *ParseCSSBorderColor (Element element, PSchema tsch,
723: PresentationContext context,
724: char *cssRule, CSSInfoPtr css,
725: ThotBool isHTML)
1.42 cvs 726: {
1.79 cvs 727: char *ptrT, *ptrR, *ptrB, *ptrL;
1.93 vatton 728: int skippedNL;
1.42 cvs 729:
1.82 cvs 730: ptrT = SkipBlanksAndComments (cssRule);
1.42 cvs 731: /* First parse Border-Top */
1.43 cvs 732: ptrR = ParseCSSBorderColorTop (element, tsch, context, ptrT, css, isHTML);
1.82 cvs 733: ptrR = SkipBlanksAndComments (ptrR);
734: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1.42 cvs 735: {
1.93 vatton 736: skippedNL = NewLineSkipped;
1.42 cvs 737: cssRule = ptrR;
738: /* apply the Border-Top to all */
1.43 cvs 739: ptrR = ParseCSSBorderColorRight (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 740: NewLineSkipped = skippedNL;
1.43 cvs 741: ptrR = ParseCSSBorderColorBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 742: NewLineSkipped = skippedNL;
1.43 cvs 743: ptrR = ParseCSSBorderColorLeft (element, tsch, context, ptrT, css, isHTML);
1.42 cvs 744: }
745: else
746: {
747: /* parse Border-Right */
1.43 cvs 748: ptrB = ParseCSSBorderColorRight (element, tsch, context, ptrR, css, isHTML);
1.82 cvs 749: ptrB = SkipBlanksAndComments (ptrB);
750: if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
1.42 cvs 751: {
1.93 vatton 752: skippedNL = NewLineSkipped;
1.42 cvs 753: cssRule = ptrB;
754: /* apply the Border-Top to Border-Bottom */
1.43 cvs 755: ptrB = ParseCSSBorderColorBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 756: NewLineSkipped = skippedNL;
1.42 cvs 757: /* apply the Border-Right to Border-Left */
1.43 cvs 758: ptrB = ParseCSSBorderColorLeft (element, tsch, context, ptrR, css, isHTML);
1.42 cvs 759: }
760: else
761: {
1.93 vatton 762: skippedNL = NewLineSkipped;
1.42 cvs 763: /* parse Border-Bottom */
1.43 cvs 764: ptrL = ParseCSSBorderColorBottom (element, tsch, context, ptrB, css, isHTML);
1.93 vatton 765: NewLineSkipped = skippedNL;
1.82 cvs 766: ptrL = SkipBlanksAndComments (ptrL);
767: if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
1.42 cvs 768: {
769: cssRule = ptrL;
770: /* apply the Border-Right to Border-Left */
1.43 cvs 771: ptrL = ParseCSSBorderColorLeft (element, tsch, context, ptrR, css, isHTML);
1.42 cvs 772: }
773: else
774: /* parse Border-Left */
1.43 cvs 775: cssRule = ParseCSSBorderColorLeft (element, tsch, context, ptrL, css, isHTML);
1.82 cvs 776: cssRule = SkipBlanksAndComments (cssRule);
1.42 cvs 777: }
778: }
779: return (cssRule);
780: }
781:
782: /*----------------------------------------------------------------------
1.59 cvs 783: ParseCSSBorderStyleTop: parse a CSS BorderStyleTop
1.42 cvs 784: attribute string.
785: ----------------------------------------------------------------------*/
1.79 cvs 786: static char *ParseCSSBorderStyleTop (Element element, PSchema tsch,
787: PresentationContext context,
788: char *cssRule, CSSInfoPtr css,
789: ThotBool isHTML)
1.42 cvs 790: {
1.43 cvs 791: PresentationValue border;
792:
1.82 cvs 793: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 794: cssRule = ParseBorderStyle (cssRule, &border);
795: if (border.typed_data.unit != STYLE_UNIT_INVALID)
796: TtaSetStylePresentation (PRBorderTopStyle, element, tsch, context, border);
1.42 cvs 797: return (cssRule);
798: }
799:
800: /*----------------------------------------------------------------------
1.59 cvs 801: ParseCSSBorderStyleLeft: parse a CSS BorderStyleLeft
1.42 cvs 802: attribute string.
803: ----------------------------------------------------------------------*/
1.79 cvs 804: static char *ParseCSSBorderStyleLeft (Element element, PSchema tsch,
805: PresentationContext context,
806: char *cssRule, CSSInfoPtr css,
807: ThotBool isHTML)
1.42 cvs 808: {
1.43 cvs 809: PresentationValue border;
810:
1.82 cvs 811: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 812: cssRule = ParseBorderStyle (cssRule, &border);
813: if (border.typed_data.unit != STYLE_UNIT_INVALID)
814: TtaSetStylePresentation (PRBorderLeftStyle, element, tsch, context, border);
1.42 cvs 815: return (cssRule);
816: }
817:
818: /*----------------------------------------------------------------------
1.59 cvs 819: ParseCSSBorderStyleBottom: parse a CSS BorderStyleBottom
1.1 cvs 820: attribute string.
821: ----------------------------------------------------------------------*/
1.79 cvs 822: static char *ParseCSSBorderStyleBottom (Element element, PSchema tsch,
823: PresentationContext context,
824: char *cssRule, CSSInfoPtr css,
825: ThotBool isHTML)
1.1 cvs 826: {
1.43 cvs 827: PresentationValue border;
828:
1.82 cvs 829: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 830: cssRule = ParseBorderStyle (cssRule, &border);
831: if (border.typed_data.unit != STYLE_UNIT_INVALID)
832: TtaSetStylePresentation (PRBorderBottomStyle, element, tsch, context, border);
1.1 cvs 833: return (cssRule);
834: }
835:
836: /*----------------------------------------------------------------------
1.59 cvs 837: ParseCSSBorderStyleRight: parse a CSS BorderStyleRight
1.1 cvs 838: attribute string.
839: ----------------------------------------------------------------------*/
1.79 cvs 840: static char *ParseCSSBorderStyleRight (Element element, PSchema tsch,
841: PresentationContext context,
842: char *cssRule, CSSInfoPtr css,
843: ThotBool isHTML)
1.1 cvs 844: {
1.43 cvs 845: PresentationValue border;
846:
1.82 cvs 847: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 848: cssRule = ParseBorderStyle (cssRule, &border);
849: if (border.typed_data.unit != STYLE_UNIT_INVALID)
850: TtaSetStylePresentation (PRBorderRightStyle, element, tsch, context, border);
1.1 cvs 851: return (cssRule);
852: }
853:
854: /*----------------------------------------------------------------------
1.59 cvs 855: ParseCSSBorderStyleStyle: parse a CSS border-style
1.1 cvs 856: attribute string.
857: ----------------------------------------------------------------------*/
1.79 cvs 858: static char *ParseCSSBorderStyle (Element element, PSchema tsch,
859: PresentationContext context,
860: char *cssRule, CSSInfoPtr css,
861: ThotBool isHTML)
1.1 cvs 862: {
1.79 cvs 863: char *ptrT, *ptrR, *ptrB, *ptrL;
1.93 vatton 864: int skippedNL;
1.42 cvs 865:
1.82 cvs 866: ptrT = SkipBlanksAndComments (cssRule);
1.42 cvs 867: /* First parse Border-Top */
1.43 cvs 868: ptrR = ParseCSSBorderStyleTop (element, tsch, context, ptrT, css, isHTML);
1.82 cvs 869: ptrR = SkipBlanksAndComments (ptrR);
870: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1.42 cvs 871: {
1.93 vatton 872: skippedNL = NewLineSkipped;
1.42 cvs 873: cssRule = ptrR;
874: /* apply the Border-Top to all */
1.43 cvs 875: ptrR = ParseCSSBorderStyleRight (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 876: NewLineSkipped = skippedNL;
1.43 cvs 877: ptrR = ParseCSSBorderStyleBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 878: NewLineSkipped = skippedNL;
1.43 cvs 879: ptrR = ParseCSSBorderStyleLeft (element, tsch, context, ptrT, css, isHTML);
1.42 cvs 880: }
881: else
882: {
883: /* parse Border-Right */
1.43 cvs 884: ptrB = ParseCSSBorderStyleRight (element, tsch, context, ptrR, css, isHTML);
1.82 cvs 885: ptrB = SkipBlanksAndComments (ptrB);
886: if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
1.42 cvs 887: {
1.93 vatton 888: skippedNL = NewLineSkipped;
1.42 cvs 889: cssRule = ptrB;
890: /* apply the Border-Top to Border-Bottom */
1.43 cvs 891: ptrB = ParseCSSBorderStyleBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 892: NewLineSkipped = skippedNL;
1.42 cvs 893: /* apply the Border-Right to Border-Left */
1.43 cvs 894: ptrB = ParseCSSBorderStyleLeft (element, tsch, context, ptrR, css, isHTML);
1.42 cvs 895: }
896: else
897: {
898: /* parse Border-Bottom */
1.43 cvs 899: ptrL = ParseCSSBorderStyleBottom (element, tsch, context, ptrB, css, isHTML);
1.82 cvs 900: ptrL = SkipBlanksAndComments (ptrL);
901: if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
1.42 cvs 902: {
903: cssRule = ptrL;
904: /* apply the Border-Right to Border-Left */
1.43 cvs 905: ptrL = ParseCSSBorderStyleLeft (element, tsch, context, ptrR, css, isHTML);
1.42 cvs 906: }
907: else
908: /* parse Border-Left */
1.43 cvs 909: cssRule = ParseCSSBorderStyleLeft (element, tsch, context, ptrL, css, isHTML);
1.82 cvs 910: cssRule = SkipBlanksAndComments (cssRule);
1.42 cvs 911: }
912: }
913: return (cssRule);
914: }
915:
916: /*----------------------------------------------------------------------
1.59 cvs 917: ParseCSSBorderTop: parse a CSS BorderTop
1.42 cvs 918: attribute string.
919: ----------------------------------------------------------------------*/
1.79 cvs 920: static char *ParseCSSBorderTop (Element element, PSchema tsch,
921: PresentationContext context, char *cssRule,
922: CSSInfoPtr css, ThotBool isHTML)
1.42 cvs 923: {
1.79 cvs 924: char *ptr;
1.43 cvs 925:
1.82 cvs 926: cssRule = SkipBlanksAndComments (cssRule);
927: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
1.43 cvs 928: {
929: ptr = cssRule;
930: cssRule = ParseCSSBorderStyleTop (element, tsch, context, cssRule, css, isHTML);
931: if (ptr == cssRule)
932: cssRule = ParseCSSBorderTopWidth (element, tsch, context, cssRule, css, isHTML);
933: if (ptr == cssRule)
934: cssRule = ParseCSSBorderColorTop (element, tsch, context, cssRule, css, isHTML);
935: if (ptr == cssRule)
936: /* rule not found */
1.99 vatton 937: cssRule = SkipValue (cssRule, TRUE);
1.82 cvs 938: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 939: }
1.42 cvs 940: return (cssRule);
941: }
942:
943: /*----------------------------------------------------------------------
1.59 cvs 944: ParseCSSBorderLeft: parse a CSS BorderLeft
1.42 cvs 945: attribute string.
946: ----------------------------------------------------------------------*/
1.79 cvs 947: static char *ParseCSSBorderLeft (Element element, PSchema tsch,
948: PresentationContext context, char *cssRule,
949: CSSInfoPtr css, ThotBool isHTML)
1.42 cvs 950: {
1.79 cvs 951: char *ptr;
1.43 cvs 952:
1.82 cvs 953: cssRule = SkipBlanksAndComments (cssRule);
954: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
1.43 cvs 955: {
956: ptr = cssRule;
957: cssRule = ParseCSSBorderStyleLeft (element, tsch, context, cssRule, css, isHTML);
958: if (ptr == cssRule)
959: cssRule = ParseCSSBorderLeftWidth (element, tsch, context, cssRule, css, isHTML);
960: if (ptr == cssRule)
961: cssRule = ParseCSSBorderColorLeft (element, tsch, context, cssRule, css, isHTML);
962: if (ptr == cssRule)
963: /* rule not found */
1.99 vatton 964: cssRule = SkipValue (cssRule, TRUE);
1.82 cvs 965: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 966: }
1.1 cvs 967: return (cssRule);
968: }
969:
970: /*----------------------------------------------------------------------
1.59 cvs 971: ParseCSSBorderBottom: parse a CSS BorderBottom
1.1 cvs 972: attribute string.
973: ----------------------------------------------------------------------*/
1.79 cvs 974: static char *ParseCSSBorderBottom (Element element, PSchema tsch,
975: PresentationContext context, char *cssRule,
976: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 977: {
1.79 cvs 978: char *ptr;
1.43 cvs 979:
1.82 cvs 980: cssRule = SkipBlanksAndComments (cssRule);
981: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
1.43 cvs 982: {
983: ptr = cssRule;
984: cssRule = ParseCSSBorderStyleBottom (element, tsch, context, cssRule, css, isHTML);
985: if (ptr == cssRule)
986: cssRule = ParseCSSBorderBottomWidth (element, tsch, context, cssRule, css, isHTML);
987: if (ptr == cssRule)
988: cssRule = ParseCSSBorderColorBottom (element, tsch, context, cssRule, css, isHTML);
989: if (ptr == cssRule)
990: /* rule not found */
1.99 vatton 991: cssRule = SkipValue (cssRule, TRUE);
1.82 cvs 992: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 993: }
1.1 cvs 994: return (cssRule);
995: }
996:
997: /*----------------------------------------------------------------------
1.59 cvs 998: ParseCSSBorderRight: parse a CSS BorderRight
1.1 cvs 999: attribute string.
1000: ----------------------------------------------------------------------*/
1.79 cvs 1001: static char *ParseCSSBorderRight (Element element, PSchema tsch,
1002: PresentationContext context, char *cssRule,
1003: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1004: {
1.79 cvs 1005: char *ptr;
1.43 cvs 1006:
1.82 cvs 1007: cssRule = SkipBlanksAndComments (cssRule);
1008: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
1.43 cvs 1009: {
1010: ptr = cssRule;
1011: cssRule = ParseCSSBorderStyleRight (element, tsch, context, cssRule, css, isHTML);
1012: if (ptr == cssRule)
1013: cssRule = ParseCSSBorderRightWidth (element, tsch, context, cssRule, css, isHTML);
1014: if (ptr == cssRule)
1015: cssRule = ParseCSSBorderColorRight (element, tsch, context, cssRule, css, isHTML);
1016: if (ptr == cssRule)
1017: /* rule not found */
1.99 vatton 1018: cssRule = SkipValue (cssRule, TRUE);
1.82 cvs 1019: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 1020: }
1.1 cvs 1021: return (cssRule);
1022: }
1023:
1024: /*----------------------------------------------------------------------
1.59 cvs 1025: ParseCSSBorder: parse a CSS border
1.42 cvs 1026: attribute string.
1027: ----------------------------------------------------------------------*/
1.79 cvs 1028: static char *ParseCSSBorder (Element element, PSchema tsch,
1029: PresentationContext context, char *cssRule,
1030: CSSInfoPtr css, ThotBool isHTML)
1.42 cvs 1031: {
1.79 cvs 1032: char *ptrT, *ptrR;
1.93 vatton 1033: int skippedNL;
1.42 cvs 1034:
1.82 cvs 1035: ptrT = SkipBlanksAndComments (cssRule);
1.42 cvs 1036: /* First parse Border-Top */
1037: ptrR = ParseCSSBorderTop (element, tsch, context, ptrT, css, isHTML);
1.82 cvs 1038: ptrR = SkipBlanksAndComments (ptrR);
1039: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1.42 cvs 1040: {
1.93 vatton 1041: skippedNL = NewLineSkipped;
1.42 cvs 1042: cssRule = ptrR;
1043: /* apply the Border-Top to all */
1044: ptrR = ParseCSSBorderRight (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 1045: NewLineSkipped = skippedNL;
1.42 cvs 1046: ptrR = ParseCSSBorderBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 1047: NewLineSkipped = skippedNL;
1.42 cvs 1048: ptrR = ParseCSSBorderLeft (element, tsch, context, ptrT, css, isHTML);
1049: }
1050: return (cssRule);
1051: }
1052:
1053: /*----------------------------------------------------------------------
1.59 cvs 1054: ParseCSSClear: parse a CSS clear attribute string
1.1 cvs 1055: ----------------------------------------------------------------------*/
1.79 cvs 1056: static char *ParseCSSClear (Element element, PSchema tsch,
1057: PresentationContext context, char *cssRule,
1058: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1059: {
1.99 vatton 1060: cssRule = SkipValue (cssRule, FALSE);
1.1 cvs 1061: return (cssRule);
1062: }
1063:
1064: /*----------------------------------------------------------------------
1.59 cvs 1065: ParseCSSDisplay: parse a CSS display attribute string
1.1 cvs 1066: ----------------------------------------------------------------------*/
1.79 cvs 1067: static char *ParseCSSDisplay (Element element, PSchema tsch,
1068: PresentationContext context, char *cssRule,
1069: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1070: {
1071: PresentationValue pval;
1072:
1073: pval.typed_data.unit = STYLE_UNIT_REL;
1074: pval.typed_data.real = FALSE;
1.82 cvs 1075: cssRule = SkipBlanksAndComments (cssRule);
1076: if (!strncasecmp (cssRule, "block", 5))
1.1 cvs 1077: {
1.79 cvs 1078: /* pval.typed_data.value = STYLE_INLINE;
1.93 vatton 1079: TtaSetStylePresentation (PRLine, element, tsch, context, pval); */
1080: cssRule = SkipWord (cssRule);
1.1 cvs 1081: }
1.82 cvs 1082: else if (!strncasecmp (cssRule, "inline", 6))
1.1 cvs 1083: {
1.79 cvs 1084: /* pval.typed_data.value = STYLE_INLINE;
1.93 vatton 1085: TtaSetStylePresentation (PRLine, element, tsch, context, pval); */
1086: cssRule = SkipWord (cssRule);
1.1 cvs 1087: }
1.82 cvs 1088: else if (!strncasecmp (cssRule, "none", 4))
1.1 cvs 1089: {
1090: pval.typed_data.value = STYLE_HIDE;
1091: TtaSetStylePresentation (PRVisibility, element, tsch, context, pval);
1092: cssRule = SkipWord (cssRule);
1093: }
1.82 cvs 1094: else if (!strncasecmp (cssRule, "list-item", 9))
1.99 vatton 1095: cssRule = SkipValue (cssRule, FALSE);
1.1 cvs 1096: else
1.86 cvs 1097: CSSParseError ("Invalid display value", cssRule);
1.34 cvs 1098:
1.1 cvs 1099: return (cssRule);
1100: }
1101:
1102: /*----------------------------------------------------------------------
1.59 cvs 1103: ParseCSSFloat: parse a CSS float attribute string
1.1 cvs 1104: ----------------------------------------------------------------------*/
1.79 cvs 1105: static char *ParseCSSFloat (Element element, PSchema tsch,
1106: PresentationContext context, char *cssRule,
1107: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1108: {
1.99 vatton 1109: cssRule = SkipValue (cssRule, FALSE);
1.1 cvs 1110: return (cssRule);
1111: }
1112:
1113: /*----------------------------------------------------------------------
1.59 cvs 1114: ParseCSSLetterSpacing: parse a CSS letter-spacing
1.1 cvs 1115: attribute string.
1116: ----------------------------------------------------------------------*/
1.79 cvs 1117: static char *ParseCSSLetterSpacing (Element element, PSchema tsch,
1118: PresentationContext context, char *cssRule,
1119: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1120: {
1.99 vatton 1121: cssRule = SkipValue (cssRule, FALSE);
1.1 cvs 1122: return (cssRule);
1123: }
1124:
1125: /*----------------------------------------------------------------------
1.59 cvs 1126: ParseCSSListStyleType: parse a CSS list-style-type
1.1 cvs 1127: attribute string.
1128: ----------------------------------------------------------------------*/
1.79 cvs 1129: static char *ParseCSSListStyleType (Element element, PSchema tsch,
1130: PresentationContext context, char *cssRule,
1131: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1132: {
1.99 vatton 1133: cssRule = SkipValue (cssRule, FALSE);
1.1 cvs 1134: return (cssRule);
1135: }
1136:
1137: /*----------------------------------------------------------------------
1.59 cvs 1138: ParseCSSListStyleImage: parse a CSS list-style-image
1.1 cvs 1139: attribute string.
1140: ----------------------------------------------------------------------*/
1.79 cvs 1141: static char *ParseCSSListStyleImage (Element element, PSchema tsch,
1142: PresentationContext context, char *cssRule,
1143: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1144: {
1.99 vatton 1145: cssRule = SkipValue (cssRule, FALSE);
1.1 cvs 1146: return (cssRule);
1147: }
1148:
1149: /*----------------------------------------------------------------------
1.59 cvs 1150: ParseCSSListStylePosition: parse a CSS list-style-position
1.1 cvs 1151: attribute string.
1152: ----------------------------------------------------------------------*/
1.79 cvs 1153: static char *ParseCSSListStylePosition (Element element, PSchema tsch,
1154: PresentationContext context,
1155: char *cssRule, CSSInfoPtr css,
1156: ThotBool isHTML)
1.1 cvs 1157: {
1.99 vatton 1158: cssRule = SkipValue (cssRule, FALSE);
1.1 cvs 1159: return (cssRule);
1160: }
1161:
1162: /*----------------------------------------------------------------------
1.59 cvs 1163: ParseCSSListStyle: parse a CSS list-style
1.1 cvs 1164: attribute string.
1165: ----------------------------------------------------------------------*/
1.79 cvs 1166: static char *ParseCSSListStyle (Element element, PSchema tsch,
1167: PresentationContext context, char *cssRule,
1168: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1169: {
1.99 vatton 1170: cssRule = SkipValue (cssRule, FALSE);
1.1 cvs 1171: return (cssRule);
1172: }
1173:
1174: /*----------------------------------------------------------------------
1.59 cvs 1175: ParseCSSTextAlign: parse a CSS text-align
1.1 cvs 1176: attribute string.
1177: ----------------------------------------------------------------------*/
1.79 cvs 1178: static char *ParseCSSTextAlign (Element element, PSchema tsch,
1179: PresentationContext context, char *cssRule,
1180: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1181: {
1182: PresentationValue align;
1183:
1184: align.typed_data.value = 0;
1185: align.typed_data.unit = STYLE_UNIT_REL;
1186: align.typed_data.real = FALSE;
1187:
1.82 cvs 1188: cssRule = SkipBlanksAndComments (cssRule);
1189: if (!strncasecmp (cssRule, "left", 4))
1.1 cvs 1190: {
1191: align.typed_data.value = AdjustLeft;
1192: cssRule = SkipWord (cssRule);
1193: }
1.82 cvs 1194: else if (!strncasecmp (cssRule, "right", 5))
1.1 cvs 1195: {
1196: align.typed_data.value = AdjustRight;
1197: cssRule = SkipWord (cssRule);
1198: }
1.82 cvs 1199: else if (!strncasecmp (cssRule, "center", 6))
1.1 cvs 1200: {
1201: align.typed_data.value = Centered;
1202: cssRule = SkipWord (cssRule);
1203: }
1.82 cvs 1204: else if (!strncasecmp (cssRule, "justify", 7))
1.1 cvs 1205: {
1.81 cvs 1206: align.typed_data.value = Justify;
1.1 cvs 1207: cssRule = SkipWord (cssRule);
1208: }
1209: else
1210: {
1.86 cvs 1211: CSSParseError ("Invalid align value", cssRule);
1.1 cvs 1212: return (cssRule);
1213: }
1214:
1215: /*
1216: * install the new presentation.
1217: */
1218: if (align.typed_data.value)
1.81 cvs 1219: TtaSetStylePresentation (PRAdjust, element, tsch, context, align);
1.1 cvs 1220: return (cssRule);
1221: }
1222:
1223: /*----------------------------------------------------------------------
1.59 cvs 1224: ParseCSSTextIndent: parse a CSS text-indent
1.1 cvs 1225: attribute string.
1226: ----------------------------------------------------------------------*/
1.79 cvs 1227: static char *ParseCSSTextIndent (Element element, PSchema tsch,
1228: PresentationContext context, char *cssRule,
1229: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1230: {
1231: PresentationValue pval;
1232:
1.82 cvs 1233: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 1234: cssRule = ParseCSSUnit (cssRule, &pval);
1235: if (pval.typed_data.unit == STYLE_UNIT_INVALID)
1236: return (cssRule);
1237: /* install the attribute */
1238: TtaSetStylePresentation (PRIndent, element, tsch, context, pval);
1239: return (cssRule);
1240: }
1241:
1242: /*----------------------------------------------------------------------
1.59 cvs 1243: ParseCSSTextTransform: parse a CSS text-transform
1.1 cvs 1244: attribute string.
1245: ----------------------------------------------------------------------*/
1.79 cvs 1246: static char *ParseCSSTextTransform (Element element, PSchema tsch,
1247: PresentationContext context, char *cssRule,
1248: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1249: {
1.99 vatton 1250: cssRule = SkipValue (cssRule, FALSE);
1.1 cvs 1251: return (cssRule);
1252: }
1253:
1254: /*----------------------------------------------------------------------
1.59 cvs 1255: ParseCSSVerticalAlign: parse a CSS vertical-align
1.1 cvs 1256: attribute string.
1257: ----------------------------------------------------------------------*/
1.79 cvs 1258: static char *ParseCSSVerticalAlign (Element element, PSchema tsch,
1259: PresentationContext context, char *cssRule,
1260: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1261: {
1.99 vatton 1262: cssRule = SkipValue (cssRule, FALSE);
1.1 cvs 1263: return (cssRule);
1264: }
1265:
1266: /*----------------------------------------------------------------------
1.59 cvs 1267: ParseCSSWhiteSpace: parse a CSS white-space
1.1 cvs 1268: attribute string.
1269: ----------------------------------------------------------------------*/
1.79 cvs 1270: static char *ParseCSSWhiteSpace (Element element, PSchema tsch,
1271: PresentationContext context, char *cssRule,
1272: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1273: {
1.82 cvs 1274: cssRule = SkipBlanksAndComments (cssRule);
1275: if (!strncasecmp (cssRule, "normal", 6))
1.1 cvs 1276: cssRule = SkipWord (cssRule);
1.82 cvs 1277: else if (!strncasecmp (cssRule, "pre", 3))
1.1 cvs 1278: cssRule = SkipWord (cssRule);
1279: else
1280: return (cssRule);
1281: return (cssRule);
1282: }
1283:
1284: /*----------------------------------------------------------------------
1.59 cvs 1285: ParseCSSWordSpacing: parse a CSS word-spacing
1.1 cvs 1286: attribute string.
1287: ----------------------------------------------------------------------*/
1.79 cvs 1288: static char *ParseCSSWordSpacing (Element element, PSchema tsch,
1289: PresentationContext context, char *cssRule,
1290: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1291: {
1.99 vatton 1292: cssRule = SkipValue (cssRule, FALSE);
1.1 cvs 1293: return (cssRule);
1294: }
1295:
1296: /*----------------------------------------------------------------------
1.59 cvs 1297: ParseCSSLineSpacing: parse a CSS font leading string
1.25 cvs 1298: we expect the input string describing the attribute to be
1299: value% or value
1300: ----------------------------------------------------------------------*/
1.79 cvs 1301: static char *ParseCSSLineSpacing (Element element, PSchema tsch,
1302: PresentationContext context, char *cssRule,
1303: CSSInfoPtr css, ThotBool isHTML)
1.25 cvs 1304: {
1305: PresentationValue lead;
1306:
1307: cssRule = ParseCSSUnit (cssRule, &lead);
1.93 vatton 1308: if (lead.typed_data.unit != STYLE_UNIT_INVALID)
1309: /* install the new presentation */
1310: TtaSetStylePresentation (PRLineSpacing, element, tsch, context, lead);
1.25 cvs 1311: return (cssRule);
1312: }
1313:
1314: /*----------------------------------------------------------------------
1.59 cvs 1315: ParseCSSFontSize: parse a CSS font size attr string
1.1 cvs 1316: we expect the input string describing the attribute to be
1317: xx-small, x-small, small, medium, large, x-large, xx-large
1318: or an absolute size, or an imcrement relative to the parent
1319: ----------------------------------------------------------------------*/
1.79 cvs 1320: static char *ParseCSSFontSize (Element element, PSchema tsch,
1321: PresentationContext context, char *cssRule,
1322: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1323: {
1324: PresentationValue pval;
1.79 cvs 1325: char *ptr = NULL;
1.14 cvs 1326: ThotBool real;
1.1 cvs 1327:
1328: pval.typed_data.real = FALSE;
1.82 cvs 1329: cssRule = SkipBlanksAndComments (cssRule);
1330: if (!strncasecmp (cssRule, "larger", 6))
1.1 cvs 1331: {
1332: pval.typed_data.unit = STYLE_UNIT_PERCENT;
1333: pval.typed_data.value = 130;
1334: cssRule = SkipWord (cssRule);
1335: }
1.82 cvs 1336: else if (!strncasecmp (cssRule, "smaller", 7))
1.1 cvs 1337: {
1338: pval.typed_data.unit = STYLE_UNIT_PERCENT;
1339: pval.typed_data.value = 80;
1340: cssRule = SkipWord (cssRule);
1341: }
1.82 cvs 1342: else if (!strncasecmp (cssRule, "xx-small", 8))
1.1 cvs 1343: {
1344: pval.typed_data.unit = STYLE_UNIT_REL;
1345: pval.typed_data.value = 1;
1346: cssRule = SkipWord (cssRule);
1347: }
1.82 cvs 1348: else if (!strncasecmp (cssRule, "x-small", 7))
1.1 cvs 1349: {
1350: pval.typed_data.unit = STYLE_UNIT_REL;
1351: pval.typed_data.value = 2;
1352: cssRule = SkipWord (cssRule);
1353: }
1.82 cvs 1354: else if (!strncasecmp (cssRule, "small", 5))
1.1 cvs 1355: {
1356: pval.typed_data.unit = STYLE_UNIT_REL;
1357: pval.typed_data.value = 3;
1358: cssRule = SkipWord (cssRule);
1359: }
1.82 cvs 1360: else if (!strncasecmp (cssRule, "medium", 6))
1.1 cvs 1361: {
1362: pval.typed_data.unit = STYLE_UNIT_REL;
1363: pval.typed_data.value = 4;
1364: cssRule = SkipWord (cssRule);
1365: }
1.82 cvs 1366: else if (!strncasecmp (cssRule, "large", 5))
1.1 cvs 1367: {
1368: pval.typed_data.unit = STYLE_UNIT_REL;
1369: pval.typed_data.value = 5;
1370: cssRule = SkipWord (cssRule);
1371: }
1.82 cvs 1372: else if (!strncasecmp (cssRule, "x-large", 7))
1.1 cvs 1373: {
1374: pval.typed_data.unit = STYLE_UNIT_REL;
1375: pval.typed_data.value = 6;
1376: cssRule = SkipWord (cssRule);
1377: }
1.82 cvs 1378: else if (!strncasecmp (cssRule, "xx-large", 8))
1.1 cvs 1379: {
1380: pval.typed_data.unit = STYLE_UNIT_REL;
1381: pval.typed_data.value = 7;
1382: cssRule = SkipWord (cssRule);
1383: }
1384: else
1385: {
1.25 cvs 1386: /* look for a '/' within the current cssRule */
1.82 cvs 1387: ptr = strchr (cssRule, '/');
1.25 cvs 1388: if (ptr != NULL)
1389: {
1390: /* keep the line spacing rule */
1.82 cvs 1391: ptr[0] = EOS;
1.25 cvs 1392: ptr = &ptr[1];
1393: }
1.1 cvs 1394: cssRule = ParseCSSUnit (cssRule, &pval);
1395: if (pval.typed_data.unit == STYLE_UNIT_INVALID ||
1396: pval.typed_data.value < 0)
1397: return (cssRule);
1398: if (pval.typed_data.unit == STYLE_UNIT_REL && pval.typed_data.value > 0)
1399: /* CSS relative sizes have to be higher than Thot ones */
1400: pval.typed_data.value += 1;
1401: else
1402: {
1403: real = pval.typed_data.real;
1404: if (pval.typed_data.unit == STYLE_UNIT_EM)
1405: {
1406: if (real)
1407: {
1408: pval.typed_data.value /= 10;
1.11 cvs 1409: pval.typed_data.real = FALSE;
1.1 cvs 1410: real = FALSE;
1411: }
1412: else
1413: pval.typed_data.value *= 100;
1414: pval.typed_data.unit = STYLE_UNIT_PERCENT;
1415: }
1416: }
1.25 cvs 1417:
1.1 cvs 1418: }
1419:
1.25 cvs 1420: /* install the presentation style */
1.1 cvs 1421: TtaSetStylePresentation (PRSize, element, tsch, context, pval);
1.25 cvs 1422:
1423: if (ptr != NULL)
1424: cssRule = ParseCSSLineSpacing (element, tsch, context, ptr, css, isHTML);
1.1 cvs 1425: return (cssRule);
1426: }
1427:
1428: /*----------------------------------------------------------------------
1.59 cvs 1429: ParseCSSFontFamily: parse a CSS font family string
1.1 cvs 1430: we expect the input string describing the attribute to be
1431: a common generic font style name
1432: ----------------------------------------------------------------------*/
1.79 cvs 1433: static char *ParseCSSFontFamily (Element element, PSchema tsch,
1434: PresentationContext context, char *cssRule,
1435: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1436: {
1437: PresentationValue font;
1.79 cvs 1438: char quoteChar;
1.1 cvs 1439:
1440: font.typed_data.value = 0;
1441: font.typed_data.unit = STYLE_UNIT_REL;
1442: font.typed_data.real = FALSE;
1.82 cvs 1443: cssRule = SkipBlanksAndComments (cssRule);
1444: if (*cssRule == '"' || *cssRule == '\'')
1.1 cvs 1445: {
1446: quoteChar = *cssRule;
1447: cssRule++;
1448: }
1449: else
1.82 cvs 1450: quoteChar = EOS;
1.1 cvs 1451:
1.92 cvs 1452: if (!strncasecmp (cssRule, "times", 5) &&
1453: (quoteChar == EOS || quoteChar == cssRule[5]))
1.86 cvs 1454: {
1.1 cvs 1455: font.typed_data.value = STYLE_FONT_TIMES;
1.86 cvs 1456: cssRule += 5;
1457: }
1.92 cvs 1458: else if (!strncasecmp (cssRule, "serif", 5) &&
1459: (quoteChar == EOS || quoteChar == cssRule[5]))
1.86 cvs 1460: {
1.1 cvs 1461: font.typed_data.value = STYLE_FONT_TIMES;
1.86 cvs 1462: cssRule += 5;
1.92 cvs 1463: if (quoteChar != EOS)
1464: cssRule++;
1.86 cvs 1465: }
1.92 cvs 1466: else if (!strncasecmp (cssRule, "helvetica", 9) &&
1467: (quoteChar == EOS || quoteChar == cssRule[9]))
1.86 cvs 1468: {
1469: font.typed_data.value = STYLE_FONT_HELVETICA;
1470: cssRule += 9;
1.92 cvs 1471: if (quoteChar != EOS)
1472: cssRule++;
1.86 cvs 1473: }
1.92 cvs 1474: else if (!strncasecmp (cssRule, "verdana", 7) &&
1475: (quoteChar == EOS || quoteChar == cssRule[7]))
1.86 cvs 1476: {
1.1 cvs 1477: font.typed_data.value = STYLE_FONT_HELVETICA;
1.86 cvs 1478: cssRule += 7;
1.92 cvs 1479: if (quoteChar != EOS)
1480: cssRule++;
1.86 cvs 1481: }
1.92 cvs 1482: else if (!strncasecmp (cssRule, "sans-serif", 10) &&
1483: (quoteChar == EOS || quoteChar == cssRule[10]))
1.86 cvs 1484: {
1.1 cvs 1485: font.typed_data.value = STYLE_FONT_HELVETICA;
1.86 cvs 1486: cssRule += 10;
1.92 cvs 1487: if (quoteChar != EOS)
1488: cssRule++;
1.86 cvs 1489: }
1.92 cvs 1490: else if (!strncasecmp (cssRule, "courier", 7) &&
1491: (quoteChar == EOS || quoteChar == cssRule[7]))
1.86 cvs 1492: {
1.1 cvs 1493: font.typed_data.value = STYLE_FONT_COURIER;
1.86 cvs 1494: cssRule += 7;
1.92 cvs 1495: if (quoteChar != EOS)
1496: cssRule++;
1.86 cvs 1497: }
1.92 cvs 1498: else if (!strncasecmp (cssRule, "monospace", 9) &&
1499: (quoteChar == EOS || quoteChar == cssRule[9]))
1.86 cvs 1500: {
1.1 cvs 1501: font.typed_data.value = STYLE_FONT_COURIER;
1.86 cvs 1502: cssRule += 9;
1.92 cvs 1503: if (quoteChar != EOS)
1504: cssRule++;
1.86 cvs 1505: }
1.1 cvs 1506: else
1507: /* unknown font name. Skip it */
1508: {
1.92 cvs 1509: if (quoteChar != EOS)
1.54 cvs 1510: cssRule = SkipQuotedString (cssRule, quoteChar);
1.86 cvs 1511: else
1.1 cvs 1512: cssRule = SkipWord (cssRule);
1.82 cvs 1513: cssRule = SkipBlanksAndComments (cssRule);
1514: if (*cssRule == ',')
1.1 cvs 1515: {
1.86 cvs 1516: cssRule++;
1517: cssRule = ParseCSSFontFamily (element, tsch, context, cssRule, css, isHTML);
1518: return (cssRule);
1.1 cvs 1519: }
1520: }
1521:
1522: if (font.typed_data.value != 0)
1523: {
1.93 vatton 1524: cssRule = SkipBlanksAndComments (cssRule);
1.99 vatton 1525: cssRule = SkipValue (cssRule, FALSE);
1.93 vatton 1526: /* install the new presentation */
1527: TtaSetStylePresentation (PRFont, element, tsch, context, font);
1.1 cvs 1528: }
1529: return (cssRule);
1530: }
1531:
1532: /*----------------------------------------------------------------------
1.59 cvs 1533: ParseCSSFontWeight: parse a CSS font weight string
1.1 cvs 1534: we expect the input string describing the attribute to be
1.20 cvs 1535: normal, bold, bolder, lighter, 100, 200, 300, ... 900, inherit.
1.1 cvs 1536: ----------------------------------------------------------------------*/
1.79 cvs 1537: static char *ParseCSSFontWeight (Element element, PSchema tsch,
1538: PresentationContext context, char *cssRule,
1539: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1540: {
1.20 cvs 1541: PresentationValue weight;
1.1 cvs 1542:
1543: weight.typed_data.value = 0;
1544: weight.typed_data.unit = STYLE_UNIT_REL;
1545: weight.typed_data.real = FALSE;
1.82 cvs 1546: cssRule = SkipBlanksAndComments (cssRule);
1547: if (!strncasecmp (cssRule, "100", 3) && !isalpha (cssRule[3]))
1.1 cvs 1548: {
1549: weight.typed_data.value = -3;
1550: cssRule = SkipWord (cssRule);
1551: }
1.82 cvs 1552: else if (!strncasecmp (cssRule, "200", 3) && !isalpha (cssRule[3]))
1.1 cvs 1553: {
1554: weight.typed_data.value = -2;
1555: cssRule = SkipWord (cssRule);
1556: }
1.82 cvs 1557: else if (!strncasecmp (cssRule, "300", 3) && ! isalpha(cssRule[3]))
1.1 cvs 1558: {
1559: weight.typed_data.value = -1;
1560: cssRule = SkipWord (cssRule);
1561: }
1.82 cvs 1562: else if (!strncasecmp (cssRule, "normal", 6) || (!strncasecmp (cssRule, "400", 3) && !isalpha (cssRule[3])))
1.1 cvs 1563: {
1564: weight.typed_data.value = 0;
1565: cssRule = SkipWord (cssRule);
1566: }
1.82 cvs 1567: else if (!strncasecmp (cssRule, "500", 3) && !isalpha (cssRule[3]))
1.1 cvs 1568: {
1569: weight.typed_data.value = +1;
1570: cssRule = SkipWord (cssRule);
1571: }
1.82 cvs 1572: else if (!strncasecmp (cssRule, "600", 3) && !isalpha (cssRule[3]))
1.1 cvs 1573: {
1574: weight.typed_data.value = +2;
1575: cssRule = SkipWord (cssRule);
1576: }
1.82 cvs 1577: else if (!strncasecmp (cssRule, "bold", 4) || (!strncasecmp (cssRule, "700", 3) && !isalpha (cssRule[3])))
1.1 cvs 1578: {
1579: weight.typed_data.value = +3;
1580: cssRule = SkipWord (cssRule);
1581: }
1.82 cvs 1582: else if (!strncasecmp (cssRule, "800", 3) && !isalpha (cssRule[3]))
1.1 cvs 1583: {
1584: weight.typed_data.value = +4;
1585: cssRule = SkipWord (cssRule);
1586: }
1.82 cvs 1587: else if (!strncasecmp (cssRule, "900", 3) && !isalpha (cssRule[3]))
1.1 cvs 1588: {
1589: weight.typed_data.value = +5;
1590: cssRule = SkipWord (cssRule);
1591: }
1.82 cvs 1592: else if (!strncasecmp (cssRule, "inherit", 7) || !strncasecmp (cssRule, "bolder", 6) || !strncasecmp (cssRule, "lighter", 7))
1.1 cvs 1593: {
1594: /* not implemented */
1595: cssRule = SkipWord (cssRule);
1596: return (cssRule);
1597: }
1598: else
1599: return (cssRule);
1600:
1601: /*
1.20 cvs 1602: * Here we have to reduce since only two font weight values are supported
1.1 cvs 1603: * by the Thot presentation API.
1604: */
1.20 cvs 1605: if (weight.typed_data.value > 0)
1606: weight.typed_data.value = STYLE_WEIGHT_BOLD;
1607: else
1608: weight.typed_data.value = STYLE_WEIGHT_NORMAL;
1.1 cvs 1609:
1610: /* install the new presentation */
1.21 cvs 1611: TtaSetStylePresentation (PRWeight, element, tsch, context, weight);
1.1 cvs 1612: return (cssRule);
1613: }
1614:
1615: /*----------------------------------------------------------------------
1.59 cvs 1616: ParseCSSFontVariant: parse a CSS font variant string
1.1 cvs 1617: we expect the input string describing the attribute to be
1618: normal or small-caps
1619: ----------------------------------------------------------------------*/
1.79 cvs 1620: static char *ParseCSSFontVariant (Element element, PSchema tsch,
1621: PresentationContext context, char *cssRule,
1622: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1623: {
1624: PresentationValue style;
1625:
1626: style.typed_data.value = 0;
1627: style.typed_data.unit = STYLE_UNIT_REL;
1628: style.typed_data.real = FALSE;
1.82 cvs 1629: cssRule = SkipBlanksAndComments (cssRule);
1630: if (!strncasecmp (cssRule, "small-caps", 10))
1.1 cvs 1631: {
1632: /* Not supported yet */
1633: cssRule = SkipWord (cssRule);
1634: }
1.82 cvs 1635: else if (!strncasecmp (cssRule, "normal", 6))
1.1 cvs 1636: {
1637: /* Not supported yet */
1638: cssRule = SkipWord (cssRule);
1639: }
1.82 cvs 1640: else if (!strncasecmp (cssRule, "inherit", 7))
1.1 cvs 1641: {
1642: /* Not supported yet */
1643: cssRule = SkipWord (cssRule);
1644: }
1645: else
1646: return (cssRule);
1647:
1648: return (cssRule);
1649: }
1650:
1651:
1652: /*----------------------------------------------------------------------
1.59 cvs 1653: ParseCSSFontStyle: parse a CSS font style string
1.1 cvs 1654: we expect the input string describing the attribute to be
1655: italic, oblique or normal
1656: ----------------------------------------------------------------------*/
1.79 cvs 1657: static char *ParseCSSFontStyle (Element element, PSchema tsch,
1658: PresentationContext context, char *cssRule,
1659: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1660: {
1661: PresentationValue style;
1662: PresentationValue size;
1663:
1664: style.typed_data.value = 0;
1665: style.typed_data.unit = STYLE_UNIT_REL;
1666: style.typed_data.real = FALSE;
1667: size.typed_data.value = 0;
1668: size.typed_data.unit = STYLE_UNIT_REL;
1669: size.typed_data.real = FALSE;
1.82 cvs 1670: cssRule = SkipBlanksAndComments (cssRule);
1671: if (!strncasecmp (cssRule, "italic", 6))
1.1 cvs 1672: {
1673: style.typed_data.value = STYLE_FONT_ITALICS;
1674: cssRule = SkipWord (cssRule);
1675: }
1.82 cvs 1676: else if (!strncasecmp (cssRule, "oblique", 7))
1.1 cvs 1677: {
1678: style.typed_data.value = STYLE_FONT_OBLIQUE;
1679: cssRule = SkipWord (cssRule);
1680: }
1.82 cvs 1681: else if (!strncasecmp (cssRule, "normal", 6))
1.1 cvs 1682: {
1683: style.typed_data.value = STYLE_FONT_ROMAN;
1684: cssRule = SkipWord (cssRule);
1685: }
1686: else
1687: {
1688: /* invalid font style */
1689: return (cssRule);
1690: }
1691:
1692: /*
1693: * install the new presentation.
1694: */
1695: if (style.typed_data.value != 0)
1.20 cvs 1696: TtaSetStylePresentation (PRStyle, element, tsch, context, style);
1.1 cvs 1697: if (size.typed_data.value != 0)
1698: {
1699: PresentationValue previous_size;
1700:
1701: if (!TtaGetStylePresentation (PRSize, element, tsch, context, &previous_size))
1702: {
1703: /* !!!!!!!!!!!!!!!!!!!!!!!! Unite + relatif !!!!!!!!!!!!!!!! */
1704: size.typed_data.value += previous_size.typed_data.value;
1705: TtaSetStylePresentation (PRSize, element, tsch, context, size);
1706: }
1707: else
1708: {
1709: size.typed_data.value = 10;
1710: TtaSetStylePresentation (PRSize, element, tsch, context, size);
1711: }
1712: }
1713: return (cssRule);
1714: }
1715:
1716: /*----------------------------------------------------------------------
1.59 cvs 1717: ParseCSSFont: parse a CSS font attribute string
1718: we expect the input string describing the attribute to be
1719: !!!!!!
1.1 cvs 1720: ----------------------------------------------------------------------*/
1.79 cvs 1721: static char *ParseCSSFont (Element element, PSchema tsch,
1722: PresentationContext context, char *cssRule,
1723: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1724: {
1.79 cvs 1725: char *ptr;
1.93 vatton 1726: int skippedNL;
1.1 cvs 1727:
1.82 cvs 1728: cssRule = SkipBlanksAndComments (cssRule);
1729: if (!strncasecmp (cssRule, "caption", 7))
1.1 cvs 1730: ;
1.82 cvs 1731: else if (!strncasecmp (cssRule, "icon", 4))
1.1 cvs 1732: ;
1.82 cvs 1733: else if (!strncasecmp (cssRule, "menu", 4))
1.1 cvs 1734: ;
1.82 cvs 1735: else if (!strncasecmp (cssRule, "message-box", 11))
1.1 cvs 1736: ;
1.82 cvs 1737: else if (!strncasecmp (cssRule, "small-caption", 13))
1.1 cvs 1738: ;
1.82 cvs 1739: else if (!strncasecmp (cssRule, "status-bar", 10))
1.1 cvs 1740: ;
1741: else
1.43 cvs 1742: {
1.82 cvs 1743: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
1.43 cvs 1744: {
1.72 cvs 1745: ptr = cssRule;
1.93 vatton 1746: skippedNL = NewLineSkipped;
1.72 cvs 1747: cssRule = ParseCSSFontStyle (element, tsch, context, cssRule, css, isHTML);
1748: if (ptr == cssRule)
1.93 vatton 1749: {
1750: NewLineSkipped = skippedNL;
1751: cssRule = ParseCSSFontVariant (element, tsch, context, cssRule, css, isHTML);
1752: }
1.72 cvs 1753: if (ptr == cssRule)
1.93 vatton 1754: {
1755: NewLineSkipped = skippedNL;
1756: cssRule = ParseCSSFontWeight (element, tsch, context, cssRule, css, isHTML);
1757: }
1.72 cvs 1758: if (ptr == cssRule)
1.93 vatton 1759: {
1760: NewLineSkipped = skippedNL;
1761: cssRule = ParseCSSFontSize (element, tsch, context, cssRule, css, isHTML);
1762: }
1.72 cvs 1763: if (ptr == cssRule)
1.93 vatton 1764: {
1765: NewLineSkipped = skippedNL;
1766: cssRule = ParseCSSFontFamily (element, tsch, context, cssRule, css, isHTML);
1767: }
1.99 vatton 1768: if (ptr == cssRule)
1769: cssRule = SkipValue (cssRule, TRUE);
1.82 cvs 1770: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 1771: }
1772: }
1773: return (cssRule);
1.1 cvs 1774: }
1775:
1776: /*----------------------------------------------------------------------
1.59 cvs 1777: ParseCSSTextDecoration: parse a CSS text decor string
1778: we expect the input string describing the attribute to be
1779: underline, overline, line-through, box, shadowbox, box3d,
1780: cartouche, blink or none
1.1 cvs 1781: ----------------------------------------------------------------------*/
1.79 cvs 1782: static char *ParseCSSTextDecoration (Element element, PSchema tsch,
1783: PresentationContext context, char *cssRule,
1784: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1785: {
1786: PresentationValue decor;
1787:
1788: decor.typed_data.value = 0;
1789: decor.typed_data.unit = STYLE_UNIT_REL;
1790: decor.typed_data.real = FALSE;
1.82 cvs 1791: cssRule = SkipBlanksAndComments (cssRule);
1792: if (!strncasecmp (cssRule, "underline", strlen ("underline")))
1.1 cvs 1793: {
1794: decor.typed_data.value = Underline;
1795: cssRule = SkipWord (cssRule);
1796: }
1.82 cvs 1797: else if (!strncasecmp (cssRule, "overline", strlen ("overline")))
1.1 cvs 1798: {
1799: decor.typed_data.value = Overline;
1800: cssRule = SkipWord (cssRule);
1801: }
1.82 cvs 1802: else if (!strncasecmp (cssRule, "line-through", strlen ("line-through")))
1.1 cvs 1803: {
1804: decor.typed_data.value = CrossOut;
1805: cssRule = SkipWord (cssRule);
1806: }
1.82 cvs 1807: else if (!strncasecmp (cssRule, "box", strlen ("box")))
1.1 cvs 1808: {
1809: /* the box text-decoration attribute is not yet supported */
1810: cssRule = SkipWord (cssRule);
1811: }
1.82 cvs 1812: else if (!strncasecmp (cssRule, "boxshadow", strlen ("boxshadow")))
1.1 cvs 1813: {
1814: /* the boxshadow text-decoration attribute is not yet supported */
1815: cssRule = SkipWord (cssRule);
1816: }
1.82 cvs 1817: else if (!strncasecmp (cssRule, "box3d", strlen ("box3d")))
1.1 cvs 1818: {
1819: /* the box3d text-decoration attribute is not yet supported */
1820: cssRule = SkipWord (cssRule);
1821: }
1.82 cvs 1822: else if (!strncasecmp (cssRule, "cartouche", strlen ("cartouche")))
1.1 cvs 1823: {
1824: /*the cartouche text-decoration attribute is not yet supported */
1825: cssRule = SkipWord (cssRule);
1826: }
1.82 cvs 1827: else if (!strncasecmp (cssRule, "blink", strlen ("blink")))
1.1 cvs 1828: {
1829: /*the blink text-decoration attribute will not be supported */
1830: cssRule = SkipWord (cssRule);
1831: }
1.82 cvs 1832: else if (!strncasecmp (cssRule, "none", strlen ("none")))
1.1 cvs 1833: {
1834: decor.typed_data.value = NoUnderline;
1835: cssRule = SkipWord (cssRule);
1836: }
1837: else
1838: {
1.86 cvs 1839: CSSParseError ("Invalid text decoration", cssRule);
1.1 cvs 1840: return (cssRule);
1841: }
1842:
1843: /*
1844: * install the new presentation.
1845: */
1846: if (decor.typed_data.value)
1847: {
1848: TtaSetStylePresentation (PRUnderline, element, tsch, context, decor);
1849: }
1850: return (cssRule);
1851: }
1852:
1853: /*----------------------------------------------------------------------
1.59 cvs 1854: ParseCSSHeight: parse a CSS height attribute
1.1 cvs 1855: ----------------------------------------------------------------------*/
1.79 cvs 1856: static char *ParseCSSHeight (Element element, PSchema tsch,
1.93 vatton 1857: PresentationContext context, char *cssRule,
1858: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1859: {
1.93 vatton 1860: PresentationValue val;
1861:
1.82 cvs 1862: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 1863: /* first parse the attribute string */
1.82 cvs 1864: if (!strcasecmp (cssRule, "auto"))
1.93 vatton 1865: cssRule = SkipWord (cssRule);
1866: else
1.1 cvs 1867: {
1.93 vatton 1868: cssRule = ParseCSSUnit (cssRule, &val);
1869: if (val.typed_data.unit != STYLE_UNIT_INVALID)
1870: /* install the new presentation */
1871: TtaSetStylePresentation (PRHeight, element, tsch, context, val);
1.1 cvs 1872: }
1873: return (cssRule);
1874: }
1875:
1876: /*----------------------------------------------------------------------
1.59 cvs 1877: ParseCSSWidth: parse a CSS width attribute
1.1 cvs 1878: ----------------------------------------------------------------------*/
1.79 cvs 1879: static char *ParseCSSWidth (Element element, PSchema tsch,
1.78 cvs 1880: PresentationContext context,
1.79 cvs 1881: char *cssRule, CSSInfoPtr css,
1.78 cvs 1882: ThotBool isHTML)
1.1 cvs 1883: {
1.93 vatton 1884: PresentationValue val;
1885:
1.82 cvs 1886: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 1887: /* first parse the attribute string */
1.82 cvs 1888: if (!strcasecmp (cssRule, "auto"))
1.93 vatton 1889: cssRule = SkipWord (cssRule);
1890: else
1.1 cvs 1891: {
1.93 vatton 1892: cssRule = ParseCSSUnit (cssRule, &val);
1893: if (val.typed_data.unit != STYLE_UNIT_INVALID)
1894: /* install the new presentation */
1895: TtaSetStylePresentation (PRWidth, element, tsch, context, val);
1.1 cvs 1896: }
1897: return (cssRule);
1898: }
1899:
1900: /*----------------------------------------------------------------------
1.59 cvs 1901: ParseCSSMarginTop: parse a CSS margin-top attribute
1.1 cvs 1902: ----------------------------------------------------------------------*/
1.79 cvs 1903: static char *ParseCSSMarginTop (Element element, PSchema tsch,
1.78 cvs 1904: PresentationContext context,
1.79 cvs 1905: char *cssRule, CSSInfoPtr css,
1.78 cvs 1906: ThotBool isHTML)
1.1 cvs 1907: {
1908: PresentationValue margin;
1909:
1.82 cvs 1910: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 1911: /* first parse the attribute string */
1912: cssRule = ParseCSSUnit (cssRule, &margin);
1.43 cvs 1913: if (margin.typed_data.unit != STYLE_UNIT_INVALID)
1.98 vatton 1914: TtaSetStylePresentation (PRMarginTop, element, tsch, context, margin);
1.1 cvs 1915: return (cssRule);
1916: }
1917:
1918: /*----------------------------------------------------------------------
1.59 cvs 1919: ParseCSSMarginBottom: parse a CSS margin-bottom attribute
1.1 cvs 1920: ----------------------------------------------------------------------*/
1.79 cvs 1921: static char *ParseCSSMarginBottom (Element element, PSchema tsch,
1.78 cvs 1922: PresentationContext context,
1.79 cvs 1923: char *cssRule, CSSInfoPtr css,
1.78 cvs 1924: ThotBool isHTML)
1.1 cvs 1925: {
1926: PresentationValue margin;
1927:
1.82 cvs 1928: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 1929: /* first parse the attribute string */
1930: cssRule = ParseCSSUnit (cssRule, &margin);
1.43 cvs 1931: if (margin.typed_data.unit != STYLE_UNIT_INVALID)
1932: TtaSetStylePresentation (PRMarginBottom, element, tsch, context, margin);
1.1 cvs 1933: return (cssRule);
1934: }
1935:
1936: /*----------------------------------------------------------------------
1.59 cvs 1937: ParseCSSMarginLeft: parse a CSS margin-left attribute string
1.1 cvs 1938: ----------------------------------------------------------------------*/
1.79 cvs 1939: static char *ParseCSSMarginLeft (Element element, PSchema tsch,
1.78 cvs 1940: PresentationContext context,
1.79 cvs 1941: char *cssRule, CSSInfoPtr css,
1.78 cvs 1942: ThotBool isHTML)
1.1 cvs 1943: {
1944: PresentationValue margin;
1945:
1.82 cvs 1946: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 1947: /* first parse the attribute string */
1948: cssRule = ParseCSSUnit (cssRule, &margin);
1.43 cvs 1949: if (margin.typed_data.unit != STYLE_UNIT_INVALID)
1.98 vatton 1950: TtaSetStylePresentation (PRMarginLeft, element, tsch, context, margin);
1.1 cvs 1951: return (cssRule);
1952: }
1953:
1954: /*----------------------------------------------------------------------
1.59 cvs 1955: ParseCSSMarginRight: parse a CSS margin-right attribute string
1.1 cvs 1956: ----------------------------------------------------------------------*/
1.79 cvs 1957: static char *ParseCSSMarginRight (Element element, PSchema tsch,
1.78 cvs 1958: PresentationContext context,
1.79 cvs 1959: char *cssRule, CSSInfoPtr css,
1.78 cvs 1960: ThotBool isHTML)
1.1 cvs 1961: {
1962: PresentationValue margin;
1963:
1.82 cvs 1964: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 1965: /* first parse the attribute string */
1966: cssRule = ParseCSSUnit (cssRule, &margin);
1.43 cvs 1967: if (margin.typed_data.unit != STYLE_UNIT_INVALID)
1968: TtaSetStylePresentation (PRMarginRight, element, tsch, context, margin);
1.1 cvs 1969: return (cssRule);
1970: }
1971:
1972: /*----------------------------------------------------------------------
1.59 cvs 1973: ParseCSSMargin: parse a CSS margin attribute string
1.1 cvs 1974: ----------------------------------------------------------------------*/
1.79 cvs 1975: static char *ParseCSSMargin (Element element, PSchema tsch,
1.78 cvs 1976: PresentationContext context,
1.79 cvs 1977: char *cssRule, CSSInfoPtr css,
1.78 cvs 1978: ThotBool isHTML)
1.1 cvs 1979: {
1.79 cvs 1980: char *ptrT, *ptrR, *ptrB, *ptrL;
1.93 vatton 1981: int skippedNL;
1.1 cvs 1982:
1.82 cvs 1983: ptrT = SkipBlanksAndComments (cssRule);
1.1 cvs 1984: /* First parse Margin-Top */
1985: ptrR = ParseCSSMarginTop (element, tsch, context, ptrT, css, isHTML);
1.82 cvs 1986: ptrR = SkipBlanksAndComments (ptrR);
1987: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1.1 cvs 1988: {
1.93 vatton 1989: skippedNL = NewLineSkipped;
1.1 cvs 1990: cssRule = ptrR;
1991: /* apply the Margin-Top to all */
1992: ptrR = ParseCSSMarginRight (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 1993: NewLineSkipped = skippedNL;
1.1 cvs 1994: ptrR = ParseCSSMarginBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 1995: NewLineSkipped = skippedNL;
1.1 cvs 1996: ptrR = ParseCSSMarginLeft (element, tsch, context, ptrT, css, isHTML);
1997: }
1998: else
1999: {
2000: /* parse Margin-Right */
2001: ptrB = ParseCSSMarginRight (element, tsch, context, ptrR, css, isHTML);
1.82 cvs 2002: ptrB = SkipBlanksAndComments (ptrB);
2003: if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
1.1 cvs 2004: {
1.93 vatton 2005: skippedNL = NewLineSkipped;
1.1 cvs 2006: cssRule = ptrB;
2007: /* apply the Margin-Top to Margin-Bottom */
2008: ptrB = ParseCSSMarginBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 2009: NewLineSkipped = skippedNL;
1.1 cvs 2010: /* apply the Margin-Right to Margin-Left */
2011: ptrB = ParseCSSMarginLeft (element, tsch, context, ptrR, css, isHTML);
2012: }
2013: else
2014: {
2015: /* parse Margin-Bottom */
2016: ptrL = ParseCSSMarginBottom (element, tsch, context, ptrB, css, isHTML);
1.82 cvs 2017: ptrL = SkipBlanksAndComments (ptrL);
2018: if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
1.1 cvs 2019: {
2020: cssRule = ptrL;
2021: /* apply the Margin-Right to Margin-Left */
2022: ptrL = ParseCSSMarginLeft (element, tsch, context, ptrR, css, isHTML);
2023: }
2024: else
2025: /* parse Margin-Left */
2026: cssRule = ParseCSSMarginLeft (element, tsch, context, ptrL, css, isHTML);
1.82 cvs 2027: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 2028: }
2029: }
2030: return (cssRule);
2031: }
2032:
2033: /*----------------------------------------------------------------------
1.59 cvs 2034: ParseCSSPaddingTop: parse a CSS PaddingTop attribute string
1.1 cvs 2035: ----------------------------------------------------------------------*/
1.79 cvs 2036: static char *ParseCSSPaddingTop (Element element, PSchema tsch,
1.78 cvs 2037: PresentationContext context,
1.79 cvs 2038: char *cssRule, CSSInfoPtr css,
1.78 cvs 2039: ThotBool isHTML)
1.1 cvs 2040: {
1.43 cvs 2041: PresentationValue padding;
2042:
1.82 cvs 2043: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 2044: /* first parse the attribute string */
2045: cssRule = ParseCSSUnit (cssRule, &padding);
2046: if (padding.typed_data.unit != STYLE_UNIT_INVALID)
2047: TtaSetStylePresentation (PRPaddingTop, element, tsch, context, padding);
1.1 cvs 2048: return (cssRule);
2049: }
2050:
2051: /*----------------------------------------------------------------------
1.59 cvs 2052: ParseCSSPaddingBottom: parse a CSS PaddingBottom attribute string
1.1 cvs 2053: ----------------------------------------------------------------------*/
1.79 cvs 2054: static char *ParseCSSPaddingBottom (Element element, PSchema tsch,
1.78 cvs 2055: PresentationContext context,
1.79 cvs 2056: char *cssRule, CSSInfoPtr css,
1.78 cvs 2057: ThotBool isHTML)
1.1 cvs 2058: {
1.43 cvs 2059: PresentationValue padding;
2060:
1.82 cvs 2061: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 2062: /* first parse the attribute string */
2063: cssRule = ParseCSSUnit (cssRule, &padding);
2064: if (padding.typed_data.unit != STYLE_UNIT_INVALID)
2065: TtaSetStylePresentation (PRPaddingBottom, element, tsch, context, padding);
1.1 cvs 2066: return (cssRule);
2067: }
2068:
2069: /*----------------------------------------------------------------------
1.59 cvs 2070: ParseCSSPaddingLeft: parse a CSS PaddingLeft attribute string.
1.1 cvs 2071: ----------------------------------------------------------------------*/
1.79 cvs 2072: static char *ParseCSSPaddingLeft (Element element, PSchema tsch,
1.78 cvs 2073: PresentationContext context,
1.79 cvs 2074: char *cssRule, CSSInfoPtr css,
1.78 cvs 2075: ThotBool isHTML)
1.1 cvs 2076: {
1.43 cvs 2077: PresentationValue padding;
2078:
1.82 cvs 2079: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 2080: /* first parse the attribute string */
2081: cssRule = ParseCSSUnit (cssRule, &padding);
2082: if (padding.typed_data.unit != STYLE_UNIT_INVALID)
2083: TtaSetStylePresentation (PRPaddingLeft, element, tsch, context, padding);
1.1 cvs 2084: return (cssRule);
2085: }
2086:
2087: /*----------------------------------------------------------------------
1.59 cvs 2088: ParseCSSPaddingRight: parse a CSS PaddingRight attribute string.
1.1 cvs 2089: ----------------------------------------------------------------------*/
1.79 cvs 2090: static char *ParseCSSPaddingRight (Element element, PSchema tsch,
1.78 cvs 2091: PresentationContext context,
1.79 cvs 2092: char *cssRule, CSSInfoPtr css,
1.78 cvs 2093: ThotBool isHTML)
1.1 cvs 2094: {
1.43 cvs 2095: PresentationValue padding;
2096:
1.82 cvs 2097: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 2098: /* first parse the attribute string */
2099: cssRule = ParseCSSUnit (cssRule, &padding);
2100: if (padding.typed_data.unit != STYLE_UNIT_INVALID)
2101: TtaSetStylePresentation (PRPaddingRight, element, tsch, context, padding);
1.1 cvs 2102: return (cssRule);
2103: }
2104:
2105: /*----------------------------------------------------------------------
1.59 cvs 2106: ParseCSSPadding: parse a CSS padding attribute string.
1.1 cvs 2107: ----------------------------------------------------------------------*/
1.79 cvs 2108: static char *ParseCSSPadding (Element element, PSchema tsch,
1.78 cvs 2109: PresentationContext context,
1.79 cvs 2110: char *cssRule, CSSInfoPtr css,
1.78 cvs 2111: ThotBool isHTML)
1.1 cvs 2112: {
1.79 cvs 2113: char *ptrT, *ptrR, *ptrB, *ptrL;
1.93 vatton 2114: int skippedNL;
1.43 cvs 2115:
1.82 cvs 2116: ptrT = SkipBlanksAndComments (cssRule);
1.43 cvs 2117: /* First parse Padding-Top */
2118: ptrR = ParseCSSPaddingTop (element, tsch, context, ptrT, css, isHTML);
1.82 cvs 2119: ptrR = SkipBlanksAndComments (ptrR);
2120: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1.43 cvs 2121: {
1.93 vatton 2122: skippedNL = NewLineSkipped;
1.43 cvs 2123: cssRule = ptrR;
2124: /* apply the Padding-Top to all */
2125: ptrR = ParseCSSPaddingRight (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 2126: NewLineSkipped = skippedNL;
1.43 cvs 2127: ptrR = ParseCSSPaddingBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 2128: NewLineSkipped = skippedNL;
1.43 cvs 2129: ptrR = ParseCSSPaddingLeft (element, tsch, context, ptrT, css, isHTML);
2130: }
2131: else
2132: {
2133: /* parse Padding-Right */
2134: ptrB = ParseCSSPaddingRight (element, tsch, context, ptrR, css, isHTML);
1.82 cvs 2135: ptrB = SkipBlanksAndComments (ptrB);
2136: if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
1.43 cvs 2137: {
1.93 vatton 2138: skippedNL = NewLineSkipped;
1.43 cvs 2139: cssRule = ptrB;
2140: /* apply the Padding-Top to Padding-Bottom */
2141: ptrB = ParseCSSPaddingBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 2142: NewLineSkipped = skippedNL;
1.43 cvs 2143: /* apply the Padding-Right to Padding-Left */
2144: ptrB = ParseCSSPaddingLeft (element, tsch, context, ptrR, css, isHTML);
2145: }
2146: else
2147: {
2148: /* parse Padding-Bottom */
2149: ptrL = ParseCSSPaddingBottom (element, tsch, context, ptrB, css, isHTML);
1.82 cvs 2150: ptrL = SkipBlanksAndComments (ptrL);
2151: if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
1.43 cvs 2152: {
2153: cssRule = ptrL;
2154: /* apply the Padding-Right to Padding-Left */
2155: ptrL = ParseCSSPaddingLeft (element, tsch, context, ptrR, css, isHTML);
2156: }
2157: else
2158: /* parse Padding-Left */
2159: cssRule = ParseCSSPaddingLeft (element, tsch, context, ptrL, css, isHTML);
1.82 cvs 2160: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 2161: }
2162: }
1.1 cvs 2163: return (cssRule);
2164: }
2165:
2166: /*----------------------------------------------------------------------
1.59 cvs 2167: ParseCSSForeground: parse a CSS foreground attribute
1.1 cvs 2168: ----------------------------------------------------------------------*/
1.79 cvs 2169: static char *ParseCSSForeground (Element element, PSchema tsch,
1.78 cvs 2170: PresentationContext context,
1.79 cvs 2171: char *cssRule,
1.78 cvs 2172: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2173: {
2174: PresentationValue best;
2175:
2176: cssRule = ParseCSSColor (cssRule, &best);
1.25 cvs 2177: if (best.typed_data.unit != STYLE_UNIT_INVALID)
2178: /* install the new presentation */
2179: TtaSetStylePresentation (PRForeground, element, tsch, context, best);
1.1 cvs 2180: return (cssRule);
2181: }
2182:
2183: /*----------------------------------------------------------------------
1.59 cvs 2184: ParseCSSBackgroundColor: parse a CSS background color attribute
1.1 cvs 2185: ----------------------------------------------------------------------*/
1.79 cvs 2186: static char *ParseCSSBackgroundColor (Element element, PSchema tsch,
1.78 cvs 2187: PresentationContext context,
1.79 cvs 2188: char *cssRule,
1.78 cvs 2189: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2190: {
2191: PresentationValue best;
2192: unsigned int savedtype = 0;
1.14 cvs 2193: ThotBool moved;
1.1 cvs 2194:
2195: /* move the BODY rule to the HTML element */
2196: moved = (context->type == HTML_EL_BODY && isHTML);
2197: if (moved)
2198: {
2199: if (element)
2200: element = TtaGetMainRoot (context->doc);
2201: else
2202: {
2203: savedtype = context->type;
1.83 cvs 2204: context->type = HTML_EL_Document;
1.1 cvs 2205: }
2206: }
2207:
2208: best.typed_data.unit = STYLE_UNIT_INVALID;
2209: best.typed_data.real = FALSE;
1.82 cvs 2210: if (!strncasecmp (cssRule, "transparent", strlen ("transparent")))
1.1 cvs 2211: {
2212: best.typed_data.value = STYLE_PATTERN_NONE;
2213: best.typed_data.unit = STYLE_UNIT_REL;
2214: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
1.65 cvs 2215: cssRule = SkipWord (cssRule);
1.1 cvs 2216: }
2217: else
2218: {
2219: cssRule = ParseCSSColor (cssRule, &best);
2220: if (best.typed_data.unit != STYLE_UNIT_INVALID)
2221: {
2222: /* install the new presentation. */
2223: TtaSetStylePresentation (PRBackground, element, tsch, context, best);
1.59 cvs 2224: /* thot specificity: need to set fill pattern for background color */
1.1 cvs 2225: best.typed_data.value = STYLE_PATTERN_BACKGROUND;
2226: best.typed_data.unit = STYLE_UNIT_REL;
2227: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
2228: best.typed_data.value = 1;
2229: best.typed_data.unit = STYLE_UNIT_REL;
2230: TtaSetStylePresentation (PRShowBox, element, tsch, context, best);
2231: }
2232: }
2233:
2234: /* restore the refered element */
2235: if (moved && !element)
2236: context->type = savedtype;
2237: return (cssRule);
2238: }
2239:
1.63 cvs 2240:
2241: /*----------------------------------------------------------------------
1.65 cvs 2242: ParseSVGStroke: parse a SVG stroke property
2243: ----------------------------------------------------------------------*/
1.79 cvs 2244: static char *ParseSVGStroke (Element element, PSchema tsch,
2245: PresentationContext context, char *cssRule,
2246: CSSInfoPtr css, ThotBool isHTML)
1.65 cvs 2247: {
2248: PresentationValue best;
2249:
2250: best.typed_data.unit = STYLE_UNIT_INVALID;
2251: best.typed_data.real = FALSE;
1.82 cvs 2252: if (!strncasecmp (cssRule, "none", 4))
1.65 cvs 2253: {
2254: best.typed_data.value = -2; /* -2 means transparent */
2255: best.typed_data.unit = STYLE_UNIT_REL;
2256: TtaSetStylePresentation (PRForeground, element, tsch, context, best);
2257: cssRule = SkipWord (cssRule);
2258: }
2259: else
2260: {
2261: cssRule = ParseCSSColor (cssRule, &best);
2262: if (best.typed_data.unit != STYLE_UNIT_INVALID)
2263: /* install the new presentation */
2264: TtaSetStylePresentation (PRForeground, element, tsch, context, best);
2265: }
2266: return (cssRule);
2267: }
2268:
2269: /*----------------------------------------------------------------------
1.63 cvs 2270: ParseSVGFill: parse a SVG fill property
2271: ----------------------------------------------------------------------*/
1.79 cvs 2272: static char *ParseSVGFill (Element element, PSchema tsch,
2273: PresentationContext context, char *cssRule,
2274: CSSInfoPtr css, ThotBool isHTML)
1.63 cvs 2275: {
2276: PresentationValue best;
2277:
2278: best.typed_data.unit = STYLE_UNIT_INVALID;
2279: best.typed_data.real = FALSE;
1.82 cvs 2280: if (!strncasecmp (cssRule, "none", 4))
1.63 cvs 2281: {
2282: best.typed_data.value = STYLE_PATTERN_NONE;
2283: best.typed_data.unit = STYLE_UNIT_REL;
2284: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
1.65 cvs 2285: cssRule = SkipWord (cssRule);
1.63 cvs 2286: }
2287: else
2288: {
2289: cssRule = ParseCSSColor (cssRule, &best);
2290: if (best.typed_data.unit != STYLE_UNIT_INVALID)
2291: {
2292: /* install the new presentation. */
2293: TtaSetStylePresentation (PRBackground, element, tsch, context, best);
2294: /* thot specificity: need to set fill pattern for background color */
2295: best.typed_data.value = STYLE_PATTERN_BACKGROUND;
2296: best.typed_data.unit = STYLE_UNIT_REL;
2297: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
2298: }
2299: }
2300: return (cssRule);
2301: }
2302:
1.1 cvs 2303: /*----------------------------------------------------------------------
1.59 cvs 2304: ParseCSSBackgroundImageCallback: Callback called asynchronously by
2305: FetchImage when a background image has been fetched.
1.1 cvs 2306: ----------------------------------------------------------------------*/
1.82 cvs 2307: void ParseCSSBackgroundImageCallback (Document doc, Element element,
2308: char *file, void *extra)
1.1 cvs 2309: {
1.82 cvs 2310: DisplayMode dispMode;
2311: BackgroundImageCallbackPtr callblock;
2312: Element el;
2313: PSchema tsch;
2314: PresentationContext context;
2315: PresentationValue image;
2316: PresentationValue value;
1.1 cvs 2317:
1.82 cvs 2318: callblock = (BackgroundImageCallbackPtr) extra;
1.34 cvs 2319: if (callblock == NULL)
2320: return;
1.1 cvs 2321:
1.34 cvs 2322: /* avoid too many redisplay */
2323: dispMode = TtaGetDisplayMode (doc);
2324: if (dispMode == DisplayImmediately)
2325: TtaSetDisplayMode (doc, DeferredDisplay);
2326:
2327: el = callblock->el;
2328: tsch = callblock->tsch;
2329: context = &callblock->context.specific;
2330:
2331: /* Ok the image was fetched, finish the background-image handling */
2332: image.pointer = file;
2333: TtaSetStylePresentation (PRBackgroundPicture, el, tsch, context, image);
1.1 cvs 2334:
1.70 cvs 2335: /* enforce the showbox */
1.34 cvs 2336: value.typed_data.value = 1;
2337: value.typed_data.unit = STYLE_UNIT_REL;
2338: value.typed_data.real = FALSE;
2339: TtaSetStylePresentation (PRShowBox, el, tsch, context, value);
2340:
2341: TtaFreeMemory (callblock);
2342: /* restore the display mode */
2343: if (dispMode == DisplayImmediately)
2344: TtaSetDisplayMode (doc, dispMode);
1.1 cvs 2345: }
2346:
2347:
2348: /*----------------------------------------------------------------------
2349: GetCSSBackgroundURL searches a CSS BackgroundImage url within
2350: the styleString.
2351: Returns NULL or a new allocated url string.
2352: ----------------------------------------------------------------------*/
1.79 cvs 2353: char *GetCSSBackgroundURL (char *styleString)
1.1 cvs 2354: {
1.79 cvs 2355: char *b, *e, *ptr;
2356: int len;
1.1 cvs 2357:
2358: ptr = NULL;
1.82 cvs 2359: b = strstr (styleString, "url");
1.1 cvs 2360: if (b != NULL)
2361: {
2362: b += 3;
1.82 cvs 2363: b = SkipBlanksAndComments (b);
2364: if (*b == '(')
1.1 cvs 2365: {
2366: b++;
1.82 cvs 2367: b = SkipBlanksAndComments (b);
1.1 cvs 2368: /*** Caution: Strings can either be written with double quotes or
2369: with single quotes. Only double quotes are handled here.
2370: Escaped quotes are not handled. See function SkipQuotedString */
1.82 cvs 2371: if (*b == '"')
1.1 cvs 2372: {
2373: b++;
2374: /* search the url end */
2375: e = b;
1.82 cvs 2376: while (*e != EOS && *e != '"')
1.1 cvs 2377: e++;
2378: }
2379: else
2380: {
2381: /* search the url end */
2382: e = b;
1.82 cvs 2383: while (*e != EOS && *e != ')')
1.1 cvs 2384: e++;
2385: }
1.82 cvs 2386: if (*e != EOS)
1.1 cvs 2387: {
2388: len = (int)(e - b);
1.82 cvs 2389: ptr = (char*) TtaGetMemory (len+1);
2390: strncpy (ptr, b, len);
2391: ptr[len] = EOS;
1.1 cvs 2392: }
2393: }
2394: }
2395: return (ptr);
2396: }
2397:
2398:
2399: /*----------------------------------------------------------------------
1.59 cvs 2400: ParseCSSBackgroundImage: parse a CSS BackgroundImage attribute string.
1.1 cvs 2401: ----------------------------------------------------------------------*/
1.79 cvs 2402: static char *ParseCSSBackgroundImage (Element element, PSchema tsch,
2403: PresentationContext context,
2404: char *cssRule, CSSInfoPtr css,
2405: ThotBool isHTML)
1.1 cvs 2406: {
1.49 cvs 2407: Element el;
2408: GenericContext gblock;
1.71 cvs 2409: PresentationContext sblock;
1.1 cvs 2410: BackgroundImageCallbackPtr callblock;
1.49 cvs 2411: PresentationValue image, value;
1.79 cvs 2412: char *url;
1.82 cvs 2413: char *bg_image;
1.79 cvs 2414: char saved;
2415: char *base;
2416: char tempname[MAX_LENGTH];
2417: char imgname[MAX_LENGTH];
1.49 cvs 2418: unsigned int savedtype = 0;
2419: ThotBool moved;
1.1 cvs 2420:
2421: /* default element for FetchImage */
2422: el = TtaGetMainRoot (context->doc);
2423: /* move the BODY rule to the HTML element */
2424: moved = (context->type == HTML_EL_BODY && isHTML);
2425: if (moved)
2426: {
2427: if (element)
2428: element = el;
2429: else
2430: {
2431: savedtype = context->type;
1.83 cvs 2432: context->type = HTML_EL_Document;
1.1 cvs 2433: }
2434: }
2435: else if (element)
2436: el = element;
2437:
2438: url = NULL;
1.82 cvs 2439: cssRule = SkipBlanksAndComments (cssRule);
2440: if (!strncasecmp (cssRule, "url", 3))
1.1 cvs 2441: {
2442: cssRule += 3;
1.82 cvs 2443: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 2444: if (*cssRule == '(')
2445: {
2446: cssRule++;
1.82 cvs 2447: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 2448: /*** Caution: Strings can either be written with double quotes or
2449: with single quotes. Only double quotes are handled here.
2450: Escaped quotes are not handled. See function SkipQuotedString */
2451: if (*cssRule == '"')
2452: {
2453: cssRule++;
2454: base = cssRule;
1.82 cvs 2455: while (*cssRule != EOS && *cssRule != '"')
1.1 cvs 2456: cssRule++;
2457: }
2458: else
2459: {
2460: base = cssRule;
2461: while (*cssRule != EOS && *cssRule != ')')
2462: cssRule++;
2463: }
2464: saved = *cssRule;
1.82 cvs 2465: *cssRule = EOS;
2466: url = TtaStrdup (base);
1.1 cvs 2467: *cssRule = saved;
2468: if (saved == '"')
2469: /* we need to skip two characters */
2470: cssRule++;
2471: }
2472: cssRule++;
2473:
2474: if (context->destroy)
2475: {
2476: /* remove the background image PRule */
2477: image.pointer = NULL;
2478: TtaSetStylePresentation (PRBackgroundPicture, element, tsch, context, image);
2479: if (TtaGetStylePresentation (PRFillPattern, element, tsch, context, &value) < 0)
2480: {
2481: /* there is no FillPattern rule -> remove ShowBox rule */
2482: value.typed_data.value = 1;
2483: value.typed_data.unit = STYLE_UNIT_REL;
2484: value.typed_data.real = FALSE;
2485: TtaSetStylePresentation (PRShowBox, element, tsch, context, value);
2486: }
2487: }
2488: else if (url)
2489: {
1.30 cvs 2490: bg_image = TtaGetEnvString ("ENABLE_BG_IMAGES");
1.82 cvs 2491: if (bg_image == NULL || !strcasecmp (bg_image, "yes"))
1.1 cvs 2492: {
2493: callblock = (BackgroundImageCallbackPtr) TtaGetMemory(sizeof(BackgroundImageCallbackBlock));
2494: if (callblock != NULL)
2495: {
2496: callblock->el = element;
2497: callblock->tsch = tsch;
2498: if (element == NULL)
1.18 cvs 2499: {
2500: gblock = (GenericContext) context;
2501: memcpy (&callblock->context.generic, gblock,
2502: sizeof (GenericContextBlock));
2503: }
2504: else
2505: {
2506: sblock = context;
2507: memcpy (&callblock->context.specific, sblock,
2508: sizeof(PresentationContextBlock));
2509: }
2510:
2511: /* check if the image url is related to an external CSS */
2512: if (css != NULL && css->category == CSS_EXTERNAL_STYLE)
2513: {
2514: NormalizeURL (url, 0, tempname, imgname, css->url);
2515: /* fetch and display background image of element */
1.49 cvs 2516: FetchImage (context->doc, el, tempname, AMAYA_LOAD_IMAGE, ParseCSSBackgroundImageCallback, callblock);
1.18 cvs 2517: }
2518: else
1.49 cvs 2519: FetchImage (context->doc, el, url, AMAYA_LOAD_IMAGE, ParseCSSBackgroundImageCallback, callblock);
1.18 cvs 2520: }
2521: }
2522:
2523: if (url)
2524: TtaFreeMemory (url);
2525: }
2526: }
2527:
2528: /* restore the refered element */
2529: if (moved && !element)
2530: context->type = savedtype;
2531: return (cssRule);
2532: }
2533:
2534: /*----------------------------------------------------------------------
1.59 cvs 2535: ParseCSSBackgroundRepeat: parse a CSS BackgroundRepeat attribute string.
1.18 cvs 2536: ----------------------------------------------------------------------*/
1.79 cvs 2537: static char *ParseCSSBackgroundRepeat (Element element, PSchema tsch,
1.97 vatton 2538: PresentationContext context,
2539: char *cssRule, CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 2540: {
2541: PresentationValue repeat;
2542: unsigned int savedtype = 0;
2543: ThotBool moved;
2544:
2545: /* move the BODY rule to the HTML element */
2546: moved = (context->type == HTML_EL_BODY && isHTML);
2547: if (moved)
2548: {
2549: if (element)
2550: element = TtaGetMainRoot (context->doc);
2551: else
2552: {
2553: savedtype = context->type;
1.83 cvs 2554: context->type = HTML_EL_Document;
1.18 cvs 2555: }
2556: }
2557:
2558: repeat.typed_data.value = STYLE_REALSIZE;
2559: repeat.typed_data.unit = STYLE_UNIT_REL;
2560: repeat.typed_data.real = FALSE;
1.82 cvs 2561: cssRule = SkipBlanksAndComments (cssRule);
2562: if (!strncasecmp (cssRule, "no-repeat", 9))
1.18 cvs 2563: repeat.typed_data.value = STYLE_REALSIZE;
1.82 cvs 2564: else if (!strncasecmp (cssRule, "repeat-y", 8))
1.18 cvs 2565: repeat.typed_data.value = STYLE_VREPEAT;
1.82 cvs 2566: else if (!strncasecmp (cssRule, "repeat-x", 8))
1.18 cvs 2567: repeat.typed_data.value = STYLE_HREPEAT;
1.82 cvs 2568: else if (!strncasecmp (cssRule, "repeat", 6))
1.18 cvs 2569: repeat.typed_data.value = STYLE_REPEAT;
2570: else
2571: return (cssRule);
2572:
2573: /* install the new presentation */
2574: TtaSetStylePresentation (PRPictureMode, element, tsch, context, repeat);
2575: cssRule = SkipWord (cssRule);
2576:
2577: /* restore the refered element */
2578: if (moved && !element)
2579: context->type = savedtype;
2580: return (cssRule);
2581: }
2582:
2583: /*----------------------------------------------------------------------
1.59 cvs 2584: ParseCSSBackgroundAttachment: parse a CSS BackgroundAttachment
1.18 cvs 2585: attribute string.
2586: ----------------------------------------------------------------------*/
1.79 cvs 2587: static char *ParseCSSBackgroundAttachment (Element element, PSchema tsch,
2588: PresentationContext context,
2589: char *cssRule, CSSInfoPtr css,
2590: ThotBool isHTML)
1.18 cvs 2591: {
2592: unsigned int savedtype = 0;
2593: ThotBool moved;
1.1 cvs 2594:
1.18 cvs 2595: /* move the BODY rule to the HTML element */
2596: moved = (context->type == HTML_EL_BODY && isHTML);
2597: if (moved)
2598: {
2599: if (element)
2600: element = TtaGetMainRoot (context->doc);
2601: else
2602: {
2603: savedtype = context->type;
1.83 cvs 2604: context->type = HTML_EL_Document;
1.1 cvs 2605: }
2606: }
2607:
1.82 cvs 2608: cssRule = SkipBlanksAndComments (cssRule);
2609: if (!strncasecmp (cssRule, "scroll", 6))
1.18 cvs 2610: cssRule = SkipWord (cssRule);
1.82 cvs 2611: else if (!strncasecmp (cssRule, "fixed", 5))
1.18 cvs 2612: cssRule = SkipWord (cssRule);
2613:
1.1 cvs 2614: /* restore the refered element */
2615: if (moved && !element)
2616: context->type = savedtype;
1.18 cvs 2617: return (cssRule);
1.1 cvs 2618: }
2619:
2620: /*----------------------------------------------------------------------
1.59 cvs 2621: ParseCSSBackgroundPosition: parse a CSS BackgroundPosition
1.1 cvs 2622: attribute string.
2623: ----------------------------------------------------------------------*/
1.79 cvs 2624: static char *ParseCSSBackgroundPosition (Element element, PSchema tsch,
2625: PresentationContext context,
2626: char *cssRule, CSSInfoPtr css,
2627: ThotBool isHTML)
1.1 cvs 2628: {
1.18 cvs 2629: PresentationValue repeat;
2630: unsigned int savedtype = 0;
2631: ThotBool moved;
2632: ThotBool ok;
1.1 cvs 2633:
2634: /* move the BODY rule to the HTML element */
2635: moved = (context->type == HTML_EL_BODY && isHTML);
2636: if (moved)
2637: {
2638: if (element)
2639: element = TtaGetMainRoot (context->doc);
2640: else
2641: {
2642: savedtype = context->type;
1.83 cvs 2643: context->type = HTML_EL_Document;
1.1 cvs 2644: }
2645: }
2646:
1.82 cvs 2647: cssRule = SkipBlanksAndComments (cssRule);
1.18 cvs 2648: ok = TRUE;
1.82 cvs 2649: if (!strncasecmp (cssRule, "left", 4))
1.18 cvs 2650: cssRule = SkipWord (cssRule);
1.82 cvs 2651: else if (!strncasecmp (cssRule, "right", 5))
1.18 cvs 2652: cssRule = SkipWord (cssRule);
1.82 cvs 2653: else if (!strncasecmp (cssRule, "center", 6))
1.18 cvs 2654: cssRule = SkipWord (cssRule);
1.82 cvs 2655: else if (!strncasecmp (cssRule, "top", 3))
1.18 cvs 2656: cssRule = SkipWord (cssRule);
1.82 cvs 2657: else if (!strncasecmp (cssRule, "bottom", 6))
1.18 cvs 2658: cssRule = SkipWord (cssRule);
1.82 cvs 2659: else if (isdigit (*cssRule))
1.18 cvs 2660: cssRule = SkipWord (cssRule);
2661: else
2662: ok = FALSE;
2663:
2664: if (ok)
2665: {
2666: /* force realsize for the background image */
2667: repeat.typed_data.value = STYLE_REALSIZE;
2668: repeat.typed_data.unit = STYLE_UNIT_REL;
2669: repeat.typed_data.real = FALSE;
2670: TtaSetStylePresentation (PRPictureMode, element, tsch, context, repeat);
2671: }
2672:
2673: /* restore the refered element */
2674: if (moved && !element)
2675: context->type = savedtype;
2676: return (cssRule);
2677: }
2678:
2679: /*----------------------------------------------------------------------
1.59 cvs 2680: ParseCSSBackground: parse a CSS background attribute
1.18 cvs 2681: ----------------------------------------------------------------------*/
1.79 cvs 2682: static char *ParseCSSBackground (Element element, PSchema tsch,
2683: PresentationContext context, char *cssRule,
2684: CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 2685: {
1.79 cvs 2686: char *ptr;
1.93 vatton 2687: int skippedNL;
1.18 cvs 2688:
1.82 cvs 2689: cssRule = SkipBlanksAndComments (cssRule);
2690: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
1.18 cvs 2691: {
1.71 cvs 2692: /* perhaps a Background Image */
1.82 cvs 2693: if (!strncasecmp (cssRule, "url", 3))
1.63 cvs 2694: cssRule = ParseCSSBackgroundImage (element, tsch, context, cssRule,
2695: css, isHTML);
1.18 cvs 2696: /* perhaps a Background Attachment */
1.82 cvs 2697: else if (!strncasecmp (cssRule, "scroll", 6) ||
2698: !strncasecmp (cssRule, "fixed", 5))
1.63 cvs 2699: cssRule = ParseCSSBackgroundAttachment (element, tsch, context,
2700: cssRule, css, isHTML);
1.18 cvs 2701: /* perhaps a Background Repeat */
1.82 cvs 2702: else if (!strncasecmp (cssRule, "no-repeat", 9) ||
2703: !strncasecmp (cssRule, "repeat-y", 8) ||
2704: !strncasecmp (cssRule, "repeat-x", 8) ||
2705: !strncasecmp (cssRule, "repeat", 6))
2706: cssRule = ParseCSSBackgroundRepeat (element, tsch, context,
2707: cssRule, css, isHTML);
1.18 cvs 2708: /* perhaps a Background Position */
1.82 cvs 2709: else if (!strncasecmp (cssRule, "left", 4) ||
2710: !strncasecmp (cssRule, "right", 5) ||
2711: !strncasecmp (cssRule, "center", 6) ||
2712: !strncasecmp (cssRule, "top", 3) ||
2713: !strncasecmp (cssRule, "bottom", 6) ||
2714: isdigit (*cssRule))
1.63 cvs 2715: cssRule = ParseCSSBackgroundPosition (element, tsch, context,
2716: cssRule, css, isHTML);
1.18 cvs 2717: /* perhaps a Background Color */
2718: else
2719: {
1.93 vatton 2720: skippedNL = NewLineSkipped;
1.18 cvs 2721: /* check if the rule has been found */
2722: ptr = cssRule;
1.82 cvs 2723: cssRule = ParseCSSBackgroundColor (element, tsch, context,
2724: cssRule, css, isHTML);
1.43 cvs 2725: if (ptr == cssRule)
1.93 vatton 2726: {
2727: NewLineSkipped = skippedNL;
2728: /* rule not found */
2729: cssRule = SkipProperty (cssRule);
2730: }
1.18 cvs 2731: }
1.82 cvs 2732: cssRule = SkipBlanksAndComments (cssRule);
1.18 cvs 2733: }
2734: return (cssRule);
2735: }
2736:
1.59 cvs 2737: /*----------------------------------------------------------------------
1.60 cvs 2738: ParseCSSPageBreakBefore: parse a CSS page-break-before attribute
1.59 cvs 2739: ----------------------------------------------------------------------*/
1.79 cvs 2740: static char *ParseCSSPageBreakBefore (Element element, PSchema tsch,
2741: PresentationContext context, char *cssRule,
2742: CSSInfoPtr css, ThotBool isHTML)
1.59 cvs 2743: {
2744: PresentationValue page;
2745:
2746: page.typed_data.unit = STYLE_UNIT_INVALID;
2747: page.typed_data.real = FALSE;
1.82 cvs 2748: cssRule = SkipBlanksAndComments (cssRule);
2749: if (!strncasecmp (cssRule, "auto", 4))
1.59 cvs 2750: {
2751: /*page.typed_data.unit = STYLE_UNIT_REL;*/
2752: page.typed_data.value = STYLE_AUTO;
2753: }
1.82 cvs 2754: else if (!strncasecmp (cssRule, "always", 6))
1.59 cvs 2755: {
2756: page.typed_data.unit = STYLE_UNIT_REL;
2757: page.typed_data.value = STYLE_ALWAYS;
2758: }
1.82 cvs 2759: else if (!strncasecmp (cssRule, "avoid", 5))
1.59 cvs 2760: {
2761: page.typed_data.unit = STYLE_UNIT_REL;
2762: page.typed_data.value = STYLE_AVOID;
2763: }
1.82 cvs 2764: else if (!strncasecmp (cssRule, "left", 4))
1.59 cvs 2765: {
2766: page.typed_data.unit = STYLE_UNIT_REL;
2767: page.typed_data.value = STYLE_PAGELEFT;
2768: }
1.82 cvs 2769: else if (!strncasecmp (cssRule, "right", 5))
1.59 cvs 2770: {
2771: page.typed_data.unit = STYLE_UNIT_REL;
2772: page.typed_data.value = STYLE_PAGERIGHT;
2773: }
1.82 cvs 2774: else if (!strncasecmp (cssRule, "inherit", 7))
1.59 cvs 2775: {
2776: /*page.typed_data.unit = STYLE_UNIT_REL;*/
2777: page.typed_data.value = STYLE_INHERIT;
2778: }
2779: cssRule = SkipWord (cssRule);
2780: /* install the new presentation */
2781: if (page.typed_data.unit == STYLE_UNIT_REL &&
2782: page.typed_data.value == STYLE_ALWAYS)
2783: TtaSetStylePresentation (PRPageBefore, element, tsch, context, page);
2784: return (cssRule);
2785: }
2786:
2787: /*----------------------------------------------------------------------
1.60 cvs 2788: ParseCSSPageBreakAfter: parse a CSS page-break-after attribute
1.59 cvs 2789: ----------------------------------------------------------------------*/
1.79 cvs 2790: static char *ParseCSSPageBreakAfter (Element element, PSchema tsch,
2791: PresentationContext context,
2792: char *cssRule, CSSInfoPtr css,
2793: ThotBool isHTML)
1.59 cvs 2794: {
2795: PresentationValue page;
2796:
2797: page.typed_data.unit = STYLE_UNIT_INVALID;
2798: page.typed_data.real = FALSE;
1.82 cvs 2799: cssRule = SkipBlanksAndComments (cssRule);
2800: if (!strncasecmp (cssRule, "auto", 4))
1.59 cvs 2801: {
2802: /*page.typed_data.unit = STYLE_UNIT_REL;*/
2803: page.typed_data.value = STYLE_AUTO;
2804: }
1.82 cvs 2805: else if (!strncasecmp (cssRule, "always", 6))
1.59 cvs 2806: {
2807: page.typed_data.unit = STYLE_UNIT_REL;
2808: page.typed_data.value = STYLE_ALWAYS;
2809: }
1.82 cvs 2810: else if (!strncasecmp (cssRule, "avoid", 5))
1.59 cvs 2811: {
2812: page.typed_data.unit = STYLE_UNIT_REL;
2813: page.typed_data.value = STYLE_AVOID;
2814: }
1.82 cvs 2815: else if (!strncasecmp (cssRule, "left", 4))
1.59 cvs 2816: {
2817: page.typed_data.unit = STYLE_UNIT_REL;
2818: page.typed_data.value = STYLE_PAGELEFT;
2819: }
1.82 cvs 2820: else if (!strncasecmp (cssRule, "right", 5))
1.59 cvs 2821: {
2822: page.typed_data.unit = STYLE_UNIT_REL;
2823: page.typed_data.value = STYLE_PAGERIGHT;
2824: }
1.82 cvs 2825: else if (!strncasecmp (cssRule, "inherit", 7))
1.59 cvs 2826: {
2827: /*page.typed_data.unit = STYLE_UNIT_REL;*/
2828: page.typed_data.value = STYLE_INHERIT;
2829: }
2830: cssRule = SkipWord (cssRule);
2831: /* install the new presentation */
2832: /*if (page.typed_data.unit == STYLE_UNIT_REL)
2833: TtaSetStylePresentation (PRPageAfter, element, tsch, context, page);*/
2834: return (cssRule);
2835: }
2836:
2837: /*----------------------------------------------------------------------
1.60 cvs 2838: ParseCSSPageBreakInside: parse a CSS page-break-inside attribute
1.59 cvs 2839: ----------------------------------------------------------------------*/
1.79 cvs 2840: static char *ParseCSSPageBreakInside (Element element, PSchema tsch,
2841: PresentationContext context,
2842: char *cssRule, CSSInfoPtr css,
2843: ThotBool isHTML)
1.59 cvs 2844: {
2845: PresentationValue page;
2846:
2847: page.typed_data.unit = STYLE_UNIT_INVALID;
2848: page.typed_data.real = FALSE;
1.82 cvs 2849: cssRule = SkipBlanksAndComments (cssRule);
2850: if (!strncasecmp (cssRule, "auto", 4))
1.59 cvs 2851: {
2852: /*page.typed_data.unit = STYLE_UNIT_REL;*/
2853: page.typed_data.value = STYLE_AUTO;
2854: }
1.82 cvs 2855: else if (!strncasecmp (cssRule, "avoid", 5))
1.59 cvs 2856: {
2857: page.typed_data.unit = STYLE_UNIT_REL;
2858: page.typed_data.value = STYLE_AVOID;
2859: }
1.82 cvs 2860: else if (!strncasecmp (cssRule, "inherit", 7))
1.59 cvs 2861: {
2862: /*page.typed_data.unit = STYLE_UNIT_REL;*/
2863: page.typed_data.value = STYLE_INHERIT;
2864: }
2865: cssRule = SkipWord (cssRule);
2866: /* install the new presentation */
1.96 vatton 2867: /*if (page.typed_data.unit == STYLE_UNIT_REL &&
1.59 cvs 2868: page.typed_data.value == STYLE_AVOID)
1.96 vatton 2869: TtaSetStylePresentation (PRPageInside, element, tsch, context, page);*/
1.59 cvs 2870: return (cssRule);
2871: }
1.18 cvs 2872:
2873:
1.60 cvs 2874: /*----------------------------------------------------------------------
1.63 cvs 2875: ParseSVGStrokeWidth: parse a SVG stroke-width property value.
1.60 cvs 2876: ----------------------------------------------------------------------*/
1.79 cvs 2877: static char *ParseSVGStrokeWidth (Element element, PSchema tsch,
2878: PresentationContext context, char *cssRule,
2879: CSSInfoPtr css, ThotBool isHTML)
1.60 cvs 2880: {
2881: PresentationValue width;
2882:
1.82 cvs 2883: cssRule = SkipBlanksAndComments (cssRule);
1.60 cvs 2884: width.typed_data.value = 0;
2885: width.typed_data.unit = STYLE_UNIT_INVALID;
2886: width.typed_data.real = FALSE;
1.82 cvs 2887: if (isdigit (*cssRule))
1.60 cvs 2888: cssRule = ParseCSSUnit (cssRule, &width);
2889: if (width.typed_data.unit != STYLE_UNIT_INVALID)
2890: {
2891: TtaSetStylePresentation (PRLineWeight, element, tsch, context, width);
2892: width.typed_data.value = 1;
2893: width.typed_data.unit = STYLE_UNIT_REL;
2894: }
2895: return (cssRule);
2896: }
2897:
1.18 cvs 2898: /************************************************************************
2899: * *
2900: * FUNCTIONS STYLE DECLARATIONS *
2901: * *
2902: ************************************************************************/
2903: /*
1.59 cvs 2904: * NOTE: Long attribute name MUST be placed before shortened ones !
1.18 cvs 2905: * e.g. "FONT-SIZE" must be placed before "FONT"
2906: */
2907: static CSSProperty CSSProperties[] =
2908: {
1.82 cvs 2909: {"font-family", ParseCSSFontFamily},
2910: {"font-style", ParseCSSFontStyle},
2911: {"font-variant", ParseCSSFontVariant},
2912: {"font-weight", ParseCSSFontWeight},
2913: {"font-size", ParseCSSFontSize},
2914: {"font", ParseCSSFont},
2915:
2916: {"color", ParseCSSForeground},
2917: {"background-color", ParseCSSBackgroundColor},
2918: {"background-image", ParseCSSBackgroundImage},
2919: {"background-repeat", ParseCSSBackgroundRepeat},
2920: {"background-attachment", ParseCSSBackgroundAttachment},
2921: {"background-position", ParseCSSBackgroundPosition},
2922: {"background", ParseCSSBackground},
2923:
2924: {"word-spacing", ParseCSSWordSpacing},
2925: {"letter-spacing", ParseCSSLetterSpacing},
2926: {"text-decoration", ParseCSSTextDecoration},
2927: {"vertical-align", ParseCSSVerticalAlign},
2928: {"text-transform", ParseCSSTextTransform},
2929: {"text-align", ParseCSSTextAlign},
2930: {"text-indent", ParseCSSTextIndent},
2931: {"line-height", ParseCSSLineSpacing},
2932:
2933: {"margin-top", ParseCSSMarginTop},
2934: {"margin-right", ParseCSSMarginRight},
2935: {"margin-bottom", ParseCSSMarginBottom},
2936: {"margin-left", ParseCSSMarginLeft},
2937: {"margin", ParseCSSMargin},
2938:
2939: {"padding-top", ParseCSSPaddingTop},
2940: {"padding-right", ParseCSSPaddingRight},
2941: {"padding-bottom", ParseCSSPaddingBottom},
2942: {"padding-left", ParseCSSPaddingLeft},
2943: {"padding", ParseCSSPadding},
2944:
2945: {"border-top-width", ParseCSSBorderTopWidth},
2946: {"border-right-width", ParseCSSBorderRightWidth},
2947: {"border-bottom-width", ParseCSSBorderBottomWidth},
2948: {"border-left-width", ParseCSSBorderLeftWidth},
2949: {"border-width", ParseCSSBorderWidth},
2950: {"border-top-color", ParseCSSBorderColorTop},
2951: {"border-right-color", ParseCSSBorderColorRight},
2952: {"border-bottom-color", ParseCSSBorderColorBottom},
2953: {"border-left-color", ParseCSSBorderColorLeft},
2954: {"border-color", ParseCSSBorderColor},
2955: {"border-top-style", ParseCSSBorderStyleTop},
2956: {"border-right-style", ParseCSSBorderStyleRight},
2957: {"border-bottom-style", ParseCSSBorderStyleBottom},
2958: {"border-left-style", ParseCSSBorderStyleLeft},
2959: {"border-style", ParseCSSBorderStyle},
2960: {"border-top", ParseCSSBorderTop},
2961: {"border-right", ParseCSSBorderRight},
2962: {"border-bottom", ParseCSSBorderBottom},
2963: {"border-left", ParseCSSBorderLeft},
2964: {"border", ParseCSSBorder},
2965:
2966: {"width", ParseCSSWidth},
2967: {"height", ParseCSSHeight},
2968: {"float", ParseCSSFloat},
2969: {"clear", ParseCSSClear},
2970:
2971: {"display", ParseCSSDisplay},
2972: {"white-space", ParseCSSWhiteSpace},
2973:
2974: {"list-style-type", ParseCSSListStyleType},
2975: {"list-style-image", ParseCSSListStyleImage},
2976: {"list-style-position", ParseCSSListStylePosition},
2977: {"list-style", ParseCSSListStyle},
2978:
2979: {"page-break-before", ParseCSSPageBreakBefore},
2980: {"page-break-after", ParseCSSPageBreakAfter},
2981: {"page-break-inside", ParseCSSPageBreakInside},
1.60 cvs 2982:
2983: /* SVG extensions */
1.82 cvs 2984: {"stroke-width", ParseSVGStrokeWidth},
2985: {"stroke", ParseSVGStroke},
2986: {"fill", ParseSVGFill}
1.18 cvs 2987: };
2988: #define NB_CSSSTYLEATTRIBUTE (sizeof(CSSProperties) / sizeof(CSSProperty))
2989:
2990: /*----------------------------------------------------------------------
1.59 cvs 2991: ParseCSSRule: parse a CSS Style string
1.18 cvs 2992: we expect the input string describing the style to be of the
1.59 cvs 2993: form: PRORPERTY: DESCRIPTION [ ; PROPERTY: DESCRIPTION ] *
1.18 cvs 2994: but tolerate incorrect or incomplete input
2995: ----------------------------------------------------------------------*/
1.79 cvs 2996: static void ParseCSSRule (Element element, PSchema tsch,
2997: PresentationContext context, char *cssRule,
2998: CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 2999: {
1.34 cvs 3000: DisplayMode dispMode;
1.79 cvs 3001: char *p = NULL;
1.18 cvs 3002: int lg;
1.34 cvs 3003: unsigned int i;
1.76 cvs 3004: ThotBool found;
1.18 cvs 3005:
1.34 cvs 3006: /* avoid too many redisplay */
3007: dispMode = TtaGetDisplayMode (context->doc);
3008: if (dispMode == DisplayImmediately)
3009: TtaSetDisplayMode (context->doc, DeferredDisplay);
3010:
1.82 cvs 3011: while (*cssRule != EOS)
1.18 cvs 3012: {
1.82 cvs 3013: cssRule = SkipBlanksAndComments (cssRule);
1.89 cvs 3014: if (*cssRule == '{')
3015: {
3016: cssRule++;
3017: CSSParseError ("Invalid character", "{");
3018: cssRule = SkipBlanksAndComments (cssRule);
3019: }
1.18 cvs 3020:
3021: found = FALSE;
3022: /* look for the type of property */
3023: for (i = 0; i < NB_CSSSTYLEATTRIBUTE && !found; i++)
3024: {
1.82 cvs 3025: lg = strlen (CSSProperties[i].name);
3026: if (!strncasecmp (cssRule, CSSProperties[i].name, lg))
1.18 cvs 3027: {
1.86 cvs 3028: p = cssRule + lg;
1.18 cvs 3029: found = TRUE;
3030: i--;
3031: }
3032: }
3033:
3034: if (i == NB_CSSSTYLEATTRIBUTE)
3035: cssRule = SkipProperty (cssRule);
3036: else
3037: {
3038: /* update index and skip the ":" indicator if present */
1.86 cvs 3039: p = SkipBlanksAndComments (p);
3040: if (*p == ':')
1.18 cvs 3041: {
1.86 cvs 3042: p++;
3043: p = SkipBlanksAndComments (p);
1.74 cvs 3044: /* try to parse the value associated with this property */
3045: if (CSSProperties[i].parsing_function != NULL)
1.61 cvs 3046: {
1.75 cvs 3047: p = CSSProperties[i].parsing_function (element, tsch, context,
1.86 cvs 3048: p, css, isHTML);
1.74 cvs 3049: /* update index and skip the ";" separator if present */
3050: cssRule = p;
1.61 cvs 3051: }
1.18 cvs 3052: }
1.74 cvs 3053: else
3054: cssRule = SkipProperty (cssRule);
1.18 cvs 3055: }
1.89 cvs 3056:
1.18 cvs 3057: /* next property */
1.82 cvs 3058: cssRule = SkipBlanksAndComments (cssRule);
1.89 cvs 3059: if (*cssRule == '}')
3060: {
3061: cssRule++;
3062: CSSParseError ("Invalid character", "}");
3063: cssRule = SkipBlanksAndComments (cssRule);
3064: }
1.82 cvs 3065: if (*cssRule == ',' || *cssRule == ';')
1.18 cvs 3066: {
3067: cssRule++;
1.82 cvs 3068: cssRule = SkipBlanksAndComments (cssRule);
1.18 cvs 3069: }
3070: }
1.34 cvs 3071:
3072: /* restore the display mode */
3073: if (dispMode == DisplayImmediately)
3074: TtaSetDisplayMode (context->doc, dispMode);
1.18 cvs 3075: }
1.1 cvs 3076:
3077:
3078: /*----------------------------------------------------------------------
1.59 cvs 3079: PToCss: translate a PresentationSetting to the
1.18 cvs 3080: equivalent CSS string, and add it to the buffer given as the
1.67 cvs 3081: argument. It is used when extracting the CSS string from actual
3082: presentation.
3083: el is the element for which the style rule is generated
1.18 cvs 3084:
3085: All the possible values returned by the presentation drivers are
3086: described in thotlib/include/presentation.h
3087: -----------------------------------------------------------------------*/
1.79 cvs 3088: void PToCss (PresentationSetting settings, char *buffer, int len, Element el)
1.1 cvs 3089: {
1.76 cvs 3090: ElementType elType;
1.18 cvs 3091: float fval = 0;
3092: unsigned short red, green, blue;
3093: int add_unit = 0;
3094: unsigned int unit, i;
3095: ThotBool real = FALSE;
3096:
1.82 cvs 3097: buffer[0] = EOS;
1.18 cvs 3098: if (len < 40)
3099: return;
3100:
3101: unit = settings->value.typed_data.unit;
3102: if (settings->value.typed_data.real)
3103: {
3104: real = TRUE;
3105: fval = (float) settings->value.typed_data.value;
3106: fval /= 1000;
3107: }
1.1 cvs 3108:
1.18 cvs 3109: switch (settings->type)
1.1 cvs 3110: {
1.18 cvs 3111: case PRVisibility:
3112: break;
3113: case PRFont:
3114: switch (settings->value.typed_data.value)
3115: {
3116: case STYLE_FONT_HELVETICA:
1.82 cvs 3117: strcpy (buffer, "font-family: helvetica");
1.18 cvs 3118: break;
3119: case STYLE_FONT_TIMES:
1.82 cvs 3120: strcpy (buffer, "font-family: times");
1.18 cvs 3121: break;
3122: case STYLE_FONT_COURIER:
1.82 cvs 3123: strcpy (buffer, "font-family: courier");
1.18 cvs 3124: break;
3125: }
3126: break;
3127: case PRStyle:
3128: switch (settings->value.typed_data.value)
3129: {
3130: case STYLE_FONT_ROMAN:
1.82 cvs 3131: strcpy (buffer, "font-style: normal");
1.18 cvs 3132: break;
3133: case STYLE_FONT_ITALICS:
1.82 cvs 3134: strcpy (buffer, "font-style: italic");
1.18 cvs 3135: break;
3136: case STYLE_FONT_OBLIQUE:
1.82 cvs 3137: strcpy (buffer, "font-style: oblique");
1.18 cvs 3138: break;
1.20 cvs 3139: }
3140: break;
3141: case PRWeight:
3142: switch (settings->value.typed_data.value)
3143: {
3144: case STYLE_WEIGHT_BOLD:
1.82 cvs 3145: strcpy (buffer, "font-weight: bold");
1.20 cvs 3146: break;
3147: case STYLE_WEIGHT_NORMAL:
1.82 cvs 3148: strcpy (buffer, "font-weight: normal");
1.18 cvs 3149: break;
3150: }
3151: break;
3152: case PRSize:
3153: if (unit == STYLE_UNIT_REL)
3154: {
3155: if (real)
3156: {
1.82 cvs 3157: sprintf (buffer, "font-size: %g", fval);
1.18 cvs 3158: add_unit = 1;
3159: }
3160: else
3161: switch (settings->value.typed_data.value)
3162: {
3163: case 1:
1.82 cvs 3164: strcpy (buffer, "font-size: xx-small");
1.18 cvs 3165: break;
3166: case 2:
1.82 cvs 3167: strcpy (buffer, "font-size: x-small");
1.18 cvs 3168: break;
3169: case 3:
1.82 cvs 3170: strcpy (buffer, "font-size: small");
1.18 cvs 3171: break;
3172: case 4:
1.82 cvs 3173: strcpy (buffer, "font-size: medium");
1.18 cvs 3174: break;
3175: case 5:
1.82 cvs 3176: strcpy (buffer, "font-size: large");
1.18 cvs 3177: break;
3178: case 6:
1.82 cvs 3179: strcpy (buffer, "font-size: x-large");
1.18 cvs 3180: break;
3181: case 7:
3182: case 8:
3183: case 9:
3184: case 10:
3185: case 11:
3186: case 12:
1.82 cvs 3187: strcpy (buffer, "font-size: xx-large");
1.18 cvs 3188: break;
3189: }
3190: }
3191: else
3192: {
3193: if (real)
1.82 cvs 3194: sprintf (buffer, "font-size: %g", fval);
1.18 cvs 3195: else
1.82 cvs 3196: sprintf (buffer, "font-size: %d",
1.67 cvs 3197: settings->value.typed_data.value);
1.18 cvs 3198: add_unit = 1;
3199: }
3200: break;
3201: case PRUnderline:
3202: switch (settings->value.typed_data.value)
3203: {
3204: case STYLE_UNDERLINE:
1.82 cvs 3205: strcpy (buffer, "text-decoration: underline");
1.18 cvs 3206: break;
3207: case STYLE_OVERLINE:
1.82 cvs 3208: strcpy (buffer, "text-decoration: overline");
1.18 cvs 3209: break;
3210: case STYLE_CROSSOUT:
1.82 cvs 3211: strcpy (buffer, "text-decoration: line-through");
1.18 cvs 3212: break;
3213: }
3214: break;
3215: case PRIndent:
3216: if (real)
1.82 cvs 3217: sprintf (buffer, "text-indent: %g", fval);
1.18 cvs 3218: else
1.82 cvs 3219: sprintf (buffer, "text-indent: %d",
1.67 cvs 3220: settings->value.typed_data.value);
1.18 cvs 3221: add_unit = 1;
3222: break;
3223: case PRLineSpacing:
3224: if (real)
1.82 cvs 3225: sprintf (buffer, "line-height: %g", fval);
1.1 cvs 3226: else
1.82 cvs 3227: sprintf (buffer, "line-height: %d",
1.67 cvs 3228: settings->value.typed_data.value);
1.18 cvs 3229: add_unit = 1;
3230: break;
3231: case PRAdjust:
3232: switch (settings->value.typed_data.value)
1.1 cvs 3233: {
1.18 cvs 3234: case STYLE_ADJUSTLEFT:
1.82 cvs 3235: strcpy (buffer, "text-align: left");
1.18 cvs 3236: break;
3237: case STYLE_ADJUSTRIGHT:
1.82 cvs 3238: strcpy (buffer, "text-align: right");
1.18 cvs 3239: break;
3240: case STYLE_ADJUSTCENTERED:
1.82 cvs 3241: strcpy (buffer, "text-align: center");
1.18 cvs 3242: break;
3243: case STYLE_ADJUSTLEFTWITHDOTS:
1.82 cvs 3244: strcpy (buffer, "text-align: left");
1.81 cvs 3245: break;
3246: case STYLE_ADJUSTJUSTIFY:
1.82 cvs 3247: strcpy (buffer, "text-align: justify");
1.18 cvs 3248: break;
1.1 cvs 3249: }
1.18 cvs 3250: break;
3251: case PRHyphenate:
3252: break;
3253: case PRFillPattern:
3254: break;
3255: case PRBackground:
3256: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
1.76 cvs 3257: elType = TtaGetElementType(el);
1.100 vatton 3258: #ifdef _SVG
3259: if (strcmp(TtaGetSSchemaName (elType.ElSSchema), "SVG") == 0)
1.82 cvs 3260: sprintf (buffer, "fill: #%02X%02X%02X", red, green, blue);
1.67 cvs 3261: else
1.100 vatton 3262: #endif /* _SVG */
1.82 cvs 3263: sprintf (buffer, "background-color: #%02X%02X%02X", red, green,
1.67 cvs 3264: blue);
1.18 cvs 3265: break;
3266: case PRForeground:
3267: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
1.76 cvs 3268: elType = TtaGetElementType(el);
1.100 vatton 3269: #ifdef _SVG
3270: if (strcmp(TtaGetSSchemaName (elType.ElSSchema), "SVG") == 0)
1.82 cvs 3271: sprintf (buffer, "stroke: #%02X%02X%02X", red, green, blue);
1.67 cvs 3272: else
1.100 vatton 3273: #endif /* _SVG */
1.82 cvs 3274: sprintf (buffer, "color: #%02X%02X%02X", red, green, blue);
1.67 cvs 3275: break;
3276: case PRLineWeight:
1.76 cvs 3277: elType = TtaGetElementType(el);
1.100 vatton 3278: #ifdef _SVG
3279: if (!strcmp(TtaGetSSchemaName (elType.ElSSchema), "SVG"))
3280: #endif /* _SVG */
1.69 cvs 3281: {
3282: if (real)
1.82 cvs 3283: sprintf (buffer, "stroke-width: %g", fval);
1.69 cvs 3284: else
1.82 cvs 3285: sprintf (buffer, "stroke-width: %d",
1.69 cvs 3286: settings->value.typed_data.value);
3287: }
1.67 cvs 3288: add_unit = 1;
1.18 cvs 3289: break;
1.67 cvs 3290:
1.40 cvs 3291: case PRMarginTop:
1.18 cvs 3292: if (real)
1.82 cvs 3293: sprintf (buffer, "marging-top: %g", fval);
1.18 cvs 3294: else
1.82 cvs 3295: sprintf (buffer, "marging-top: %d",
1.67 cvs 3296: settings->value.typed_data.value);
1.18 cvs 3297: add_unit = 1;
3298: break;
1.40 cvs 3299: case PRMarginLeft:
1.18 cvs 3300: if (real)
1.82 cvs 3301: sprintf (buffer, "margin-left: %g", fval);
1.18 cvs 3302: else
1.82 cvs 3303: sprintf (buffer, "margin-left: %d",
1.67 cvs 3304: settings->value.typed_data.value);
1.18 cvs 3305: add_unit = 1;
3306: break;
3307: case PRHeight:
3308: if (real)
1.82 cvs 3309: sprintf (buffer, "height: %g", fval);
1.18 cvs 3310: else
1.82 cvs 3311: sprintf (buffer, "height: %d", settings->value.typed_data.value);
1.18 cvs 3312: add_unit = 1;
3313: break;
3314: case PRWidth:
3315: if (real)
1.82 cvs 3316: sprintf (buffer, "width: %g", fval);
1.1 cvs 3317: else
1.82 cvs 3318: sprintf (buffer, "width: %d", settings->value.typed_data.value);
1.18 cvs 3319: add_unit = 1;
3320: break;
3321: case PRLine:
3322: if (settings->value.typed_data.value == STYLE_INLINE)
1.82 cvs 3323: strcpy (buffer, "display: inline");
1.18 cvs 3324: else if (settings->value.typed_data.value == STYLE_NOTINLINE)
1.82 cvs 3325: strcpy (buffer, "display: block");
1.18 cvs 3326: break;
3327: case PRBackgroundPicture:
3328: if (settings->value.pointer != NULL)
1.82 cvs 3329: sprintf (buffer, "background-image: url(%s)",
1.67 cvs 3330: (char*)(settings->value.pointer));
1.1 cvs 3331: else
1.82 cvs 3332: sprintf (buffer, "background-image: none");
1.18 cvs 3333: break;
3334: case PRPictureMode:
3335: switch (settings->value.typed_data.value)
1.1 cvs 3336: {
1.18 cvs 3337: case STYLE_REALSIZE:
1.82 cvs 3338: sprintf (buffer, "background-repeat: no-repeat");
1.18 cvs 3339: break;
3340: case STYLE_REPEAT:
1.82 cvs 3341: sprintf (buffer, "background-repeat: repeat");
1.18 cvs 3342: break;
3343: case STYLE_VREPEAT:
1.82 cvs 3344: sprintf (buffer, "background-repeat: repeat-y");
1.18 cvs 3345: break;
3346: case STYLE_HREPEAT:
1.82 cvs 3347: sprintf (buffer, "background-repeat: repeat-x");
1.18 cvs 3348: break;
1.1 cvs 3349: }
1.18 cvs 3350: break;
3351: default:
3352: break;
1.1 cvs 3353: }
3354:
1.18 cvs 3355: if (add_unit)
1.1 cvs 3356: {
1.18 cvs 3357: /* add the unit string to the CSS string */
3358: for (i = 0; i < NB_UNITS; i++)
1.1 cvs 3359: {
1.18 cvs 3360: if (CSSUnitNames[i].unit == unit)
1.1 cvs 3361: {
1.82 cvs 3362: strcat (buffer, CSSUnitNames[i].sign);
1.18 cvs 3363: break;
1.1 cvs 3364: }
3365: }
3366: }
3367: }
3368:
3369: /*----------------------------------------------------------------------
1.59 cvs 3370: ParseHTMLSpecificStyle: parse and apply a CSS Style string.
1.18 cvs 3371: This function must be called when a specific style is applied to an
3372: element.
1.68 cvs 3373: The parameter isCSS is 1 when the specific presentation should be
3374: translated into a CSS rule, 0 if it should be translated into a
3375: presentation attribute.
1.1 cvs 3376: ----------------------------------------------------------------------*/
1.79 cvs 3377: void ParseHTMLSpecificStyle (Element el, char *cssRule, Document doc,
1.78 cvs 3378: int isCSS, ThotBool destroy)
1.1 cvs 3379: {
3380: PresentationContext context;
3381: ElementType elType;
1.14 cvs 3382: ThotBool isHTML;
1.1 cvs 3383:
3384: /* A rule applying to BODY is really meant to address HTML */
3385: elType = TtaGetElementType (el);
1.89 cvs 3386:
1.86 cvs 3387: /* store the current line for eventually reported errors */
3388: LineNumber = TtaGetElementLineNumber (el);
1.89 cvs 3389: if (destroy)
3390: /* no reported errors */
3391: ParsedDoc = 0;
3392: else if (ParsedDoc != doc)
3393: {
3394: /* update the context for reported errors */
3395: ParsedDoc = doc;
3396: DocURL = DocumentURLs[doc];
3397: }
1.82 cvs 3398: isHTML = (strcmp (TtaGetSSchemaName (elType.ElSSchema), "HTML") == 0);
1.1 cvs 3399: /* create the context of the Specific presentation driver */
3400: context = TtaGetSpecificStyleContext (doc);
3401: if (context == NULL)
3402: return;
3403: context->type = elType.ElTypeNum;
1.68 cvs 3404: context->cssLevel = isCSS;
1.1 cvs 3405: context->destroy = destroy;
3406: /* Call the parser */
3407: ParseCSSRule (el, NULL, (PresentationContext) context, cssRule, NULL, isHTML);
3408: /* free the context */
3409: TtaFreeMemory(context);
3410: }
3411:
1.68 cvs 3412:
1.1 cvs 3413: /*----------------------------------------------------------------------
1.59 cvs 3414: ParseGenericSelector: Create a generic context for a given
1.1 cvs 3415: selector string. If the selector is made of multiple comma-
3416: separated selector items, it parses them one at a time and
3417: return the end of the selector string to be handled or NULL
3418: ----------------------------------------------------------------------*/
1.79 cvs 3419: static char *ParseGenericSelector (char *selector, char *cssRule,
3420: GenericContext ctxt, Document doc,
3421: CSSInfoPtr css)
3422: {
3423: ElementType elType;
3424: PSchema tsch;
1.105 ! cvs 3425: /*AttributeType attrType;*/
1.79 cvs 3426: char sel[MAX_ANCESTORS * 50];
3427: char *deb, *cur;
3428: char *structName;
3429: char *names[MAX_ANCESTORS];
3430: char *ids[MAX_ANCESTORS];
3431: char *classes[MAX_ANCESTORS];
3432: char *pseudoclasses[MAX_ANCESTORS];
3433: char *attrs[MAX_ANCESTORS];
3434: char *attrvals[MAX_ANCESTORS];
1.91 cvs 3435: char *ptr;
3436: int i, j, k, max;
3437: int att, maxAttr;
1.79 cvs 3438: ThotBool isHTML;
3439: ThotBool level;
1.1 cvs 3440:
1.82 cvs 3441: sel[0] = EOS;
1.1 cvs 3442: for (i = 0; i < MAX_ANCESTORS; i++)
3443: {
1.25 cvs 3444: names[i] = NULL;
3445: ids[i] = NULL;
3446: classes[i] = NULL;
3447: pseudoclasses[i] = NULL;
3448: attrs[i] = NULL;
3449: attrvals[i] = NULL;
3450:
3451: ctxt->name[i] = 0;
3452: ctxt->names_nb[i] = 0;
3453: ctxt->attrType[i] = 0;
3454: ctxt->attrText[i] = NULL;
1.1 cvs 3455: }
1.25 cvs 3456: ctxt->box = 0;
3457: ctxt->type = 0;
1.68 cvs 3458: /* the priority level of the rule depends on the selector */
3459: ctxt->cssLevel = 0;
1.25 cvs 3460:
1.82 cvs 3461: selector = SkipBlanksAndComments (selector);
1.27 cvs 3462: cur = &sel[0];
1.25 cvs 3463: max = 0; /* number of loops */
1.1 cvs 3464: while (1)
3465: {
1.85 cvs 3466: /* point to the following word in sel[] */
1.27 cvs 3467: deb = cur;
1.25 cvs 3468: /* copy an item of the selector into sel[] */
1.1 cvs 3469: /* put one word in the sel buffer */
1.82 cvs 3470: while (*selector != EOS && *selector != ',' &&
3471: *selector != '.' && *selector != ':' &&
3472: *selector != '#' && !TtaIsBlank (selector))
1.50 cvs 3473: *cur++ = *selector++;
1.82 cvs 3474: *cur++ = EOS; /* close the first string in sel[] */
3475: if (deb[0] != EOS)
1.27 cvs 3476: names[0] = deb;
1.25 cvs 3477: else
1.27 cvs 3478: names[0] = NULL;
3479: classes[0] = NULL;
3480: pseudoclasses[0] = NULL;
3481: ids[0] = NULL;
3482: attrs[0] = NULL;
3483: attrvals[0] = NULL;
1.25 cvs 3484:
1.27 cvs 3485: /* now names[0] points to the beginning of the parsed item
1.25 cvs 3486: and cur to the next chain to be parsed */
1.82 cvs 3487: if (*selector == ':' || *selector == '.' || *selector == '#')
1.85 cvs 3488: /* point to the following word in sel[] */
3489: deb = cur;
1.1 cvs 3490:
1.82 cvs 3491: if (*selector == '.')
1.1 cvs 3492: {
3493: selector++;
1.82 cvs 3494: while (*selector != EOS && *selector != ',' &&
3495: *selector != '.' && *selector != ':' &&
3496: !TtaIsBlank (selector))
1.1 cvs 3497: *cur++ = *selector++;
1.86 cvs 3498: /* close the word */
3499: *cur++ = EOS;
1.85 cvs 3500: /* point to the class in sel[] if it's valid name */
1.86 cvs 3501: if (deb[0] <= 64)
3502: CSSParseError ("Invalid class", deb);
3503: else
1.85 cvs 3504: classes[0] = deb;
1.1 cvs 3505: }
1.82 cvs 3506: else if (*selector == ':')
1.1 cvs 3507: {
3508: selector++;
1.82 cvs 3509: while (*selector != EOS && *selector != ',' &&
3510: *selector != '.' && *selector != ':' &&
3511: !TtaIsBlank (selector))
1.50 cvs 3512: *cur++ = *selector++;
1.86 cvs 3513: /* close the word */
3514: *cur++ = EOS;
1.85 cvs 3515: /* point to the pseudoclass in sel[] if it's valid name */
1.86 cvs 3516: if (deb[0] <= 64)
3517: CSSParseError ("Invalid pseudoclass", deb);
3518: else
1.85 cvs 3519: pseudoclasses[0]= deb;
1.1 cvs 3520: }
1.82 cvs 3521: else if (*selector == '#')
1.1 cvs 3522: {
3523: selector++;
1.82 cvs 3524: while (*selector != EOS && *selector != ',' &&
3525: *selector != '.' && *selector != ':' &&
3526: !TtaIsBlank (selector))
1.50 cvs 3527: *cur++ = *selector++;
1.86 cvs 3528: /* close the word */
3529: *cur++ = EOS;
1.85 cvs 3530: /* point to the attribute in sel[] if it's valid name */
1.86 cvs 3531: if (deb[0] <= 64)
3532: CSSParseError ("Invalid id", deb);
3533: else
1.85 cvs 3534: ids[0] = deb;
1.1 cvs 3535: }
1.82 cvs 3536: else if (*selector == '[')
1.1 cvs 3537: {
1.25 cvs 3538: selector++;
1.85 cvs 3539: while (*selector != EOS && *selector != ']' &&
3540: *selector != '=' && *selector != '~')
1.25 cvs 3541: *cur++ = *selector++;
1.86 cvs 3542: /* close the word */
3543: *cur++ = EOS;
1.85 cvs 3544: /* point to the attribute in sel[] if it's valid name */
1.86 cvs 3545: if (deb[0] <= 64)
3546: CSSParseError ("Invalid attribute", deb);
3547: else
1.85 cvs 3548: attrs[0] = deb;
3549: if (*selector == '=')
1.25 cvs 3550: {
1.85 cvs 3551: /* look for a value "xxxx" */
1.82 cvs 3552: while (*selector != EOS && *selector != ']' && *selector != '"')
1.85 cvs 3553: *cur++ = *selector++;
3554: /* there is a value */
1.86 cvs 3555: if (*selector == EOS)
3556: CSSParseError ("Invalid attribute value", deb);
3557: else
1.25 cvs 3558: {
3559: /* we are now parsing the attribute value */
1.27 cvs 3560: attrvals[0] = cur;
1.25 cvs 3561: selector++;
1.82 cvs 3562: while (*selector != EOS && *selector != '"')
1.25 cvs 3563: *cur++ = *selector++;
1.82 cvs 3564: if (*selector != EOS)
1.25 cvs 3565: selector++;
3566: }
3567: }
1.82 cvs 3568: *cur++ = EOS;
1.1 cvs 3569: }
3570:
1.82 cvs 3571: selector = SkipBlanksAndComments (selector);
1.25 cvs 3572: /* is it a multi-level selector? */
1.82 cvs 3573: if (*selector == EOS)
1.1 cvs 3574: /* end of the selector */
3575: break;
1.82 cvs 3576: else if (*selector == ',')
1.1 cvs 3577: {
3578: /* end of the current selector */
3579: selector++;
3580: break;
3581: }
1.25 cvs 3582: else
3583: {
3584: /* shifts the list to make room for the new name */
3585: max++; /* a new level in ancestor tables */
3586: if (max == MAX_ANCESTORS)
3587: /* abort the CSS parsing */
3588: return (selector);
3589: for (i = max; i > 0; i--)
3590: {
3591: names[i] = names[i - 1];
3592: ids[i] = ids[i - 1];
3593: classes[i] = classes[i - 1];
3594: attrs[i] = attrs[i - 1];
3595: attrvals[i] = attrvals[i - 1];
3596: pseudoclasses[i] = pseudoclasses[i - 1];
3597: }
3598: }
1.1 cvs 3599: }
3600:
3601: /* Now set up the context block */
1.25 cvs 3602: i = 0;
3603: k = 0;
3604: j = 0;
1.35 cvs 3605: maxAttr = 0;
1.91 cvs 3606: /* default schema name */
3607: ptr = "HTML";
1.25 cvs 3608: while (i <= max)
3609: {
3610: if (names[i])
3611: {
3612: /* get the new element type of this name */
3613: GIType (names[i], &elType, doc);
3614: if (i == 0)
3615: {
3616: /* Store the element type */
3617: ctxt->type = elType.ElTypeNum;
1.32 cvs 3618: ctxt->name[0] = elType.ElTypeNum;
3619: ctxt->names_nb[0] = 0;
1.25 cvs 3620: ctxt->schema = elType.ElSSchema;
1.91 cvs 3621: ptr = TtaGetSSchemaName (elType.ElSSchema);
1.27 cvs 3622: k++;
1.25 cvs 3623: }
3624: else if (elType.ElTypeNum != 0)
3625: {
3626: /* look at the current context to see if the type is already
3627: stored */
3628: j = 0;
1.32 cvs 3629: while (j < k && ctxt->name[j] != elType.ElTypeNum)
1.25 cvs 3630: j++;
3631: if (j == k)
3632: {
3633: /* add a new entry */
3634: k++;
3635: ctxt->name[j] = elType.ElTypeNum;
3636: if (j != 0)
3637: ctxt->names_nb[j] = 1;
3638: }
3639: else
3640: /* increment the number of ancestor levels */
3641: ctxt->names_nb[j]++;
3642: }
3643: else
3644: {
3645: /* add a new entry */
3646: j = k;
3647: k++;
3648: }
3649: }
1.1 cvs 3650:
1.25 cvs 3651: /* store attributes information */
3652: if (classes[i])
3653: {
3654: ctxt->attrText[j] = classes[i];
1.100 vatton 3655: if (!strcmp (ptr, "SVG"))
3656: ctxt->attrType[j] = SVG_ATTR_class;
1.91 cvs 3657: else if (!strcmp (ptr, "MathML"))
3658: ctxt->attrType[j] = MathML_ATTR_class;
3659: else
3660: ctxt->attrType[j] = HTML_ATTR_Class;
1.79 cvs 3661: /* add a new entry */
1.80 cvs 3662: maxAttr = i + 1;
1.25 cvs 3663: }
1.79 cvs 3664: if (pseudoclasses[i])
1.25 cvs 3665: {
3666: ctxt->attrText[j] = pseudoclasses[i];
1.100 vatton 3667: if (!strcmp (ptr, "SVG"))
3668: ctxt->attrType[j] = SVG_ATTR_PseudoClass;
1.91 cvs 3669: else if (!strcmp (ptr, "MathML"))
3670: ctxt->attrType[j] = MathML_ATTR_PseudoClass;
3671: else
3672: ctxt->attrType[j] = HTML_ATTR_PseudoClass;
1.79 cvs 3673: /* add a new entry */
1.80 cvs 3674: maxAttr = i + 1;
1.25 cvs 3675: }
1.79 cvs 3676: if (ids[i])
1.25 cvs 3677: {
3678: ctxt->attrText[j] = ids[i];
1.100 vatton 3679: if (!strcmp (ptr, "SVG"))
3680: ctxt->attrType[j] = SVG_ATTR_id;
1.91 cvs 3681: else if (!strcmp (ptr, "MathML"))
3682: ctxt->attrType[j] = MathML_ATTR_id;
3683: else
3684: ctxt->attrType[j] = HTML_ATTR_ID;
1.80 cvs 3685: /* add a new entry */
3686: maxAttr = i + 1;
1.25 cvs 3687: }
1.79 cvs 3688: if (attrs[i])
1.25 cvs 3689: {
1.100 vatton 3690: if (!strcmp (ptr, "SVG"))
1.101 cvs 3691: MapXMLAttribute (SVG_TYPE, attrs[i], names[i], &level, doc, &att);
1.91 cvs 3692: else if (!strcmp (ptr, "MathML"))
3693: MapXMLAttribute (MATH_TYPE, attrs[i], names[i], &level, doc, &att);
3694: else
3695: MapXMLAttribute (XHTML_TYPE, attrs[i], names[i], &level, doc, &att);
1.25 cvs 3696: ctxt->attrText[j] = attrvals[i];
1.91 cvs 3697: /* we should pass also the attribute schema in the context */
3698: ctxt->attrType[j] = att;
1.80 cvs 3699: maxAttr = i + 1;
1.25 cvs 3700: }
3701: i++;
1.1 cvs 3702: }
3703:
1.25 cvs 3704: /* sort the list of ancestors by name order */
3705: max = k;
3706: i = 1;
3707: while (i < max)
1.28 cvs 3708: {
3709: for (k = i + 1; k < max; k++)
3710: if (ctxt->name[i] > ctxt->name[k])
3711: {
3712: j = ctxt->name[i];
3713: ctxt->name[i] = ctxt->name[k];
3714: ctxt->name[k] = j;
3715: j = ctxt->names_nb[i];
3716: ctxt->names_nb[i] = ctxt->names_nb[k];
3717: ctxt->names_nb[k] = j;
3718: j = ctxt->attrType[i];
3719: ctxt->attrType[i] = ctxt->attrType[k];
3720: ctxt->attrType[k] = j;
3721: cur = ctxt->attrText[i];
3722: ctxt->attrText[i] = ctxt->attrText[k];
3723: ctxt->attrText[k] = cur;
3724: }
3725: i++;
3726: }
1.84 cvs 3727:
1.25 cvs 3728: /* Get the schema name of the main element */
1.105 ! cvs 3729: if (ctxt->schema != NULL)
! 3730: {
! 3731: isHTML = (strcmp (TtaGetSSchemaName (ctxt->schema), "HTML") == 0);
! 3732: tsch = GetPExtension (doc, ctxt->schema, css);
! 3733: structName = TtaGetSSchemaName (ctxt->schema);
! 3734: if (tsch && cssRule)
! 3735: ParseCSSRule (NULL, tsch, (PresentationContext) ctxt, cssRule, css, isHTML);
! 3736: }
1.1 cvs 3737: return (selector);
3738: }
3739:
3740: /*----------------------------------------------------------------------
1.73 cvs 3741: ParseStyleDeclaration: parse a style declaration
3742: stored in the style element of a document
1.59 cvs 3743: We expect the style string to be of the form:
1.1 cvs 3744: [
3745: e.g: pinky, awful { color: pink, font-family: helvetica }
3746: ----------------------------------------------------------------------*/
1.79 cvs 3747: static void ParseStyleDeclaration (Element el, char *cssRule, Document doc,
3748: CSSInfoPtr css, ThotBool destroy)
1.1 cvs 3749: {
1.79 cvs 3750: GenericContext ctxt;
3751: char *decl_end;
3752: char *sel_end;
3753: char *selector;
3754: char saved1;
3755: char saved2;
1.1 cvs 3756:
3757: /* separate the selectors string */
1.82 cvs 3758: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 3759: decl_end = cssRule;
1.82 cvs 3760: while (*decl_end != EOS && *decl_end != '{')
1.1 cvs 3761: decl_end++;
1.82 cvs 3762: if (*decl_end == EOS)
1.86 cvs 3763: {
3764: CSSParseError ("Invalid selector", cssRule);
3765: return;
3766: }
1.1 cvs 3767: /* verify and clean the selector string */
3768: sel_end = decl_end - 1;
1.82 cvs 3769: while (*sel_end == SPACE || *sel_end == BSPACE ||
3770: *sel_end == EOL || *sel_end == CR)
1.1 cvs 3771: sel_end--;
3772: sel_end++;
3773: saved1 = *sel_end;
1.82 cvs 3774: *sel_end = EOS;
1.1 cvs 3775: selector = cssRule;
3776:
3777: /* now, deal with the content ... */
3778: decl_end++;
3779: cssRule = decl_end;
1.82 cvs 3780: while (*decl_end != EOS && *decl_end != '}')
1.1 cvs 3781: decl_end++;
1.82 cvs 3782: if (*decl_end == EOS)
1.1 cvs 3783: {
1.86 cvs 3784: CSSParseError ("Invalid selector", cssRule);
1.1 cvs 3785: return;
3786: }
3787: saved2 = *decl_end;
1.82 cvs 3788: *decl_end = EOS;
1.1 cvs 3789:
3790: /*
3791: * parse the style attribute string and install the corresponding
3792: * presentation attributes on the new element
3793: */
3794: ctxt = TtaGetGenericStyleContext (doc);
3795: if (ctxt == NULL)
3796: return;
3797: ctxt->destroy = destroy;
3798:
1.82 cvs 3799: while ((selector != NULL) && (*selector != EOS))
1.25 cvs 3800: selector = ParseGenericSelector (selector, cssRule, ctxt, doc, css);
1.1 cvs 3801: TtaFreeMemory (ctxt);
3802:
3803: /* restore the string to its original form ! */
3804: *sel_end = saved1;
3805: *decl_end = saved2;
3806: }
3807:
3808: /************************************************************************
3809: * *
3810: * EVALUATION FUNCTIONS / CASCADING AND OVERLOADING *
3811: * *
3812: ************************************************************************/
3813:
3814: /*----------------------------------------------------------------------
1.59 cvs 3815: IsImplicitClassName: return wether the Class name is an
1.1 cvs 3816: implicit one, eg "H1" or "H2 EM" meaning it's a GI name
3817: or an HTML context name.
3818: ----------------------------------------------------------------------*/
1.79 cvs 3819: int IsImplicitClassName (char *class, Document doc)
1.1 cvs 3820: {
1.79 cvs 3821: char name[200];
3822: char *cur = name;
3823: char *first;
3824: char save;
3825: SSchema schema;
1.1 cvs 3826:
3827: /* make a local copy */
1.82 cvs 3828: strncpy (name, class, 199);
1.1 cvs 3829: name[199] = 0;
3830:
3831: /* loop looking if each word is a GI */
3832: while (*cur != 0)
3833: {
3834: first = cur;
3835: cur = SkipWord (cur);
3836: save = *cur;
3837: *cur = 0;
3838: schema = NULL;
3839: if (MapGI (first, &schema, doc) == -1)
3840: {
3841: return (0);
3842: }
3843: *cur = save;
1.82 cvs 3844: cur = SkipBlanksAndComments (cur);
1.1 cvs 3845: }
3846: return (1);
3847: }
3848:
3849: /************************************************************************
3850: * *
1.59 cvs 3851: * Functions Needed for support of HTML 3.2: translate to CSS equiv *
1.1 cvs 3852: * *
3853: ************************************************************************/
3854:
3855: /*----------------------------------------------------------------------
1.59 cvs 3856: HTMLSetBackgroundColor:
1.1 cvs 3857: ----------------------------------------------------------------------*/
1.79 cvs 3858: void HTMLSetBackgroundColor (Document doc, Element el, char *color)
1.1 cvs 3859: {
1.79 cvs 3860: char css_command[100];
1.1 cvs 3861:
1.82 cvs 3862: sprintf (css_command, "background-color: %s", color);
1.68 cvs 3863: ParseHTMLSpecificStyle (el, css_command, doc, 1, FALSE);
1.1 cvs 3864: }
3865:
3866: /*----------------------------------------------------------------------
1.59 cvs 3867: HTMLSetBackgroundImage:
1.1 cvs 3868: repeat = repeat value
3869: image = url of background image
3870: ----------------------------------------------------------------------*/
1.79 cvs 3871: void HTMLSetBackgroundImage (Document doc, Element el, int repeat, char *image)
1.1 cvs 3872: {
1.79 cvs 3873: char css_command[400];
1.1 cvs 3874:
3875: /******* check buffer overflow ********/
1.82 cvs 3876: sprintf (css_command, "background-image: url(%s); background-repeat: ", image);
1.1 cvs 3877: if (repeat == STYLE_REPEAT)
1.82 cvs 3878: strcat (css_command, "repeat");
1.1 cvs 3879: else if (repeat == STYLE_HREPEAT)
1.82 cvs 3880: strcat (css_command, "repeat-x");
1.1 cvs 3881: else if (repeat == STYLE_VREPEAT)
1.82 cvs 3882: strcat (css_command, "repeat-y");
1.1 cvs 3883: else
1.82 cvs 3884: strcat (css_command, "no-repeat");
1.68 cvs 3885: ParseHTMLSpecificStyle (el, css_command, doc, 1, FALSE);
1.1 cvs 3886: }
3887:
3888: /*----------------------------------------------------------------------
1.59 cvs 3889: HTMLSetForegroundColor:
1.1 cvs 3890: ----------------------------------------------------------------------*/
1.97 vatton 3891: void HTMLSetForegroundColor (Document doc, Element el, char *color)
1.1 cvs 3892: {
1.79 cvs 3893: char css_command[100];
1.1 cvs 3894:
1.82 cvs 3895: sprintf (css_command, "color: %s", color);
1.68 cvs 3896: ParseHTMLSpecificStyle (el, css_command, doc, 1, FALSE);
1.1 cvs 3897: }
3898:
3899: /*----------------------------------------------------------------------
1.59 cvs 3900: HTMLResetBackgroundColor:
1.1 cvs 3901: ----------------------------------------------------------------------*/
1.97 vatton 3902: void HTMLResetBackgroundColor (Document doc, Element el)
1.1 cvs 3903: {
1.79 cvs 3904: char css_command[100];
1.1 cvs 3905:
1.82 cvs 3906: sprintf (css_command, "background: red");
1.68 cvs 3907: ParseHTMLSpecificStyle (el, css_command, doc, 1, TRUE);
1.1 cvs 3908: }
3909:
3910: /*----------------------------------------------------------------------
1.59 cvs 3911: HTMLResetBackgroundImage:
1.1 cvs 3912: ----------------------------------------------------------------------*/
1.97 vatton 3913: void HTMLResetBackgroundImage (Document doc, Element el)
1.1 cvs 3914: {
1.79 cvs 3915: char css_command[1000];
1.1 cvs 3916:
1.82 cvs 3917: sprintf (css_command, "background-image: url(xx); background-repeat: repeat");
1.68 cvs 3918: ParseHTMLSpecificStyle (el, css_command, doc, 1, TRUE);
1.1 cvs 3919: }
3920:
3921: /*----------------------------------------------------------------------
1.59 cvs 3922: HTMLResetForegroundColor:
1.1 cvs 3923: ----------------------------------------------------------------------*/
1.97 vatton 3924: void HTMLResetForegroundColor (Document doc, Element el)
1.1 cvs 3925: {
1.79 cvs 3926: char css_command[100];
1.1 cvs 3927:
1.36 cvs 3928: /* it's not necessary to well know the current color but it must be valid */
1.82 cvs 3929: sprintf (css_command, "color: red");
1.68 cvs 3930: ParseHTMLSpecificStyle (el, css_command, doc, 1, TRUE);
1.1 cvs 3931: }
3932:
3933: /*----------------------------------------------------------------------
1.59 cvs 3934: HTMLSetAlinkColor:
1.1 cvs 3935: ----------------------------------------------------------------------*/
1.97 vatton 3936: void HTMLSetAlinkColor (Document doc, char *color)
1.1 cvs 3937: {
1.79 cvs 3938: char css_command[100];
1.1 cvs 3939:
1.82 cvs 3940: sprintf (css_command, "a:link { color: %s }", color);
1.1 cvs 3941: ApplyCSSRules (NULL, css_command, doc, FALSE);
3942: }
3943:
3944: /*----------------------------------------------------------------------
1.59 cvs 3945: HTMLSetAactiveColor:
1.1 cvs 3946: ----------------------------------------------------------------------*/
1.97 vatton 3947: void HTMLSetAactiveColor (Document doc, char *color)
1.1 cvs 3948: {
1.79 cvs 3949: char css_command[100];
1.1 cvs 3950:
1.82 cvs 3951: sprintf (css_command, "a:active { color: %s }", color);
1.1 cvs 3952: ApplyCSSRules (NULL, css_command, doc, FALSE);
3953: }
3954:
3955: /*----------------------------------------------------------------------
1.59 cvs 3956: HTMLSetAvisitedColor:
1.1 cvs 3957: ----------------------------------------------------------------------*/
1.79 cvs 3958: void HTMLSetAvisitedColor (Document doc, char *color)
1.1 cvs 3959: {
1.79 cvs 3960: char css_command[100];
1.1 cvs 3961:
1.82 cvs 3962: sprintf (css_command, "a:visited { color: %s }", color);
1.1 cvs 3963: ApplyCSSRules (NULL, css_command, doc, FALSE);
3964: }
3965:
3966: /*----------------------------------------------------------------------
1.59 cvs 3967: HTMLResetAlinkColor:
1.1 cvs 3968: ----------------------------------------------------------------------*/
3969: void HTMLResetAlinkColor (Document doc)
3970: {
1.79 cvs 3971: char css_command[100];
1.1 cvs 3972:
1.82 cvs 3973: sprintf (css_command, "a:link { color: red }");
1.1 cvs 3974: ApplyCSSRules (NULL, css_command, doc, TRUE);
3975: }
3976:
3977: /*----------------------------------------------------------------------
1.59 cvs 3978: HTMLResetAactiveColor:
1.1 cvs 3979: ----------------------------------------------------------------------*/
3980: void HTMLResetAactiveColor (Document doc)
3981: {
1.79 cvs 3982: char css_command[100];
1.1 cvs 3983:
1.82 cvs 3984: sprintf (css_command, "a:active { color: red }");
1.1 cvs 3985: ApplyCSSRules (NULL, css_command, doc, TRUE);
3986: }
3987:
3988: /*----------------------------------------------------------------------
1.59 cvs 3989: HTMLResetAvisitedColor:
1.1 cvs 3990: ----------------------------------------------------------------------*/
3991: void HTMLResetAvisitedColor (Document doc)
3992: {
1.79 cvs 3993: char css_command[100];
1.1 cvs 3994:
1.82 cvs 3995: sprintf (css_command, "a:visited { color: red }");
1.1 cvs 3996: ApplyCSSRules (NULL, css_command, doc, TRUE);
3997: }
3998:
3999: /*----------------------------------------------------------------------
1.73 cvs 4000: ApplyCSSRules: parse a CSS Style description stored in the
1.1 cvs 4001: header of a HTML document.
4002: ----------------------------------------------------------------------*/
1.79 cvs 4003: void ApplyCSSRules (Element el, char *cssRule, Document doc, ThotBool destroy)
1.1 cvs 4004: {
4005: CSSInfoPtr css;
4006:
4007: css = SearchCSS (doc, NULL);
4008: if (css == NULL)
4009: /* create the document css */
4010: css = AddCSS (doc, doc, CSS_DOCUMENT_STYLE, NULL, NULL);
4011: ParseStyleDeclaration (el, cssRule, doc, css, destroy);
4012: }
4013:
4014: /*----------------------------------------------------------------------
1.59 cvs 4015: ReadCSSRules: is the front-end function called by the HTML parser
1.1 cvs 4016: when detecting a <STYLE TYPE="text/css"> indicating it's the
4017: beginning of a CSS fragment or when reading a file .css.
4018:
4019: The CSS parser has to handle <!-- ... --> constructs used to
4020: prevent prehistoric browser from displaying the CSS as a text
4021: content. It will stop on any sequence "<x" where x is different
4022: from ! and will return x as to the caller. Theorically x should
4023: be equal to / for the </STYLE> end of style.
4024:
4025: The parameter doc gives the document tree that contains CSS information.
4026: The parameter docRef gives the document to which CSS are to be applied.
4027: This function uses the current css context or creates it. It's able
1.23 cvs 4028: to work on the given buffer or call GetNextChar to read the parsed
1.1 cvs 4029: file.
1.86 cvs 4030: Parameter numberOfLinesRead indicates the number of lines already
4031: read in the file.
1.1 cvs 4032: Parameter withUndo indicates whether the changes made in the document
4033: structure and content have to be registered in the Undo queue or not
4034: ----------------------------------------------------------------------*/
1.86 cvs 4035: char ReadCSSRules (Document docRef, CSSInfoPtr css, char *buffer,
4036: int numberOfLinesRead, ThotBool withUndo)
1.1 cvs 4037: {
1.6 cvs 4038: DisplayMode dispMode;
1.82 cvs 4039: char c;
4040: char *cssRule, *base;
1.19 cvs 4041: int index;
1.1 cvs 4042: int CSSindex;
4043: int CSScomment;
4044: int import;
4045: int openRule;
1.93 vatton 4046: int newlines;
1.14 cvs 4047: ThotBool HTMLcomment;
1.102 vatton 4048: ThotBool toParse, eof, quoted;
1.36 cvs 4049: ThotBool ignoreMedia, media;
1.88 cvs 4050: ThotBool noRule, ignoreImport;
1.1 cvs 4051:
4052: CSScomment = MAX_CSS_LENGTH;
4053: HTMLcomment = FALSE;
4054: CSSindex = 0;
4055: toParse = FALSE;
4056: noRule = FALSE;
1.36 cvs 4057: media = FALSE;
1.88 cvs 4058: ignoreImport = FALSE;
1.1 cvs 4059: ignoreMedia = FALSE;
4060: import = MAX_CSS_LENGTH;
4061: eof = FALSE;
4062: openRule = 0;
1.82 cvs 4063: c = SPACE;
1.1 cvs 4064: index = 0;
1.93 vatton 4065: /* number of new lines parsed */
4066: newlines = 0;
1.6 cvs 4067: /* avoid too many redisplay */
4068: dispMode = TtaGetDisplayMode (docRef);
4069: if (dispMode == DisplayImmediately)
4070: TtaSetDisplayMode (docRef, DeferredDisplay);
1.18 cvs 4071:
4072: /* look for the CSS context */
4073: if (css == NULL)
4074: css = SearchCSS (docRef, NULL);
4075: if (css == NULL)
4076: css = AddCSS (docRef, docRef, CSS_DOCUMENT_STYLE, NULL, NULL);
1.1 cvs 4077:
1.86 cvs 4078: /* register parsed CSS file and the document to which CSS are to be applied */
4079: ParsedDoc = docRef;
4080: if (css->url)
4081: DocURL = css->url;
4082: else
4083: /* the CSS source in within the document itself */
4084: DocURL = DocumentURLs[docRef];
4085: LineNumber = numberOfLinesRead + 1;
1.93 vatton 4086: NewLineSkipped = 0;
1.82 cvs 4087: while (CSSindex < MAX_CSS_LENGTH && c != EOS && !eof)
4088: {
4089: c = buffer[index++];
4090: eof = (c == EOS);
4091: CSSbuffer[CSSindex] = c;
4092: if (CSScomment == MAX_CSS_LENGTH ||
4093: c == '*' || c == '/' || c == '<')
4094: {
4095: /* we're not within a comment or we're parsing * or / */
4096: switch (c)
4097: {
4098: case '@': /* perhaps an import primitive */
4099: import = CSSindex;
4100: break;
4101: case ';':
4102: if (import != MAX_CSS_LENGTH && !media)
4103: {
4104: if (strncasecmp (&CSSbuffer[import+1], "import", 6))
4105: /* it's not an import */
4106: import = MAX_CSS_LENGTH;
4107: /* save the text */
4108: noRule = TRUE;
4109: }
4110: break;
4111: case '*':
4112: if (CSScomment == MAX_CSS_LENGTH && CSSindex > 0 &&
4113: CSSbuffer[CSSindex - 1] == '/')
4114: /* start a comment */
4115: CSScomment = CSSindex - 1;
4116: break;
4117: case '/':
4118: if (CSSindex > 1 && CSScomment != MAX_CSS_LENGTH &&
4119: CSSbuffer[CSSindex - 1] == '*')
4120: {
4121: /* close a comment:and ignore its contents */
4122: CSSindex = CSScomment - 1; /* will be incremented later */
4123: CSScomment = MAX_CSS_LENGTH;
1.93 vatton 4124: /* clean up the buffer */
1.103 vatton 4125: if (newlines && CSSindex > 0)
4126: while (CSSindex > 0 &&
4127: (CSSbuffer[CSSindex] == SPACE ||
4128: CSSbuffer[CSSindex] == BSPACE ||
4129: CSSbuffer[CSSindex] == EOL ||
4130: CSSbuffer[CSSindex] == TAB ||
4131: CSSbuffer[CSSindex] == __CR__))
1.93 vatton 4132: {
4133: if ( CSSbuffer[CSSindex] == EOL)
4134: {
4135: LineNumber ++;
4136: newlines --;
4137: }
4138: CSSindex--;
4139: }
1.82 cvs 4140: }
4141: else if (CSScomment == MAX_CSS_LENGTH && CSSindex > 0 &&
4142: CSSbuffer[CSSindex - 1] == '<')
4143: {
4144: /* this is the closing tag ! */
4145: CSSindex -= 2; /* remove </ from the CSS string */
4146: noRule = TRUE;
4147: }
4148: break;
4149: case '<':
4150: if (CSScomment == MAX_CSS_LENGTH)
4151: {
4152: /* only if we're not parsing a comment */
4153: c = buffer[index++];
4154: eof = (c == EOS);
4155: if (c == '!')
4156: {
4157: /* CSS within an HTML comment */
4158: HTMLcomment = TRUE;
4159: CSSindex++;
4160: CSSbuffer[CSSindex] = c;
4161: }
4162: else if (c == EOS)
4163: CSSindex++;
4164: }
4165: break;
4166: case '-':
4167: if (CSSindex > 0 && CSSbuffer[CSSindex - 1] == '-' &&
4168: HTMLcomment)
4169: /* CSS within an HTML comment */
4170: noRule = TRUE;
4171: break;
4172: case '>':
4173: if (HTMLcomment)
4174: noRule = TRUE;
4175: break;
4176: case ' ':
4177: if (import != MAX_CSS_LENGTH && openRule == 0)
4178: media = !strncmp (&CSSbuffer[import+1], "media", 5);
4179: break;
4180: case '{':
4181: openRule++;
4182: if (import != MAX_CSS_LENGTH && openRule == 1 && media)
4183: {
4184: /* is it the screen concerned? */
4185: CSSbuffer[CSSindex+1] = EOS;
4186: if (TtaIsPrinting ())
4187: base = strstr (&CSSbuffer[import], "print");
4188: else
4189: base = strstr (&CSSbuffer[import], "screen");
4190: if (base == NULL)
4191: ignoreMedia = TRUE;
4192: noRule = TRUE;
4193: }
4194: break;
4195: case '}':
4196: openRule--;
4197: if (import != MAX_CSS_LENGTH && openRule == 0)
4198: {
4199: import = MAX_CSS_LENGTH;
4200: noRule = TRUE;
4201: ignoreMedia = FALSE;
4202: media = FALSE;
4203: }
4204: else
4205: toParse = TRUE;
4206: break;
4207: default:
1.86 cvs 4208: if (c == EOL)
1.93 vatton 4209: newlines++;
1.82 cvs 4210: break;
4211: }
4212: }
1.93 vatton 4213: else if (c == EOL)
4214: LineNumber++;
1.82 cvs 4215: if (c != CR)
4216: CSSindex++;
4217:
4218: if (CSSindex >= MAX_CSS_LENGTH && CSScomment < MAX_CSS_LENGTH)
4219: /* we're still parsing a comment: remove the text comment */
4220: CSSindex = CSScomment;
4221:
4222: if (CSSindex >= MAX_CSS_LENGTH || toParse || noRule)
4223: {
4224: CSSbuffer[CSSindex] = EOS;
4225: /* parse a not empty string */
4226: if (CSSindex > 0)
4227: {
1.50 cvs 4228: /* apply CSS rule if it's not just a saving of text */
4229: if (!noRule && !ignoreMedia)
1.88 cvs 4230: {
4231: /* future import rules must be ignored */
4232: ignoreImport = TRUE;
4233: ParseStyleDeclaration (NULL, CSSbuffer, docRef, css, FALSE);
1.93 vatton 4234: LineNumber += newlines;
4235: newlines = 0;
4236: NewLineSkipped = 0;
1.88 cvs 4237: }
1.82 cvs 4238: else if (import != MAX_CSS_LENGTH &&
4239: !strncasecmp (&CSSbuffer[import+1], "import", 6))
4240: {
4241: /* import section */
4242: cssRule = &CSSbuffer[import+7];
4243: cssRule = TtaSkipBlanks (cssRule);
1.93 vatton 4244: /* save the current line number */
4245: newlines += LineNumber;
1.82 cvs 4246: if (!strncasecmp (cssRule, "url", 3))
4247: {
1.50 cvs 4248: cssRule = &cssRule[3];
1.82 cvs 4249: cssRule = TtaSkipBlanks (cssRule);
4250: if (*cssRule == '(')
4251: {
4252: cssRule++;
4253: cssRule = TtaSkipBlanks (cssRule);
1.102 vatton 4254: quoted = (*cssRule == '"' || *cssRule == '\'');
4255: if (quoted)
4256: cssRule++;
1.82 cvs 4257: base = cssRule;
4258: while (*cssRule != EOS && *cssRule != ')')
4259: cssRule++;
1.102 vatton 4260: if (quoted)
4261: cssRule--;
1.82 cvs 4262: *cssRule = EOS;
1.88 cvs 4263: if (!ignoreImport)
4264: LoadStyleSheet (base, docRef, NULL, css, css->media[docRef]);
1.82 cvs 4265: }
4266: }
1.87 cvs 4267: else if (*cssRule == '"')
4268: {
1.88 cvs 4269: /*
4270: Do we have to accept single quotes?
4271: Double quotes are acceted here.
4272: Escaped quotes are not handled. See function SkipQuotedString
4273: */
1.87 cvs 4274: cssRule++;
4275: cssRule = TtaSkipBlanks (cssRule);
4276: base = cssRule;
4277: while (*cssRule != EOS && *cssRule != '"')
4278: cssRule++;
4279: *cssRule = EOS;
1.88 cvs 4280: if (!ignoreImport)
4281: LoadStyleSheet (base, docRef, NULL, css, css->media[docRef]);
1.82 cvs 4282: }
1.93 vatton 4283: /* restore the number of lines */
4284: LineNumber = newlines;
4285: newlines = 0;
1.82 cvs 4286: import = MAX_CSS_LENGTH;
4287: }
1.93 vatton 4288:
1.82 cvs 4289: }
4290: toParse = FALSE;
4291: noRule = FALSE;
4292: CSSindex = 0;
1.50 cvs 4293: }
1.82 cvs 4294: }
1.6 cvs 4295: /* restore the display mode */
4296: if (dispMode == DisplayImmediately)
1.82 cvs 4297: TtaSetDisplayMode (docRef, dispMode);
1.86 cvs 4298:
4299: /* Prepare the context for style attributes */
4300: DocURL = DocumentURLs[docRef];
4301: LineNumber = -1;
1.1 cvs 4302: return (c);
4303: }
1.89 cvs 4304:
Webmaster