[Libreoffice-commits] core.git: include/vcl vcl/source vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon Jun 22 15:32:54 UTC 2020


 include/vcl/salvtables.hxx    |    2 +
 include/vcl/weld.hxx          |    1 
 vcl/source/app/salvtables.cxx |   21 ++++++++++++-
 vcl/unx/gtk3/gtk3gtkinst.cxx  |   64 +++++++++++++++++++++---------------------
 4 files changed, 54 insertions(+), 34 deletions(-)

New commits:
commit a5a8731ce214bcd5ce1c95155b0538ff2d9d337e
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Jun 22 11:26:39 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Jun 22 17:32:16 2020 +0200

    add get_page_index
    
    Change-Id: Id90e8fc3fc2f7fa88368e02eaa492b8fc21138e0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96859
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/vcl/salvtables.hxx b/include/vcl/salvtables.hxx
index fbb87a1dc907..1dc2d6a0cadd 100644
--- a/include/vcl/salvtables.hxx
+++ b/include/vcl/salvtables.hxx
@@ -1037,6 +1037,8 @@ public:
 
     virtual int get_current_page() const override;
 
+    virtual int get_page_index(const OString& rIdent) const override;
+
     virtual OString get_page_ident(int nPage) const override;
 
     virtual OString get_current_page_ident() const override;
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index e14c2c0d5ed3..2e0134a8c4a4 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -374,6 +374,7 @@ protected:
 
 public:
     virtual int get_current_page() const = 0;
+    virtual int get_page_index(const OString& rIdent) const = 0;
     virtual OString get_page_ident(int nPage) const = 0;
     virtual OString get_current_page_ident() const = 0;
     virtual void set_current_page(int nPage) = 0;
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 116c974d1d6a..3e294b4164e5 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -2175,12 +2175,21 @@ OString SalInstanceNotebook::get_current_page_ident() const
     return m_xNotebook->GetPageName(m_xNotebook->GetCurPageId());
 }
 
-weld::Container* SalInstanceNotebook::get_page(const OString& rIdent) const
+int SalInstanceNotebook::get_page_index(const OString& rIdent) const
 {
     sal_uInt16 nPageId = m_xNotebook->GetPageId(rIdent);
     sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(nPageId);
     if (nPageIndex == TAB_PAGE_NOTFOUND)
+        return -1;
+    return nPageIndex;
+}
+
+weld::Container* SalInstanceNotebook::get_page(const OString& rIdent) const
+{
+    int nPageIndex = get_page_index(rIdent);
+    if (nPageIndex == -1)
         return nullptr;
+    sal_uInt16 nPageId = m_xNotebook->GetPageId(rIdent);
     TabPage* pPage = m_xNotebook->GetTabPage(nPageId);
     vcl::Window* pChild = pPage->GetChild(0);
     if (m_aPages.size() < nPageIndex + 1U)
@@ -2304,10 +2313,18 @@ public:
 
     virtual OString get_current_page_ident() const override { return m_xNotebook->GetCurPageId(); }
 
-    virtual weld::Container* get_page(const OString& rIdent) const override
+    virtual int get_page_index(const OString& rIdent) const override
     {
         sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(rIdent);
         if (nPageIndex == TAB_PAGE_NOTFOUND)
+            return -1;
+        return nPageIndex;
+    }
+
+    virtual weld::Container* get_page(const OString& rIdent) const override
+    {
+        int nPageIndex = get_page_index(rIdent);
+        if (nPageIndex == -1)
             return nullptr;
         auto pChild = m_xNotebook->GetPage(rIdent);
         if (m_aPages.size() < nPageIndex + 1U)
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 26e1742f7e61..df717239e62c 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -6108,36 +6108,6 @@ private:
         enable_notify_events();
     }
 
-    gint get_page_number(const OString& rIdent) const
-    {
-        auto nMainIndex = get_page_number(m_pNotebook, rIdent);
-        auto nOverFlowIndex = get_page_number(m_pOverFlowNotebook, rIdent);
-
-        if (nMainIndex == -1 && nOverFlowIndex == -1)
-            return -1;
-
-        if (m_bOverFlowBoxIsStart)
-        {
-            if (nOverFlowIndex != -1)
-                return nOverFlowIndex;
-            else
-            {
-                auto nOverFlowLen = m_bOverFlowBoxActive ? gtk_notebook_get_n_pages(m_pOverFlowNotebook) - 1 : 0;
-                return nMainIndex + nOverFlowLen;
-            }
-        }
-        else
-        {
-            if (nMainIndex != -1)
-                return nMainIndex;
-            else
-            {
-                auto nMainLen = gtk_notebook_get_n_pages(m_pNotebook);
-                return nOverFlowIndex + nMainLen;
-            }
-        }
-    }
-
     void make_overflow_boxes()
     {
         m_pOverFlowBox = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
@@ -6417,9 +6387,39 @@ public:
         return nPage != -1 ? get_page_ident(nPage) : OString();
     }
 
+    virtual int get_page_index(const OString& rIdent) const override
+    {
+        auto nMainIndex = get_page_number(m_pNotebook, rIdent);
+        auto nOverFlowIndex = get_page_number(m_pOverFlowNotebook, rIdent);
+
+        if (nMainIndex == -1 && nOverFlowIndex == -1)
+            return -1;
+
+        if (m_bOverFlowBoxIsStart)
+        {
+            if (nOverFlowIndex != -1)
+                return nOverFlowIndex;
+            else
+            {
+                auto nOverFlowLen = m_bOverFlowBoxActive ? gtk_notebook_get_n_pages(m_pOverFlowNotebook) - 1 : 0;
+                return nMainIndex + nOverFlowLen;
+            }
+        }
+        else
+        {
+            if (nMainIndex != -1)
+                return nMainIndex;
+            else
+            {
+                auto nMainLen = gtk_notebook_get_n_pages(m_pNotebook);
+                return nOverFlowIndex + nMainLen;
+            }
+        }
+    }
+
     virtual weld::Container* get_page(const OString& rIdent) const override
     {
-        int nPage = get_page_number(rIdent);
+        int nPage = get_page_index(rIdent);
         if (nPage < 0)
             return nullptr;
 
@@ -6492,7 +6492,7 @@ public:
 
     virtual void set_current_page(const OString& rIdent) override
     {
-        gint nPage = get_page_number(rIdent);
+        gint nPage = get_page_index(rIdent);
         set_current_page(nPage);
     }
 


More information about the Libreoffice-commits mailing list