From 69aa93c828303dcc44253fe88ff3d6024d10817b Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Wed, 17 Sep 2003 18:34:42 +0000 Subject: Initial Import --- src/levelhandler.cpp | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 src/levelhandler.cpp (limited to 'src/levelhandler.cpp') 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; +} + + + + -- cgit v1.2.3