X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/119f7a8c81c6fa9fd26f6ceab7e2ee3973054355..8c3bbbea2def1fc75b77b71398c1bb5b7f98f833:/utils/tex2rtf/src/htmlutil.cpp diff --git a/utils/tex2rtf/src/htmlutil.cpp b/utils/tex2rtf/src/htmlutil.cpp index d29e17b7f3..b68d0b5b2f 100644 --- a/utils/tex2rtf/src/htmlutil.cpp +++ b/utils/tex2rtf/src/htmlutil.cpp @@ -2,17 +2,14 @@ // Name: htmlutil.cpp // Purpose: Converts Latex to HTML // Author: Julian Smart -// Modified by: +// Modified by: Wlodzimierz ABX Skiba 2003/2004 Unicode support +// Ron Lee // Created: 7.9.93 // RCS-ID: $Id$ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -21,18 +18,32 @@ #endif #ifndef WX_PRECOMP -#include "wx/wx.h" #endif +#include "wx/arrstr.h" + #include "tex2any.h" #include "tex2rtf.h" #include "table.h" +#include +#define HTML_FILENAME_PATTERN _T("%s_%s.html") + +#if !WXWIN_COMPATIBILITY_2_4 +static inline wxChar* copystring(const wxChar* s) + { return wxStrcpy(new wxChar[wxStrlen(s) + 1], s); } +#endif + +extern wxHashTable TexReferences; + +extern int passNumber; + +extern void DecToHex(int, wxChar *); +void GenerateHTMLIndexFile(wxChar *fname); -extern void DecToHex(int, char *); -void GenerateHTMLIndexFile(char *fname); +bool PrimaryAnchorOfTheFile( wxChar *file, wxChar *label ); -void GenerateHTMLWorkshopFiles(char *fname); -void HTMLWorkshopAddToContents(int level, char *s, char *file); +void GenerateHTMLWorkshopFiles(wxChar *fname); +void HTMLWorkshopAddToContents(int level, wxChar *s, wxChar *file); void HTMLWorkshopStartContents(); void HTMLWorkshopEndContents(); @@ -40,15 +51,15 @@ void OutputContentsFrame(void); #include "readshg.h" // Segmented hypergraphics parsing -char *ChaptersName = NULL; -char *SectionsName = NULL; -char *SubsectionsName = NULL; -char *SubsubsectionsName = NULL; -char *TitlepageName = NULL; -char *lastFileName = NULL; -char *lastTopic = NULL; -char *currentFileName = NULL; -char *contentsFrameName = NULL; +wxChar *ChaptersName = NULL; +wxChar *SectionsName = NULL; +wxChar *SubsectionsName = NULL; +wxChar *SubsubsectionsName = NULL; +wxChar *TitlepageName = NULL; +wxChar *lastFileName = NULL; +wxChar *lastTopic = NULL; +wxChar *currentFileName = NULL; +wxChar *contentsFrameName = NULL; static TexChunk *descriptionItemArg = NULL; static TexChunk *helpRefFilename = NULL; @@ -60,28 +71,33 @@ FILE *FrameContents = NULL; FILE *Titlepage = NULL; // FILE *FrameTitlepage = NULL; int fileId = 0; -bool subsectionStarted = FALSE; +bool subsectionStarted = false; // Which column of a row are we in? (Assumes no nested tables, of course) int currentColumn = 0; // Are we in verbatim mode? If so, format differently. -static bool inVerbatim = FALSE; +static bool inVerbatim = false; // Need to know whether we're in a table or figure for benefit // of listoffigures/listoftables -static bool inFigure = FALSE; -static bool inTable = FALSE; +static bool inFigure = false; +static bool inTable = false; // This is defined in the Tex2Any library. -extern char *BigBuffer; +extern wxChar *BigBuffer; + +// DHS Two-column table dimensions. +static int TwoColWidthA = -1; +static int TwoColWidthB = -1; + class HyperReference: public wxObject { public: - char *refName; - char *refFile; - HyperReference(char *name, char *file) + wxChar *refName; + wxChar *refFile; + HyperReference(wxChar *name, wxChar *file) { if (name) refName = copystring(name); if (file) refFile = copystring(file); @@ -91,9 +107,9 @@ class HyperReference: public wxObject class TexNextPage: public wxObject { public: - char *label; - char *filename; - TexNextPage(char *theLabel, char *theFile) + wxChar *label; + wxChar *filename; + TexNextPage(wxChar *theLabel, wxChar *theFile) { label = copystring(theLabel); filename = copystring(theFile); @@ -107,23 +123,23 @@ class TexNextPage: public wxObject wxHashTable TexNextPages(wxKEY_STRING); -static char *CurrentChapterName = NULL; -static char *CurrentChapterFile = NULL; -static char *CurrentSectionName = NULL; -static char *CurrentSectionFile = NULL; -static char *CurrentSubsectionName = NULL; -static char *CurrentSubsectionFile = NULL; -static char *CurrentSubsubsectionName = NULL; -static char *CurrentSubsubsectionFile = NULL; -static char *CurrentTopic = NULL; - -static void SetCurrentTopic(char *s) +static wxChar *CurrentChapterName = NULL; +static wxChar *CurrentChapterFile = NULL; +static wxChar *CurrentSectionName = NULL; +static wxChar *CurrentSectionFile = NULL; +static wxChar *CurrentSubsectionName = NULL; +static wxChar *CurrentSubsectionFile = NULL; +static wxChar *CurrentSubsubsectionName = NULL; +static wxChar *CurrentSubsubsectionFile = NULL; +static wxChar *CurrentTopic = NULL; + +static void SetCurrentTopic(wxChar *s) { if (CurrentTopic) delete[] CurrentTopic; CurrentTopic = copystring(s); } -void SetCurrentChapterName(char *s, char *file) +void SetCurrentChapterName(wxChar *s, wxChar *file) { if (CurrentChapterName) delete[] CurrentChapterName; CurrentChapterName = copystring(s); @@ -134,7 +150,7 @@ void SetCurrentChapterName(char *s, char *file) SetCurrentTopic(s); } -void SetCurrentSectionName(char *s, char *file) +void SetCurrentSectionName(wxChar *s, wxChar *file) { if (CurrentSectionName) delete[] CurrentSectionName; CurrentSectionName = copystring(s); @@ -144,7 +160,7 @@ void SetCurrentSectionName(char *s, char *file) currentFileName = CurrentSectionFile; SetCurrentTopic(s); } -void SetCurrentSubsectionName(char *s, char *file) +void SetCurrentSubsectionName(wxChar *s, wxChar *file) { if (CurrentSubsectionName) delete[] CurrentSubsectionName; CurrentSubsectionName = copystring(s); @@ -153,7 +169,7 @@ void SetCurrentSubsectionName(char *s, char *file) currentFileName = CurrentSubsectionFile; SetCurrentTopic(s); } -void SetCurrentSubsubsectionName(char *s, char *file) +void SetCurrentSubsubsectionName(wxChar *s, wxChar *file) { if (CurrentSubsubsectionName) delete[] CurrentSubsubsectionName; CurrentSubsubsectionName = copystring(s); @@ -163,28 +179,40 @@ void SetCurrentSubsubsectionName(char *s, char *file) SetCurrentTopic(s); } + +// mapping between fileId and filenames if truncateFilenames=false: +static wxArrayString gs_filenames; + + /* * Close former filedescriptor and reopen using another filename. * */ -void ReopenFile(FILE **fd, char **fileName) +void ReopenFile(FILE **fd, wxChar **fileName, const wxChar *label) { if (*fd) { - fprintf(*fd, "\n\n"); + wxFprintf(*fd, _T("\n\n")); fclose(*fd); } fileId ++; - char buf[400]; + wxChar buf[400]; if (truncateFilenames) - sprintf(buf, "%s%d.htm", FileRoot, fileId); + { + wxSnprintf(buf, sizeof(buf), _T("%s%d.htm"), FileRoot, fileId); + } else - sprintf(buf, "%s%d.html", FileRoot, fileId); + { + if (fileId == 1) + gs_filenames.Add(wxEmptyString); + wxSnprintf(buf, sizeof(buf), HTML_FILENAME_PATTERN, FileRoot, label); + gs_filenames.Add(buf); + } if (*fileName) delete[] *fileName; - *fileName = copystring(FileNameFromPath(buf)); - *fd = fopen(buf, "w"); - fprintf(*fd, "\n"); + *fileName = copystring(wxFileNameFromPath(buf)); + *fd = wxFopen(buf, _T("w")); + wxFprintf(*fd, _T("\n")); } /* @@ -192,7 +220,7 @@ void ReopenFile(FILE **fd, char **fileName) * in subsectionCombine mode */ -static char *SectionContentsFilename = NULL; +static wxChar *SectionContentsFilename = NULL; static FILE *SectionContentsFD = NULL; void ReopenSectionContentsFile(void) @@ -209,13 +237,13 @@ void ReopenSectionContentsFile(void) // Create the name from the current section filename if ( CurrentSectionFile ) { - char buf[256]; - strcpy(buf, CurrentSectionFile); + wxChar buf[256]; + wxStrcpy(buf, CurrentSectionFile); wxStripExtension(buf); - strcat(buf, ".con"); + wxStrcat(buf, _T(".con")); SectionContentsFilename = copystring(buf); - SectionContentsFD = fopen(SectionContentsFilename, "w"); + SectionContentsFD = wxFopen(SectionContentsFilename, _T("w")); } } @@ -228,11 +256,11 @@ void ReopenSectionContentsFile(void) void ProcessText2HTML(TexChunk *chunk) { - bool changed = FALSE; + bool changed = false; int ptr = 0; int i = 0; - char ch = 1; - int len = strlen(chunk->value); + wxChar ch = 1; + int len = wxStrlen(chunk->value); while (ch != 0) { ch = chunk->value[i]; @@ -242,37 +270,37 @@ void ProcessText2HTML(TexChunk *chunk) ((len > i+1 && chunk->value[i+1] == 13) && (len > i+2 && chunk->value[i+2] == 10)))) { - BigBuffer[ptr] = 0; strcat(BigBuffer, "

\n\n"); ptr += 5; + BigBuffer[ptr] = 0; wxStrcat(BigBuffer, _T("

\n\n")); ptr += 5; i += 2; - changed = TRUE; + changed = true; } - else if (!inVerbatim && ch == '`' && (len >= i+1 && chunk->value[i+1] == '`')) + else if (!inVerbatim && ch == _T('`') && (len >= i+1 && chunk->value[i+1] == '`')) { BigBuffer[ptr] = '"'; ptr ++; i += 2; - changed = TRUE; + changed = true; } - else if (!inVerbatim && ch == '`') // Change ` to ' + else if (!inVerbatim && ch == _T('`')) // Change ` to ' { BigBuffer[ptr] = 39; ptr ++; i += 1; - changed = TRUE; + changed = true; } - else if (ch == '<') // Change < to < + else if (ch == _T('<')) // Change < to < { BigBuffer[ptr] = 0; - strcat(BigBuffer, "<"); + wxStrcat(BigBuffer, _T("<")); ptr += 4; i += 1; - changed = TRUE; + changed = true; } - else if (ch == '>') // Change > to > + else if (ch == _T('>')) // Change > to > { BigBuffer[ptr] = 0; - strcat(BigBuffer, ">"); + wxStrcat(BigBuffer, _T(">")); ptr += 4; i += 1; - changed = TRUE; + changed = true; } else { @@ -313,29 +341,29 @@ void Text2HTML(TexChunk *chunk) return; if (def && (def->macroId == ltVERBATIM || def->macroId == ltVERB || def->macroId == ltSPECIAL)) - inVerbatim = TRUE; + inVerbatim = true; - wxNode *node = chunk->children.First(); + wxNode *node = chunk->children.GetFirst(); while (node) { - TexChunk *child_chunk = (TexChunk *)node->Data(); + TexChunk *child_chunk = (TexChunk *)node->GetData(); Text2HTML(child_chunk); - node = node->Next(); + node = node->GetNext(); } if (def && (def->macroId == ltVERBATIM || def->macroId == ltVERB || def->macroId == ltSPECIAL)) - inVerbatim = FALSE; + inVerbatim = false; break; } case CHUNK_TYPE_ARG: { - wxNode *node = chunk->children.First(); + wxNode *node = chunk->children.GetFirst(); while (node) { - TexChunk *child_chunk = (TexChunk *)node->Data(); + TexChunk *child_chunk = (TexChunk *)node->GetData(); Text2HTML(child_chunk); - node = node->Next(); + node = node->GetNext(); } break; @@ -354,60 +382,68 @@ void Text2HTML(TexChunk *chunk) * */ -void AddBrowseButtons(char *upLabel, char *upFilename, - char *previousLabel, char *previousFilename, - char *thisLabel, char *thisFilename) +void AddBrowseButtons(wxChar *upLabel, wxChar *upFilename, + wxChar *previousLabel, wxChar *previousFilename, + wxChar *thisLabel, wxChar *thisFilename) { - char contentsReferenceBuf[80]; - char upReferenceBuf[80]; - char backReferenceBuf[80]; - char forwardReferenceBuf[80]; + wxChar contentsReferenceBuf[80]; + wxChar upReferenceBuf[80]; + wxChar backReferenceBuf[80]; + wxChar forwardReferenceBuf[80]; if (htmlBrowseButtons == HTML_BUTTONS_NONE) return; - char *contentsReference = NULL; + wxChar *contentsReference; // no need to initialize because always assigned below if (htmlBrowseButtons == HTML_BUTTONS_TEXT) contentsReference = ContentsNameString; else { // contentsReference = "\"Contents\""; contentsReference = contentsReferenceBuf; - sprintf(contentsReference, "\"Contents\"", ConvertCase("contents.gif")); + wxSnprintf(contentsReference, sizeof(contentsReferenceBuf), + _T("\"Contents\""), + ConvertCase(_T("contents.gif"))); } - char *upReference = NULL; + wxChar *upReference; // no need to initialize because always assigned below if (htmlBrowseButtons == HTML_BUTTONS_TEXT) upReference = UpNameString; else { // upReference = "\"Up\""; upReference = upReferenceBuf; - sprintf(upReference, "\"Up\"", ConvertCase("up.gif")); + wxSnprintf(upReference, sizeof(upReferenceBuf), + _T("\"Up\""), + ConvertCase(_T("up.gif"))); } - char *backReference = NULL; + wxChar *backReference; // no need to initialize because always assigned below if (htmlBrowseButtons == HTML_BUTTONS_TEXT) - backReference = "<<"; + backReference = _T("<<"); else { // backReference = "\"Previous\""; backReference = backReferenceBuf; - sprintf(backReference, "\"Previous\"", ConvertCase("back.gif")); + wxSnprintf(backReference, sizeof(backReferenceBuf), + _T("\"Previous\""), + ConvertCase(_T("back.gif"))); } - char *forwardReference = NULL; + wxChar *forwardReference; // no need to initialize because always assigned below if (htmlBrowseButtons == HTML_BUTTONS_TEXT) - forwardReference = ">>"; + forwardReference = _T(">>"); else { // forwardReference = "\"Next\""; forwardReference = forwardReferenceBuf; - sprintf(forwardReference, "\"Next\"", ConvertCase("forward.gif")); + wxSnprintf(forwardReference, sizeof(forwardReferenceBuf), + _T("\"Next\""), + ConvertCase(_T("forward.gif"))); } - TexOutput("

"); + TexOutput(_T("
")); - char buf[200]; + wxChar buf[200]; /* * Contents button @@ -416,19 +452,23 @@ void AddBrowseButtons(char *upLabel, char *upFilename, if (truncateFilenames) { - char buf1[80]; - strcpy(buf1, ConvertCase(FileNameFromPath(FileRoot))); - sprintf(buf, "\n%s ", buf1, ConvertCase("htm"), contentsReference); + wxChar buf1[80]; + wxStrcpy(buf1, ConvertCase(wxFileNameFromPath(FileRoot))); + wxSnprintf(buf, sizeof(buf), + _T("\n%s "), + buf1, ConvertCase(_T("htm")), contentsReference); } else { - char buf1[80]; - strcpy(buf1, ConvertCase(FileNameFromPath(FileRoot))); - sprintf(buf, "\n%s ", buf1, ConvertCase("_contents.html"), contentsReference); + wxChar buf1[80]; + wxStrcpy(buf1, ConvertCase(wxFileNameFromPath(FileRoot))); + wxSnprintf(buf, sizeof(buf), + _T("\n%s "), + buf1, ConvertCase(_T("_contents.html")), contentsReference); } -// TexOutput(""); +// TexOutput(_T("<NOFRAMES>")); TexOutput(buf); -// TexOutput(""); +// TexOutput(_T("")); /* * Up button @@ -437,15 +477,19 @@ void AddBrowseButtons(char *upLabel, char *upFilename, if (upLabel && upFilename) { - if (strlen(upLabel) > 0) - sprintf(buf, "%s ", ConvertCase(upFilename), upLabel, upReference); + if ( (wxStrlen(upLabel) > 0) && !PrimaryAnchorOfTheFile(upFilename, upLabel) ) + wxSnprintf(buf, sizeof(buf), + _T("%s "), + ConvertCase(upFilename), upLabel, upReference); else - sprintf(buf, "%s ", ConvertCase(upFilename), upReference); - if (strcmp(upLabel, "contents") == 0) + wxSnprintf(buf, sizeof(buf), + _T("%s "), + ConvertCase(upFilename), upReference); + if (wxStrcmp(upLabel, _T("contents")) == 0) { -// TexOutput(""); +// TexOutput(_T("<NOFRAMES>")); TexOutput(buf); -// TexOutput(""); +// TexOutput(_T("")); } else TexOutput(buf); @@ -458,12 +502,19 @@ void AddBrowseButtons(char *upLabel, char *upFilename, if (previousLabel && previousFilename) { - sprintf(buf, "%s ", ConvertCase(previousFilename), previousLabel, backReference); - if (strcmp(previousLabel, "contents") == 0) + if (PrimaryAnchorOfTheFile(previousFilename, previousLabel)) + wxSnprintf(buf, sizeof(buf), + _T("%s "), + ConvertCase(previousFilename), backReference); + else + wxSnprintf(buf, sizeof(buf), + _T("%s "), + ConvertCase(previousFilename), previousLabel, backReference); + if (wxStrcmp(previousLabel, _T("contents")) == 0) { -// TexOutput(""); +// TexOutput(_T("<NOFRAMES>")); TexOutput(buf); -// TexOutput(""); +// TexOutput(_T("")); } else TexOutput(buf); @@ -471,12 +522,12 @@ void AddBrowseButtons(char *upLabel, char *upFilename, else { // A placeholder so the buttons don't keep moving position - sprintf(buf, "%s ", backReference); + wxSnprintf(buf, sizeof(buf), _T("%s "), backReference); TexOutput(buf); } - char *nextLabel = NULL; - char *nextFilename = NULL; + wxChar *nextLabel = NULL; + wxChar *nextFilename = NULL; // Get the next page, and record the previous page's 'next' page // (i.e. this page) @@ -505,13 +556,20 @@ void AddBrowseButtons(char *upLabel, char *upFilename, if (nextLabel && nextFilename) { - sprintf(buf, "%s ", ConvertCase(nextFilename), nextLabel, forwardReference); + if (PrimaryAnchorOfTheFile(nextFilename, nextLabel)) + wxSnprintf(buf, sizeof(buf), + _T("%s "), + ConvertCase(nextFilename), forwardReference); + else + wxSnprintf(buf, sizeof(buf), + _T("%s "), + ConvertCase(nextFilename), nextLabel, forwardReference); TexOutput(buf); } else { // A placeholder so the buttons don't keep moving position - sprintf(buf, "%s ", forwardReference); + wxSnprintf(buf, sizeof(buf), _T("%s "), forwardReference); TexOutput(buf); } @@ -519,8 +577,8 @@ void AddBrowseButtons(char *upLabel, char *upFilename, * Horizontal rule to finish it off nicely. * */ - TexOutput("
"); - TexOutput("
\n"); + TexOutput(_T("
")); + TexOutput(_T("
\n")); // Update last topic/filename if (lastFileName) @@ -533,39 +591,41 @@ void AddBrowseButtons(char *upLabel, char *upFilename, // A colour string is either 3 numbers separated by semicolons (RGB), // or a reference to a GIF. Return the filename or a hex string like #934CE8 -char *ParseColourString(char *bkStr, bool *isPicture) +wxChar *ParseColourString(wxChar *bkStr, bool *isPicture) { - static char resStr[300]; - strcpy(resStr, bkStr); - char *tok1 = strtok(resStr, ";"); - char *tok2 = strtok(NULL, ";"); - if (tok1) + static wxChar resStr[300]; + wxStrcpy(resStr, bkStr); + wxStringTokenizer tok(resStr, _T(";"), wxTOKEN_STRTOK); + if (tok.HasMoreTokens()) { - if (!tok2) + wxString token1 = tok.GetNextToken(); + if (!tok.HasMoreTokens()) { - *isPicture = TRUE; + *isPicture = true; return resStr; } else { - *isPicture = FALSE; - char *tok3 = strtok(NULL, ";"); - if (tok3) + wxString token2 = tok.GetNextToken(); + *isPicture = false; + if (tok.HasMoreTokens()) { + wxString token3 = tok.GetNextToken(); + // Now convert 3 strings into decimal numbers, and then hex numbers. - int red = atoi(tok1); - int green = atoi(tok2); - int blue = atoi(tok3); + int red = wxAtoi(token1.c_str()); + int green = wxAtoi(token2.c_str()); + int blue = wxAtoi(token3.c_str()); - strcpy(resStr, "#"); + wxStrcpy(resStr, _T("#")); - char buf[3]; + wxChar buf[3]; DecToHex(red, buf); - strcat(resStr, buf); + wxStrcat(resStr, buf); DecToHex(green, buf); - strcat(resStr, buf); + wxStrcat(resStr, buf); DecToHex(blue, buf); - strcat(resStr, buf); + wxStrcat(resStr, buf); return resStr; } else return NULL; @@ -574,60 +634,97 @@ char *ParseColourString(char *bkStr, bool *isPicture) else return NULL; } +void OutputFont(void) +{ + // Only output if explicitly requested by htmlFaceName= directive in + // tex2rtf.ini. Otherwise do NOT set the font because we want to use browser's + // default font: + if (htmlFaceName) + { + // Output + TexOutput(_T("\n")); + } +} + // Output start of block void OutputBodyStart(void) { - TexOutput("\n\n"); + TexOutput(_T(">\n")); + + OutputFont(); +} + +void HTMLHead() +{ + TexOutput(_T("")); + if (htmlStylesheet) { + TexOutput(_T("")); + } +}; + +void HTMLHeadTo(FILE* f) +{ + if (htmlStylesheet) + wxFprintf(f,_T(""),htmlStylesheet); + else + wxFprintf(f,_T("")); } // Called on start/end of macro examination @@ -649,10 +746,10 @@ void HTMLOnMacro(int macroId, int no_args, bool start) chapterNo ++; SetCurrentOutput(NULL); - startedSections = TRUE; + startedSections = true; - char *topicName = FindTopicName(GetNextChunk()); - ReopenFile(&Chapters, &ChaptersName); + wxChar *topicName = FindTopicName(GetNextChunk()); + ReopenFile(&Chapters, &ChaptersName, topicName); AddTexRef(topicName, ChaptersName, ChapterNameString); SetCurrentChapterName(topicName, ChaptersName); @@ -660,46 +757,53 @@ void HTMLOnMacro(int macroId, int no_args, bool start) SetCurrentOutput(Chapters); - TexOutput(""); + HTMLHead(); + TexOutput(_T("<title>")); OutputCurrentSection(); // Repeat section header - TexOutput("\n"); + TexOutput(_T("\n")); OutputBodyStart(); - char titleBuf[200]; + wxChar titleBuf[200]; if (truncateFilenames) - sprintf(titleBuf, "%s.htm", FileNameFromPath(FileRoot)); + wxSnprintf(titleBuf, sizeof(titleBuf), _T("%s.htm"), wxFileNameFromPath(FileRoot)); else - sprintf(titleBuf, "%s_contents.html", FileNameFromPath(FileRoot)); + wxSnprintf(titleBuf, sizeof(titleBuf), _T("%s_contents.html"), wxFileNameFromPath(FileRoot)); - fprintf(Chapters, "", topicName); + wxFprintf(Chapters, _T(""), topicName); - AddBrowseButtons("", titleBuf, // Up + AddBrowseButtons(_T(""), titleBuf, // Up lastTopic, lastFileName, // Last topic topicName, ChaptersName); // This topic - fprintf(Contents, "\n
  • ", ConvertCase(ChaptersName), topicName); + if(PrimaryAnchorOfTheFile(ChaptersName, topicName)) + wxFprintf(Contents, _T("\n
  • "), ConvertCase(ChaptersName)); + else + wxFprintf(Contents, _T("\n
  • "), ConvertCase(ChaptersName), topicName); if (htmlFrameContents && FrameContents) { SetCurrentOutput(FrameContents); - fprintf(FrameContents, "\n
  • ", ConvertCase(ChaptersName), topicName); + if(PrimaryAnchorOfTheFile(ChaptersName, topicName)) + wxFprintf(FrameContents, _T("\n
  • "), ConvertCase(ChaptersName)); + else + wxFprintf(FrameContents, _T("\n
  • "), ConvertCase(ChaptersName), topicName); OutputCurrentSection(); - fprintf(FrameContents, "\n"); + wxFprintf(FrameContents, _T("\n")); } SetCurrentOutputs(Contents, Chapters); - fprintf(Chapters, "\n

    "); + wxFprintf(Chapters, _T("\n

    ")); OutputCurrentSection(); - fprintf(Contents, "\n"); - fprintf(Chapters, "

    \n"); + wxFprintf(Contents, _T("\n")); + wxFprintf(Chapters, _T("\n")); SetCurrentOutput(Chapters); // Add this section title to the list of keywords if (htmlIndex) { - OutputCurrentSectionToString(wxBuffer); - AddKeyWordForTopic(topicName, wxBuffer, ConvertCase(currentFileName)); + OutputCurrentSectionToString(wxTex2RTFBuffer); + AddKeyWordForTopic(topicName, wxTex2RTFBuffer, ConvertCase(currentFileName)); } } break; @@ -713,28 +817,29 @@ void HTMLOnMacro(int macroId, int no_args, bool start) { subsectionNo = 0; subsubsectionNo = 0; - subsectionStarted = FALSE; + subsectionStarted = false; if (macroId != ltSECTIONSTAR) sectionNo ++; SetCurrentOutput(NULL); - startedSections = TRUE; + startedSections = true; - char *topicName = FindTopicName(GetNextChunk()); - ReopenFile(&Sections, &SectionsName); + wxChar *topicName = FindTopicName(GetNextChunk()); + ReopenFile(&Sections, &SectionsName, topicName); AddTexRef(topicName, SectionsName, SectionNameString); SetCurrentSectionName(topicName, SectionsName); if (htmlWorkshopFiles) HTMLWorkshopAddToContents(1, topicName, SectionsName); SetCurrentOutput(Sections); - TexOutput(""); + HTMLHead(); + TexOutput(_T("<title>")); OutputCurrentSection(); - TexOutput("\n"); + TexOutput(_T("\n")); OutputBodyStart(); - fprintf(Sections, "", topicName); + wxFprintf(Sections, _T(""), topicName); AddBrowseButtons(CurrentChapterName, CurrentChapterFile, // Up lastTopic, lastFileName, // Last topic topicName, SectionsName); // This topic @@ -743,25 +848,35 @@ void HTMLOnMacro(int macroId, int no_args, bool start) SetCurrentOutputs(jumpFrom, Sections); if (DocumentStyle == LATEX_ARTICLE) - fprintf(jumpFrom, "\n
  • ", ConvertCase(SectionsName), topicName); + { + if(PrimaryAnchorOfTheFile(SectionsName, topicName)) + wxFprintf(jumpFrom, _T("\n
  • "), ConvertCase(SectionsName)); + else + wxFprintf(jumpFrom, _T("\n
  • "), ConvertCase(SectionsName), topicName); + } else - fprintf(jumpFrom, "\n", ConvertCase(SectionsName), topicName); + { + if(PrimaryAnchorOfTheFile(SectionsName, topicName)) + wxFprintf(jumpFrom, _T("\n"), ConvertCase(SectionsName)); + else + wxFprintf(jumpFrom, _T("\n"), ConvertCase(SectionsName), topicName); + } - fprintf(Sections, "\n

    "); + wxFprintf(Sections, _T("\n

    ")); OutputCurrentSection(); if (DocumentStyle == LATEX_ARTICLE) - fprintf(jumpFrom, "\n"); + wxFprintf(jumpFrom, _T("\n")); else - fprintf(jumpFrom, "
    \n"); - fprintf(Sections, "

    \n"); + wxFprintf(jumpFrom, _T("

    \n")); + wxFprintf(Sections, _T("\n")); SetCurrentOutput(Sections); // Add this section title to the list of keywords if (htmlIndex) { - OutputCurrentSectionToString(wxBuffer); - AddKeyWordForTopic(topicName, wxBuffer, currentFileName); + OutputCurrentSectionToString(wxTex2RTFBuffer); + AddKeyWordForTopic(topicName, wxTex2RTFBuffer, currentFileName); } } break; @@ -775,7 +890,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start) { if (!Sections) { - OnError("You cannot have a subsection before a section!"); + OnError(_T("You cannot have a subsection before a section!")); } else { @@ -786,59 +901,65 @@ void HTMLOnMacro(int macroId, int no_args, bool start) if ( combineSubSections && !subsectionStarted ) { + fflush(Sections); + // Read old .con file in at this point - char buf[256]; - strcpy(buf, CurrentSectionFile); + wxChar buf[256]; + wxStrcpy(buf, CurrentSectionFile); wxStripExtension(buf); - strcat(buf, ".con"); - FILE *fd = fopen(buf, "r"); + wxStrcat(buf, _T(".con")); + FILE *fd = wxFopen(buf, _T("r")); if ( fd ) { int ch = getc(fd); while (ch != EOF) { - putc(ch, Sections); + wxPutc(ch, Sections); ch = getc(fd); } fclose(fd); } - fprintf(Sections, "

    \n"); + wxFprintf(Sections, _T("

    \n")); // Close old file, create a new file for the sub(sub)section contents entries ReopenSectionContentsFile(); } - startedSections = TRUE; - subsectionStarted = TRUE; + startedSections = true; + subsectionStarted = true; - char *topicName = FindTopicName(GetNextChunk()); + wxChar *topicName = FindTopicName(GetNextChunk()); if ( !combineSubSections ) { SetCurrentOutput(NULL); - ReopenFile(&Subsections, &SubsectionsName); + ReopenFile(&Subsections, &SubsectionsName, topicName); AddTexRef(topicName, SubsectionsName, SubsectionNameString); SetCurrentSubsectionName(topicName, SubsectionsName); if (htmlWorkshopFiles) HTMLWorkshopAddToContents(2, topicName, SubsectionsName); SetCurrentOutput(Subsections); - TexOutput(""); + HTMLHead(); + TexOutput(_T("<title>")); OutputCurrentSection(); - TexOutput("\n"); + TexOutput(_T("\n")); OutputBodyStart(); - fprintf(Subsections, "", topicName); + wxFprintf(Subsections, _T(""), topicName); AddBrowseButtons(CurrentSectionName, CurrentSectionFile, // Up lastTopic, lastFileName, // Last topic topicName, SubsectionsName); // This topic SetCurrentOutputs(Sections, Subsections); - fprintf(Sections, "\n", ConvertCase(SubsectionsName), topicName); + if(PrimaryAnchorOfTheFile(SubsectionsName, topicName)) + wxFprintf(Sections, _T("\n"), ConvertCase(SubsectionsName)); + else + wxFprintf(Sections, _T("\n"), ConvertCase(SubsectionsName), topicName); - fprintf(Subsections, "\n

    "); + wxFprintf(Subsections, _T("\n

    ")); OutputCurrentSection(); - fprintf(Sections, "
    \n"); - fprintf(Subsections, "

    \n"); + wxFprintf(Sections, _T("

    \n")); + wxFprintf(Subsections, _T("

    \n")); SetCurrentOutput(Subsections); } @@ -848,18 +969,18 @@ void HTMLOnMacro(int macroId, int no_args, bool start) SetCurrentSubsectionName(topicName, SectionsName); // if ( subsectionNo != 0 ) - fprintf(Sections, "\n
    \n"); + wxFprintf(Sections, _T("\n
    \n")); // We're putting everything into the section file - fprintf(Sections, "", topicName); - fprintf(Sections, "\n

    "); + wxFprintf(Sections, _T(""), topicName); + wxFprintf(Sections, _T("\n

    ")); OutputCurrentSection(); - fprintf(Sections, "

    \n"); + wxFprintf(Sections, _T("\n")); SetCurrentOutput(SectionContentsFD); - fprintf(SectionContentsFD, "", topicName); + wxFprintf(SectionContentsFD, _T(""), topicName); OutputCurrentSection(); - TexOutput("
    \n"); + TexOutput(_T("
    \n")); if (htmlWorkshopFiles) HTMLWorkshopAddToContents(2, topicName, SectionsName); SetCurrentOutput(Sections); @@ -867,8 +988,8 @@ void HTMLOnMacro(int macroId, int no_args, bool start) // Add this section title to the list of keywords if (htmlIndex) { - OutputCurrentSectionToString(wxBuffer); - AddKeyWordForTopic(topicName, wxBuffer, currentFileName); + OutputCurrentSectionToString(wxTex2RTFBuffer); + AddKeyWordForTopic(topicName, wxTex2RTFBuffer, currentFileName); } } @@ -882,61 +1003,65 @@ void HTMLOnMacro(int macroId, int no_args, bool start) { if (!Subsections && !combineSubSections) { - OnError("You cannot have a subsubsection before a subsection!"); + OnError(_T("You cannot have a subsubsection before a subsection!")); } else { if (macroId != ltSUBSUBSECTIONSTAR) subsubsectionNo ++; - startedSections = TRUE; + startedSections = true; - char *topicName = FindTopicName(GetNextChunk()); + wxChar *topicName = FindTopicName(GetNextChunk()); if ( !combineSubSections ) { SetCurrentOutput(NULL); - ReopenFile(&Subsubsections, &SubsubsectionsName); + ReopenFile(&Subsubsections, &SubsubsectionsName, topicName); AddTexRef(topicName, SubsubsectionsName, SubsubsectionNameString); SetCurrentSubsubsectionName(topicName, SubsubsectionsName); if (htmlWorkshopFiles) HTMLWorkshopAddToContents(3, topicName, SubsubsectionsName); SetCurrentOutput(Subsubsections); - TexOutput(""); + HTMLHead(); + TexOutput(_T("<title>")); OutputCurrentSection(); - TexOutput("\n"); + TexOutput(_T("\n")); OutputBodyStart(); - fprintf(Subsubsections, "", topicName); + wxFprintf(Subsubsections, _T(""), topicName); AddBrowseButtons(CurrentSubsectionName, CurrentSubsectionFile, // Up lastTopic, lastFileName, // Last topic topicName, SubsubsectionsName); // This topic SetCurrentOutputs(Subsections, Subsubsections); - fprintf(Subsections, "\n", ConvertCase(SubsubsectionsName), topicName); + if(PrimaryAnchorOfTheFile(SubsubsectionsName, topicName)) + wxFprintf(Subsections, _T("\n"), ConvertCase(SubsubsectionsName)); + else + wxFprintf(Subsections, _T("\n"), ConvertCase(SubsubsectionsName), topicName); - fprintf(Subsubsections, "\n

    "); + wxFprintf(Subsubsections, _T("\n

    ")); OutputCurrentSection(); - fprintf(Subsections, "
    \n"); - fprintf(Subsubsections, "

    \n"); + wxFprintf(Subsections, _T("

    \n")); + wxFprintf(Subsubsections, _T("\n")); } else { AddTexRef(topicName, SectionsName, SubsubsectionNameString); SetCurrentSubsectionName(topicName, SectionsName); - fprintf(Sections, "\n
    \n"); + wxFprintf(Sections, _T("\n
    \n")); // We're putting everything into the section file - fprintf(Sections, "", topicName); - fprintf(Sections, "\n

    "); + wxFprintf(Sections, _T(""), topicName); + wxFprintf(Sections, _T("\n

    ")); OutputCurrentSection(); - fprintf(Sections, "

    \n"); + wxFprintf(Sections, _T("\n")); /* TODO: where do we put subsubsection contents entry - indented, with subsection entries? SetCurrentOutput(SectionContentsFD); - fprintf(SectionContentsFD, "", topicName); + wxFprintf(SectionContentsFD, "", topicName); OutputCurrentSection(); - TexOutput("
    "); + TexOutput(_T("
    ")); */ if (htmlWorkshopFiles) HTMLWorkshopAddToContents(2, topicName, SectionsName); SetCurrentOutput(Sections); @@ -945,8 +1070,8 @@ void HTMLOnMacro(int macroId, int no_args, bool start) // Add this section title to the list of keywords if (htmlIndex) { - OutputCurrentSectionToString(wxBuffer); - AddKeyWordForTopic(topicName, wxBuffer, currentFileName); + OutputCurrentSectionToString(wxTex2RTFBuffer); + AddKeyWordForTopic(topicName, wxTex2RTFBuffer, currentFileName); } } } @@ -997,19 +1122,19 @@ void HTMLOnMacro(int macroId, int no_args, bool start) } case ltVOID: // if (start) -// TexOutput("void"); +// TexOutput(_T("void")); break; case ltHARDY: if (start) - TexOutput("HARDY"); + TexOutput(_T("HARDY")); break; case ltWXCLIPS: if (start) - TexOutput("wxCLIPS"); + TexOutput(_T("wxCLIPS")); break; case ltAMPERSAND: if (start) - TexOutput("&"); + TexOutput(_T("&")); break; case ltSPECIALAMPERSAND: { @@ -1018,17 +1143,18 @@ void HTMLOnMacro(int macroId, int no_args, bool start) if (inTabular) { // End cell, start cell - TexOutput(""); + + TexOutput(_T("
    ")); // Start new row and cell, setting alignment for the first cell. if (currentColumn < noColumns) currentColumn ++; - char buf[100]; + wxChar buf[100]; if (TableData[currentColumn].justification == 'c') - sprintf(buf, "\n"); + wxSnprintf(buf, sizeof(buf), _T("\n")); else if (TableData[currentColumn].justification == 'r') - sprintf(buf, "\n"); + wxSnprintf(buf, sizeof(buf), _T("\n")); else if (TableData[currentColumn].absWidth) { // Convert from points * 20 into pixels. @@ -1037,14 +1163,15 @@ void HTMLOnMacro(int macroId, int no_args, bool start) // Say the display is 100 DPI (dots/pixels per inch). // There are 72 pts to the inch. So 1pt = 1/72 inch, or 100 * 1/72 dots. int pixels = (int)(points * 100.0 / 72.0); - sprintf(buf, "", pixels); + wxSnprintf(buf, sizeof(buf), _T(""), pixels); } else - sprintf(buf, "\n"); + wxSnprintf(buf, sizeof(buf), _T("\n")); TexOutput(buf); + OutputFont(); } else - TexOutput("&"); + TexOutput(_T("&")); } break; } @@ -1057,10 +1184,10 @@ void HTMLOnMacro(int macroId, int no_args, bool start) // End row. In fact, tables without use of \row or \ruledrow isn't supported for // HTML: the syntax is too different (e.g. how do we know where to put the first // if we've ended the last row?). So normally you wouldn't use \\ to end a row. - TexOutput("\n"); + TexOutput(_T("\n")); } else - TexOutput("
    \n"); + TexOutput(_T("
    \n")); } break; } @@ -1072,11 +1199,11 @@ void HTMLOnMacro(int macroId, int no_args, bool start) currentColumn = 0; // Start new row and cell, setting alignment for the first cell. - char buf[100]; + wxChar buf[100]; if (TableData[currentColumn].justification == 'c') - sprintf(buf, "\n"); + wxSnprintf(buf, sizeof(buf), _T("\n")); else if (TableData[currentColumn].justification == 'r') - sprintf(buf, "\n"); + wxSnprintf(buf, sizeof(buf), _T("\n")); else if (TableData[currentColumn].absWidth) { // Convert from points * 20 into pixels. @@ -1085,17 +1212,18 @@ void HTMLOnMacro(int macroId, int no_args, bool start) // Say the display is 100 DPI (dots/pixels per inch). // There are 72 pts to the inch. So 1pt = 1/72 inch, or 100 * 1/72 dots. int pixels = (int)(points * 100.0 / 72.0); - sprintf(buf, "\n", pixels); + wxSnprintf(buf, sizeof(buf), _T("\n"), pixels); } else - sprintf(buf, "\n"); + wxSnprintf(buf, sizeof(buf), _T("\n")); TexOutput(buf); + OutputFont(); } else { // End cell and row // Start new row and cell - TexOutput("\n\n"); + TexOutput(_T("
    \n\n")); } break; } @@ -1103,7 +1231,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start) case ltBRCLEAR: { if (start) - TexOutput("
    "); + TexOutput(_T("
    ")); break; } case ltRTFSP: // Explicit space, RTF only @@ -1112,19 +1240,20 @@ void HTMLOnMacro(int macroId, int no_args, bool start) { if (start) { - if (inVerbatim) - TexOutput("~"); - else - TexOutput(" "); + #if (1) // if(inVerbatim) + TexOutput(_T("~")); + #else + TexOutput(_T(" ")); + #endif } break; } case ltINDENTED : { if ( start ) - TexOutput("
        \n"); + TexOutput(_T("
            \n")); else - TexOutput("
        \n"); + TexOutput(_T("
    \n")); break; } case ltITEMIZE: @@ -1148,39 +1277,39 @@ void HTMLOnMacro(int macroId, int no_args, bool start) switch (listType) { case LATEX_ITEMIZE: - TexOutput("
      \n"); + TexOutput(_T("
        \n")); break; case LATEX_ENUMERATE: - TexOutput("
          \n"); + TexOutput(_T("
            \n")); break; case LATEX_DESCRIPTION: default: - TexOutput("
            \n"); + TexOutput(_T("
            \n")); break; } } else { indentLevel --; - if (itemizeStack.First()) + if (itemizeStack.GetFirst()) { - ItemizeStruc *struc = (ItemizeStruc *)itemizeStack.First()->Data(); + ItemizeStruc *struc = (ItemizeStruc *)itemizeStack.GetFirst()->GetData(); switch (struc->listType) { case LATEX_ITEMIZE: - TexOutput("
      \n"); + TexOutput(_T("
    \n")); break; case LATEX_ENUMERATE: - TexOutput("\n"); + TexOutput(_T("\n")); break; case LATEX_DESCRIPTION: default: - TexOutput("\n"); + TexOutput(_T("\n")); break; } delete struc; - delete itemizeStack.First(); + delete itemizeStack.GetFirst(); } } break; @@ -1188,15 +1317,19 @@ void HTMLOnMacro(int macroId, int no_args, bool start) case ltTWOCOLLIST : { if ( start ) - TexOutput("\n\n"); - else - TexOutput("\n
    \n"); + TexOutput(_T("\n\n")); + else { + TexOutput(_T("\n
    \n")); + // DHS + TwoColWidthA = -1; + TwoColWidthB = -1; + } break; } case ltPAR: { if (start) - TexOutput("

    \n"); + TexOutput(_T("

    \n")); break; } /* For footnotes we need to output the text at the bottom of the page and @@ -1206,28 +1339,28 @@ void HTMLOnMacro(int macroId, int no_args, bool start) { if (start) { - TexOutput("); + TexOutput(_T("")); } - else TexOutput(""); + else TexOutput(_T("")); break; } */ case ltVERB: { if (start) - TexOutput(""); - else TexOutput(""); + TexOutput(_T("")); + else TexOutput(_T("")); break; } case ltVERBATIM: { if (start) { - char buf[100]; - sprintf(buf, "

    \n");
    +      wxChar buf[100];
    +      wxSnprintf(buf, sizeof(buf), _T("
    \n"));
           TexOutput(buf);
         }
    -    else TexOutput("
    \n"); + else TexOutput(_T("
    \n")); break; } case ltCENTERLINE: @@ -1235,9 +1368,9 @@ void HTMLOnMacro(int macroId, int no_args, bool start) { if (start) { - TexOutput("
    "); + TexOutput(_T("
    ")); } - else TexOutput("
    "); + else TexOutput(_T("
    ")); break; } case ltFLUSHLEFT: @@ -1245,9 +1378,9 @@ void HTMLOnMacro(int macroId, int no_args, bool start) /* if (start) { - TexOutput("{\\ql "); + TexOutput(_T("{\\ql ")); } - else TexOutput("}\\par\\pard\n"); + else TexOutput(_T("}\\par\\pard\n")); */ break; } @@ -1256,9 +1389,9 @@ void HTMLOnMacro(int macroId, int no_args, bool start) /* if (start) { - TexOutput("{\\qr "); + TexOutput(_T("{\\qr ")); } - else TexOutput("}\\par\\pard\n"); + else TexOutput(_T("}\\par\\pard\n")); */ break; } @@ -1267,9 +1400,9 @@ void HTMLOnMacro(int macroId, int no_args, bool start) if (start) { // Netscape extension - TexOutput(""); + TexOutput(_T("")); } - else TexOutput(""); + else TexOutput(_T("")); break; } case ltTINY: @@ -1277,9 +1410,9 @@ void HTMLOnMacro(int macroId, int no_args, bool start) if (start) { // Netscape extension - TexOutput(""); + TexOutput(_T("")); } - else TexOutput(""); + else TexOutput(_T("")); break; } case ltNORMALSIZE: @@ -1287,9 +1420,9 @@ void HTMLOnMacro(int macroId, int no_args, bool start) if (start) { // Netscape extension - TexOutput(""); + TexOutput(_T("")); } - else TexOutput(""); + else TexOutput(_T("")); break; } case ltlarge: @@ -1297,9 +1430,9 @@ void HTMLOnMacro(int macroId, int no_args, bool start) if (start) { // Netscape extension - TexOutput(""); + TexOutput(_T("")); } - else TexOutput(""); + else TexOutput(_T("")); break; } case ltLarge: @@ -1307,9 +1440,9 @@ void HTMLOnMacro(int macroId, int no_args, bool start) if (start) { // Netscape extension - TexOutput(""); + TexOutput(_T("")); } - else TexOutput(""); + else TexOutput(_T("")); break; } case ltLARGE: @@ -1317,9 +1450,9 @@ void HTMLOnMacro(int macroId, int no_args, bool start) if (start) { // Netscape extension - TexOutput(""); + TexOutput(_T("")); } - else TexOutput(""); + else TexOutput(_T("")); break; } case ltBFSERIES: @@ -1328,9 +1461,9 @@ void HTMLOnMacro(int macroId, int no_args, bool start) { if (start) { - TexOutput(""); + TexOutput(_T("")); } - else TexOutput(""); + else TexOutput(_T("")); break; } case ltITSHAPE: @@ -1339,9 +1472,9 @@ void HTMLOnMacro(int macroId, int no_args, bool start) { if (start) { - TexOutput(""); + TexOutput(_T("")); } - else TexOutput(""); + else TexOutput(_T("")); break; } case ltEMPH: @@ -1349,18 +1482,18 @@ void HTMLOnMacro(int macroId, int no_args, bool start) { if (start) { - TexOutput(""); + TexOutput(_T("")); } - else TexOutput(""); + else TexOutput(_T("")); break; } case ltUNDERLINE: { if (start) { - TexOutput("
      "); + TexOutput(_T("
        ")); } - else TexOutput("
      "); + else TexOutput(_T("
    ")); break; } case ltTTFAMILY: @@ -1369,52 +1502,52 @@ void HTMLOnMacro(int macroId, int no_args, bool start) { if (start) { - TexOutput(""); + TexOutput(_T("")); } - else TexOutput(""); + else TexOutput(_T("")); break; } case ltCOPYRIGHT: { if (start) - TexOutput("©", TRUE); + TexOutput(_T("©"), true); break; } case ltREGISTERED: { if (start) - TexOutput("®", TRUE); + TexOutput(_T("®"), true); break; } // Arrows case ltLEFTARROW: { - if (start) TexOutput("<--"); + if (start) TexOutput(_T("<--")); break; } case ltLEFTARROW2: { - if (start) TexOutput("<=="); + if (start) TexOutput(_T("<==")); break; } case ltRIGHTARROW: { - if (start) TexOutput("-->"); + if (start) TexOutput(_T("-->")); break; } case ltRIGHTARROW2: { - if (start) TexOutput("==>"); + if (start) TexOutput(_T("==>")); break; } case ltLEFTRIGHTARROW: { - if (start) TexOutput("<-->"); + if (start) TexOutput(_T("<-->")); break; } case ltLEFTRIGHTARROW2: { - if (start) TexOutput("<==>"); + if (start) TexOutput(_T("<==>")); break; } /* @@ -1427,24 +1560,24 @@ void HTMLOnMacro(int macroId, int no_args, bool start) { if (!start) { - wxNode *node = itemizeStack.First(); + wxNode *node = itemizeStack.GetFirst(); if (node) { - ItemizeStruc *struc = (ItemizeStruc *)node->Data(); + ItemizeStruc *struc = (ItemizeStruc *)node->GetData(); struc->currentItem += 1; if (struc->listType == LATEX_DESCRIPTION) { if (descriptionItemArg) { - TexOutput("
    "); + TexOutput(_T("
    ")); TraverseChildrenFromChunk(descriptionItemArg); - TexOutput("\n"); + TexOutput(_T("\n")); descriptionItemArg = NULL; } - TexOutput("
    "); + TexOutput(_T("
    ")); } else - TexOutput("
  • "); + TexOutput(_T("
  • ")); } } break; @@ -1454,25 +1587,25 @@ void HTMLOnMacro(int macroId, int no_args, bool start) if (start && DocumentTitle && DocumentAuthor) { // Add a special label for the contents page. -// TexOutput("
    \n"); - TexOutput(""); - TexOutput("

    \n"); +// TexOutput(_T("
    \n")); + TexOutput(_T("")); + TexOutput(_T("

    \n")); TraverseChildrenFromChunk(DocumentTitle); - TexOutput("

    "); - TexOutput("

    "); - TexOutput("\n"); - TexOutput("

    \n\n"); - TexOutput("

    "); + TexOutput(_T("

    ")); + TexOutput(_T("

    ")); + TexOutput(_T("\n")); + TexOutput(_T("

    \n\n")); + TexOutput(_T("

    ")); TraverseChildrenFromChunk(DocumentAuthor); - TexOutput("

    \n\n"); + TexOutput(_T("

    \n\n")); if (DocumentDate) { - TexOutput("

    "); + TexOutput(_T("

    ")); TraverseChildrenFromChunk(DocumentDate); - TexOutput("

    \n\n"); + TexOutput(_T("

    \n\n")); } -// TexOutput("\n

    \n"); - TexOutput("\n


    \n"); +// TexOutput(_T("\n\n")); + TexOutput(_T("\n


    \n")); /* // Now do optional frame contents page @@ -1481,24 +1614,24 @@ void HTMLOnMacro(int macroId, int no_args, bool start) SetCurrentOutput(FrameContents); // Add a special label for the contents page. - TexOutput("

    \n"); - TexOutput("

    \n"); + TexOutput(_T("
    \n")); + TexOutput(_T("

    \n")); TraverseChildrenFromChunk(DocumentTitle); - TexOutput("

    "); - TexOutput("

    "); - TexOutput("\n"); - TexOutput("

    \n\n"); - TexOutput("

    "); + TexOutput(_T("

    ")); + TexOutput(_T("

    ")); + TexOutput(_T("\n")); + TexOutput(_T("

    \n\n")); + TexOutput(_T("

    ")); TraverseChildrenFromChunk(DocumentAuthor); - TexOutput("

    \n\n"); + TexOutput(_T("

    \n\n")); if (DocumentDate) { - TexOutput("

    "); + TexOutput(_T("

    ")); TraverseChildrenFromChunk(DocumentDate); - TexOutput("

    \n\n"); + TexOutput(_T("

    \n\n")); } - TexOutput("\n

    \n"); - TexOutput("


    \n"); + TexOutput(_T("\n\n")); + TexOutput(_T("


    \n")); SetCurrentOutput(Titlepage); } @@ -1527,7 +1660,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start) else { DefaultOnMacro(macroId, no_args, start); - TexOutput("\n"); + TexOutput(_T("\n")); } break; } @@ -1535,7 +1668,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start) { if (start) { - TexOutput("


    \n"); + TexOutput(_T("
    \n")); } break; } @@ -1543,7 +1676,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start) { if (start) { - TexOutput("
    \n"); + TexOutput(_T("
    \n")); } break; } @@ -1551,21 +1684,27 @@ void HTMLOnMacro(int macroId, int no_args, bool start) { if (start) { - FILE *fd = fopen(ContentsName, "r"); + // NB: if this is uncommented, the table of contents + // completely disappears. If left commented, it's in the wrong + // place. + //fflush(Titlepage); + + FILE *fd = wxFopen(ContentsName, _T("r")); if (fd) { int ch = getc(fd); while (ch != EOF) { - putc(ch, Titlepage); + wxPutc(ch, Titlepage); ch = getc(fd); } fclose(fd); + fflush(Titlepage); } else { - TexOutput("RUN TEX2RTF AGAIN FOR CONTENTS PAGE\n"); - OnInform("Run Tex2RTF again to include contents page."); + TexOutput(_T("RUN TEX2RTF AGAIN FOR CONTENTS PAGE\n")); + OnInform(_T("Run Tex2RTF again to include contents page.")); } } break; @@ -1573,22 +1712,22 @@ void HTMLOnMacro(int macroId, int no_args, bool start) case ltLANGLEBRA: { if (start) - TexOutput("<"); + TexOutput(_T("<")); break; } case ltRANGLEBRA: { if (start) - TexOutput(">"); + TexOutput(_T(">")); break; } case ltQUOTE: case ltQUOTATION: { if (start) - TexOutput("
    "); + TexOutput(_T("
    ")); else - TexOutput("
    "); + TexOutput(_T("
    ")); break; } case ltCAPTION: @@ -1597,27 +1736,27 @@ void HTMLOnMacro(int macroId, int no_args, bool start) if (start) { if (inTabular) - TexOutput("\n"); + TexOutput(_T("\n")); - char figBuf[40]; + wxChar figBuf[40]; if ( inFigure ) { figureNo ++; if (DocumentStyle != LATEX_ARTICLE) - sprintf(figBuf, "%s %d.%d: ", FigureNameString, chapterNo, figureNo); + wxSnprintf(figBuf, sizeof(figBuf), _T("%s %d.%d: "), FigureNameString, chapterNo, figureNo); else - sprintf(figBuf, "%s %d: ", FigureNameString, figureNo); + wxSnprintf(figBuf, sizeof(figBuf), _T("%s %d: "), FigureNameString, figureNo); } else { tableNo ++; if (DocumentStyle != LATEX_ARTICLE) - sprintf(figBuf, "%s %d.%d: ", TableNameString, chapterNo, tableNo); + wxSnprintf(figBuf, sizeof(figBuf), _T("%s %d.%d: "), TableNameString, chapterNo, tableNo); else - sprintf(figBuf, "%s %d: ", TableNameString, tableNo); + wxSnprintf(figBuf, sizeof(figBuf), _T("%s %d: "), TableNameString, tableNo); } TexOutput(figBuf); @@ -1625,9 +1764,9 @@ void HTMLOnMacro(int macroId, int no_args, bool start) else { if (inTabular) - TexOutput("\n\n"); + TexOutput(_T("\n\n")); - char *topicName = FindTopicName(GetNextChunk()); + wxChar *topicName = FindTopicName(GetNextChunk()); int n = inFigure ? figureNo : tableNo; @@ -1639,19 +1778,19 @@ void HTMLOnMacro(int macroId, int no_args, bool start) } case ltSS: { - if (start) TexOutput("ß"); + if (start) TexOutput(_T("ß")); break; } case ltFIGURE: { - if (start) inFigure = TRUE; - else inFigure = FALSE; + if (start) inFigure = true; + else inFigure = false; break; } case ltTABLE: { - if (start) inTable = TRUE; - else inTable = FALSE; + if (start) inTable = true; + else inTable = false; break; } default: @@ -1659,7 +1798,74 @@ void HTMLOnMacro(int macroId, int no_args, bool start) break; } } - +/* CheckTypeRef() + + should be called at of argument which usually is + type declaration which propably contains name of + documented class + + examples: + HTMLOnArgument + - ltFUNC, + - ltPARAM + - ltCPARAM + + checks: GetArgData() if contains Type Declaration + and can be referenced to some file + prints: + beforetypeafter + + returns: + false - if no reference was found + true - if reference was found and HREF printed +*/ +static bool CheckTypeRef() +{ + wxString typeDecl = GetArgData(); + if( !typeDecl.empty() ) { + typeDecl.Replace(wxT("\\"),wxT("")); + wxString label = typeDecl; + label.Replace(wxT("const"),wxT("")); + label.Replace(wxT("virtual"),wxT("")); + label.Replace(wxT("static"),wxT("")); + label.Replace(wxT("extern"),wxT("")); + label = label.BeforeFirst('&'); + label = label.BeforeFirst(wxT('*')); + label = label.BeforeFirst(wxT('\\')); + label.Trim(true); label.Trim(false); + wxString typeName = label; + label.MakeLower(); + TexRef *texRef = FindReference((wxChar*)label.c_str()); + + if (texRef && texRef->refFile && wxStrcmp(texRef->refFile, _T("??")) != 0) { + int a = typeDecl.Find(typeName); + wxString before = typeDecl.Mid( 0, a ); + wxString after = typeDecl.Mid( a+typeName.Length() ); + //wxFprintf(stderr,wxT("%s <%s> %s to ... %s#%s !!!!\n"), + // before.c_str(), + // typeName.c_str(), + // after.c_str(), + // texRef->refFile,label.c_str()); + TexOutput(before); + TexOutput(_T("refFile); + TexOutput(_T("#")); + TexOutput(label); + TexOutput(wxT("\">")); + TexOutput(typeName); + TexOutput(wxT("")); + TexOutput(after); + return true; + } else { + //wxFprintf(stderr,wxT("'%s' from (%s) -> label %s NOT FOUND\n"), + // typeName.c_str(), + // typeDecl.c_str(), + // label.c_str()); + return false; + } + } + return false; +} // Called on start/end of argument examination bool HTMLOnArgument(int macroId, int arg_no, bool start) { @@ -1681,43 +1887,47 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) { if (!start && (arg_no == 1)) currentSection = GetArgChunk(); - return FALSE; - break; + return false; } case ltFUNC: { - if (start && (arg_no == 1)) - TexOutput(""); + if (start && (arg_no == 1)) { + TexOutput(_T("")); + if( CheckTypeRef() ) { + TexOutput(_T(" ")); + return false; + } + } if (!start && (arg_no == 1)) - TexOutput(" "); + TexOutput(_T("
    ")); if (start && (arg_no == 2)) { - if (!suppressNameDecoration) TexOutput(""); + if (!suppressNameDecoration) TexOutput(_T("")); currentMember = GetArgChunk(); } if (!start && (arg_no == 2)) { - if (!suppressNameDecoration) TexOutput(""); + if (!suppressNameDecoration) TexOutput(_T("")); } if (start && (arg_no == 3)) - TexOutput("("); + TexOutput(_T("(")); if (!start && (arg_no == 3)) - TexOutput(")"); + TexOutput(_T(")")); break; } case ltCLIPSFUNC: { if (start && (arg_no == 1)) - TexOutput(""); + TexOutput(_T("")); if (!start && (arg_no == 1)) - TexOutput(" "); + TexOutput(_T(" ")); if (start && (arg_no == 2)) { - if (!suppressNameDecoration) TexOutput("( "); + if (!suppressNameDecoration) TexOutput(_T("( ")); currentMember = GetArgChunk(); } if (!start && (arg_no == 2)) @@ -1725,64 +1935,58 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) } if (!start && (arg_no == 3)) - TexOutput(")"); + TexOutput(_T(")")); break; } case ltPFUNC: { if (!start && (arg_no == 1)) - TexOutput(" "); + TexOutput(_T(" ")); if (start && (arg_no == 2)) - TexOutput("(*"); + TexOutput(_T("(*")); if (!start && (arg_no == 2)) - TexOutput(")"); + TexOutput(_T(")")); if (start && (arg_no == 2)) currentMember = GetArgChunk(); if (start && (arg_no == 3)) - TexOutput("("); + TexOutput(_T("(")); if (!start && (arg_no == 3)) - TexOutput(")"); + TexOutput(_T(")")); break; } case ltPARAM: - { - if (start && (arg_no == 1)) - TexOutput(""); - if (!start && (arg_no == 1)) - TexOutput(""); - if (start && (arg_no == 2)) - { - TexOutput(""); - } - if (!start && (arg_no == 2)) - { - TexOutput(""); - } - break; - } case ltCPARAM: { - if (start && (arg_no == 1)) - TexOutput(""); - if (!start && (arg_no == 1)) - TexOutput(" "); // This is the difference from param - one space! + const wxChar* pend = macroId == ltCPARAM ? + _T(" ") : _T(""); + if( arg_no == 1) { + if( start ) { + TexOutput(_T("")); + if( CheckTypeRef() ) { + TexOutput(pend); + return false; + } + } else { + TexOutput(pend); + } + } if (start && (arg_no == 2)) { - TexOutput(""); + TexOutput(_T("")); } if (!start && (arg_no == 2)) { - TexOutput(""); + TexOutput(_T("")); } break; } case ltMEMBER: { if (!start && (arg_no == 1)) - TexOutput(" "); + TexOutput(_T(" ")); if (start && (arg_no == 2)) currentMember = GetArgChunk(); @@ -1792,9 +1996,9 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) { if (start) { - char *sec = NULL; + wxChar *sec = NULL; - char *refName = GetArgData(); + wxChar *refName = GetArgData(); if (refName) { TexRef *texRef = FindReference(refName); @@ -1807,38 +2011,39 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) { TexOutput(sec); } - return FALSE; + return false; } break; } case ltURLREF: { if (IsArgOptional()) - return FALSE; + return false; else if ((GetNoArgs() - arg_no) == 1) { if (start) helpRefText = GetArgChunk(); - return FALSE; + return false; } else if ((GetNoArgs() - arg_no) == 0) // Arg = 2, or 3 if first is optional { if (start) { TexChunk *ref = GetArgChunk(); - TexOutput(""); + inVerbatim = false; + TexOutput(_T("\">")); if (helpRefText) TraverseChildrenFromChunk(helpRefText); - TexOutput(""); + TexOutput(_T("")); } - return FALSE; + return false; } break; } + case ltHELPREF: case ltHELPREFN: case ltPOPREF: @@ -1847,58 +2052,72 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) { if (start) helpRefFilename = GetArgChunk(); - return FALSE; + return false; } if ((GetNoArgs() - arg_no) == 1) { if (start) helpRefText = GetArgChunk(); - return FALSE; + return false; } else if ((GetNoArgs() - arg_no) == 0) // Arg = 2, or 3 if first is optional { if (start) { - char *refName = GetArgData(); - char *refFilename = NULL; + wxChar *refName = GetArgData(); + wxChar *refFilename = NULL; if (refName) { TexRef *texRef = FindReference(refName); if (texRef) { - if (texRef->refFile && strcmp(texRef->refFile, "??") != 0) + if (texRef->refFile && wxStrcmp(texRef->refFile, _T("??")) != 0) refFilename = texRef->refFile; - TexOutput(""); + if(!PrimaryAnchorOfTheFile(texRef->refFile, refName)) + { + TexOutput(_T("#")); + TexOutput(refName); + } + } + TexOutput(_T("\">")); if (helpRefText) TraverseChildrenFromChunk(helpRefText); - TexOutput(""); + TexOutput(_T("")); } else { if (helpRefText) TraverseChildrenFromChunk(helpRefText); - TexOutput(" (REF NOT FOUND)"); + if (!ignoreBadRefs) + TexOutput(_T(" (REF NOT FOUND)")); + + // for launching twice do not warn in preparation pass + if ((passNumber == 1 && !runTwice) || + (passNumber == 2 && runTwice)) + { + wxString errBuf; + errBuf.Printf(_T("Warning: unresolved reference '%s'"), refName); + OnInform((wxChar *)errBuf.c_str()); + } } } - else TexOutput("??"); + else TexOutput(_T("??")); } - return FALSE; + return false; } break; } @@ -1911,117 +2130,120 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) { if (start) { - char *alignment = ""; + wxChar *alignment = _T(""); if (macroId == ltIMAGEL) - alignment = " align=left"; + alignment = _T(" align=left"); else if (macroId == ltIMAGER) - alignment = " align=right"; + alignment = _T(" align=right"); // Try to find an XBM or GIF image first. - char *filename = copystring(GetArgData()); - char buf[500]; + wxChar *filename = copystring(GetArgData()); + wxChar buf[500]; - strcpy(buf, filename); + wxStrcpy(buf, filename); StripExtension(buf); - strcat(buf, ".xbm"); + wxStrcat(buf, _T(".xbm")); wxString f = TexPathList.FindValidPath(buf); - if (f == "") // Try for a GIF instead + if (f == _T("")) // Try for a GIF instead { - strcpy(buf, filename); + wxStrcpy(buf, filename); StripExtension(buf); - strcat(buf, ".gif"); + wxStrcat(buf, _T(".gif")); f = TexPathList.FindValidPath(buf); } - if (f == "") // Try for a JPEG instead + if (f == _T("")) // Try for a JPEG instead { - strcpy(buf, filename); + wxStrcpy(buf, filename); StripExtension(buf); - strcat(buf, ".jpg"); + wxStrcat(buf, _T(".jpg")); f = TexPathList.FindValidPath(buf); } - if (f == "") // Try for a PNG instead + if (f == _T("")) // Try for a PNG instead { - strcpy(buf, filename); + wxStrcpy(buf, filename); StripExtension(buf); - strcat(buf, ".png"); + wxStrcat(buf, _T(".png")); f = TexPathList.FindValidPath(buf); } - if (f != "") + if (f != _T("")) { - char *inlineFilename = copystring(f); + wxChar *inlineFilename = copystring(f); #if 0 - char *originalFilename = TexPathList.FindValidPath(filename); + wxChar *originalFilename = TexPathList.FindValidPath(filename); // If we have found the existing filename, make the inline // image point to the original file (could be PS, for example) - if (originalFilename && (strcmp(inlineFilename, originalFilename) != 0)) - { - TexOutput(""); - TexOutput("")); + TexOutput(_T(""); - } + TexOutput(_T("\"")); + TexOutput(alignment); + TexOutput(_T(">")); + } else #endif - { - TexOutput(""); + TexOutput(_T("\"")); + TexOutput(alignment); + TexOutput(_T(">")); delete[] inlineFilename; - } + } } else { // Last resort - a link to a PS file. - TexOutput("Picture\n"); - sprintf(buf, "Warning: could not find an inline XBM/GIF for %s.", filename); + TexOutput(_T("\">Picture\n")); + wxSnprintf(buf, sizeof(buf), _T("Warning: could not find an inline XBM/GIF for %s."), filename); OnInform(buf); } } } - return FALSE; - break; + return false; } // First arg is PSBOX spec (ignored), second is image file, third is map name. case ltIMAGEMAP: { - static char *imageFile = NULL; + static wxChar *imageFile = NULL; if (start && (arg_no == 2)) { // Try to find an XBM or GIF image first. - char *filename = copystring(GetArgData()); - char buf[500]; + wxChar *filename = copystring(GetArgData()); + wxChar buf[500]; - strcpy(buf, filename); + wxStrcpy(buf, filename); StripExtension(buf); - strcat(buf, ".xbm"); + wxStrcat(buf, _T(".xbm")); wxString f = TexPathList.FindValidPath(buf); - if (f == "") // Try for a GIF instead + if (f == _T("")) // Try for a GIF instead { - strcpy(buf, filename); + wxStrcpy(buf, filename); StripExtension(buf); - strcat(buf, ".gif"); + wxStrcat(buf, _T(".gif")); f = TexPathList.FindValidPath(buf); } - if (f == "") + if (f == _T("")) { - char buf[300]; - sprintf(buf, "Warning: could not find an inline XBM/GIF for %s.", filename); + wxChar buf[300]; + wxSnprintf(buf, sizeof(buf), _T("Warning: could not find an inline XBM/GIF for %s."), filename); OnInform(buf); } delete[] filename; if (imageFile) delete[] imageFile; imageFile = NULL; - if (f) + if (!f.empty()) { imageFile = copystring(f); } @@ -2032,42 +2254,41 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) { // First, try to find a .shg (segmented hypergraphics file) // that we can convert to a map file - char buf[256]; - strcpy(buf, imageFile); + wxChar buf[256]; + wxStrcpy(buf, imageFile); StripExtension(buf); - strcat(buf, ".shg"); + wxStrcat(buf, _T(".shg")); wxString f = TexPathList.FindValidPath(buf); - if (f != "") + if (f != _T("")) { // The default HTML file to go to is THIS file (so a no-op) - SHGToMap((char*) (const char*) f, currentFileName); + SHGToMap((wxChar *)f.c_str(), currentFileName); } - char *mapName = GetArgData(); - TexOutput(""); - TexOutput("")); + TexOutput(_T("

    "); + TexOutput(_T("\" ISMAP>

    ")); delete[] imageFile; imageFile = NULL; } } - return FALSE; - break; + return false; } case ltINDENTED : { if ( arg_no == 1 ) - return FALSE; + return false; else { - return TRUE; + return true; } } case ltITEM: @@ -2075,68 +2296,90 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) if (start) { descriptionItemArg = GetArgChunk(); - return FALSE; + return false; } + return true; } case ltTWOCOLITEM: case ltTWOCOLITEMRULED: { /* if (start && (arg_no == 1)) - TexOutput("\n

    "); + TexOutput(_T("\n
    ")); if (start && (arg_no == 2)) - TexOutput("
    "); + TexOutput(_T("
    ")); */ if (arg_no == 1) { - if ( start ) - TexOutput("\n\n"); + if ( start ) { + // DHS + if (TwoColWidthA > -1) + { + wxChar buf[100]; + wxSnprintf(buf, sizeof(buf), _T("\n\n"),TwoColWidthA); + TexOutput(buf); + } else - TexOutput("\n\n"); + { + TexOutput(_T("\n\n")); + } + OutputFont(); + } else + TexOutput(_T("\n\n")); } if (arg_no == 2) { - if ( start ) - TexOutput("\n\n"); + // DHS + if ( start ) + { + if (TwoColWidthB > -1) + { + wxChar buf[100]; + wxSnprintf(buf, sizeof(buf), _T("\n\n"),TwoColWidthB); + TexOutput(buf); + } else - TexOutput("\n\n"); + { + TexOutput(_T("\n\n")); + } + OutputFont(); + } else + TexOutput(_T("\n\n")); } - return TRUE; - break; + return true; } case ltNUMBEREDBIBITEM: { if (arg_no == 1 && start) { - TexOutput("\n
    "); + TexOutput(_T("\n
    ")); } if (arg_no == 2 && !start) - TexOutput("

    \n"); + TexOutput(_T("

    \n")); break; } case ltBIBITEM: { - char buf[100]; + wxChar buf[100]; if (arg_no == 1 && start) { - char *citeKey = GetArgData(); + wxChar *citeKey = GetArgData(); TexRef *ref = (TexRef *)TexReferences.Get(citeKey); if (ref) { if (ref->sectionNumber) delete[] ref->sectionNumber; - sprintf(buf, "[%d]", citeCount); + wxSnprintf(buf, sizeof(buf), _T("[%d]"), citeCount); ref->sectionNumber = copystring(buf); } - sprintf(buf, "\n

    [%d] ", citeCount); + wxSnprintf(buf, sizeof(buf), _T("\n
    [%d] "), citeCount); TexOutput(buf); citeCount ++; - return FALSE; + return false; } if (arg_no == 2 && !start) - TexOutput("

    \n"); - return TRUE; - break; + TexOutput(_T("

    \n")); + return true; } case ltMARGINPAR: case ltMARGINPARODD: @@ -2146,13 +2389,35 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) { if (start) { - TexOutput("


    \n"); - return TRUE; + TexOutput(_T("
    \n")); + return true; } else - TexOutput("

    \n"); + TexOutput(_T("


    \n")); break; } + // DHS + case ltTWOCOLWIDTHA: + { + if (start) + { + wxChar *val = GetArgData(); + float points = ParseUnitArgument(val); + TwoColWidthA = (int)((points * 100.0) / 72.0); + } + return false; + } + // DHS + case ltTWOCOLWIDTHB: + { + if (start) + { + wxChar *val = GetArgData(); + float points = ParseUnitArgument(val); + TwoColWidthB = (int)((points * 100.0) / 72.0); + } + return false; + } /* * Accents * @@ -2161,272 +2426,266 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) { if (start) { - char *val = GetArgData(); + wxChar *val = GetArgData(); if (val) { switch (val[0]) { case 'a': - TexOutput("à"); + TexOutput(_T("à")); break; case 'e': - TexOutput("è"); + TexOutput(_T("è")); break; case 'i': - TexOutput("ì"); + TexOutput(_T("ì")); break; case 'o': - TexOutput("ò"); + TexOutput(_T("ò")); break; case 'u': - TexOutput("ù"); + TexOutput(_T("ù")); break; case 'A': - TexOutput("À"); + TexOutput(_T("À")); break; case 'E': - TexOutput("È"); + TexOutput(_T("È")); break; case 'I': - TexOutput("Ì"); + TexOutput(_T("Ì")); break; case 'O': - TexOutput("Ò"); + TexOutput(_T("Ò")); break; case 'U': - TexOutput("Ì"); + TexOutput(_T("Ì")); break; default: break; } } } - return FALSE; - break; + return false; } case ltACCENT_ACUTE: { if (start) { - char *val = GetArgData(); + wxChar *val = GetArgData(); if (val) { switch (val[0]) { case 'a': - TexOutput("á"); + TexOutput(_T("á")); break; case 'e': - TexOutput("é"); + TexOutput(_T("é")); break; case 'i': - TexOutput("í"); + TexOutput(_T("í")); break; case 'o': - TexOutput("ó"); + TexOutput(_T("ó")); break; case 'u': - TexOutput("ú"); + TexOutput(_T("ú")); break; case 'y': - TexOutput("ý"); + TexOutput(_T("ý")); break; case 'A': - TexOutput("Á"); + TexOutput(_T("Á")); break; case 'E': - TexOutput("É"); + TexOutput(_T("É")); break; case 'I': - TexOutput("Í"); + TexOutput(_T("Í")); break; case 'O': - TexOutput("Ó"); + TexOutput(_T("Ó")); break; case 'U': - TexOutput("Ú"); + TexOutput(_T("Ú")); break; case 'Y': - TexOutput("Ý"); + TexOutput(_T("Ý")); break; default: break; } } } - return FALSE; - break; + return false; } case ltACCENT_CARET: { if (start) { - char *val = GetArgData(); + wxChar *val = GetArgData(); if (val) { switch (val[0]) { case 'a': - TexOutput("â"); + TexOutput(_T("â")); break; case 'e': - TexOutput("ê"); + TexOutput(_T("ê")); break; case 'i': - TexOutput("î"); + TexOutput(_T("î")); break; case 'o': - TexOutput("ô"); + TexOutput(_T("ô")); break; case 'u': - TexOutput("û"); + TexOutput(_T("û")); break; case 'A': - TexOutput("Â"); + TexOutput(_T("Â")); break; case 'E': - TexOutput("Ê"); + TexOutput(_T("Ê")); break; case 'I': - TexOutput("Î"); + TexOutput(_T("Î")); break; case 'O': - TexOutput("Ô"); + TexOutput(_T("Ô")); break; case 'U': - TexOutput("Î"); + TexOutput(_T("Î")); break; default: break; } } } - return FALSE; - break; + return false; } case ltACCENT_TILDE: { if (start) { - char *val = GetArgData(); + wxChar *val = GetArgData(); if (val) { switch (val[0]) { case ' ': - TexOutput("~"); + TexOutput(_T("~")); break; case 'a': - TexOutput("ã"); + TexOutput(_T("ã")); break; case 'n': - TexOutput("ñ"); + TexOutput(_T("ñ")); break; case 'o': - TexOutput("õ"); + TexOutput(_T("õ")); break; case 'A': - TexOutput("Ã"); + TexOutput(_T("Ã")); break; case 'N': - TexOutput("Ñ"); + TexOutput(_T("Ñ")); break; case 'O': - TexOutput("Õ"); + TexOutput(_T("Õ")); break; default: break; } } } - return FALSE; - break; + return false; } case ltACCENT_UMLAUT: { if (start) { - char *val = GetArgData(); + wxChar *val = GetArgData(); if (val) { switch (val[0]) { case 'a': - TexOutput("ä"); + TexOutput(_T("ä")); break; case 'e': - TexOutput("ë"); + TexOutput(_T("ë")); break; case 'i': - TexOutput("ï"); + TexOutput(_T("ï")); break; case 'o': - TexOutput("ö"); + TexOutput(_T("ö")); break; case 'u': - TexOutput("ü"); + TexOutput(_T("ü")); break; case 'y': - TexOutput("ÿ"); + TexOutput(_T("ÿ")); break; case 'A': - TexOutput("Ä"); + TexOutput(_T("Ä")); break; case 'E': - TexOutput("Ë"); + TexOutput(_T("Ë")); break; case 'I': - TexOutput("Ï"); + TexOutput(_T("Ï")); break; case 'O': - TexOutput("Ö"); + TexOutput(_T("Ö")); break; case 'U': - TexOutput("Ü"); + TexOutput(_T("Ü")); break; case 'Y': - TexOutput("Ÿ"); + TexOutput(_T("Ÿ")); break; default: break; } } } - return FALSE; - break; + return false; } case ltACCENT_DOT: { if (start) { - char *val = GetArgData(); + wxChar *val = GetArgData(); if (val) { switch (val[0]) { case 'a': - TexOutput("å"); + TexOutput(_T("å")); break; case 'A': - TexOutput("Å"); + TexOutput(_T("Å")); break; default: break; } } } - return FALSE; - break; + return false; } case ltBACKGROUND: { if (start) { - char *val = GetArgData(); + wxChar *val = GetArgData(); if (val) { - bool isPicture = FALSE; - char *s = ParseColourString(val, &isPicture); + bool isPicture = false; + ParseColourString(val, &isPicture); if (isPicture) { if (backgroundImageString) @@ -2441,14 +2700,13 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) } } } - return FALSE; - break; + return false; } case ltBACKGROUNDIMAGE: { if (start) { - char *val = GetArgData(); + wxChar *val = GetArgData(); if (val) { if (backgroundImageString) @@ -2456,14 +2714,13 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) backgroundImageString = copystring(val); } } - return FALSE; - break; + return false; } case ltBACKGROUNDCOLOUR: { if (start) { - char *val = GetArgData(); + wxChar *val = GetArgData(); if (val) { if (backgroundColourString) @@ -2471,14 +2728,13 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) backgroundColourString = copystring(val); } } - return FALSE; - break; + return false; } case ltTEXTCOLOUR: { if (start) { - char *val = GetArgData(); + wxChar *val = GetArgData(); if (val) { if (textColourString) @@ -2486,14 +2742,13 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) textColourString = copystring(val); } } - return FALSE; - break; + return false; } case ltLINKCOLOUR: { if (start) { - char *val = GetArgData(); + wxChar *val = GetArgData(); if (val) { if (linkColourString) @@ -2501,14 +2756,13 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) linkColourString = copystring(val); } } - return FALSE; - break; + return false; } case ltFOLLOWEDLINKCOLOUR: { if (start) { - char *val = GetArgData(); + wxChar *val = GetArgData(); if (val) { if (followedLinkColourString) @@ -2516,40 +2770,38 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) followedLinkColourString = copystring(val); } } - return FALSE; - break; + return false; } case ltACCENT_CADILLA: { if (start) { - char *val = GetArgData(); + wxChar *val = GetArgData(); if (val) { switch (val[0]) { case 'c': - TexOutput("ç"); + TexOutput(_T("ç")); break; case 'C': - TexOutput("Ç"); + TexOutput(_T("Ç")); break; default: break; } } } - return FALSE; - break; + return false; } /* case ltFOOTNOTE: case ltFOOTNOTEPOPUP: { if (arg_no == 1) - return TRUE; + return true; else - return FALSE; + return false; break; } */ @@ -2561,41 +2813,41 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) if (start) { currentRowNumber = 0; - inTabular = TRUE; - startRows = TRUE; - tableVerticalLineLeft = FALSE; - tableVerticalLineRight = FALSE; - int currentWidth = 0; + inTabular = true; + startRows = true; + tableVerticalLineLeft = false; + tableVerticalLineRight = false; - char *alignString = copystring(GetArgData()); + wxChar *alignString = copystring(GetArgData()); ParseTableArgument(alignString); - TexOutput("\n"); + TexOutput(_T("
    \n")); // Write the first row formatting for compatibility // with standard Latex if (compatibilityMode) { - TexOutput("\n\n
    "); + TexOutput(_T("
    ")); + OutputFont(); /* for (int i = 0; i < noColumns; i++) { currentWidth += TableData[i].width; - sprintf(buf, "\\cellx%d", currentWidth); + wxSnprintf(buf, sizeof(buf), _T("\\cellx%d"), currentWidth); TexOutput(buf); } - TexOutput("\\pard\\intbl\n"); + TexOutput(_T("\\pard\\intbl\n")); */ } delete[] alignString; - return FALSE; + return false; } } else if (arg_no == 2 && !start) { - TexOutput("
    \n"); - inTabular = FALSE; + TexOutput(_T("\n")); + inTabular = false; } break; } @@ -2603,60 +2855,62 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) { if (start && (arg_no == 1)) { - ReopenFile(&Chapters, &ChaptersName); - AddTexRef("bibliography", ChaptersName, "bibliography"); - SetCurrentSubsectionName("bibliography", ChaptersName); + ReopenFile(&Chapters, &ChaptersName, _T("bibliography")); + AddTexRef(_T("bibliography"), ChaptersName, _T("bibliography")); + SetCurrentSubsectionName(_T("bibliography"), ChaptersName); citeCount = 1; SetCurrentOutput(Chapters); - char titleBuf[150]; + wxChar titleBuf[150]; if (truncateFilenames) - sprintf(titleBuf, "%s.htm", FileNameFromPath(FileRoot)); + wxSnprintf(titleBuf, sizeof(titleBuf), _T("%s.htm"), wxFileNameFromPath(FileRoot)); else - sprintf(titleBuf, "%s_contents.html", FileNameFromPath(FileRoot)); + wxSnprintf(titleBuf, sizeof(titleBuf), _T("%s_contents.html"), wxFileNameFromPath(FileRoot)); - TexOutput(""); + HTMLHead(); + TexOutput(_T("<title>")); TexOutput(ReferencesNameString); - TexOutput("\n"); + TexOutput(_T("\n")); OutputBodyStart(); - fprintf(Chapters, "\n

    %s", "bibliography", ReferencesNameString); - AddBrowseButtons("contents", titleBuf, // Up + wxFprintf(Chapters, _T("\n

    %s"), _T("bibliography"), ReferencesNameString); + AddBrowseButtons(_T("contents"), titleBuf, // Up lastTopic, lastFileName, // Last topic - "bibliography", ChaptersName); // This topic + _T("bibliography"), ChaptersName); // This topic SetCurrentOutputs(Contents, Chapters); - fprintf(Contents, "\n
  • ", ConvertCase(ChaptersName), "bibliography"); + if(PrimaryAnchorOfTheFile(ChaptersName, _T("bibliography"))) + wxFprintf(Contents, _T("\n
  • "), ConvertCase(ChaptersName)); + else + wxFprintf(Contents, _T("\n
  • "), ConvertCase(ChaptersName), _T("bibliography")); - fprintf(Contents, "%s\n", ReferencesNameString); - fprintf(Chapters, "
  • \n\n"); + wxFprintf(Contents, _T("%s\n"), ReferencesNameString); + wxFprintf(Chapters, _T("

    \n\n")); SetCurrentOutput(Chapters); - return FALSE; + return false; } if (!start && (arg_no == 2)) { } - return TRUE; - break; + return true; } case ltINDEX: { /* Build up list of keywords associated with topics */ if (start) { -// char *entry = GetArgData(); - char buf[300]; +// wxChar *entry = GetArgData(); + wxChar buf[300]; OutputChunkToString(GetArgChunk(), buf); if (CurrentTopic) { AddKeyWordForTopic(CurrentTopic, buf, currentFileName); } } - return FALSE; - break; + return false; } case ltFCOL: // case ltBCOL: @@ -2667,24 +2921,23 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) { case 1: { - char *name = GetArgData(); - char buf2[10]; + wxChar *name = GetArgData(); + wxChar buf2[10]; if (!FindColourHTMLString(name, buf2)) { - strcpy(buf2, "#000000"); - char buf[100]; - sprintf(buf, "Could not find colour name %s", name); + wxStrcpy(buf2, _T("#000000")); + wxChar buf[100]; + wxSnprintf(buf, sizeof(buf), _T("Could not find colour name %s"), name); OnError(buf); } - TexOutput(""); + TexOutput(_T("\">")); break; } case 2: { - return TRUE; - break; + return true; } default: break; @@ -2692,17 +2945,16 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) } else { - if (arg_no == 2) TexOutput(""); + if (arg_no == 2) TexOutput(_T("")); } - return FALSE; - break; + return false; } case ltINSERTATLEVEL: { // This macro allows you to insert text at a different level // from the current level, e.g. into the Sections from within a subsubsection. if (useWord) - return FALSE; + return false; static int currentLevelNo = 1; static FILE* oldLevelFile = Chapters; if (start) @@ -2713,8 +2965,8 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) { oldLevelFile = CurrentOutput1; - char *str = GetArgData(); - currentLevelNo = atoi(str); + wxChar *str = GetArgData(); + currentLevelNo = wxAtoi(str); FILE* outputFile; // TODO: cope with article style (no chapters) switch (currentLevelNo) @@ -2747,18 +2999,16 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) } if (outputFile) CurrentOutput1 = outputFile; - return FALSE; - break; + return false; } case 2: { - return TRUE; - break; + return true; } default: break; } - return TRUE; + return true; } else { @@ -2766,257 +3016,259 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) { CurrentOutput1 = oldLevelFile; } - return TRUE; + return true; } } default: return DefaultOnArgument(macroId, arg_no, start); - break; } - return TRUE; + return true; } bool HTMLGo(void) { - fileId = 0; - inVerbatim = FALSE; - indentLevel = 0; - inTabular = FALSE; - startRows = FALSE; - tableVerticalLineLeft = FALSE; - tableVerticalLineRight = FALSE; - noColumns = 0; - - if (InputFile && OutputFile) - { - // Do some HTML-specific transformations on all the strings, - // recursively - Text2HTML(GetTopLevelChunk()); - - char buf[300]; - if (truncateFilenames) - sprintf(buf, "%s.htm", FileRoot); - else - sprintf(buf, "%s_contents.html", FileRoot); - if (TitlepageName) delete[] TitlepageName; - TitlepageName = copystring(buf); - Titlepage = fopen(buf, "w"); + fileId = 0; + inVerbatim = false; + indentLevel = 0; + inTabular = false; + startRows = false; + tableVerticalLineLeft = false; + tableVerticalLineRight = false; + noColumns = 0; + + if (!InputFile.empty() && !OutputFile.empty()) + { + // Do some HTML-specific transformations on all the strings, + // recursively + Text2HTML(GetTopLevelChunk()); + + wxChar buf[300]; + if (truncateFilenames) + wxSnprintf(buf, sizeof(buf), _T("%s.htm"), FileRoot); + else + wxSnprintf(buf, sizeof(buf), _T("%s_contents.html"), FileRoot); + if (TitlepageName) delete[] TitlepageName; + TitlepageName = copystring(buf); + Titlepage = wxFopen(buf, _T("w")); - if (truncateFilenames) - sprintf(buf, "%s_fc.htm", FileRoot); - else - sprintf(buf, "%s_fcontents.html", FileRoot); + if (truncateFilenames) + wxSnprintf(buf, sizeof(buf), _T("%s_fc.htm"), FileRoot); + else + wxSnprintf(buf, sizeof(buf), _T("%s_fcontents.html"), FileRoot); - contentsFrameName = copystring(buf); + contentsFrameName = copystring(buf); - Contents = fopen(TmpContentsName, "w"); + Contents = wxFopen(TmpContentsName, _T("w")); - if (htmlFrameContents) - { -// FrameContents = fopen(TmpFrameContentsName, "w"); - FrameContents = fopen(contentsFrameName, "w"); - fprintf(FrameContents, "\n
      \n"); - } + if (htmlFrameContents) + { +// FrameContents = wxFopen(TmpFrameContentsName, _T("w")); + FrameContents = wxFopen(contentsFrameName, _T("w")); + wxFprintf(FrameContents, _T("\n
        \n")); + } - if (!Titlepage || !Contents) - { - OnError("Cannot open output file!"); - return FALSE; - } - AddTexRef("contents", FileNameFromPath(TitlepageName), ContentsNameString); + if (!Titlepage || !Contents) + { + OnError(_T("Cannot open output file!")); + return false; + } + AddTexRef(_T("contents"), wxFileNameFromPath(TitlepageName), ContentsNameString); - fprintf(Contents, "

        %s

        \n", ContentsNameString); + wxFprintf(Contents, _T("

        %s

        \n"), ContentsNameString); - fprintf(Contents, "

          \n"); + wxFprintf(Contents, _T("
            \n")); - SetCurrentOutput(Titlepage); - if (htmlWorkshopFiles) HTMLWorkshopStartContents(); - OnInform("Converting..."); + SetCurrentOutput(Titlepage); + if (htmlWorkshopFiles) HTMLWorkshopStartContents(); + OnInform(_T("Converting...")); - TraverseDocument(); - fprintf(Contents, "
          \n\n"); + TraverseDocument(); + wxFprintf(Contents, _T("
        \n\n")); -// SetCurrentOutput(Titlepage); - fclose(Titlepage); +// SetCurrentOutput(Titlepage); + fclose(Titlepage); - if (Contents) - { -// fprintf(Titlepage, "\n\n"); - fclose(Contents); - Contents = NULL; - } - - if (FrameContents) - { - fprintf(FrameContents, "\n
      \n"); - fprintf(FrameContents, "\n"); - fclose(FrameContents); - FrameContents = NULL; - } + if (Contents) + { +// wxFprintf(Titlepage, _T("\n\n")); + fclose(Contents); + Contents = NULL; + } - if (Chapters) - { - fprintf(Chapters, "\n\n"); - fclose(Chapters); - Chapters = NULL; - } - if (Sections) - { - fprintf(Sections, "\n\n"); - fclose(Sections); - Sections = NULL; - } - if (Subsections && !combineSubSections) - { - fprintf(Subsections, "\n\n"); - fclose(Subsections); - Subsections = NULL; - } - if (Subsubsections && !combineSubSections) - { - fprintf(Subsubsections, "\n\n"); - fclose(Subsubsections); - Subsubsections = NULL; - } - if ( SectionContentsFD ) - { - fclose(SectionContentsFD); - SectionContentsFD = NULL; - } + if (FrameContents) + { + wxFprintf(FrameContents, _T("\n
    \n")); + wxFprintf(FrameContents, _T("\n")); + fclose(FrameContents); + FrameContents = NULL; + } - // Create a temporary file for the title page header, add some info, - // and concat the titlepage just generated. - // This is necessary in order to put the title of the document - // at the TOP of the file within , even though we only find out - // what it is later on. - FILE *tmpTitle = fopen("title.tmp", "w"); - if (tmpTitle) - { - if (DocumentTitle) - { - SetCurrentOutput(tmpTitle); - TexOutput("\n\n"); - TraverseChildrenFromChunk(DocumentTitle); - TexOutput("\n"); - } - else - { - SetCurrentOutput(tmpTitle); - if (contentsString) - fprintf(tmpTitle, "%s\n\n", contentsString); - else - fprintf(tmpTitle, "%s\n\n", FileNameFromPath(FileRoot)); - } + if (Chapters) + { + wxFprintf(Chapters, _T("\n\n")); + fclose(Chapters); + Chapters = NULL; + } + if (Sections) + { + wxFprintf(Sections, _T("\n\n")); + fclose(Sections); + Sections = NULL; + } + if (Subsections && !combineSubSections) + { + wxFprintf(Subsections, _T("\n\n")); + fclose(Subsections); + Subsections = NULL; + } + if (Subsubsections && !combineSubSections) + { + wxFprintf(Subsubsections, _T("\n\n")); + fclose(Subsubsections); + Subsubsections = NULL; + } + if ( SectionContentsFD ) + { + fclose(SectionContentsFD); + SectionContentsFD = NULL; + } - // Output frame information - if (htmlFrameContents) - { - char firstFileName[300]; - if (truncateFilenames) - sprintf(firstFileName, "%s1.htm", FileRoot); - else - sprintf(firstFileName, "%s1.html", FileRoot); + // Create a temporary file for the title page header, add some info, + // and concat the titlepage just generated. + // This is necessary in order to put the title of the document + // at the TOP of the file within , even though we only find out + // what it is later on. + FILE *tmpTitle = wxFopen(_T("title.tmp"), _T("w")); + if (tmpTitle) + { + if (DocumentTitle) + { + SetCurrentOutput(tmpTitle); + HTMLHead(); + TexOutput(_T("\n")); + TraverseChildrenFromChunk(DocumentTitle); + TexOutput(_T("\n")); + } + else + { + SetCurrentOutput(tmpTitle); + HTMLHeadTo(tmpTitle); + if (contentsString) + wxFprintf(tmpTitle, _T("%s\n\n"), contentsString); + else + wxFprintf(tmpTitle, _T("%s\n\n"), wxFileNameFromPath(FileRoot)); + } - fprintf(tmpTitle, "\n"); + // Output frame information + if (htmlFrameContents) + { + wxChar firstFileName[300]; + if (truncateFilenames) + wxSnprintf(firstFileName, sizeof(firstFileName), _T("%s1.htm"), FileRoot); + else + wxStrcpy(firstFileName, gs_filenames[1].c_str()); - fprintf(tmpTitle, "\n", ConvertCase(FileNameFromPath(contentsFrameName))); - fprintf(tmpTitle, "\n", ConvertCase(FileNameFromPath(firstFileName))); - fprintf(tmpTitle, "\n"); + wxFprintf(tmpTitle, _T("\n")); - fprintf(tmpTitle, "\n"); - } + wxFprintf(tmpTitle, _T("<FRAME SRC=\"%s\">\n"), ConvertCase(wxFileNameFromPath(contentsFrameName))); + wxFprintf(tmpTitle, _T("<FRAME SRC=\"%s\" NAME=\"mainwindow\">\n"), ConvertCase(wxFileNameFromPath(firstFileName))); + wxFprintf(tmpTitle, _T("</FRAMESET>\n")); - // Output <BODY...> to temporary title page - OutputBodyStart(); + wxFprintf(tmpTitle, _T("<NOFRAMES>\n")); + } - // Concat titlepage - FILE *fd = fopen(TitlepageName, "r"); - if (fd) - { - int ch = getc(fd); - while (ch != EOF) - { - putc(ch, tmpTitle); - ch = getc(fd); - } - fclose(fd); - } + // Output <BODY...> to temporary title page + OutputBodyStart(); + fflush(tmpTitle); - fprintf(tmpTitle, "\n</BODY>\n"); + // Concat titlepage + FILE *fd = wxFopen(TitlepageName, _T("r")); + if (fd) + { + int ch = getc(fd); + while (ch != EOF) + { + wxPutc(ch, tmpTitle); + ch = getc(fd); + } + fclose(fd); + } - if (htmlFrameContents) - { - fprintf(tmpTitle, "\n\n"); - } - fprintf(tmpTitle, "\n\n"); + wxFprintf(tmpTitle, _T("\n\n")); - fclose(tmpTitle); - if (FileExists(TitlepageName)) wxRemoveFile(TitlepageName); - if (!wxRenameFile("title.tmp", TitlepageName)) - { - wxCopyFile("title.tmp", TitlepageName); - wxRemoveFile("title.tmp"); - } - } + if (htmlFrameContents) + { + wxFprintf(tmpTitle, _T("\n\n")); + } + wxFprintf(tmpTitle, _T("\n\n")); - if (lastFileName) delete[] lastFileName; - lastFileName = NULL; - if (lastTopic) delete[] lastTopic; - lastTopic = NULL; + fclose(tmpTitle); + if (wxFileExists(TitlepageName)) wxRemoveFile(TitlepageName); + if (!wxRenameFile(_T("title.tmp"), TitlepageName)) + { + wxCopyFile(_T("title.tmp"), TitlepageName); + wxRemoveFile(_T("title.tmp")); + } + } - if (FileExists(ContentsName)) wxRemoveFile(ContentsName); + if (lastFileName) delete[] lastFileName; + lastFileName = NULL; + if (lastTopic) delete[] lastTopic; + lastTopic = NULL; - if (!wxRenameFile(TmpContentsName, ContentsName)) - { - wxCopyFile(TmpContentsName, ContentsName); - wxRemoveFile(TmpContentsName); - } + if (wxFileExists(ContentsName)) wxRemoveFile(ContentsName); - // Generate .htx file if requested - if (htmlIndex) - { - char htmlIndexName[300]; - sprintf(htmlIndexName, "%s.htx", FileRoot); - GenerateHTMLIndexFile(htmlIndexName); - } + if (!wxRenameFile(TmpContentsName, ContentsName)) + { + wxCopyFile(TmpContentsName, ContentsName); + wxRemoveFile(TmpContentsName); + } - // Generate HTML Help Workshop files if requested - if (htmlWorkshopFiles) - { - HTMLWorkshopEndContents(); - GenerateHTMLWorkshopFiles(FileRoot); - } + // Generate .htx file if requested + if (htmlIndex) + { + wxChar htmlIndexName[300]; + wxSnprintf(htmlIndexName, sizeof(htmlIndexName), _T("%s.htx"), FileRoot); + GenerateHTMLIndexFile(htmlIndexName); + } + // Generate HTML Help Workshop files if requested + if (htmlWorkshopFiles) + { + HTMLWorkshopEndContents(); + GenerateHTMLWorkshopFiles(FileRoot); + } - return TRUE; - } + return true; + } - return FALSE; + return false; } // Output .htx index file -void GenerateHTMLIndexFile(char *fname) +void GenerateHTMLIndexFile(wxChar *fname) { - FILE *fd = fopen(fname, "w"); + FILE *fd = wxFopen(fname, _T("w")); if (!fd) return; TopicTable.BeginFind(); - wxNode *node = NULL; - while ((node = TopicTable.Next())) + wxHashTable::Node *node = TopicTable.Next(); + while (node) { - TexTopic *texTopic = (TexTopic *)node->Data(); - const char *topicName = node->GetKeyString(); + TexTopic *texTopic = (TexTopic *)node->GetData(); + const wxChar *topicName = node->GetKeyString(); if (texTopic->filename && texTopic->keywords) { - wxNode *node1 = texTopic->keywords->First(); + wxStringListNode *node1 = texTopic->keywords->GetFirst(); while (node1) { - char *s = (char *)node1->Data(); - fprintf(fd, "%s|%s|%s\n", topicName, texTopic->filename, s); - node1 = node1->Next(); + wxChar *s = (wxChar *)node1->GetData(); + wxFprintf(fd, _T("%s|%s|%s\n"), topicName, texTopic->filename, s); + node1 = node1->GetNext(); } } + node = TopicTable.Next(); } fclose(fd); } @@ -3030,98 +3282,101 @@ void GenerateHTMLIndexFile(char *fname) // output .hpp, .hhc and .hhk files: -void GenerateHTMLWorkshopFiles(char *fname) +void GenerateHTMLWorkshopFiles(wxChar *fname) { FILE *f; - char buf[300]; + wxChar buf[300]; /* Generate project file : */ - sprintf(buf, "%s.hhp", fname); - f = fopen(buf, "wt"); - fprintf(f, - "[OPTIONS]\n" - "Compatibility=1.1\n" - "Full-text search=Yes\n" - "Contents file=%s.hhc\n" - "Compiled file=%s.chm\n" - "Default Window=%sHelp\n" - "Default topic=%s\n" - "Index file=%s.hhk\n" - "Title=", - FileNameFromPath(fname), - FileNameFromPath(fname), - FileNameFromPath(fname), - FileNameFromPath(TitlepageName), - FileNameFromPath(fname) + wxSnprintf(buf, sizeof(buf), _T("%s.hhp"), fname); + f = wxFopen(buf, _T("wt")); + wxFprintf(f, + _T("[OPTIONS]\n") + _T("Compatibility=1.1\n") + _T("Full-text search=Yes\n") + _T("Contents file=%s.hhc\n") + _T("Compiled file=%s.chm\n") + _T("Default Window=%sHelp\n") + _T("Default topic=%s\n") + _T("Index file=%s.hhk\n") + _T("Title="), + wxFileNameFromPath(fname), + wxFileNameFromPath(fname), + wxFileNameFromPath(fname), + wxFileNameFromPath(TitlepageName), + wxFileNameFromPath(fname) ); if (DocumentTitle) { SetCurrentOutput(f); TraverseChildrenFromChunk(DocumentTitle); } - else fprintf(f, "(unknown)"); + else wxFprintf(f, _T("(unknown)")); - fprintf(f, "\n\n[WINDOWS]\n" - "%sHelp=,\"%s.hhc\",\"%s.hhk\",\"%s\",,,,,,0x2420,,0x380e,,,,,0,,,", - FileNameFromPath(fname), - FileNameFromPath(fname), - FileNameFromPath(fname), - FileNameFromPath(TitlepageName)); + wxFprintf(f, _T("\n\n[WINDOWS]\n") + _T("%sHelp=,\"%s.hhc\",\"%s.hhk\",\"%s\",,,,,,0x2420,,0x380e,,,,,0,,,"), + wxFileNameFromPath(fname), + wxFileNameFromPath(fname), + wxFileNameFromPath(fname), + wxFileNameFromPath(TitlepageName)); - fprintf(f, "\n\n[FILES]\n"); - fprintf(f, "%s\n", FileNameFromPath(TitlepageName)); + wxFprintf(f, _T("\n\n[FILES]\n")); + wxFprintf(f, _T("%s\n"), wxFileNameFromPath(TitlepageName)); for (int i = 1; i <= fileId; i++) { if (truncateFilenames) - sprintf(buf, "%s%d.htm", FileNameFromPath(FileRoot), i); + wxSnprintf(buf, sizeof(buf), _T("%s%d.htm"), wxFileNameFromPath(FileRoot), i); else - sprintf(buf, "%s%d.html", FileNameFromPath(FileRoot), i); - fprintf(f, "%s\n", buf); + wxStrcpy(buf, wxFileNameFromPath(gs_filenames[i].c_str())); + wxFprintf(f, _T("%s\n"), buf); } fclose(f); /* Generate index file : */ - sprintf(buf, "%s.hhk", fname); - f = fopen(buf, "wt"); - - fprintf(f, - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - " \n" - "\n" - "
      \n"); + wxSnprintf(buf, sizeof(buf), _T("%s.hhk"), fname); + f = wxFopen(buf, _T("wt")); + + wxFprintf(f, + _T("\n") + _T("\n")); + HTMLHeadTo(f); + wxFprintf(f, + _T("\n") + _T("\n") + _T("\n") + _T("\n") + _T("\n") + _T(" \n") + _T("\n") + _T("
        \n")); TopicTable.BeginFind(); - wxNode *node = NULL; - while ((node = TopicTable.Next())) + wxHashTable::Node *node = TopicTable.Next(); + while (node) { - TexTopic *texTopic = (TexTopic *)node->Data(); - const char *topicName = node->GetKeyString(); + TexTopic *texTopic = (TexTopic *)node->GetData(); + const wxChar *topicName = node->GetKeyString(); if (texTopic->filename && texTopic->keywords) { - wxNode *node1 = texTopic->keywords->First(); + wxStringListNode *node1 = texTopic->keywords->GetFirst(); while (node1) { - char *s = (char *)node1->Data(); - fprintf(f, - "
      • \n" - " \n" - " \n" - " \n", - texTopic->filename, topicName, s); - node1 = node1->Next(); + wxChar *s = (wxChar *)node1->GetData(); + wxFprintf(f, + _T("
      • \n") + _T(" \n") + _T(" \n") + _T(" \n"), + texTopic->filename, topicName, s); + node1 = node1->GetNext(); } } + node = TopicTable.Next(); } - fprintf(f, "
      \n"); + wxFprintf(f, _T("
    \n")); fclose(f); } @@ -3130,53 +3385,55 @@ void GenerateHTMLWorkshopFiles(char *fname) static FILE *HTMLWorkshopContents = NULL; static int HTMLWorkshopLastLevel = 0; -void HTMLWorkshopAddToContents(int level, char *s, char *file) +void HTMLWorkshopAddToContents(int level, wxChar *s, wxChar *file) { int i; if (level > HTMLWorkshopLastLevel) for (i = HTMLWorkshopLastLevel; i < level; i++) - fprintf(HTMLWorkshopContents, "
      "); + wxFprintf(HTMLWorkshopContents, _T("
        ")); if (level < HTMLWorkshopLastLevel) for (i = level; i < HTMLWorkshopLastLevel; i++) - fprintf(HTMLWorkshopContents, "
      "); + wxFprintf(HTMLWorkshopContents, _T("
    ")); SetCurrentOutput(HTMLWorkshopContents); - fprintf(HTMLWorkshopContents, - "
  • \n" - " \n" - " \n") + _T(" \n") + _T(" \n" - " \n"); + wxFprintf(HTMLWorkshopContents, + _T("\">\n") + _T(" \n")); HTMLWorkshopLastLevel = level; } void HTMLWorkshopStartContents() { - char buf[300]; - sprintf(buf, "%s.hhc", FileRoot); - HTMLWorkshopContents = fopen(buf, "wt"); + wxChar buf[300]; + wxSnprintf(buf, sizeof(buf), _T("%s.hhc"), FileRoot); + HTMLWorkshopContents = wxFopen(buf, _T("wt")); HTMLWorkshopLastLevel = 0; - fprintf(HTMLWorkshopContents, - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - " \n" - "\n" - "
      \n" - "
    • \n" - "\n" - "\n\n", - FileNameFromPath(TitlepageName) + wxFprintf(HTMLWorkshopContents, + _T("\n") + _T("\n")); + HTMLHeadTo(HTMLWorkshopContents); + wxFprintf(HTMLWorkshopContents, + _T("\n") + _T("\n") + _T("\n") + _T("\n") + _T("\n") + _T(" \n") + _T("\n") + _T("
        \n") + _T("
      • \n") + _T("\n") + _T("\n\n"), + wxFileNameFromPath(TitlepageName) ); } @@ -3184,7 +3441,15 @@ void HTMLWorkshopStartContents() void HTMLWorkshopEndContents() { - for (int i = HTMLWorkshopLastLevel; i >= 0; i--) - fprintf(HTMLWorkshopContents, "
      \n"); - fclose(HTMLWorkshopContents); + for (int i = HTMLWorkshopLastLevel; i >= 0; i--) + wxFprintf(HTMLWorkshopContents, _T("
    \n")); + fclose(HTMLWorkshopContents); +} + + +bool PrimaryAnchorOfTheFile( wxChar *file, wxChar *label ) +{ + wxString file_label; + file_label.Printf( HTML_FILENAME_PATTERN, FileRoot, label ); + return file_label.IsSameAs( file , false ); }