sc/source/ui/cctrl/checklistmenu.cxx |   47 +++++++++++++++++------------------
 sc/source/ui/inc/checklistmenu.hxx   |    8 ++---
 sc/source/ui/view/gridwin.cxx        |   10 ++-----
 sc/source/ui/view/gridwin2.cxx       |    3 +-
 4 files changed, 33 insertions(+), 35 deletions(-)

New commits:
commit 416c11d189a18a08c28135b8aa5e0f12cd51dcd6
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Mon Sep 21 15:15:47 2020 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Mon Sep 21 20:09:44 2020 +0200

    set whether dates are needed in the ctor
    
    so its known from the start which mode will be in use
    
    Change-Id: I2fe69af481360a1668992010ad57c6bd3748d51d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103116
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sc/source/ui/cctrl/checklistmenu.cxx 
b/sc/source/ui/cctrl/checklistmenu.cxx
index 8707aff3f477..2edb5f50b1fe 100644
--- a/sc/source/ui/cctrl/checklistmenu.cxx
+++ b/sc/source/ui/cctrl/checklistmenu.cxx
@@ -167,7 +167,8 @@ ScCheckListMenuWindow* 
ScCheckListMenuControl::addSubMenuItem(const OUString& rT
     MenuItemData aItem;
     aItem.mbEnabled = bEnabled;
     vcl::Window *pContainer = mxFrame->GetWindow(GetWindowType::FirstChild);
-    aItem.mxSubMenuWin.reset(VclPtr<ScCheckListMenuWindow>::Create(pContainer, 
mpDoc, false, -1, mxFrame.get()));
+    aItem.mxSubMenuWin.reset(VclPtr<ScCheckListMenuWindow>::Create(pContainer, 
mpDoc, false,
+                                                                   false, -1, 
mxFrame.get()));
     maMenuItems.emplace_back(std::move(aItem));
 
     mxMenu->append_text(rText);
@@ -412,7 +413,8 @@ ScCheckListMember::ScCheckListMember()
 }
 
 ScCheckListMenuControl::ScCheckListMenuControl(ScCheckListMenuWindow* pParent, 
vcl::Window* pContainer,
-                                               ScDocument* pDoc, bool 
bCanHaveSubMenu, int nWidth)
+                                               ScDocument* pDoc, bool 
bCanHaveSubMenu,
+                                               bool bHasDates, int nWidth)
     : mxFrame(pParent)
     , mxBuilder(Application::CreateInterimBuilder(pContainer, 
"modules/scalc/ui/filterdropdown.ui", false))
     , mxContainer(mxBuilder->weld_container("FilterDropDown"))
@@ -422,7 +424,6 @@ 
ScCheckListMenuControl::ScCheckListMenuControl(ScCheckListMenuWindow* pParent, v
     , mxBox(mxBuilder->weld_widget("box"))
     , mxListChecks(mxBuilder->weld_tree_view("check_list_box"))
     , mxTreeChecks(mxBuilder->weld_tree_view("check_tree_box"))
-    , mpChecks(mxTreeChecks.get())
     , mxChkToggleAll(mxBuilder->weld_check_button("toggle_all"))
     , mxBtnSelectSingle(mxBuilder->weld_button("select_current"))
     , mxBtnUnselectSingle(mxBuilder->weld_button("unselect_current"))
@@ -436,11 +437,27 @@ 
ScCheckListMenuControl::ScCheckListMenuControl(ScCheckListMenuWindow* pParent, v
     , mnSelectedMenu(MENU_NOT_SELECTED)
     , mpDoc(pDoc)
     , mnAsyncPostPopdownId(nullptr)
-    , mbHasDates(false)
+    , mbHasDates(bHasDates)
     , mbCanHaveSubMenu(bCanHaveSubMenu)
     , maOpenTimer(this)
     , maCloseTimer(this)
 {
+    /*
+       tdf#136559 If we have no dates we don't need a tree
+       structure, just a list. GtkListStore can be then
+       used which is much faster than a GtkTreeStore, so
+       with no dates switch to the treeview which uses the
+       faster GtkListStore
+    */
+    if (mbHasDates)
+        mpChecks = mxTreeChecks.get();
+    else
+    {
+        mxTreeChecks->hide();
+        mxListChecks->show();
+        mpChecks = mxListChecks.get();
+    }
+
     bool bIsSubMenu = pParent->GetParentMenu();
 
     int nChecksHeight = mxTreeChecks->get_height_rows(9);
@@ -531,13 +548,13 @@ ScCheckListMenuControl::~ScCheckListMenuControl()
 }
 
 ScCheckListMenuWindow::ScCheckListMenuWindow(vcl::Window* pParent, ScDocument* 
pDoc, bool bCanHaveSubMenu,
-                                             int nWidth, 
ScCheckListMenuWindow* pParentMenu)
+                                             bool bTreeMode, int nWidth, 
ScCheckListMenuWindow* pParentMenu)
     : DockingWindow(pParent, "InterimDockParent", 
"svx/ui/interimdockparent.ui")
     , mxParentMenu(pParentMenu)
     , mxBox(get("box"))
 {
     setDeferredProperties();
-    mxControl.reset(new ScCheckListMenuControl(this, mxBox.get(), pDoc, 
bCanHaveSubMenu, nWidth));
+    mxControl.reset(new ScCheckListMenuControl(this, mxBox.get(), pDoc, 
bCanHaveSubMenu, bTreeMode, nWidth));
     
SetBackground(Application::GetSettings().GetStyleSettings().GetMenuColor());
     set_id("check_list_menu");
 }
@@ -1150,24 +1167,6 @@ IMPL_LINK(ScCheckListMenuControl, KeyInputHdl, const 
KeyEvent&, rKEvt, bool)
     return false;
 }
 
-void ScCheckListMenuControl::setHasDates(bool bHasDates)
-{
-    mbHasDates = bHasDates;
-
-    /*
-       tdf#136559 If we have no dates we don't need a tree
-       structure, just a list. GtkListStore can be then
-       used which is much faster than a GtkTreeStore, so
-       with no dates switch to the treeview which uses the
-       faster GtkListStore
-    */
-    assert(!mpChecks->n_children());
-    mpChecks->hide();
-    mpChecks = bHasDates ? mxTreeChecks.get() : mxListChecks.get();
-    mpChecks->show();
-    assert(!mpChecks->n_children());
-}
-
 namespace
 {
     void insertMember(weld::TreeView& rView, weld::TreeIter& rIter, const 
ScCheckListMember& rMember)
diff --git a/sc/source/ui/inc/checklistmenu.hxx 
b/sc/source/ui/inc/checklistmenu.hxx
index 69cb7b92f0fc..eb5c418a3cad 100644
--- a/sc/source/ui/inc/checklistmenu.hxx
+++ b/sc/source/ui/inc/checklistmenu.hxx
@@ -115,8 +115,8 @@ public:
         Config();
     };
 
-    explicit ScCheckListMenuControl(ScCheckListMenuWindow* pParent, 
vcl::Window* pContainer, ScDocument* pDoc,
-                                    bool bCanHaveSubMenu, int nWidth);
+    ScCheckListMenuControl(ScCheckListMenuWindow* pParent, vcl::Window* 
pContainer, ScDocument* pDoc,
+                           bool bCanHaveSubMenu, bool bTreeMode, int nWidth);
     ~ScCheckListMenuControl();
 
     void addMenuItem(const OUString& rText, Action* pAction);
@@ -163,7 +163,6 @@ public:
     void setOKAction(Action* p);
     void setPopupEndAction(Action* p);
 
-    void setHasDates(bool bHasDates);
     int GetTextWidth(const OUString& rsName) const;
     int IncreaseWindowWidthToFitText(int nMaxTextWidth);
 
@@ -301,7 +300,8 @@ private:
 class ScCheckListMenuWindow : public DockingWindow
 {
 public:
-    explicit ScCheckListMenuWindow(vcl::Window* pParent, ScDocument* pDoc, 
bool bCanHaveSubMenu, int nWidth = -1,
+    explicit ScCheckListMenuWindow(vcl::Window* pParent, ScDocument* pDoc,
+                                   bool bCanHaveSubMenu, bool bTreeMode, int 
nWidth = -1,
                                    ScCheckListMenuWindow* pParentMenu = 
nullptr);
     virtual void dispose() override;
     virtual ~ScCheckListMenuWindow() override;
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 0da30ebc1035..4a9759f01e13 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -653,17 +653,15 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW 
nRow)
     bool bLOKActive = comphelper::LibreOfficeKit::isActive();
 
     mpAutoFilterPopup.disposeAndClear();
-    int nColWidth = ScViewData::ToPixel(rDoc.GetColWidth(nCol, nTab), 
pViewData->GetPPTX());
-    mpAutoFilterPopup.reset(VclPtr<ScCheckListMenuWindow>::Create(this, &rDoc, 
false, nColWidth));
-    ScCheckListMenuControl& rControl = mpAutoFilterPopup->get_widget();
 
     // Estimate the width (in pixels) of the longest text in the list
     ScFilterEntries aFilterEntries;
     rDoc.GetFilterEntries(nCol, nRow, nTab, aFilterEntries);
 
-    // Set this early so the list or tree widget is selected for use before we 
might
-    // use IncreaseWindowWidthToFitText to change its width
-    rControl.setHasDates(aFilterEntries.mbHasDates);
+    int nColWidth = ScViewData::ToPixel(rDoc.GetColWidth(nCol, nTab), 
pViewData->GetPPTX());
+    mpAutoFilterPopup.reset(VclPtr<ScCheckListMenuWindow>::Create(this, &rDoc, 
false,
+                                                                  
aFilterEntries.mbHasDates, nColWidth));
+    ScCheckListMenuControl& rControl = mpAutoFilterPopup->get_widget();
 
     int nMaxTextWidth = 0;
     if (aFilterEntries.size() <= 10)
diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx
index 636559a2e132..bab2cd2e7469 100644
--- a/sc/source/ui/view/gridwin2.cxx
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -467,7 +467,8 @@ void ScGridWindow::DPLaunchFieldPopupMenu(const Point& 
rScrPos, const Size& rScr
     const ScDPLabelData& rLabelData = pDPData->maLabels;
 
     mpDPFieldPopup.disposeAndClear();
-    mpDPFieldPopup.reset(VclPtr<ScCheckListMenuWindow>::Create(this, 
&pViewData->GetDocument(), bDimOrientNotPage));
+    mpDPFieldPopup.reset(VclPtr<ScCheckListMenuWindow>::Create(this, 
&pViewData->GetDocument(),
+                                                               
bDimOrientNotPage, false));
 
     ScCheckListMenuControl& rControl = mpDPFieldPopup->get_widget();
     rControl.setExtendedData(std::move(pDPData));
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to