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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 16 16:28:36 UTC 2020


 sc/source/ui/cctrl/checklistmenu.cxx |   23 ++++++++++++-----------
 sc/source/ui/inc/checklistmenu.hxx   |    3 ++-
 sc/source/ui/view/gridwin.cxx        |    3 ++-
 sc/source/ui/view/gridwin2.cxx       |    3 ++-
 4 files changed, 18 insertions(+), 14 deletions(-)

New commits:
commit 0747e8b98089803d6b66bc8ede3e961c2471f455
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Jun 16 15:44:57 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Jun 16 18:28:00 2020 +0200

    size width request to fit column hint
    
    Change-Id: I1439984e4ff52bebb1c1e777c1cdffcc5820c169
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96472
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx
index f24114423b90..7a4d8348f913 100644
--- a/sc/source/ui/cctrl/checklistmenu.cxx
+++ b/sc/source/ui/cctrl/checklistmenu.cxx
@@ -460,7 +460,8 @@ ScCheckListMenuControl::ScCheckListMenuControl(ScCheckListMenuWindow* pParent, v
     , mxBtnCancel(mxBuilder->weld_button("cancel"))
     , mxDropDown(mxMenu->create_virtual_device())
     , mnWidthHint(nWidth)
-    , maWndSize()
+    , mnCheckWidthReq(-1)
+    , mnWndWidth(0)
     , mePrevToggleAllState(TRISTATE_INDET)
     , mnSelectedMenu(MENU_NOT_SELECTED)
     , mpDoc(pDoc)
@@ -470,6 +471,9 @@ ScCheckListMenuControl::ScCheckListMenuControl(ScCheckListMenuWindow* pParent, v
     , maOpenTimer(this)
     , maCloseTimer(this)
 {
+    if (mnWidthHint != -1)
+        mnCheckWidthReq = mnWidthHint - mxFrame->get_border_width() * 2 - 4;
+
     // sort ok/cancel into native order, if this was a dialog they would be auto-sorted, but this
     // popup isn't a true dialog
     mxButtonBox->sort_native_button_order();
@@ -521,9 +525,10 @@ ScCheckListMenuWindow::ScCheckListMenuWindow(vcl::Window* pParent, ScDocument* p
     : DockingWindow(pParent, "InterimDockParent", "svx/ui/interimdockparent.ui")
     , mxParentMenu(pParentMenu)
     , mxBox(get("box"))
-    , mxControl(new ScCheckListMenuControl(this, mxBox.get(), pDoc, bCanHaveSubMenu, nWidth))
     , mnMenuStackLevel(nMenuStackLevel)
 {
+    setDeferredProperties();
+    mxControl.reset(new ScCheckListMenuControl(this, mxBox.get(), pDoc, bCanHaveSubMenu, nWidth));
     SetBackground(Application::GetSettings().GetStyleSettings().GetMenuColor());
     set_id("check_list_menu");
 }
@@ -576,18 +581,14 @@ void ScCheckListMenuControl::packWindow()
     mxBtnSelectSingle->connect_clicked(LINK(this, ScCheckListMenuControl, ButtonHdl));
     mxBtnUnselectSingle->connect_clicked(LINK(this, ScCheckListMenuControl, ButtonHdl));
 
-    mxChecks->set_size_request(-1, mxChecks->get_height_rows(9));
+    mxChecks->set_size_request(mnCheckWidthReq, mxChecks->get_height_rows(9));
+
     mxMenu->set_size_request(-1, mxMenu->get_preferred_size().Height() + 2);
     mnSelectedMenu = 0;
     mxMenu->set_cursor(mnSelectedMenu);
     mxMenu->unselect_all();
 
-    maWndSize = mxContainer->get_preferred_size();
-    if (maWndSize.Width() < mnWidthHint)
-    {
-        mxContainer->set_size_request(mnWidthHint, -1);
-        maWndSize.setWidth(mnWidthHint);
-    }
+    mnWndWidth = mxContainer->get_preferred_size().Width() + mxFrame->get_border_width() * 2 + 4;
 }
 
 void ScCheckListMenuControl::setAllMemberState(bool bSet)
@@ -1291,12 +1292,12 @@ void ScCheckListMenuControl::launch(const tools::Rectangle& rRect)
         long nLeft = aRect.Left() - aRect.GetWidth();
         aRect.SetLeft( nLeft );
     }
-    else if (maWndSize.Width() < aRect.GetWidth())
+    else if (mnWndWidth < aRect.GetWidth())
     {
         // Target rectangle (i.e. cell width) is wider than the window.
         // Simulate right-aligned launch by modifying the target rectangle
         // size.
-        long nDiff = aRect.GetWidth() - maWndSize.Width();
+        long nDiff = aRect.GetWidth() - mnWndWidth;
         aRect.AdjustLeft(nDiff );
     }
 
diff --git a/sc/source/ui/inc/checklistmenu.hxx b/sc/source/ui/inc/checklistmenu.hxx
index 02c966d8f13d..6eb474cf20b4 100644
--- a/sc/source/ui/inc/checklistmenu.hxx
+++ b/sc/source/ui/inc/checklistmenu.hxx
@@ -283,7 +283,8 @@ private:
 
     Config maConfig;
     int mnWidthHint; /// min width hint
-    Size maWndSize;  /// whole window size.
+    int mnCheckWidthReq; /// matching width request for mxChecks
+    int mnWndWidth;  /// whole window width.
     Size maMenuSize; /// size of all menu items combined.
     TriState mePrevToggleAllState;
 
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 1d3d189e92e3..7a569795b630 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -719,7 +719,6 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
         else
             rControl.addMember(aVal, bSelected);
     }
-    rControl.initMembers();
 
     // Populate the menu.
     rControl.addMenuItem(
@@ -739,6 +738,8 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
     rControl.addMenuItem(
         ScResId(SCSTR_STDFILTER), new AutoFilterAction(this, AutoFilterMode::Custom));
 
+    rControl.initMembers();
+
     ScCheckListMenuControl::Config aConfig;
     aConfig.mbAllowEmptySet = false;
     aConfig.mbRTL = pViewData->GetDocument()->IsLayoutRTL(pViewData->GetTabNo());
diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx
index 71a68605d1d2..2bf3eab908f6 100644
--- a/sc/source/ui/view/gridwin2.cxx
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -486,7 +486,6 @@ void ScGridWindow::DPLaunchFieldPopupMenu(const Point& rScrPos, const Size& rScr
             else
                 rControl.addMember(rMem.getDisplayName(), rMem.mbVisible);
         }
-        rControl.initMembers();
     }
 
     if (bDimOrientNotPage)
@@ -527,6 +526,8 @@ void ScGridWindow::DPLaunchFieldPopupMenu(const Point& rScrPos, const Size& rScr
         }
     }
 
+    rControl.initMembers();
+
     tools::Rectangle aCellRect(rScrPos, rScrSize);
 
     ScCheckListMenuControl::Config aConfig;


More information about the Libreoffice-commits mailing list