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: ContentState.h /main/1 1996/07/29 16:48:27 cde-hp $ */
24 // Copyright (c) 1994, 1996 James Clark
25 // See the file COPYING for copying permission.
27 #ifndef ContentState_INCLUDED
28 #define ContentState_INCLUDED 1
35 #include "OpenElement.h"
44 namespace SP_NAMESPACE {
47 class SP_API ContentState {
50 void startContent(const Dtd &);
51 void pushElement(OpenElement *);
52 OpenElement *popSaveElement();
54 OpenElement ¤tElement();
55 const OpenElement ¤tElement() const;
56 void getOpenElementInfo(Vector<OpenElementInfo> &,
57 const StringC &rniPcdata) const;
58 unsigned tagLevel() const;
59 Boolean elementIsIncluded(const ElementType *) const;
60 Boolean elementIsExcluded(const ElementType *) const;
61 Boolean elementIsOpen(const ElementType *) const;
62 Boolean afterDocumentElement() const;
63 const ElementType *lastEndedElementType() const;
64 Mode contentMode() const;
65 const ElementType *lookupCreateUndefinedElement(const StringC &,
67 Boolean checkImplyLoop(unsigned);
68 static const ShortReferenceMap theEmptyMap;
70 IList<OpenElement> openElements_;
71 Vector<unsigned> openElementCount_;
72 Vector<unsigned> includeCount_;
73 Vector<unsigned> excludeCount_;
74 unsigned totalExcludeCount_;
76 unsigned netEnablingCount_;
77 const ElementType *lastEndedElementType_;
78 NamedTable<ElementType> undefinedElementTypeTable_;
79 ElementType documentElementContainer_;
83 OpenElement &ContentState::currentElement()
85 return *openElements_.head();
89 const OpenElement &ContentState::currentElement() const
91 return *openElements_.head();
95 Boolean ContentState::elementIsOpen(const ElementType *e) const
97 return openElementCount_[e->index()] != 0;
101 Boolean ContentState::elementIsIncluded(const ElementType *e) const
103 return includeCount_[e->index()] != 0 && excludeCount_[e->index()] == 0;
107 Boolean ContentState::elementIsExcluded(const ElementType *e) const
109 return excludeCount_[e->index()] != 0;
113 const ElementType *ContentState::lastEndedElementType() const
115 return lastEndedElementType_;
119 unsigned ContentState::tagLevel() const
125 Boolean ContentState::afterDocumentElement() const
127 return tagLevel() == 0 && currentElement().isFinished();
131 Mode ContentState::contentMode() const
133 return openElements_.head()->mode(netEnablingCount_ > 0);
140 #endif /* not ContentState_INCLUDED */