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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Mar 5 16:54:19 UTC 2021


 sd/source/ui/sidebar/LayoutMenu.cxx |   32 +++++++++++++++++++++-----------
 sd/source/ui/sidebar/LayoutMenu.hxx |   11 -----------
 2 files changed, 21 insertions(+), 22 deletions(-)

New commits:
commit ee499ffe6727c36a7cf6fd2a9c6f8a52b8a111c8
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Mar 5 11:44:13 2021 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Mar 5 17:53:25 2021 +0100

    move valueset resize into LayoutValueSet class
    
    Change-Id: If1a5dbcdac95a167779b30c26f4aa61bbe104cce
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112011
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sd/source/ui/sidebar/LayoutMenu.cxx b/sd/source/ui/sidebar/LayoutMenu.cxx
index e435bdcdcde0..513623a47fe9 100644
--- a/sd/source/ui/sidebar/LayoutMenu.cxx
+++ b/sd/source/ui/sidebar/LayoutMenu.cxx
@@ -132,6 +132,15 @@ class LayoutValueSet : public ValueSet
 {
 private:
     LayoutMenu& mrMenu;
+
+    /** Calculate the number of displayed rows.  This depends on the given
+        item size, the given number of columns, and the size of the
+        control.  Note that this is not the number of rows managed by the
+        valueset.  This number may be larger.  In that case a vertical
+        scroll bar is displayed.
+    */
+    int CalculateRowCount(const Size& rItemSize, int nColumnCount);
+
 public:
     LayoutValueSet(LayoutMenu& rMenu)
         : ValueSet(nullptr)
@@ -139,6 +148,8 @@ public:
     {
     }
 
+    virtual void Resize() override;
+
     virtual bool Command(const CommandEvent& rEvent) override
     {
         if (rEvent.GetCommand() == CommandEventId::ContextMenu)
@@ -272,16 +283,16 @@ ui::LayoutSize LayoutMenu::GetHeightForWidth (const sal_Int32 nWidth)
     return ui::LayoutSize(nPreferredHeight,nPreferredHeight,nPreferredHeight);
 }
 
-void LayoutMenu::Resize()
+void LayoutValueSet::Resize()
 {
     Size aWindowSize = GetOutputSizePixel();
     if (IsVisible() && aWindowSize.Width() > 0)
     {
         // Calculate the number of rows and columns.
-        if (mxLayoutValueSet->GetItemCount() > 0)
+        if (GetItemCount() > 0)
         {
-            Image aImage = mxLayoutValueSet->GetItemImage(mxLayoutValueSet->GetItemId(0));
-            Size aItemSize = mxLayoutValueSet->CalcItemSizePixel (
+            Image aImage = GetItemImage(GetItemId(0));
+            Size aItemSize = CalcItemSizePixel (
                 aImage.GetSizePixel());
             aItemSize.AdjustWidth(8 );
             aItemSize.AdjustHeight(8 );
@@ -293,12 +304,12 @@ void LayoutMenu::Resize()
 
             int nRowCount = CalculateRowCount (aItemSize, nColumnCount);
 
-            mxLayoutValueSet->SetColCount(nColumnCount);
-            mxLayoutValueSet->SetLineCount(nRowCount);
+            SetColCount(nColumnCount);
+            SetLineCount(nRowCount);
         }
     }
 
-    mxLayoutValueSet->Resize();
+    ValueSet::Resize();
 }
 
 void LayoutMenu::MouseButtonDown (const MouseEvent& rEvent)
@@ -356,14 +367,13 @@ void LayoutMenu::InvalidateContent()
     UpdateSelection();
 }
 
-int LayoutMenu::CalculateRowCount (const Size&, int nColumnCount)
+int LayoutValueSet::CalculateRowCount (const Size&, int nColumnCount)
 {
     int nRowCount = 0;
 
-    if (mxLayoutValueSet->GetItemCount() > 0 && nColumnCount > 0)
+    if (GetItemCount() > 0 && nColumnCount > 0)
     {
-        nRowCount = (mxLayoutValueSet->GetItemCount() + nColumnCount - 1) / nColumnCount;
-        //        nRowCount = GetOutputSizePixel().Height() / rItemSize.Height();
+        nRowCount = (GetItemCount() + nColumnCount - 1) / nColumnCount;
         if (nRowCount < 1)
             nRowCount = 1;
     }
diff --git a/sd/source/ui/sidebar/LayoutMenu.hxx b/sd/source/ui/sidebar/LayoutMenu.hxx
index b9eb1d167177..c93ac3e410d7 100644
--- a/sd/source/ui/sidebar/LayoutMenu.hxx
+++ b/sd/source/ui/sidebar/LayoutMenu.hxx
@@ -77,9 +77,6 @@ public:
     // From ILayoutableWindow
     virtual css::ui::LayoutSize GetHeightForWidth(const sal_Int32 nWidth) override;
 
-    // From vcl::Window
-    virtual void Resize() override;
-
     /** Show a context menu when the right mouse button is pressed.
     */
     virtual void MouseButtonDown(const MouseEvent& rEvent) override;
@@ -115,14 +112,6 @@ private:
     css::uno::Reference<css::ui::XSidebar> mxSidebar;
     bool mbIsDisposed;
 
-    /** Calculate the number of displayed rows.  This depends on the given
-        item size, the given number of columns, and the size of the
-        control.  Note that this is not the number of rows managed by the
-        valueset.  This number may be larger.  In that case a vertical
-        scroll bar is displayed.
-    */
-    int CalculateRowCount(const Size& rItemSize, int nColumnCount);
-
     /** Fill the value set with the layouts that are applicable to the
         current main view shell.
     */


More information about the Libreoffice-commits mailing list