]>
git.saurik.com Git - wxWidgets.git/blob - utils/tex2rtf/src/tex2rtf.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Converts Latex to linear/WinHelp RTF, HTML, wxHelp.
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
32 #if defined(NO_GUI) || defined(__UNIX__)
48 #if (defined(__WXGTK__) || defined(__WXMOTIF__)) && !defined(NO_GUI)
49 #include "tex2rtf.xpm"
52 const float versionNo
= 2.0;
54 TexChunk
*currentMember
= NULL
;
55 bool startedSections
= FALSE
;
56 char *contentsString
= NULL
;
57 bool suppressNameDecoration
= FALSE
;
58 bool OkToClose
= TRUE
;
64 extern char *BigBuffer
;
65 extern char *TexFileRoot
;
66 extern char *TexBibName
; // Bibliography output file name
67 extern char *TexTmpBibName
; // Temporary bibliography output file name
68 extern wxList ColourTable
;
69 extern TexChunk
*TopLevel
;
70 extern char *PageStyle
;
71 extern char *BibliographyStyleString
;
72 extern char *DocumentStyleString
;
73 extern char *bitmapMethod
;
74 extern char *backgroundColourString
;
75 extern char *ContentsNameString
;
76 extern char *AbstractNameString
;
77 extern char *GlossaryNameString
;
78 extern char *ReferencesNameString
;
79 extern char *FiguresNameString
;
80 extern char *TablesNameString
;
81 extern char *FigureNameString
;
82 extern char *TableNameString
;
83 extern char *IndexNameString
;
84 extern char *ChapterNameString
;
85 extern char *SectionNameString
;
86 extern char *SubsectionNameString
;
87 extern char *SubsubsectionNameString
;
88 extern char *UpNameString
;
93 wxHelpController
*HelpInstance
= NULL
;
97 static char *ipc_buffer
= NULL
;
98 static char Tex2RTFLastStatus
[100];
99 Tex2RTFServer
*TheTex2RTFServer
= NULL
;
103 char *bulletFile
= NULL
;
105 FILE *Contents
= NULL
; // Contents page
106 FILE *Chapters
= NULL
; // Chapters (WinHelp RTF) or rest of file (linear RTF)
107 FILE *Sections
= NULL
;
108 FILE *Subsections
= NULL
;
109 FILE *Subsubsections
= NULL
;
111 FILE *WinHelpContentsFile
= NULL
;
113 char *InputFile
= NULL
;
114 char *OutputFile
= NULL
;
115 char *MacroFile
= copystring("tex2rtf.ini");
117 char *FileRoot
= NULL
;
118 char *ContentsName
= NULL
; // Contents page from last time around
119 char *TmpContentsName
= NULL
; // Current contents page
120 char *TmpFrameContentsName
= NULL
; // Current frame contents page
121 char *WinHelpContentsFileName
= NULL
; // WinHelp .cnt file
122 char *RefName
= NULL
; // Reference file name
124 char *RTFCharset
= copystring("ansi");
127 int BufSize
= 100; // Size of buffer in K
133 void ShowOptions(void);
137 #if wxUSE_GUI || !defined(__UNIX__)
138 // wxBase for Unix does not have wxBuffer
141 char *wxBuffer
; // we must init it, otherwise tex2rtf will crash
143 int main(int argc
, char **argv
)
145 wxMenuBar
*menuBar
= NULL
;
146 MyFrame
*frame
= NULL
;
148 // DECLARE_APP(MyApp)
151 // `Main program' equivalent, creating windows and returning main app frame
155 // Use default list of macros defined in tex2any.cc
156 DefineDefaultMacros();
157 AddMacroDef(ltHARDY
, "hardy", 0);
159 FileRoot
= new char[300];
160 ContentsName
= new char[300];
161 TmpContentsName
= new char[300];
162 TmpFrameContentsName
= new char[300];
163 WinHelpContentsFileName
= new char[300];
164 RefName
= new char[300];
166 ColourTable
.DeleteContents(TRUE
);
170 // Read input/output files
173 if (argv
[1][0] != '-')
180 if (argv
[2][0] != '-')
182 OutputFile
= argv
[2];
190 wxBuffer
= new char[1500];
191 // this is done in wxApp, but NO_GUI version doesn't call it :-(
193 if (!InputFile
|| !OutputFile
)
195 cout
<< "Tex2RTF: input or output file is missing.\n";
203 TexPathList
.EnsureFileAccessible(InputFile
);
205 if (!InputFile
|| !OutputFile
)
206 isInteractive
= TRUE
;
209 for (i
= n
; i
< argc
;)
211 if (strcmp(argv
[i
], "-winhelp") == 0)
214 convertMode
= TEX_RTF
;
218 else if (strcmp(argv
[i
], "-interactive") == 0)
221 isInteractive
= TRUE
;
224 else if (strcmp(argv
[i
], "-sync") == 0) // Don't yield
229 else if (strcmp(argv
[i
], "-rtf") == 0)
232 convertMode
= TEX_RTF
;
234 else if (strcmp(argv
[i
], "-html") == 0)
237 convertMode
= TEX_HTML
;
239 else if (strcmp(argv
[i
], "-xlp") == 0)
242 convertMode
= TEX_XLP
;
244 else if (strcmp(argv
[i
], "-twice") == 0)
249 else if (strcmp(argv
[i
], "-macros") == 0)
254 MacroFile
= copystring(argv
[i
]);
258 else if (strcmp(argv
[i
], "-bufsize") == 0)
263 BufSize
= atoi(argv
[i
]);
267 else if (strcmp(argv
[i
], "-charset") == 0)
274 if (strcmp(s
, "ansi") == 0 || strcmp(s
, "pc") == 0 || strcmp(s
, "mac") == 0 ||
275 strcmp(s
, "pca") == 0)
276 RTFCharset
= copystring(s
);
279 OnError("Incorrect argument for -charset");
287 buf
.Printf("Invalid switch %s.\n", argv
[i
]);
288 OnError((char *)buf
.c_str());
298 #if defined(__WXMSW__) && !defined(NO_GUI)
300 Tex2RTFLastStatus
[0] = 0; // DDE connection return value
301 TheTex2RTFServer
= new Tex2RTFServer
;
302 TheTex2RTFServer
->Create("TEX2RTF");
305 #if defined(__WXMSW__) && defined(__WIN16__)
306 // Limit to max Windows array size
307 if (BufSize
> 64) BufSize
= 64;
310 TexInitialize(BufSize
);
311 ResetContentsLevels(0);
319 // Create the main frame window
320 frame
= new MyFrame(NULL
, -1, "Tex2RTF", wxPoint(-1, -1), wxSize(400, 300));
321 frame
->CreateStatusBar(2);
324 // TODO: uncomment this when we have tex2rtf.xpm
325 frame
->SetIcon(wxICON(tex2rtf
));
329 sprintf(buf
, "Tex2RTF [%s]", FileNameFromPath(InputFile
));
330 frame
->SetTitle(buf
);
334 wxMenu
*file_menu
= new wxMenu
;
335 file_menu
->Append(TEX_GO
, "&Go", "Run converter");
336 file_menu
->Append(TEX_SET_INPUT
, "Set &Input File", "Set the LaTeX input file");
337 file_menu
->Append(TEX_SET_OUTPUT
, "Set &Output File", "Set the output file");
338 file_menu
->AppendSeparator();
339 file_menu
->Append(TEX_VIEW_LATEX
, "View &LaTeX File", "View the LaTeX input file");
340 file_menu
->Append(TEX_VIEW_OUTPUT
, "View Output &File", "View output file");
341 file_menu
->Append(TEX_SAVE_FILE
, "&Save log file", "Save displayed text into file");
342 file_menu
->AppendSeparator();
343 file_menu
->Append(TEX_QUIT
, "E&xit", "Exit Tex2RTF");
345 wxMenu
*macro_menu
= new wxMenu
;
347 macro_menu
->Append(TEX_LOAD_CUSTOM_MACROS
, "&Load Custom Macros", "Load custom LaTeX macro file");
348 macro_menu
->Append(TEX_VIEW_CUSTOM_MACROS
, "View &Custom Macros", "View custom LaTeX macros");
350 wxMenu
*mode_menu
= new wxMenu
;
352 mode_menu
->Append(TEX_MODE_RTF
, "Output linear &RTF", "Wordprocessor-compatible RTF");
353 mode_menu
->Append(TEX_MODE_WINHELP
, "Output &WinHelp RTF", "WinHelp-compatible RTF");
354 mode_menu
->Append(TEX_MODE_HTML
, "Output &HTML", "HTML World Wide Web hypertext file");
355 mode_menu
->Append(TEX_MODE_XLP
, "Output &XLP", "wxHelp hypertext help file");
357 wxMenu
*help_menu
= new wxMenu
;
359 help_menu
->Append(TEX_HELP
, "&Help", "Tex2RTF Contents Page");
360 help_menu
->Append(TEX_ABOUT
, "&About Tex2RTF", "About Tex2RTF");
362 menuBar
= new wxMenuBar
;
363 menuBar
->Append(file_menu
, "&File");
364 menuBar
->Append(macro_menu
, "&Macros");
365 menuBar
->Append(mode_menu
, "&Conversion Mode");
366 menuBar
->Append(help_menu
, "&Help");
368 frame
->SetMenuBar(menuBar
);
369 frame
->textWindow
= new wxTextCtrl(frame
, -1, "", wxPoint(-1, -1), wxSize(-1, -1), wxTE_READONLY
|wxTE_MULTILINE
);
371 (*frame
->textWindow
) << "Welcome to Julian Smart's LaTeX to RTF converter.\n";
375 HelpInstance
= new wxHelpController();
376 HelpInstance
->Initialize("tex2rtf");
380 * Read macro/initialisation file
385 if ((path
= TexPathList
.FindValidPath(MacroFile
)) != "")
386 ReadCustomMacros((char*) (const char*) path
);
390 if (winHelp
&& (convertMode
== TEX_RTF
))
391 strcat(buf
, "WinHelp RTF");
392 else if (!winHelp
&& (convertMode
== TEX_RTF
))
393 strcat(buf
, "linear RTF");
394 else if (convertMode
== TEX_HTML
) strcat(buf
, "HTML");
395 else if (convertMode
== TEX_XLP
) strcat(buf
, "XLP");
396 strcat(buf
, " mode.");
397 frame
->SetStatusText(buf
, 1);
406 * Read macro/initialisation file
411 if ((path
= TexPathList
.FindValidPath(MacroFile
)) != "")
412 ReadCustomMacros((char*) (const char*) path
);
427 // Return the main frame window
438 wxNode
*node
= CustomMacroList
.First();
441 CustomMacro
*macro
= (CustomMacro
*)node
->Data();
444 node
= CustomMacroList
.First();
446 MacroDefs
.BeginFind();
447 node
= MacroDefs
.Next();
450 TexMacroDef
* def
= (TexMacroDef
*) node
->Data();
452 node
= MacroDefs
.Next();
456 delete TheTex2RTFServer
;
471 delete currentArgData
;
472 currentArgData
= NULL
;
486 delete TexTmpBibName
;
487 TexTmpBibName
= NULL
;
501 delete TmpContentsName
;
502 TmpContentsName
= NULL
;
504 if (TmpFrameContentsName
)
506 delete TmpFrameContentsName
;
507 TmpFrameContentsName
= NULL
;
509 if (WinHelpContentsFileName
)
511 delete WinHelpContentsFileName
;
512 WinHelpContentsFileName
= NULL
;
536 delete [] BibliographyStyleString
;
537 delete [] DocumentStyleString
;
538 delete [] bitmapMethod
;
539 delete [] backgroundColourString
;
540 delete [] ContentsNameString
;
541 delete [] AbstractNameString
;
542 delete [] GlossaryNameString
;
543 delete [] ReferencesNameString
;
544 delete [] FiguresNameString
;
545 delete [] TablesNameString
;
546 delete [] FigureNameString
;
547 delete [] TableNameString
;
548 delete [] IndexNameString
;
549 delete [] ChapterNameString
;
550 delete [] SectionNameString
;
551 delete [] SubsectionNameString
;
552 delete [] SubsubsectionNameString
;
553 delete [] UpNameString
;
555 delete[] winHelpTitle
;
557 // TODO: this simulates zero-memory leaks!
558 // Otherwise there are just too many...
560 wxDebugContext::SetCheckpoint();
566 void ShowOptions(void)
569 sprintf(buf
, "Tex2RTF version %.2f", versionNo
);
571 OnInform("Usage: tex2rtf [input] [output] [switches]\n");
572 OnInform("where valid switches are");
573 OnInform(" -interactive");
574 OnInform(" -bufsize <size in K>");
575 OnInform(" -charset <pc | pca | ansi | mac> (default ansi)");
578 OnInform(" -macros <filename>");
579 OnInform(" -winhelp");
587 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
588 EVT_CLOSE(MyFrame::OnCloseWindow
)
589 EVT_MENU(TEX_QUIT
, MyFrame::OnExit
)
590 EVT_MENU(TEX_GO
, MyFrame::OnGo
)
591 EVT_MENU(TEX_SET_INPUT
, MyFrame::OnSetInput
)
592 EVT_MENU(TEX_SET_OUTPUT
, MyFrame::OnSetOutput
)
593 EVT_MENU(TEX_SAVE_FILE
, MyFrame::OnSaveFile
)
594 EVT_MENU(TEX_VIEW_LATEX
, MyFrame::OnViewLatex
)
595 EVT_MENU(TEX_VIEW_OUTPUT
, MyFrame::OnViewOutput
)
596 EVT_MENU(TEX_VIEW_CUSTOM_MACROS
, MyFrame::OnShowMacros
)
597 EVT_MENU(TEX_LOAD_CUSTOM_MACROS
, MyFrame::OnLoadMacros
)
598 EVT_MENU(TEX_MODE_RTF
, MyFrame::OnModeRTF
)
599 EVT_MENU(TEX_MODE_WINHELP
, MyFrame::OnModeWinHelp
)
600 EVT_MENU(TEX_MODE_HTML
, MyFrame::OnModeHTML
)
601 EVT_MENU(TEX_MODE_XLP
, MyFrame::OnModeXLP
)
602 EVT_MENU(TEX_HELP
, MyFrame::OnHelp
)
603 EVT_MENU(TEX_ABOUT
, MyFrame::OnAbout
)
606 // My frame constructor
607 MyFrame::MyFrame(wxFrame
*frame
, wxWindowID id
, const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
):
608 wxFrame(frame
, id
, title
, pos
, size
)
611 void MyFrame::OnCloseWindow(wxCloseEvent
& event
)
613 if (!stopRunning
&& !OkToClose
)
625 void MyFrame::OnExit(wxCommandEvent
& event
)
631 void MyFrame::OnGo(wxCommandEvent
& event
)
635 menuBar
->EnableTop(0, FALSE
);
636 menuBar
->EnableTop(1, FALSE
);
637 menuBar
->EnableTop(2, FALSE
);
638 menuBar
->EnableTop(3, FALSE
);
648 menuBar
->EnableTop(0, TRUE
);
649 menuBar
->EnableTop(1, TRUE
);
650 menuBar
->EnableTop(2, TRUE
);
651 menuBar
->EnableTop(3, TRUE
);
654 void MyFrame::OnSetInput(wxCommandEvent
& event
)
656 ChooseInputFile(TRUE
);
659 void MyFrame::OnSetOutput(wxCommandEvent
& event
)
661 ChooseOutputFile(TRUE
);
664 void MyFrame::OnSaveFile(wxCommandEvent
& event
)
666 wxString s
= wxFileSelector("Save text to file", "", "", "txt", "*.txt");
669 textWindow
->SaveFile(s
);
671 sprintf(buf
, "Saved text to %s", (const char*) s
);
672 frame
->SetStatusText(buf
, 0);
676 void MyFrame::OnViewOutput(wxCommandEvent
& event
)
679 if (OutputFile
&& wxFileExists(OutputFile
))
681 textWindow
->LoadFile(OutputFile
);
683 wxString
str(wxFileNameFromPath(OutputFile
));
684 sprintf(buf
, "Tex2RTF [%s]", (const char*) str
);
685 frame
->SetTitle(buf
);
689 void MyFrame::OnViewLatex(wxCommandEvent
& event
)
692 if (InputFile
&& wxFileExists(InputFile
))
694 textWindow
->LoadFile(InputFile
);
696 wxString
str(wxFileNameFromPath(OutputFile
));
697 sprintf(buf
, "Tex2RTF [%s]", (const char*) str
);
698 frame
->SetTitle(buf
);
702 void MyFrame::OnLoadMacros(wxCommandEvent
& event
)
705 wxString s
= wxFileSelector("Choose custom macro file", wxPathOnly(MacroFile
), wxFileNameFromPath(MacroFile
), "ini", "*.ini");
706 if (s
!= "" && wxFileExists(s
))
708 MacroFile
= copystring(s
);
709 ReadCustomMacros((char*) (const char*) s
);
714 void MyFrame::OnShowMacros(wxCommandEvent
& event
)
721 void MyFrame::OnModeRTF(wxCommandEvent
& event
)
723 convertMode
= TEX_RTF
;
727 SetStatusText("In linear RTF mode.", 1);
730 void MyFrame::OnModeWinHelp(wxCommandEvent
& event
)
732 convertMode
= TEX_RTF
;
736 SetStatusText("In WinHelp RTF mode.", 1);
739 void MyFrame::OnModeHTML(wxCommandEvent
& event
)
741 convertMode
= TEX_HTML
;
745 SetStatusText("In HTML mode.", 1);
748 void MyFrame::OnModeXLP(wxCommandEvent
& event
)
750 convertMode
= TEX_XLP
;
753 SetStatusText("In XLP mode.", 1);
756 void MyFrame::OnHelp(wxCommandEvent
& event
)
759 HelpInstance
->LoadFile();
760 HelpInstance
->DisplayContents();
764 void MyFrame::OnAbout(wxCommandEvent
& event
)
768 char *platform
= " (32-bit)";
771 char *platform
= " (16-bit)";
776 sprintf(buf
, "Tex2RTF Version %.2f%s\nLaTeX to RTF, WinHelp, HTML and wxHelp Conversion\n\n(c) Julian Smart 1999", versionNo
, platform
);
777 wxMessageBox(buf
, "About Tex2RTF");
780 void ChooseInputFile(bool force
)
782 if (force
|| !InputFile
)
784 wxString s
= wxFileSelector("Choose LaTeX input file", wxPathOnly(InputFile
), wxFileNameFromPath(InputFile
), "tex", "*.tex");
787 // Different file, so clear index entries.
789 ResetContentsLevels(0);
793 InputFile
= copystring(s
);
794 wxString str
= wxFileNameFromPath(InputFile
);
796 buf
.Printf("Tex2RTF [%s]", str
.c_str());
797 frame
->SetTitle((char *)buf
.c_str());
803 void ChooseOutputFile(bool force
)
805 char extensionBuf
[10];
807 strcpy(wildBuf
, "*.");
810 path
= wxPathOnly(OutputFile
);
812 path
= wxPathOnly(InputFile
);
818 strcpy(extensionBuf
, "rtf");
819 strcat(wildBuf
, "rtf");
824 strcpy(extensionBuf
, "xlp");
825 strcat(wildBuf
, "xlp");
830 #if defined(__WXMSW__) && defined(__WIN16__)
831 strcpy(extensionBuf
, "htm");
832 strcat(wildBuf
, "htm");
834 strcpy(extensionBuf
, "html");
835 strcat(wildBuf
, "html");
840 if (force
|| !OutputFile
)
842 wxString s
= wxFileSelector("Choose output file", path
, wxFileNameFromPath(OutputFile
),
843 extensionBuf
, wildBuf
);
845 OutputFile
= copystring(s
);
857 if (!InputFile
|| !OutputFile
)
864 wxString str
= wxFileNameFromPath(InputFile
);
866 sprintf(buf
, "Tex2RTF [%s]", (const char*) str
);
867 frame
->SetTitle(buf
);
873 // Find extension-less filename
874 strcpy(FileRoot
, OutputFile
);
875 StripExtension(FileRoot
);
877 if (truncateFilenames
&& convertMode
== TEX_HTML
)
879 // Truncate to five characters. This ensures that
880 // we can generate DOS filenames such as thing999. But 1000 files
881 // may not be enough, of course...
882 char* sName
= wxFileNameFromPath( FileRoot
); // this Julian's method is non-destructive reference
885 if(strlen( sName
) > 5)
886 sName
[5] = '\0'; // that should do!
889 sprintf(ContentsName
, "%s.con", FileRoot
);
890 sprintf(TmpContentsName
, "%s.cn1", FileRoot
);
891 sprintf(TmpFrameContentsName
, "%s.frc", FileRoot
);
892 sprintf(WinHelpContentsFileName
, "%s.cnt", FileRoot
);
893 sprintf(RefName
, "%s.ref", FileRoot
);
895 TexPathList
.EnsureFileAccessible(InputFile
);
898 wxString s
= TexPathList
.FindValidPath("bullet.bmp");
901 wxString str
= wxFileNameFromPath(s
);
902 bulletFile
= copystring(str
);
906 if (wxFileExists(RefName
))
907 ReadTexReferences(RefName
);
909 bool success
= FALSE
;
911 if (InputFile
&& OutputFile
)
913 if (!FileExists(InputFile
))
915 OnError("Cannot open input file!");
923 buf
.Printf("Working, pass %d...", passNumber
);
924 frame
->SetStatusText((char *)buf
.c_str());
928 OnInform("Reading LaTeX file...");
929 TexLoadFile(InputFile
);
952 OnInform("*** Aborted by user.");
959 WriteTexReferences(RefName
);
961 startedSections
= FALSE
;
965 long tim
= wxGetElapsedTime();
966 buf
.Printf("Finished PASS #%d in %ld seconds.\n", passNumber
, (long)(tim
/1000.0));
967 OnInform((char *)buf
.c_str());
971 buf
.Printf("Errors encountered during this pass: %lu\n", errorCount
);
972 OnInform((char *)buf
.c_str());
977 buf
.Printf("Done, %d %s.", passNumber
, (passNumber
> 1) ? "passes" : "pass");
978 frame
->SetStatusText((char *)buf
.c_str());
981 buf
.Printf("Done, %d %s.", passNumber
, (passNumber
> 1) ? "passes" : "pass");
982 OnInform((char *)buf
.c_str());
985 buf
.Printf("Errors encountered during this pass: %lu\n", errorCount
);
986 OnInform((char *)buf
.c_str());
996 startedSections
= FALSE
;
998 OnInform("Sorry, unsuccessful.");
1003 void OnError(char *msg
)
1008 cerr
<< "Error: " << msg
<< "\n";
1011 if (isInteractive
&& frame
)
1012 (*frame
->textWindow
) << "Error: " << msg
<< "\n";
1016 cerr
<< "Error: " << msg
<< "\n";
1028 void OnInform(char *msg
)
1031 cout
<< msg
<< "\n";
1034 if (isInteractive
&& frame
)
1035 (*frame
->textWindow
) << msg
<< "\n";
1039 cout
<< msg
<< "\n";
1053 void OnMacro(int macroId
, int no_args
, bool start
)
1055 switch (convertMode
)
1059 RTFOnMacro(macroId
, no_args
, start
);
1064 XLPOnMacro(macroId
, no_args
, start
);
1069 HTMLOnMacro(macroId
, no_args
, start
);
1075 bool OnArgument(int macroId
, int arg_no
, bool start
)
1077 switch (convertMode
)
1081 return RTFOnArgument(macroId
, arg_no
, start
);
1086 return XLPOnArgument(macroId
, arg_no
, start
);
1091 return HTMLOnArgument(macroId
, arg_no
, start
);
1101 #if defined(__WXMSW__) && !defined(NO_GUI)
1107 wxConnectionBase
*Tex2RTFServer::OnAcceptConnection(const wxString
& topic
)
1109 if (topic
== "TEX2RTF")
1112 ipc_buffer
= new char[1000];
1114 return new Tex2RTFConnection(ipc_buffer
, 4000);
1124 Tex2RTFConnection::Tex2RTFConnection(char *buf
, int size
):wxDDEConnection(buf
, size
)
1128 Tex2RTFConnection::~Tex2RTFConnection(void)
1132 bool SplitCommand(char *data
, char *firstArg
, char *secondArg
)
1137 int len
= strlen(data
);
1139 // Find first argument (command name)
1142 if (data
[i
] == ' ' || data
[i
] == 0)
1146 firstArg
[i
] = data
[i
];
1153 // Find second argument
1156 while (data
[i
] != 0)
1158 secondArg
[j
] = data
[i
];
1167 bool Tex2RTFConnection::OnExecute(const wxString
& topic
, char *data
, int size
, int format
)
1169 strcpy(Tex2RTFLastStatus
, "OK");
1172 char secondArg
[300];
1173 if (SplitCommand(data
, firstArg
, secondArg
))
1175 bool hasArg
= (strlen(secondArg
) > 0);
1176 if (strcmp(firstArg
, "INPUT") == 0 && hasArg
)
1178 if (InputFile
) delete[] InputFile
;
1179 InputFile
= copystring(secondArg
);
1183 wxString str
= wxFileNameFromPath(InputFile
);
1184 sprintf(buf
, "Tex2RTF [%s]", (const char*) str
);
1185 frame
->SetTitle(buf
);
1188 else if (strcmp(firstArg
, "OUTPUT") == 0 && hasArg
)
1190 if (OutputFile
) delete[] OutputFile
;
1191 OutputFile
= copystring(secondArg
);
1193 else if (strcmp(firstArg
, "GO") == 0)
1195 strcpy(Tex2RTFLastStatus
, "WORKING");
1197 strcpy(Tex2RTFLastStatus
, "CONVERSION ERROR");
1199 strcpy(Tex2RTFLastStatus
, "OK");
1201 else if (strcmp(firstArg
, "EXIT") == 0)
1203 if (frame
) frame
->Close();
1205 else if (strcmp(firstArg
, "MINIMIZE") == 0 || strcmp(firstArg
, "ICONIZE") == 0)
1208 frame
->Iconize(TRUE
);
1210 else if (strcmp(firstArg
, "SHOW") == 0 || strcmp(firstArg
, "RESTORE") == 0)
1214 frame
->Iconize(FALSE
);
1220 // Try for a setting
1221 strcpy(Tex2RTFLastStatus
, RegisterSetting(firstArg
, secondArg
, FALSE
));
1223 if (frame
&& strcmp(firstArg
, "conversionMode") == 0)
1228 if (winHelp
&& (convertMode
== TEX_RTF
))
1229 strcat(buf
, "WinHelp RTF");
1230 else if (!winHelp
&& (convertMode
== TEX_RTF
))
1231 strcat(buf
, "linear RTF");
1232 else if (convertMode
== TEX_HTML
) strcat(buf
, "HTML");
1233 else if (convertMode
== TEX_XLP
) strcat(buf
, "XLP");
1234 strcat(buf
, " mode.");
1235 frame
->SetStatusText(buf
, 1);
1243 char *Tex2RTFConnection::OnRequest(const wxString
& topic
, const wxString
& item
, int *size
, int format
)
1245 return Tex2RTFLastStatus
;
1252 //void wxObject::Dump(ostream& str)
1254 // if (GetClassInfo() && GetClassInfo()->GetClassName())
1255 // str << GetClassInfo()->GetClassName();
1257 // str << "unknown object class";