]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/tex2rtf/src/rtfutils.cpp
Make _dist_dir a shadow directory of symlinks rather then copied files, and add
[wxWidgets.git] / utils / tex2rtf / src / rtfutils.cpp
index 5bc087ed67b0717edb9aafbeae7955015a7faa4e..5b0b6386519395befa3cf9e971990744cdba02c5 100644 (file)
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
@@ -521,65 +517,65 @@ void OutputNumberStyle(wxChar *numberStyle)
  * Write a Windows help project file
  */
 
  * 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"));
-
-  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;
-
-  wxChar *helpTitle = winHelpTitle;
-  if (!helpTitle)
-    helpTitle = _T("Untitled");
+    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"));
+
+    FILE *fd = wxFopen(hpjFilename, _T("w"));
+    if (!fd)
+        return false;
 
 
-  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"));
+    wxChar *helpTitle = winHelpTitle;
+    if (!helpTitle)
+        helpTitle = _T("Untitled");
 
 
-  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"));
+    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("[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("\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 +5166,7 @@ bool RTFGo(void)
   inVerbatim = false;
   browseId = 0;
 
   inVerbatim = false;
   browseId = 0;
 
-  if (InputFile && OutputFile)
+  if (!InputFile.empty() && !OutputFile.empty())
   {
     // Do some RTF-specific transformations on all the strings,
     // recursively
   {
     // Do some RTF-specific transformations on all the strings,
     // recursively
@@ -5312,11 +5308,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
       {
       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
       {
       }
       else
       {
-        wxCopyFile(_T("tmp1.rtf"), OutputFile);
+          wxCopyFile(_T("tmp1.rtf"), OutputFile);
       }
       delete [] cwdStr;
       Tex2RTFYield(true);
       }
       delete [] cwdStr;
       Tex2RTFYield(true);
@@ -5342,7 +5338,7 @@ bool RTFGo(void)
       wxRemoveFile(_T("popups.rtf"));
     }
     if (winHelp && generateHPJ)
       wxRemoveFile(_T("popups.rtf"));
     }
     if (winHelp && generateHPJ)
-      WriteHPJ(OutputFile);
+        WriteHPJ(OutputFile);
     return true;
   }
   return false;
     return true;
   }
   return false;