X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f6bcfd974ef26faf6f91a62cac09827e09463fd1..ceec2216bd3c65103e51a4ed9927f90fc1291d9c:/utils/tex2rtf/src/tex2rtf.cpp diff --git a/utils/tex2rtf/src/tex2rtf.cpp b/utils/tex2rtf/src/tex2rtf.cpp index 88d23ff9c8..6e157386e3 100644 --- a/utils/tex2rtf/src/tex2rtf.cpp +++ b/utils/tex2rtf/src/tex2rtf.cpp @@ -2,7 +2,8 @@ // Name: tex2rtf.cpp // Purpose: Converts Latex to linear/WinHelp RTF, HTML, wxHelp. // Author: Julian Smart -// Modified by: +// Modified by: Wlodzimiez ABX Skiba 2003/2004 Unicode support +// Ron Lee // Created: 7.9.93 // RCS-ID: $Id$ // Copyright: (c) Julian Smart @@ -21,15 +22,26 @@ #endif #ifndef WX_PRECOMP -#include "wx/wx.h" + #ifndef NO_GUI + #include "wx/menu.h" + #include "wx/textctrl.h" + #include "wx/filedlg.h" + #include "wx/msgdlg.h" + #endif #endif #ifndef NO_GUI -#include -#include -#endif + #include "wx/timer.h" + #include "wx/help.h" + #include "wx/cshelp.h" + #include "wx/helphtml.h" + #ifdef __WXMSW__ + #include "wx/msw/helpchm.h" + #else + #include "wx/html/helpctrl.h" + #endif +#endif // !NO_GUI -#if defined(NO_GUI) || defined(__UNIX__) #if wxUSE_IOSTREAMH #include #include @@ -37,41 +49,55 @@ #include #include #endif -#endif #include #include #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(__WXX11__)) && !defined(NO_GUI) #include "tex2rtf.xpm" #endif -const float versionNo = 2.0; +#if !WXWIN_COMPATIBILITY_2_4 +static inline wxChar* copystring(const wxChar* s) + { return wxStrcpy(new wxChar[wxStrlen(s) + 1], s); } +#endif + +const float versionNo = (float)TEX2RTF_VERSION_NUMBER; TexChunk *currentMember = NULL; -bool startedSections = FALSE; -char *contentsString = NULL; -bool suppressNameDecoration = FALSE; -bool OkToClose = TRUE; +bool startedSections = false; +wxChar *contentsString = NULL; +bool suppressNameDecoration = false; +bool OkToClose = true; int passNumber = 1; +unsigned long errorCount = 0; #ifndef NO_GUI +extern wxChar *BigBuffer; +extern wxChar *TexFileRoot; +extern wxChar *TexBibName; // Bibliography output file name +extern wxChar *TexTmpBibName; // Temporary bibliography output file name +extern wxList ColourTable; +extern TexChunk *TopLevel; + #if wxUSE_HELP -wxHelpController *HelpInstance = NULL; +wxHelpControllerBase *HelpInstance = NULL; #endif // wxUSE_HELP #ifdef __WXMSW__ -static char *ipc_buffer = NULL; -static char Tex2RTFLastStatus[100]; +static wxChar *ipc_buffer = NULL; +static wxChar Tex2RTFLastStatus[100]; Tex2RTFServer *TheTex2RTFServer = NULL; -#endif -#endif +#endif // __WXMSW__ -char *bulletFile = NULL; +#endif // !NO_GUI + +wxChar *bulletFile = NULL; FILE *Contents = NULL; // Contents page FILE *Chapters = NULL; // Chapters (WinHelp RTF) or rest of file (linear RTF) @@ -81,18 +107,18 @@ FILE *Subsubsections = NULL; FILE *Popups = NULL; FILE *WinHelpContentsFile = NULL; -char *InputFile = NULL; -char *OutputFile = NULL; -char *MacroFile = copystring("tex2rtf.ini"); +wxChar *InputFile = NULL; +wxChar *OutputFile = NULL; +wxChar *MacroFile = copystring(_T("tex2rtf.ini")); -char *FileRoot = NULL; -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 +wxChar *FileRoot = NULL; +wxChar *ContentsName = NULL; // Contents page from last time around +wxChar *TmpContentsName = NULL; // Current contents page +wxChar *TmpFrameContentsName = NULL; // Current frame contents page +wxChar *WinHelpContentsFileName = NULL; // WinHelp .cnt file +wxChar *RefFileName = NULL; // Reference file name -char *RTFCharset = copystring("ansi"); +wxChar *RTFCharset = copystring(_T("ansi")); #ifdef __WXMSW__ int BufSize = 100; // Size of buffer in K @@ -103,36 +129,32 @@ int BufSize = 500; bool Go(void); void ShowOptions(void); -#ifdef NO_GUI +wxChar 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 - -int main(int argc, char **argv) +#ifdef NO_GUI + IMPLEMENT_APP_CONSOLE(MyApp) #else -wxMenuBar *menuBar = NULL; -MyFrame *frame = NULL; - -// DECLARE_APP(MyApp) -IMPLEMENT_APP(MyApp) + wxMenuBar *menuBar = NULL; + MyFrame *frame = NULL; + // DECLARE_APP(MyApp) + IMPLEMENT_APP(MyApp) +#endif // `Main program' equivalent, creating windows and returning main app frame bool MyApp::OnInit() -#endif { // Use default list of macros defined in tex2any.cc DefineDefaultMacros(); - AddMacroDef(ltHARDY, "hardy", 0); + AddMacroDef(ltHARDY, _T("hardy"), 0); - FileRoot = new char[300]; - ContentsName = new char[300]; - TmpContentsName = new char[300]; - TmpFrameContentsName = new char[300]; - WinHelpContentsFileName = new char[300]; - RefName = new char[300]; + FileRoot = new wxChar[300]; + ContentsName = new wxChar[300]; + TmpContentsName = new wxChar[300]; + TmpFrameContentsName = new wxChar[300]; + WinHelpContentsFileName = new wxChar[300]; + RefFileName = new wxChar[300]; + + WX_CLEAR_LIST(wxList,ColourTable); int n = 1; @@ -156,66 +178,63 @@ 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); } - #endif + if (InputFile) { TexPathList.EnsureFileAccessible(InputFile); } if (!InputFile || !OutputFile) - isInteractive = TRUE; + isInteractive = true; int i; for (i = n; i < argc;) { - if (strcmp(argv[i], "-winhelp") == 0) + if (wxStrcmp(argv[i], _T("-winhelp")) == 0) { i ++; convertMode = TEX_RTF; - winHelp = TRUE; + winHelp = true; } #ifndef NO_GUI - else if (strcmp(argv[i], "-interactive") == 0) + else if (wxStrcmp(argv[i], _T("-interactive")) == 0) { i ++; - isInteractive = TRUE; + isInteractive = true; } #endif - else if (strcmp(argv[i], "-sync") == 0) // Don't yield + else if (wxStrcmp(argv[i], _T("-sync")) == 0) // Don't yield { i ++; - isSync = TRUE; + isSync = true; } - else if (strcmp(argv[i], "-rtf") == 0) + else if (wxStrcmp(argv[i], _T("-rtf")) == 0) { i ++; convertMode = TEX_RTF; } - else if (strcmp(argv[i], "-html") == 0) + else if (wxStrcmp(argv[i], _T("-html")) == 0) { i ++; convertMode = TEX_HTML; } - else if (strcmp(argv[i], "-xlp") == 0) + else if (wxStrcmp(argv[i], _T("-xlp")) == 0) { i ++; convertMode = TEX_XLP; } - else if (strcmp(argv[i], "-twice") == 0) + else if (wxStrcmp(argv[i], _T("-twice")) == 0) { i ++; - runTwice = TRUE; + runTwice = true; } - else if (strcmp(argv[i], "-macros") == 0) + else if (wxStrcmp(argv[i], _T("-macros")) == 0) { i ++; if (i < argc) @@ -224,43 +243,53 @@ bool MyApp::OnInit() i ++; } } - else if (strcmp(argv[i], "-bufsize") == 0) + else if (wxStrcmp(argv[i], _T("-bufsize")) == 0) { i ++; if (i < argc) { - BufSize = atoi(argv[i]); + BufSize = wxAtoi(argv[i]); i ++; } } - else if (strcmp(argv[i], "-charset") == 0) + else if (wxStrcmp(argv[i], _T("-charset")) == 0) { i ++; if (i < argc) { - char *s = argv[i]; + wxChar *s = argv[i]; i ++; - if (strcmp(s, "ansi") == 0 || strcmp(s, "pc") == 0 || strcmp(s, "mac") == 0 || - strcmp(s, "pca") == 0) + if (wxStrcmp(s, _T("ansi")) == 0 || wxStrcmp(s, _T("pc")) == 0 || wxStrcmp(s, _T("mac")) == 0 || + wxStrcmp(s, _T("pca")) == 0) RTFCharset = copystring(s); else { - OnError("Incorrect argument for -charset"); - return FALSE; + OnError(_T("Incorrect argument for -charset")); + return false; } } } + else if (wxStrcmp(argv[i], _T("-checkcurleybraces")) == 0) + { + i ++; + checkCurleyBraces = true; + } + else if (wxStrcmp(argv[i], _T("-checksyntax")) == 0) + { + i ++; + checkSyntax = true; + } else { - char buf[100]; - sprintf(buf, "Invalid switch %s.\n", argv[i]); - OnError(buf); - i++; + wxString buf; + buf.Printf(_T("Invalid switch %s.\n"), argv[i]); + OnError((wxChar *)buf.c_str()); #ifdef NO_GUI ShowOptions(); exit(1); +#else + return false; #endif - return FALSE; } } @@ -268,12 +297,7 @@ bool MyApp::OnInit() wxDDEInitialize(); Tex2RTFLastStatus[0] = 0; // DDE connection return value TheTex2RTFServer = new Tex2RTFServer; - TheTex2RTFServer->Create("TEX2RTF"); -#endif - -#if defined(__WXMSW__) && defined(__WIN16__) - // Limit to max Windows array size - if (BufSize > 64) BufSize = 64; + TheTex2RTFServer->Create(_T("TEX2RTF")); #endif TexInitialize(BufSize); @@ -283,11 +307,13 @@ bool MyApp::OnInit() if (isInteractive) { - char buf[100]; + wxChar buf[100]; // Create the main frame window - frame = new MyFrame(NULL, -1, "Tex2RTF", wxPoint(-1, -1), wxSize(400, 300)); + frame = new MyFrame(NULL, wxID_ANY, _T("Tex2RTF"), wxDefaultPosition, wxSize(400, 300)); +#if wxUSE_STATUSBAR frame->CreateStatusBar(2); +#endif // wxUSE_STATUSBAR // Give it an icon // TODO: uncomment this when we have tex2rtf.xpm @@ -295,54 +321,67 @@ bool MyApp::OnInit() if (InputFile) { - sprintf(buf, "Tex2RTF [%s]", FileNameFromPath(InputFile)); + wxSnprintf(buf, sizeof(buf), _T("Tex2RTF [%s]"), wxFileNameFromPath(InputFile)); frame->SetTitle(buf); } // Make a menubar wxMenu *file_menu = new wxMenu; - file_menu->Append(TEX_GO, "&Go", "Run converter"); - file_menu->Append(TEX_SET_INPUT, "Set &Input File", "Set the LaTeX input file"); - file_menu->Append(TEX_SET_OUTPUT, "Set &Output File", "Set the output file"); + file_menu->Append(TEX_GO, _T("&Go"), _T("Run converter")); + file_menu->Append(TEX_SET_INPUT, _T("Set &Input File"), _T("Set the LaTeX input file")); + file_menu->Append(TEX_SET_OUTPUT, _T("Set &Output File"), _T("Set the output file")); file_menu->AppendSeparator(); - file_menu->Append(TEX_VIEW_LATEX, "View &LaTeX File", "View the LaTeX input file"); - file_menu->Append(TEX_VIEW_OUTPUT, "View Output &File", "View output file"); - file_menu->Append(TEX_SAVE_FILE, "&Save log file", "Save displayed text into file"); + file_menu->Append(TEX_VIEW_LATEX, _T("View &LaTeX File"), _T("View the LaTeX input file")); + file_menu->Append(TEX_VIEW_OUTPUT, _T("View Output &File"), _T("View output file")); + file_menu->Append(TEX_SAVE_FILE, _T("&Save log file"), _T("Save displayed text into file")); file_menu->AppendSeparator(); - file_menu->Append(TEX_QUIT, "E&xit", "Exit Tex2RTF"); + file_menu->Append(TEX_QUIT, _T("E&xit"), _T("Exit Tex2RTF")); wxMenu *macro_menu = new wxMenu; - macro_menu->Append(TEX_LOAD_CUSTOM_MACROS, "&Load Custom Macros", "Load custom LaTeX macro file"); - macro_menu->Append(TEX_VIEW_CUSTOM_MACROS, "View &Custom Macros", "View custom LaTeX macros"); + macro_menu->Append(TEX_LOAD_CUSTOM_MACROS, _T("&Load Custom Macros"), _T("Load custom LaTeX macro file")); + macro_menu->Append(TEX_VIEW_CUSTOM_MACROS, _T("View &Custom Macros"), _T("View custom LaTeX macros")); wxMenu *mode_menu = new wxMenu; - mode_menu->Append(TEX_MODE_RTF, "Output linear &RTF", "Wordprocessor-compatible RTF"); - mode_menu->Append(TEX_MODE_WINHELP, "Output &WinHelp RTF", "WinHelp-compatible RTF"); - mode_menu->Append(TEX_MODE_HTML, "Output &HTML", "HTML World Wide Web hypertext file"); - mode_menu->Append(TEX_MODE_XLP, "Output &XLP", "wxHelp hypertext help file"); + mode_menu->Append(TEX_MODE_RTF, _T("Output linear &RTF"), _T("Wordprocessor-compatible RTF")); + mode_menu->Append(TEX_MODE_WINHELP, _T("Output &WinHelp RTF"), _T("WinHelp-compatible RTF")); + mode_menu->Append(TEX_MODE_HTML, _T("Output &HTML"), _T("HTML World Wide Web hypertext file")); + mode_menu->Append(TEX_MODE_XLP, _T("Output &XLP"), _T("wxHelp hypertext help file")); + + wxMenu *options_menu = new wxMenu; + + options_menu->Append(TEX_OPTIONS_CURLEY_BRACE, _T("Curley brace matching"), _T("Checks for mismatched curley braces"),true); + options_menu->Append(TEX_OPTIONS_SYNTAX_CHECKING, _T("Syntax checking"), _T("Syntax checking for common errors"),true); + + options_menu->Check(TEX_OPTIONS_CURLEY_BRACE, checkCurleyBraces); + options_menu->Check(TEX_OPTIONS_SYNTAX_CHECKING, checkSyntax); wxMenu *help_menu = new wxMenu; - help_menu->Append(TEX_HELP, "&Help", "Tex2RTF Contents Page"); - help_menu->Append(TEX_ABOUT, "&About Tex2RTF", "About Tex2RTF"); + help_menu->Append(TEX_HELP, _T("&Help"), _T("Tex2RTF Contents Page")); + help_menu->Append(TEX_ABOUT, _T("&About Tex2RTF"), _T("About Tex2RTF")); menuBar = new wxMenuBar; - menuBar->Append(file_menu, "&File"); - menuBar->Append(macro_menu, "&Macros"); - menuBar->Append(mode_menu, "&Conversion Mode"); - menuBar->Append(help_menu, "&Help"); + menuBar->Append(file_menu, _T("&File")); + menuBar->Append(macro_menu, _T("&Macros")); + menuBar->Append(mode_menu, _T("&Conversion Mode")); + menuBar->Append(options_menu, _T("&Options")); + menuBar->Append(help_menu, _T("&Help")); frame->SetMenuBar(menuBar); - frame->textWindow = new wxTextCtrl(frame, -1, "", wxPoint(-1, -1), wxSize(-1, -1), wxTE_READONLY|wxTE_MULTILINE); + frame->textWindow = new wxTextCtrl(frame, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_READONLY|wxTE_MULTILINE); - (*frame->textWindow) << "Welcome to Julian Smart's LaTeX to RTF converter.\n"; + (*frame->textWindow) << _T("Welcome to Tex2RTF.\n"); // ShowOptions(); #if wxUSE_HELP - HelpInstance = new wxHelpController(); - HelpInstance->Initialize("tex2rtf"); +#if wxUSE_MS_HTML_HELP && !defined(__WXUNIVERSAL__) + HelpInstance = new wxCHMHelpController; +#else + HelpInstance = new wxHtmlHelpController; +#endif + HelpInstance->Initialize(_T("tex2rtf")); #endif // wxUSE_HELP /* @@ -350,23 +389,33 @@ bool MyApp::OnInit() * */ - wxString path; - if ((path = TexPathList.FindValidPath(MacroFile)) != "") - ReadCustomMacros((char*) (const char*) path); - - strcpy(buf, "In "); + wxString path = TexPathList.FindValidPath(MacroFile); + if (path != _T("")) + ReadCustomMacros((wxChar *)path.c_str()); - if (winHelp && (convertMode == TEX_RTF)) - strcat(buf, "WinHelp RTF"); - else if (!winHelp && (convertMode == TEX_RTF)) - strcat(buf, "linear RTF"); - else if (convertMode == TEX_HTML) strcat(buf, "HTML"); - else if (convertMode == TEX_XLP) strcat(buf, "XLP"); - strcat(buf, " mode."); +#if wxUSE_STATUSBAR + wxStrcpy(buf, _T("In ")); + switch (convertMode) + { + case TEX_RTF: + wxStrcat(buf, (winHelp) ? _T("WinHelp RTF") : _T("linear RTF")); + break; + case TEX_HTML: + wxStrcat(buf, _T("HTML")); + break; + case TEX_XLP: + wxStrcat(buf, _T("XLP")); + break; + default: + wxStrcat(buf, _T("unknown")); + break; + } + wxStrcat(buf, _T(" mode.")); frame->SetStatusText(buf, 1); +#endif // wxUSE_STATUSBAR - frame->Show(TRUE); - return TRUE; + frame->Show(true); + return true; } else #endif // NO_GUI @@ -376,46 +425,42 @@ bool MyApp::OnInit() * */ - wxString path; - if ((path = TexPathList.FindValidPath(MacroFile)) != "") - ReadCustomMacros((char*) (const char*) path); + wxString path = TexPathList.FindValidPath(MacroFile); + if (path != _T("")) + ReadCustomMacros((wxChar*)path.c_str()); Go(); - if (runTwice) Go(); + if (runTwice) + { + Go(); + } #ifdef NO_GUI - return 0; + return true; #else - return NULL; + OnExit(); // Do cleanup since OnExit won't be called now + return false; #endif } - -#ifndef NO_GUI - // Return the main frame window - return TRUE; -#else - delete[] wxBuffer; - return FALSE; -#endif } #ifndef NO_GUI int MyApp::OnExit() { - wxNode *node = CustomMacroList.First(); + wxNode *node = CustomMacroList.GetFirst(); while (node) { - CustomMacro *macro = (CustomMacro *)node->Data(); + CustomMacro *macro = (CustomMacro *)node->GetData(); delete macro; delete node; - node = CustomMacroList.First(); + node = CustomMacroList.GetFirst(); } MacroDefs.BeginFind(); - node = MacroDefs.Next(); - while (node) + wxHashTable::Node* mNode = MacroDefs.Next(); + while (mNode) { - TexMacroDef* def = (TexMacroDef*) node->Data(); + TexMacroDef* def = (TexMacroDef*) mNode->GetData(); delete def; - node = MacroDefs.Next(); + mNode = MacroDefs.Next(); } MacroDefs.Clear(); #ifdef __WXMSW__ @@ -427,10 +472,105 @@ int MyApp::OnExit() delete HelpInstance; #endif // wxUSE_HELP + if (BigBuffer) + { + delete BigBuffer; + BigBuffer = NULL; + } + if (currentArgData) + { + delete currentArgData; + currentArgData = NULL; + } + if (TexFileRoot) + { + delete TexFileRoot; + TexFileRoot = NULL; + } + if (TexBibName) + { + delete TexBibName; + TexBibName = NULL; + } + if (TexTmpBibName) + { + delete TexTmpBibName; + TexTmpBibName = NULL; + } + if (FileRoot) + { + delete FileRoot; + FileRoot = NULL; + } + if (ContentsName) + { + delete ContentsName; + ContentsName = NULL; + } + if (TmpContentsName) + { + delete TmpContentsName; + TmpContentsName = NULL; + } + if (TmpFrameContentsName) + { + delete TmpFrameContentsName; + TmpFrameContentsName = NULL; + } + if (WinHelpContentsFileName) + { + delete WinHelpContentsFileName; + WinHelpContentsFileName = NULL; + } + if (RefFileName) + { + delete RefFileName; + RefFileName = NULL; + } + if (TopLevel) + { + delete TopLevel; + TopLevel = NULL; + } + if (MacroFile) + { + delete MacroFile; + MacroFile = NULL; + } + if (RTFCharset) + { + delete RTFCharset; + RTFCharset = NULL; + } + + delete [] PageStyle; + delete [] BibliographyStyleString; + delete [] DocumentStyleString; + delete [] bitmapMethod; + delete [] backgroundColourString; + delete [] ContentsNameString; + delete [] AbstractNameString; + delete [] GlossaryNameString; + delete [] ReferencesNameString; + delete [] FiguresNameString; + delete [] TablesNameString; + delete [] FigureNameString; + delete [] TableNameString; + delete [] IndexNameString; + delete [] ChapterNameString; + delete [] SectionNameString; + delete [] SubsectionNameString; + delete [] SubsubsectionNameString; + delete [] UpNameString; + if (winHelpTitle) + delete[] winHelpTitle; + // TODO: this simulates zero-memory leaks! // Otherwise there are just too many... #ifndef __WXGTK__ +#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT wxDebugContext::SetCheckpoint(); +#endif #endif return 0; @@ -438,21 +578,25 @@ int MyApp::OnExit() #endif void ShowOptions(void) { - char buf[100]; - sprintf(buf, "Tex2RTF version %.2f", versionNo); + wxChar buf[100]; + wxSnprintf(buf, sizeof(buf), _T("Tex2RTF version %.2f"), versionNo); OnInform(buf); - OnInform("Usage: tex2rtf [input] [output] [switches]\n"); - OnInform("where valid switches are"); - OnInform(" -interactive"); - OnInform(" -bufsize "); - OnInform(" -charset (default ansi)"); - OnInform(" -twice"); - OnInform(" -sync"); - OnInform(" -macros "); - OnInform(" -winhelp"); - OnInform(" -rtf"); - OnInform(" -html"); - OnInform(" -xlp\n"); + OnInform(_T("Usage: tex2rtf [input] [output] [switches]\n")); + OnInform(_T("where valid switches are")); +#ifndef NO_GUI + OnInform(_T(" -interactive")); +#endif + OnInform(_T(" -bufsize ")); + OnInform(_T(" -charset (default ansi)")); + OnInform(_T(" -twice")); + OnInform(_T(" -sync")); + OnInform(_T(" -checkcurleybraces")); + OnInform(_T(" -checksyntax")); + OnInform(_T(" -macros ")); + OnInform(_T(" -winhelp")); + OnInform(_T(" -rtf")); + OnInform(_T(" -html")); + OnInform(_T(" -xlp\n")); } #ifndef NO_GUI @@ -472,6 +616,8 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(TEX_MODE_WINHELP, MyFrame::OnModeWinHelp) EVT_MENU(TEX_MODE_HTML, MyFrame::OnModeHTML) EVT_MENU(TEX_MODE_XLP, MyFrame::OnModeXLP) + EVT_MENU(TEX_OPTIONS_CURLEY_BRACE, MyFrame::OnOptionsCurleyBrace) + EVT_MENU(TEX_OPTIONS_SYNTAX_CHECKING, MyFrame::OnOptionsSyntaxChecking) EVT_MENU(TEX_HELP, MyFrame::OnHelp) EVT_MENU(TEX_ABOUT, MyFrame::OnAbout) END_EVENT_TABLE() @@ -481,12 +627,12 @@ MyFrame::MyFrame(wxFrame *frame, wxWindowID id, const wxString& title, const wxP wxFrame(frame, id, title, pos, size) {} -void MyFrame::OnCloseWindow(wxCloseEvent& event) +void MyFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) { if (!stopRunning && !OkToClose) { - stopRunning = TRUE; - runTwice = FALSE; + stopRunning = true; + runTwice = false; return; } else if (OkToClose) @@ -495,136 +641,191 @@ void MyFrame::OnCloseWindow(wxCloseEvent& event) } } -void MyFrame::OnExit(wxCommandEvent& event) +void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event)) { - this->Destroy(); + Close(); +// this->Destroy(); } -void MyFrame::OnGo(wxCommandEvent& event) +void MyFrame::OnGo(wxCommandEvent& WXUNUSED(event)) { passNumber = 1; - menuBar->EnableTop(0, FALSE); - menuBar->EnableTop(1, FALSE); - menuBar->EnableTop(2, FALSE); - menuBar->EnableTop(3, FALSE); + errorCount = 0; + menuBar->EnableTop(0, false); + menuBar->EnableTop(1, false); + menuBar->EnableTop(2, false); + menuBar->EnableTop(3, false); textWindow->Clear(); - Tex2RTFYield(TRUE); + Tex2RTFYield(true); Go(); - if (runTwice) + if (stopRunning) + { +#if wxUSE_STATUSBAR + SetStatusText(_T("Build aborted!")); +#endif // wxUSE_STATUSBAR + wxString errBuf; + errBuf.Printf(_T("\nErrors encountered during this pass: %lu\n"), errorCount); + OnInform((wxChar *)errBuf.c_str()); + } + + + if (runTwice && !stopRunning) { - Tex2RTFYield(TRUE); + Tex2RTFYield(true); Go(); } - menuBar->EnableTop(0, TRUE); - menuBar->EnableTop(1, TRUE); - menuBar->EnableTop(2, TRUE); - menuBar->EnableTop(3, TRUE); + menuBar->EnableTop(0, true); + menuBar->EnableTop(1, true); + menuBar->EnableTop(2, true); + menuBar->EnableTop(3, true); } -void MyFrame::OnSetInput(wxCommandEvent& event) +void MyFrame::OnSetInput(wxCommandEvent& WXUNUSED(event)) { - ChooseInputFile(TRUE); + ChooseInputFile(true); } -void MyFrame::OnSetOutput(wxCommandEvent& event) +void MyFrame::OnSetOutput(wxCommandEvent& WXUNUSED(event)) { - ChooseOutputFile(TRUE); + ChooseOutputFile(true); } -void MyFrame::OnSaveFile(wxCommandEvent& event) +void MyFrame::OnSaveFile(wxCommandEvent& WXUNUSED(event)) { - wxString s = wxFileSelector("Save text to file", "", "", "txt", "*.txt"); - if (s != "") + wxString s = wxFileSelector(_T("Save text to file"), _T(""), _T(""), _T("txt"), _T("*.txt")); + if (s != _T("")) { textWindow->SaveFile(s); - char buf[350]; - sprintf(buf, "Saved text to %s", (const char*) s); +#if wxUSE_STATUSBAR + wxChar buf[350]; + wxSnprintf(buf, sizeof(buf), _T("Saved text to %s"), (const wxChar*) s.c_str()); frame->SetStatusText(buf, 0); +#endif // wxUSE_STATUSBAR } } -void MyFrame::OnViewOutput(wxCommandEvent& event) +void MyFrame::OnViewOutput(wxCommandEvent& WXUNUSED(event)) { ChooseOutputFile(); if (OutputFile && wxFileExists(OutputFile)) { textWindow->LoadFile(OutputFile); - char buf[300]; + wxChar buf[300]; wxString str(wxFileNameFromPath(OutputFile)); - sprintf(buf, "Tex2RTF [%s]", (const char*) str); + wxSnprintf(buf, sizeof(buf), _T("Tex2RTF [%s]"), (const wxChar*) str.c_str()); frame->SetTitle(buf); } } -void MyFrame::OnViewLatex(wxCommandEvent& event) +void MyFrame::OnViewLatex(wxCommandEvent& WXUNUSED(event)) { ChooseInputFile(); if (InputFile && wxFileExists(InputFile)) { textWindow->LoadFile(InputFile); - char buf[300]; + wxChar buf[300]; wxString str(wxFileNameFromPath(OutputFile)); - sprintf(buf, "Tex2RTF [%s]", (const char*) str); + wxSnprintf(buf, sizeof(buf), _T("Tex2RTF [%s]"), (const wxChar*) str.c_str()); frame->SetTitle(buf); } } -void MyFrame::OnLoadMacros(wxCommandEvent& event) +void MyFrame::OnLoadMacros(wxCommandEvent& WXUNUSED(event)) { textWindow->Clear(); - wxString s = wxFileSelector("Choose custom macro file", wxPathOnly(MacroFile), wxFileNameFromPath(MacroFile), "ini", "*.ini"); - if (s != "" && wxFileExists(s)) + wxString s = wxFileSelector(_T("Choose custom macro file"), wxPathOnly(MacroFile), wxFileNameFromPath(MacroFile), _T("ini"), _T("*.ini")); + if (s != _T("") && wxFileExists(s)) { MacroFile = copystring(s); - ReadCustomMacros((char*) (const char*) s); + ReadCustomMacros((wxChar *)s.c_str()); ShowCustomMacros(); } } -void MyFrame::OnShowMacros(wxCommandEvent& event) +void MyFrame::OnShowMacros(wxCommandEvent& WXUNUSED(event)) { textWindow->Clear(); - Tex2RTFYield(TRUE); + Tex2RTFYield(true); ShowCustomMacros(); } -void MyFrame::OnModeRTF(wxCommandEvent& event) +void MyFrame::OnModeRTF(wxCommandEvent& WXUNUSED(event)) { convertMode = TEX_RTF; - winHelp = FALSE; + winHelp = false; InputFile = NULL; OutputFile = NULL; - SetStatusText("In linear RTF mode.", 1); +#if wxUSE_STATUSBAR + SetStatusText(_T("In linear RTF mode."), 1); +#endif // wxUSE_STATUSBAR } -void MyFrame::OnModeWinHelp(wxCommandEvent& event) +void MyFrame::OnModeWinHelp(wxCommandEvent& WXUNUSED(event)) { convertMode = TEX_RTF; - winHelp = TRUE; + winHelp = true; InputFile = NULL; OutputFile = NULL; - SetStatusText("In WinHelp RTF mode.", 1); +#if wxUSE_STATUSBAR + SetStatusText(_T("In WinHelp RTF mode."), 1); +#endif // wxUSE_STATUSBAR } -void MyFrame::OnModeHTML(wxCommandEvent& event) +void MyFrame::OnModeHTML(wxCommandEvent& WXUNUSED(event)) { convertMode = TEX_HTML; - winHelp = FALSE; + winHelp = false; InputFile = NULL; OutputFile = NULL; - SetStatusText("In HTML mode.", 1); +#if wxUSE_STATUSBAR + SetStatusText(_T("In HTML mode."), 1); +#endif // wxUSE_STATUSBAR } -void MyFrame::OnModeXLP(wxCommandEvent& event) +void MyFrame::OnModeXLP(wxCommandEvent& WXUNUSED(event)) { convertMode = TEX_XLP; InputFile = NULL; OutputFile = NULL; - SetStatusText("In XLP mode.", 1); +#if wxUSE_STATUSBAR + SetStatusText(_T("In XLP mode."), 1); +#endif // wxUSE_STATUSBAR +} + +void MyFrame::OnOptionsCurleyBrace(wxCommandEvent& WXUNUSED(event)) +{ + checkCurleyBraces = !checkCurleyBraces; +#if wxUSE_STATUSBAR + if (checkCurleyBraces) + { + SetStatusText(_T("Checking curley braces: YES"), 1); + } + else + { + SetStatusText(_T("Checking curley braces: NO"), 1); + } +#endif // wxUSE_STATUSBAR +} + + +void MyFrame::OnOptionsSyntaxChecking(wxCommandEvent& WXUNUSED(event)) +{ + checkSyntax = !checkSyntax; +#if wxUSE_STATUSBAR + if (checkSyntax) + { + SetStatusText(_T("Checking syntax: YES"), 1); + } + else + { + SetStatusText(_T("Checking syntax: NO"), 1); + } +#endif // wxUSE_STATUSBAR } -void MyFrame::OnHelp(wxCommandEvent& event) + +void MyFrame::OnHelp(wxCommandEvent& WXUNUSED(event)) { #if wxUSE_HELP HelpInstance->LoadFile(); @@ -632,38 +833,40 @@ void MyFrame::OnHelp(wxCommandEvent& event) #endif // wxUSE_HELP } -void MyFrame::OnAbout(wxCommandEvent& event) +void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { - char buf[300]; + wxChar buf[300]; #ifdef __WIN32__ - char *platform = " (32-bit)"; + wxChar *platform = _T(" (32-bit)"); #else #ifdef __WXMSW__ - char *platform = " (16-bit)"; + wxChar *platform = _T(" (16-bit)"); #else - char *platform = ""; + wxChar *platform = _T(""); #endif #endif - sprintf(buf, "Tex2RTF Version %.2f%s\nLaTeX to RTF, WinHelp, HTML and wxHelp Conversion\n\n(c) Julian Smart 1999", versionNo, platform); - wxMessageBox(buf, "About Tex2RTF"); + wxSnprintf(buf, sizeof(buf), _T("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, _T("About Tex2RTF")); } void ChooseInputFile(bool force) { if (force || !InputFile) { - wxString s = wxFileSelector("Choose LaTeX input file", wxPathOnly(InputFile), wxFileNameFromPath(InputFile), "tex", "*.tex"); - if (s != "") + wxString s = wxFileSelector(_T("Choose LaTeX input file"), wxPathOnly(InputFile), wxFileNameFromPath(InputFile), _T("tex"), _T("*.tex")); + if (s != _T("")) { // Different file, so clear index entries. ClearKeyWordTable(); ResetContentsLevels(0); passNumber = 1; - char buf[300]; + errorCount = 0; + InputFile = copystring(s); wxString str = wxFileNameFromPath(InputFile); - sprintf(buf, "Tex2RTF [%s]", (const char*) str); - frame->SetTitle(buf); + wxString buf; + buf.Printf(_T("Tex2RTF [%s]"), str.c_str()); + frame->SetTitle((wxChar *)buf.c_str()); OutputFile = NULL; } } @@ -671,9 +874,9 @@ void ChooseInputFile(bool force) void ChooseOutputFile(bool force) { - char extensionBuf[10]; - char wildBuf[10]; - strcpy(wildBuf, "*."); + wxChar extensionBuf[10]; + wxChar wildBuf[10]; + wxStrcpy(wildBuf, _T("*.")); wxString path; if (OutputFile) path = wxPathOnly(OutputFile); @@ -684,33 +887,28 @@ void ChooseOutputFile(bool force) { case TEX_RTF: { - strcpy(extensionBuf, "rtf"); - strcat(wildBuf, "rtf"); + wxStrcpy(extensionBuf, _T("rtf")); + wxStrcat(wildBuf, _T("rtf")); break; } case TEX_XLP: { - strcpy(extensionBuf, "xlp"); - strcat(wildBuf, "xlp"); + wxStrcpy(extensionBuf, _T("xlp")); + wxStrcat(wildBuf, _T("xlp")); break; } case TEX_HTML: { -#if defined(__WXMSW__) && defined(__WIN16__) - strcpy(extensionBuf, "htm"); - strcat(wildBuf, "htm"); -#else - strcpy(extensionBuf, "html"); - strcat(wildBuf, "html"); -#endif + wxStrcpy(extensionBuf, _T("html")); + wxStrcat(wildBuf, _T("html")); break; } } if (force || !OutputFile) { - wxString s = wxFileSelector("Choose output file", path, wxFileNameFromPath(OutputFile), + wxString s = wxFileSelector(_T("Choose output file"), path, wxFileNameFromPath(OutputFile), extensionBuf, wildBuf); - if (s != "") + if (s != _T("")) OutputFile = copystring(s); } } @@ -723,16 +921,16 @@ bool Go(void) ChooseOutputFile(); #endif - if (!InputFile || !OutputFile) - return FALSE; + if (!InputFile || !OutputFile || stopRunning) + return false; #ifndef NO_GUI if (isInteractive) { - char buf[300]; + wxChar buf[300]; wxString str = wxFileNameFromPath(InputFile); - sprintf(buf, "Tex2RTF [%s]", (const char*) str); + wxSnprintf(buf, sizeof(buf), _T("Tex2RTF [%s]"), (const wxChar*) str); frame->SetTitle(buf); } @@ -740,7 +938,7 @@ bool Go(void) #endif // Find extension-less filename - strcpy(FileRoot, OutputFile); + wxStrcpy(FileRoot, OutputFile); StripExtension(FileRoot); if (truncateFilenames && convertMode == TEX_HTML) @@ -748,55 +946,61 @@ bool Go(void) // Truncate to five characters. This ensures that // we can generate DOS filenames such as thing999. But 1000 files // may not be enough, of course... - char* sName = wxFileNameFromPath( FileRoot); // this Julian's method is non-destructive reference + wxChar* sName = wxFileNameFromPath( FileRoot); // this Julian's method is non-destructive reference if(sName) - if(strlen( sName) > 5) + if(wxStrlen( sName) > 5) sName[5] = '\0'; // that should do! } - sprintf(ContentsName, "%s.con", FileRoot); - sprintf(TmpContentsName, "%s.cn1", FileRoot); - sprintf(TmpFrameContentsName, "%s.frc", FileRoot); - sprintf(WinHelpContentsFileName, "%s.cnt", FileRoot); - sprintf(RefName, "%s.ref", FileRoot); + wxSnprintf(ContentsName, 300, _T("%s.con"), FileRoot); + wxSnprintf(TmpContentsName, 300, _T("%s.cn1"), FileRoot); + wxSnprintf(TmpFrameContentsName, 300, _T("%s.frc"), FileRoot); + wxSnprintf(WinHelpContentsFileName, 300, _T("%s.cnt"), FileRoot); + wxSnprintf(RefFileName, 300, _T("%s.ref"), FileRoot); TexPathList.EnsureFileAccessible(InputFile); if (!bulletFile) { - wxString s = TexPathList.FindValidPath("bullet.bmp"); - if (s != "") + wxString s = TexPathList.FindValidPath(_T("bullet.bmp")); + if (s != _T("")) { wxString str = wxFileNameFromPath(s); bulletFile = copystring(str); } } - if (wxFileExists(RefName)) - ReadTexReferences(RefName); + if (wxFileExists(RefFileName)) + ReadTexReferences(RefFileName); - bool success = FALSE; + bool success = false; if (InputFile && OutputFile) { - if (!FileExists(InputFile)) + if (!wxFileExists(InputFile)) { - OnError("Cannot open input file!"); + OnError(_T("Cannot open input file!")); TexCleanUp(); - return FALSE; + return false; } -#ifndef NO_GUI +#if !defined(NO_GUI) && wxUSE_STATUSBAR if (isInteractive) { - char buf[50]; - sprintf(buf, "Working, pass %d...", passNumber); - frame->SetStatusText(buf); + wxString buf; + buf.Printf(_T("Working, pass %d...Click CLOSE to abort"), passNumber); + frame->SetStatusText((wxChar *)buf.c_str()); } #endif - OkToClose = FALSE; - OnInform("Reading LaTeX file..."); + OkToClose = false; + OnInform(_T("Reading LaTeX file...")); TexLoadFile(InputFile); + if (stopRunning) + { + OkToClose = true; + return false; + } + switch (convertMode) { case TEX_RTF: @@ -818,87 +1022,118 @@ bool Go(void) } if (stopRunning) { - OnInform("*** Aborted by user."); - success = FALSE; - stopRunning = FALSE; + OnInform(_T("*** Aborted by user.")); + success = false; + stopRunning = false; + OkToClose = true; } if (success) { - WriteTexReferences(RefName); + WriteTexReferences(RefFileName); TexCleanUp(); - startedSections = FALSE; + startedSections = false; - char buf[100]; + wxString buf; #ifndef NO_GUI long tim = wxGetElapsedTime(); - sprintf(buf, "Finished PASS #%d in %ld seconds.\n", passNumber, (long)(tim/1000.0)); - OnInform(buf); + buf.Printf(_T("Finished PASS #%d in %ld seconds.\n"), passNumber, (long)(tim/1000.0)); + OnInform((wxChar *)buf.c_str()); + + if (errorCount) + { + buf.Printf(_T("Errors encountered during this pass: %lu\n"), errorCount); + OnInform((wxChar *)buf.c_str()); + } + +#if wxUSE_STATUSBAR if (isInteractive) { - sprintf(buf, "Done, %d %s.", passNumber, (passNumber > 1) ? "passes" : "pass"); - frame->SetStatusText(buf); + buf.Printf(_T("Done, %d %s."), passNumber, (passNumber > 1) ? _T("passes") : _T("pass")); + frame->SetStatusText((wxChar *)buf.c_str()); } +#endif // wxUSE_STATUSBAR #else - sprintf(buf, "Done, %d %s.", passNumber, (passNumber > 1) ? "passes" : "pass"); - OnInform(buf); + buf.Printf(_T("Done, %d %s."), passNumber, (passNumber > 1) ? _T("passes") : _T("pass")); + OnInform((wxChar *)buf.c_str()); + if (errorCount) + { + buf.Printf(_T("Errors encountered during this pass: %lu\n"), errorCount); + OnInform((wxChar *)buf.c_str()); + } #endif passNumber ++; - OkToClose = TRUE; - return TRUE; + errorCount = 0; + OkToClose = true; + return true; } TexCleanUp(); - startedSections = FALSE; + startedSections = false; + +#if !defined(NO_GUI) && wxUSE_STATUSBAR + frame->SetStatusText(_T("Aborted by user.")); +#endif // GUI - OnInform("Sorry, unsuccessful."); - OkToClose = TRUE; - return FALSE; + OnInform(_T("Sorry, unsuccessful.")); + OkToClose = true; + return false; } -void OnError(char *msg) +void OnError(const wxChar *msg) { + wxString msg_string = msg; + errorCount++; + #ifdef NO_GUI - cerr << "Error: " << msg << "\n"; - cerr.flush(); + wxSTD cerr << "Error: " << msg_string.mb_str() << "\n"; + wxSTD cerr.flush(); #else if (isInteractive && frame) - (*frame->textWindow) << "Error: " << msg << "\n"; + (*frame->textWindow) << _T("Error: ") << msg << _T("\n"); else #ifdef __UNIX__ { - cerr << "Error: " << msg << "\n"; - cerr.flush(); + wxSTD cerr << "Error: " << msg_string.mb_str() << "\n"; + wxSTD cerr.flush(); } #endif + #ifdef __WXMSW__ - wxError(msg); + wxLogError(msg); #endif - Tex2RTFYield(TRUE); + Tex2RTFYield(true); #endif // NO_GUI } -void OnInform(char *msg) +void OnInform(const wxChar *msg) { + wxString msg_string = msg; #ifdef NO_GUI - cout << msg << "\n"; - cout.flush(); + wxSTD cout << msg_string.mb_str() << "\n"; + wxSTD cout.flush(); #else if (isInteractive && frame) - (*frame->textWindow) << msg << "\n"; + (*frame->textWindow) << msg << _T("\n"); +/* This whole block of code is just wrong I think. It would behave + completely wrong under anything other than MSW due to the ELSE + with no statement, and the cout calls would fail under MSW, as + the code in this block is compiled if !NO_GUI This code has been + here since v1.1 of this file too. - gt else #ifdef __WXMSW__ { - cout << msg << "\n"; - cout.flush(); + wxSTD cout << msg_string.mb_str() << "\n"; + wxSTD cout.flush(); } #endif #ifdef __WXMSW__ {} #endif +*/ if (isInteractive) { - Tex2RTFYield(TRUE); + Tex2RTFYield(true); } #endif // NO_GUI } @@ -932,20 +1167,20 @@ bool OnArgument(int macroId, int arg_no, bool start) case TEX_RTF: { return RTFOnArgument(macroId, arg_no, start); - break; + // break; } case TEX_XLP: { return XLPOnArgument(macroId, arg_no, start); - break; + // break; } case TEX_HTML: { return HTMLOnArgument(macroId, arg_no, start); - break; + // break; } } - return TRUE; + return true; } /* @@ -959,10 +1194,10 @@ bool OnArgument(int macroId, int arg_no, bool start) wxConnectionBase *Tex2RTFServer::OnAcceptConnection(const wxString& topic) { - if (topic == "TEX2RTF") + if (topic == _T("TEX2RTF")) { if (!ipc_buffer) - ipc_buffer = new char[1000]; + ipc_buffer = new wxChar[1000]; return new Tex2RTFConnection(ipc_buffer, 4000); } @@ -974,7 +1209,7 @@ wxConnectionBase *Tex2RTFServer::OnAcceptConnection(const wxString& topic) * Connection */ -Tex2RTFConnection::Tex2RTFConnection(char *buf, int size):wxDDEConnection(buf, size) +Tex2RTFConnection::Tex2RTFConnection(wxChar *buf, int size):wxDDEConnection(buf, size) { } @@ -982,18 +1217,17 @@ Tex2RTFConnection::~Tex2RTFConnection(void) { } -bool SplitCommand(char *data, char *firstArg, char *secondArg) +bool SplitCommand(wxChar *data, wxChar *firstArg, wxChar *secondArg) { firstArg[0] = 0; secondArg[0] = 0; int i = 0; - int len = strlen(data); - bool stop = FALSE; + bool stop = false; // Find first argument (command name) while (!stop) { if (data[i] == ' ' || data[i] == 0) - stop = TRUE; + stop = true; else { firstArg[i] = data[i]; @@ -1014,86 +1248,86 @@ bool SplitCommand(char *data, char *firstArg, char *secondArg) } secondArg[j] = 0; } - return TRUE; + return true; } -bool Tex2RTFConnection::OnExecute(const wxString& topic, char *data, int size, int format) +bool Tex2RTFConnection::OnExecute(const wxString& WXUNUSED(topic), wxChar *data, int WXUNUSED(size), wxIPCFormat WXUNUSED(format)) { - strcpy(Tex2RTFLastStatus, "OK"); + wxStrcpy(Tex2RTFLastStatus, _T("OK")); - char firstArg[50]; - char secondArg[300]; + wxChar firstArg[50]; + wxChar secondArg[300]; if (SplitCommand(data, firstArg, secondArg)) { - bool hasArg = (strlen(secondArg) > 0); - if (strcmp(firstArg, "INPUT") == 0 && hasArg) + bool hasArg = (wxStrlen(secondArg) > 0); + if (wxStrcmp(firstArg, _T("INPUT")) == 0 && hasArg) { if (InputFile) delete[] InputFile; InputFile = copystring(secondArg); if (frame) { - char buf[100]; + wxChar buf[100]; wxString str = wxFileNameFromPath(InputFile); - sprintf(buf, "Tex2RTF [%s]", (const char*) str); + wxSnprintf(buf, sizeof(buf), _T("Tex2RTF [%s]"), (const wxChar*) str); frame->SetTitle(buf); } } - else if (strcmp(firstArg, "OUTPUT") == 0 && hasArg) + else if (wxStrcmp(firstArg, _T("OUTPUT")) == 0 && hasArg) { if (OutputFile) delete[] OutputFile; OutputFile = copystring(secondArg); } - else if (strcmp(firstArg, "GO") == 0) + else if (wxStrcmp(firstArg, _T("GO")) == 0) { - strcpy(Tex2RTFLastStatus, "WORKING"); + wxStrcpy(Tex2RTFLastStatus, _T("WORKING")); if (!Go()) - strcpy(Tex2RTFLastStatus, "CONVERSION ERROR"); + wxStrcpy(Tex2RTFLastStatus, _T("CONVERSION ERROR")); else - strcpy(Tex2RTFLastStatus, "OK"); + wxStrcpy(Tex2RTFLastStatus, _T("OK")); } - else if (strcmp(firstArg, "EXIT") == 0) + else if (wxStrcmp(firstArg, _T("EXIT")) == 0) { if (frame) frame->Close(); } - else if (strcmp(firstArg, "MINIMIZE") == 0 || strcmp(firstArg, "ICONIZE") == 0) + else if (wxStrcmp(firstArg, _T("MINIMIZE")) == 0 || wxStrcmp(firstArg, _T("ICONIZE")) == 0) { if (frame) - frame->Iconize(TRUE); + frame->Iconize(true); } - else if (strcmp(firstArg, "SHOW") == 0 || strcmp(firstArg, "RESTORE") == 0) + else if (wxStrcmp(firstArg, _T("SHOW")) == 0 || wxStrcmp(firstArg, _T("RESTORE")) == 0) { if (frame) { - frame->Iconize(FALSE); - frame->Show(TRUE); + frame->Iconize(false); + frame->Show(true); } } else { // Try for a setting - strcpy(Tex2RTFLastStatus, RegisterSetting(firstArg, secondArg, FALSE)); -#ifndef NO_GUI - if (frame && strcmp(firstArg, "conversionMode") == 0) + wxStrcpy(Tex2RTFLastStatus, RegisterSetting(firstArg, secondArg, false)); +#if !defined(NO_GUI) && wxUSE_STATUSBAR + if (frame && wxStrcmp(firstArg, _T("conversionMode")) == 0) { - char buf[100]; - strcpy(buf, "In "); + wxChar buf[100]; + wxStrcpy(buf, _T("In ")); if (winHelp && (convertMode == TEX_RTF)) - strcat(buf, "WinHelp RTF"); + wxStrcat(buf, _T("WinHelp RTF")); else if (!winHelp && (convertMode == TEX_RTF)) - strcat(buf, "linear RTF"); - else if (convertMode == TEX_HTML) strcat(buf, "HTML"); - else if (convertMode == TEX_XLP) strcat(buf, "XLP"); - strcat(buf, " mode."); + wxStrcat(buf, _T("linear RTF")); + else if (convertMode == TEX_HTML) wxStrcat(buf, _T("HTML")); + else if (convertMode == TEX_XLP) wxStrcat(buf, _T("XLP")); + wxStrcat(buf, _T(" mode.")); frame->SetStatusText(buf, 1); } #endif } } - return TRUE; + return true; } -char *Tex2RTFConnection::OnRequest(const wxString& topic, const wxString& item, int *size, int format) +wxChar *Tex2RTFConnection::OnRequest(const wxString& WXUNUSED(topic), const wxString& WXUNUSED(item), int *WXUNUSED(size), wxIPCFormat WXUNUSED(format)) { return Tex2RTFLastStatus; } @@ -1102,7 +1336,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();