2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 // $XConsortium: Tml_TextRenderer.C /main/7 1996/09/10 16:03:56 cde-hal $
24 /* Copyright (c) 1995,1996 FUJITSU LIMITED */
25 /* All Rights Reserved */
29 #include "Tml_TextRenderer.hh"
30 #include "DtSR_SearchZones.hh"
32 #include "StyleSheet/FeatureValue.h"
34 Tml_TextRenderer::Tml_TextRenderer(ostringstream &ostr, UAS_SearchZones &zones) :
35 f_ostr(ostr), f_zones(zones), f_current_level(0)
39 Tml_TextRenderer::~Tml_TextRenderer()
44 Tml_TextRenderer::initialize()
46 // NOTE: You don't have to keep track of default_features.
47 // Resolver will take care of the rest (i.e. delete).
48 FeatureSet* default_features = new FeatureSet;
50 default_features->add(new Feature(gSymTab->intern("IGNORE"),
51 new FeatureValueInt(0)));
53 return default_features;
57 Tml_TextRenderer::Begin()
61 for (; f_marked_level.entries(); f_marked_level.pop());
62 f_marked_level.push(f_current_level);
64 for (; f_effect.entries(); f_effect.pop());
67 if (effective_zone(DtSR_SearchZones::uas_bodies))
68 base_effect = ShiftIn;
70 base_effect = ShiftOut;
72 f_effect.push(base_effect);
73 f_ostr << f_effect.top();
75 f_ignore_stack.push(0);
79 Tml_TextRenderer::End()
83 if (f_ignore_stack.entries())
88 Tml_TextRenderer::effective_zone(UAS_SearchZones::uas_zones zone)
91 case UAS_SearchZones::uas_titles :
92 return f_zones.titles();
94 case UAS_SearchZones::uas_bodies :
95 return f_zones.bodies();
97 case UAS_SearchZones::uas_examples :
98 return f_zones.examples();
100 case UAS_SearchZones::uas_indexes :
101 return f_zones.indexes();
103 case UAS_SearchZones::uas_tables :
104 return f_zones.tables();
106 case UAS_SearchZones::uas_graphics :
107 return f_zones.graphics();
110 fprintf(stderr, "(ERROR) unknown zone found\n");
118 Tml_TextRenderer::BeginElement(const Element &element,
119 const FeatureSet&, const FeatureSet& complete,
124 const Attribute *scope_attr =
125 element.get_attribute(gSymTab->intern("OLIAS.SCOPE"));
127 if (scope_attr) { // scope attribute specified
129 f_marked_level.push(f_current_level);
132 fprintf(stderr, "(DEBUG) %s specifies OLIAS.SCOPE=\"%s\"\n",
133 element.gi().name(), scope_attr->value());
136 if (effective_zone(DtSR_SearchZones::
137 zonename2zone(scope_attr->value()))) {
144 f_effect.push(effect);
145 f_ostr << f_effect.top();
148 const Attribute *terms_attr =
149 element.get_olias_attribute(gSymTab->intern("TERMS"));
151 CC_TPtrSlistIterator<Feature> iter(*(FeatureSet*)&complete);
153 const Symbol &feature = iter.key()->name();
154 if (feature == gSymTab->intern("IGNORE")) {
155 Feature *ignore = iter.key();
156 f_ignore_stack.push((int)*(ignore->value()));
161 const char* terms = terms_attr->value();
162 f_ostr << terms << '\n';
170 Tml_TextRenderer::EndElement(const Symbol &)
174 if (f_current_level == f_marked_level.top()) {
177 f_ostr << f_effect.top();
179 f_marked_level.pop();
184 if (f_ignore_stack.entries())
185 f_ignore_stack.pop();
189 Tml_TextRenderer::data(const char *data, unsigned int)
191 if (! f_ignore_stack.top())