1 // Copyright (c) 1996 James Clark
2 // See the file copying.txt for copying permission.
4 #ifndef ProcessContext_INCLUDED
5 #define ProcessContext_INCLUDED 1
12 #include "Collector.h"
14 #include "FOTBuilder.h"
16 #include "SosofoObj.h"
18 #include "ProcessingMode.h"
23 #ifdef DSSSL_NAMESPACE
24 namespace DSSSL_NAMESPACE {
29 class ProcessContext : public Collector::DynamicRoot {
31 ProcessContext(Interpreter &, FOTBuilder &);
32 FOTBuilder ¤tFOTBuilder();
33 StyleStack ¤tStyleStack();
34 void process(const NodePtr &);
35 void processNode(const NodePtr &, const ProcessingMode *, bool chunk = 1);
36 void processNodeSafe(const NodePtr &, const ProcessingMode *, bool chunk = 1);
37 void nextMatch(StyleObj *);
38 void processChildren(const ProcessingMode *);
39 void processChildrenTrim(const ProcessingMode *);
40 void trace(Collector &) const;
43 // Uses of label: do this
44 void startConnection(SymbolObj *, const Location &);
46 // happens only for object with a non-principal port
47 void pushPorts(bool hasPrincipalPort,
48 const Vector<SymbolObj *> &ports, const Vector<FOTBuilder *> &fotbs);
50 void pushPrincipalPort(FOTBuilder* principalPort);
51 void popPrincipalPort();
52 // happens inside pushPorts() (if any)
53 void startMapContent(ELObj *, const Location &);
55 void startDiscardLabeled(SymbolObj *);
56 void endDiscardLabeled();
60 void startTablePart();
62 void addTableColumn(unsigned columnIndex, unsigned span, StyleObj *);
63 unsigned currentTableColumn();
64 void noteTableCell(unsigned colIndex, unsigned colSpan, unsigned rowSpan);
65 StyleObj *tableColumnStyle(unsigned columnIndex, unsigned span);
66 StyleObj *tableRowStyle();
67 void startTableRow(StyleObj *);
72 void setPageType(unsigned);
73 bool getPageType(unsigned &) const;
77 ProcessContext(const ProcessContext &); // undefined
78 void operator=(const ProcessContext &); // undefined
79 void badContentMap(bool &, const Location &);
80 void coverSpannedRows();
81 void restoreConnection(unsigned connectableLevel, size_t portIndex);
85 IQueue<SaveFOTBuilder> saveQueue;
86 Vector<SymbolObj *> labels;
89 // A flow object with a port that can be connected to.
91 friend struct Connectable;
92 struct Connectable : public Link {
93 Connectable(int nPorts, const StyleStack &, unsigned);
95 StyleStack styleStack;
96 unsigned flowObjLevel;
97 Vector<SymbolObj *> principalPortLabels;
99 // An connection between a flow object and its flow parent
102 friend struct Connection;
103 struct Connection : public Link {
104 Connection(FOTBuilder *);
105 Connection(const StyleStack &, Port *, unsigned connectableLevel);
107 StyleStack styleStack;
109 unsigned connectableLevel;
112 struct Table : public Link {
114 unsigned currentColumn;
115 // first index is column (zero-based)
116 // second is span - 1.
117 Vector<Vector<StyleObj *> > columnStyles;
118 // for each column, how many rows are covered
119 // starting with the current row
120 Vector<unsigned> covered;
124 unsigned rowConnectableLevel;
126 struct NodeStackEntry {
127 unsigned long elementIndex;
129 const ProcessingMode *processingMode;
131 FOTBuilder ignoreFotb_;
132 IList<Connection> connectionStack_;
133 IList<Connectable> connectableStack_;
134 unsigned connectableStackLevel_;
135 IList<Table> tableStack_;
136 NCVector<IQueue<SaveFOTBuilder> > principalPortSaveQueues_;
138 ProcessingMode::Specificity matchSpecificity_;
139 unsigned flowObjLevel_;
142 Vector<NodeStackEntry> nodeStack_;
143 friend class CurrentNodeSetter;
148 FOTBuilder &ProcessContext::currentFOTBuilder()
150 return *connectionStack_.head()->fotb;
154 StyleStack &ProcessContext::currentStyleStack()
156 return connectionStack_.head()->styleStack;
160 VM &ProcessContext::vm()
166 void ProcessContext::startFlowObj()
172 void ProcessContext::setPageType(unsigned n)
179 void ProcessContext::clearPageType()
185 bool ProcessContext::getPageType(unsigned &n) const
194 bool ProcessContext::inTable() const
196 return !tableStack_.empty();
199 #ifdef DSSSL_NAMESPACE
203 #endif /* not ProcessContext_INCLUDED */