summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2021-01-12 16:10:58 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2021-01-14 10:21:05 +0100
commit5ade3c6ce8324247a5a3bc052b4299115c5a8471 (patch)
tree60df9fba297e939286c34d184221f02af016eca3
parentc87b1a887462cd3842eb90c9d6c50193c2d350f1 (diff)
Move SalInstanceIconView decl to header file
Change-Id: I179f044b3db38ee51f539ef4023b136eac55f4ed Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108982 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109182 Tested-by: Jenkins
-rw-r--r--vcl/inc/salvtables.hxx59
-rw-r--r--vcl/source/app/salvtables.cxx415
2 files changed, 260 insertions, 214 deletions
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index c435230653c5..562621251215 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -27,6 +27,7 @@
#include <vcl/toolkit/svtabbx.hxx>
#include <vcl/toolkit/svlbitm.hxx>
#include <o3tl/sorted_vector.hxx>
+#include "iconview.hxx"
class SalInstanceBuilder : public weld::Builder
{
@@ -1704,4 +1705,62 @@ public:
virtual ~SalInstanceExpander() override;
};
+class SalInstanceIconView : public SalInstanceContainer, public virtual weld::IconView
+{
+private:
+ // owner for UserData
+ std::vector<std::unique_ptr<OUString>> m_aUserData;
+ VclPtr<::IconView> m_xIconView;
+
+ DECL_LINK(SelectHdl, SvTreeListBox*, void);
+ DECL_LINK(DeSelectHdl, SvTreeListBox*, void);
+ DECL_LINK(DoubleClickHdl, SvTreeListBox*, bool);
+
+public:
+ SalInstanceIconView(::IconView* pIconView, SalInstanceBuilder* pBuilder, bool bTakeOwnership);
+
+ virtual void freeze() override;
+
+ virtual void thaw() override;
+
+ virtual void insert(int pos, const OUString* pStr, const OUString* pId,
+ const OUString* pIconName, weld::TreeIter* pRet) override;
+
+ virtual void insert(int pos, const OUString* pStr, const OUString* pId,
+ const VirtualDevice* pIcon, weld::TreeIter* pRet) override;
+
+ virtual OUString get_selected_id() const override;
+
+ virtual OUString get_selected_text() const override;
+
+ virtual int count_selected_items() const override;
+
+ virtual void select(int pos) override;
+
+ virtual void unselect(int pos) override;
+
+ virtual int n_children() const override;
+
+ virtual std::unique_ptr<weld::TreeIter> make_iterator(const weld::TreeIter* pOrig
+ = nullptr) const override;
+
+ virtual bool get_selected(weld::TreeIter* pIter) const override;
+
+ virtual bool get_cursor(weld::TreeIter* pIter) const override;
+
+ virtual void set_cursor(const weld::TreeIter& rIter) override;
+
+ virtual bool get_iter_first(weld::TreeIter& rIter) const override;
+
+ virtual void scroll_to_item(const weld::TreeIter& rIter) override;
+
+ virtual void selected_foreach(const std::function<bool(weld::TreeIter&)>& func) override;
+
+ virtual OUString get_id(const weld::TreeIter& rIter) const override;
+
+ virtual void clear() override;
+
+ virtual ~SalInstanceIconView() override;
+};
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 0aa3db724e91..cb806a5174bd 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -26,7 +26,6 @@
#include <com/sun/star/awt/XWindowPeer.hpp>
#include <o3tl/sorted_vector.hxx>
#include <officecfg/Office/Common.hxx>
-#include <iconview.hxx>
#include <salframe.hxx>
#include <salinst.hxx>
#include <salvd.hxx>
@@ -5043,264 +5042,252 @@ IMPL_LINK(SalInstanceTreeView, EditedEntryHdl, IterString, rIterString, bool)
iter_string(SalInstanceTreeIter(rIterString.first), rIterString.second));
}
-class SalInstanceIconView : public SalInstanceContainer, public virtual weld::IconView
+SalInstanceIconView::SalInstanceIconView(::IconView* pIconView, SalInstanceBuilder* pBuilder,
+ bool bTakeOwnership)
+ : SalInstanceContainer(pIconView, pBuilder, bTakeOwnership)
+ , m_xIconView(pIconView)
{
-private:
- // owner for UserData
- std::vector<std::unique_ptr<OUString>> m_aUserData;
- VclPtr<::IconView> m_xIconView;
+ m_xIconView->SetSelectHdl(LINK(this, SalInstanceIconView, SelectHdl));
+ m_xIconView->SetDeselectHdl(LINK(this, SalInstanceIconView, DeSelectHdl));
+ m_xIconView->SetDoubleClickHdl(LINK(this, SalInstanceIconView, DoubleClickHdl));
+}
- DECL_LINK(SelectHdl, SvTreeListBox*, void);
- DECL_LINK(DeSelectHdl, SvTreeListBox*, void);
- DECL_LINK(DoubleClickHdl, SvTreeListBox*, bool);
+void SalInstanceIconView::freeze()
+{
+ SalInstanceWidget::freeze();
+ m_xIconView->SetUpdateMode(false);
+}
-public:
- SalInstanceIconView(::IconView* pIconView, SalInstanceBuilder* pBuilder, bool bTakeOwnership)
- : SalInstanceContainer(pIconView, pBuilder, bTakeOwnership)
- , m_xIconView(pIconView)
+void SalInstanceIconView::thaw()
+{
+ m_xIconView->SetUpdateMode(true);
+ SalInstanceWidget::thaw();
+}
+
+void SalInstanceIconView::insert(int pos, const OUString* pStr, const OUString* pId,
+ const OUString* pIconName, weld::TreeIter* pRet)
+{
+ disable_notify_events();
+ auto nInsertPos = pos == -1 ? TREELIST_APPEND : pos;
+ void* pUserData;
+ if (pId)
{
- m_xIconView->SetSelectHdl(LINK(this, SalInstanceIconView, SelectHdl));
- m_xIconView->SetDeselectHdl(LINK(this, SalInstanceIconView, DeSelectHdl));
- m_xIconView->SetDoubleClickHdl(LINK(this, SalInstanceIconView, DoubleClickHdl));
+ m_aUserData.emplace_back(std::make_unique<OUString>(*pId));
+ pUserData = m_aUserData.back().get();
}
+ else
+ pUserData = nullptr;
- virtual void freeze() override
+ SvTreeListEntry* pEntry = new SvTreeListEntry;
+ if (pIconName)
{
- SalInstanceWidget::freeze();
- m_xIconView->SetUpdateMode(false);
+ Image aImage(createImage(*pIconName));
+ pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aImage, aImage, false));
}
-
- virtual void thaw() override
+ else
{
- m_xIconView->SetUpdateMode(true);
- SalInstanceWidget::thaw();
+ Image aDummy;
+ pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aDummy, aDummy, false));
}
+ if (pStr)
+ pEntry->AddItem(std::make_unique<SvLBoxString>(*pStr));
+ pEntry->SetUserData(pUserData);
+ m_xIconView->Insert(pEntry, nullptr, nInsertPos);
- virtual void insert(int pos, const OUString* pStr, const OUString* pId,
- const OUString* pIconName, weld::TreeIter* pRet) override
+ if (pRet)
{
- disable_notify_events();
- auto nInsertPos = pos == -1 ? TREELIST_APPEND : pos;
- void* pUserData;
- if (pId)
- {
- m_aUserData.emplace_back(std::make_unique<OUString>(*pId));
- pUserData = m_aUserData.back().get();
- }
- else
- pUserData = nullptr;
-
- SvTreeListEntry* pEntry = new SvTreeListEntry;
- if (pIconName)
- {
- Image aImage(createImage(*pIconName));
- pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aImage, aImage, false));
- }
- else
- {
- Image aDummy;
- pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aDummy, aDummy, false));
- }
- if (pStr)
- pEntry->AddItem(std::make_unique<SvLBoxString>(*pStr));
- pEntry->SetUserData(pUserData);
- m_xIconView->Insert(pEntry, nullptr, nInsertPos);
+ SalInstanceTreeIter* pVclRetIter = static_cast<SalInstanceTreeIter*>(pRet);
+ pVclRetIter->iter = pEntry;
+ }
- if (pRet)
- {
- SalInstanceTreeIter* pVclRetIter = static_cast<SalInstanceTreeIter*>(pRet);
- pVclRetIter->iter = pEntry;
- }
+ enable_notify_events();
+}
- enable_notify_events();
+void SalInstanceIconView::insert(int pos, const OUString* pStr, const OUString* pId,
+ const VirtualDevice* pIcon, weld::TreeIter* pRet)
+{
+ disable_notify_events();
+ auto nInsertPos = pos == -1 ? TREELIST_APPEND : pos;
+ void* pUserData;
+ if (pId)
+ {
+ m_aUserData.emplace_back(std::make_unique<OUString>(*pId));
+ pUserData = m_aUserData.back().get();
}
+ else
+ pUserData = nullptr;
- virtual void insert(int pos, const OUString* pStr, const OUString* pId,
- const VirtualDevice* pIcon, weld::TreeIter* pRet) override
+ SvTreeListEntry* pEntry = new SvTreeListEntry;
+ if (pIcon)
{
- disable_notify_events();
- auto nInsertPos = pos == -1 ? TREELIST_APPEND : pos;
- void* pUserData;
- if (pId)
- {
- m_aUserData.emplace_back(std::make_unique<OUString>(*pId));
- pUserData = m_aUserData.back().get();
- }
- else
- pUserData = nullptr;
-
- SvTreeListEntry* pEntry = new SvTreeListEntry;
- if (pIcon)
- {
- const Point aNull(0, 0);
- const Size aSize = pIcon->GetOutputSizePixel();
- Image aImage(pIcon->GetBitmapEx(aNull, aSize));
- pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aImage, aImage, false));
- }
- else
- {
- Image aDummy;
- pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aDummy, aDummy, false));
- }
- if (pStr)
- pEntry->AddItem(std::make_unique<SvLBoxString>(*pStr));
- pEntry->SetUserData(pUserData);
- m_xIconView->Insert(pEntry, nullptr, nInsertPos);
-
- if (pRet)
- {
- SalInstanceTreeIter* pVclRetIter = static_cast<SalInstanceTreeIter*>(pRet);
- pVclRetIter->iter = pEntry;
- }
-
- enable_notify_events();
+ const Point aNull(0, 0);
+ const Size aSize = pIcon->GetOutputSizePixel();
+ Image aImage(pIcon->GetBitmapEx(aNull, aSize));
+ pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aImage, aImage, false));
}
-
- virtual OUString get_selected_id() const override
+ else
{
- assert(m_xIconView->IsUpdateMode() && "don't request selection when frozen");
- if (SvTreeListEntry* pEntry = m_xIconView->FirstSelected())
- {
- if (const OUString* pStr = static_cast<const OUString*>(pEntry->GetUserData()))
- return *pStr;
- }
- return OUString();
+ Image aDummy;
+ pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aDummy, aDummy, false));
}
+ if (pStr)
+ pEntry->AddItem(std::make_unique<SvLBoxString>(*pStr));
+ pEntry->SetUserData(pUserData);
+ m_xIconView->Insert(pEntry, nullptr, nInsertPos);
- virtual OUString get_selected_text() const override
+ if (pRet)
{
- assert(m_xIconView->IsUpdateMode() && "don't request selection when frozen");
- if (SvTreeListEntry* pEntry = m_xIconView->FirstSelected())
- return m_xIconView->GetEntryText(pEntry);
- return OUString();
+ SalInstanceTreeIter* pVclRetIter = static_cast<SalInstanceTreeIter*>(pRet);
+ pVclRetIter->iter = pEntry;
}
- virtual int count_selected_items() const override { return m_xIconView->GetSelectionCount(); }
+ enable_notify_events();
+}
- virtual void select(int pos) override
+OUString SalInstanceIconView::get_selected_id() const
+{
+ assert(m_xIconView->IsUpdateMode() && "don't request selection when frozen");
+ if (SvTreeListEntry* pEntry = m_xIconView->FirstSelected())
{
- assert(m_xIconView->IsUpdateMode()
- && "don't select when frozen, select after thaw. Note selection doesn't survive a "
- "freeze");
- disable_notify_events();
- if (pos == -1 || (pos == 0 && n_children() == 0))
- m_xIconView->SelectAll(false);
- else
- {
- SvTreeListEntry* pEntry = m_xIconView->GetEntry(nullptr, pos);
- m_xIconView->Select(pEntry, true);
- m_xIconView->MakeVisible(pEntry);
- }
- enable_notify_events();
+ if (const OUString* pStr = static_cast<const OUString*>(pEntry->GetUserData()))
+ return *pStr;
}
+ return OUString();
+}
- virtual void unselect(int pos) override
- {
- assert(m_xIconView->IsUpdateMode()
- && "don't select when frozen, select after thaw. Note selection doesn't survive a "
- "freeze");
- disable_notify_events();
- if (pos == -1)
- m_xIconView->SelectAll(true);
- else
- {
- SvTreeListEntry* pEntry = m_xIconView->GetEntry(nullptr, pos);
- m_xIconView->Select(pEntry, false);
- }
- enable_notify_events();
- }
+OUString SalInstanceIconView::get_selected_text() const
+{
+ assert(m_xIconView->IsUpdateMode() && "don't request selection when frozen");
+ if (SvTreeListEntry* pEntry = m_xIconView->FirstSelected())
+ return m_xIconView->GetEntryText(pEntry);
+ return OUString();
+}
- virtual int n_children() const override
- {
- return m_xIconView->GetModel()->GetChildList(nullptr).size();
- }
+int SalInstanceIconView::count_selected_items() const { return m_xIconView->GetSelectionCount(); }
- virtual std::unique_ptr<weld::TreeIter>
- make_iterator(const weld::TreeIter* pOrig) const override
+void SalInstanceIconView::select(int pos)
+{
+ assert(m_xIconView->IsUpdateMode()
+ && "don't select when frozen, select after thaw. Note selection doesn't survive a "
+ "freeze");
+ disable_notify_events();
+ if (pos == -1 || (pos == 0 && n_children() == 0))
+ m_xIconView->SelectAll(false);
+ else
{
- return std::unique_ptr<weld::TreeIter>(
- new SalInstanceTreeIter(static_cast<const SalInstanceTreeIter*>(pOrig)));
+ SvTreeListEntry* pEntry = m_xIconView->GetEntry(nullptr, pos);
+ m_xIconView->Select(pEntry, true);
+ m_xIconView->MakeVisible(pEntry);
}
+ enable_notify_events();
+}
- virtual bool get_selected(weld::TreeIter* pIter) const override
+void SalInstanceIconView::unselect(int pos)
+{
+ assert(m_xIconView->IsUpdateMode()
+ && "don't select when frozen, select after thaw. Note selection doesn't survive a "
+ "freeze");
+ disable_notify_events();
+ if (pos == -1)
+ m_xIconView->SelectAll(true);
+ else
{
- SvTreeListEntry* pEntry = m_xIconView->FirstSelected();
- auto pVclIter = static_cast<SalInstanceTreeIter*>(pIter);
- if (pVclIter)
- pVclIter->iter = pEntry;
- return pEntry != nullptr;
+ SvTreeListEntry* pEntry = m_xIconView->GetEntry(nullptr, pos);
+ m_xIconView->Select(pEntry, false);
}
+ enable_notify_events();
+}
- virtual bool get_cursor(weld::TreeIter* pIter) const override
- {
- SvTreeListEntry* pEntry = m_xIconView->GetCurEntry();
- auto pVclIter = static_cast<SalInstanceTreeIter*>(pIter);
- if (pVclIter)
- pVclIter->iter = pEntry;
- return pEntry != nullptr;
- }
+int SalInstanceIconView::n_children() const
+{
+ return m_xIconView->GetModel()->GetChildList(nullptr).size();
+}
- virtual void set_cursor(const weld::TreeIter& rIter) override
- {
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- disable_notify_events();
- m_xIconView->SetCurEntry(rVclIter.iter);
- enable_notify_events();
- }
+std::unique_ptr<weld::TreeIter>
+SalInstanceIconView::make_iterator(const weld::TreeIter* pOrig) const
+{
+ return std::unique_ptr<weld::TreeIter>(
+ new SalInstanceTreeIter(static_cast<const SalInstanceTreeIter*>(pOrig)));
+}
- virtual bool get_iter_first(weld::TreeIter& rIter) const override
- {
- SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
- rVclIter.iter = m_xIconView->GetEntry(0);
- return rVclIter.iter != nullptr;
- }
+bool SalInstanceIconView::get_selected(weld::TreeIter* pIter) const
+{
+ SvTreeListEntry* pEntry = m_xIconView->FirstSelected();
+ auto pVclIter = static_cast<SalInstanceTreeIter*>(pIter);
+ if (pVclIter)
+ pVclIter->iter = pEntry;
+ return pEntry != nullptr;
+}
- virtual void scroll_to_item(const weld::TreeIter& rIter) override
- {
- assert(m_xIconView->IsUpdateMode()
- && "don't select when frozen, select after thaw. Note selection doesn't survive a "
- "freeze");
- disable_notify_events();
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- m_xIconView->MakeVisible(rVclIter.iter);
- enable_notify_events();
- }
+bool SalInstanceIconView::get_cursor(weld::TreeIter* pIter) const
+{
+ SvTreeListEntry* pEntry = m_xIconView->GetCurEntry();
+ auto pVclIter = static_cast<SalInstanceTreeIter*>(pIter);
+ if (pVclIter)
+ pVclIter->iter = pEntry;
+ return pEntry != nullptr;
+}
- virtual void selected_foreach(const std::function<bool(weld::TreeIter&)>& func) override
- {
- SalInstanceTreeIter aVclIter(m_xIconView->FirstSelected());
- while (aVclIter.iter)
- {
- if (func(aVclIter))
- return;
- aVclIter.iter = m_xIconView->NextSelected(aVclIter.iter);
- }
- }
+void SalInstanceIconView::set_cursor(const weld::TreeIter& rIter)
+{
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ disable_notify_events();
+ m_xIconView->SetCurEntry(rVclIter.iter);
+ enable_notify_events();
+}
- virtual OUString get_id(const weld::TreeIter& rIter) const override
- {
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- const OUString* pStr = static_cast<const OUString*>(rVclIter.iter->GetUserData());
- if (pStr)
- return *pStr;
- return OUString();
- }
+bool SalInstanceIconView::get_iter_first(weld::TreeIter& rIter) const
+{
+ SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
+ rVclIter.iter = m_xIconView->GetEntry(0);
+ return rVclIter.iter != nullptr;
+}
- virtual void clear() override
- {
- disable_notify_events();
- m_xIconView->Clear();
- m_aUserData.clear();
- enable_notify_events();
- }
+void SalInstanceIconView::scroll_to_item(const weld::TreeIter& rIter)
+{
+ assert(m_xIconView->IsUpdateMode()
+ && "don't select when frozen, select after thaw. Note selection doesn't survive a "
+ "freeze");
+ disable_notify_events();
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ m_xIconView->MakeVisible(rVclIter.iter);
+ enable_notify_events();
+}
- virtual ~SalInstanceIconView() override
+void SalInstanceIconView::selected_foreach(const std::function<bool(weld::TreeIter&)>& func)
+{
+ SalInstanceTreeIter aVclIter(m_xIconView->FirstSelected());
+ while (aVclIter.iter)
{
- m_xIconView->SetDoubleClickHdl(Link<SvTreeListBox*, bool>());
- m_xIconView->SetSelectHdl(Link<SvTreeListBox*, void>());
- m_xIconView->SetDeselectHdl(Link<SvTreeListBox*, void>());
+ if (func(aVclIter))
+ return;
+ aVclIter.iter = m_xIconView->NextSelected(aVclIter.iter);
}
-};
+}
+
+OUString SalInstanceIconView::get_id(const weld::TreeIter& rIter) const
+{
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ const OUString* pStr = static_cast<const OUString*>(rVclIter.iter->GetUserData());
+ if (pStr)
+ return *pStr;
+ return OUString();
+}
+
+void SalInstanceIconView::clear()
+{
+ disable_notify_events();
+ m_xIconView->Clear();
+ m_aUserData.clear();
+ enable_notify_events();
+}
+
+SalInstanceIconView::~SalInstanceIconView()
+{
+ m_xIconView->SetDoubleClickHdl(Link<SvTreeListBox*, bool>());
+ m_xIconView->SetSelectHdl(Link<SvTreeListBox*, void>());
+ m_xIconView->SetDeselectHdl(Link<SvTreeListBox*, void>());
+}
IMPL_LINK_NOARG(SalInstanceIconView, SelectHdl, SvTreeListBox*, void)
{