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

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

Webmaster