w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

letterformat.c
Go to the documentation of this file.
1 /* letterformat.c - LaTeX commands specific to the letter format
2 
3 Copyright (C) 2001-2002 The Free Software Foundation
4 
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 This file is available from http://sourceforge.net/projects/latex2rtf/
20 
21 Authors:
22  2001-2002 Scott Prahl
23 */
24 
25 #include <stdlib.h>
26 #include <string.h>
27 #include "main.h"
28 #include "parser.h"
29 #include "letterformat.h"
30 #include "cfg.h"
31 #include "commands.h"
32 #include "funct1.h"
33 #include "convert.h"
34 
35 static bool g_letterOpened = FALSE; /* true after \opening */
36 
37 static char * g_letterToAddress = NULL;
38 static char * g_letterReturnAddress= NULL;
39 static char * g_letterSignature = NULL;
40 
41 void
43 /******************************************************************************
44  purpose: saves the signature in the letter document style
45  Use in the preamble or between \begin{letter} and \opening
46  ******************************************************************************/
47 {
48  if (g_letterSignature)
51 }
52 
53 void
55 /******************************************************************************
56  purpose: saves the address in the letter document style
57  Use in the preamble or between \begin{letter} and \opening
58  ******************************************************************************/
59 {
63 }
64 
65 void
67 /******************************************************************************
68  purpose: pushes all necessary letter-commands on a stack
69 parameter: code: on/off-option for environment
70  ******************************************************************************/
71 {
72  if (code & ON) {
74  if (g_letterToAddress)
77  } else {
79  }
80 }
81 
82 void
84 /******************************************************************************
85  purpose: /opening{Dear...} prints return address, Date, to address and opening
86  ******************************************************************************/
87 {
88  char oldalignment;
89  char *s;
90 
91 /* put return address and date at the top right */
93  oldalignment=alignment;
94  alignment = RIGHT;
95  fprintRTF("\n\\par\\pard\\q%c ", alignment);
96  diagnostics(5, "Entering ConvertString() from CmdAddress");
98  diagnostics(5, "Exiting ConvertString() from CmdAddress");
99 
100 /* put the date on the right */
101  fprintRTF("\\par\\chdate ");
102 
103 /* put addressee on the left */
104  alignment = LEFT;
105  fprintRTF("\n\\par\\pard\\q%c ", alignment);
106  diagnostics(4, "Entering Convert() from CmdOpening");
108  diagnostics(4, "Exiting Convert() from CmdOpening");
109 
110 /* finally print the opening*/
111  s = getBraceParam();
112  ConvertString(s);
113  free(s);
114 
115  alignment = oldalignment;
116  fprintRTF("\n\\par\\pard\\q%c ", alignment);
117 }
118 
119 void
120 CmdClosing( /* @unused@ */ int code)
121 /******************************************************************************
122  purpose: special command in the LaTex-letter-environment will be converted to a
123  similar Rtf-style
124  globals: alignment
125  ******************************************************************************/
126 {
127  char oldalignment;
128  char *s;
129 
130  oldalignment = alignment;
131 
132 /* print closing on the right */
133  alignment = RIGHT;
134  fprintRTF("\n\\par\\pard\\q%c ", alignment);
135  diagnostics(5, "Entering ConvertString() from CmdClosing");
136  s = getBraceParam();
137  ConvertString(s);
138  free(s);
139  diagnostics(5, "Exiting ConvertString() from CmdClosing");
140 
141 /* print signature a couple of lines down */
142  fprintRTF("\n\\par\\par\\par ");
143 
144  diagnostics(5, "Entering ConvertString() from CmdSignature");
146  diagnostics(5, "Exiting ConvertString() from CmdSignature");
147 
149  alignment = oldalignment;
150  fprintRTF("\n\\par\\pard\\q%c ", alignment);
151 }
152 
153 void
155 /******************************************************************************
156  purpose: translate encl and cc into appropriate language
157  ******************************************************************************/
158 {
159  char * s = getBraceParam();
160 
161  if (code == LETTER_ENCL)
162  ConvertBabelName("ENCLNAME");
163  else if (code == LETTER_CC)
164  ConvertBabelName("CCNAME");
165 
166  ConvertString(s);
167  free(s);
168 }
169 
void ConvertBabelName(char *name)
Definition: cfg.c:429
@ FALSE
Definition: dd.h:101
@ TRUE
Definition: dd.h:102
#define free(a)
Definition: decNumber.cpp:310
#define s
Definition: afcover.h:80
#define NULL
Definition: ftobjs.h:61
void PushEnvironment(int code)
Definition: commands.c:812
void PopEnvironment()
Definition: commands.c:903
#define LETTER
Definition: commands.h:8
void ConvertString(char *string)
Definition: convert.c:103
void diagnostics(int level, char *format,...)
Definition: main.c:469
void fprintRTF(char *format,...)
Definition: main.c:722
char alignment
Definition: main.c:119
char * getBraceParam(void)
void CmdLetter(int code)
Definition: letterformat.c:66
static bool g_letterOpened
Definition: letterformat.c:35
static char * g_letterReturnAddress
Definition: letterformat.c:38
static char * g_letterSignature
Definition: letterformat.c:39
void CmdPs(int code)
Definition: letterformat.c:154
void CmdAddress(int code)
Definition: letterformat.c:54
void CmdSignature(int code)
Definition: letterformat.c:42
void CmdOpening(int code)
Definition: letterformat.c:83
void CmdClosing(int code)
Definition: letterformat.c:120
static char * g_letterToAddress
Definition: letterformat.c:37
#define LETTER_ENCL
Definition: letterformat.h:3
#define LETTER_CC
Definition: letterformat.h:2
@ LEFT
Definition: pl-parser.h:48
@ RIGHT
Definition: pl-parser.h:49
Definition: inftrees.h:24
@ ON
Definition: ubidiimp.h:55