1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Converts Latex to Word RTF/WinHelp RTF
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"
39 #if !WXWIN_COMPATIBILITY_2_4
40 static inline wxChar
* copystring(const wxChar
* s
)
41 { return wxStrcpy(new wxChar
[wxStrlen(s
) + 1], s
); }
45 static int indentLevel
= 0;
46 static int forbidParindent
= 0; // if > 0, no parindent (e.g. in center environment)
47 int forbidResetPar
= 0; // If > 0, don't reset memory of having output a new par
49 static wxChar
*contentsLineSection
= NULL
;
50 static wxChar
*contentsLineValue
= NULL
;
51 static TexChunk
*descriptionItemArg
= NULL
;
52 static wxStringList environmentStack
; // Stack of paragraph styles we need to remember
53 static int footnoteCount
= 0;
54 static int citeCount
= 1;
56 extern bool startedSections
;
57 extern FILE *Contents
;
58 extern FILE *Chapters
;
60 extern FILE *WinHelpContentsFile
;
61 extern wxChar
*RTFCharset
;
62 // This is defined in the Tex2Any library and isn't in use after parsing
63 extern wxChar
*BigBuffer
;
65 extern wxHashTable TexReferences
;
67 // Are we in verbatim mode? If so, format differently.
68 static bool inVerbatim
= FALSE
;
70 // We're in a series of PopRef topics, so don't output section headings
71 bool inPopRefSection
= FALSE
;
74 static bool hotSpotColour
= TRUE
;
75 static bool hotSpotUnderline
= TRUE
;
77 // Transparency (WHITE = transparent)
78 static bool bitmapTransparency
= TRUE
;
80 // Linear RTF requires us to set the style per section.
81 static wxChar
*currentNumberStyle
= NULL
;
82 static int currentItemSep
= 8;
83 static int CurrentTextWidth
= 8640; // Say, six inches
84 static int CurrentLeftMarginOdd
= 400;
85 static int CurrentLeftMarginEven
= 1440;
86 static int CurrentRightMarginOdd
= 1440;
87 static int CurrentRightMarginEven
= 400;
88 static int CurrentMarginParWidth
= 2000;
89 static int CurrentMarginParSep
= 400; // Gap between marginpar and text
90 static int CurrentMarginParX
= CurrentLeftMarginOdd
+ CurrentTextWidth
+ CurrentMarginParSep
;
91 static int GutterWidth
= 2300;
93 // Two-column table dimensions, in twips
94 static int TwoColWidthA
= 1500;
95 static int TwoColWidthB
= 3000;
97 const int PageWidth
= 12242; // 8.25 inches wide for A4
99 // Remember the anchor in a helpref
100 static TexChunk
*helpRefText
= NULL
;
103 * Flag to say we've just issued a \par\pard command, so don't
104 * repeat this unnecessarily.
108 int issuedNewParagraph
= 0;
110 // Need to know whether we're in a table or figure for benefit
111 // of listoffigures/listoftables
112 static bool inFigure
= FALSE
;
113 static bool inTable
= FALSE
;
119 static wxChar
*CurrentChapterName
= NULL
;
120 static wxChar
*CurrentSectionName
= NULL
;
121 static wxChar
*CurrentSubsectionName
= NULL
;
122 static wxChar
*CurrentTopic
= NULL
;
124 static bool InPopups()
126 if (CurrentChapterName
&& (wxStrcmp(CurrentChapterName
, _T("popups")) == 0))
128 if (CurrentSectionName
&& (wxStrcmp(CurrentSectionName
, _T("popups")) == 0))
133 static void SetCurrentTopic(wxChar
*s
)
135 if (CurrentTopic
) delete[] CurrentTopic
;
136 CurrentTopic
= copystring(s
);
139 void SetCurrentChapterName(wxChar
*s
)
141 if (CurrentChapterName
) delete[] CurrentChapterName
;
142 CurrentChapterName
= copystring(s
);
145 void SetCurrentSectionName(wxChar
*s
)
147 if (CurrentSectionName
) delete[] CurrentSectionName
;
148 CurrentSectionName
= copystring(s
);
151 void SetCurrentSubsectionName(wxChar
*s
)
153 if (CurrentSubsectionName
) delete[] CurrentSubsectionName
;
154 CurrentSubsectionName
= copystring(s
);
158 // Indicate that a parent topic at level 'level' has children.
159 // Level 1 is a chapter, 2 is a section, etc.
160 void NotifyParentHasChildren(int parentLevel
)
162 wxChar
*parentTopic
= NULL
;
167 parentTopic
= CurrentChapterName
;
172 parentTopic
= CurrentSectionName
;
177 parentTopic
= CurrentSubsectionName
;
187 TexTopic
*texTopic
= (TexTopic
*)TopicTable
.Get(parentTopic
);
190 texTopic
= new TexTopic
;
191 TopicTable
.Put(parentTopic
, texTopic
);
193 texTopic
->hasChildren
= TRUE
;
197 // Have to keep a count of what levels are books, what are pages,
198 // in order to correct for a Win95 bug which means that if you
199 // have a book at level n, and then a page at level n, the page
200 // ends up on level n + 1.
202 bool ContentsLevels
[5];
204 // Reset below this level (starts from 1)
205 void ResetContentsLevels(int l
)
208 for (i
= l
; i
< 5; i
++)
209 ContentsLevels
[i
] = FALSE
;
211 // There are always books on the top level
212 ContentsLevels
[0] = TRUE
;
215 // Output a WinHelp section as a keyword, substituting
217 void OutputSectionKeyword(FILE *fd
)
219 OutputCurrentSectionToString(wxTex2RTFBuffer
);
222 for (i
= 0; i
< wxStrlen(wxTex2RTFBuffer
); i
++)
223 if (wxTex2RTFBuffer
[i
] == ':')
224 wxTex2RTFBuffer
[i
] = ' ';
225 // Don't write to index if there's some RTF in the string
226 else if ( wxTex2RTFBuffer
[i
] == '{' )
229 wxFprintf(fd
, _T("K{\\footnote {K} "));
230 wxFprintf(fd
, _T("%s"), wxTex2RTFBuffer
);
232 wxFprintf(fd
, _T("}\n"));
235 // Write a line for the .cnt file, if we're doing this.
236 void WriteWinHelpContentsFileLine(wxChar
*topicName
, wxChar
*xitle
, int level
)
238 // First, convert any RTF characters to ASCII
242 while ( (xitle
[s
]!=0)&&(d
<255) )
244 wxChar ch
=xitle
[s
]&0xff;
246 wxChar ch1
=xitle
[s
+1]&0xff;
247 wxChar ch2
=xitle
[s
+2]&0xff;
248 wxChar ch3
=xitle
[s
+3]&0xff;
249 s
+=4; // next character
250 if ((ch1
==0x27)&&(ch2
==0x66)&&(ch3
==0x36)) { title
[d
++]='ö'; }
251 if ((ch1
==0x27)&&(ch2
==0x65)&&(ch3
==0x34)) { title
[d
++]='ä'; }
252 if ((ch1
==0x27)&&(ch2
==0x66)&&(ch3
==0x63)) { title
[d
++]='ü'; }
253 if ((ch1
==0x27)&&(ch2
==0x64)&&(ch3
==0x36)) { title
[d
++]='Ö'; }
254 if ((ch1
==0x27)&&(ch2
==0x63)&&(ch3
==0x34)) { title
[d
++]='Ä'; }
255 if ((ch1
==0x27)&&(ch2
==0x64)&&(ch3
==0x63)) { title
[d
++]='Ü'; }
263 // Section (2) becomes level 1 if it's an article.
264 if (DocumentStyle
== LATEX_ARTICLE
)
267 if (level
== 0) // Means we had a Chapter in an article, oops.
270 ResetContentsLevels(level
);
275 if (winHelp
&& winHelpContents
&& WinHelpContentsFile
)
277 TexTopic
*texTopic
= (TexTopic
*)TopicTable
.Get(topicName
);
280 // If a previous section at this level was a book, we *have* to have a
281 // book not a page, because of a bug in WHC (or WinHelp 4).
282 if (texTopic
->hasChildren
|| level
== 1 || ContentsLevels
[level
-1])
284 // At this level, we have a pointer to a further hierarchy.
285 // So we need a 'book' consisting of (say) Chapter 1.
286 wxFprintf(WinHelpContentsFile
, _T("%d %s\n"), level
, title
);
288 // Then we have a 'page' consisting of the text for this chapter
289 wxFprintf(WinHelpContentsFile
, _T("%d %s=%s\n"), level
+1, title
, topicName
);
291 // Then we'll be writing out further pages or books at level + 1...
293 // Remember that at this level, we had a book and *must* for the
294 // remainder of sections at this level.
295 ContentsLevels
[level
-1] = TRUE
;
299 wxFprintf(WinHelpContentsFile
, _T("%d %s=%s\n"), level
, title
, topicName
);
304 if (level
== 1 || ContentsLevels
[level
-1])
306 // Always have a book at level 1
307 wxFprintf(WinHelpContentsFile
, _T("%d %s\n"), level
, title
);
308 wxFprintf(WinHelpContentsFile
, _T("%d %s=%s\n"), level
+1, title
, topicName
);
309 ContentsLevels
[level
-1] = TRUE
;
312 // Probably doesn't have children if it hasn't been added to the topic table
313 wxFprintf(WinHelpContentsFile
, _T("%d %s=%s\n"), level
, title
, topicName
);
318 void SplitIndexEntry(wxChar
*entry
, wxChar
*buf1
, wxChar
*buf2
)
320 int len
= wxStrlen(entry
); int i
= 0;
321 while ((i
< len
) && entry
[i
] != '!')
322 { buf1
[i
] = entry
[i
]; i
++; }
323 buf1
[i
] = 0; buf2
[0] = 0; int j
= 0;
328 while (i
< len
) { buf2
[j
] = entry
[i
]; i
++; j
++; }
334 * Output topic index entries in WinHelp RTF
337 void GenerateKeywordsForTopic(wxChar
*topic
)
339 TexTopic
*texTopic
= (TexTopic
*)TopicTable
.Get(topic
);
343 wxStringList
*list
= texTopic
->keywords
;
346 wxStringListNode
*node
= list
->GetFirst();
349 wxChar
*s
= (wxChar
*)node
->GetData();
351 // Must separate out main entry form subentry (only 1 subentry allowed)
352 wxChar buf1
[100]; wxChar buf2
[100];
353 SplitIndexEntry(s
, buf1
, buf2
);
355 // Check for ':' which messes up index
357 for (i
= 0; i
< wxStrlen(buf1
) ; i
++)
360 for (i
= 0; i
< wxStrlen(buf2
) ; i
++)
364 // {K} is a strange fix to prevent words beginning with K not
365 // being indexed properly
366 TexOutput(_T("K{\\footnote {K} "));
368 if (wxStrlen(buf2
) > 0)
374 TexOutput(_T("}\n"));
375 node
= node
->GetNext();
381 * Output index entry in linear RTF
385 void GenerateIndexEntry(wxChar
*entry
)
389 wxChar buf1
[100]; wxChar buf2
[100];
390 SplitIndexEntry(entry
, buf1
, buf2
);
392 TexOutput(_T("{\\xe\\v {"));
394 if (wxStrlen(buf2
) > 0)
396 TexOutput(_T("\\:"));
404 * Write a suitable RTF header.
408 void WriteColourTable(FILE *fd
)
410 wxFprintf(fd
, _T("{\\colortbl"));
411 wxNode
*node
= ColourTable
.GetFirst();
414 ColourTableEntry
*entry
= (ColourTableEntry
*)node
->GetData();
415 wxFprintf(fd
, _T("\\red%d\\green%d\\blue%d;\n"), entry
->red
, entry
->green
, entry
->blue
);
416 node
= node
->GetNext();
418 wxFprintf(fd
, _T("}"));
422 * Write heading style
426 void WriteHeadingStyle(FILE *fd
, int heading
)
432 wxFprintf(fd
, _T("\\sb300\\sa260\\f2\\b\\fs%d"), chapterFont
*2);
437 wxFprintf(fd
, _T("\\sb200\\sa240\\f2\\b\\fs%d"), sectionFont
*2);
442 wxFprintf(fd
, _T("\\sb120\\sa240\\f2\\b\\fs%d"), subsectionFont
*2);
447 wxFprintf(fd
, _T("\\sb120\\sa240\\f2\\b\\fs%d"), subsectionFont
*2);
455 void WriteRTFHeader(FILE *fd
)
457 wxFprintf(fd
, _T("{\\rtf1\\%s \\deff0\n"), RTFCharset
);
458 wxFprintf(fd
, _T("{\\fonttbl{\\f0\\froman Times New Roman;}{\\f1\\ftech Symbol;}{\\f2\\fswiss Arial;}\n"));
459 wxFprintf(fd
, _T("{\\f3\\fmodern Courier;}{\\f4\\ftech Wingdings;}{\\f5\\ftech Monotype Sorts;}\n}"));
463 wxFprintf(fd
, _T("{\\stylesheet{\\f2\\fs22\\sa200 \\snext0 Normal;}\n"));
465 wxFprintf(fd
, _T("{\\s1 ")); WriteHeadingStyle(fd
, 1); wxFprintf(fd
, _T("\\sbasedon0\\snext0 heading 1;}\n"));
466 wxFprintf(fd
, _T("{\\s2 ")); WriteHeadingStyle(fd
, 2); wxFprintf(fd
, _T("\\sbasedon0\\snext0 heading 2;}\n"));
467 wxFprintf(fd
, _T("{\\s3 ")); WriteHeadingStyle(fd
, 3); wxFprintf(fd
, _T("\\sbasedon0\\snext0 heading 3;}\n"));
468 wxFprintf(fd
, _T("{\\s4 ")); WriteHeadingStyle(fd
, 4); wxFprintf(fd
, _T("\\sbasedon0\\snext0 heading 4;}\n"));
471 wxFprintf(fd
, _T("{\\s10\\ql \\li720\\ri0\\nowidctlpar\\faauto\\rin0\\lin720\\itap0 \\cbpat17\
472 \\f2\\fs20 \\sbasedon0 \\snext24 Code;}\n"));
474 // Table of contents styles
475 wxFprintf(fd
, _T("{\\s20\\sb300\\tqr\\tldot\\tx8640 \\b\\f2 \\sbasedon0\\snext0 toc 1;}\n"));
477 wxFprintf(fd
, _T("{\\s21\\sb90\\tqr\\tldot\\li400\\tqr\\tx8640 \\f2\\fs20\\sbasedon0\\snext0 toc 2;}\n"));
478 wxFprintf(fd
, _T("{\\s22\\sb90\\tqr\\tldot\\li800\\tx8640 \\f2\\fs20 \\sbasedon0\\snext0 toc 3;}\n"));
479 wxFprintf(fd
, _T("{\\s23\\sb90\\tqr\\tldot\\li1200\\tx8640 \\f2\\fs20 \\sbasedon0\\snext0 toc 4;}\n"));
482 wxFprintf(fd
, _T("{\\s30\\fi-200\\li200\\tqr\\tx3960 \\f2\\fs18 \\sbasedon0\\snext0 index 1;}\n"));
483 wxFprintf(fd
, _T("{\\s31\\fi-200\\li400\\tqr\\tx3960 \\f2\\fs18 \\sbasedon0\\snext0 index 2;}\n"));
484 wxFprintf(fd
, _T("{\\s32\\fi-200\\li600\\tqr\\tx3960 \\f2\\fs18 \\sbasedon0\\snext0 index 3;}\n"));
485 wxFprintf(fd
, _T("{\\s33\\fi-200\\li800\\tqr\\tx3960 \\f2\\fs18 \\sbasedon0\\snext0 index 4;}\n"));
486 wxFprintf(fd
, _T("{\\s35\\qc\\sb240\\sa120 \\b\\f2\\fs26 \\sbasedon0\\snext30 index heading;}\n"));
487 wxFprintf(fd
, _T("}\n"));
489 WriteColourTable(fd
);
490 wxFprintf(fd
, _T("\n\\ftnbj\\ftnrestart")); // Latex default is footnotes at bottom of page, not section.
491 wxFprintf(fd
, _T("\n"));
494 void OutputNumberStyle(wxChar
*numberStyle
)
498 if (wxStrcmp(numberStyle
, _T("arabic")) == 0)
500 TexOutput(_T("\\pgndec"));
502 else if (wxStrcmp(numberStyle
, _T("roman")) == 0)
504 TexOutput(_T("\\pgnlcrm"));
506 else if (wxStrcmp(numberStyle
, _T("Roman")) == 0)
508 TexOutput(_T("\\pgnucrm"));
510 else if (wxStrcmp(numberStyle
, _T("alph")) == 0)
512 TexOutput(_T("\\pgnlcltr"));
514 else if (wxStrcmp(numberStyle
, _T("Alph")) == 0)
516 TexOutput(_T("\\pgnucltr"));
522 * Write a Windows help project file
525 bool WriteHPJ(wxChar
*filename
)
527 wxChar hpjFilename
[256];
530 wxStrcpy(hpjFilename
, filename
);
531 StripExtension(hpjFilename
);
532 wxStrcat(hpjFilename
, _T(".hpj"));
534 wxStrcpy(helpFile
, wxFileNameFromPath(filename
));
535 StripExtension(helpFile
);
536 wxStrcpy(rtfFile
, helpFile
);
537 wxStrcat(helpFile
, _T(".hlp"));
538 wxStrcat(rtfFile
, _T(".rtf"));
540 FILE *fd
= wxFopen(hpjFilename
, _T("w"));
544 wxChar
*helpTitle
= winHelpTitle
;
546 helpTitle
= _T("Untitled");
548 wxString thePath
= wxPathOnly(InputFile
);
549 if (thePath
.IsEmpty())
551 wxFprintf(fd
, _T("[OPTIONS]\n"));
552 wxFprintf(fd
, _T("BMROOT=%s ; Assume that bitmaps are where the source is\n"), thePath
.c_str());
553 wxFprintf(fd
, _T("TITLE=%s\n"), helpTitle
);
554 wxFprintf(fd
, _T("CONTENTS=Contents\n"));
556 if (winHelpVersion
> 3)
558 wxFprintf(fd
, _T("; COMPRESS=12 Hall Zeck ; Max compression, but needs lots of memory\n"));
559 wxFprintf(fd
, _T("COMPRESS=8 Zeck\n"));
560 wxFprintf(fd
, _T("LCID=0x809 0x0 0x0 ;English (British)\n"));
561 wxFprintf(fd
, _T("HLP=.\\%s.hlp\n"), wxFileNameFromPath(FileRoot
));
565 wxFprintf(fd
, _T("COMPRESS=HIGH\n"));
567 wxFprintf(fd
, _T("\n"));
569 if (winHelpVersion
> 3)
571 wxFprintf(fd
, _T("[WINDOWS]\n"));
572 wxFprintf(fd
, _T("Main=\"\",(553,102,400,600),20736,(r14876671),(r12632256),f3\n"));
573 wxFprintf(fd
, _T("\n"));
576 wxFprintf(fd
, _T("[FILES]\n%s\n\n"), rtfFile
);
577 wxFprintf(fd
, _T("[CONFIG]\n"));
579 wxFprintf(fd
, _T("CreateButton(\"Up\", \"&Up\", \"JumpId(`%s', `Contents')\")\n"), helpFile
);
580 wxFprintf(fd
, _T("BrowseButtons()\n\n"));
581 wxFprintf(fd
, _T("[MAP]\n\n[BITMAPS]\n\n"));
588 * Given a TexChunk with a string value, scans through the string
589 * converting Latex-isms into RTF-isms, such as 2 newlines -> \par,
590 * and inserting spaces at the start of lines since in Latex, a newline
591 * implies a space, but not in RTF.
595 void ProcessText2RTF(TexChunk
*chunk
)
597 bool changed
= FALSE
;
601 int len
= wxStrlen(chunk
->value
);
604 ch
= chunk
->value
[i
];
610 BigBuffer
[ptr
] = 0; wxStrcat(BigBuffer
, _T("\\par\n")); ptr
+= 5;
611 // BigBuffer[ptr] = 0; wxStrcat(BigBuffer, _T("\\par{\\v this was verbatim}\n")); ptr += 5;
617 // If the first character of the next line is ASCII,
618 // put a space in. Implicit in Latex, not in RTF.
620 The reason this is difficult is that you don't really know
621 where a space would be appropriate. If you always put in a space
622 when you find a newline, unwanted spaces appear in the text.
624 if ((i
> 0) && (len
> i
+1 && isascii(chunk
->value
[i
+1]) &&
625 !isspace(chunk
->value
[i
+1])) ||
626 ((len
> i
+1 && chunk
->value
[i
+1] == 13) &&
627 (len
> i
+2 && isascii(chunk
->value
[i
+2]) &&
628 !isspace(chunk
->value
[i
+2]))))
631 // DOS files have a 13 after the 10
635 if (chunk
->value
[i
] == 13)
642 BigBuffer
[ptr
] = ' ';
645 // Note that the actual ASCII character seen is dealt with in the next
656 else if (!inVerbatim
&& ch
== '`' && (len
>= i
+1 && chunk
->value
[i
+1] == '`'))
658 BigBuffer
[ptr
] = '"'; ptr
++;
662 else if (!inVerbatim
&& ch
== '`') // Change ` to '
664 BigBuffer
[ptr
] = 39; ptr
++;
668 else if (inVerbatim
&& ch
== '\\') // Change backslash to two backslashes
670 BigBuffer
[ptr
] = '\\'; ptr
++;
671 BigBuffer
[ptr
] = '\\'; ptr
++;
675 else if (inVerbatim
&& (ch
== '{' || ch
== '}')) // Escape the curley bracket
677 BigBuffer
[ptr
] = '\\'; ptr
++;
678 BigBuffer
[ptr
] = ch
; ptr
++;
693 delete[] chunk
->value
;
694 chunk
->value
= copystring(BigBuffer
);
699 * Scan through all chunks starting from the given one,
700 * calling ProcessText2RTF to convert Latex-isms to RTF-isms.
701 * This should be called after Tex2Any has parsed the file,
702 * and before TraverseDocument is called.
706 void Text2RTF(TexChunk
*chunk
)
709 if (stopRunning
) return;
713 case CHUNK_TYPE_MACRO
:
715 TexMacroDef
*def
= chunk
->def
;
716 if (def
&& def
->ignore
)
719 if (def
&& (def
->macroId
== ltVERBATIM
|| def
->macroId
== ltVERB
))
722 wxNode
*node
= chunk
->children
.GetFirst();
725 TexChunk
*child_chunk
= (TexChunk
*)node
->GetData();
726 Text2RTF(child_chunk
);
727 node
= node
->GetNext();
730 if (def
&& (def
->macroId
== ltVERBATIM
|| def
->macroId
== ltVERB
))
737 wxNode
*node
= chunk
->children
.GetFirst();
740 TexChunk
*child_chunk
= (TexChunk
*)node
->GetData();
741 Text2RTF(child_chunk
);
742 node
= node
->GetNext();
747 case CHUNK_TYPE_STRING
:
750 ProcessText2RTF(chunk
);
761 wxChar browseBuf
[10];
762 static long browseId
= 0;
763 wxChar
*GetBrowseString(void)
767 wxSprintf(buf
, _T("%ld"), browseId
);
768 int noZeroes
= 5-wxStrlen(buf
);
769 wxStrcpy(browseBuf
, _T("browse"));
770 for (int i
= 0; i
< noZeroes
; i
++)
771 wxStrcat(browseBuf
, _T("0"));
772 wxStrcat(browseBuf
, buf
);
777 * Keeping track of environments to restore the styles after \pard.
778 * Push strings like "\qc" onto stack.
782 void PushEnvironmentStyle(wxChar
*style
)
784 environmentStack
.Add(style
);
787 void PopEnvironmentStyle(void)
789 wxStringListNode
*node
= environmentStack
.GetLast();
792 wxChar
*val
= (wxChar
*)node
->GetData();
798 // Write out the styles, most recent first.
799 void WriteEnvironmentStyles(void)
801 wxStringListNode
*node
= environmentStack
.GetLast();
804 wxChar
*val
= (wxChar
*)node
->GetData();
806 node
= node
->GetNext();
808 if (!inTabular
&& (ParIndent
> 0) && (forbidParindent
== 0))
811 wxSprintf(buf
, _T("\\fi%d"), ParIndent
*20); // Convert points to TWIPS
814 if (environmentStack
.GetCount() > 0 || (ParIndent
> 0))
824 void OutputRTFHeaderCommands(void)
827 if (PageStyle
&& wxStrcmp(PageStyle
, _T("plain")) == 0)
829 TexOutput(_T("{\\headerl }{\\headerr }"));
831 else if (PageStyle
&& wxStrcmp(PageStyle
, _T("empty")) == 0)
833 TexOutput(_T("{\\headerl }{\\headerr }"));
835 else if (PageStyle
&& wxStrcmp(PageStyle
, _T("headings")) == 0)
838 TexOutput(_T("{\\headerl\\fi0 "));
841 TexOutput(_T("\\brdrb\\brdrs\\brdrw15\\brsp20 "));
843 TexOutput(_T("{\\i \\qr "));
844 if (DocumentStyle
== LATEX_ARTICLE
)
846 wxSprintf(buf
, _T("SECTION %d"), sectionNo
);
851 wxSprintf(buf
, _T("CHAPTER %d: "), chapterNo
);
854 TexOutput(_T("{\\field{\\*\\fldinst PAGE \\\\* MERGEFORMAT }{\\fldrslt 1}}"));
855 TexOutput(_T("}\\par\\pard}"));
858 TexOutput(_T("{\\headerr\\fi0 "));
861 TexOutput(_T("\\brdrb\\brdrs\\brdrw15\\brsp20 "));
863 TexOutput(_T("{\\i \\qc "));
864 if (DocumentStyle
== LATEX_ARTICLE
)
866 wxSprintf(buf
, _T("SECTION %d"), sectionNo
);
871 wxSprintf(buf
, _T("CHAPTER %d"), chapterNo
);
874 TexOutput(_T("{\\field{\\*\\fldinst PAGE \\\\* MERGEFORMAT }{\\fldrslt 1}}"));
875 TexOutput(_T("}\\par\\pard}"));
879 int oldForbidResetPar
= forbidResetPar
;
882 if (LeftHeaderEven
|| CentreHeaderEven
|| RightHeaderEven
)
884 TexOutput(_T("{\\headerl\\fi0 "));
887 TexOutput(_T("\\brdrb\\brdrs\\brdrw15\\brsp20 "));
891 if (!CentreHeaderEven
&& !RightHeaderEven
)
892 TexOutput(_T("\\ql "));
893 TraverseChildrenFromChunk(LeftHeaderEven
);
895 if (CentreHeaderEven
)
897 if (!LeftHeaderEven
&& !RightHeaderEven
)
898 TexOutput(_T("\\qc "));
900 TexOutput(_T("\\tab\\tab\\tab "));
901 TraverseChildrenFromChunk(CentreHeaderEven
);
905 if (!LeftHeaderEven
&& !CentreHeaderEven
)
906 TexOutput(_T("\\qr "));
908 TexOutput(_T("\\tab\\tab\\tab\\tab\\tab\\tab "));
909 TraverseChildrenFromChunk(RightHeaderEven
);
911 TexOutput(_T("\\par\\pard}"));
914 if (LeftHeaderOdd
|| CentreHeaderOdd
|| RightHeaderOdd
)
916 TexOutput(_T("{\\headerr\\fi0 "));
919 TexOutput(_T("\\brdrb\\brdrs\\brdrw15\\brsp20 "));
923 if (!CentreHeaderOdd
&& !RightHeaderOdd
)
924 TexOutput(_T("\\ql "));
925 TraverseChildrenFromChunk(LeftHeaderOdd
);
929 if (!LeftHeaderOdd
&& !RightHeaderOdd
)
930 TexOutput(_T("\\qc "));
932 TexOutput(_T("\\tab\\tab\\tab "));
933 TraverseChildrenFromChunk(CentreHeaderOdd
);
937 if (!LeftHeaderOdd
&& !CentreHeaderOdd
)
938 TexOutput(_T("\\qr "));
940 TexOutput(_T("\\tab\\tab\\tab\\tab\\tab\\tab "));
941 TraverseChildrenFromChunk(RightHeaderOdd
);
943 TexOutput(_T("\\par\\pard}"));
945 // As an approximation, don't put a header on the first page of a section.
946 // This may not always be desired, but it's a reasonable guess.
947 TexOutput(_T("{\\headerf }"));
949 forbidResetPar
= oldForbidResetPar
;
953 void OutputRTFFooterCommands(void)
955 if (PageStyle
&& wxStrcmp(PageStyle
, _T("plain")) == 0)
957 TexOutput(_T("{\\footerl\\fi0 "));
959 TexOutput(_T("\\brdrt\\brdrs\\brdrw15\\brsp20 "));
960 TexOutput(_T("{\\qc "));
961 TexOutput(_T("{\\field{\\*\\fldinst PAGE \\\\* MERGEFORMAT }{\\fldrslt 1}}"));
962 TexOutput(_T("}\\par\\pard}"));
964 TexOutput(_T("{\\footerr\\fi0 "));
966 TexOutput(_T("\\brdrt\\brdrs\\brdrw15\\brsp20 "));
967 TexOutput(_T("{\\qc "));
968 TexOutput(_T("{\\field{\\*\\fldinst PAGE \\\\* MERGEFORMAT }{\\fldrslt 1}}"));
969 TexOutput(_T("}\\par\\pard}"));
971 else if (PageStyle
&& wxStrcmp(PageStyle
, _T("empty")) == 0)
973 TexOutput(_T("{\\footerl }{\\footerr }"));
975 else if (PageStyle
&& wxStrcmp(PageStyle
, _T("headings")) == 0)
977 TexOutput(_T("{\\footerl }{\\footerr }"));
981 if (LeftFooterEven
|| CentreFooterEven
|| RightFooterEven
)
983 TexOutput(_T("{\\footerl\\fi0 "));
985 TexOutput(_T("\\brdrt\\brdrs\\brdrw15\\brsp20 "));
988 if (!CentreFooterEven
&& !RightFooterEven
)
989 TexOutput(_T("\\ql "));
990 TraverseChildrenFromChunk(LeftFooterEven
);
992 if (CentreFooterEven
)
994 if (!LeftFooterEven
&& !RightFooterEven
)
995 TexOutput(_T("\\qc "));
997 TexOutput(_T("\\tab\\tab\\tab "));
998 TraverseChildrenFromChunk(CentreFooterEven
);
1000 if (RightFooterEven
)
1002 if (!LeftFooterEven
&& !CentreFooterEven
)
1003 TexOutput(_T("\\qr "));
1005 TexOutput(_T("\\tab\\tab\\tab\\tab\\tab\\tab "));
1006 TraverseChildrenFromChunk(RightFooterEven
);
1008 TexOutput(_T("\\par\\pard}"));
1011 if (LeftFooterOdd
|| CentreFooterOdd
|| RightFooterOdd
)
1013 TexOutput(_T("{\\footerr\\fi0 "));
1015 TexOutput(_T("\\brdrt\\brdrs\\brdrw15\\brsp20 "));
1018 if (!CentreFooterOdd
&& !RightFooterOdd
)
1019 TexOutput(_T("\\ql "));
1020 TraverseChildrenFromChunk(LeftFooterOdd
);
1022 if (CentreFooterOdd
)
1024 if (!LeftFooterOdd
&& !RightFooterOdd
)
1025 TexOutput(_T("\\qc "));
1027 TexOutput(_T("\\tab\\tab\\tab "));
1028 TraverseChildrenFromChunk(CentreFooterOdd
);
1032 if (!LeftFooterOdd
&& !CentreFooterOdd
)
1033 TexOutput(_T("\\qr "));
1035 TexOutput(_T("\\tab\\tab\\tab\\tab\\tab\\tab "));
1036 TraverseChildrenFromChunk(RightFooterOdd
);
1038 TexOutput(_T("\\par\\pard}"));
1041 // As an approximation, put a footer on the first page of a section.
1042 // This may not always be desired, but it's a reasonable guess.
1043 if (LeftFooterOdd
|| CentreFooterOdd
|| RightFooterOdd
)
1045 TexOutput(_T("{\\footerf\\fi0 "));
1048 if (!CentreFooterOdd
&& !RightFooterOdd
)
1049 TexOutput(_T("\\ql "));
1050 TraverseChildrenFromChunk(LeftFooterOdd
);
1052 if (CentreFooterOdd
)
1054 if (!LeftFooterOdd
&& !RightFooterOdd
)
1055 TexOutput(_T("\\qc "));
1057 TexOutput(_T("\\tab\\tab\\tab "));
1058 TraverseChildrenFromChunk(CentreFooterOdd
);
1062 if (!LeftFooterOdd
&& !CentreFooterOdd
)
1063 TexOutput(_T("\\qr "));
1065 TexOutput(_T("\\tab\\tab\\tab\\tab\\tab\\tab "));
1066 TraverseChildrenFromChunk(RightFooterOdd
);
1068 TexOutput(_T("\\par\\pard}"));
1073 // Called on start/end of macro examination
1074 void RTFOnMacro(int macroId
, int no_args
, bool start
)
1078 wxSprintf(tmpBuf, _T("%d (%d)"), macroId, (int)start);
1079 OutputDebugString("RTFOnMacro Start "); OutputDebugString(tmpBuf);
1080 OutputDebugString("\n"); wxYield();
1083 // ltLABEL is included here because after a section but BEFORE
1084 // the label is seen, a new paragraph is issued. Don't upset this by
1085 // immediately forgetting we've done it.
1086 if (start
&& (macroId
!= ltPAR
&& macroId
!= ltITEMIZE
&&
1087 macroId
!= ltENUMERATE
&& macroId
!= ltDESCRIPTION
&&
1088 macroId
!= ltVERBATIM
&& macroId
!= ltLABEL
&&
1089 macroId
!= ltSETHEADER
&& macroId
!= ltSETFOOTER
&&
1090 macroId
!= ltPAGENUMBERING
&&
1091 (forbidResetPar
== 0)))
1093 issuedNewParagraph
= 0;
1101 case ltCHAPTERHEADING
:
1102 case ltCHAPTERHEADINGSTAR
:
1110 subsubsectionNo
= 0;
1113 if (macroId
!= ltCHAPTERSTAR
&& macroId
!= ltCHAPTERHEADINGSTAR
)
1116 wxChar
*topicName
= FindTopicName(GetNextChunk());
1117 SetCurrentChapterName(topicName
);
1119 if (winHelpContents
&& winHelp
&& !InPopups())
1121 OutputCurrentSectionToString(wxTex2RTFBuffer
);
1122 WriteWinHelpContentsFileLine(topicName
, wxTex2RTFBuffer
, 1);
1124 AddTexRef(topicName
, NULL
, ChapterNameString
, chapterNo
);
1129 wxFprintf(Contents
, _T("\n{\\uldb "));
1130 wxFprintf(Chapters
, _T("\\page"));
1131 wxFprintf(Chapters
, _T("\n${\\footnote "));
1133 SetCurrentOutputs(Contents
, Chapters
);
1135 SetCurrentOutput(Chapters
);
1139 wxFprintf(Chapters
, _T("\\sect\\pgncont\\titlepg\n"));
1141 // If a non-custom page style, we generate the header now.
1142 if (PageStyle
&& (wxStrcmp(PageStyle
, _T("plain")) == 0 ||
1143 wxStrcmp(PageStyle
, _T("empty")) == 0 ||
1144 wxStrcmp(PageStyle
, _T("headings")) == 0))
1146 OutputRTFHeaderCommands();
1147 OutputRTFFooterCommands();
1150 // Need to reset the current numbering style, or RTF forgets it.
1151 SetCurrentOutput(Chapters
);
1152 OutputNumberStyle(currentNumberStyle
);
1154 SetCurrentOutput(Contents
);
1158 if (macroId
== ltCHAPTER
)
1161 wxFprintf(Contents
, _T("\\par\n\\pard{\\b %d\\tab "), chapterNo
);
1163 else if (macroId
== ltCHAPTERHEADING
)
1165 wxFprintf(Contents
, _T("\\par\n\\pard{\\b "));
1167 else SetCurrentOutput(NULL
); // No entry in table of contents
1171 startedSections
= TRUE
;
1173 // Output heading to contents page
1176 OutputCurrentSection();
1179 wxFprintf(Contents
, _T("}{\\v %s}\\par\\pard\n"), topicName
);
1180 else if ((macroId
== ltCHAPTER
) || (macroId
== ltCHAPTERHEADING
))
1181 wxFprintf(Contents
, _T("}\\par\\par\\pard\n"));
1183 // From here, just output to chapter
1184 SetCurrentOutput(Chapters
);
1189 wxFprintf(Chapters
, _T("}\n#{\\footnote %s}\n"), topicName
);
1190 wxFprintf(Chapters
, _T("+{\\footnote %s}\n"), GetBrowseString());
1192 OutputSectionKeyword(Chapters
);
1194 GenerateKeywordsForTopic(topicName
);
1197 // If we're generating a .cnt file, we don't want to be able
1198 // jump up to the old-style contents page, so disable it.
1199 if (winHelpContents
)
1200 wxFprintf(Chapters
, _T("!{\\footnote DisableButton(\"Up\")}\n"));
1202 wxFprintf(Chapters
, _T("!{\\footnote EnableButton(\"Up\");ChangeButtonBinding(\"Up\", \"JumpId(`%s.hlp', `%s')\")}\n"),
1203 wxFileNameFromPath(FileRoot
), _T("Contents"));
1209 wxChar
*styleCommand
= _T("");
1210 if (!winHelp
&& useHeadingStyles
&& (macroId
== ltCHAPTER
|| macroId
== ltCHAPTERHEADING
|| macroId
== ltCHAPTERHEADINGSTAR
))
1211 styleCommand
= _T("\\s1");
1212 wxFprintf(Chapters
, _T("\\pard{%s"), ((winHelp
&& !InPopups()) ? _T("\\keepn\\sa140\\sb140") : styleCommand
));
1213 WriteHeadingStyle(Chapters
, 1); wxFprintf(Chapters
, _T(" "));
1216 if (macroId
== ltCHAPTER
)
1219 // wxFprintf(Chapters, "{\\bkmkstart %s}%d{\\bkmkend %s}. ", topicName, chapterNo,
1220 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), topicName
, topicName
);
1222 wxFprintf(Chapters
, _T("%d. "), chapterNo
);
1226 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), topicName
, topicName
);
1229 OutputCurrentSection();
1230 TexOutput(_T("\\par\\pard}\n"));
1232 issuedNewParagraph
= 1;
1233 WriteEnvironmentStyles();
1239 case ltSECTIONHEADING
:
1240 case ltSECTIONHEADINGSTAR
:
1244 if (DocumentStyle
== LATEX_ARTICLE
)
1245 jumpFrom
= Contents
;
1247 jumpFrom
= Chapters
;
1252 subsubsectionNo
= 0;
1253 if (DocumentStyle
== LATEX_ARTICLE
)
1256 if (macroId
!= ltSECTIONSTAR
&& macroId
!= ltSECTIONHEADINGSTAR
)
1259 wxChar
*topicName
= FindTopicName(GetNextChunk());
1260 SetCurrentSectionName(topicName
);
1261 NotifyParentHasChildren(1);
1262 if (winHelpContents
&& winHelp
&& !InPopups())
1264 OutputCurrentSectionToString(wxTex2RTFBuffer
);
1265 WriteWinHelpContentsFileLine(topicName
, wxTex2RTFBuffer
, 2);
1267 AddTexRef(topicName
, NULL
, SectionNameString
, chapterNo
, sectionNo
);
1271 SetCurrentOutputs(jumpFrom
, Sections
);
1272 // Newline for a new section if this is an article
1273 if ((DocumentStyle
== LATEX_ARTICLE
) &&
1274 ((macroId
== ltSECTION
) || (macroId
== ltSECTIONSTAR
) || (macroId
== ltSECTIONHEADINGSTAR
)))
1275 wxFprintf(Sections
, _T("\\page\n"));
1278 wxFprintf(jumpFrom
, _T("\n{\\uldb "));
1282 if (DocumentStyle
== LATEX_ARTICLE
)
1284 TexOutput(_T("\\sect\\pgncont\n"));
1285 // If a non-custom page style, we generate the header now.
1286 if (PageStyle
&& (wxStrcmp(PageStyle
, _T("plain")) == 0 ||
1287 wxStrcmp(PageStyle
, _T("empty")) == 0 ||
1288 wxStrcmp(PageStyle
, _T("headings")) == 0))
1290 OutputRTFHeaderCommands();
1291 OutputRTFFooterCommands();
1294 SetCurrentOutput(Contents
);
1296 if (macroId
== ltSECTION
)
1300 if (DocumentStyle
== LATEX_REPORT
)
1301 wxFprintf(Contents
, _T("\n\\pard{\\tab %d.%d\\tab "), chapterNo
, sectionNo
);
1303 wxFprintf(Contents
, _T("\\par\n\\pard{\\b %d\\tab "), sectionNo
);
1306 else if (macroId
== ltSECTIONHEADING
)
1310 if (DocumentStyle
== LATEX_REPORT
)
1311 wxFprintf(Contents
, _T("\n\\pard{\\tab ")); //, chapterNo, sectionNo);
1313 wxFprintf(Contents
, _T("\\par\n\\pard{\\b ")); //, sectionNo);
1316 else SetCurrentOutput(NULL
);
1319 if (startedSections
)
1322 wxFprintf(Sections
, _T("\\page\n"));
1324 startedSections
= TRUE
;
1327 wxFprintf(Sections
, _T("\n${\\footnote "));
1329 // Output heading to contents page
1331 OutputCurrentSection();
1336 wxFprintf(jumpFrom
, _T("}{\\v %s}\\par\\pard\n"), topicName
);
1338 else if ((macroId
!= ltSECTIONSTAR
) && (macroId
!= ltGLOSS
))
1340 if (DocumentStyle
== LATEX_REPORT
)
1341 wxFprintf(Contents
, _T("}\\par\\pard\n"));
1343 wxFprintf(Contents
, _T("}\\par\\par\\pard\n"));
1346 SetCurrentOutput(winHelp
? Sections
: Chapters
);
1350 wxFprintf(Sections
, _T("}\n#{\\footnote %s}\n"), topicName
);
1351 wxFprintf(Sections
, _T("+{\\footnote %s}\n"), GetBrowseString());
1352 OutputSectionKeyword(Sections
);
1353 GenerateKeywordsForTopic(topicName
);
1356 if (DocumentStyle
== LATEX_ARTICLE
)
1358 wxFprintf(Sections
, _T("!{\\footnote EnableButton(\"Up\");ChangeButtonBinding(\"Up\", \"JumpId(`%s.hlp', `%s')\")}\n"),
1359 wxFileNameFromPath(FileRoot
), _T("Contents"));
1361 else if (CurrentChapterName
)
1363 wxFprintf(Sections
, _T("!{\\footnote EnableButton(\"Up\");ChangeButtonBinding(\"Up\", \"JumpId(`%s.hlp', `%s')\")}\n"),
1364 wxFileNameFromPath(FileRoot
), CurrentChapterName
);
1371 wxChar
*styleCommand
= _T("");
1372 if (!winHelp
&& useHeadingStyles
&& (macroId
!= ltSECTIONSTAR
))
1374 if (DocumentStyle
== LATEX_ARTICLE
)
1375 styleCommand
= _T("\\s1");
1377 styleCommand
= _T("\\s2");
1379 wxChar
*keep
= _T("");
1380 if (winHelp
&& (macroId
!= ltGLOSS
) && !InPopups())
1381 keep
= _T("\\keepn\\sa140\\sb140");
1383 wxFprintf(winHelp
? Sections
: Chapters
, _T("\\pard{%s%s"),
1384 keep
, styleCommand
);
1386 WriteHeadingStyle((winHelp
? Sections
: Chapters
),
1387 (DocumentStyle
== LATEX_ARTICLE
? 1 : 2));
1388 wxFprintf(winHelp
? Sections
: Chapters
, _T(" "));
1392 if ((macroId
!= ltSECTIONSTAR
) && (macroId
!= ltSECTIONHEADINGSTAR
) && (macroId
!= ltGLOSS
))
1394 if (DocumentStyle
== LATEX_REPORT
)
1397 // wxFprintf(Chapters, _T("{\\bkmkstart %s}%d.%d{\\bkmkend %s}. "), topicName, chapterNo, sectionNo,
1398 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), topicName
,
1401 wxFprintf(Chapters
, _T("%d.%d. "), chapterNo
, sectionNo
);
1406 // wxFprintf(Chapters, "{\\bkmkstart %s}%d{\\bkmkend %s}. ", topicName, sectionNo,
1407 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), topicName
,
1410 wxFprintf(Chapters
, _T("%d. "), sectionNo
);
1415 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), topicName
, topicName
);
1418 OutputCurrentSection();
1419 TexOutput(_T("\\par\\pard}\n"));
1420 // TexOutput(_T("\\par\\pard}\\par\n"));
1422 issuedNewParagraph
= 1;
1423 WriteEnvironmentStyles();
1424 // issuedNewParagraph = 2;
1429 case ltSUBSECTIONSTAR
:
1430 case ltMEMBERSECTION
:
1431 case ltFUNCTIONSECTION
:
1435 if (winHelp
&& !Sections
)
1437 OnError(_T("You cannot have a subsection before a section!"));
1441 subsubsectionNo
= 0;
1443 if (macroId
!= ltSUBSECTIONSTAR
)
1446 wxChar
*topicName
= FindTopicName(GetNextChunk());
1447 SetCurrentSubsectionName(topicName
);
1448 NotifyParentHasChildren(2);
1449 if (winHelpContents
&& winHelp
&& !InPopups())
1451 OutputCurrentSectionToString(wxTex2RTFBuffer
);
1452 WriteWinHelpContentsFileLine(topicName
, wxTex2RTFBuffer
, 3);
1454 AddTexRef(topicName
, NULL
, SectionNameString
, chapterNo
, sectionNo
, subsectionNo
);
1458 SetCurrentOutputs(Sections
, Subsections
);
1459 SetCurrentOutputs(Sections
, Subsections
);
1461 wxFprintf(Sections
, _T("\n{\\uldb "));
1465 if ((macroId
!= ltSUBSECTIONSTAR
) && (macroId
!= ltMEMBERSECTION
) &&
1466 (macroId
!= ltFUNCTIONSECTION
))
1468 SetCurrentOutput(Contents
);
1469 if (DocumentStyle
== LATEX_REPORT
)
1470 wxFprintf(Contents
, _T("\n\\pard\\tab\\tab %d.%d.%d\\tab "), chapterNo
, sectionNo
, subsectionNo
);
1472 wxFprintf(Contents
, _T("\n\\pard\\tab %d.%d\\tab "), sectionNo
, subsectionNo
);
1473 } else SetCurrentOutput(NULL
);
1475 if (startedSections
)
1480 wxFprintf(Subsections
, _T("\\page\n"));
1482 // Experimental JACS 2004-02-21
1485 wxFprintf(Chapters
, _T("\\par\n"));
1488 startedSections
= TRUE
;
1491 wxFprintf(Subsections
, _T("\n${\\footnote "));
1493 // Output to contents page
1495 OutputCurrentSection();
1500 wxFprintf(Sections
, _T("}{\\v %s}\\par\\pard\n"), topicName
);
1502 else if ((macroId
!= ltSUBSECTIONSTAR
) && (macroId
!= ltMEMBERSECTION
) &&
1503 (macroId
!= ltFUNCTIONSECTION
))
1504 wxFprintf(Contents
, _T("\\par\\pard\n"));
1506 SetCurrentOutput(winHelp
? Subsections
: Chapters
);
1509 wxFprintf(Subsections
, _T("}\n#{\\footnote %s}\n"), topicName
);
1510 wxFprintf(Subsections
, _T("+{\\footnote %s}\n"), GetBrowseString());
1511 OutputSectionKeyword(Subsections
);
1512 GenerateKeywordsForTopic(topicName
);
1513 if (useUpButton
&& CurrentSectionName
)
1515 wxFprintf(Subsections
, _T("!{\\footnote EnableButton(\"Up\");ChangeButtonBinding(\"Up\", \"JumpId(`%s.hlp', `%s')\")}\n"),
1516 wxFileNameFromPath(FileRoot
), CurrentSectionName
);
1519 if (!winHelp
&& indexSubsections
&& useWord
)
1521 // Insert index entry for this subsection
1522 TexOutput(_T("{\\xe\\v {"));
1523 OutputCurrentSection();
1524 TexOutput(_T("}}"));
1529 wxChar
*styleCommand
= _T("");
1530 if (!winHelp
&& useHeadingStyles
&& (macroId
!= ltSUBSECTIONSTAR
))
1532 if (DocumentStyle
== LATEX_ARTICLE
)
1533 styleCommand
= _T("\\s2");
1535 styleCommand
= _T("\\s3");
1537 wxChar
*keep
= _T("");
1538 if (winHelp
&& !InPopups())
1539 keep
= _T("\\keepn\\sa140\\sb140");
1541 wxFprintf(winHelp
? Subsections
: Chapters
, _T("\\pard{%s%s"),
1542 keep
, styleCommand
);
1544 WriteHeadingStyle((winHelp
? Subsections
: Chapters
),
1545 (DocumentStyle
== LATEX_ARTICLE
? 2 : 3));
1546 wxFprintf(winHelp
? Subsections
: Chapters
, _T(" "));
1550 if ((macroId
!= ltSUBSECTIONSTAR
) && (macroId
!= ltMEMBERSECTION
) &&
1551 (macroId
!= ltFUNCTIONSECTION
))
1553 if (DocumentStyle
== LATEX_REPORT
)
1556 // wxFprintf(Chapters, _T("{\\bkmkstart %s}%d.%d.%d{\\bkmkend %s}. "), topicName, chapterNo, sectionNo, subsectionNo,
1557 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), topicName
,
1560 wxFprintf(Chapters
, _T("%d.%d.%d. "), chapterNo
, sectionNo
, subsectionNo
);
1565 // wxFprintf(Chapters, _T("{\\bkmkstart %s}%d.%d{\\bkmkend %s}. "), topicName, sectionNo, subsectionNo,
1566 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), topicName
,
1569 wxFprintf(Chapters
, _T("%d.%d. "), sectionNo
, subsectionNo
);
1574 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), topicName
, topicName
);
1577 OutputCurrentSection(); // Repeat section header
1579 // Experimental JACS
1580 TexOutput(_T("\\par\\pard}\n"));
1581 // TexOutput(_T("\\par\\pard}\\par\n"));
1583 issuedNewParagraph
= 1;
1584 WriteEnvironmentStyles();
1589 case ltSUBSUBSECTION
:
1590 case ltSUBSUBSECTIONSTAR
:
1594 if (winHelp
&& !Subsections
)
1596 OnError(_T("You cannot have a subsubsection before a subsection!"));
1600 if (macroId
!= ltSUBSUBSECTIONSTAR
)
1603 wxChar
*topicName
= FindTopicName(GetNextChunk());
1604 SetCurrentTopic(topicName
);
1605 NotifyParentHasChildren(3);
1606 if (winHelpContents
&& winHelp
)
1608 OutputCurrentSectionToString(wxTex2RTFBuffer
);
1609 WriteWinHelpContentsFileLine(topicName
, wxTex2RTFBuffer
, 4);
1611 AddTexRef(topicName
, NULL
, SectionNameString
, chapterNo
, sectionNo
, subsectionNo
, subsubsectionNo
);
1615 SetCurrentOutputs(Subsections
, Subsubsections
);
1616 wxFprintf(Subsections
, _T("\n{\\uldb "));
1620 if (macroId
!= ltSUBSUBSECTIONSTAR
)
1622 if (DocumentStyle
== LATEX_ARTICLE
)
1624 SetCurrentOutput(Contents
);
1625 wxFprintf(Contents
, _T("\n\\tab\\tab %d.%d.%d\\tab "),
1626 sectionNo
, subsectionNo
, subsubsectionNo
);
1629 SetCurrentOutput(NULL
); // Don't write it into the contents, or anywhere else
1632 SetCurrentOutput(NULL
); // Don't write it into the contents, or anywhere else
1635 if (startedSections
)
1638 wxFprintf(Subsubsections
, _T("\\page\n"));
1639 // Experimental JACS 2004-02-21
1642 wxFprintf(Chapters
, _T("\\par\n"));
1646 startedSections
= TRUE
;
1649 wxFprintf(Subsubsections
, _T("\n${\\footnote "));
1651 // Output header to contents page
1652 OutputCurrentSection();
1655 wxFprintf(Subsections
, _T("}{\\v %s}\\par\\pard\n"), topicName
);
1656 else if ((DocumentStyle
== LATEX_ARTICLE
) && (macroId
!= ltSUBSUBSECTIONSTAR
))
1657 wxFprintf(Contents
, _T("\\par\\pard\n"));
1659 SetCurrentOutput(winHelp
? Subsubsections
: Chapters
);
1662 wxFprintf(Subsubsections
, _T("}\n#{\\footnote %s}\n"), topicName
);
1663 wxFprintf(Subsubsections
, _T("+{\\footnote %s}\n"), GetBrowseString());
1664 OutputSectionKeyword(Subsubsections
);
1665 GenerateKeywordsForTopic(topicName
);
1666 if (useUpButton
&& CurrentSubsectionName
)
1668 wxFprintf(Subsubsections
, _T("!{\\footnote EnableButton(\"Up\");ChangeButtonBinding(\"Up\", \"JumpId(`%s.hlp', `%s')\")}\n"),
1669 wxFileNameFromPath(FileRoot
), CurrentSubsectionName
);
1672 if (!winHelp
&& indexSubsections
&& useWord
)
1674 // Insert index entry for this subsubsection
1675 TexOutput(_T("{\\xe\\v {"));
1676 OutputCurrentSection();
1677 TexOutput(_T("}}"));
1680 wxChar
*styleCommand
= _T("");
1681 if (!winHelp
&& useHeadingStyles
&& (macroId
!= ltSUBSUBSECTIONSTAR
))
1683 if (DocumentStyle
== LATEX_ARTICLE
)
1684 styleCommand
= _T("\\s3");
1686 styleCommand
= _T("\\s4");
1688 wxChar
*keep
= _T("");
1690 keep
= _T("\\keepn\\sa140\\sb140");
1692 wxFprintf(winHelp
? Subsubsections
: Chapters
, _T("\\pard{%s%s"),
1693 keep
, styleCommand
);
1695 WriteHeadingStyle((winHelp
? Subsubsections
: Chapters
),
1696 (DocumentStyle
== LATEX_ARTICLE
? 3 : 4));
1697 wxFprintf(winHelp
? Subsubsections
: Chapters
, _T(" "));
1701 if ((macroId
!= ltSUBSUBSECTIONSTAR
))
1703 if (DocumentStyle
== LATEX_ARTICLE
)
1706 // wxFprintf(Chapters, _T("{\\bkmkstart %s}%d.%d.%d{\\bkmkend %s}. "), topicName, sectionNo, subsectionNo, subsubsectionNo,
1707 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), topicName
,
1710 wxFprintf(Chapters
, _T("%d.%d.%d. "), sectionNo
, subsectionNo
, subsubsectionNo
);
1715 // wxFprintf(Chapters, _T("{\\bkmkstart %s}%d.%d.%d.%d{\\bkmkend %s}. "), topicName, chapterNo, sectionNo, subsectionNo, subsubsectionNo,
1716 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), topicName
,
1719 wxFprintf(Chapters
, _T("%d.%d.%d.%d. "), chapterNo
, sectionNo
, subsectionNo
, subsubsectionNo
);
1724 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), topicName
, topicName
);
1727 OutputCurrentSection(); // Repeat section header
1728 TexOutput(_T("\\par\\pard}\n"));
1729 issuedNewParagraph
= 1;
1730 WriteEnvironmentStyles();
1731 // TexOutput(_T("\\par\\pard}\\par\n"));
1732 // issuedNewParagraph = 2;
1742 wxChar
*topicName
= FindTopicName(GetNextChunk());
1743 SetCurrentTopic(topicName
);
1745 TexOutput(_T("\\pard\\par"));
1752 if (winHelp
|| !useWord
)
1754 if (DocumentStyle
!= LATEX_ARTICLE
)
1755 wxSprintf(figBuf
, _T("%s %d.%d: "), FigureNameString
, chapterNo
, figureNo
);
1757 wxSprintf(figBuf
, _T("%s %d: "), FigureNameString
, figureNo
);
1761 wxSprintf(figBuf
, _T("%s {\\field\\flddirty{\\*\\fldinst SEQ Figure \\\\* ARABIC }{\\fldrslt {\\bkmkstart %s}??{\\bkmkend %s}}}: "),
1762 FigureNameString
, topicName
, topicName
);
1769 if (winHelp
|| !useWord
)
1771 if (DocumentStyle
!= LATEX_ARTICLE
)
1772 wxSprintf(figBuf
, _T("%s %d.%d: "), TableNameString
, chapterNo
, tableNo
);
1774 wxSprintf(figBuf
, _T("%s %d: "), TableNameString
, tableNo
);
1778 wxSprintf(figBuf
, _T("%s {\\field\\flddirty{\\*\\fldinst SEQ Table \\\\* ARABIC }{\\fldrslt {\\bkmkstart %s}??{\\bkmkend %s}}}: "),
1779 TableNameString
, topicName
, topicName
);
1783 int n
= (inTable
? tableNo
: figureNo
);
1784 AddTexRef(topicName
, NULL
, NULL
,
1785 ((DocumentStyle
!= LATEX_ARTICLE
) ? chapterNo
: n
),
1786 ((DocumentStyle
!= LATEX_ARTICLE
) ? n
: 0));
1789 TexOutput(_T("\\qc{\\b "));
1791 TexOutput(_T("\\ql{\\b "));
1794 OutputCurrentSection();
1796 TexOutput(_T("}\\par\\pard\n"));
1797 WriteEnvironmentStyles();
1804 // SetCurrentOutput(winHelp ? Subsections : Chapters);
1811 TexOutput(_T("}\n"));
1814 TexOutput(_T("K{\\footnote {K} "));
1815 suppressNameDecoration
= TRUE
;
1816 TraverseChildrenFromChunk(currentMember
);
1817 suppressNameDecoration
= FALSE
;
1818 TexOutput(_T("}\n"));
1820 if (!winHelp
&& useWord
)
1822 // Insert index entry for this function
1823 TexOutput(_T("{\\xe\\v {"));
1824 suppressNameDecoration
= TRUE
; // Necessary so don't print "(\\bf" etc.
1825 TraverseChildrenFromChunk(currentMember
);
1826 suppressNameDecoration
= FALSE
;
1827 TexOutput(_T("}}"));
1834 // SetCurrentOutput(winHelp ? Subsections : Chapters);
1841 TexOutput(_T("}\n"));
1844 TexOutput(_T("K{\\footnote {K} "));
1845 suppressNameDecoration
= TRUE
; // Necessary so don't print "(\\bf" etc.
1846 TraverseChildrenFromChunk(currentMember
);
1847 suppressNameDecoration
= FALSE
;
1848 TexOutput(_T("}\n"));
1850 if (!winHelp
&& useWord
)
1852 // Insert index entry for this function
1853 TexOutput(_T("{\\xe\\v {"));
1854 suppressNameDecoration
= TRUE
; // Necessary so don't print "(\\bf" etc.
1855 TraverseChildrenFromChunk(currentMember
);
1856 suppressNameDecoration
= FALSE
;
1857 TexOutput(_T("}}"));
1864 // SetCurrentOutput(winHelp ? Subsections : Chapters);
1867 TexOutput(_T("{\\b "));
1871 TexOutput(_T("}\n"));
1874 TexOutput(_T("K{\\footnote {K} "));
1875 TraverseChildrenFromChunk(currentMember
);
1876 TexOutput(_T("}\n"));
1878 if (!winHelp
&& useWord
)
1880 // Insert index entry for this function
1881 TexOutput(_T("{\\xe\\v {"));
1882 suppressNameDecoration
= TRUE
; // Necessary so don't print "(\\bf" etc.
1883 TraverseChildrenFromChunk(currentMember
);
1884 suppressNameDecoration
= FALSE
;
1885 TexOutput(_T("}}"));
1893 SetCurrentOutput(Chapters
);
1896 case ltTABLEOFCONTENTS
:
1900 if (!winHelp
&& useWord
)
1902 // Insert Word for Windows table of contents
1903 TexOutput(_T("\\par\\pard\\pgnrestart\\sect\\titlepg"));
1905 // In linear RTF, same as chapter headings.
1906 wxSprintf(buf
, _T("{\\b\\fs%d %s}\\par\\par\\pard\n\n"), chapterFont
*2, ContentsNameString
);
1909 wxSprintf(buf
, _T("{\\field{\\*\\fldinst TOC \\\\o \"1-%d\" }{\\fldrslt PRESS F9 TO REFORMAT CONTENTS}}\n"), contentsDepth
);
1911 // TexOutput(_T("\\sect\\sectd"));
1915 FILE *fd
= wxFopen(ContentsName
, _T("r"));
1928 TexOutput(_T("{\\i RUN TEX2RTF AGAIN FOR CONTENTS PAGE}\\par\n"));
1929 OnInform(_T("Run Tex2RTF again to include contents page."));
1938 // TexOutput(_T("{\\b void}"));
1944 TexOutput(_T("{\\scaps HARDY}"));
1950 TexOutput(_T("wxCLIPS"));
1953 case ltSPECIALAMPERSAND
:
1958 TexOutput(_T("\\cell "));
1964 case ltSPECIALTILDE
:
1968 if (TRUE
) // (inVerbatim)
1975 case ltBACKSLASHCHAR
:
1981 // TexOutput(_T("\\cell\\row\\trowd\\trgaph108\\trleft-108\n"));
1982 TexOutput(_T("\\cell\\row\\trowd\\trgaph108\n"));
1983 int currentWidth
= 0;
1984 for (int i
= 0; i
< noColumns
; i
++)
1986 currentWidth
+= TableData
[i
].width
;
1987 if (TableData
[i
].rightBorder
)
1988 TexOutput(_T("\\clbrdrr\\brdrs\\brdrw15"));
1990 if (TableData
[i
].leftBorder
)
1991 TexOutput(_T("\\clbrdrl\\brdrs\\brdrw15"));
1993 wxSprintf(buf
, _T("\\cellx%d"), currentWidth
);
1996 TexOutput(_T("\\pard\\intbl\n"));
1999 TexOutput(_T("\\line\n"));
2006 TexOutput(_T("\tab "));
2009 case ltRTFSP
: // Explicit space, RTF only
2021 if (indentLevel
> 0)
2023 // Experimental JACS 2004-02-21
2024 TexOutput(_T("\\par\n"));
2025 issuedNewParagraph
= 1;
2026 // TexOutput(_T("\\par\\par\n"));
2027 // issuedNewParagraph = 2;
2031 // Top-level list: issue a new paragraph if we haven't
2033 if (!issuedNewParagraph
)
2035 TexOutput(_T("\\par\\pard"));
2036 WriteEnvironmentStyles();
2037 issuedNewParagraph
= 1;
2039 else issuedNewParagraph
= 0;
2042 TexOutput(_T("\\fi0\n"));
2044 if (macroId
== ltENUMERATE
)
2045 listType
= LATEX_ENUMERATE
;
2046 else if (macroId
== ltITEMIZE
)
2047 listType
= LATEX_ITEMIZE
;
2049 listType
= LATEX_DESCRIPTION
;
2052 wxNode
*node
= itemizeStack
.GetFirst();
2054 oldIndent
= ((ItemizeStruc
*)node
->GetData())->indentation
;
2056 int indentSize1
= oldIndent
+ 20*labelIndentTab
;
2057 int indentSize2
= oldIndent
+ 20*itemIndentTab
;
2059 ItemizeStruc
*struc
= new ItemizeStruc(listType
, indentSize2
, indentSize1
);
2060 itemizeStack
.Insert(struc
);
2062 wxSprintf(buf
, _T("\\tx%d\\tx%d\\li%d\\sa200"), indentSize1
, indentSize2
, indentSize2
);
2063 PushEnvironmentStyle(buf
);
2067 currentItemSep
= 8; // Reset to the default
2069 PopEnvironmentStyle();
2071 if (itemizeStack
.GetFirst())
2073 ItemizeStruc
*struc
= (ItemizeStruc
*)itemizeStack
.GetFirst()->GetData();
2075 delete itemizeStack
.GetFirst();
2077 /* Change 18/7/97 - don't know why we wish to do this
2078 if (itemizeStack.Number() == 0)
2080 OnMacro(ltPAR, 0, TRUE);
2081 OnMacro(ltPAR, 0, FALSE);
2082 issuedNewParagraph = 2;
2094 wxNode
*node
= itemizeStack
.GetFirst();
2096 oldIndent
= ((ItemizeStruc
*)node
->GetData())->indentation
;
2098 int indentSize
= oldIndent
+ TwoColWidthA
;
2100 ItemizeStruc
*struc
= new ItemizeStruc(LATEX_TWOCOL
, indentSize
);
2101 itemizeStack
.Insert(struc
);
2103 // wxSprintf(buf, _T("\\tx%d\\li%d\\ri%d"), indentSize, indentSize, TwoColWidthA+TwoColWidthB+oldIndent);
2104 wxSprintf(buf
, _T("\\tx%d\\li%d\\sa200"), indentSize
, indentSize
);
2105 PushEnvironmentStyle(buf
);
2110 PopEnvironmentStyle();
2111 if (itemizeStack
.GetFirst())
2113 ItemizeStruc
*struc
= (ItemizeStruc
*)itemizeStack
.GetFirst()->GetData();
2115 delete itemizeStack
.GetFirst();
2119 TexOutput(_T("\\pard\n"));
2120 WriteEnvironmentStyles();
2122 /* why do we need this? */
2124 TexOutput(_T("\\pard\n"));
2126 if (itemizeStack
.GetCount() == 0)
2128 issuedNewParagraph
= 0;
2129 OnMacro(ltPAR
, 0, TRUE
);
2130 OnMacro(ltPAR
, 0, FALSE
);
2138 wxNode
*node
= itemizeStack
.GetFirst();
2141 ItemizeStruc
*struc
= (ItemizeStruc
*)node
->GetData();
2144 struc
->currentItem
+= 1;
2145 wxChar indentBuf
[60];
2147 int indentSize1
= struc
->labelIndentation
;
2148 int indentSize2
= struc
->indentation
;
2150 TexOutput(_T("\n"));
2151 if (struc
->currentItem
> 1 && issuedNewParagraph
== 0)
2154 // if (currentItemSep > 0)
2155 // TexOutput(_T("\\par"));
2157 TexOutput(_T("\\par"));
2158 issuedNewParagraph
= 1;
2159 // WriteEnvironmentStyles();
2162 wxSprintf(buf
, _T("\\tx%d\\tx%d\\li%d\\fi-%d\n"), indentSize1
, indentSize2
,
2163 indentSize2
, 20*itemIndentTab
);
2166 switch (struc
->listType
)
2168 case LATEX_ENUMERATE
:
2170 if (descriptionItemArg
)
2172 TexOutput(_T("\\tab{ "));
2173 TraverseChildrenFromChunk(descriptionItemArg
);
2174 TexOutput(_T("}\\tab"));
2175 descriptionItemArg
= NULL
;
2179 wxSprintf(indentBuf
, _T("\\tab{\\b %d.}\\tab"), struc
->currentItem
);
2180 TexOutput(indentBuf
);
2186 if (descriptionItemArg
)
2188 TexOutput(_T("\\tab{ "));
2189 TraverseChildrenFromChunk(descriptionItemArg
);
2190 TexOutput(_T("}\\tab"));
2191 descriptionItemArg
= NULL
;
2195 if (bulletFile
&& winHelp
)
2197 if (winHelpVersion
> 3) // Transparent bitmap
2198 wxSprintf(indentBuf
, _T("\\tab\\{bmct %s\\}\\tab"), bulletFile
);
2200 wxSprintf(indentBuf
, _T("\\tab\\{bmc %s\\}\\tab"), bulletFile
);
2203 wxSprintf(indentBuf
, _T("\\tab{\\b o}\\tab"));
2205 wxSprintf(indentBuf
, _T("\\tab{\\f1\\'b7}\\tab"));
2206 TexOutput(indentBuf
);
2211 case LATEX_DESCRIPTION
:
2213 if (descriptionItemArg
)
2215 TexOutput(_T("\\tab{\\b "));
2216 TraverseChildrenFromChunk(descriptionItemArg
);
2217 TexOutput(_T("} "));
2218 descriptionItemArg
= NULL
;
2228 case ltTWOCOLITEMRULED
:
2230 wxNode
*node
= itemizeStack
.GetFirst();
2233 ItemizeStruc
*struc
= (ItemizeStruc
*)node
->GetData();
2236 struc
->currentItem
+= 1;
2239 wxNode
*node2
= NULL
;
2240 if (itemizeStack
.GetCount() > 1) // TODO: do I actually mean Nth(0) here??
2241 node2
= itemizeStack
.Item(1);
2243 oldIndent
= ((ItemizeStruc
*)node2
->GetData())->indentation
;
2245 TexOutput(_T("\n"));
2248 if (struc
->currentItem
> 1)
2250 if (currentItemSep
> 0)
2251 TexOutput(_T("\\par"));
2253 // WriteEnvironmentStyles();
2257 // wxSprintf(buf, _T("\\tx%d\\li%d\\fi-%d\\ri%d\n"), TwoColWidthA,
2258 // TwoColWidthA, TwoColWidthA, TwoColWidthA+TwoColWidthB+oldIndent);
2260 wxSprintf(buf, _T("\\tx%d\\li%d\\fi-%d\n"), TwoColWidthA,
2261 TwoColWidthA, TwoColWidthA);
2263 wxSprintf(buf
, _T("\\tx%d\\li%d\\fi-%d\n"), TwoColWidthA
+ oldIndent
,
2264 TwoColWidthA
+ oldIndent
, TwoColWidthA
);
2277 if (macroId
== ltVERBATIM
)
2279 if (!issuedNewParagraph
)
2281 TexOutput(_T("\\par\\pard"));
2282 WriteEnvironmentStyles();
2283 issuedNewParagraph
= 1;
2285 else issuedNewParagraph
= 0;
2289 if (macroId
== ltVERBATIM
)
2290 wxSprintf(buf
, _T("{\\f3\\s10\\fs20\\li720\\sa0 "));
2292 wxSprintf(buf
, _T("{\\f3\\fs20 "));
2298 if (macroId
== ltVERBATIM
)
2300 TexOutput(_T("\\pard\n"));
2301 WriteEnvironmentStyles();
2304 TexOutput(_T("\\par\n"));
2305 issuedNewParagraph
= 1;
2316 TexOutput(_T("\\qc "));
2318 PushEnvironmentStyle(_T("\\qc\\sa200"));
2322 TexOutput(_T("\\par\\pard\n"));
2323 issuedNewParagraph
= 1;
2325 PopEnvironmentStyle();
2326 WriteEnvironmentStyles();
2334 TexOutput(_T("\\ql\\sa200 "));
2336 PushEnvironmentStyle(_T("\\ql"));
2340 TexOutput(_T("\\par\\pard\n"));
2341 issuedNewParagraph
= 1;
2343 PopEnvironmentStyle();
2344 WriteEnvironmentStyles();
2352 TexOutput(_T("\\qr\\sa200 "));
2354 PushEnvironmentStyle(_T("\\qr"));
2358 TexOutput(_T("\\par\\pard\n"));
2359 issuedNewParagraph
= 1;
2361 PopEnvironmentStyle();
2362 WriteEnvironmentStyles();
2367 case ltFOOTNOTESIZE
:
2371 wxSprintf(buf
, _T("{\\fs%d\n"), smallFont
*2);
2374 else TexOutput(_T("}\n"));
2382 wxSprintf(buf
, _T("{\\fs%d\n"), tinyFont
*2);
2385 else TexOutput(_T("}\n"));
2392 wxSprintf(buf
, _T("{\\fs%d\n"), normalFont
*2);
2395 else TexOutput(_T("}\n"));
2402 wxSprintf(buf
, _T("{\\fs%d\n"), largeFont1
*2);
2405 else TexOutput(_T("}\n"));
2412 wxSprintf(buf
, _T("{\\fs%d\n"), LargeFont2
*2);
2415 else TexOutput(_T("}\n"));
2422 wxSprintf(buf
, _T("{\\fs%d\n"), LARGEFont3
*2);
2425 else TexOutput(_T("}\n"));
2432 wxSprintf(buf
, _T("{\\fs%d\n"), hugeFont1
*2);
2435 else TexOutput(_T("}\n"));
2442 wxSprintf(buf
, _T("{\\fs%d\n"), HugeFont2
*2);
2445 else TexOutput(_T("}\n"));
2452 wxSprintf(buf
, _T("{\\fs%d\n"), HUGEFont3
*2);
2455 else TexOutput(_T("}\n"));
2464 TexOutput(_T("{\\b "));
2466 else TexOutput(_T("}"));
2473 TexOutput(_T("{\\ul "));
2475 else TexOutput(_T("}"));
2486 TexOutput(_T("{\\i "));
2488 else TexOutput(_T("}"));
2491 // Roman font: do nothing. Should really switch between
2500 TexOutput(_T("{\\plain "));
2502 else TexOutput(_T("}"));
2506 // Medium-weight font. Unbolden...
2511 TexOutput(_T("{\\b0 "));
2513 else TexOutput(_T("}"));
2516 // Upright (un-italic or slant)
2521 TexOutput(_T("{\\i0 "));
2523 else TexOutput(_T("}"));
2532 TexOutput(_T("{\\scaps "));
2534 else TexOutput(_T("}"));
2543 TexOutput(_T("{\\f3 "));
2545 else TexOutput(_T("}"));
2551 TexOutput(_T("\\{"));
2557 TexOutput(_T("\\}"));
2563 TexOutput(_T("\\\\"));
2570 if ( issuedNewParagraph
== 0 )
2572 TexOutput(_T("\\par\\pard"));
2573 issuedNewParagraph
++;
2575 // Extra par if parskip is more than zero (usually looks best.)
2576 // N.B. JACS 2004-02-21: shouldn't need this for linear RTF if
2577 // we have a suitable set of styles.
2578 if (winHelp
&& !inTabular
&& (ParSkip
> 0))
2580 TexOutput(_T("\\par"));
2581 issuedNewParagraph
++;
2583 WriteEnvironmentStyles();
2585 // 1 is a whole paragraph if ParSkip == 0,
2586 // half a paragraph if ParSkip > 0
2587 else if ( issuedNewParagraph
== 1 )
2589 // Don't need a par at all if we've already had one,
2590 // and ParSkip == 0.
2592 // Extra par if parskip is more than zero (usually looks best.)
2593 if (winHelp
&& !inTabular
&& (ParSkip
> 0))
2595 TexOutput(_T("\\par"));
2596 issuedNewParagraph
++;
2598 WriteEnvironmentStyles();
2601 if (!issuedNewParagraph || (issuedNewParagraph > 1))
2603 TexOutput(_T("\\par\\pard"));
2605 // Extra par if parskip is more than zero (usually looks best.)
2606 if (!inTabular && (ParSkip > 0))
2607 TexOutput(_T("\\par"));
2608 WriteEnvironmentStyles();
2612 TexOutput(_T("\n"));
2618 // In Windows Help, no newpages until we've started some chapters or sections
2619 if (!(winHelp
&& !startedSections
))
2621 TexOutput(_T("\\page\n"));
2626 if (start
&& DocumentTitle
)
2628 TexOutput(_T("\\par\\pard"));
2630 TexOutput(_T("\\par"));
2631 wxSprintf(buf
, _T("\\qc{\\fs%d\\b "), titleFont
*2);
2633 TraverseChildrenFromChunk(DocumentTitle
);
2634 TexOutput(_T("}\\par\\pard\n"));
2639 TexOutput(_T("\\par"));
2640 wxSprintf(buf
, _T("\\par\\qc{\\fs%d "), authorFont
*2);
2642 TraverseChildrenFromChunk(DocumentAuthor
);
2644 TexOutput(_T("\\par\\pard\n"));
2648 TexOutput(_T("\\par"));
2649 wxSprintf(buf
, _T("\\qc{\\fs%d "), authorFont
*2);
2651 TraverseChildrenFromChunk(DocumentDate
);
2652 TexOutput(_T("}\\par\\pard\n"));
2654 // If linear RTF, we want this titlepage to be in a separate
2655 // section with its own (blank) header and footer
2656 if (!winHelp
&& (DocumentStyle
!= LATEX_ARTICLE
))
2658 TexOutput(_T("{\\header }{\\footer }\n"));
2659 // Not sure about this: we get too many sections.
2660 // TexOutput(_T("\\sect"));
2665 case ltADDCONTENTSLINE
:
2669 if (contentsLineSection
&& contentsLineValue
)
2671 if (wxStrcmp(contentsLineSection
, _T("chapter")) == 0)
2673 wxFprintf(Contents
, _T("\\par\n{\\b %s}\\par\n"), contentsLineValue
);
2675 else if (wxStrcmp(contentsLineSection
, _T("section")) == 0)
2677 if (DocumentStyle
!= LATEX_ARTICLE
)
2678 wxFprintf(Contents
, _T("\n\\tab%s\\par\n"), contentsLineValue
);
2680 wxFprintf(Contents
, _T("\\par\n{\\b %s}\\par\n"), contentsLineValue
);
2690 TexOutput(_T("\\brdrb\\brdrs\\par\\pard\n"));
2691 issuedNewParagraph
= 1;
2692 WriteEnvironmentStyles();
2700 TexOutput(_T("\\brdrb\\brdrs\\par\\pard\n"));
2701 issuedNewParagraph
= 1;
2702 WriteEnvironmentStyles();
2712 case ltNUMBEREDBIBITEM
:
2715 TexOutput(_T("\\li260\\fi-260 ")); // Indent from 2nd line
2717 TexOutput(_T("\\par\\pard\\par\n\n"));
2724 TexOutput(_T("{\\field{\\*\\fldinst PAGE \\\\* MERGEFORMAT }{\\fldrslt 1}}"));
2732 // TexOutput(_T("{\\field{\\*\\fldinst SECTION \\\\* MERGEFORMAT }{\\fldrslt 1}}"));
2733 wxSprintf(buf
, _T("%d"), chapterNo
);
2742 // TexOutput(_T("{\\field{\\*\\fldinst SECTION \\\\* MERGEFORMAT }{\\fldrslt 1}}"));
2743 wxSprintf(buf
, _T("%d"), sectionNo
);
2750 if (!start
&& !winHelp
)
2752 TexOutput(_T("\\cols2\n"));
2758 if (!start
&& !winHelp
)
2760 TexOutput(_T("\\cols1\n"));
2766 if (start
&& useWord
&& !winHelp
)
2768 FakeCurrentSection(_T("Index"));
2769 OnMacro(ltPAR
, 0, TRUE
);
2770 OnMacro(ltPAR
, 0, FALSE
);
2771 TexOutput(_T("\\par{\\field{\\*\\fldinst INDEX \\\\h \"\\emdash A\\emdash \"\\\\c \"2\"}{\\fldrslt PRESS F9 TO REFORMAT INDEX}}\n"));
2775 case ltLISTOFFIGURES
:
2777 if (start
&& useWord
&& !winHelp
)
2779 FakeCurrentSection(FiguresNameString
, FALSE
);
2780 OnMacro(ltPAR
, 0, TRUE
);
2781 OnMacro(ltPAR
, 0, FALSE
);
2782 OnMacro(ltPAR
, 0, TRUE
);
2783 OnMacro(ltPAR
, 0, FALSE
);
2785 wxSprintf(buf
, _T("{\\field\\fldedit{\\*\\fldinst TOC \\\\c \"%s\" }{\\fldrslt PRESS F9 TO REFORMAT LIST OF FIGURES}}\n"),
2791 case ltLISTOFTABLES
:
2793 if (start
&& useWord
&& !winHelp
)
2795 FakeCurrentSection(TablesNameString
, FALSE
);
2796 OnMacro(ltPAR
, 0, TRUE
);
2797 OnMacro(ltPAR
, 0, FALSE
);
2798 OnMacro(ltPAR
, 0, TRUE
);
2799 OnMacro(ltPAR
, 0, FALSE
);
2801 wxSprintf(buf
, _T("{\\field\\fldedit{\\*\\fldinst TOC \\\\c \"%s\" }{\\fldrslt PRESS F9 TO REFORMAT LIST OF TABLES}}\n"),
2809 if (start
) TexOutput(_T("{\\f1\\'61}"));
2812 if (start
) TexOutput(_T("{\\f1\\'62}"));
2815 if (start
) TexOutput(_T("{\\f1\\'63}"));
2818 if (start
) TexOutput(_T("{\\f1\\'64}"));
2822 if (start
) TexOutput(_T("{\\f1\\'65}"));
2825 if (start
) TexOutput(_T("{\\f1\\'7A}"));
2828 if (start
) TexOutput(_T("{\\f1\\'68}"));
2832 if (start
) TexOutput(_T("{\\f1\\'71}"));
2835 if (start
) TexOutput(_T("{\\f1\\'69}"));
2838 if (start
) TexOutput(_T("{\\f1\\'6B}"));
2841 if (start
) TexOutput(_T("{\\f1\\'6C}"));
2844 if (start
) TexOutput(_T("{\\f1\\'6D}"));
2847 if (start
) TexOutput(_T("{\\f1\\'6E}"));
2850 if (start
) TexOutput(_T("{\\f1\\'78}"));
2853 if (start
) TexOutput(_T("{\\f1\\'70}"));
2856 if (start
) TexOutput(_T("{\\f1\\'76}"));
2860 if (start
) TexOutput(_T("{\\f1\\'72}"));
2863 if (start
) TexOutput(_T("{\\f1\\'73}"));
2866 if (start
) TexOutput(_T("{\\f1\\'56}"));
2869 if (start
) TexOutput(_T("{\\f1\\'74}"));
2872 if (start
) TexOutput(_T("{\\f1\\'75}"));
2876 if (start
) TexOutput(_T("{\\f1\\'66}"));
2879 if (start
) TexOutput(_T("{\\f1\\'63}"));
2882 if (start
) TexOutput(_T("{\\f1\\'79}"));
2885 if (start
) TexOutput(_T("{\\f1\\'77}"));
2888 if (start
) TexOutput(_T("{\\f1\\'47}"));
2891 if (start
) TexOutput(_T("{\\f1\\'44}"));
2894 if (start
) TexOutput(_T("{\\f1\\'51}"));
2897 if (start
) TexOutput(_T("{\\f1\\'4C}"));
2900 if (start
) TexOutput(_T("{\\f1\\'58}"));
2903 if (start
) TexOutput(_T("{\\f1\\'50}"));
2906 if (start
) TexOutput(_T("{\\f1\\'53}"));
2909 if (start
) TexOutput(_T("{\\f1\\'54}"));
2912 if (start
) TexOutput(_T("{\\f1\\'46}"));
2915 if (start
) TexOutput(_T("{\\f1\\'59}"));
2918 if (start
) TexOutput(_T("{\\f1\\'57}"));
2920 // Binary operation symbols
2923 if (start
) TexOutput(_T("{\\f1\\'A3}"));
2926 if (start
) TexOutput(_T("<<"));
2929 if (start
) TexOutput(_T("{\\f1\\'CC}"));
2932 if (start
) TexOutput(_T("{\\f1\\'CD}"));
2935 if (start
) TexOutput(_T("{\\f1\\'CE}"));
2939 if (start
) TexOutput(_T("{\\f1\\'B3}"));
2942 if (start
) TexOutput(_T(">>"));
2945 if (start
) TexOutput(_T("{\\f1\\'C9}"));
2948 if (start
) TexOutput(_T("{\\f1\\'CD}"));
2951 if (start
) TexOutput(_T("{\\f1\\'27}"));
2954 if (start
) TexOutput(_T("{\\f1\\'5E}"));
2957 if (start
) TexOutput(_T("{\\f1\\'B9}"));
2960 if (start
) TexOutput(_T("{\\f1\\'BB}"));
2963 if (start
) TexOutput(_T("{\\f1\\'40}"));
2966 if (start
) TexOutput(_T("{\\f1\\'BA}"));
2969 if (start
) TexOutput(_T("{\\f1\\'B5}"));
2972 if (start
) TexOutput(_T("{\\f1\\'7E}"));
2975 if (start
) TexOutput(_T("{\\f4\\'4A}"));
2978 if (start
) TexOutput(_T("{\\f4\\'4C}"));
2981 if (start
) TexOutput(_T("|"));
2984 // Negated relation symbols
2986 if (start
) TexOutput(_T("{\\f1\\'B9}"));
2989 if (start
) TexOutput(_T("{\\f1\\'CF}"));
2992 if (start
) TexOutput(_T("{\\f1\\'CB}"));
2997 if (start
) TexOutput(_T("{\\f1\\'AC}"));
3000 if (start
) TexOutput(_T("{\\f1\\'DC}"));
3003 if (start
) TexOutput(_T("{\\f1\\'AE}"));
3006 if (start
) TexOutput(_T("{\\f1\\'DE}"));
3008 case ltLEFTRIGHTARROW
:
3009 if (start
) TexOutput(_T("{\\f1\\'AB}"));
3011 case ltLEFTRIGHTARROW2
:
3012 if (start
) TexOutput(_T("{\\f1\\'DB}"));
3015 if (start
) TexOutput(_T("{\\f1\\'AD}"));
3018 if (start
) TexOutput(_T("{\\f1\\'DD}"));
3021 if (start
) TexOutput(_T("{\\f1\\'AF}"));
3024 if (start
) TexOutput(_T("{\\f1\\'DF}"));
3027 // Miscellaneous symbols
3029 if (start
) TexOutput(_T("{\\f1\\'CO}"));
3032 if (start
) TexOutput(_T("{\\f1\\'C3}"));
3035 if (start
) TexOutput(_T("{\\f1\\'C2}"));
3038 if (start
) TexOutput(_T("{\\f1\\'C1}"));
3041 if (start
) TexOutput(_T("{\\f1\\'C6}"));
3044 if (start
) TexOutput(_T("{\\f1\\'D1}"));
3047 if (start
) TexOutput(_T("{\\f1\\'D6}"));
3050 if (start
) TexOutput(_T("{\\f1\\'B6}"));
3053 if (start
) TexOutput(_T("{\\f1\\'5E}"));
3056 if (start
) TexOutput(_T("{\\f1\\'22}"));
3059 if (start
) TexOutput(_T("{\\f1\\'24}"));
3062 if (start
) TexOutput(_T("{\\f1\\'D8}"));
3065 if (start
) TexOutput(_T("{\\f1\\'23}"));
3068 if (start
) TexOutput(_T("{\\f1\\'D0}"));
3071 if (start
) TexOutput(_T("{\\f5\\'73}"));
3074 if (start
) TexOutput(_T("{\\f5\\'A8}"));
3077 if (start
) TexOutput(_T("{\\f5\\'A9}"));
3080 if (start
) TexOutput(_T("{\\f5\\'AA}"));
3083 if (start
) TexOutput(_T("{\\f5\\'AB}"));
3086 if (start
) TexOutput(_T("{\\f1\\'A5}"));
3089 if (start
) TexOutput(_T("{\\f0\\'A9}"));
3092 if (start
) TexOutput(_T("{\\f0\\'AE}"));
3095 if (start
) TexOutput(_T("{\\f1\\'B1}"));
3098 if (start
) TexOutput(_T("{\\f1\\'B1}"));
3101 if (start
) TexOutput(_T("{\\f1\\'B4}"));
3104 if (start
) TexOutput(_T("{\\f1\\'B8}"));
3107 if (start
) TexOutput(_T("{\\f1\\'D7}"));
3110 if (start
) TexOutput(_T("{\\f1\\'2A}"));
3113 if (start
) TexOutput(_T("{\\f5\\'AB}"));
3116 if (start
) TexOutput(_T("{\\f1\\'C7}"));
3119 if (start
) TexOutput(_T("{\\f1\\'C8}"));
3122 if (start
) TexOutput(_T("{\\f1\\'DA}"));
3125 if (start
) TexOutput(_T("{\\f1\\'D9}"));
3128 if (start
) TexOutput(_T("{\\f1\\'B0}"));
3131 if (start
) TexOutput(_T("{\\f1\\'B7}"));
3134 if (start
) TexOutput(_T("{\\f1\\'E0}"));
3137 if (start
) TexOutput(_T("{\\f1\\'C6}"));
3140 if (start
) TexOutput(_T("{\\f1\\'E0}"));
3142 case ltBIGTRIANGLEDOWN
:
3143 if (start
) TexOutput(_T("{\\f1\\'D1}"));
3146 if (start
) TexOutput(_T("{\\f1\\'C5}"));
3149 if (start
) TexOutput(_T("{\\f1\\'C4}"));
3152 if (start
) TexOutput(_T("{\\'DF}"));
3156 if (start
) inFigure
= TRUE
;
3157 else inFigure
= FALSE
;
3162 if (start
) inTable
= TRUE
;
3163 else inTable
= FALSE
;
3168 DefaultOnMacro(macroId
, no_args
, start
);
3174 // Called on start/end of argument examination
3175 bool RTFOnArgument(int macroId
, int arg_no
, bool start
)
3182 case ltCHAPTERHEADING
:
3185 case ltSECTIONHEADING
:
3187 case ltSUBSECTIONSTAR
:
3188 case ltSUBSUBSECTION
:
3189 case ltSUBSUBSECTIONSTAR
:
3191 case ltMEMBERSECTION
:
3192 case ltFUNCTIONSECTION
:
3196 if (!start
&& (arg_no
== 1))
3197 currentSection
= GetArgChunk();
3202 if (start
&& (arg_no
== 1))
3203 TexOutput(_T("\\pard\\li600\\fi-600{\\b "));
3205 if (!start
&& (arg_no
== 1))
3206 TexOutput(_T("} "));
3208 if (start
&& (arg_no
== 2))
3210 if (!suppressNameDecoration
) TexOutput(_T("{\\b "));
3211 currentMember
= GetArgChunk();
3213 if (!start
&& (arg_no
== 2))
3215 if (!suppressNameDecoration
) TexOutput(_T("}"));
3218 if (start
&& (arg_no
== 3))
3220 if (!start
&& (arg_no
== 3))
3222 // TexOutput(_T(")\\li0\\fi0"));
3223 // TexOutput(_T(")\\par\\pard\\li0\\fi0"));
3224 // issuedNewParagraph = 1;
3226 WriteEnvironmentStyles();
3232 if (start
&& (arg_no
== 1))
3233 TexOutput(_T("\\pard\\li260\\fi-260{\\b "));
3234 if (!start
&& (arg_no
== 1))
3235 TexOutput(_T("} "));
3237 if (start
&& (arg_no
== 2))
3239 if (!suppressNameDecoration
) TexOutput(_T("({\\b "));
3240 currentMember
= GetArgChunk();
3242 if (!start
&& (arg_no
== 2))
3244 if (!suppressNameDecoration
) TexOutput(_T("}"));
3247 if (!start
&& (arg_no
== 3))
3249 TexOutput(_T(")\\li0\\fi0"));
3250 WriteEnvironmentStyles();
3256 if (start
&& (arg_no
== 1))
3257 TexOutput(_T("\\pard\\li260\\fi-260"));
3259 if (!start
&& (arg_no
== 1))
3262 if (start
&& (arg_no
== 2))
3263 TexOutput(_T("(*"));
3264 if (!start
&& (arg_no
== 2))
3267 if (start
&& (arg_no
== 2))
3268 currentMember
= GetArgChunk();
3270 if (start
&& (arg_no
== 3))
3272 if (!start
&& (arg_no
== 3))
3274 TexOutput(_T(")\\li0\\fi0"));
3275 WriteEnvironmentStyles();
3281 if (start
&& (arg_no
== 1))
3282 TexOutput(_T("{\\b "));
3283 if (!start
&& (arg_no
== 1))
3285 if (start
&& (arg_no
== 2))
3287 TexOutput(_T("{\\i "));
3289 if (!start
&& (arg_no
== 2))
3297 if (start
&& (arg_no
== 1))
3298 TexOutput(_T("{\\b "));
3299 if (!start
&& (arg_no
== 1))
3300 TexOutput(_T("} ")); // This is the difference from param - one space!
3301 if (start
&& (arg_no
== 2))
3303 TexOutput(_T("{\\i "));
3305 if (!start
&& (arg_no
== 2))
3313 if (!start
&& (arg_no
== 1))
3316 if (start
&& (arg_no
== 2))
3317 currentMember
= GetArgChunk();
3326 wxChar
*refName
= GetArgData();
3327 if (winHelp
|| !useWord
)
3331 TexRef
*texRef
= FindReference(refName
);
3334 sec
= texRef
->sectionNumber
;
3344 wxFprintf(Chapters
, _T("{\\field{\\*\\fldinst REF %s \\\\* MERGEFORMAT }{\\fldrslt ??}}"),
3356 if ((GetNoArgs() - arg_no
) == 1)
3359 TexOutput(_T("{\\uldb "));
3363 if ((GetNoArgs() - arg_no
) == 0) // Arg = 2, or 3 if first is optional
3367 TexOutput(_T("{\\v "));
3369 // Remove green colour/underlining if specified
3370 if (!hotSpotUnderline
&& !hotSpotColour
)
3372 else if (!hotSpotColour
)
3375 else TexOutput(_T("}"));
3378 else // If a linear document, must resolve the references ourselves
3380 if ((GetNoArgs() - arg_no
) == 1)
3382 // In a linear document we display the anchor text in italic plus
3385 TexOutput(_T("{\\i "));
3390 helpRefText
= GetArgChunk();
3394 else if ((GetNoArgs() - arg_no
) == 0) // Arg = 2, or 3 if first is optional
3396 if (macroId
!= ltHELPREFN
)
3398 wxChar
*refName
= GetArgData();
3399 TexRef
*texRef
= NULL
;
3401 texRef
= FindReference(refName
);
3404 if (texRef
|| !ignoreBadRefs
)
3405 TexOutput(_T(" ("));
3408 if (texRef
|| !ignoreBadRefs
)
3412 TexOutput(_T("p. "));
3413 TexOutput(_T("{\\field{\\*\\fldinst PAGEREF "));
3415 TexOutput(_T(" \\\\* MERGEFORMAT }{\\fldrslt ??}}"));
3419 // Only print section name if we're not in Word mode,
3420 // so can't do page references
3423 TexOutput(texRef
->sectionName
);
3425 TexOutput(texRef
->sectionNumber
);
3430 TexOutput(_T("??"));
3431 wxSprintf(buf
, _T("Warning: unresolved reference '%s'"), refName
);
3437 else TexOutput(_T("??"));
3441 if (texRef
|| !ignoreBadRefs
)
3456 else if (arg_no
== 2)
3461 TexOutput(_T(" ({\\f3 "));
3465 TexOutput(_T("})"));
3476 if ((GetNoArgs() - arg_no
) == 1)
3479 TexOutput(_T("{\\ul "));
3483 if ((GetNoArgs() - arg_no
) == 0) // Arg = 2, or 3 if first is optional
3487 TexOutput(_T("{\\v "));
3489 // Remove green colour/underlining if specified
3490 if (!hotSpotUnderline
&& !hotSpotColour
)
3492 else if (!hotSpotColour
)
3495 else TexOutput(_T("}"));
3498 else // A linear document...
3500 if ((GetNoArgs() - arg_no
) == 1)
3502 // In a linear document we just display the anchor text in italic
3504 TexOutput(_T("{\\i "));
3513 case ltADDCONTENTSLINE
:
3515 if (start
&& !winHelp
)
3518 contentsLineSection
= copystring(GetArgData());
3519 else if (arg_no
== 3)
3520 contentsLineValue
= copystring(GetArgData());
3534 static int imageWidth
= 0;
3535 static int imageHeight
= 0;
3537 if (start
&& (arg_no
== 1))
3539 wxChar
*imageDimensions
= copystring(GetArgData());
3541 // imageWidth - Convert points to TWIPS (1 twip = 1/20th of point)
3542 wxStringTokenizer
tok(imageDimensions
, _T(";:"), wxTOKEN_STRTOK
);
3543 if(tok
.HasMoreTokens())
3545 wxString token
= tok
.GetNextToken();
3546 imageWidth
= (int)(20*ParseUnitArgument((wxChar
*)token
.c_str()));
3553 // imageHeight - Convert points to TWIPS (1 twip = 1/20th of point)
3554 if(tok
.HasMoreTokens())
3556 wxString token
= tok
.GetNextToken();
3557 imageHeight
= (int)(20*ParseUnitArgument((wxChar
*)token
.c_str()));
3564 if (imageDimensions
) // glt
3565 delete [] imageDimensions
;
3568 else if (start
&& (arg_no
== 2 ))
3570 wxChar
*filename
= copystring(GetArgData());
3571 wxString f
= _T("");
3572 if ((winHelp
|| (wxStrcmp(bitmapMethod
, _T("includepicture")) == 0) || (wxStrcmp(bitmapMethod
, _T("import")) == 0)) && useWord
)
3574 if (f
== _T("")) // Try for a .shg (segmented hypergraphics file)
3576 wxStrcpy(buf
, filename
);
3577 StripExtension(buf
);
3578 wxStrcat(buf
, _T(".shg"));
3579 f
= TexPathList
.FindValidPath(buf
);
3581 if (f
== _T("")) // Try for a .bmp
3583 wxStrcpy(buf
, filename
);
3584 StripExtension(buf
);
3585 wxStrcat(buf
, _T(".bmp"));
3586 f
= TexPathList
.FindValidPath(buf
);
3588 if (f
== _T("")) // Try for a metafile instead
3590 wxStrcpy(buf
, filename
);
3591 StripExtension(buf
);
3592 wxStrcat(buf
, _T(".wmf"));
3593 f
= TexPathList
.FindValidPath(buf
);
3599 if (bitmapTransparency
&& (winHelpVersion
> 3))
3600 TexOutput(_T("\\{bmct "));
3602 TexOutput(_T("\\{bmc "));
3603 wxString str
= wxFileNameFromPath(f
);
3604 TexOutput((wxChar
*) (const wxChar
*) str
);
3605 TexOutput(_T("\\}"));
3609 // Microsoft Word method
3610 if (wxStrcmp(bitmapMethod
, _T("import")) == 0)
3611 TexOutput(_T("{\\field{\\*\\fldinst IMPORT "));
3613 TexOutput(_T("{\\field{\\*\\fldinst INCLUDEPICTURE "));
3615 // Full path appears not to be valid!
3616 wxString str
= wxFileNameFromPath(f
);
3617 TexOutput((wxChar
*)(const wxChar
*) str
);
3619 int len = wxStrlen(f);
3620 wxChar smallBuf[2]; smallBuf[1] = 0;
3621 for (int i = 0; i < len; i++)
3624 TexOutput(smallBuf);
3625 if (smallBuf[0] == '\\')
3626 TexOutput(smallBuf);
3629 TexOutput(_T("}{\\fldrslt PRESS F9 TO FORMAT PICTURE}}"));
3634 TexOutput(_T("[No BMP or WMF for image file "));
3635 TexOutput(filename
);
3637 wxSprintf(buf
, _T("Warning: could not find a BMP or WMF equivalent for %s."), filename
);
3640 if (filename
) // glt
3645 if (f
== _T("")) // Try for a .bmp
3647 wxStrcpy(buf
, filename
);
3648 StripExtension(buf
);
3649 wxStrcat(buf
, _T(".bmp"));
3650 f
= TexPathList
.FindValidPath(buf
);
3654 FILE *fd
= wxFopen(f
, _T("rb"));
3655 if (OutputBitmapHeader(fd
, winHelp
))
3656 OutputBitmapData(fd
);
3659 wxSprintf(buf
, _T("Could not read bitmap %s.\nMay be in wrong format (needs RGB-encoded Windows BMP)."), f
.c_str());
3664 else // Try for a metafile instead
3667 wxStrcpy(buf
, filename
);
3668 StripExtension(buf
);
3669 wxStrcat(buf
, _T(".wmf"));
3670 f
= TexPathList
.FindValidPath(buf
);
3673 // HFILE handle = _lopen(f, READ);
3674 FILE *fd
= wxFopen(f
, _T("rb"));
3675 if (OutputMetafileHeader(fd
, winHelp
, imageWidth
, imageHeight
))
3677 OutputMetafileData(fd
);
3681 wxSprintf(buf
, _T("Could not read metafile %s. Perhaps it's not a placeable metafile?"), f
.c_str());
3689 TexOutput(_T("[No BMP or WMF for image file "));
3690 TexOutput(filename
);
3692 wxSprintf(buf
, _T("Warning: could not find a BMP or WMF equivalent for %s."), filename
);
3705 case ltSUPERTABULAR
:
3711 currentRowNumber
= 0;
3714 tableVerticalLineLeft
= FALSE
;
3715 tableVerticalLineRight
= FALSE
;
3716 int currentWidth
= 0;
3718 wxChar
*alignString
= copystring(GetArgData());
3719 ParseTableArgument(alignString
);
3721 // TexOutput(_T("\\trowd\\trgaph108\\trleft-108"));
3722 TexOutput(_T("\\trowd\\trgaph108"));
3724 // Write the first row formatting for compatibility
3725 // with standard Latex
3726 if (compatibilityMode
)
3728 for (int i
= 0; i
< noColumns
; i
++)
3730 currentWidth
+= TableData
[i
].width
;
3731 wxSprintf(buf
, _T("\\cellx%d"), currentWidth
);
3734 TexOutput(_T("\\pard\\intbl\n"));
3736 delete[] alignString
;
3741 else if (arg_no
== 2 && !start
)
3743 TexOutput(_T("\\pard\n"));
3744 WriteEnvironmentStyles();
3755 TexOutput(_T("\\li360\n"));
3757 PushEnvironmentStyle(_T("\\li360\\sa200"));
3762 PopEnvironmentStyle();
3763 OnMacro(ltPAR
, 0, TRUE
);
3764 OnMacro(ltPAR
, 0, FALSE
);
3772 TexOutput(_T("\\li360\n"));
3773 PushEnvironmentStyle(_T("\\li360\\sa200"));
3777 PopEnvironmentStyle();
3778 OnMacro(ltPAR
, 0, TRUE
);
3779 OnMacro(ltPAR
, 0, FALSE
);
3791 wxSprintf(buf
, _T("\\sa200\\box\\trgaph108%s\n"), ((macroId
== ltNORMALBOXD
) ? _T("\\brdrdb") : _T("\\brdrs")));
3793 PushEnvironmentStyle(buf
);
3797 PopEnvironmentStyle();
3798 OnMacro(ltPAR
, 0, TRUE
);
3799 OnMacro(ltPAR
, 0, FALSE
);
3803 case ltHELPFONTSIZE
:
3807 wxChar
*data
= GetArgData();
3808 if (wxStrcmp(data
, _T("10")) == 0)
3810 else if (wxStrcmp(data
, _T("11")) == 0)
3812 else if (wxStrcmp(data
, _T("12")) == 0)
3814 wxSprintf(buf
, _T("\\fs%d\n"), normalFont
*2);
3821 case ltHELPFONTFAMILY
:
3825 wxChar
*data
= GetArgData();
3826 if (wxStrcmp(data
, _T("Swiss")) == 0)
3827 TexOutput(_T("\\f2\n"));
3828 else if (wxStrcmp(data
, _T("Symbol")) == 0)
3829 TexOutput(_T("\\f1\n"));
3830 else if (wxStrcmp(data
, _T("Times")) == 0)
3831 TexOutput(_T("\\f0\n"));
3839 if (start
&& arg_no
== 1)
3841 wxChar
*data
= GetArgData();
3842 ParIndent
= ParseUnitArgument(data
);
3843 if (ParIndent
== 0 || forbidParindent
== 0)
3845 wxSprintf(buf
, _T("\\fi%d\n"), ParIndent
*20);
3854 if (start
&& IsArgOptional())
3856 descriptionItemArg
= GetArgChunk();
3862 case ltTWOCOLITEMRULED
:
3869 TexOutput(_T("\\tab "));
3876 if (macroId
== ltTWOCOLITEMRULED
)
3877 TexOutput(_T("\\brdrb\\brdrs\\brdrw15\\brsp20 "));
3878 TexOutput(_T("\\par\\pard\n"));
3879 issuedNewParagraph
= 1;
3880 WriteEnvironmentStyles();
3891 case ltACCENT_GRAVE
:
3895 wxChar
*val
= GetArgData();
3901 TexOutput(_T("\\'e0"));
3904 TexOutput(_T("\\'e8"));
3907 TexOutput(_T("\\'ec"));
3910 TexOutput(_T("\\'f2"));
3913 TexOutput(_T("\\'f9"));
3916 TexOutput(_T("\\'c0"));
3919 TexOutput(_T("\\'c8"));
3922 TexOutput(_T("\\'cc"));
3925 TexOutput(_T("\\'d2"));
3928 TexOutput(_T("\\'d9"));
3937 case ltACCENT_ACUTE
:
3941 wxChar
*val
= GetArgData();
3947 TexOutput(_T("\\'e1"));
3950 TexOutput(_T("\\'e9"));
3953 TexOutput(_T("\\'ed"));
3956 TexOutput(_T("\\'f3"));
3959 TexOutput(_T("\\'fa"));
3962 TexOutput(_T("\\'fd"));
3965 TexOutput(_T("\\'c1"));
3968 TexOutput(_T("\\'c9"));
3971 TexOutput(_T("\\'cd"));
3974 TexOutput(_T("\\'d3"));
3977 TexOutput(_T("\\'da"));
3980 TexOutput(_T("\\'dd"));
3989 case ltACCENT_CARET
:
3993 wxChar
*val
= GetArgData();
3999 TexOutput(_T("\\'e2"));
4002 TexOutput(_T("\\'ea"));
4005 TexOutput(_T("\\'ee"));
4008 TexOutput(_T("\\'f4"));
4011 TexOutput(_T("\\'fb"));
4014 TexOutput(_T("\\'c2"));
4017 TexOutput(_T("\\'ca"));
4020 TexOutput(_T("\\'ce"));
4023 TexOutput(_T("\\'d4"));
4026 TexOutput(_T("\\'db"));
4035 case ltACCENT_TILDE
:
4039 wxChar
*val
= GetArgData();
4045 TexOutput(_T("\\'e3"));
4051 TexOutput(_T("\\'f1"));
4054 TexOutput(_T("\\'f5"));
4057 TexOutput(_T("\\'c3"));
4060 TexOutput(_T("\\'d1"));
4063 TexOutput(_T("\\'d5"));
4072 case ltACCENT_UMLAUT
:
4076 wxChar
*val
= GetArgData();
4082 TexOutput(_T("\\'e4"));
4085 TexOutput(_T("\\'eb"));
4088 TexOutput(_T("\\'ef"));
4091 TexOutput(_T("\\'f6"));
4094 TexOutput(_T("\\'fc"));
4097 TexOutput(_T("\\'df"));
4100 TexOutput(_T("\\'ff"));
4103 TexOutput(_T("\\'c4"));
4106 TexOutput(_T("\\'cb"));
4109 TexOutput(_T("\\'cf"));
4112 TexOutput(_T("\\'d6"));
4115 TexOutput(_T("\\'dc"));
4118 TexOutput(_T("\\'df"));
4131 wxChar
*val
= GetArgData();
4137 TexOutput(_T("\\'e5"));
4140 TexOutput(_T("\\'c5"));
4149 case ltACCENT_CADILLA
:
4153 wxChar
*val
= GetArgData();
4159 TexOutput(_T("\\'e7"));
4162 TexOutput(_T("\\'c7"));
4173 static wxChar
*helpTopic
= NULL
;
4174 static FILE *savedOutput
= NULL
;
4181 OnInform(_T("Consider using \\footnotepopup instead of \\footnote."));
4184 wxSprintf(footBuf
, _T("(%d)"), footnoteCount
);
4186 TexOutput(_T(" {\\ul "));
4189 helpTopic
= FindTopicName(NULL
);
4190 TexOutput(_T("{\\v "));
4192 // Remove green colour/underlining if specified
4193 if (!hotSpotUnderline
&& !hotSpotColour
)
4195 else if (!hotSpotColour
)
4198 TexOutput(helpTopic
);
4201 wxFprintf(Popups
, _T("\\page\n"));
4202 // wxFprintf(Popups, _T("\n${\\footnote }")); // No title
4203 wxFprintf(Popups
, _T("\n#{\\footnote %s}\n"), helpTopic
);
4204 wxFprintf(Popups
, _T("+{\\footnote %s}\n"), GetBrowseString());
4205 savedOutput
= CurrentOutput1
;
4206 SetCurrentOutput(Popups
);
4210 SetCurrentOutput(savedOutput
);
4220 TexOutput(_T(" {\\super \\chftn{\\footnote \\fs20 {\\super \\chftn}"), TRUE
);
4224 TexOutput(_T("}}"), TRUE
);
4229 case ltFOOTNOTEPOPUP
:
4231 static wxChar
*helpTopic
= NULL
;
4232 static FILE *savedOutput
= NULL
;
4239 TexOutput(_T("{\\ul "));
4241 else TexOutput(_T("}"));
4244 else if (arg_no
== 2)
4248 helpTopic
= FindTopicName(NULL
);
4249 TexOutput(_T("{\\v "));
4251 // Remove green colour/underlining if specified
4252 if (!hotSpotUnderline
&& !hotSpotColour
)
4254 else if (!hotSpotColour
)
4257 TexOutput(helpTopic
);
4260 wxFprintf(Popups
, _T("\\page\n"));
4261 // wxFprintf(Popups, _T("\n${\\footnote }")); // No title
4262 wxFprintf(Popups
, _T("\n#{\\footnote %s}\n"), helpTopic
);
4263 wxFprintf(Popups
, _T("+{\\footnote %s}\n"), GetBrowseString());
4264 savedOutput
= CurrentOutput1
;
4265 SetCurrentOutput(Popups
);
4269 SetCurrentOutput(savedOutput
);
4280 TexOutput(_T(" {\\super \\chftn{\\footnote \\fs20 {\\super \\chftn}"), TRUE
);
4284 TexOutput(_T("}}"), TRUE
);
4292 if (start
&& (arg_no
== 1))
4304 if (winHelp
) return FALSE
;
4310 LeftHeaderEven
= GetArgChunk();
4311 if (wxStrlen(GetArgData(LeftHeaderEven
)) == 0)
4312 LeftHeaderEven
= NULL
;
4315 CentreHeaderEven
= GetArgChunk();
4316 if (wxStrlen(GetArgData(CentreHeaderEven
)) == 0)
4317 CentreHeaderEven
= NULL
;
4320 RightHeaderEven
= GetArgChunk();
4321 if (wxStrlen(GetArgData(RightHeaderEven
)) == 0)
4322 RightHeaderEven
= NULL
;
4325 LeftHeaderOdd
= GetArgChunk();
4326 if (wxStrlen(GetArgData(LeftHeaderOdd
)) == 0)
4327 LeftHeaderOdd
= NULL
;
4330 CentreHeaderOdd
= GetArgChunk();
4331 if (wxStrlen(GetArgData(CentreHeaderOdd
)) == 0)
4332 CentreHeaderOdd
= NULL
;
4335 RightHeaderOdd
= GetArgChunk();
4336 if (wxStrlen(GetArgData(RightHeaderOdd
)) == 0)
4337 RightHeaderOdd
= NULL
;
4338 OutputRTFHeaderCommands();
4353 if (winHelp
) return FALSE
;
4359 LeftFooterEven
= GetArgChunk();
4360 if (wxStrlen(GetArgData(LeftFooterEven
)) == 0)
4361 LeftFooterEven
= NULL
;
4364 CentreFooterEven
= GetArgChunk();
4365 if (wxStrlen(GetArgData(CentreFooterEven
)) == 0)
4366 CentreFooterEven
= NULL
;
4369 RightFooterEven
= GetArgChunk();
4370 if (wxStrlen(GetArgData(RightFooterEven
)) == 0)
4371 RightFooterEven
= NULL
;
4374 LeftFooterOdd
= GetArgChunk();
4375 if (wxStrlen(GetArgData(LeftFooterOdd
)) == 0)
4376 LeftFooterOdd
= NULL
;
4379 CentreFooterOdd
= GetArgChunk();
4380 if (wxStrlen(GetArgData(CentreFooterOdd
)) == 0)
4381 CentreFooterOdd
= NULL
;
4384 RightFooterOdd
= GetArgChunk();
4385 if (wxStrlen(GetArgData(RightFooterOdd
)) == 0)
4386 RightFooterOdd
= NULL
;
4387 OutputRTFFooterCommands();
4397 if (winHelp
) return FALSE
;
4398 // Fake a SetHeader command
4401 LeftHeaderOdd
= NULL
;
4402 CentreHeaderOdd
= NULL
;
4403 RightHeaderOdd
= NULL
;
4404 LeftHeaderEven
= NULL
;
4405 CentreHeaderEven
= NULL
;
4406 RightHeaderEven
= NULL
;
4407 OnInform(_T("Consider using setheader/setfooter rather than markright."));
4409 RTFOnArgument(ltSETHEADER
, 4, start
);
4411 OutputRTFHeaderCommands();
4416 if (winHelp
) return FALSE
;
4417 // Fake a SetHeader command
4424 LeftHeaderOdd
= NULL
;
4425 CentreHeaderOdd
= NULL
;
4426 RightHeaderOdd
= NULL
;
4427 LeftHeaderEven
= NULL
;
4428 CentreHeaderEven
= NULL
;
4429 RightHeaderEven
= NULL
;
4430 OnInform(_T("Consider using setheader/setfooter rather than markboth."));
4432 return RTFOnArgument(ltSETHEADER
, 1, start
);
4436 RTFOnArgument(ltSETHEADER
, 4, start
);
4438 OutputRTFHeaderCommands();
4444 case ltPAGENUMBERING
:
4451 if (winHelp
) return FALSE
;
4454 TexOutput(_T("\\pgnrestart"));
4455 wxChar
*data
= GetArgData();
4456 if (currentNumberStyle
) delete[] currentNumberStyle
;
4457 currentNumberStyle
= copystring(data
);
4458 OutputNumberStyle(currentNumberStyle
);
4460 TexOutput(_T("\n"));
4466 if (winHelp
) return FALSE
;
4475 wxChar
*val
= GetArgData();
4476 currentItemSep
= ParseUnitArgument(val
);
4481 case ltEVENSIDEMARGIN
:
4485 case ltODDSIDEMARGIN
:
4489 wxChar
*val
= GetArgData();
4490 int twips
= (int)(20*ParseUnitArgument(val
));
4491 // Add an inch since in LaTeX it's specified minus an inch
4493 CurrentLeftMarginOdd
= twips
;
4494 wxSprintf(buf
, _T("\\margl%d\n"), twips
);
4497 CurrentMarginParX
= CurrentLeftMarginOdd
+ CurrentTextWidth
+ CurrentMarginParSep
;
4501 case ltMARGINPARWIDTH
:
4505 wxChar
*val
= GetArgData();
4506 int twips
= (int)(20*ParseUnitArgument(val
));
4507 CurrentMarginParWidth
= twips
;
4511 case ltMARGINPARSEP
:
4515 wxChar
*val
= GetArgData();
4516 int twips
= (int)(20*ParseUnitArgument(val
));
4517 CurrentMarginParSep
= twips
;
4518 CurrentMarginParX
= CurrentLeftMarginOdd
+ CurrentTextWidth
+ CurrentMarginParSep
;
4526 wxChar
*val
= GetArgData();
4527 int twips
= (int)(20*ParseUnitArgument(val
));
4528 CurrentTextWidth
= twips
;
4530 // Need to set an implicit right margin
4531 CurrentRightMarginOdd
= PageWidth
- CurrentTextWidth
- CurrentLeftMarginOdd
;
4532 CurrentRightMarginEven
= PageWidth
- CurrentTextWidth
- CurrentLeftMarginEven
;
4533 CurrentMarginParX
= CurrentLeftMarginOdd
+ CurrentTextWidth
+ CurrentMarginParSep
;
4534 wxSprintf(buf
, _T("\\margr%d\n"), CurrentRightMarginOdd
);
4540 case ltMARGINPARODD
:
4546 TexOutput(_T("\\sa200\\box\n"));
4547 PushEnvironmentStyle(_T("\\sa200\\box"));
4551 wxSprintf(buf
, _T("\\phpg\\posx%d\\absw%d\n"), CurrentMarginParX
, CurrentMarginParWidth
);
4560 TexOutput(_T("\\par\\pard\n"));
4561 PopEnvironmentStyle();
4562 WriteEnvironmentStyles();
4565 TexOutput(_T("\\par\\pard\n"));
4566 issuedNewParagraph
= 1;
4570 case ltMARGINPAREVEN
:
4576 TexOutput(_T("\\sa200\\box\n"));
4577 PushEnvironmentStyle(_T("\\sa200\\box"));
4583 // Have to calculate what the margins are changed to in WfW margin
4584 // mirror mode, on an even (left-hand) page.
4585 int x
= PageWidth
- CurrentRightMarginOdd
- CurrentMarginParWidth
- CurrentMarginParSep
4586 - CurrentTextWidth
+ GutterWidth
;
4587 wxSprintf(buf
, _T("\\phpg\\posx%d\\absw%d\n"), x
, CurrentMarginParWidth
);
4592 wxSprintf(buf
, _T("\\phpg\\posx%d\\absw%d\n"), CurrentMarginParX
, CurrentMarginParWidth
);
4602 TexOutput(_T("\\par\\pard\n"));
4603 PopEnvironmentStyle();
4604 WriteEnvironmentStyles();
4607 issuedNewParagraph
= 1;
4608 TexOutput(_T("\\par\\pard\n"));
4612 case ltTWOCOLWIDTHA
:
4616 wxChar
*val
= GetArgData();
4617 int twips
= (int)(20*ParseUnitArgument(val
));
4618 TwoColWidthA
= twips
;
4622 case ltTWOCOLWIDTHB
:
4626 wxChar
*val
= GetArgData();
4627 int twips
= (int)(20*ParseUnitArgument(val
));
4628 TwoColWidthB
= twips
;
4637 int currentWidth
= 0;
4639 if (!compatibilityMode
|| (currentRowNumber
> 0))
4641 TexOutput(_T("\\pard\\intbl"));
4643 if (macroId
== ltRULEDROW
)
4645 for (int i
= 0; i
< noColumns
; i
++)
4647 currentWidth
+= TableData
[i
].width
;
4650 TexOutput(_T("\\clbrdrt\\brdrs\\brdrw15"));
4652 else if (ruleTop
> 1)
4654 TexOutput(_T("\\clbrdrt\\brdrdb\\brdrw15"));
4656 if (ruleBottom
== 1)
4658 TexOutput(_T("\\clbrdrb\\brdrs\\brdrw15"));
4660 else if (ruleBottom
> 1)
4662 TexOutput(_T("\\clbrdrb\\brdrdb\\brdrw15"));
4665 if (TableData
[i
].rightBorder
)
4666 TexOutput(_T("\\clbrdrr\\brdrs\\brdrw15"));
4668 if (TableData
[i
].leftBorder
)
4669 TexOutput(_T("\\clbrdrl\\brdrs\\brdrw15"));
4671 wxSprintf(buf
, _T("\\cellx%d"), currentWidth
);
4674 TexOutput(_T("\\pard\\intbl\n"));
4678 currentRowNumber
++;
4683 // TexOutput(_T("\\cell\\row\\trowd\\trgaph108\\trleft-108\n"));
4684 TexOutput(_T("\\cell\\row\\trowd\\trgaph108\n"));
4690 static int noMultiColumns
= 0;
4697 noMultiColumns
= wxAtoi(GetArgData());
4714 for (int i
= 1; i
< noMultiColumns
; i
++)
4715 TexOutput(_T("\\cell"));
4722 if (start
&& (arg_no
== 1))
4725 // TexOutput(_T("\\fi0\n"));
4727 wxNode
*node
= itemizeStack
.GetFirst();
4729 oldIndent
= ((ItemizeStruc
*)node
->GetData())->indentation
;
4731 int indentValue
= 20*ParseUnitArgument(GetArgData());
4732 int indentSize
= indentValue
+ oldIndent
;
4734 ItemizeStruc
*struc
= new ItemizeStruc(LATEX_INDENT
, indentSize
);
4735 itemizeStack
.Insert(struc
);
4737 wxSprintf(buf
, _T("\\tx%d\\li%d\\sa200 "), indentSize
, indentSize
);
4738 PushEnvironmentStyle(buf
);
4742 if (!start
&& (arg_no
== 2))
4744 PopEnvironmentStyle();
4745 if (itemizeStack
.GetFirst())
4747 ItemizeStruc
*struc
= (ItemizeStruc
*)itemizeStack
.GetFirst()->GetData();
4749 delete itemizeStack
.GetFirst();
4751 if (itemizeStack
.GetCount() == 0)
4753 TexOutput(_T("\\par\\pard\n"));
4754 issuedNewParagraph
= 1;
4755 WriteEnvironmentStyles();
4764 if (start && (arg_no == 1))
4767 wxNode *node = itemizeStack.GetFirst();
4769 oldIndent = ((ItemizeStruc *)node->GetData())->indentation;
4771 int boxWidth = 20*ParseUnitArgument(GetArgData());
4773 int indentValue = (int)((CurrentTextWidth - oldIndent - boxWidth)/2.0);
4774 int indentSize = indentValue + oldIndent;
4775 int indentSizeRight = indentSize + boxWidth;
4777 ItemizeStruc *struc = new ItemizeStruc(LATEX_INDENT, indentSize);
4778 itemizeStack.Insert(struc);
4780 wxSprintf(buf, _T("\\tx%d\\li%d\\lr%d\\sa200\\box%s "), indentSize, indentSize, indentSizeRight,
4781 ((macroId == ltCENTEREDBOX) ? _T("\\brdrs") : _T("\\brdrdb")));
4782 PushEnvironmentStyle(buf);
4786 if (!start && (arg_no == 2))
4788 PopEnvironmentStyle();
4789 if (itemizeStack.GetFirst())
4791 ItemizeStruc *struc = (ItemizeStruc *)itemizeStack.GetFirst()->GetData();
4793 delete itemizeStack.GetFirst();
4795 if (itemizeStack.Number() == 0)
4797 TexOutput(_T("\\par\\pard\n"));
4798 issuedNewParagraph = 1;
4799 WriteEnvironmentStyles();
4806 case ltDOCUMENTSTYLE
:
4808 DefaultOnArgument(macroId
, arg_no
, start
);
4809 if (!start
&& !IsArgOptional())
4811 if (MinorDocumentStyleString
)
4813 if (StringMatch(_T("twoside"), MinorDocumentStyleString
))
4814 // Mirror margins, switch on odd/even headers & footers, and break sections at odd pages
4815 TexOutput(_T("\\margmirror\\facingp\\sbkodd"));
4816 if (StringMatch(_T("twocolumn"), MinorDocumentStyleString
))
4817 TexOutput(_T("\\cols2"));
4819 TexOutput(_T("\n"));
4823 case ltSETHOTSPOTCOLOUR
:
4824 case ltSETHOTSPOTCOLOR
:
4828 wxChar
*text
= GetArgData();
4829 if (wxStrcmp(text
, _T("yes")) == 0 || wxStrcmp(text
, _T("on")) == 0 || wxStrcmp(text
, _T("ok")) == 0)
4830 hotSpotColour
= TRUE
;
4832 hotSpotColour
= FALSE
;
4836 case ltSETTRANSPARENCY
:
4840 wxChar
*text
= GetArgData();
4841 if (wxStrcmp(text
, _T("yes")) == 0 || wxStrcmp(text
, _T("on")) == 0 || wxStrcmp(text
, _T("ok")) == 0)
4842 bitmapTransparency
= TRUE
;
4844 bitmapTransparency
= FALSE
;
4848 case ltSETHOTSPOTUNDERLINE
:
4852 wxChar
*text
= GetArgData();
4853 if (wxStrcmp(text
, _T("yes")) == 0 || wxStrcmp(text
, _T("on")) == 0 || wxStrcmp(text
, _T("ok")) == 0)
4854 hotSpotUnderline
= TRUE
;
4856 hotSpotUnderline
= FALSE
;
4862 if (arg_no
== 1 && start
)
4864 wxChar
*citeKey
= GetArgData();
4865 TexRef
*ref
= (TexRef
*)TexReferences
.Get(citeKey
);
4868 if (ref
->sectionNumber
) delete[] ref
->sectionNumber
;
4869 wxSprintf(buf
, _T("[%d]"), citeCount
);
4870 ref
->sectionNumber
= copystring(buf
);
4873 TexOutput(_T("\\li260\\fi-260 ")); // Indent from 2nd line
4874 wxSprintf(buf
, _T("{\\b [%d]} "), citeCount
);
4879 if (arg_no
== 2 && !start
)
4880 TexOutput(_T("\\par\\pard\\par\n\n"));
4883 case ltTHEBIBLIOGRAPHY
:
4885 if (start
&& (arg_no
== 1))
4889 SetCurrentOutputs(Contents
, Chapters
);
4893 wxFprintf(Chapters
, _T("\\sect\\pgncont\\titlepg\n"));
4895 // If a non-custom page style, we generate the header now.
4896 if (PageStyle
&& (wxStrcmp(PageStyle
, _T("plain")) == 0 ||
4897 wxStrcmp(PageStyle
, _T("empty")) == 0 ||
4898 wxStrcmp(PageStyle
, _T("headings")) == 0))
4900 OutputRTFHeaderCommands();
4901 OutputRTFFooterCommands();
4904 // Need to reset the current numbering style, or RTF forgets it.
4905 OutputNumberStyle(currentNumberStyle
);
4906 SetCurrentOutput(Contents
);
4909 wxFprintf(Chapters
, _T("\\page\n"));
4912 wxFprintf(Contents
, _T("\n{\\uldb %s}"), ReferencesNameString
);
4914 wxFprintf(Contents
, _T("\\par\n\\pard{\\b %s}"), ReferencesNameString
);
4916 startedSections
= TRUE
;
4919 wxFprintf(Chapters
, _T("\n${\\footnote %s}"), ReferencesNameString
);
4921 wxChar
*topicName
= _T("bibliography");
4924 wxFprintf(Contents
, _T("{\\v %s}\\par\\pard\n"), topicName
);
4926 wxFprintf(Contents
, _T("\\par\\par\\pard\n"));
4930 wxFprintf(Chapters
, _T("\n#{\\footnote %s}\n"), topicName
);
4931 wxFprintf(Chapters
, _T("+{\\footnote %s}\n"), GetBrowseString());
4932 wxFprintf(Chapters
, _T("K{\\footnote {K} %s}\n"), ReferencesNameString
);
4933 GenerateKeywordsForTopic(topicName
);
4936 wxFprintf(Chapters
, _T("!{\\footnote EnableButton(\"Up\");ChangeButtonBinding(\"Up\", \"JumpId(`%s.hlp', `%s')\")}\n"),
4937 wxFileNameFromPath(FileRoot
), "Contents");
4941 SetCurrentOutput(Chapters
);
4942 wxChar
*styleCommand
= _T("");
4943 if (!winHelp
&& useHeadingStyles
)
4944 styleCommand
= _T("\\s1");
4945 wxFprintf(Chapters
, _T("\\pard{%s"), (winHelp
? _T("\\keepn\\sa140\\sb140") : styleCommand
));
4946 WriteHeadingStyle(Chapters
, 1); wxFprintf(Chapters
, _T(" References\\par\\pard}\n"));
4955 * In Windows help, all keywords should be at the start of the
4956 * topic, but Latex \index commands can be anywhere in the text.
4957 * So we're going to have to build up lists of keywords for a topic,
4958 * and insert them on the second pass.
4960 * In linear RTF, we can embed the index entry now.
4965 // wxChar *entry = GetArgData();
4967 OutputChunkToString(GetArgChunk(), buf
);
4972 AddKeyWordForTopic(CurrentTopic
, buf
);
4975 else GenerateIndexEntry(buf
);
4988 wxChar
*name
= GetArgData();
4989 int pos
= FindColourPosition(name
);
4992 wxSprintf(buf
, _T("{%s%d "), ((macroId
== ltFCOL
) ? _T("\\cf") : _T("\\cb")), pos
);
4997 wxSprintf(buf
, _T("Could not find colour name %s"), name
);
5012 if (arg_no
== 2) TexOutput(_T("}"));
5018 if (start
&& !winHelp
&& useWord
)
5020 wxChar
*s
= GetArgData();
5021 // Only insert a bookmark here if it's not just been inserted
5022 // in a section heading.
5023 if ( !CurrentTopic
|| !(wxStrcmp(CurrentTopic
, s
) == 0) )
5025 if ( (!CurrentChapterName || !(CurrentChapterName && (wxStrcmp(CurrentChapterName, s) == 0))) &&
5026 (!CurrentSectionName || !(CurrentSectionName && (wxStrcmp(CurrentSectionName, s) == 0))) &&
5027 (!CurrentSubsectionName || !(CurrentSubsectionName && (wxStrcmp(CurrentSubsectionName, s) == 0)))
5031 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), s
,s
);
5038 if (start
&& useWord
&& !winHelp
)
5040 wxChar
*s
= GetArgData();
5041 wxFprintf(Chapters
, _T("{\\field{\\*\\fldinst PAGEREF %s \\\\* MERGEFORMAT }{\\fldrslt ??}}"),
5049 inPopRefSection
= TRUE
;
5051 inPopRefSection
= FALSE
;
5054 case ltINSERTATLEVEL
:
5056 // This macro allows you to insert text at a different level
5057 // from the current level, e.g. into the Sections from within a subsubsection.
5058 if (!winHelp
& useWord
)
5060 static int currentLevelNo
= 1;
5061 static FILE* oldLevelFile
= Chapters
;
5068 oldLevelFile
= CurrentOutput1
;
5070 wxChar
*str
= GetArgData();
5071 currentLevelNo
= wxAtoi(str
);
5073 // TODO: cope with article style (no chapters)
5074 switch (currentLevelNo
)
5078 outputFile
= Chapters
;
5083 outputFile
= Sections
;
5088 outputFile
= Subsections
;
5093 outputFile
= Subsubsections
;
5103 CurrentOutput1
= outputFile
;
5119 CurrentOutput1
= oldLevelFile
;
5125 return DefaultOnArgument(macroId
, arg_no
, start
);
5137 forbidParindent
= 0;
5138 contentsLineSection
= NULL
;
5139 contentsLineValue
= NULL
;
5140 descriptionItemArg
= NULL
;
5145 tableVerticalLineLeft
= FALSE
;
5146 tableVerticalLineRight
= FALSE
;
5148 startedSections
= FALSE
;
5152 if (InputFile
&& OutputFile
)
5154 // Do some RTF-specific transformations on all the strings,
5156 Text2RTF(GetTopLevelChunk());
5158 Contents
= wxFopen(TmpContentsName
, _T("w"));
5159 Chapters
= wxFopen(_T("chapters.rtf"), _T("w"));
5162 Sections
= wxFopen(_T("sections.rtf"), _T("w"));
5163 Subsections
= wxFopen(_T("subsections.rtf"), _T("w"));
5164 Subsubsections
= wxFopen(_T("subsubsections.rtf"), _T("w"));
5165 Popups
= wxFopen(_T("popups.rtf"), _T("w"));
5166 if (winHelpContents
)
5168 WinHelpContentsFile
= wxFopen(WinHelpContentsFileName
, _T("w"));
5169 if (WinHelpContentsFile
)
5170 wxFprintf(WinHelpContentsFile
, _T(":Base %s.hlp\n"), wxFileNameFromPath(FileRoot
));
5173 if (!Sections
|| !Subsections
|| !Subsubsections
|| !Popups
|| (winHelpContents
&& !WinHelpContentsFile
))
5175 OnError(_T("Ouch! Could not open temporary file(s) for writing."));
5179 if (!Contents
|| !Chapters
)
5181 OnError(_T("Ouch! Could not open temporary file(s) for writing."));
5187 wxFprintf(Chapters
, _T("\n#{\\footnote Contents}\n"));
5188 wxFprintf(Chapters
, _T("${\\footnote Contents}\n"));
5189 wxFprintf(Chapters
, _T("+{\\footnote %s}\n"), GetBrowseString());
5190 wxFprintf(Chapters
, _T("K{\\footnote {K} %s}\n"), ContentsNameString
);
5191 wxFprintf(Chapters
, _T("!{\\footnote DisableButton(\"Up\")}\n"));
5195 wxFprintf(Chapters
, _T("\\titlepg\n"));
5196 wxFprintf(Contents
, _T("\\par\\pard\\pgnrestart\\sect\\titlepg"));
5199 // In WinHelp, Contents title takes font of title.
5200 // In linear RTF, same as chapter headings.
5201 wxFprintf(Contents
, _T("{\\b\\fs%d %s}\\par\\par\\pard\n\n"),
5202 (winHelp
? titleFont
: chapterFont
)*2, ContentsNameString
);
5204 // By default, Swiss, 11 point.
5205 wxFprintf(Chapters
, _T("\\f2\\fs22\n"));
5207 PushEnvironmentStyle(_T("\\f2\\fs22\\sa200"));
5209 SetCurrentOutput(Chapters
);
5214 OnInform(_T("Converting..."));
5218 FILE *Header
= wxFopen(_T("header.rtf"), _T("w"));
5221 OnError(_T("Ouch! Could not open temporary file header.rtf for writing."));
5224 WriteRTFHeader(Header
);
5227 PopEnvironmentStyle();
5232 // wxFprintf(Contents, _T("\\page\n"));
5233 wxFprintf(Chapters
, _T("\\page\n"));
5234 wxFprintf(Sections
, _T("\\page\n"));
5235 wxFprintf(Subsections
, _T("\\page\n"));
5236 wxFprintf(Subsubsections
, _T("\\page\n\n"));
5237 wxFprintf(Popups
, _T("\\page\n}\n"));
5240 // TexOutput(_T("\n\\info{\\doccomm Document created by Julian Smart's Tex2RTF.}\n"));
5242 TexOutput(_T("}\n"));
5243 fclose(Contents
); Contents
= NULL
;
5244 fclose(Chapters
); Chapters
= NULL
;
5247 fclose(Sections
); Sections
= NULL
;
5248 fclose(Subsections
); Subsections
= NULL
;
5249 fclose(Subsubsections
); Subsubsections
= NULL
;
5250 fclose(Popups
); Popups
= NULL
;
5251 if (winHelpContents
)
5253 fclose(WinHelpContentsFile
); WinHelpContentsFile
= NULL
;
5259 wxConcatFiles(_T("header.rtf"), _T("chapters.rtf"), _T("tmp1.rtf"));
5261 wxConcatFiles(_T("tmp1.rtf"), _T("sections.rtf"), _T("tmp2.rtf"));
5263 wxConcatFiles(_T("tmp2.rtf"), _T("subsections.rtf"), _T("tmp3.rtf"));
5265 wxConcatFiles(_T("tmp3.rtf"), _T("subsubsections.rtf"), _T("tmp4.rtf"));
5267 wxConcatFiles(_T("tmp4.rtf"), _T("popups.rtf"), OutputFile
);
5270 wxRemoveFile(_T("tmp1.rtf"));
5271 wxRemoveFile(_T("tmp2.rtf"));
5272 wxRemoveFile(_T("tmp3.rtf"));
5273 wxRemoveFile(_T("tmp4.rtf"));
5277 wxConcatFiles(_T("header.rtf"), _T("chapters.rtf"), _T("tmp1.rtf"));
5279 if (wxFileExists(OutputFile
))
5280 wxRemoveFile(OutputFile
);
5283 cwdStr
= wxGetWorkingDirectory();
5285 wxString outputDirStr
;
5286 outputDirStr
= wxPathOnly(OutputFile
);
5288 // Determine if the temp file and the output file are in the same directory,
5289 // and if they are, then just rename the temp file rather than copying
5290 // it, as this is much faster when working with large (multi-megabyte files)
5291 if ((wxStrcmp(outputDirStr
.c_str(),_T("")) == 0) || // no path specified on output file
5292 (wxStrcmp(cwdStr
,outputDirStr
.c_str()) == 0)) // paths do not match
5294 wxRenameFile(_T("tmp1.rtf"), OutputFile
);
5298 wxCopyFile(_T("tmp1.rtf"), OutputFile
);
5302 wxRemoveFile(_T("tmp1.rtf"));
5305 if (wxFileExists(ContentsName
)) wxRemoveFile(ContentsName
);
5307 if (!wxRenameFile(TmpContentsName
, ContentsName
))
5309 wxCopyFile(TmpContentsName
, ContentsName
);
5310 wxRemoveFile(TmpContentsName
);
5313 wxRemoveFile(_T("chapters.rtf"));
5314 wxRemoveFile(_T("header.rtf"));
5318 wxRemoveFile(_T("sections.rtf"));
5319 wxRemoveFile(_T("subsections.rtf"));
5320 wxRemoveFile(_T("subsubsections.rtf"));
5321 wxRemoveFile(_T("popups.rtf"));
5323 if (winHelp
&& generateHPJ
)
5324 WriteHPJ(OutputFile
);