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