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

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

Webmaster