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

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

Webmaster