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

1.1       cvs         1: /*
                      2:  *
1.312     quint       3:  *  (c) COPYRIGHT INRIA and W3C, 1996-2005
1.1       cvs         4:  *  Please first read the full copyright statement in file COPYRIGHT.
                      5:  *
                      6:  */
1.164     quint       7: 
1.1       cvs         8: /*
1.164     quint       9:  * Everything directly related to the CSS syntax should now hopefully
1.1       cvs        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.141     cvs        23: #include "document.h"
1.1       cvs        24: 
1.302     quint      25: typedef struct _CSSImageCallbackBlock
1.1       cvs        26: {
1.207     vatton     27:   Element                el;
                     28:   PSchema                tsch;
                     29:   CSSInfoPtr             css;
                     30:   PresentationContext    ctxt;
1.302     quint      31:   unsigned int           ruleType;
1.1       cvs        32: }
1.302     quint      33: CSSImageCallbackBlock, *CSSImageCallbackPtr;
1.1       cvs        34: 
                     35: #include "AHTURLTools_f.h"
                     36: #include "HTMLpresentation_f.h"
                     37: #include "HTMLimage_f.h"
                     38: #include "UIcss_f.h"
                     39: #include "css_f.h"
1.24      cvs        40: #include "fetchHTMLname_f.h"
1.91      cvs        41: #include "fetchXMLname_f.h"
1.1       cvs        42: #include "html2thot_f.h"
1.91      cvs        43: #include "init_f.h"
1.1       cvs        44: #include "styleparser_f.h"
1.366     vatton     45: #include "wxdialogapi_f.h"
1.1       cvs        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.327     vatton     55:                                  PSchema tsch,
                     56:                                  PresentationContext context,
                     57:                                  char *cssRule,
                     58:                                  CSSInfoPtr css,
                     59:                                  ThotBool isHTML);
1.1       cvs        60: 
                     61: /* Description of the set of CSS properties supported */
                     62: typedef struct CSSProperty
1.327     vatton     63: {
                     64:   char                *name;
                     65:   PropertyParser       parsing_function;
                     66: }
1.1       cvs        67: CSSProperty;
                     68: 
1.86      cvs        69: static int           LineNumber = -1; /* The line where the error occurs */
1.93      vatton     70: static int           NewLineSkipped = 0;
1.311     vatton     71: static int           RedisplayImages = 0; /* number of BG images loading */
                     72: static int           RedisplayDoc = 0; /* document to be redisplayed */
                     73: static int           Style_parsing = 0; /* > 0 when parsing a set of CSS rules */
1.360     vatton     74: static char         *ImportantPos = NULL;
1.310     vatton     75: static ThotBool      RedisplayBGImage = FALSE; /* TRUE when a BG image is inserted */
1.116     vatton     76: static ThotBool      DoApply = TRUE;
1.366     vatton     77: static ThotBool      All_sides = FALSE; // TRUE when "boder valus must be displayed
                     78: 
1.1       cvs        79: 
                     80: /*----------------------------------------------------------------------
1.327     vatton     81:   SkipWord:                                                  
1.1       cvs        82:   ----------------------------------------------------------------------*/
1.79      cvs        83: static char *SkipWord (char *ptr)
1.1       cvs        84: {
1.168     vatton     85:   while (isalnum((int)*ptr) || *ptr == '-' || *ptr == '#' || *ptr == '%')
                     86:     ptr++;
1.1       cvs        87:   return (ptr);
                     88: }
                     89: 
                     90: /*----------------------------------------------------------------------
1.327     vatton     91:   SkipBlanksAndComments:                                                  
1.13      cvs        92:   ----------------------------------------------------------------------*/
1.82      cvs        93: char *SkipBlanksAndComments (char *ptr)
1.13      cvs        94: {
1.93      vatton     95:   /* skip spaces */
1.155     cheyroul   96:   while (*ptr == SPACE ||
1.327     vatton     97:          *ptr == BSPACE ||
                     98:          *ptr == EOL ||
                     99:          *ptr == TAB ||
                    100:          *ptr == __CR__)
1.93      vatton    101:     {
                    102:       if (*ptr == EOL)
1.327     vatton    103:         /* increment the number of newline skipped */
                    104:         NewLineSkipped++;
1.93      vatton    105:       ptr++;
                    106:     }
1.155     cheyroul  107:   while (ptr[0] == '/' &&
1.327     vatton    108:          ptr[1] == '*')
1.13      cvs       109:     {
                    110:       /* look for the end of the comment */
                    111:       ptr = &ptr[2];
                    112:       while (ptr[0] != EOS && (ptr[0] != '*' || ptr[1] != '/'))
1.327     vatton    113:         ptr++;
1.13      cvs       114:       if (ptr[0] != EOS)
1.327     vatton    115:         ptr = &ptr[2];
1.93      vatton    116:       /* skip spaces */
                    117:       while (*ptr == SPACE || *ptr == BSPACE || *ptr == EOL ||
1.327     vatton    118:              *ptr == TAB || *ptr == __CR__)
                    119:         {
                    120:           if (*ptr == EOL)
                    121:             /* increment the number of newline skipped */
                    122:             NewLineSkipped++;
                    123:           ptr++;
                    124:         }
1.13      cvs       125:     }
                    126:   return (ptr);
                    127: }
                    128: 
1.366     vatton    129: 
                    130: /*----------------------------------------------------------------------
                    131:   Number of values
                    132:   ----------------------------------------------------------------------*/
                    133: static int NumberOfValues (char *ptr)
                    134: {
                    135:   int n = 0;
                    136:   while (*ptr != EOS && *ptr != ';' &&  *ptr != '}')
                    137:     {
                    138:       ptr = SkipBlanksAndComments (ptr);
                    139:       n++;
                    140:       ptr = SkipWord (ptr);
                    141:     }
                    142:   return n;
                    143: }
                    144: 
1.49      cvs       145: /*----------------------------------------------------------------------
1.327     vatton    146:   SkipQuotedString
1.1       cvs       147:   ----------------------------------------------------------------------*/
1.79      cvs       148: static char *SkipQuotedString (char *ptr, char quote)
1.1       cvs       149: {
1.14      cvs       150:   ThotBool     stop;
1.1       cvs       151: 
                    152:   stop = FALSE;
                    153:   while (!stop)
                    154:     {
1.327     vatton    155:       if (*ptr == quote)
                    156:         {
                    157:           ptr++;
                    158:           stop = TRUE;
                    159:         }
                    160:       else if (*ptr == EOS)
                    161:         stop = TRUE;
                    162:       else if (*ptr == '\\')
                    163:         /* escape character */
                    164:         {
                    165:           ptr++;
1.82      cvs       166:           if ((*ptr >= '0' && *ptr <= '9') || (*ptr >= 'A' && *ptr <= 'F') ||
1.327     vatton    167:               (*ptr >= 'a' && *ptr <= 'f'))
                    168:             {
                    169:               ptr++;
                    170:               if ((*ptr >= '0' && *ptr <= '9') || (*ptr >= 'A' && *ptr <= 'F') ||
                    171:                   (*ptr >= 'a' && *ptr <= 'f'))
                    172:                 ptr++;
                    173:             }
                    174:           else
                    175:             ptr++;
                    176:         }
                    177:       else
                    178:         ptr++;
1.1       cvs       179:     }
                    180:   return (ptr);
                    181: }
                    182: 
                    183: /*----------------------------------------------------------------------
1.327     vatton    184:   CSSPrintError
                    185:   print the error message msg on stderr.
                    186:   When the line is 0 ask to expat the current line number
1.86      cvs       187:   ----------------------------------------------------------------------*/
1.168     vatton    188: static void CSSPrintError (char *msg, char *value)
1.86      cvs       189: {
1.366     vatton    190:   if (!DoDialog && !TtaIsPrinting () && ParsedDoc > 0)
1.86      cvs       191:     {
                    192:       if (!ErrFile)
1.327     vatton    193:         {
                    194:           if (OpenParsingErrors (ParsedDoc) == FALSE)
                    195:             return;
                    196:         }
1.86      cvs       197: 
1.308     vatton    198:       /* check if a CSS error file shoulb be updated too */
                    199:       if (ParsedCSS > 0 && !CSSErrFile)
1.327     vatton    200:         OpenParsingErrors (ParsedCSS);
1.308     vatton    201: 
1.348     vatton    202:       if (Error_DocURL)
1.327     vatton    203:         {
1.348     vatton    204:           fprintf (ErrFile, "\n*** Errors/warnings in %s\n", Error_DocURL);
1.327     vatton    205:           /* set to NULL as long as the CSS file doesn't change */
1.348     vatton    206:           Error_DocURL = NULL;
1.327     vatton    207:         }
1.89      cvs       208:       CSSErrorsFound = TRUE;
1.86      cvs       209:       if (LineNumber < 0)
1.347     quint     210:         {
                    211:           if (value)
                    212:             fprintf (ErrFile, "  In style attribute, %s \"%s\"\n", msg, value);
                    213:           else
                    214:             fprintf (ErrFile, "  In style attribute, %s\n", msg);
                    215:         }
1.86      cvs       216:       else
1.327     vatton    217:         {
1.347     quint     218:           if (value)
                    219:             fprintf (ErrFile, "@  line %d: %s \"%s\"\n",
                    220:                      LineNumber+NewLineSkipped, msg, value);
                    221:           else
                    222:             fprintf (ErrFile, "@  line %d: %s\n", LineNumber+NewLineSkipped,
                    223:                      msg);
1.327     vatton    224:           if (CSSErrFile)
1.347     quint     225:             {
                    226:               if (value)
                    227:                 fprintf (CSSErrFile, "@  line %d: %s \"%s\"\n",
                    228:                          LineNumber+NewLineSkipped, msg, value);
                    229:               else
                    230:                 fprintf (CSSErrFile, "@  line %d: %s\n",
                    231:                          LineNumber+NewLineSkipped, msg);
                    232:             }
1.327     vatton    233:         }
1.86      cvs       234:     }
                    235: }
                    236: 
1.168     vatton    237: /*----------------------------------------------------------------------
1.327     vatton    238:   CSSParseError
                    239:   print the error message msg on stderr.
1.168     vatton    240:   ----------------------------------------------------------------------*/
                    241: static void CSSParseError (char *msg, char *value, char *endvalue)
                    242: {
1.230     quint     243:   char        c = EOS;
1.168     vatton    244: 
                    245:   if (endvalue)
                    246:     {
                    247:       /* close the string here */
                    248:       c = *endvalue;
                    249:       *endvalue = EOS;
                    250:     }
                    251:   CSSPrintError (msg, value);
                    252:   if (endvalue)
                    253:     *endvalue = c;
                    254: }
                    255: 
1.288     vatton    256: /*----------------------------------------------------------------------
1.342     vatton    257:   SkipString move to the end of the string
                    258:   ----------------------------------------------------------------------*/
                    259: static char *SkipString (char *ptr)
                    260: {
                    261:   char        c = *ptr;
                    262: 
                    263:   ptr++;
                    264:   while (*ptr != EOS &&
                    265:          (*ptr != c || (*ptr == c && ptr[-1] == '\\')))
                    266:     ptr++;
                    267:   return ptr;
                    268: }
                    269: 
                    270: /*----------------------------------------------------------------------
1.327     vatton    271:   CSSCheckEndValue
                    272:   print an error message if another character is found
1.288     vatton    273:   ----------------------------------------------------------------------*/
                    274: static char *CSSCheckEndValue (char *cssRule, char *endvalue, char *msg)
                    275: {
                    276:   char        c = EOS;
                    277:   if (*endvalue != EOS && *endvalue != SPACE && *endvalue != '/' &&
1.316     quint     278:       *endvalue != ';' && *endvalue != '}' && *endvalue != EOL && 
                    279:       *endvalue != TAB && *endvalue !=  __CR__)
1.288     vatton    280:     {
                    281:       while (*endvalue != EOS && *endvalue != SPACE && *endvalue != '/' &&
1.327     vatton    282:              *endvalue != ';' && *endvalue != '}' && *endvalue != EOL &&
                    283:              *endvalue != TAB && *endvalue !=  __CR__)
1.342     vatton    284:         {
                    285:           if (*endvalue == '"' || *endvalue == '\'')
                    286:             endvalue = SkipString (endvalue);
                    287:           if (*endvalue != EOS)
                    288:             endvalue++;
                    289:         }
1.288     vatton    290:       /* close the string here */
                    291:       c = *endvalue;
                    292:       *endvalue = EOS;
                    293:       CSSPrintError (msg, cssRule);
                    294:       *endvalue = c;
                    295:     }
                    296:   return endvalue;
                    297: }
                    298: 
1.89      cvs       299: 
1.86      cvs       300: /*----------------------------------------------------------------------
1.327     vatton    301:   SkipProperty skips a property and display and error message
1.86      cvs       302:   ----------------------------------------------------------------------*/
1.234     vatton    303: static char *SkipProperty (char *ptr, ThotBool reportError)
1.86      cvs       304: {
                    305:   char       *deb;
                    306:   char        c;
                    307: 
                    308:   deb = ptr;
1.301     vatton    309:   while (*ptr != EOS && *ptr != ';' && *ptr != '}' && *ptr != '}')
1.133     vatton    310:     {
1.342     vatton    311:       if (*ptr == '"' || *ptr == '\'')
                    312:         ptr = SkipString (ptr);
                    313:       if (*ptr != EOS)
                    314:         ptr++;
1.133     vatton    315:     }
1.95      cvs       316:   /* print the skipped property */
1.86      cvs       317:   c = *ptr;
                    318:   *ptr = EOS;
1.366     vatton    319:   if (DoDialog)
                    320:     DisplayStyleValue ("", deb, ptr);
                    321:   else if (reportError && *deb != EOS &&
                    322:            strncasecmp (deb, "azimuth", 7) &&
                    323:            strncasecmp (deb, "border-collapse", 15) &&
                    324:            strncasecmp (deb, "border-spacing", 14) &&
                    325:            strncasecmp (deb, "caption-side", 12) &&
                    326:            strncasecmp (deb, "clip", 4) &&
                    327:            strncasecmp (deb, "counter-increment", 16) &&
                    328:            strncasecmp (deb, "counter-reset", 13) &&
                    329:            strncasecmp (deb, "cue-after", 9) &&
                    330:            strncasecmp (deb, "cue-before", 10) &&
                    331:            strncasecmp (deb, "cue", 3) &&
                    332:            strncasecmp (deb, "cursor", 6) &&
                    333:            strncasecmp (deb, "elevation", 9) &&
                    334:            strncasecmp (deb, "empty-cells", 11) &&
                    335:            strncasecmp (deb, "font-strech", 11) &&
                    336:            strncasecmp (deb, "letter-spacing", 14) &&
                    337:            strncasecmp (deb, "marker-offset", 12) &&
                    338:            strncasecmp (deb, "max-height", 10) &&
                    339:            strncasecmp (deb, "max-width", 9) &&
                    340:            strncasecmp (deb, "min-height", 10) &&
                    341:            strncasecmp (deb, "min-width", 9) &&
                    342:            strncasecmp (deb, "orphans", 7) &&
                    343:            strncasecmp (deb, "outline-color", 13) &&
                    344:            strncasecmp (deb, "outline-style", 13) &&
                    345:            strncasecmp (deb, "outline-width", 13) &&
                    346:            strncasecmp (deb, "outline", 7) &&
                    347:            strncasecmp (deb, "overflow", 8) &&
                    348:            strncasecmp (deb, "pause-after", 11) &&
                    349:            strncasecmp (deb, "pause-before", 12) &&
                    350:            strncasecmp (deb, "pause", 5) &&
                    351:            strncasecmp (deb, "quotes", 6) &&
                    352:            strncasecmp (deb, "richness", 8) &&
                    353:            strncasecmp (deb, "speech-rate", 11) &&
                    354:            strncasecmp (deb, "speak-header", 12) &&
                    355:            strncasecmp (deb, "speak-punctuation", 17) &&
                    356:            strncasecmp (deb, "speak-numeral", 13) &&
                    357:            strncasecmp (deb, "speak", 5) &&
                    358:            strncasecmp (deb, "pitch-range", 11) &&
                    359:            strncasecmp (deb, "pitch", 5) &&
                    360:            strncasecmp (deb, "stress", 6) &&
                    361:            strncasecmp (deb, "table-layout", 12) &&
                    362:            strncasecmp (deb, "text-shadow", 11) &&
                    363:            strncasecmp (deb, "voice-family", 12) &&
                    364:            strncasecmp (deb, "volume", 6) &&
                    365:            strncasecmp (deb, "widows", 6))
1.205     quint     366:     CSSPrintError ("CSS property ignored:", deb);
1.86      cvs       367:   *ptr = c;
                    368:   return (ptr);
                    369: }
                    370: 
                    371: /*----------------------------------------------------------------------
1.327     vatton    372:   SkipValue
                    373:   skips the value and display an error message if msg is not NULL
1.1       cvs       374:   ----------------------------------------------------------------------*/
1.168     vatton    375: static char *SkipValue (char *msg, char *ptr)
1.1       cvs       376: {
1.86      cvs       377:   char       *deb;
                    378:   char        c;
                    379: 
                    380:   deb = ptr;
1.338     vatton    381:   while (*ptr != EOS && *ptr != ';' && *ptr != '}' && *ptr != '}' && *ptr != '\n')
1.133     vatton    382:     {
1.342     vatton    383:       if (*ptr == '"' || *ptr == '\'')
                    384:         ptr = SkipString (ptr);
                    385:       if (*ptr != EOS)
                    386:         ptr++;
1.133     vatton    387:     }
1.95      cvs       388:   /* print the skipped property */
1.86      cvs       389:   c = *ptr;
                    390:   *ptr = EOS;
1.168     vatton    391:   if (msg && *deb != EOS && *deb != ',')
                    392:     CSSPrintError (msg, deb);
1.86      cvs       393:   *ptr = c;
1.1       cvs       394:   return (ptr);
                    395: }
                    396: 
                    397: /*----------------------------------------------------------------------
1.327     vatton    398:   ParseNumber:                                                  
                    399:   parse a number and returns the corresponding value.
1.1       cvs       400:   ----------------------------------------------------------------------*/
1.79      cvs       401: char *ParseNumber (char *cssRule, PresentationValue *pval)
1.1       cvs       402: {
                    403:   int                 val = 0;
                    404:   int                 minus = 0;
                    405:   int                 valid = 0;
                    406:   int                 f = 0;
1.14      cvs       407:   ThotBool            real = FALSE;
1.1       cvs       408: 
1.184     vatton    409:   pval->typed_data.unit = UNIT_REL;
1.1       cvs       410:   pval->typed_data.real = FALSE;
1.82      cvs       411:   cssRule = SkipBlanksAndComments (cssRule);
                    412:   if (*cssRule == '-')
1.1       cvs       413:     {
                    414:       minus = 1;
                    415:       cssRule++;
1.82      cvs       416:       cssRule = SkipBlanksAndComments (cssRule);
1.1       cvs       417:     }
                    418: 
1.82      cvs       419:   if (*cssRule == '+')
1.1       cvs       420:     {
                    421:       cssRule++;
1.82      cvs       422:       cssRule = SkipBlanksAndComments (cssRule);
1.1       cvs       423:     }
                    424: 
1.82      cvs       425:   while ((*cssRule >= '0') && (*cssRule <= '9'))
1.1       cvs       426:     {
                    427:       val *= 10;
1.82      cvs       428:       val += *cssRule - '0';
1.1       cvs       429:       cssRule++;
                    430:       valid = 1;
                    431:     }
                    432: 
1.82      cvs       433:   if (*cssRule == '.')
1.1       cvs       434:     {
                    435:       real = TRUE;
                    436:       f = val;
                    437:       val = 0;
                    438:       cssRule++;
                    439:       /* keep only 3 digits */
1.82      cvs       440:       if (*cssRule >= '0' && *cssRule <= '9')
1.327     vatton    441:         {
                    442:           val = (*cssRule - '0') * 100;
                    443:           cssRule++;
                    444:           if (*cssRule >= '0' && *cssRule <= '9')
                    445:             {
                    446:               val += (*cssRule - '0') * 10;
                    447:               cssRule++;
                    448:               if ((*cssRule >= '0') && (*cssRule <= '9'))
                    449:                 {
                    450:                   val += *cssRule - '0';
                    451:                   cssRule++;
                    452:                 }
                    453:             }
                    454: 
                    455:           while (*cssRule >= '0' && *cssRule <= '9')
                    456:             cssRule++;
                    457:           valid = 1;
                    458:         }
1.1       cvs       459:     }
                    460: 
                    461:   if (!valid)
                    462:     {
1.184     vatton    463:       pval->typed_data.unit = UNIT_INVALID;
1.1       cvs       464:       pval->typed_data.value = 0;
                    465:     }
                    466:   else
                    467:     {
                    468:       pval->typed_data.real = real;
                    469:       if (real)
1.327     vatton    470:         {
                    471:           if (minus)
                    472:             pval->typed_data.value = -(f * 1000 + val);
                    473:           else
                    474:             pval->typed_data.value = f * 1000 + val;
                    475:         }
1.1       cvs       476:       else
1.327     vatton    477:         {
                    478:           if (minus)
                    479:             pval->typed_data.value = -val;
                    480:           else
                    481:             pval->typed_data.value = val;
                    482:         }
1.64      cvs       483:     }
                    484:   return (cssRule);
                    485: }
1.195     vatton    486: 
1.155     cheyroul  487: /*----------------------------------------------------------------------
1.327     vatton    488:   ParseCSSUnit:                                                  
                    489:   parse a CSS Unit substring and returns the corresponding      
                    490:   value and its unit.                                           
1.64      cvs       491:   ----------------------------------------------------------------------*/
1.82      cvs       492: char *ParseCSSUnit (char *cssRule, PresentationValue *pval)
1.64      cvs       493: {
                    494:   unsigned int        uni;
                    495: 
1.184     vatton    496:   pval->typed_data.unit = UNIT_REL;
1.64      cvs       497:   cssRule = ParseNumber (cssRule, pval);
1.184     vatton    498:   if (pval->typed_data.unit == UNIT_INVALID)
1.327     vatton    499:     cssRule = SkipWord (cssRule);
1.64      cvs       500:   else
                    501:     {
1.82      cvs       502:       cssRule = SkipBlanksAndComments (cssRule);
1.231     vatton    503:       uni = 0;
                    504:       while (CSSUnitNames[uni].sign)
1.327     vatton    505:         {
                    506:           if (!strncasecmp (CSSUnitNames[uni].sign, cssRule,
                    507:                             strlen (CSSUnitNames[uni].sign)))
                    508:             {
                    509:               pval->typed_data.unit = CSSUnitNames[uni].unit;
                    510:               return (cssRule + strlen (CSSUnitNames[uni].sign));
                    511:             }
                    512:           else
                    513:             uni++;
                    514:         }
1.64      cvs       515:       /* not in the list of predefined units */
1.184     vatton    516:       pval->typed_data.unit = UNIT_BOX;
1.1       cvs       517:     }
                    518:   return (cssRule);
                    519: }
                    520: 
1.43      cvs       521: /*----------------------------------------------------------------------
1.327     vatton    522:   ParseClampedUnit:                                                  
                    523:   parse a CSS Unit substring and returns the corresponding value and unit.
                    524:   [0,1]
1.239     vatton    525:   ----------------------------------------------------------------------*/
                    526: char *ParseClampedUnit (char *cssRule, PresentationValue *pval)
                    527: {
1.251     vatton    528:   char           *p;
                    529: 
                    530:   p = cssRule;
1.239     vatton    531:   cssRule = ParseNumber (cssRule, pval);
1.301     vatton    532:   if (*cssRule != EOS && *cssRule != SPACE && *cssRule != ';' && *cssRule != '}')
1.239     vatton    533:     {
1.251     vatton    534:       cssRule++;
1.239     vatton    535:       pval->typed_data.unit = UNIT_REL;
                    536:       if (pval->typed_data.value > 100)
1.327     vatton    537:         pval->typed_data.value = 1000;
1.239     vatton    538:       else
1.327     vatton    539:         pval->typed_data.value *= 10;
1.251     vatton    540:       CSSParseError ("Invalid value", p, cssRule);
1.239     vatton    541:     }
                    542:   else
                    543:     {
                    544:       pval->typed_data.unit = UNIT_REL;
                    545:       if (pval->typed_data.real)
1.327     vatton    546:         pval->typed_data.real = FALSE;
1.239     vatton    547:       else if (pval->typed_data.value > 1)
1.327     vatton    548:         {
                    549:           pval->typed_data.value = 1000;
                    550:           CSSParseError ("Invalid value", p, cssRule);
                    551:         }
1.251     vatton    552:       else if (pval->typed_data.value < 0)
1.327     vatton    553:         {
                    554:           pval->typed_data.value = 0;
                    555:           CSSParseError ("Invalid value", p, cssRule);
                    556:         }
1.239     vatton    557:       else
1.327     vatton    558:         pval->typed_data.value *= 1000;
1.239     vatton    559:     }
                    560:   pval->data = pval->typed_data.value;
                    561:   return (cssRule);
                    562: }
                    563: 
                    564: 
                    565: /*----------------------------------------------------------------------
1.327     vatton    566:   ParseABorderValue                                       
1.43      cvs       567:   ----------------------------------------------------------------------*/
1.288     vatton    568: static char *ParseABorderValue (char *cssRule, PresentationValue *border)
1.43      cvs       569: {
1.288     vatton    570:   char             *ptr = cssRule;
1.168     vatton    571: 
1.43      cvs       572:   /* first parse the attribute string */
1.319     quint     573:   border->typed_data.value = 0;
                    574:   border->typed_data.unit = UNIT_INVALID;
                    575:   border->typed_data.real = FALSE;
                    576:   if (!strncasecmp (cssRule, "thin", 4))
                    577:     {
                    578:       border->typed_data.unit = UNIT_PX;
                    579:       border->typed_data.value = 1;
                    580:       cssRule += 4;
                    581:     }
                    582:   else if (!strncasecmp (cssRule, "medium", 6))
                    583:     {
                    584:       border->typed_data.unit = UNIT_PX;
                    585:       border->typed_data.value = 3;
                    586:       cssRule += 6;
                    587:     }
                    588:   else if (!strncasecmp (cssRule, "thick", 5))
                    589:     {
                    590:       border->typed_data.unit = UNIT_PX;
                    591:       border->typed_data.value = 5;
                    592:       cssRule += 5;
                    593:     }
                    594:   else if (!strncasecmp (cssRule, "inherit", 7))
                    595:     {
                    596:       border->typed_data.unit = VALUE_INHERIT;
                    597:       cssRule += 7;
                    598:     }
                    599:   else if (isdigit (*cssRule) || *cssRule == '.')
                    600:     {
                    601:       cssRule = ParseCSSUnit (cssRule, border);
                    602:       if (border->typed_data.value == 0)
1.327     vatton    603:         border->typed_data.unit = UNIT_PX;
1.319     quint     604:       else if (border->typed_data.unit == UNIT_INVALID ||
1.327     vatton    605:                border->typed_data.unit == UNIT_BOX ||
                    606:                border->typed_data.unit == UNIT_PERCENT)
                    607:         {
                    608:           border->typed_data.unit = UNIT_INVALID;
                    609:           border->typed_data.value = 0;
                    610:           CSSParseError ("Invalid border-width value", ptr, cssRule);
                    611:         }
1.319     quint     612:     }
                    613:   return (cssRule);
1.43      cvs       614: }
                    615: 
1.288     vatton    616: 
                    617: /*----------------------------------------------------------------------
1.327     vatton    618:   ParseBorderStyle                                      
1.43      cvs       619:   ----------------------------------------------------------------------*/
1.79      cvs       620: static char *ParseBorderStyle (char *cssRule, PresentationValue *border)
1.43      cvs       621: {
                    622:   /* first parse the attribute string */
1.327     vatton    623:   border->typed_data.value = 0;
                    624:   border->typed_data.unit = UNIT_PX;
                    625:   border->typed_data.real = FALSE;
                    626:   if (!strncasecmp (cssRule, "none", 4))
                    627:     {
                    628:       border->typed_data.value = BorderStyleNone;
                    629:       cssRule += 4;
                    630:     }
                    631:   else if (!strncasecmp (cssRule, "hidden", 6))
                    632:     {
                    633:       border->typed_data.value = BorderStyleHidden;
                    634:       cssRule += 6;
                    635:     }
                    636:   else if (!strncasecmp (cssRule, "dotted", 6))
                    637:     {
1.288     vatton    638:       cssRule += 6;
1.327     vatton    639:       border->typed_data.value = BorderStyleDotted;
1.288     vatton    640:     }
1.327     vatton    641:   else if (!strncasecmp (cssRule, "dashed", 6))
                    642:     {
                    643:       border->typed_data.value = BorderStyleDashed;
                    644:       cssRule += 6;
                    645:     }
                    646:   else if (!strncasecmp (cssRule, "solid", 5))
                    647:     {
                    648:       border->typed_data.value = BorderStyleSolid;
                    649:       cssRule += 5;
                    650:     }
                    651:   else if (!strncasecmp (cssRule, "double", 6))
                    652:     {
                    653:       border->typed_data.value = BorderStyleDouble;
                    654:       cssRule += 6;
                    655:     }
                    656:   else if (!strncasecmp (cssRule, "groove", 6))
                    657:     {
                    658:       border->typed_data.value = BorderStyleGroove;
                    659:       cssRule += 6;
                    660:     }
                    661:   else if (!strncasecmp (cssRule, "ridge", 5))
                    662:     {
                    663:       border->typed_data.value = BorderStyleRidge;
                    664:       cssRule += 5;
                    665:     }
                    666:   else if (!strncasecmp (cssRule, "inset", 5))
                    667:     {
                    668:       border->typed_data.value = BorderStyleInset;
                    669:       cssRule += 5;
                    670:     }
                    671:   else if (!strncasecmp (cssRule, "outset", 6))
                    672:     {
                    673:       border->typed_data.value = BorderStyleOutset;
                    674:       cssRule += 6;
                    675:     }
                    676:   else
                    677:     {
                    678:       /* invalid style */
                    679:       border->typed_data.unit = UNIT_INVALID;
                    680:       return (cssRule);
                    681:     }
                    682:   return (cssRule);
1.43      cvs       683: }
                    684: 
                    685: /*----------------------------------------------------------------------
1.327     vatton    686:   ParseCSSColor: parse a CSS color attribute string    
                    687:   we expect the input string describing the attribute to be     
                    688:   either a color name, a 3 tuple or an hexadecimal encoding.    
                    689:   The color used will be approximed from the current color      
                    690:   table                                                         
1.43      cvs       691:   ----------------------------------------------------------------------*/
1.79      cvs       692: static char *ParseCSSColor (char *cssRule, PresentationValue * val)
1.43      cvs       693: {
1.79      cvs       694:   char               *ptr;
1.43      cvs       695:   unsigned short      redval = (unsigned short) -1;
                    696:   unsigned short      greenval = 0;    /* composant of each RGB       */
                    697:   unsigned short      blueval = 0;     /* default to red if unknown ! */
                    698:   int                 best = 0;        /* best color in list found */
                    699: 
1.82      cvs       700:   cssRule = SkipBlanksAndComments (cssRule);
1.184     vatton    701:   val->typed_data.unit = UNIT_INVALID;
1.43      cvs       702:   val->typed_data.real = FALSE;
                    703:   val->typed_data.value = 0;
1.57      cvs       704:   ptr = TtaGiveRGB (cssRule, &redval, &greenval, &blueval);
1.292     vatton    705:   if (!strncasecmp (cssRule, "InactiveCaptionText", 19))
                    706:     {
1.364     vatton    707:       val->typed_data.unit = VALUE_INHERIT;
1.292     vatton    708:       cssRule += 19;
                    709:     }
                    710:   else if (!strncasecmp (cssRule, "ThreeDLightShadow", 17))
                    711:     {
1.364     vatton    712:       val->typed_data.unit = VALUE_INHERIT;
1.292     vatton    713:       cssRule += 17;
                    714:     }
                    715:   else if (!strncasecmp (cssRule, "ThreeDDarkShadow", 16))
                    716:     {
1.364     vatton    717:       val->typed_data.unit = VALUE_INHERIT;
1.292     vatton    718:       cssRule += 16;
                    719:     }
                    720:   else if (!strncasecmp (cssRule, "ButtonHighlight", 15) ||
1.327     vatton    721:            !strncasecmp (cssRule, "InactiveCaption", 15) ||
                    722:            !strncasecmp (cssRule, "ThreeDHighlight", 15))
1.292     vatton    723:     {
1.364     vatton    724:       val->typed_data.unit = VALUE_INHERIT;
1.292     vatton    725:       cssRule += 15;
                    726:     }
                    727:   else if (!strncasecmp (cssRule, "InactiveBorder", 14) ||
1.327     vatton    728:            !strncasecmp (cssRule, "InfoBackground", 14))
1.292     vatton    729:     {
1.364     vatton    730:       val->typed_data.unit = VALUE_INHERIT;
1.292     vatton    731:       cssRule += 14;
                    732:     }
                    733:   else if (!strncasecmp (cssRule, "ActiveCaption", 13) ||
1.327     vatton    734:            !strncasecmp (cssRule, "HighlightText", 13))
1.292     vatton    735:     {
1.364     vatton    736:       val->typed_data.unit = VALUE_INHERIT;
1.292     vatton    737:       cssRule += 13;
                    738:     }
                    739:   else if (!strncasecmp (cssRule, "ActiveBorder", 12) ||
1.327     vatton    740:            !strncasecmp (cssRule, "AppWorkspace", 12) ||
                    741:            !strncasecmp (cssRule, "ButtonShadow", 12) ||
                    742:            !strncasecmp (cssRule, "ThreeDShadow", 12))
1.292     vatton    743:     {
1.364     vatton    744:       val->typed_data.unit = VALUE_INHERIT;
1.292     vatton    745:       cssRule += 12;
                    746:     }
                    747:   else if (!strncasecmp (cssRule, "CaptionText", 11) ||
1.327     vatton    748:            !strncasecmp (cssRule, "WindowFrame", 11))
1.292     vatton    749:     {
1.364     vatton    750:       val->typed_data.unit = VALUE_INHERIT;
1.292     vatton    751:       cssRule += 11;
                    752:     }
                    753:   else if (!strncasecmp (cssRule, "Background", 10) ||
1.327     vatton    754:            !strncasecmp (cssRule, "ButtonFace", 10) ||
                    755:            !strncasecmp (cssRule, "ButtonText", 10) ||
                    756:            !strncasecmp (cssRule, "ThreeDFace", 10) ||
                    757:            !strncasecmp (cssRule, "WindowText", 10))
1.292     vatton    758:     {
1.364     vatton    759:       val->typed_data.unit = VALUE_INHERIT;
1.292     vatton    760:       cssRule += 10;
                    761:     }
                    762:   else if (!strncasecmp (cssRule, "Highlight", 9) ||
1.327     vatton    763:            !strncasecmp (cssRule, "Scrollbar", 9))
1.292     vatton    764:     {
1.364     vatton    765:       val->typed_data.unit = VALUE_INHERIT;
1.292     vatton    766:       cssRule += 9;
                    767:     }
                    768:   else if (!strncasecmp (cssRule, "GrayText", 8) ||
1.327     vatton    769:            !strncasecmp (cssRule, "InfoText", 8) ||
                    770:            !strncasecmp (cssRule, "MenuText", 8))
1.292     vatton    771:     {
1.364     vatton    772:       val->typed_data.unit = VALUE_INHERIT;
1.292     vatton    773:       cssRule += 8;
                    774:     }
                    775:   else if (!strncasecmp (cssRule, "Window", 6))
                    776:     {
1.364     vatton    777:       val->typed_data.unit = VALUE_INHERIT;
1.292     vatton    778:       cssRule += 6;
                    779:     }
                    780:   else if (!strncasecmp (cssRule, "Menu", 5))
                    781:     {
1.364     vatton    782:       val->typed_data.unit = VALUE_INHERIT;
1.292     vatton    783:       cssRule += 5;
                    784:     }
1.293     quint     785:   else if (!strncasecmp (cssRule, "inherit", 7))
                    786:     {
                    787:       val->typed_data.unit = VALUE_INHERIT;
                    788:       cssRule += 7;
                    789:     }
1.292     vatton    790: 
1.57      cvs       791:   if (ptr == cssRule)
1.43      cvs       792:     {
1.168     vatton    793:       cssRule = SkipWord (cssRule);
                    794:       CSSParseError ("Invalid color value", ptr, cssRule);
1.43      cvs       795:       val->typed_data.value = 0;
1.184     vatton    796:       val->typed_data.unit = UNIT_INVALID;
1.43      cvs       797:     }
1.293     quint     798:   else if (val->typed_data.unit != VALUE_INHERIT)
1.43      cvs       799:     {
                    800:       best = TtaGetThotColor (redval, greenval, blueval);
                    801:       val->typed_data.value = best;
1.184     vatton    802:       val->typed_data.unit = UNIT_REL;
1.57      cvs       803:       cssRule = ptr;
1.43      cvs       804:     }
                    805:   val->typed_data.real = FALSE;
1.262     vatton    806:   cssRule = SkipBlanksAndComments (cssRule);
1.65      cvs       807:   return (cssRule);
1.43      cvs       808: }
1.1       cvs       809: 
                    810: /*----------------------------------------------------------------------
1.231     vatton    811:   CheckImportantRule updates the field important of the context and
                    812:   the line number.
1.117     vatton    813:   ----------------------------------------------------------------------*/
1.360     vatton    814: static void CheckImportantRule (char *cssRule, PresentationContext context)
1.117     vatton    815: {
1.276     vatton    816:   PresentationContextBlock dummyctxt;
                    817: 
                    818:   if (context == NULL)
                    819:     /* no context provided */
                    820:     context = &dummyctxt;
                    821: 
1.117     vatton    822:   cssRule = SkipBlanksAndComments (cssRule);
1.360     vatton    823:   while (*cssRule != EOS && *cssRule != '!' && *cssRule != ';')
                    824:     cssRule++;
1.120     vatton    825:   if (*cssRule != '!')
                    826:     context->important = FALSE;
                    827:   else
1.117     vatton    828:     {
1.120     vatton    829:       cssRule++;
1.360     vatton    830:       ImportantPos = cssRule;
1.120     vatton    831:       cssRule = SkipBlanksAndComments (cssRule);
                    832:       if (!strncasecmp (cssRule, "important", 9))
1.327     vatton    833:         {
1.360     vatton    834:           ImportantPos[-1] = EOS;
1.327     vatton    835:           context->important = TRUE;
                    836:         }
1.120     vatton    837:       else
1.360     vatton    838:         {
                    839:           ImportantPos = NULL;
                    840:           context->important = FALSE;
                    841:         }
                    842:     }
                    843: }
                    844: 
                    845: /*----------------------------------------------------------------------
                    846:   SkipImportantRule skips important markup
                    847:   ----------------------------------------------------------------------*/
                    848: static char *SkipImportantRule (char *cssRule)
                    849: {
                    850:   if (ImportantPos)
                    851:     {
                    852:       ImportantPos[-1] = '!';
1.361     vatton    853:       cssRule = ImportantPos;
                    854:       cssRule = SkipBlanksAndComments (cssRule);
                    855:       cssRule += 9;
1.360     vatton    856:       ImportantPos = NULL;
1.117     vatton    857:     }
1.360     vatton    858:   cssRule = SkipBlanksAndComments (cssRule);
1.117     vatton    859:   return (cssRule);
                    860: }
                    861: 
                    862: /*----------------------------------------------------------------------
1.327     vatton    863:   ParseCSSBorderTopWidth: parse a CSS BorderTopWidth
                    864:   attribute string.                                          
1.1       cvs       865:   ----------------------------------------------------------------------*/
1.79      cvs       866: static char *ParseCSSBorderTopWidth (Element element, PSchema tsch,
1.327     vatton    867:                                      PresentationContext context, 
                    868:                                      char *cssRule, CSSInfoPtr css,
                    869:                                      ThotBool isHTML)
1.1       cvs       870: {
1.41      cvs       871:   PresentationValue   border;
1.366     vatton    872:   char               *start_value = cssRule;
1.41      cvs       873:   
1.82      cvs       874:   cssRule = SkipBlanksAndComments (cssRule);
1.288     vatton    875:   cssRule = ParseABorderValue (cssRule, &border);
1.366     vatton    876:   if (border.typed_data.unit != UNIT_INVALID)
                    877:     {
                    878:       if (DoDialog)
                    879:         {
                    880:           if (All_sides)
                    881:             DisplayStyleValue ("border-width", start_value, cssRule);
                    882:           else
                    883:             DisplayStyleValue ("border-top-width", start_value, cssRule);
                    884:         }
                    885:       else if (DoApply)
                    886:         TtaSetStylePresentation (PRBorderTopWidth, element, tsch, context, border);
                    887:     }
1.1       cvs       888:   return (cssRule);
                    889: }
                    890: 
                    891: /*----------------------------------------------------------------------
1.327     vatton    892:   ParseCSSBorderBottomWidth: parse a CSS BorderBottomWidth
                    893:   attribute string.                                          
1.1       cvs       894:   ----------------------------------------------------------------------*/
1.79      cvs       895: static char *ParseCSSBorderBottomWidth (Element element, PSchema tsch,
1.327     vatton    896:                                         PresentationContext context,
                    897:                                         char *cssRule, CSSInfoPtr css,
                    898:                                         ThotBool isHTML)
1.1       cvs       899: {
1.41      cvs       900:   PresentationValue   border;
1.366     vatton    901:   char               *start_value = cssRule;
1.41      cvs       902:   
1.82      cvs       903:   cssRule = SkipBlanksAndComments (cssRule);
1.41      cvs       904:   /* first parse the attribute string */
1.288     vatton    905:   cssRule = ParseABorderValue (cssRule, &border);
1.366     vatton    906:   if (border.typed_data.unit != UNIT_INVALID)
                    907:     {
                    908:       if (DoDialog)
                    909:         DisplayStyleValue ("border-bottom-width", start_value, cssRule);
                    910:       else if (DoApply)
                    911:         TtaSetStylePresentation (PRBorderBottomWidth, element, tsch, context, border);
                    912:     }
1.1       cvs       913:   return (cssRule);
                    914: }
                    915: 
                    916: /*----------------------------------------------------------------------
1.327     vatton    917:   ParseCSSBorderLeftWidth: parse a CSS BorderLeftWidth
                    918:   attribute string.                                          
1.1       cvs       919:   ----------------------------------------------------------------------*/
1.79      cvs       920: static char *ParseCSSBorderLeftWidth (Element element, PSchema tsch,
1.327     vatton    921:                                       PresentationContext context,
                    922:                                       char *cssRule, CSSInfoPtr css,
                    923:                                       ThotBool isHTML)
1.1       cvs       924: {
1.41      cvs       925:   PresentationValue   border;
1.366     vatton    926:   char               *start_value = cssRule;
1.41      cvs       927:   
1.82      cvs       928:   cssRule = SkipBlanksAndComments (cssRule);
1.41      cvs       929:   /* first parse the attribute string */
1.288     vatton    930:   cssRule = ParseABorderValue (cssRule, &border);
1.366     vatton    931:   if (border.typed_data.unit != UNIT_INVALID)
                    932:     {
                    933:       if (DoDialog)
                    934:         DisplayStyleValue ("border-left-width", start_value, cssRule);
                    935:       else if (DoApply)
                    936:         TtaSetStylePresentation (PRBorderLeftWidth, element, tsch, context, border);
                    937:     }
1.1       cvs       938:   return (cssRule);
                    939: }
                    940: 
                    941: /*----------------------------------------------------------------------
1.327     vatton    942:   ParseCSSBorderRightWidth: parse a CSS BorderRightWidth
                    943:   attribute string.                                          
1.1       cvs       944:   ----------------------------------------------------------------------*/
1.79      cvs       945: static char *ParseCSSBorderRightWidth (Element element, PSchema tsch,
1.327     vatton    946:                                        PresentationContext context,
                    947:                                        char *cssRule, CSSInfoPtr css,
                    948:                                        ThotBool isHTML)
1.1       cvs       949: {
1.41      cvs       950:   PresentationValue   border;
1.366     vatton    951:   char               *start_value = cssRule;
1.41      cvs       952:   
1.82      cvs       953:   cssRule = SkipBlanksAndComments (cssRule);
1.41      cvs       954:   /* first parse the attribute string */
1.288     vatton    955:   cssRule = ParseABorderValue (cssRule, &border);
1.184     vatton    956:   if (border.typed_data.unit != UNIT_INVALID && DoApply)
1.366     vatton    957:     {
                    958:       if (DoDialog)
                    959:         DisplayStyleValue ("border-right-width", start_value, cssRule);
                    960:       else if (DoApply)
                    961:         TtaSetStylePresentation (PRBorderRightWidth, element, tsch, context, border);
                    962:     }
1.1       cvs       963:   return (cssRule);
                    964: }
                    965: 
                    966: /*----------------------------------------------------------------------
1.327     vatton    967:   ParseCSSBorderWidth: parse a CSS BorderWidth
                    968:   attribute string.                                          
1.1       cvs       969:   ----------------------------------------------------------------------*/
1.79      cvs       970: static char *ParseCSSBorderWidth (Element element, PSchema tsch,
1.327     vatton    971:                                   PresentationContext context,
                    972:                                   char *cssRule, CSSInfoPtr css,
                    973:                                   ThotBool isHTML)
1.1       cvs       974: {
1.79      cvs       975:   char *ptrT, *ptrR, *ptrB, *ptrL;
1.366     vatton    976:   int   skippedNL, n;
1.41      cvs       977: 
1.82      cvs       978:   ptrT = SkipBlanksAndComments (cssRule);
1.366     vatton    979:   if (DoDialog)
                    980:     n = NumberOfValues (ptrT);
                    981:   if (DoDialog && n < 2)
1.42      cvs       982:     {
1.366     vatton    983:       // check if the border dialog must be updated
                    984:       All_sides = TRUE;
                    985:      ptrR = ParseCSSBorderTopWidth (element, tsch, context, ptrT, css, isHTML);
                    986:       All_sides = FALSE;
1.42      cvs       987:     }
                    988:   else
                    989:     {
1.366     vatton    990:       /* First parse Border-Top */
                    991:       ptrR = ParseCSSBorderTopWidth (element, tsch, context, ptrT, css, isHTML);
                    992:       ptrR = SkipBlanksAndComments (ptrR);
                    993:       if (*ptrR == ';' || *ptrR == '}' || *ptrR == EOS || *ptrR == ',')
1.327     vatton    994:         {
                    995:           skippedNL = NewLineSkipped;
1.366     vatton    996:           cssRule = ptrR;
                    997:           /* apply the Border-Top to all */
                    998:           ptrR = ParseCSSBorderRightWidth (element, tsch, context, ptrT, css, isHTML);
                    999:           NewLineSkipped = skippedNL;
                   1000:           ptrR = ParseCSSBorderBottomWidth (element, tsch, context, ptrT, css, isHTML);
1.327     vatton   1001:           NewLineSkipped = skippedNL;
1.366     vatton   1002:           ptrR = ParseCSSBorderLeftWidth (element, tsch, context, ptrT, css, isHTML);
1.327     vatton   1003:         }
1.42      cvs      1004:       else
1.327     vatton   1005:         {
1.366     vatton   1006:           /* parse Border-Right */
                   1007:           ptrB = ParseCSSBorderRightWidth (element, tsch, context, ptrR, css, isHTML);
                   1008:           ptrB = SkipBlanksAndComments (ptrB);
                   1009:           if (*ptrB == ';' || *ptrB == '}' || *ptrB == EOS || *ptrB == ',')
1.327     vatton   1010:             {
1.366     vatton   1011:               skippedNL = NewLineSkipped;
                   1012:               cssRule = ptrB;
                   1013:               /* apply the Border-Top to Border-Bottom */
                   1014:               ptrB = ParseCSSBorderBottomWidth (element, tsch, context, ptrT, css, isHTML);
                   1015:               NewLineSkipped = skippedNL;
1.327     vatton   1016:               /* apply the Border-Right to Border-Left */
1.366     vatton   1017:               ptrB = ParseCSSBorderLeftWidth (element, tsch, context, ptrR, css, isHTML);
1.327     vatton   1018:             }
                   1019:           else
1.366     vatton   1020:             {
                   1021:               /* parse Border-Bottom */
                   1022:               ptrL = ParseCSSBorderBottomWidth (element, tsch, context, ptrB, css, isHTML);
                   1023:               ptrL = SkipBlanksAndComments (ptrL);
                   1024:               if (*ptrL == ';' || *ptrL == '}' || *ptrL == EOS || *ptrL == ',')
                   1025:                 {
                   1026:                   cssRule = ptrL;
                   1027:                   /* apply the Border-Right to Border-Left */
                   1028:                   ptrL = ParseCSSBorderLeftWidth (element, tsch, context, ptrR, css, isHTML);
                   1029:                 }
                   1030:               else
                   1031:                 /* parse Border-Left */
                   1032:                 cssRule = ParseCSSBorderLeftWidth (element, tsch, context, ptrL, css, isHTML);
                   1033:               cssRule = SkipBlanksAndComments (cssRule);
                   1034:             }
1.327     vatton   1035:         }
1.42      cvs      1036:     }
1.1       cvs      1037:   return (cssRule);
                   1038: }
                   1039: 
                   1040: /*----------------------------------------------------------------------
1.327     vatton   1041:   ParseCSSBorderColorTop: parse a CSS BorderColorTop
                   1042:   attribute string.                                          
1.1       cvs      1043:   ----------------------------------------------------------------------*/
1.79      cvs      1044: static char *ParseCSSBorderColorTop (Element element, PSchema tsch,
1.327     vatton   1045:                                      PresentationContext context,
                   1046:                                      char *cssRule, CSSInfoPtr css,
                   1047:                                      ThotBool isHTML)
1.1       cvs      1048: {
1.117     vatton   1049:   PresentationValue   best;
1.366     vatton   1050:   char               *start_value = cssRule;
1.43      cvs      1051: 
1.234     vatton   1052:   if (!strncasecmp (cssRule, "transparent", 11))
                   1053:     {
                   1054:       best.typed_data.value = -2;  /* -2 means transparent */
                   1055:       best.typed_data.unit = UNIT_REL;
                   1056:       cssRule = SkipWord (cssRule);
                   1057:     }
                   1058:   else
                   1059:     cssRule = ParseCSSColor (cssRule, &best);
1.366     vatton   1060:   if (best.typed_data.unit != UNIT_INVALID)
                   1061:     {
                   1062:       if (DoDialog)
                   1063:         {
                   1064:           if (All_sides)
                   1065:             DisplayStyleValue ("border-color", start_value, cssRule);
                   1066:           else
                   1067:             DisplayStyleValue ("border-top-color", start_value, cssRule);
                   1068:         }
                   1069:       else if (DoApply)
                   1070:         /* install the new presentation */
                   1071:         TtaSetStylePresentation (PRBorderTopColor, element, tsch, context, best);
                   1072:     }
1.117     vatton   1073:   return (cssRule);
1.1       cvs      1074: }
                   1075: 
                   1076: /*----------------------------------------------------------------------
1.327     vatton   1077:   ParseCSSBorderColorLeft: parse a CSS BorderColorLeft
                   1078:   attribute string.                                          
1.42      cvs      1079:   ----------------------------------------------------------------------*/
1.79      cvs      1080: static char *ParseCSSBorderColorLeft (Element element, PSchema tsch,
1.327     vatton   1081:                                       PresentationContext context,
                   1082:                                       char *cssRule, CSSInfoPtr css,
                   1083:                                       ThotBool isHTML)
1.42      cvs      1084: {
1.117     vatton   1085:   PresentationValue   best;
1.366     vatton   1086:   char               *start_value = cssRule;
1.117     vatton   1087:   
1.234     vatton   1088:   if (!strncasecmp (cssRule, "transparent", 11))
                   1089:     {
                   1090:       best.typed_data.value = -2;  /* -2 means transparent */
                   1091:       best.typed_data.unit = UNIT_REL;
                   1092:       cssRule = SkipWord (cssRule);
                   1093:     }
                   1094:   else
                   1095:     cssRule = ParseCSSColor (cssRule, &best);
1.184     vatton   1096:   if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.366     vatton   1097:     {
                   1098:       if (DoDialog)
                   1099:         DisplayStyleValue ("border-left-color", start_value, cssRule);
                   1100:       else if (DoApply)
                   1101:         /* install the new presentation */
                   1102:         TtaSetStylePresentation (PRBorderLeftColor, element, tsch, context, best);
                   1103:     }
1.117     vatton   1104:   return (cssRule);
1.42      cvs      1105: }
                   1106: 
                   1107: /*----------------------------------------------------------------------
1.327     vatton   1108:   ParseCSSBorderColorBottom: parse a CSS BorderColorBottom
                   1109:   attribute string.                                          
1.42      cvs      1110:   ----------------------------------------------------------------------*/
1.79      cvs      1111: static char *ParseCSSBorderColorBottom (Element element, PSchema tsch,
1.327     vatton   1112:                                         PresentationContext context,
                   1113:                                         char *cssRule, CSSInfoPtr css,
                   1114:                                         ThotBool isHTML)
1.42      cvs      1115: {
1.117     vatton   1116:   PresentationValue   best;
1.366     vatton   1117:   char               *start_value = cssRule;
1.43      cvs      1118: 
1.234     vatton   1119:   if (!strncasecmp (cssRule, "transparent", 11))
                   1120:     {
                   1121:       best.typed_data.value = -2;  /* -2 means transparent */
                   1122:       best.typed_data.unit = UNIT_REL;
                   1123:       cssRule = SkipWord (cssRule);
                   1124:     }
                   1125:   else
                   1126:     cssRule = ParseCSSColor (cssRule, &best);
1.184     vatton   1127:   if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.366     vatton   1128:     {
                   1129:       if (DoDialog)
                   1130:         DisplayStyleValue ("border-bottom-color", start_value, cssRule);
                   1131:       else if (DoApply)
                   1132:         /* install the new presentation */
                   1133:         TtaSetStylePresentation (PRBorderBottomColor, element, tsch, context, best);
                   1134:     }
1.327     vatton   1135:   return (cssRule);
1.42      cvs      1136: }
                   1137: 
                   1138: /*----------------------------------------------------------------------
1.327     vatton   1139:   ParseCSSBorderColorRight: parse a CSS BorderColorRight
                   1140:   attribute string.                                          
1.1       cvs      1141:   ----------------------------------------------------------------------*/
1.79      cvs      1142: static char *ParseCSSBorderColorRight (Element element, PSchema tsch,
1.327     vatton   1143:                                        PresentationContext context,
                   1144:                                        char *cssRule, CSSInfoPtr css,
                   1145:                                        ThotBool isHTML)
1.1       cvs      1146: {
1.117     vatton   1147:   PresentationValue   best;
1.366     vatton   1148:   char               *start_value = cssRule;
1.43      cvs      1149: 
1.234     vatton   1150:   if (!strncasecmp (cssRule, "transparent", 11))
                   1151:     {
                   1152:       best.typed_data.value = -2;  /* -2 means transparent */
                   1153:       best.typed_data.unit = UNIT_REL;
                   1154:       cssRule = SkipWord (cssRule);
                   1155:     }
                   1156:   else
                   1157:     cssRule = ParseCSSColor (cssRule, &best);
1.184     vatton   1158:   if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.366     vatton   1159:     {
                   1160:       if (DoDialog)
                   1161:         DisplayStyleValue ("border-right-color", start_value, cssRule);
                   1162:       else if (DoApply)
                   1163:         TtaSetStylePresentation (PRBorderRightColor, element, tsch, context, best);
                   1164:     }
1.117     vatton   1165:   return (cssRule);
1.1       cvs      1166: }
                   1167: 
                   1168: /*----------------------------------------------------------------------
1.327     vatton   1169:   ParseCSSBorderColor: parse a CSS border-color        
                   1170:   attribute string.                                          
1.42      cvs      1171:   ----------------------------------------------------------------------*/
1.79      cvs      1172: static char *ParseCSSBorderColor (Element element, PSchema tsch,
1.327     vatton   1173:                                   PresentationContext context,
                   1174:                                   char *cssRule, CSSInfoPtr css,
                   1175:                                   ThotBool isHTML)
1.42      cvs      1176: {
1.79      cvs      1177:   char *ptrT, *ptrR, *ptrB, *ptrL;
1.366     vatton   1178:   int   skippedNL, n;
1.42      cvs      1179: 
1.82      cvs      1180:   ptrT = SkipBlanksAndComments (cssRule);
1.366     vatton   1181:   if (DoDialog)
                   1182:     n = NumberOfValues (ptrT);
                   1183:   if (DoDialog && n < 2)
1.42      cvs      1184:     {
1.366     vatton   1185:       // check if the border dialog must be updated
                   1186:       All_sides = TRUE;
                   1187:      ptrR = ParseCSSBorderColorTop (element, tsch, context, ptrT, css, isHTML);
                   1188:       All_sides = FALSE;
1.42      cvs      1189:     }
                   1190:   else
                   1191:     {
1.366     vatton   1192:       /* First parse Border-Top */
                   1193:       ptrR = ParseCSSBorderColorTop (element, tsch, context, ptrT, css, isHTML);
                   1194:       ptrR = SkipBlanksAndComments (ptrR);
                   1195:       if (*ptrR == ';' || *ptrR == '}' || *ptrR == EOS || *ptrR == ',')
1.327     vatton   1196:         {
                   1197:           skippedNL = NewLineSkipped;
1.366     vatton   1198:           cssRule = ptrR;
                   1199:           /* apply the Border-Top to all */
                   1200:           ptrR = ParseCSSBorderColorRight (element, tsch, context, ptrT, css, isHTML);
                   1201:           NewLineSkipped = skippedNL;
                   1202:           ptrR = ParseCSSBorderColorBottom (element, tsch, context, ptrT, css, isHTML);
1.327     vatton   1203:           NewLineSkipped = skippedNL;
1.366     vatton   1204:           ptrR = ParseCSSBorderColorLeft (element, tsch, context, ptrT, css, isHTML);
1.327     vatton   1205:         }
1.42      cvs      1206:       else
1.327     vatton   1207:         {
1.366     vatton   1208:           /* parse Border-Right */
                   1209:           ptrB = ParseCSSBorderColorRight (element, tsch, context, ptrR, css, isHTML);
                   1210:           ptrB = SkipBlanksAndComments (ptrB);
                   1211:           if (*ptrB == ';' || *ptrB == '}' || *ptrB == EOS || *ptrB == ',')
1.327     vatton   1212:             {
1.366     vatton   1213:               skippedNL = NewLineSkipped;
                   1214:               cssRule = ptrB;
                   1215:               /* apply the Border-Top to Border-Bottom */
                   1216:               ptrB = ParseCSSBorderColorBottom (element, tsch, context, ptrT, css, isHTML);
                   1217:               NewLineSkipped = skippedNL;
1.327     vatton   1218:               /* apply the Border-Right to Border-Left */
1.366     vatton   1219:               ptrB = ParseCSSBorderColorLeft (element, tsch, context, ptrR, css, isHTML);
1.327     vatton   1220:             }
                   1221:           else
1.366     vatton   1222:             {
                   1223:               skippedNL = NewLineSkipped;
                   1224:               /* parse Border-Bottom */
                   1225:               ptrL = ParseCSSBorderColorBottom (element, tsch, context, ptrB, css, isHTML);
                   1226:               NewLineSkipped = skippedNL;
                   1227:               ptrL = SkipBlanksAndComments (ptrL);
                   1228:               if (*ptrL == ';' || *ptrL == '}' || *ptrL == EOS || *ptrL == ',')
                   1229:                 {
                   1230:                   cssRule = ptrL;
                   1231:                   /* apply the Border-Right to Border-Left */
                   1232:                   ptrL = ParseCSSBorderColorLeft (element, tsch, context, ptrR, css, isHTML);
                   1233:                 }
                   1234:               else
                   1235:                 /* parse Border-Left */
                   1236:                 cssRule = ParseCSSBorderColorLeft (element, tsch, context, ptrL, css, isHTML);
                   1237:               cssRule = SkipBlanksAndComments (cssRule);
                   1238:             }
1.327     vatton   1239:         }
1.42      cvs      1240:     }
                   1241:   return (cssRule);
                   1242: }
                   1243: 
                   1244: /*----------------------------------------------------------------------
1.327     vatton   1245:   ParseCSSBorderStyleTop: parse a CSS BorderStyleTop
                   1246:   attribute string.                                          
1.42      cvs      1247:   ----------------------------------------------------------------------*/
1.79      cvs      1248: static char *ParseCSSBorderStyleTop (Element element, PSchema tsch,
1.327     vatton   1249:                                      PresentationContext context,
                   1250:                                      char *cssRule, CSSInfoPtr css,
                   1251:                                      ThotBool isHTML)
1.42      cvs      1252: {
1.43      cvs      1253:   PresentationValue   border;
1.366     vatton   1254:   char               *start_value;
1.43      cvs      1255:   
1.82      cvs      1256:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   1257:   start_value = cssRule;
1.43      cvs      1258:   cssRule = ParseBorderStyle (cssRule, &border);
1.366     vatton   1259:   if (border.typed_data.unit != UNIT_INVALID)
                   1260:     {
                   1261:       if (DoDialog)
                   1262:         {
                   1263:           if (All_sides)
                   1264:             DisplayStyleValue ("border-style", start_value, cssRule);
                   1265:           else
                   1266:             DisplayStyleValue ("border-top-style", start_value, cssRule);
                   1267:         }
                   1268:       else if (DoApply)
                   1269:         TtaSetStylePresentation (PRBorderTopStyle, element, tsch, context, border);
                   1270:     }
1.42      cvs      1271:   return (cssRule);
                   1272: }
                   1273: 
                   1274: /*----------------------------------------------------------------------
1.327     vatton   1275:   ParseCSSBorderStyleLeft: parse a CSS BorderStyleLeft
                   1276:   attribute string.                                          
1.42      cvs      1277:   ----------------------------------------------------------------------*/
1.79      cvs      1278: static char *ParseCSSBorderStyleLeft (Element element, PSchema tsch,
1.327     vatton   1279:                                       PresentationContext context,
                   1280:                                       char *cssRule, CSSInfoPtr css,
                   1281:                                       ThotBool isHTML)
1.42      cvs      1282: {
1.43      cvs      1283:   PresentationValue   border;
1.366     vatton   1284:   char               *start_value;
1.43      cvs      1285:   
1.82      cvs      1286:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   1287:   start_value = cssRule;
1.43      cvs      1288:   cssRule = ParseBorderStyle (cssRule, &border);
1.366     vatton   1289:   if (border.typed_data.unit != UNIT_INVALID)
                   1290:     {
                   1291:       if (DoDialog)
                   1292:         DisplayStyleValue ("border-left-style", start_value, cssRule);
                   1293:       else if (DoApply)
                   1294:         TtaSetStylePresentation (PRBorderLeftStyle, element, tsch, context, border);
                   1295:     }
1.42      cvs      1296:   return (cssRule);
                   1297: }
                   1298: 
                   1299: /*----------------------------------------------------------------------
1.327     vatton   1300:   ParseCSSBorderStyleBottom: parse a CSS BorderStyleBottom
                   1301:   attribute string.                                          
1.1       cvs      1302:   ----------------------------------------------------------------------*/
1.79      cvs      1303: static char *ParseCSSBorderStyleBottom (Element element, PSchema tsch,
1.327     vatton   1304:                                         PresentationContext context,
                   1305:                                         char *cssRule, CSSInfoPtr css,
                   1306:                                         ThotBool isHTML)
1.1       cvs      1307: {
1.43      cvs      1308:   PresentationValue   border;
1.366     vatton   1309:   char               *start_value;
1.43      cvs      1310:   
1.82      cvs      1311:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   1312:   start_value = cssRule;
1.43      cvs      1313:   cssRule = ParseBorderStyle (cssRule, &border);
1.366     vatton   1314:   if (border.typed_data.unit != UNIT_INVALID)
                   1315:     {
                   1316:       if (DoDialog)
                   1317:         DisplayStyleValue ("border-bottom-style", start_value, cssRule);
                   1318:       else if (DoApply)
                   1319:         TtaSetStylePresentation (PRBorderBottomStyle, element, tsch, context, border);
                   1320:     }
1.1       cvs      1321:   return (cssRule);
                   1322: }
                   1323: 
                   1324: /*----------------------------------------------------------------------
1.327     vatton   1325:   ParseCSSBorderStyleRight: parse a CSS BorderStyleRight
                   1326:   attribute string.                                          
1.1       cvs      1327:   ----------------------------------------------------------------------*/
1.79      cvs      1328: static char *ParseCSSBorderStyleRight (Element element, PSchema tsch,
1.327     vatton   1329:                                        PresentationContext context,
                   1330:                                        char *cssRule, CSSInfoPtr css,
                   1331:                                        ThotBool isHTML)
1.1       cvs      1332: {
1.43      cvs      1333:   PresentationValue   border;
1.366     vatton   1334:   char               *start_value;
1.43      cvs      1335:   
1.82      cvs      1336:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   1337:   start_value = cssRule;
1.43      cvs      1338:   cssRule = ParseBorderStyle (cssRule, &border);
1.184     vatton   1339:   if (border.typed_data.unit != UNIT_INVALID && DoApply)
1.366     vatton   1340:     {
                   1341:       if (DoDialog)
                   1342:         DisplayStyleValue ("border-right-style", start_value, cssRule);
                   1343:       else if (DoApply)
                   1344:         TtaSetStylePresentation (PRBorderRightStyle, element, tsch, context, border);
                   1345:     }
1.1       cvs      1346:   return (cssRule);
                   1347: }
                   1348: 
                   1349: /*----------------------------------------------------------------------
1.349     quint    1350:   ParseCSSBorderStyle: parse a CSS border-style attribute string.
1.1       cvs      1351:   ----------------------------------------------------------------------*/
1.79      cvs      1352: static char *ParseCSSBorderStyle (Element element, PSchema tsch,
1.327     vatton   1353:                                   PresentationContext context,
                   1354:                                   char *cssRule, CSSInfoPtr css,
                   1355:                                   ThotBool isHTML)
1.1       cvs      1356: {
1.79      cvs      1357:   char *ptrT, *ptrR, *ptrB, *ptrL;
1.366     vatton   1358:   int   skippedNL, n;
1.42      cvs      1359: 
1.82      cvs      1360:   ptrT = SkipBlanksAndComments (cssRule);
1.366     vatton   1361:   if (DoDialog)
                   1362:     n = NumberOfValues (ptrT);
                   1363:   if (DoDialog && n < 2)
1.42      cvs      1364:     {
1.366     vatton   1365:       // check if the border dialog must be updated
                   1366:       All_sides = TRUE;
                   1367:      ptrR =  ParseCSSBorderStyleTop(element, tsch, context, ptrT, css, isHTML);
                   1368:       All_sides = FALSE;
1.42      cvs      1369:     }
                   1370:   else
                   1371:     {
1.366     vatton   1372:       /* First parse Border-Top */
                   1373:       ptrR = ParseCSSBorderStyleTop (element, tsch, context, ptrT, css, isHTML);
                   1374:       ptrR = SkipBlanksAndComments (ptrR);
                   1375:       if (*ptrR == ';' || *ptrR == '}' || *ptrR == EOS || *ptrR == ',')
1.327     vatton   1376:         {
                   1377:           skippedNL = NewLineSkipped;
1.366     vatton   1378:           cssRule = ptrR;
                   1379:           /* apply the Border-Top to all */
                   1380:           ptrR = ParseCSSBorderStyleRight (element, tsch, context, ptrT, css, isHTML);
                   1381:           NewLineSkipped = skippedNL;
                   1382:           ptrR = ParseCSSBorderStyleBottom (element, tsch, context, ptrT, css, isHTML);
1.327     vatton   1383:           NewLineSkipped = skippedNL;
1.366     vatton   1384:           ptrR = ParseCSSBorderStyleLeft (element, tsch, context, ptrT, css, isHTML);
1.327     vatton   1385:         }
1.42      cvs      1386:       else
1.327     vatton   1387:         {
1.366     vatton   1388:           /* parse Border-Right */
                   1389:           ptrB = ParseCSSBorderStyleRight (element, tsch, context, ptrR, css, isHTML);
                   1390:           ptrB = SkipBlanksAndComments (ptrB);
                   1391:           if (*ptrB == ';' || *ptrR == '}' || *ptrB == EOS || *ptrB == ',')
1.327     vatton   1392:             {
1.366     vatton   1393:               skippedNL = NewLineSkipped;
                   1394:               cssRule = ptrB;
                   1395:               /* apply the Border-Top to Border-Bottom */
                   1396:               ptrB = ParseCSSBorderStyleBottom (element, tsch, context, ptrT, css, isHTML);
                   1397:               NewLineSkipped = skippedNL;
1.327     vatton   1398:               /* apply the Border-Right to Border-Left */
1.366     vatton   1399:               ptrB = ParseCSSBorderStyleLeft (element, tsch, context, ptrR, css, isHTML);
1.327     vatton   1400:             }
                   1401:           else
1.366     vatton   1402:             {
                   1403:               /* parse Border-Bottom */
                   1404:               ptrL = ParseCSSBorderStyleBottom (element, tsch, context, ptrB, css, isHTML);
                   1405:               ptrL = SkipBlanksAndComments (ptrL);
                   1406:               if (*ptrL == ';' || *ptrR == '}' || *ptrL == EOS || *ptrL == ',')
                   1407:                 {
                   1408:                   cssRule = ptrL;
                   1409:                   /* apply the Border-Right to Border-Left */
                   1410:                   ptrL = ParseCSSBorderStyleLeft (element, tsch, context, ptrR, css, isHTML);
                   1411:                 }
                   1412:               else
                   1413:                 /* parse Border-Left */
                   1414:                 cssRule = ParseCSSBorderStyleLeft (element, tsch, context, ptrL, css, isHTML);
                   1415:               cssRule = SkipBlanksAndComments (cssRule);
                   1416:             }
1.327     vatton   1417:         }
1.42      cvs      1418:     }
                   1419:   return (cssRule);
                   1420: }
                   1421: 
                   1422: /*----------------------------------------------------------------------
1.327     vatton   1423:   ParseCSSBorderTop: parse a CSS BorderTop
                   1424:   attribute string.                                          
1.42      cvs      1425:   ----------------------------------------------------------------------*/
1.79      cvs      1426: static char *ParseCSSBorderTop (Element element, PSchema tsch,
1.327     vatton   1427:                                 PresentationContext context, char *cssRule,
                   1428:                                 CSSInfoPtr css, ThotBool isHTML)
1.42      cvs      1429: {
1.79      cvs      1430:   char           *ptr;
1.322     vatton   1431:   ThotBool        style, width;
1.43      cvs      1432: 
1.82      cvs      1433:   cssRule = SkipBlanksAndComments (cssRule);
1.322     vatton   1434:   /* register given values */
1.337     vatton   1435:   if (!strncmp (cssRule, "none", 4))
                   1436:     style = width = TRUE;
                   1437:   else
                   1438:     style = width = FALSE;
1.301     vatton   1439:   while (*cssRule != ';' && *cssRule != '}' && *cssRule != EOS && *cssRule != ',')
1.43      cvs      1440:     {
                   1441:       ptr = cssRule;
                   1442:       cssRule = ParseCSSBorderStyleTop (element, tsch, context, cssRule, css, isHTML);
                   1443:       if (ptr == cssRule)
1.327     vatton   1444:         {
                   1445:           cssRule = ParseCSSBorderTopWidth (element, tsch, context, cssRule, css, isHTML);
                   1446:           if (ptr == cssRule)
                   1447:             cssRule = ParseCSSBorderColorTop (element, tsch, context, cssRule, css, isHTML);
                   1448:           else
                   1449:             width = TRUE;
                   1450:           if (ptr == cssRule)
                   1451:             {
                   1452:               /* rule not found */
                   1453:               cssRule = SkipValue ("Invalid border value", cssRule);
                   1454:               return (cssRule);
                   1455:             }
                   1456:         }
1.322     vatton   1457:       else
1.327     vatton   1458:         style = TRUE;
1.82      cvs      1459:       cssRule = SkipBlanksAndComments (cssRule);
1.43      cvs      1460:     }
1.322     vatton   1461: 
                   1462:   if (!width)
                   1463:     ParseCSSBorderTopWidth (element, tsch, context, "medium", css, isHTML);
                   1464:   if (!style)
                   1465:     ParseCSSBorderStyleTop (element, tsch, context, "none", css, isHTML);
1.42      cvs      1466:   return (cssRule);
                   1467: }
                   1468: 
                   1469: /*----------------------------------------------------------------------
1.327     vatton   1470:   ParseCSSBorderLeft: parse a CSS BorderLeft
                   1471:   attribute string.                                          
1.42      cvs      1472:   ----------------------------------------------------------------------*/
1.79      cvs      1473: static char *ParseCSSBorderLeft (Element element, PSchema tsch,
1.327     vatton   1474:                                  PresentationContext context, char *cssRule,
                   1475:                                  CSSInfoPtr css, ThotBool isHTML)
1.42      cvs      1476: {
1.79      cvs      1477:   char           *ptr;
1.322     vatton   1478:   ThotBool        style, width;
1.43      cvs      1479: 
1.82      cvs      1480:   cssRule = SkipBlanksAndComments (cssRule);
1.322     vatton   1481:   /* register given values */
1.337     vatton   1482:   if (!strncmp (cssRule, "none", 4))
                   1483:     style = width = TRUE;
                   1484:   else
                   1485:     style = width = FALSE;
1.301     vatton   1486:   while (*cssRule != ';' && *cssRule != '}' && *cssRule != EOS && *cssRule != ',')
1.43      cvs      1487:     {
                   1488:       ptr = cssRule;
                   1489:       cssRule = ParseCSSBorderStyleLeft (element, tsch, context, cssRule, css, isHTML);
                   1490:       if (ptr == cssRule)
1.327     vatton   1491:         {
                   1492:           cssRule = ParseCSSBorderLeftWidth (element, tsch, context, cssRule, css, isHTML);
                   1493:           if (ptr == cssRule)
                   1494:             cssRule = ParseCSSBorderColorLeft (element, tsch, context, cssRule, css, isHTML);
                   1495:           else
                   1496:             width = TRUE;
                   1497:           if (ptr == cssRule)
                   1498:             {
                   1499:               /* rule not found */
                   1500:               cssRule = SkipValue ("Invalid border value", cssRule);
                   1501:               return (cssRule);
                   1502:             }
                   1503:         }
1.322     vatton   1504:       else
1.327     vatton   1505:         style = TRUE;
                   1506:       cssRule = SkipBlanksAndComments (cssRule);
1.43      cvs      1507:     }
1.322     vatton   1508: 
                   1509:   if (!width)
                   1510:     ParseCSSBorderLeftWidth (element, tsch, context, "medium", css, isHTML);
                   1511:   if (!style)
                   1512:     ParseCSSBorderStyleLeft (element, tsch, context, "none", css, isHTML);
1.1       cvs      1513:   return (cssRule);
                   1514: }
                   1515: 
                   1516: /*----------------------------------------------------------------------
1.327     vatton   1517:   ParseCSSBorderBottom: parse a CSS BorderBottom
                   1518:   attribute string.                                          
1.1       cvs      1519:   ----------------------------------------------------------------------*/
1.79      cvs      1520: static char *ParseCSSBorderBottom (Element element, PSchema tsch,
1.327     vatton   1521:                                    PresentationContext context, char *cssRule,
                   1522:                                    CSSInfoPtr css, ThotBool isHTML)
1.1       cvs      1523: {
1.79      cvs      1524:   char           *ptr;
1.322     vatton   1525:   ThotBool        style, width;
1.43      cvs      1526: 
1.82      cvs      1527:   cssRule = SkipBlanksAndComments (cssRule);
1.322     vatton   1528:   /* register given values */
1.337     vatton   1529:   if (!strncmp (cssRule, "none", 4))
                   1530:     style = width = TRUE;
                   1531:   else
                   1532:     style = width = FALSE;
1.301     vatton   1533:   while (*cssRule != ';' && *cssRule != '}' && *cssRule != EOS && *cssRule != ',')
1.43      cvs      1534:     {
                   1535:       ptr = cssRule;
                   1536:       cssRule = ParseCSSBorderStyleBottom (element, tsch, context, cssRule, css, isHTML);
                   1537:       if (ptr == cssRule)
1.327     vatton   1538:         {
                   1539:           cssRule = ParseCSSBorderBottomWidth (element, tsch, context, cssRule, css, isHTML);
                   1540:           if (ptr == cssRule)
                   1541:             cssRule = ParseCSSBorderColorBottom (element, tsch, context, cssRule, css, isHTML);
                   1542:           else
                   1543:             width = TRUE;
                   1544:           if (ptr == cssRule)
                   1545:             {
                   1546:               /* rule not found */
                   1547:               cssRule = SkipValue ("Invalid border value", cssRule);
                   1548:               return (cssRule);
                   1549:             }
                   1550:         }
1.322     vatton   1551:       else
1.327     vatton   1552:         style = TRUE;
1.82      cvs      1553:       cssRule = SkipBlanksAndComments (cssRule);
1.43      cvs      1554:     }
1.322     vatton   1555: 
                   1556:   if (!width)
                   1557:     ParseCSSBorderBottomWidth (element, tsch, context, "medium", css, isHTML);
                   1558:   if (!style)
                   1559:     ParseCSSBorderStyleBottom (element, tsch, context, "none", css, isHTML);
1.1       cvs      1560:   return (cssRule);
                   1561: }
                   1562: 
                   1563: /*----------------------------------------------------------------------
1.327     vatton   1564:   ParseCSSBorderRight: parse a CSS BorderRight
                   1565:   attribute string.                                          
1.1       cvs      1566:   ----------------------------------------------------------------------*/
1.79      cvs      1567: static char *ParseCSSBorderRight (Element element, PSchema tsch,
1.327     vatton   1568:                                   PresentationContext context, char *cssRule,
                   1569:                                   CSSInfoPtr css, ThotBool isHTML)
1.1       cvs      1570: {
1.79      cvs      1571:   char            *ptr;
1.322     vatton   1572:   ThotBool        style, width;
1.43      cvs      1573: 
1.82      cvs      1574:   cssRule = SkipBlanksAndComments (cssRule);
1.322     vatton   1575:   /* register given values */
1.337     vatton   1576:   if (!strncmp (cssRule, "none", 4))
                   1577:     style = width = TRUE;
                   1578:   else
                   1579:     style = width = FALSE;
1.301     vatton   1580:   while (*cssRule != ';' && *cssRule != '}' && *cssRule != EOS && *cssRule != ',')
1.43      cvs      1581:     {
                   1582:       ptr = cssRule;
                   1583:       cssRule = ParseCSSBorderStyleRight (element, tsch, context, cssRule, css, isHTML);
                   1584:       if (ptr == cssRule)
1.327     vatton   1585:         {
                   1586:           cssRule = ParseCSSBorderRightWidth (element, tsch, context, cssRule, css, isHTML);
                   1587:           if (ptr == cssRule)
                   1588:             cssRule = ParseCSSBorderColorRight (element, tsch, context, cssRule, css, isHTML);
                   1589:           else
                   1590:             width = TRUE;
                   1591:           if (ptr == cssRule)
                   1592:             {
                   1593:               /* rule not found */
                   1594:               cssRule = SkipValue ("Invalid border value", cssRule);
                   1595:               return (cssRule);
                   1596:             }
                   1597:         }
1.322     vatton   1598:       else
1.327     vatton   1599:         style = TRUE;
1.82      cvs      1600:       cssRule = SkipBlanksAndComments (cssRule);
1.43      cvs      1601:     }
1.322     vatton   1602: 
                   1603:   if (!width)
                   1604:     ParseCSSBorderRightWidth (element, tsch, context, "medium", css, isHTML);
                   1605:   if (!style)
                   1606:     ParseCSSBorderStyleRight (element, tsch, context, "none", css, isHTML);
1.1       cvs      1607:   return (cssRule);
                   1608: }
                   1609: 
                   1610: /*----------------------------------------------------------------------
1.327     vatton   1611:   ParseCSSBorder: parse a CSS border        
                   1612:   attribute string.                                          
1.42      cvs      1613:   ----------------------------------------------------------------------*/
1.79      cvs      1614: static char *ParseCSSBorder (Element element, PSchema tsch,
1.327     vatton   1615:                              PresentationContext context, char *cssRule,
                   1616:                              CSSInfoPtr css, ThotBool isHTML)
1.42      cvs      1617: {
1.79      cvs      1618:   char *ptrT, *ptrR;
1.366     vatton   1619:   int   skippedNL, n;
1.42      cvs      1620: 
1.82      cvs      1621:   ptrT = SkipBlanksAndComments (cssRule);
1.366     vatton   1622:   if (DoDialog)
                   1623:     n = NumberOfValues (ptrT);
                   1624:   if (DoDialog && n < 4)
1.42      cvs      1625:     {
1.366     vatton   1626:       // check if the border dialog must be updated
                   1627:       All_sides = TRUE;
                   1628:      ptrR = ParseCSSBorderTop (element, tsch, context, ptrT, css, isHTML);
                   1629:       All_sides = FALSE;
                   1630:     }
                   1631:   else
                   1632:     {
                   1633:       /* First parse Border-Top */
                   1634:       ptrR = ParseCSSBorderTop (element, tsch, context, ptrT, css, isHTML);
                   1635:       ptrR = SkipBlanksAndComments (ptrR);
                   1636:       if (*ptrR == ';' || *ptrR == '}' || *ptrR == EOS || *ptrR == ',')
                   1637:         {
                   1638:           skippedNL = NewLineSkipped;
                   1639:           cssRule = ptrR;
                   1640:           /* apply the Border-Top to all */
                   1641:           ptrR = ParseCSSBorderRight (element, tsch, context, ptrT, css, isHTML);
                   1642:           NewLineSkipped = skippedNL;
                   1643:           ptrR = ParseCSSBorderBottom (element, tsch, context, ptrT, css, isHTML);
                   1644:           NewLineSkipped = skippedNL;
                   1645:           ptrR = ParseCSSBorderLeft (element, tsch, context, ptrT, css, isHTML);
                   1646:         }
1.42      cvs      1647:     }
                   1648:   return (cssRule);
                   1649: }
                   1650: 
1.218     vatton   1651: 
1.42      cvs      1652: /*----------------------------------------------------------------------
1.327     vatton   1653:   ParseCSSFloat: parse a CSS float attribute string    
1.184     vatton   1654:   ----------------------------------------------------------------------*/
                   1655: static char *ParseCSSFloat (Element element, PSchema tsch,
1.327     vatton   1656:                             PresentationContext context, char *cssRule,
                   1657:                             CSSInfoPtr css, ThotBool isHTML)
1.184     vatton   1658: {
1.257     vatton   1659:   DisplayMode         dispMode;
1.184     vatton   1660:   PresentationValue   pval;
1.288     vatton   1661:   char               *ptr = cssRule;
1.184     vatton   1662: 
                   1663:   pval.typed_data.value = 0;
1.187     vatton   1664:   pval.typed_data.unit = UNIT_BOX;
1.192     cvs      1665:   pval.typed_data.real = FALSE;
1.190     vatton   1666:   if (!strncasecmp (cssRule, "inherit", 7))
                   1667:     {
1.293     quint    1668:       pval.typed_data.unit = VALUE_INHERIT;
1.288     vatton   1669:       cssRule += 7;
1.190     vatton   1670:     }
1.184     vatton   1671:   if (!strncasecmp (cssRule, "none", 4))
1.288     vatton   1672:     {
                   1673:       pval.typed_data.value = FloatNone;
1.293     quint    1674:       cssRule += 4;
1.288     vatton   1675:     }
1.184     vatton   1676:   else if (!strncasecmp (cssRule, "left", 4))
1.288     vatton   1677:     {
                   1678:       pval.typed_data.value = FloatLeft;
1.293     quint    1679:       cssRule += 4;
1.288     vatton   1680:     }
1.184     vatton   1681:   else if (!strncasecmp (cssRule, "right", 5))
1.288     vatton   1682:     {
                   1683:       pval.typed_data.value = FloatRight;
1.293     quint    1684:       cssRule += 5;
1.288     vatton   1685:     }
1.184     vatton   1686: 
1.293     quint    1687:   if (pval.typed_data.value == 0 && pval.typed_data.unit != VALUE_INHERIT)
1.359     quint    1688:     {
                   1689:       if (!strncasecmp (cssRule, "top", 3) ||
                   1690:           !strncasecmp (cssRule, "bottom", 6) ||
                   1691:           !strncasecmp (cssRule, "inside", 6) ||
                   1692:           !strncasecmp (cssRule, "outside", 7) ||
                   1693:           !strncasecmp (cssRule, "start", 5) ||
                   1694:           !strncasecmp (cssRule, "end", 3))
                   1695:         cssRule = SkipValue ("Warning: CSS3 value not supported", cssRule);
                   1696:       else
                   1697:         cssRule = SkipValue ("Invalid float value", cssRule);
                   1698:     }
1.184     vatton   1699:   else
                   1700:     {
1.366     vatton   1701:       if (DoDialog)
                   1702:         DisplayStyleValue ("float", ptr, cssRule);
                   1703:       else if (DoApply)
1.327     vatton   1704:         {
                   1705:           dispMode = TtaGetDisplayMode (context->doc);
                   1706:           if (dispMode != NoComputedDisplay)
                   1707:             {
                   1708:               /* force a redisplay of the whole document */
                   1709:               TtaSetDisplayMode (context->doc, NoComputedDisplay);
1.257     vatton   1710: #ifdef AMAYA_DEBUG
1.327     vatton   1711:               /*printf ("Force NoComputedDisplay doc=%d\n", context->doc);*/
1.257     vatton   1712: #endif /* AMAYA_DEBUG */
1.327     vatton   1713:             }
                   1714:           TtaSetStylePresentation (PRFloat, element, tsch, context, pval);
                   1715:         }
1.288     vatton   1716:       cssRule = CSSCheckEndValue (ptr, cssRule, "Invalid float value");
1.184     vatton   1717:     }
                   1718:   return (cssRule);
                   1719: }
                   1720: 
                   1721: /*----------------------------------------------------------------------
1.327     vatton   1722:   ParseCSSClear: parse a CSS clear rule 
1.1       cvs      1723:   ----------------------------------------------------------------------*/
1.79      cvs      1724: static char *ParseCSSClear (Element element, PSchema tsch,
1.327     vatton   1725:                             PresentationContext context, char *cssRule,
                   1726:                             CSSInfoPtr css, ThotBool isHTML)
1.1       cvs      1727: {
1.184     vatton   1728:   PresentationValue   pval;
1.366     vatton   1729:   char               *start_value = cssRule;
1.184     vatton   1730: 
                   1731:   pval.typed_data.value = 0;
1.187     vatton   1732:   pval.typed_data.unit = UNIT_BOX;
1.193     vatton   1733:   pval.typed_data.real = FALSE;
1.190     vatton   1734:   if (!strncasecmp (cssRule, "inherit", 7))
1.293     quint    1735:     pval.typed_data.unit = VALUE_INHERIT;
1.184     vatton   1736:   if (!strncasecmp (cssRule, "none", 4))
                   1737:     pval.typed_data.value = ClearNone;
                   1738:   else if (!strncasecmp (cssRule, "left", 4))
                   1739:     pval.typed_data.value = ClearLeft;
                   1740:   else if (!strncasecmp (cssRule, "right", 5))
                   1741:     pval.typed_data.value = ClearRight;
                   1742:   else if (!strncasecmp (cssRule, "both", 4))
                   1743:     pval.typed_data.value = ClearBoth;
                   1744: 
1.293     quint    1745:   if (pval.typed_data.value == 0 && pval.typed_data.unit != VALUE_INHERIT)
1.295     vatton   1746:     {
                   1747:       cssRule = SkipValue ("Invalid clear value", cssRule);
                   1748:       cssRule = SkipValue (NULL, cssRule);
                   1749:     }
1.184     vatton   1750:   else
                   1751:     {
1.295     vatton   1752:       cssRule = SkipValue (NULL, cssRule);
1.366     vatton   1753:       if (DoDialog)
                   1754:         DisplayStyleValue ("clear", start_value, cssRule);
                   1755:       else if (DoApply)
1.327     vatton   1756:         TtaSetStylePresentation (PRClear, element, tsch, context, pval);
1.184     vatton   1757:     }
                   1758:   return (cssRule);
                   1759: }
                   1760: 
                   1761: /*----------------------------------------------------------------------
1.333     vatton   1762:   ParseCSSVisibility: parse a CSS visibility attribute string        
                   1763:   ----------------------------------------------------------------------*/
                   1764: static char *ParseCSSVisibility(Element element, PSchema tsch,
                   1765:                                 PresentationContext context, char *cssRule,
                   1766:                                 CSSInfoPtr css, ThotBool isHTML)
                   1767: {
                   1768:   PresentationValue   pval;
1.366     vatton   1769:   char               *ptr;
1.333     vatton   1770: 
                   1771:   pval.typed_data.unit = UNIT_REL;
                   1772:   pval.typed_data.real = FALSE;
                   1773:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   1774:   ptr = cssRule;
1.333     vatton   1775:   if (!strncasecmp (cssRule, "hidden", 6))
                   1776:     {
                   1777:       cssRule += 6;
                   1778:       pval.typed_data.value = VsHidden;
                   1779:     }
                   1780:   else if (!strncasecmp (cssRule, "visible", 7))
                   1781:     {
                   1782:       cssRule += 7;
                   1783:       pval.typed_data.value = VsVisible;
                   1784:     }
                   1785:   else if (!strncasecmp (cssRule, "collapse", 8))
                   1786:     {
                   1787:       cssRule += 8;
                   1788:       pval.typed_data.value = VsCollapse;
                   1789:     }
                   1790:   else if (!strncasecmp (cssRule, "inherit", 7))
                   1791:     {
                   1792:       cssRule += 7;
                   1793:       pval.typed_data.value = VsInherit;
                   1794:     }
                   1795:   else
                   1796:     {
                   1797:       cssRule = SkipValue ("Invalid visibility value", cssRule);
                   1798:       return (cssRule);
                   1799:     }
1.366     vatton   1800:   if (DoDialog)
                   1801:     DisplayStyleValue ("visibility", ptr, cssRule);
                   1802:   else if (DoApply)
1.333     vatton   1803:     TtaSetStylePresentation (PRVis, element, tsch, context, pval);
                   1804:   cssRule = CSSCheckEndValue (ptr, cssRule, "Invalid visibility value");
                   1805:   return (cssRule);
                   1806: }
                   1807: 
                   1808: 
                   1809: /*----------------------------------------------------------------------
1.327     vatton   1810:   ParseCSSDisplay: parse a CSS display attribute string        
1.1       cvs      1811:   ----------------------------------------------------------------------*/
1.79      cvs      1812: static char *ParseCSSDisplay (Element element, PSchema tsch,
1.327     vatton   1813:                               PresentationContext context, char *cssRule,
                   1814:                               CSSInfoPtr css, ThotBool isHTML)
1.1       cvs      1815: {
1.184     vatton   1816:   PresentationValue   pval;
1.366     vatton   1817:   char               *ptr;
1.1       cvs      1818: 
1.184     vatton   1819:   pval.typed_data.unit = UNIT_REL;
                   1820:   pval.typed_data.real = FALSE;
                   1821:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   1822:   ptr = cssRule;
1.184     vatton   1823:   if (!strncasecmp (cssRule, "none", 4))
1.288     vatton   1824:     {
                   1825:       cssRule += 4;
                   1826:       pval.typed_data.value = DisplayNone;
                   1827:     }
1.277     quint    1828:   else if (!strncasecmp (cssRule, "block", 5))
1.288     vatton   1829:     {
                   1830:       cssRule += 5;
                   1831:       pval.typed_data.value = Block;
                   1832:     }
1.303     vatton   1833:   else if (!strncasecmp (cssRule, "inline-block", 12))
                   1834:     {
                   1835:       cssRule += 12;
                   1836:       pval.typed_data.value = InlineBlock;
                   1837:     }
1.277     quint    1838:   else if (!strncasecmp (cssRule, "inline", 6))
1.288     vatton   1839:     {
                   1840:       cssRule += 6;
                   1841:       pval.typed_data.value = Inline;
                   1842:     }
1.277     quint    1843:   else if (!strncasecmp (cssRule, "list-item", 9))
1.288     vatton   1844:     {
                   1845:       cssRule += 9;
                   1846:       pval.typed_data.value = ListItem;
                   1847:     }
1.277     quint    1848:   else if (!strncasecmp (cssRule, "run-in", 6))
1.288     vatton   1849:     {
                   1850:       cssRule += 6;
                   1851:       pval.typed_data.value = RunIn;
                   1852:     }
1.293     quint    1853:   else if (!strncasecmp (cssRule, "inherit", 7))
                   1854:     {
                   1855:       cssRule += 7;
                   1856:       pval.typed_data.unit = VALUE_INHERIT;
                   1857:     }
1.277     quint    1858:   else
1.184     vatton   1859:     {
1.277     quint    1860:       if (strncasecmp (cssRule, "table-row-group", 15) &&
1.327     vatton   1861:           strncasecmp (cssRule, "table-column-group", 18) &&
                   1862:           strncasecmp (cssRule, "table-header-group", 5) &&
                   1863:           strncasecmp (cssRule, "table-footer-group", 6) &&
                   1864:           strncasecmp (cssRule, "table-row", 9) &&
                   1865:           strncasecmp (cssRule, "table-column", 12) &&
                   1866:           strncasecmp (cssRule, "table-cell", 10) &&
                   1867:           strncasecmp (cssRule, "table-caption", 13) &&
                   1868:           strncasecmp (cssRule, "inline-table", 12) &&
                   1869:           strncasecmp (cssRule, "table", 5))
                   1870:         cssRule = SkipValue ("Display value not supported", cssRule);
1.281     quint    1871:       else
1.327     vatton   1872:         cssRule = SkipWord (cssRule);
1.277     quint    1873:       return (cssRule);
1.184     vatton   1874:     }
1.277     quint    1875: 
1.366     vatton   1876:   if (DoDialog)
                   1877:     DisplayStyleValue ("display", ptr, cssRule);
                   1878:   else if (DoApply)
1.295     vatton   1879:     TtaSetStylePresentation (PRDisplay, element, tsch, context, pval);
1.288     vatton   1880:   cssRule = CSSCheckEndValue (ptr, cssRule, "Invalid display value");
1.1       cvs      1881:   return (cssRule);
                   1882: }
                   1883: 
                   1884: /*----------------------------------------------------------------------
1.327     vatton   1885:   ParseCSSLetterSpacing: parse a CSS letter-spacing    
                   1886:   attribute string.                                          
1.1       cvs      1887:   ----------------------------------------------------------------------*/
1.79      cvs      1888: static char *ParseCSSLetterSpacing (Element element, PSchema tsch,
1.327     vatton   1889:                                     PresentationContext context, char *cssRule,
                   1890:                                     CSSInfoPtr css, ThotBool isHTML)
1.1       cvs      1891: {
1.366     vatton   1892:   char               *start_value = cssRule;
                   1893: 
1.168     vatton   1894:   cssRule = SkipValue (NULL, cssRule);
1.366     vatton   1895:   if (DoDialog)
                   1896:     DisplayStyleValue ("letter-spacing", start_value, cssRule);
1.1       cvs      1897:   return (cssRule);
                   1898: }
                   1899: 
                   1900: /*----------------------------------------------------------------------
1.327     vatton   1901:   ParseACSSListStyleType: parse a CSS list-style-type
                   1902:   attribute string.                                          
1.1       cvs      1903:   ----------------------------------------------------------------------*/
1.318     vatton   1904: static char *ParseACSSListStyleType (Element element, PSchema tsch,
1.327     vatton   1905:                                      PresentationContext context, char *cssRule,
                   1906:                                      CSSInfoPtr css, ThotBool isHTML)
1.1       cvs      1907: {
1.281     quint    1908:   PresentationValue   pval;
1.366     vatton   1909:   char               *start_value;
1.281     quint    1910: 
                   1911:   pval.typed_data.unit = UNIT_REL;
                   1912:   pval.typed_data.real = FALSE;
                   1913:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   1914:   start_value = cssRule;
1.281     quint    1915:   if (!strncasecmp (cssRule, "disc", 4))
1.288     vatton   1916:     {
                   1917:       cssRule += 4;
                   1918:       pval.typed_data.value = Disc;
                   1919:     }
1.281     quint    1920:   else if (!strncasecmp (cssRule, "circle", 6))
1.293     quint    1921:     {
1.288     vatton   1922:       cssRule += 6;
                   1923:       pval.typed_data.value = Circle;
1.293     quint    1924:     }
1.281     quint    1925:   else if (!strncasecmp (cssRule, "square", 6))
1.293     quint    1926:     {
1.288     vatton   1927:       cssRule += 6;
1.293     quint    1928:       pval.typed_data.value = Square;
                   1929:     }
1.283     quint    1930:   else if (!strncasecmp (cssRule, "decimal-leading-zero", 20))
1.293     quint    1931:     {
1.288     vatton   1932:       cssRule += 20;
1.293     quint    1933:       pval.typed_data.value = DecimalLeadingZero;
                   1934:     }
1.281     quint    1935:   else if (!strncasecmp (cssRule, "decimal", 7))
1.293     quint    1936:     {
1.288     vatton   1937:       cssRule += 7;
1.293     quint    1938:       pval.typed_data.value = Decimal;
                   1939:     }
1.281     quint    1940:   else if (!strncasecmp (cssRule, "lower-roman", 11))
1.293     quint    1941:     {
1.288     vatton   1942:       cssRule += 11;
1.293     quint    1943:       pval.typed_data.value = LowerRoman;
                   1944:     }
1.281     quint    1945:   else if (!strncasecmp (cssRule, "upper-roman", 11))
1.293     quint    1946:     {
1.288     vatton   1947:       cssRule += 11;
1.293     quint    1948:       pval.typed_data.value = UpperRoman;
                   1949:     }
1.281     quint    1950:   else if (!strncasecmp (cssRule, "lower-greek", 11))
1.293     quint    1951:     {
1.288     vatton   1952:       cssRule += 11;
1.293     quint    1953:       pval.typed_data.value = LowerGreek;
                   1954:     }
1.281     quint    1955:   else if (!strncasecmp (cssRule, "lower-latin", 11))
1.293     quint    1956:     {
1.288     vatton   1957:       cssRule += 11;
1.293     quint    1958:       pval.typed_data.value = LowerLatin;
                   1959:     }
1.281     quint    1960:   else if (!strncasecmp (cssRule, "lower-alpha", 11))
1.293     quint    1961:     {
1.288     vatton   1962:       cssRule += 11;
1.293     quint    1963:       pval.typed_data.value = LowerLatin;
                   1964:     }
1.281     quint    1965:   else if (!strncasecmp (cssRule, "upper-latin", 11))
1.293     quint    1966:     {
1.288     vatton   1967:       cssRule += 11;
1.293     quint    1968:       pval.typed_data.value = UpperLatin;
                   1969:     }
1.281     quint    1970:   else if (!strncasecmp (cssRule, "upper-alpha", 11))
1.293     quint    1971:     {
1.288     vatton   1972:       cssRule += 11;
1.293     quint    1973:       pval.typed_data.value = UpperLatin;
                   1974:     }
1.281     quint    1975:   else if (!strncasecmp (cssRule, "armenian", 8))
1.293     quint    1976:     {
1.288     vatton   1977:       cssRule += 8;
1.293     quint    1978:       pval.typed_data.value = Decimal;
                   1979:     }
1.281     quint    1980:   else if (!strncasecmp (cssRule, "georgian", 8))
1.293     quint    1981:     {
1.288     vatton   1982:       cssRule += 8;
1.293     quint    1983:       pval.typed_data.value = Decimal;
                   1984:     }
1.281     quint    1985:   else if (!strncasecmp (cssRule, "none", 4))
1.293     quint    1986:     {
1.288     vatton   1987:       cssRule += 4;
1.293     quint    1988:       pval.typed_data.value = ListStyleTypeNone;
                   1989:     }
1.281     quint    1990:   else if (!strncasecmp (cssRule, "inherit", 7))
                   1991:     {
1.293     quint    1992:       cssRule += 7;
                   1993:       pval.typed_data.unit = VALUE_INHERIT;
1.281     quint    1994:     }
                   1995:   else
                   1996:     {
                   1997:       cssRule = SkipValue ("Invalid list-style-type value", cssRule);
                   1998:       return (cssRule);
                   1999:     }
                   2000: 
1.366     vatton   2001:   if (DoDialog)
                   2002:     DisplayStyleValue ("list-style-type", start_value, cssRule);
                   2003:   else if (DoApply)
1.295     vatton   2004:     TtaSetStylePresentation (PRListStyleType, element, tsch, context, pval);
1.318     vatton   2005:   return (cssRule);
                   2006: }
                   2007: 
                   2008: /*----------------------------------------------------------------------
1.327     vatton   2009:   ParseCSSListStyleType: parse a CSS list-style-type
                   2010:   attribute string.                                          
1.318     vatton   2011:   ----------------------------------------------------------------------*/
                   2012: static char *ParseCSSListStyleType (Element element, PSchema tsch,
1.327     vatton   2013:                                     PresentationContext context, char *cssRule,
                   2014:                                     CSSInfoPtr css, ThotBool isHTML)
1.318     vatton   2015: {
                   2016:   char               *ptr = cssRule;
                   2017:   cssRule = ParseACSSListStyleType (element, tsch, context, cssRule, css,
1.327     vatton   2018:                                     isHTML);
1.288     vatton   2019:   cssRule = CSSCheckEndValue (ptr, cssRule, "Invalid list-style-type value");
1.318     vatton   2020:   return cssRule;
1.1       cvs      2021: }
                   2022: 
                   2023: /*----------------------------------------------------------------------
1.281     quint    2024:   ParseCSSUrl: parse an URL
                   2025:   ----------------------------------------------------------------------*/
                   2026: static char *ParseCSSUrl (char *cssRule, char **url)
                   2027: {
                   2028:   char                       saved;
                   2029:   char                      *base, *ptr;
                   2030: 
                   2031:   cssRule = SkipBlanksAndComments (cssRule);
                   2032:   saved = *cssRule;
                   2033:   if (*cssRule == '(')
                   2034:     {
                   2035:       cssRule++;
                   2036:       cssRule = SkipBlanksAndComments (cssRule);
                   2037:       /*** Escaped quotes are not handled. See function SkipQuotedString */
                   2038:       if (*cssRule == '"')
1.327     vatton   2039:         {
                   2040:           cssRule++;
                   2041:           base = cssRule;
                   2042:           while (*cssRule != EOS && *cssRule != '"')
                   2043:             cssRule++;
                   2044:         }
1.281     quint    2045:       else if (*cssRule == '\'')
1.327     vatton   2046:         {
                   2047:           cssRule++;
                   2048:           base = cssRule;
                   2049:           while (*cssRule != EOS && *cssRule != '\'')
                   2050:             cssRule++;
                   2051:         }
1.281     quint    2052:       else
1.327     vatton   2053:         {
                   2054:           base = cssRule;
                   2055:           while (*cssRule != EOS && *cssRule != ')')
                   2056:             cssRule++;
                   2057:         }
1.281     quint    2058:       /* keep the current position */
                   2059:       ptr = cssRule;
                   2060:       if (saved == ')')
1.327     vatton   2061:         {
                   2062:           /* remove extra spaces */
                   2063:           if (cssRule[-1] == SPACE)
                   2064:             {
                   2065:               *cssRule = SPACE;
                   2066:               cssRule--;
                   2067:               while (cssRule[-1] == SPACE)
                   2068:                 cssRule--;
                   2069:             }
                   2070:         }
1.281     quint    2071:       saved = *cssRule;
                   2072:       *cssRule = EOS;
                   2073:       *url = TtaStrdup (base);
                   2074:       *cssRule = saved;
                   2075:       if (saved == '"' || saved == '\'')
1.327     vatton   2076:         /* we need to skip the quote character and possible spaces */
                   2077:         {
                   2078:           cssRule++;
                   2079:           cssRule = SkipBlanksAndComments (cssRule);
                   2080:         }
1.281     quint    2081:       else
1.327     vatton   2082:         cssRule = ptr;
1.281     quint    2083:     }
                   2084:   cssRule++;
                   2085:   return cssRule;
                   2086: }
                   2087: 
                   2088: /*----------------------------------------------------------------------
1.302     quint    2089:   ParseCSSImageCallback: Callback called asynchronously by
                   2090:   FetchImage when a CSS image (background-image or list-style-image)
                   2091:   has been fetched.
                   2092:   ----------------------------------------------------------------------*/
                   2093: void ParseCSSImageCallback (Document doc, Element element, char *file,
1.327     vatton   2094:                             void *extra, ThotBool isnew)
1.302     quint    2095: {
                   2096:   DisplayMode                dispMode = DisplayImmediately;
                   2097:   CSSImageCallbackPtr        callblock;
                   2098:   Element                    el;
                   2099:   PSchema                    tsch;
                   2100:   CSSInfoPtr                 css;
                   2101:   PresentationContext        ctxt;
                   2102:   PresentationValue          image;
                   2103:   PresentationValue          value;
                   2104: 
                   2105:   callblock = (CSSImageCallbackPtr) extra;
                   2106:   if (callblock == NULL)
                   2107:     return;
                   2108: 
                   2109:   css = NULL;
                   2110:   el = callblock->el;
                   2111:   tsch = callblock->tsch;
                   2112:   ctxt = callblock->ctxt;
                   2113:   if (doc == 0 && !isnew)
                   2114:     /* apply to the current document only */
                   2115:     doc = ctxt->doc;
                   2116:   if (doc)
                   2117:     {
                   2118:       /* avoid too many redisplay */
                   2119:       dispMode = TtaGetDisplayMode (doc);
                   2120:       if (dispMode == DisplayImmediately)
1.327     vatton   2121:         TtaSetDisplayMode (doc, DeferredDisplay);
1.302     quint    2122:     }
                   2123:   else
                   2124:     {
1.330     cvs      2125:       dispMode = TtaGetDisplayMode (RedisplayDoc);
1.302     quint    2126:       /* check if the CSS still exists */
                   2127:       css = CSSList;
                   2128:       while (css && css != callblock->css)
1.327     vatton   2129:         css = css->NextCSS;
1.302     quint    2130:       if (css == NULL)
1.327     vatton   2131:         tsch = NULL;
1.302     quint    2132:     }
                   2133:   if (el || tsch)
                   2134:     {
                   2135:       /* Ok the image was fetched */
                   2136:       image.typed_data.unit = UNIT_REL;
                   2137:       image.typed_data.real = FALSE;
                   2138:       image.pointer = file;
                   2139:       TtaSetStylePresentation (callblock->ruleType, el, tsch, ctxt, image);
                   2140:       
                   2141:       if (callblock->ruleType == PRBackgroundPicture)
1.327     vatton   2142:         /* enforce the showbox */
                   2143:         {
                   2144:           value.typed_data.value = 1;
                   2145:           value.typed_data.unit = UNIT_REL;
                   2146:           value.typed_data.real = FALSE;
                   2147:           TtaSetStylePresentation (PRShowBox, el, tsch, ctxt, value);
                   2148:         }
1.302     quint    2149:       /* check if the context can be freed */
                   2150:       ctxt->uses -= 1;
                   2151:       if (ctxt->uses == 0)
1.327     vatton   2152:         /* no other image loading */
                   2153:         TtaFreeMemory (ctxt);
1.302     quint    2154:     }
                   2155: 
                   2156:   TtaFreeMemory (callblock);
1.330     cvs      2157:   if (css)
                   2158:     RedisplayImages--;
1.302     quint    2159:   if (doc)
                   2160:     {
                   2161:       if (dispMode == DisplayImmediately)
1.327     vatton   2162:         /* restore the display mode */
                   2163:         TtaSetDisplayMode (doc, dispMode);
1.302     quint    2164:     }
1.311     vatton   2165:   else if (css && Style_parsing == 0 && RedisplayImages == 0 && RedisplayDoc)
1.302     quint    2166:     {
1.310     vatton   2167:       /* all background images are now loaded */
1.330     cvs      2168:       if (css->infos[RedisplayDoc] &&
1.327     vatton   2169:           /* don't manage a document used by make book */
1.330     cvs      2170:           (DocumentMeta[RedisplayDoc] == NULL ||
                   2171:            DocumentMeta[RedisplayDoc]->method != CE_MAKEBOOK))
1.327     vatton   2172:         {
                   2173:           /* Change the Display Mode to take into account the new
                   2174:              presentation */
1.330     cvs      2175:           dispMode = TtaGetDisplayMode (RedisplayDoc);
1.329     vatton   2176: #ifdef AMAYA_DEBUG
                   2177:           //printf ("ParseCSSImageCallback Show BGimages\n");
                   2178: #endif /* AMAYA_DEBUG */
1.313     vatton   2179:           /* force the redisplay of this box */
1.330     cvs      2180:           TtaSetDisplayMode (RedisplayDoc, NoComputedDisplay);
                   2181:           TtaSetDisplayMode (RedisplayDoc, dispMode);
1.327     vatton   2182:         }
1.330     cvs      2183:       RedisplayBGImage = FALSE;
1.302     quint    2184:     }
1.310     vatton   2185:   else
1.328     vatton   2186:     RedisplayBGImage = TRUE;
1.302     quint    2187: }
                   2188: 
                   2189: /*----------------------------------------------------------------------
                   2190:   SetCSSImage fetch the image referred by a background-image or a
                   2191:   list-style-image property.
                   2192:   ----------------------------------------------------------------------*/
                   2193: static char *SetCSSImage (Element element, PSchema tsch,
1.327     vatton   2194:                           PresentationContext ctxt, char *cssRule,
                   2195:                           CSSInfoPtr css, unsigned int ruleType)
1.302     quint    2196: {
                   2197:   CSSImageCallbackPtr        callblock;
                   2198:   Element                    el;
1.304     cvs      2199:   PresentationValue          image;
1.366     vatton   2200:   char                      *url, *ptr;
1.302     quint    2201:   char                      *bg_image;
                   2202:   char                       tempname[MAX_LENGTH];
                   2203:   char                       imgname[MAX_LENGTH];
                   2204: 
                   2205:   if (element)
                   2206:     el = element;
                   2207:   else
                   2208:     /* default element for FetchImage */
                   2209:     el = TtaGetMainRoot (ctxt->doc);
                   2210:   url = NULL;
                   2211:   cssRule = ParseCSSUrl (cssRule, &url);
1.366     vatton   2212:   ptr = cssRule;
1.302     quint    2213:   if (ctxt->destroy)
                   2214:     {
                   2215:       /* remove the background image PRule */
                   2216:       image.pointer = NULL;
1.366     vatton   2217:       TtaSetStylePresentation (ruleType, element, tsch, ctxt, image);
1.302     quint    2218:     }
1.366     vatton   2219:   else if (url)
1.302     quint    2220:     {
1.366     vatton   2221:       if (css && css->url)
                   2222:         /* the image concerns a CSS file */
                   2223:         NormalizeURL (url, 0, tempname, imgname, css->url);
                   2224:       else
                   2225:         /* the image concerns a style element */
                   2226:         NormalizeURL (url, ctxt->doc, tempname, imgname, NULL);
                   2227:       if (DoDialog)
                   2228:         {
                   2229:           if (ruleType == PRBackgroundPicture)
                   2230:             DisplayStyleValue ("background-image", tempname, &tempname[MAX_LENGTH-1]);
                   2231:           else if (ruleType == PRListStyleImage)
                   2232:             DisplayStyleValue ("list-style-image", tempname, &tempname[MAX_LENGTH-1]);
                   2233:           else if (ruleType == PRContentURL)
                   2234:             DisplayStyleValue ("", ptr, cssRule);
                   2235:         }
                   2236:       else if (DoApply)
                   2237:         {
                   2238:           bg_image = TtaGetEnvString ("ENABLE_BG_IMAGES");
                   2239:           if (bg_image == NULL || !strcasecmp (bg_image, "yes"))
                   2240:             /* background images are enabled */
                   2241:             {
                   2242:               callblock = (CSSImageCallbackPtr) TtaGetMemory (sizeof (CSSImageCallbackBlock));
                   2243:               if (callblock)
                   2244:                 {
                   2245:                   callblock->el = element;
                   2246:                   callblock->tsch = tsch;
                   2247:                   callblock->css = css;
                   2248:                   callblock->ctxt = ctxt;
                   2249:                   callblock->ruleType = ruleType;
                   2250:                   /* new use of the context */
                   2251:                   ctxt->uses += 1;
                   2252:                   /* check if the image url is related to an external CSS */
                   2253:                   if (css)
                   2254:                     {
                   2255:                       RedisplayDoc = ctxt->doc;
                   2256:                       /* fetch and display background image of element */
                   2257:                       if (FetchImage (0, el, tempname, AMAYA_LOAD_IMAGE,
                   2258:                                       ParseCSSImageCallback, callblock))
                   2259:                         RedisplayImages++;
                   2260:                     }
1.327     vatton   2261:                   else
1.366     vatton   2262:                     FetchImage (ctxt->doc, el, url, AMAYA_LOAD_IMAGE,
                   2263:                                 ParseCSSImageCallback, callblock);
1.327     vatton   2264:                 }
                   2265:             }
                   2266:         }
1.366     vatton   2267:       TtaFreeMemory (url);
1.302     quint    2268:     }
                   2269:   return (cssRule);
                   2270: }
                   2271: 
                   2272: /*----------------------------------------------------------------------
1.327     vatton   2273:   ParseACSSListStyleImage: parse a CSS list-style-image
                   2274:   attribute string.                                          
1.1       cvs      2275:   ----------------------------------------------------------------------*/
1.318     vatton   2276: static char *ParseACSSListStyleImage (Element element, PSchema tsch,
1.327     vatton   2277:                                       PresentationContext ctxt,
                   2278:                                       char *cssRule, CSSInfoPtr css,
                   2279:                                       ThotBool isHTML)
1.1       cvs      2280: {
1.288     vatton   2281:   char               *url;
1.366     vatton   2282:   char               *start_value;
1.293     quint    2283:   PresentationValue   pval;
1.281     quint    2284: 
1.293     quint    2285:   pval.typed_data.unit = UNIT_REL;
                   2286:   pval.typed_data.real = FALSE;
1.281     quint    2287:   url = NULL;
                   2288:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   2289:   start_value = cssRule;
1.281     quint    2290:   if (!strncasecmp (cssRule, "none", 4))
                   2291:     {
                   2292:       cssRule += 4;
1.302     quint    2293:       pval.typed_data.value = 0;
1.366     vatton   2294:       if (DoDialog)
                   2295:         DisplayStyleValue ("list-style-image", start_value, cssRule);
                   2296:       else if (DoApply)
1.327     vatton   2297:         TtaSetStylePresentation (PRListStyleImage, element, tsch, ctxt, pval);
1.281     quint    2298:     }
                   2299:   else if (!strncasecmp (cssRule, "url", 3))
                   2300:     {  
                   2301:       cssRule += 3;
1.302     quint    2302:       cssRule = SetCSSImage (element, tsch, ctxt, cssRule, css,
1.327     vatton   2303:                              PRListStyleImage);
1.281     quint    2304:     }
                   2305:   else if (!strncasecmp (cssRule, "inherit", 7))
1.288     vatton   2306:     {
                   2307:       cssRule += 7;
1.293     quint    2308:       pval.typed_data.unit = VALUE_INHERIT;
1.366     vatton   2309:       if (DoDialog)
                   2310:         DisplayStyleValue ("list-style-image", start_value, cssRule);
                   2311:       else if (DoApply)
1.327     vatton   2312:         TtaSetStylePresentation (PRListStyleImage, element, tsch, ctxt, pval);
                   2313:     }
1.281     quint    2314:   else
1.295     vatton   2315:       cssRule = SkipValue ("Invalid list-style-image value", cssRule);
1.1       cvs      2316:   return (cssRule);
                   2317: }
                   2318: 
                   2319: /*----------------------------------------------------------------------
1.327     vatton   2320:   ParseCSSListStyleImage: parse a CSS list-style-image
                   2321:   attribute string.                                          
1.318     vatton   2322:   ----------------------------------------------------------------------*/
                   2323: static char *ParseCSSListStyleImage (Element element, PSchema tsch,
1.327     vatton   2324:                                      PresentationContext ctxt,
                   2325:                                      char *cssRule, CSSInfoPtr css,
                   2326:                                      ThotBool isHTML)
1.318     vatton   2327: {
                   2328:   char               *ptr = cssRule;
                   2329:   cssRule = ParseACSSListStyleImage (element, tsch, ctxt, cssRule, css,
1.327     vatton   2330:                                      isHTML);
1.318     vatton   2331:   cssRule = CSSCheckEndValue (ptr, cssRule, "Invalid list-style-image value");
                   2332:   return cssRule;
                   2333: }
                   2334: 
                   2335: /*----------------------------------------------------------------------
1.327     vatton   2336:   ParseACSSListStylePosition: parse a CSS list-style-position
                   2337:   attribute string.                                          
1.1       cvs      2338:   ----------------------------------------------------------------------*/
1.318     vatton   2339: static char *ParseACSSListStylePosition (Element element, PSchema tsch,
1.327     vatton   2340:                                          PresentationContext context,
                   2341:                                          char *cssRule, CSSInfoPtr css,
                   2342:                                          ThotBool isHTML)
1.1       cvs      2343: {
1.281     quint    2344:   PresentationValue   pval;
1.366     vatton   2345:   char               *start_value;
1.281     quint    2346: 
                   2347:   pval.typed_data.unit = UNIT_REL;
                   2348:   pval.typed_data.real = FALSE;
                   2349:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   2350:   start_value = cssRule;
1.281     quint    2351:   if (!strncasecmp (cssRule, "inside", 6))
1.288     vatton   2352:     {
                   2353:       pval.typed_data.value = Inside;
                   2354:       cssRule += 6;
                   2355:     }
1.281     quint    2356:   else if (!strncasecmp (cssRule, "outside", 7))
1.288     vatton   2357:     {
                   2358:       pval.typed_data.value = Outside;
                   2359:       cssRule += 7;
                   2360:     }
1.293     quint    2361:   else if (!strncasecmp (cssRule, "inherit", 7))
                   2362:     {
                   2363:       pval.typed_data.unit = VALUE_INHERIT;
                   2364:       cssRule += 7;
                   2365:     }
1.281     quint    2366:   else
                   2367:     {
1.293     quint    2368:       cssRule = SkipValue ("Invalid list-style-position value", cssRule);
1.281     quint    2369:       return (cssRule);
                   2370:     }
1.293     quint    2371: 
1.366     vatton   2372:   if (DoDialog)
                   2373:     DisplayStyleValue ("list-style-position", start_value, cssRule);
                   2374:   else if (DoApply)
1.295     vatton   2375:     TtaSetStylePresentation (PRListStylePosition, element, tsch, context, pval);
1.327     vatton   2376:   return (cssRule);
1.318     vatton   2377: }
                   2378: 
                   2379: /*----------------------------------------------------------------------
1.327     vatton   2380:   ParseCSSListStylePosition: parse a CSS list-style-position
                   2381:   attribute string.                                          
1.318     vatton   2382:   ----------------------------------------------------------------------*/
                   2383: static char *ParseCSSListStylePosition (Element element, PSchema tsch,
1.327     vatton   2384:                                         PresentationContext context,
                   2385:                                         char *cssRule, CSSInfoPtr css,
                   2386:                                         ThotBool isHTML)
1.318     vatton   2387: {
                   2388:   char               *ptr = cssRule;
                   2389:   cssRule = ParseACSSListStylePosition (element, tsch, context, cssRule, css,
1.327     vatton   2390:                                         isHTML);
1.288     vatton   2391:   cssRule = CSSCheckEndValue (ptr, cssRule, "Invalid list-style-position value");
1.318     vatton   2392:   return cssRule;
1.1       cvs      2393: }
                   2394: 
                   2395: /*----------------------------------------------------------------------
1.327     vatton   2396:   ParseCSSListStyle: parse a CSS list-style value string.                                          
1.1       cvs      2397:   ----------------------------------------------------------------------*/
1.79      cvs      2398: static char *ParseCSSListStyle (Element element, PSchema tsch,
1.327     vatton   2399:                                 PresentationContext ctxt, char *cssRule,
                   2400:                                 CSSInfoPtr css, ThotBool isHTML)
1.1       cvs      2401: {
1.318     vatton   2402:   char               *ptr = cssRule;
                   2403:   int                 skippedNL;
1.281     quint    2404: 
                   2405:   cssRule = SkipBlanksAndComments (cssRule);
1.301     vatton   2406:   while (*cssRule != ';' && *cssRule != '}' && *cssRule != EOS && *cssRule != ',')
1.281     quint    2407:     {
1.316     quint    2408:       skippedNL = NewLineSkipped;
1.281     quint    2409:       /* perhaps a list-style-image */
                   2410:       if (!strncasecmp (cssRule, "url", 3))
1.327     vatton   2411:         cssRule = ParseACSSListStyleImage (element, tsch, ctxt, cssRule, css,
                   2412:                                            isHTML);
1.281     quint    2413:       /* perhaps a list-style-position */
                   2414:       else if (!strncasecmp (cssRule, "inside", 6) ||
                   2415:                !strncasecmp (cssRule, "outside", 7))
1.327     vatton   2416:         cssRule = ParseACSSListStylePosition (element, tsch, ctxt, cssRule,
                   2417:                                               css, isHTML);
1.281     quint    2418:       /* perhaps a list-style-type */
                   2419:       else if (!strncasecmp (cssRule, "disc", 4) ||
1.327     vatton   2420:                !strncasecmp (cssRule, "circle", 6) ||
                   2421:                !strncasecmp (cssRule, "square", 6) ||
                   2422:                !strncasecmp (cssRule, "decimal", 7) ||
                   2423:                !strncasecmp (cssRule, "decimal-leading-zero", 20) ||
                   2424:                !strncasecmp (cssRule, "lower-roman", 11) ||
                   2425:                !strncasecmp (cssRule, "upper-roman", 11) ||
                   2426:                !strncasecmp (cssRule, "lower-greek", 11) ||
                   2427:                !strncasecmp (cssRule, "lower-latin", 11) ||
                   2428:                !strncasecmp (cssRule, "lower-alpha", 11) ||
                   2429:                !strncasecmp (cssRule, "upper-latin", 11) ||
                   2430:                !strncasecmp (cssRule, "upper-alpha", 11) ||
                   2431:                !strncasecmp (cssRule, "armenian", 8) ||
                   2432:                !strncasecmp (cssRule, "georgian", 8) ||
                   2433:                !strncasecmp (cssRule, "none", 4) ||
                   2434:                !strncasecmp (cssRule, "inherit", 7))
                   2435:         cssRule = ParseACSSListStyleType (element, tsch, ctxt, cssRule, css,
                   2436:                                           isHTML);
1.281     quint    2437:       else
1.327     vatton   2438:         {
                   2439:           NewLineSkipped = skippedNL;
                   2440:           /* rule not found */
                   2441:           cssRule = SkipProperty (cssRule, FALSE);
                   2442:         }
1.281     quint    2443:       cssRule = SkipBlanksAndComments (cssRule);
                   2444:     }
1.318     vatton   2445:   cssRule = CSSCheckEndValue (ptr, cssRule, "Invalid list-style value");
1.1       cvs      2446:   return (cssRule);
                   2447: }
                   2448: 
                   2449: /*----------------------------------------------------------------------
1.327     vatton   2450:   ParseCSSTextAlign: parse a CSS text-align            
                   2451:   attribute string.                                          
1.1       cvs      2452:   ----------------------------------------------------------------------*/
1.79      cvs      2453: static char *ParseCSSTextAlign (Element element, PSchema tsch,
1.327     vatton   2454:                                 PresentationContext context, char *cssRule,
                   2455:                                 CSSInfoPtr css, ThotBool isHTML)
1.1       cvs      2456: {
1.366     vatton   2457:   char               *ptr;
1.327     vatton   2458:   PresentationValue   align;
                   2459: 
                   2460:   align.typed_data.value = 0;
                   2461:   align.typed_data.unit = UNIT_REL;
                   2462:   align.typed_data.real = FALSE;
                   2463: 
                   2464:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   2465:   ptr = cssRule;
1.327     vatton   2466:   if (!strncasecmp (cssRule, "left", 4))
                   2467:     {
                   2468:       align.typed_data.value = AdjustLeft;
                   2469:       cssRule += 4;
                   2470:     }
                   2471:   else if (!strncasecmp (cssRule, "right", 5))
                   2472:     {
                   2473:       align.typed_data.value = AdjustRight;
                   2474:       cssRule += 5;
                   2475:     }
                   2476:   else if (!strncasecmp (cssRule, "center", 6))
                   2477:     {
                   2478:       align.typed_data.value = Centered;
                   2479:       cssRule += 6;
                   2480:     }
                   2481:   else if (!strncasecmp (cssRule, "justify", 7))
                   2482:     {
                   2483:       align.typed_data.value = Justify;
                   2484:       cssRule += 7;
                   2485:     }
                   2486:   else
                   2487:     {
                   2488:       cssRule = SkipValue ("Invalid text-align value", cssRule);
                   2489:       return (cssRule);
                   2490:     }
1.1       cvs      2491: 
1.327     vatton   2492:   /*
                   2493:    * install the new presentation.
                   2494:    */
1.366     vatton   2495:   if (align.typed_data.value)
                   2496:     {
                   2497:       if (DoDialog)
                   2498:         DisplayStyleValue ("text-align", ptr, cssRule);
                   2499:       else if (DoApply)
                   2500:         TtaSetStylePresentation (PRAdjust, element, tsch, context, align);
                   2501:     }
1.327     vatton   2502:   cssRule = CSSCheckEndValue (ptr, cssRule, "Invalid text-align value");
                   2503:   return (cssRule);
1.1       cvs      2504: }
                   2505: 
                   2506: /*----------------------------------------------------------------------
1.243     quint    2507:   ParseCSSTextAnchor: parse a CSS text-anchor property (SVG property)
                   2508:   We use the Thot Adjust PRule to represent the text-anchor property
                   2509:   for CSS 1.0, as Adjust is not used otherwise in this context.
                   2510:   ----------------------------------------------------------------------*/
                   2511: static char *ParseCSSTextAnchor (Element element, PSchema tsch,
1.327     vatton   2512:                                  PresentationContext context, char *cssRule,
                   2513:                                  CSSInfoPtr css, ThotBool isHTML)
1.243     quint    2514: {
1.327     vatton   2515:   PresentationValue   align;
1.366     vatton   2516:   char               *ptr;
1.327     vatton   2517: 
                   2518:   align.typed_data.value = 0;
                   2519:   align.typed_data.unit = UNIT_REL;
                   2520:   align.typed_data.real = FALSE;
1.243     quint    2521: 
1.327     vatton   2522:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   2523:   ptr = cssRule;
1.327     vatton   2524:   if (!strncasecmp (cssRule, "start", 5))
                   2525:     {
                   2526:       align.typed_data.value = AdjustLeft;
                   2527:       cssRule += 5;
                   2528:     }
                   2529:   else if (!strncasecmp (cssRule, "middle", 6))
                   2530:     {
                   2531:       align.typed_data.value = Centered;
                   2532:       cssRule += 6;
                   2533:     }
                   2534:   else if (!strncasecmp (cssRule, "end", 3))
                   2535:     {
                   2536:       align.typed_data.value = AdjustRight;
                   2537:       cssRule += 3;
                   2538:     }
                   2539:   else if (!strncasecmp (cssRule, "inherit", 7))
                   2540:     {
                   2541:       align.typed_data.unit = VALUE_INHERIT;
                   2542:       cssRule += 7;
                   2543:     }
                   2544:   else
                   2545:     {
                   2546:       cssRule = SkipValue ("Invalid text-anchor value", cssRule);
1.295     vatton   2547:       return (cssRule);
1.327     vatton   2548:     }
1.243     quint    2549: 
1.327     vatton   2550:   /*
                   2551:    * install the new presentation.
                   2552:    */
1.366     vatton   2553:   if (align.typed_data.value || align.typed_data.unit == VALUE_INHERIT)
                   2554:     {
                   2555:       if (DoDialog)
                   2556:         DisplayStyleValue ("text-anchor", ptr, cssRule);
                   2557:       else if (DoApply)
                   2558:         TtaSetStylePresentation (PRAdjust, element, tsch, context, align);
                   2559:     }
1.327     vatton   2560:   cssRule = CSSCheckEndValue (ptr, cssRule, "Invalid text-anchor value");
                   2561:   return (cssRule);
1.243     quint    2562: }
                   2563: 
                   2564: /*----------------------------------------------------------------------
1.327     vatton   2565:   ParseCSSDirection: parse a CSS direction property
1.112     quint    2566:   ----------------------------------------------------------------------*/
                   2567: static char *ParseCSSDirection (Element element, PSchema tsch,
1.327     vatton   2568:                                 PresentationContext context, char *cssRule,
                   2569:                                 CSSInfoPtr css, ThotBool isHTML)
1.112     quint    2570: {
1.327     vatton   2571:   PresentationValue   direction;
1.366     vatton   2572:   char               *ptr;
1.327     vatton   2573: 
                   2574:   direction.typed_data.value = 0;
                   2575:   direction.typed_data.unit = UNIT_REL;
                   2576:   direction.typed_data.real = FALSE;
                   2577: 
                   2578:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   2579:   ptr = cssRule;
1.327     vatton   2580:   if (!strncasecmp (cssRule, "ltr", 3))
                   2581:     {
                   2582:       direction.typed_data.value = LeftToRight;
                   2583:       cssRule += 3;
                   2584:     }
                   2585:   else if (!strncasecmp (cssRule, "rtl", 3))
                   2586:     {
                   2587:       direction.typed_data.value = RightToLeft;
                   2588:       cssRule += 3;
                   2589:     }
                   2590:   else if (!strncasecmp (cssRule, "inherit", 7))
                   2591:     {
                   2592:       direction.typed_data.unit = VALUE_INHERIT;
                   2593:       cssRule += 7;
                   2594:     }
                   2595:   else
                   2596:     {
                   2597:       cssRule = SkipValue ("Invalid direction value", cssRule);
                   2598:       return (cssRule);
                   2599:     }
1.112     quint    2600: 
1.327     vatton   2601:   /*
                   2602:    * install the new presentation.
                   2603:    */
1.366     vatton   2604:   if (direction.typed_data.value || direction.typed_data.unit == VALUE_INHERIT)
                   2605:     {
                   2606:       if (DoDialog)
                   2607:         DisplayStyleValue ("direction", ptr, cssRule);
                   2608:       else if (DoApply)
                   2609:         TtaSetStylePresentation (PRDirection, element, tsch, context, direction);
                   2610:     }
1.327     vatton   2611:   cssRule = CSSCheckEndValue (ptr, cssRule, "Invalid direction value");
                   2612:   return (cssRule);
1.112     quint    2613: }
                   2614: 
                   2615: /*----------------------------------------------------------------------
1.327     vatton   2616:   ParseCSSUnicodeBidi: parse a CSS unicode-bidi property
1.113     quint    2617:   ----------------------------------------------------------------------*/
                   2618: static char *ParseCSSUnicodeBidi (Element element, PSchema tsch,
1.327     vatton   2619:                                   PresentationContext context, char *cssRule,
                   2620:                                   CSSInfoPtr css, ThotBool isHTML)
1.113     quint    2621: {
1.327     vatton   2622:   PresentationValue   bidi;
1.366     vatton   2623:   char               *ptr;
1.113     quint    2624: 
1.327     vatton   2625:   bidi.typed_data.value = 0;
                   2626:   bidi.typed_data.unit = UNIT_REL;
                   2627:   bidi.typed_data.real = FALSE;
                   2628: 
                   2629:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   2630:   ptr = cssRule;
1.327     vatton   2631:   if (!strncasecmp (cssRule, "normal", 6))
                   2632:     {
                   2633:       bidi.typed_data.value = Normal;
                   2634:       cssRule += 6;
                   2635:     }
                   2636:   else if (!strncasecmp (cssRule, "embed", 5))
                   2637:     {
                   2638:       bidi.typed_data.value = Embed;
                   2639:       cssRule += 5;
                   2640:     }
                   2641:   else if (!strncasecmp (cssRule, "bidi-override", 13))
                   2642:     {
                   2643:       bidi.typed_data.value = Override;
                   2644:       cssRule += 13;
                   2645:     }
                   2646:   else if (!strncasecmp (cssRule, "inherit", 7))
                   2647:     {
                   2648:       bidi.typed_data.unit = VALUE_INHERIT;
                   2649:       cssRule += 7;
                   2650:     }
                   2651:   else
                   2652:     {
                   2653:       cssRule = SkipValue ("Invalid unicode-bidi value", cssRule);
1.295     vatton   2654:       return (cssRule);
1.327     vatton   2655:     }
1.113     quint    2656: 
1.327     vatton   2657:   /*
                   2658:    * install the new presentation.
                   2659:    */
1.366     vatton   2660:   if (bidi.typed_data.value || bidi.typed_data.unit == VALUE_INHERIT)
                   2661:     {
                   2662:       if (DoDialog)
                   2663:         DisplayStyleValue ("unicode-bidi", ptr, cssRule);
                   2664:       else if (DoApply)
                   2665:         TtaSetStylePresentation (PRUnicodeBidi, element, tsch, context, bidi);
                   2666:     }
1.327     vatton   2667:   cssRule = CSSCheckEndValue (ptr, cssRule, "Invalid unicode-bidi value");
                   2668:   return (cssRule);
1.113     quint    2669: }
                   2670: 
                   2671: /*----------------------------------------------------------------------
1.327     vatton   2672:   ParseCSSTextIndent: parse a CSS text-indent
                   2673:   attribute string.                                          
1.1       cvs      2674:   ----------------------------------------------------------------------*/
1.79      cvs      2675: static char *ParseCSSTextIndent (Element element, PSchema tsch,
1.327     vatton   2676:                                  PresentationContext context, char *cssRule,
                   2677:                                  CSSInfoPtr css, ThotBool isHTML)
1.1       cvs      2678: {
1.327     vatton   2679:   PresentationValue   pval;
                   2680:   char               *ptr;
1.1       cvs      2681: 
1.327     vatton   2682:   cssRule = SkipBlanksAndComments (cssRule);
                   2683:   ptr = cssRule;
                   2684:   cssRule = ParseCSSUnit (cssRule, &pval);
                   2685:   if (pval.typed_data.value == 0)
                   2686:     pval.typed_data.unit = UNIT_PX;
                   2687:   else if (pval.typed_data.unit == UNIT_INVALID ||
                   2688:            pval.typed_data.unit == UNIT_BOX)
                   2689:     {
                   2690:       CSSParseError ("Invalid text-indent value", ptr, cssRule);
                   2691:       return (cssRule);
                   2692:     }
                   2693:   /* install the attribute */
1.366     vatton   2694:   if (DoDialog)
                   2695:     DisplayStyleValue ("text-indent", ptr, cssRule);
                   2696:   else if (DoApply)
1.327     vatton   2697:     TtaSetStylePresentation (PRIndent, element, tsch, context, pval);
                   2698:   return (cssRule);
1.1       cvs      2699: }
                   2700: 
                   2701: /*----------------------------------------------------------------------
1.327     vatton   2702:   ParseCSSTextTransform: parse a CSS text-transform    
                   2703:   attribute string.                                          
1.1       cvs      2704:   ----------------------------------------------------------------------*/
1.79      cvs      2705: static char *ParseCSSTextTransform (Element element, PSchema tsch,
1.327     vatton   2706:                                     PresentationContext context, char *cssRule,
                   2707:                                     CSSInfoPtr css, ThotBool isHTML)
1.1       cvs      2708: {
1.366     vatton   2709:   char               *ptr;
                   2710: 
                   2711:   cssRule = SkipBlanksAndComments (cssRule);
                   2712:   ptr = cssRule;
1.168     vatton   2713:   cssRule = SkipValue (NULL, cssRule);
1.366     vatton   2714:   if (DoDialog)
                   2715:     DisplayStyleValue ("text-transform", ptr, cssRule);
1.1       cvs      2716:   return (cssRule);
                   2717: }
                   2718: 
                   2719: /*----------------------------------------------------------------------
1.327     vatton   2720:   ParseCSSVerticalAlign: parse a CSS vertical-align    
                   2721:   attribute string.                                          
1.1       cvs      2722:   ----------------------------------------------------------------------*/
1.79      cvs      2723: static char *ParseCSSVerticalAlign (Element element, PSchema tsch,
1.327     vatton   2724:                                     PresentationContext context, char *cssRule,
                   2725:                                     CSSInfoPtr css, ThotBool isHTML)
1.1       cvs      2726: {
1.273     quint    2727:   char                 *ptr;
                   2728:   PresentationValue    pval;
                   2729: 
                   2730:   pval.typed_data.unit = UNIT_REL;
                   2731:   pval.typed_data.real = FALSE;
                   2732:   cssRule = SkipBlanksAndComments (cssRule);
1.288     vatton   2733:   ptr = cssRule;
1.273     quint    2734:   if (!strncasecmp (cssRule, "baseline", 8))
                   2735:     {
                   2736:       pval.typed_data.value = 0;
1.288     vatton   2737:       cssRule += 8;
1.273     quint    2738:     }
                   2739:   else if (!strncasecmp (cssRule, "sub", 3))
                   2740:     {
                   2741:       pval.typed_data.value = -3;
1.288     vatton   2742:       cssRule += 3;
1.273     quint    2743:     }
                   2744:   else if (!strncasecmp (cssRule, "super", 5))
                   2745:     {
                   2746:       pval.typed_data.value = 4;
1.288     vatton   2747:       cssRule += 5;
1.273     quint    2748:     }
                   2749:   else if (!strncasecmp (cssRule, "top", 3))
                   2750:     {
1.275     quint    2751:       pval.typed_data.unit = UNIT_INVALID;      /* Not supported yet */
1.274     vatton   2752:       pval.typed_data.value = 0;
1.288     vatton   2753:       cssRule += 3;
1.273     quint    2754:     }
                   2755:   else if (!strncasecmp (cssRule, "text-top", 8))
                   2756:     {
1.275     quint    2757:       pval.typed_data.unit = UNIT_INVALID;      /* Not supported yet */
1.274     vatton   2758:       pval.typed_data.value = 0;
1.288     vatton   2759:       cssRule += 8;
1.273     quint    2760:     }
                   2761:   else if (!strncasecmp (cssRule, "middle", 6))
                   2762:     {
1.275     quint    2763:       pval.typed_data.unit = UNIT_INVALID;      /* Not supported yet */
1.274     vatton   2764:       pval.typed_data.value = 0;
1.288     vatton   2765:       cssRule += 6;
1.273     quint    2766:     }
                   2767:   else if (!strncasecmp (cssRule, "bottom", 6))
                   2768:     {
1.275     quint    2769:       pval.typed_data.unit = UNIT_INVALID;      /* Not supported yet */
1.274     vatton   2770:       pval.typed_data.value = 0;
1.288     vatton   2771:       cssRule += 6;
1.273     quint    2772:     }
                   2773:   else if (!strncasecmp (cssRule, "text-bottom", 11))
                   2774:     {
1.275     quint    2775:       pval.typed_data.unit = UNIT_INVALID;      /* Not supported yet */
1.274     vatton   2776:       pval.typed_data.value = 0;
1.288     vatton   2777:       cssRule += 11;
1.273     quint    2778:     }
                   2779:   else if (!strncasecmp (cssRule, "inherit", 7))
                   2780:     {
1.293     quint    2781:       pval.typed_data.unit = VALUE_INHERIT;
1.274     vatton   2782:       pval.typed_data.value = 0;
1.288     vatton   2783:       cssRule +=7;
1.273     quint    2784:     }
                   2785:   else
                   2786:     {
                   2787:       /* parse <percentage> or <length> */
                   2788:       cssRule = ParseCSSUnit (cssRule, &pval);
                   2789:       if (pval.typed_data.unit == UNIT_INVALID)
1.327     vatton   2790:         {
                   2791:           pval.typed_data.value = 0;
                   2792:           CSSParseError ("Invalid vertical-align value", ptr, cssRule);
                   2793:           return (cssRule);
                   2794:         }
1.273     quint    2795:       else if (pval.typed_data.value == 0)
1.327     vatton   2796:         pval.typed_data.unit = UNIT_PX;
1.273     quint    2797:       else if (pval.typed_data.unit == UNIT_BOX)
1.327     vatton   2798:         pval.typed_data.unit = UNIT_EM;
1.273     quint    2799:       else if (pval.typed_data.unit == UNIT_PERCENT)
1.327     vatton   2800:         /* it's a percentage */
                   2801:         {
                   2802:           /* convert it into a relative size */
                   2803:           pval.typed_data.unit = UNIT_REL;
                   2804:           pval.typed_data.value /= 10;
                   2805:         }
1.273     quint    2806:     }
1.295     vatton   2807: 
1.366     vatton   2808:   if (pval.typed_data.unit != UNIT_INVALID)
                   2809:     {
                   2810:       if (DoDialog)
                   2811:         DisplayStyleValue ("vertical-align", ptr, cssRule);
                   2812:       else if (DoApply)
                   2813:         TtaSetStylePresentation (PRHorizRef, element, tsch, context, pval);
                   2814:     }
1.288     vatton   2815:   cssRule = CSSCheckEndValue (ptr, cssRule, "Invalid vertical-align value");
1.1       cvs      2816:   return (cssRule);
                   2817: }
                   2818: 
                   2819: /*----------------------------------------------------------------------
1.327     vatton   2820:   ParseCSSWhiteSpace: parse a CSS white-space          
                   2821:   attribute string.                                          
1.1       cvs      2822:   ----------------------------------------------------------------------*/
1.79      cvs      2823: static char *ParseCSSWhiteSpace (Element element, PSchema tsch,
1.327     vatton   2824:                                  PresentationContext context, char *cssRule,
                   2825:                                  CSSInfoPtr css, ThotBool isHTML)
1.1       cvs      2826: {
1.366     vatton   2827:   char *ptr;
1.288     vatton   2828: 
1.327     vatton   2829:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   2830:   ptr = cssRule;
1.327     vatton   2831:   if (!strncasecmp (cssRule, "normal", 6))
                   2832:     cssRule += 6;
                   2833:   else if (!strncasecmp (cssRule, "pre", 3))
                   2834:     cssRule += 3;
                   2835:   else if (!strncasecmp (cssRule, "nowrap", 6))
                   2836:     cssRule += 6;
                   2837:   else if (!strncasecmp (cssRule, "pre-wrap", 8))
                   2838:     cssRule += 8;
                   2839:   else if (!strncasecmp (cssRule, "pre-line", 8))
                   2840:     cssRule += 8;
                   2841:   else if (!strncasecmp (cssRule, "inherit", 7))
                   2842:     cssRule += 7;
                   2843:   else
                   2844:     cssRule = SkipValue ("Invalid white-space value", cssRule);
                   2845: 
1.366     vatton   2846:   if (ptr  != cssRule &&DoDialog)
                   2847:     DisplayStyleValue ("white-space", ptr, cssRule);
1.327     vatton   2848:   cssRule = CSSCheckEndValue (ptr, cssRule, "Invalid white-space value");
                   2849:   return (cssRule);
1.1       cvs      2850: }
                   2851: 
                   2852: /*----------------------------------------------------------------------
1.327     vatton   2853:   ParseCSSWordSpacing: parse a CSS word-spacing        
                   2854:   attribute string.                                          
1.1       cvs      2855:   ----------------------------------------------------------------------*/
1.79      cvs      2856: static char *ParseCSSWordSpacing (Element element, PSchema tsch,
1.327     vatton   2857:                                   PresentationContext context, char *cssRule,
                   2858:                                   CSSInfoPtr css, ThotBool isHTML)
1.1       cvs      2859: {
1.366     vatton   2860:   char *ptr;
                   2861: 
                   2862:   cssRule = SkipBlanksAndComments (cssRule);
                   2863:   ptr = cssRule;
1.168     vatton   2864:   cssRule = SkipValue (NULL, cssRule);
1.366     vatton   2865:   if (DoDialog)
                   2866:     DisplayStyleValue ("word-spacing", ptr, cssRule);
1.1       cvs      2867:   return (cssRule);
                   2868: }
                   2869: 
                   2870: /*----------------------------------------------------------------------
1.327     vatton   2871:   ParseCSSLineHeight: parse a CSS line-height property
1.25      cvs      2872:   ----------------------------------------------------------------------*/
1.162     quint    2873: static char *ParseCSSLineHeight (Element element, PSchema tsch,
1.327     vatton   2874:                                  PresentationContext context, char *cssRule,
                   2875:                                  CSSInfoPtr css, ThotBool isHTML)
1.25      cvs      2876: {
1.162     quint    2877:   PresentationValue   pval;
1.288     vatton   2878:   char               *ptr;
1.162     quint    2879: 
1.366     vatton   2880:   cssRule = SkipBlanksAndComments (cssRule);
1.162     quint    2881:   ptr = cssRule;
                   2882:   if (!strncasecmp (cssRule, "normal", 6))
                   2883:     {
1.184     vatton   2884:       pval.typed_data.unit = UNIT_REL;
1.162     quint    2885:       pval.typed_data.real = TRUE;
                   2886:       pval.typed_data.value = 1100;
1.288     vatton   2887:       cssRule += 6;
1.162     quint    2888:     }
                   2889:   else if (!strncasecmp (cssRule, "inherit", 7))
                   2890:     {
1.293     quint    2891:       pval.typed_data.unit = VALUE_INHERIT;
1.354     quint    2892:       cssRule += 7;
1.162     quint    2893:     }
                   2894:   else
                   2895:     cssRule = ParseCSSUnit (cssRule, &pval);
1.25      cvs      2896: 
1.184     vatton   2897:   if (pval.typed_data.unit == UNIT_INVALID)
1.168     vatton   2898:     CSSParseError ("Invalid line-height value", ptr, cssRule);
1.366     vatton   2899:   if (DoDialog)
                   2900:     DisplayStyleValue ("line-height", ptr, cssRule);
1.162     quint    2901:   else if (DoApply)
                   2902:     {
1.166     vatton   2903:       /* install the new presentation */
1.184     vatton   2904:       if (pval.typed_data.unit == UNIT_BOX)
1.327     vatton   2905:         pval.typed_data.unit = UNIT_EM;
1.162     quint    2906:       TtaSetStylePresentation (PRLineSpacing, element, tsch, context, pval);
                   2907:     }
                   2908:   return (cssRule);
1.25      cvs      2909: }
                   2910: 
                   2911: /*----------------------------------------------------------------------
1.327     vatton   2912:   ParseCSSFontSizeAdjust: parse a CSS fontsizeAdjust attr string  
                   2913:   we expect the input string describing the attribute to be     
                   2914:   xx-small, x-small, small, medium, large, x-large, xx-large      
                   2915:   or an absolute size, or an imcrement relative to the parent     
1.1       cvs      2916:   ----------------------------------------------------------------------*/
1.219     vatton   2917: static char *ParseCSSFontSizeAdjust (Element element, PSchema tsch,
1.327     vatton   2918:                                      PresentationContext context, char *cssRule,
                   2919:                                      CSSInfoPtr css, ThotBool isHTML)
1.219     vatton   2920: {
1.366     vatton   2921: 
                   2922:   cssRule = SkipBlanksAndComments (cssRule);
1.234     vatton   2923:   cssRule = SkipProperty (cssRule, FALSE);
1.222     quint    2924:   return (cssRule);
1.219     vatton   2925: }
                   2926: 
                   2927: /*----------------------------------------------------------------------
1.327     vatton   2928:   ParseACSSFontSize: parse a CSS font size attr string  
                   2929:   we expect the input string describing the attribute to be     
                   2930:   xx-small, x-small, small, medium, large, x-large, xx-large      
                   2931:   or an absolute size, or an imcrement relative to the parent.
                   2932:   The parameter check is TRUE if the rule is just checked.
1.219     vatton   2933:   ----------------------------------------------------------------------*/
1.270     vatton   2934: static char *ParseACSSFontSize (Element element, PSchema tsch,
1.327     vatton   2935:                                 PresentationContext context, char *cssRule,
                   2936:                                 CSSInfoPtr css, ThotBool isHTML, ThotBool check)
1.1       cvs      2937: {
1.327     vatton   2938:   ElementType         elType;
                   2939:   PresentationValue   pval;
                   2940:   char               *ptr = NULL, *ptr1 = NULL;
1.366     vatton   2941:   char               *start_value;
                   2942:   ThotBool               real, linespace = FALSE;
1.327     vatton   2943: 
                   2944:   pval.typed_data.real = FALSE;
                   2945:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   2946:   start_value = cssRule;
1.327     vatton   2947:   /* look for a '/' within the current cssRule */
                   2948:   ptr1 = strchr (cssRule, ';');
                   2949:   ptr = strchr (cssRule, '/');
                   2950:   if (ptr && (ptr1 == NULL || ptr < ptr1))
                   2951:     {
                   2952:       /* keep the line spacing rule */
                   2953:       linespace = TRUE;
                   2954:       ptr[0] = EOS;
                   2955:     }
                   2956:   else
                   2957:     ptr = NULL;
                   2958:   ptr1 = cssRule;
1.289     vatton   2959:   /* relative size */
1.327     vatton   2960:   if (!strncasecmp (cssRule, "larger", 6))
                   2961:     {
                   2962:       pval.typed_data.unit = UNIT_PERCENT;
                   2963:       pval.typed_data.value = 130;
                   2964:       cssRule += 6;
                   2965:     }
                   2966:   else if (!strncasecmp (cssRule, "smaller", 7))
                   2967:     {
                   2968:       pval.typed_data.unit = UNIT_PERCENT;
                   2969:       pval.typed_data.value = 80;
                   2970:       cssRule += 7;
                   2971:     }
                   2972:   /* absolute size */
                   2973:   else if (!strncasecmp (cssRule, "xx-small", 8))
                   2974:     {
                   2975:       pval.typed_data.unit = UNIT_PT;
1.336     vatton   2976:       pval.typed_data.value = 6;
1.327     vatton   2977:       cssRule += 8;
                   2978:     }
                   2979:   else if (!strncasecmp (cssRule, "x-small", 7))
                   2980:     {
                   2981:       pval.typed_data.unit = UNIT_PT;
1.336     vatton   2982:       pval.typed_data.value = 8;
1.327     vatton   2983:       cssRule += 7;
                   2984:     }
                   2985:   else if (!strncasecmp (cssRule, "small", 5))
                   2986:     {
                   2987:       pval.typed_data.unit = UNIT_PT;
1.336     vatton   2988:       pval.typed_data.value = 10;
1.327     vatton   2989:       cssRule += 5;
                   2990:     }
                   2991:   else if (!strncasecmp (cssRule, "medium", 6))
                   2992:     {
                   2993:       pval.typed_data.unit = UNIT_PT;
                   2994:       pval.typed_data.value = 12;
                   2995:       cssRule += 6;
                   2996:     }
                   2997:   else if (!strncasecmp (cssRule, "large", 5))
                   2998:     {
                   2999:       pval.typed_data.unit = UNIT_PT;
                   3000:       pval.typed_data.value = 13;
                   3001:       cssRule += 5;
                   3002:     }
                   3003:   else if (!strncasecmp (cssRule, "x-large", 7))
                   3004:     {
                   3005:       pval.typed_data.unit = UNIT_PT;
                   3006:       pval.typed_data.value = 14;
                   3007:       cssRule += 7;
                   3008:     }
                   3009:   else if (!strncasecmp (cssRule, "xx-large", 8))
                   3010:     {
                   3011:       pval.typed_data.unit = UNIT_PT;
                   3012:       pval.typed_data.value = 16;
                   3013:       cssRule += 8;
                   3014:     }
                   3015:   else if (!strncasecmp (cssRule, "inherit", 7))
                   3016:     {
                   3017:       pval.typed_data.unit = VALUE_INHERIT;
                   3018:       pval.typed_data.value = 0;
                   3019:       cssRule += 7;
                   3020:     }
                   3021:   /* length or percentage */
                   3022:   else if (!isdigit (*cssRule) && *cssRule != '.')
                   3023:     {
                   3024:       if (!check)
1.360     vatton   3025:         cssRule = SkipValue ("Invalid font-size value", cssRule);
1.327     vatton   3026:       return (cssRule);
                   3027:     }
                   3028:   else
                   3029:     {       
                   3030:       cssRule = ParseCSSUnit (cssRule, &pval);
                   3031:       if (pval.typed_data.unit == UNIT_BOX)
                   3032:         /* no unit specified */
                   3033:         {
                   3034:           elType = TtaGetElementType(element);
                   3035:           if (!strcmp(TtaGetSSchemaName (elType.ElSSchema), "SVG"))
                   3036:             /* we are working for an SVG element. No unit means pixels */
                   3037:             pval.typed_data.unit = UNIT_PX;
                   3038:         }
                   3039:       if (pval.typed_data.value != 0 &&
                   3040:           (pval.typed_data.unit == UNIT_INVALID ||
                   3041:            pval.typed_data.unit == UNIT_BOX ||
                   3042:            pval.typed_data.value < 0))
                   3043:         /* not a valid value */
                   3044:         return (cssRule);
                   3045:       else if (pval.typed_data.unit == UNIT_REL && pval.typed_data.value > 0)
                   3046:         /* CSS relative sizes have to be higher than Thot ones */
                   3047:         pval.typed_data.value += 1;
                   3048:       else 
                   3049:         {
                   3050:           real = pval.typed_data.real;
                   3051:           if (pval.typed_data.unit == UNIT_EM)
                   3052:             {
                   3053:               if (real)
                   3054:                 {
                   3055:                   pval.typed_data.value /= 10;
                   3056:                   pval.typed_data.real = FALSE;
                   3057:                   real = FALSE;
                   3058:                 }
                   3059:               else
                   3060:                 pval.typed_data.value *= 100;
                   3061:               pval.typed_data.unit = UNIT_PERCENT;
                   3062:             }
                   3063:           else if (pval.typed_data.unit == UNIT_XHEIGHT)
                   3064:             {
                   3065:               /* a font size expressed in ex is converted into a percentage.
                   3066:                  For example, "3ex" is converted into "180%", supposing
                   3067:                  that 1ex is approximately 0.6 times the height of the
                   3068:                  current font */
                   3069:               if (real)
                   3070:                 {
                   3071:                   pval.typed_data.value *= 6;
                   3072:                   pval.typed_data.value /= 100;
                   3073:                   pval.typed_data.real = FALSE;
                   3074:                   real = FALSE;
                   3075:                 }
                   3076:               else
                   3077:                 pval.typed_data.value *= 60;
                   3078:               pval.typed_data.unit = UNIT_PERCENT;
                   3079:             }
                   3080:         }
                   3081:     }
                   3082: 
                   3083:   /* install the presentation style */
1.366     vatton   3084:   if (!check)
                   3085:     {
                   3086:       if (DoDialog)
                   3087:         DisplayStyleValue ("font-size", start_value, cssRule);
                   3088:       else if (DoApply)
                   3089:         TtaSetStylePresentation (PRSize, element, tsch, context, pval);
                   3090:     }
1.327     vatton   3091:   if (!check && ptr)
                   3092:     cssRule = ParseCSSLineHeight (element, tsch, context, &ptr[1], css, isHTML);
                   3093:   if (linespace)
                   3094:     *ptr = '/';
                   3095: 
                   3096:   return (cssRule);
                   3097: }
                   3098: 
                   3099: /*----------------------------------------------------------------------
                   3100:   ParseCSSFontSize: parse a CSS font size attr string  
                   3101:   we expect the input string describing the attribute to be     
                   3102:   xx-small, x-small, small, medium, large, x-large, xx-large      
                   3103:   or an absolute size, or an imcrement relative to the parent     
1.270     vatton   3104:   ----------------------------------------------------------------------*/
                   3105: static char *ParseCSSFontSize (Element element, PSchema tsch,
1.327     vatton   3106:                                PresentationContext context, char *cssRule,
                   3107:                                CSSInfoPtr css, ThotBool isHTML)
1.270     vatton   3108: {
1.299     vatton   3109:   char               *ptr = cssRule;
1.295     vatton   3110:   cssRule = ParseACSSFontSize (element, tsch, context, cssRule, css, isHTML, FALSE);
1.299     vatton   3111:   cssRule = CSSCheckEndValue (ptr, cssRule, "Invalid font-size value");
1.295     vatton   3112:   return cssRule;
1.270     vatton   3113: }
                   3114: 
                   3115: /*----------------------------------------------------------------------
1.327     vatton   3116:   ParseACSSFontFamily: parse a CSS font family string   
                   3117:   we expect the input string describing the attribute to be     
                   3118:   a common generic font style name                                
1.1       cvs      3119:   ----------------------------------------------------------------------*/
1.268     vatton   3120: static char *ParseACSSFontFamily (Element element, PSchema tsch,
1.327     vatton   3121:                                   PresentationContext context, char *cssRule,
                   3122:                                   CSSInfoPtr css, ThotBool isHTML)
1.1       cvs      3123: {
                   3124:   PresentationValue   font;
1.252     vatton   3125:   char                quoteChar, *p;
1.1       cvs      3126: 
                   3127:   font.typed_data.value = 0;
1.184     vatton   3128:   font.typed_data.unit = UNIT_REL;
1.1       cvs      3129:   font.typed_data.real = FALSE;
1.82      cvs      3130:   cssRule = SkipBlanksAndComments (cssRule);
                   3131:   if (*cssRule == '"' || *cssRule == '\'')
1.327     vatton   3132:     {
                   3133:       quoteChar = *cssRule;
                   3134:       cssRule++;
                   3135:     }
1.1       cvs      3136:   else
1.327     vatton   3137:     quoteChar = EOS;
1.1       cvs      3138: 
1.293     quint    3139:   if (!strncasecmp (cssRule, "inherit", 7) && quoteChar == EOS)
                   3140:     {
                   3141:       font.typed_data.unit = VALUE_INHERIT;
                   3142:       cssRule += 7;
                   3143:     }
                   3144:   else if (!strncasecmp (cssRule, "times", 5) &&
1.327     vatton   3145:            (quoteChar == EOS || quoteChar == cssRule[5]))
1.86      cvs      3146:     {
1.184     vatton   3147:       font.typed_data.value = FontTimes;
1.86      cvs      3148:       cssRule += 5;
                   3149:     }
1.92      cvs      3150:   else if (!strncasecmp (cssRule, "serif", 5) &&
1.327     vatton   3151:            (quoteChar == EOS || quoteChar == cssRule[5]))
1.86      cvs      3152:     {
1.184     vatton   3153:       font.typed_data.value = FontTimes;
1.86      cvs      3154:       cssRule += 5;
1.92      cvs      3155:       if (quoteChar != EOS)
1.327     vatton   3156:         cssRule++;
1.86      cvs      3157:     }
1.92      cvs      3158:   else if (!strncasecmp (cssRule, "helvetica", 9) &&
1.327     vatton   3159:            (quoteChar == EOS || quoteChar == cssRule[9]))
1.86      cvs      3160:     {
1.327     vatton   3161:       font.typed_data.value = FontHelvetica;
1.86      cvs      3162:       cssRule += 9;
1.92      cvs      3163:       if (quoteChar != EOS)
1.327     vatton   3164:         cssRule++;
1.86      cvs      3165:     }
1.92      cvs      3166:   else if (!strncasecmp (cssRule, "verdana", 7) &&
1.327     vatton   3167:            (quoteChar == EOS || quoteChar == cssRule[7]))
1.86      cvs      3168:     {
1.184     vatton   3169:       font.typed_data.value = FontHelvetica;
1.86      cvs      3170:       cssRule += 7;
1.92      cvs      3171:       if (quoteChar != EOS)
1.327     vatton   3172:         cssRule++;
1.86      cvs      3173:     }
1.92      cvs      3174:   else if (!strncasecmp (cssRule, "sans-serif", 10) &&
1.327     vatton   3175:            (quoteChar == EOS || quoteChar == cssRule[10]))
1.86      cvs      3176:     {
1.184     vatton   3177:       font.typed_data.value = FontHelvetica;
1.86      cvs      3178:       cssRule += 10;
1.92      cvs      3179:       if (quoteChar != EOS)
1.327     vatton   3180:         cssRule++;
1.86      cvs      3181:     }
1.268     vatton   3182:   else if (!strncasecmp (cssRule, "courier new", 11) &&
1.327     vatton   3183:            (quoteChar == EOS || quoteChar == cssRule[11]))
1.268     vatton   3184:     {
                   3185:       font.typed_data.value = FontCourier;
                   3186:       cssRule += 11;
                   3187:       if (quoteChar != EOS)
1.327     vatton   3188:         cssRule++;
1.268     vatton   3189:     }
1.92      cvs      3190:   else if (!strncasecmp (cssRule, "courier", 7) &&
1.327     vatton   3191:            (quoteChar == EOS || quoteChar == cssRule[7]))
1.86      cvs      3192:     {
1.184     vatton   3193:       font.typed_data.value = FontCourier;
1.86      cvs      3194:       cssRule += 7;
1.92      cvs      3195:       if (quoteChar != EOS)
1.327     vatton   3196:         cssRule++;
1.86      cvs      3197:     }
1.92      cvs      3198:   else if (!strncasecmp (cssRule, "monospace", 9) &&
1.327     vatton   3199:            (quoteChar == EOS || quoteChar == cssRule[9]))
1.86      cvs      3200:     {
1.184     vatton   3201:       font.typed_data.value = FontCourier;
1.86      cvs      3202:       cssRule += 9;
1.92      cvs      3203:       if (quoteChar != EOS)
1.327     vatton   3204:         cssRule++;
1.86      cvs      3205:     }
1.1       cvs      3206:   else
                   3207:     /* unknown font name.  Skip it */
                   3208:     {
1.252     vatton   3209:       p = cssRule;
1.92      cvs      3210:       if (quoteChar != EOS)
1.327     vatton   3211:         cssRule = SkipQuotedString (cssRule, quoteChar);
1.86      cvs      3212:       else
1.327     vatton   3213:         cssRule = SkipWord (cssRule);
1.252     vatton   3214:       while (p == cssRule &&
1.327     vatton   3215:              *cssRule != ','  && *cssRule != ';'  && *cssRule != '}' && *cssRule != EOS)
                   3216:         {
                   3217:           cssRule++;
                   3218:           p = cssRule;
                   3219:           cssRule = SkipWord (cssRule);
                   3220:         }
1.82      cvs      3221:       cssRule = SkipBlanksAndComments (cssRule);
                   3222:       if (*cssRule == ',')
1.327     vatton   3223:         {
                   3224:           /* recursive call to ParseCSSFontFamily */
                   3225:           cssRule++;
                   3226:           cssRule = ParseACSSFontFamily (element, tsch, context, cssRule, css, isHTML);
                   3227:           return (cssRule);
                   3228:         }
1.1       cvs      3229:     }
                   3230: 
1.239     vatton   3231:   /* skip other values */
                   3232:   cssRule = SkipBlanksAndComments (cssRule);
                   3233:   while (*cssRule == ',')
                   3234:     {
                   3235:       cssRule++;
                   3236:       cssRule = SkipValue (NULL, cssRule);
                   3237:       cssRule = SkipBlanksAndComments (cssRule);
                   3238:     }
                   3239: 
1.366     vatton   3240:   if (font.typed_data.value != 0 || font.typed_data.unit == VALUE_INHERIT)
                   3241:     {
                   3242:       if (!DoDialog && DoApply)
                   3243:         /* install the new presentation */
                   3244:         TtaSetStylePresentation (PRFont, element, tsch, context, font);
                   3245:     }
1.1       cvs      3246:   return (cssRule);
                   3247: }
                   3248: 
                   3249: /*----------------------------------------------------------------------
1.327     vatton   3250:   ParseCSSFontFamily: parse a CSS font family string   
                   3251:   we expect the input string describing the attribute to be     
                   3252:   a common generic font style name                                
1.268     vatton   3253:   ----------------------------------------------------------------------*/
                   3254: static char *ParseCSSFontFamily (Element element, PSchema tsch,
1.327     vatton   3255:                                  PresentationContext context, char *cssRule,
                   3256:                                  CSSInfoPtr css, ThotBool isHTML)
1.268     vatton   3257: {
1.366     vatton   3258:   char               *start_value;
                   3259: 
                   3260:   cssRule = SkipBlanksAndComments (cssRule);
                   3261:   start_value = cssRule;
1.268     vatton   3262:   cssRule = ParseACSSFontFamily (element, tsch, context, cssRule, css, isHTML);
                   3263:   /* skip extra values */
1.301     vatton   3264:   while (cssRule && *cssRule != ';' && *cssRule != '}' && *cssRule != EOS)
1.268     vatton   3265:     cssRule++;
1.366     vatton   3266:   if (DoDialog)
                   3267:     DisplayStyleValue ("font-family", start_value, cssRule);
1.268     vatton   3268:   return (cssRule);
                   3269: }
                   3270: 
                   3271: /*----------------------------------------------------------------------
1.327     vatton   3272:   ParseACSSFontWeight: parse a CSS font weight string   
                   3273:   we expect the input string describing the attribute to be     
                   3274:   normal, bold, bolder, lighter, 100, 200, 300, ... 900, inherit.
1.1       cvs      3275:   ----------------------------------------------------------------------*/
1.263     vatton   3276: static char *ParseACSSFontWeight (Element element, PSchema tsch,
1.327     vatton   3277:                                   PresentationContext context, char *cssRule,
                   3278:                                   CSSInfoPtr css, ThotBool isHTML)
1.1       cvs      3279: {
1.327     vatton   3280:   PresentationValue   weight;
1.366     vatton   3281:   char               *ptr;
1.1       cvs      3282: 
1.327     vatton   3283:   weight.typed_data.value = 0;
                   3284:   weight.typed_data.unit = UNIT_REL;
                   3285:   weight.typed_data.real = FALSE;
                   3286:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   3287:   ptr = cssRule;
1.351     quint    3288:   if (isdigit (*cssRule) && *cssRule != '0' &&
                   3289:       cssRule[1] == '0' && cssRule[2] == '0' &&
                   3290:       (cssRule[3] == EOS || cssRule[3] == SPACE || cssRule[3] == '/' ||
                   3291:        cssRule[3] == ';' || cssRule[3] == '}' || cssRule[3] == EOL || 
                   3292:        cssRule[3] == TAB || cssRule[3] ==  __CR__))
1.327     vatton   3293:     {
1.351     quint    3294:       if (!strncasecmp (cssRule, "100", 3))
                   3295:         {
                   3296:           weight.typed_data.value = -3;
                   3297:           cssRule = SkipWord (cssRule);
                   3298:         }
                   3299:       else if (!strncasecmp (cssRule, "200", 3))
                   3300:         {
                   3301:           weight.typed_data.value = -2;
                   3302:           cssRule = SkipWord (cssRule);
                   3303:         }
                   3304:       else if (!strncasecmp (cssRule, "300", 3))
                   3305:         {
                   3306:           weight.typed_data.value = -1;
                   3307:           cssRule = SkipWord (cssRule);
                   3308:         }
                   3309:       else if (!strncasecmp (cssRule, "400", 3))
                   3310:         {
                   3311:           weight.typed_data.value = 0;
                   3312:           cssRule = SkipWord (cssRule);
                   3313:         }
                   3314:       else if (!strncasecmp (cssRule, "500", 3))
                   3315:         {
                   3316:           weight.typed_data.value = +1;
                   3317:           cssRule = SkipWord (cssRule);
                   3318:         }
                   3319:       else if (!strncasecmp (cssRule, "600", 3))
                   3320:         {
                   3321:           weight.typed_data.value = +2;
                   3322:           cssRule = SkipWord (cssRule);
                   3323:         }
                   3324:       else if (!strncasecmp (cssRule, "700", 3))
                   3325:         {
                   3326:           weight.typed_data.value = +3;
                   3327:           cssRule = SkipWord (cssRule);
                   3328:         }
                   3329:       else if (!strncasecmp (cssRule, "800", 3))
                   3330:         {
                   3331:           weight.typed_data.value = +4;
                   3332:           cssRule = SkipWord (cssRule);
                   3333:         }
                   3334:       else if (!strncasecmp (cssRule, "900", 3))
                   3335:         {
                   3336:           weight.typed_data.value = +5;
                   3337:           cssRule = SkipWord (cssRule);
                   3338:         }
1.327     vatton   3339:     }
1.351     quint    3340:   else if (!strncasecmp (cssRule, "normal", 6))
1.327     vatton   3341:     {
                   3342:       weight.typed_data.value = 0;
                   3343:       cssRule = SkipWord (cssRule);
                   3344:     }
1.351     quint    3345:   else if (!strncasecmp (cssRule, "bold", 4))
1.327     vatton   3346:     {
                   3347:       weight.typed_data.value = +3;
                   3348:       cssRule = SkipWord (cssRule);
                   3349:     }
                   3350:   else if (!strncasecmp (cssRule, "inherit", 7))
                   3351:     {
                   3352:       weight.typed_data.unit = VALUE_INHERIT;
                   3353:       cssRule += 7;
                   3354:     }
                   3355:   else if (!strncasecmp (cssRule, "bolder", 6) ||
                   3356:            !strncasecmp (cssRule, "lighter", 7))
                   3357:     {
                   3358:       /* not implemented */
                   3359:       cssRule = SkipWord (cssRule);
                   3360:       return (cssRule);
                   3361:     }
                   3362:   else
                   3363:     return (cssRule);
                   3364: 
                   3365:   /*
                   3366:    * Here we have to reduce since only two font weight values are supported
                   3367:    * by the Thot presentation API.
                   3368:    */
                   3369:   if (weight.typed_data.unit != VALUE_INHERIT)
                   3370:     {
                   3371:       if (weight.typed_data.value > 0)
                   3372:         weight.typed_data.value = WeightBold;
                   3373:       else
                   3374:         weight.typed_data.value = WeightNormal;
                   3375:     }
                   3376: 
                   3377:   /* install the new presentation */
1.366     vatton   3378:   if (cssRule != ptr && DoDialog)
                   3379:     DisplayStyleValue ("font-weight", ptr, cssRule);
                   3380:   else if (DoApply)
1.327     vatton   3381:     TtaSetStylePresentation (PRWeight, element, tsch, context, weight);
                   3382:   return (cssRule);
                   3383: }
                   3384: 
                   3385: /*----------------------------------------------------------------------
                   3386:   ParseCSSFontWeight: parse a CSS font weight string   
                   3387:   we expect the input string describing the attribute to be     
                   3388:   normal, bold, bolder, lighter, 100, 200, 300, ... 900, inherit.
1.263     vatton   3389:   ----------------------------------------------------------------------*/
                   3390: static char *ParseCSSFontWeight (Element element, PSchema tsch,
1.327     vatton   3391:                                  PresentationContext context, char *cssRule,
                   3392:                                  CSSInfoPtr css, ThotBool isHTML)
1.263     vatton   3393: {
                   3394:   char           *ptr;
                   3395:   
1.366     vatton   3396:   cssRule = SkipBlanksAndComments (cssRule);
1.263     vatton   3397:   ptr = cssRule;
                   3398:   cssRule = ParseACSSFontWeight (element, tsch, context, cssRule, css, isHTML);
                   3399:   if (ptr == cssRule)
                   3400:     cssRule = SkipValue ("Invalid font-weight value", cssRule);
                   3401:   return (cssRule);
                   3402: }
                   3403: 
                   3404: /*----------------------------------------------------------------------
1.327     vatton   3405:   ParseACSSFontVariant: parse a CSS font variant string     
                   3406:   we expect the input string describing the attribute to be     
                   3407:   normal or small-caps
1.1       cvs      3408:   ----------------------------------------------------------------------*/
1.263     vatton   3409: static char *ParseACSSFontVariant (Element element, PSchema tsch,
1.327     vatton   3410:                                    PresentationContext context, char *cssRule,
                   3411:                                    CSSInfoPtr css, ThotBool isHTML)
1.1       cvs      3412: {
1.327     vatton   3413:   PresentationValue   style;
1.366     vatton   3414:   char               *ptr;
1.1       cvs      3415: 
1.327     vatton   3416:   style.typed_data.value = 0;
                   3417:   style.typed_data.unit = UNIT_REL;
                   3418:   style.typed_data.real = FALSE;
                   3419:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   3420:   ptr = cssRule;
1.327     vatton   3421:   if (!strncasecmp (cssRule, "small-caps", 10))
                   3422:     {
                   3423:       /* Not supported yet */
                   3424:       cssRule = SkipWord (cssRule);
                   3425:     }
                   3426:   else if (!strncasecmp (cssRule, "normal", 6))
                   3427:     {
                   3428:       /* Not supported yet */
                   3429:       cssRule = SkipWord (cssRule);
                   3430:     }
                   3431:   else if (!strncasecmp (cssRule, "inherit", 7))
                   3432:     {
                   3433:       /* Not supported yet */
                   3434:       cssRule = SkipWord (cssRule);
                   3435:     }
1.366     vatton   3436:   if (cssRule != ptr && DoDialog)
                   3437:     DisplayStyleValue ("font-variant", ptr, cssRule);
1.295     vatton   3438:   return (cssRule);
1.263     vatton   3439: }
1.1       cvs      3440: 
1.263     vatton   3441: /*----------------------------------------------------------------------
1.327     vatton   3442:   ParseCSSFontVariant: parse a CSS font variant string     
                   3443:   we expect the input string describing the attribute to be     
                   3444:   normal or small-caps
1.263     vatton   3445:   ----------------------------------------------------------------------*/
                   3446: static char *ParseCSSFontVariant (Element element, PSchema tsch,
1.327     vatton   3447:                                   PresentationContext context, char *cssRule,
                   3448:                                   CSSInfoPtr css, ThotBool isHTML)
1.263     vatton   3449: {
                   3450:   char           *ptr;
                   3451:   
                   3452:   ptr = cssRule;
                   3453:   cssRule = ParseACSSFontVariant (element, tsch, context, cssRule, css, isHTML);
                   3454:   if (ptr == cssRule)
                   3455:     cssRule = SkipValue ("Invalid font-variant value", cssRule);
                   3456:   return (cssRule);
1.1       cvs      3457: }
                   3458: 
                   3459: 
                   3460: /*----------------------------------------------------------------------
1.327     vatton   3461:   ParseACSSFontStyle: parse a CSS font style string     
                   3462:   we expect the input string describing the attribute to be     
                   3463:   normal, italic, oblique or inherit                         
1.1       cvs      3464:   ----------------------------------------------------------------------*/
1.263     vatton   3465: static char *ParseACSSFontStyle (Element element, PSchema tsch,
1.327     vatton   3466:                                  PresentationContext context, char *cssRule,
                   3467:                                  CSSInfoPtr css, ThotBool isHTML)
1.1       cvs      3468: {
1.327     vatton   3469:   PresentationValue   style;
                   3470:   PresentationValue   size;
1.366     vatton   3471:   PresentationValue   previous_size;
                   3472:   char               *ptr;
1.1       cvs      3473: 
1.327     vatton   3474:   style.typed_data.value = 0;
                   3475:   style.typed_data.unit = UNIT_REL;
                   3476:   style.typed_data.real = FALSE;
                   3477:   size.typed_data.value = 0;
                   3478:   size.typed_data.unit = UNIT_REL;
                   3479:   size.typed_data.real = FALSE;
                   3480:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   3481:   ptr = cssRule;
1.327     vatton   3482:   if (!strncasecmp (cssRule, "italic", 6))
                   3483:     {
                   3484:       style.typed_data.value = StyleItalics;
                   3485:       cssRule = SkipWord (cssRule);
                   3486:     }
                   3487:   else if (!strncasecmp (cssRule, "oblique", 7))
                   3488:     {
                   3489:       style.typed_data.value = StyleOblique;
                   3490:       cssRule = SkipWord (cssRule);
                   3491:     }
                   3492:   else if (!strncasecmp (cssRule, "normal", 6))
                   3493:     {
                   3494:       style.typed_data.value = StyleRoman;
                   3495:       cssRule = SkipWord (cssRule);
                   3496:     }
                   3497:   else if (!strncasecmp (cssRule, "inherit", 7))
                   3498:     {
                   3499:       style.typed_data.unit = VALUE_INHERIT;
                   3500:       cssRule = SkipWord (cssRule);
                   3501:     }
                   3502:   else
                   3503:     /* invalid font style */
                   3504:     return (cssRule);
                   3505: 
                   3506:   /*
                   3507:    * install the new presentation.
                   3508:    */
1.366     vatton   3509:   if (style.typed_data.value != 0 || style.typed_data.unit == VALUE_INHERIT)
1.327     vatton   3510:     {
1.366     vatton   3511:       if (DoDialog)
                   3512:         DisplayStyleValue ("font-style", ptr, cssRule);
                   3513:       else if (DoApply)
                   3514:         TtaSetStylePresentation (PRStyle, element, tsch, context, style);
1.327     vatton   3515:     }
1.366     vatton   3516:   if (size.typed_data.value != 0)
1.327     vatton   3517:     {
1.366     vatton   3518:       if (DoDialog)
                   3519:         DisplayStyleValue ("font-style", ptr, cssRule);
                   3520:       else if (DoApply)
1.327     vatton   3521:         {
1.366     vatton   3522:           if (!TtaGetStylePresentation (PRSize, element, tsch, context, &previous_size))
                   3523:             {
                   3524:               /* !!!!!!!!!!!!!!!!!!!!!!!! Unit + relative !!!!!!!!!!!!!!!! */
                   3525:               size.typed_data.value += previous_size.typed_data.value;
                   3526:               TtaSetStylePresentation (PRSize, element, tsch, context, size);
                   3527:             }
                   3528:           else
                   3529:             {
                   3530:               size.typed_data.value = 10;
                   3531:               TtaSetStylePresentation (PRSize, element, tsch, context, size);
                   3532:             }
1.327     vatton   3533:         }
                   3534:     }
                   3535:   return (cssRule);
                   3536: }
                   3537: 
                   3538: /*----------------------------------------------------------------------
                   3539:   ParseCSSFontStyle: parse a CSS font style string     
                   3540:   we expect the input string describing the attribute to be     
                   3541:   italic, oblique or normal                         
1.263     vatton   3542:   ----------------------------------------------------------------------*/
                   3543: static char *ParseCSSFontStyle (Element element, PSchema tsch,
1.327     vatton   3544:                                 PresentationContext context, char *cssRule,
                   3545:                                 CSSInfoPtr css, ThotBool isHTML)
1.263     vatton   3546: {
                   3547:   char           *ptr;
                   3548:   
                   3549:   ptr = cssRule;
                   3550:   cssRule = ParseACSSFontStyle (element, tsch, context, cssRule, css, isHTML);
                   3551:   if (ptr == cssRule)
                   3552:     cssRule = SkipValue ("Invalid font-style value", cssRule);
                   3553:   return (cssRule);
                   3554: }
                   3555: 
                   3556: /*----------------------------------------------------------------------
1.59      cvs      3557:   ParseCSSFont: parse a CSS font attribute string
                   3558:   we expect the input string describing the attribute to be
                   3559:   !!!!!!                                  
1.1       cvs      3560:   ----------------------------------------------------------------------*/
1.79      cvs      3561: static char *ParseCSSFont (Element element, PSchema tsch,
1.327     vatton   3562:                            PresentationContext context, char *cssRule,
                   3563:                            CSSInfoPtr css, ThotBool isHTML)
1.1       cvs      3564: {
1.270     vatton   3565:   char           *ptr, *p;
1.366     vatton   3566:   char           *start_value;
1.93      vatton   3567:   int             skippedNL;
1.272     vatton   3568:   ThotBool        variant = FALSE, style = FALSE, weight = FALSE, found; 
1.1       cvs      3569: 
1.82      cvs      3570:   cssRule = SkipBlanksAndComments (cssRule);
                   3571:   if (!strncasecmp (cssRule, "caption", 7))
1.263     vatton   3572:     cssRule += 7;
1.82      cvs      3573:   else if (!strncasecmp (cssRule, "icon", 4))
1.263     vatton   3574:     cssRule += 4;
1.82      cvs      3575:   else if (!strncasecmp (cssRule, "menu", 4))
1.263     vatton   3576:     cssRule += 4;
1.82      cvs      3577:   else if (!strncasecmp (cssRule, "message-box", 11))
1.263     vatton   3578:     cssRule += 11;
1.82      cvs      3579:   else if (!strncasecmp (cssRule, "small-caption", 13))
1.263     vatton   3580:     cssRule += 13;
1.82      cvs      3581:   else if (!strncasecmp (cssRule, "status-bar", 10))
1.263     vatton   3582:     cssRule += 10;
                   3583:   else if (!strncasecmp (cssRule, "inherit", 7))
1.293     quint    3584:     {
                   3585:       ParseACSSFontStyle (element, tsch, context, cssRule, css, isHTML);
                   3586:       ParseACSSFontVariant (element, tsch, context, cssRule, css, isHTML);
                   3587:       ParseACSSFontWeight (element, tsch, context, cssRule, css, isHTML);
                   3588:       ParseACSSFontSize (element, tsch, context, cssRule, css, isHTML, FALSE);
1.366     vatton   3589:       cssRule = SkipBlanksAndComments (cssRule);
                   3590:       start_value = cssRule;
1.293     quint    3591:       ParseACSSFontFamily (element, tsch, context, cssRule, css, isHTML);
                   3592:       cssRule += 7;
1.366     vatton   3593:       if (DoDialog)
                   3594:         DisplayStyleValue ("font-family", start_value, cssRule);
1.293     quint    3595:     }
1.1       cvs      3596:   else
1.43      cvs      3597:     {
1.270     vatton   3598:       ptr = NULL;
                   3599:       p = cssRule;
1.301     vatton   3600:       while (*cssRule != ';' && *cssRule != '}' && *cssRule != EOS && p == cssRule)
1.327     vatton   3601:         {
                   3602:           found = FALSE;
                   3603:           /* style, variant, weight can appear in any order */
                   3604:           ptr = cssRule;
                   3605:           skippedNL = NewLineSkipped;
                   3606:           cssRule = ParseACSSFontStyle (element, tsch, context, cssRule, css, isHTML);
                   3607:           if (ptr != cssRule)
                   3608:             {
                   3609:               skippedNL = NewLineSkipped;
                   3610:               found = TRUE;
                   3611:               style = TRUE;
                   3612:             }
                   3613:           else
                   3614:             NewLineSkipped = skippedNL;
                   3615:           ptr = cssRule;
                   3616:           cssRule = ParseACSSFontVariant (element, tsch, context, cssRule, css, isHTML);
                   3617:           if (ptr != cssRule)
                   3618:             {
                   3619:               skippedNL = NewLineSkipped;
                   3620:               found = TRUE;
                   3621:               variant = TRUE;
                   3622:             }
                   3623:           else
                   3624:             NewLineSkipped = skippedNL;
                   3625:           ptr = cssRule;
                   3626:           cssRule = ParseACSSFontWeight (element, tsch, context, cssRule, css, isHTML);
                   3627:           if (ptr != cssRule)
                   3628:             {
                   3629:               skippedNL = NewLineSkipped;
                   3630:               found = TRUE;
                   3631:               weight = TRUE;
                   3632:             }
                   3633:           else
                   3634:             NewLineSkipped = skippedNL;
                   3635:           cssRule = SkipBlanksAndComments (cssRule);
                   3636:           p = ParseACSSFontSize (element, tsch, context, cssRule, css, isHTML, TRUE);
                   3637:           NewLineSkipped = skippedNL;
                   3638:           if (!found)
                   3639:             /* break the loop when the current value was not parsed */
                   3640:             p = cssRule + 1;
                   3641:         }
1.263     vatton   3642:       ptr = cssRule;
1.270     vatton   3643:       /* set default variant, style, weight */
                   3644:       if (!variant)
1.327     vatton   3645:         ParseACSSFontVariant (element, tsch, context, "normal", css, isHTML);
1.270     vatton   3646:       if (!style)
1.327     vatton   3647:         ParseACSSFontStyle (element, tsch, context, "normal", css, isHTML);
1.270     vatton   3648:       if (!weight)
1.327     vatton   3649:         ParseACSSFontWeight (element, tsch, context, "normal", css, isHTML);
1.270     vatton   3650:       /* now parse the font size and the font family */
1.301     vatton   3651:       if (*cssRule != ';' && *cssRule != '}' && *cssRule != EOS)
1.327     vatton   3652:         cssRule = ParseACSSFontSize (element, tsch, context, cssRule, css, isHTML, FALSE);
1.301     vatton   3653:       if (*cssRule != ';' && *cssRule != '}' && *cssRule != EOS)
1.366     vatton   3654:         {
                   3655:           cssRule = SkipBlanksAndComments (cssRule);
                   3656:           start_value = cssRule;
                   3657:           cssRule = ParseACSSFontFamily (element, tsch, context, cssRule, css, isHTML);
                   3658:           if (DoDialog)
                   3659:             DisplayStyleValue ("font-family", start_value, cssRule);
                   3660:         }
1.263     vatton   3661:       if (ptr == cssRule)
1.360     vatton   3662:         cssRule = SkipValue ("Invalid font value", cssRule);
1.43      cvs      3663:     }
1.263     vatton   3664:   cssRule = SkipBlanksAndComments (cssRule);
1.301     vatton   3665:   if (*cssRule != ';' && *cssRule != '}' && *cssRule != EOS)
1.360     vatton   3666:     cssRule = SkipValue ("Invalid font value", cssRule);
1.43      cvs      3667:   return (cssRule);
1.1       cvs      3668: }
                   3669: 
                   3670: /*----------------------------------------------------------------------
1.356     quint    3671:   ParseCSSTextDecoration: parse a CSS text-decoration value.
                   3672:   We expect the input string to be none, inherit or a combination of
                   3673:   underline, overline, line-through, and blink.
1.1       cvs      3674:   ----------------------------------------------------------------------*/
1.79      cvs      3675: static char *ParseCSSTextDecoration (Element element, PSchema tsch,
1.327     vatton   3676:                                      PresentationContext context, char *cssRule,
                   3677:                                      CSSInfoPtr css, ThotBool isHTML)
1.1       cvs      3678: {
1.327     vatton   3679:   PresentationValue   decor;
1.366     vatton   3680:   char               *ptr;
1.356     quint    3681:   ThotBool            ok;
1.327     vatton   3682: 
                   3683:   decor.typed_data.value = 0;
                   3684:   decor.typed_data.unit = UNIT_REL;
                   3685:   decor.typed_data.real = FALSE;
                   3686:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   3687:   ptr = cssRule;
1.356     quint    3688:   ok = TRUE;
1.327     vatton   3689:   if (!strncasecmp (cssRule, "none", 4))
                   3690:     {
                   3691:       decor.typed_data.value = NoUnderline;
                   3692:       cssRule += 4;
                   3693:     }
                   3694:   else if (!strncasecmp (cssRule, "inherit", 7))
                   3695:     {
                   3696:       decor.typed_data.unit = VALUE_INHERIT;
                   3697:       cssRule += 7;
                   3698:     }
                   3699:   else
                   3700:     {
1.356     quint    3701:       do
                   3702:         {
                   3703:           if (!strncasecmp (cssRule, "underline", 9))
                   3704:             {
                   3705:               decor.typed_data.value = Underline;
                   3706:               cssRule += 9;
                   3707:             }
                   3708:           else if (!strncasecmp (cssRule, "overline", 8))
                   3709:             {
                   3710:               decor.typed_data.value = Overline;
                   3711:               cssRule += 8;
                   3712:             }
                   3713:           else if (!strncasecmp (cssRule, "line-through", 12))
                   3714:             {
                   3715:               decor.typed_data.value = CrossOut;
                   3716:               cssRule += 12;
                   3717:             }
                   3718:           else if (!strncasecmp (cssRule, "blink", 5))
                   3719:             {
                   3720:               /* the blink text-decoration attribute is not supported */
                   3721:               cssRule += 5;
                   3722:             }
                   3723:           else
                   3724:             ok = FALSE;
                   3725:           if (ok)
                   3726:             {
                   3727:               cssRule = SkipBlanksAndComments (cssRule);
                   3728:             }
                   3729:         }
                   3730:       while (ok && (*cssRule != ';' && *cssRule != '}' && *cssRule != EOS));
                   3731:     }
                   3732:   if (!ok)
                   3733:     {
1.327     vatton   3734:       cssRule = SkipValue ("Invalid text-decoration value", cssRule);
                   3735:       return (cssRule);
                   3736:     }
1.1       cvs      3737: 
1.327     vatton   3738:   /*
                   3739:    * install the new presentation.
                   3740:    */
1.366     vatton   3741:   if (decor.typed_data.value || decor.typed_data.unit == VALUE_INHERIT)
                   3742:     {
                   3743:       if (DoDialog)
                   3744:         DisplayStyleValue ("text-decoration", ptr, cssRule);
                   3745:       else if (DoApply)
                   3746:         TtaSetStylePresentation (PRUnderline, element, tsch, context, decor);
                   3747:     }
1.327     vatton   3748:   cssRule = CSSCheckEndValue (ptr, cssRule, "Invalid text-decoration value");
                   3749:   return (cssRule);
1.1       cvs      3750: }
                   3751: 
                   3752: /*----------------------------------------------------------------------
1.327     vatton   3753:   ParseCSSHeight: parse a CSS height attribute
1.1       cvs      3754:   ----------------------------------------------------------------------*/
1.79      cvs      3755: static char *ParseCSSHeight (Element element, PSchema tsch,
1.327     vatton   3756:                              PresentationContext context, char *cssRule,
                   3757:                              CSSInfoPtr css, ThotBool isHTML)
1.1       cvs      3758: {
1.117     vatton   3759:   PresentationValue   val;
1.168     vatton   3760:   char               *ptr;
1.93      vatton   3761: 
1.117     vatton   3762:   cssRule = SkipBlanksAndComments (cssRule);
1.168     vatton   3763:   ptr = cssRule;
1.117     vatton   3764:   /* first parse the attribute string */
1.164     quint    3765:   if (!strncasecmp (cssRule, "auto", 4))
                   3766:     {
1.184     vatton   3767:       val.typed_data.unit = VALUE_AUTO;
1.164     quint    3768:       val.typed_data.value = 0;
                   3769:       val.typed_data.real = FALSE;
1.288     vatton   3770:       cssRule += 4;
                   3771:       cssRule = CSSCheckEndValue (ptr, cssRule, "Invalid height value");
1.164     quint    3772:     }
1.117     vatton   3773:   else
1.168     vatton   3774:     cssRule = ParseCSSUnit (cssRule, &val);
1.295     vatton   3775: 
1.168     vatton   3776:   if (val.typed_data.value != 0 &&
1.184     vatton   3777:       (val.typed_data.unit == UNIT_INVALID ||
                   3778:        val.typed_data.unit == UNIT_BOX))
1.211     vatton   3779:     {
                   3780:       CSSParseError ("height value", ptr, cssRule);
1.212     cvs      3781:       val.typed_data.unit = UNIT_PX;
1.211     vatton   3782:     }
1.366     vatton   3783: 
                   3784:   if (DoDialog)
                   3785:     DisplayStyleValue ("height", ptr, cssRule);
                   3786:   else if (DoApply)
1.295     vatton   3787:     /* install the new presentation */
                   3788:     TtaSetStylePresentation (PRHeight, element, tsch, context, val);
1.117     vatton   3789:   return (cssRule);
1.1       cvs      3790: }
                   3791: 
                   3792: /*----------------------------------------------------------------------
1.327     vatton   3793:   ParseCSSWidth: parse a CSS width attribute
1.1       cvs      3794:   ----------------------------------------------------------------------*/
1.79      cvs      3795: static char *ParseCSSWidth (Element element, PSchema tsch,
1.327     vatton   3796:                             PresentationContext context,
                   3797:                             char *cssRule, CSSInfoPtr css,
                   3798:                             ThotBool isHTML)
1.1       cvs      3799: {
1.117     vatton   3800:   PresentationValue   val;
1.168     vatton   3801:   char               *ptr;
1.93      vatton   3802: 
1.117     vatton   3803:   cssRule = SkipBlanksAndComments (cssRule);
1.168     vatton   3804:   ptr = cssRule;
1.117     vatton   3805:   /* first parse the attribute string */
1.164     quint    3806:   if (!strncasecmp (cssRule, "auto", 4))
                   3807:     {
1.184     vatton   3808:       val.typed_data.unit = VALUE_AUTO;
1.164     quint    3809:       val.typed_data.value = 0;
                   3810:       val.typed_data.real = FALSE;
1.288     vatton   3811:       cssRule += 4;
                   3812:       cssRule = CSSCheckEndValue (ptr, cssRule, "Invalid width value");
1.164     quint    3813:     }
1.117     vatton   3814:   else
1.327     vatton   3815:     cssRule = ParseCSSUnit (cssRule, &val);
1.168     vatton   3816:   if (val.typed_data.value != 0 &&
1.184     vatton   3817:       (val.typed_data.unit == UNIT_INVALID ||
                   3818:        val.typed_data.unit == UNIT_BOX))
1.211     vatton   3819:     {
                   3820:       CSSParseError ("Invalid width value", ptr, cssRule);
1.212     cvs      3821:       val.typed_data.unit = UNIT_PX;
1.211     vatton   3822:     }
1.295     vatton   3823: 
1.366     vatton   3824:   if (DoDialog)
                   3825:     DisplayStyleValue ("width", ptr, cssRule);
                   3826:   else if (DoApply)
1.295     vatton   3827:     /* install the new presentation */
                   3828:     TtaSetStylePresentation (PRWidth, element, tsch, context, val);
1.117     vatton   3829:   return (cssRule);
1.1       cvs      3830: }
                   3831: 
                   3832: /*----------------------------------------------------------------------
1.327     vatton   3833:   ParseACSSMarginTop: parse a CSS margin-top attribute
1.1       cvs      3834:   ----------------------------------------------------------------------*/
1.296     vatton   3835: static char *ParseACSSMarginTop (Element element, PSchema tsch,
1.327     vatton   3836:                                  PresentationContext context,
                   3837:                                  char *cssRule, CSSInfoPtr css,
                   3838:                                  ThotBool isHTML)
1.1       cvs      3839: {
                   3840:   PresentationValue   margin;
1.168     vatton   3841:   char               *ptr;
1.1       cvs      3842:   
1.82      cvs      3843:   cssRule = SkipBlanksAndComments (cssRule);
1.168     vatton   3844:   ptr = cssRule;
1.1       cvs      3845:   /* first parse the attribute string */
1.164     quint    3846:   if (!strncasecmp (cssRule, "auto", 4))
                   3847:     {
1.184     vatton   3848:       margin.typed_data.unit = VALUE_AUTO;
1.164     quint    3849:       margin.typed_data.value = 0;
                   3850:       margin.typed_data.real = FALSE;
1.288     vatton   3851:       cssRule += 4;
1.164     quint    3852:     }
                   3853:   else
1.168     vatton   3854:     cssRule = ParseCSSUnit (cssRule, &margin);
1.295     vatton   3855: 
1.168     vatton   3856:   if (margin.typed_data.value != 0 &&
1.184     vatton   3857:       (margin.typed_data.unit == UNIT_INVALID ||
                   3858:        margin.typed_data.unit == UNIT_BOX))
1.169     vatton   3859:     CSSParseError ("Invalid margin-top value", ptr, cssRule);
1.366     vatton   3860:   else if (DoDialog)
                   3861:     {
                   3862:       if (All_sides)
                   3863:         DisplayStyleValue ("margin", ptr, cssRule);
                   3864:       else
                   3865:         DisplayStyleValue ("margin-top", ptr, cssRule);
                   3866:     }
1.168     vatton   3867:   else if (DoApply)
1.295     vatton   3868:     TtaSetStylePresentation (PRMarginTop, element, tsch, context, margin);
1.1       cvs      3869:   return (cssRule);
                   3870: }
                   3871: 
                   3872: /*----------------------------------------------------------------------
1.327     vatton   3873:   ParseCSSMarginTop: parse a CSS margin-top attribute
1.296     vatton   3874:   ----------------------------------------------------------------------*/
                   3875: static char *ParseCSSMarginTop (Element element, PSchema tsch,
1.327     vatton   3876:                                 PresentationContext context,
                   3877:                                 char *cssRule, CSSInfoPtr css,
                   3878:                                 ThotBool isHTML)
1.296     vatton   3879: {
                   3880:   char *ptr = cssRule;
                   3881: 
                   3882:   cssRule = ParseACSSMarginTop (element, tsch, context, ptr, css, isHTML);
                   3883:   cssRule = CSSCheckEndValue (ptr, cssRule, "Invalid margin-top value");
                   3884:   return (cssRule);
                   3885: }
                   3886: 
                   3887: /*----------------------------------------------------------------------
                   3888:   ParseACSSMarginBottom: parse a CSS margin-bottom attribute
1.1       cvs      3889:   ----------------------------------------------------------------------*/
1.296     vatton   3890: static char *ParseACSSMarginBottom (Element element, PSchema tsch,
1.327     vatton   3891:                                     PresentationContext context,
                   3892:                                     char *cssRule, CSSInfoPtr css,
                   3893:                                     ThotBool isHTML)
1.1       cvs      3894: {
                   3895:   PresentationValue   margin;
1.168     vatton   3896:   char               *ptr;
1.1       cvs      3897:   
1.82      cvs      3898:   cssRule = SkipBlanksAndComments (cssRule);
1.168     vatton   3899:   ptr = cssRule;
1.1       cvs      3900:   /* first parse the attribute string */
1.164     quint    3901:   if (!strncasecmp (cssRule, "auto", 4))
                   3902:     {
1.184     vatton   3903:       margin.typed_data.unit = VALUE_AUTO;
1.164     quint    3904:       margin.typed_data.value = 0;
                   3905:       margin.typed_data.real = FALSE;
1.288     vatton   3906:       cssRule += 4;
1.164     quint    3907:     }
                   3908:   else
1.168     vatton   3909:     cssRule = ParseCSSUnit (cssRule, &margin);
1.295     vatton   3910: 
1.168     vatton   3911:   if (margin.typed_data.value != 0 &&
1.184     vatton   3912:       (margin.typed_data.unit == UNIT_INVALID ||
                   3913:        margin.typed_data.unit == UNIT_BOX))
1.169     vatton   3914:     CSSParseError ("Invalid margin-bottom value", ptr, cssRule);
1.366     vatton   3915:   else if (DoDialog)
                   3916:     DisplayStyleValue ("margin-bottom", ptr, cssRule);
1.168     vatton   3917:   else if (DoApply)
1.295     vatton   3918:     TtaSetStylePresentation (PRMarginBottom, element, tsch, context, margin);
1.1       cvs      3919:   return (cssRule);
                   3920: }
                   3921: 
                   3922: /*----------------------------------------------------------------------
1.296     vatton   3923:   ParseCSSMarginBottom: parse a CSS margin-bottom attribute
                   3924:   ----------------------------------------------------------------------*/
                   3925: static char *ParseCSSMarginBottom (Element element, PSchema tsch,
1.327     vatton   3926:                                    PresentationContext context,
                   3927:                                    char *cssRule, CSSInfoPtr css,
                   3928:                                    ThotBool isHTML)
1.296     vatton   3929: {
                   3930:   char *ptr = cssRule;
                   3931: 
                   3932:   cssRule = ParseACSSMarginBottom (element, tsch, context, ptr, css, isHTML);
                   3933:   cssRule = CSSCheckEndValue (ptr, cssRule, "Invalid margin-bottom value");
                   3934:   return (cssRule);
                   3935: }
                   3936: 
                   3937: /*----------------------------------------------------------------------
                   3938:   ParseACSSMarginLeft: parse a CSS margin-left attribute string
1.1       cvs      3939:   ----------------------------------------------------------------------*/
1.296     vatton   3940: static char *ParseACSSMarginLeft (Element element, PSchema tsch,
1.327     vatton   3941:                                   PresentationContext context,
                   3942:                                   char *cssRule, CSSInfoPtr css,
                   3943:                                   ThotBool isHTML)
1.1       cvs      3944: {
                   3945:   PresentationValue   margin;
1.168     vatton   3946:   char               *ptr;
1.1       cvs      3947:   
1.82      cvs      3948:   cssRule = SkipBlanksAndComments (cssRule);
1.168     vatton   3949:   ptr = cssRule;
1.1       cvs      3950:   /* first parse the attribute string */
1.164     quint    3951:   if (!strncasecmp (cssRule, "auto", 4))
                   3952:     {
1.184     vatton   3953:       margin.typed_data.unit = VALUE_AUTO;
1.164     quint    3954:       margin.typed_data.value = 0;
                   3955:       margin.typed_data.real = FALSE;
1.288     vatton   3956:       cssRule += 4;
1.164     quint    3957:     }
                   3958:   else
1.168     vatton   3959:     cssRule = ParseCSSUnit (cssRule, &margin);
1.295     vatton   3960: 
1.168     vatton   3961:   if (margin.typed_data.value != 0 &&
1.184     vatton   3962:       (margin.typed_data.unit == UNIT_INVALID ||
                   3963:        margin.typed_data.unit == UNIT_BOX))
1.169     vatton   3964:     CSSParseError ("Invalid margin-left value", ptr, cssRule);
1.366     vatton   3965:   else if (DoDialog)
                   3966:     DisplayStyleValue ("margin-left", ptr, cssRule);
1.295     vatton   3967:   else if (DoApply && margin.typed_data.unit != UNIT_INVALID && DoApply)
1.327     vatton   3968:     TtaSetStylePresentation (PRMarginLeft, element, tsch, context, margin);
1.1       cvs      3969:   return (cssRule);
                   3970: }
                   3971: 
                   3972: /*----------------------------------------------------------------------
1.296     vatton   3973:   ParseCSSMarginBottom: parse a CSS margin-bottom attribute
                   3974:   ----------------------------------------------------------------------*/
                   3975: static char *ParseCSSMarginLeft (Element element, PSchema tsch,
1.327     vatton   3976:                                  PresentationContext context,
                   3977:                                  char *cssRule, CSSInfoPtr css,
                   3978:                                  ThotBool isHTML)
1.296     vatton   3979: {
                   3980:   char *ptr = cssRule;
                   3981: 
                   3982:   cssRule = ParseACSSMarginLeft (element, tsch, context, ptr, css, isHTML);
                   3983:   cssRule = CSSCheckEndValue (ptr, cssRule, "Invalid margin-left value");
                   3984:   return (cssRule);
                   3985: }
                   3986: 
                   3987: 
                   3988: /*----------------------------------------------------------------------
                   3989:   ParseACSSMarginRight: parse a CSS margin-right attribute string
1.1       cvs      3990:   ----------------------------------------------------------------------*/
1.296     vatton   3991: static char *ParseACSSMarginRight (Element element, PSchema tsch,
1.327     vatton   3992:                                    PresentationContext context,
                   3993:                                    char *cssRule, CSSInfoPtr css,
                   3994:                                    ThotBool isHTML)
1.1       cvs      3995: {
                   3996:   PresentationValue   margin;
1.168     vatton   3997:   char               *ptr;
1.1       cvs      3998:   
1.82      cvs      3999:   cssRule = SkipBlanksAndComments (cssRule);
1.168     vatton   4000:   ptr = cssRule;
1.1       cvs      4001:   /* first parse the attribute string */
1.164     quint    4002:   if (!strncasecmp (cssRule, "auto", 4))
                   4003:     {
1.184     vatton   4004:       margin.typed_data.unit = VALUE_AUTO;
1.164     quint    4005:       margin.typed_data.value = 0;
                   4006:       margin.typed_data.real = FALSE;
1.288     vatton   4007:       cssRule += 4;
1.164     quint    4008:     }
                   4009:   else
1.168     vatton   4010:     cssRule = ParseCSSUnit (cssRule, &margin);
1.295     vatton   4011: 
1.168     vatton   4012:   if (margin.typed_data.value != 0 &&
1.184     vatton   4013:       (margin.typed_data.unit == UNIT_INVALID ||
                   4014:        margin.typed_data.unit == UNIT_BOX))
1.169     vatton   4015:     CSSParseError ("Invalid margin-right value", ptr, cssRule);
1.366     vatton   4016:   else if (DoDialog)
                   4017:     DisplayStyleValue ("margin-right", ptr, cssRule);
1.168     vatton   4018:   else if (DoApply)
1.295     vatton   4019:     TtaSetStylePresentation (PRMarginRight, element, tsch, context, margin);
1.1       cvs      4020:   return (cssRule);
                   4021: }
                   4022: 
                   4023: /*----------------------------------------------------------------------
1.296     vatton   4024:   ParseCSSMarginRight: parse a CSS margin-right attribute string
                   4025:   ----------------------------------------------------------------------*/
                   4026: static char *ParseCSSMarginRight (Element element, PSchema tsch,
1.327     vatton   4027:                                   PresentationContext context,
                   4028:                                   char *cssRule, CSSInfoPtr css,
                   4029:                                   ThotBool isHTML)
1.296     vatton   4030: {
                   4031:   char *ptr = cssRule;
                   4032: 
1.297     vatton   4033:   cssRule = ParseACSSMarginRight (element, tsch, context, ptr, css, isHTML);
1.296     vatton   4034:   cssRule = CSSCheckEndValue (ptr, cssRule, "Invalid margin-right value");
                   4035:   return (cssRule);
                   4036: }
                   4037: 
                   4038: /*----------------------------------------------------------------------
1.59      cvs      4039:   ParseCSSMargin: parse a CSS margin attribute string
1.1       cvs      4040:   ----------------------------------------------------------------------*/
1.79      cvs      4041: static char *ParseCSSMargin (Element element, PSchema tsch,
1.327     vatton   4042:                              PresentationContext context,
                   4043:                              char *cssRule, CSSInfoPtr css,
                   4044:                              ThotBool isHTML)
1.1       cvs      4045: {
1.79      cvs      4046:   char *ptrT, *ptrR, *ptrB, *ptrL;
1.366     vatton   4047:   int   skippedNL, n;
1.1       cvs      4048: 
1.82      cvs      4049:   ptrT = SkipBlanksAndComments (cssRule);
1.366     vatton   4050:   if (DoDialog)
                   4051:     n = NumberOfValues (ptrT);
                   4052:   if (DoDialog && n < 2)
1.1       cvs      4053:     {
1.366     vatton   4054:       // check if the margin dialog must be updated
                   4055:       All_sides = TRUE;
                   4056:       ptrR = ParseACSSMarginTop (element, tsch, context, ptrT, css, isHTML);
                   4057:       All_sides = FALSE;
1.1       cvs      4058:     }
                   4059:   else
                   4060:     {
1.366     vatton   4061:       /* First parse Margin-Top */
                   4062:       ptrR = ParseACSSMarginTop (element, tsch, context, ptrT, css, isHTML);
                   4063:       ptrR = SkipBlanksAndComments (ptrR);
                   4064:       if (*ptrR == ';' || *ptrR == '}' || *ptrR == EOS || *ptrR == ',')
1.327     vatton   4065:         {
                   4066:           skippedNL = NewLineSkipped;
1.366     vatton   4067:           cssRule = ptrR;
                   4068:           /* apply the Margin-Top to all */
                   4069:           ptrR = ParseACSSMarginRight (element, tsch, context, ptrT, css, isHTML);
1.327     vatton   4070:           NewLineSkipped = skippedNL;
1.366     vatton   4071:           ptrR = ParseACSSMarginBottom (element, tsch, context, ptrT, css, isHTML);
                   4072:           NewLineSkipped = skippedNL;
                   4073:           ptrR = ParseACSSMarginLeft (element, tsch, context, ptrT, css, isHTML);
1.327     vatton   4074:         }
1.1       cvs      4075:       else
1.327     vatton   4076:         {
1.366     vatton   4077:           /* parse Margin-Right */
                   4078:           ptrB = ParseACSSMarginRight (element, tsch, context, ptrR, css, isHTML);
                   4079:           ptrB = SkipBlanksAndComments (ptrB);
                   4080:           if (*ptrB == ';' || *ptrB == '}' || *ptrB == EOS || *ptrB == ',')
1.327     vatton   4081:             {
1.366     vatton   4082:               skippedNL = NewLineSkipped;
                   4083:               cssRule = ptrB;
                   4084:               /* apply the Margin-Top to Margin-Bottom */
                   4085:               ptrB = ParseACSSMarginBottom (element, tsch, context, ptrT, css, isHTML);
                   4086:               NewLineSkipped = skippedNL;
1.327     vatton   4087:               /* apply the Margin-Right to Margin-Left */
1.366     vatton   4088:               ptrB = ParseACSSMarginLeft (element, tsch, context, ptrR, css, isHTML);
1.327     vatton   4089:             }
                   4090:           else
1.366     vatton   4091:             {
                   4092:               /* parse Margin-Bottom */
                   4093:               ptrL = ParseACSSMarginBottom (element, tsch, context, ptrB, css, isHTML);
                   4094:               ptrL = SkipBlanksAndComments (ptrL);
                   4095:               if (*ptrL == ';' || *ptrL == '}' || *ptrL == EOS || *ptrL == ',')
                   4096:                 {
                   4097:                   cssRule = ptrL;
                   4098:                   /* apply the Margin-Right to Margin-Left */
                   4099:                   ptrL = ParseACSSMarginLeft (element, tsch, context, ptrR, css, isHTML);
                   4100:                 }
                   4101:               else
                   4102:                 /* parse Margin-Left */
                   4103:                 cssRule = ParseACSSMarginLeft (element, tsch, context, ptrL, css, isHTML);
                   4104:               cssRule = SkipBlanksAndComments (cssRule);
                   4105:             }
1.327     vatton   4106:         }
1.1       cvs      4107:     }
                   4108:   return (cssRule);
                   4109: }
                   4110: 
                   4111: /*----------------------------------------------------------------------
1.327     vatton   4112:   ParseCSSPaddingTop: parse a CSS PaddingTop attribute string
1.1       cvs      4113:   ----------------------------------------------------------------------*/
1.79      cvs      4114: static char *ParseCSSPaddingTop (Element element, PSchema tsch,
1.327     vatton   4115:                                  PresentationContext context,
                   4116:                                  char *cssRule, CSSInfoPtr css,
                   4117:                                  ThotBool isHTML)
1.1       cvs      4118: {
1.43      cvs      4119:   PresentationValue   padding;
1.168     vatton   4120:   char               *ptr;
1.43      cvs      4121:   
1.82      cvs      4122:   cssRule = SkipBlanksAndComments (cssRule);
1.168     vatton   4123:   ptr = cssRule;
1.43      cvs      4124:   /* first parse the attribute string */
                   4125:   cssRule = ParseCSSUnit (cssRule, &padding);
1.295     vatton   4126: 
1.168     vatton   4127:   if (padding.typed_data.value != 0 &&
1.184     vatton   4128:       (padding.typed_data.unit == UNIT_INVALID ||
                   4129:        padding.typed_data.unit == UNIT_BOX))
1.168     vatton   4130:     {
1.169     vatton   4131:       CSSParseError ("Invalid padding-top value", ptr, cssRule);
1.168     vatton   4132:       padding.typed_data.value = 0;
                   4133:     }
1.366     vatton   4134:   else if (DoDialog)
                   4135:     {
                   4136:       if (All_sides)
                   4137:         DisplayStyleValue ("padding", ptr, cssRule);
                   4138:       else
                   4139:         DisplayStyleValue ("padding-top", ptr, cssRule);
                   4140:     }
1.168     vatton   4141:   else if (DoApply)
1.295     vatton   4142:     TtaSetStylePresentation (PRPaddingTop, element, tsch, context, padding);
1.1       cvs      4143:   return (cssRule);
                   4144: }
                   4145: 
                   4146: /*----------------------------------------------------------------------
1.59      cvs      4147:   ParseCSSPaddingBottom: parse a CSS PaddingBottom attribute string
1.1       cvs      4148:   ----------------------------------------------------------------------*/
1.79      cvs      4149: static char *ParseCSSPaddingBottom (Element element, PSchema tsch,
1.327     vatton   4150:                                     PresentationContext context,
                   4151:                                     char *cssRule, CSSInfoPtr css,
                   4152:                                     ThotBool isHTML)
1.1       cvs      4153: {
1.43      cvs      4154:   PresentationValue   padding;
1.168     vatton   4155:   char               *ptr;
1.43      cvs      4156:   
1.82      cvs      4157:   cssRule = SkipBlanksAndComments (cssRule);
1.168     vatton   4158:   ptr = cssRule;
1.43      cvs      4159:   /* first parse the attribute string */
                   4160:   cssRule = ParseCSSUnit (cssRule, &padding);
1.168     vatton   4161:   if (padding.typed_data.value == 0)
1.184     vatton   4162:     padding.typed_data.unit = UNIT_EM;
1.295     vatton   4163: 
1.168     vatton   4164:   if (padding.typed_data.value != 0 &&
1.184     vatton   4165:       (padding.typed_data.unit == UNIT_INVALID ||
                   4166:        padding.typed_data.unit == UNIT_BOX))
1.168     vatton   4167:     {
1.169     vatton   4168:       CSSParseError ("Invalid padding-bottom value", ptr, cssRule);
1.168     vatton   4169:       padding.typed_data.value = 0;
                   4170:     }
1.366     vatton   4171:   else if (DoDialog)
                   4172:     DisplayStyleValue ("padding-bottom", ptr, cssRule);
1.168     vatton   4173:   else if (DoApply)
1.295     vatton   4174:     TtaSetStylePresentation (PRPaddingBottom, element, tsch, context, padding);
1.1       cvs      4175:   return (cssRule);
                   4176: }
                   4177: 
                   4178: /*----------------------------------------------------------------------
1.59      cvs      4179:   ParseCSSPaddingLeft: parse a CSS PaddingLeft attribute string.
1.1       cvs      4180:   ----------------------------------------------------------------------*/
1.79      cvs      4181: static char *ParseCSSPaddingLeft (Element element, PSchema tsch,
1.327     vatton   4182:                                   PresentationContext context,
                   4183:                                   char *cssRule, CSSInfoPtr css,
                   4184:                                   ThotBool isHTML)
1.1       cvs      4185: {
1.43      cvs      4186:   PresentationValue   padding;
1.168     vatton   4187:   char               *ptr;
1.43      cvs      4188:   
1.82      cvs      4189:   cssRule = SkipBlanksAndComments (cssRule);
1.168     vatton   4190:   ptr = cssRule;
1.43      cvs      4191:   /* first parse the attribute string */
                   4192:   cssRule = ParseCSSUnit (cssRule, &padding);
1.168     vatton   4193:   if (padding.typed_data.value == 0)
1.184     vatton   4194:     padding.typed_data.unit = UNIT_EM;
1.295     vatton   4195: 
1.168     vatton   4196:   if (padding.typed_data.value != 0 &&
1.184     vatton   4197:       (padding.typed_data.unit == UNIT_INVALID ||
                   4198:        padding.typed_data.unit == UNIT_BOX))
1.168     vatton   4199:     {
1.169     vatton   4200:       CSSParseError ("Invalid padding-left value", ptr, cssRule);
1.168     vatton   4201:       padding.typed_data.value = 0;
                   4202:     }
1.366     vatton   4203:   else if (DoDialog)
                   4204:     DisplayStyleValue ("padding-left", ptr, cssRule);
1.168     vatton   4205:   else if (DoApply)
1.295     vatton   4206:     TtaSetStylePresentation (PRPaddingLeft, element, tsch, context, padding);
1.1       cvs      4207:   return (cssRule);
                   4208: }
                   4209: 
                   4210: /*----------------------------------------------------------------------
1.59      cvs      4211:   ParseCSSPaddingRight: parse a CSS PaddingRight attribute string.
1.1       cvs      4212:   ----------------------------------------------------------------------*/
1.79      cvs      4213: static char *ParseCSSPaddingRight (Element element, PSchema tsch,
1.327     vatton   4214:                                    PresentationContext context,
                   4215:                                    char *cssRule, CSSInfoPtr css,
                   4216:                                    ThotBool isHTML)
1.1       cvs      4217: {
1.43      cvs      4218:   PresentationValue   padding;
1.168     vatton   4219:   char               *ptr;
1.43      cvs      4220:   
1.82      cvs      4221:   cssRule = SkipBlanksAndComments (cssRule);
1.168     vatton   4222:   ptr = cssRule;
1.43      cvs      4223:   /* first parse the attribute string */
                   4224:   cssRule = ParseCSSUnit (cssRule, &padding);
1.168     vatton   4225:   if (padding.typed_data.value == 0)
1.184     vatton   4226:     padding.typed_data.unit = UNIT_EM;
1.295     vatton   4227: 
1.168     vatton   4228:   if (padding.typed_data.value != 0 &&
1.184     vatton   4229:       (padding.typed_data.unit == UNIT_INVALID ||
                   4230:        padding.typed_data.unit == UNIT_BOX))
1.168     vatton   4231:     {
1.169     vatton   4232:       CSSParseError ("Invalid padding-right value", ptr, cssRule);
1.168     vatton   4233:       padding.typed_data.value = 0;
                   4234:     }
1.366     vatton   4235:   else if (DoDialog)
                   4236:     DisplayStyleValue ("padding-right", ptr, cssRule);
1.168     vatton   4237:   else if (DoApply)
1.295     vatton   4238:     TtaSetStylePresentation (PRPaddingRight, element, tsch, context, padding);
1.1       cvs      4239:   return (cssRule);
                   4240: }
                   4241: 
                   4242: /*----------------------------------------------------------------------
1.327     vatton   4243:   ParseCSSPadding: parse a CSS padding attribute string. 
1.1       cvs      4244:   ----------------------------------------------------------------------*/
1.79      cvs      4245: static char *ParseCSSPadding (Element element, PSchema tsch,
1.327     vatton   4246:                               PresentationContext context,
                   4247:                               char *cssRule, CSSInfoPtr css,
                   4248:                               ThotBool isHTML)
1.1       cvs      4249: {
1.79      cvs      4250:   char *ptrT, *ptrR, *ptrB, *ptrL;
1.366     vatton   4251:   int   skippedNL, n;
1.43      cvs      4252: 
1.82      cvs      4253:   ptrT = SkipBlanksAndComments (cssRule);
1.366     vatton   4254:   if (DoDialog)
                   4255:     n = NumberOfValues (ptrT);
                   4256:   if (DoDialog && n < 2)
1.43      cvs      4257:     {
1.366     vatton   4258:       // check if the padding dialog must be updated
                   4259:       All_sides = TRUE;
                   4260:       ptrR = ParseCSSPaddingTop (element, tsch, context, ptrT, css, isHTML);
                   4261:       All_sides = FALSE;
1.43      cvs      4262:     }
                   4263:   else
                   4264:     {
1.366     vatton   4265:       /* First parse Padding-Top */
                   4266:       ptrR = ParseCSSPaddingTop (element, tsch, context, ptrT, css, isHTML);
                   4267:       ptrR = SkipBlanksAndComments (ptrR);
                   4268:       if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1.327     vatton   4269:         {
                   4270:           skippedNL = NewLineSkipped;
1.366     vatton   4271:           cssRule = ptrR;
                   4272:           /* apply the Padding-Top to all */
                   4273:           ptrR = ParseCSSPaddingRight (element, tsch, context, ptrT, css, isHTML);
1.327     vatton   4274:           NewLineSkipped = skippedNL;
1.366     vatton   4275:           ptrR = ParseCSSPaddingBottom (element, tsch, context, ptrT, css, isHTML);
                   4276:           NewLineSkipped = skippedNL;
                   4277:           ptrR = ParseCSSPaddingLeft (element, tsch, context, ptrT, css, isHTML);
1.327     vatton   4278:         }
1.43      cvs      4279:       else
1.327     vatton   4280:         {
1.366     vatton   4281:           /* parse Padding-Right */
                   4282:           ptrB = ParseCSSPaddingRight (element, tsch, context, ptrR, css, isHTML);
                   4283:           ptrB = SkipBlanksAndComments (ptrB);
                   4284:           if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
1.327     vatton   4285:             {
1.366     vatton   4286:               skippedNL = NewLineSkipped;
                   4287:               cssRule = ptrB;
                   4288:               /* apply the Padding-Top to Padding-Bottom */
                   4289:               ptrB = ParseCSSPaddingBottom (element, tsch, context, ptrT, css, isHTML);
                   4290:               NewLineSkipped = skippedNL;
1.327     vatton   4291:               /* apply the Padding-Right to Padding-Left */
1.366     vatton   4292:               ptrB = ParseCSSPaddingLeft (element, tsch, context, ptrR, css, isHTML);
1.327     vatton   4293:             }
                   4294:           else
1.366     vatton   4295:             {
                   4296:               /* parse Padding-Bottom */
                   4297:               ptrL = ParseCSSPaddingBottom (element, tsch, context, ptrB, css, isHTML);
                   4298:               ptrL = SkipBlanksAndComments (ptrL);
                   4299:               if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
                   4300:                 {
                   4301:                   cssRule = ptrL;
                   4302:                   /* apply the Padding-Right to Padding-Left */
                   4303:                   ptrL = ParseCSSPaddingLeft (element, tsch, context, ptrR, css, isHTML);
                   4304:                 }
                   4305:               else
                   4306:                 /* parse Padding-Left */
                   4307:                 cssRule = ParseCSSPaddingLeft (element, tsch, context, ptrL, css, isHTML);
                   4308:               cssRule = SkipBlanksAndComments (cssRule);
                   4309:             }
1.327     vatton   4310:         }
1.43      cvs      4311:     }
1.1       cvs      4312:   return (cssRule);
                   4313: }
                   4314: 
                   4315: /*----------------------------------------------------------------------
1.327     vatton   4316:   ParseCSSForeground: parse a CSS foreground attribute 
1.1       cvs      4317:   ----------------------------------------------------------------------*/
1.79      cvs      4318: static char *ParseCSSForeground (Element element, PSchema tsch,
1.327     vatton   4319:                                  PresentationContext context,
                   4320:                                  char *cssRule,
                   4321:                                  CSSInfoPtr css, ThotBool isHTML)
1.1       cvs      4322: {
1.117     vatton   4323:   PresentationValue   best;
1.262     vatton   4324:   char               *p;
1.1       cvs      4325: 
1.366     vatton   4326:   cssRule = SkipBlanksAndComments (cssRule);
1.262     vatton   4327:   p = cssRule;
1.117     vatton   4328:   cssRule = ParseCSSColor (cssRule, &best);
1.366     vatton   4329:   if (best.typed_data.unit != UNIT_INVALID)
1.327     vatton   4330:     {
                   4331:       if (*cssRule != EOS && *cssRule !=';')
                   4332:         {
                   4333:           cssRule = SkipProperty (cssRule, FALSE);
1.366     vatton   4334:           CSSParseError ("Invalid color value", p, cssRule);
1.327     vatton   4335:         }
1.366     vatton   4336:       else if (DoDialog)
                   4337:         DisplayStyleValue ("color", p, cssRule);
                   4338:       else if (DoApply)
1.327     vatton   4339:         /* install the new presentation */
                   4340:         TtaSetStylePresentation (PRForeground, element, tsch, context, best);
                   4341:     }
                   4342:   return (cssRule);
1.1       cvs      4343: }
                   4344: 
                   4345: /*----------------------------------------------------------------------
1.59      cvs      4346:   ParseCSSBackgroundColor: parse a CSS background color attribute 
1.1       cvs      4347:   ----------------------------------------------------------------------*/
1.79      cvs      4348: static char *ParseCSSBackgroundColor (Element element, PSchema tsch,
1.327     vatton   4349:                                       PresentationContext context,
                   4350:                                       char *cssRule,
                   4351:                                       CSSInfoPtr css, ThotBool isHTML)
1.1       cvs      4352: {
                   4353:   PresentationValue     best;
1.366     vatton   4354:   char                 *ptr;
1.1       cvs      4355: 
1.366     vatton   4356:   cssRule = SkipBlanksAndComments (cssRule);
                   4357:   ptr = cssRule;
1.184     vatton   4358:   best.typed_data.unit = UNIT_INVALID;
1.1       cvs      4359:   best.typed_data.real = FALSE;
1.198     vatton   4360:   if (!strncasecmp (cssRule, "transparent", 11))
1.1       cvs      4361:     {
1.184     vatton   4362:       best.typed_data.value = PATTERN_NONE;
                   4363:       best.typed_data.unit = UNIT_REL;
1.295     vatton   4364:       cssRule = SkipWord (cssRule);
1.116     vatton   4365:       if (DoApply)
1.327     vatton   4366:         TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
                   4367:     }
1.1       cvs      4368:   else
                   4369:     {
                   4370:       cssRule = ParseCSSColor (cssRule, &best);
1.366     vatton   4371:       if (best.typed_data.unit != UNIT_INVALID)
1.327     vatton   4372:         {
1.366     vatton   4373:           if (DoDialog)
                   4374:             DisplayStyleValue ("background-color", ptr, cssRule);
                   4375:           else if (DoApply)
                   4376:             {
                   4377:               /* install the new presentation. */
                   4378:               TtaSetStylePresentation (PRBackground, element, tsch, context, best);
                   4379:               /* thot specificity: need to set fill pattern for background color */
                   4380:               best.typed_data.value = PATTERN_BACKGROUND;
                   4381:               best.typed_data.unit = UNIT_REL;
                   4382:               TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
                   4383:               best.typed_data.value = 1;
                   4384:               best.typed_data.unit = UNIT_REL;
                   4385:               TtaSetStylePresentation (PRShowBox, element, tsch, context, best);
                   4386:             }
1.327     vatton   4387:         }
1.1       cvs      4388:     }
                   4389:   return (cssRule);
                   4390: }
                   4391: 
1.63      cvs      4392: /*----------------------------------------------------------------------
1.65      cvs      4393:   ParseSVGStroke: parse a SVG stroke property
                   4394:   ----------------------------------------------------------------------*/
1.79      cvs      4395: static char *ParseSVGStroke (Element element, PSchema tsch,
1.327     vatton   4396:                              PresentationContext context, char *cssRule,
                   4397:                              CSSInfoPtr css, ThotBool isHTML)
1.65      cvs      4398: {
                   4399:   PresentationValue     best;
1.245     quint    4400:   char                  *url;
1.65      cvs      4401: 
1.184     vatton   4402:   best.typed_data.unit = UNIT_INVALID;
1.65      cvs      4403:   best.typed_data.real = FALSE;
1.82      cvs      4404:   if (!strncasecmp (cssRule, "none", 4))
1.65      cvs      4405:     {
                   4406:       best.typed_data.value = -2;  /* -2 means transparent */
1.184     vatton   4407:       best.typed_data.unit = UNIT_REL;
1.65      cvs      4408:       cssRule = SkipWord (cssRule);
                   4409:     }
1.245     quint    4410:   else if (!strncasecmp (cssRule, "currentColor", 12))
                   4411:     {
1.293     quint    4412:       best.typed_data.unit = VALUE_INHERIT;
                   4413:       cssRule = SkipWord (cssRule);
1.245     quint    4414:     }
                   4415:   else if (!strncasecmp (cssRule, "url", 3))
                   4416:     {  
                   4417:       cssRule += 3;
                   4418:       cssRule = ParseCSSUrl (cssRule, &url);
                   4419:       /* **** do something with the url ***** */;
                   4420:       TtaFreeMemory (url);
                   4421:       /* **** caution: another color value may follow the uri (in case
1.327     vatton   4422:          the uri could ne be dereferenced) *** */
1.245     quint    4423:     }
1.65      cvs      4424:   else
1.293     quint    4425:     cssRule = ParseCSSColor (cssRule, &best);
                   4426: 
                   4427:   if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.295     vatton   4428:     /* install the new presentation */
                   4429:     TtaSetStylePresentation (PRForeground, element, tsch, context, best);
1.65      cvs      4430:   return (cssRule);
                   4431: }
                   4432: 
                   4433: /*----------------------------------------------------------------------
1.63      cvs      4434:   ParseSVGFill: parse a SVG fill property
                   4435:   ----------------------------------------------------------------------*/
1.79      cvs      4436: static char *ParseSVGFill (Element element, PSchema tsch,
1.327     vatton   4437:                            PresentationContext context, char *cssRule,
                   4438:                            CSSInfoPtr css, ThotBool isHTML)
1.63      cvs      4439: {
                   4440:   PresentationValue     best;
1.245     quint    4441:   char                  *url;
1.63      cvs      4442: 
1.184     vatton   4443:   best.typed_data.unit = UNIT_INVALID;
1.63      cvs      4444:   best.typed_data.real = FALSE;
1.82      cvs      4445:   if (!strncasecmp (cssRule, "none", 4))
1.63      cvs      4446:     {
1.184     vatton   4447:       best.typed_data.value = PATTERN_NONE;
                   4448:       best.typed_data.unit = UNIT_REL;
1.116     vatton   4449:       if (DoApply)
1.327     vatton   4450:         TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
1.65      cvs      4451:       cssRule = SkipWord (cssRule);
1.294     vatton   4452:       return (cssRule);
1.63      cvs      4453:     }
1.245     quint    4454:   else if (!strncasecmp (cssRule, "currentColor", 12))
                   4455:     {
1.293     quint    4456:       best.typed_data.unit = VALUE_INHERIT;
                   4457:       cssRule = SkipWord (cssRule);
1.245     quint    4458:     }
                   4459:   else if (!strncasecmp (cssRule, "url", 3))
                   4460:     {  
                   4461:       cssRule += 3;
                   4462:       cssRule = ParseCSSUrl (cssRule, &url);
                   4463:       /* **** do something with the url ***** */;
                   4464:       TtaFreeMemory (url);
                   4465:       /* **** caution: another color value may follow the uri (in case
1.327     vatton   4466:          the uri could ne be dereferenced) *** */
1.245     quint    4467:     }
1.63      cvs      4468:   else
1.327     vatton   4469:     cssRule = ParseCSSColor (cssRule, &best);
1.293     quint    4470: 
                   4471:   if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.63      cvs      4472:     {
1.293     quint    4473:       /* install the new presentation. */
                   4474:       TtaSetStylePresentation (PRBackground, element, tsch, context, best);
                   4475:       /* thot specificity: need to set fill pattern for background color */
                   4476:       best.typed_data.value = PATTERN_BACKGROUND;
                   4477:       best.typed_data.unit = UNIT_REL;
                   4478:       TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
1.63      cvs      4479:     }
                   4480:   return (cssRule);
                   4481: }
1.161     quint    4482: 
1.155     cheyroul 4483: /*----------------------------------------------------------------------
1.346     quint    4484:   ParseSVGOpacity: parse a SVG opacity property
1.155     cheyroul 4485:   ----------------------------------------------------------------------*/
                   4486: static char *ParseSVGOpacity (Element element, PSchema tsch,
1.327     vatton   4487:                               PresentationContext context, char *cssRule,
                   4488:                               CSSInfoPtr css, ThotBool isHTML)
1.155     cheyroul 4489: {
                   4490:   PresentationValue     best;
1.63      cvs      4491: 
1.184     vatton   4492:   best.typed_data.unit = UNIT_INVALID;
1.155     cheyroul 4493:   best.typed_data.real = FALSE;
                   4494:   cssRule = ParseClampedUnit (cssRule, &best);
                   4495:   if (DoApply)
1.295     vatton   4496:     /* install the new presentation. */
                   4497:     TtaSetStylePresentation (PROpacity, element, tsch, context, best);
1.155     cheyroul 4498:   return (cssRule);
                   4499: }
1.346     quint    4500: 
1.170     cheyroul 4501: /*----------------------------------------------------------------------
1.346     quint    4502:   ParseSVGStrokeOpacity: parse a SVG stroke-opacity property
1.170     cheyroul 4503:   ----------------------------------------------------------------------*/
                   4504: static char *ParseSVGStrokeOpacity (Element element, PSchema tsch,
1.327     vatton   4505:                                     PresentationContext context, char *cssRule,
                   4506:                                     CSSInfoPtr css, ThotBool isHTML)
1.170     cheyroul 4507: {
                   4508:   PresentationValue     best;
1.161     quint    4509: 
1.184     vatton   4510:   best.typed_data.unit = UNIT_INVALID;
1.170     cheyroul 4511:   best.typed_data.real = FALSE;
                   4512:   cssRule = ParseClampedUnit (cssRule, &best);
                   4513:   if (DoApply)
1.295     vatton   4514:     /* install the new presentation. */
                   4515:     TtaSetStylePresentation (PRStrokeOpacity, element, tsch, context, best);
1.170     cheyroul 4516:   return (cssRule);
                   4517: }
1.346     quint    4518: 
1.170     cheyroul 4519: /*----------------------------------------------------------------------
1.346     quint    4520:   ParseSVGFillOpacity: parse a SVG fil-opacityl property
1.170     cheyroul 4521:   ----------------------------------------------------------------------*/
                   4522: static char *ParseSVGFillOpacity (Element element, PSchema tsch,
1.327     vatton   4523:                                   PresentationContext context, char *cssRule,
                   4524:                                   CSSInfoPtr css, ThotBool isHTML)
1.170     cheyroul 4525: {
                   4526:   PresentationValue     best;
                   4527: 
1.184     vatton   4528:   best.typed_data.unit = UNIT_INVALID;
1.170     cheyroul 4529:   best.typed_data.real = FALSE;
                   4530:   cssRule = ParseClampedUnit (cssRule, &best);
                   4531:   if (DoApply)
1.295     vatton   4532:     /* install the new presentation. */
                   4533:     TtaSetStylePresentation (PRFillOpacity, element, tsch, context, best);
1.170     cheyroul 4534:   return (cssRule);
                   4535: }
1.207     vatton   4536: 
1.1       cvs      4537: /*----------------------------------------------------------------------
1.327     vatton   4538:   GetCSSBackgroundURL searches a CSS BackgroundImage url within
                   4539:   the cssRule.
                   4540:   Returns NULL or a new allocated url string.
1.217     vatton   4541:   ----------------------------------------------------------------------*/
                   4542: char *GetCSSBackgroundURL (char *cssRule)
                   4543: {
                   4544:   char            *b, *url;
                   4545: 
                   4546:   url = NULL;
                   4547:   b = strstr (cssRule, "url");
                   4548:   if (b)
1.290     gully    4549:     b = ParseCSSUrl (b, &url);
1.217     vatton   4550:   return (url);
                   4551: }
                   4552: 
                   4553: /*----------------------------------------------------------------------
1.327     vatton   4554:   ParseCSSContent: parse the value of property "content"
1.217     vatton   4555:   ----------------------------------------------------------------------*/
                   4556: static char *ParseCSSContent (Element element, PSchema tsch,
1.327     vatton   4557:                               PresentationContext ctxt, char *cssRule,
                   4558:                               CSSInfoPtr css, ThotBool isHTML)
1.217     vatton   4559: {
1.312     quint    4560:   PresentationValue   value;
1.353     quint    4561:   char                *last, *start, quoteChar, savedChar;
                   4562:   int                 length, val;
1.366     vatton   4563:   char               *buffer, *p;
                   4564:   char               *start_value;
1.312     quint    4565:   ThotBool            repeat;
                   4566: 
                   4567:   value.typed_data.unit = UNIT_REL;
                   4568:   value.typed_data.real = FALSE;
                   4569:   value.typed_data.value = 0;
1.366     vatton   4570:   if (!DoDialog && DoApply)
1.347     quint    4571:     TtaSetStylePresentation (PRContent, element, tsch, ctxt, value);
1.217     vatton   4572:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   4573:   start_value = cssRule;
1.312     quint    4574:   repeat = TRUE;
                   4575:   while (repeat)
                   4576:     {
1.366     vatton   4577:       p = cssRule;
1.312     quint    4578:       if (!strncasecmp (cssRule, "normal", 6))
1.327     vatton   4579:         /* The pseudo-element is not generated */
                   4580:         {
                   4581:           /* @@@@@@ */
                   4582:           cssRule += 6;
                   4583:           repeat = FALSE;
                   4584:         }
1.331     quint    4585:       else if (!strncasecmp (cssRule, "none", 4))
                   4586:         /* The pseudo-element is not generated */
                   4587:         {
                   4588:           /* @@@@@@ */
                   4589:           cssRule += 4;
                   4590:           repeat = FALSE;
                   4591:         }
1.312     quint    4592:       else if (*cssRule == '"' || *cssRule == '\'')
1.327     vatton   4593:         /* It's a string */
                   4594:         {
                   4595:           quoteChar = *cssRule;
1.353     quint    4596:           /* how long is the string? */
                   4597:           last = cssRule;
                   4598:           last = SkipString (last);
                   4599:           length = last - cssRule;
                   4600:           /* get a buffer to store the string */
1.366     vatton   4601:           buffer = (char *)TtaGetMemory (length);
1.353     quint    4602:           p = buffer; /* beginning of the string */
1.327     vatton   4603:           cssRule++;
                   4604:           while (*cssRule != EOS && *cssRule != quoteChar)
1.353     quint    4605:             {
                   4606:               if (*cssRule == '\\')
                   4607:                 {
                   4608:                   cssRule++; /* skip the backslash */
                   4609:                   if ((*cssRule >= '0' && *cssRule <= '9') ||
                   4610:                       (*cssRule >= 'A' && *cssRule <= 'F') ||
                   4611:                       (*cssRule >= 'a' && *cssRule <= 'f'))
                   4612:                     {
                   4613:                       start = cssRule; /* first hex digit after the backslash*/
                   4614:                       cssRule++;
                   4615:                       while ((*cssRule >= '0' && *cssRule <= '9') ||
                   4616:                              (*cssRule >= 'A' && *cssRule <= 'F') ||
                   4617:                              (*cssRule >= 'a' && *cssRule <= 'f'))
                   4618:                         cssRule++;
                   4619:                       savedChar = *cssRule;
                   4620:                       *cssRule = EOS;
                   4621:                       sscanf (start, "%x", &val);
1.366     vatton   4622:                       TtaWCToMBstring ((wchar_t) val, (unsigned char **) &p);
1.353     quint    4623:                       *cssRule = savedChar;
                   4624:                     }
                   4625:                   else
                   4626:                     {
                   4627:                       *p = *cssRule;
                   4628:                       p++; cssRule++;
                   4629:                     }
                   4630:                 }
                   4631:               else
                   4632:                 {
                   4633:                   *p = *cssRule;
                   4634:                   p++; cssRule++;
                   4635:                 }
                   4636:             }
                   4637:           *p = EOS;
1.366     vatton   4638:           if (DoDialog)
                   4639:             {
                   4640:               DisplayStyleValue ("", start_value, p);
                   4641:               start_value = p;
                   4642:             }
                   4643:           else if (*cssRule != quoteChar)
1.327     vatton   4644:             cssRule = SkipProperty (cssRule, FALSE);
                   4645:           else
                   4646:             {
                   4647:               *cssRule = EOS;
                   4648:               value.typed_data.unit = UNIT_REL;
                   4649:               value.typed_data.real = FALSE;
1.353     quint    4650:               value.pointer = buffer;
1.347     quint    4651:               if (DoApply)
                   4652:                 TtaSetStylePresentation (PRContentString, element, tsch, ctxt,
                   4653:                                          value);
1.327     vatton   4654:               *cssRule = quoteChar;
                   4655:               cssRule++;
                   4656:             }
1.353     quint    4657:           TtaFreeMemory (buffer);
1.327     vatton   4658:         }
1.312     quint    4659:       else if (!strncasecmp (cssRule, "url", 3))
1.327     vatton   4660:         {  
                   4661:           cssRule += 3;
1.347     quint    4662:           cssRule = SetCSSImage (element, tsch, ctxt, cssRule, css,
                   4663:                                  PRContentURL);
1.366     vatton   4664:           if (DoDialog)
                   4665:             {
                   4666:               DisplayStyleValue ("", start_value, p);
                   4667:               start_value = p;
                   4668:             }
1.327     vatton   4669:         }
1.312     quint    4670:       else if (!strncasecmp (cssRule, "counter", 7))
1.327     vatton   4671:         {
                   4672:           cssRule += 7;
                   4673:           /* @@@@@@ */
1.366     vatton   4674:           if (DoDialog)
                   4675:             {
                   4676:               DisplayStyleValue ("", start_value, p);
                   4677:               start_value = p;
                   4678:             }
                   4679:           else
                   4680:             cssRule = SkipProperty (cssRule, FALSE);
1.327     vatton   4681:         }
1.312     quint    4682:       else if (!strncasecmp (cssRule, "counters", 8))
1.327     vatton   4683:         {
                   4684:           cssRule += 8;
                   4685:           /* @@@@@@ */
1.366     vatton   4686:           if (DoDialog)
                   4687:             {
                   4688:               DisplayStyleValue ("", start_value, p);
                   4689:               start_value = p;
                   4690:             }
                   4691:           else
                   4692:             cssRule = SkipProperty (cssRule, FALSE);
1.327     vatton   4693:         }
1.312     quint    4694:       else if (!strncasecmp (cssRule, "attr", 4))
1.327     vatton   4695:         {
1.347     quint    4696:           value.pointer = NULL;
1.327     vatton   4697:           cssRule += 4;
1.347     quint    4698:           cssRule = SkipBlanksAndComments (cssRule);
                   4699:           if (*cssRule == '(')
                   4700:             {
                   4701:               cssRule++;
                   4702:               cssRule = SkipBlanksAndComments (cssRule);
                   4703:               start = cssRule;
                   4704:               while (*cssRule != EOS && *cssRule != ')')
                   4705:                 cssRule++;
                   4706:               if (*cssRule != ')')
                   4707:                 cssRule = start;
                   4708:               else
                   4709:                 {
                   4710:                   last = cssRule;
                   4711:                   /* remove extra spaces */
                   4712:                   if (last[-1] == SPACE)
                   4713:                     {
                   4714:                       *last = SPACE;
                   4715:                       last--;
                   4716:                       while (last[-1] == SPACE)
                   4717:                         last--;
                   4718:                     }
                   4719:                   savedChar = *last;
                   4720:                   *last = EOS;
                   4721:                   value.typed_data.unit = UNIT_REL;
                   4722:                   value.typed_data.real = FALSE;
                   4723:                   value.pointer = start;
1.366     vatton   4724:                   if (DoDialog)
                   4725:                     {
                   4726:                       DisplayStyleValue ("", start_value, p);
                   4727:                       start_value = p;
                   4728:                     }
                   4729:                   else if (DoApply)
1.347     quint    4730:                     TtaSetStylePresentation (PRContentAttr, element, tsch,
                   4731:                                              ctxt, value);
                   4732:                   *last = savedChar;
                   4733:                 }
                   4734:             }
                   4735:           if (value.pointer == NULL)
                   4736:             {
1.353     quint    4737:               CSSParseError ("Invalid content value", (char*) p, cssRule);
1.366     vatton   4738:               if (DoDialog)
                   4739:                 {
                   4740:                   DisplayStyleValue ("", start_value, p);
                   4741:                   start_value = p;
                   4742:                 }
                   4743:               else
                   4744:                 cssRule = SkipProperty (cssRule, FALSE);
1.347     quint    4745:             }
                   4746:           cssRule++;
1.327     vatton   4747:         }
1.312     quint    4748:       else if (!strncasecmp (cssRule, "open-quote", 10))
1.327     vatton   4749:         {
                   4750:           cssRule += 10;
                   4751:           /* @@@@@@ */
                   4752:         }
1.312     quint    4753:       else if (!strncasecmp (cssRule, "close-quote", 11))
1.327     vatton   4754:         {
                   4755:           cssRule += 11;
                   4756:           /* @@@@@@ */
                   4757:         }
1.312     quint    4758:       else if (!strncasecmp (cssRule, "no-open-quote", 13))
1.327     vatton   4759:         {
                   4760:           cssRule += 13;
                   4761:           /* @@@@@@ */
                   4762:         }
1.312     quint    4763:       else if (!strncasecmp (cssRule, "no-close-quote", 14))
1.327     vatton   4764:         {
                   4765:           cssRule += 14;
                   4766:           /* @@@@@@ */
                   4767:         }
1.312     quint    4768:       else if (!strncasecmp (cssRule, "inherit", 7))
1.327     vatton   4769:         {
                   4770:           cssRule += 7;
                   4771:           /* @@@@@@ */
                   4772:           repeat = FALSE;
                   4773:         }
1.312     quint    4774:       else
1.327     vatton   4775:         {
1.353     quint    4776:           CSSParseError ("Invalid content value", (char*) p, cssRule);
1.366     vatton   4777:           if (DoDialog)
                   4778:             {
                   4779:               DisplayStyleValue ("", start_value, p);
                   4780:               start_value = p;
                   4781:             }
                   4782:           else
                   4783:             cssRule = SkipProperty (cssRule, FALSE);
1.327     vatton   4784:         }
1.312     quint    4785:       cssRule = SkipBlanksAndComments (cssRule);
                   4786:       if (repeat)
1.327     vatton   4787:         if (*cssRule == ';' || *cssRule == '}' || *cssRule == EOS ||
                   4788:             *cssRule == '!')
                   4789:           repeat = FALSE;
1.217     vatton   4790:     }
                   4791:   return (cssRule);
                   4792: }
1.1       cvs      4793: 
                   4794: /*----------------------------------------------------------------------
1.59      cvs      4795:   ParseCSSBackgroundImage: parse a CSS BackgroundImage attribute string.
1.1       cvs      4796:   ----------------------------------------------------------------------*/
1.79      cvs      4797: static char *ParseCSSBackgroundImage (Element element, PSchema tsch,
1.327     vatton   4798:                                       PresentationContext ctxt,
                   4799:                                       char *cssRule, CSSInfoPtr css,
                   4800:                                       ThotBool isHTML)
1.1       cvs      4801: {
1.49      cvs      4802:   PresentationValue          image, value;
1.357     quint    4803:   char                       *ptr;
1.148     vatton   4804: 
1.82      cvs      4805:   cssRule = SkipBlanksAndComments (cssRule);
1.357     quint    4806:   ptr = cssRule;
1.161     quint    4807:   if (!strncasecmp (cssRule, "none", 4))
                   4808:     {
1.260     vatton   4809:       cssRule += 4;
1.366     vatton   4810:       if (DoDialog)
                   4811:         DisplayStyleValue ("background-image", ptr, cssRule);
                   4812:       else if (DoApply)
1.327     vatton   4813:         {
                   4814:           /* no background image */
                   4815:           image.pointer = NULL;
                   4816:           TtaSetStylePresentation (PRBackgroundPicture, element, tsch, ctxt,
                   4817:                                    image);
                   4818:         }
1.161     quint    4819:     }
1.357     quint    4820:   else if (!strncasecmp (cssRule, "inherit", 7))
                   4821:     {
                   4822:       value.typed_data.unit = VALUE_INHERIT;
                   4823:       cssRule += 7;
1.366     vatton   4824:       if (DoDialog)
                   4825:         DisplayStyleValue ("background-image", ptr, cssRule);
1.357     quint    4826:     }
1.161     quint    4827:   else if (!strncasecmp (cssRule, "url", 3))
1.1       cvs      4828:     {  
                   4829:       cssRule += 3;
1.302     quint    4830:       cssRule = SetCSSImage (element, tsch, ctxt, cssRule, css,
1.327     vatton   4831:                              PRBackgroundPicture);
1.207     vatton   4832:       if (ctxt->destroy)
1.327     vatton   4833:         if (TtaGetStylePresentation (PRFillPattern, element, tsch, ctxt,
                   4834:                                      &value) < 0)
                   4835:           {
                   4836:             /* there is no FillPattern rule -> remove ShowBox rule */
                   4837:             value.typed_data.value = 1;
                   4838:             value.typed_data.unit = UNIT_REL;
                   4839:             value.typed_data.real = FALSE;
                   4840:             TtaSetStylePresentation (PRShowBox, element, tsch, ctxt, value);
                   4841:           }
1.18      cvs      4842:     }
1.357     quint    4843:   else
                   4844:     {
                   4845:       cssRule = SkipWord (cssRule);
                   4846:       CSSParseError ("Invalid background-image value", ptr, cssRule);
                   4847:       cssRule = SkipProperty (cssRule, FALSE);
                   4848:     }
1.18      cvs      4849:   return (cssRule);
                   4850: }
                   4851: 
                   4852: /*----------------------------------------------------------------------
1.295     vatton   4853:   ParseACSSBackgroundRepeat: parse a CSS BackgroundRepeat attribute string.
1.18      cvs      4854:   ----------------------------------------------------------------------*/
1.295     vatton   4855: static char *ParseACSSBackgroundRepeat (Element element, PSchema tsch,
1.327     vatton   4856:                                         PresentationContext ctxt,
                   4857:                                         char *cssRule, CSSInfoPtr css, ThotBool isHTML)
1.18      cvs      4858: {
                   4859:   PresentationValue   repeat;
1.366     vatton   4860:   char               *start_value;
1.18      cvs      4861: 
1.366     vatton   4862:   cssRule = SkipBlanksAndComments (cssRule);
                   4863:   start_value = cssRule;
1.184     vatton   4864:   repeat.typed_data.value = REALSIZE;
1.191     vatton   4865:   repeat.typed_data.unit = UNIT_BOX;
1.18      cvs      4866:   repeat.typed_data.real = FALSE;
1.82      cvs      4867:   cssRule = SkipBlanksAndComments (cssRule);
                   4868:   if (!strncasecmp (cssRule, "no-repeat", 9))
1.184     vatton   4869:     repeat.typed_data.value = REALSIZE;
1.82      cvs      4870:   else if (!strncasecmp (cssRule, "repeat-y", 8))
1.265     vatton   4871:     repeat.typed_data.value = YREPEAT;
1.82      cvs      4872:   else if (!strncasecmp (cssRule, "repeat-x", 8))
1.265     vatton   4873:     repeat.typed_data.value = XREPEAT;
1.82      cvs      4874:   else if (!strncasecmp (cssRule, "repeat", 6))
1.184     vatton   4875:     repeat.typed_data.value = REPEAT;
1.18      cvs      4876:   else
                   4877:     return (cssRule);
                   4878: 
1.295     vatton   4879:   cssRule = SkipWord (cssRule);
                   4880:   /* check if it's an important rule */
1.366     vatton   4881:   if (DoDialog)
                   4882:     DisplayStyleValue ("background-repeat", start_value, cssRule);
                   4883:   else if (DoApply)
1.295     vatton   4884:     /* install the new presentation */
1.362     quint    4885:     TtaSetStylePresentation (PRBackgroundRepeat, element, tsch, ctxt, repeat);
1.295     vatton   4886:   return (cssRule);
                   4887: }
                   4888: 
                   4889: /*----------------------------------------------------------------------
                   4890:   ParseCSSBackgroundRepeat: parse a CSS BackgroundRepeat attribute string.
                   4891:   ----------------------------------------------------------------------*/
                   4892: static char *ParseCSSBackgroundRepeat (Element element, PSchema tsch,
1.315     gully    4893:                                        PresentationContext ctxt,
                   4894:                                        char *cssRule, CSSInfoPtr css,
                   4895:                                        ThotBool isHTML)
1.295     vatton   4896: {
                   4897:   cssRule = ParseACSSBackgroundRepeat (element, tsch, ctxt,
1.315     gully    4898:                                        cssRule, css, isHTML);
                   4899:   if (cssRule)
1.117     vatton   4900:     {
1.295     vatton   4901:       cssRule = SkipValue ("Invalid background-repeat value", cssRule);
1.117     vatton   4902:       /* check if it's an important rule */
                   4903:     }
1.295     vatton   4904:   return cssRule;
1.18      cvs      4905: }
                   4906: 
                   4907: /*----------------------------------------------------------------------
1.327     vatton   4908:   ParseACSSBackgroundAttachment: parse a CSS BackgroundAttachment
                   4909:   attribute string.                                          
1.18      cvs      4910:   ----------------------------------------------------------------------*/
1.295     vatton   4911: static char *ParseACSSBackgroundAttachment (Element element, PSchema tsch,
1.327     vatton   4912:                                             PresentationContext ctxt,
                   4913:                                             char *cssRule, CSSInfoPtr css,
                   4914:                                             ThotBool isHTML)
1.18      cvs      4915: {
1.366     vatton   4916:   char               *start_value;
                   4917: 
1.163     quint    4918:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   4919:   start_value = cssRule;
1.163     quint    4920:   if (!strncasecmp (cssRule, "scroll", 6))
1.199     vatton   4921:     {
                   4922:       cssRule = SkipWord (cssRule);
                   4923:     }
1.163     quint    4924:   else if (!strncasecmp (cssRule, "fixed", 5))
1.199     vatton   4925:     {
                   4926:       cssRule = SkipWord (cssRule);
                   4927:     }
1.362     quint    4928:   else if (!strncasecmp (cssRule, "inherit", 7))
                   4929:     {
                   4930:       cssRule = SkipWord (cssRule);
                   4931:     }
1.366     vatton   4932:   if (start_value != cssRule && DoDialog)
                   4933:     DisplayStyleValue ("background-attachment", start_value, cssRule);
1.163     quint    4934:   return (cssRule);
1.1       cvs      4935: }
                   4936: 
                   4937: /*----------------------------------------------------------------------
1.327     vatton   4938:   ParseCSSBackgroundAttachment: parse a CSS BackgroundAttachment
                   4939:   attribute string.                                          
1.295     vatton   4940:   ----------------------------------------------------------------------*/
                   4941: static char *ParseCSSBackgroundAttachment (Element element, PSchema tsch,
1.327     vatton   4942:                                            PresentationContext ctxt,
                   4943:                                            char *cssRule, CSSInfoPtr css,
                   4944:                                            ThotBool isHTML)
1.295     vatton   4945: {
                   4946:   char     *ptr;
                   4947: 
                   4948:   ptr = cssRule;
                   4949:   cssRule = ParseACSSBackgroundAttachment (element, tsch, ctxt,
1.327     vatton   4950:                                            cssRule, css, isHTML);
1.295     vatton   4951:   if (ptr == cssRule)
1.366     vatton   4952:     cssRule = SkipValue ("Invalid background-attachment value", cssRule);
1.295     vatton   4953:   return cssRule;
                   4954: }
                   4955: 
                   4956: /*----------------------------------------------------------------------
1.327     vatton   4957:   ParseACSSBackgroundPosition: parse a CSS BackgroundPosition
                   4958:   attribute string.                                          
1.1       cvs      4959:   ----------------------------------------------------------------------*/
1.279     vatton   4960: static char *ParseACSSBackgroundPosition (Element element, PSchema tsch,
1.327     vatton   4961:                                           PresentationContext ctxt,
                   4962:                                           char *cssRule, CSSInfoPtr css,
1.362     quint    4963:                                           ThotBool isHTML, ThotBool *across)
1.1       cvs      4964: {
1.362     quint    4965:   PresentationValue   val;
                   4966:   char               *ptr;
1.1       cvs      4967: 
1.163     quint    4968:   cssRule = SkipBlanksAndComments (cssRule);
1.362     quint    4969:   ptr = cssRule;
                   4970:   val.typed_data.value = 0;
                   4971:   val.typed_data.real = FALSE;
                   4972:   val.typed_data.unit = UNIT_INVALID;
1.163     quint    4973:   if (!strncasecmp (cssRule, "left", 4))
1.362     quint    4974:     {
                   4975:       val.typed_data.value = 0;
                   4976:       val.typed_data.unit = UNIT_PERCENT;
                   4977:       cssRule += 4;
                   4978:       *across = TRUE;
                   4979:     }
1.163     quint    4980:   else if (!strncasecmp (cssRule, "right", 5))
1.362     quint    4981:     {
                   4982:       val.typed_data.value = 100;
                   4983:       val.typed_data.unit = UNIT_PERCENT;
                   4984:       cssRule += 5;
                   4985:       *across = TRUE;
                   4986:     }
1.163     quint    4987:   else if (!strncasecmp (cssRule, "center", 6))
1.362     quint    4988:     {
                   4989:       val.typed_data.value = 50;
                   4990:       val.typed_data.unit = UNIT_PERCENT;
                   4991:       cssRule += 6;
                   4992:     }
1.163     quint    4993:   else if (!strncasecmp (cssRule, "top", 3))
1.362     quint    4994:     {
                   4995:       val.typed_data.value = 0;
                   4996:       val.typed_data.unit = UNIT_PERCENT;
                   4997:       cssRule += 3;
                   4998:       *across = FALSE;
                   4999:     }
1.163     quint    5000:   else if (!strncasecmp (cssRule, "bottom", 6))
1.191     vatton   5001:     {
1.362     quint    5002:       val.typed_data.value = 100;
                   5003:       val.typed_data.unit = UNIT_PERCENT;
                   5004:       cssRule += 6;
                   5005:       *across = FALSE;
                   5006:     }
                   5007:   else if (!strncasecmp (cssRule, "inherit", 7))
                   5008:     {
                   5009:       val.typed_data.unit = VALUE_INHERIT;
                   5010:       cssRule += 7;
1.191     vatton   5011:     }
1.163     quint    5012:   else
1.362     quint    5013:     /* <length> or <percentage> */
                   5014:     {
                   5015:       cssRule = ParseCSSUnit (cssRule, &val);
                   5016:       if (val.typed_data.unit == UNIT_BOX && val.typed_data.value == 0)
                   5017:         /* 0 with no unit. Accept */
                   5018:         val.typed_data.unit = UNIT_PERCENT;
                   5019:     }
1.163     quint    5020: 
1.366     vatton   5021:   if (val.typed_data.unit != UNIT_INVALID && val.typed_data.unit != UNIT_BOX)
1.362     quint    5022:     {
1.366     vatton   5023:       if (DoDialog)
                   5024:         {
                   5025:           if (val.typed_data.unit == VALUE_INHERIT)
                   5026:             {
                   5027:               DisplayStyleValue ("background-positionH", ptr, cssRule);
                   5028:               DisplayStyleValue ("background-positionV", ptr, cssRule);
                   5029:             }
                   5030:           else if (*across)
                   5031:               DisplayStyleValue ("background-positionH", ptr, cssRule);
                   5032:           else
                   5033:               DisplayStyleValue ("background-positionV", ptr, cssRule);
                   5034:         }
                   5035:       else if (DoApply)
1.362     quint    5036:         /* install the new presentation */
                   5037:         {
                   5038:           if (val.typed_data.unit == VALUE_INHERIT)
                   5039:             /* "inherit" applies to both dimensions */
                   5040:             {
                   5041:               TtaSetStylePresentation (PRBackgroundHorizPos, element, tsch,
                   5042:                                        ctxt, val);
                   5043:               TtaSetStylePresentation (PRBackgroundVertPos, element, tsch,
                   5044:                                        ctxt, val);
                   5045:             }
                   5046:           else if (*across)
                   5047:             TtaSetStylePresentation (PRBackgroundHorizPos, element, tsch,
                   5048:                                      ctxt, val);
                   5049:           else
                   5050:             TtaSetStylePresentation (PRBackgroundVertPos, element, tsch,
                   5051:                                      ctxt, val);
                   5052:         }
                   5053:     }
1.279     vatton   5054:   return (cssRule);
                   5055: }
1.218     vatton   5056: 
1.279     vatton   5057: /*----------------------------------------------------------------------
1.327     vatton   5058:   ParseCSSBackgroundPosition: parse a CSS BackgroundPosition
                   5059:   attribute string.                                          
1.279     vatton   5060:   ----------------------------------------------------------------------*/
                   5061: static char *ParseCSSBackgroundPosition (Element element, PSchema tsch,
1.327     vatton   5062:                                          PresentationContext ctxt,
                   5063:                                          char *cssRule, CSSInfoPtr css,
                   5064:                                          ThotBool isHTML)
1.279     vatton   5065: {
1.295     vatton   5066:   char     *ptr;
1.362     quint    5067:   ThotBool  across;
1.295     vatton   5068: 
                   5069:   ptr = cssRule;
1.362     quint    5070:   across = TRUE;
                   5071:   cssRule = ParseACSSBackgroundPosition (element, tsch, ctxt, cssRule, css,
                   5072:                                          isHTML, &across);
1.295     vatton   5073:   if (ptr == cssRule)
1.360     vatton   5074:     cssRule = SkipValue ("Invalid background-position value", cssRule);
1.362     quint    5075:   else
1.298     vatton   5076:     {
1.362     quint    5077:       cssRule = SkipBlanksAndComments (cssRule);
                   5078:       if (*cssRule !=  ';' && *cssRule !=  '!' && *cssRule != EOS)
                   5079:         {
                   5080:           /* possible second value */
                   5081:           ptr = cssRule;
                   5082:           across = !across;
                   5083:           cssRule = ParseACSSBackgroundPosition (element, tsch, ctxt, cssRule,
                   5084:                                                  css, isHTML, &across);
                   5085:           if (ptr == cssRule)
                   5086:             cssRule = SkipValue ("Invalid background-position value", cssRule);
                   5087:         }
1.298     vatton   5088:     }
1.163     quint    5089:   return (cssRule);
1.18      cvs      5090: }
                   5091: 
                   5092: /*----------------------------------------------------------------------
1.327     vatton   5093:   ParseCSSBackground: parse a CSS background attribute 
1.18      cvs      5094:   ----------------------------------------------------------------------*/
1.79      cvs      5095: static char *ParseCSSBackground (Element element, PSchema tsch,
1.327     vatton   5096:                                  PresentationContext ctxt, char *cssRule,
                   5097:                                  CSSInfoPtr css, ThotBool isHTML)
1.18      cvs      5098: {
1.323     vatton   5099:   char           *ptr;
                   5100:   int             skippedNL;
1.362     quint    5101:   ThotBool        img, repeat, position, attach, color, across;
1.18      cvs      5102: 
1.82      cvs      5103:   cssRule = SkipBlanksAndComments (cssRule);
1.323     vatton   5104:   img = repeat = position = attach = color = FALSE;
1.362     quint    5105:   across = TRUE;
1.301     vatton   5106:   while (*cssRule != ';' && *cssRule != '}' && *cssRule != EOS && *cssRule != ',')
1.18      cvs      5107:     {
1.71      cvs      5108:       /* perhaps a Background Image */
1.198     vatton   5109:       if (!strncasecmp (cssRule, "url", 3) || !strncasecmp (cssRule, "none", 4))
1.327     vatton   5110:         {
1.334     vatton   5111:           if (!strncasecmp (cssRule, "none", 4))
                   5112:             repeat = TRUE;
1.327     vatton   5113:           cssRule = ParseCSSBackgroundImage (element, tsch, ctxt, cssRule,
                   5114:                                              css, isHTML);
                   5115:           img = TRUE;
                   5116:         }
1.18      cvs      5117:       /* perhaps a Background Attachment */
1.82      cvs      5118:       else if (!strncasecmp (cssRule, "scroll", 6) ||
                   5119:                !strncasecmp (cssRule, "fixed", 5))
1.327     vatton   5120:         {
                   5121:           cssRule = ParseACSSBackgroundAttachment (element, tsch, ctxt,
                   5122:                                                    cssRule, css, isHTML);
1.328     vatton   5123:           attach = repeat = TRUE;
1.327     vatton   5124:         }
1.18      cvs      5125:       /* perhaps a Background Repeat */
1.82      cvs      5126:       else if (!strncasecmp (cssRule, "no-repeat", 9) ||
                   5127:                !strncasecmp (cssRule, "repeat-y", 8)  ||
                   5128:                !strncasecmp (cssRule, "repeat-x", 8)  ||
                   5129:                !strncasecmp (cssRule, "repeat", 6))
1.327     vatton   5130:         {
                   5131:           cssRule = ParseACSSBackgroundRepeat (element, tsch, ctxt,
                   5132:                                                cssRule, css, isHTML);
                   5133:           repeat = TRUE;
                   5134:         }
1.18      cvs      5135:       /* perhaps a Background Position */
1.82      cvs      5136:       else if (!strncasecmp (cssRule, "left", 4)   ||
                   5137:                !strncasecmp (cssRule, "right", 5)  ||
                   5138:                !strncasecmp (cssRule, "center", 6) ||
                   5139:                !strncasecmp (cssRule, "top", 3)    ||
                   5140:                !strncasecmp (cssRule, "bottom", 6) ||
1.279     vatton   5141:                isdigit (*cssRule) || *cssRule == '.' || *cssRule == '-')
1.327     vatton   5142:         {
1.362     quint    5143:           cssRule = ParseACSSBackgroundPosition (element, tsch, ctxt, cssRule,
                   5144:                                                  css, isHTML, &across);
                   5145:           across = !across;
1.328     vatton   5146:           position = repeat = TRUE;
1.327     vatton   5147:         }
1.18      cvs      5148:       /* perhaps a Background Color */
1.323     vatton   5149:       else if (!color)
1.327     vatton   5150:         {
                   5151:           skippedNL = NewLineSkipped;
                   5152:           /* check if the rule has been found */
                   5153:           ptr = cssRule;
                   5154:           cssRule = ParseCSSBackgroundColor (element, tsch, ctxt,
                   5155:                                              cssRule, css, isHTML);
                   5156:           if (ptr == cssRule)
                   5157:             {
                   5158:               NewLineSkipped = skippedNL;
                   5159:               /* rule not found */
                   5160:               cssRule = SkipProperty (cssRule, FALSE);
                   5161:             }
                   5162:           else
                   5163:             color = TRUE;
                   5164:         }
1.328     vatton   5165:       else
1.327     vatton   5166:         cssRule = SkipProperty (cssRule, FALSE);
1.328     vatton   5167: 
1.82      cvs      5168:       cssRule = SkipBlanksAndComments (cssRule);
1.18      cvs      5169:     }
1.328     vatton   5170: 
                   5171:   if (color && !img)
                   5172:     ParseCSSBackgroundImage (element, tsch, ctxt, "none", css, isHTML);
                   5173:   
                   5174:   if (img && !repeat)
                   5175:     ParseACSSBackgroundRepeat (element, tsch, ctxt,
                   5176:                                "repeat", css, isHTML);
                   5177:   if (img && !position)
                   5178:     ParseACSSBackgroundPosition (element, tsch, ctxt,
1.362     quint    5179:                                  "0% 0%", css, isHTML, &across);
1.328     vatton   5180:   if (img && !attach)
                   5181:     ParseACSSBackgroundAttachment (element, tsch, ctxt,
                   5182:                                    "scroll", css, isHTML);
1.327     vatton   5183:   return (cssRule);
1.18      cvs      5184: }
                   5185: 
1.59      cvs      5186: /*----------------------------------------------------------------------
1.327     vatton   5187:   ParseCSSPageBreakBefore: parse a CSS page-break-before attribute 
1.59      cvs      5188:   ----------------------------------------------------------------------*/
1.79      cvs      5189: static char *ParseCSSPageBreakBefore (Element element, PSchema tsch,
1.327     vatton   5190:                                       PresentationContext ctxt, char *cssRule,
                   5191:                                       CSSInfoPtr css, ThotBool isHTML)
1.59      cvs      5192: {
                   5193:   PresentationValue   page;
1.366     vatton   5194:   char               *start_value;
1.59      cvs      5195: 
1.184     vatton   5196:   page.typed_data.unit = UNIT_INVALID;
1.59      cvs      5197:   page.typed_data.real = FALSE;
1.82      cvs      5198:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   5199:   start_value = cssRule;
1.82      cvs      5200:   if (!strncasecmp (cssRule, "auto", 4))
1.184     vatton   5201:     page.typed_data.value = PageAuto;
1.82      cvs      5202:   else if (!strncasecmp (cssRule, "always", 6))
1.59      cvs      5203:     {
1.184     vatton   5204:       page.typed_data.unit = UNIT_REL;
                   5205:       page.typed_data.value = PageAlways;
1.59      cvs      5206:     }
1.82      cvs      5207:   else if (!strncasecmp (cssRule, "avoid", 5))
1.59      cvs      5208:     {
1.184     vatton   5209:       page.typed_data.unit = UNIT_REL;
                   5210:       page.typed_data.value = PageAvoid;
1.59      cvs      5211:     }
1.82      cvs      5212:   else if (!strncasecmp (cssRule, "left", 4))
1.59      cvs      5213:     {
1.184     vatton   5214:       page.typed_data.unit = UNIT_REL;
                   5215:       page.typed_data.value = PageLeft;
1.59      cvs      5216:     }
1.82      cvs      5217:   else if (!strncasecmp (cssRule, "right", 5))
1.59      cvs      5218:     {
1.184     vatton   5219:       page.typed_data.unit = UNIT_REL;
                   5220:       page.typed_data.value = PageRight;
1.59      cvs      5221:     }
1.82      cvs      5222:   else if (!strncasecmp (cssRule, "inherit", 7))
1.59      cvs      5223:     {
1.293     quint    5224:       page.typed_data.unit = VALUE_INHERIT;
1.184     vatton   5225:       page.typed_data.value = PageInherit;
1.59      cvs      5226:     }
                   5227:   cssRule = SkipWord (cssRule);
                   5228:   /* install the new presentation */
1.366     vatton   5229:   if ((page.typed_data.unit == UNIT_REL && page.typed_data.value == PageAlways)
                   5230:       || page.typed_data.unit == VALUE_INHERIT)
                   5231:     {
                   5232:       if (DoDialog)
                   5233:         DisplayStyleValue ("page-break-before", start_value, cssRule);
                   5234:       else if (DoApply)
                   5235:         TtaSetStylePresentation (PRPageBefore, element, tsch, ctxt, page);
                   5236:     }
1.59      cvs      5237:   return (cssRule);
                   5238: }
                   5239: 
                   5240: /*----------------------------------------------------------------------
1.327     vatton   5241:   ParseCSSPageBreakAfter: parse a CSS page-break-after attribute 
1.59      cvs      5242:   ----------------------------------------------------------------------*/
1.79      cvs      5243: static char *ParseCSSPageBreakAfter (Element element, PSchema tsch,
1.327     vatton   5244:                                      PresentationContext ctxt,
                   5245:                                      char *cssRule, CSSInfoPtr css,
                   5246:                                      ThotBool isHTML)
1.59      cvs      5247: {
                   5248:   PresentationValue   page;
1.366     vatton   5249:   char               *start_value;
1.59      cvs      5250: 
1.184     vatton   5251:   page.typed_data.unit = UNIT_INVALID;
1.59      cvs      5252:   page.typed_data.real = FALSE;
1.82      cvs      5253:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   5254:   start_value = cssRule;
1.82      cvs      5255:   if (!strncasecmp (cssRule, "auto", 4))
1.184     vatton   5256:     page.typed_data.value = PageAuto;
1.82      cvs      5257:   else if (!strncasecmp (cssRule, "always", 6))
1.59      cvs      5258:     {
1.184     vatton   5259:       page.typed_data.unit = UNIT_REL;
                   5260:       page.typed_data.value = PageAlways;
1.59      cvs      5261:     }
1.82      cvs      5262:   else if (!strncasecmp (cssRule, "avoid", 5))
1.59      cvs      5263:     {
1.184     vatton   5264:       page.typed_data.unit = UNIT_REL;
                   5265:       page.typed_data.value = PageAvoid;
1.59      cvs      5266:     }
1.82      cvs      5267:   else if (!strncasecmp (cssRule, "left", 4))
1.59      cvs      5268:     {
1.184     vatton   5269:       page.typed_data.unit = UNIT_REL;
                   5270:       page.typed_data.value = PageLeft;
1.59      cvs      5271:     }
1.82      cvs      5272:   else if (!strncasecmp (cssRule, "right", 5))
1.59      cvs      5273:     {
1.184     vatton   5274:       page.typed_data.unit = UNIT_REL;
                   5275:       page.typed_data.value = PageRight;
1.59      cvs      5276:     }
1.82      cvs      5277:   else if (!strncasecmp (cssRule, "inherit", 7))
1.59      cvs      5278:     {
1.293     quint    5279:       page.typed_data.unit = VALUE_INHERIT;
1.184     vatton   5280:       page.typed_data.value = PageInherit;
1.59      cvs      5281:     }
                   5282:   cssRule = SkipWord (cssRule);
                   5283:   /* install the new presentation */
1.366     vatton   5284:   if (page.typed_data.unit == UNIT_REL || page.typed_data.unit == VALUE_INHERIT)
                   5285:     {
                   5286:       if (DoDialog)
                   5287:         DisplayStyleValue ("page-break-after", start_value, cssRule);
1.367   ! cvs      5288:       //else if (DoApply)
        !          5289:         // TtaSetStylePresentation (PRPageAfter, element, tsch, ctxt, page);
1.366     vatton   5290:     }
1.59      cvs      5291:   return (cssRule);
                   5292: }
                   5293: 
                   5294: /*----------------------------------------------------------------------
1.327     vatton   5295:   ParseCSSPageBreakInside: parse a CSS page-break-inside attribute 
1.59      cvs      5296:   ----------------------------------------------------------------------*/
1.79      cvs      5297: static char *ParseCSSPageBreakInside (Element element, PSchema tsch,
1.327     vatton   5298:                                       PresentationContext ctxt,
                   5299:                                       char *cssRule, CSSInfoPtr css,
                   5300:                                       ThotBool isHTML)
1.59      cvs      5301: {
                   5302:   PresentationValue   page;
1.366     vatton   5303:   char               *start_value;
1.59      cvs      5304: 
1.184     vatton   5305:   page.typed_data.unit = UNIT_INVALID;
1.59      cvs      5306:   page.typed_data.real = FALSE;
1.82      cvs      5307:   cssRule = SkipBlanksAndComments (cssRule);
1.366     vatton   5308:   start_value = cssRule;
1.82      cvs      5309:   if (!strncasecmp (cssRule, "auto", 4))
1.59      cvs      5310:     {
1.184     vatton   5311:       /*page.typed_data.unit = UNIT_REL;*/
                   5312:       page.typed_data.value = PageAuto;
1.59      cvs      5313:     }
1.82      cvs      5314:   else if (!strncasecmp (cssRule, "avoid", 5))
1.59      cvs      5315:     {
1.184     vatton   5316:       page.typed_data.unit = UNIT_REL;
                   5317:       page.typed_data.value = PageAvoid;
1.59      cvs      5318:     }
1.82      cvs      5319:   else if (!strncasecmp (cssRule, "inherit", 7))
1.59      cvs      5320:     {
1.293     quint    5321:       /* page.typed_data.unit = VALUE_INHERIT; */
1.184     vatton   5322:       page.typed_data.value = PageInherit;
1.59      cvs      5323:     }
                   5324:   cssRule = SkipWord (cssRule);
                   5325:   /* install the new presentation */
1.366     vatton   5326:   if ((page.typed_data.unit == UNIT_REL || page.typed_data.unit == VALUE_INHERIT) &&
                   5327:       page.typed_data.value == PageAvoid)
                   5328:     {
                   5329:       if (DoDialog)
                   5330:         DisplayStyleValue ("page-break-inside", start_value, cssRule);
1.367   ! cvs      5331:       //else if (DoApply)
        !          5332:         //TtaSetStylePresentation (PRPageInside, element, tsch, ctxt, page);
1.366     vatton   5333:     }
1.59      cvs      5334:   return (cssRule);
                   5335: }
1.18      cvs      5336: 
1.60      cvs      5337: /*----------------------------------------------------------------------
1.327     vatton   5338:   ParseSVGStrokeWidth: parse a SVG stroke-width property value.
1.60      cvs      5339:   ----------------------------------------------------------------------*/
1.79      cvs      5340: static char *ParseSVGStrokeWidth (Element element, PSchema tsch,
1.327     vatton   5341:                                   PresentationContext ctxt, char *cssRule,
                   5342:                                   CSSInfoPtr css, ThotBool isHTML)
1.60      cvs      5343: {
                   5344:   PresentationValue   width;
                   5345:   
1.82      cvs      5346:   cssRule = SkipBlanksAndComments (cssRule);
1.60      cvs      5347:   width.typed_data.value = 0;
1.184     vatton   5348:   width.typed_data.unit = UNIT_INVALID;
1.60      cvs      5349:   width.typed_data.real = FALSE;
1.110     vatton   5350:   if (isdigit (*cssRule) || *cssRule == '.')
1.166     vatton   5351:     {
1.327     vatton   5352:       cssRule = ParseCSSUnit (cssRule, &width);
                   5353:       if (width.typed_data.unit == UNIT_BOX)
                   5354:         width.typed_data.unit = UNIT_PX;
1.166     vatton   5355:     }
1.295     vatton   5356:   else
                   5357:     cssRule = SkipValue ("Invalid stroke-width value", cssRule);
                   5358: 
1.184     vatton   5359:   if (width.typed_data.unit != UNIT_INVALID && DoApply)
1.117     vatton   5360:     {
1.207     vatton   5361:       TtaSetStylePresentation (PRLineWeight, element, tsch, ctxt, width);
1.117     vatton   5362:       width.typed_data.value = 1;
1.184     vatton   5363:       width.typed_data.unit = UNIT_REL;
1.117     vatton   5364:     }
1.60      cvs      5365:   return (cssRule);
                   5366: }
                   5367: 
1.217     vatton   5368: /*----------------------------------------------------------------------
1.327     vatton   5369:   ParseCSSPosition: parse a CSS Position attribute string.
1.217     vatton   5370:   ----------------------------------------------------------------------*/
                   5371: static char *ParseCSSPosition (Element element, PSchema tsch,
1.327     vatton   5372:                                PresentationContext ctxt, char *cssRule,
                   5373:                                CSSInfoPtr css, ThotBool isHTML)
1.217     vatton   5374: {
1.305     quint    5375:   char               *ptr;
                   5376:   PresentationValue   pval;
1.217     vatton   5377: 
1.305     quint    5378:   pval.typed_data.value = 0;
                   5379:   pval.typed_data.unit = UNIT_BOX;
                   5380:   pval.typed_data.real = FALSE;
1.217     vatton   5381:   cssRule = SkipBlanksAndComments (cssRule);
                   5382:   ptr = cssRule;
                   5383:   if (!strncasecmp (cssRule, "static", 6))
1.337     vatton   5384:     {
                   5385:       pval.typed_data.value = PositionStatic;
                   5386:       cssRule += 6;
                   5387:     }
                   5388:   else if (!strncasecmp (cssRule, "relative", 8))
                   5389:     {
                   5390:       pval.typed_data.value = PositionRelative;
                   5391:       cssRule += 8;
                   5392:     }
1.217     vatton   5393:   else if (!strncasecmp (cssRule, "absolute", 8))
1.337     vatton   5394:     {
                   5395:       pval.typed_data.value = PositionAbsolute;
                   5396:       cssRule += 8;
                   5397:     }
1.217     vatton   5398:   else if (!strncasecmp (cssRule, "fixed", 5))
1.337     vatton   5399:     {
                   5400:       pval.typed_data.value = PositionFixed;
                   5401:       cssRule += 5;
                   5402:     }
1.217     vatton   5403:   else if (!strncasecmp (cssRule, "inherit", 7))
1.337     vatton   5404:     {
                   5405:       pval.typed_data.unit = VALUE_INHERIT;
                   5406:       cssRule += 7;
                   5407:     }
1.305     quint    5408: 
                   5409:   if (pval.typed_data.value == 0 && pval.typed_data.unit != VALUE_INHERIT)
                   5410:     {
                   5411:       cssRule = SkipValue ("Invalid position value", ptr);
                   5412:       cssRule = SkipValue (NULL, cssRule);
                   5413:     }
1.217     vatton   5414:   else
1.305     quint    5415:     {
1.337     vatton   5416:       cssRule = SkipBlanksAndComments (cssRule);
                   5417:       if (*cssRule != EOS && *cssRule != ';')
                   5418:         SkipValue ("Invalid position value", ptr);
1.366     vatton   5419:       else if (DoDialog)
                   5420:         DisplayStyleValue ("position", ptr, cssRule);
1.337     vatton   5421:       else if (DoApply)
1.327     vatton   5422:         TtaSetStylePresentation (PRPosition, element, tsch, ctxt, pval);
1.305     quint    5423:     }
1.217     vatton   5424:   return (cssRule);
                   5425: }
                   5426: 
                   5427: /*----------------------------------------------------------------------
1.327     vatton   5428:   ParseCSSTop: parse a CSS Top attribute
1.217     vatton   5429:   ----------------------------------------------------------------------*/
                   5430: static char *ParseCSSTop (Element element, PSchema tsch,
1.327     vatton   5431:                           PresentationContext context, char *cssRule,
                   5432:                           CSSInfoPtr css, ThotBool isHTML)
1.217     vatton   5433: {
                   5434:   PresentationValue   val;
                   5435:   char               *ptr;
                   5436: 
                   5437:   cssRule = SkipBlanksAndComments (cssRule);
                   5438:   ptr = cssRule;
1.305     quint    5439:   /* first parse the value */
                   5440:   if (!strncasecmp (cssRule, "auto", 4))
1.217     vatton   5441:     {
                   5442:       val.typed_data.unit = VALUE_AUTO;
                   5443:       val.typed_data.value = 0;
                   5444:       val.typed_data.real = FALSE;
                   5445:       cssRule = SkipWord (cssRule);
                   5446:     }
1.305     quint    5447:   else if (!strncasecmp (cssRule, "inherit", 7))
                   5448:     {
                   5449:       val.typed_data.unit = VALUE_INHERIT;
                   5450:       cssRule = SkipWord (cssRule);
                   5451:     }
1.217     vatton   5452:   else
                   5453:     cssRule = ParseCSSUnit (cssRule, &val);
                   5454:   if (val.typed_data.value != 0 &&
                   5455:       (val.typed_data.unit == UNIT_INVALID ||
                   5456:        val.typed_data.unit == UNIT_BOX))
                   5457:     {
1.218     vatton   5458:       cssRule = SkipValue ("top value", ptr);
1.217     vatton   5459:       val.typed_data.unit = UNIT_PX;
                   5460:     }
1.366     vatton   5461:   if (DoDialog)
                   5462:         DisplayStyleValue ("top", ptr, cssRule);
                   5463:   else if (DoApply)
1.305     quint    5464:     TtaSetStylePresentation (PRTop, element, tsch, context, val);
1.217     vatton   5465:   return (cssRule);
                   5466: }
                   5467: 
                   5468: /*----------------------------------------------------------------------
1.327     vatton   5469:   ParseCSSRight: parse a CSS Right attribute
1.217     vatton   5470:   ----------------------------------------------------------------------*/
                   5471: static char *ParseCSSRight (Element element, PSchema tsch,
1.327     vatton   5472:                             PresentationContext context, char *cssRule,
                   5473:                             CSSInfoPtr css, ThotBool isHTML)
1.217     vatton   5474: {
                   5475:   PresentationValue   val;
                   5476:   char               *ptr;
                   5477: 
                   5478:   cssRule = SkipBlanksAndComments (cssRule);
                   5479:   ptr = cssRule;
                   5480:   /* first parse the attribute string */
1.305     quint    5481:   if (!strncasecmp (cssRule, "auto", 4))
1.217     vatton   5482:     {
                   5483:       val.typed_data.unit = VALUE_AUTO;
                   5484:       val.typed_data.value = 0;
                   5485:       val.typed_data.real = FALSE;
                   5486:       cssRule = SkipWord (cssRule);
                   5487:     }
1.305     quint    5488:   else if (!strncasecmp (cssRule, "inherit", 7))
                   5489:     {
                   5490:       val.typed_data.unit = VALUE_INHERIT;
                   5491:       cssRule = SkipWord (cssRule);
                   5492:     }
1.217     vatton   5493:   else
                   5494:     cssRule = ParseCSSUnit (cssRule, &val);
                   5495:   if (val.typed_data.value != 0 &&
                   5496:       (val.typed_data.unit == UNIT_INVALID ||
                   5497:        val.typed_data.unit == UNIT_BOX))
                   5498:     {
1.218     vatton   5499:       cssRule = SkipValue ("right value", ptr);
1.217     vatton   5500:       val.typed_data.unit = UNIT_PX;
                   5501:     }
1.366     vatton   5502:   if (DoDialog)
                   5503:         DisplayStyleValue ("right", ptr, cssRule);
                   5504:   else if (DoApply)
1.305     quint    5505:     TtaSetStylePresentation (PRRight, element, tsch, context, val);
1.217     vatton   5506:   return (cssRule);
                   5507: }
                   5508: 
                   5509: /*----------------------------------------------------------------------
1.327     vatton   5510:   ParseCSSBottom: parse a CSS Bottom attribute
1.217     vatton   5511:   ----------------------------------------------------------------------*/
                   5512: static char *ParseCSSBottom (Element element, PSchema tsch,
1.327     vatton   5513:                              PresentationContext context, char *cssRule,
                   5514:                              CSSInfoPtr css, ThotBool isHTML)
1.217     vatton   5515: {
                   5516:   PresentationValue   val;
                   5517:   char               *ptr;
                   5518: 
                   5519:   cssRule = SkipBlanksAndComments (cssRule);
                   5520:   ptr = cssRule;
                   5521:   /* first parse the attribute string */
1.305     quint    5522:   if (!strncasecmp (cssRule, "auto", 4))
1.217     vatton   5523:     {
                   5524:       val.typed_data.unit = VALUE_AUTO;
                   5525:       val.typed_data.value = 0;
                   5526:       val.typed_data.real = FALSE;
                   5527:       cssRule = SkipWord (cssRule);
                   5528:     }
1.305     quint    5529:   else if (!strncasecmp (cssRule, "inherit", 7))
                   5530:     {
                   5531:       val.typed_data.unit = VALUE_INHERIT;
                   5532:       cssRule = SkipWord (cssRule);
                   5533:     }
1.217     vatton   5534:   else
                   5535:     cssRule = ParseCSSUnit (cssRule, &val);
                   5536:   if (val.typed_data.value != 0 &&
                   5537:       (val.typed_data.unit == UNIT_INVALID ||
                   5538:        val.typed_data.unit == UNIT_BOX))
                   5539:     {
1.218     vatton   5540:       cssRule = SkipValue ("bottom value", ptr);
1.217     vatton   5541:       val.typed_data.unit = UNIT_PX;
                   5542:     }
1.366     vatton   5543:   if (DoDialog)
                   5544:         DisplayStyleValue ("bottom", ptr, cssRule);
                   5545:   else if (DoApply)
1.305     quint    5546:     TtaSetStylePresentation (PRBottom, element, tsch, context, val);
1.217     vatton   5547:   return (cssRule);
                   5548: }
                   5549: 
                   5550: /*----------------------------------------------------------------------
1.327     vatton   5551:   ParseCSSLeft: parse a CSS Left attribute
1.217     vatton   5552:   ----------------------------------------------------------------------*/
                   5553: static char *ParseCSSLeft (Element element, PSchema tsch,
1.327     vatton   5554:                            PresentationContext context, char *cssRule,
                   5555:                            CSSInfoPtr css, ThotBool isHTML)
1.217     vatton   5556: {
                   5557:   PresentationValue   val;
                   5558:   char               *ptr;
                   5559: 
                   5560:   cssRule = SkipBlanksAndComments (cssRule);
                   5561:   ptr = cssRule;
                   5562:   /* first parse the attribute string */
1.305     quint    5563:   if (!strncasecmp (cssRule, "auto", 4))
1.217     vatton   5564:     {
                   5565:       val.typed_data.unit = VALUE_AUTO;
                   5566:       val.typed_data.value = 0;
                   5567:       val.typed_data.real = FALSE;
                   5568:       cssRule = SkipWord (cssRule);
                   5569:     }
1.305     quint    5570:   else if (!strncasecmp (cssRule, "inherit", 7))
                   5571:     {
                   5572:       val.typed_data.unit = VALUE_INHERIT;
                   5573:       cssRule = SkipWord (cssRule);
                   5574:     }
1.217     vatton   5575:   else
                   5576:     cssRule = ParseCSSUnit (cssRule, &val);
                   5577:   if (val.typed_data.value != 0 &&
                   5578:       (val.typed_data.unit == UNIT_INVALID ||
                   5579:        val.typed_data.unit == UNIT_BOX))
                   5580:     {
1.218     vatton   5581:       cssRule = SkipValue ("left value", ptr);
1.217     vatton   5582:       val.typed_data.unit = UNIT_PX;
                   5583:     }
1.366     vatton   5584:   if (DoDialog)
                   5585:         DisplayStyleValue ("left", ptr, cssRule);
                   5586:   else if (DoApply)
1.305     quint    5587:     TtaSetStylePresentation (PRLeft, element, tsch, context, val);
1.217     vatton   5588:   return (cssRule);
                   5589: }
                   5590: 
                   5591: /*----------------------------------------------------------------------
1.327     vatton   5592:   ParseCSSZIndex: parse a CSS z-index attribute
1.217     vatton   5593:   ----------------------------------------------------------------------*/
                   5594: static char *ParseCSSZIndex (Element element, PSchema tsch,
1.327     vatton   5595:                              PresentationContext context, char *cssRule,
                   5596:                              CSSInfoPtr css, ThotBool isHTML)
1.217     vatton   5597: {
                   5598:   PresentationValue   val;
                   5599:   char               *ptr;
                   5600: 
                   5601:   cssRule = SkipBlanksAndComments (cssRule);
                   5602:   ptr = cssRule;
                   5603:   /* first parse the attribute string */
                   5604:   if (!strncasecmp (cssRule, "auto", 4) ||
                   5605:       !strncasecmp (cssRule, "inherit", 7))
                   5606:     {
                   5607:       val.typed_data.unit = VALUE_AUTO;
                   5608:       val.typed_data.value = 0;
                   5609:       val.typed_data.real = FALSE;
                   5610:       cssRule = SkipWord (cssRule);
                   5611:     }
                   5612:   else
                   5613:     {
                   5614:       cssRule = ParseCSSUnit (cssRule, &val);
                   5615:       if (val.typed_data.unit != UNIT_BOX)
1.327     vatton   5616:         {
                   5617:           cssRule = SkipValue ("z-index value", ptr);
                   5618:           val.typed_data.unit = UNIT_BOX;
                   5619:         }
1.217     vatton   5620:     }
1.366     vatton   5621:   if (DoDialog)
                   5622:         DisplayStyleValue ("z-index", ptr, cssRule);
1.217     vatton   5623:   /***
1.327     vatton   5624:       if (DoApply)
                   5625:       TtaSetStylePresentation (PR, element, tsch, context, val);
1.217     vatton   5626:   ***/
                   5627:   return (cssRule);
                   5628: }
                   5629: 
1.340     quint    5630: /*----------------------------------------------------------------------
                   5631:  *
                   5632:  *     FUNCTIONS STYLE DECLARATIONS
                   5633:  *
                   5634:  *----------------------------------------------------------------------*/
1.18      cvs      5635: /*
1.59      cvs      5636:  * NOTE: Long attribute name MUST be placed before shortened ones !
1.18      cvs      5637:  *        e.g. "FONT-SIZE" must be placed before "FONT"
                   5638:  */
                   5639: static CSSProperty CSSProperties[] =
1.327     vatton   5640:   {
                   5641:     {"background-color", ParseCSSBackgroundColor},
                   5642:     {"background-image", ParseCSSBackgroundImage},
                   5643:     {"background-repeat", ParseCSSBackgroundRepeat},
                   5644:     {"background-attachment", ParseCSSBackgroundAttachment},
                   5645:     {"background-position", ParseCSSBackgroundPosition},
                   5646:     {"background", ParseCSSBackground},
                   5647:     {"border-top-width", ParseCSSBorderTopWidth},
                   5648:     {"border-right-width", ParseCSSBorderRightWidth},
                   5649:     {"border-bottom-width", ParseCSSBorderBottomWidth},
                   5650:     {"border-left-width", ParseCSSBorderLeftWidth},
                   5651:     {"border-width", ParseCSSBorderWidth},
                   5652:     {"border-top-color", ParseCSSBorderColorTop},
                   5653:     {"border-right-color", ParseCSSBorderColorRight},
                   5654:     {"border-bottom-color", ParseCSSBorderColorBottom},
                   5655:     {"border-left-color", ParseCSSBorderColorLeft},
                   5656:     {"border-color", ParseCSSBorderColor},
                   5657:     {"border-top-style", ParseCSSBorderStyleTop},
                   5658:     {"border-right-style", ParseCSSBorderStyleRight},
                   5659:     {"border-bottom-style", ParseCSSBorderStyleBottom},
                   5660:     {"border-left-style", ParseCSSBorderStyleLeft},
                   5661:     {"border-style", ParseCSSBorderStyle},
                   5662:     {"border-top", ParseCSSBorderTop},
                   5663:     {"border-right", ParseCSSBorderRight},
                   5664:     {"border-bottom", ParseCSSBorderBottom},
                   5665:     {"border-left", ParseCSSBorderLeft},
                   5666:     {"border", ParseCSSBorder},
                   5667:     {"bottom", ParseCSSBottom},
                   5668:     {"clear", ParseCSSClear},
                   5669:     {"color", ParseCSSForeground},
                   5670:     {"content", ParseCSSContent},
                   5671:     {"direction", ParseCSSDirection},
                   5672:     {"display", ParseCSSDisplay},
                   5673:     {"float", ParseCSSFloat},
                   5674:     {"font-family", ParseCSSFontFamily},
                   5675:     {"font-style", ParseCSSFontStyle},
                   5676:     {"font-variant", ParseCSSFontVariant},
                   5677:     {"font-weight", ParseCSSFontWeight},
                   5678:     {"font-size-adjust", ParseCSSFontSizeAdjust},
                   5679:     {"font-size", ParseCSSFontSize},
                   5680:     {"font", ParseCSSFont},
                   5681:     {"height", ParseCSSHeight},
                   5682:     {"left", ParseCSSLeft},
                   5683:     {"letter-spacing", ParseCSSLetterSpacing},
                   5684:     {"line-height", ParseCSSLineHeight},
                   5685:     {"list-style-type", ParseCSSListStyleType},
                   5686:     {"list-style-image", ParseCSSListStyleImage},
                   5687:     {"list-style-position", ParseCSSListStylePosition},
                   5688:     {"list-style", ParseCSSListStyle},
                   5689:     {"margin-bottom", ParseCSSMarginBottom},
                   5690:     {"margin-top", ParseCSSMarginTop},
                   5691:     {"margin-right", ParseCSSMarginRight},
                   5692:     {"margin-left", ParseCSSMarginLeft},
                   5693:     {"margin", ParseCSSMargin},
                   5694:     {"padding-top", ParseCSSPaddingTop},
                   5695:     {"padding-right", ParseCSSPaddingRight},
                   5696:     {"padding-bottom", ParseCSSPaddingBottom},
                   5697:     {"padding-left", ParseCSSPaddingLeft},
                   5698:     {"padding", ParseCSSPadding},
                   5699:     {"page-break-before", ParseCSSPageBreakBefore},
                   5700:     {"page-break-after", ParseCSSPageBreakAfter},
                   5701:     {"page-break-inside", ParseCSSPageBreakInside},
                   5702:     {"position", ParseCSSPosition},
                   5703:     {"right", ParseCSSRight},
                   5704:     {"text-align", ParseCSSTextAlign},
                   5705:     {"text-anchor", ParseCSSTextAnchor},
                   5706:     {"text-indent", ParseCSSTextIndent},
                   5707:     {"text-decoration", ParseCSSTextDecoration},
                   5708:     {"text-transform", ParseCSSTextTransform},
                   5709:     {"top", ParseCSSTop},
                   5710:     {"unicode-bidi", ParseCSSUnicodeBidi},
                   5711:     {"vertical-align", ParseCSSVerticalAlign},
                   5712:     {"white-space", ParseCSSWhiteSpace},
                   5713:     {"width", ParseCSSWidth},
1.333     vatton   5714:     {"visibility", ParseCSSVisibility},
1.327     vatton   5715:     {"word-spacing", ParseCSSWordSpacing},
                   5716:     {"z-index", ParseCSSZIndex},
                   5717: 
                   5718:     /* SVG extensions */
                   5719:     {"fill-opacity", ParseSVGFillOpacity},
                   5720:     {"fill", ParseSVGFill},
                   5721:     {"opacity", ParseSVGOpacity},
                   5722:     {"stroke-opacity", ParseSVGStrokeOpacity},
                   5723:     {"stroke-width", ParseSVGStrokeWidth},
                   5724:     {"stroke", ParseSVGStroke}
                   5725:   };
1.155     cheyroul 5726: 
1.18      cvs      5727: #define NB_CSSSTYLEATTRIBUTE (sizeof(CSSProperties) / sizeof(CSSProperty))
                   5728: 
                   5729: /*----------------------------------------------------------------------
1.327     vatton   5730:   ParseCSSRule: parse a CSS Style string                        
                   5731:   we expect the input string describing the style to be of the form
                   5732:   property: value [ ; property: value ]* 
                   5733:   but tolerate incorrect or incomplete input                    
1.18      cvs      5734:   ----------------------------------------------------------------------*/
1.366     vatton   5735: void  ParseCSSRule (Element element, PSchema tsch, PresentationContext ctxt,
                   5736:                     char *cssRule, CSSInfoPtr css, ThotBool isHTML)
1.18      cvs      5737: {
1.366     vatton   5738:   DisplayMode         dispMode = DisplayImmediately;
1.312     quint    5739:   char               *p = NULL, *next, *end;
1.214     quint    5740:   char               *valueStart;
1.18      cvs      5741:   int                 lg;
1.34      cvs      5742:   unsigned int        i;
1.76      cvs      5743:   ThotBool            found;
1.18      cvs      5744: 
1.34      cvs      5745:   /* avoid too many redisplay */
1.366     vatton   5746:   if (!DoDialog && ctxt->doc)
                   5747:     {
                   5748:       dispMode = TtaGetDisplayMode (ctxt->doc);
                   5749:       if (dispMode == DisplayImmediately)
                   5750:         TtaSetDisplayMode (ctxt->doc, DeferredDisplay);
                   5751:     }
1.34      cvs      5752: 
1.82      cvs      5753:   while (*cssRule != EOS)
1.18      cvs      5754:     {
1.82      cvs      5755:       cssRule = SkipBlanksAndComments (cssRule);
1.352     vatton   5756:       if (*cssRule == '#')
                   5757:         {
                   5758:           end = SkipProperty (cssRule, FALSE);
1.357     quint    5759:           CSSParseError ("Invalid property", cssRule, end);
1.352     vatton   5760:           cssRule = end; 
                   5761:         }
                   5762:       else if (*cssRule < 0x41 || *cssRule > 0x7A ||
1.327     vatton   5763:           (*cssRule > 0x5A && *cssRule < 0x60))
                   5764:         cssRule++;
1.194     vatton   5765:       else if (*cssRule != EOS)
1.327     vatton   5766:         {
                   5767:           found = FALSE;
                   5768:           /* look for the type of property */
                   5769:           for (i = 0; i < NB_CSSSTYLEATTRIBUTE && !found; i++)
                   5770:             {
                   5771:               lg = strlen (CSSProperties[i].name);
                   5772:               if (!strncasecmp (cssRule, CSSProperties[i].name, lg))
                   5773:                 {
                   5774:                   p = cssRule + lg;
                   5775:                   found = TRUE;
                   5776:                   i--;
                   5777:                 }
                   5778:             }
                   5779: 
1.360     vatton   5780:           // check if it's an important rule
                   5781:           CheckImportantRule (cssRule, ctxt);
1.327     vatton   5782:           if (i < NB_CSSSTYLEATTRIBUTE &&
                   5783:               !strcasecmp (CSSProperties[i].name, "content") &&
                   5784:               ((GenericContext)ctxt)->pseudo != PbBefore &&
                   5785:               ((GenericContext)ctxt)->pseudo != PbAfter)
1.340     quint    5786:             /* property content is allowed only for pseudo-elements :before and
                   5787:                :after */
1.327     vatton   5788:             {
1.352     vatton   5789:               end = SkipProperty (cssRule, FALSE);
1.327     vatton   5790:               CSSParseError ("content is allowed only for pseudo-elements",
                   5791:                              cssRule, end);
1.352     vatton   5792:               cssRule = end;
1.327     vatton   5793:             }
1.352     vatton   5794:           else if (i == NB_CSSSTYLEATTRIBUTE)
1.327     vatton   5795:             cssRule = SkipProperty (cssRule, TRUE);
                   5796:           else
                   5797:             {
                   5798:               /* update index and skip the ":" indicator if present */
                   5799:               p = SkipBlanksAndComments (p);
                   5800:               if (*p == ':')
                   5801:                 {
                   5802:                   p++;
                   5803:                   p = SkipBlanksAndComments (p);
                   5804:                   /* try to parse the value associated with this property */
                   5805:                   if (CSSProperties[i].parsing_function != NULL)
                   5806:                     {
                   5807:                       valueStart = p;
                   5808:                       p = CSSProperties[i].parsing_function (element, tsch,
                   5809:                                                              ctxt, p, css, isHTML);
                   5810:                       if (!element && isHTML)
                   5811:                         {
                   5812:                           if  (ctxt->type == HTML_EL_Input)
                   5813:                             /* it's a generic rule for the HTML element input.
                   5814:                                Generate a Thot Pres rule for each kind of
                   5815:                                input element */
                   5816:                             {
                   5817:                               ctxt->type = HTML_EL_Text_Input;
                   5818:                               p = CSSProperties[i].parsing_function (element,
                   5819:                                                                      tsch, ctxt, valueStart, css, isHTML);
                   5820:                               ctxt->type = HTML_EL_Password_Input;
                   5821:                               p = CSSProperties[i].parsing_function (element,
                   5822:                                                                      tsch, ctxt, valueStart, css, isHTML);
                   5823:                               ctxt->type = HTML_EL_File_Input;
                   5824:                               p = CSSProperties[i].parsing_function (element,
                   5825:                                                                      tsch, ctxt, valueStart, css, isHTML);
                   5826:                               ctxt->type = HTML_EL_Checkbox_Input;
                   5827:                               p = CSSProperties[i].parsing_function (element,
                   5828:                                                                      tsch, ctxt, valueStart, css, isHTML);
                   5829:                               ctxt->type = HTML_EL_Radio_Input;
                   5830:                               p = CSSProperties[i].parsing_function (element,
                   5831:                                                                      tsch, ctxt, valueStart, css, isHTML);
                   5832:                               ctxt->type = HTML_EL_Submit_Input;
                   5833:                               p = CSSProperties[i].parsing_function (element,
                   5834:                                                                      tsch, ctxt, valueStart, css, isHTML);
                   5835:                               ctxt->type = HTML_EL_Reset_Input;
                   5836:                               p = CSSProperties[i].parsing_function (element,
                   5837:                                                                      tsch, ctxt, valueStart, css, isHTML);
                   5838:                               ctxt->type = HTML_EL_Button_Input;
                   5839:                               p = CSSProperties[i].parsing_function (element,
                   5840:                                                                      tsch, ctxt, valueStart, css, isHTML);
                   5841:                               ctxt->type = HTML_EL_Input;
                   5842:                             }
                   5843:                           else if (ctxt->type == HTML_EL_ruby)
                   5844:                             /* it's a generic rule for the HTML element ruby.
                   5845:                                Generate a Thot Pres rule for each kind of
                   5846:                                ruby element. */
                   5847:                             {
                   5848:                               ctxt->type = HTML_EL_simple_ruby;
                   5849:                               p = CSSProperties[i].parsing_function (element,
                   5850:                                                                      tsch, ctxt, valueStart, css, isHTML);
                   5851:                               ctxt->type = HTML_EL_complex_ruby;
                   5852:                               p = CSSProperties[i].parsing_function (element,
                   5853:                                                                      tsch, ctxt, valueStart, css, isHTML);
                   5854:                               ctxt->type = HTML_EL_ruby;
                   5855:                             }
                   5856:                         }
                   5857:                       /* update index and skip the ";" separator if present */
                   5858:                       next = SkipBlanksAndComments (p);
                   5859:                       if (*next != EOS && *next != ';')
                   5860:                         CSSParseError ("Missing closing ';'", cssRule, p);
                   5861:                       cssRule = next;
                   5862:                     }
                   5863:                 }
                   5864:               else
                   5865:                 cssRule = SkipProperty (cssRule, TRUE);
                   5866:             }
1.360     vatton   5867:           // skip important markup
                   5868:           cssRule = SkipImportantRule (cssRule);
                   5869: 
1.327     vatton   5870:         }
1.18      cvs      5871:       /* next property */
1.82      cvs      5872:       cssRule = SkipBlanksAndComments (cssRule);
1.89      cvs      5873:       if (*cssRule == '}')
1.327     vatton   5874:         {
                   5875:           cssRule++;
                   5876:           CSSPrintError ("Invalid character", "}");
                   5877:           cssRule = SkipBlanksAndComments (cssRule);
                   5878:         }
1.155     cheyroul 5879:       if (*cssRule == ',' ||
1.327     vatton   5880:           *cssRule == ';')
                   5881:         {
                   5882:           cssRule++;
                   5883:           cssRule = SkipBlanksAndComments (cssRule);
                   5884:         }
1.18      cvs      5885:     }
1.34      cvs      5886: 
                   5887:   /* restore the display mode */
1.366     vatton   5888:   if (!DoDialog && ctxt->doc && dispMode == DisplayImmediately)
1.207     vatton   5889:     TtaSetDisplayMode (ctxt->doc, dispMode);
1.18      cvs      5890: }
1.1       cvs      5891: 
1.111     cvs      5892: /*----------------------------------------------------------------------
1.327     vatton   5893:   ParseHTMLSpecificStyle: parse and apply a CSS Style string.
                   5894:   This function must be called when a specific style is applied to an
                   5895:   element.
                   5896:   The parameter specificity is the specificity of the style, 0 if it is
                   5897:   not really a CSS rule.
1.1       cvs      5898:   ----------------------------------------------------------------------*/
1.79      cvs      5899: void  ParseHTMLSpecificStyle (Element el, char *cssRule, Document doc,
1.327     vatton   5900:                               int specificity, ThotBool destroy)
1.1       cvs      5901: {
1.257     vatton   5902:   DisplayMode         dispMode;
1.207     vatton   5903:   PresentationContext ctxt;
                   5904:   ElementType         elType;
                   5905:   ThotBool            isHTML;
1.1       cvs      5906: 
1.207     vatton   5907:   /*  A rule applying to BODY is really meant to address HTML */
                   5908:   elType = TtaGetElementType (el);
1.286     quint    5909:   NewLineSkipped = 0;
1.207     vatton   5910:   /* store the current line for eventually reported errors */
                   5911:   LineNumber = TtaGetElementLineNumber (el);
                   5912:   if (destroy)
                   5913:     /* no reported errors */
                   5914:     ParsedDoc = 0;
                   5915:   else if (ParsedDoc != doc)
                   5916:     {
                   5917:       /* update the context for reported errors */
                   5918:       ParsedDoc = doc;
1.348     vatton   5919:       Error_DocURL = DocumentURLs[doc];
1.207     vatton   5920:     }
                   5921:   isHTML = (strcmp (TtaGetSSchemaName (elType.ElSSchema), "HTML") == 0);
                   5922:   /* create the context of the Specific presentation driver */
                   5923:   ctxt = TtaGetSpecificStyleContext (doc);
                   5924:   if (ctxt == NULL)
                   5925:     return;
                   5926:   ctxt->type = elType.ElTypeNum;
                   5927:   ctxt->cssSpecificity = specificity;
1.236     quint    5928:   ctxt->cssLine = LineNumber;
1.207     vatton   5929:   ctxt->destroy = destroy;
                   5930:   /* first use of the context */
                   5931:   ctxt->uses = 1;
1.257     vatton   5932:   /* save the current display mode */
                   5933:   dispMode = TtaGetDisplayMode (doc);
1.207     vatton   5934:   /* Call the parser */
1.366     vatton   5935:   DoDialog = FALSE; // not parsing for CSS dialog
1.207     vatton   5936:   ParseCSSRule (el, NULL, (PresentationContext) ctxt, cssRule, NULL, isHTML);
1.257     vatton   5937:   /* restore the display mode if necessary */
                   5938:   TtaSetDisplayMode (doc, dispMode);
1.207     vatton   5939:   /* check if the context can be freed */
                   5940:   ctxt->uses -= 1;
                   5941:   if (ctxt->uses == 0)
                   5942:     /* no image loading */
                   5943:     TtaFreeMemory(ctxt);
1.1       cvs      5944: }
                   5945: 
1.366     vatton   5946: 
1.343     vatton   5947: /*----------------------------------------------------------------------
                   5948:   AddClassName adds the class name into the class list of css if it's
                   5949:   not already there.
                   5950:   ----------------------------------------------------------------------*/
                   5951: static void AddClassName (char *name, CSSInfoPtr css)
                   5952: {
1.344     cvs      5953:   int                   l, index, k, length, add;
1.343     vatton   5954:   char          *buf;
                   5955:   ThotBool       found, previous;
                   5956: 
                   5957:   l = strlen (name);
                   5958:   if (l == 0 || css == NULL)
                   5959:     return;
                   5960:   if (css->class_list)
                   5961:     {
                   5962:       buf = css->class_list;
                   5963:       length = strlen (css->class_list);
                   5964:     }
                   5965:   else
                   5966:     {
                   5967:       if (l > 200)
                   5968:         length = l + 1;
                   5969:       else
                   5970:         length = 200;
                   5971:       buf = (char *)TtaGetMemory (length * sizeof (char));
                   5972:       memset (buf, 0, length);
                   5973:       css->class_list = buf;
                   5974:       css->lg_class_list = length;
                   5975:       length = 0;
                   5976:     }
                   5977: 
                   5978:   /* compare that name with all class names already known */
                   5979:   index = 0;
                   5980:   found = FALSE;
                   5981:   previous = FALSE;
                   5982:   while (index < length && !found && !previous)
                   5983:     {
                   5984:       k = 0;
                   5985:       while (k < l && buf[index + k] != EOS && buf[index + k] != SPACE)
                   5986:         {
                   5987:           if (name[k] == buf[index+k])
                   5988:             k++;
                   5989:           else
                   5990:             {
                   5991:               previous = (name[k] < buf[index + k]);
                   5992:               break;
                   5993:             }
                   5994:         }
                   5995:       found = (k == l);
                   5996:       if (!previous)
                   5997:         {
                   5998:           index += k;
                   5999:           while (buf[index] != EOS && buf[index] != SPACE)
                   6000:             index++;
                   6001:           if (buf[index] == SPACE)
                   6002:             index++;
                   6003:         }
                   6004:     }
                   6005:   
                   6006:   if (!found)
                   6007:     /* this class name is not known, append it */
                   6008:     {
                   6009:       l++; /* add a space before */
                   6010:       if (css->lg_class_list <= length + l)
                   6011:         {
                   6012:           // increase the list size
                   6013:           if (l > 200)
                   6014:             add = l + 1;
                   6015:           else
                   6016:             add = 200 ;
                   6017:           buf = (char *)TtaRealloc (buf, css->lg_class_list + (add * sizeof (char)));
                   6018:           if (buf == NULL)
                   6019:             return;
                   6020:           else
                   6021:             {
                   6022:             css->class_list = buf;
                   6023:             memset (&buf[css->lg_class_list], 0, add);
                   6024:             css->lg_class_list += add;
                   6025:             }
                   6026:         }
                   6027: 
                   6028:       if (previous)
                   6029:         {
                   6030:           // move the tail of the current list
                   6031:           for (k = length; k >= index; k--)
                   6032:             buf[k+l] = buf[k];
                   6033:           /* add this new class name at the current position */
                   6034:            strcpy (&buf[index], name);
                   6035:           buf[index + l - 1] = SPACE;
                   6036:         }
                   6037:       else
                   6038:         {
                   6039:           /* add this new class name at the end */
                   6040:           if (index != 0)
                   6041:             buf[index++] = SPACE;
                   6042:           strcpy (&buf[index], name);
                   6043:         }
                   6044:      }
                   6045: }
                   6046: 
1.68      cvs      6047: 
1.1       cvs      6048: /*----------------------------------------------------------------------
1.207     vatton   6049:   ParseGenericSelector: Create a generic context for a given selector
                   6050:   string.
                   6051:   If the selector is made of multiple comma, it parses them one at a time
                   6052:   and return the end of the selector string to be handled or NULL.
1.231     vatton   6053:   The parameter ctxt gives the current style context which will be passed
                   6054:   to Thotlib.
                   6055:   The parameter css points to the current CSS context.
                   6056:   The parameter link points to the link element.
                   6057:   The parameter url gives the URL of the parsed style sheet.
1.1       cvs      6058:   ----------------------------------------------------------------------*/
1.207     vatton   6059: static char *ParseGenericSelector (char *selector, char *cssRule,
1.327     vatton   6060:                                    GenericContext ctxt, Document doc,
                   6061:                                    CSSInfoPtr css, Element link, char *url)
1.79      cvs      6062: {
                   6063:   ElementType        elType;
                   6064:   PSchema            tsch;
1.119     vatton   6065:   AttributeType      attrType;
1.240     quint    6066:   char              *deb, *cur, *sel, *next, c;
1.317     vatton   6067:   char              *schemaName, *mappedName, *saveURL;
1.79      cvs      6068:   char              *names[MAX_ANCESTORS];
1.355     quint    6069:   ThotBool           pseudoFirstChild[MAX_ANCESTORS];
1.340     quint    6070:   ElemRel            rel[MAX_ANCESTORS];
                   6071:   char              *attrnames[MAX_ANCESTORS];
                   6072:   int                attrnums[MAX_ANCESTORS];
                   6073:   int                attrlevels[MAX_ANCESTORS];
1.79      cvs      6074:   char              *attrvals[MAX_ANCESTORS];
1.133     vatton   6075:   AttrMatch          attrmatch[MAX_ANCESTORS];
1.340     quint    6076:   int                nbnames, nbattrs;
                   6077:   int                i, j;
1.256     vatton   6078:   int                att, kind;
1.118     vatton   6079:   int                specificity, xmlType;
1.217     vatton   6080:   int                skippedNL;
1.79      cvs      6081:   ThotBool           isHTML;
1.347     quint    6082:   ThotBool           level, quoted, doubleColon;
1.340     quint    6083: #define ATTR_ID 1
                   6084: #define ATTR_CLASS 2
                   6085: #define ATTR_PSEUDO 3
1.1       cvs      6086: 
1.207     vatton   6087:   sel = ctxt->sel;
1.82      cvs      6088:   sel[0] = EOS;
1.117     vatton   6089:   specificity = 0;
1.1       cvs      6090:   for (i = 0; i < MAX_ANCESTORS; i++)
                   6091:     {
1.25      cvs      6092:       names[i] = NULL;
1.355     quint    6093:       pseudoFirstChild[i] = FALSE;
1.340     quint    6094:       rel[i] = RelAncestor;
                   6095:       attrnames[i] = NULL;
                   6096:       attrnums[i] = 0;
                   6097:       attrlevels[i] = 0;
1.25      cvs      6098:       attrvals[i] = NULL;
1.133     vatton   6099:       attrmatch[i] = Txtmatch;
1.25      cvs      6100:       ctxt->name[i] = 0;
1.355     quint    6101:       ctxt->firstChild[i] = FALSE;
1.25      cvs      6102:       ctxt->attrType[i] = 0;
1.129     vatton   6103:       ctxt->attrLevel[i] = 0;
1.25      cvs      6104:       ctxt->attrText[i] = NULL;
1.178     quint    6105:       ctxt->attrMatch[i] = Txtmatch;
1.1       cvs      6106:     }
1.25      cvs      6107:   ctxt->box = 0;
1.312     quint    6108:   ctxt->var = 0;
1.306     quint    6109:   ctxt->pseudo = PbNone;
1.25      cvs      6110:   ctxt->type = 0;
1.366     vatton   6111:   DoDialog = FALSE; // not arsing for CSS dialog
1.114     quint    6112:   /* the specificity of the rule depends on the selector */
                   6113:   ctxt->cssSpecificity = 0;
1.231     vatton   6114:   /* localisation of the CSS rule */
                   6115:   ctxt->cssLine = LineNumber + NewLineSkipped;
                   6116:   ctxt->cssURL = url;
1.240     quint    6117: 
1.286     quint    6118:   skippedNL = NewLineSkipped;
1.82      cvs      6119:   selector = SkipBlanksAndComments (selector);
1.286     quint    6120:   NewLineSkipped = skippedNL;
1.27      cvs      6121:   cur = &sel[0];
1.340     quint    6122:   nbnames = 0;
                   6123:   nbattrs = 0;
1.1       cvs      6124:   while (1)
                   6125:     {
1.85      cvs      6126:       /* point to the following word in sel[] */
1.27      cvs      6127:       deb = cur;
1.25      cvs      6128:       /* copy an item of the selector into sel[] */
1.1       cvs      6129:       /* put one word in the sel buffer */
1.82      cvs      6130:       while (*selector != EOS && *selector != ',' &&
                   6131:              *selector != '.' && *selector != ':' &&
1.118     vatton   6132:              *selector != '#' && *selector != '[' &&
1.250     vatton   6133:              *selector != '>' && *selector != '+' &&
1.327     vatton   6134:              !TtaIsBlank (selector))
                   6135:         *cur++ = *selector++;
1.82      cvs      6136:       *cur++ = EOS; /* close the first string  in sel[] */
                   6137:       if (deb[0] != EOS)
1.340     quint    6138:         /* the selector starts with an element name */
1.327     vatton   6139:         {
                   6140:           if (deb[0] <= 64 && deb[0] != '*')
                   6141:             {
                   6142:               CSSPrintError ("Invalid element", deb);
                   6143:               return NULL;
                   6144:             }
                   6145:           else
                   6146:             {
                   6147:               names[0] = deb;
                   6148:               if (!strcmp (names[0], "html"))
                   6149:                 /* give a greater priority to the backgoud color of html */
                   6150:                 specificity += 3;
                   6151:               else
                   6152:                 /* selector "*" has specificity zero */
                   6153:                 if (strcmp (names[0], "*"))
                   6154:                   specificity += 1;
                   6155:             }
                   6156:         }
1.25      cvs      6157:       else
1.340     quint    6158:         names[0] = NULL; /* no element name */
1.226     quint    6159: 
1.340     quint    6160:       rel[0] = RelVoid;
1.25      cvs      6161: 
1.27      cvs      6162:       /* now names[0] points to the beginning of the parsed item
1.340     quint    6163:          and cur to the next string to be parsed */
1.129     vatton   6164:       while (*selector == '.' || *selector == ':' ||
1.327     vatton   6165:              *selector == '#' || *selector == '[')
                   6166:         {
                   6167:           /* point to the following word in sel[] */
                   6168:           deb = cur;
                   6169:           if (*selector == '.')
1.340     quint    6170:             /* class */
1.327     vatton   6171:             {
                   6172:               selector++;
1.340     quint    6173:               while (*selector != '.' && *selector != ':' &&
                   6174:                      *selector != '#' && *selector != '[' &&
                   6175:                      *selector != EOS && *selector != ',' &&
                   6176:                      *selector != '+' && *selector != '>' &&
1.327     vatton   6177:                      !TtaIsBlank (selector))
                   6178:                 {
                   6179:                   if (*selector == '\\')
                   6180:                     {
                   6181:                       selector++;
                   6182:                       if (*selector != EOS)
                   6183:                         *cur++ = *selector++;
                   6184:                     }
                   6185:                   else
                   6186:                     *cur++ = *selector++;
                   6187:                 }
                   6188:               /* close the word */
                   6189:               *cur++ = EOS;
1.340     quint    6190:               /* point to the class in sel[] if it's a valid name */
1.327     vatton   6191:               if (deb[0] <= 64)
                   6192:                 {
                   6193:                   CSSPrintError ("Invalid class", deb);
                   6194:                   DoApply = FALSE;
                   6195:                 }
                   6196:               else
                   6197:                 {
1.340     quint    6198:                   /* simulate selector [class ~= "xxx"] */
                   6199:                   nbattrs++;
                   6200:                   if (nbattrs == MAX_ANCESTORS)
                   6201:                     /* abort parsing */
                   6202:                     {
                   6203:                       CSSPrintError ("Selector too long", deb);
                   6204:                       return (selector);
                   6205:                     }
                   6206:                   for (i = nbattrs; i > 0; i--)
                   6207:                     {
                   6208:                       attrnames[i] = attrnames[i - 1];
                   6209:                       attrnums[i] = attrnums[i - 1];
                   6210:                       attrlevels[i] = attrlevels[i - 1];
                   6211:                       attrvals[i] = attrvals[i - 1];
                   6212:                       attrmatch[i] = attrmatch[i - 1];
                   6213:                     }
                   6214:                   attrnames[0] = NULL;
                   6215:                   attrnums[0] = ATTR_CLASS;
                   6216:                   attrlevels[0] = 0;
                   6217:                   attrmatch[0] = Txtword;
                   6218:                   attrvals[0] = deb;
1.327     vatton   6219:                   specificity += 10;
1.343     vatton   6220:                  }
1.327     vatton   6221:             }
                   6222:           else if (*selector == ':')
1.340     quint    6223:             /* pseudo-class or pseudo-element */
1.327     vatton   6224:             {
                   6225:               selector++;
1.347     quint    6226:               doubleColon = FALSE;
                   6227:               if (*selector == ':')
                   6228:                 /* it's a double "::". Probably CSS3 syntax */
                   6229:                 {
                   6230:                   selector++;
                   6231:                   doubleColon = TRUE;
                   6232:                 }
1.340     quint    6233:               while (*selector != '.' && *selector != ':' &&
                   6234:                      *selector != '#' && *selector != '[' &&
                   6235:                      *selector != EOS && *selector != ',' &&
                   6236:                      *selector != '+' && *selector != '>' &&
1.327     vatton   6237:                      !TtaIsBlank (selector))
                   6238:                 *cur++ = *selector++;
                   6239:               /* close the word */
                   6240:               *cur++ = EOS;
1.340     quint    6241:               /* point to the pseudo-class or pseudo-element in sel[] if it's
                   6242:                  a valid name */
1.355     quint    6243:               if (!strcmp (deb, "first-child"))
                   6244:                 /* first-child pseudo-class */
1.327     vatton   6245:                 {
1.355     quint    6246:                   pseudoFirstChild[0] = TRUE;
                   6247:                   specificity += 10;
1.327     vatton   6248:                 }
1.355     quint    6249:               else if (!strcmp (deb, "link") || !strcmp (deb, "visited"))
                   6250:                 /* link or visited pseudo-classes */
1.327     vatton   6251:                 {
1.355     quint    6252:                   nbattrs++;
                   6253:                   if (nbattrs == MAX_ANCESTORS)
                   6254:                     /* abort parsing */
1.347     quint    6255:                     {
1.355     quint    6256:                       CSSPrintError ("Selector too long", deb);
                   6257:                       return (selector);
1.347     quint    6258:                     }
1.355     quint    6259:                   for (i = nbattrs; i > 0; i--)
1.347     quint    6260:                     {
1.355     quint    6261:                       attrnames[i] = attrnames[i - 1];
                   6262:                       attrnums[i] = attrnums[i - 1];
                   6263:                       attrlevels[i] = attrlevels[i - 1];
                   6264:                       attrvals[i] = attrvals[i - 1];
                   6265:                       attrmatch[i] = attrmatch[i - 1];
1.347     quint    6266:                     }
1.355     quint    6267:                   attrnames[0] = NULL;
                   6268:                   attrnums[0] = ATTR_PSEUDO;
                   6269:                   attrlevels[0] = 0;
                   6270:                   attrmatch[0] = Txtmatch;
                   6271:                   attrvals[0] = deb;
                   6272:                   specificity += 10;
                   6273:                 }
                   6274:               else if (!strcmp (deb, "hover") || !strcmp (deb, "active") ||
                   6275:                        !strcmp (deb, "focus"))
                   6276:                 /* hover, active, focus pseudo-classes */
                   6277:                 {
                   6278:                   specificity += 10;
                   6279:                   /* not supported */
                   6280:                   DoApply = FALSE;
                   6281:                 }
                   6282:               else if (!strncmp (deb, "lang", 4))
                   6283:                 /* it's the lang pseudo-class */
                   6284:                 {
                   6285:                   if (deb[4] != '(' || deb[strlen(deb)-1] != ')')
                   6286:                     /* at least one parenthesis is missing. Error */
1.327     vatton   6287:                     {
1.355     quint    6288:                       CSSPrintError ("Invalid :lang pseudo-class", deb);
                   6289:                       DoApply = FALSE;
1.327     vatton   6290:                     }
                   6291:                   else
1.355     quint    6292:                     /* simulate selector [lang|="xxx"] */
1.340     quint    6293:                     {
                   6294:                       nbattrs++;
                   6295:                       if (nbattrs == MAX_ANCESTORS)
                   6296:                         /* abort parsing */
                   6297:                         {
                   6298:                           CSSPrintError ("Selector too long", deb);
                   6299:                           return (selector);
                   6300:                         }
1.355     quint    6301:                       deb[strlen(deb)-1] = EOS;
                   6302:                       deb[4] = EOS;
1.340     quint    6303:                       for (i = nbattrs; i > 0; i--)
                   6304:                         {
                   6305:                           attrnames[i] = attrnames[i - 1];
                   6306:                           attrnums[i] = attrnums[i - 1];
                   6307:                           attrlevels[i] = attrlevels[i - 1];
                   6308:                           attrvals[i] = attrvals[i - 1];
                   6309:                           attrmatch[i] = attrmatch[i - 1];
                   6310:                         }
1.355     quint    6311:                       attrnames[0] = deb;
                   6312:                       attrnums[0] = 0;
1.340     quint    6313:                       attrlevels[0] = 0;
1.355     quint    6314:                       attrmatch[0] = Txtsubstring;
                   6315:                       attrvals[0] = &deb[5];
                   6316:                       specificity += 10;
1.340     quint    6317:                     }
1.327     vatton   6318:                 }
1.355     quint    6319:               else if (!strcmp (deb, "first-line") ||
                   6320:                        !strcmp (deb, "first-letter"))
                   6321:                 /* pseudo-elements first-line or first-letter */
                   6322:                 {
                   6323:                   if (doubleColon)
                   6324:                     CSSPrintError ("Warning: \"::\" is CSS3 syntax", NULL);
                   6325:                   specificity += 1;
                   6326:                   /* not supported */
                   6327:                   DoApply = FALSE;
                   6328:                 }
                   6329:               else if (!strncmp (deb, "before", 6))
                   6330:                 /* pseudo-element before */
                   6331:                 {
                   6332:                   if (doubleColon)
                   6333:                     CSSPrintError ("Warning: \"::before\" is CSS3 syntax",
                   6334:                                    NULL);
                   6335:                   ctxt->pseudo = PbBefore;
                   6336:                   specificity += 1;
                   6337:                 }
                   6338:               else if (!strncmp (deb, "after", 5))
                   6339:                 /* pseudo-element after */
                   6340:                 {
                   6341:                   if (doubleColon)
                   6342:                     CSSPrintError ("Warning: \"::after\" is CSS3 syntax",
                   6343:                                    NULL);
                   6344:                   ctxt->pseudo = PbAfter;
                   6345:                   specificity += 1;
                   6346:                 }
                   6347:               else
                   6348:                 {
                   6349:                   CSSPrintError ("Invalid pseudo-element", deb);
                   6350:                   DoApply = FALSE;
                   6351:                 }
                   6352:               if (names[0] && !strcmp (names[0], "*"))
                   6353:                 names[0] = NULL;
1.327     vatton   6354:             }
                   6355:           else if (*selector == '#')
1.340     quint    6356:             /* unique identifier */
1.327     vatton   6357:             {
                   6358:               selector++;
1.340     quint    6359:               while (*selector != '.' && *selector != ':' &&
                   6360:                      *selector != '#' && *selector != '[' &&
                   6361:                      *selector != '+' && *selector != '>' &&
                   6362:                      *selector != EOS && *selector != ',' &&
1.327     vatton   6363:                      !TtaIsBlank (selector))
                   6364:                 *cur++ = *selector++;
                   6365:               /* close the word */
                   6366:               *cur++ = EOS;
                   6367:               /* point to the attribute in sel[] if it's valid name */
                   6368:               if (deb[0] <= 64)
                   6369:                 {
                   6370:                   CSSPrintError ("Invalid id", deb);
                   6371:                   DoApply = FALSE;
                   6372:                 }
                   6373:               else
                   6374:                 {
1.340     quint    6375:                   nbattrs++;
                   6376:                   if (nbattrs == MAX_ANCESTORS)
                   6377:                     /* abort parsing */
                   6378:                     {
                   6379:                       CSSPrintError ("Selector too long", deb);
                   6380:                       return (selector);
                   6381:                     }
                   6382:                   for (i = nbattrs; i > 0; i--)
                   6383:                     {
                   6384:                       attrnames[i] = attrnames[i - 1];
                   6385:                       attrnums[i] = attrnums[i - 1];
                   6386:                       attrlevels[i] = attrlevels[i - 1];
                   6387:                       attrvals[i] = attrvals[i - 1];
                   6388:                       attrmatch[i] = attrmatch[i - 1];
                   6389:                     }
                   6390:                   attrnames[0] = NULL;
                   6391:                   attrnums[0] = ATTR_ID;
                   6392:                   attrlevels[0] = 0;
                   6393:                   attrmatch[0] = Txtmatch;
                   6394:                   attrvals[0] = deb;
                   6395:                   specificity += 100;
                   6396:                   if (names[0] && !strcmp (names[0], "*"))
                   6397:                     names[0] = NULL;
1.327     vatton   6398:                 }
                   6399:             }
                   6400:           else if (*selector == '[')
                   6401:             {
                   6402:               selector++;
1.341     quint    6403:               selector = SkipBlanksAndComments (selector);
1.327     vatton   6404:               while (*selector != EOS && *selector != ']' &&
                   6405:                      *selector != '=' && *selector != '~' &&
1.341     quint    6406:                      *selector != '|' && *selector != '^' &&
                   6407:                      !TtaIsBlank (selector))
1.327     vatton   6408:                 *cur++ = *selector++;
1.341     quint    6409:               /* close the word (attribute name) */
1.327     vatton   6410:               *cur++ = EOS;
                   6411:               /* point to the attribute in sel[] if it's valid name */
                   6412:               if (deb[0] <= 64)
                   6413:                 {
                   6414:                   CSSPrintError ("Invalid attribute", deb);
                   6415:                   DoApply = FALSE;
                   6416:                 }
                   6417:               else
                   6418:                 {
1.340     quint    6419:                   nbattrs++;
                   6420:                   if (nbattrs == MAX_ANCESTORS)
                   6421:                     /* abort parsing */
                   6422:                     {
                   6423:                       CSSPrintError ("Selector too long", deb);
                   6424:                       return (selector);
                   6425:                     }
                   6426:                   for (i = nbattrs; i > 0; i--)
                   6427:                     {
                   6428:                       attrnames[i] = attrnames[i - 1];
                   6429:                       attrnums[i] = attrnums[i - 1];
                   6430:                       attrlevels[i] = attrlevels[i - 1];
                   6431:                       attrvals[i] = attrvals[i - 1];
                   6432:                       attrmatch[i] = attrmatch[i - 1];
                   6433:                     }
                   6434:                   attrnames[0] = deb;
                   6435:                   attrnums[0] = 0;
                   6436:                   attrlevels[0] = 0;
1.327     vatton   6437:                   specificity += 10;
1.340     quint    6438:                   /* check matching */
1.341     quint    6439:                   selector = SkipBlanksAndComments (selector);
1.340     quint    6440:                   if (*selector == '~')
                   6441:                     {
                   6442:                       attrmatch[0] = Txtword;
                   6443:                       selector++;
                   6444:                     }
                   6445:                   else if (*selector == '|')
                   6446:                     {
                   6447:                       attrmatch[0] = Txtsubstring;
                   6448:                       selector++;
                   6449:                     }
1.341     quint    6450:                   else if (*selector == '^')
                   6451:                     {
                   6452:                       attrmatch[0] = Txtsubstring;
                   6453:                       selector++;
                   6454:                     }
1.340     quint    6455:                   else
                   6456:                     attrmatch[0] = Txtmatch;
1.327     vatton   6457:                 }
                   6458:               if (*selector == '=')
                   6459:                 {
                   6460:                   /* look for a value "xxxx" */
                   6461:                   selector++;
1.341     quint    6462:                   selector = SkipBlanksAndComments (selector);
1.327     vatton   6463:                   if (*selector != '"')
                   6464:                     quoted = FALSE;
                   6465:                   else
                   6466:                     {
                   6467:                       quoted = TRUE;
                   6468:                       /* we are now parsing the attribute value */
                   6469:                       selector++;
                   6470:                     }
                   6471:                   deb = cur;
                   6472:                   while ((quoted &&
                   6473:                           (*selector != '"' ||
                   6474:                            (*selector == '"' && selector[-1] == '\\'))) ||
                   6475:                          (!quoted && *selector != ']'))
                   6476:                     {
                   6477:                       if (*selector == EOS)
                   6478:                         {
                   6479:                           CSSPrintError ("Invalid attribute value", deb);
                   6480:                           DoApply = FALSE;
                   6481:                         }
                   6482:                       else
                   6483:                         {
                   6484:                           if (attrmatch[0] == Txtword && TtaIsBlank (selector))
                   6485:                             {
                   6486:                               CSSPrintError ("No space allowed here: ", selector);
                   6487:                               DoApply = FALSE;
                   6488:                             }
                   6489:                           *cur++ = *selector;
                   6490:                         }
                   6491:                       selector++;
                   6492:                     }
                   6493:                   /* there is a value */
                   6494:                   if (quoted && *selector == '"')
                   6495:                     {
                   6496:                       selector++;
                   6497:                       quoted = FALSE;
                   6498:                     }
1.341     quint    6499:                   selector = SkipBlanksAndComments (selector);
1.327     vatton   6500:                   if (*selector != ']')
                   6501:                     {
                   6502:                       CSSPrintError ("Invalid attribute value", deb);
                   6503:                       DoApply = FALSE;
                   6504:                     }
                   6505:                   else
                   6506:                     {
                   6507:                       *cur++ = EOS;
                   6508:                       attrvals[0] = deb;
                   6509:                       selector++;
                   6510:                     }
                   6511:                 }
                   6512:               /* end of the attribute */
                   6513:               else if (*selector != ']')
                   6514:                 {
                   6515:                   selector[1] = EOS;
                   6516:                   CSSPrintError ("Invalid attribute", selector);
                   6517:                   selector += 2;
                   6518:                   DoApply = FALSE;
                   6519:                 }
                   6520:               else
                   6521:                 {
                   6522:                   selector++;
                   6523:                   if (names[0] && !strcmp (names[0], "*"))
                   6524:                     names[0] = NULL;
                   6525:                 }
                   6526:             }
                   6527:           else
                   6528:             {
                   6529:               /* not supported selector */
1.340     quint    6530:               while (*selector != '.' && *selector != ':' &&
                   6531:                      *selector != '#' && *selector != '[' &&
                   6532:                      *selector != EOS && *selector != ',' &&
                   6533:                      *selector != '+' && *selector != '>' &&
1.327     vatton   6534:                      !TtaIsBlank (selector))
                   6535:                 *cur++ = *selector++;
                   6536:               /* close the word */
                   6537:               *cur++ = EOS;
                   6538:               CSSPrintError ("Selector not supported:", deb);
                   6539:               DoApply = FALSE;     
                   6540:             }
                   6541:         }
1.1       cvs      6542: 
1.286     quint    6543:       skippedNL = NewLineSkipped;
1.82      cvs      6544:       selector = SkipBlanksAndComments (selector);
1.286     quint    6545:       NewLineSkipped = skippedNL;
                   6546: 
1.25      cvs      6547:       /* is it a multi-level selector? */
1.82      cvs      6548:       if (*selector == EOS)
1.327     vatton   6549:         /* end of the selector */
                   6550:         break;
1.82      cvs      6551:       else if (*selector == ',')
1.327     vatton   6552:         {
                   6553:           /* end of the current selector */
                   6554:           selector++;
                   6555:           skippedNL = NewLineSkipped;
                   6556:           next = SkipBlanksAndComments (selector);
                   6557:           NewLineSkipped = skippedNL;
                   6558:           if (*next == EOS)
                   6559:             /* nothing after the comma. Invalid selector */
                   6560:             {
                   6561:               /*CSSPrintError ("Syntax error:", selector);*/
                   6562:               return NULL;
                   6563:             }
                   6564:           break;
                   6565:         }
1.25      cvs      6566:       else
1.327     vatton   6567:         {
                   6568:           if (*selector == '>')
                   6569:             {
1.340     quint    6570:               /* handle parent */
1.327     vatton   6571:               selector++;
                   6572:               skippedNL = NewLineSkipped;
                   6573:               selector = SkipBlanksAndComments (selector);
                   6574:               NewLineSkipped = skippedNL;
1.340     quint    6575:               rel[0] = RelParent;
1.327     vatton   6576:             }
                   6577:           else if (*selector == '+')
                   6578:             {
1.340     quint    6579:               /* handle immediate sibling */
1.327     vatton   6580:               selector++;
                   6581:               skippedNL = NewLineSkipped;
                   6582:               selector = SkipBlanksAndComments (selector);
                   6583:               NewLineSkipped = skippedNL;
                   6584:               rel[0] = RelPrevious;
                   6585:             }
1.340     quint    6586:           else
                   6587:             rel[0] = RelAncestor;
                   6588:           nbnames++; /* a new level in ancestor tables */
                   6589:           if (nbnames == MAX_ANCESTORS)
                   6590:             /* abort parsing */
                   6591:             {
                   6592:               CSSPrintError ("Selector too long", deb);
                   6593:               return (selector);
                   6594:             }
                   6595:           /* shift the list to make room for the next part of the selector */
                   6596:           for (i = nbnames; i > 0; i--)
1.327     vatton   6597:             {
                   6598:               names[i] = names[i - 1];
1.355     quint    6599:               pseudoFirstChild[i] = pseudoFirstChild[i - 1];
1.327     vatton   6600:               rel[i] = rel[i - 1];
                   6601:             }
1.340     quint    6602:           /* increase the level of all attributes */
                   6603:           for (i = 0; i < nbattrs; i++)
                   6604:               attrlevels[i]++;
1.327     vatton   6605:         }
1.1       cvs      6606:     }
                   6607: 
1.343     vatton   6608:   /* Now update the list of classes defined by the CSS */
                   6609:   for (i = 0; i < nbattrs; i++)
                   6610:     if (attrvals[i] && attrnums[i] == ATTR_CLASS)
                   6611:       AddClassName (attrvals[i], css);
                   6612: 
1.1       cvs      6613:   /* Now set up the context block */
1.25      cvs      6614:   i = 0;
                   6615:   j = 0;
1.91      cvs      6616:   /* default schema name */
1.119     vatton   6617:   ctxt->schema = NULL;
1.340     quint    6618:   ctxt->nbElem = nbnames;
1.122     vatton   6619:   elType.ElSSchema = NULL;
1.355     quint    6620:   elType.ElTypeNum = 0;
1.122     vatton   6621:   schemaName = TtaGetSSchemaName(TtaGetDocumentSSchema (doc));
1.119     vatton   6622:   if (!strcmp (schemaName, "HTML"))
                   6623:     xmlType = XHTML_TYPE;
                   6624:   else if (!strcmp (schemaName, "MathML"))
                   6625:     xmlType = MATH_TYPE;
                   6626:   else if (!strcmp (schemaName, "SVG"))
                   6627:     xmlType = SVG_TYPE;
                   6628:   else if (!strcmp (schemaName, "XLink"))
                   6629:     xmlType = XLINK_TYPE;
                   6630:   else if (!strcmp (schemaName, "Annot"))
                   6631:     xmlType = ANNOT_TYPE;
                   6632:   else
                   6633:     xmlType = XML_TYPE;
1.340     quint    6634:   while (i <= nbnames)
1.25      cvs      6635:     {
1.340     quint    6636:       ctxt->rel[i] = rel[i];
1.355     quint    6637:       ctxt->firstChild[i] = pseudoFirstChild[i];
                   6638:       if (!names[i] && i > 0)
1.340     quint    6639:         ctxt->name[i] = HTML_EL_ANY_TYPE;
                   6640:       else
                   6641:         /* store element information */
1.327     vatton   6642:         {
                   6643:           /* get the element type of this name in the current document */
                   6644:           if (xmlType == XML_TYPE)
                   6645:             /* it's a generic XML document. Check the main document schema */
                   6646:             {
                   6647:               elType.ElSSchema = TtaGetDocumentSSchema (doc);
1.355     quint    6648:               elType.ElTypeNum = 0;
                   6649:               if (names[i])
                   6650:                 TtaGetXmlElementType (names[i], &elType, &mappedName, doc);
1.327     vatton   6651:               if (!elType.ElTypeNum)
                   6652:                 {
1.355     quint    6653:                   if (!names[i] || !strcmp (names[i], "*"))
1.327     vatton   6654:                     elType.ElTypeNum = HTML_EL_ANY_TYPE;
                   6655:                   else
                   6656:                     elType.ElSSchema = NULL;
                   6657:                 }
                   6658:             }
                   6659:           else
                   6660:             {
1.355     quint    6661:               if (!names[i] || !strcmp (names[i], "*"))
1.327     vatton   6662:                 {
                   6663:                   elType.ElSSchema = TtaGetDocumentSSchema (doc);
                   6664:                   elType.ElTypeNum = HTML_EL_ANY_TYPE;
                   6665:                 }
                   6666:               else
                   6667:                 MapXMLElementType (xmlType, names[i], &elType, &mappedName, &c,
                   6668:                                    &level, doc);
                   6669:             }
                   6670:           if (i == 0)
1.340     quint    6671:             /* rightmost part of the selector */
1.327     vatton   6672:             {
                   6673:               if (elType.ElSSchema == NULL)
                   6674:                 {
1.340     quint    6675:                   /* element name not found. Search in all loaded schemas */
1.355     quint    6676:                   if (names[i])
                   6677:                     TtaGetXmlElementType (names[i], &elType, NULL, doc);
1.327     vatton   6678:                   if (elType.ElSSchema)
                   6679:                     {
                   6680:                       /* the element type concerns an imported nature */
                   6681:                       schemaName = TtaGetSSchemaName(elType.ElSSchema);
                   6682:                       if (!strcmp (schemaName, "HTML"))
                   6683:                         {
                   6684:                           if (xmlType == XHTML_TYPE &&
                   6685:                               DocumentMeta[doc] && DocumentMeta[doc]->xmlformat)
                   6686:                             /* the selector was found but the case is not correct */
                   6687:                             elType.ElSSchema = NULL;
                   6688:                           else
                   6689:                             xmlType = XHTML_TYPE;
                   6690:                         }
                   6691:                       else if (!strcmp (schemaName, "MathML"))
                   6692:                         xmlType = MATH_TYPE;
                   6693:                       else if (!strcmp (schemaName, "SVG"))
                   6694:                         xmlType = SVG_TYPE;
                   6695:                       else if (!strcmp (schemaName, "XLink"))
                   6696:                         xmlType = XLINK_TYPE;
                   6697:                       else if (!strcmp (schemaName, "Annot"))
                   6698:                         xmlType = ANNOT_TYPE;
                   6699:                       else
                   6700:                         xmlType = XML_TYPE;
                   6701:                     }
1.118     vatton   6702: #ifdef XML_GENERIC
1.327     vatton   6703:                   else if (xmlType == XML_TYPE)
                   6704:                     {
                   6705:                       /* Creation of a new element type in the main schema */
                   6706:                       elType.ElSSchema = TtaGetDocumentSSchema (doc);
1.355     quint    6707:                       if (names[i])
                   6708:                         TtaAppendXmlElement (names[i], &elType, &mappedName,
                   6709:                                              doc);
1.327     vatton   6710:                     }
1.118     vatton   6711: #endif /* XML_GENERIC */
1.327     vatton   6712:                   else
                   6713:                     {
                   6714:                       if (xmlType != XHTML_TYPE)
                   6715:                         {
                   6716:                           MapXMLElementType (XHTML_TYPE, names[i], &elType,
                   6717:                                              &mappedName, &c, &level, doc);
                   6718:                           if (elType.ElSSchema)
                   6719:                             elType.ElSSchema = GetXHTMLSSchema (doc);
                   6720:                         }
                   6721:                       if (elType.ElSSchema == NULL && xmlType != MATH_TYPE)
                   6722:                         {
                   6723:                           MapXMLElementType (MATH_TYPE, names[i], &elType,
                   6724:                                              &mappedName, &c, &level, doc);
                   6725:                           if (elType.ElSSchema)
                   6726:                             elType.ElSSchema = GetMathMLSSchema (doc);
                   6727:                         }
                   6728:                       if (elType.ElSSchema == NULL && xmlType != SVG_TYPE)
                   6729:                         {
                   6730:                           MapXMLElementType (SVG_TYPE, names[i], &elType,
                   6731:                                              &mappedName, &c, &level, doc);
                   6732:                           if (elType.ElSSchema)
                   6733:                             elType.ElSSchema = GetSVGSSchema (doc);
                   6734:                         }
                   6735:                     }
                   6736:                 }
                   6737: 
                   6738:               if (elType.ElSSchema == NULL)
                   6739:                 /* cannot apply these CSS rules */
                   6740:                 DoApply = FALSE;
                   6741:               else
                   6742:                 {
1.340     quint    6743:                   /* Store the element type contained in the rightmost part of
                   6744:                      the selector */
                   6745:                   ctxt->schema = elType.ElSSchema;
1.327     vatton   6746:                   ctxt->type = elType.ElTypeNum;
                   6747:                   ctxt->name[0] = elType.ElTypeNum;
1.340     quint    6748:                   ctxt->rel[0] = RelVoid;
1.327     vatton   6749:                 }
                   6750:             }
1.340     quint    6751:           else
                   6752:             /* not the rightmost part of the selector */
1.327     vatton   6753:             {
1.340     quint    6754:               if (elType.ElTypeNum != 0)
                   6755:                 ctxt->name[i] = elType.ElTypeNum;
                   6756: #ifdef XML_GENERIC
                   6757:               else if (xmlType == XML_TYPE)
1.327     vatton   6758:                 {
1.340     quint    6759:                   TtaGetXmlElementType (names[i], &elType, NULL, doc);
                   6760:                   if (elType.ElTypeNum == 0)
1.327     vatton   6761:                     {
1.340     quint    6762:                       /* Creation of a new element type in the main schema */
                   6763:                       elType.ElSSchema = TtaGetDocumentSSchema (doc);
                   6764:                       TtaAppendXmlElement (names[i], &elType, &mappedName, doc);
1.327     vatton   6765:                     }
1.340     quint    6766:                   if (elType.ElTypeNum != 0)
                   6767:                     ctxt->name[i] = elType.ElTypeNum;
1.327     vatton   6768:                 }
1.340     quint    6769: #endif /* XML_GENERIC */
1.327     vatton   6770:             }
1.340     quint    6771:         }
                   6772: 
                   6773:       /* store attribute information for this element */
                   6774:       while (j < nbattrs && attrlevels[j] <= i)
                   6775:         {
                   6776:           if (attrnames[j] || attrnums[j])
1.327     vatton   6777:             {
1.340     quint    6778:               if (attrnums[j] > 0)
1.327     vatton   6779:                 {
1.340     quint    6780:                   if (attrnums[j] == ATTR_CLASS)
1.327     vatton   6781:                     {
1.340     quint    6782:                       if (xmlType == SVG_TYPE)
                   6783:                         ctxt->attrType[j] = SVG_ATTR_class;
                   6784:                       else if (xmlType == MATH_TYPE)
                   6785:                         ctxt->attrType[j] = MathML_ATTR_class;
                   6786:                       else if (xmlType == XHTML_TYPE)
                   6787:                         ctxt->attrType[j] = HTML_ATTR_Class;
1.327     vatton   6788:                       else
1.119     vatton   6789: #ifdef XML_GENERIC
1.340     quint    6790:                         ctxt->attrType[j] = XML_ATTR_class;
1.107     cvs      6791: #else /* XML_GENERIC */
1.340     quint    6792:                         ctxt->attrType[j] = HTML_ATTR_Class;
1.107     cvs      6793: #endif /* XML_GENERIC */
1.340     quint    6794:                     }
                   6795:                   else if (attrnums[j] == ATTR_PSEUDO)
                   6796:                     {
                   6797:                       if (xmlType == SVG_TYPE)
                   6798:                         ctxt->attrType[j] = SVG_ATTR_PseudoClass;
                   6799:                       else if (xmlType == MATH_TYPE)
                   6800:                         ctxt->attrType[j] = MathML_ATTR_PseudoClass;
                   6801:                       else if (xmlType == XHTML_TYPE)
                   6802:                         ctxt->attrType[j] = HTML_ATTR_PseudoClass;
                   6803:                       else
1.119     vatton   6804: #ifdef XML_GENERIC
1.340     quint    6805:                         ctxt->attrType[j] = XML_ATTR_PseudoClass;
1.107     cvs      6806: #else /* XML_GENERIC */
1.340     quint    6807:                         ctxt->attrType[j] = HTML_ATTR_PseudoClass;
1.107     cvs      6808: #endif /* XML_GENERIC */
1.340     quint    6809:                     }
                   6810:                   else if (attrnums[j] == ATTR_ID)
                   6811:                     {
                   6812:                       if (xmlType == SVG_TYPE)
                   6813:                         ctxt->attrType[j] = SVG_ATTR_id;
                   6814:                       else if (xmlType == MATH_TYPE)
                   6815:                         ctxt->attrType[j] = MathML_ATTR_id;
                   6816:                       else if (xmlType == XHTML_TYPE)
                   6817:                         ctxt->attrType[j] = HTML_ATTR_ID;
                   6818:                       else
1.119     vatton   6819: #ifdef XML_GENERIC
1.340     quint    6820:                         ctxt->attrType[j] = XML_ATTR_xmlid;
1.107     cvs      6821: #else /* XML_GENERIC */
1.340     quint    6822:                         ctxt->attrType[j] = HTML_ATTR_ID;
1.107     cvs      6823: #endif /* XML_GENERIC */
1.340     quint    6824:                     }
                   6825:                   attrType.AttrTypeNum = ctxt->attrType[j];
                   6826:                   attrType.AttrSSchema =  ctxt->schema;
                   6827:                 }
                   6828:               else if (attrnames[j])
                   6829:                 {
                   6830:                   if (xmlType == XML_TYPE)
                   6831:                     {
                   6832:                       if (ctxt->schema)
                   6833:                         attrType.AttrSSchema = ctxt->schema;
                   6834:                       else
                   6835:                         attrType.AttrSSchema = TtaGetDocumentSSchema (doc);
                   6836:                       TtaGetXmlAttributeType (attrnames[j], &attrType, doc);
                   6837:                       att = attrType.AttrTypeNum;
                   6838:                       if (ctxt->schema == NULL && att != 0)
                   6839:                         ctxt->schema = attrType.AttrSSchema;
                   6840:                     }
                   6841:                   else
                   6842:                     {
                   6843:                       MapXMLAttribute (xmlType, attrnames[j], names[i], &level,
                   6844:                                        doc, &att);
                   6845:                       if (ctxt->schema == NULL && att != 0)
                   6846:                         ctxt->schema = TtaGetDocumentSSchema (doc);
                   6847:                     }
                   6848:                   if (att == 0 && ctxt->schema == NULL)
                   6849:                     /* Attribute name not found: Search in the list of all
                   6850:                        schemas loaded for this document */
                   6851:                     {
                   6852:                       attrType.AttrSSchema = NULL;
                   6853:                       TtaGetXmlAttributeType (attrnames[j], &attrType, doc);
                   6854:                       att = attrType.AttrTypeNum;
                   6855:                       if (att != 0)
                   6856:                         ctxt->schema = attrType.AttrSSchema;
                   6857:                     }
                   6858:                   attrType.AttrSSchema = ctxt->schema;
                   6859:                   attrType.AttrTypeNum = att;
                   6860:                   if (i == 0 && att == 0 && ctxt->schema == NULL)
                   6861:                     {
                   6862:                       /* Not found -> search in the list of loaded schemas */
                   6863:                       attrType.AttrSSchema = NULL;
                   6864:                       TtaGetXmlAttributeType (attrnames[j], &attrType, doc);
                   6865:                       att = attrType.AttrTypeNum;
                   6866:                       if (attrType.AttrSSchema)
                   6867:                         /* the element type concerns an imported nature */
                   6868:                         schemaName = TtaGetSSchemaName(attrType.AttrSSchema);
1.119     vatton   6869: #ifdef XML_GENERIC
1.340     quint    6870:                       else if (xmlType == XML_TYPE)
                   6871:                         {
                   6872:                           /* The attribute is not yet present in the tree */
                   6873:                           /* Create a new global attribute */
                   6874:                           attrType.AttrSSchema = TtaGetDocumentSSchema (doc);
                   6875:                           TtaAppendXmlAttribute (attrnames[j], &attrType, doc);
                   6876:                         }
                   6877: #endif /* XML_GENERIC */
                   6878:                       if (attrType.AttrSSchema == NULL)
                   6879:                         /* cannot apply these CSS rules */
                   6880:                         DoApply = FALSE;
                   6881:                       else if (elType.ElSSchema)
                   6882:                         ctxt->schema = elType.ElSSchema;
                   6883:                       else
                   6884:                         ctxt->schema = attrType.AttrSSchema;
                   6885:                     }
                   6886:                   if (att == 0)
                   6887:                     {
                   6888:                       CSSPrintError ("Unknown attribute", attrnames[j]);
                   6889:                       DoApply = FALSE;     
                   6890:                     }
                   6891:                   else
1.345     quint    6892:                     {
                   6893:                       ctxt->attrType[j] = att;
                   6894:                       if (att == DummyAttribute && !strcmp (schemaName,"HTML"))
                   6895:                         /* it's the "type" attribute for an "input" element.
                   6896:                            In the tree, it is represented by the element type,
                   6897:                            not by an attribute */
                   6898:                         {
                   6899:                           ctxt->attrType[j] = 0;
                   6900:                           if (attrvals[j] && attrmatch[i] == Txtmatch)
                   6901:                             /* a value is specified for attribute type. This
                   6902:                                value provides the Thot element type */
                   6903:                             {
                   6904:                               MapXMLAttributeValue (xmlType, attrvals[j],
                   6905:                                                     &attrType, &kind);
                   6906:                               /* attrType contains the element type */
                   6907:                               if (i == 0)
                   6908:                                 ctxt->type = kind;
                   6909:                               ctxt->name[i] = kind;
                   6910:                             } 
                   6911:                         }
                   6912:                     }
1.340     quint    6913:                 }
                   6914:               if (ctxt->attrType[j])
1.327     vatton   6915:                 {
1.340     quint    6916:                   /* check the attribute type */
                   6917:                   if (!strcmp (schemaName, "HTML"))
                   6918:                     xmlType = XHTML_TYPE;
                   6919:                   else if (!strcmp (schemaName, "MathML"))
                   6920:                     xmlType = MATH_TYPE;
                   6921:                   else if (!strcmp (schemaName, "SVG"))
                   6922:                     xmlType = SVG_TYPE;
                   6923:                   else if (!strcmp (schemaName, "XLink"))
                   6924:                     xmlType = XLINK_TYPE;
                   6925:                   else if (!strcmp (schemaName, "Annot"))
                   6926:                     xmlType = ANNOT_TYPE;
                   6927:                   else
                   6928:                     xmlType = XML_TYPE;
                   6929:                   kind = TtaGetAttributeKind (attrType);
                   6930:                   if (kind == 0 && attrvals[j])
                   6931:                     {
                   6932:                       /* enumerated value */
                   6933:                       MapXMLAttributeValue (xmlType, attrvals[j], &attrType,
                   6934:                                             &kind);
                   6935:                       /* store the attribute value */
                   6936:                       ctxt->attrText[j] = (char *) kind;
                   6937:                     }
                   6938:                   else
                   6939:                     ctxt->attrText[j] = attrvals[j];
                   6940:                   /* update attrLevel */
                   6941:                   ctxt->attrMatch[j] = attrmatch[j];
                   6942:                   ctxt->attrLevel[j] = attrlevels[j];
                   6943:                     }
                   6944:               j++;
1.327     vatton   6945:             }
                   6946:         }
1.340     quint    6947:       /* add a new entry */
1.25      cvs      6948:       i++;
1.119     vatton   6949:       if (i == 1 && ctxt->schema == NULL)
1.327     vatton   6950:         /* use the document schema */
                   6951:         ctxt->schema = TtaGetDocumentSSchema (doc);
1.1       cvs      6952:     }
1.340     quint    6953: 
1.312     quint    6954:   ctxt->important = FALSE;
1.117     vatton   6955:   /* set the selector specificity */
                   6956:   ctxt->cssSpecificity = specificity;
1.25      cvs      6957:   /* Get the schema name of the main element */
1.119     vatton   6958:   schemaName = TtaGetSSchemaName (ctxt->schema);
                   6959:   isHTML = (strcmp (schemaName, "HTML") == 0);
1.206     vatton   6960:   tsch = GetPExtension (doc, ctxt->schema, css, link);
1.217     vatton   6961:   skippedNL = NewLineSkipped;
1.119     vatton   6962:   if (tsch && cssRule)
1.317     vatton   6963:     {
                   6964:       if (css)
1.327     vatton   6965:         {
                   6966:           /* point the right URL for loaded images */
                   6967:           saveURL = css->url;
                   6968:           css->url = url;
                   6969:         }
1.317     vatton   6970:       else
1.327     vatton   6971:         saveURL = NULL;
                   6972:       ParseCSSRule (NULL, tsch, (PresentationContext) ctxt, cssRule, css, isHTML);
1.317     vatton   6973:       if (css)
1.327     vatton   6974:         /* restore previous url */
                   6975:         css->url = saveURL;
1.317     vatton   6976:     }
1.116     vatton   6977:   /* future CSS rules should apply */
                   6978:   DoApply = TRUE;
1.217     vatton   6979:   if (selector)
                   6980:     NewLineSkipped = skippedNL;
1.1       cvs      6981:   return (selector);
                   6982: }
                   6983: 
                   6984: /*----------------------------------------------------------------------
1.206     vatton   6985:   ParseStyleDeclaration: parse a style declaration stored in the style
                   6986:   element of a document                       
                   6987:   We expect the style string to be of the form:                   
                   6988:   .pinky, .awful { color: pink; font-family: helvetica }        
1.231     vatton   6989:   The parameter css points to the current CSS context.
                   6990:   The parameter link points to the link element.
                   6991:   The parameter url gives the URL of the parsed style sheet.
1.1       cvs      6992:   ----------------------------------------------------------------------*/
1.206     vatton   6993: static void ParseStyleDeclaration (Element el, char *cssRule, Document doc,
1.327     vatton   6994:                                    CSSInfoPtr css, Element link, char *url,
                   6995:                                    ThotBool destroy)
1.1       cvs      6996: {
1.79      cvs      6997:   GenericContext      ctxt;
                   6998:   char               *decl_end;
                   6999:   char               *sel_end;
                   7000:   char               *selector;
1.1       cvs      7001: 
                   7002:   /* separate the selectors string */
1.82      cvs      7003:   cssRule = SkipBlanksAndComments (cssRule);
1.1       cvs      7004:   decl_end = cssRule;
1.82      cvs      7005:   while (*decl_end != EOS && *decl_end != '{')
1.286     quint    7006:     {
                   7007:       if (*decl_end == EOL)
1.327     vatton   7008:         NewLineSkipped++;
1.286     quint    7009:       decl_end++;
                   7010:     }
1.82      cvs      7011:   if (*decl_end == EOS)
1.86      cvs      7012:     {
1.168     vatton   7013:       CSSPrintError ("Invalid selector", cssRule);
1.86      cvs      7014:       return;
                   7015:     }
1.1       cvs      7016:   /* verify and clean the selector string */
                   7017:   sel_end = decl_end - 1;
1.82      cvs      7018:   while (*sel_end == SPACE || *sel_end == BSPACE ||
1.327     vatton   7019:          *sel_end == EOL || *sel_end == CR)
1.1       cvs      7020:     sel_end--;
                   7021:   sel_end++;
1.82      cvs      7022:   *sel_end = EOS;
1.1       cvs      7023:   selector = cssRule;
                   7024: 
                   7025:   /* now, deal with the content ... */
                   7026:   decl_end++;
                   7027:   cssRule = decl_end;
1.137     vatton   7028:   decl_end = &cssRule[strlen (cssRule) - 1];
                   7029:   if (*decl_end != '{')
                   7030:     *decl_end = EOS;
1.1       cvs      7031:   /*
                   7032:    * parse the style attribute string and install the corresponding
                   7033:    * presentation attributes on the new element
                   7034:    */
                   7035:   ctxt = TtaGetGenericStyleContext (doc);
                   7036:   if (ctxt == NULL)
                   7037:     return;
                   7038:   ctxt->destroy = destroy;
1.207     vatton   7039:   /* first use of the context */
                   7040:   ctxt->uses = 1;
1.197     vatton   7041:   while (selector && *selector != EOS)
1.363     vatton   7042:     {
                   7043:       if (ctxt->uses > 1)
                   7044:         {
                   7045:           /* this context is waiting for a callback */
                   7046:           ctxt = TtaGetGenericStyleContext (doc);
                   7047:           if (ctxt == NULL)
                   7048:             return;
                   7049:           ctxt->destroy = destroy;
                   7050:           /* first use of the context */
                   7051:           ctxt->uses = 1; 
                   7052:         }
                   7053:       selector = ParseGenericSelector (selector, cssRule, ctxt, doc, css,
                   7054:                                        link, url);
                   7055:     }
1.207     vatton   7056:   /* check if the context can be freed */
                   7057:   ctxt->uses -= 1;
                   7058:   if (ctxt->uses == 0)
                   7059:     /* no image loading */
                   7060:     TtaFreeMemory (ctxt);
1.1       cvs      7061: }
                   7062: 
                   7063: /************************************************************************
                   7064:  *                                                                     *  
                   7065:  *     EVALUATION FUNCTIONS / CASCADING AND OVERLOADING                *
                   7066:  *                                                                     *  
                   7067:  ************************************************************************/
                   7068: 
                   7069: /*----------------------------------------------------------------------
1.327     vatton   7070:   IsImplicitClassName: return wether the Class name is an        
                   7071:   implicit one, eg "H1" or "H2 EM" meaning it's a GI name       
                   7072:   or an HTML context name.                                      
1.1       cvs      7073:   ----------------------------------------------------------------------*/
1.248     gully    7074: int IsImplicitClassName (char *class_, Document doc)
1.1       cvs      7075: {
1.327     vatton   7076:   char         name[200];
                   7077:   char        *cur = name;
                   7078:   char        *first; 
                   7079:   char         save;
                   7080:   SSchema      schema;
                   7081: 
                   7082:   /* make a local copy */
                   7083:   strncpy (name, class_, 199);
                   7084:   name[199] = 0;
                   7085: 
                   7086:   /* loop looking if each word is a GI */
                   7087:   while (*cur != 0)
                   7088:     {
                   7089:       first = cur;
                   7090:       cur = SkipWord (cur);
                   7091:       save = *cur;
                   7092:       *cur = 0;
                   7093:       schema = NULL;
                   7094:       if (MapGI (first, &schema, doc) == -1)
                   7095:         {
                   7096:           return (0);
                   7097:         }
                   7098:       *cur = save;
                   7099:       cur = SkipBlanksAndComments (cur);
                   7100:     }
                   7101:   return (1);
1.1       cvs      7102: }
                   7103: 
                   7104: /************************************************************************
1.114     quint    7105:  *  Functions needed for support of HTML: translate to CSS equivalent   *
1.1       cvs      7106:  ************************************************************************/
                   7107: 
                   7108: /*----------------------------------------------------------------------
1.327     vatton   7109:   HTMLSetBackgroundColor:
1.1       cvs      7110:   ----------------------------------------------------------------------*/
1.264     vatton   7111: void HTMLSetBackgroundColor (Document doc, Element el, int specificity,
1.327     vatton   7112:                              char *color)
1.1       cvs      7113: {
1.350     vatton   7114:   char             css_command[1000];
1.1       cvs      7115: 
1.327     vatton   7116:   sprintf (css_command, "background-color: %s", color);
                   7117:   ParseHTMLSpecificStyle (el, css_command, doc, specificity, FALSE);
1.1       cvs      7118: }
                   7119: 
                   7120: /*----------------------------------------------------------------------
1.327     vatton   7121:   HTMLSetForegroundColor:                                        
1.1       cvs      7122:   ----------------------------------------------------------------------*/
1.264     vatton   7123: void HTMLSetForegroundColor (Document doc, Element el, int specificity,
1.327     vatton   7124:                              char *color)
1.1       cvs      7125: {
1.350     vatton   7126:   char           css_command[1000];
1.1       cvs      7127: 
1.327     vatton   7128:   sprintf (css_command, "color: %s", color);
                   7129:   ParseHTMLSpecificStyle (el, css_command, doc, specificity, FALSE);
1.1       cvs      7130: }
                   7131: 
                   7132: /*----------------------------------------------------------------------
1.327     vatton   7133:   HTMLResetBackgroundColor:                                      
1.1       cvs      7134:   ----------------------------------------------------------------------*/
1.97      vatton   7135: void HTMLResetBackgroundColor (Document doc, Element el)
1.1       cvs      7136: {
1.350     vatton   7137:   char           css_command[1000];
1.1       cvs      7138: 
1.327     vatton   7139:   sprintf (css_command, "background: red");
                   7140:   ParseHTMLSpecificStyle (el, css_command, doc, 0, TRUE);
1.1       cvs      7141: }
                   7142: 
                   7143: /*----------------------------------------------------------------------
1.327     vatton   7144:   HTMLResetBackgroundImage:                                      
1.1       cvs      7145:   ----------------------------------------------------------------------*/
1.97      vatton   7146: void HTMLResetBackgroundImage (Document doc, Element el)
1.1       cvs      7147: {
1.327     vatton   7148:   char           css_command[1000];
1.1       cvs      7149: 
1.327     vatton   7150:   sprintf (css_command, "background-image: url(xx); background-repeat: repeat");
                   7151:   ParseHTMLSpecificStyle (el, css_command, doc, 0, TRUE);
1.1       cvs      7152: }
                   7153: 
                   7154: /*----------------------------------------------------------------------
1.327     vatton   7155:   HTMLResetForegroundColor:                                      
1.1       cvs      7156:   ----------------------------------------------------------------------*/
1.97      vatton   7157: void HTMLResetForegroundColor (Document doc, Element el)
1.1       cvs      7158: {
1.350     vatton   7159:   char           css_command[1000];
1.1       cvs      7160: 
1.327     vatton   7161:   /* it's not necessary to well know the current color but it must be valid */
                   7162:   sprintf (css_command, "color: red");
                   7163:   ParseHTMLSpecificStyle (el, css_command, doc, 0, TRUE);
1.1       cvs      7164: }
                   7165: 
                   7166: /*----------------------------------------------------------------------
1.327     vatton   7167:   HTMLSetAlinkColor:                                             
1.1       cvs      7168:   ----------------------------------------------------------------------*/
1.208     vatton   7169: void HTMLSetAlinkColor (Document doc, Element el, char *color)
1.1       cvs      7170: {
1.350     vatton   7171:   char           css_command[1000];
1.1       cvs      7172: 
1.327     vatton   7173:   sprintf (css_command, ":link { color: %s }", color);
                   7174:   ApplyCSSRules (el, css_command, doc, FALSE);
1.1       cvs      7175: }
                   7176: 
                   7177: /*----------------------------------------------------------------------
1.327     vatton   7178:   HTMLSetAactiveColor:                                           
1.1       cvs      7179:   ----------------------------------------------------------------------*/
1.208     vatton   7180: void HTMLSetAactiveColor (Document doc, Element el, char *color)
1.1       cvs      7181: {
1.350     vatton   7182:   char           css_command[1000];
1.1       cvs      7183: 
1.327     vatton   7184:   sprintf (css_command, ":active { color: %s }", color);
                   7185:   ApplyCSSRules (el, css_command, doc, FALSE);
1.1       cvs      7186: }
                   7187: 
                   7188: /*----------------------------------------------------------------------
1.327     vatton   7189:   HTMLSetAvisitedColor:                                          
1.1       cvs      7190:   ----------------------------------------------------------------------*/
1.208     vatton   7191: void HTMLSetAvisitedColor (Document doc, Element el, char *color)
1.1       cvs      7192: {
1.350     vatton   7193:   char           css_command[1000];
1.1       cvs      7194: 
1.327     vatton   7195:   sprintf (css_command, ":visited { color: %s }", color);
                   7196:   ApplyCSSRules (el, css_command, doc, FALSE);
1.1       cvs      7197: }
                   7198: 
                   7199: /*----------------------------------------------------------------------
1.327     vatton   7200:   HTMLResetAlinkColor:                                           
1.1       cvs      7201:   ----------------------------------------------------------------------*/
1.208     vatton   7202: void HTMLResetAlinkColor (Document doc, Element el)
1.1       cvs      7203: {
1.350     vatton   7204:   char           css_command[1000];
1.1       cvs      7205: 
1.327     vatton   7206:   sprintf (css_command, ":link { color: red }");
                   7207:   ApplyCSSRules (el, css_command, doc, TRUE);
1.1       cvs      7208: }
                   7209: 
                   7210: /*----------------------------------------------------------------------
1.327     vatton   7211:   HTMLResetAactiveColor:                                                 
1.1       cvs      7212:   ----------------------------------------------------------------------*/
1.208     vatton   7213: void HTMLResetAactiveColor (Document doc, Element el)
1.1       cvs      7214: {
1.350     vatton   7215:   char           css_command[1000];
1.1       cvs      7216: 
1.327     vatton   7217:   sprintf (css_command, ":active { color: red }");
                   7218:   ApplyCSSRules (el, css_command, doc, TRUE);
1.1       cvs      7219: }
                   7220: 
                   7221: /*----------------------------------------------------------------------
1.327     vatton   7222:   HTMLResetAvisitedColor:                                        
1.1       cvs      7223:   ----------------------------------------------------------------------*/
1.208     vatton   7224: void HTMLResetAvisitedColor (Document doc, Element el)
1.1       cvs      7225: {
1.350     vatton   7226:   char           css_command[1000];
1.1       cvs      7227: 
1.327     vatton   7228:   sprintf (css_command, ":visited { color: red }");
                   7229:   ApplyCSSRules (el, css_command, doc, TRUE);
1.1       cvs      7230: }
                   7231: 
                   7232: /*----------------------------------------------------------------------
1.206     vatton   7233:   ApplyCSSRules: parse a CSS Style description stored in the header of
                   7234:   a HTML document.
1.1       cvs      7235:   ----------------------------------------------------------------------*/
1.79      cvs      7236: void ApplyCSSRules (Element el, char *cssRule, Document doc, ThotBool destroy)
1.1       cvs      7237: {
1.206     vatton   7238:   CSSInfoPtr          css;
                   7239:   PInfoPtr            pInfo;
1.207     vatton   7240:   ThotBool            loadcss;
                   7241: 
                   7242:   /* check if we have to load CSS */
                   7243:   TtaGetEnvBoolean ("LOAD_CSS", &loadcss);
                   7244:   if (!loadcss)
                   7245:     return;
1.1       cvs      7246: 
1.206     vatton   7247:   css = SearchCSS (doc, NULL, el, &pInfo);
1.1       cvs      7248:   if (css == NULL)
1.209     vatton   7249:     {
                   7250:       /* create the document css context */
                   7251:       css = AddCSS (doc, doc, CSS_DOCUMENT_STYLE, CSS_ALL, NULL, NULL, el);
                   7252:       pInfo = css->infos[doc];
                   7253:     }
1.206     vatton   7254:   else if (pInfo == NULL)
                   7255:     /* create the entry into the css context */
                   7256:     pInfo = AddInfoCSS (doc, css, CSS_DOCUMENT_STYLE, CSS_ALL, el);
1.209     vatton   7257:   if (pInfo->PiEnabled)
1.231     vatton   7258:     ParseStyleDeclaration (el, cssRule, doc, css, el, NULL, destroy); 
1.1       cvs      7259: }
                   7260: 
                   7261: /*----------------------------------------------------------------------
1.327     vatton   7262:   ReadCSSRules:  is the front-end function called by the document parser
                   7263:   when detecting a <style type="text/css"> indicating it's the
                   7264:   beginning of a CSS fragment or when reading a file .css.
1.1       cvs      7265:   
1.327     vatton   7266:   The CSS parser has to handle <!-- ... --> constructs used to
                   7267:   prevent prehistoric browser from displaying the CSS as a text
                   7268:   content. It will stop on any sequence "<x" where x is different
                   7269:   from ! and will return x as to the caller. Theorically x should
                   7270:   be equal to / for the </style> end of style.
                   7271:   The parameter doc gives the document tree that contains CSS information.
                   7272:   The parameter docRef gives the document to which CSS are to be applied.
                   7273:   This function uses the current css context or creates it. It's able
                   7274:   to work on the given buffer or call GetNextChar to read the parsed
                   7275:   file.
                   7276:   The parameter url gives the URL of the parsed style sheet.
                   7277:   The parameter numberOfLinesRead gives the number of lines already
                   7278:   read in the file.
                   7279:   The parameter withUndo indicates whether the changes made in the document
                   7280:   structure and content have to be registered in the Undo queue or not.
1.1       cvs      7281:   ----------------------------------------------------------------------*/
1.133     vatton   7282: char ReadCSSRules (Document docRef, CSSInfoPtr css, char *buffer, char *url,
1.343     vatton   7283:                    int numberOfLinesRead, ThotBool withUndo, Element link)
1.1       cvs      7284: {
1.6       cvs      7285:   DisplayMode         dispMode;
1.206     vatton   7286:   CSSInfoPtr          refcss = NULL;
1.321     vatton   7287:   CSSmedia            css_media = CSS_ALL;
1.206     vatton   7288:   PInfoPtr            pInfo;
1.321     vatton   7289:   char                c;
1.138     vatton   7290:   char               *cssRule, *base, *saveDocURL, *ptr;
1.19      cvs      7291:   int                 index;
1.1       cvs      7292:   int                 CSSindex;
1.327     vatton   7293:   int                 CSScomment;
1.1       cvs      7294:   int                 import;
1.358     quint    7295:   int                 openBlock;
1.93      vatton   7296:   int                 newlines;
1.358     quint    7297:   int                 page;
1.14      cvs      7298:   ThotBool            HTMLcomment;
1.342     vatton   7299:   ThotBool            toParse, eof, quoted, s_quoted;
1.358     quint    7300:   ThotBool            ignore, media, lineComment;
1.234     vatton   7301:   ThotBool            noRule, ignoreImport, fontface;
1.1       cvs      7302: 
1.327     vatton   7303:   CSScomment = MAX_CSS_LENGTH;
1.1       cvs      7304:   HTMLcomment = FALSE;
                   7305:   CSSindex = 0;
                   7306:   toParse = FALSE;
                   7307:   noRule = FALSE;
1.234     vatton   7308:   media = FALSE;
1.88      cvs      7309:   ignoreImport = FALSE;
1.342     vatton   7310:   ignore = lineComment = FALSE;
1.358     quint    7311:   page = 0;
1.342     vatton   7312:   quoted = s_quoted = FALSE;
1.234     vatton   7313:   fontface = FALSE;
1.1       cvs      7314:   eof = FALSE;
1.358     quint    7315:   openBlock = 0;
1.234     vatton   7316:   import = MAX_CSS_LENGTH;
1.82      cvs      7317:   c = SPACE;
1.1       cvs      7318:   index = 0;
1.134     vatton   7319:   base = NULL;
1.310     vatton   7320:   /* entering the CSS parsing */
1.311     vatton   7321:   Style_parsing++;
1.93      vatton   7322:   /* number of new lines parsed */
                   7323:   newlines = 0;
1.6       cvs      7324:   /* avoid too many redisplay */
                   7325:   dispMode = TtaGetDisplayMode (docRef);
                   7326:   if (dispMode == DisplayImmediately)
                   7327:     TtaSetDisplayMode (docRef, DeferredDisplay);
1.18      cvs      7328: 
                   7329:   /* look for the CSS context */
                   7330:   if (css == NULL)
1.206     vatton   7331:     css = SearchCSS (docRef, NULL, link, &pInfo);
1.207     vatton   7332:   else
                   7333:     pInfo = css->infos[docRef];
1.18      cvs      7334:   if (css == NULL)
1.206     vatton   7335:     {
                   7336:       css = AddCSS (docRef, docRef, CSS_DOCUMENT_STYLE, CSS_ALL, NULL, NULL, link);
                   7337:       pInfo = css->infos[docRef];
                   7338:     }
                   7339:   else if (pInfo == NULL)
                   7340:     pInfo = AddInfoCSS (docRef, css, CSS_DOCUMENT_STYLE, CSS_ALL, link);
1.174     vatton   7341:   /* look for the CSS descriptor that points to the extension schema */
                   7342:   refcss = css;
1.224     vatton   7343:   if (pInfo && pInfo->PiCategory == CSS_IMPORT)
1.173     cvs      7344:     {
1.206     vatton   7345:       while (refcss &&
1.327     vatton   7346:              refcss->infos[docRef] && refcss->infos[docRef]->PiCategory == CSS_IMPORT)
                   7347:         refcss = refcss->NextCSS;
1.206     vatton   7348:       if (refcss)
1.327     vatton   7349:         pInfo = refcss->infos[docRef];
1.173     cvs      7350:     }
                   7351: 
1.343     vatton   7352:   /* register parsed CSS file and the document to which CSS are to be applied */
1.86      cvs      7353:   ParsedDoc = docRef;
1.343     vatton   7354:   /* clean up the list of classes */
                   7355:   TtaFreeMemory (refcss->class_list);
                   7356:   refcss->class_list = NULL;
1.133     vatton   7357:   if (url)
1.348     vatton   7358:     Error_DocURL = url;
1.86      cvs      7359:   else
                   7360:     /* the CSS source in within the document itself */
1.348     vatton   7361:     Error_DocURL = DocumentURLs[docRef];
1.86      cvs      7362:   LineNumber = numberOfLinesRead + 1;
1.93      vatton   7363:   NewLineSkipped = 0;
1.217     vatton   7364:   newlines = 0;
1.82      cvs      7365:   while (CSSindex < MAX_CSS_LENGTH && c != EOS && !eof)
                   7366:     {
                   7367:       c = buffer[index++];
                   7368:       eof = (c == EOS);
                   7369:       CSSbuffer[CSSindex] = c;
1.342     vatton   7370:       if (!lineComment &&
                   7371:           (CSScomment == MAX_CSS_LENGTH || c == '*' || c == '/' || c == '<' || c == EOL))
1.327     vatton   7372:         {
                   7373:           /* we're not within a comment or we're parsing * or / */
                   7374:           switch (c)
                   7375:             {
                   7376:             case '@': /* perhaps an import primitive */
1.342     vatton   7377:               if (!fontface && !page && !quoted && !s_quoted)
1.327     vatton   7378:                 import = CSSindex;
                   7379:               break;
                   7380:             case ';':
1.342     vatton   7381:               if (!quoted && !s_quoted && !media && import != MAX_CSS_LENGTH)
1.327     vatton   7382:                 { 
                   7383:                   if (strncasecmp (&CSSbuffer[import+1], "import", 6))
                   7384:                     /* it's not an import */
                   7385:                     import = MAX_CSS_LENGTH;
                   7386:                   /* save the text */
                   7387:                   noRule = TRUE;
                   7388:                 }
                   7389:               break;
                   7390:             case '*':
1.342     vatton   7391:               if (!quoted && !s_quoted && CSScomment == MAX_CSS_LENGTH && CSSindex > 0 &&
1.327     vatton   7392:                   CSSbuffer[CSSindex - 1] == '/')
                   7393:                 /* start a comment */
                   7394:                 CSScomment = CSSindex - 1;
                   7395:               break;
                   7396:             case '/':
1.342     vatton   7397:               if (!quoted && !s_quoted && CSSindex > 1 && CSScomment != MAX_CSS_LENGTH &&
1.327     vatton   7398:                   CSSbuffer[CSSindex - 1] == '*')
                   7399:                 {
                   7400:                   while (CSSindex > 0 && CSSindex >= CSScomment)
                   7401:                     {
                   7402:                       if ( CSSbuffer[CSSindex] == EOL)
                   7403:                         {
                   7404:                           LineNumber ++;
                   7405:                           newlines --;
                   7406:                         }
                   7407:                       CSSindex--;
                   7408:                     }
                   7409:                   CSSindex = CSScomment - 1; /* will be incremented later */
                   7410:                   CSScomment = MAX_CSS_LENGTH;
                   7411:                   /* clean up the buffer */
                   7412:                   if (newlines && CSSindex > 0)
                   7413:                     while (CSSindex > 0 &&
                   7414:                            (CSSbuffer[CSSindex] == SPACE ||
                   7415:                             CSSbuffer[CSSindex] == BSPACE ||
                   7416:                             CSSbuffer[CSSindex] == EOL ||
                   7417:                             CSSbuffer[CSSindex] == TAB ||
                   7418:                             CSSbuffer[CSSindex] == __CR__))
                   7419:                       {
                   7420:                         if ( CSSbuffer[CSSindex] == EOL)
                   7421:                           {
                   7422:                             LineNumber ++;
                   7423:                             newlines --;
                   7424:                           }
                   7425:                         CSSindex--;
                   7426:                       }
                   7427:                 }
1.342     vatton   7428:               else if (!fontface && !page && !quoted && !s_quoted &&
1.327     vatton   7429:                        CSScomment == MAX_CSS_LENGTH && CSSindex > 0 &&
                   7430:                        CSSbuffer[CSSindex - 1] ==  '<')
                   7431:                 {
                   7432:                   /* this is the closing tag ! */
                   7433:                   CSSindex -= 2; /* remove </ from the CSS string */
                   7434:                   noRule = TRUE;
1.342     vatton   7435:                 }
                   7436:               else if (!quoted && !s_quoted &&
                   7437:                        (CSSindex == 1 || (CSSindex > 1 && CSSbuffer[CSSindex - 2] == EOL))  &&
                   7438:                        CSScomment == MAX_CSS_LENGTH &&
                   7439:                        CSSbuffer[CSSindex - 1] == '/')
                   7440:                 {
                   7441:                   CSSindex--;
                   7442:                   lineComment = TRUE;
                   7443:                 }
                   7444:                 
1.327     vatton   7445:               break;
                   7446:             case '<':
1.342     vatton   7447:               if (!fontface && !page && !quoted && !s_quoted &&
1.327     vatton   7448:                   CSScomment == MAX_CSS_LENGTH)
                   7449:                 {
                   7450:                   /* only if we're not parsing a comment */
                   7451:                   c = buffer[index++];
                   7452:                   eof = (c == EOS);
                   7453:                   if (c == '!')
                   7454:                     {
                   7455:                       /* CSS within an HTML comment */
                   7456:                       HTMLcomment = TRUE;
                   7457:                       CSSindex++;
                   7458:                       CSSbuffer[CSSindex] = c;
                   7459:                     }
                   7460:                   else if (c == EOS)
                   7461:                     CSSindex++;
                   7462:                 }
                   7463:               break;
                   7464:             case '-':
1.342     vatton   7465:               if (!fontface && !page && !quoted && !s_quoted &&
1.327     vatton   7466:                   CSSindex > 0 && CSSbuffer[CSSindex - 1] == '-' &&
                   7467:                   HTMLcomment)
                   7468:                 /* CSS within an HTML comment */
                   7469:                 noRule = TRUE;
                   7470:               break;
                   7471:             case '>':
1.342     vatton   7472:               if (!fontface && !page && !quoted && !s_quoted && HTMLcomment)
1.327     vatton   7473:                 noRule = TRUE;
                   7474:               break;
                   7475:             case ' ':
1.358     quint    7476:               if (!quoted && !s_quoted && import != MAX_CSS_LENGTH && openBlock == 0)
1.327     vatton   7477:                 media = !strncasecmp (&CSSbuffer[import+1], "media", 5);
                   7478:               break;
                   7479:             case '{':
1.342     vatton   7480:               if (!quoted && !s_quoted)
1.327     vatton   7481:                 {
1.358     quint    7482:                   openBlock++;
1.327     vatton   7483:                   if (import != MAX_CSS_LENGTH)
                   7484:                     {
1.358     quint    7485:                       if (openBlock == 1 && media)
1.327     vatton   7486:                         {
                   7487:                           /* is it the screen concerned? */
                   7488:                           CSSbuffer[CSSindex+1] = EOS;
                   7489:                           css_media = CheckMediaCSS (&CSSbuffer[import+7]);
                   7490:                           if (TtaIsPrinting ())
                   7491:                             ignore = (css_media != CSS_ALL && css_media != CSS_PRINT);
                   7492:                           else
                   7493:                             ignore = (css_media != CSS_ALL && css_media != CSS_SCREEN);
                   7494:                           noRule = TRUE;
                   7495:                         }
                   7496:                       else if (!strncasecmp (&CSSbuffer[import+1], "page", 4))
1.358     quint    7497:                         /* it is a @page block */
1.327     vatton   7498:                         {
1.358     quint    7499:                           page = openBlock;/*remember the level of this block*/
1.327     vatton   7500:                           noRule = TRUE;
                   7501:                         }
                   7502:                       else if (!strncasecmp (&CSSbuffer[import+1], "font-face", 9))
                   7503:                         {
                   7504:                           fontface = TRUE;
                   7505:                           noRule = TRUE;
                   7506:                         }
                   7507:                     }
                   7508:                 }
                   7509:               break;
                   7510:             case '}':
1.342     vatton   7511:               if (!quoted && !s_quoted)
1.327     vatton   7512:                 {
1.358     quint    7513:                   if (page == openBlock)
                   7514:                     /* closing the @page block */
1.327     vatton   7515:                     {
                   7516:                       noRule = TRUE;
1.358     quint    7517:                       page = 0; /* close the page section */
1.327     vatton   7518:                     }
                   7519:                   else if (fontface)
                   7520:                     {
                   7521:                       noRule = TRUE;
                   7522:                       fontface = FALSE; /* close the fontface section */
                   7523:                     }
1.358     quint    7524:                   else if (openBlock == 1 && import != MAX_CSS_LENGTH)
1.327     vatton   7525:                     {
                   7526:                       import = MAX_CSS_LENGTH;
                   7527:                       noRule = TRUE;
                   7528:                       ignore = FALSE;
                   7529:                       media = FALSE;
                   7530:                     }
1.358     quint    7531:                   else if (!page)
1.327     vatton   7532:                     toParse = TRUE;
1.358     quint    7533:                   openBlock--;
1.327     vatton   7534:                 }
                   7535:               break;
                   7536:             case '"':
                   7537:               if (quoted)
                   7538:                 {
1.342     vatton   7539:                   if (CSSindex > 0 && CSSbuffer[CSSindex - 1] != '\\')
1.327     vatton   7540:                     quoted = FALSE;
                   7541:                 }
1.342     vatton   7542:               else if (!s_quoted)
1.327     vatton   7543:                 quoted = TRUE;
                   7544:               break;
1.342     vatton   7545:              case '\'':
                   7546:               if (s_quoted)
                   7547:                 {
                   7548:                   if (CSSindex > 0 && CSSbuffer[CSSindex - 1] != '\\')
                   7549:                     s_quoted = FALSE;
                   7550:                 }
                   7551:               else if (!quoted)
                   7552:                 s_quoted = TRUE;
                   7553:               break;
                   7554:            default:
1.327     vatton   7555:               if (c == EOL)
                   7556:                 {
                   7557:                   newlines++;
                   7558:                 }
                   7559:               break;
                   7560:             }
1.82      cvs      7561:         }
1.93      vatton   7562:       else if (c == EOL)
1.327     vatton   7563:         {
                   7564:           LineNumber++;
1.342     vatton   7565:           lineComment = FALSE;
1.327     vatton   7566:           c = CR;
                   7567:         }
1.234     vatton   7568: 
1.342     vatton   7569:       if (!lineComment && c != CR)
1.327     vatton   7570:         CSSindex++;
1.82      cvs      7571: 
                   7572:       if (CSSindex >= MAX_CSS_LENGTH && CSScomment < MAX_CSS_LENGTH)
1.327     vatton   7573:         /* we're still parsing a comment: remove the text comment */
                   7574:         CSSindex = CSScomment;
1.82      cvs      7575: 
                   7576:       if (CSSindex >= MAX_CSS_LENGTH || toParse || noRule)
1.327     vatton   7577:         {
                   7578:           CSSbuffer[CSSindex] = EOS;
                   7579:           /* parse a not empty string */
                   7580:           if (CSSindex > 0)
                   7581:             {
1.50      cvs      7582:               /* apply CSS rule if it's not just a saving of text */
1.234     vatton   7583:               if (!noRule && !ignore)
1.327     vatton   7584:                 {
                   7585:                   /* future import rules must be ignored */
                   7586:                   ignoreImport = TRUE;
                   7587:                   NewLineSkipped = 0;
                   7588:                   ParseStyleDeclaration (NULL, CSSbuffer, docRef, refcss,
                   7589:                                          pInfo->PiLink, url, FALSE);
                   7590:                   LineNumber += newlines;
                   7591:                   newlines = 0;
                   7592:                 }
1.82      cvs      7593:               else if (import != MAX_CSS_LENGTH &&
1.327     vatton   7594:                        !strncasecmp (&CSSbuffer[import+1], "import", 6))
                   7595:                 {
                   7596:                   /* import section */
                   7597:                   cssRule = &CSSbuffer[import+7];
                   7598:                   cssRule = TtaSkipBlanks (cssRule);
                   7599:                   /* save the current line number */
                   7600:                   newlines += LineNumber;
                   7601:                   if (!strncasecmp (cssRule, "url", 3))
                   7602:                     {
1.50      cvs      7603:                       cssRule = &cssRule[3];
1.82      cvs      7604:                       cssRule = TtaSkipBlanks (cssRule);
                   7605:                       if (*cssRule == '(')
1.327     vatton   7606:                         {
                   7607:                           cssRule++;
                   7608:                           cssRule = TtaSkipBlanks (cssRule);
                   7609:                           quoted = (*cssRule == '"' || *cssRule == '\'');
                   7610:                           if (quoted)
                   7611:                             cssRule++;
                   7612:                           base = cssRule;
                   7613:                           while (*cssRule != EOS && *cssRule != ')')
                   7614:                             cssRule++;
                   7615:                           if (quoted)
                   7616:                             {
                   7617:                               /* isolate the file name */
                   7618:                               cssRule[-1] = EOS;
                   7619:                               quoted = FALSE;
                   7620:                             }
                   7621:                           else
                   7622:                             {
                   7623:                               /* remove extra spaces */
                   7624:                               if (cssRule[-1] == SPACE)
                   7625:                                 {
                   7626:                                   *cssRule = SPACE;
                   7627:                                   cssRule--;
                   7628:                                   while (cssRule[-1] == SPACE)
                   7629:                                     cssRule--;
                   7630:                                 }
                   7631:                             }
                   7632:                           *cssRule = EOS;
                   7633:                         }
                   7634:                     }
                   7635:                   else if (*cssRule == '"')
                   7636:                     {
                   7637:                       /*
                   7638:                         Do we have to accept single quotes?
                   7639:                         Double quotes are accepted here.
                   7640:                         Escaped quotes are not handled. See function SkipQuotedString
                   7641:                       */
                   7642:                       cssRule++;
                   7643:                       cssRule = TtaSkipBlanks (cssRule);
                   7644:                       base = cssRule;
                   7645:                       while (*cssRule != EOS &&
                   7646:                              (*cssRule != '"' ||
                   7647:                               (*cssRule == '"' && cssRule[-1] == '\\')))
                   7648:                         cssRule++;
                   7649:                       /* isolate the file name */
                   7650:                       *cssRule = EOS;
                   7651:                     }
                   7652:                   /* check if a media is defined */
                   7653:                   cssRule++;
                   7654:                   cssRule = TtaSkipBlanks (cssRule);
                   7655:                   if (*cssRule != ';')
                   7656:                     {
                   7657:                       css_media = CheckMediaCSS (cssRule);
                   7658:                       if (TtaIsPrinting ())
                   7659:                         ignoreImport = (css_media != CSS_ALL && css_media != CSS_PRINT);
                   7660:                       else
                   7661:                         ignoreImport = (css_media != CSS_ALL && css_media != CSS_SCREEN);
                   7662:                     }
                   7663:                   if (!ignoreImport)
                   7664:                     {
                   7665:                       /* save the displayed URL when an error is reported */
1.348     vatton   7666:                       saveDocURL = Error_DocURL;
1.327     vatton   7667:                       ptr = TtaStrdup (base);
                   7668:                       /* get the CSS URI in UTF-8 */
                   7669:                       /*ptr = ReallocUTF8String (ptr, docRef);*/
                   7670:                       LoadStyleSheet (base, docRef, (Element) css, css,
                   7671:                                       url, pInfo->PiMedia,
                   7672:                                       pInfo->PiCategory == CSS_USER_STYLE);
                   7673:                       /* restore the displayed URL when an error is reported */
1.348     vatton   7674:                       Error_DocURL = saveDocURL;
1.327     vatton   7675:                       TtaFreeMemory (ptr);
                   7676:                     }
                   7677:                   /* restore the number of lines */
                   7678:                   LineNumber = newlines;
                   7679:                   newlines = 0;
                   7680:                   NewLineSkipped = 0;
                   7681:                   import = MAX_CSS_LENGTH;
                   7682:                 }
                   7683:               else
                   7684:                 {
                   7685:                   LineNumber += newlines;
                   7686:                   newlines = 0;
                   7687:                 }
                   7688:             }
                   7689:           toParse = FALSE;
                   7690:           noRule = FALSE;
                   7691:           CSSindex = 0;
1.50      cvs      7692:         }
1.82      cvs      7693:     }
1.310     vatton   7694:   /* closing the CSS parsing */
1.311     vatton   7695:   Style_parsing--;
1.330     cvs      7696:   if (RedisplayImages == 0 && RedisplayBGImage && Style_parsing == 0)
1.310     vatton   7697:     {
1.311     vatton   7698:       /* CSS parsing finishes after a BG image was loaded */
1.310     vatton   7699:       RedisplayBGImage = FALSE;
1.330     cvs      7700:       if (dispMode != NoComputedDisplay)
                   7701:         {
                   7702:           RedisplayDoc = 0;
                   7703:           //printf ("ReadCSS Show BGimages\n");
                   7704:           TtaSetDisplayMode (docRef, NoComputedDisplay);
                   7705:           TtaSetDisplayMode (docRef, dispMode);
                   7706:         }
1.310     vatton   7707:     }
1.330     cvs      7708:   else if (dispMode != NoComputedDisplay)
1.311     vatton   7709:     /* restore the display mode */
                   7710:     TtaSetDisplayMode (docRef, dispMode);
1.86      cvs      7711: 
                   7712:   /* Prepare the context for style attributes */
1.348     vatton   7713:   Error_DocURL = DocumentURLs[docRef];
1.86      cvs      7714:   LineNumber = -1;
1.1       cvs      7715:   return (c);
                   7716: }

Webmaster