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