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

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Wed May 13 14:04:24 UTC 2020


 vcl/inc/salvtables.hxx        |   40 ++++++++
 vcl/source/app/salvtables.cxx |  190 +++++++++++++++++++-----------------------
 2 files changed, 127 insertions(+), 103 deletions(-)

New commits:
commit d090fdbc7644e8b28123212b2b9226973905368a
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Wed May 13 10:11:29 2020 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Wed May 13 16:03:41 2020 +0200

    Move SalInstanceNotebook to header file
    
    Change-Id: Id14b6fca6f12f49691a621f636300f9da320834c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94097
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index aaed72a8301b..2321e9198b6a 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -20,6 +20,8 @@
 #include <vcl/lstbox.hxx>
 #include <vcl/menubtn.hxx>
 #include <vcl/combobox.hxx>
+#include <vcl/tabctrl.hxx>
+#include <vcl/layout.hxx>
 
 class SalInstanceBuilder : public weld::Builder
 {
@@ -1005,4 +1007,42 @@ public:
     virtual ~SalInstanceButton() override;
 };
 
+class SalInstanceNotebook : public SalInstanceContainer, public virtual weld::Notebook
+{
+private:
+    VclPtr<TabControl> m_xNotebook;
+    mutable std::vector<std::unique_ptr<SalInstanceContainer>> m_aPages;
+    std::map<OString, std::pair<VclPtr<TabPage>, VclPtr<VclGrid>>> m_aAddedPages;
+
+    DECL_LINK(DeactivatePageHdl, TabControl*, bool);
+    DECL_LINK(ActivatePageHdl, TabControl*, void);
+
+public:
+    SalInstanceNotebook(TabControl* pNotebook, SalInstanceBuilder* pBuilder, bool bTakeOwnership);
+
+    virtual int get_current_page() const override;
+
+    virtual OString get_page_ident(int nPage) const override;
+
+    virtual OString get_current_page_ident() const override;
+
+    virtual weld::Container* get_page(const OString& rIdent) const override;
+
+    virtual void set_current_page(int nPage) override;
+
+    virtual void set_current_page(const OString& rIdent) override;
+
+    virtual void remove_page(const OString& rIdent) override;
+
+    virtual void insert_page(const OString& rIdent, const OUString& rLabel, int nPos) override;
+
+    virtual int get_n_pages() const override;
+
+    virtual OUString get_tab_label_text(const OString& rIdent) const override;
+
+    virtual void set_tab_label_text(const OString& rIdent, const OUString& rText) override;
+
+    virtual ~SalInstanceNotebook() override;
+};
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
\ No newline at end of file
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index b63d64df87c5..b9d8e2de83c9 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -2118,128 +2118,112 @@ IMPL_LINK_NOARG(SalInstanceScrolledWindow, HscrollHdl, ScrollBar*, void)
         m_aOrigHScrollHdl.Call(&m_xScrolledWindow->getHorzScrollBar());
 }
 
-namespace
-{
-class SalInstanceNotebook : public SalInstanceContainer, public virtual weld::Notebook
+SalInstanceNotebook::SalInstanceNotebook(TabControl* pNotebook, SalInstanceBuilder* pBuilder, bool bTakeOwnership)
+    : SalInstanceContainer(pNotebook, pBuilder, bTakeOwnership)
+    , m_xNotebook(pNotebook)
 {
-private:
-    VclPtr<TabControl> m_xNotebook;
-    mutable std::vector<std::unique_ptr<SalInstanceContainer>> m_aPages;
-    std::map<OString, std::pair<VclPtr<TabPage>, VclPtr<VclGrid>>> m_aAddedPages;
+    m_xNotebook->SetActivatePageHdl(LINK(this, SalInstanceNotebook, ActivatePageHdl));
+    m_xNotebook->SetDeactivatePageHdl(LINK(this, SalInstanceNotebook, DeactivatePageHdl));
+}
 
-    DECL_LINK(DeactivatePageHdl, TabControl*, bool);
-    DECL_LINK(ActivatePageHdl, TabControl*, void);
+int SalInstanceNotebook::get_current_page() const
+{
+    return m_xNotebook->GetPagePos(m_xNotebook->GetCurPageId());
+}
 
-public:
-    SalInstanceNotebook(TabControl* pNotebook, SalInstanceBuilder* pBuilder, bool bTakeOwnership)
-        : SalInstanceContainer(pNotebook, pBuilder, bTakeOwnership)
-        , m_xNotebook(pNotebook)
-    {
-        m_xNotebook->SetActivatePageHdl(LINK(this, SalInstanceNotebook, ActivatePageHdl));
-        m_xNotebook->SetDeactivatePageHdl(LINK(this, SalInstanceNotebook, DeactivatePageHdl));
-    }
+OString SalInstanceNotebook::get_page_ident(int nPage) const
+{
+    return m_xNotebook->GetPageName(m_xNotebook->GetPageId(nPage));
+}
 
-    virtual int get_current_page() const override
-    {
-        return m_xNotebook->GetPagePos(m_xNotebook->GetCurPageId());
-    }
+OString SalInstanceNotebook::get_current_page_ident() const
+{
+    return m_xNotebook->GetPageName(m_xNotebook->GetCurPageId());
+}
 
-    virtual OString get_page_ident(int nPage) const override
-    {
-        return m_xNotebook->GetPageName(m_xNotebook->GetPageId(nPage));
-    }
+weld::Container* SalInstanceNotebook::get_page(const OString& rIdent) const
+{
+    sal_uInt16 nPageId = m_xNotebook->GetPageId(rIdent);
+    sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(nPageId);
+    if (nPageIndex == TAB_PAGE_NOTFOUND)
+        return nullptr;
+    TabPage* pPage = m_xNotebook->GetTabPage(nPageId);
+    vcl::Window* pChild = pPage->GetChild(0);
+    if (m_aPages.size() < nPageIndex + 1U)
+        m_aPages.resize(nPageIndex + 1U);
+    if (!m_aPages[nPageIndex])
+        m_aPages[nPageIndex].reset(new SalInstanceContainer(pChild, m_pBuilder, false));
+    return m_aPages[nPageIndex].get();
+}
 
-    virtual OString get_current_page_ident() const override
-    {
-        return m_xNotebook->GetPageName(m_xNotebook->GetCurPageId());
-    }
+void SalInstanceNotebook::set_current_page(int nPage)
+{
+    m_xNotebook->SetCurPageId(m_xNotebook->GetPageId(nPage));
+}
 
-    virtual weld::Container* get_page(const OString& rIdent) const override
-    {
-        sal_uInt16 nPageId = m_xNotebook->GetPageId(rIdent);
-        sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(nPageId);
-        if (nPageIndex == TAB_PAGE_NOTFOUND)
-            return nullptr;
-        TabPage* pPage = m_xNotebook->GetTabPage(nPageId);
-        vcl::Window* pChild = pPage->GetChild(0);
-        if (m_aPages.size() < nPageIndex + 1U)
-            m_aPages.resize(nPageIndex + 1U);
-        if (!m_aPages[nPageIndex])
-            m_aPages[nPageIndex].reset(new SalInstanceContainer(pChild, m_pBuilder, false));
-        return m_aPages[nPageIndex].get();
-    }
+void SalInstanceNotebook::set_current_page(const OString& rIdent)
+{
+    m_xNotebook->SetCurPageId(m_xNotebook->GetPageId(rIdent));
+}
 
-    virtual void set_current_page(int nPage) override
-    {
-        m_xNotebook->SetCurPageId(m_xNotebook->GetPageId(nPage));
-    }
+void SalInstanceNotebook::remove_page(const OString& rIdent)
+{
+    sal_uInt16 nPageId = m_xNotebook->GetPageId(rIdent);
+    sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(nPageId);
+    if (nPageIndex == TAB_PAGE_NOTFOUND)
+        return;
 
-    virtual void set_current_page(const OString& rIdent) override
-    {
-        m_xNotebook->SetCurPageId(m_xNotebook->GetPageId(rIdent));
-    }
+    m_xNotebook->RemovePage(nPageId);
+    if (nPageIndex < m_aPages.size())
+        m_aPages.erase(m_aPages.begin() + nPageIndex);
 
-    virtual void remove_page(const OString& rIdent) override
+    auto iter = m_aAddedPages.find(rIdent);
+    if (iter != m_aAddedPages.end())
     {
-        sal_uInt16 nPageId = m_xNotebook->GetPageId(rIdent);
-        sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(nPageId);
-        if (nPageIndex == TAB_PAGE_NOTFOUND)
-            return;
-
-        m_xNotebook->RemovePage(nPageId);
-        if (nPageIndex < m_aPages.size())
-            m_aPages.erase(m_aPages.begin() + nPageIndex);
-
-        auto iter = m_aAddedPages.find(rIdent);
-        if (iter != m_aAddedPages.end())
-        {
-            iter->second.second.disposeAndClear();
-            iter->second.first.disposeAndClear();
-            m_aAddedPages.erase(iter);
-        }
+        iter->second.second.disposeAndClear();
+        iter->second.first.disposeAndClear();
+        m_aAddedPages.erase(iter);
     }
+}
 
-    virtual void insert_page(const OString& rIdent, const OUString& rLabel, int nPos) override
-    {
-        sal_uInt16 nPageCount = m_xNotebook->GetPageCount();
-        sal_uInt16 nLastPageId = nPageCount ? m_xNotebook->GetPageId(nPageCount - 1) : 0;
-        sal_uInt16 nNewPageId = nLastPageId + 1;
-        m_xNotebook->InsertPage(nNewPageId, rLabel, nPos == -1 ? TAB_APPEND : nPos);
-        VclPtrInstance<TabPage> xPage(m_xNotebook);
-        VclPtrInstance<VclGrid> xGrid(xPage);
-        xPage->Show();
-        xGrid->set_hexpand(true);
-        xGrid->set_vexpand(true);
-        xGrid->Show();
-        m_xNotebook->SetTabPage(nNewPageId, xPage);
-        m_xNotebook->SetPageName(nNewPageId, rIdent);
-        m_aAddedPages.try_emplace(rIdent, xPage, xGrid);
-    }
+void SalInstanceNotebook::insert_page(const OString& rIdent, const OUString& rLabel, int nPos)
+{
+    sal_uInt16 nPageCount = m_xNotebook->GetPageCount();
+    sal_uInt16 nLastPageId = nPageCount ? m_xNotebook->GetPageId(nPageCount - 1) : 0;
+    sal_uInt16 nNewPageId = nLastPageId + 1;
+    m_xNotebook->InsertPage(nNewPageId, rLabel, nPos == -1 ? TAB_APPEND : nPos);
+    VclPtrInstance<TabPage> xPage(m_xNotebook);
+    VclPtrInstance<VclGrid> xGrid(xPage);
+    xPage->Show();
+    xGrid->set_hexpand(true);
+    xGrid->set_vexpand(true);
+    xGrid->Show();
+    m_xNotebook->SetTabPage(nNewPageId, xPage);
+    m_xNotebook->SetPageName(nNewPageId, rIdent);
+    m_aAddedPages.try_emplace(rIdent, xPage, xGrid);
+}
 
-    virtual int get_n_pages() const override { return m_xNotebook->GetPageCount(); }
+int SalInstanceNotebook::get_n_pages() const { return m_xNotebook->GetPageCount(); }
 
-    virtual OUString get_tab_label_text(const OString& rIdent) const override
-    {
-        return m_xNotebook->GetPageText(m_xNotebook->GetPageId(rIdent));
-    }
+OUString SalInstanceNotebook::get_tab_label_text(const OString& rIdent) const
+{
+    return m_xNotebook->GetPageText(m_xNotebook->GetPageId(rIdent));
+}
 
-    virtual void set_tab_label_text(const OString& rIdent, const OUString& rText) override
-    {
-        return m_xNotebook->SetPageText(m_xNotebook->GetPageId(rIdent), rText);
-    }
+void SalInstanceNotebook::set_tab_label_text(const OString& rIdent, const OUString& rText)
+{
+    return m_xNotebook->SetPageText(m_xNotebook->GetPageId(rIdent), rText);
+}
 
-    virtual ~SalInstanceNotebook() override
+SalInstanceNotebook::~SalInstanceNotebook()
+{
+    for (auto& rItem : m_aAddedPages)
     {
-        for (auto& rItem : m_aAddedPages)
-        {
-            rItem.second.second.disposeAndClear();
-            rItem.second.first.disposeAndClear();
-        }
-        m_xNotebook->SetActivatePageHdl(Link<TabControl*, void>());
-        m_xNotebook->SetDeactivatePageHdl(Link<TabControl*, bool>());
+        rItem.second.second.disposeAndClear();
+        rItem.second.first.disposeAndClear();
     }
-};
-
+    m_xNotebook->SetActivatePageHdl(Link<TabControl*, void>());
+    m_xNotebook->SetDeactivatePageHdl(Link<TabControl*, bool>());
 }
 
 IMPL_LINK_NOARG(SalInstanceNotebook, DeactivatePageHdl, TabControl*, bool)


More information about the Libreoffice-commits mailing list