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
|
// Copyright (c) 1996 James Clark
// See the file copying.txt for copying permission.
#ifndef ProcessContext_INCLUDED
#define ProcessContext_INCLUDED 1
#include "Resource.h"
#include "Ptr.h"
#include "Vector.h"
#include "NCVector.h"
#include "Owner.h"
#include "Collector.h"
#include "Style.h"
#include "FOTBuilder.h"
#include "ELObj.h"
#include "SosofoObj.h"
#include "VM.h"
#include "ProcessingMode.h"
#include "Link.h"
#include "IList.h"
#include "IQueue.h"
#ifdef DSSSL_NAMESPACE
namespace DSSSL_NAMESPACE {
#endif
class Expression;
class ProcessContext : public Collector::DynamicRoot {
public:
ProcessContext(Interpreter &, FOTBuilder &);
FOTBuilder ¤tFOTBuilder();
StyleStack ¤tStyleStack();
void process(const NodePtr &);
void processNode(const NodePtr &, const ProcessingMode *, bool chunk = 1);
void processNodeSafe(const NodePtr &, const ProcessingMode *, bool chunk = 1);
void nextMatch(StyleObj *);
void processChildren(const ProcessingMode *);
void processChildrenTrim(const ProcessingMode *);
void trace(Collector &) const;
void startFlowObj();
void endFlowObj();
// Uses of label: do this
void startConnection(SymbolObj *, const Location &);
void endConnection();
// happens only for objcet with a non-principal port
void pushPorts(bool hasPrincipalPort,
const Vector<SymbolObj *> &ports, const Vector<FOTBuilder *> &fotbs);
void popPorts();
// happens inside pushPorts() (if any)
void startMapContent(ELObj *, const Location &);
void endMapContent();
void startDiscardLabeled(SymbolObj *);
void endDiscardLabeled();
// table support
void startTable();
void endTable();
void startTablePart();
void endTablePart();
void addTableColumn(unsigned columnIndex, unsigned span, StyleObj *);
unsigned currentTableColumn();
void noteTableCell(unsigned colIndex, unsigned colSpan, unsigned rowSpan);
StyleObj *tableColumnStyle(unsigned columnIndex, unsigned span);
StyleObj *tableRowStyle();
void startTableRow(StyleObj *);
bool inTable() const;
bool inTableRow();
void endTableRow();
void clearPageType();
void setPageType(unsigned);
bool getPageType(unsigned &) const;
VM &vm();
private:
ProcessContext(const ProcessContext &); // undefined
void operator=(const ProcessContext &); // undefined
void badContentMap(bool &, const Location &);
void coverSpannedRows();
void restoreConnection(unsigned connectableLevel, size_t portIndex);
struct Port {
Port();
FOTBuilder *fotb;
IQueue<SaveFOTBuilder> saveQueue;
Vector<SymbolObj *> labels;
unsigned connected;
};
// A flow object with a port that can be connected to.
struct Connectable;
friend struct Connectable;
struct Connectable : public Link {
Connectable(int nPorts, const StyleStack &, unsigned);
NCVector<Port> ports;
StyleStack styleStack;
unsigned flowObjLevel;
Vector<SymbolObj *> principalPortLabels;
};
// An connection between a flow object and its flow parent
// made with label:.
struct Connection;
friend struct Connection;
struct Connection : public Link {
Connection(FOTBuilder *);
Connection(const StyleStack &, Port *, unsigned connectableLevel);
FOTBuilder *fotb;
StyleStack styleStack;
Port *port;
unsigned connectableLevel;
unsigned nBadFollow;
};
struct Table : public Link {
Table();
unsigned currentColumn;
// first index is column (zero-based)
// second is span - 1.
Vector<Vector<StyleObj *> > columnStyles;
// for each column, how many rows are covered
// starting with the current row
Vector<unsigned> covered;
unsigned nColumns;
StyleObj *rowStyle;
bool inTableRow;
unsigned rowConnectableLevel;
};
struct NodeStackEntry {
unsigned long elementIndex;
unsigned groveIndex;
const ProcessingMode *processingMode;
};
FOTBuilder ignoreFotb_;
IList<Connection> connectionStack_;
IList<Connectable> connectableStack_;
unsigned connectableStackLevel_;
IList<Table> tableStack_;
NCVector<IQueue<SaveFOTBuilder> > principalPortSaveQueues_;
VM vm_;
ProcessingMode::Specificity matchSpecificity_;
unsigned flowObjLevel_;
bool havePageType_;
unsigned pageType_;
Vector<NodeStackEntry> nodeStack_;
friend class CurrentNodeSetter;
friend struct Table;
};
inline
FOTBuilder &ProcessContext::currentFOTBuilder()
{
return *connectionStack_.head()->fotb;
}
inline
StyleStack &ProcessContext::currentStyleStack()
{
return connectionStack_.head()->styleStack;
}
inline
VM &ProcessContext::vm()
{
return vm_;
}
inline
void ProcessContext::startFlowObj()
{
flowObjLevel_++;
}
inline
void ProcessContext::setPageType(unsigned n)
{
havePageType_ = 1;
pageType_ = n;
}
inline
void ProcessContext::clearPageType()
{
havePageType_ = 0;
}
inline
bool ProcessContext::getPageType(unsigned &n) const
{
if (!havePageType_)
return 0;
n = pageType_;
return 1;
}
inline
bool ProcessContext::inTable() const
{
return !tableStack_.empty();
}
#ifdef DSSSL_NAMESPACE
}
#endif
#endif /* not ProcessContext_INCLUDED */
|