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

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

Webmaster