diff options
author | Stef Walter <stef@memberwebs.com> | 2003-09-17 18:34:42 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2003-09-17 18:34:42 +0000 |
commit | 69aa93c828303dcc44253fe88ff3d6024d10817b (patch) | |
tree | 63d14dacbd3d81363fcbea1036c47a0210b0f397 /src/levelhandler.cpp | |
parent | 15f3015d2e8305b729d7996faad410b3378497da (diff) |
Initial Import
Diffstat (limited to 'src/levelhandler.cpp')
-rw-r--r-- | src/levelhandler.cpp | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/src/levelhandler.cpp b/src/levelhandler.cpp new file mode 100644 index 0000000..1c55e9c --- /dev/null +++ b/src/levelhandler.cpp @@ -0,0 +1,98 @@ +// LevelHandler.cpp: implementation of the LevelHandler class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "LevelHandler.h" + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +LevelHandler::LevelHandler() +{ + +} + +LevelHandler::~LevelHandler() +{ + clear(); +} + +void LevelHandler::clear() +{ + m_curLevel.release(); + m_topLevel.release(); + + BaseHandler::clear(); +} + +void LevelHandler::startDocument(RtfReader* reader) +{ + BaseHandler::startDocument(reader); + + m_topLevel = new Level; + m_curLevel = m_topLevel; +} + +void LevelHandler::endDocument() +{ + BaseHandler::endDocument(); +} + +void LevelHandler::groupStart() +{ + BaseHandler::groupStart(); + ASSERT(m_curLevel); + pushLevel(); +} + +void LevelHandler::groupEnd() +{ + ASSERT(m_curLevel); + popLevel(); + BaseHandler::groupEnd(); +} + +DOM::Element LevelHandler::getElement() +{ + ASSERT(m_curLevel); + return m_curLevel->getElement(); +} + +void LevelHandler::pushLevel() +{ + // Push a level on the stack + m_curLevel = m_curLevel->pushLevel(); +} + +void LevelHandler::popLevel() +{ + // Pull a level off the stack + LevelPtr level = m_curLevel->getPrevious(); + + // TODO: report errors here + if(level) + m_curLevel = level; +} + +void LevelHandler::rewindLevel(LevelPtr ptr) +{ + ASSERT(ptr != NULL); + + LevelPtr prev = ptr->getPrevious(); + + if(prev != NULL) + m_curLevel = prev; + else + m_curLevel = ptr; +} + +LevelPtr LevelHandler::getLevel() +{ + return m_curLevel; +} + + + + |