summaryrefslogtreecommitdiff
path: root/src/xmlcomposer.cpp
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2004-07-24 22:32:14 +0000
committerStef Walter <stef@memberwebs.com>2004-07-24 22:32:14 +0000
commita70bc0519f2705257efca1c8a714a44c941534fb (patch)
treef43dd57982917760b8d12534e5a3c9520da8f024 /src/xmlcomposer.cpp
parent07e7c437647e45b6f06b30a8dc02b663fd6a782c (diff)
- Bug fixes to new fixup scheme
Diffstat (limited to 'src/xmlcomposer.cpp')
-rw-r--r--src/xmlcomposer.cpp48
1 files changed, 31 insertions, 17 deletions
diff --git a/src/xmlcomposer.cpp b/src/xmlcomposer.cpp
index 2b65833..398cb55 100644
--- a/src/xmlcomposer.cpp
+++ b/src/xmlcomposer.cpp
@@ -220,13 +220,25 @@ void XmlComposer::pushElement(const DOM::Element& element)
m_curLevel->setElement(element);
}
+void XmlComposer::pushTopElement(const DOM::Element& element)
+{
+ ASSERT(m_curLevel != NULL);
+ DOM::Element top = m_document.getDocumentElement();
+ if(top.hasChildNodes())
+ top.insertBefore(element, top.getFirstChild());
+ else
+ top.appendChild(element);
+
+ m_curLevel->setElement(element);
+}
+
DOM::Element XmlComposer::popElement()
{
DOM::Element element = getElement();
ASSERT(m_curLevel != NULL);
DOM::Node parent = element.getParentNode();
- ASSERT(parent.getNodeType() == DOM::Node::ELEMENT_NODE);
+ ASSERT(parent != NULL && parent.getNodeType() == DOM::Node::ELEMENT_NODE);
// Set it deep so it replaces the current element
m_curLevel->setElement((DOM::Element&)parent, true);
@@ -317,19 +329,21 @@ void XmlComposer::incrementAutoCount(int type)
*/
#define AN_ELEMENT(name) \
- m_composer->pushElement(m_composer->createElement(name))
+ m_composer->pushElement(m_composer->createElement(name))
+#define AN_TOP_ELEMENT(name) \
+ m_composer->pushTopElement(m_composer->createElement(name))
#define AN_POP_ELEMENT() \
m_composer->popElement()
#define AN_ATTRIBUTE(name, value) \
- m_composer->setAttribute(name, value)
+ m_composer->setAttribute(name, value)
#define AN_DESTINATION_ATTR(name) \
- m_composer->setDestination(new Attribute(name))
+ m_composer->setDestination(new Attribute(name))
#define AN_DESTINATION(cls) \
- m_composer->setDestination(new cls)
+ m_composer->setDestination(new cls)
#define AN_ANALYSER(cls) \
- m_composer->setAnalyser(AnalyserPtr(new cls))
+ m_composer->setAnalyser(AnalyserPtr(new cls))
#define AN_SET_ANALYSER(cls) \
- m_composer->setAnalyser(AnalyserPtr(cls))
+ m_composer->setAnalyser(AnalyserPtr(cls))
#define HAS_PARAM (flags & kHasParam)
#define DEFAULT_CONTROLWORD processDefault(cw, flags, param)
#define DUMMY 1 == 1
@@ -394,7 +408,6 @@ DOM::Element XmlComposer::BaseAnalyser::getCurrentBlock()
node = node.getLastChild();
return DOMHelpers::getPriorElement(node, kElBlock);
-
}
bool XmlComposer::BaseAnalyser::processTextContent(const string& cw, int flags, int param)
@@ -617,7 +630,7 @@ ON_GROUPEND(Upr)
ON_INITIALIZE(Stylesheet)
{
- AN_ELEMENT(kElStylesheet);
+ AN_TOP_ELEMENT(kElStylesheet);
}
ON_GROUPSTART(Stylesheet)
@@ -705,7 +718,7 @@ ON_GROUPEND(Style)
ON_INITIALIZE(FontTable)
{
- AN_ELEMENT(kElFontTable);
+ AN_TOP_ELEMENT(kElFontTable);
AN_DESTINATION(Null);
}
@@ -720,7 +733,7 @@ ON_GROUPSTART(FontTable)
ON_INITIALIZE(Font)
{
- AN_ELEMENT(kElFont);
+ AN_ELEMENT(kElFontDef);
AN_DESTINATION_ATTR(kAtName);
}
@@ -744,7 +757,7 @@ ON_GROUPSTART(Font)
ON_INITIALIZE(ListTable)
{
- AN_ELEMENT(kElListtable);
+ AN_TOP_ELEMENT(kElListtable);
}
ON_GROUPSTART(ListTable)
@@ -763,7 +776,10 @@ ON_INITIALIZE(List)
{
// Create a default element
AN_ELEMENT(kElListdef);
- AN_ATTRIBUTE(kAtType, kValDisc);
+
+ if(DO_EXTRAS())
+ AN_ATTRIBUTE(kAtType, kValDisc);
+
AN_ATTRIBUTE(kAtOrdered, L"0");
levelsSeen = 0;
}
@@ -913,7 +929,7 @@ ON_CONTROLWORD(ListOverrideTable)
if(curList != NULL)
{
parent.appendChild(curList);
- curList.setAttribute(kAtList, NUM_ATTR(lsId));
+ curList.setAttribute(kAtId, NUM_ATTR(lsId));
}
}
@@ -928,7 +944,7 @@ ON_CONTROLWORD(ListOverrideTable)
ON_INITIALIZE(Info)
{
// Create a new element
- AN_ELEMENT(kElInfo);
+ AN_TOP_ELEMENT(kElInfo);
AN_DESTINATION(Null);
}
@@ -1017,8 +1033,6 @@ ON_INITIALIZE(Content)
ON_CHARDATA(Content)
{
- int v;
-
// Create the first time we get content
if(!created)
{