[Libreoffice-commits] core.git: sc/source

Caolán McNamara caolanm at redhat.com
Mon Jan 23 21:16:09 UTC 2017


 sc/source/ui/condformat/condformatdlg.cxx |   24 ++++++++++++++++++++++++
 sc/source/ui/inc/condformatdlg.hxx        |    3 +++
 2 files changed, 27 insertions(+)

New commits:
commit 4ef8740c98e6db96832191985e5cd49ca94be0bf
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Jan 23 20:59:17 2017 +0000

    Related: tdf#105466 add a freeze/thaw to avoid interim RecalcAlls
    
    so when we are going to do one anyway, skip all the RecalcAlls
    that are triggered by queue_resize due to widgets getting added/removed
    
    Change-Id: I23104e27ce1331f660e90fdd3a28a38a4f778a94

diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 37bf0b2..a705f18 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -39,6 +39,7 @@
 ScCondFormatList::ScCondFormatList(vcl::Window* pParent, WinBits nStyle)
     : Control(pParent, nStyle | WB_DIALOGCONTROL)
     , mbHasScrollBar(false)
+    , mbFrozen(false)
     , mpScrollBar(VclPtr<ScrollBar>::Create(this, WB_VERT ))
     , mpDoc(nullptr)
     , mpDialogParent(nullptr)
@@ -56,6 +57,7 @@ ScCondFormatList::~ScCondFormatList()
 
 void ScCondFormatList::dispose()
 {
+    Freeze();
     mpDialogParent.clear();
     mpScrollBar.disposeAndClear();
     for (auto it = maEntries.begin(); it != maEntries.end(); ++it)
@@ -73,6 +75,8 @@ void ScCondFormatList::init(ScDocument* pDoc, ScCondFormatDlg* pDialogParent,
     maPos = rPos;
     maRanges = rRanges;
 
+    Freeze();
+
     if(pFormat)
     {
         size_t nCount = pFormat->size();
@@ -137,6 +141,7 @@ void ScCondFormatList::init(ScDocument* pDoc, ScCondFormatDlg* pDialogParent,
                 break;
         }
     }
+    Thaw();
     RecalcAll();
     if (!maEntries.empty())
         (*maEntries.begin())->SetActive();
@@ -185,6 +190,9 @@ ScConditionalFormat* ScCondFormatList::GetConditionalFormat() const
 
 void ScCondFormatList::RecalcAll()
 {
+    if (mbFrozen)
+        return;
+
     sal_Int32 nTotalHeight = 0;
     sal_Int32 nIndex = 1;
     for (const auto& item : maEntries)
@@ -257,6 +265,7 @@ IMPL_LINK(ScCondFormatList, ColFormatTypeHdl, ListBox&, rBox, void)
             if((*itr)->GetType() == condformat::entry::COLORSCALE2)
                 return;
 
+            Freeze();
             itr->disposeAndClear();
             *itr = VclPtr<ScColorScale2FrmtEntry>::Create( this, mpDoc, maPos );
             break;
@@ -264,6 +273,7 @@ IMPL_LINK(ScCondFormatList, ColFormatTypeHdl, ListBox&, rBox, void)
             if((*itr)->GetType() == condformat::entry::COLORSCALE3)
                 return;
 
+            Freeze();
             itr->disposeAndClear();
             *itr = VclPtr<ScColorScale3FrmtEntry>::Create( this, mpDoc, maPos );
             break;
@@ -271,6 +281,7 @@ IMPL_LINK(ScCondFormatList, ColFormatTypeHdl, ListBox&, rBox, void)
             if((*itr)->GetType() == condformat::entry::DATABAR)
                 return;
 
+            Freeze();
             itr->disposeAndClear();
             *itr = VclPtr<ScDataBarFrmtEntry>::Create( this, mpDoc, maPos );
             break;
@@ -278,6 +289,7 @@ IMPL_LINK(ScCondFormatList, ColFormatTypeHdl, ListBox&, rBox, void)
             if((*itr)->GetType() == condformat::entry::ICONSET)
                 return;
 
+            Freeze();
             itr->disposeAndClear();
             *itr = VclPtr<ScIconSetFrmtEntry>::Create( this, mpDoc, maPos );
             break;
@@ -286,6 +298,7 @@ IMPL_LINK(ScCondFormatList, ColFormatTypeHdl, ListBox&, rBox, void)
     }
     mpDialogParent->InvalidateRefData();
     (*itr)->SetActive();
+    Thaw();
     RecalcAll();
 }
 
@@ -326,6 +339,7 @@ IMPL_LINK(ScCondFormatList, AfterTypeListHdl, void*, p, void)
                 case condformat::entry::ICONSET:
                     return;
             }
+            Freeze();
             itr->disposeAndClear();
             *itr = VclPtr<ScColorScale3FrmtEntry>::Create(this, mpDoc, maPos);
             mpDialogParent->InvalidateRefData();
@@ -335,6 +349,7 @@ IMPL_LINK(ScCondFormatList, AfterTypeListHdl, void*, p, void)
             if((*itr)->GetType() == condformat::entry::CONDITION)
                 return;
 
+            Freeze();
             itr->disposeAndClear();
             *itr = VclPtr<ScConditionFrmtEntry>::Create(this, mpDoc, mpDialogParent, maPos);
             mpDialogParent->InvalidateRefData();
@@ -344,6 +359,7 @@ IMPL_LINK(ScCondFormatList, AfterTypeListHdl, void*, p, void)
             if((*itr)->GetType() == condformat::entry::FORMULA)
                 return;
 
+            Freeze();
             itr->disposeAndClear();
             *itr = VclPtr<ScFormulaFrmtEntry>::Create(this, mpDoc, mpDialogParent, maPos);
             mpDialogParent->InvalidateRefData();
@@ -353,6 +369,7 @@ IMPL_LINK(ScCondFormatList, AfterTypeListHdl, void*, p, void)
             if((*itr)->GetType() == condformat::entry::DATE)
                 return;
 
+            Freeze();
             itr->disposeAndClear();
             *itr = VclPtr<ScDateFrmtEntry>::Create( this, mpDoc );
             mpDialogParent->InvalidateRefData();
@@ -360,11 +377,13 @@ IMPL_LINK(ScCondFormatList, AfterTypeListHdl, void*, p, void)
             break;
 
     }
+    Thaw();
     RecalcAll();
 }
 
 IMPL_LINK_NOARG( ScCondFormatList, AddBtnHdl, Button*, void )
 {
+    Freeze();
     VclPtr<ScCondFrmtEntry> pNewEntry = VclPtr<ScConditionFrmtEntry>::Create(this, mpDoc, mpDialogParent, maPos);
     maEntries.push_back( pNewEntry );
     for(EntryContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
@@ -373,11 +392,13 @@ IMPL_LINK_NOARG( ScCondFormatList, AddBtnHdl, Button*, void )
     }
     mpDialogParent->InvalidateRefData();
     pNewEntry->SetActive();
+    Thaw();
     RecalcAll();
 }
 
 IMPL_LINK_NOARG( ScCondFormatList, RemoveBtnHdl, Button*, void )
 {
+    Freeze();
     for(EntryContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
     {
         auto widget = *itr;
@@ -389,6 +410,7 @@ IMPL_LINK_NOARG( ScCondFormatList, RemoveBtnHdl, Button*, void )
         }
     }
     mpDialogParent->InvalidateRefData();
+    Thaw();
     RecalcAll();
 }
 
@@ -397,6 +419,7 @@ IMPL_LINK( ScCondFormatList, EntrySelectHdl, ScCondFrmtEntry&, rEntry, void )
     if(rEntry.IsSelected())
         return;
 
+    Freeze();
     //A child has focus, but we will hide that, so regrab to whatever new thing gets
     //shown instead of leaving it stuck in the inaccessible hidden element
     bool bReGrabFocus = HasChildPathFocus();
@@ -406,6 +429,7 @@ IMPL_LINK( ScCondFormatList, EntrySelectHdl, ScCondFrmtEntry&, rEntry, void )
     }
     mpDialogParent->InvalidateRefData();
     rEntry.SetActive();
+    Thaw();
     RecalcAll();
     if (bReGrabFocus)
         GrabFocus();
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index a79ae0d..40ca3db 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -47,6 +47,7 @@ private:
     EntryContainer maEntries;
 
     bool mbHasScrollBar;
+    bool mbFrozen;
     VclPtr<ScrollBar> mpScrollBar;
 
     ScDocument* mpDoc;
@@ -70,6 +71,8 @@ public:
     virtual void Resize() override;
 
     ScConditionalFormat* GetConditionalFormat() const;
+    void Freeze() { mbFrozen = true; }
+    void Thaw() { mbFrozen = false; }
     void RecalcAll();
 
     DECL_LINK( AddBtnHdl, Button*, void );


More information about the Libreoffice-commits mailing list