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

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

Webmaster