Annotation of Amaya/amaya/styleparser.c, revision 1.51

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

Webmaster