diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-11-21 15:16:20 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2014-11-21 17:32:25 +0100 |
commit | 329742e6c9da7cd7848d92a6846e3d1249d8d9b4 (patch) | |
tree | a95afc0c354530fdb40de06dd5c0bf1144d727b8 | |
parent | c1a0e74d3ce81e3e84c782e1a2f13dc814bf6575 (diff) |
fdo#85886 don't redraw the Navigator content tree if nothing changed
This fixes the flickering of the scrollbar on re-draw once a second.
Perhaps it helps for the performance issue too.
Change-Id: I2ec8f0a8a241b128113bfa3d47fb09ba472b4a7e
-rw-r--r-- | sw/source/uibase/inc/conttree.hxx | 10 | ||||
-rw-r--r-- | sw/source/uibase/utlui/content.cxx | 34 |
2 files changed, 41 insertions, 3 deletions
diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx index e4aa7d9f7a21..43d76b38716a 100644 --- a/sw/source/uibase/inc/conttree.hxx +++ b/sw/source/uibase/inc/conttree.hxx @@ -19,6 +19,7 @@ #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_CONTTREE_HXX #define INCLUDED_SW_SOURCE_UIBASE_INC_CONTTREE_HXX +#include <svl/lstner.hxx> #include <svtools/treelistbox.hxx> #include <svtools/svlbitm.hxx> #include "swcont.hxx" @@ -43,7 +44,9 @@ class SdrObject; #define EDIT_MODE_DELETE 4 #define EDIT_MODE_RENAME 5 -class SwContentTree : public SvTreeListBox +class SwContentTree + : public SvTreeListBox + , public SfxListener { ImageList aEntryImages; OUString sSpace; @@ -85,6 +88,7 @@ class SwContentTree : public SvTreeListBox bool bIsOutlineMoveable :1; bool bViewHasChanged :1; bool bIsImageListInitialized : 1; + bool m_bActiveDocModified :1; static bool bIsInDrag; @@ -196,6 +200,10 @@ public: virtual bool Select( SvTreeListEntry* pEntry, bool bSelect=true ) SAL_OVERRIDE; virtual sal_Int32 GetEntryRealChildrenNum( SvTreeListEntry* pEntry ) const; + + using Control::Notify; // FIXME why do we have 2 of these + virtual void Notify(SfxBroadcaster& rBC, SfxHint const& rHint) SAL_OVERRIDE; + }; // TreeListBox for global documents diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index bd75cde79bc6..cac96edf4d7a 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -1756,6 +1756,7 @@ void SwContentTree::Display( bool bActive ) ScrollOutputArea( (short)nDelta ); } + m_bActiveDocModified = false; } // In the Clear the content types have to be deleted, also. @@ -2208,6 +2209,8 @@ void SwContentTree::SetActiveShell(SwWrtShell* pSh) bool bClear = pActiveShell != pSh; if(bIsActive && bClear) { + if (pActiveShell) + EndListening(*pActiveShell->GetView().GetDocShell()); pActiveShell = pSh; FindActiveTypeAndRemoveUserData(); Clear(); @@ -2216,6 +2219,7 @@ void SwContentTree::SetActiveShell(SwWrtShell* pSh) { if(!lcl_FindShell(pActiveShell)) { + EndListening(*pActiveShell->GetView().GetDocShell()); pActiveShell = pSh; bIsActive = true; bIsConstant = false; @@ -2226,6 +2230,7 @@ void SwContentTree::SetActiveShell(SwWrtShell* pSh) // the screen filled new. if(bIsActive && bClear) { + StartListening(*pActiveShell->GetView().GetDocShell()); FindActiveTypeAndRemoveUserData(); for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++) { @@ -2239,9 +2244,12 @@ void SwContentTree::SetActiveShell(SwWrtShell* pSh) void SwContentTree::SetConstantShell(SwWrtShell* pSh) { + if (pActiveShell) + EndListening(*pActiveShell->GetView().GetDocShell()); pActiveShell = pSh; bIsActive = false; bIsConstant = true; + StartListening(*pActiveShell->GetView().GetDocShell()); FindActiveTypeAndRemoveUserData(); for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++) { @@ -2250,6 +2258,21 @@ void SwContentTree::SetConstantShell(SwWrtShell* pSh) Display(true); } + + +void SwContentTree::Notify(SfxBroadcaster & rBC, SfxHint const& rHint) +{ + SfxSimpleHint const*const pHint(dynamic_cast<SfxSimpleHint const*>(&rHint)); + if (pHint && SFX_HINT_DOCCHANGED == pHint->GetId()) + { + m_bActiveDocModified = true; + } + else + { + SfxListener::Notify(rBC, rHint); + } +} + // Execute commands of the Navigator void SwContentTree::ExecCommand(sal_uInt16 nCmd, bool bModifier) @@ -2436,18 +2459,25 @@ IMPL_LINK_NOARG(SwContentTree, TimerUpdate) } if(bIsActive && pActShell != GetWrtShell()) + { SetActiveShell(pActShell); + } else if( (bIsActive || (bIsConstant && pActShell == GetWrtShell())) && HasContentChanged()) { - FindActiveTypeAndRemoveUserData(); - Display(true); + if (!bIsActive || m_bActiveDocModified) + { // don't burn cpu and redraw and flicker if not modified + FindActiveTypeAndRemoveUserData(); + Display(true); + } } } else if(!pView && bIsActive && !bIsIdleClear) { if(pActiveShell) + { SetActiveShell(0); + } Clear(); bIsIdleClear = true; } |