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

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

Webmaster