Annotation of Amaya/amaya/HTMLbook.c, revision 1.36

1.1       cvs         1: /*
                      2:  *
                      3:  *  (c) COPYRIGHT MIT and INRIA, 1996.
                      4:  *  Please first read the full copyright statement in file COPYRIGHT.
                      5:  *
                      6:  */
                      7: 
                      8: /*
                      9:  * Initialization functions and button functions of Amaya application.
                     10:  *
                     11:  * Authors: V. Quint, I. Vatton
1.26      cvs        12:  *          R. Guetari (W3C/INRIA) - Windows routines.
1.1       cvs        13:  */
                     14: 
                     15: 
                     16: /* Included headerfiles */
                     17: #define THOT_EXPORT
                     18: #include "amaya.h"
                     19: #include "print.h"
                     20: 
                     21: #define NumFormPrint       1
                     22: #define NumMenuOptions     2
                     23: #define NumMenuPaperFormat 3
                     24: #define NumMenuSupport     4
                     25: #define NumZonePrinterName 5
                     26: #define PRINT_MAX_REF     6
                     27: 
1.25      cvs        28: /* structure to register sub-documents in MakeBook function*/
                     29: typedef struct _SubDoc
                     30:   {
                     31:      struct _SubDoc  *SDnext;
                     32:      Element          SDel;
1.36    ! cvs        33:      STRING           SDname;
1.25      cvs        34:   }SubDoc;
                     35: 
1.29      cvs        36: /* the structure used for the GetIncludedDocuments_callback function */
                     37: typedef struct _GetIncludedDocuments_context {
                     38:   Element              link, next;
                     39:   Attribute            RelAttr, HrefAttr;
1.36    ! cvs        40:   STRING               url, ptr, text;
1.29      cvs        41:   Document             document;
                     42: } GetIncludedDocuments_context;
                     43: 
1.25      cvs        44: static struct _SubDoc  *SubDocs;
1.2       cvs        45: static int              PaperPrint;
                     46: static int              ManualFeed;
                     47: static int              PageSize;
1.36    ! cvs        48: static CHAR             PSdir[MAX_PATH];
        !            49: static CHAR             pPrinter[MAX_PATH];
1.1       cvs        50: static Document                docPrint;
                     51: static boolean         numberLinks;
                     52: static boolean         withToC;
1.34      cvs        53: static boolean          printURL;
1.1       cvs        54: static int              basePrint;
                     55: 
                     56: #include "init_f.h"
                     57: #include "HTMLactions_f.h"
                     58: #include "HTMLbook_f.h"
                     59: #include "HTMLedit_f.h"
1.25      cvs        60: #include "HTMLhistory_f.h"
1.1       cvs        61: 
1.31      cvs        62: #ifdef _WINDOWS 
                     63: #include "windialogapi_f.h"
                     64: #endif /* _WINDOWS */
                     65: 
1.29      cvs        66: /*-----------------------------------------------------------------------
                     67:   Function prototypes
                     68:   ----------------------------------------------------------------------*/
                     69: #ifdef __STDC__
                     70: static void         GetIncludedDocuments (Element el, Document document);
                     71: void                MakeBook_callback (Document document);
                     72: #else
                     73: static void         GetIncludedDocuments (/* el, document */);
                     74: void                MakeBook_callback (/* Document document */);
                     75: #endif
1.1       cvs        76: 
                     77: /*----------------------------------------------------------------------
1.16      cvs        78:   RegisterSubDoc adds a new entry in SubDoc table.
                     79:   ----------------------------------------------------------------------*/
                     80: #ifdef __STDC__
1.36    ! cvs        81: static void         RegisterSubDoc (Element el, STRING url)
1.16      cvs        82: #else
                     83: static void         RegisterSubDoc (el, url)
                     84: Element             el;
1.36    ! cvs        85: STRING              url;
1.16      cvs        86: #endif
                     87: {
                     88:   struct _SubDoc  *entry, *last;
                     89: 
                     90:   if (url == NULL || url[0] == EOS)
                     91:     return;
                     92: 
                     93:   entry = TtaGetMemory (sizeof (struct _SubDoc));
                     94:   entry->SDnext = NULL;
                     95:   entry->SDel = el;
                     96:   entry->SDname = TtaStrdup (url);
                     97: 
                     98:   if (SubDocs == NULL)
                     99:     SubDocs = entry;
                    100:   else
                    101:     {
                    102:       last = SubDocs;
                    103:       while (last->SDnext != NULL)
                    104:        last = last->SDnext;
                    105:       last->SDnext = entry;
                    106:     }
                    107: }
                    108: 
                    109: 
                    110: /*----------------------------------------------------------------------
                    111:   SearchSubDoc searches whether a document name is registered or not
                    112:   within the SubDoc table.
                    113:   Return the DIV element that correspond to the sub-document or NULL.
                    114:   ----------------------------------------------------------------------*/
                    115: #ifdef __STDC__
1.36    ! cvs       116: static Element      SearchSubDoc (STRING url)
1.16      cvs       117: #else
                    118: static Element      SearchSubDoc (url)
1.36    ! cvs       119: STRING              url;
1.16      cvs       120: #endif
                    121: {
                    122:   Element          el;
                    123:   struct _SubDoc  *entry;
                    124:   boolean          docFound;
                    125: 
                    126:   if (url == NULL || url[0] == EOS)
                    127:     return (NULL);
                    128: 
                    129:   entry = SubDocs;
                    130:   docFound = FALSE;
                    131:   el = NULL;
                    132:   while (!docFound && entry != NULL)
                    133:     {
1.36    ! cvs       134:       docFound = (ustrcmp (url, entry->SDname) == 0);
1.16      cvs       135:       if (!docFound)
                    136:        entry = entry->SDnext;
                    137:       else
                    138:        /* document found -> return the DIV element */
                    139:        el = entry->SDel;
                    140:     }
                    141:   return (el);
                    142: }
                    143: 
                    144: /*----------------------------------------------------------------------
                    145:   FreeSubDocTable frees all entries in SubDoc table.
                    146:   ----------------------------------------------------------------------*/
                    147: static void         FreeSubDocTable ()
                    148: {
                    149:   struct _SubDoc  *entry, *last;
                    150: 
                    151:   entry = SubDocs;
                    152:   while (entry != NULL)
                    153:     {
                    154:       last = entry;
                    155:       entry = entry->SDnext;
                    156:       TtaFreeMemory (last->SDname);
                    157:       TtaFreeMemory (last);
                    158:     }
                    159:   SubDocs = NULL;
                    160: }
                    161: 
                    162: 
                    163: 
                    164: /*----------------------------------------------------------------------
1.1       cvs       165:   SetInternalLinks
1.8       cvs       166:   Associate an InternalLink attribute with all anchor (A) elements of the
                    167:   document which designate an element in the same document.
1.1       cvs       168:   InternalLink is a Thot reference attribute that links a source and a
                    169:   target anchor and that allows P schemas to display and print cross-references
                    170:   ----------------------------------------------------------------------*/
                    171: #ifdef __STDC__
1.4       cvs       172: void             SetInternalLinks (Document document)
1.1       cvs       173: #else
1.4       cvs       174: void             SetInternalLinks (document)
1.1       cvs       175: Document                document;
                    176: #endif
                    177: {
1.32      cvs       178:   Element              el, div, link, target, sibling;
                    179:   ElementType          elType, linkType;
1.16      cvs       180:   Attribute            HrefAttr, IntLinkAttr;
1.17      cvs       181:   Attribute             attr, ExtLinkAttr;
1.16      cvs       182:   AttributeType                attrType;
1.36    ! cvs       183:   STRING               text, ptr, url; 
        !           184:   CHAR                  number[10];
        !           185:   CHAR                  value[MAX_LENGTH];
1.25      cvs       186:   int                  length, i, volume;
                    187:   int                   status, position;
1.16      cvs       188:   boolean               split;
1.1       cvs       189: 
1.16      cvs       190:   /* Remember the current status of the document */
                    191:   status = TtaIsDocumentModified (document);
1.32      cvs       192:   el = TtaGetMainRoot (document);
                    193:   volume = TtaGetElementVolume (el);
                    194:   elType = TtaGetElementType (el);
                    195:   elType.ElTypeNum = HTML_EL_AnyLink;
1.16      cvs       196:   attrType.AttrSSchema = elType.ElSSchema;
1.32      cvs       197:   /* looks for all links in the document */
1.16      cvs       198:   link = el;
                    199:   while (link != NULL)
                    200:     {
1.25      cvs       201:       /* display the progression of the work */
                    202:       el = link;
                    203:       position = 0;
                    204:       while (el != NULL)
                    205:        {
                    206:          sibling = el;
                    207:          do
                    208:            {
                    209:              /* add volume of each previous element */
                    210:              TtaPreviousSibling (&sibling);
                    211:              if (sibling != NULL)
                    212:                position += TtaGetElementVolume (sibling);
                    213:            }
                    214:          while (sibling != NULL);
                    215:          el = TtaGetParent (el);
                    216:        }
                    217:       sprintf (number, "%d", position*100/volume);
                    218:       TtaSetStatus (document, 1, TtaGetMessage (AMAYA, AM_UPDATED_LINK), number);
                    219:       TtaHandlePendingEvents ();
1.16      cvs       220:       link = TtaSearchTypedElement (elType, SearchForward, link);
                    221:       if (link != NULL)
1.32      cvs       222:        /* a link has been found */
1.16      cvs       223:        {
1.32      cvs       224:          linkType = TtaGetElementType (link);
                    225:          if (linkType.ElTypeNum == HTML_EL_Anchor)
                    226:             attrType.AttrTypeNum = HTML_ATTR_HREF_;
                    227:          else
                    228:             attrType.AttrTypeNum = HTML_ATTR_cite;
1.16      cvs       229:          HrefAttr = TtaGetAttribute (link, attrType);
                    230:          attrType.AttrTypeNum = HTML_ATTR_InternalLink;
                    231:          IntLinkAttr = TtaGetAttribute (link, attrType);
                    232:          attrType.AttrTypeNum = HTML_ATTR_ExternalLink;
                    233:          ExtLinkAttr = TtaGetAttribute (link, attrType);
                    234:          if (HrefAttr == NULL)
1.32      cvs       235:            /* this element is not a link (no href or cite attribute) */
1.16      cvs       236:            /* remove attributes InternalLink and ExternalLink if they
                    237:               are present */
                    238:            {
1.8       cvs       239:              if (IntLinkAttr != NULL)
1.16      cvs       240:                TtaRemoveAttribute (link, IntLinkAttr, document);
                    241:              if (ExtLinkAttr != NULL)
                    242:                TtaRemoveAttribute (link, ExtLinkAttr, document);          
                    243:            }
                    244:          else
1.32      cvs       245:            /* this element has an HREF or cite attribute */
1.16      cvs       246:            {
                    247:              length = TtaGetTextAttributeLength (HrefAttr);
                    248:              text = TtaGetMemory (length + 1);
                    249:              TtaGiveTextAttributeValue (HrefAttr, text, &length);
                    250: 
                    251:              /* does an external link become an internal link ? */
1.25      cvs       252:              if (document == DocBook && SubDocs != NULL)
1.16      cvs       253:                {
1.36    ! cvs       254:                  ptr = ustrrchr (text, '#');
1.16      cvs       255:                  url = text;
1.18      cvs       256:                  split = FALSE;
1.16      cvs       257:                  if (ptr == text)
                    258:                      /* a local link */
                    259:                      url = NULL;
1.17      cvs       260:                  else if (ptr != NULL)
1.16      cvs       261:                    {
                    262:                      /* split url and name part */
                    263:                      ptr[0] = EOS;
                    264:                      split = TRUE;
                    265:                    }
                    266: 
                    267:                  /* Is it a sub-document */
                    268:                  div = SearchSubDoc (url);
                    269:                  if (split)
                    270:                    /* retore the mark */
                    271:                    ptr[0] = '#';
                    272: 
                    273:                  if (div == NULL)
                    274:                    {
                    275:                      /* it's not a sub-document */
                    276:                      if (url == NULL)
                    277:                        /* a local link */
                    278:                        ptr = &text[1];
                    279:                      else
                    280:                        /* still an externa; link */
                    281:                        ptr = NULL;
                    282:                    }
                    283:                  else
                    284:                    {
                    285:                      /* this link becomes internal */
1.17      cvs       286:                      if (ptr != NULL)
1.16      cvs       287:                        {
1.17      cvs       288:                          /* get the target name */
1.36    ! cvs       289:                          ustrcpy (value, ptr);
        !           290:                          length = ustrlen (value);
1.17      cvs       291:                          /* check whether the name changed */
                    292:                          i = 0;
                    293:                          target = SearchNAMEattribute (document, &value[1], NULL);
                    294:                          while (target != NULL)
1.16      cvs       295:                            {
1.17      cvs       296:                              /* is it the right NAME */
                    297:                              if (TtaIsAncestor (target, div))
                    298:                                target = NULL;
                    299:                              else
                    300:                                {
                    301:                                  /* continue the search */
                    302:                                  i++;
                    303:                                  sprintf (&value[length], "%d", i);
1.32      cvs       304:                                  target = SearchNAMEattribute (document,
                    305:                                                        &value[1], NULL);
1.17      cvs       306:                                }
1.16      cvs       307:                            }
                    308:                        }
1.17      cvs       309:                      else
                    310:                        {
                    311:                          /* get the DIV name */
                    312:                          attrType.AttrTypeNum = HTML_ATTR_ID;
                    313:                          attr = TtaGetAttribute (div, attrType);
                    314:                          length = 200;
                    315:                          value[0] = '#';
                    316:                          TtaGiveTextAttributeValue (attr, &value[1], &length);
                    317:                        }
1.16      cvs       318:                      ptr = &value[1];
                    319:                      TtaSetAttributeText (HrefAttr, value, link, document);
                    320:                    }
                    321:                }
                    322:              else if (text[0] == '#')
                    323:                  ptr = &text[1];
                    324:              else
                    325:                ptr = NULL;
                    326: 
                    327:              if (ptr != NULL)
                    328:                /* it's an internal link. Attach an attribute InternalLink */
                    329:                /* to the link, if this attribute does not exist yet */
                    330:                {
                    331:                  if (IntLinkAttr == NULL)
                    332:                    {
                    333:                      attrType.AttrTypeNum = HTML_ATTR_InternalLink;
                    334:                      IntLinkAttr = TtaNewAttribute (attrType);
                    335:                      TtaAttachAttribute (link, IntLinkAttr, document);
                    336:                    }
                    337:                  /* looks for the target element */
                    338:                  target = SearchNAMEattribute (document, ptr, NULL);
                    339:                  if (target != NULL)
                    340:                    /* set the Thot link */
1.32      cvs       341:                    TtaSetAttributeReference (IntLinkAttr, link, document,
                    342:                                              target, document);
1.16      cvs       343:                }
                    344:              else
                    345:                /* it's an external link */
                    346:                {
                    347:                  /* Remove the InternalLink attribute if it is present */
                    348:                  if (IntLinkAttr != NULL)
                    349:                    TtaRemoveAttribute (link, IntLinkAttr, document);
                    350:                  /* create an ExternalLink attribute if there is none */
                    351:                  if (ExtLinkAttr == NULL)
                    352:                    {
                    353:                      attrType.AttrTypeNum = HTML_ATTR_ExternalLink;
                    354:                      ExtLinkAttr = TtaNewAttribute (attrType);
                    355:                      TtaAttachAttribute (link, ExtLinkAttr, document);
                    356:                    }
                    357:                }
                    358:              TtaFreeMemory (text);
                    359:            }
                    360:        }
                    361:     }
                    362:   /* Reset document status */
                    363:   if (!status)
                    364:     TtaSetDocumentUnmodified (document);
1.3       cvs       365: }
                    366: 
                    367: /*----------------------------------------------------------------------
                    368:   CheckPrintingDocument reinitialize printing parameters as soon as
                    369:   the printing document changes.
                    370:   ----------------------------------------------------------------------*/
                    371: #ifdef __STDC__
                    372: static void         CheckPrintingDocument (Document document)
                    373: #else
                    374: static void         CheckPrintingDocument (document)
                    375: Document            document;
                    376: #endif
                    377: {
1.36    ! cvs       378:    CHAR             docName[MAX_LENGTH];
        !           379:    STRING           ptr; 
        !           380:    CHAR             suffix[MAX_LENGTH];
1.3       cvs       381:    int              lg;
                    382: 
                    383:    if (docPrint != document)
                    384:      {
                    385:        /* initialize print parameters */
                    386:        docPrint = document;
                    387: 
                    388:        /* define the new default PS file */
                    389:        ptr = TtaGetEnvString ("TMPDIR");
                    390:        if (ptr != NULL && TtaCheckDirectory (ptr))
                    391:         {
1.36    ! cvs       392:           ustrcpy(PSdir,ptr);
        !           393:           lg = ustrlen(PSdir);
1.3       cvs       394:           if (PSdir[lg - 1] == DIR_SEP)
                    395:             PSdir[--lg] = '\0';
                    396:         }
                    397:        else
                    398:         {
1.6       cvs       399: #          ifdef _WINDOWS
1.36    ! cvs       400:           ustrcpy (PSdir,"C:\\TEMP");
1.6       cvs       401: #          else  /* !_WINDOWS */
1.36    ! cvs       402:           ustrcpy (PSdir,"/tmp");
1.6       cvs       403: #          endif /* !_WINDOWS */
1.36    ! cvs       404:           lg = ustrlen (PSdir);
1.3       cvs       405:         }
1.36    ! cvs       406:        ustrcpy (docName, TtaGetDocumentName (document));
1.3       cvs       407:        ExtractSuffix (docName, suffix);
1.27      cvs       408: #      ifdef _WINDOWS
                    409:        sprintf (&PSdir[lg], "\\%s.ps", docName);
                    410: #      else /* !_WINDOWS */
1.3       cvs       411:        sprintf (&PSdir[lg], "/%s.ps", docName);
1.27      cvs       412: #      endif /* !_WINDOWS */
1.3       cvs       413:        TtaSetPsFile (PSdir);
                    414:        /* define the new default PrintSchema */
                    415:        numberLinks = FALSE;
                    416:        withToC = FALSE;
1.34      cvs       417:        printURL = TRUE;
1.3       cvs       418:        TtaSetPrintSchema ("");
                    419:        /* no manual feed */
                    420:        ManualFeed = PP_OFF;
                    421:        TtaSetPrintParameter (PP_ManualFeed, ManualFeed);
                    422:      }
                    423: }
                    424: 
                    425: 
                    426: /*----------------------------------------------------------------------
                    427:    PrintAs prints the document using predefined parameters.
                    428:    ----------------------------------------------------------------------*/  
                    429: #ifdef __STDC__
                    430: void                PrintAs (Document document, View view)
                    431: #else  /* __STDC__ */
                    432: void                PrintAs (document, view)
                    433: Document            document;
                    434: #endif /* __STDC__ */
                    435: {
1.34      cvs       436:   AttributeType      attrType;
                    437:   Attribute          attr;
                    438:   Element            el;
1.36    ! cvs       439:   CHAR               viewsToPrint[MAX_PATH];
1.34      cvs       440:   boolean            status;
1.3       cvs       441: 
                    442:    CheckPrintingDocument (document);
1.36    ! cvs       443:    ustrcpy (viewsToPrint, "Formatted_view ");
1.3       cvs       444:    if (withToC)
1.36    ! cvs       445:      ustrcat (viewsToPrint, "Table_of_contents ");
1.3       cvs       446:    if (numberLinks)
1.8       cvs       447:      /* display numbered links */
1.3       cvs       448:      {
1.8       cvs       449:        /* associate an attribute InternalLink with all anchors refering
                    450:          a target in the same document.  This allows P schemas to work
                    451:          properly */
                    452:        SetInternalLinks (docPrint);
1.3       cvs       453:        if (PageSize == PP_A4)
                    454:         TtaSetPrintSchema ("HTMLPLP");
                    455:        else
                    456:         TtaSetPrintSchema ("HTMLPLPUS");
1.36    ! cvs       457:        ustrcat (viewsToPrint, "Links_view ");
1.32      cvs       458:      }
                    459:    else
                    460:      {
                    461:        if (PageSize == PP_A4)
                    462:         TtaSetPrintSchema ("HTMLPP");
                    463:        else
                    464:         TtaSetPrintSchema ("HTMLPPUS");     
1.3       cvs       465:      }
1.34      cvs       466:    /* post or remove the PrintURL attribute */
                    467:    el =  TtaGetMainRoot (document);
                    468:    status = TtaIsDocumentModified (document);
                    469:    attrType.AttrSSchema = TtaGetDocumentSSchema (document);
                    470:    attrType.AttrTypeNum = HTML_ATTR_PrintURL;
                    471:    attr = TtaGetAttribute (el, attrType);
                    472:    if (attr == 0 && printURL)
                    473:      {
                    474:        attr = TtaNewAttribute (attrType);
                    475:        TtaAttachAttribute (el, attr, document);
                    476:      }
                    477:    if (attr != 0 && !printURL)
                    478:      TtaRemoveAttribute (el, attr, document);
1.3       cvs       479:    TtaPrint (docPrint, viewsToPrint);
1.34      cvs       480:    if (!status)
                    481:      TtaSetDocumentUnmodified (document);
1.1       cvs       482: }
                    483: 
                    484: 
                    485: /*----------------------------------------------------------------------
                    486:    CallbackImage manage returns of Picture form.                   
                    487:   ----------------------------------------------------------------------*/
                    488: #ifdef __STDC__
1.36    ! cvs       489: void                CallbackPrint (int ref, int typedata, STRING data)
1.1       cvs       490: #else  /* __STDC__ */
                    491: void                CallbackPrint (ref, typedata, data)
                    492: int                 ref;
                    493: int                 typedata;
1.36    ! cvs       494: STRING              data;
1.1       cvs       495: #endif /* __STDC__ */
                    496: {
                    497:   int                 val;
                    498: 
                    499:   val = (int) data;
                    500:   switch (ref - basePrint)
                    501:     {
                    502:     case NumFormPrint:
                    503:       TtaDestroyDialogue (basePrint+NumFormPrint);
                    504:       switch (val)
                    505:        {
                    506:        case 1:
                    507:          /* confirms the paper print option */
                    508:          /* the other options are not taken into account without this
                    509:             confirmation */
1.2       cvs       510:          TtaSetPrintParameter (PP_Destination, PaperPrint);
                    511:          TtaSetPrintParameter (PP_ManualFeed, ManualFeed);
                    512:          TtaSetPrintParameter (PP_PaperSize, PageSize);
                    513:          TtaSetPrintCommand (pPrinter);
                    514:          TtaSetPsFile (PSdir);
1.3       cvs       515:          PrintAs (docPrint, 1);
1.1       cvs       516:          break;
1.2       cvs       517:        case 0:
                    518:          PaperPrint = TtaGetPrintParameter (PP_Destination);
                    519:          ManualFeed = TtaGetPrintParameter (PP_ManualFeed);
                    520:          PageSize = TtaGetPrintParameter (PP_PaperSize);         
                    521:          TtaGetPrintCommand (pPrinter);
                    522:          TtaGetPsFile (PSdir);
                    523:          break;
1.1       cvs       524:        default:
                    525:          break;
                    526:        }
                    527:       break;
                    528:     case NumMenuOptions:
                    529:       switch (val)
                    530:        {
                    531:        case 0:
                    532:          /* Manual feed option */
1.2       cvs       533:          if (ManualFeed == PP_ON)
                    534:            ManualFeed = PP_OFF;
                    535:          else
                    536:            ManualFeed = PP_ON;
1.1       cvs       537:          break;
                    538:        case 1:
                    539:          /* Toc option */
                    540:          withToC = !withToC;
                    541:          break;
                    542:        case 2:
1.3       cvs       543:          /* numberLinks option */
1.1       cvs       544:          numberLinks = !numberLinks;
1.34      cvs       545:        case 3:
                    546:          /* URL option */
                    547:          printURL = !printURL;
1.1       cvs       548:          break;
                    549:        }
                    550:       break;
                    551:     case NumMenuPaperFormat:
                    552:       /* page size submenu */
                    553:       switch (val)
                    554:        {
                    555:        case 0:
1.2       cvs       556:          PageSize = PP_A4;
1.1       cvs       557:          break;
                    558:        case 1:
1.2       cvs       559:          PageSize = PP_US;
1.1       cvs       560:          break;
                    561:        }
                    562:       break;
                    563:     case NumMenuSupport:
                    564:       /* paper print/save PostScript submenu */
                    565:       switch (val)
                    566:        {
                    567:        case 0:
1.2       cvs       568:          if (PaperPrint == PP_PS)
1.1       cvs       569:            {
1.2       cvs       570:              PaperPrint = PP_PRINTER;
1.1       cvs       571:              TtaSetTextForm (basePrint+NumZonePrinterName, pPrinter);
                    572:            }
                    573:          break;
                    574:        case 1:
1.2       cvs       575:          if (PaperPrint == PP_PRINTER)
1.1       cvs       576:            {
1.2       cvs       577:              PaperPrint = PP_PS;
1.1       cvs       578:              TtaSetTextForm (basePrint+NumZonePrinterName, PSdir);
                    579:            }
                    580:          break;
                    581:        }
                    582:       break;
                    583:     case NumZonePrinterName:
                    584:       if (data[0] != '\0')
1.2       cvs       585:        if (PaperPrint == PP_PRINTER)
1.1       cvs       586:          /* text capture zone for the printer name */
1.36    ! cvs       587:          ustrncpy (pPrinter, data, MAX_PATH);
1.1       cvs       588:        else
                    589:          /* text capture zone for the name of the PostScript file */
1.36    ! cvs       590:          ustrncpy (PSdir, data, MAX_PATH);
1.1       cvs       591:       break;
                    592:     }
                    593: }
                    594: 
                    595: /*----------------------------------------------------------------------
                    596:   ----------------------------------------------------------------------*/
                    597: #ifdef __STDC__
                    598: void                InitPrint (void)
                    599: #else  /* __STDC__ */
                    600: void                InitPrint ()
                    601: #endif /* __STDC__ */
                    602: {
1.36    ! cvs       603:   STRING ptr;
1.1       cvs       604: 
                    605:    basePrint = TtaSetCallback (CallbackPrint, PRINT_MAX_REF);
                    606:    docPrint = 0;
                    607: 
                    608:    /* init printer variables */
                    609:    /* read default printer variable */
                    610:    ptr = TtaGetEnvString ("THOTPRINT");
                    611:    if (ptr == NULL)
1.36    ! cvs       612:      ustrcpy (pPrinter, "");
1.1       cvs       613:    else
1.36    ! cvs       614:      ustrcpy (pPrinter, ptr);
1.1       cvs       615: 
1.2       cvs       616:    PageSize = PP_A4;
                    617:    PaperPrint = PP_PRINTER;
1.35      cvs       618:    printURL = TRUE;
1.2       cvs       619:    TtaSetPrintParameter (PP_Destination, PaperPrint);
                    620:    TtaSetPrintParameter (PP_PaperSize, PageSize);
                    621:    TtaSetPrintCommand (pPrinter);
1.1       cvs       622: }
                    623: 
                    624: /*----------------------------------------------------------------------
1.3       cvs       625:   SetupAndPrint sets printing parameters and starts the printing process
1.1       cvs       626:   ----------------------------------------------------------------------*/
                    627: #ifdef __STDC__
                    628: void                SetupAndPrint (Document document, View view)
                    629: #else
                    630: void                SetupAndPrint (document, view)
                    631: Document            document;
                    632: View                view;
                    633: #endif
                    634: {
1.10      cvs       635: #  ifndef _WINDOWS
1.36    ! cvs       636:    CHAR             bufMenu[MAX_LENGTH];
1.3       cvs       637:    int              i;
1.27      cvs       638: #  endif /* !_WINDOWS */
1.1       cvs       639: 
                    640:    /* Print form */
1.3       cvs       641:    CheckPrintingDocument (document);
1.27      cvs       642: 
                    643: #  ifndef _WINDOWS
1.1       cvs       644:    TtaNewSheet (basePrint+NumFormPrint, TtaGetViewFrame (document, view), 
                    645:                TtaGetMessage (LIB, TMSG_LIB_PRINT),
1.3       cvs       646:           1, TtaGetMessage (AMAYA, AM_BUTTON_PRINT), FALSE, 2, 'L', D_CANCEL);
1.1       cvs       647:    i = 0;
                    648:    sprintf (&bufMenu[i], "%s%s", "T", TtaGetMessage (LIB, TMSG_MANUAL_FEED));
1.36    ! cvs       649:    i += ustrlen (&bufMenu[i]) + 1;
1.1       cvs       650:    sprintf (&bufMenu[i], "%s%s", "T", TtaGetMessage (AMAYA, AM_PRINT_TOC));
1.36    ! cvs       651:    i += ustrlen (&bufMenu[i]) + 1;
1.1       cvs       652:    sprintf (&bufMenu[i], "%s%s", "T", TtaGetMessage (AMAYA, AM_NUMBERED_LINKS));
1.36    ! cvs       653:    i += ustrlen (&bufMenu[i]) + 1;
1.34      cvs       654:    sprintf (&bufMenu[i], "%s%s", "T", TtaGetMessage (AMAYA, AM_PRINT_URL));
1.1       cvs       655:    TtaNewToggleMenu (basePrint+NumMenuOptions, basePrint+NumFormPrint,
1.34      cvs       656:                TtaGetMessage (LIB, TMSG_OPTIONS), 4, bufMenu, NULL, FALSE);
1.2       cvs       657:    if (ManualFeed == PP_ON)
1.1       cvs       658:       TtaSetToggleMenu (basePrint+NumMenuOptions, 0, TRUE);
                    659:    if (withToC)
                    660:       TtaSetToggleMenu (basePrint+NumMenuOptions, 1, TRUE);
                    661:    if (numberLinks)
                    662:       TtaSetToggleMenu (basePrint+NumMenuOptions, 2, TRUE);
1.34      cvs       663:    if (printURL)
                    664:       TtaSetToggleMenu (basePrint+NumMenuOptions, 3, TRUE);
1.1       cvs       665: 
                    666:    /* Paper format submenu */
                    667:    i = 0;
                    668:    sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_A4));
1.36    ! cvs       669:    i += ustrlen (&bufMenu[i]) + 1;
1.1       cvs       670:    sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_US));
                    671:    TtaNewSubmenu (basePrint+NumMenuPaperFormat, basePrint+NumFormPrint, 0,
                    672:             TtaGetMessage (LIB, TMSG_PAPER_SIZE), 2, bufMenu, NULL, FALSE);
1.2       cvs       673:    if (PageSize == PP_US)
1.1       cvs       674:       TtaSetMenuForm (basePrint+NumMenuPaperFormat, 1);
                    675:    else
                    676:       TtaSetMenuForm (basePrint+NumMenuPaperFormat, 0);
                    677: 
                    678:    /* Print to paper/ Print to file submenu */
                    679:    i = 0;
                    680:    sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_PRINTER));
1.36    ! cvs       681:    i += ustrlen (&bufMenu[i]) + 1;
1.1       cvs       682:    sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_PS_FILE));
                    683:    TtaNewSubmenu (basePrint+NumMenuSupport, basePrint+NumFormPrint, 0,
                    684:                   TtaGetMessage (LIB, TMSG_OUTPUT), 2, bufMenu, NULL, TRUE);
                    685:    /* text capture zone for the printer name */
                    686:    TtaNewTextForm (basePrint+NumZonePrinterName, basePrint+NumFormPrint, NULL, 30, 1, FALSE);
                    687: 
                    688:    /* initialization of the PaperPrint selector */
1.2       cvs       689:    if (PaperPrint == PP_PRINTER)
1.1       cvs       690:      {
                    691:        TtaSetMenuForm (basePrint+NumMenuSupport, 0);
                    692:        TtaSetTextForm (basePrint+NumZonePrinterName, pPrinter);
                    693:      }
                    694:    else
                    695:      {
                    696:        TtaSetMenuForm (basePrint+NumMenuSupport, 1);
                    697:        TtaSetTextForm (basePrint+NumZonePrinterName, PSdir);
                    698:      }
                    699: 
                    700:    /* activates the Print form */
1.10      cvs       701:     TtaShowDialogue (basePrint+NumFormPrint, FALSE);
                    702: #   else  /* _WINDOWS */
1.27      cvs       703:     CreatePrintDlgWindow (TtaGetViewFrame (document, view), PSdir, basePrint, NumMenuSupport, NumMenuOptions, NumMenuPaperFormat, NumZonePrinterName, NumFormPrint); 
1.10      cvs       704: #   endif /* _WINDOWS */
1.1       cvs       705: }
                    706: 
                    707: /*----------------------------------------------------------------------
                    708:   SectionNumbering
                    709:   Execute the "Section Numbering" command
                    710:   ----------------------------------------------------------------------*/
                    711: #ifdef __STDC__
                    712: void                SectionNumbering (Document document, View view)
                    713: #else
                    714: void                SectionNumbering (document, view)
                    715: Document            document;
                    716: View                view;
                    717: #endif
                    718: {
                    719:    ChangeAttrOnRoot (document, HTML_ATTR_SectionNumbering);
                    720: }
                    721: 
                    722: /*----------------------------------------------------------------------
                    723:   UpdateURLsInSubtree
                    724:   Update NAMEs and URLs in subtree of el element, to take into account
                    725:   the move from one document to another.
                    726:   If a NAME attribute already exists in the new document, it is changed
                    727:   to avoid duplicate names.
                    728:   Transform the HREF and SRC attribute to make them independent from their
                    729:   former base.
                    730:   ----------------------------------------------------------------------*/
                    731: #ifdef __STDC__
                    732: static void         UpdateURLsInSubtree (NotifyElement *event, Element el)
                    733: #else
                    734: static void         UpdateURLsInSubtree (event, el)
                    735: NotifyElement      *event;
                    736: Element             el;
                    737: #endif
                    738: {
                    739: Element             nextEl;
                    740: 
                    741:   event->element = el;
                    742:   ElementPasted (event);
                    743:   nextEl = TtaGetFirstChild (el);
                    744:   while (nextEl != NULL)
                    745:     {
                    746:       UpdateURLsInSubtree (event, nextEl);
                    747:       TtaNextSibling (&nextEl);
                    748:     }
                    749: }
                    750: 
                    751: 
                    752: /*----------------------------------------------------------------------
                    753:   MoveDocumentBody
                    754:   Copy the elements contained in the BODY of document sourceDoc to the
                    755:   position of element *el in document destDoc.
                    756:   Delete the element containing *el and all its empty ancestors.
                    757:   If deleteTree is TRUE, copied elements are deleted from the source
                    758:   document.
                    759:   ----------------------------------------------------------------------*/
                    760: #ifdef __STDC__
1.36    ! cvs       761: static void    MoveDocumentBody (Element *el, Document destDoc, Document sourceDoc, STRING target, STRING url, boolean deleteTree)
1.1       cvs       762: #else
1.16      cvs       763: static void    MoveDocumentBody (el, destDoc, sourceDoc, target, url, deleteTree)
1.12      cvs       764: Element       *el;
                    765: Document       destDoc;
                    766: Document       sourceDoc;
1.36    ! cvs       767: STRING         target;
        !           768: STRING         url;
1.12      cvs       769: boolean        deleteTree;
1.1       cvs       770: #endif
                    771: {
1.14      cvs       772:   Element         root, ancestor, elem, firstInserted;
1.12      cvs       773:   Element          lastInserted, srce, copy, old, parent, sibling;
                    774:   ElementType     elType;
                    775:   NotifyElement    event;
                    776:   int             checkingMode;
1.13      cvs       777:   boolean          isID;
1.1       cvs       778: 
1.13      cvs       779:   if (target != NULL)
                    780:     {
                    781:       /* locate the target element within the source document */
                    782:       root = SearchNAMEattribute (sourceDoc, target, NULL);
                    783:       elType = TtaGetElementType (root);
                    784:       isID = (elType.ElTypeNum != HTML_EL_Anchor 
                    785:              && elType.ElTypeNum != HTML_EL_MAP);
                    786:     }
                    787:   else
                    788:     {
                    789:       isID = FALSE;
                    790:       /* get the BODY element of source document */
                    791:       root = TtaGetMainRoot (sourceDoc);
                    792:       elType = TtaGetElementType (root);
                    793:       elType.ElTypeNum = HTML_EL_BODY;
                    794:       root = TtaSearchTypedElement (elType, SearchForward, root);
                    795:     }
                    796: 
                    797:   if (root != NULL)
1.12      cvs       798:     {
                    799:       /* don't check the abstract tree against the structure schema */
                    800:       checkingMode = TtaGetStructureChecking (destDoc);
                    801:       TtaSetStructureChecking (0, destDoc);
                    802:       /* get elem, the ancestor of *el which is a child of a DIV or BODY
                    803:         element in the destination document. The copied elements will be
                    804:         inserted just before this element. */
                    805:       elem = *el;
                    806:       do
1.1       cvs       807:        {
1.12      cvs       808:          ancestor = TtaGetParent (elem);
                    809:          if (ancestor != NULL)
                    810:            {
                    811:              elType = TtaGetElementType (ancestor);
                    812:              if (elType.ElTypeNum == HTML_EL_BODY ||
                    813:                  elType.ElTypeNum == HTML_EL_Division)
                    814:                ancestor = NULL;
                    815:              else
                    816:                elem = ancestor;
                    817:            }
1.1       cvs       818:        }
1.12      cvs       819:       while (ancestor != NULL);
                    820:       parent = TtaGetParent (elem);
1.14      cvs       821: 
                    822:       /* insert a DIV element */
1.15      cvs       823:       elType.ElTypeNum = HTML_EL_Division;
1.16      cvs       824:       lastInserted = TtaNewElement (destDoc, elType);
                    825:       TtaInsertSibling (lastInserted, elem, TRUE, destDoc);
                    826:       RegisterSubDoc (lastInserted, url);
1.17      cvs       827:       CreateTargetAnchor (destDoc, lastInserted);
1.14      cvs       828: 
1.12      cvs       829:       /* do copy */
1.16      cvs       830:       firstInserted = NULL;
1.17      cvs       831:       if (isID)
                    832:        srce = root;
                    833:       else
                    834:        srce = TtaGetFirstChild (root);
1.12      cvs       835:       while (srce != NULL)
1.1       cvs       836:        {
1.12      cvs       837:          copy = TtaCopyTree (srce, sourceDoc, destDoc, parent);
                    838:          if (copy != NULL)
                    839:            {
1.16      cvs       840:              if (firstInserted == NULL)
1.12      cvs       841:                /* this is the first copied element. Insert it before elem */
                    842:                {
1.16      cvs       843:                  TtaInsertFirstChild (&copy, lastInserted, destDoc);
1.12      cvs       844:                  firstInserted = copy;
                    845:                }
                    846:              else
                    847:                /* insert the new copied element after the element previously
                    848:                   copied */
                    849:                TtaInsertSibling (copy, lastInserted, FALSE, destDoc);
                    850:              lastInserted = copy;
                    851:              /* update the NAMEs and URLs in the copied element */
                    852:              event.document = destDoc;
                    853:              event.position = sourceDoc;
                    854:              UpdateURLsInSubtree(&event, copy);
                    855:            }
                    856:          /* get the next element in the source document */
                    857:          old = srce;
                    858:          TtaNextSibling (&srce);
                    859:          if (deleteTree)
                    860:            TtaDeleteTree (old, sourceDoc);
1.13      cvs       861:          /* Stop here if the target points to a specific element with an ID */
                    862:          if (isID)
                    863:            srce = NULL;
1.1       cvs       864:        }
1.12      cvs       865:       
                    866:       /* delete the element(s) containing the link to the copied document */
                    867:       /* delete the parent element of *el and all empty ancestors */
                    868:       elem = TtaGetParent (*el);
                    869:       do
1.1       cvs       870:        {
1.12      cvs       871:          sibling = elem;
                    872:          TtaNextSibling (&sibling);
                    873:          if (sibling == NULL)
                    874:            {
                    875:              sibling = elem;
                    876:              TtaPreviousSibling (&sibling);
                    877:              if (sibling == NULL)
                    878:                elem = TtaGetParent (elem);
                    879:            }
1.1       cvs       880:        }
1.12      cvs       881:       while (sibling == NULL);
                    882:       TtaDeleteTree (elem, destDoc);
                    883:       /* restore previous chacking mode */
                    884:       TtaSetStructureChecking (checkingMode, destDoc);
                    885:       /* return the address of the first copied element */
                    886:       *el = firstInserted;
                    887:     }
1.1       cvs       888: }
                    889: 
1.29      cvs       890: 
                    891: #ifdef __STDC__
                    892: void               GetIncludedDocuments_callback (int newdoc, int status, 
1.36    ! cvs       893:                                             STRING urlName,
        !           894:                                             STRING outputfile, 
        !           895:                                             STRING content_type,
1.29      cvs       896:                                             void * context)
                    897: #else  /* __STDC__ */
                    898: void               GetIncludedDocuments_callback (newdoc, status, urlName,
                    899:                                              outputfile, content_type, 
                    900:                                              context)
                    901: int newdoc;
                    902: int status;
1.36    ! cvs       903: STRING urlName;
        !           904: STRING outputfile;
        !           905: STRING content_type;
1.29      cvs       906: void *context;
                    907: #endif /* __STDC__ */
                    908: {
                    909:   Element              link, next;
                    910:   Attribute            RelAttr, HrefAttr;
1.36    ! cvs       911:   STRING               url, ptr, text;
1.29      cvs       912:   Document             document;
                    913:   GetIncludedDocuments_context  *ctx;
                    914: 
                    915:   /* restore GetIncludedDocuments's context */
                    916:   ctx = (GetIncludedDocuments_context *) context;
                    917:   
                    918:   if (!ctx)
                    919:     return;
                    920: 
                    921:   RelAttr = ctx->RelAttr;
                    922:   link = ctx->link;
                    923:   HrefAttr = ctx->HrefAttr;
                    924:   url = ctx->url;
                    925:   ptr = ctx->ptr;
                    926:   document = ctx->document;
                    927:   next = ctx->next;
                    928:   text = ctx->text;
                    929: 
                    930:   TtaFreeMemory (ctx);
                    931: 
                    932:   if (RelAttr != NULL && link != NULL)
                    933:     {
                    934:       if (HrefAttr != NULL)
                    935:        {
                    936:          if (url != NULL)
                    937:            {
                    938:              if (newdoc != 0 && newdoc != document)
                    939:                {
                    940:                  /* it's not the document itself */
                    941:                  /* copy the target document at the position of the link */
                    942:                  MoveDocumentBody (&next, document, newdoc, ptr, url,
                    943:                                    newdoc == IncludedDocument);
                    944:                }
                    945:              /* global variables */
                    946:              FreeDocumentResource (IncludedDocument);
                    947:              TtaCloseDocument (IncludedDocument);
                    948:              IncludedDocument = 0;
                    949:            }
                    950:          TtaFreeMemory (text);
                    951:        }
                    952:     }
                    953:   
                    954:   if (next != NULL && DocBook == document)
                    955:     {
                    956:       SetStopButton (document);
                    957:       GetIncludedDocuments (next, document);
                    958:     }
                    959:   else
                    960:     MakeBook_callback (document);
                    961: }
                    962: 
1.1       cvs       963: /*----------------------------------------------------------------------
                    964:   GetIncludedDocuments
                    965:   Look forward, starting from element el, for a link (A) with attribute
1.5       cvs       966:   REL="chapter" or REL="subdocument" and replace that link by the contents
                    967:   of the target document.
1.1       cvs       968:   ----------------------------------------------------------------------*/
                    969: #ifdef __STDC__
1.29      cvs       970: static void         GetIncludedDocuments (Element el, Document document)
1.1       cvs       971: #else
1.29      cvs       972: static void         GetIncludedDocuments (el, document)
1.1       cvs       973: Element                    el;
                    974: Document            document;
                    975: #endif
                    976: {
1.29      cvs       977:   Element              link, next;
                    978:   Attribute            RelAttr, HrefAttr = NULL;
                    979:   AttributeType        attrType;
                    980:   int                  length;
1.36    ! cvs       981:   STRING               text, ptr, url = NULL;
1.29      cvs       982:   Document             newdoc;
                    983:   boolean              call_callback = FALSE;
                    984:   GetIncludedDocuments_context  *ctx = NULL;
                    985: 
                    986:   link = el;
                    987:   RelAttr = NULL;
                    988:   next = NULL;
                    989: 
                    990:   ctx = TtaGetMemory (sizeof (GetIncludedDocuments_context));
                    991:   memset (ctx, 0, sizeof (GetIncludedDocuments_context));
                    992: 
                    993:   attrType.AttrSSchema = TtaGetDocumentSSchema (document);
                    994:   attrType.AttrTypeNum = HTML_ATTR_REL;
                    995: 
                    996: 
                    997:   /* looks for an anchor having an attribute REL="chapter" or
                    998:      REL="subdocument" */
                    999:   while (link != NULL && RelAttr == NULL)
                   1000:     {
                   1001:       TtaSearchAttribute (attrType, SearchForward, link, &link, &RelAttr);
                   1002:       if (link != NULL && RelAttr != NULL)
                   1003:        {
                   1004:          length = TtaGetTextAttributeLength (RelAttr);
                   1005:          text = TtaGetMemory (length + 1);
                   1006:          TtaGiveTextAttributeValue (RelAttr, text, &length);
1.36    ! cvs      1007:          if (ustrcasecmp (text, "chapter") && ustrcasecmp (text, "subdocument"))
1.29      cvs      1008:            RelAttr = NULL;
                   1009:          TtaFreeMemory (text);
                   1010:        }
                   1011:     }
                   1012:   
                   1013:   ctx->RelAttr = RelAttr;
                   1014:   ctx->link =  link;
                   1015:   ctx->document = document;
                   1016:   ctx->HrefAttr = HrefAttr;
1.1       cvs      1017: 
1.29      cvs      1018:   if (RelAttr != NULL && link != NULL)
                   1019:     /* a link with attribute REL="Chapter" has been found */
                   1020:     {
                   1021:       next = link;
                   1022:       ctx->next =next;
                   1023:       attrType.AttrTypeNum = HTML_ATTR_HREF_;
                   1024:       HrefAttr = TtaGetAttribute (link, attrType);
                   1025:       if (HrefAttr != NULL)
1.1       cvs      1026:         /* this link has an attribute HREF */
                   1027:         {
                   1028:           length = TtaGetTextAttributeLength (HrefAttr);
                   1029:           text = TtaGetMemory (length + 1);
                   1030:           TtaGiveTextAttributeValue (HrefAttr, text, &length);
1.36    ! cvs      1031:           ptr = ustrrchr (text, '#');
1.12      cvs      1032:           url = text;
                   1033:           if (ptr != NULL)
                   1034:             {
                   1035:               if (ptr == text)
                   1036:                 url = NULL;
1.16      cvs      1037:               /* link to a particular position within a remote document */
1.12      cvs      1038:               ptr[0] = EOS;
                   1039:               ptr = &ptr[1];
                   1040:             }
1.29      cvs      1041:           
                   1042:           ctx->url = url;
                   1043:           ctx->ptr = ptr;
                   1044:           ctx->text = text;
                   1045:           ctx->HrefAttr = HrefAttr;
1.12      cvs      1046: 
                   1047:           if (url != NULL)
1.29      cvs      1048:             /* this link designates an external document */
1.1       cvs      1049:             {
                   1050:               /* create a new document and loads the target document */
1.25      cvs      1051:               IncludedDocument = TtaNewDocument ("HTML", "tmp");
1.30      cvs      1052:               if (IncludedDocument != 0)
                   1053:                  {
                   1054:                  TtaSetStatus (document, 1, TtaGetMessage (AMAYA, AM_FETCHING), url);
                   1055:                  newdoc = GetHTMLDocument (url, NULL, IncludedDocument,
1.29      cvs      1056:                                         document, CE_MAKEBOOK, FALSE, 
                   1057:                                         (void *) GetIncludedDocuments_callback,
                   1058:                                         (void *) ctx);
1.30      cvs      1059:                  }
1.1       cvs      1060:             }
1.29      cvs      1061:           else 
                   1062:             call_callback = TRUE;
                   1063:          }
                   1064:        else
                   1065:         call_callback = TRUE;
                   1066:      } 
                   1067:    else
                   1068:      call_callback = TRUE;
                   1069:     
                   1070:     if (call_callback)
                   1071:       GetIncludedDocuments_callback (document, -1, url, NULL, NULL, 
                   1072:                                     (void *) ctx);
1.1       cvs      1073: }
                   1074: 
                   1075: 
                   1076: /*----------------------------------------------------------------------
1.29      cvs      1077:   MakeBook_callback
                   1078:   ----------------------------------------------------------------------*/
                   1079: #ifdef __STDC__
                   1080: void MakeBook_callback (Document document)
                   1081: #else
                   1082: void MakeBook_callback (Document document)
                   1083: #endif /* __STDC__ */
                   1084: 
                   1085: {
                   1086:   ResetStop (document);
                   1087:   /* update internal links */
                   1088:   SetInternalLinks (document);
                   1089:   /* remove registered  sub-documents */
                   1090:   FreeSubDocTable ();
                   1091:   DocBook = 0;
                   1092:   TtaSetStatus (document, 1, TtaGetMessage (AMAYA, AM_DOCUMENT_LOADED), NULL);
                   1093: }
                   1094: 
                   1095: /*----------------------------------------------------------------------
1.1       cvs      1096:   MakeBook
                   1097:   Replace all links in a document which have an attribute REL="chapter"
1.5       cvs      1098:   or REL="subdocument" by the corresponding target document.
1.1       cvs      1099:   ----------------------------------------------------------------------*/
                   1100: #ifdef __STDC__
                   1101: void                MakeBook (Document document, View view)
                   1102: #else
                   1103: void                MakeBook (document, view)
                   1104: Document            document;
                   1105: View                view;
                   1106: #endif
                   1107: {
                   1108:    Element         root, body, el;
                   1109:    ElementType     elType;
                   1110: 
1.24      cvs      1111:    /* stops all current transfers on this document */
1.25      cvs      1112:    StopTransfer (document, 1);
                   1113:    /* simulate a transfert in the main document */
                   1114:    ActiveMakeBook (document);
1.1       cvs      1115:    root = TtaGetMainRoot (document);
                   1116:    elType = TtaGetElementType (root);
                   1117:    elType.ElTypeNum = HTML_EL_BODY;
                   1118:    body = TtaSearchTypedElement (elType, SearchForward, root);
                   1119:    TtaSetDocumentModified (document);
                   1120:    el = body;
1.29      cvs      1121: 
                   1122:    if (el != NULL && DocBook == document)
                   1123:      GetIncludedDocuments (el, document);
                   1124:    else
                   1125:      MakeBook_callback (document);
1.1       cvs      1126: }
1.29      cvs      1127: 
                   1128: 
                   1129: 
                   1130: 
                   1131: 
                   1132: 
                   1133: 
                   1134: 
                   1135: 
                   1136: 

Webmaster