Diff for /Amaya/amaya/HTMLbook.c between versions 1.134 and 1.135

version 1.134, 2005/09/22 10:16:54 version 1.135, 2005/11/24 14:55:03
Line 13 Line 13
  */   */
   
 #ifdef _WX  #ifdef _WX
   #include "wx/wx.h"  #include "wx/wx.h"
 #endif /* _WX */  #endif /* _WX */
   
 /* Included headerfiles */  /* Included headerfiles */
Line 29 Line 29
   
 /* structure to register sub-documents in MakeBook function*/  /* structure to register sub-documents in MakeBook function*/
 typedef struct _SubDoc  typedef struct _SubDoc
   {  {
      struct _SubDoc  *SDnext;    struct _SubDoc  *SDnext;
      Element          SDel;    Element          SDel;
      char            *SDname;    char            *SDname;
   }SubDoc;  }SubDoc;
   
 /* the structure used for the GetIncludedDocuments_callback function */  /* the structure used for the GetIncludedDocuments_callback function */
 typedef struct _IncludeCtxt  typedef struct _IncludeCtxt
Line 75  static int              PagePerSheet; Line 75  static int              PagePerSheet;
 #endif /* _WINGUI */  #endif /* _WINGUI */
   
 #ifdef _WX  #ifdef _WX
   #include "wxdialogapi_f.h"  #include "wxdialogapi_f.h"
 #endif /* _WX */  #endif /* _WX */
   
 static ThotBool GetIncludedDocuments (Element el, Element link,  static ThotBool GetIncludedDocuments (Element el, Element link,
                                       Document doc, IncludeCtxt *prev);                                        Document doc, IncludeCtxt *prev);
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
   RedisplayDocument redisplays a view of a document    RedisplayDocument redisplays a view of a document
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
Line 120  static void RegisterSubDoc (Element el, Line 120  static void RegisterSubDoc (Element el,
     {      {
       last = SubDocs;        last = SubDocs;
       while (last->SDnext != NULL)        while (last->SDnext != NULL)
         last = last->SDnext;          last = last->SDnext;
       last->SDnext = entry;        last->SDnext = entry;
     }      }
 }  }
Line 147  static Element SearchSubDoc (char *url) Line 147  static Element SearchSubDoc (char *url)
     {      {
       docFound = (strcmp (url, entry->SDname) == 0);        docFound = (strcmp (url, entry->SDname) == 0);
       if (!docFound)        if (!docFound)
         entry = entry->SDnext;          entry = entry->SDnext;
       else        else
         /* document found -> return the DIV element */          /* document found -> return the DIV element */
         el = entry->SDel;          el = entry->SDel;
     }      }
   return (el);    return (el);
 }  }
Line 210  void SetInternalLinks (Document document Line 210  void SetInternalLinks (Document document
       el = link;        el = link;
       position = 0;        position = 0;
       while (el != NULL)        while (el != NULL)
         {          {
           sibling = el;            sibling = el;
           do            do
             {              {
               /* add volume of each previous element */                /* add volume of each previous element */
               TtaPreviousSibling (&sibling);                TtaPreviousSibling (&sibling);
               if (sibling != NULL)                if (sibling != NULL)
                 position += TtaGetElementVolume (sibling);                  position += TtaGetElementVolume (sibling);
             }              }
           while (sibling != NULL);            while (sibling != NULL);
           el = TtaGetParent (el);            el = TtaGetParent (el);
         }          }
       sprintf (number, "%d", position*100/volume);        sprintf (number, "%d", position*100/volume);
       TtaSetStatus (document, 1, TtaGetMessage (AMAYA, AM_UPDATED_LINK), number);        TtaSetStatus (document, 1, TtaGetMessage (AMAYA, AM_UPDATED_LINK), number);
       TtaHandlePendingEvents ();        TtaHandlePendingEvents ();
       link = TtaSearchTypedElement (elType, SearchForward, link);        link = TtaSearchTypedElement (elType, SearchForward, link);
       if (link != NULL)        if (link != NULL)
         /* a link has been found */          /* a link has been found */
         {          {
           linkType = TtaGetElementType (link);            linkType = TtaGetElementType (link);
           if (linkType.ElTypeNum == HTML_EL_Anchor)            if (linkType.ElTypeNum == HTML_EL_Anchor)
              attrType.AttrTypeNum = HTML_ATTR_HREF_;              attrType.AttrTypeNum = HTML_ATTR_HREF_;
           else            else
              attrType.AttrTypeNum = HTML_ATTR_cite;              attrType.AttrTypeNum = HTML_ATTR_cite;
           HrefAttr = TtaGetAttribute (link, attrType);            HrefAttr = TtaGetAttribute (link, attrType);
           attrType.AttrTypeNum = HTML_ATTR_InternalLink;            attrType.AttrTypeNum = HTML_ATTR_InternalLink;
           IntLinkAttr = TtaGetAttribute (link, attrType);            IntLinkAttr = TtaGetAttribute (link, attrType);
           attrType.AttrTypeNum = HTML_ATTR_ExternalLink;            attrType.AttrTypeNum = HTML_ATTR_ExternalLink;
           ExtLinkAttr = TtaGetAttribute (link, attrType);            ExtLinkAttr = TtaGetAttribute (link, attrType);
           if (HrefAttr == NULL)            if (HrefAttr == NULL)
             /* this element is not a link (no href or cite attribute) */              /* this element is not a link (no href or cite attribute) */
             /* remove attributes InternalLink and ExternalLink if they              /* remove attributes InternalLink and ExternalLink if they
                are present */                 are present */
             {              {
               if (IntLinkAttr != NULL)                if (IntLinkAttr != NULL)
                 TtaRemoveAttribute (link, IntLinkAttr, document);                  TtaRemoveAttribute (link, IntLinkAttr, document);
               if (ExtLinkAttr != NULL)                if (ExtLinkAttr != NULL)
                 TtaRemoveAttribute (link, ExtLinkAttr, document);                            TtaRemoveAttribute (link, ExtLinkAttr, document);          
             }              }
           else            else
             /* this element has an HREF or cite attribute */              /* this element has an HREF or cite attribute */
             {              {
               length = TtaGetTextAttributeLength (HrefAttr);                length = TtaGetTextAttributeLength (HrefAttr);
               text = (char *)TtaGetMemory (length + 1);                text = (char *)TtaGetMemory (length + 1);
               TtaGiveTextAttributeValue (HrefAttr, text, &length);                TtaGiveTextAttributeValue (HrefAttr, text, &length);
   
               /* does an external link become an internal link ? */                /* does an external link become an internal link ? */
               if (document == DocBook && SubDocs != NULL)                if (document == DocBook && SubDocs != NULL)
                 {                  {
                   ptr = strrchr (text, '#');                    ptr = strrchr (text, '#');
                   url = text;                    url = text;
                   split = FALSE;                    split = FALSE;
                   if (ptr == text)                    if (ptr == text)
                       /* a local link */                      /* a local link */
                       url = NULL;                      url = NULL;
                   else if (ptr != NULL)                    else if (ptr != NULL)
                     {                      {
                       /* split url and name part */                        /* split url and name part */
                       ptr[0] = EOS;                        ptr[0] = EOS;
                       split = TRUE;                        split = TRUE;
                     }                      }
   
                   /* Is it a sub-document */                    /* Is it a sub-document */
                   div = SearchSubDoc (url);                    div = SearchSubDoc (url);
                   if (split)                    if (split)
                     /* retore the mark */                      /* retore the mark */
                     ptr[0] = '#';                      ptr[0] = '#';
   
                   if (div == NULL)                    if (div == NULL)
                     {                      {
                       /* it's not a sub-document */                        /* it's not a sub-document */
                       if (url == NULL)                        if (url == NULL)
                         /* a local link */                          /* a local link */
                         ptr = &text[1];                          ptr = &text[1];
                       else                        else
                         /* still an externa; link */                          /* still an externa; link */
                         ptr = NULL;                          ptr = NULL;
                     }                      }
                   else                    else
                     {                      {
                       /* this link becomes internal */                        /* this link becomes internal */
                       if (ptr != NULL)                        if (ptr != NULL)
                         {                          {
                           /* get the target name */                            /* get the target name */
                           strcpy (value, ptr);                            strcpy (value, ptr);
                           length = strlen (value);                            length = strlen (value);
                           /* check whether the name changed */                            /* check whether the name changed */
                           i = 0;                            i = 0;
                           target = SearchNAMEattribute (document, &value[1], NULL, NULL);                            target = SearchNAMEattribute (document, &value[1], NULL, NULL);
                           while (target != NULL)                            while (target != NULL)
                             {                              {
                               /* is it the right NAME */                                /* is it the right NAME */
                               if (TtaIsAncestor (target, div))                                if (TtaIsAncestor (target, div))
                                 target = NULL;                                  target = NULL;
                               else                                else
                                 {                                  {
                                   /* continue the search */                                    /* continue the search */
                                   i++;                                    i++;
                                   sprintf (&value[length], "%d", i);                                    sprintf (&value[length], "%d", i);
                                   target = SearchNAMEattribute (document,                                    target = SearchNAMEattribute (document,
                                                         &value[1], NULL, NULL);                                                                  &value[1], NULL, NULL);
                                 }                                  }
                             }                              }
                         }                          }
                       else                        else
                         {                          {
                           /* get the DIV name */                            /* get the DIV name */
                           attrType.AttrTypeNum = HTML_ATTR_ID;                            attrType.AttrTypeNum = HTML_ATTR_ID;
                           attr = TtaGetAttribute (div, attrType);                            attr = TtaGetAttribute (div, attrType);
                           length = 200;                            length = 200;
                           value[0] = '#';                            value[0] = '#';
                           TtaGiveTextAttributeValue (attr, &value[1], &length);                            TtaGiveTextAttributeValue (attr, &value[1], &length);
                         }                          }
                       ptr = &value[1];                        ptr = &value[1];
                       TtaSetAttributeText (HrefAttr, value, link, document);                        TtaSetAttributeText (HrefAttr, value, link, document);
                     }                      }
                 }                  }
               else if (text[0] == '#')                else if (text[0] == '#')
                   ptr = &text[1];                  ptr = &text[1];
               else                else
                 ptr = NULL;                  ptr = NULL;
   
               if (ptr != NULL)                if (ptr != NULL)
                 /* it's an internal link. Attach an attribute InternalLink */                  /* it's an internal link. Attach an attribute InternalLink */
                 /* to the link, if this attribute does not exist yet */                  /* to the link, if this attribute does not exist yet */
                 {                  {
                   if (IntLinkAttr == NULL)                    if (IntLinkAttr == NULL)
                     {                      {
                       attrType.AttrTypeNum = HTML_ATTR_InternalLink;                        attrType.AttrTypeNum = HTML_ATTR_InternalLink;
                       IntLinkAttr = TtaNewAttribute (attrType);                        IntLinkAttr = TtaNewAttribute (attrType);
                       TtaAttachAttribute (link, IntLinkAttr, document);                        TtaAttachAttribute (link, IntLinkAttr, document);
                     }                      }
                   /* looks for the target element */                    /* looks for the target element */
                   target = SearchNAMEattribute (document, ptr, NULL, NULL);                    target = SearchNAMEattribute (document, ptr, NULL, NULL);
                   if (target != NULL)                    if (target != NULL)
                     /* set the Thot link */                      /* set the Thot link */
                     TtaSetAttributeReference (IntLinkAttr, link, document,                      TtaSetAttributeReference (IntLinkAttr, link, document,
                                               target);                                                target);
                 }                  }
               else                else
                 /* it's an external link */                  /* it's an external link */
                 {                  {
                   /* Remove the InternalLink attribute if it is present */                    /* Remove the InternalLink attribute if it is present */
                   if (IntLinkAttr != NULL)                    if (IntLinkAttr != NULL)
                     TtaRemoveAttribute (link, IntLinkAttr, document);                      TtaRemoveAttribute (link, IntLinkAttr, document);
                   /* create an ExternalLink attribute if there is none */                    /* create an ExternalLink attribute if there is none */
                   if (ExtLinkAttr == NULL)                    if (ExtLinkAttr == NULL)
                     {                      {
                       attrType.AttrTypeNum = HTML_ATTR_ExternalLink;                        attrType.AttrTypeNum = HTML_ATTR_ExternalLink;
                       ExtLinkAttr = TtaNewAttribute (attrType);                        ExtLinkAttr = TtaNewAttribute (attrType);
                       TtaAttachAttribute (link, ExtLinkAttr, document);                        TtaAttachAttribute (link, ExtLinkAttr, document);
                     }                      }
                 }                  }
               TtaFreeMemory (text);                TtaFreeMemory (text);
             }              }
         }          }
     }      }
   /* Reset document status */    /* Reset document status */
   if (!status)    if (!status)
Line 394  static void CheckPrintingDocument (Docum Line 394  static void CheckPrintingDocument (Docum
       /* define the new default PS file */        /* define the new default PS file */
       ptr = TtaGetEnvString ("APP_TMPDIR");        ptr = TtaGetEnvString ("APP_TMPDIR");
       if (ptr != NULL && TtaCheckDirectory (ptr))        if (ptr != NULL && TtaCheckDirectory (ptr))
         strcpy (PSfile, ptr);          strcpy (PSfile, ptr);
       else        else
         strcpy (PSfile, TtaGetDefEnvString ("APP_TMPDIR"));          strcpy (PSfile, TtaGetDefEnvString ("APP_TMPDIR"));
       lg = strlen (PSfile);        lg = strlen (PSfile);
       if (PSfile[lg - 1] == DIR_SEP)        if (PSfile[lg - 1] == DIR_SEP)
         PSfile[--lg] = EOS;          PSfile[--lg] = EOS;
       strcpy (docName, TtaGetDocumentName (document));        strcpy (docName, TtaGetDocumentName (document));
       TtaExtractSuffix (docName, suffix);        TtaExtractSuffix (docName, suffix);
       sprintf (&PSfile[lg], "%c%s.ps", DIR_SEP, docName);        sprintf (&PSfile[lg], "%c%s.ps", DIR_SEP, docName);
Line 408  static void CheckPrintingDocument (Docum Line 408  static void CheckPrintingDocument (Docum
 }  }
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
    PrintDocument prints the document using predefined parameters.    PrintDocument prints the document using predefined parameters.
    ----------------------------------------------------------------------*/      ----------------------------------------------------------------------*/  
 static void PrintDocument (Document doc, View view)  static void PrintDocument (Document doc, View view)
 {  {
 #if defined(_WINDOWS) && defined(_WX) && defined(IV)  #if defined(_WINDOWS) && defined(_WX) && defined(IV)
   /* On windows and with wxWidgets, disable printing for the moment */    /* On windows and with wxWidgets, disable printing for the moment */
   wxMessageDialog messagedialog( NULL,    wxMessageDialog messagedialog( NULL,
                                  TtaConvMessageToWX("Not implemented yet"),                                    TtaConvMessageToWX("Not implemented yet"), 
                                  _T("Warning"),                                   _T("Warning"),
                                  (long) wxOK | wxICON_EXCLAMATION | wxSTAY_ON_TOP);                                   (long) wxOK | wxICON_EXCLAMATION | wxSTAY_ON_TOP);
   messagedialog.ShowModal();    messagedialog.ShowModal();
 #else /* defined(_WINDOWS) && defined(_WX) */  #else /* defined(_WINDOWS) && defined(_WX) */
   AttributeType      attrType;    AttributeType      attrType;
Line 430  static void PrintDocument (Document doc, Line 430  static void PrintDocument (Document doc,
   
   textFile = (DocumentTypes[doc] == docText ||    textFile = (DocumentTypes[doc] == docText ||
               DocumentTypes[doc] == docSource ||                DocumentTypes[doc] == docSource ||
               DocumentTypes[doc] == docCSS);                DocumentTypes[doc] == docCSS);
   
   /* initialize printing information */    /* initialize printing information */
   CheckPrintingDocument (doc);    CheckPrintingDocument (doc);
Line 441  static void PrintDocument (Document doc, Line 441  static void PrintDocument (Document doc,
   if (textFile)    if (textFile)
     {      {
       if (PageSize == PP_A4)        if (PageSize == PP_A4)
         {          {
           if (Orientation == PP_Landscape)            if (Orientation == PP_Landscape)
             TtaSetPrintSchema ("TextFilePL");              TtaSetPrintSchema ("TextFilePL");
           else            else
             TtaSetPrintSchema ("TextFilePP");              TtaSetPrintSchema ("TextFilePP");
         }          }
       else        else
         {          {
           if (Orientation == PP_Landscape)            if (Orientation == PP_Landscape)
             TtaSetPrintSchema ("TextFileUSL");              TtaSetPrintSchema ("TextFileUSL");
           else            else
             TtaSetPrintSchema ("TextFilePPUS");              TtaSetPrintSchema ("TextFilePPUS");
         }          }
     }      }
   else if (DocumentTypes[doc] == docSVG)    else if (DocumentTypes[doc] == docSVG)
     TtaSetPrintSchema ("SVGP");      TtaSetPrintSchema ("SVGP");
Line 464  static void PrintDocument (Document doc, Line 464  static void PrintDocument (Document doc,
   else if (DocumentTypes[doc] == docHTML)    else if (DocumentTypes[doc] == docHTML)
     {      {
       if (NumberLinks)        if (NumberLinks)
         /* display numbered links */          /* display numbered links */
         {          {
           /* associate an attribute InternalLink with all anchors refering            /* associate an attribute InternalLink with all anchors refering
              a target in the same document.  This allows P schemas to work               a target in the same document.  This allows P schemas to work
              properly */               properly */
           SetInternalLinks (DocPrint);            SetInternalLinks (DocPrint);
           if (PageSize == PP_A4)            if (PageSize == PP_A4)
             {              {
               if (Orientation == PP_Landscape)                if (Orientation == PP_Landscape)
                 TtaSetPrintSchema ("HTMLPLL");                  TtaSetPrintSchema ("HTMLPLL");
               else                else
                 TtaSetPrintSchema ("HTMLPLP");                  TtaSetPrintSchema ("HTMLPLP");
             }              }
           else            else
             {              {
               if (Orientation == PP_Landscape)                if (Orientation == PP_Landscape)
                 TtaSetPrintSchema ("HTMLUSLL");                  TtaSetPrintSchema ("HTMLUSLL");
               else                else
                 TtaSetPrintSchema ("HTMLPLPUS");                  TtaSetPrintSchema ("HTMLPLPUS");
             }              }
           strcat (viewsToPrint, "Links_view ");            strcat (viewsToPrint, "Links_view ");
         }          }
       else if (PageSize == PP_A4)        else if (PageSize == PP_A4)
         {          {
           if (Orientation == PP_Landscape)            if (Orientation == PP_Landscape)
             TtaSetPrintSchema ("HTMLPL");              TtaSetPrintSchema ("HTMLPL");
           else            else
             TtaSetPrintSchema ("HTMLPP");              TtaSetPrintSchema ("HTMLPP");
         }          }
       else        else
         {          {
           if (Orientation == PP_Landscape)            if (Orientation == PP_Landscape)
             TtaSetPrintSchema ("HTMLUSL");              TtaSetPrintSchema ("HTMLUSL");
           else            else
             TtaSetPrintSchema ("HTMLPPUS");              TtaSetPrintSchema ("HTMLPPUS");
         }              }    
     }      }
   status = TtaIsDocumentModified (doc);    status = TtaIsDocumentModified (doc);
   
Line 510  static void PrintDocument (Document doc, Line 510  static void PrintDocument (Document doc,
       attrType.AttrSSchema = TtaGetDocumentSSchema (doc);        attrType.AttrSSchema = TtaGetDocumentSSchema (doc);
       elType.ElSSchema = attrType.AttrSSchema;        elType.ElSSchema = attrType.AttrSSchema;
       if (textFile)        if (textFile)
         {          {
           elType. ElTypeNum = TextFile_EL_TextFile;            elType. ElTypeNum = TextFile_EL_TextFile;
           attrType.AttrTypeNum = TextFile_ATTR_PrintURL;            attrType.AttrTypeNum = TextFile_ATTR_PrintURL;
         }          }
       else        else
         {          {
           elType. ElTypeNum = HTML_EL_HTML;            elType. ElTypeNum = HTML_EL_HTML;
           attrType.AttrTypeNum = HTML_ATTR_PrintURL;            attrType.AttrTypeNum = HTML_ATTR_PrintURL;
         }          }
       docEl = TtaGetMainRoot (doc);        docEl = TtaGetMainRoot (doc);
       el = TtaSearchTypedElement (elType, SearchForward, docEl);        el = TtaSearchTypedElement (elType, SearchForward, docEl);
       attr = TtaGetAttribute (el, attrType);        attr = TtaGetAttribute (el, attrType);
       if (!attr && PrintURL)        if (!attr && PrintURL)
         {          {
           attr = TtaNewAttribute (attrType);            attr = TtaNewAttribute (attrType);
           TtaAttachAttribute (el, attr, doc);            TtaAttachAttribute (el, attr, doc);
         }          }
       if (attr && !PrintURL)        if (attr && !PrintURL)
         TtaRemoveAttribute (el, attr, doc);          TtaRemoveAttribute (el, attr, doc);
     }      }
       
   /* get the path dir where css files have to be stored */    /* get the path dir where css files have to be stored */
Line 551  static void PrintDocument (Document doc, Line 551  static void PrintDocument (Document doc,
 }  }
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
    PrintAs prints the document using predefined parameters.    PrintAs prints the document using predefined parameters.
    ----------------------------------------------------------------------*/      ----------------------------------------------------------------------*/  
 void PrintAs (Document doc, View view)  void PrintAs (Document doc, View view)
 {  {
 #ifdef _WINGUI  #ifdef _WINGUI
Line 564  void PrintAs (Document doc, View view) Line 564  void PrintAs (Document doc, View view)
 }  }
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
    CallbackImage handle return of Print form.                       CallbackImage handle return of Print form.                   
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 void CallbackPrint (int ref, int typedata, char *data)  void CallbackPrint (int ref, int typedata, char *data)
 {  {
Line 576  void CallbackPrint (int ref, int typedat Line 576  void CallbackPrint (int ref, int typedat
     case FormPrint:      case FormPrint:
       TtaDestroyDialogue (BasePrint + FormPrint);        TtaDestroyDialogue (BasePrint + FormPrint);
       switch (val)        switch (val)
         {          {
         case 1:          case 1:
           TtaSetPrintCommand (PPrinter);            TtaSetPrintCommand (PPrinter);
           TtaSetPsFile (PSfile);            TtaSetPsFile (PSfile);
           /* update the environment variable */            /* update the environment variable */
           TtaSetEnvString ("THOTPRINT", PPrinter, TRUE);            TtaSetEnvString ("THOTPRINT", PPrinter, TRUE);
           TtaSaveAppRegistry ();            TtaSaveAppRegistry ();
           PrintDocument (DocPrint, 1);            PrintDocument (DocPrint, 1);
           break;            break;
         default:          default:
           break;            break;
         }          }
       break;        break;
     case PrintOptions:      case PrintOptions:
       switch (val)        switch (val)
         {          {
         case 0:          case 0:
           /* Manual feed option */            /* Manual feed option */
           if (ManualFeed == PP_ON)            if (ManualFeed == PP_ON)
             ManualFeed = PP_OFF;              ManualFeed = PP_OFF;
           else            else
             ManualFeed = PP_ON;              ManualFeed = PP_ON;
           TtaSetPrintParameter (PP_ManualFeed, ManualFeed);            TtaSetPrintParameter (PP_ManualFeed, ManualFeed);
           break;            break;
         case 1:          case 1:
           /* Toc option */            /* Toc option */
           WithToC = !WithToC;            WithToC = !WithToC;
           break;            break;
         case 2:          case 2:
           /* NumberLinks option */            /* NumberLinks option */
           NumberLinks = !NumberLinks;            NumberLinks = !NumberLinks;
         case 3:          case 3:
           /* URL option */            /* URL option */
           PrintURL = !PrintURL;            PrintURL = !PrintURL;
           break;            break;
         case 4:          case 4:
           /* CSS option */            /* CSS option */
           IgnoreCSS = !IgnoreCSS;            IgnoreCSS = !IgnoreCSS;
           break;            break;
         }          }
       break;        break;
     case PaperFormat:      case PaperFormat:
       /* page size submenu */        /* page size submenu */
       switch (val)        switch (val)
         {          {
         case 0:          case 0:
           PageSize = PP_A4;            PageSize = PP_A4;
           break;            break;
         case 1:          case 1:
           PageSize = PP_US;            PageSize = PP_US;
           break;            break;
         }          }
       TtaSetPrintParameter (PP_PaperSize, PageSize);        TtaSetPrintParameter (PP_PaperSize, PageSize);
       break;        break;
     case PaperOrientation:      case PaperOrientation:
Line 638  void CallbackPrint (int ref, int typedat Line 638  void CallbackPrint (int ref, int typedat
     case PPagesPerSheet:      case PPagesPerSheet:
       /* pages per sheet submenu */        /* pages per sheet submenu */
       switch (val)        switch (val)
         {          {
         case 0:          case 0:
           PagePerSheet = 1;            PagePerSheet = 1;
           break;            break;
         case 1:          case 1:
           PagePerSheet = 2;            PagePerSheet = 2;
           break;            break;
         case 2:          case 2:
           PagePerSheet = 4;            PagePerSheet = 4;
           break;            break;
         }          }
       TtaSetPrintParameter (PP_PagesPerSheet, PagePerSheet);        TtaSetPrintParameter (PP_PagesPerSheet, PagePerSheet);
       break;        break;
     case PrintSupport:      case PrintSupport:
       /* paper print/save PostScript submenu */        /* paper print/save PostScript submenu */
       switch (val)        switch (val)
         {          {
         case 0:          case 0:
           if (PaperPrint == PP_PS)            if (PaperPrint == PP_PS)
             {              {
               PaperPrint = PP_PRINTER;                PaperPrint = PP_PRINTER;
 #ifdef _GTK  #ifdef _GTK
               TtaSetTextForm (BasePrint + PPrinterName, PPrinter);                TtaSetTextForm (BasePrint + PPrinterName, PPrinter);
 #endif /* _GTK */  #endif /* _GTK */
               TtaSetPrintParameter (PP_Destination, PaperPrint);                TtaSetPrintParameter (PP_Destination, PaperPrint);
             }              }
           break;            break;
         case 1:          case 1:
           if (PaperPrint == PP_PRINTER)            if (PaperPrint == PP_PRINTER)
             {              {
               PaperPrint = PP_PS;                PaperPrint = PP_PS;
 #ifdef _GTK  #ifdef _GTK
               TtaSetTextForm (BasePrint + PPrinterName, PSfile);                TtaSetTextForm (BasePrint + PPrinterName, PSfile);
 #endif /* _GTK */  #endif /* _GTK */
               TtaSetPrintParameter (PP_Destination, PaperPrint);                TtaSetPrintParameter (PP_Destination, PaperPrint);
             }              }
           break;            break;
         }          }
       break;        break;
     case PPrinterName:      case PPrinterName:
       if (data[0] != EOS)        if (data[0] != EOS)
         {          {
         if (PaperPrint == PP_PRINTER)            if (PaperPrint == PP_PRINTER)
             /* text capture zone for the printer name */              /* text capture zone for the printer name */
             strncpy (PPrinter, data, MAX_PATH);              strncpy (PPrinter, data, MAX_PATH);
         else            else
           /* text capture zone for the name of the PostScript file */              /* text capture zone for the name of the PostScript file */
           strncpy (PSfile, data, MAX_PATH);              strncpy (PSfile, data, MAX_PATH);
         }          }
       break;        break;
     }      }
 }  }
Line 697  void InitPrint (void) Line 697  void InitPrint (void)
 {  {
   char* ptr;    char* ptr;
   
    BasePrint = TtaSetCallback ((Proc)CallbackPrint, PRINT_MAX_REF);    BasePrint = TtaSetCallback ((Proc)CallbackPrint, PRINT_MAX_REF);
    DocPrint = 0;    DocPrint = 0;
    DocPrintURL = NULL;    DocPrintURL = NULL;
   
    /* read default printer variable */    /* read default printer variable */
    ptr = TtaGetEnvString ("THOTPRINT");    ptr = TtaGetEnvString ("THOTPRINT");
    if (ptr == NULL)    if (ptr == NULL)
      strcpy (PPrinter, "");      strcpy (PPrinter, "");
    else    else
      strcpy (PPrinter, ptr);      strcpy (PPrinter, ptr);
    TtaSetPrintCommand (PPrinter);    TtaSetPrintCommand (PPrinter);
    PaperPrint = PP_PRINTER;    PaperPrint = PP_PRINTER;
    TtaSetPrintParameter (PP_Destination, PaperPrint);    TtaSetPrintParameter (PP_Destination, PaperPrint);
   
    /* define the new default PrintSchema */    /* define the new default PrintSchema */
    NumberLinks = FALSE;    NumberLinks = FALSE;
    WithToC = FALSE;    WithToC = FALSE;
    IgnoreCSS = FALSE;    IgnoreCSS = FALSE;
    PrintURL = TRUE;    PrintURL = TRUE;
    PageSize = TtaGetPrintParameter (PP_PaperSize);            PageSize = TtaGetPrintParameter (PP_PaperSize);         
    TtaSetPrintSchema ("");    TtaSetPrintSchema ("");
    /* no manual feed */    /* no manual feed */
    ManualFeed = PP_OFF;    ManualFeed = PP_OFF;
    TtaSetPrintParameter (PP_ManualFeed, ManualFeed);    TtaSetPrintParameter (PP_ManualFeed, ManualFeed);
    PagePerSheet = 1;    PagePerSheet = 1;
    TtaSetPrintParameter (PP_PagesPerSheet, PagePerSheet);    TtaSetPrintParameter (PP_PagesPerSheet, PagePerSheet);
 }  }
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
Line 742  void SetupAndPrint (Document doc, View v Line 742  void SetupAndPrint (Document doc, View v
   
 #ifdef _GTK  #ifdef _GTK
   TtaNewSheet (BasePrint + FormPrint, TtaGetViewFrame (doc, view),     TtaNewSheet (BasePrint + FormPrint, TtaGetViewFrame (doc, view), 
                TtaGetMessage (LIB, TMSG_LIB_PRINT), 1,                 TtaGetMessage (LIB, TMSG_LIB_PRINT), 1,
                TtaGetMessage (LIB, TMSG_BUTTON_PRINT), FALSE, 3, 'L', D_CANCEL);                 TtaGetMessage (LIB, TMSG_BUTTON_PRINT), FALSE, 3, 'L', D_CANCEL);
   
   /* Paper format submenu */    /* Paper format submenu */
   i = 0;    i = 0;
Line 751  void SetupAndPrint (Document doc, View v Line 751  void SetupAndPrint (Document doc, View v
   i += strlen (&bufMenu[i]) + 1;    i += strlen (&bufMenu[i]) + 1;
   sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_US));    sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_US));
   TtaNewSubmenu (BasePrint + PaperFormat, BasePrint + FormPrint, 0,    TtaNewSubmenu (BasePrint + PaperFormat, BasePrint + FormPrint, 0,
                  TtaGetMessage (LIB, TMSG_PAPER_SIZE), 2, bufMenu, NULL, 0, TRUE);                   TtaGetMessage (LIB, TMSG_PAPER_SIZE), 2, bufMenu, NULL, 0, TRUE);
   if (PageSize == PP_US)    if (PageSize == PP_US)
     TtaSetMenuForm (BasePrint + PaperFormat, 1);      TtaSetMenuForm (BasePrint + PaperFormat, 1);
   else    else
Line 763  void SetupAndPrint (Document doc, View v Line 763  void SetupAndPrint (Document doc, View v
   i += strlen (&bufMenu[i]) + 1;    i += strlen (&bufMenu[i]) + 1;
   sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (AMAYA, AM_LANDSCAPE));    sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (AMAYA, AM_LANDSCAPE));
   TtaNewSubmenu (BasePrint + PaperOrientation, BasePrint + FormPrint, 0,    TtaNewSubmenu (BasePrint + PaperOrientation, BasePrint + FormPrint, 0,
                  TtaGetMessage (AMAYA, AM_ORIENTATION), 2, bufMenu, NULL, 0, TRUE);                   TtaGetMessage (AMAYA, AM_ORIENTATION), 2, bufMenu, NULL, 0, TRUE);
   if (Orientation == PP_Landscape)    if (Orientation == PP_Landscape)
     TtaSetMenuForm (BasePrint + PaperOrientation, 1);      TtaSetMenuForm (BasePrint + PaperOrientation, 1);
   else    else
Line 776  void SetupAndPrint (Document doc, View v Line 776  void SetupAndPrint (Document doc, View v
   i += strlen (&bufMenu[i]) + 1;    i += strlen (&bufMenu[i]) + 1;
   sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_4_PAGE_SHEET));    sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_4_PAGE_SHEET));
   TtaNewSubmenu (BasePrint + PPagesPerSheet, BasePrint + FormPrint, 0,    TtaNewSubmenu (BasePrint + PPagesPerSheet, BasePrint + FormPrint, 0,
                  TtaGetMessage (LIB, TMSG_REDUCTION), 3, bufMenu, NULL, 0, TRUE);                   TtaGetMessage (LIB, TMSG_REDUCTION), 3, bufMenu, NULL, 0, TRUE);
   if (PagePerSheet == 1)    if (PagePerSheet == 1)
     TtaSetMenuForm (BasePrint + PPagesPerSheet, 0);      TtaSetMenuForm (BasePrint + PPagesPerSheet, 0);
   else if (PagePerSheet == 2)    else if (PagePerSheet == 2)
Line 790  void SetupAndPrint (Document doc, View v Line 790  void SetupAndPrint (Document doc, View v
   i += strlen (&bufMenu[i]) + 1;    i += strlen (&bufMenu[i]) + 1;
   sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_PS_FILE));    sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_PS_FILE));
   TtaNewSubmenu (BasePrint + PrintSupport, BasePrint + FormPrint, 0,    TtaNewSubmenu (BasePrint + PrintSupport, BasePrint + FormPrint, 0,
                  TtaGetMessage (LIB, TMSG_OUTPUT), 2, bufMenu, NULL, 0, TRUE);                   TtaGetMessage (LIB, TMSG_OUTPUT), 2, bufMenu, NULL, 0, TRUE);
   
   /* PaperPrint selector */    /* PaperPrint selector */
   TtaNewTextForm (BasePrint + PPrinterName, BasePrint + FormPrint, NULL, 30, 1, TRUE);    TtaNewTextForm (BasePrint + PPrinterName, BasePrint + FormPrint, NULL, 30, 1, TRUE);
Line 817  void SetupAndPrint (Document doc, View v Line 817  void SetupAndPrint (Document doc, View v
   i += strlen (&bufMenu[i]) + 1;    i += strlen (&bufMenu[i]) + 1;
   sprintf (&bufMenu[i], "%s%s", "T", TtaGetMessage (AMAYA, AM_WITH_CSS));    sprintf (&bufMenu[i], "%s%s", "T", TtaGetMessage (AMAYA, AM_WITH_CSS));
   TtaNewToggleMenu (BasePrint + PrintOptions, BasePrint + FormPrint,    TtaNewToggleMenu (BasePrint + PrintOptions, BasePrint + FormPrint,
                     TtaGetMessage (LIB, TMSG_OPTIONS), 5, bufMenu, NULL, FALSE);                      TtaGetMessage (LIB, TMSG_OPTIONS), 5, bufMenu, NULL, FALSE);
   if (ManualFeed == PP_ON)    if (ManualFeed == PP_ON)
     TtaSetToggleMenu (BasePrint + PrintOptions, 0, TRUE);      TtaSetToggleMenu (BasePrint + PrintOptions, 0, TRUE);
   else    else
Line 887  void SetupAndPrint (Document doc, View v Line 887  void SetupAndPrint (Document doc, View v
     /* The dialog creation */      /* The dialog creation */
     ThotBool created;      ThotBool created;
     created = CreatePrintDlgWX (BasePrint + FormPrint, TtaGetViewFrame (doc, view),      created = CreatePrintDlgWX (BasePrint + FormPrint, TtaGetViewFrame (doc, view),
                                 PPrinter,                                  PPrinter,
                                 PSfile,                                   PSfile, 
                                 paper_format,                                  paper_format,
                                 orientation,                                  orientation,
                                 disposition,                                  disposition,
                                 paper_print,                                  paper_print,
                                 manual_feed,                                  manual_feed,
                                 with_toc,                                  with_toc,
                                 with_links,                                  with_links,
                                 with_url,                                  with_url,
                                 ignore_css);                                  ignore_css);
     if (created)      if (created)
       {        {
         TtaShowDialogue (BasePrint+FormPrint, FALSE);          TtaShowDialogue (BasePrint+FormPrint, FALSE);
       }        }
   }    }
       
Line 928  void UpdateURLsInSubtree (NotifyElement Line 928  void UpdateURLsInSubtree (NotifyElement
     {      {
       elType.ElSSchema = HTMLschema;        elType.ElSSchema = HTMLschema;
       while (nextEl != NULL)        while (nextEl != NULL)
         {          {
           event->element = nextEl;            event->element = nextEl;
           ElementPasted (event);            ElementPasted (event);
                       
           /* manage included links and anchors */            /* manage included links and anchors */
           elType.ElTypeNum = HTML_EL_Anchor;            elType.ElTypeNum = HTML_EL_Anchor;
           child = TtaSearchTypedElement (elType, SearchInTree, nextEl);            child = TtaSearchTypedElement (elType, SearchInTree, nextEl);
           while (child)            while (child)
             {              {
               event->element = child;                event->element = child;
               ElementPasted (event);                ElementPasted (event);
               child = TtaSearchTypedElementInTree (elType, SearchForward, nextEl, child);                child = TtaSearchTypedElementInTree (elType, SearchForward, nextEl, child);
             }              }
                       
           /* manage included links and anchors */            /* manage included links and anchors */
           elType.ElTypeNum = HTML_EL_PICTURE_UNIT;            elType.ElTypeNum = HTML_EL_PICTURE_UNIT;
           child = TtaSearchTypedElement (elType, SearchInTree, nextEl);            child = TtaSearchTypedElement (elType, SearchInTree, nextEl);
           while (child)            while (child)
             {              {
               event->element = child;                event->element = child;
               ElementPasted (event);                ElementPasted (event);
               child = TtaSearchTypedElementInTree (elType, SearchForward, nextEl, child);                child = TtaSearchTypedElementInTree (elType, SearchForward, nextEl, child);
             }              }
           TtaNextSibling (&nextEl);            TtaNextSibling (&nextEl);
         }          }
     }      }
 }  }
   
Line 967  void UpdateURLsInSubtree (NotifyElement Line 967  void UpdateURLsInSubtree (NotifyElement
   Return the root element that delimits the new inserted part (a div).    Return the root element that delimits the new inserted part (a div).
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 static Element MoveDocumentBody (Element el, Document destDoc,  static Element MoveDocumentBody (Element el, Document destDoc,
                                  Document sourceDoc, char *target,                                   Document sourceDoc, char *target,
                                  char *url, ThotBool deleteTree)                                   char *url, ThotBool deleteTree)
 {  {
   Element          root, ancestor, elem, firstInserted, div;    Element          root, ancestor, elem, firstInserted, div;
   Element          lastInserted, srce, copy, old, parent, sibling;    Element          lastInserted, srce, copy, old, parent, sibling;
Line 984  static Element MoveDocumentBody (Element Line 984  static Element MoveDocumentBody (Element
       root = SearchNAMEattribute (sourceDoc, target, NULL, NULL);        root = SearchNAMEattribute (sourceDoc, target, NULL, NULL);
       elType = TtaGetElementType (root);        elType = TtaGetElementType (root);
       isID = (elType.ElTypeNum != HTML_EL_Anchor &&        isID = (elType.ElTypeNum != HTML_EL_Anchor &&
               elType.ElTypeNum != HTML_EL_MAP);                elType.ElTypeNum != HTML_EL_MAP);
     }      }
   else    else
     {      {
Line 1002  static Element MoveDocumentBody (Element Line 1002  static Element MoveDocumentBody (Element
       checkingMode = TtaGetStructureChecking (destDoc);        checkingMode = TtaGetStructureChecking (destDoc);
       TtaSetStructureChecking (FALSE, destDoc);        TtaSetStructureChecking (FALSE, destDoc);
       /* get elem, the ancestor of el which is a child of a DIV or BODY        /* get elem, the ancestor of el which is a child of a DIV or BODY
          element in the destination document. The copied elements will be           element in the destination document. The copied elements will be
          inserted just before this element. */           inserted just before this element. */
       elem = el;        elem = el;
       do        do
         {          {
           ancestor = TtaGetParent (elem);            ancestor = TtaGetParent (elem);
           if (ancestor != NULL)            if (ancestor != NULL)
             {              {
               elType = TtaGetElementType (ancestor);                elType = TtaGetElementType (ancestor);
               if (elType.ElTypeNum == HTML_EL_BODY ||                if (elType.ElTypeNum == HTML_EL_BODY ||
                   elType.ElTypeNum == HTML_EL_Division)                    elType.ElTypeNum == HTML_EL_Division)
                 ancestor = NULL;                  ancestor = NULL;
               else                else
                 elem = ancestor;                  elem = ancestor;
             }              }
         }          }
       while (ancestor != NULL);        while (ancestor != NULL);
       parent = TtaGetParent (elem);        parent = TtaGetParent (elem);
   
Line 1033  static Element MoveDocumentBody (Element Line 1033  static Element MoveDocumentBody (Element
       /* do copy */        /* do copy */
       firstInserted = NULL;        firstInserted = NULL;
       if (isID)        if (isID)
         srce = root;          srce = root;
       else        else
         srce = TtaGetFirstChild (root);          srce = TtaGetFirstChild (root);
       while (srce != NULL)        while (srce != NULL)
         {          {
           copy = TtaCopyTree (srce, sourceDoc, destDoc, parent);            copy = TtaCopyTree (srce, sourceDoc, destDoc, parent);
           if (copy != NULL)            if (copy != NULL)
             {              {
               if (firstInserted == NULL)                if (firstInserted == NULL)
                 /* this is the first copied element. Insert it before elem */                  /* this is the first copied element. Insert it before elem */
                 {                  {
                   TtaInsertFirstChild (&copy, lastInserted, destDoc);                    TtaInsertFirstChild (&copy, lastInserted, destDoc);
                   firstInserted = copy;                    firstInserted = copy;
                 }                  }
               else                else
                 /* insert the new copied element after the element previously                  /* insert the new copied element after the element previously
                    copied */                     copied */
                 TtaInsertSibling (copy, lastInserted, FALSE, destDoc);                  TtaInsertSibling (copy, lastInserted, FALSE, destDoc);
               lastInserted = copy;                lastInserted = copy;
               /* update the NAMEs and URLs in the copied element */                /* update the NAMEs and URLs in the copied element */
               event.event = TteElemPaste;                event.event = TteElemPaste;
               event.document = destDoc;                event.document = destDoc;
               event.element = copy;                event.element = copy;
               event.elementType = TtaGetElementType (copy);                event.elementType = TtaGetElementType (copy);
               event.position = sourceDoc;                event.position = sourceDoc;
               event.info = 0;                event.info = 0;
               UpdateURLsInSubtree(&event, copy);                UpdateURLsInSubtree(&event, copy);
             }              }
           /* get the next element in the source document */            /* get the next element in the source document */
           old = srce;            old = srce;
           TtaNextSibling (&srce);            TtaNextSibling (&srce);
           if (deleteTree)            if (deleteTree)
             TtaDeleteTree (old, sourceDoc);              TtaDeleteTree (old, sourceDoc);
           /* Stop here if the target points to a specific element with an ID */            /* Stop here if the target points to a specific element with an ID */
           if (isID)            if (isID)
             srce = NULL;              srce = NULL;
         }          }
               
       /* delete the element(s) containing the link to the copied document */        /* delete the element(s) containing the link to the copied document */
       /* delete the parent element of el and all empty ancestors */        /* delete the parent element of el and all empty ancestors */
       elem = TtaGetParent (el);        elem = TtaGetParent (el);
       do        do
         {          {
           sibling = elem;            sibling = elem;
           TtaNextSibling (&sibling);            TtaNextSibling (&sibling);
           if (sibling == NULL)            if (sibling == NULL)
             {              {
               sibling = elem;                sibling = elem;
               TtaPreviousSibling (&sibling);                TtaPreviousSibling (&sibling);
               if (sibling == NULL)                if (sibling == NULL)
                 elem = TtaGetParent (elem);                  elem = TtaGetParent (elem);
             }              }
         }          }
       while (sibling == NULL);        while (sibling == NULL);
       TtaDeleteTree (elem, destDoc);        TtaDeleteTree (elem, destDoc);
       /* restore previous chacking mode */        /* restore previous chacking mode */
Line 1118  static void CloseMakeBook (Document docu Line 1118  static void CloseMakeBook (Document docu
   GetIncludedDocuments_callback finishes the GetIncludedDocuments procedure    GetIncludedDocuments_callback finishes the GetIncludedDocuments procedure
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 void   GetIncludedDocuments_callback (int newdoc, int status,   void   GetIncludedDocuments_callback (int newdoc, int status, 
                                       char *urlName,                                        char *urlName,
                                       char *outputfile,                                         char *outputfile, 
                                       AHTHeaders *http_headers,                                        AHTHeaders *http_headers,
                                       void * context)                                        void * context)
 {  {
   Element               link, div;    Element               link, div;
   IncludeCtxt          *ctx, *prev;    IncludeCtxt          *ctx, *prev;
Line 1140  void   GetIncludedDocuments_callback (in Line 1140  void   GetIncludedDocuments_callback (in
   if (utf8path)    if (utf8path)
     {      {
       if (newdoc && newdoc != DocBook)        if (newdoc && newdoc != DocBook)
         {          {
           /* it's not the DocBook itself */            /* it's not the DocBook itself */
           /* copy the target document at the position of the link */            /* copy the target document at the position of the link */
           TtaSetDocumentModified (DocBook);            TtaSetDocumentModified (DocBook);
           div = MoveDocumentBody (link, DocBook, newdoc, ptr, utf8path,            div = MoveDocumentBody (link, DocBook, newdoc, ptr, utf8path,
                                   (ThotBool)(newdoc == IncludedDocument));                                    (ThotBool)(newdoc == IncludedDocument));
         }          }
       /* global variables */        /* global variables */
       FreeDocumentResource (IncludedDocument);        FreeDocumentResource (IncludedDocument);
       TtaCloseDocument (IncludedDocument);        TtaCloseDocument (IncludedDocument);
Line 1185  void   GetIncludedDocuments_callback (in Line 1185  void   GetIncludedDocuments_callback (in
   Return TRUE if one inclusion is launched.    Return TRUE if one inclusion is launched.
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 static ThotBool GetIncludedDocuments (Element el, Element link,  static ThotBool GetIncludedDocuments (Element el, Element link,
                                       Document doc, IncludeCtxt *prev)                                        Document doc, IncludeCtxt *prev)
 {  {
   ElementType           elType;    ElementType           elType;
   Attribute             attr;    Attribute             attr;
Line 1207  static ThotBool GetIncludedDocuments (El Line 1207  static ThotBool GetIncludedDocuments (El
     {      {
       link = TtaSearchTypedElementInTree (elType, SearchForward, el, link);        link = TtaSearchTypedElementInTree (elType, SearchForward, el, link);
       if (link)        if (link)
         {          {
           attrType.AttrTypeNum = HTML_ATTR_REL;            attrType.AttrTypeNum = HTML_ATTR_REL;
           attr = TtaGetAttribute (link, attrType);            attr = TtaGetAttribute (link, attrType);
         }          }
       if (attr)        if (attr)
         {          {
           length = TtaGetTextAttributeLength (attr);            length = TtaGetTextAttributeLength (attr);
           utf8path = (char *)TtaGetMemory (length + 1);            utf8path = (char *)TtaGetMemory (length + 1);
           TtaGiveTextAttributeValue (attr, utf8path, &length);            TtaGiveTextAttributeValue (attr, utf8path, &length);
           /* Valid rel values are rel="chapter" or rel="subdocument" */            /* Valid rel values are rel="chapter" or rel="subdocument" */
           if (strcasecmp (utf8path, "chapter") &&            if (strcasecmp (utf8path, "chapter") &&
               strcasecmp (utf8path, "subdocument"))                strcasecmp (utf8path, "subdocument"))
             attr = NULL;              attr = NULL;
           TtaFreeMemory (utf8path);            TtaFreeMemory (utf8path);
         }          }
       
       if (attr)        if (attr)
         {          {
           /* a link with attribute rel="Chapter" has been found */            /* a link with attribute rel="Chapter" has been found */
           attrType.AttrTypeNum = HTML_ATTR_HREF_;            attrType.AttrTypeNum = HTML_ATTR_HREF_;
           attr = TtaGetAttribute (link, attrType);            attr = TtaGetAttribute (link, attrType);
         }          }
       if (attr)        if (attr)
         /* this link has an attribute HREF */          /* this link has an attribute HREF */
         {          {
           length = TtaGetTextAttributeLength (attr);            length = TtaGetTextAttributeLength (attr);
           utf8path = (char *)TtaGetMemory (length + 1);            utf8path = (char *)TtaGetMemory (length + 1);
           TtaGiveTextAttributeValue (attr, utf8path, &length);            TtaGiveTextAttributeValue (attr, utf8path, &length);
           ptr = strrchr (utf8path, '#');            ptr = strrchr (utf8path, '#');
           if (ptr)            if (ptr)
             {              {
               /* link to a particular position within a document */                /* link to a particular position within a document */
               if (ptr == utf8path)                if (ptr == utf8path)
                 {                  {
                   /* local link */                    /* local link */
                   TtaFreeMemory (utf8path);                    TtaFreeMemory (utf8path);
                   utf8path = NULL;                    utf8path = NULL;
                 }                  }
               else                else
                 {                  {
                   ptr[0] = EOS;                    ptr[0] = EOS;
                   ptr = &ptr[1];                    ptr = &ptr[1];
                 }                  }
             }              }
                                       
           if (utf8path)            if (utf8path)
             /* this link designates an external document */              /* this link designates an external document */
             {              {
               /* create a new document and loads the target document */                /* create a new document and loads the target document */
               IncludedDocument = TtaNewDocument ("HTML", "tmp");                IncludedDocument = TtaNewDocument ("HTML", "tmp");
               if (IncludedDocument != 0)                if (IncludedDocument != 0)
                 {                  {
                   TtaSetStatus (doc, 1, TtaGetMessage (AMAYA, AM_FETCHING), utf8path);                    TtaSetStatus (doc, 1, TtaGetMessage (AMAYA, AM_FETCHING), utf8path);
                   ctx = (IncludeCtxt *)TtaGetMemory (sizeof (IncludeCtxt));                    ctx = (IncludeCtxt *)TtaGetMemory (sizeof (IncludeCtxt));
                   ctx->div =  el;                    ctx->div =  el;
                   ctx->link = link;                    ctx->link = link;
                   ctx->utf8path = utf8path; /* the URL of the document */                    ctx->utf8path = utf8path; /* the URL of the document */
                   ctx->name = ptr;                    ctx->name = ptr;
                   ctx->ctxt = prev; /* previous context */                    ctx->ctxt = prev; /* previous context */
                   /* Get the reference of the calling document */                    /* Get the reference of the calling document */
                   SetStopButton (doc);                    SetStopButton (doc);
                   newdoc = GetAmayaDoc (utf8path, NULL, IncludedDocument,                    newdoc = GetAmayaDoc (utf8path, NULL, IncludedDocument,
                                         doc, CE_MAKEBOOK, FALSE,                                           doc, CE_MAKEBOOK, FALSE, 
                                         (void (*)(int, int, char*, char*, const AHTHeaders*, void*)) GetIncludedDocuments_callback,                                          (void (*)(int, int, char*, char*, const AHTHeaders*, void*)) GetIncludedDocuments_callback,
                                         (void *) ctx);                                          (void *) ctx);
                   found = TRUE;                    found = TRUE;
                 }                  }
             }              }
           else            else
             TtaFreeMemory (utf8path);              TtaFreeMemory (utf8path);
         }          }
     }      }
   return (found);    return (found);
 }  }
Line 1492  void SectionNumbering (Document doc, Vie Line 1492  void SectionNumbering (Document doc, Vie
   ThotBool            closeUndo, change = FALSE;    ThotBool            closeUndo, change = FALSE;
   
   /* check if there is HTML Hi elements and if the current position is    /* check if there is HTML Hi elements and if the current position is
    within a HTML Body element */       within a HTML Body element */
   dispMode = TtaGetDisplayMode (doc);    dispMode = TtaGetDisplayMode (doc);
   
   /* check if there is any HTML element within the document */    /* check if there is any HTML element within the document */
Line 1502  void SectionNumbering (Document doc, Vie Line 1502  void SectionNumbering (Document doc, Vie
     return;      return;
   
   if (TtaPrepareUndo (doc))    if (TtaPrepareUndo (doc))
       closeUndo = FALSE;      closeUndo = FALSE;
   else    else
     {      {
       closeUndo = TRUE;        closeUndo = TRUE;
Line 1524  void SectionNumbering (Document doc, Vie Line 1524  void SectionNumbering (Document doc, Vie
   while (el)    while (el)
     {      {
       el = TtaSearchElementAmong5Types (searchedType1, searchedType2,        el = TtaSearchElementAmong5Types (searchedType1, searchedType2,
                                         searchedType3, searchedType4,                                          searchedType3, searchedType4,
                                         searchedType5, SearchForward, el);                                          searchedType5, SearchForward, el);
       if (el)        if (el)
         {          {
           /* generate the text number */            /* generate the text number */
           elType = TtaGetElementType (el);            elType = TtaGetElementType (el);
           s[0] = EOS;            s[0] = EOS;
           switch (elType.ElTypeNum)            switch (elType.ElTypeNum)
             {              {
             case HTML_EL_H2:              case HTML_EL_H2:
               nH2++;                nH2++;
               nH3 = nH4 = nH5 = nH6 = 0;                nH3 = nH4 = nH5 = nH6 = 0;
               sprintf (s, "%d.", nH2);                sprintf (s, "%d.", nH2);
               break;                break;
             case HTML_EL_H3:              case HTML_EL_H3:
               nH3++;                nH3++;
               nH4 = nH5 = nH6 = 0;                nH4 = nH5 = nH6 = 0;
               if (nH2)                if (nH2)
                 sprintf (s, "%d.", nH2);                  sprintf (s, "%d.", nH2);
               sprintf (n, "%d.", nH3);                sprintf (n, "%d.", nH3);
               strcat (s, n);                strcat (s, n);
               break;                break;
             case HTML_EL_H4:              case HTML_EL_H4:
               nH4++;                nH4++;
               nH5 = nH6 = 0;                nH5 = nH6 = 0;
               if (nH2)                if (nH2)
                 sprintf (s, "%d.", nH2);                  sprintf (s, "%d.", nH2);
               if (nH3)                if (nH3)
                 {                  {
                   sprintf (n, "%d.", nH3);                    sprintf (n, "%d.", nH3);
                   strcat (s, n);                    strcat (s, n);
                 }                  }
               sprintf (n, "%d.", nH4);                sprintf (n, "%d.", nH4);
               strcat (s, n);                strcat (s, n);
               break;                break;
             case HTML_EL_H5:              case HTML_EL_H5:
               nH5++;                nH5++;
               nH6 = 0;                nH6 = 0;
               if (nH2)                if (nH2)
                 sprintf (s, "%d.", nH2);                  sprintf (s, "%d.", nH2);
               if (nH3)                if (nH3)
                 {                  {
                   sprintf (n, "%d.", nH3);                    sprintf (n, "%d.", nH3);
                   strcat (s, n);                    strcat (s, n);
                 }                  }
               if (nH4)                if (nH4)
                 {                  {
                   sprintf (n, "%d.", nH4);                    sprintf (n, "%d.", nH4);
                   strcat (s, n);                    strcat (s, n);
                 }                  }
               sprintf (n, "%d.", nH5);                sprintf (n, "%d.", nH5);
               strcat (s, n);                strcat (s, n);
               break;                break;
             case HTML_EL_H6:              case HTML_EL_H6:
               nH6++;                nH6++;
               if (nH2)                if (nH2)
                 sprintf (s, "%d.", nH2);                  sprintf (s, "%d.", nH2);
               if (nH3)                if (nH3)
                 {                  {
                   sprintf (n, "%d.", nH3);                    sprintf (n, "%d.", nH3);
                   strcat (s, n);                    strcat (s, n);
                 }                  }
               if (nH4)                if (nH4)
                 {                  {
                   sprintf (n, "%d.", nH4);                    sprintf (n, "%d.", nH4);
                   strcat (s, n);                    strcat (s, n);
                 }                  }
               if (nH5)                if (nH5)
                 {                  {
                   sprintf (n, "%d.", nH5);                    sprintf (n, "%d.", nH5);
                   strcat (s, n);                    strcat (s, n);
                 }                  }
               sprintf (n, "%d.", nH6);                sprintf (n, "%d.", nH6);
               strcat (s, n);                strcat (s, n);
               break;                break;
             default: break;              default: break;
             }              }
           strcat (s, " ");            strcat (s, " ");
   
           /* look for the first leaf child */            /* look for the first leaf child */
           child = el;            child = el;
           if (child)            if (child)
             {              {
               do                do
                 {                  {
                   child = TtaGetFirstChild (child);                    child = TtaGetFirstChild (child);
                   childType = TtaGetElementType (child);                    childType = TtaGetElementType (child);
                 }                  }
               while (!TtaIsLeaf (childType) && childType.ElSSchema == HTMLschema);                while (!TtaIsLeaf (childType) && childType.ElSSchema == HTMLschema);
             }              }
           if (child && childType.ElSSchema == HTMLschema &&            if (child && childType.ElSSchema == HTMLschema &&
               childType.ElTypeNum == HTML_EL_TEXT_UNIT)                childType.ElTypeNum == HTML_EL_TEXT_UNIT)
             {              {
               /* the first leaf child is a text unit */                /* the first leaf child is a text unit */
               new_ = NULL;                new_ = NULL;
               /* check the text contents */                /* check the text contents */
               length = TtaGetTextLength (child) + 1;                length = TtaGetTextLength (child) + 1;
               text = (char *)TtaGetMemory (length);                text = (char *)TtaGetMemory (length);
               TtaGiveTextContent (child, (unsigned char *)text, &length, &lang);                TtaGiveTextContent (child, (unsigned char *)text, &length, &lang);
               /* remove the old number */                /* remove the old number */
               i = 0;                i = 0;
               while (isdigit (text[i]) || text[i] == '.')                while (isdigit (text[i]) || text[i] == '.')
                 i++;                  i++;
               TtaRegisterElementReplace (child, doc);                TtaRegisterElementReplace (child, doc);
               TtaSetTextContent (child, (unsigned char *)s, Latin_Script, doc);                TtaSetTextContent (child, (unsigned char *)s, Latin_Script, doc);
               TtaAppendTextContent (child, (unsigned char *)&text[i], doc);                TtaAppendTextContent (child, (unsigned char *)&text[i], doc);
               TtaFreeMemory (text);                TtaFreeMemory (text);
               change = TRUE;                change = TRUE;
             }              }
           else            else
             {              {
               /* add a new text element */                /* add a new text element */
               elType.ElTypeNum = HTML_EL_TEXT_UNIT;                elType.ElTypeNum = HTML_EL_TEXT_UNIT;
               new_ = TtaNewElement (doc, elType);                new_ = TtaNewElement (doc, elType);
               if (child)                if (child)
                 /* insert before */                  /* insert before */
                 TtaInsertSibling (new_, child, TRUE, doc);                  TtaInsertSibling (new_, child, TRUE, doc);
               else                else
                 TtaInsertFirstChild (&new_, el, doc);                  TtaInsertFirstChild (&new_, el, doc);
               TtaSetTextContent (new_, (unsigned char *)s, Latin_Script, doc);                TtaSetTextContent (new_, (unsigned char *)s, Latin_Script, doc);
               TtaRegisterElementCreate (new_, doc);                TtaRegisterElementCreate (new_, doc);
               change = TRUE;                change = TRUE;
             }              }
         }          }
     }      }
   
   if (closeUndo)    if (closeUndo)
Line 1677  void MakeToc (Document doc, View view) Line 1677  void MakeToc (Document doc, View view)
   ThotBool            closeUndo;    ThotBool            closeUndo;
   
   /* check if there is HTML Hi elements and if the current position is    /* check if there is HTML Hi elements and if the current position is
    within a HTML Body element */       within a HTML Body element */
   dispMode = TtaGetDisplayMode (doc);    dispMode = TtaGetDisplayMode (doc);
   
   /* get the insert point */    /* get the insert point */
Line 1686  void MakeToc (Document doc, View view) Line 1686  void MakeToc (Document doc, View view)
     {      {
       /* no selection */        /* no selection */
       TtaDisplaySimpleMessage (CONFIRM, AMAYA, AM_NO_INSERT_POINT);        TtaDisplaySimpleMessage (CONFIRM, AMAYA, AM_NO_INSERT_POINT);
     return;        return;
     }      }
   elType = TtaGetElementType (el);    elType = TtaGetElementType (el);
   s = TtaGetSSchemaName (elType.ElSSchema);    s = TtaGetSSchemaName (elType.ElSSchema);
Line 1701  void MakeToc (Document doc, View view) Line 1701  void MakeToc (Document doc, View view)
     TtaSetDisplayMode (doc, SuspendDisplay);      TtaSetDisplayMode (doc, SuspendDisplay);
   
   if (TtaPrepareUndo (doc))    if (TtaPrepareUndo (doc))
       closeUndo = FALSE;      closeUndo = FALSE;
   else    else
     {      {
       closeUndo = TRUE;        closeUndo = TRUE;
Line 1726  void MakeToc (Document doc, View view) Line 1726  void MakeToc (Document doc, View view)
   while (el)    while (el)
     {      {
       el = TtaSearchElementAmong5Types (searchedType1, searchedType2,        el = TtaSearchElementAmong5Types (searchedType1, searchedType2,
                                         searchedType3, searchedType4,                                          searchedType3, searchedType4,
                                         searchedType5, SearchForward, el);                                          searchedType5, SearchForward, el);
       if (el)        if (el)
         {          {
           if (toc == NULL)            if (toc == NULL)
             {              {
               /* genetate the enclosing division */                /* genetate the enclosing division */
               elType.ElTypeNum = HTML_EL_Division;                elType.ElTypeNum = HTML_EL_Division;
               TtaCreateElement (elType, doc);                TtaCreateElement (elType, doc);
               TtaGiveFirstSelectedElement (doc, &child, &firstChar, &i);                TtaGiveFirstSelectedElement (doc, &child, &firstChar, &i);
               toc = TtaGetTypedAncestor (child, elType);                toc = TtaGetTypedAncestor (child, elType);
               TtaRegisterElementDelete (child, doc);                TtaRegisterElementDelete (child, doc);
               TtaRemoveTree (child, doc);                TtaRemoveTree (child, doc);
               if (toc)                if (toc)
                 {                  {
                   /* it's the last created element */                    /* it's the last created element */
                   attrType.AttrTypeNum = HTML_ATTR_Class;                    attrType.AttrTypeNum = HTML_ATTR_Class;
                   attr = TtaNewAttribute (attrType);                    attr = TtaNewAttribute (attrType);
                   TtaAttachAttribute (toc, attr, doc);                    TtaAttachAttribute (toc, attr, doc);
                   TtaSetAttributeText (attr, "toc", toc, doc);                    TtaSetAttributeText (attr, "toc", toc, doc);
                   TtaRegisterAttributeCreate (attr, toc, doc);                    TtaRegisterAttributeCreate (attr, toc, doc);
                 }                  }
             }              }
           if (toc == NULL)            if (toc == NULL)
             el = NULL;              el = NULL;
           else            else
             {              {
               /* does the element have an ID attribute already? */                /* does the element have an ID attribute already? */
               attrType.AttrTypeNum = HTML_ATTR_ID;                attrType.AttrTypeNum = HTML_ATTR_ID;
               attr = TtaGetAttribute (el, attrType);                attr = TtaGetAttribute (el, attrType);
               if (!attr)                if (!attr)
                 {                  {
                   /* generate the ID if it does't exist */                    /* generate the ID if it does't exist */
                   CreateTargetAnchor (doc, el, TRUE, TRUE);                    CreateTargetAnchor (doc, el, TRUE, TRUE);
                   attr = TtaGetAttribute (el, attrType);                    attr = TtaGetAttribute (el, attrType);
                 }                  }
               i = TtaGetTextAttributeLength (attr) + 1;                i = TtaGetTextAttributeLength (attr) + 1;
               id = (char *)TtaGetMemory (i + 1);                id = (char *)TtaGetMemory (i + 1);
               id[0] = '#';                id[0] = '#';
               TtaGiveTextAttributeValue (attr, &id[1], &i);                TtaGiveTextAttributeValue (attr, &id[1], &i);
                               
               /* locate or generate the list */                /* locate or generate the list */
               elType = TtaGetElementType (el);                elType = TtaGetElementType (el);
               if (elType.ElTypeNum == HTML_EL_H2)                if (elType.ElTypeNum == HTML_EL_H2)
                 {                  {
                   parent = toc;                    parent = toc;
                   lH3 = lH4 = lH5 = lH6 = NULL;                    lH3 = lH4 = lH5 = lH6 = NULL;
                   list = &lH2;                    list = &lH2;
                 }                  }
               else if (elType.ElTypeNum == HTML_EL_H3)                else if (elType.ElTypeNum == HTML_EL_H3)
                 {                  {
                   if (lH2)                    if (lH2)
                     parent = TtaGetLastChild (lH2);                      parent = TtaGetLastChild (lH2);
                   else                    else
                     parent = toc;                      parent = toc;
                   lH4 = lH5 = lH6 = NULL;                    lH4 = lH5 = lH6 = NULL;
                   list = &lH3;                    list = &lH3;
                 }                  }
               else if (elType.ElTypeNum == HTML_EL_H4)                else if (elType.ElTypeNum == HTML_EL_H4)
                 {                  {
                   if (lH3)                    if (lH3)
                     parent =  TtaGetLastChild (lH3);                      parent =  TtaGetLastChild (lH3);
                   else if (lH2)                    else if (lH2)
                     parent =  TtaGetLastChild (lH2);                      parent =  TtaGetLastChild (lH2);
                   else                    else
                     parent = toc;                      parent = toc;
                   lH5 = lH6 = NULL;                    lH5 = lH6 = NULL;
                   list = &lH4;                    list = &lH4;
                 }                  }
               else if (elType.ElTypeNum == HTML_EL_H5)                else if (elType.ElTypeNum == HTML_EL_H5)
                 {                  {
                   if (lH4)                    if (lH4)
                     parent =  TtaGetLastChild (lH4);                      parent =  TtaGetLastChild (lH4);
                   else if (lH3)                    else if (lH3)
                     parent =  TtaGetLastChild (lH3);                      parent =  TtaGetLastChild (lH3);
                   else if (lH2)                    else if (lH2)
                     parent =  TtaGetLastChild (lH2);                      parent =  TtaGetLastChild (lH2);
                   else                    else
                     parent = toc;                      parent = toc;
                   lH6 = NULL;                    lH6 = NULL;
                   list = &lH5;                    list = &lH5;
                 }                  }
               else if (elType.ElTypeNum == HTML_EL_H6)                else if (elType.ElTypeNum == HTML_EL_H6)
                 {                  {
                   if (lH5)                    if (lH5)
                     parent =  TtaGetLastChild (lH5);                      parent =  TtaGetLastChild (lH5);
                   else if (lH4)                    else if (lH4)
                     parent =  TtaGetLastChild (lH4);                      parent =  TtaGetLastChild (lH4);
                   else if (lH3)                    else if (lH3)
                     parent =  TtaGetLastChild (lH3);                      parent =  TtaGetLastChild (lH3);
                   else if (lH2)                    else if (lH2)
                     parent =  TtaGetLastChild (lH2);                      parent =  TtaGetLastChild (lH2);
                   else                    else
                     parent = toc;                      parent = toc;
                   list = &lH6;                    list = &lH6;
                 }                  }
   
               if (*list == NULL)                if (*list == NULL)
                 {                  {
                   /* generate the list */                    /* generate the list */
                   *list = TtaNewElement (doc, ulType);                    *list = TtaNewElement (doc, ulType);
                   child = TtaGetLastChild (parent);                    child = TtaGetLastChild (parent);
                   if (child)                    if (child)
                     TtaInsertSibling (*list, child, FALSE, doc);                      TtaInsertSibling (*list, child, FALSE, doc);
                   else                    else
                     TtaInsertFirstChild (list, parent, doc);                      TtaInsertFirstChild (list, parent, doc);
                   TtaRegisterElementCreate (*list, doc);                    TtaRegisterElementCreate (*list, doc);
                 }                  }
               /* generate the list item */                /* generate the list item */
               elType.ElTypeNum = HTML_EL_List_Item;                elType.ElTypeNum = HTML_EL_List_Item;
               item = TtaNewElement (doc, elType);                item = TtaNewElement (doc, elType);
               /* generate the HTML_EL_Pseudo_paragraph */                /* generate the HTML_EL_Pseudo_paragraph */
               elType.ElTypeNum =  HTML_EL_Pseudo_paragraph;                elType.ElTypeNum =  HTML_EL_Pseudo_paragraph;
               parent = TtaNewElement (doc, elType);                parent = TtaNewElement (doc, elType);
               TtaInsertFirstChild (&parent, item, doc);                TtaInsertFirstChild (&parent, item, doc);
               /* generate the link anchor */                /* generate the link anchor */
               elType.ElTypeNum = HTML_EL_Anchor;                elType.ElTypeNum = HTML_EL_Anchor;
               new_ = TtaNewElement (doc, elType);                new_ = TtaNewElement (doc, elType);
               TtaInsertFirstChild (&new_, parent, doc);                TtaInsertFirstChild (&new_, parent, doc);
               attrType.AttrTypeNum = HTML_ATTR_HREF_;                attrType.AttrTypeNum = HTML_ATTR_HREF_;
               attr = TtaNewAttribute (attrType);                attr = TtaNewAttribute (attrType);
               TtaAttachAttribute (new_, attr, doc);                TtaAttachAttribute (new_, attr, doc);
               TtaSetAttributeText (attr, id, new_, doc);                TtaSetAttributeText (attr, id, new_, doc);
               TtaFreeMemory (id);                TtaFreeMemory (id);
               id = NULL;                id = NULL;
               /* get a copy of the Hi contents */                /* get a copy of the Hi contents */
               srce = TtaGetFirstChild (el);                srce = TtaGetFirstChild (el);
               prev = NULL;                prev = NULL;
               parent = NULL;                parent = NULL;
               while (srce)                while (srce)
                 {                  {
                   copyType = TtaGetElementType (srce);                    copyType = TtaGetElementType (srce);
                   if (copyType.ElTypeNum == HTML_EL_Anchor &&                    if (copyType.ElTypeNum == HTML_EL_Anchor &&
                       copyType.ElSSchema == elType.ElSSchema)                        copyType.ElSSchema == elType.ElSSchema)
                     {                      {
                       /* copy the anchor contents instead of the anchor */                        /* copy the anchor contents instead of the anchor */
                       parent = srce;                        parent = srce;
                       srce = TtaGetFirstChild (parent);                        srce = TtaGetFirstChild (parent);
                     }                      }
                   if (srce)                    if (srce)
                     {                      {
                       /* copy children of the next source */                        /* copy children of the next source */
                       copy = TtaCopyTree (srce, doc, doc, new_);                        copy = TtaCopyTree (srce, doc, doc, new_);
                       if (copy)                        if (copy)
                         {                          {
                           if (prev == NULL)                            if (prev == NULL)
                             /* this is the first copied element. Insert it before elem */                              /* this is the first copied element. Insert it before elem */
                             TtaInsertFirstChild (&copy, new_, doc);                              TtaInsertFirstChild (&copy, new_, doc);
                           else                            else
                             /* insert the new copied element after the element previously                              /* insert the new copied element after the element previously
                                copied */                                 copied */
                             TtaInsertSibling (copy, prev, FALSE, doc);                              TtaInsertSibling (copy, prev, FALSE, doc);
                           prev = copy;                            prev = copy;
                         }                          }
                       TtaNextSibling (&srce);                        TtaNextSibling (&srce);
                     }                      }
                   if (srce == NULL && parent)                    if (srce == NULL && parent)
                     {                      {
                       /* copy children of an anchor */                        /* copy children of an anchor */
                       srce = parent;                        srce = parent;
                       parent = NULL;                        parent = NULL;
                       if (srce)                        if (srce)
                         TtaNextSibling (&srce);                          TtaNextSibling (&srce);
                     }                      }
                 }                  }
               child = TtaGetLastChild (*list);                child = TtaGetLastChild (*list);
               if (child)                if (child)
                 TtaInsertSibling (item, child, FALSE, doc);                  TtaInsertSibling (item, child, FALSE, doc);
               else                else
                 TtaInsertFirstChild (&item, *list, doc);                  TtaInsertFirstChild (&item, *list, doc);
               TtaRegisterElementCreate (item, doc);                TtaRegisterElementCreate (item, doc);
             }              }
         }          }
     }      }
   
   if (closeUndo)    if (closeUndo)
     TtaCloseUndoSequence (doc);      TtaCloseUndoSequence (doc);
     /* force a complete redisplay to apply CSS */
     TtaSetDisplayMode (doc, NoComputedDisplay);
   if (dispMode == DisplayImmediately)    if (dispMode == DisplayImmediately)
     TtaSetDisplayMode (doc, dispMode);      TtaSetDisplayMode (doc, dispMode);
   /* select the end of the toc */    /* select the end of the toc */
Line 1910  void MakeToc (Document doc, View view) Line 1912  void MakeToc (Document doc, View view)
     {      {
       child = prev;        child = prev;
       while (child)        while (child)
         {          {
           child = TtaGetLastChild (prev);            child = TtaGetLastChild (prev);
           if (child)            if (child)
             prev = child;              prev = child;
         }          }
       elType = TtaGetElementType (prev);        elType = TtaGetElementType (prev);
       if (elType.ElTypeNum == HTML_EL_TEXT_UNIT)        if (elType.ElTypeNum == HTML_EL_TEXT_UNIT)
         {          {
           i = TtaGetElementVolume (prev);            i = TtaGetElementVolume (prev);
           TtaSelectString (doc, prev, i+1, i);            TtaSelectString (doc, prev, i+1, i);
         }          }
       else        else
         TtaSelectElement (doc, prev);          TtaSelectElement (doc, prev);
     }      }
 }  }

Removed from v.1.134  
changed lines
  Added in v.1.135


Webmaster