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();
1180 wxFprintf(Contents
, _T("}{\\v %s}\\pard\\par\n"), topicName
);
1181 //WriteEnvironmentStyles();
1183 else if ((macroId
== ltCHAPTER
) || (macroId
== ltCHAPTERHEADING
))
1184 wxFprintf(Contents
, _T("}\\par\\par\\pard\n"));
1186 // From here, just output to chapter
1187 SetCurrentOutput(Chapters
);
1192 wxFprintf(Chapters
, _T("}\n#{\\footnote %s}\n"), topicName
);
1193 wxFprintf(Chapters
, _T("+{\\footnote %s}\n"), GetBrowseString());
1195 OutputSectionKeyword(Chapters
);
1197 GenerateKeywordsForTopic(topicName
);
1200 // If we're generating a .cnt file, we don't want to be able
1201 // jump up to the old-style contents page, so disable it.
1202 if (winHelpContents
)
1203 wxFprintf(Chapters
, _T("!{\\footnote DisableButton(\"Up\")}\n"));
1205 wxFprintf(Chapters
, _T("!{\\footnote EnableButton(\"Up\");ChangeButtonBinding(\"Up\", \"JumpId(`%s.hlp', `%s')\")}\n"),
1206 wxFileNameFromPath(FileRoot
), _T("Contents"));
1212 wxChar
*styleCommand
= _T("");
1213 if (!winHelp
&& useHeadingStyles
&& (macroId
== ltCHAPTER
|| macroId
== ltCHAPTERHEADING
|| macroId
== ltCHAPTERHEADINGSTAR
))
1214 styleCommand
= _T("\\s1");
1215 wxFprintf(Chapters
, _T("\\pard{%s"), ((winHelp
&& !InPopups()) ? _T("\\keepn\\sa140\\sb140") : styleCommand
));
1216 WriteHeadingStyle(Chapters
, 1); wxFprintf(Chapters
, _T(" "));
1219 if (macroId
== ltCHAPTER
)
1222 // wxFprintf(Chapters, "{\\bkmkstart %s}%d{\\bkmkend %s}. ", topicName, chapterNo,
1223 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), topicName
, topicName
);
1225 wxFprintf(Chapters
, _T("%d. "), chapterNo
);
1229 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), topicName
, topicName
);
1232 OutputCurrentSection();
1233 TexOutput(_T("\\par\\pard}\n"));
1235 issuedNewParagraph
= 1;
1236 WriteEnvironmentStyles();
1242 case ltSECTIONHEADING
:
1243 case ltSECTIONHEADINGSTAR
:
1247 if (DocumentStyle
== LATEX_ARTICLE
)
1248 jumpFrom
= Contents
;
1250 jumpFrom
= Chapters
;
1255 subsubsectionNo
= 0;
1256 if (DocumentStyle
== LATEX_ARTICLE
)
1259 if (macroId
!= ltSECTIONSTAR
&& macroId
!= ltSECTIONHEADINGSTAR
)
1262 wxChar
*topicName
= FindTopicName(GetNextChunk());
1263 SetCurrentSectionName(topicName
);
1264 NotifyParentHasChildren(1);
1265 if (winHelpContents
&& winHelp
&& !InPopups())
1267 OutputCurrentSectionToString(wxTex2RTFBuffer
);
1268 WriteWinHelpContentsFileLine(topicName
, wxTex2RTFBuffer
, 2);
1270 AddTexRef(topicName
, NULL
, SectionNameString
, chapterNo
, sectionNo
);
1274 SetCurrentOutputs(jumpFrom
, Sections
);
1275 // Newline for a new section if this is an article
1276 if ((DocumentStyle
== LATEX_ARTICLE
) &&
1277 ((macroId
== ltSECTION
) || (macroId
== ltSECTIONSTAR
) || (macroId
== ltSECTIONHEADINGSTAR
)))
1278 wxFprintf(Sections
, _T("\\page\n"));
1281 wxFprintf(jumpFrom
, _T("\n{\\uldb "));
1285 if (DocumentStyle
== LATEX_ARTICLE
)
1287 TexOutput(_T("\\sect\\pgncont\n"));
1288 // If a non-custom page style, we generate the header now.
1289 if (PageStyle
&& (wxStrcmp(PageStyle
, _T("plain")) == 0 ||
1290 wxStrcmp(PageStyle
, _T("empty")) == 0 ||
1291 wxStrcmp(PageStyle
, _T("headings")) == 0))
1293 OutputRTFHeaderCommands();
1294 OutputRTFFooterCommands();
1297 SetCurrentOutput(Contents
);
1299 if (macroId
== ltSECTION
)
1303 if (DocumentStyle
== LATEX_REPORT
)
1304 wxFprintf(Contents
, _T("\n\\pard{\\tab %d.%d\\tab "), chapterNo
, sectionNo
);
1306 wxFprintf(Contents
, _T("\\par\n\\pard{\\b %d\\tab "), sectionNo
);
1309 else if (macroId
== ltSECTIONHEADING
)
1313 if (DocumentStyle
== LATEX_REPORT
)
1314 wxFprintf(Contents
, _T("\n\\pard{\\tab ")); //, chapterNo, sectionNo);
1316 wxFprintf(Contents
, _T("\\par\n\\pard{\\b ")); //, sectionNo);
1319 else SetCurrentOutput(NULL
);
1322 if (startedSections
)
1325 wxFprintf(Sections
, _T("\\page\n"));
1327 startedSections
= TRUE
;
1330 wxFprintf(Sections
, _T("\n${\\footnote "));
1332 // Output heading to contents page
1334 OutputCurrentSection();
1340 wxFprintf(jumpFrom
, _T("}{\\v %s}\\pard\\par\n"), topicName
);
1341 //WriteEnvironmentStyles();
1344 else if ((macroId
!= ltSECTIONSTAR
) && (macroId
!= ltGLOSS
))
1346 if (DocumentStyle
== LATEX_REPORT
)
1347 wxFprintf(Contents
, _T("}\\par\\pard\n"));
1349 wxFprintf(Contents
, _T("}\\par\\par\\pard\n"));
1352 SetCurrentOutput(winHelp
? Sections
: Chapters
);
1356 wxFprintf(Sections
, _T("}\n#{\\footnote %s}\n"), topicName
);
1357 wxFprintf(Sections
, _T("+{\\footnote %s}\n"), GetBrowseString());
1358 OutputSectionKeyword(Sections
);
1359 GenerateKeywordsForTopic(topicName
);
1362 if (DocumentStyle
== LATEX_ARTICLE
)
1364 wxFprintf(Sections
, _T("!{\\footnote EnableButton(\"Up\");ChangeButtonBinding(\"Up\", \"JumpId(`%s.hlp', `%s')\")}\n"),
1365 wxFileNameFromPath(FileRoot
), _T("Contents"));
1367 else if (CurrentChapterName
)
1369 wxFprintf(Sections
, _T("!{\\footnote EnableButton(\"Up\");ChangeButtonBinding(\"Up\", \"JumpId(`%s.hlp', `%s')\")}\n"),
1370 wxFileNameFromPath(FileRoot
), CurrentChapterName
);
1377 wxChar
*styleCommand
= _T("");
1378 if (!winHelp
&& useHeadingStyles
&& (macroId
!= ltSECTIONSTAR
))
1380 if (DocumentStyle
== LATEX_ARTICLE
)
1381 styleCommand
= _T("\\s1");
1383 styleCommand
= _T("\\s2");
1385 wxChar
*keep
= _T("");
1386 if (winHelp
&& (macroId
!= ltGLOSS
) && !InPopups())
1387 keep
= _T("\\keepn\\sa140\\sb140");
1389 wxFprintf(winHelp
? Sections
: Chapters
, _T("\\pard{%s%s"),
1390 keep
, styleCommand
);
1392 WriteHeadingStyle((winHelp
? Sections
: Chapters
),
1393 (DocumentStyle
== LATEX_ARTICLE
? 1 : 2));
1394 wxFprintf(winHelp
? Sections
: Chapters
, _T(" "));
1398 if ((macroId
!= ltSECTIONSTAR
) && (macroId
!= ltSECTIONHEADINGSTAR
) && (macroId
!= ltGLOSS
))
1400 if (DocumentStyle
== LATEX_REPORT
)
1403 // wxFprintf(Chapters, _T("{\\bkmkstart %s}%d.%d{\\bkmkend %s}. "), topicName, chapterNo, sectionNo,
1404 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), topicName
,
1407 wxFprintf(Chapters
, _T("%d.%d. "), chapterNo
, sectionNo
);
1412 // wxFprintf(Chapters, "{\\bkmkstart %s}%d{\\bkmkend %s}. ", topicName, sectionNo,
1413 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), topicName
,
1416 wxFprintf(Chapters
, _T("%d. "), sectionNo
);
1421 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), topicName
, topicName
);
1424 OutputCurrentSection();
1425 TexOutput(_T("\\par\\pard}\n"));
1426 // TexOutput(_T("\\par\\pard}\\par\n"));
1428 issuedNewParagraph
= 1;
1429 WriteEnvironmentStyles();
1430 // issuedNewParagraph = 2;
1435 case ltSUBSECTIONSTAR
:
1436 case ltMEMBERSECTION
:
1437 case ltFUNCTIONSECTION
:
1441 if (winHelp
&& !Sections
)
1443 OnError(_T("You cannot have a subsection before a section!"));
1447 subsubsectionNo
= 0;
1449 if (macroId
!= ltSUBSECTIONSTAR
)
1452 wxChar
*topicName
= FindTopicName(GetNextChunk());
1453 SetCurrentSubsectionName(topicName
);
1454 NotifyParentHasChildren(2);
1455 if (winHelpContents
&& winHelp
&& !InPopups())
1457 OutputCurrentSectionToString(wxTex2RTFBuffer
);
1458 WriteWinHelpContentsFileLine(topicName
, wxTex2RTFBuffer
, 3);
1460 AddTexRef(topicName
, NULL
, SectionNameString
, chapterNo
, sectionNo
, subsectionNo
);
1464 SetCurrentOutputs(Sections
, Subsections
);
1465 SetCurrentOutputs(Sections
, Subsections
);
1467 wxFprintf(Sections
, _T("\n{\\uldb "));
1471 if ((macroId
!= ltSUBSECTIONSTAR
) && (macroId
!= ltMEMBERSECTION
) &&
1472 (macroId
!= ltFUNCTIONSECTION
))
1474 SetCurrentOutput(Contents
);
1475 if (DocumentStyle
== LATEX_REPORT
)
1476 wxFprintf(Contents
, _T("\n\\pard\\tab\\tab %d.%d.%d\\tab "), chapterNo
, sectionNo
, subsectionNo
);
1478 wxFprintf(Contents
, _T("\n\\pard\\tab %d.%d\\tab "), sectionNo
, subsectionNo
);
1479 } else SetCurrentOutput(NULL
);
1481 if (startedSections
)
1486 wxFprintf(Subsections
, _T("\\page\n"));
1488 // Experimental JACS 2004-02-21
1491 wxFprintf(Chapters
, _T("\\par\n"));
1494 startedSections
= TRUE
;
1497 wxFprintf(Subsections
, _T("\n${\\footnote "));
1499 // Output to contents page
1501 OutputCurrentSection();
1507 wxFprintf(Sections
, _T("}{\\v %s}\\pard\\par\n"), topicName
);
1508 //WriteEnvironmentStyles();
1511 else if ((macroId
!= ltSUBSECTIONSTAR
) && (macroId
!= ltMEMBERSECTION
) &&
1512 (macroId
!= ltFUNCTIONSECTION
))
1513 wxFprintf(Contents
, _T("\\par\\pard\n"));
1515 SetCurrentOutput(winHelp
? Subsections
: Chapters
);
1518 wxFprintf(Subsections
, _T("}\n#{\\footnote %s}\n"), topicName
);
1519 wxFprintf(Subsections
, _T("+{\\footnote %s}\n"), GetBrowseString());
1520 OutputSectionKeyword(Subsections
);
1521 GenerateKeywordsForTopic(topicName
);
1522 if (useUpButton
&& CurrentSectionName
)
1524 wxFprintf(Subsections
, _T("!{\\footnote EnableButton(\"Up\");ChangeButtonBinding(\"Up\", \"JumpId(`%s.hlp', `%s')\")}\n"),
1525 wxFileNameFromPath(FileRoot
), CurrentSectionName
);
1528 if (!winHelp
&& indexSubsections
&& useWord
)
1530 // Insert index entry for this subsection
1531 TexOutput(_T("{\\xe\\v {"));
1532 OutputCurrentSection();
1533 TexOutput(_T("}}"));
1538 wxChar
*styleCommand
= _T("");
1539 if (!winHelp
&& useHeadingStyles
&& (macroId
!= ltSUBSECTIONSTAR
))
1541 if (DocumentStyle
== LATEX_ARTICLE
)
1542 styleCommand
= _T("\\s2");
1544 styleCommand
= _T("\\s3");
1546 wxChar
*keep
= _T("");
1547 if (winHelp
&& !InPopups())
1548 keep
= _T("\\keepn\\sa140\\sb140");
1550 wxFprintf(winHelp
? Subsections
: Chapters
, _T("\\pard{%s%s"),
1551 keep
, styleCommand
);
1553 WriteHeadingStyle((winHelp
? Subsections
: Chapters
),
1554 (DocumentStyle
== LATEX_ARTICLE
? 2 : 3));
1555 wxFprintf(winHelp
? Subsections
: Chapters
, _T(" "));
1559 if ((macroId
!= ltSUBSECTIONSTAR
) && (macroId
!= ltMEMBERSECTION
) &&
1560 (macroId
!= ltFUNCTIONSECTION
))
1562 if (DocumentStyle
== LATEX_REPORT
)
1565 // wxFprintf(Chapters, _T("{\\bkmkstart %s}%d.%d.%d{\\bkmkend %s}. "), topicName, chapterNo, sectionNo, subsectionNo,
1566 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), topicName
,
1569 wxFprintf(Chapters
, _T("%d.%d.%d. "), chapterNo
, sectionNo
, subsectionNo
);
1574 // wxFprintf(Chapters, _T("{\\bkmkstart %s}%d.%d{\\bkmkend %s}. "), topicName, sectionNo, subsectionNo,
1575 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), topicName
,
1578 wxFprintf(Chapters
, _T("%d.%d. "), sectionNo
, subsectionNo
);
1583 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), topicName
, topicName
);
1586 OutputCurrentSection(); // Repeat section header
1588 // Experimental JACS
1589 TexOutput(_T("\\par\\pard}\n"));
1590 // TexOutput(_T("\\par\\pard}\\par\n"));
1592 issuedNewParagraph
= 1;
1593 WriteEnvironmentStyles();
1598 case ltSUBSUBSECTION
:
1599 case ltSUBSUBSECTIONSTAR
:
1603 if (winHelp
&& !Subsections
)
1605 OnError(_T("You cannot have a subsubsection before a subsection!"));
1609 if (macroId
!= ltSUBSUBSECTIONSTAR
)
1612 wxChar
*topicName
= FindTopicName(GetNextChunk());
1613 SetCurrentTopic(topicName
);
1614 NotifyParentHasChildren(3);
1615 if (winHelpContents
&& winHelp
)
1617 OutputCurrentSectionToString(wxTex2RTFBuffer
);
1618 WriteWinHelpContentsFileLine(topicName
, wxTex2RTFBuffer
, 4);
1620 AddTexRef(topicName
, NULL
, SectionNameString
, chapterNo
, sectionNo
, subsectionNo
, subsubsectionNo
);
1624 SetCurrentOutputs(Subsections
, Subsubsections
);
1625 wxFprintf(Subsections
, _T("\n{\\uldb "));
1629 if (macroId
!= ltSUBSUBSECTIONSTAR
)
1631 if (DocumentStyle
== LATEX_ARTICLE
)
1633 SetCurrentOutput(Contents
);
1634 wxFprintf(Contents
, _T("\n\\tab\\tab %d.%d.%d\\tab "),
1635 sectionNo
, subsectionNo
, subsubsectionNo
);
1638 SetCurrentOutput(NULL
); // Don't write it into the contents, or anywhere else
1641 SetCurrentOutput(NULL
); // Don't write it into the contents, or anywhere else
1644 if (startedSections
)
1647 wxFprintf(Subsubsections
, _T("\\page\n"));
1648 // Experimental JACS 2004-02-21
1651 wxFprintf(Chapters
, _T("\\par\n"));
1655 startedSections
= TRUE
;
1658 wxFprintf(Subsubsections
, _T("\n${\\footnote "));
1660 // Output header to contents page
1661 OutputCurrentSection();
1665 wxFprintf(Subsections
, _T("}{\\v %s}\\pard\\par\n"), topicName
);
1666 //WriteEnvironmentStyles();
1668 else if ((DocumentStyle
== LATEX_ARTICLE
) && (macroId
!= ltSUBSUBSECTIONSTAR
))
1669 wxFprintf(Contents
, _T("\\par\\pard\n"));
1671 SetCurrentOutput(winHelp
? Subsubsections
: Chapters
);
1674 wxFprintf(Subsubsections
, _T("}\n#{\\footnote %s}\n"), topicName
);
1675 wxFprintf(Subsubsections
, _T("+{\\footnote %s}\n"), GetBrowseString());
1676 OutputSectionKeyword(Subsubsections
);
1677 GenerateKeywordsForTopic(topicName
);
1678 if (useUpButton
&& CurrentSubsectionName
)
1680 wxFprintf(Subsubsections
, _T("!{\\footnote EnableButton(\"Up\");ChangeButtonBinding(\"Up\", \"JumpId(`%s.hlp', `%s')\")}\n"),
1681 wxFileNameFromPath(FileRoot
), CurrentSubsectionName
);
1684 if (!winHelp
&& indexSubsections
&& useWord
)
1686 // Insert index entry for this subsubsection
1687 TexOutput(_T("{\\xe\\v {"));
1688 OutputCurrentSection();
1689 TexOutput(_T("}}"));
1692 wxChar
*styleCommand
= _T("");
1693 if (!winHelp
&& useHeadingStyles
&& (macroId
!= ltSUBSUBSECTIONSTAR
))
1695 if (DocumentStyle
== LATEX_ARTICLE
)
1696 styleCommand
= _T("\\s3");
1698 styleCommand
= _T("\\s4");
1700 wxChar
*keep
= _T("");
1702 keep
= _T("\\keepn\\sa140\\sb140");
1704 wxFprintf(winHelp
? Subsubsections
: Chapters
, _T("\\pard{%s%s"),
1705 keep
, styleCommand
);
1707 WriteHeadingStyle((winHelp
? Subsubsections
: Chapters
),
1708 (DocumentStyle
== LATEX_ARTICLE
? 3 : 4));
1709 wxFprintf(winHelp
? Subsubsections
: Chapters
, _T(" "));
1713 if ((macroId
!= ltSUBSUBSECTIONSTAR
))
1715 if (DocumentStyle
== LATEX_ARTICLE
)
1718 // wxFprintf(Chapters, _T("{\\bkmkstart %s}%d.%d.%d{\\bkmkend %s}. "), topicName, sectionNo, subsectionNo, subsubsectionNo,
1719 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), topicName
,
1722 wxFprintf(Chapters
, _T("%d.%d.%d. "), sectionNo
, subsectionNo
, subsubsectionNo
);
1727 // wxFprintf(Chapters, _T("{\\bkmkstart %s}%d.%d.%d.%d{\\bkmkend %s}. "), topicName, chapterNo, sectionNo, subsectionNo, subsubsectionNo,
1728 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), topicName
,
1731 wxFprintf(Chapters
, _T("%d.%d.%d.%d. "), chapterNo
, sectionNo
, subsectionNo
, subsubsectionNo
);
1736 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), topicName
, topicName
);
1739 OutputCurrentSection(); // Repeat section header
1740 TexOutput(_T("\\par\\pard}\n"));
1741 issuedNewParagraph
= 1;
1742 WriteEnvironmentStyles();
1743 // TexOutput(_T("\\par\\pard}\\par\n"));
1744 // issuedNewParagraph = 2;
1754 wxChar
*topicName
= FindTopicName(GetNextChunk());
1755 SetCurrentTopic(topicName
);
1757 TexOutput(_T("\\pard\\par"));
1764 if (winHelp
|| !useWord
)
1766 if (DocumentStyle
!= LATEX_ARTICLE
)
1767 wxSprintf(figBuf
, _T("%s %d.%d: "), FigureNameString
, chapterNo
, figureNo
);
1769 wxSprintf(figBuf
, _T("%s %d: "), FigureNameString
, figureNo
);
1773 wxSprintf(figBuf
, _T("%s {\\field\\flddirty{\\*\\fldinst SEQ Figure \\\\* ARABIC }{\\fldrslt {\\bkmkstart %s}??{\\bkmkend %s}}}: "),
1774 FigureNameString
, topicName
, topicName
);
1781 if (winHelp
|| !useWord
)
1783 if (DocumentStyle
!= LATEX_ARTICLE
)
1784 wxSprintf(figBuf
, _T("%s %d.%d: "), TableNameString
, chapterNo
, tableNo
);
1786 wxSprintf(figBuf
, _T("%s %d: "), TableNameString
, tableNo
);
1790 wxSprintf(figBuf
, _T("%s {\\field\\flddirty{\\*\\fldinst SEQ Table \\\\* ARABIC }{\\fldrslt {\\bkmkstart %s}??{\\bkmkend %s}}}: "),
1791 TableNameString
, topicName
, topicName
);
1795 int n
= (inTable
? tableNo
: figureNo
);
1796 AddTexRef(topicName
, NULL
, NULL
,
1797 ((DocumentStyle
!= LATEX_ARTICLE
) ? chapterNo
: n
),
1798 ((DocumentStyle
!= LATEX_ARTICLE
) ? n
: 0));
1801 TexOutput(_T("\\qc{\\b "));
1803 TexOutput(_T("\\ql{\\b "));
1806 OutputCurrentSection();
1808 TexOutput(_T("}\\par\\pard\n"));
1809 WriteEnvironmentStyles();
1816 // SetCurrentOutput(winHelp ? Subsections : Chapters);
1823 TexOutput(_T("}\n"));
1826 TexOutput(_T("K{\\footnote {K} "));
1827 suppressNameDecoration
= TRUE
;
1828 TraverseChildrenFromChunk(currentMember
);
1829 suppressNameDecoration
= FALSE
;
1830 TexOutput(_T("}\n"));
1832 if (!winHelp
&& useWord
)
1834 // Insert index entry for this function
1835 TexOutput(_T("{\\xe\\v {"));
1836 suppressNameDecoration
= TRUE
; // Necessary so don't print "(\\bf" etc.
1837 TraverseChildrenFromChunk(currentMember
);
1838 suppressNameDecoration
= FALSE
;
1839 TexOutput(_T("}}"));
1846 // SetCurrentOutput(winHelp ? Subsections : Chapters);
1853 TexOutput(_T("}\n"));
1856 TexOutput(_T("K{\\footnote {K} "));
1857 suppressNameDecoration
= TRUE
; // Necessary so don't print "(\\bf" etc.
1858 TraverseChildrenFromChunk(currentMember
);
1859 suppressNameDecoration
= FALSE
;
1860 TexOutput(_T("}\n"));
1862 if (!winHelp
&& useWord
)
1864 // Insert index entry for this function
1865 TexOutput(_T("{\\xe\\v {"));
1866 suppressNameDecoration
= TRUE
; // Necessary so don't print "(\\bf" etc.
1867 TraverseChildrenFromChunk(currentMember
);
1868 suppressNameDecoration
= FALSE
;
1869 TexOutput(_T("}}"));
1876 // SetCurrentOutput(winHelp ? Subsections : Chapters);
1879 TexOutput(_T("{\\b "));
1883 TexOutput(_T("}\n"));
1886 TexOutput(_T("K{\\footnote {K} "));
1887 TraverseChildrenFromChunk(currentMember
);
1888 TexOutput(_T("}\n"));
1890 if (!winHelp
&& useWord
)
1892 // Insert index entry for this function
1893 TexOutput(_T("{\\xe\\v {"));
1894 suppressNameDecoration
= TRUE
; // Necessary so don't print "(\\bf" etc.
1895 TraverseChildrenFromChunk(currentMember
);
1896 suppressNameDecoration
= FALSE
;
1897 TexOutput(_T("}}"));
1905 SetCurrentOutput(Chapters
);
1908 case ltTABLEOFCONTENTS
:
1912 if (!winHelp
&& useWord
)
1914 // Insert Word for Windows table of contents
1915 TexOutput(_T("\\par\\pard\\pgnrestart\\sect\\titlepg"));
1917 // In linear RTF, same as chapter headings.
1918 wxSprintf(buf
, _T("{\\b\\fs%d %s}\\par\\par\\pard\n\n"), chapterFont
*2, ContentsNameString
);
1921 wxSprintf(buf
, _T("{\\field{\\*\\fldinst TOC \\\\o \"1-%d\" }{\\fldrslt PRESS F9 TO REFORMAT CONTENTS}}\n"), contentsDepth
);
1923 // TexOutput(_T("\\sect\\sectd"));
1927 FILE *fd
= wxFopen(ContentsName
, _T("r"));
1940 TexOutput(_T("{\\i RUN TEX2RTF AGAIN FOR CONTENTS PAGE}\\par\n"));
1941 OnInform(_T("Run Tex2RTF again to include contents page."));
1950 // TexOutput(_T("{\\b void}"));
1956 TexOutput(_T("{\\scaps HARDY}"));
1962 TexOutput(_T("wxCLIPS"));
1965 case ltSPECIALAMPERSAND
:
1970 TexOutput(_T("\\cell "));
1976 case ltSPECIALTILDE
:
1980 if (TRUE
) // (inVerbatim)
1987 case ltBACKSLASHCHAR
:
1993 // TexOutput(_T("\\cell\\row\\trowd\\trgaph108\\trleft-108\n"));
1994 TexOutput(_T("\\cell\\row\\trowd\\trgaph108\n"));
1995 int currentWidth
= 0;
1996 for (int i
= 0; i
< noColumns
; i
++)
1998 currentWidth
+= TableData
[i
].width
;
1999 if (TableData
[i
].rightBorder
)
2000 TexOutput(_T("\\clbrdrr\\brdrs\\brdrw15"));
2002 if (TableData
[i
].leftBorder
)
2003 TexOutput(_T("\\clbrdrl\\brdrs\\brdrw15"));
2005 wxSprintf(buf
, _T("\\cellx%d"), currentWidth
);
2008 TexOutput(_T("\\pard\\intbl\n"));
2011 TexOutput(_T("\\line\n"));
2018 TexOutput(_T("\tab "));
2021 case ltRTFSP
: // Explicit space, RTF only
2033 if (indentLevel
> 0)
2035 // Experimental JACS 2004-02-21
2036 TexOutput(_T("\\par\n"));
2037 issuedNewParagraph
= 1;
2038 // TexOutput(_T("\\par\\par\n"));
2039 // issuedNewParagraph = 2;
2043 // Top-level list: issue a new paragraph if we haven't
2045 if (!issuedNewParagraph
)
2047 TexOutput(_T("\\par\\pard"));
2048 WriteEnvironmentStyles();
2049 issuedNewParagraph
= 1;
2051 else issuedNewParagraph
= 0;
2054 TexOutput(_T("\\fi0\n"));
2056 if (macroId
== ltENUMERATE
)
2057 listType
= LATEX_ENUMERATE
;
2058 else if (macroId
== ltITEMIZE
)
2059 listType
= LATEX_ITEMIZE
;
2061 listType
= LATEX_DESCRIPTION
;
2064 wxNode
*node
= itemizeStack
.GetFirst();
2066 oldIndent
= ((ItemizeStruc
*)node
->GetData())->indentation
;
2068 int indentSize1
= oldIndent
+ 20*labelIndentTab
;
2069 int indentSize2
= oldIndent
+ 20*itemIndentTab
;
2071 ItemizeStruc
*struc
= new ItemizeStruc(listType
, indentSize2
, indentSize1
);
2072 itemizeStack
.Insert(struc
);
2074 wxSprintf(buf
, _T("\\tx%d\\tx%d\\li%d\\sa200"), indentSize1
, indentSize2
, indentSize2
);
2075 PushEnvironmentStyle(buf
);
2079 currentItemSep
= 8; // Reset to the default
2081 PopEnvironmentStyle();
2083 if (itemizeStack
.GetFirst())
2085 ItemizeStruc
*struc
= (ItemizeStruc
*)itemizeStack
.GetFirst()->GetData();
2087 delete itemizeStack
.GetFirst();
2089 /* Change 18/7/97 - don't know why we wish to do this
2090 if (itemizeStack.Number() == 0)
2092 OnMacro(ltPAR, 0, TRUE);
2093 OnMacro(ltPAR, 0, FALSE);
2094 issuedNewParagraph = 2;
2106 wxNode
*node
= itemizeStack
.GetFirst();
2108 oldIndent
= ((ItemizeStruc
*)node
->GetData())->indentation
;
2110 int indentSize
= oldIndent
+ TwoColWidthA
;
2112 ItemizeStruc
*struc
= new ItemizeStruc(LATEX_TWOCOL
, indentSize
);
2113 itemizeStack
.Insert(struc
);
2115 // wxSprintf(buf, _T("\\tx%d\\li%d\\ri%d"), indentSize, indentSize, TwoColWidthA+TwoColWidthB+oldIndent);
2116 wxSprintf(buf
, _T("\\tx%d\\li%d\\sa200"), indentSize
, indentSize
);
2117 PushEnvironmentStyle(buf
);
2122 PopEnvironmentStyle();
2123 if (itemizeStack
.GetFirst())
2125 ItemizeStruc
*struc
= (ItemizeStruc
*)itemizeStack
.GetFirst()->GetData();
2127 delete itemizeStack
.GetFirst();
2131 TexOutput(_T("\\pard\n"));
2132 WriteEnvironmentStyles();
2134 /* why do we need this? */
2136 TexOutput(_T("\\pard\n"));
2138 if (itemizeStack
.GetCount() == 0)
2140 issuedNewParagraph
= 0;
2141 OnMacro(ltPAR
, 0, TRUE
);
2142 OnMacro(ltPAR
, 0, FALSE
);
2150 wxNode
*node
= itemizeStack
.GetFirst();
2153 ItemizeStruc
*struc
= (ItemizeStruc
*)node
->GetData();
2156 struc
->currentItem
+= 1;
2157 wxChar indentBuf
[60];
2159 int indentSize1
= struc
->labelIndentation
;
2160 int indentSize2
= struc
->indentation
;
2162 TexOutput(_T("\n"));
2163 if (struc
->currentItem
> 1 && issuedNewParagraph
== 0)
2166 // if (currentItemSep > 0)
2167 // TexOutput(_T("\\par"));
2169 TexOutput(_T("\\par"));
2170 issuedNewParagraph
= 1;
2171 // WriteEnvironmentStyles();
2174 wxSprintf(buf
, _T("\\tx%d\\tx%d\\li%d\\fi-%d\n"), indentSize1
, indentSize2
,
2175 indentSize2
, 20*itemIndentTab
);
2178 switch (struc
->listType
)
2180 case LATEX_ENUMERATE
:
2182 if (descriptionItemArg
)
2184 TexOutput(_T("\\tab{ "));
2185 TraverseChildrenFromChunk(descriptionItemArg
);
2186 TexOutput(_T("}\\tab"));
2187 descriptionItemArg
= NULL
;
2191 wxSprintf(indentBuf
, _T("\\tab{\\b %d.}\\tab"), struc
->currentItem
);
2192 TexOutput(indentBuf
);
2198 if (descriptionItemArg
)
2200 TexOutput(_T("\\tab{ "));
2201 TraverseChildrenFromChunk(descriptionItemArg
);
2202 TexOutput(_T("}\\tab"));
2203 descriptionItemArg
= NULL
;
2207 if (bulletFile
&& winHelp
)
2209 if (winHelpVersion
> 3) // Transparent bitmap
2210 wxSprintf(indentBuf
, _T("\\tab\\{bmct %s\\}\\tab"), bulletFile
);
2212 wxSprintf(indentBuf
, _T("\\tab\\{bmc %s\\}\\tab"), bulletFile
);
2215 wxSprintf(indentBuf
, _T("\\tab{\\b o}\\tab"));
2217 wxSprintf(indentBuf
, _T("\\tab{\\f1\\'b7}\\tab"));
2218 TexOutput(indentBuf
);
2223 case LATEX_DESCRIPTION
:
2225 if (descriptionItemArg
)
2227 TexOutput(_T("\\tab{\\b "));
2228 TraverseChildrenFromChunk(descriptionItemArg
);
2229 TexOutput(_T("} "));
2230 descriptionItemArg
= NULL
;
2240 case ltTWOCOLITEMRULED
:
2242 wxNode
*node
= itemizeStack
.GetFirst();
2245 ItemizeStruc
*struc
= (ItemizeStruc
*)node
->GetData();
2248 struc
->currentItem
+= 1;
2251 wxNode
*node2
= NULL
;
2252 if (itemizeStack
.GetCount() > 1) // TODO: do I actually mean Nth(0) here??
2253 node2
= itemizeStack
.Item(1);
2255 oldIndent
= ((ItemizeStruc
*)node2
->GetData())->indentation
;
2257 TexOutput(_T("\n"));
2260 if (struc
->currentItem
> 1)
2262 if (currentItemSep
> 0)
2263 TexOutput(_T("\\par"));
2265 // WriteEnvironmentStyles();
2269 // wxSprintf(buf, _T("\\tx%d\\li%d\\fi-%d\\ri%d\n"), TwoColWidthA,
2270 // TwoColWidthA, TwoColWidthA, TwoColWidthA+TwoColWidthB+oldIndent);
2272 wxSprintf(buf, _T("\\tx%d\\li%d\\fi-%d\n"), TwoColWidthA,
2273 TwoColWidthA, TwoColWidthA);
2275 wxSprintf(buf
, _T("\\tx%d\\li%d\\fi-%d\n"), TwoColWidthA
+ oldIndent
,
2276 TwoColWidthA
+ oldIndent
, TwoColWidthA
);
2289 if (macroId
== ltVERBATIM
)
2291 if (!issuedNewParagraph
)
2293 TexOutput(_T("\\par\\pard"));
2294 WriteEnvironmentStyles();
2295 issuedNewParagraph
= 1;
2297 else issuedNewParagraph
= 0;
2301 if (macroId
== ltVERBATIM
)
2302 wxSprintf(buf
, _T("{\\f3\\s10\\fs20\\li720\\sa0 "));
2304 wxSprintf(buf
, _T("{\\f3\\fs20 "));
2310 if (macroId
== ltVERBATIM
)
2312 TexOutput(_T("\\pard\n"));
2313 WriteEnvironmentStyles();
2316 TexOutput(_T("\\par\n"));
2317 issuedNewParagraph
= 1;
2328 TexOutput(_T("\\qc "));
2330 PushEnvironmentStyle(_T("\\qc\\sa200"));
2334 TexOutput(_T("\\par\\pard\n"));
2335 issuedNewParagraph
= 1;
2337 PopEnvironmentStyle();
2338 WriteEnvironmentStyles();
2346 TexOutput(_T("\\ql\\sa200 "));
2348 PushEnvironmentStyle(_T("\\ql"));
2352 TexOutput(_T("\\par\\pard\n"));
2353 issuedNewParagraph
= 1;
2355 PopEnvironmentStyle();
2356 WriteEnvironmentStyles();
2364 TexOutput(_T("\\qr\\sa200 "));
2366 PushEnvironmentStyle(_T("\\qr"));
2370 TexOutput(_T("\\par\\pard\n"));
2371 issuedNewParagraph
= 1;
2373 PopEnvironmentStyle();
2374 WriteEnvironmentStyles();
2379 case ltFOOTNOTESIZE
:
2383 wxSprintf(buf
, _T("{\\fs%d\n"), smallFont
*2);
2386 else TexOutput(_T("}\n"));
2394 wxSprintf(buf
, _T("{\\fs%d\n"), tinyFont
*2);
2397 else TexOutput(_T("}\n"));
2404 wxSprintf(buf
, _T("{\\fs%d\n"), normalFont
*2);
2407 else TexOutput(_T("}\n"));
2414 wxSprintf(buf
, _T("{\\fs%d\n"), largeFont1
*2);
2417 else TexOutput(_T("}\n"));
2424 wxSprintf(buf
, _T("{\\fs%d\n"), LargeFont2
*2);
2427 else TexOutput(_T("}\n"));
2434 wxSprintf(buf
, _T("{\\fs%d\n"), LARGEFont3
*2);
2437 else TexOutput(_T("}\n"));
2444 wxSprintf(buf
, _T("{\\fs%d\n"), hugeFont1
*2);
2447 else TexOutput(_T("}\n"));
2454 wxSprintf(buf
, _T("{\\fs%d\n"), HugeFont2
*2);
2457 else TexOutput(_T("}\n"));
2464 wxSprintf(buf
, _T("{\\fs%d\n"), HUGEFont3
*2);
2467 else TexOutput(_T("}\n"));
2476 TexOutput(_T("{\\b "));
2478 else TexOutput(_T("}"));
2485 TexOutput(_T("{\\ul "));
2487 else TexOutput(_T("}"));
2498 TexOutput(_T("{\\i "));
2500 else TexOutput(_T("}"));
2503 // Roman font: do nothing. Should really switch between
2512 TexOutput(_T("{\\plain "));
2514 else TexOutput(_T("}"));
2518 // Medium-weight font. Unbolden...
2523 TexOutput(_T("{\\b0 "));
2525 else TexOutput(_T("}"));
2528 // Upright (un-italic or slant)
2533 TexOutput(_T("{\\i0 "));
2535 else TexOutput(_T("}"));
2544 TexOutput(_T("{\\scaps "));
2546 else TexOutput(_T("}"));
2555 TexOutput(_T("{\\f3 "));
2557 else TexOutput(_T("}"));
2563 TexOutput(_T("\\{"));
2569 TexOutput(_T("\\}"));
2575 TexOutput(_T("\\\\"));
2582 if ( issuedNewParagraph
== 0 )
2584 TexOutput(_T("\\par\\pard"));
2585 issuedNewParagraph
++;
2587 // Extra par if parskip is more than zero (usually looks best.)
2588 // N.B. JACS 2004-02-21: shouldn't need this for linear RTF if
2589 // we have a suitable set of styles.
2591 if (winHelp
&& !inTabular
&& (ParSkip
> 0))
2593 TexOutput(_T("\\par"));
2594 issuedNewParagraph
++;
2597 WriteEnvironmentStyles();
2599 // 1 is a whole paragraph if ParSkip == 0,
2600 // half a paragraph if ParSkip > 0
2601 else if ( issuedNewParagraph
== 1 )
2603 // Don't need a par at all if we've already had one,
2604 // and ParSkip == 0.
2607 // Extra par if parskip is more than zero (usually looks best.)
2608 if (winHelp
&& !inTabular
&& (ParSkip
> 0))
2610 TexOutput(_T("\\par"));
2611 issuedNewParagraph
++;
2614 WriteEnvironmentStyles();
2617 if (!issuedNewParagraph || (issuedNewParagraph > 1))
2619 TexOutput(_T("\\par\\pard"));
2621 // Extra par if parskip is more than zero (usually looks best.)
2622 if (!inTabular && (ParSkip > 0))
2623 TexOutput(_T("\\par"));
2624 WriteEnvironmentStyles();
2628 TexOutput(_T("\n"));
2634 // In Windows Help, no newpages until we've started some chapters or sections
2635 if (!(winHelp
&& !startedSections
))
2637 TexOutput(_T("\\page\n"));
2642 if (start
&& DocumentTitle
)
2644 TexOutput(_T("\\par\\pard"));
2646 TexOutput(_T("\\par"));
2647 wxSprintf(buf
, _T("\\qc{\\fs%d\\b "), titleFont
*2);
2649 TraverseChildrenFromChunk(DocumentTitle
);
2650 TexOutput(_T("}\\par\\pard\n"));
2655 TexOutput(_T("\\par"));
2656 wxSprintf(buf
, _T("\\par\\qc{\\fs%d "), authorFont
*2);
2658 TraverseChildrenFromChunk(DocumentAuthor
);
2660 TexOutput(_T("\\par\\pard\n"));
2664 TexOutput(_T("\\par"));
2665 wxSprintf(buf
, _T("\\qc{\\fs%d "), authorFont
*2);
2667 TraverseChildrenFromChunk(DocumentDate
);
2668 TexOutput(_T("}\\par\\pard\n"));
2670 // If linear RTF, we want this titlepage to be in a separate
2671 // section with its own (blank) header and footer
2672 if (!winHelp
&& (DocumentStyle
!= LATEX_ARTICLE
))
2674 TexOutput(_T("{\\header }{\\footer }\n"));
2675 // Not sure about this: we get too many sections.
2676 // TexOutput(_T("\\sect"));
2681 case ltADDCONTENTSLINE
:
2685 if (contentsLineSection
&& contentsLineValue
)
2687 if (wxStrcmp(contentsLineSection
, _T("chapter")) == 0)
2689 wxFprintf(Contents
, _T("\\par\n{\\b %s}\\par\n"), contentsLineValue
);
2691 else if (wxStrcmp(contentsLineSection
, _T("section")) == 0)
2693 if (DocumentStyle
!= LATEX_ARTICLE
)
2694 wxFprintf(Contents
, _T("\n\\tab%s\\par\n"), contentsLineValue
);
2696 wxFprintf(Contents
, _T("\\par\n{\\b %s}\\par\n"), contentsLineValue
);
2706 TexOutput(_T("\\brdrb\\brdrs\\par\\pard\n"));
2707 issuedNewParagraph
= 1;
2708 WriteEnvironmentStyles();
2716 TexOutput(_T("\\brdrb\\brdrs\\par\\pard\n"));
2717 issuedNewParagraph
= 1;
2718 WriteEnvironmentStyles();
2728 case ltNUMBEREDBIBITEM
:
2731 TexOutput(_T("\\li260\\fi-260 ")); // Indent from 2nd line
2733 TexOutput(_T("\\par\\pard\\par\n\n"));
2740 TexOutput(_T("{\\field{\\*\\fldinst PAGE \\\\* MERGEFORMAT }{\\fldrslt 1}}"));
2748 // TexOutput(_T("{\\field{\\*\\fldinst SECTION \\\\* MERGEFORMAT }{\\fldrslt 1}}"));
2749 wxSprintf(buf
, _T("%d"), chapterNo
);
2758 // TexOutput(_T("{\\field{\\*\\fldinst SECTION \\\\* MERGEFORMAT }{\\fldrslt 1}}"));
2759 wxSprintf(buf
, _T("%d"), sectionNo
);
2766 if (!start
&& !winHelp
)
2768 TexOutput(_T("\\cols2\n"));
2774 if (!start
&& !winHelp
)
2776 TexOutput(_T("\\cols1\n"));
2782 if (start
&& useWord
&& !winHelp
)
2784 FakeCurrentSection(_T("Index"));
2785 OnMacro(ltPAR
, 0, TRUE
);
2786 OnMacro(ltPAR
, 0, FALSE
);
2787 TexOutput(_T("\\par{\\field{\\*\\fldinst INDEX \\\\h \"\\emdash A\\emdash \"\\\\c \"2\"}{\\fldrslt PRESS F9 TO REFORMAT INDEX}}\n"));
2791 case ltLISTOFFIGURES
:
2793 if (start
&& useWord
&& !winHelp
)
2795 FakeCurrentSection(FiguresNameString
, 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 FIGURES}}\n"),
2807 case ltLISTOFTABLES
:
2809 if (start
&& useWord
&& !winHelp
)
2811 FakeCurrentSection(TablesNameString
, FALSE
);
2812 OnMacro(ltPAR
, 0, TRUE
);
2813 OnMacro(ltPAR
, 0, FALSE
);
2814 OnMacro(ltPAR
, 0, TRUE
);
2815 OnMacro(ltPAR
, 0, FALSE
);
2817 wxSprintf(buf
, _T("{\\field\\fldedit{\\*\\fldinst TOC \\\\c \"%s\" }{\\fldrslt PRESS F9 TO REFORMAT LIST OF TABLES}}\n"),
2825 if (start
) TexOutput(_T("{\\f1\\'61}"));
2828 if (start
) TexOutput(_T("{\\f1\\'62}"));
2831 if (start
) TexOutput(_T("{\\f1\\'63}"));
2834 if (start
) TexOutput(_T("{\\f1\\'64}"));
2838 if (start
) TexOutput(_T("{\\f1\\'65}"));
2841 if (start
) TexOutput(_T("{\\f1\\'7A}"));
2844 if (start
) TexOutput(_T("{\\f1\\'68}"));
2848 if (start
) TexOutput(_T("{\\f1\\'71}"));
2851 if (start
) TexOutput(_T("{\\f1\\'69}"));
2854 if (start
) TexOutput(_T("{\\f1\\'6B}"));
2857 if (start
) TexOutput(_T("{\\f1\\'6C}"));
2860 if (start
) TexOutput(_T("{\\f1\\'6D}"));
2863 if (start
) TexOutput(_T("{\\f1\\'6E}"));
2866 if (start
) TexOutput(_T("{\\f1\\'78}"));
2869 if (start
) TexOutput(_T("{\\f1\\'70}"));
2872 if (start
) TexOutput(_T("{\\f1\\'76}"));
2876 if (start
) TexOutput(_T("{\\f1\\'72}"));
2879 if (start
) TexOutput(_T("{\\f1\\'73}"));
2882 if (start
) TexOutput(_T("{\\f1\\'56}"));
2885 if (start
) TexOutput(_T("{\\f1\\'74}"));
2888 if (start
) TexOutput(_T("{\\f1\\'75}"));
2892 if (start
) TexOutput(_T("{\\f1\\'66}"));
2895 if (start
) TexOutput(_T("{\\f1\\'63}"));
2898 if (start
) TexOutput(_T("{\\f1\\'79}"));
2901 if (start
) TexOutput(_T("{\\f1\\'77}"));
2904 if (start
) TexOutput(_T("{\\f1\\'47}"));
2907 if (start
) TexOutput(_T("{\\f1\\'44}"));
2910 if (start
) TexOutput(_T("{\\f1\\'51}"));
2913 if (start
) TexOutput(_T("{\\f1\\'4C}"));
2916 if (start
) TexOutput(_T("{\\f1\\'58}"));
2919 if (start
) TexOutput(_T("{\\f1\\'50}"));
2922 if (start
) TexOutput(_T("{\\f1\\'53}"));
2925 if (start
) TexOutput(_T("{\\f1\\'54}"));
2928 if (start
) TexOutput(_T("{\\f1\\'46}"));
2931 if (start
) TexOutput(_T("{\\f1\\'59}"));
2934 if (start
) TexOutput(_T("{\\f1\\'57}"));
2936 // Binary operation symbols
2939 if (start
) TexOutput(_T("{\\f1\\'A3}"));
2942 if (start
) TexOutput(_T("<<"));
2945 if (start
) TexOutput(_T("{\\f1\\'CC}"));
2948 if (start
) TexOutput(_T("{\\f1\\'CD}"));
2951 if (start
) TexOutput(_T("{\\f1\\'CE}"));
2955 if (start
) TexOutput(_T("{\\f1\\'B3}"));
2958 if (start
) TexOutput(_T(">>"));
2961 if (start
) TexOutput(_T("{\\f1\\'C9}"));
2964 if (start
) TexOutput(_T("{\\f1\\'CD}"));
2967 if (start
) TexOutput(_T("{\\f1\\'27}"));
2970 if (start
) TexOutput(_T("{\\f1\\'5E}"));
2973 if (start
) TexOutput(_T("{\\f1\\'B9}"));
2976 if (start
) TexOutput(_T("{\\f1\\'BB}"));
2979 if (start
) TexOutput(_T("{\\f1\\'40}"));
2982 if (start
) TexOutput(_T("{\\f1\\'BA}"));
2985 if (start
) TexOutput(_T("{\\f1\\'B5}"));
2988 if (start
) TexOutput(_T("{\\f1\\'7E}"));
2991 if (start
) TexOutput(_T("{\\f4\\'4A}"));
2994 if (start
) TexOutput(_T("{\\f4\\'4C}"));
2997 if (start
) TexOutput(_T("|"));
3000 // Negated relation symbols
3002 if (start
) TexOutput(_T("{\\f1\\'B9}"));
3005 if (start
) TexOutput(_T("{\\f1\\'CF}"));
3008 if (start
) TexOutput(_T("{\\f1\\'CB}"));
3013 if (start
) TexOutput(_T("{\\f1\\'AC}"));
3016 if (start
) TexOutput(_T("{\\f1\\'DC}"));
3019 if (start
) TexOutput(_T("{\\f1\\'AE}"));
3022 if (start
) TexOutput(_T("{\\f1\\'DE}"));
3024 case ltLEFTRIGHTARROW
:
3025 if (start
) TexOutput(_T("{\\f1\\'AB}"));
3027 case ltLEFTRIGHTARROW2
:
3028 if (start
) TexOutput(_T("{\\f1\\'DB}"));
3031 if (start
) TexOutput(_T("{\\f1\\'AD}"));
3034 if (start
) TexOutput(_T("{\\f1\\'DD}"));
3037 if (start
) TexOutput(_T("{\\f1\\'AF}"));
3040 if (start
) TexOutput(_T("{\\f1\\'DF}"));
3043 // Miscellaneous symbols
3045 if (start
) TexOutput(_T("{\\f1\\'CO}"));
3048 if (start
) TexOutput(_T("{\\f1\\'C3}"));
3051 if (start
) TexOutput(_T("{\\f1\\'C2}"));
3054 if (start
) TexOutput(_T("{\\f1\\'C1}"));
3057 if (start
) TexOutput(_T("{\\f1\\'C6}"));
3060 if (start
) TexOutput(_T("{\\f1\\'D1}"));
3063 if (start
) TexOutput(_T("{\\f1\\'D6}"));
3066 if (start
) TexOutput(_T("{\\f1\\'B6}"));
3069 if (start
) TexOutput(_T("{\\f1\\'5E}"));
3072 if (start
) TexOutput(_T("{\\f1\\'22}"));
3075 if (start
) TexOutput(_T("{\\f1\\'24}"));
3078 if (start
) TexOutput(_T("{\\f1\\'D8}"));
3081 if (start
) TexOutput(_T("{\\f1\\'23}"));
3084 if (start
) TexOutput(_T("{\\f1\\'D0}"));
3087 if (start
) TexOutput(_T("{\\f5\\'73}"));
3090 if (start
) TexOutput(_T("{\\f5\\'A8}"));
3093 if (start
) TexOutput(_T("{\\f5\\'A9}"));
3096 if (start
) TexOutput(_T("{\\f5\\'AA}"));
3099 if (start
) TexOutput(_T("{\\f5\\'AB}"));
3102 if (start
) TexOutput(_T("{\\f1\\'A5}"));
3105 if (start
) TexOutput(_T("{\\f0\\'A9}"));
3108 if (start
) TexOutput(_T("{\\f0\\'AE}"));
3111 if (start
) TexOutput(_T("{\\f1\\'B1}"));
3114 if (start
) TexOutput(_T("{\\f1\\'B1}"));
3117 if (start
) TexOutput(_T("{\\f1\\'B4}"));
3120 if (start
) TexOutput(_T("{\\f1\\'B8}"));
3123 if (start
) TexOutput(_T("{\\f1\\'D7}"));
3126 if (start
) TexOutput(_T("{\\f1\\'2A}"));
3129 if (start
) TexOutput(_T("{\\f5\\'AB}"));
3132 if (start
) TexOutput(_T("{\\f1\\'C7}"));
3135 if (start
) TexOutput(_T("{\\f1\\'C8}"));
3138 if (start
) TexOutput(_T("{\\f1\\'DA}"));
3141 if (start
) TexOutput(_T("{\\f1\\'D9}"));
3144 if (start
) TexOutput(_T("{\\f1\\'B0}"));
3147 if (start
) TexOutput(_T("{\\f1\\'B7}"));
3150 if (start
) TexOutput(_T("{\\f1\\'E0}"));
3153 if (start
) TexOutput(_T("{\\f1\\'C6}"));
3156 if (start
) TexOutput(_T("{\\f1\\'E0}"));
3158 case ltBIGTRIANGLEDOWN
:
3159 if (start
) TexOutput(_T("{\\f1\\'D1}"));
3162 if (start
) TexOutput(_T("{\\f1\\'C5}"));
3165 if (start
) TexOutput(_T("{\\f1\\'C4}"));
3168 if (start
) TexOutput(_T("{\\'DF}"));
3172 if (start
) inFigure
= TRUE
;
3173 else inFigure
= FALSE
;
3178 if (start
) inTable
= TRUE
;
3179 else inTable
= FALSE
;
3184 DefaultOnMacro(macroId
, no_args
, start
);
3190 // Called on start/end of argument examination
3191 bool RTFOnArgument(int macroId
, int arg_no
, bool start
)
3198 case ltCHAPTERHEADING
:
3201 case ltSECTIONHEADING
:
3203 case ltSUBSECTIONSTAR
:
3204 case ltSUBSUBSECTION
:
3205 case ltSUBSUBSECTIONSTAR
:
3207 case ltMEMBERSECTION
:
3208 case ltFUNCTIONSECTION
:
3212 if (!start
&& (arg_no
== 1))
3213 currentSection
= GetArgChunk();
3218 if (start
&& (arg_no
== 1))
3219 TexOutput(_T("\\pard\\li600\\fi-600{\\b "));
3221 if (!start
&& (arg_no
== 1))
3222 TexOutput(_T("} "));
3224 if (start
&& (arg_no
== 2))
3226 if (!suppressNameDecoration
) TexOutput(_T("{\\b "));
3227 currentMember
= GetArgChunk();
3229 if (!start
&& (arg_no
== 2))
3231 if (!suppressNameDecoration
) TexOutput(_T("}"));
3234 if (start
&& (arg_no
== 3))
3236 if (!start
&& (arg_no
== 3))
3238 // TexOutput(_T(")\\li0\\fi0"));
3239 // TexOutput(_T(")\\par\\pard\\li0\\fi0"));
3240 // issuedNewParagraph = 1;
3242 WriteEnvironmentStyles();
3248 if (start
&& (arg_no
== 1))
3249 TexOutput(_T("\\pard\\li260\\fi-260{\\b "));
3250 if (!start
&& (arg_no
== 1))
3251 TexOutput(_T("} "));
3253 if (start
&& (arg_no
== 2))
3255 if (!suppressNameDecoration
) TexOutput(_T("({\\b "));
3256 currentMember
= GetArgChunk();
3258 if (!start
&& (arg_no
== 2))
3260 if (!suppressNameDecoration
) TexOutput(_T("}"));
3263 if (!start
&& (arg_no
== 3))
3265 TexOutput(_T(")\\li0\\fi0"));
3266 WriteEnvironmentStyles();
3272 if (start
&& (arg_no
== 1))
3273 TexOutput(_T("\\pard\\li260\\fi-260"));
3275 if (!start
&& (arg_no
== 1))
3278 if (start
&& (arg_no
== 2))
3279 TexOutput(_T("(*"));
3280 if (!start
&& (arg_no
== 2))
3283 if (start
&& (arg_no
== 2))
3284 currentMember
= GetArgChunk();
3286 if (start
&& (arg_no
== 3))
3288 if (!start
&& (arg_no
== 3))
3290 TexOutput(_T(")\\li0\\fi0"));
3291 WriteEnvironmentStyles();
3297 if (start
&& (arg_no
== 1))
3298 TexOutput(_T("{\\b "));
3299 if (!start
&& (arg_no
== 1))
3301 if (start
&& (arg_no
== 2))
3303 TexOutput(_T("{\\i "));
3305 if (!start
&& (arg_no
== 2))
3313 if (start
&& (arg_no
== 1))
3314 TexOutput(_T("{\\b "));
3315 if (!start
&& (arg_no
== 1))
3316 TexOutput(_T("} ")); // This is the difference from param - one space!
3317 if (start
&& (arg_no
== 2))
3319 TexOutput(_T("{\\i "));
3321 if (!start
&& (arg_no
== 2))
3329 if (!start
&& (arg_no
== 1))
3332 if (start
&& (arg_no
== 2))
3333 currentMember
= GetArgChunk();
3342 wxChar
*refName
= GetArgData();
3343 if (winHelp
|| !useWord
)
3347 TexRef
*texRef
= FindReference(refName
);
3350 sec
= texRef
->sectionNumber
;
3360 wxFprintf(Chapters
, _T("{\\field{\\*\\fldinst REF %s \\\\* MERGEFORMAT }{\\fldrslt ??}}"),
3372 if ((GetNoArgs() - arg_no
) == 1)
3375 TexOutput(_T("{\\uldb "));
3379 if ((GetNoArgs() - arg_no
) == 0) // Arg = 2, or 3 if first is optional
3383 TexOutput(_T("{\\v "));
3385 // Remove green colour/underlining if specified
3386 if (!hotSpotUnderline
&& !hotSpotColour
)
3388 else if (!hotSpotColour
)
3391 else TexOutput(_T("}"));
3394 else // If a linear document, must resolve the references ourselves
3396 if ((GetNoArgs() - arg_no
) == 1)
3398 // In a linear document we display the anchor text in italic plus
3401 TexOutput(_T("{\\i "));
3406 helpRefText
= GetArgChunk();
3410 else if ((GetNoArgs() - arg_no
) == 0) // Arg = 2, or 3 if first is optional
3412 if (macroId
!= ltHELPREFN
)
3414 wxChar
*refName
= GetArgData();
3415 TexRef
*texRef
= NULL
;
3417 texRef
= FindReference(refName
);
3420 if (texRef
|| !ignoreBadRefs
)
3421 TexOutput(_T(" ("));
3424 if (texRef
|| !ignoreBadRefs
)
3428 TexOutput(_T("p. "));
3429 TexOutput(_T("{\\field{\\*\\fldinst PAGEREF "));
3431 TexOutput(_T(" \\\\* MERGEFORMAT }{\\fldrslt ??}}"));
3435 // Only print section name if we're not in Word mode,
3436 // so can't do page references
3439 TexOutput(texRef
->sectionName
);
3441 TexOutput(texRef
->sectionNumber
);
3446 TexOutput(_T("??"));
3447 wxSprintf(buf
, _T("Warning: unresolved reference '%s'"), refName
);
3453 else TexOutput(_T("??"));
3457 if (texRef
|| !ignoreBadRefs
)
3472 else if (arg_no
== 2)
3477 TexOutput(_T(" ({\\f3 "));
3481 TexOutput(_T("})"));
3492 if ((GetNoArgs() - arg_no
) == 1)
3495 TexOutput(_T("{\\ul "));
3499 if ((GetNoArgs() - arg_no
) == 0) // Arg = 2, or 3 if first is optional
3503 TexOutput(_T("{\\v "));
3505 // Remove green colour/underlining if specified
3506 if (!hotSpotUnderline
&& !hotSpotColour
)
3508 else if (!hotSpotColour
)
3511 else TexOutput(_T("}"));
3514 else // A linear document...
3516 if ((GetNoArgs() - arg_no
) == 1)
3518 // In a linear document we just display the anchor text in italic
3520 TexOutput(_T("{\\i "));
3529 case ltADDCONTENTSLINE
:
3531 if (start
&& !winHelp
)
3534 contentsLineSection
= copystring(GetArgData());
3535 else if (arg_no
== 3)
3536 contentsLineValue
= copystring(GetArgData());
3550 static int imageWidth
= 0;
3551 static int imageHeight
= 0;
3553 if (start
&& (arg_no
== 1))
3555 wxChar
*imageDimensions
= copystring(GetArgData());
3557 // imageWidth - Convert points to TWIPS (1 twip = 1/20th of point)
3558 wxStringTokenizer
tok(imageDimensions
, _T(";:"), wxTOKEN_STRTOK
);
3559 if(tok
.HasMoreTokens())
3561 wxString token
= tok
.GetNextToken();
3562 imageWidth
= (int)(20*ParseUnitArgument((wxChar
*)token
.c_str()));
3569 // imageHeight - Convert points to TWIPS (1 twip = 1/20th of point)
3570 if(tok
.HasMoreTokens())
3572 wxString token
= tok
.GetNextToken();
3573 imageHeight
= (int)(20*ParseUnitArgument((wxChar
*)token
.c_str()));
3580 if (imageDimensions
) // glt
3581 delete [] imageDimensions
;
3584 else if (start
&& (arg_no
== 2 ))
3586 wxChar
*filename
= copystring(GetArgData());
3587 wxString f
= _T("");
3588 if ((winHelp
|| (wxStrcmp(bitmapMethod
, _T("includepicture")) == 0) || (wxStrcmp(bitmapMethod
, _T("import")) == 0)) && useWord
)
3590 if (f
== _T("")) // Try for a .shg (segmented hypergraphics file)
3592 wxStrcpy(buf
, filename
);
3593 StripExtension(buf
);
3594 wxStrcat(buf
, _T(".shg"));
3595 f
= TexPathList
.FindValidPath(buf
);
3597 if (f
== _T("")) // Try for a .bmp
3599 wxStrcpy(buf
, filename
);
3600 StripExtension(buf
);
3601 wxStrcat(buf
, _T(".bmp"));
3602 f
= TexPathList
.FindValidPath(buf
);
3604 if (f
== _T("")) // Try for a metafile instead
3606 wxStrcpy(buf
, filename
);
3607 StripExtension(buf
);
3608 wxStrcat(buf
, _T(".wmf"));
3609 f
= TexPathList
.FindValidPath(buf
);
3615 if (bitmapTransparency
&& (winHelpVersion
> 3))
3616 TexOutput(_T("\\{bmct "));
3618 TexOutput(_T("\\{bmc "));
3619 wxString str
= wxFileNameFromPath(f
);
3620 TexOutput((wxChar
*) (const wxChar
*) str
);
3621 TexOutput(_T("\\}"));
3625 // Microsoft Word method
3626 if (wxStrcmp(bitmapMethod
, _T("import")) == 0)
3627 TexOutput(_T("{\\field{\\*\\fldinst IMPORT "));
3629 TexOutput(_T("{\\field{\\*\\fldinst INCLUDEPICTURE "));
3631 // Full path appears not to be valid!
3632 wxString str
= wxFileNameFromPath(f
);
3633 TexOutput((wxChar
*)(const wxChar
*) str
);
3635 int len = wxStrlen(f);
3636 wxChar smallBuf[2]; smallBuf[1] = 0;
3637 for (int i = 0; i < len; i++)
3640 TexOutput(smallBuf);
3641 if (smallBuf[0] == '\\')
3642 TexOutput(smallBuf);
3645 TexOutput(_T("}{\\fldrslt PRESS F9 TO FORMAT PICTURE}}"));
3650 TexOutput(_T("[No BMP or WMF for image file "));
3651 TexOutput(filename
);
3653 wxSprintf(buf
, _T("Warning: could not find a BMP or WMF equivalent for %s."), filename
);
3656 if (filename
) // glt
3661 if (f
== _T("")) // Try for a .bmp
3663 wxStrcpy(buf
, filename
);
3664 StripExtension(buf
);
3665 wxStrcat(buf
, _T(".bmp"));
3666 f
= TexPathList
.FindValidPath(buf
);
3670 FILE *fd
= wxFopen(f
, _T("rb"));
3671 if (OutputBitmapHeader(fd
, winHelp
))
3672 OutputBitmapData(fd
);
3675 wxSprintf(buf
, _T("Could not read bitmap %s.\nMay be in wrong format (needs RGB-encoded Windows BMP)."), f
.c_str());
3680 else // Try for a metafile instead
3683 wxStrcpy(buf
, filename
);
3684 StripExtension(buf
);
3685 wxStrcat(buf
, _T(".wmf"));
3686 f
= TexPathList
.FindValidPath(buf
);
3689 // HFILE handle = _lopen(f, READ);
3690 FILE *fd
= wxFopen(f
, _T("rb"));
3691 if (OutputMetafileHeader(fd
, winHelp
, imageWidth
, imageHeight
))
3693 OutputMetafileData(fd
);
3697 wxSprintf(buf
, _T("Could not read metafile %s. Perhaps it's not a placeable metafile?"), f
.c_str());
3705 TexOutput(_T("[No BMP or WMF for image file "));
3706 TexOutput(filename
);
3708 wxSprintf(buf
, _T("Warning: could not find a BMP or WMF equivalent for %s."), filename
);
3721 case ltSUPERTABULAR
:
3727 currentRowNumber
= 0;
3730 tableVerticalLineLeft
= FALSE
;
3731 tableVerticalLineRight
= FALSE
;
3732 int currentWidth
= 0;
3734 wxChar
*alignString
= copystring(GetArgData());
3735 ParseTableArgument(alignString
);
3737 // TexOutput(_T("\\trowd\\trgaph108\\trleft-108"));
3738 TexOutput(_T("\\trowd\\trgaph108"));
3740 // Write the first row formatting for compatibility
3741 // with standard Latex
3742 if (compatibilityMode
)
3744 for (int i
= 0; i
< noColumns
; i
++)
3746 currentWidth
+= TableData
[i
].width
;
3747 wxSprintf(buf
, _T("\\cellx%d"), currentWidth
);
3750 TexOutput(_T("\\pard\\intbl\n"));
3752 delete[] alignString
;
3757 else if (arg_no
== 2 && !start
)
3759 TexOutput(_T("\\pard\n"));
3760 WriteEnvironmentStyles();
3771 TexOutput(_T("\\li360\n"));
3773 PushEnvironmentStyle(_T("\\li360\\sa200"));
3778 PopEnvironmentStyle();
3779 OnMacro(ltPAR
, 0, TRUE
);
3780 OnMacro(ltPAR
, 0, FALSE
);
3788 TexOutput(_T("\\li360\n"));
3789 PushEnvironmentStyle(_T("\\li360\\sa200"));
3793 PopEnvironmentStyle();
3794 OnMacro(ltPAR
, 0, TRUE
);
3795 OnMacro(ltPAR
, 0, FALSE
);
3807 wxSprintf(buf
, _T("\\sa200\\box\\trgaph108%s\n"), ((macroId
== ltNORMALBOXD
) ? _T("\\brdrdb") : _T("\\brdrs")));
3809 PushEnvironmentStyle(buf
);
3813 PopEnvironmentStyle();
3814 OnMacro(ltPAR
, 0, TRUE
);
3815 OnMacro(ltPAR
, 0, FALSE
);
3819 case ltHELPFONTSIZE
:
3823 wxChar
*data
= GetArgData();
3824 if (wxStrcmp(data
, _T("10")) == 0)
3826 else if (wxStrcmp(data
, _T("11")) == 0)
3828 else if (wxStrcmp(data
, _T("12")) == 0)
3830 wxSprintf(buf
, _T("\\fs%d\n"), normalFont
*2);
3837 case ltHELPFONTFAMILY
:
3841 wxChar
*data
= GetArgData();
3842 if (wxStrcmp(data
, _T("Swiss")) == 0)
3843 TexOutput(_T("\\f2\n"));
3844 else if (wxStrcmp(data
, _T("Symbol")) == 0)
3845 TexOutput(_T("\\f1\n"));
3846 else if (wxStrcmp(data
, _T("Times")) == 0)
3847 TexOutput(_T("\\f0\n"));
3855 if (start
&& arg_no
== 1)
3857 wxChar
*data
= GetArgData();
3858 ParIndent
= ParseUnitArgument(data
);
3859 if (ParIndent
== 0 || forbidParindent
== 0)
3861 wxSprintf(buf
, _T("\\fi%d\n"), ParIndent
*20);
3870 if (start
&& IsArgOptional())
3872 descriptionItemArg
= GetArgChunk();
3878 case ltTWOCOLITEMRULED
:
3885 TexOutput(_T("\\tab "));
3892 if (macroId
== ltTWOCOLITEMRULED
)
3893 TexOutput(_T("\\brdrb\\brdrs\\brdrw15\\brsp20 "));
3894 TexOutput(_T("\\par\\pard\n"));
3895 issuedNewParagraph
= 1;
3896 WriteEnvironmentStyles();
3907 case ltACCENT_GRAVE
:
3911 wxChar
*val
= GetArgData();
3917 TexOutput(_T("\\'e0"));
3920 TexOutput(_T("\\'e8"));
3923 TexOutput(_T("\\'ec"));
3926 TexOutput(_T("\\'f2"));
3929 TexOutput(_T("\\'f9"));
3932 TexOutput(_T("\\'c0"));
3935 TexOutput(_T("\\'c8"));
3938 TexOutput(_T("\\'cc"));
3941 TexOutput(_T("\\'d2"));
3944 TexOutput(_T("\\'d9"));
3953 case ltACCENT_ACUTE
:
3957 wxChar
*val
= GetArgData();
3963 TexOutput(_T("\\'e1"));
3966 TexOutput(_T("\\'e9"));
3969 TexOutput(_T("\\'ed"));
3972 TexOutput(_T("\\'f3"));
3975 TexOutput(_T("\\'fa"));
3978 TexOutput(_T("\\'fd"));
3981 TexOutput(_T("\\'c1"));
3984 TexOutput(_T("\\'c9"));
3987 TexOutput(_T("\\'cd"));
3990 TexOutput(_T("\\'d3"));
3993 TexOutput(_T("\\'da"));
3996 TexOutput(_T("\\'dd"));
4005 case ltACCENT_CARET
:
4009 wxChar
*val
= GetArgData();
4015 TexOutput(_T("\\'e2"));
4018 TexOutput(_T("\\'ea"));
4021 TexOutput(_T("\\'ee"));
4024 TexOutput(_T("\\'f4"));
4027 TexOutput(_T("\\'fb"));
4030 TexOutput(_T("\\'c2"));
4033 TexOutput(_T("\\'ca"));
4036 TexOutput(_T("\\'ce"));
4039 TexOutput(_T("\\'d4"));
4042 TexOutput(_T("\\'db"));
4051 case ltACCENT_TILDE
:
4055 wxChar
*val
= GetArgData();
4061 TexOutput(_T("\\'e3"));
4067 TexOutput(_T("\\'f1"));
4070 TexOutput(_T("\\'f5"));
4073 TexOutput(_T("\\'c3"));
4076 TexOutput(_T("\\'d1"));
4079 TexOutput(_T("\\'d5"));
4088 case ltACCENT_UMLAUT
:
4092 wxChar
*val
= GetArgData();
4098 TexOutput(_T("\\'e4"));
4101 TexOutput(_T("\\'eb"));
4104 TexOutput(_T("\\'ef"));
4107 TexOutput(_T("\\'f6"));
4110 TexOutput(_T("\\'fc"));
4113 TexOutput(_T("\\'df"));
4116 TexOutput(_T("\\'ff"));
4119 TexOutput(_T("\\'c4"));
4122 TexOutput(_T("\\'cb"));
4125 TexOutput(_T("\\'cf"));
4128 TexOutput(_T("\\'d6"));
4131 TexOutput(_T("\\'dc"));
4134 TexOutput(_T("\\'df"));
4147 wxChar
*val
= GetArgData();
4153 TexOutput(_T("\\'e5"));
4156 TexOutput(_T("\\'c5"));
4165 case ltACCENT_CADILLA
:
4169 wxChar
*val
= GetArgData();
4175 TexOutput(_T("\\'e7"));
4178 TexOutput(_T("\\'c7"));
4189 static wxChar
*helpTopic
= NULL
;
4190 static FILE *savedOutput
= NULL
;
4197 OnInform(_T("Consider using \\footnotepopup instead of \\footnote."));
4200 wxSprintf(footBuf
, _T("(%d)"), footnoteCount
);
4202 TexOutput(_T(" {\\ul "));
4205 helpTopic
= FindTopicName(NULL
);
4206 TexOutput(_T("{\\v "));
4208 // Remove green colour/underlining if specified
4209 if (!hotSpotUnderline
&& !hotSpotColour
)
4211 else if (!hotSpotColour
)
4214 TexOutput(helpTopic
);
4217 wxFprintf(Popups
, _T("\\page\n"));
4218 // wxFprintf(Popups, _T("\n${\\footnote }")); // No title
4219 wxFprintf(Popups
, _T("\n#{\\footnote %s}\n"), helpTopic
);
4220 wxFprintf(Popups
, _T("+{\\footnote %s}\n"), GetBrowseString());
4221 savedOutput
= CurrentOutput1
;
4222 SetCurrentOutput(Popups
);
4226 SetCurrentOutput(savedOutput
);
4236 TexOutput(_T(" {\\super \\chftn{\\footnote \\fs20 {\\super \\chftn}"), TRUE
);
4240 TexOutput(_T("}}"), TRUE
);
4245 case ltFOOTNOTEPOPUP
:
4247 static wxChar
*helpTopic
= NULL
;
4248 static FILE *savedOutput
= NULL
;
4255 TexOutput(_T("{\\ul "));
4257 else TexOutput(_T("}"));
4260 else if (arg_no
== 2)
4264 helpTopic
= FindTopicName(NULL
);
4265 TexOutput(_T("{\\v "));
4267 // Remove green colour/underlining if specified
4268 if (!hotSpotUnderline
&& !hotSpotColour
)
4270 else if (!hotSpotColour
)
4273 TexOutput(helpTopic
);
4276 wxFprintf(Popups
, _T("\\page\n"));
4277 // wxFprintf(Popups, _T("\n${\\footnote }")); // No title
4278 wxFprintf(Popups
, _T("\n#{\\footnote %s}\n"), helpTopic
);
4279 wxFprintf(Popups
, _T("+{\\footnote %s}\n"), GetBrowseString());
4280 savedOutput
= CurrentOutput1
;
4281 SetCurrentOutput(Popups
);
4285 SetCurrentOutput(savedOutput
);
4296 TexOutput(_T(" {\\super \\chftn{\\footnote \\fs20 {\\super \\chftn}"), TRUE
);
4300 TexOutput(_T("}}"), TRUE
);
4308 if (start
&& (arg_no
== 1))
4320 if (winHelp
) return FALSE
;
4326 LeftHeaderEven
= GetArgChunk();
4327 if (wxStrlen(GetArgData(LeftHeaderEven
)) == 0)
4328 LeftHeaderEven
= NULL
;
4331 CentreHeaderEven
= GetArgChunk();
4332 if (wxStrlen(GetArgData(CentreHeaderEven
)) == 0)
4333 CentreHeaderEven
= NULL
;
4336 RightHeaderEven
= GetArgChunk();
4337 if (wxStrlen(GetArgData(RightHeaderEven
)) == 0)
4338 RightHeaderEven
= NULL
;
4341 LeftHeaderOdd
= GetArgChunk();
4342 if (wxStrlen(GetArgData(LeftHeaderOdd
)) == 0)
4343 LeftHeaderOdd
= NULL
;
4346 CentreHeaderOdd
= GetArgChunk();
4347 if (wxStrlen(GetArgData(CentreHeaderOdd
)) == 0)
4348 CentreHeaderOdd
= NULL
;
4351 RightHeaderOdd
= GetArgChunk();
4352 if (wxStrlen(GetArgData(RightHeaderOdd
)) == 0)
4353 RightHeaderOdd
= NULL
;
4354 OutputRTFHeaderCommands();
4369 if (winHelp
) return FALSE
;
4375 LeftFooterEven
= GetArgChunk();
4376 if (wxStrlen(GetArgData(LeftFooterEven
)) == 0)
4377 LeftFooterEven
= NULL
;
4380 CentreFooterEven
= GetArgChunk();
4381 if (wxStrlen(GetArgData(CentreFooterEven
)) == 0)
4382 CentreFooterEven
= NULL
;
4385 RightFooterEven
= GetArgChunk();
4386 if (wxStrlen(GetArgData(RightFooterEven
)) == 0)
4387 RightFooterEven
= NULL
;
4390 LeftFooterOdd
= GetArgChunk();
4391 if (wxStrlen(GetArgData(LeftFooterOdd
)) == 0)
4392 LeftFooterOdd
= NULL
;
4395 CentreFooterOdd
= GetArgChunk();
4396 if (wxStrlen(GetArgData(CentreFooterOdd
)) == 0)
4397 CentreFooterOdd
= NULL
;
4400 RightFooterOdd
= GetArgChunk();
4401 if (wxStrlen(GetArgData(RightFooterOdd
)) == 0)
4402 RightFooterOdd
= NULL
;
4403 OutputRTFFooterCommands();
4413 if (winHelp
) return FALSE
;
4414 // Fake a SetHeader command
4417 LeftHeaderOdd
= NULL
;
4418 CentreHeaderOdd
= NULL
;
4419 RightHeaderOdd
= NULL
;
4420 LeftHeaderEven
= NULL
;
4421 CentreHeaderEven
= NULL
;
4422 RightHeaderEven
= NULL
;
4423 OnInform(_T("Consider using setheader/setfooter rather than markright."));
4425 RTFOnArgument(ltSETHEADER
, 4, start
);
4427 OutputRTFHeaderCommands();
4432 if (winHelp
) return FALSE
;
4433 // Fake a SetHeader command
4440 LeftHeaderOdd
= NULL
;
4441 CentreHeaderOdd
= NULL
;
4442 RightHeaderOdd
= NULL
;
4443 LeftHeaderEven
= NULL
;
4444 CentreHeaderEven
= NULL
;
4445 RightHeaderEven
= NULL
;
4446 OnInform(_T("Consider using setheader/setfooter rather than markboth."));
4448 return RTFOnArgument(ltSETHEADER
, 1, start
);
4452 RTFOnArgument(ltSETHEADER
, 4, start
);
4454 OutputRTFHeaderCommands();
4460 case ltPAGENUMBERING
:
4467 if (winHelp
) return FALSE
;
4470 TexOutput(_T("\\pgnrestart"));
4471 wxChar
*data
= GetArgData();
4472 if (currentNumberStyle
) delete[] currentNumberStyle
;
4473 currentNumberStyle
= copystring(data
);
4474 OutputNumberStyle(currentNumberStyle
);
4476 TexOutput(_T("\n"));
4482 if (winHelp
) return FALSE
;
4491 wxChar
*val
= GetArgData();
4492 currentItemSep
= ParseUnitArgument(val
);
4497 case ltEVENSIDEMARGIN
:
4501 case ltODDSIDEMARGIN
:
4505 wxChar
*val
= GetArgData();
4506 int twips
= (int)(20*ParseUnitArgument(val
));
4507 // Add an inch since in LaTeX it's specified minus an inch
4509 CurrentLeftMarginOdd
= twips
;
4510 wxSprintf(buf
, _T("\\margl%d\n"), twips
);
4513 CurrentMarginParX
= CurrentLeftMarginOdd
+ CurrentTextWidth
+ CurrentMarginParSep
;
4517 case ltMARGINPARWIDTH
:
4521 wxChar
*val
= GetArgData();
4522 int twips
= (int)(20*ParseUnitArgument(val
));
4523 CurrentMarginParWidth
= twips
;
4527 case ltMARGINPARSEP
:
4531 wxChar
*val
= GetArgData();
4532 int twips
= (int)(20*ParseUnitArgument(val
));
4533 CurrentMarginParSep
= twips
;
4534 CurrentMarginParX
= CurrentLeftMarginOdd
+ CurrentTextWidth
+ CurrentMarginParSep
;
4542 wxChar
*val
= GetArgData();
4543 int twips
= (int)(20*ParseUnitArgument(val
));
4544 CurrentTextWidth
= twips
;
4546 // Need to set an implicit right margin
4547 CurrentRightMarginOdd
= PageWidth
- CurrentTextWidth
- CurrentLeftMarginOdd
;
4548 CurrentRightMarginEven
= PageWidth
- CurrentTextWidth
- CurrentLeftMarginEven
;
4549 CurrentMarginParX
= CurrentLeftMarginOdd
+ CurrentTextWidth
+ CurrentMarginParSep
;
4550 wxSprintf(buf
, _T("\\margr%d\n"), CurrentRightMarginOdd
);
4556 case ltMARGINPARODD
:
4562 TexOutput(_T("\\sa200\\box\n"));
4563 PushEnvironmentStyle(_T("\\sa200\\box"));
4567 wxSprintf(buf
, _T("\\phpg\\posx%d\\absw%d\n"), CurrentMarginParX
, CurrentMarginParWidth
);
4576 TexOutput(_T("\\par\\pard\n"));
4577 PopEnvironmentStyle();
4578 WriteEnvironmentStyles();
4581 TexOutput(_T("\\par\\pard\n"));
4582 issuedNewParagraph
= 1;
4586 case ltMARGINPAREVEN
:
4592 TexOutput(_T("\\sa200\\box\n"));
4593 PushEnvironmentStyle(_T("\\sa200\\box"));
4599 // Have to calculate what the margins are changed to in WfW margin
4600 // mirror mode, on an even (left-hand) page.
4601 int x
= PageWidth
- CurrentRightMarginOdd
- CurrentMarginParWidth
- CurrentMarginParSep
4602 - CurrentTextWidth
+ GutterWidth
;
4603 wxSprintf(buf
, _T("\\phpg\\posx%d\\absw%d\n"), x
, CurrentMarginParWidth
);
4608 wxSprintf(buf
, _T("\\phpg\\posx%d\\absw%d\n"), CurrentMarginParX
, CurrentMarginParWidth
);
4618 TexOutput(_T("\\par\\pard\n"));
4619 PopEnvironmentStyle();
4620 WriteEnvironmentStyles();
4623 issuedNewParagraph
= 1;
4624 TexOutput(_T("\\par\\pard\n"));
4628 case ltTWOCOLWIDTHA
:
4632 wxChar
*val
= GetArgData();
4633 int twips
= (int)(20*ParseUnitArgument(val
));
4634 TwoColWidthA
= twips
;
4638 case ltTWOCOLWIDTHB
:
4642 wxChar
*val
= GetArgData();
4643 int twips
= (int)(20*ParseUnitArgument(val
));
4644 TwoColWidthB
= twips
;
4653 int currentWidth
= 0;
4655 if (!compatibilityMode
|| (currentRowNumber
> 0))
4657 TexOutput(_T("\\pard\\intbl"));
4659 if (macroId
== ltRULEDROW
)
4661 for (int i
= 0; i
< noColumns
; i
++)
4663 currentWidth
+= TableData
[i
].width
;
4666 TexOutput(_T("\\clbrdrt\\brdrs\\brdrw15"));
4668 else if (ruleTop
> 1)
4670 TexOutput(_T("\\clbrdrt\\brdrdb\\brdrw15"));
4672 if (ruleBottom
== 1)
4674 TexOutput(_T("\\clbrdrb\\brdrs\\brdrw15"));
4676 else if (ruleBottom
> 1)
4678 TexOutput(_T("\\clbrdrb\\brdrdb\\brdrw15"));
4681 if (TableData
[i
].rightBorder
)
4682 TexOutput(_T("\\clbrdrr\\brdrs\\brdrw15"));
4684 if (TableData
[i
].leftBorder
)
4685 TexOutput(_T("\\clbrdrl\\brdrs\\brdrw15"));
4687 wxSprintf(buf
, _T("\\cellx%d"), currentWidth
);
4690 TexOutput(_T("\\pard\\intbl\n"));
4694 currentRowNumber
++;
4699 // TexOutput(_T("\\cell\\row\\trowd\\trgaph108\\trleft-108\n"));
4700 TexOutput(_T("\\cell\\row\\trowd\\trgaph108\n"));
4706 static int noMultiColumns
= 0;
4713 noMultiColumns
= wxAtoi(GetArgData());
4730 for (int i
= 1; i
< noMultiColumns
; i
++)
4731 TexOutput(_T("\\cell"));
4738 if (start
&& (arg_no
== 1))
4741 // TexOutput(_T("\\fi0\n"));
4743 wxNode
*node
= itemizeStack
.GetFirst();
4745 oldIndent
= ((ItemizeStruc
*)node
->GetData())->indentation
;
4747 int indentValue
= 20*ParseUnitArgument(GetArgData());
4748 int indentSize
= indentValue
+ oldIndent
;
4750 ItemizeStruc
*struc
= new ItemizeStruc(LATEX_INDENT
, indentSize
);
4751 itemizeStack
.Insert(struc
);
4753 wxSprintf(buf
, _T("\\tx%d\\li%d\\sa200 "), indentSize
, indentSize
);
4754 PushEnvironmentStyle(buf
);
4758 if (!start
&& (arg_no
== 2))
4760 PopEnvironmentStyle();
4761 if (itemizeStack
.GetFirst())
4763 ItemizeStruc
*struc
= (ItemizeStruc
*)itemizeStack
.GetFirst()->GetData();
4765 delete itemizeStack
.GetFirst();
4767 if (itemizeStack
.GetCount() == 0)
4769 TexOutput(_T("\\par\\pard\n"));
4770 issuedNewParagraph
= 1;
4771 WriteEnvironmentStyles();
4780 if (start && (arg_no == 1))
4783 wxNode *node = itemizeStack.GetFirst();
4785 oldIndent = ((ItemizeStruc *)node->GetData())->indentation;
4787 int boxWidth = 20*ParseUnitArgument(GetArgData());
4789 int indentValue = (int)((CurrentTextWidth - oldIndent - boxWidth)/2.0);
4790 int indentSize = indentValue + oldIndent;
4791 int indentSizeRight = indentSize + boxWidth;
4793 ItemizeStruc *struc = new ItemizeStruc(LATEX_INDENT, indentSize);
4794 itemizeStack.Insert(struc);
4796 wxSprintf(buf, _T("\\tx%d\\li%d\\lr%d\\sa200\\box%s "), indentSize, indentSize, indentSizeRight,
4797 ((macroId == ltCENTEREDBOX) ? _T("\\brdrs") : _T("\\brdrdb")));
4798 PushEnvironmentStyle(buf);
4802 if (!start && (arg_no == 2))
4804 PopEnvironmentStyle();
4805 if (itemizeStack.GetFirst())
4807 ItemizeStruc *struc = (ItemizeStruc *)itemizeStack.GetFirst()->GetData();
4809 delete itemizeStack.GetFirst();
4811 if (itemizeStack.Number() == 0)
4813 TexOutput(_T("\\par\\pard\n"));
4814 issuedNewParagraph = 1;
4815 WriteEnvironmentStyles();
4822 case ltDOCUMENTSTYLE
:
4824 DefaultOnArgument(macroId
, arg_no
, start
);
4825 if (!start
&& !IsArgOptional())
4827 if (MinorDocumentStyleString
)
4829 if (StringMatch(_T("twoside"), MinorDocumentStyleString
))
4830 // Mirror margins, switch on odd/even headers & footers, and break sections at odd pages
4831 TexOutput(_T("\\margmirror\\facingp\\sbkodd"));
4832 if (StringMatch(_T("twocolumn"), MinorDocumentStyleString
))
4833 TexOutput(_T("\\cols2"));
4835 TexOutput(_T("\n"));
4839 case ltSETHOTSPOTCOLOUR
:
4840 case ltSETHOTSPOTCOLOR
:
4844 wxChar
*text
= GetArgData();
4845 if (wxStrcmp(text
, _T("yes")) == 0 || wxStrcmp(text
, _T("on")) == 0 || wxStrcmp(text
, _T("ok")) == 0)
4846 hotSpotColour
= TRUE
;
4848 hotSpotColour
= FALSE
;
4852 case ltSETTRANSPARENCY
:
4856 wxChar
*text
= GetArgData();
4857 if (wxStrcmp(text
, _T("yes")) == 0 || wxStrcmp(text
, _T("on")) == 0 || wxStrcmp(text
, _T("ok")) == 0)
4858 bitmapTransparency
= TRUE
;
4860 bitmapTransparency
= FALSE
;
4864 case ltSETHOTSPOTUNDERLINE
:
4868 wxChar
*text
= GetArgData();
4869 if (wxStrcmp(text
, _T("yes")) == 0 || wxStrcmp(text
, _T("on")) == 0 || wxStrcmp(text
, _T("ok")) == 0)
4870 hotSpotUnderline
= TRUE
;
4872 hotSpotUnderline
= FALSE
;
4878 if (arg_no
== 1 && start
)
4880 wxChar
*citeKey
= GetArgData();
4881 TexRef
*ref
= (TexRef
*)TexReferences
.Get(citeKey
);
4884 if (ref
->sectionNumber
) delete[] ref
->sectionNumber
;
4885 wxSprintf(buf
, _T("[%d]"), citeCount
);
4886 ref
->sectionNumber
= copystring(buf
);
4889 TexOutput(_T("\\li260\\fi-260 ")); // Indent from 2nd line
4890 wxSprintf(buf
, _T("{\\b [%d]} "), citeCount
);
4895 if (arg_no
== 2 && !start
)
4896 TexOutput(_T("\\par\\pard\\par\n\n"));
4899 case ltTHEBIBLIOGRAPHY
:
4901 if (start
&& (arg_no
== 1))
4905 SetCurrentOutputs(Contents
, Chapters
);
4909 wxFprintf(Chapters
, _T("\\sect\\pgncont\\titlepg\n"));
4911 // If a non-custom page style, we generate the header now.
4912 if (PageStyle
&& (wxStrcmp(PageStyle
, _T("plain")) == 0 ||
4913 wxStrcmp(PageStyle
, _T("empty")) == 0 ||
4914 wxStrcmp(PageStyle
, _T("headings")) == 0))
4916 OutputRTFHeaderCommands();
4917 OutputRTFFooterCommands();
4920 // Need to reset the current numbering style, or RTF forgets it.
4921 OutputNumberStyle(currentNumberStyle
);
4922 SetCurrentOutput(Contents
);
4925 wxFprintf(Chapters
, _T("\\page\n"));
4928 wxFprintf(Contents
, _T("\n{\\uldb %s}"), ReferencesNameString
);
4930 wxFprintf(Contents
, _T("\\par\n\\pard{\\b %s}"), ReferencesNameString
);
4932 startedSections
= TRUE
;
4935 wxFprintf(Chapters
, _T("\n${\\footnote %s}"), ReferencesNameString
);
4937 wxChar
*topicName
= _T("bibliography");
4941 wxFprintf(Contents
, _T("{\\v %s}\\par\\pard\n"), topicName
);
4942 WriteEnvironmentStyles();
4945 wxFprintf(Contents
, _T("\\par\\par\\pard\n"));
4949 wxFprintf(Chapters
, _T("\n#{\\footnote %s}\n"), topicName
);
4950 wxFprintf(Chapters
, _T("+{\\footnote %s}\n"), GetBrowseString());
4951 wxFprintf(Chapters
, _T("K{\\footnote {K} %s}\n"), ReferencesNameString
);
4952 GenerateKeywordsForTopic(topicName
);
4955 wxFprintf(Chapters
, _T("!{\\footnote EnableButton(\"Up\");ChangeButtonBinding(\"Up\", \"JumpId(`%s.hlp', `%s')\")}\n"),
4956 wxFileNameFromPath(FileRoot
), "Contents");
4960 SetCurrentOutput(Chapters
);
4961 wxChar
*styleCommand
= _T("");
4962 if (!winHelp
&& useHeadingStyles
)
4963 styleCommand
= _T("\\s1");
4964 wxFprintf(Chapters
, _T("\\pard{%s"), (winHelp
? _T("\\keepn\\sa140\\sb140") : styleCommand
));
4965 WriteHeadingStyle(Chapters
, 1); wxFprintf(Chapters
, _T(" References\\par\\pard}\n"));
4974 * In Windows help, all keywords should be at the start of the
4975 * topic, but Latex \index commands can be anywhere in the text.
4976 * So we're going to have to build up lists of keywords for a topic,
4977 * and insert them on the second pass.
4979 * In linear RTF, we can embed the index entry now.
4984 // wxChar *entry = GetArgData();
4986 OutputChunkToString(GetArgChunk(), buf
);
4991 AddKeyWordForTopic(CurrentTopic
, buf
);
4994 else GenerateIndexEntry(buf
);
5007 wxChar
*name
= GetArgData();
5008 int pos
= FindColourPosition(name
);
5011 wxSprintf(buf
, _T("{%s%d "), ((macroId
== ltFCOL
) ? _T("\\cf") : _T("\\cb")), pos
);
5016 wxSprintf(buf
, _T("Could not find colour name %s"), name
);
5031 if (arg_no
== 2) TexOutput(_T("}"));
5037 if (start
&& !winHelp
&& useWord
)
5039 wxChar
*s
= GetArgData();
5040 // Only insert a bookmark here if it's not just been inserted
5041 // in a section heading.
5042 if ( !CurrentTopic
|| !(wxStrcmp(CurrentTopic
, s
) == 0) )
5044 if ( (!CurrentChapterName || !(CurrentChapterName && (wxStrcmp(CurrentChapterName, s) == 0))) &&
5045 (!CurrentSectionName || !(CurrentSectionName && (wxStrcmp(CurrentSectionName, s) == 0))) &&
5046 (!CurrentSubsectionName || !(CurrentSubsectionName && (wxStrcmp(CurrentSubsectionName, s) == 0)))
5050 wxFprintf(Chapters
, _T("{\\bkmkstart %s}{\\bkmkend %s}"), s
,s
);
5057 if (start
&& useWord
&& !winHelp
)
5059 wxChar
*s
= GetArgData();
5060 wxFprintf(Chapters
, _T("{\\field{\\*\\fldinst PAGEREF %s \\\\* MERGEFORMAT }{\\fldrslt ??}}"),
5068 inPopRefSection
= TRUE
;
5070 inPopRefSection
= FALSE
;
5073 case ltINSERTATLEVEL
:
5075 // This macro allows you to insert text at a different level
5076 // from the current level, e.g. into the Sections from within a subsubsection.
5077 if (!winHelp
& useWord
)
5079 static int currentLevelNo
= 1;
5080 static FILE* oldLevelFile
= Chapters
;
5087 oldLevelFile
= CurrentOutput1
;
5089 wxChar
*str
= GetArgData();
5090 currentLevelNo
= wxAtoi(str
);
5092 // TODO: cope with article style (no chapters)
5093 switch (currentLevelNo
)
5097 outputFile
= Chapters
;
5102 outputFile
= Sections
;
5107 outputFile
= Subsections
;
5112 outputFile
= Subsubsections
;
5122 CurrentOutput1
= outputFile
;
5138 CurrentOutput1
= oldLevelFile
;
5144 return DefaultOnArgument(macroId
, arg_no
, start
);
5156 forbidParindent
= 0;
5157 contentsLineSection
= NULL
;
5158 contentsLineValue
= NULL
;
5159 descriptionItemArg
= NULL
;
5164 tableVerticalLineLeft
= FALSE
;
5165 tableVerticalLineRight
= FALSE
;
5167 startedSections
= FALSE
;
5171 if (InputFile
&& OutputFile
)
5173 // Do some RTF-specific transformations on all the strings,
5175 Text2RTF(GetTopLevelChunk());
5177 Contents
= wxFopen(TmpContentsName
, _T("w"));
5178 Chapters
= wxFopen(_T("chapters.rtf"), _T("w"));
5181 Sections
= wxFopen(_T("sections.rtf"), _T("w"));
5182 Subsections
= wxFopen(_T("subsections.rtf"), _T("w"));
5183 Subsubsections
= wxFopen(_T("subsubsections.rtf"), _T("w"));
5184 Popups
= wxFopen(_T("popups.rtf"), _T("w"));
5185 if (winHelpContents
)
5187 WinHelpContentsFile
= wxFopen(WinHelpContentsFileName
, _T("w"));
5188 if (WinHelpContentsFile
)
5189 wxFprintf(WinHelpContentsFile
, _T(":Base %s.hlp\n"), wxFileNameFromPath(FileRoot
));
5192 if (!Sections
|| !Subsections
|| !Subsubsections
|| !Popups
|| (winHelpContents
&& !WinHelpContentsFile
))
5194 OnError(_T("Ouch! Could not open temporary file(s) for writing."));
5198 if (!Contents
|| !Chapters
)
5200 OnError(_T("Ouch! Could not open temporary file(s) for writing."));
5206 wxFprintf(Chapters
, _T("\n#{\\footnote Contents}\n"));
5207 wxFprintf(Chapters
, _T("${\\footnote Contents}\n"));
5208 wxFprintf(Chapters
, _T("+{\\footnote %s}\n"), GetBrowseString());
5209 wxFprintf(Chapters
, _T("K{\\footnote {K} %s}\n"), ContentsNameString
);
5210 wxFprintf(Chapters
, _T("!{\\footnote DisableButton(\"Up\")}\n"));
5214 wxFprintf(Chapters
, _T("\\titlepg\n"));
5215 wxFprintf(Contents
, _T("\\par\\pard\\pgnrestart\\sect\\titlepg"));
5218 // In WinHelp, Contents title takes font of title.
5219 // In linear RTF, same as chapter headings.
5220 wxFprintf(Contents
, _T("{\\b\\fs%d %s}\\par\\par\\pard\n\n"),
5221 (winHelp
? titleFont
: chapterFont
)*2, ContentsNameString
);
5223 // By default, Swiss, 11 point.
5224 wxFprintf(Chapters
, _T("\\f2\\fs22\n"));
5226 PushEnvironmentStyle(_T("\\f2\\fs22\\sa200"));
5228 SetCurrentOutput(Chapters
);
5233 OnInform(_T("Converting..."));
5237 FILE *Header
= wxFopen(_T("header.rtf"), _T("w"));
5240 OnError(_T("Ouch! Could not open temporary file header.rtf for writing."));
5243 WriteRTFHeader(Header
);
5246 PopEnvironmentStyle();
5251 // wxFprintf(Contents, _T("\\page\n"));
5252 wxFprintf(Chapters
, _T("\\page\n"));
5253 wxFprintf(Sections
, _T("\\page\n"));
5254 wxFprintf(Subsections
, _T("\\page\n"));
5255 wxFprintf(Subsubsections
, _T("\\page\n\n"));
5256 wxFprintf(Popups
, _T("\\page\n}\n"));
5259 // TexOutput(_T("\n\\info{\\doccomm Document created by Julian Smart's Tex2RTF.}\n"));
5261 TexOutput(_T("}\n"));
5262 fclose(Contents
); Contents
= NULL
;
5263 fclose(Chapters
); Chapters
= NULL
;
5266 fclose(Sections
); Sections
= NULL
;
5267 fclose(Subsections
); Subsections
= NULL
;
5268 fclose(Subsubsections
); Subsubsections
= NULL
;
5269 fclose(Popups
); Popups
= NULL
;
5270 if (winHelpContents
)
5272 fclose(WinHelpContentsFile
); WinHelpContentsFile
= NULL
;
5278 wxConcatFiles(_T("header.rtf"), _T("chapters.rtf"), _T("tmp1.rtf"));
5280 wxConcatFiles(_T("tmp1.rtf"), _T("sections.rtf"), _T("tmp2.rtf"));
5282 wxConcatFiles(_T("tmp2.rtf"), _T("subsections.rtf"), _T("tmp3.rtf"));
5284 wxConcatFiles(_T("tmp3.rtf"), _T("subsubsections.rtf"), _T("tmp4.rtf"));
5286 wxConcatFiles(_T("tmp4.rtf"), _T("popups.rtf"), OutputFile
);
5289 wxRemoveFile(_T("tmp1.rtf"));
5290 wxRemoveFile(_T("tmp2.rtf"));
5291 wxRemoveFile(_T("tmp3.rtf"));
5292 wxRemoveFile(_T("tmp4.rtf"));
5296 wxConcatFiles(_T("header.rtf"), _T("chapters.rtf"), _T("tmp1.rtf"));
5298 if (wxFileExists(OutputFile
))
5299 wxRemoveFile(OutputFile
);
5302 cwdStr
= wxGetWorkingDirectory();
5304 wxString outputDirStr
;
5305 outputDirStr
= wxPathOnly(OutputFile
);
5307 // Determine if the temp file and the output file are in the same directory,
5308 // and if they are, then just rename the temp file rather than copying
5309 // it, as this is much faster when working with large (multi-megabyte files)
5310 if ((wxStrcmp(outputDirStr
.c_str(),_T("")) == 0) || // no path specified on output file
5311 (wxStrcmp(cwdStr
,outputDirStr
.c_str()) == 0)) // paths do not match
5313 wxRenameFile(_T("tmp1.rtf"), OutputFile
);
5317 wxCopyFile(_T("tmp1.rtf"), OutputFile
);
5321 wxRemoveFile(_T("tmp1.rtf"));
5324 if (wxFileExists(ContentsName
)) wxRemoveFile(ContentsName
);
5326 if (!wxRenameFile(TmpContentsName
, ContentsName
))
5328 wxCopyFile(TmpContentsName
, ContentsName
);
5329 wxRemoveFile(TmpContentsName
);
5332 wxRemoveFile(_T("chapters.rtf"));
5333 wxRemoveFile(_T("header.rtf"));
5337 wxRemoveFile(_T("sections.rtf"));
5338 wxRemoveFile(_T("subsections.rtf"));
5339 wxRemoveFile(_T("subsubsections.rtf"));
5340 wxRemoveFile(_T("popups.rtf"));
5342 if (winHelp
&& generateHPJ
)
5343 WriteHPJ(OutputFile
);