Missing wxUSE_... flags and source cleaning.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35305 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1826,7 +1826,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
|
||||
static bool CheckTypeRef()
|
||||
{
|
||||
wxString typeDecl = GetArgData();
|
||||
if( !typeDecl.IsEmpty() ) {
|
||||
if( !typeDecl.empty() ) {
|
||||
typeDecl.Replace(wxT("\\"),wxT(""));
|
||||
wxString label = typeDecl;
|
||||
label.Replace(wxT("const"),wxT(""));
|
||||
@@ -2247,7 +2247,7 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start)
|
||||
if (imageFile)
|
||||
delete[] imageFile;
|
||||
imageFile = NULL;
|
||||
if (!f.IsEmpty())
|
||||
if (!f.empty())
|
||||
{
|
||||
imageFile = copystring(f);
|
||||
}
|
||||
@@ -3031,223 +3031,222 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start)
|
||||
|
||||
bool HTMLGo(void)
|
||||
{
|
||||
fileId = 0;
|
||||
inVerbatim = false;
|
||||
indentLevel = 0;
|
||||
inTabular = false;
|
||||
startRows = false;
|
||||
tableVerticalLineLeft = false;
|
||||
tableVerticalLineRight = false;
|
||||
noColumns = 0;
|
||||
fileId = 0;
|
||||
inVerbatim = false;
|
||||
indentLevel = 0;
|
||||
inTabular = false;
|
||||
startRows = false;
|
||||
tableVerticalLineLeft = false;
|
||||
tableVerticalLineRight = false;
|
||||
noColumns = 0;
|
||||
|
||||
if (InputFile && OutputFile)
|
||||
{
|
||||
// Do some HTML-specific transformations on all the strings,
|
||||
// recursively
|
||||
Text2HTML(GetTopLevelChunk());
|
||||
|
||||
wxChar buf[300];
|
||||
if (truncateFilenames)
|
||||
wxSnprintf(buf, sizeof(buf), _T("%s.htm"), FileRoot);
|
||||
else
|
||||
wxSnprintf(buf, sizeof(buf), _T("%s_contents.html"), FileRoot);
|
||||
if (TitlepageName) delete[] TitlepageName;
|
||||
TitlepageName = copystring(buf);
|
||||
Titlepage = wxFopen(buf, _T("w"));
|
||||
|
||||
if (truncateFilenames)
|
||||
wxSnprintf(buf, sizeof(buf), _T("%s_fc.htm"), FileRoot);
|
||||
else
|
||||
wxSnprintf(buf, sizeof(buf), _T("%s_fcontents.html"), FileRoot);
|
||||
|
||||
contentsFrameName = copystring(buf);
|
||||
|
||||
Contents = wxFopen(TmpContentsName, _T("w"));
|
||||
|
||||
if (htmlFrameContents)
|
||||
if (!InputFile.empty() && !OutputFile.empty())
|
||||
{
|
||||
// FrameContents = wxFopen(TmpFrameContentsName, _T("w"));
|
||||
FrameContents = wxFopen(contentsFrameName, _T("w"));
|
||||
wxFprintf(FrameContents, _T("<HTML>\n<UL>\n"));
|
||||
}
|
||||
// Do some HTML-specific transformations on all the strings,
|
||||
// recursively
|
||||
Text2HTML(GetTopLevelChunk());
|
||||
|
||||
if (!Titlepage || !Contents)
|
||||
{
|
||||
OnError(_T("Cannot open output file!"));
|
||||
return false;
|
||||
}
|
||||
AddTexRef(_T("contents"), wxFileNameFromPath(TitlepageName), ContentsNameString);
|
||||
|
||||
wxFprintf(Contents, _T("<P><P><H2>%s</H2><P><P>\n"), ContentsNameString);
|
||||
|
||||
wxFprintf(Contents, _T("<UL>\n"));
|
||||
|
||||
SetCurrentOutput(Titlepage);
|
||||
if (htmlWorkshopFiles) HTMLWorkshopStartContents();
|
||||
OnInform(_T("Converting..."));
|
||||
|
||||
TraverseDocument();
|
||||
wxFprintf(Contents, _T("</UL>\n\n"));
|
||||
|
||||
// SetCurrentOutput(Titlepage);
|
||||
fclose(Titlepage);
|
||||
|
||||
if (Contents)
|
||||
{
|
||||
// wxFprintf(Titlepage, _T("\n</BODY></HTML>\n"));
|
||||
fclose(Contents);
|
||||
Contents = NULL;
|
||||
}
|
||||
|
||||
if (FrameContents)
|
||||
{
|
||||
wxFprintf(FrameContents, _T("\n</UL>\n"));
|
||||
wxFprintf(FrameContents, _T("</HTML>\n"));
|
||||
fclose(FrameContents);
|
||||
FrameContents = NULL;
|
||||
}
|
||||
|
||||
if (Chapters)
|
||||
{
|
||||
wxFprintf(Chapters, _T("\n</FONT></BODY></HTML>\n"));
|
||||
fclose(Chapters);
|
||||
Chapters = NULL;
|
||||
}
|
||||
if (Sections)
|
||||
{
|
||||
wxFprintf(Sections, _T("\n</FONT></BODY></HTML>\n"));
|
||||
fclose(Sections);
|
||||
Sections = NULL;
|
||||
}
|
||||
if (Subsections && !combineSubSections)
|
||||
{
|
||||
wxFprintf(Subsections, _T("\n</FONT></BODY></HTML>\n"));
|
||||
fclose(Subsections);
|
||||
Subsections = NULL;
|
||||
}
|
||||
if (Subsubsections && !combineSubSections)
|
||||
{
|
||||
wxFprintf(Subsubsections, _T("\n</FONT></BODY></HTML>\n"));
|
||||
fclose(Subsubsections);
|
||||
Subsubsections = NULL;
|
||||
}
|
||||
if ( SectionContentsFD )
|
||||
{
|
||||
fclose(SectionContentsFD);
|
||||
SectionContentsFD = NULL;
|
||||
}
|
||||
|
||||
// Create a temporary file for the title page header, add some info,
|
||||
// and concat the titlepage just generated.
|
||||
// This is necessary in order to put the title of the document
|
||||
// at the TOP of the file within <HEAD>, even though we only find out
|
||||
// what it is later on.
|
||||
FILE *tmpTitle = wxFopen(_T("title.tmp"), _T("w"));
|
||||
if (tmpTitle)
|
||||
{
|
||||
if (DocumentTitle)
|
||||
{
|
||||
SetCurrentOutput(tmpTitle);
|
||||
HTMLHead();
|
||||
TexOutput(_T("\n<TITLE>"));
|
||||
TraverseChildrenFromChunk(DocumentTitle);
|
||||
TexOutput(_T("</TITLE></HEAD>\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetCurrentOutput(tmpTitle);
|
||||
HTMLHeadTo(tmpTitle);
|
||||
if (contentsString)
|
||||
wxFprintf(tmpTitle, _T("<TITLE>%s</TITLE></HEAD>\n\n"), contentsString);
|
||||
else
|
||||
wxFprintf(tmpTitle, _T("<TITLE>%s</TITLE></HEAD>\n\n"), wxFileNameFromPath(FileRoot));
|
||||
}
|
||||
|
||||
// Output frame information
|
||||
if (htmlFrameContents)
|
||||
{
|
||||
wxChar firstFileName[300];
|
||||
wxChar buf[300];
|
||||
if (truncateFilenames)
|
||||
wxSnprintf(firstFileName, sizeof(firstFileName), _T("%s1.htm"), FileRoot);
|
||||
wxSnprintf(buf, sizeof(buf), _T("%s.htm"), FileRoot);
|
||||
else
|
||||
wxStrcpy(firstFileName, gs_filenames[1].c_str());
|
||||
wxSnprintf(buf, sizeof(buf), _T("%s_contents.html"), FileRoot);
|
||||
if (TitlepageName) delete[] TitlepageName;
|
||||
TitlepageName = copystring(buf);
|
||||
Titlepage = wxFopen(buf, _T("w"));
|
||||
|
||||
wxFprintf(tmpTitle, _T("<FRAMESET COLS=\"30%%,70%%\">\n"));
|
||||
if (truncateFilenames)
|
||||
wxSnprintf(buf, sizeof(buf), _T("%s_fc.htm"), FileRoot);
|
||||
else
|
||||
wxSnprintf(buf, sizeof(buf), _T("%s_fcontents.html"), FileRoot);
|
||||
|
||||
wxFprintf(tmpTitle, _T("<FRAME SRC=\"%s\">\n"), ConvertCase(wxFileNameFromPath(contentsFrameName)));
|
||||
wxFprintf(tmpTitle, _T("<FRAME SRC=\"%s\" NAME=\"mainwindow\">\n"), ConvertCase(wxFileNameFromPath(firstFileName)));
|
||||
wxFprintf(tmpTitle, _T("</FRAMESET>\n"));
|
||||
contentsFrameName = copystring(buf);
|
||||
|
||||
wxFprintf(tmpTitle, _T("<NOFRAMES>\n"));
|
||||
}
|
||||
Contents = wxFopen(TmpContentsName, _T("w"));
|
||||
|
||||
// Output <BODY...> to temporary title page
|
||||
OutputBodyStart();
|
||||
fflush(tmpTitle);
|
||||
|
||||
// Concat titlepage
|
||||
FILE *fd = wxFopen(TitlepageName, _T("r"));
|
||||
if (fd)
|
||||
{
|
||||
int ch = getc(fd);
|
||||
while (ch != EOF)
|
||||
if (htmlFrameContents)
|
||||
{
|
||||
wxPutc(ch, tmpTitle);
|
||||
ch = getc(fd);
|
||||
// FrameContents = wxFopen(TmpFrameContentsName, _T("w"));
|
||||
FrameContents = wxFopen(contentsFrameName, _T("w"));
|
||||
wxFprintf(FrameContents, _T("<HTML>\n<UL>\n"));
|
||||
}
|
||||
fclose(fd);
|
||||
}
|
||||
|
||||
wxFprintf(tmpTitle, _T("\n</FONT></BODY>\n"));
|
||||
if (!Titlepage || !Contents)
|
||||
{
|
||||
OnError(_T("Cannot open output file!"));
|
||||
return false;
|
||||
}
|
||||
AddTexRef(_T("contents"), wxFileNameFromPath(TitlepageName), ContentsNameString);
|
||||
|
||||
if (htmlFrameContents)
|
||||
{
|
||||
wxFprintf(tmpTitle, _T("\n</NOFRAMES>\n"));
|
||||
}
|
||||
wxFprintf(tmpTitle, _T("\n</HTML>\n"));
|
||||
wxFprintf(Contents, _T("<P><P><H2>%s</H2><P><P>\n"), ContentsNameString);
|
||||
|
||||
fclose(tmpTitle);
|
||||
if (wxFileExists(TitlepageName)) wxRemoveFile(TitlepageName);
|
||||
if (!wxRenameFile(_T("title.tmp"), TitlepageName))
|
||||
{
|
||||
wxCopyFile(_T("title.tmp"), TitlepageName);
|
||||
wxRemoveFile(_T("title.tmp"));
|
||||
}
|
||||
wxFprintf(Contents, _T("<UL>\n"));
|
||||
|
||||
SetCurrentOutput(Titlepage);
|
||||
if (htmlWorkshopFiles) HTMLWorkshopStartContents();
|
||||
OnInform(_T("Converting..."));
|
||||
|
||||
TraverseDocument();
|
||||
wxFprintf(Contents, _T("</UL>\n\n"));
|
||||
|
||||
// SetCurrentOutput(Titlepage);
|
||||
fclose(Titlepage);
|
||||
|
||||
if (Contents)
|
||||
{
|
||||
// wxFprintf(Titlepage, _T("\n</BODY></HTML>\n"));
|
||||
fclose(Contents);
|
||||
Contents = NULL;
|
||||
}
|
||||
|
||||
if (FrameContents)
|
||||
{
|
||||
wxFprintf(FrameContents, _T("\n</UL>\n"));
|
||||
wxFprintf(FrameContents, _T("</HTML>\n"));
|
||||
fclose(FrameContents);
|
||||
FrameContents = NULL;
|
||||
}
|
||||
|
||||
if (Chapters)
|
||||
{
|
||||
wxFprintf(Chapters, _T("\n</FONT></BODY></HTML>\n"));
|
||||
fclose(Chapters);
|
||||
Chapters = NULL;
|
||||
}
|
||||
if (Sections)
|
||||
{
|
||||
wxFprintf(Sections, _T("\n</FONT></BODY></HTML>\n"));
|
||||
fclose(Sections);
|
||||
Sections = NULL;
|
||||
}
|
||||
if (Subsections && !combineSubSections)
|
||||
{
|
||||
wxFprintf(Subsections, _T("\n</FONT></BODY></HTML>\n"));
|
||||
fclose(Subsections);
|
||||
Subsections = NULL;
|
||||
}
|
||||
if (Subsubsections && !combineSubSections)
|
||||
{
|
||||
wxFprintf(Subsubsections, _T("\n</FONT></BODY></HTML>\n"));
|
||||
fclose(Subsubsections);
|
||||
Subsubsections = NULL;
|
||||
}
|
||||
if ( SectionContentsFD )
|
||||
{
|
||||
fclose(SectionContentsFD);
|
||||
SectionContentsFD = NULL;
|
||||
}
|
||||
|
||||
// Create a temporary file for the title page header, add some info,
|
||||
// and concat the titlepage just generated.
|
||||
// This is necessary in order to put the title of the document
|
||||
// at the TOP of the file within <HEAD>, even though we only find out
|
||||
// what it is later on.
|
||||
FILE *tmpTitle = wxFopen(_T("title.tmp"), _T("w"));
|
||||
if (tmpTitle)
|
||||
{
|
||||
if (DocumentTitle)
|
||||
{
|
||||
SetCurrentOutput(tmpTitle);
|
||||
HTMLHead();
|
||||
TexOutput(_T("\n<TITLE>"));
|
||||
TraverseChildrenFromChunk(DocumentTitle);
|
||||
TexOutput(_T("</TITLE></HEAD>\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetCurrentOutput(tmpTitle);
|
||||
HTMLHeadTo(tmpTitle);
|
||||
if (contentsString)
|
||||
wxFprintf(tmpTitle, _T("<TITLE>%s</TITLE></HEAD>\n\n"), contentsString);
|
||||
else
|
||||
wxFprintf(tmpTitle, _T("<TITLE>%s</TITLE></HEAD>\n\n"), wxFileNameFromPath(FileRoot));
|
||||
}
|
||||
|
||||
// Output frame information
|
||||
if (htmlFrameContents)
|
||||
{
|
||||
wxChar firstFileName[300];
|
||||
if (truncateFilenames)
|
||||
wxSnprintf(firstFileName, sizeof(firstFileName), _T("%s1.htm"), FileRoot);
|
||||
else
|
||||
wxStrcpy(firstFileName, gs_filenames[1].c_str());
|
||||
|
||||
wxFprintf(tmpTitle, _T("<FRAMESET COLS=\"30%%,70%%\">\n"));
|
||||
|
||||
wxFprintf(tmpTitle, _T("<FRAME SRC=\"%s\">\n"), ConvertCase(wxFileNameFromPath(contentsFrameName)));
|
||||
wxFprintf(tmpTitle, _T("<FRAME SRC=\"%s\" NAME=\"mainwindow\">\n"), ConvertCase(wxFileNameFromPath(firstFileName)));
|
||||
wxFprintf(tmpTitle, _T("</FRAMESET>\n"));
|
||||
|
||||
wxFprintf(tmpTitle, _T("<NOFRAMES>\n"));
|
||||
}
|
||||
|
||||
// Output <BODY...> to temporary title page
|
||||
OutputBodyStart();
|
||||
fflush(tmpTitle);
|
||||
|
||||
// Concat titlepage
|
||||
FILE *fd = wxFopen(TitlepageName, _T("r"));
|
||||
if (fd)
|
||||
{
|
||||
int ch = getc(fd);
|
||||
while (ch != EOF)
|
||||
{
|
||||
wxPutc(ch, tmpTitle);
|
||||
ch = getc(fd);
|
||||
}
|
||||
fclose(fd);
|
||||
}
|
||||
|
||||
wxFprintf(tmpTitle, _T("\n</FONT></BODY>\n"));
|
||||
|
||||
if (htmlFrameContents)
|
||||
{
|
||||
wxFprintf(tmpTitle, _T("\n</NOFRAMES>\n"));
|
||||
}
|
||||
wxFprintf(tmpTitle, _T("\n</HTML>\n"));
|
||||
|
||||
fclose(tmpTitle);
|
||||
if (wxFileExists(TitlepageName)) wxRemoveFile(TitlepageName);
|
||||
if (!wxRenameFile(_T("title.tmp"), TitlepageName))
|
||||
{
|
||||
wxCopyFile(_T("title.tmp"), TitlepageName);
|
||||
wxRemoveFile(_T("title.tmp"));
|
||||
}
|
||||
}
|
||||
|
||||
if (lastFileName) delete[] lastFileName;
|
||||
lastFileName = NULL;
|
||||
if (lastTopic) delete[] lastTopic;
|
||||
lastTopic = NULL;
|
||||
|
||||
if (wxFileExists(ContentsName)) wxRemoveFile(ContentsName);
|
||||
|
||||
if (!wxRenameFile(TmpContentsName, ContentsName))
|
||||
{
|
||||
wxCopyFile(TmpContentsName, ContentsName);
|
||||
wxRemoveFile(TmpContentsName);
|
||||
}
|
||||
|
||||
// Generate .htx file if requested
|
||||
if (htmlIndex)
|
||||
{
|
||||
wxChar htmlIndexName[300];
|
||||
wxSnprintf(htmlIndexName, sizeof(htmlIndexName), _T("%s.htx"), FileRoot);
|
||||
GenerateHTMLIndexFile(htmlIndexName);
|
||||
}
|
||||
|
||||
// Generate HTML Help Workshop files if requested
|
||||
if (htmlWorkshopFiles)
|
||||
{
|
||||
HTMLWorkshopEndContents();
|
||||
GenerateHTMLWorkshopFiles(FileRoot);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (lastFileName) delete[] lastFileName;
|
||||
lastFileName = NULL;
|
||||
if (lastTopic) delete[] lastTopic;
|
||||
lastTopic = NULL;
|
||||
|
||||
if (wxFileExists(ContentsName)) wxRemoveFile(ContentsName);
|
||||
|
||||
if (!wxRenameFile(TmpContentsName, ContentsName))
|
||||
{
|
||||
wxCopyFile(TmpContentsName, ContentsName);
|
||||
wxRemoveFile(TmpContentsName);
|
||||
}
|
||||
|
||||
// Generate .htx file if requested
|
||||
if (htmlIndex)
|
||||
{
|
||||
wxChar htmlIndexName[300];
|
||||
wxSnprintf(htmlIndexName, sizeof(htmlIndexName), _T("%s.htx"), FileRoot);
|
||||
GenerateHTMLIndexFile(htmlIndexName);
|
||||
}
|
||||
|
||||
// Generate HTML Help Workshop files if requested
|
||||
if (htmlWorkshopFiles)
|
||||
{
|
||||
HTMLWorkshopEndContents();
|
||||
GenerateHTMLWorkshopFiles(FileRoot);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Output .htx index file
|
||||
|
@@ -521,65 +521,65 @@ void OutputNumberStyle(wxChar *numberStyle)
|
||||
* Write a Windows help project file
|
||||
*/
|
||||
|
||||
bool WriteHPJ(wxChar *filename)
|
||||
bool WriteHPJ(const wxString& filename)
|
||||
{
|
||||
wxChar hpjFilename[256];
|
||||
wxChar helpFile[50];
|
||||
wxChar rtfFile[50];
|
||||
wxStrcpy(hpjFilename, filename);
|
||||
StripExtension(hpjFilename);
|
||||
wxStrcat(hpjFilename, _T(".hpj"));
|
||||
wxChar hpjFilename[256];
|
||||
wxChar helpFile[50];
|
||||
wxChar rtfFile[50];
|
||||
wxStrcpy(hpjFilename, filename);
|
||||
StripExtension(hpjFilename);
|
||||
wxStrcat(hpjFilename, _T(".hpj"));
|
||||
|
||||
wxStrcpy(helpFile, wxFileNameFromPath(filename));
|
||||
StripExtension(helpFile);
|
||||
wxStrcpy(rtfFile, helpFile);
|
||||
wxStrcat(helpFile, _T(".hlp"));
|
||||
wxStrcat(rtfFile, _T(".rtf"));
|
||||
wxStrcpy(helpFile, wxFileNameFromPath(filename));
|
||||
StripExtension(helpFile);
|
||||
wxStrcpy(rtfFile, helpFile);
|
||||
wxStrcat(helpFile, _T(".hlp"));
|
||||
wxStrcat(rtfFile, _T(".rtf"));
|
||||
|
||||
FILE *fd = wxFopen(hpjFilename, _T("w"));
|
||||
if (!fd)
|
||||
return false;
|
||||
FILE *fd = wxFopen(hpjFilename, _T("w"));
|
||||
if (!fd)
|
||||
return false;
|
||||
|
||||
wxChar *helpTitle = winHelpTitle;
|
||||
if (!helpTitle)
|
||||
helpTitle = _T("Untitled");
|
||||
wxChar *helpTitle = winHelpTitle;
|
||||
if (!helpTitle)
|
||||
helpTitle = _T("Untitled");
|
||||
|
||||
wxString thePath = wxPathOnly(InputFile);
|
||||
if (thePath.IsEmpty())
|
||||
thePath = _T(".");
|
||||
wxFprintf(fd, _T("[OPTIONS]\n"));
|
||||
wxFprintf(fd, _T("BMROOT=%s ; Assume that bitmaps are where the source is\n"), thePath.c_str());
|
||||
wxFprintf(fd, _T("TITLE=%s\n"), helpTitle);
|
||||
wxFprintf(fd, _T("CONTENTS=Contents\n"));
|
||||
wxString thePath = wxPathOnly(InputFile);
|
||||
if (thePath.empty())
|
||||
thePath = _T(".");
|
||||
wxFprintf(fd, _T("[OPTIONS]\n"));
|
||||
wxFprintf(fd, _T("BMROOT=%s ; Assume that bitmaps are where the source is\n"), thePath.c_str());
|
||||
wxFprintf(fd, _T("TITLE=%s\n"), helpTitle);
|
||||
wxFprintf(fd, _T("CONTENTS=Contents\n"));
|
||||
|
||||
if (winHelpVersion > 3)
|
||||
{
|
||||
wxFprintf(fd, _T("; COMPRESS=12 Hall Zeck ; Max compression, but needs lots of memory\n"));
|
||||
wxFprintf(fd, _T("COMPRESS=8 Zeck\n"));
|
||||
wxFprintf(fd, _T("LCID=0x809 0x0 0x0 ;English (British)\n"));
|
||||
wxFprintf(fd, _T("HLP=.\\%s.hlp\n"), wxFileNameFromPath(FileRoot));
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFprintf(fd, _T("COMPRESS=HIGH\n"));
|
||||
}
|
||||
wxFprintf(fd, _T("\n"));
|
||||
|
||||
if (winHelpVersion > 3)
|
||||
{
|
||||
wxFprintf(fd, _T("[WINDOWS]\n"));
|
||||
wxFprintf(fd, _T("Main=\"\",(553,102,400,600),20736,(r14876671),(r12632256),f3\n"));
|
||||
if (winHelpVersion > 3)
|
||||
{
|
||||
wxFprintf(fd, _T("; COMPRESS=12 Hall Zeck ; Max compression, but needs lots of memory\n"));
|
||||
wxFprintf(fd, _T("COMPRESS=8 Zeck\n"));
|
||||
wxFprintf(fd, _T("LCID=0x809 0x0 0x0 ;English (British)\n"));
|
||||
wxFprintf(fd, _T("HLP=.\\%s.hlp\n"), wxFileNameFromPath(FileRoot));
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFprintf(fd, _T("COMPRESS=HIGH\n"));
|
||||
}
|
||||
wxFprintf(fd, _T("\n"));
|
||||
}
|
||||
|
||||
wxFprintf(fd, _T("[FILES]\n%s\n\n"), rtfFile);
|
||||
wxFprintf(fd, _T("[CONFIG]\n"));
|
||||
if (useUpButton)
|
||||
wxFprintf(fd, _T("CreateButton(\"Up\", \"&Up\", \"JumpId(`%s', `Contents')\")\n"), helpFile);
|
||||
wxFprintf(fd, _T("BrowseButtons()\n\n"));
|
||||
wxFprintf(fd, _T("[MAP]\n\n[BITMAPS]\n\n"));
|
||||
fclose(fd);
|
||||
return true;
|
||||
if (winHelpVersion > 3)
|
||||
{
|
||||
wxFprintf(fd, _T("[WINDOWS]\n"));
|
||||
wxFprintf(fd, _T("Main=\"\",(553,102,400,600),20736,(r14876671),(r12632256),f3\n"));
|
||||
wxFprintf(fd, _T("\n"));
|
||||
}
|
||||
|
||||
wxFprintf(fd, _T("[FILES]\n%s\n\n"), rtfFile);
|
||||
wxFprintf(fd, _T("[CONFIG]\n"));
|
||||
if (useUpButton)
|
||||
wxFprintf(fd, _T("CreateButton(\"Up\", \"&Up\", \"JumpId(`%s', `Contents')\")\n"), helpFile);
|
||||
wxFprintf(fd, _T("BrowseButtons()\n\n"));
|
||||
wxFprintf(fd, _T("[MAP]\n\n[BITMAPS]\n\n"));
|
||||
fclose(fd);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -5170,7 +5170,7 @@ bool RTFGo(void)
|
||||
inVerbatim = false;
|
||||
browseId = 0;
|
||||
|
||||
if (InputFile && OutputFile)
|
||||
if (!InputFile.empty() && !OutputFile.empty())
|
||||
{
|
||||
// Do some RTF-specific transformations on all the strings,
|
||||
// recursively
|
||||
@@ -5312,11 +5312,11 @@ bool RTFGo(void)
|
||||
if ((wxStrcmp(outputDirStr.c_str(),_T("")) == 0) || // no path specified on output file
|
||||
(wxStrcmp(cwdStr,outputDirStr.c_str()) == 0)) // paths do not match
|
||||
{
|
||||
wxRenameFile(_T("tmp1.rtf"), OutputFile);
|
||||
wxRenameFile(_T("tmp1.rtf"), OutputFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
wxCopyFile(_T("tmp1.rtf"), OutputFile);
|
||||
wxCopyFile(_T("tmp1.rtf"), OutputFile);
|
||||
}
|
||||
delete [] cwdStr;
|
||||
Tex2RTFYield(true);
|
||||
@@ -5342,7 +5342,7 @@ bool RTFGo(void)
|
||||
wxRemoveFile(_T("popups.rtf"));
|
||||
}
|
||||
if (winHelp && generateHPJ)
|
||||
WriteHPJ(OutputFile);
|
||||
WriteHPJ(OutputFile);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@@ -430,7 +430,7 @@ bool readInVerbatim = false; // Within a verbatim, but not nec. verbatiminput
|
||||
|
||||
unsigned long leftCurly = 0;
|
||||
unsigned long rightCurly = 0;
|
||||
static wxString currentFileName = _T("");
|
||||
static wxString currentFileName = wxEmptyString;
|
||||
|
||||
bool read_a_line(wxChar *buf)
|
||||
{
|
||||
@@ -693,7 +693,7 @@ bool read_a_line(wxChar *buf)
|
||||
|
||||
wxString actualFile = TexPathList.FindValidPath(fileName);
|
||||
currentFileName = actualFile;
|
||||
if (actualFile == _T(""))
|
||||
if (actualFile.empty())
|
||||
{
|
||||
wxString errBuf;
|
||||
errBuf.Printf(_T("Could not find file: %s"),fileName);
|
||||
@@ -767,7 +767,7 @@ bool read_a_line(wxChar *buf)
|
||||
return read_a_line(buf);
|
||||
|
||||
wxString actualFile = TexPathList.FindValidPath(fileNameStr);
|
||||
if (actualFile == _T(""))
|
||||
if (actualFile.empty())
|
||||
{
|
||||
wxChar buf2[400];
|
||||
wxSnprintf(buf2, sizeof(buf2), _T("%s.tex"), fileNameStr.c_str());
|
||||
@@ -775,7 +775,7 @@ bool read_a_line(wxChar *buf)
|
||||
}
|
||||
currentFileName = actualFile;
|
||||
|
||||
if (actualFile == _T(""))
|
||||
if (actualFile.empty())
|
||||
{
|
||||
wxString errBuf;
|
||||
errBuf.Printf(_T("Could not find file: %s"),fileName);
|
||||
@@ -1663,34 +1663,34 @@ int ParseMacroBody(const wxChar *WXUNUSED(macro_name), TexChunk *parent,
|
||||
return pos;
|
||||
}
|
||||
|
||||
bool TexLoadFile(wxChar *filename)
|
||||
bool TexLoadFile(const wxString& filename)
|
||||
{
|
||||
static wxChar *line_buffer;
|
||||
stopRunning = false;
|
||||
wxStrcpy(TexFileRoot, filename);
|
||||
StripExtension(TexFileRoot);
|
||||
wxSnprintf(TexBibName, 300, _T("%s.bb"), TexFileRoot);
|
||||
wxSnprintf(TexTmpBibName, 300, _T("%s.bb1"), TexFileRoot);
|
||||
static wxChar *line_buffer;
|
||||
stopRunning = false;
|
||||
wxStrcpy(TexFileRoot, filename);
|
||||
StripExtension(TexFileRoot);
|
||||
wxSnprintf(TexBibName, 300, _T("%s.bb"), TexFileRoot);
|
||||
wxSnprintf(TexTmpBibName, 300, _T("%s.bb1"), TexFileRoot);
|
||||
|
||||
TexPathList.EnsureFileAccessible(filename);
|
||||
TexPathList.EnsureFileAccessible(filename);
|
||||
|
||||
if (line_buffer)
|
||||
delete line_buffer;
|
||||
if (line_buffer)
|
||||
delete line_buffer;
|
||||
|
||||
line_buffer = new wxChar[MAX_LINE_BUFFER_SIZE];
|
||||
line_buffer = new wxChar[MAX_LINE_BUFFER_SIZE];
|
||||
|
||||
Inputs[0] = wxFopen(filename, _T("r"));
|
||||
LineNumbers[0] = 1;
|
||||
FileNames[0] = copystring(filename);
|
||||
if (Inputs[0])
|
||||
{
|
||||
read_a_line(line_buffer);
|
||||
ParseMacroBody(_T("toplevel"), TopLevel, 1, line_buffer, 0, NULL, true);
|
||||
if (Inputs[0]) fclose(Inputs[0]);
|
||||
return true;
|
||||
}
|
||||
Inputs[0] = wxFopen(filename, _T("r"));
|
||||
LineNumbers[0] = 1;
|
||||
FileNames[0] = copystring(filename);
|
||||
if (Inputs[0])
|
||||
{
|
||||
read_a_line(line_buffer);
|
||||
ParseMacroBody(_T("toplevel"), TopLevel, 1, line_buffer, 0, NULL, true);
|
||||
if (Inputs[0]) fclose(Inputs[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
TexMacroDef::TexMacroDef(int the_id, const wxChar *the_name, int n, bool ig, bool forbidLevel)
|
||||
@@ -3460,12 +3460,12 @@ bool DefaultOnArgument(int macroId, int arg_no, bool start)
|
||||
wxChar fileBuf[300];
|
||||
wxStrcpy(fileBuf, bibFile);
|
||||
wxString actualFile = TexPathList.FindValidPath(fileBuf);
|
||||
if (actualFile == _T(""))
|
||||
if (actualFile.empty())
|
||||
{
|
||||
wxStrcat(fileBuf, _T(".bib"));
|
||||
actualFile = TexPathList.FindValidPath(fileBuf);
|
||||
}
|
||||
if (actualFile != _T(""))
|
||||
if (!actualFile.empty())
|
||||
{
|
||||
if (!ReadBib((wxChar*) (const wxChar*) actualFile))
|
||||
{
|
||||
@@ -3714,4 +3714,3 @@ bool DefaultOnArgument(int macroId, int arg_no, bool start)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -20,7 +20,7 @@
|
||||
* Conversion modes
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#define TEX_RTF 1
|
||||
#define TEX_XLP 2
|
||||
#define TEX_HTML 3
|
||||
@@ -145,7 +145,7 @@ extern wxHashTable MacroDefs;
|
||||
extern wxStringList IgnorableInputFiles; // Ignorable \input files, e.g. psbox.tex
|
||||
|
||||
bool read_a_line(wxChar *buf);
|
||||
bool TexLoadFile(wxChar *filename);
|
||||
bool TexLoadFile(const wxString& filename);
|
||||
int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos,
|
||||
wxChar *environment = NULL, bool parseArgToBrace = true, TexChunk *customMacroArgs = NULL);
|
||||
int ParseMacroBody(const wxChar *macro_name, TexChunk *parent, int no_args,
|
||||
@@ -328,7 +328,7 @@ extern void FakeCurrentSection(wxChar *fakeSection, bool addToContents = true);
|
||||
* Local to Tex2Any library
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
extern wxChar *currentArgData;
|
||||
extern bool haveArgData; // If true, we're simulating the data.
|
||||
void StartSimulateArgument(wxChar *data);
|
||||
@@ -385,7 +385,7 @@ void SetFontSizes(int pointSize);
|
||||
* IF one exists. Inserts zero into buffer.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
void StripExtension(wxChar *buffer);
|
||||
|
||||
/*
|
||||
@@ -408,7 +408,7 @@ class TexRef: public wxObject
|
||||
* Add a reference
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
void AddTexRef(wxChar *name, wxChar *file = NULL, wxChar *sectionName = NULL,
|
||||
int chapter = 0, int section = 0, int subsection = 0, int subsubsection = 0);
|
||||
|
||||
@@ -828,7 +828,7 @@ extern void InitialiseColourTable(void);
|
||||
#define ltURLREF 551
|
||||
#define ltUPPERCASE 552
|
||||
#define ltUSEPACKAGE 553
|
||||
|
||||
|
||||
#define ltVDOTS 570
|
||||
#define ltVERBATIMINPUT 571
|
||||
#define ltVERBATIM 572
|
||||
|
@@ -49,6 +49,8 @@
|
||||
#endif
|
||||
#endif // !NO_GUI
|
||||
|
||||
#include "wx/utils.h"
|
||||
|
||||
#if wxUSE_IOSTREAMH
|
||||
#include <iostream.h>
|
||||
#include <fstream.h>
|
||||
@@ -114,8 +116,8 @@ FILE *Subsubsections = NULL;
|
||||
FILE *Popups = NULL;
|
||||
FILE *WinHelpContentsFile = NULL;
|
||||
|
||||
wxChar *InputFile = NULL;
|
||||
wxChar *OutputFile = NULL;
|
||||
wxString InputFile;
|
||||
wxString OutputFile;
|
||||
wxChar *MacroFile = copystring(_T("tex2rtf.ini"));
|
||||
|
||||
wxChar *FileRoot = NULL;
|
||||
@@ -168,37 +170,37 @@ bool MyApp::OnInit()
|
||||
// Read input/output files
|
||||
if (argc > 1)
|
||||
{
|
||||
if (argv[1][0] != '-')
|
||||
{
|
||||
InputFile = argv[1];
|
||||
n ++;
|
||||
|
||||
if (argc > 2)
|
||||
if (argv[1][0] != _T('-'))
|
||||
{
|
||||
if (argv[2][0] != '-')
|
||||
{
|
||||
OutputFile = argv[2];
|
||||
InputFile = argv[1];
|
||||
n ++;
|
||||
}
|
||||
|
||||
if (argc > 2)
|
||||
{
|
||||
if (argv[2][0] != _T('-'))
|
||||
{
|
||||
OutputFile = argv[2];
|
||||
n ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NO_GUI
|
||||
if (!InputFile || !OutputFile)
|
||||
if (InputFile.empty() || OutputFile.empty())
|
||||
{
|
||||
wxSTD cout << "Tex2RTF: input or output file is missing.\n";
|
||||
ShowOptions();
|
||||
exit(1);
|
||||
wxSTD cout << "Tex2RTF: input or output file is missing.\n";
|
||||
ShowOptions();
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (InputFile)
|
||||
if (!InputFile.empty())
|
||||
{
|
||||
TexPathList.EnsureFileAccessible(InputFile);
|
||||
TexPathList.EnsureFileAccessible(InputFile);
|
||||
}
|
||||
if (!InputFile || !OutputFile)
|
||||
isInteractive = true;
|
||||
if (InputFile.empty() || OutputFile.empty())
|
||||
isInteractive = true;
|
||||
|
||||
int i;
|
||||
for (i = n; i < argc;)
|
||||
@@ -333,10 +335,10 @@ bool MyApp::OnInit()
|
||||
// TODO: uncomment this when we have tex2rtf.xpm
|
||||
frame->SetIcon(wxICON(tex2rtf));
|
||||
|
||||
if (InputFile)
|
||||
if (!InputFile.empty())
|
||||
{
|
||||
wxSnprintf(buf, sizeof(buf), _T("Tex2RTF [%s]"), wxFileNameFromPath(InputFile));
|
||||
frame->SetTitle(buf);
|
||||
wxSnprintf(buf, sizeof(buf), _T("Tex2RTF [%s]"), wxFileNameFromPath(InputFile));
|
||||
frame->SetTitle(buf);
|
||||
}
|
||||
|
||||
// Make a menubar
|
||||
@@ -384,7 +386,7 @@ bool MyApp::OnInit()
|
||||
menuBar->Append(help_menu, _T("&Help"));
|
||||
|
||||
frame->SetMenuBar(menuBar);
|
||||
frame->textWindow = new wxTextCtrl(frame, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_READONLY|wxTE_MULTILINE);
|
||||
frame->textWindow = new wxTextCtrl(frame, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY|wxTE_MULTILINE);
|
||||
|
||||
(*frame->textWindow) << _T("Welcome to Tex2RTF.\n");
|
||||
// ShowOptions();
|
||||
@@ -393,7 +395,7 @@ bool MyApp::OnInit()
|
||||
#if wxUSE_MS_HTML_HELP && !defined(__WXUNIVERSAL__)
|
||||
HelpInstance = new wxCHMHelpController;
|
||||
#else
|
||||
HelpInstance = new wxHtmlHelpController;
|
||||
HelpInstance = new wxHelpController;
|
||||
#endif
|
||||
HelpInstance->Initialize(_T("tex2rtf"));
|
||||
#endif // wxUSE_HELP
|
||||
@@ -707,103 +709,107 @@ void MyFrame::OnSetOutput(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
void MyFrame::OnSaveFile(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxString s = wxFileSelector(_T("Save text to file"), _T(""), _T(""), _T("txt"), _T("*.txt"));
|
||||
if (s != _T(""))
|
||||
{
|
||||
#if wxUSE_FILEDLG
|
||||
wxString s = wxFileSelector(_T("Save text to file"), wxEmptyString, wxEmptyString, _T("txt"), _T("*.txt"));
|
||||
if (!s.empty())
|
||||
{
|
||||
textWindow->SaveFile(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
|
||||
}
|
||||
}
|
||||
#endif // wxUSE_FILEDLG
|
||||
}
|
||||
|
||||
void MyFrame::OnViewOutput(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
ChooseOutputFile();
|
||||
if (OutputFile && wxFileExists(OutputFile))
|
||||
{
|
||||
ChooseOutputFile();
|
||||
if (!OutputFile.empty() && wxFileExists(OutputFile))
|
||||
{
|
||||
textWindow->LoadFile(OutputFile);
|
||||
wxChar buf[300];
|
||||
wxString str(wxFileNameFromPath(OutputFile));
|
||||
wxSnprintf(buf, sizeof(buf), _T("Tex2RTF [%s]"), (const wxChar*) str.c_str());
|
||||
frame->SetTitle(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MyFrame::OnViewLatex(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
ChooseInputFile();
|
||||
if (InputFile && wxFileExists(InputFile))
|
||||
{
|
||||
ChooseInputFile();
|
||||
if (!InputFile.empty() && wxFileExists(InputFile))
|
||||
{
|
||||
textWindow->LoadFile(InputFile);
|
||||
wxChar buf[300];
|
||||
wxString str(wxFileNameFromPath(OutputFile));
|
||||
wxSnprintf(buf, sizeof(buf), _T("Tex2RTF [%s]"), (const wxChar*) str.c_str());
|
||||
frame->SetTitle(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MyFrame::OnLoadMacros(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
textWindow->Clear();
|
||||
wxString s = wxFileSelector(_T("Choose custom macro file"), wxPathOnly(MacroFile), wxFileNameFromPath(MacroFile), _T("ini"), _T("*.ini"));
|
||||
if (!s.empty() && wxFileExists(s))
|
||||
{
|
||||
textWindow->Clear();
|
||||
#if wxUSE_FILEDLG
|
||||
wxString s = wxFileSelector(_T("Choose custom macro file"), wxPathOnly(MacroFile), wxFileNameFromPath(MacroFile), _T("ini"), _T("*.ini"));
|
||||
if (!s.empty() && wxFileExists(s))
|
||||
{
|
||||
MacroFile = copystring(s);
|
||||
ReadCustomMacros((wxChar *)s.c_str());
|
||||
ShowCustomMacros();
|
||||
}
|
||||
}
|
||||
#endif // wxUSE_FILEDLG
|
||||
}
|
||||
|
||||
void MyFrame::OnShowMacros(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
textWindow->Clear();
|
||||
Tex2RTFYield(true);
|
||||
ShowCustomMacros();
|
||||
textWindow->Clear();
|
||||
Tex2RTFYield(true);
|
||||
ShowCustomMacros();
|
||||
}
|
||||
|
||||
void MyFrame::OnModeRTF(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
convertMode = TEX_RTF;
|
||||
winHelp = false;
|
||||
InputFile = NULL;
|
||||
OutputFile = NULL;
|
||||
convertMode = TEX_RTF;
|
||||
winHelp = false;
|
||||
InputFile = wxEmptyString;
|
||||
OutputFile = wxEmptyString;
|
||||
#if wxUSE_STATUSBAR
|
||||
SetStatusText(_T("In linear RTF mode."), 1);
|
||||
SetStatusText(_T("In linear RTF mode."), 1);
|
||||
#endif // wxUSE_STATUSBAR
|
||||
}
|
||||
|
||||
void MyFrame::OnModeWinHelp(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
convertMode = TEX_RTF;
|
||||
winHelp = true;
|
||||
InputFile = NULL;
|
||||
OutputFile = NULL;
|
||||
convertMode = TEX_RTF;
|
||||
winHelp = true;
|
||||
InputFile = wxEmptyString;
|
||||
OutputFile = wxEmptyString;
|
||||
#if wxUSE_STATUSBAR
|
||||
SetStatusText(_T("In WinHelp RTF mode."), 1);
|
||||
SetStatusText(_T("In WinHelp RTF mode."), 1);
|
||||
#endif // wxUSE_STATUSBAR
|
||||
}
|
||||
|
||||
void MyFrame::OnModeHTML(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
convertMode = TEX_HTML;
|
||||
winHelp = false;
|
||||
InputFile = NULL;
|
||||
OutputFile = NULL;
|
||||
convertMode = TEX_HTML;
|
||||
winHelp = false;
|
||||
InputFile = wxEmptyString;
|
||||
OutputFile = wxEmptyString;
|
||||
#if wxUSE_STATUSBAR
|
||||
SetStatusText(_T("In HTML mode."), 1);
|
||||
SetStatusText(_T("In HTML mode."), 1);
|
||||
#endif // wxUSE_STATUSBAR
|
||||
}
|
||||
|
||||
void MyFrame::OnModeXLP(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
convertMode = TEX_XLP;
|
||||
InputFile = NULL;
|
||||
OutputFile = NULL;
|
||||
convertMode = TEX_XLP;
|
||||
InputFile = wxEmptyString;
|
||||
OutputFile = wxEmptyString;
|
||||
#if wxUSE_STATUSBAR
|
||||
SetStatusText(_T("In XLP mode."), 1);
|
||||
SetStatusText(_T("In XLP mode."), 1);
|
||||
#endif // wxUSE_STATUSBAR
|
||||
}
|
||||
|
||||
@@ -850,81 +856,81 @@ void MyFrame::OnHelp(wxCommandEvent& WXUNUSED(event))
|
||||
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxChar buf[300];
|
||||
#ifdef __WIN32__
|
||||
wxChar *platform = _T(" (32-bit)");
|
||||
#else
|
||||
#ifdef __WXMSW__
|
||||
wxChar *platform = _T(" (16-bit)");
|
||||
#else
|
||||
wxChar *platform = _T("");
|
||||
#endif
|
||||
#endif
|
||||
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);
|
||||
wxString platform = wxGetOsDescription();
|
||||
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-2005"), versionNo, platform.c_str());
|
||||
wxMessageBox(buf, _T("About Tex2RTF"));
|
||||
}
|
||||
|
||||
void ChooseInputFile(bool force)
|
||||
{
|
||||
if (force || !InputFile)
|
||||
{
|
||||
wxString s = wxFileSelector(_T("Choose LaTeX input file"), wxPathOnly(InputFile), wxFileNameFromPath(InputFile), _T("tex"), _T("*.tex"));
|
||||
if (!s.empty())
|
||||
#if wxUSE_FILEDLG
|
||||
if (force || InputFile.empty())
|
||||
{
|
||||
// Different file, so clear index entries.
|
||||
ClearKeyWordTable();
|
||||
ResetContentsLevels(0);
|
||||
passNumber = 1;
|
||||
errorCount = 0;
|
||||
wxString s = wxFileSelector(_T("Choose LaTeX input file"), wxPathOnly(InputFile), wxFileNameFromPath(InputFile), _T("tex"), _T("*.tex"));
|
||||
if (!s.empty())
|
||||
{
|
||||
// Different file, so clear index entries.
|
||||
ClearKeyWordTable();
|
||||
ResetContentsLevels(0);
|
||||
passNumber = 1;
|
||||
errorCount = 0;
|
||||
|
||||
InputFile = copystring(s);
|
||||
wxString str = wxFileNameFromPath(InputFile);
|
||||
wxString buf;
|
||||
buf.Printf(_T("Tex2RTF [%s]"), str.c_str());
|
||||
frame->SetTitle((wxChar *)buf.c_str());
|
||||
OutputFile = NULL;
|
||||
InputFile = s;
|
||||
wxString str = wxFileNameFromPath(InputFile);
|
||||
wxString buf;
|
||||
buf.Printf(_T("Tex2RTF [%s]"), str.c_str());
|
||||
frame->SetTitle((wxChar *)buf.c_str());
|
||||
OutputFile = wxEmptyString;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
wxUnusedVar(force);
|
||||
#endif // wxUSE_FILEDLG
|
||||
}
|
||||
|
||||
void ChooseOutputFile(bool force)
|
||||
{
|
||||
wxChar extensionBuf[10];
|
||||
wxChar wildBuf[10];
|
||||
wxStrcpy(wildBuf, _T("*."));
|
||||
wxString path;
|
||||
if (OutputFile)
|
||||
path = wxPathOnly(OutputFile);
|
||||
else if (InputFile)
|
||||
path = wxPathOnly(InputFile);
|
||||
wxChar extensionBuf[10];
|
||||
wxChar wildBuf[10];
|
||||
wxStrcpy(wildBuf, _T("*."));
|
||||
wxString path;
|
||||
if (!OutputFile.empty())
|
||||
path = wxPathOnly(OutputFile);
|
||||
else if (!InputFile.empty())
|
||||
path = wxPathOnly(InputFile);
|
||||
|
||||
switch (convertMode)
|
||||
{
|
||||
case TEX_RTF:
|
||||
switch (convertMode)
|
||||
{
|
||||
wxStrcpy(extensionBuf, _T("rtf"));
|
||||
wxStrcat(wildBuf, _T("rtf"));
|
||||
break;
|
||||
case TEX_RTF:
|
||||
{
|
||||
wxStrcpy(extensionBuf, _T("rtf"));
|
||||
wxStrcat(wildBuf, _T("rtf"));
|
||||
break;
|
||||
}
|
||||
case TEX_XLP:
|
||||
{
|
||||
wxStrcpy(extensionBuf, _T("xlp"));
|
||||
wxStrcat(wildBuf, _T("xlp"));
|
||||
break;
|
||||
}
|
||||
case TEX_HTML:
|
||||
{
|
||||
wxStrcpy(extensionBuf, _T("html"));
|
||||
wxStrcat(wildBuf, _T("html"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
case TEX_XLP:
|
||||
#if wxUSE_FILEDLG
|
||||
if (force || OutputFile.empty())
|
||||
{
|
||||
wxStrcpy(extensionBuf, _T("xlp"));
|
||||
wxStrcat(wildBuf, _T("xlp"));
|
||||
break;
|
||||
wxString s = wxFileSelector(_T("Choose output file"), path, wxFileNameFromPath(OutputFile),
|
||||
extensionBuf, wildBuf);
|
||||
if (!s.empty())
|
||||
OutputFile = s;
|
||||
}
|
||||
case TEX_HTML:
|
||||
{
|
||||
wxStrcpy(extensionBuf, _T("html"));
|
||||
wxStrcat(wildBuf, _T("html"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (force || !OutputFile)
|
||||
{
|
||||
wxString s = wxFileSelector(_T("Choose output file"), path, wxFileNameFromPath(OutputFile),
|
||||
extensionBuf, wildBuf);
|
||||
if (!s.empty())
|
||||
OutputFile = copystring(s);
|
||||
}
|
||||
#else
|
||||
wxUnusedVar(force);
|
||||
#endif // wxUSE_FILEDLG
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -935,7 +941,7 @@ bool Go(void)
|
||||
ChooseOutputFile();
|
||||
#endif
|
||||
|
||||
if (!InputFile || !OutputFile || stopRunning)
|
||||
if (InputFile.empty() || OutputFile.empty() || stopRunning)
|
||||
return false;
|
||||
|
||||
#ifndef NO_GUI
|
||||
@@ -952,7 +958,7 @@ bool Go(void)
|
||||
#endif
|
||||
|
||||
// Find extension-less filename
|
||||
wxStrcpy(FileRoot, OutputFile);
|
||||
wxStrcpy(FileRoot, OutputFile.c_str());
|
||||
StripExtension(FileRoot);
|
||||
|
||||
if (truncateFilenames && convertMode == TEX_HTML)
|
||||
@@ -989,7 +995,7 @@ bool Go(void)
|
||||
|
||||
bool success = false;
|
||||
|
||||
if (InputFile && OutputFile)
|
||||
if (!InputFile.empty() && !OutputFile.empty())
|
||||
{
|
||||
if (!wxFileExists(InputFile))
|
||||
{
|
||||
@@ -1269,20 +1275,18 @@ bool Tex2RTFConnection::OnExecute(const wxString& WXUNUSED(topic), wxChar *data,
|
||||
bool hasArg = (wxStrlen(secondArg) > 0);
|
||||
if (wxStrcmp(firstArg, _T("INPUT")) == 0 && hasArg)
|
||||
{
|
||||
if (InputFile) delete[] InputFile;
|
||||
InputFile = copystring(secondArg);
|
||||
if (frame)
|
||||
{
|
||||
wxChar buf[100];
|
||||
wxString str = wxFileNameFromPath(InputFile);
|
||||
wxSnprintf(buf, sizeof(buf), _T("Tex2RTF [%s]"), (const wxChar*) str);
|
||||
frame->SetTitle(buf);
|
||||
}
|
||||
InputFile = secondArg;
|
||||
if (frame)
|
||||
{
|
||||
wxChar buf[100];
|
||||
wxString str = wxFileNameFromPath(InputFile);
|
||||
wxSnprintf(buf, sizeof(buf), _T("Tex2RTF [%s]"), (const wxChar*) str);
|
||||
frame->SetTitle(buf);
|
||||
}
|
||||
}
|
||||
else if (wxStrcmp(firstArg, _T("OUTPUT")) == 0 && hasArg)
|
||||
{
|
||||
if (OutputFile) delete[] OutputFile;
|
||||
OutputFile = copystring(secondArg);
|
||||
OutputFile = secondArg;
|
||||
}
|
||||
else if (wxStrcmp(firstArg, _T("GO")) == 0)
|
||||
{
|
||||
|
@@ -150,8 +150,8 @@ extern FILE *Sections;
|
||||
extern FILE *Subsections;
|
||||
extern FILE *Subsubsections;
|
||||
|
||||
extern wxChar *InputFile;
|
||||
extern wxChar *OutputFile;
|
||||
extern wxString InputFile;
|
||||
extern wxString OutputFile;
|
||||
extern wxChar *MacroFile;
|
||||
|
||||
extern wxChar *FileRoot;
|
||||
|
@@ -113,7 +113,7 @@ void XLPOnMacro(int macroId, int no_args, bool start)
|
||||
|
||||
if (macroId != ltSECTIONSTAR)
|
||||
sectionNo ++;
|
||||
|
||||
|
||||
SetCurrentOutputs(Chapters, Sections);
|
||||
long id1 = NewBlockId();
|
||||
currentBlockId = NewBlockId();
|
||||
@@ -659,7 +659,7 @@ bool XLPOnArgument(int macroId, int arg_no, bool start)
|
||||
if (start)
|
||||
{
|
||||
wxChar *sec = NULL;
|
||||
|
||||
|
||||
wxChar *refName = GetArgData();
|
||||
if (refName)
|
||||
{
|
||||
@@ -698,7 +698,7 @@ bool XLPOnArgument(int macroId, int arg_no, bool start)
|
||||
wxChar *label = GetArgData();
|
||||
hyperLinks.Append(currentBlockId, (wxObject *)copystring(label));
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@@ -1142,7 +1142,7 @@ bool XLPGo(void)
|
||||
{
|
||||
xlpBlockId = 0;
|
||||
|
||||
if (InputFile && OutputFile)
|
||||
if (!InputFile.empty() && !OutputFile.empty())
|
||||
{
|
||||
Contents = wxFopen(TmpContentsName, _T("w"));
|
||||
Chapters = wxFopen(_T("chapters.xlp"), _T("w"));
|
||||
@@ -1213,4 +1213,3 @@ bool XLPGo(void)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user