X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a29912f608e082001ee53b9873323c4bcd71f21..94e2ed3b8db0220160c0b939782cd46914ec073a:/utils/tex2rtf/src/htmlutil.cpp diff --git a/utils/tex2rtf/src/htmlutil.cpp b/utils/tex2rtf/src/htmlutil.cpp index a67bc10be4..c91ca52c9f 100644 --- a/utils/tex2rtf/src/htmlutil.cpp +++ b/utils/tex2rtf/src/htmlutil.cpp @@ -28,8 +28,18 @@ #include "tex2rtf.h" #include "table.h" + +extern wxHashTable TexReferences; + + extern void DecToHex(int, char *); void GenerateHTMLIndexFile(char *fname); + +void GenerateHTMLWorkshopFiles(char *fname); +void HTMLWorkshopAddToContents(int level, char *s, char *file); +void HTMLWorkshopStartContents(); +void HTMLWorkshopEndContents(); + void OutputContentsFrame(void); #include "readshg.h" // Segmented hypergraphics parsing @@ -70,6 +80,11 @@ static bool inTable = FALSE; // This is defined in the Tex2Any library. extern char *BigBuffer; +// DHS Two-column table dimensions. +static int TwoColWidthA = -1; +static int TwoColWidthB = -1; + + class HyperReference: public wxObject { public: @@ -125,7 +140,7 @@ void SetCurrentChapterName(char *s, char *file) CurrentChapterFile = copystring(file); currentFileName = CurrentChapterFile; - + SetCurrentTopic(s); } void SetCurrentSectionName(char *s, char *file) @@ -219,7 +234,7 @@ void ReopenSectionContentsFile(void) * converting Latex-isms into HTML-isms, such as 2 newlines ->
. * */ - + void ProcessText2HTML(TexChunk *chunk) { bool changed = FALSE; @@ -291,7 +306,7 @@ void ProcessText2HTML(TexChunk *chunk) * and before TraverseDocument is called. * */ - + void Text2HTML(TexChunk *chunk) { Tex2RTFYield(); @@ -368,7 +383,7 @@ void AddBrowseButtons(char *upLabel, char *upFilename, contentsReference = contentsReferenceBuf; sprintf(contentsReference, "", ConvertCase("contents.gif")); } - + char *upReference = NULL; if (htmlBrowseButtons == HTML_BUTTONS_TEXT) upReference = UpNameString; @@ -378,7 +393,7 @@ void AddBrowseButtons(char *upLabel, char *upFilename, upReference = upReferenceBuf; sprintf(upReference, "", ConvertCase("up.gif")); } - + char *backReference = NULL; if (htmlBrowseButtons == HTML_BUTTONS_TEXT) backReference = "<<"; @@ -388,7 +403,7 @@ void AddBrowseButtons(char *upLabel, char *upFilename, backReference = backReferenceBuf; sprintf(backReference, "", ConvertCase("back.gif")); } - + char *forwardReference = NULL; if (htmlBrowseButtons == HTML_BUTTONS_TEXT) forwardReference = ">>"; @@ -398,9 +413,9 @@ void AddBrowseButtons(char *upLabel, char *upFilename, forwardReference = forwardReferenceBuf; sprintf(forwardReference, "", ConvertCase("forward.gif")); } - + TexOutput("
\n"); - + SetCurrentOutput(Titlepage); } */ @@ -1688,7 +1714,7 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) { if (!suppressNameDecoration) TexOutput(""); } - + if (start && (arg_no == 3)) TexOutput("("); if (!start && (arg_no == 3)) @@ -1780,7 +1806,7 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) if (start) { char *sec = NULL; - + char *refName = GetArgData(); if (refName) { @@ -1881,6 +1907,9 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) if (helpRefText) TraverseChildrenFromChunk(helpRefText); TexOutput(" (REF NOT FOUND)"); + wxString errBuf; + errBuf.Printf("Warning: unresolved reference '%s'", refName); + OnInform((char *)errBuf.c_str()); } } else TexOutput("??"); @@ -1903,11 +1932,11 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) alignment = " align=left"; else if (macroId == ltIMAGER) alignment = " align=right"; - + // Try to find an XBM or GIF image first. char *filename = copystring(GetArgData()); char buf[500]; - + strcpy(buf, filename); StripExtension(buf); strcat(buf, ".xbm"); @@ -1920,6 +1949,23 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) strcat(buf, ".gif"); f = TexPathList.FindValidPath(buf); } + + if (f == "") // Try for a JPEG instead + { + strcpy(buf, filename); + StripExtension(buf); + strcat(buf, ".jpg"); + f = TexPathList.FindValidPath(buf); + } + + if (f == "") // Try for a PNG instead + { + strcpy(buf, filename); + StripExtension(buf); + strcat(buf, ".png"); + f = TexPathList.FindValidPath(buf); + } + if (f != "") { char *inlineFilename = copystring(f); @@ -1968,7 +2014,7 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) // Try to find an XBM or GIF image first. char *filename = copystring(GetArgData()); char buf[500]; - + strcpy(buf, filename); StripExtension(buf); strcat(buf, ".xbm"); @@ -1991,7 +2037,7 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) if (imageFile) delete[] imageFile; imageFile = NULL; - if (f) + if (!f.IsEmpty()) { imageFile = copystring(f); } @@ -2059,17 +2105,29 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) */ if (arg_no == 1) { - if ( start ) - TexOutput("\n
\n"); break; } + // DHS + case ltTWOCOLWIDTHA: + { + if (start) + { + char *val = GetArgData(); + float points = ParseUnitArgument(val); + TwoColWidthA = (int)((points * 100.0) / 72.0); + } + return FALSE; + break; + } + // DHS + case ltTWOCOLWIDTHB: + { + if (start) + { + char *val = GetArgData(); + float points = ParseUnitArgument(val); + TwoColWidthB = (int)((points * 100.0) / 72.0); + } + return FALSE; + break; + } /* * Accents * @@ -2522,7 +2604,7 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) return FALSE; break; } -*/ +*/ case ltTABULAR: case ltSUPERTABULAR: { @@ -2771,7 +2853,7 @@ bool HTMLGo(void) if (TitlepageName) delete[] TitlepageName; TitlepageName = copystring(buf); Titlepage = fopen(buf, "w"); - + if (truncateFilenames) sprintf(buf, "%s_fc.htm", FileRoot); else @@ -2800,6 +2882,7 @@ bool HTMLGo(void) fprintf(Contents, "