Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / StyleSheet / Resolver.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 // $XConsortium: Resolver.C /main/5 1996/10/08 19:26:17 cde-hal $
24 #include "Debug.h"
25 #include "Resolver.h"
26 #include "ResolverStack.h"
27 #include "PathTable.h"
28 #include "Renderer.h"
29 #include "Element.h"
30 #include "Feature.h"
31 #include "HardCopy/autoNumberFP.h"
32
33 extern const Element           *gCurrentElement ;
34 extern const FeatureSet        *gCurrentLocalSet;
35 extern const FeatureSet        *gParentCompleteSet;
36
37 Resolver::Resolver(PathTable& pTable, Renderer& r)
38 : f_pathTable(pTable),
39   f_Renderer(r),
40   f_resolverStack()
41 {
42   // have the Renderer install its default values as the bottom item on the
43   // Stack  
44   FeatureSet *default_features = f_Renderer.initialize();
45
46   ResolverStackElement *default_element =
47     new ResolverStackElement(new Element(gSymTab->intern("!"),0 , 0, 0),
48                              0,
49                              default_features);
50                              
51   f_resolverStack.push(default_element);
52 }
53
54 Resolver::~Resolver()
55 {
56 }
57    
58 void
59 Resolver::Begin()
60 {
61   // can do any node pre-processing here 
62   f_Renderer.Begin();
63 }
64
65 void
66 Resolver::End()
67 {
68   // can do any node post-processing here 
69   f_Renderer.End();
70   gAutoNumberFP.resetAllAutoNumbers();
71 }
72
73 unsigned int
74 Resolver::beginElement(Element *element)
75 {
76 //ON_DEBUG(element -> print(cerr));
77
78   // get raw feature set 
79   f_path.append(new PathTerm(*element));
80   FeatureSet *rawLocalFeatureSet = f_pathTable.getFeatureSet(f_path);
81
82   // get parent details 
83   ResolverStackElement* parent = f_resolverStack.top();
84
85 // qifc:
86 // when rawLocalFeatureSet != 0 to call f_Renderer.preEvaluate is
87 // too restrictive. Comment out
88 //
89   //if (rawLocalFeatureSet)
90   gAutoNumberFP.beginElement(*element);
91
92   FeatureSet *localFeatureSet = new FeatureSet;
93
94   gCurrentElement       = element ;
95   gCurrentLocalSet      = localFeatureSet ;
96   gParentCompleteSet    = &parent->completeFeatureSet() ;
97
98   //ON_DEBUG(cerr << "Path: " << f_path << endl);
99   if (rawLocalFeatureSet)
100     {
101 //     ON_DEBUG(cerr << "rawLocalFeatureSet: " << *rawLocalFeatureSet << endl);
102
103       localFeatureSet = rawLocalFeatureSet->evaluate(localFeatureSet);
104
105 //      ON_DEBUG(cerr << "localFeatureSet: " << *localFeatureSet << endl);
106     }
107
108 // qifc:
109 // when rawLocalFeatureSet != 0 to call f_Renderer.postEvaluate is
110 // too restrictive. Comment out
111 //
112   //if (rawLocalFeatureSet)
113
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(), 
118                *localFeatureSet);
119
120   // add current element to top of stack 
121   f_resolverStack.push(
122                        new ResolverStackElement(element,
123                                                 localFeatureSet, 
124                                                 completeFeatureSet)
125                        ); 
126
127   // tell renderer about new element 
128   unsigned int ignore = f_Renderer.BeginElement(*element, *localFeatureSet,
129                                                 *completeFeatureSet, 
130                                                 parent->completeFeatureSet());
131
132   if (ignore)
133     {
134       gAutoNumberFP.endElement(element->gi());
135
136       // clean up stack and path 
137       delete f_resolverStack.pop();
138       delete f_path.removeLast();
139     }
140
141   return ignore;
142 }
143    
144 void Resolver::data(const char* data, unsigned int data_length)
145 {
146   // pass through 
147   f_Renderer.data(data, data_length);
148 }
149    
150 void Resolver::endElement(const Symbol& s)
151 {
152   // NOTE: may want to pass top of stack to renderer for post element
153   // processing?  
154
155   gAutoNumberFP.endElement(s);
156
157   f_Renderer.EndElement(s);     // pass through 
158   delete f_resolverStack.pop(); // pop stack 
159   delete f_path.removeLast();   // remove item from path 
160 }