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