From 9e0f8dfa9a67b5ceb37db033df4db2b46874aa87 Mon Sep 17 00:00:00 2001 From: Stef Date: Sun, 11 Jul 2004 21:33:06 +0000 Subject: Some level fixes --- src/xmlcomposehelpers.cpp | 20 +++++++++++++++++--- src/xmlcomposehelpers.h | 2 +- src/xmlcomposer.cpp | 17 +++-------------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/xmlcomposehelpers.cpp b/src/xmlcomposehelpers.cpp index a1bc73f..6612df9 100644 --- a/src/xmlcomposehelpers.cpp +++ b/src/xmlcomposehelpers.cpp @@ -58,7 +58,10 @@ Level::Level(const Level& level) : Level::~Level() { - + if(m_analyser) + m_analyser->done(); + if(m_destination) + m_destination->done(); } LevelPtr Level::pushLevel() @@ -106,15 +109,21 @@ void Level::setAnalyser(AnalyserPtr analyser, bool deep) { if(deep && m_previous && !m_analyser) m_previous->setAnalyser(analyser, deep); + else + { + if(m_analyser != NULL) + m_analyser->done(); + m_analyser = analyser; + } } -DestinationPtr Level::getDestination() +DestinationPtr Level::getDestination(bool deep) { if(m_destination) return m_destination; - else if(m_previous) + else if(deep && m_previous) return m_previous->getDestination(); else return NULL; @@ -125,7 +134,12 @@ void Level::setDestination(DestinationPtr destination, bool deep) if(deep && m_previous && !m_destination) m_previous->setDestination(destination, deep); else + { + if(m_destination != NULL) + m_destination->done(); + m_destination = destination; + } } RtfFormatting& Level::getFormatting() diff --git a/src/xmlcomposehelpers.h b/src/xmlcomposehelpers.h index 8d7e515..f91923e 100644 --- a/src/xmlcomposehelpers.h +++ b/src/xmlcomposehelpers.h @@ -103,7 +103,7 @@ public: void setElement(DOM::Element element, bool deep = false); AnalyserPtr getAnalyser(bool deep = true); void setAnalyser(AnalyserPtr analyser, bool deep = false); - DestinationPtr getDestination(); + DestinationPtr getDestination(bool deep = true); void setDestination(DestinationPtr destination, bool deep = false); RtfFormatting& getFormatting(); void setTextProperties(RtfFormatting& textProperties); diff --git a/src/xmlcomposer.cpp b/src/xmlcomposer.cpp index 11ed2a0..4091adb 100644 --- a/src/xmlcomposer.cpp +++ b/src/xmlcomposer.cpp @@ -280,22 +280,11 @@ void RtfParser::groupEnd() ASSERT(m_curLevel != NULL); bool done = true; - // First see if this level has an ananlyser - AnalyserPtr analyser = m_curLevel->getAnalyser(false); - if(!analyser) - { - // If not then the analyser is going to live and we - // get one from a previous level - done = false; - analyser = m_curLevel->getAnalyser(); - } + LevelHandler::groupEnd(); - if(done) - analyser->done(); - else + AnalyserPtr analyser = m_curLevel->getAnalyser(); + if(analyser) analyser->groupEnd(); - - LevelHandler::groupEnd(); } #define ON_INITIALIZE(cls) \ -- cgit v1.2.3