X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8efab359f7a198a5ba4607199bb5d98051735556..17dcec6308b66bfcd51d7e5515e9bb284a179dc9:/utils/tex2rtf/src/tex2rtf.cpp diff --git a/utils/tex2rtf/src/tex2rtf.cpp b/utils/tex2rtf/src/tex2rtf.cpp index 55f736ae0d..281acafa0c 100644 --- a/utils/tex2rtf/src/tex2rtf.cpp +++ b/utils/tex2rtf/src/tex2rtf.cpp @@ -25,8 +25,8 @@ #endif #ifndef NO_GUI -#include -#include +#include "wx/help.h" +#include "wx/timer.h" #endif #if defined(NO_GUI) || defined(__UNIX__) @@ -44,12 +44,13 @@ #include "tex2any.h" #include "tex2rtf.h" #include "rtfutils.h" +#include "symbols.h" -#if (defined(__WXGTK__) || defined(__WXMOTIF__)) && !defined(NO_GUI) +#if (defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__)) && !defined(NO_GUI) #include "tex2rtf.xpm" #endif -const float versionNo = 2.0; +const float versionNo = TEX2RTF_VERSION_NUMBER; TexChunk *currentMember = NULL; bool startedSections = FALSE; @@ -119,7 +120,7 @@ char *ContentsName = NULL; // Contents page from last time around char *TmpContentsName = NULL; // Current contents page char *TmpFrameContentsName = NULL; // Current frame contents page char *WinHelpContentsFileName = NULL; // WinHelp .cnt file -char *RefName = NULL; // Reference file name +char *RefFileName = NULL; // Reference file name char *RTFCharset = copystring("ansi"); @@ -132,13 +133,9 @@ int BufSize = 500; bool Go(void); void ShowOptions(void); -#ifdef NO_GUI +char wxTex2RTFBuffer[1500]; -#if wxUSE_GUI || !defined(__UNIX__) -// wxBase for Unix does not have wxBuffer -extern -#endif -char *wxBuffer; // we must init it, otherwise tex2rtf will crash +#ifdef NO_GUI int main(int argc, char **argv) #else @@ -161,7 +158,7 @@ bool MyApp::OnInit() TmpContentsName = new char[300]; TmpFrameContentsName = new char[300]; WinHelpContentsFileName = new char[300]; - RefName = new char[300]; + RefFileName = new char[300]; ColourTable.DeleteContents(TRUE); @@ -187,12 +184,9 @@ bool MyApp::OnInit() } #ifdef NO_GUI - wxBuffer = new char[1500]; - // this is done in wxApp, but NO_GUI version doesn't call it :-( - if (!InputFile || !OutputFile) { - cout << "Tex2RTF: input or output file is missing.\n"; + wxSTD cout << "Tex2RTF: input or output file is missing.\n"; ShowOptions(); exit(1); } @@ -336,7 +330,7 @@ bool MyApp::OnInit() if (InputFile) { - sprintf(buf, "Tex2RTF [%s]", FileNameFromPath(InputFile)); + sprintf(buf, "Tex2RTF [%s]", wxFileNameFromPath(InputFile)); frame->SetTitle(buf); } @@ -387,7 +381,7 @@ bool MyApp::OnInit() frame->SetMenuBar(menuBar); frame->textWindow = new wxTextCtrl(frame, -1, "", wxPoint(-1, -1), wxSize(-1, -1), wxTE_READONLY|wxTE_MULTILINE); - (*frame->textWindow) << "Welcome to Julian Smart's LaTeX to RTF converter.\n"; + (*frame->textWindow) << "Welcome to Tex2RTF.\n"; // ShowOptions(); #if wxUSE_HELP @@ -446,7 +440,6 @@ bool MyApp::OnInit() // Return the main frame window return TRUE; #else - delete[] wxBuffer; return FALSE; #endif } @@ -530,10 +523,10 @@ int MyApp::OnExit() delete WinHelpContentsFileName; WinHelpContentsFileName = NULL; } - if (RefName) + if (RefFileName) { - delete RefName; - RefName = NULL; + delete RefFileName; + RefFileName = NULL; } if (TopLevel) { @@ -591,7 +584,9 @@ void ShowOptions(void) OnInform(buf); OnInform("Usage: tex2rtf [input] [output] [switches]\n"); OnInform("where valid switches are"); +#ifndef NO_GUI OnInform(" -interactive"); +#endif OnInform(" -bufsize "); OnInform(" -charset (default ansi)"); OnInform(" -twice"); @@ -665,7 +660,16 @@ void MyFrame::OnGo(wxCommandEvent& event) Tex2RTFYield(TRUE); Go(); - if (runTwice) + if (stopRunning) + { + SetStatusText("Build aborted!"); + wxString errBuf; + errBuf.Printf("\nErrors encountered during this pass: %lu\n", errorCount); + OnInform((char *)errBuf.c_str()); + } + + + if (runTwice && !stopRunning) { Tex2RTFYield(TRUE); Go(); @@ -826,7 +830,7 @@ void MyFrame::OnAbout(wxCommandEvent& event) char *platform = ""; #endif #endif - sprintf(buf, "Tex2RTF Version %.2f%s\nLaTeX to RTF, WinHelp, HTML and wxHelp Conversion\n\n(c) Julian Smart 1999", versionNo, platform); + sprintf(buf, "Tex2RTF Version %.2f%s\nLaTeX to RTF, WinHelp, and HTML Conversion\n\n(c) Julian Smart, George Tasker and others, 1999-2002", versionNo, platform); wxMessageBox(buf, "About Tex2RTF"); } @@ -907,7 +911,7 @@ bool Go(void) ChooseOutputFile(); #endif - if (!InputFile || !OutputFile) + if (!InputFile || !OutputFile || stopRunning) return FALSE; #ifndef NO_GUI @@ -943,7 +947,7 @@ bool Go(void) sprintf(TmpContentsName, "%s.cn1", FileRoot); sprintf(TmpFrameContentsName, "%s.frc", FileRoot); sprintf(WinHelpContentsFileName, "%s.cnt", FileRoot); - sprintf(RefName, "%s.ref", FileRoot); + sprintf(RefFileName, "%s.ref", FileRoot); TexPathList.EnsureFileAccessible(InputFile); if (!bulletFile) @@ -956,14 +960,14 @@ bool Go(void) } } - if (wxFileExists(RefName)) - ReadTexReferences(RefName); + if (wxFileExists(RefFileName)) + ReadTexReferences(RefFileName); bool success = FALSE; if (InputFile && OutputFile) { - if (!FileExists(InputFile)) + if (!wxFileExists(InputFile)) { OnError("Cannot open input file!"); TexCleanUp(); @@ -981,6 +985,12 @@ bool Go(void) OnInform("Reading LaTeX file..."); TexLoadFile(InputFile); + if (stopRunning) + { + OkToClose = TRUE; + return FALSE; + } + switch (convertMode) { case TEX_RTF: @@ -1005,11 +1015,12 @@ bool Go(void) OnInform("*** Aborted by user."); success = FALSE; stopRunning = FALSE; + OkToClose = TRUE; } if (success) { - WriteTexReferences(RefName); + WriteTexReferences(RefFileName); TexCleanUp(); startedSections = FALSE; @@ -1057,36 +1068,36 @@ bool Go(void) return FALSE; } -void OnError(char *msg) +void OnError(const char *msg) { errorCount++; #ifdef NO_GUI - cerr << "Error: " << msg << "\n"; - cerr.flush(); + wxSTD cerr << "Error: " << msg << "\n"; + wxSTD cerr.flush(); #else if (isInteractive && frame) (*frame->textWindow) << "Error: " << msg << "\n"; else #ifdef __UNIX__ { - cerr << "Error: " << msg << "\n"; - cerr.flush(); + wxSTD cerr << "Error: " << msg << "\n"; + wxSTD cerr.flush(); } #endif #ifdef __WXMSW__ - wxError(msg); + wxLogError(msg); #endif Tex2RTFYield(TRUE); #endif // NO_GUI } -void OnInform(char *msg) +void OnInform(const char *msg) { #ifdef NO_GUI - cout << msg << "\n"; - cout.flush(); + wxSTD cout << msg << "\n"; + wxSTD cout.flush(); #else if (isInteractive && frame) (*frame->textWindow) << msg << "\n"; @@ -1098,8 +1109,8 @@ void OnInform(char *msg) else #ifdef __WXMSW__ { - cout << msg << "\n"; - cout.flush(); + wxSTD cout << msg << "\n"; + wxSTD cout.flush(); } #endif #ifdef __WXMSW__ @@ -1312,7 +1323,7 @@ char *Tex2RTFConnection::OnRequest(const wxString& topic, const wxString& item, #ifndef NO_GUI #ifndef __WXGTK__ -//void wxObject::Dump(ostream& str) +//void wxObject::Dump(wxSTD ostream& str) //{ // if (GetClassInfo() && GetClassInfo()->GetClassName()) // str << GetClassInfo()->GetClassName();