// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
int i;
for (i = l; i < 5; i++)
ContentsLevels[i] = false;
-
+
// There are always books on the top level
ContentsLevels[0] = true;
}
void OutputSectionKeyword(FILE *fd)
{
OutputCurrentSectionToString(wxTex2RTFBuffer);
-
+
unsigned int i;
for (i = 0; i < wxStrlen(wxTex2RTFBuffer); i++)
if (wxTex2RTFBuffer[i] == ':')
wxFprintf(fd, _T("K{\\footnote {K} "));
wxFprintf(fd, _T("%s"), wxTex2RTFBuffer);
-
+
wxFprintf(fd, _T("}\n"));
}
wxChar title[255];
int s=0;
int d=0;
+ // assuming iso-8859-1 here even in Unicode build (FIXME?)
while ( (xitle[s]!=0)&&(d<255) )
{
- wxChar ch=xitle[s]&0xff;
+ wxChar ch=wxChar(xitle[s]&0xff);
if (ch==0x5c) {
- wxChar ch1=xitle[s+1]&0xff;
- wxChar ch2=xitle[s+2]&0xff;
- wxChar ch3=xitle[s+3]&0xff;
- s+=4; // next character
- if ((ch1==0x27)&&(ch2==0x66)&&(ch3==0x36)) { title[d++]=_T('ö'); }
- if ((ch1==0x27)&&(ch2==0x65)&&(ch3==0x34)) { title[d++]=_T('ä'); }
- if ((ch1==0x27)&&(ch2==0x66)&&(ch3==0x63)) { title[d++]=_T('ü'); }
- if ((ch1==0x27)&&(ch2==0x64)&&(ch3==0x36)) { title[d++]=_T('Ö'); }
- if ((ch1==0x27)&&(ch2==0x63)&&(ch3==0x34)) { title[d++]=_T('Ä'); }
- if ((ch1==0x27)&&(ch2==0x64)&&(ch3==0x63)) { title[d++]=_T('Ü'); }
+ wxChar ch1=wxChar(xitle[s+1]&0xff);
+ wxChar ch2=wxChar(xitle[s+2]&0xff);
+ wxChar ch3=wxChar(xitle[s+3]&0xff);
+ s+=4; // next character
+ if ((ch1==0x27)&&(ch2==0x66)&&(ch3==0x36)) { title[d++]=wxChar('ö'); }
+ if ((ch1==0x27)&&(ch2==0x65)&&(ch3==0x34)) { title[d++]=wxChar('ä'); }
+ if ((ch1==0x27)&&(ch2==0x66)&&(ch3==0x63)) { title[d++]=wxChar('ü'); }
+ if ((ch1==0x27)&&(ch2==0x64)&&(ch3==0x36)) { title[d++]=wxChar('Ö'); }
+ if ((ch1==0x27)&&(ch2==0x63)&&(ch3==0x34)) { title[d++]=wxChar('Ä'); }
+ if ((ch1==0x27)&&(ch2==0x64)&&(ch3==0x63)) { title[d++]=wxChar('Ü'); }
} else {
title[d++]=ch;
s++;
- }
+ }
}
title[d]=0;
if (level == 0) // Means we had a Chapter in an article, oops.
return;
-
+
ResetContentsLevels(level);
-
- if (!title)
- return;
-
+
if (winHelp && winHelpContents && WinHelpContentsFile)
{
TexTopic *texTopic = (TexTopic *)TopicTable.Get(topicName);
// Must separate out main entry form subentry (only 1 subentry allowed)
wxChar buf1[100]; wxChar buf2[100];
SplitIndexEntry(s, buf1, buf2);
-
+
// Check for ':' which messes up index
unsigned int i;
for (i = 0; i < wxStrlen(buf1) ; i++)
* Output index entry in linear RTF
*
*/
-
+
void GenerateIndexEntry(wxChar *entry)
{
if (useWord)
* Write a suitable RTF header.
*
*/
-
+
void WriteColourTable(FILE *fd)
{
wxFprintf(fd, _T("{\\colortbl"));
{
wxFprintf(fd, _T("{\\rtf1\\%s \\deff0\n"), RTFCharset);
wxFprintf(fd, _T("{\\fonttbl{\\f0\\froman Times New Roman;}{\\f1\\ftech Symbol;}{\\f2\\fswiss Arial;}\n"));
- wxFprintf(fd, _T("{\\f3\\fmodern Courier;}{\\f4\\ftech Wingdings;}{\\f5\\ftech Monotype Sorts;}\n}"));
+ wxFprintf(fd, _T("{\\f3\\fmodern Courier New;}{\\f4\\ftech Wingdings;}{\\f5\\ftech Monotype Sorts;}\n}"));
/*
* Style sheet
*/
// Table of contents styles
wxFprintf(fd, _T("{\\s20\\sb300\\tqr\\tldot\\tx8640 \\b\\f2 \\sbasedon0\\snext0 toc 1;}\n"));
-
+
wxFprintf(fd, _T("{\\s21\\sb90\\tqr\\tldot\\li400\\tqr\\tx8640 \\f2\\fs20\\sbasedon0\\snext0 toc 2;}\n"));
wxFprintf(fd, _T("{\\s22\\sb90\\tqr\\tldot\\li800\\tx8640 \\f2\\fs20 \\sbasedon0\\snext0 toc 3;}\n"));
wxFprintf(fd, _T("{\\s23\\sb90\\tqr\\tldot\\li1200\\tx8640 \\f2\\fs20 \\sbasedon0\\snext0 toc 4;}\n"));
/*
* 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 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");
-
- 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"));
-
- 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"));
+ wxChar *helpTitle = winHelpTitle;
+ if (!helpTitle)
+ helpTitle = _T("Untitled");
- if (winHelpVersion > 3)
- {
- wxFprintf(fd, _T("[WINDOWS]\n"));
- wxFprintf(fd, _T("Main=\"\",(553,102,400,600),20736,(r14876671),(r12632256),f3\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"));
- }
- 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;
}
i += 1;
changed = true;
}
- else if (inVerbatim && (ch == '{' || ch == '}')) // Escape the curley bracket
+ else if (inVerbatim && (ch == '{' || ch == '}')) // Escape the curly bracket
{
BigBuffer[ptr] = '\\'; ptr ++;
BigBuffer[ptr] = ch; ptr ++;
* and before TraverseDocument is called.
*
*/
-
+
void Text2RTF(TexChunk *chunk)
{
Tex2RTFYield();
* Not used yet
*
*/
-
+
wxChar browseBuf[10];
static long browseId = 0;
wxChar *GetBrowseString(void)
{
int oldForbidResetPar = forbidResetPar;
forbidResetPar = 0;
-
+
if (LeftHeaderEven || CentreHeaderEven || RightHeaderEven)
{
TexOutput(_T("{\\headerl\\fi0 "));
OutputRTFHeaderCommands();
OutputRTFFooterCommands();
}
-
+
// Need to reset the current numbering style, or RTF forgets it.
SetCurrentOutput(Chapters);
OutputNumberStyle(currentNumberStyle);
else SetCurrentOutput(NULL); // No entry in table of contents
}
}
-
+
startedSections = true;
// Output heading to contents page
if (!InPopups())
{
OutputCurrentSection();
-
+
if (winHelp)
{
wxFprintf(Contents, _T("}{\\v %s}\\pard\\par\n"), topicName);
// From here, just output to chapter
SetCurrentOutput(Chapters);
}
-
+
if (winHelp)
{
wxFprintf(Chapters, _T("}\n#{\\footnote %s}\n"), topicName);
wxFprintf(Chapters, _T("+{\\footnote %s}\n"), GetBrowseString());
-
+
OutputSectionKeyword(Chapters);
GenerateKeywordsForTopic(topicName);
}
}
else SetCurrentOutput(NULL);
- }
+ }
if (startedSections)
{
else
wxFprintf(Contents, _T("}\\par\\par\\pard\n"));
}
-
+
SetCurrentOutput(winHelp ? Sections : Chapters);
if (winHelp)
wxChar *keep = _T("");
if (winHelp && (macroId != ltGLOSS) && !InPopups())
keep = _T("\\keepn\\sa140\\sb140");
-
+
wxFprintf(winHelp ? Sections : Chapters, _T("\\pard{%s%s"),
keep, styleCommand);
#if 0
else
wxFprintf(Chapters, _T("\\par\n"));
-#endif
+#endif
}
startedSections = true;
}
}
OutputCurrentSection(); // Repeat section header
-
+
// Experimental JACS
TexOutput(_T("\\par\\pard}\n"));
// TexOutput(_T("\\par\\pard}\\par\n"));
else
SetCurrentOutput(NULL); // Don't write it into the contents, or anywhere else
}
-
+
if (startedSections)
{
if (winHelp)
#if 0
else
wxFprintf(Chapters, _T("\\par\n"));
-#endif
+#endif
}
startedSections = true;
}
else if ((DocumentStyle == LATEX_ARTICLE) && (macroId != ltSUBSUBSECTIONSTAR))
wxFprintf(Contents, _T("\\par\\pard\n"));
-
+
SetCurrentOutput(winHelp ? Subsubsections : Chapters);
if (winHelp)
{
WriteHeadingStyle((winHelp ? Subsubsections : Chapters),
(DocumentStyle == LATEX_ARTICLE ? 3 : 4));
wxFprintf(winHelp ? Subsubsections : Chapters, _T(" "));
-
+
if (!winHelp)
{
if ((macroId != ltSUBSUBSECTIONSTAR))
int ch = getc(fd);
while (ch != EOF)
{
- putc(ch, Chapters);
+ wxPutc(ch, Chapters);
ch = getc(fd);
}
fclose(fd);
if (TableData[i].leftBorder)
TexOutput(_T("\\clbrdrl\\brdrs\\brdrw15"));
-
+
wxSnprintf(buf, sizeof(buf), _T("\\cellx%d"), currentWidth);
TexOutput(buf);
}
ItemizeStruc *struc = new ItemizeStruc(listType, indentSize2, indentSize1);
itemizeStack.Insert(struc);
-
+
wxSnprintf(buf, sizeof(buf), _T("\\tx%d\\tx%d\\li%d\\sa200"), indentSize1, indentSize2, indentSize2);
PushEnvironmentStyle(buf);
}
ItemizeStruc *struc = new ItemizeStruc(LATEX_TWOCOL, indentSize);
itemizeStack.Insert(struc);
-
+
// wxSnprintf(buf, sizeof(buf), _T("\\tx%d\\li%d\\ri%d"), indentSize, indentSize, TwoColWidthA+TwoColWidthB+oldIndent);
wxSnprintf(buf, sizeof(buf), _T("\\tx%d\\li%d\\sa200"), indentSize, indentSize);
PushEnvironmentStyle(buf);
OnMacro(ltPAR, 0, true);
OnMacro(ltPAR, 0, false);
}
-#endif
+#endif
}
break;
}
// WriteEnvironmentStyles();
}
-#endif
+#endif
// wxSnprintf(buf, sizeof(buf), _T("\\tx%d\\li%d\\fi-%d\\ri%d\n"), TwoColWidthA,
// TwoColWidthA, TwoColWidthA, TwoColWidthA+TwoColWidthB+oldIndent);
else issuedNewParagraph = 0;
}
#endif
-
+
if (macroId == ltVERBATIM)
wxSnprintf(buf, sizeof(buf), _T("{\\f3\\s10\\fs20\\li720\\sa0 "));
else
#if 0
TexOutput(_T("\\par\n"));
issuedNewParagraph = 1;
-#endif
+#endif
}
}
break;
case ltRMFAMILY:
case ltRM:
{
-/*
+/*
if (start)
{
TexOutput(_T("{\\plain "));
{
TexOutput(_T("\\par\\pard"));
issuedNewParagraph ++;
-
+
// Extra par if parskip is more than zero (usually looks best.)
// N.B. JACS 2004-02-21: shouldn't need this for linear RTF if
// we have a suitable set of styles.
TexOutput(_T("\\par"));
issuedNewParagraph ++;
}
-#endif
+#endif
WriteEnvironmentStyles();
}
// 1 is a whole paragraph if ParSkip == 0,
TexOutput(_T("\\par"));
issuedNewParagraph ++;
}
-#endif
+#endif
WriteEnvironmentStyles();
}
/*
{
if (!suppressNameDecoration) TexOutput(_T("}"));
}
-
+
if (start && (arg_no == 3))
TexOutput(_T("("));
if (!start && (arg_no == 3))
if (start)
{
wxChar *sec = NULL;
-
+
wxChar *refName = GetArgData();
if (winHelp || !useWord)
{
{
if (arg_no == 3)
return false;
-
+
static int imageWidth = 0;
static int imageHeight = 0;
-
+
if (start && (arg_no == 1))
{
wxChar *imageDimensions = copystring(GetArgData());
if (imageDimensions) // glt
delete [] imageDimensions;
return false;
- }
+ }
else if (start && (arg_no == 2 ))
{
wxChar *filename = copystring(GetArgData());
}
else
{
-#endif
+#endif
TexOutput(_T("[No BMP or WMF for image file "));
TexOutput(filename);
TexOutput(_T("]"));
if (currentNumberStyle) delete[] currentNumberStyle;
currentNumberStyle = copystring(data);
OutputNumberStyle(currentNumberStyle);
-
+
TexOutput(_T("\n"));
}
return false;
if (TableData[i].leftBorder)
TexOutput(_T("\\clbrdrl\\brdrs\\brdrw15"));
-
+
wxSnprintf(buf, sizeof(buf), _T("\\cellx%d"), currentWidth);
TexOutput(buf);
}
ItemizeStruc *struc = new ItemizeStruc(LATEX_INDENT, indentSize);
itemizeStack.Insert(struc);
-
+
wxSnprintf(buf, sizeof(buf), _T("\\tx%d\\li%d\\sa200 "), indentSize, indentSize);
PushEnvironmentStyle(buf);
TexOutput(buf);
ItemizeStruc *struc = new ItemizeStruc(LATEX_INDENT, indentSize);
itemizeStack.Insert(struc);
-
+
wxSnprintf(buf, sizeof(buf), _T("\\tx%d\\li%d\\lr%d\\sa200\\box%s "), indentSize, indentSize, indentSizeRight,
((macroId == ltCENTEREDBOX) ? _T("\\brdrs") : _T("\\brdrdb")));
PushEnvironmentStyle(buf);
OutputRTFHeaderCommands();
OutputRTFFooterCommands();
}
-
+
// Need to reset the current numbering style, or RTF forgets it.
OutputNumberStyle(currentNumberStyle);
SetCurrentOutput(Contents);
wxFileNameFromPath(FileRoot), "Contents");
}
}
-
+
SetCurrentOutput(Chapters);
wxChar *styleCommand = _T("");
if (!winHelp && useHeadingStyles)
startedSections = false;
inVerbatim = false;
browseId = 0;
-
- if (InputFile && OutputFile)
+
+ if (!InputFile.empty() && !OutputFile.empty())
{
// Do some RTF-specific transformations on all the strings,
// recursively
wxFprintf(Chapters, _T("\\titlepg\n"));
wxFprintf(Contents, _T("\\par\\pard\\pgnrestart\\sect\\titlepg"));
}
-
+
// In WinHelp, Contents title takes font of title.
// In linear RTF, same as chapter headings.
wxFprintf(Contents, _T("{\\b\\fs%d %s}\\par\\par\\pard\n\n"),
// By default, Swiss, 11 point.
wxFprintf(Chapters, _T("\\f2\\fs22\n"));
-
+
PushEnvironmentStyle(_T("\\f2\\fs22\\sa200"));
SetCurrentOutput(Chapters);
fclose(Header);
PopEnvironmentStyle();
-
+
Tex2RTFYield(true);
if (winHelp)
{
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);
wxRemoveFile(_T("tmp1.rtf"));
}
-
+
if (wxFileExists(ContentsName)) wxRemoveFile(ContentsName);
if (!wxRenameFile(TmpContentsName, ContentsName))
wxRemoveFile(_T("chapters.rtf"));
wxRemoveFile(_T("header.rtf"));
-
+
if (winHelp)
{
wxRemoveFile(_T("sections.rtf"));
wxRemoveFile(_T("popups.rtf"));
}
if (winHelp && generateHPJ)
- WriteHPJ(OutputFile);
+ WriteHPJ(OutputFile);
return true;
}
return false;