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 librararies 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: Resolver.C /main/5 1996/10/08 19:26:17 cde-hal $
26 #include "ResolverStack.h"
27 #include "PathTable.h"
31 #include "HardCopy/autoNumberFP.h"
33 extern const Element *gCurrentElement ;
34 extern const FeatureSet *gCurrentLocalSet;
35 extern const FeatureSet *gParentCompleteSet;
37 Resolver::Resolver(PathTable& pTable, Renderer& r)
38 : f_pathTable(pTable),
42 // have the Renderer install its default values as the bottom item on the
44 FeatureSet *default_features = f_Renderer.initialize();
46 ResolverStackElement *default_element =
47 new ResolverStackElement(new Element(gSymTab->intern("!"),0 , 0, 0),
51 f_resolverStack.push(default_element);
61 // can do any node pre-processing here
68 // can do any node post-processing here
70 gAutoNumberFP.resetAllAutoNumbers();
74 Resolver::beginElement(Element *element)
76 //ON_DEBUG(element -> print(cerr));
78 // get raw feature set
79 f_path.append(new PathTerm(*element));
80 FeatureSet *rawLocalFeatureSet = f_pathTable.getFeatureSet(f_path);
83 ResolverStackElement* parent = f_resolverStack.top();
86 // when rawLocalFeatureSet != 0 to call f_Renderer.preEvaluate is
87 // too restrictive. Comment out
89 //if (rawLocalFeatureSet)
90 gAutoNumberFP.beginElement(*element);
92 FeatureSet *localFeatureSet = new FeatureSet;
94 gCurrentElement = element ;
95 gCurrentLocalSet = localFeatureSet ;
96 gParentCompleteSet = &parent->completeFeatureSet() ;
98 //ON_DEBUG(cerr << "Path: " << f_path << endl);
99 if (rawLocalFeatureSet)
101 // ON_DEBUG(cerr << "rawLocalFeatureSet: " << *rawLocalFeatureSet << endl);
103 localFeatureSet = rawLocalFeatureSet->evaluate(localFeatureSet);
105 // ON_DEBUG(cerr << "localFeatureSet: " << *localFeatureSet << endl);
109 // when rawLocalFeatureSet != 0 to call f_Renderer.postEvaluate is
110 // too restrictive. Comment out
112 //if (rawLocalFeatureSet)
114 // need to create a complete feature set for current element
115 // set is Sl U (Spc - Sl)
116 FeatureSet *completeFeatureSet = new
117 FeatureSet(parent->completeFeatureSet(),
120 // add current element to top of stack
121 f_resolverStack.push(
122 new ResolverStackElement(element,
127 // tell renderer about new element
128 unsigned int ignore = f_Renderer.BeginElement(*element, *localFeatureSet,
130 parent->completeFeatureSet());
134 gAutoNumberFP.endElement(element->gi());
136 // clean up stack and path
137 delete f_resolverStack.pop();
138 delete f_path.removeLast();
144 void Resolver::data(const char* data, unsigned int data_length)
147 f_Renderer.data(data, data_length);
150 void Resolver::endElement(const Symbol& s)
152 // NOTE: may want to pass top of stack to renderer for post element
155 gAutoNumberFP.endElement(s);
157 f_Renderer.EndElement(s); // pass through
158 delete f_resolverStack.pop(); // pop stack
159 delete f_path.removeLast(); // remove item from path