X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6453876e12bc1c214a8831d2931f916124f97df0..b6e5eaa59701315ca06996ff845872ca4122695f:/utils/tex2rtf/src/rtfutils.cpp diff --git a/utils/tex2rtf/src/rtfutils.cpp b/utils/tex2rtf/src/rtfutils.cpp index 93a6356748..49c710c82a 100644 --- a/utils/tex2rtf/src/rtfutils.cpp +++ b/utils/tex2rtf/src/rtfutils.cpp @@ -58,6 +58,11 @@ extern FILE *WinHelpContentsFile; extern char *RTFCharset; // This is defined in the Tex2Any library and isn't in use after parsing extern char *BigBuffer; + + +extern wxHashTable TexReferences; + + // Are we in verbatim mode? If so, format differently. static bool inVerbatim = FALSE; @@ -210,7 +215,7 @@ void OutputSectionKeyword(FILE *fd) { OutputCurrentSectionToString(wxBuffer); - int i; + unsigned int i; for (i = 0; i < strlen(wxBuffer); i++) if (wxBuffer[i] == ':') wxBuffer[i] = ' '; @@ -349,7 +354,7 @@ void GenerateKeywordsForTopic(char *topic) SplitIndexEntry(s, buf1, buf2); // Check for ':' which messes up index - int i; + unsigned int i; for (i = 0; i < strlen(buf1) ; i++) if (buf1[i] == ':') buf1[i] = ' '; @@ -662,7 +667,7 @@ void ProcessText2RTF(TexChunk *chunk) i += 1; changed = TRUE; } - else if (inVerbatim && (ch == '{' || ch == '}')) // Escape the curly bracket + else if (inVerbatim && (ch == '{' || ch == '}')) // Escape the curley bracket { BigBuffer[ptr] = '\\'; ptr ++; BigBuffer[ptr] = ch; ptr ++; @@ -3370,7 +3375,7 @@ bool RTFOnArgument(int macroId, int arg_no, bool start) else { TexOutput("??"); - sprintf(buf, "Warning: unresolved reference %s.", refName); + sprintf(buf, "Warning: unresolved reference '%s'", refName); OnInform(buf); } } @@ -3482,6 +3487,8 @@ bool RTFOnArgument(int macroId, int arg_no, bool start) // Convert points to TWIPS (1 twip = 1/20th of point) imageWidth = (int)(20*(tok1 ? ParseUnitArgument(tok1) : 0)); imageHeight = (int)(20*(tok2 ? ParseUnitArgument(tok2) : 0)); + if (imageDimensions) // glt + delete [] imageDimensions; return FALSE; } else if (start && (arg_no == 2 )) @@ -3556,6 +3563,8 @@ bool RTFOnArgument(int macroId, int arg_no, bool start) sprintf(buf, "Warning: could not find a BMP or WMF equivalent for %s.", filename); OnInform(buf); } + if (filename) // glt + delete [] filename; } else // linear RTF { @@ -5081,6 +5090,9 @@ bool RTFOnArgument(int macroId, int arg_no, bool start) bool RTFGo(void) { + if (stopRunning) + return FALSE; + // Reset variables indentLevel = 0; forbidParindent = 0; @@ -5155,6 +5167,9 @@ bool RTFGo(void) SetCurrentOutput(Chapters); + if (stopRunning) + return FALSE; + OnInform("Converting..."); TraverseDocument(); @@ -5218,8 +5233,28 @@ bool RTFGo(void) { wxConcatFiles("header.rtf", "chapters.rtf", "tmp1.rtf"); Tex2RTFYield(TRUE); - if (FileExists(OutputFile)) wxRemoveFile(OutputFile); - wxCopyFile("tmp1.rtf", OutputFile); + if (FileExists(OutputFile)) + wxRemoveFile(OutputFile); + + char *cwdStr; + cwdStr = wxGetWorkingDirectory(); + + wxString outputDirStr; + outputDirStr = wxPathOnly(OutputFile); + + // Determine if the temp file and the output file are in the same directory, + // and if they are, then just rename the temp file rather than copying + // it, as this is much faster when working with large (multi-megabyte files) + if ((wxStrcmp(outputDirStr.c_str(),"") == 0) || // no path specified on output file + (wxStrcmp(cwdStr,outputDirStr.c_str()) == 0)) // paths do not match + { + wxRenameFile("tmp1.rtf", OutputFile); + } + else + { + wxCopyFile("tmp1.rtf", OutputFile); + } + delete [] cwdStr; Tex2RTFYield(TRUE); wxRemoveFile("tmp1.rtf"); }