--- text/ptbl/xp/old/orig/pd_Document.h Sun Dec 14 15:11:15 2003 +++ text/ptbl/xp/pd_Document.h Fri Jan 16 13:36:19 2004 @@ -371,6 +371,8 @@ bool notifyListeners(const pf_Frag_Strux * pfs, pf_Frag_Strux * pfsNew, const PX_ChangeRecord * pcr) const; + void deferNotifications(void); + void processDeferredNotifications(void); bool getAttrProp(PT_AttrPropIndex indexAP, const PP_AttrProp ** ppAP) const; bool getSpanAttrProp(PL_StruxDocHandle sdh, UT_uint32 offset, bool bLeftSide, --- text/ptbl/xp/old/orig/pl_Listener.h Sat May 03 11:22:31 2003 +++ text/ptbl/xp/pl_Listener.h Fri Jan 16 13:37:02 2004 @@ -88,6 +88,10 @@ virtual bool change(PL_StruxFmtHandle sfh, const PX_ChangeRecord * pcr) = 0; + virtual void deferNotifications(void) { } + + virtual void processDeferredNotifications(void) { } + virtual bool insertStrux(PL_StruxFmtHandle sfh, const PX_ChangeRecord * pcr, PL_StruxDocHandle sdhNew, --- text/ptbl/xp/old/orig/pd_Document.cpp Fri Jan 16 05:40:18 2004 +++ text/ptbl/xp/pd_Document.cpp Fri Jan 16 13:38:06 2004 @@ -904,7 +904,11 @@ const XML_Char ** attributes, const XML_Char ** properties) { - return m_pPieceTable->changeSpanFmt(ptc,dpos1,dpos2,attributes,properties); + bool f; + deferNotifications(); + f = m_pPieceTable->changeSpanFmt(ptc,dpos1,dpos2,attributes,properties); + processDeferredNotifications(); + return f; } bool PD_Document::insertStrux(PT_DocPosition dpos, @@ -2248,6 +2252,56 @@ } return true; +} + +void PD_Document::deferNotifications(void) +{ + // notify listeners to defer notifications. + +#ifdef PT_TEST + //pcr->__dump(); +#endif + + PL_ListenerId lid; + PL_ListenerId lidCount = m_vecListeners.getItemCount(); + + // for each listener in our vector, we send a notification. + // we step over null listeners (for listeners which have been + // removed (views that went away)). + + for (lid=0; lid(m_vecListeners.getNthItem(lid)); + if (pListener) + { + pListener->deferNotifications(); + } + } +} + +void PD_Document::processDeferredNotifications(void) +{ + // notify listeners to process any deferred notifications. + +#ifdef PT_TEST + //pcr->__dump(); +#endif + + PL_ListenerId lid; + PL_ListenerId lidCount = m_vecListeners.getItemCount(); + + // for each listener in our vector, we send a notification. + // we step over null listeners (for listeners which have been + // removed (views that went away)). + + for (lid=0; lid(m_vecListeners.getNthItem(lid)); + if (pListener) + { + pListener->processDeferredNotifications(); + } + } } PL_StruxFmtHandle PD_Document::getNthFmtHandle(PL_StruxDocHandle sdh, UT_uint32 n) --- text/fmt/xp/old/orig/fl_DocListener.h Sat May 03 08:20:23 2003 +++ text/fmt/xp/fl_DocListener.h Fri Jan 16 13:37:36 2004 @@ -25,6 +25,7 @@ #include "ut_stack.h" #include "pl_Listener.h" +#include "xav_Listener.h" class FL_DocLayout; class PD_Document; @@ -52,6 +53,9 @@ virtual bool change(PL_StruxFmtHandle sfh, const PX_ChangeRecord * pcr); + virtual void deferNotifications(void); + virtual void processDeferredNotifications(void); + virtual bool insertStrux(PL_StruxFmtHandle sfh, const PX_ChangeRecord * pcr, PL_StruxDocHandle sdh, @@ -87,6 +91,8 @@ UT_Stack m_sLastContainerLayout; bool m_bFootnoteInProgress; bool m_bEndFootnoteProcessedInBlock; + AV_ChangeMask m_chgMaskCached; + bool m_bCacheChanges; }; #endif /* FL_DOCLISTENER_H */ --- text/fmt/xp/old/orig/fl_DocListener.cpp Sat Dec 13 08:39:27 2003 +++ text/fmt/xp/fl_DocListener.cpp Fri Jan 16 13:37:23 2004 @@ -81,6 +81,8 @@ m_sLastContainerLayout.push(NULL); m_bFootnoteInProgress = false; m_bEndFootnoteProcessedInBlock = false; + m_bCacheChanges = false; + m_chgMaskCached = AV_CHG_NONE; } /*! @@ -1383,14 +1385,43 @@ // need to make view to notify its various listeners to update if(chgMask != AV_CHG_NONE) { - UT_return_val_if_fail(getLayout() && getLayout()->getView(),bResult); - // first of all, increase view tick, so that the view's - // property caches are invalidated ... - getLayout()->getView()->incTick(); - getLayout()->getView()->notifyListeners(chgMask); + if (m_bCacheChanges) + { + m_chgMaskCached |= chgMask; + } + else + { + UT_return_val_if_fail(getLayout() && getLayout()->getView(),bResult); + // first of all, increase view tick, so that the view's + // property caches are invalidated ... + getLayout()->getView()->incTick(); + getLayout()->getView()->notifyListeners(chgMask); + } } return bResult; +} + +void fl_DocListener::deferNotifications(void) +{ + m_bCacheChanges = true; + m_chgMaskCached = AV_CHG_NONE; +} + +void fl_DocListener::processDeferredNotifications(void) +{ + if (m_chgMaskCached != AV_CHG_NONE) + { + if (getLayout() && getLayout()->getView()) + { + // first of all, increase view tick, so that the view's + // property caches are invalidated ... + getLayout()->getView()->incTick(); + getLayout()->getView()->notifyListeners(m_chgMaskCached); + } + m_chgMaskCached = AV_CHG_NONE; + } + m_bCacheChanges = false; } /*!