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