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: RastEventHandler.h /main/1 1996/07/29 17:02:31 cde-hp $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
27 #ifndef RastEventHandler_INCLUDED
28 #define RastEventHandler_INCLUDED 1
40 #include "OutputCharStream.h"
41 #include "LinkProcess.h"
45 #include "ErrorCountEventHandler.h"
51 namespace SP_NAMESPACE {
55 class ExternalDataEntity;
64 int operator()(Char c) const;
66 char v_[UCHAR_MAX + 1];
69 class RastEventHandler;
71 class RastLinkProcess : public LinkProcess {
74 void setHandler(RastEventHandler *);
75 Boolean selectLinkRule(const Vector<const AttributeList *> &linkAttributes,
76 const Location &location,
78 void swap(RastLinkProcess &);
80 Boolean selectLinkRulePi(const StringC &str,
82 const Vector<const AttributeList *> &linkAttributes,
85 RastLinkProcess(const RastLinkProcess &); // undefined
86 void operator=(RastLinkProcess &); // undefined
87 RastEventHandler *rast_;
90 struct LinkRulePi : public Link {
95 class RastSubdocState {
98 RastSubdocState(SgmlParser *, RastEventHandler *);
99 void init(SgmlParser *, RastEventHandler *);
100 void swap(RastSubdocState &);
103 Boolean hadActiveLpdOrDtd_;
104 Location activeLpdOrDtdLocation_;
105 Vector<StringC> activeLinkTypes_;
106 Boolean hadDocumentElement_;
107 RastLinkProcess linkProcess_;
108 Boolean haveLinkProcess_;
109 Owner<EndPrologEvent> endPrologEvent_;
110 Vector<PackedBoolean> parseSubdocQueue_;
111 IQueue<LinkRulePi> linkRuleQueue_;
118 enum { nAttributeType = simpleAttribute + 1 };
119 Vector<Vector<size_t> > attributeSortOrder_[nAttributeType];
121 RastSubdocState(const RastSubdocState &); // undefined
122 void operator=(const RastSubdocState &); // undefined
123 friend class RastLinkProcess;
126 class RastEventHandler : public ErrorCountEventHandler,
127 private RastSubdocState,
130 RastEventHandler(SgmlParser *, Messenger *);
131 void data(DataEvent *);
132 void startElement(StartElementEvent *);
133 void endElement(EndElementEvent *);
135 void sdataEntity(SdataEntityEvent *);
136 void externalDataEntity(ExternalDataEntityEvent *);
137 void subdocEntity(SubdocEntityEvent *);
138 void sgmlDecl(SgmlDeclEvent *);
139 void endProlog(EndPrologEvent *);
140 void uselink(UselinkEvent *);
141 virtual void truncateOutput();
143 void setOutputStream(OutputCharStream *os);
144 // static const char *messageText(int);
145 // static const char messageSource[];
147 void initMessage(Message &);
148 void dispatchMessage(const Message &);
149 void dispatchMessage(Message &);
151 RastEventHandler(const RastEventHandler &); // undefined
152 void operator=(const RastEventHandler &); // undefined
154 enum LineType { dataLine = '|', markupLine = '!' };
155 void lines(LineType, const Char *p, size_t length);
156 enum { maxLineLength = 60 };
157 enum { RS = '\n', RE = '\r', TAB = '\t' };
159 static const RastPrintable printable;
161 static RastPrintable printable;
164 OutputCharStream *os_;
165 StringC rastParseSubdocYesString_;
166 StringC rastParseSubdocNoString_;
167 StringC rastActiveLpdString_;
168 StringC rastLinkRuleString_;
169 unsigned piErrorCount_;
172 int lexCmp(const StringC &s1, const StringC &s2);
173 void flushLine(LineType);
174 void attributeInfo(const AttributeList &, AttributeType);
175 void externalEntityInfo(const ExternalDataEntity *, AttributeType);
176 void subdocEntityInfo(const SubdocEntity *,
177 const Ptr<InputSourceOrigin> &entityOrigin,
179 void externalIdInfo(const ExternalId &);
180 void internalEntityInfo(const InternalEntity *);
181 void queueParseSubdoc(Boolean);
182 Boolean parseNextSubdoc();
183 Boolean interpretRastPi(const Char *data, size_t dataLength,
186 void simpleLinkInfo();
187 void impliedSourceLinkRules();
189 OutputCharStream &os();
190 friend class RastLinkProcess;
194 int RastPrintable::operator()(Char c) const
196 return c <= UCHAR_MAX ? v_[c] : 0;
200 void RastEventHandler::setOutputStream(OutputCharStream *os)
206 OutputCharStream &RastEventHandler::os()
215 #endif /* not RastEventHandler_INCLUDED */