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