aboutsummaryrefslogtreecommitdiffstats
path: root/doc/api-documentation/html/markupfiltmgr_8cpp-source.html
blob: d1934ab8932c0e7b33bcadfa0525a2bd46c68218 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>markupfiltmgr.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.15 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </center>
<hr><h1>markupfiltmgr.cpp</h1><div class="fragment"><pre>00001 <font class="comment">/******************************************************************************</font>
00002 <font class="comment"> *  swmarkupmgr.cpp   - implementaion of class MarkupFilterMgr, subclass of</font>
00003 <font class="comment"> *                        used to transcode all module text to a requested</font>
00004 <font class="comment"> *                        markup.</font>
00005 <font class="comment"> *</font>
00006 <font class="comment"> * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)</font>
00007 <font class="comment"> *      CrossWire Bible Society</font>
00008 <font class="comment"> *      P. O. Box 2528</font>
00009 <font class="comment"> *      Tempe, AZ  85280-2528</font>
00010 <font class="comment"> *</font>
00011 <font class="comment"> * This program is free software; you can redistribute it and/or modify it</font>
00012 <font class="comment"> * under the terms of the GNU General Public License as published by the</font>
00013 <font class="comment"> * Free Software Foundation version 2.</font>
00014 <font class="comment"> *</font>
00015 <font class="comment"> * This program is distributed in the hope that it will be useful, but</font>
00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</font>
00018 <font class="comment"> * General Public License for more details.</font>
00019 <font class="comment"> *</font>
00020 <font class="comment"> */</font>
00021 
00022 <font class="preprocessor">#include &lt;thmlplain.h&gt;</font>
00023 <font class="preprocessor">#include &lt;gbfplain.h&gt;</font>
00024 <font class="preprocessor">#include &lt;thmlgbf.h&gt;</font>
00025 <font class="preprocessor">#include &lt;gbfthml.h&gt;</font>
00026 <font class="preprocessor">#include &lt;thmlhtml.h&gt;</font>
00027 <font class="preprocessor">#include &lt;gbfhtml.h&gt;</font>
00028 <font class="preprocessor">#include &lt;plainhtml.h&gt;</font>
00029 <font class="preprocessor">#include &lt;thmlhtmlhref.h&gt;</font>
00030 <font class="preprocessor">#include &lt;gbfhtmlhref.h&gt;</font>
00031 <font class="preprocessor">#include &lt;thmlrtf.h&gt;</font>
00032 <font class="preprocessor">#include &lt;gbfrtf.h&gt;</font>
00033 <font class="preprocessor">#include &lt;gbfosis.h&gt;</font>
00034 <font class="preprocessor">#include &lt;thmlosis.h&gt;</font>
00035 
00036 <font class="preprocessor">#include &lt;markupfiltmgr.h&gt;</font>
00037 
00038 <font class="preprocessor">#include &lt;swmgr.h&gt;</font>
00039 
00040 
00041 <font class="comment">/******************************************************************************</font>
00042 <font class="comment"> * MarkupFilterMgr Constructor - initializes instance of MarkupFilterMgr</font>
00043 <font class="comment"> *</font>
00044 <font class="comment"> * ENT:</font>
00045 <font class="comment"> *      enc - Encoding format to emit</font>
00046 <font class="comment"> *      mark - Markup format to emit</font>
00047 <font class="comment"> */</font>
00048 
<a name="l00049"></a><a class="code" href="class_markup_filter_mgr.html#a0">00049</a> <a class="code" href="class_markup_filter_mgr.html#a0">MarkupFilterMgr::MarkupFilterMgr</a> (<font class="keywordtype">char</font> mark, <font class="keywordtype">char</font> enc)
00050                    : <a class="code" href="class_encoding_filter_mgr.html">EncodingFilterMgr</a>(enc) {
00051 
00052         markup = mark;
00053 
00054         CreateFilters(markup);
00055 }
00056 
00057 
00058 <font class="comment">/******************************************************************************</font>
00059 <font class="comment"> * MarkupFilterMgr Destructor - Cleans up instance of MarkupFilterMgr</font>
00060 <font class="comment"> */</font>
00061 
<a name="l00062"></a><a class="code" href="class_markup_filter_mgr.html#a1">00062</a> <a class="code" href="class_markup_filter_mgr.html#a1">MarkupFilterMgr::~MarkupFilterMgr</a>() {
00063         <font class="keywordflow">if</font> (fromthml)
00064                 <font class="keyword">delete</font> (fromthml);
00065         <font class="keywordflow">if</font> (fromgbf)
00066                 <font class="keyword">delete</font> (fromgbf);
00067         <font class="keywordflow">if</font> (fromplain)
00068                 <font class="keyword">delete</font> (fromplain);
00069         <font class="keywordflow">if</font> (fromosis)
00070                 <font class="keyword">delete</font> (fromosis);
00071 }
00072 
00073 <font class="comment">/******************************************************************************</font>
00074 <font class="comment"> * MarkupFilterMgr::Markup      - sets/gets markup</font>
00075 <font class="comment"> *</font>
00076 <font class="comment"> * ENT: mark    - new encoding or 0 to simply get the current markup</font>
00077 <font class="comment"> *</font>
00078 <font class="comment"> * RET: markup</font>
00079 <font class="comment"> */</font>
<a name="l00080"></a><a class="code" href="class_markup_filter_mgr.html#a2">00080</a> <font class="keywordtype">char</font> <a class="code" href="class_markup_filter_mgr.html#a2">MarkupFilterMgr::Markup</a>(<font class="keywordtype">char</font> mark) {
00081         <font class="keywordflow">if</font> (mark &amp;&amp; mark != markup) {
00082                 markup = mark;
00083                 ModMap::const_iterator module;
00084 
00085                 SWFilter * oldplain = fromplain;
00086                 SWFilter * oldthml = fromthml;
00087                 SWFilter * oldgbf = fromgbf;
00088                 SWFilter * oldosis = fromosis;
00089 
00090                 CreateFilters(markup);
00091 
00092                 <font class="keywordflow">for</font> (module = getParentMgr()-&gt;Modules.begin(); module != getParentMgr()-&gt;Modules.end(); module++)
00093                         <font class="keywordflow">switch</font> (module-&gt;second-&gt;Markup()) {
00094                         <font class="keywordflow">case</font> FMT_THML:
00095                                 <font class="keywordflow">if</font> (oldthml != fromthml) {
00096                                         <font class="keywordflow">if</font> (oldthml) {
00097                                                 <font class="keywordflow">if</font> (!fromthml) {
00098                                                         module-&gt;second-&gt;RemoveRenderFilter(oldthml);
00099                                                 }
00100                                                 <font class="keywordflow">else</font> {
00101                                                         module-&gt;second-&gt;ReplaceRenderFilter(oldthml, fromthml);
00102                                                 }
00103                                         }
00104                                         <font class="keywordflow">else</font> <font class="keywordflow">if</font> (fromthml) {
00105                                                 module-&gt;second-&gt;AddRenderFilter(fromthml);
00106                                         }
00107                                 }
00108                                 <font class="keywordflow">break</font>;
00109                         <font class="keywordflow">case</font> FMT_GBF:
00110                                 <font class="keywordflow">if</font> (oldgbf != fromgbf) {
00111                                         <font class="keywordflow">if</font> (oldgbf) {
00112                                                 <font class="keywordflow">if</font> (!fromgbf) {
00113                                                         module-&gt;second-&gt;RemoveRenderFilter(oldgbf);
00114                                                 }
00115                                                 <font class="keywordflow">else</font> {
00116                                                         module-&gt;second-&gt;ReplaceRenderFilter(oldgbf, fromgbf);
00117                                                 }
00118                                         }
00119                                         <font class="keywordflow">else</font> <font class="keywordflow">if</font> (fromgbf) {
00120                                                 module-&gt;second-&gt;AddRenderFilter(fromgbf);
00121                                         }
00122                                         <font class="keywordflow">break</font>;
00123                                 }
00124                         <font class="keywordflow">case</font> FMT_PLAIN:
00125                                 <font class="keywordflow">if</font> (oldplain != fromplain) {
00126                                         <font class="keywordflow">if</font> (oldplain) {
00127                                                 <font class="keywordflow">if</font> (!fromplain) {
00128                                                         module-&gt;second-&gt;RemoveRenderFilter(oldplain);
00129                                                 }
00130                                                 <font class="keywordflow">else</font> {
00131                                                         module-&gt;second-&gt;ReplaceRenderFilter(oldplain, fromplain);
00132                                                 }
00133                                         }
00134                                         <font class="keywordflow">else</font> <font class="keywordflow">if</font> (fromplain) {
00135                                                 module-&gt;second-&gt;AddRenderFilter(fromplain);
00136                                         }
00137                                         <font class="keywordflow">break</font>;
00138                                 }
00139                         <font class="keywordflow">case</font> FMT_OSIS:
00140                                 <font class="keywordflow">if</font> (oldosis != fromosis) {
00141                                         <font class="keywordflow">if</font> (oldosis) {
00142                                                 <font class="keywordflow">if</font> (!fromosis) {
00143                                                         module-&gt;second-&gt;RemoveRenderFilter(oldosis);
00144                                                 }
00145                                                 <font class="keywordflow">else</font> {
00146                                                         module-&gt;second-&gt;ReplaceRenderFilter(oldosis, fromosis);
00147                                                 }
00148                                         }
00149                                         <font class="keywordflow">else</font> <font class="keywordflow">if</font> (fromosis) {
00150                                                 module-&gt;second-&gt;AddRenderFilter(fromosis);
00151                                         }
00152                                         <font class="keywordflow">break</font>;
00153                                 }
00154                         }
00155 
00156                 <font class="keywordflow">if</font> (oldthml)
00157                         <font class="keyword">delete</font> oldthml;
00158                 <font class="keywordflow">if</font> (oldgbf)
00159                         <font class="keyword">delete</font> oldgbf;
00160                 <font class="keywordflow">if</font> (oldplain)
00161                         <font class="keyword">delete</font> oldplain;
00162                 <font class="keywordflow">if</font> (oldosis)
00163                         <font class="keyword">delete</font> oldosis;
00164         }
00165         <font class="keywordflow">return</font> markup;
00166 }
00167 
<a name="l00168"></a><a class="code" href="class_markup_filter_mgr.html#a3">00168</a> <font class="keywordtype">void</font> <a class="code" href="class_markup_filter_mgr.html#a3">MarkupFilterMgr::AddRenderFilters</a>(<a class="code" href="class_s_w_module.html">SWModule</a> *module, ConfigEntMap &amp;section) {
00169         <font class="keywordflow">switch</font> (module-&gt;<a class="code" href="class_s_w_module.html#a20">Markup</a>()) {
00170         <font class="keywordflow">case</font> FMT_THML:
00171                 <font class="keywordflow">if</font> (fromthml)
00172                         module-&gt;<a class="code" href="class_s_w_module.html#a41">AddRenderFilter</a>(fromthml);
00173                 <font class="keywordflow">break</font>;
00174         <font class="keywordflow">case</font> FMT_GBF:
00175                 <font class="keywordflow">if</font> (fromgbf)
00176                         module-&gt;<a class="code" href="class_s_w_module.html#a41">AddRenderFilter</a>(fromgbf);
00177                 <font class="keywordflow">break</font>;
00178         <font class="keywordflow">case</font> FMT_PLAIN:
00179                 <font class="keywordflow">if</font> (fromplain)
00180                         module-&gt;<a class="code" href="class_s_w_module.html#a41">AddRenderFilter</a>(fromplain);
00181                 <font class="keywordflow">break</font>;
00182         <font class="keywordflow">case</font> FMT_OSIS:
00183                 <font class="keywordflow">if</font> (fromosis)
00184                         module-&gt;<a class="code" href="class_s_w_module.html#a41">AddRenderFilter</a>(fromosis);
00185                 <font class="keywordflow">break</font>;
00186         }
00187 }
00188 
00189 <font class="keywordtype">void</font> MarkupFilterMgr::CreateFilters(<font class="keywordtype">char</font> markup) {
00190 
00191                 <font class="keywordflow">switch</font> (markup) {
00192                 <font class="keywordflow">case</font> FMT_PLAIN:
00193                         fromplain = NULL;
00194                         fromthml = <font class="keyword">new</font> <a class="code" href="class_th_m_l_plain.html">ThMLPlain</a>();
00195                         fromgbf = <font class="keyword">new</font> <a class="code" href="class_g_b_f_plain.html">GBFPlain</a>();
00196                         fromosis = NULL;
00197                         <font class="keywordflow">break</font>;
00198                 <font class="keywordflow">case</font> FMT_THML:
00199                         fromplain = NULL;
00200                         fromthml = NULL;
00201                         fromgbf = <font class="keyword">new</font> <a class="code" href="class_g_b_f_th_m_l.html">GBFThML</a>();
00202                         fromosis = NULL;
00203                         <font class="keywordflow">break</font>;
00204                 <font class="keywordflow">case</font> FMT_GBF:
00205                         fromplain = NULL;
00206                         fromthml = <font class="keyword">new</font> <a class="code" href="class_th_m_l_g_b_f.html">ThMLGBF</a>();
00207                         fromgbf = NULL;
00208                         fromosis = NULL;
00209                         <font class="keywordflow">break</font>;
00210                 <font class="keywordflow">case</font> FMT_HTML:
00211                         fromplain = <font class="keyword">new</font> <a class="code" href="class_p_l_a_i_n_h_t_m_l.html">PLAINHTML</a>();
00212                         fromthml = <font class="keyword">new</font> <a class="code" href="class_th_m_l_h_t_m_l.html">ThMLHTML</a>();
00213                         fromgbf = <font class="keyword">new</font> <a class="code" href="class_g_b_f_h_t_m_l.html">GBFHTML</a>();
00214                         fromosis = NULL;
00215                         <font class="keywordflow">break</font>;
00216                 <font class="keywordflow">case</font> FMT_HTMLHREF:
00217                         fromplain = NULL;
00218                         fromthml = <font class="keyword">new</font> <a class="code" href="class_th_m_l_h_t_m_l_h_r_e_f.html">ThMLHTMLHREF</a>();
00219                         fromgbf = <font class="keyword">new</font> <a class="code" href="class_g_b_f_h_t_m_l_h_r_e_f.html">GBFHTMLHREF</a>();
00220                         fromosis = NULL;
00221                         <font class="keywordflow">break</font>;
00222                 <font class="keywordflow">case</font> FMT_RTF:
00223                         fromplain = NULL;
00224                         fromthml = <font class="keyword">new</font> <a class="code" href="class_th_m_l_r_t_f.html">ThMLRTF</a>();
00225                         fromgbf = <font class="keyword">new</font> <a class="code" href="class_g_b_f_r_t_f.html">GBFRTF</a>();
00226                         fromosis = NULL;
00227                         <font class="keywordflow">break</font>;
00228                 <font class="keywordflow">case</font> FMT_OSIS:
00229                         fromplain = NULL;
00230                         fromthml = <font class="keyword">new</font> <a class="code" href="class_th_m_l_o_s_i_s.html">ThMLOSIS</a>();
00231                         fromgbf = <font class="keyword">new</font> <a class="code" href="class_g_b_f_o_s_i_s.html">GBFOSIS</a>();
00232                         fromosis = NULL;
00233                         <font class="keywordflow">break</font>;
00234                 }
00235 
00236 }
</pre></div><hr><address align="right"><small>Generated on Thu Jun 20 22:12:59 2002 for The Sword Project by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 
width=110 height=53></a>1.2.15 </small></address>
</body>
</html>