[Libreoffice-commits] core.git: 2 commits - include/svx include/vcl svx/source svx/uiconfig sw/qa vcl/inc vcl/source vcl/unx
Szymon KÅos (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jan 14 09:21:23 UTC 2021
include/svx/fontworkgallery.hxx | 7 +---
include/vcl/uitest/uiobject.hxx | 19 +++++++++-
include/vcl/weld.hxx | 9 +++++
svx/source/tbxctrls/fontworkgallery.cxx | 54 ++++++++++---------------------
svx/uiconfig/ui/fontworkgallerydialog.ui | 37 +++++++++++++--------
sw/qa/uitest/writer_tests2/fontworks.py | 11 ++++--
vcl/inc/iconview.hxx | 2 +
vcl/source/app/salvtables.cxx | 41 +++++++++++++++++++++++
vcl/source/treelist/iconview.cxx | 3 +
vcl/source/uitest/uiobject.cxx | 37 +++++++++++++++++++++
vcl/unx/gtk3/gtk3gtkinst.cxx | 28 ++++++++++++++++
11 files changed, 188 insertions(+), 60 deletions(-)
New commits:
commit c87b1a887462cd3842eb90c9d6c50193c2d350f1
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Wed Jan 13 20:12:50 2021 +0100
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Thu Jan 14 10:20:45 2021 +0100
UITest: add IconView
Change-Id: I6971d73e65f0a1f60203ea1010ed8ad3ba176755
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109243
Tested-by: Jenkins
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
diff --git a/include/vcl/uitest/uiobject.hxx b/include/vcl/uitest/uiobject.hxx
index b4c7f437e9e3..e2cb07384cf7 100644
--- a/include/vcl/uitest/uiobject.hxx
+++ b/include/vcl/uitest/uiobject.hxx
@@ -24,6 +24,7 @@ class CheckBox;
class ComboBox;
class Dialog;
class Edit;
+class IconView;
class ListBox;
class RadioButton;
class TabControl;
@@ -439,7 +440,7 @@ private:
virtual OUString get_name() const override;
};
-class TreeListUIObject final : public WindowUIObject
+class TreeListUIObject : public WindowUIObject
{
public:
TreeListUIObject(const VclPtr<SvTreeListBox>& xTreeList);
@@ -455,7 +456,7 @@ public:
virtual std::set<OUString> get_children() const override;
-private:
+protected:
virtual OUString get_name() const override;
@@ -486,6 +487,20 @@ private:
SvTreeListEntry* const mpEntry;
};
+class IconViewUIObject final : public TreeListUIObject
+{
+public:
+ IconViewUIObject(const VclPtr<SvTreeListBox>& xIconView);
+
+ virtual StringMap get_state() override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+private:
+
+ virtual OUString get_name() const override;
+};
+
class ToolBoxUIObject final : public WindowUIObject
{
private:
diff --git a/sw/qa/uitest/writer_tests2/fontworks.py b/sw/qa/uitest/writer_tests2/fontworks.py
index d3034dc8134b..671f63087ba4 100644
--- a/sw/qa/uitest/writer_tests2/fontworks.py
+++ b/sw/qa/uitest/writer_tests2/fontworks.py
@@ -22,15 +22,18 @@ class fontWorksDialog(UITestCase):
self.ui_test.execute_dialog_through_command(".uno:FontworkGalleryFloater")
xDialog = self.xUITest.getTopFocusWindow()
- FontWorkSelector = xDialog.getChild("ctlFavorites")
+ FontWorkSelector = xDialog.getChild("ctlFavoriteswin")
# Select element with id (3)
- FontWorkSelector.executeAction("CHOOSE", mkPropertyValues({"POS": "3"}))
+ element3 = FontWorkSelector.getChild("2")
+ element3.executeAction("SELECT", mkPropertyValues({}))
+ print(get_state_as_dict(FontWorkSelector))
self.assertEqual(get_state_as_dict(FontWorkSelector)["SelectedItemPos"], "2")
self.assertEqual(get_state_as_dict(FontWorkSelector)["SelectedItemId"], "3")
- self.assertEqual(get_state_as_dict(FontWorkSelector)["ItemsCount"], "36")
+ self.assertEqual(get_state_as_dict(FontWorkSelector)["VisibleCount"], "36")
# Select element with id (7)
- FontWorkSelector.executeAction("CHOOSE", mkPropertyValues({"POS": "7"}))
+ element7 = FontWorkSelector.getChild("6")
+ element7.executeAction("SELECT", mkPropertyValues({}))
self.assertEqual(get_state_as_dict(FontWorkSelector)["SelectedItemPos"], "6")
self.assertEqual(get_state_as_dict(FontWorkSelector)["SelectedItemId"], "7")
diff --git a/vcl/inc/iconview.hxx b/vcl/inc/iconview.hxx
index 9c74d29f9834..f10b0ed8a53e 100644
--- a/vcl/inc/iconview.hxx
+++ b/vcl/inc/iconview.hxx
@@ -33,6 +33,8 @@ public:
void PaintEntry(SvTreeListEntry&, tools::Long nX, tools::Long nY,
vcl::RenderContext& rRenderContext);
+
+ virtual FactoryFunction GetUITestFactory() const override;
};
#endif
diff --git a/vcl/source/treelist/iconview.cxx b/vcl/source/treelist/iconview.cxx
index 12bdd75165fe..b6dd3da1c40a 100644
--- a/vcl/source/treelist/iconview.cxx
+++ b/vcl/source/treelist/iconview.cxx
@@ -21,6 +21,7 @@
#include <vcl/toolkit/viewdataentry.hxx>
#include <iconview.hxx>
#include "iconviewimpl.hxx"
+#include <vcl/uitest/uiobject.hxx>
IconView::IconView(vcl::Window* pParent, WinBits nBits)
: SvTreeListBox(pParent, nBits)
@@ -215,4 +216,6 @@ void IconView::PaintEntry(SvTreeListEntry& rEntry, tools::Long nX, tools::Long n
}
}
+FactoryFunction IconView::GetUITestFactory() const { return IconViewUIObject::create; }
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx
index 90322d500611..92122b54caab 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -26,6 +26,9 @@
#include <vcl/toolkit/dialog.hxx>
#include <vcl/toolkit/edit.hxx>
#include <vcl/toolkit/field.hxx>
+#include <vcl/toolkit/treelistbox.hxx>
+#include <vcl/toolkit/treelistentry.hxx>
+#include <vcl/toolkit/svlbitm.hxx>
#include <vcl/menubtn.hxx>
#include <vcl/toolkit/vclmedit.hxx>
#include <vcl/uitest/logger.hxx>
@@ -1729,4 +1732,38 @@ DrawingAreaUIObject::~DrawingAreaUIObject()
{
}
+IconViewUIObject::IconViewUIObject(const VclPtr<SvTreeListBox>& xIconView):
+ TreeListUIObject(xIconView)
+{
+}
+
+StringMap IconViewUIObject::get_state()
+{
+ StringMap aMap = TreeListUIObject::get_state();
+
+ SvTreeListEntry* pEntry = mxTreeList->FirstSelected();
+
+ OUString* pId = static_cast<OUString*>(pEntry->GetUserData());
+ if (pId)
+ aMap["SelectedItemId"] = *pId;
+
+ SvTreeList* pModel = mxTreeList->GetModel();
+ if (pModel)
+ aMap["SelectedItemPos"] = OUString::number(pModel->GetAbsPos(pEntry));
+
+ return aMap;
+}
+
+OUString IconViewUIObject::get_name() const
+{
+ return "IconViewUIObject";
+}
+
+std::unique_ptr<UIObject> IconViewUIObject::create(vcl::Window* pWindow)
+{
+ SvTreeListBox* pTreeList = dynamic_cast<SvTreeListBox*>(pWindow);
+ assert(pTreeList);
+ return std::unique_ptr<UIObject>(new IconViewUIObject(pTreeList));
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 25f33c3393895edced99cb69c7a450b9e2bb5343
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Fri Jan 8 09:28:38 2021 +0100
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Thu Jan 14 10:20:27 2021 +0100
Fontwork dialog: use iconview
Change-Id: I5bb35407ca83c9b0cda6f6355e6e25c21fecb459
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108960
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109181
Tested-by: Szymon Kłos <szymon.klos at collabora.com>
diff --git a/include/svx/fontworkgallery.hxx b/include/svx/fontworkgallery.hxx
index 12648ebd6a19..3fa657305ad6 100644
--- a/include/svx/fontworkgallery.hxx
+++ b/include/svx/fontworkgallery.hxx
@@ -52,17 +52,16 @@ class SAL_WARN_UNUSED SVXCORE_DLLPUBLIC FontWorkGalleryDialog final : public wel
SdrObject** mppSdrObject;
SdrModel* mpDestModel;
- std::vector<BitmapEx> maFavoritesHorizontal;
+ std::vector<VclPtr< VirtualDevice >> maFavoritesHorizontal;
- ValueSet maCtlFavorites;
- std::unique_ptr<weld::CustomWeld> mxCtlFavorites;
+ std::unique_ptr<weld::IconView> maCtlFavorites;
std::unique_ptr<weld::Button> mxOKButton;
void initFavorites(sal_uInt16 nThemeId);
void insertSelectedFontwork();
void fillFavorites(sal_uInt16 nThemeId);
- DECL_LINK(DoubleClickFavoriteHdl, ValueSet*, void);
+ DECL_LINK(DoubleClickFavoriteHdl, weld::IconView&, bool);
DECL_LINK(ClickOKHdl, weld::Button&, void );
public:
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index e4524a4dc9b5..29167234a31c 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -1253,11 +1253,20 @@ public:
const OUString* pIconName, TreeIter* pRet)
= 0;
+ virtual void insert(int pos, const OUString* pStr, const OUString* pId,
+ const VirtualDevice* pIcon, TreeIter* pRet)
+ = 0;
+
void append(const OUString& rId, const OUString& rStr, const OUString& rImage)
{
insert(-1, &rStr, &rId, &rImage, nullptr);
}
+ void append(const OUString& rId, const OUString& rStr, const VirtualDevice* pImage)
+ {
+ insert(-1, &rStr, &rId, pImage, nullptr);
+ }
+
void connect_selection_changed(const Link<IconView&, void>& rLink)
{
m_aSelectionChangeHdl = rLink;
diff --git a/svx/source/tbxctrls/fontworkgallery.cxx b/svx/source/tbxctrls/fontworkgallery.cxx
index a1b28688f13a..efef6f786e0d 100644
--- a/svx/source/tbxctrls/fontworkgallery.cxx
+++ b/svx/source/tbxctrls/fontworkgallery.cxx
@@ -48,29 +48,21 @@ using namespace ::com::sun::star::beans;
namespace svx
{
-const int nColCount = 4;
-const int nLineCount = 4;
-
FontWorkGalleryDialog::FontWorkGalleryDialog(weld::Window* pParent, SdrView& rSdrView)
: GenericDialogController(pParent, "svx/ui/fontworkgallerydialog.ui", "FontworkGalleryDialog")
, mnThemeId(0xffff)
, mrSdrView(rSdrView)
, mppSdrObject(nullptr)
, mpDestModel(nullptr)
- , maCtlFavorites(m_xBuilder->weld_scrolled_window("ctlFavoriteswin", true))
- , mxCtlFavorites(new weld::CustomWeld(*m_xBuilder, "ctlFavorites", maCtlFavorites))
+ , maCtlFavorites(m_xBuilder->weld_icon_view("ctlFavoriteswin"))
, mxOKButton(m_xBuilder->weld_button("ok"))
{
- Size aSize(maCtlFavorites.GetDrawingArea()->get_ref_device().LogicToPixel(Size(200, 200), MapMode(MapUnit::MapAppFont)));
- mxCtlFavorites->set_size_request(aSize.Width(), aSize.Height());
+ Size aSize(530, 400);
+ maCtlFavorites->set_size_request(aSize.Width(), aSize.Height());
- maCtlFavorites.SetDoubleClickHdl( LINK( this, FontWorkGalleryDialog, DoubleClickFavoriteHdl ) );
+ maCtlFavorites->connect_item_activated( LINK( this, FontWorkGalleryDialog, DoubleClickFavoriteHdl ) );
mxOKButton->connect_clicked(LINK(this, FontWorkGalleryDialog, ClickOKHdl));
- maCtlFavorites.SetColCount( nColCount );
- maCtlFavorites.SetLineCount( nLineCount );
- maCtlFavorites.SetExtraSpacing( 3 );
-
initFavorites( GALLERY_THEME_FONTWORK );
fillFavorites( GALLERY_THEME_FONTWORK );
}
@@ -96,7 +88,7 @@ void FontWorkGalleryDialog::initFavorites(sal_uInt16 nThemeId)
if (GalleryExplorer::GetSdrObj(nThemeId, nModelPos, pModel, &aThumb) && !!aThumb)
{
- ScopedVclPtrInstance< VirtualDevice > pVDev;
+ VclPtr< VirtualDevice > pVDev = VclPtr<VirtualDevice>::Create();
const Point aNull(0, 0);
if (pVDev->GetDPIScaleFactor() > 1)
@@ -113,7 +105,7 @@ void FontWorkGalleryDialog::initFavorites(sal_uInt16 nThemeId)
pVDev->DrawCheckered(aNull, aSize, nLen, aW, aG);
pVDev->DrawBitmapEx(aNull, aThumb);
- maFavoritesHorizontal.emplace_back(pVDev->GetBitmapEx(aNull, aSize));
+ maFavoritesHorizontal.emplace_back(pVDev);
}
}
@@ -125,33 +117,18 @@ void FontWorkGalleryDialog::fillFavorites(sal_uInt16 nThemeId)
{
mnThemeId = nThemeId;
- Size aThumbSize(maCtlFavorites.GetOutputSizePixel());
- aThumbSize.setWidth( aThumbSize.Width() / nColCount );
- aThumbSize.setHeight( aThumbSize.Height() / nLineCount );
- aThumbSize.AdjustWidth( -12 );
- aThumbSize.AdjustHeight( -12 );
-
auto nFavCount = maFavoritesHorizontal.size();
- // ValueSet favorites
- if( nFavCount > (nColCount * nLineCount) )
- {
- WinBits nWinBits = maCtlFavorites.GetStyle();
- nWinBits |= WB_VSCROLL;
- maCtlFavorites.SetStyle( nWinBits );
- }
-
- maCtlFavorites.Clear();
+ maCtlFavorites->clear();
for( size_t nFavorite = 1; nFavorite <= nFavCount; nFavorite++ )
{
- OUString aStr = SvxResId(RID_SVXFLOAT3D_FAVORITE) + " " + OUString::number(nFavorite);
- Image aThumbImage( maFavoritesHorizontal[nFavorite-1] );
- maCtlFavorites.InsertItem( static_cast<sal_uInt16>(nFavorite), aThumbImage, aStr );
+ OUString sId = OUString::number(static_cast<sal_uInt16>(nFavorite));
+ maCtlFavorites->append(sId, "", maFavoritesHorizontal[nFavorite-1]);
}
- if (maCtlFavorites.GetItemCount())
- maCtlFavorites.SelectItem(1);
+ if (maCtlFavorites->n_children())
+ maCtlFavorites->select(0);
}
void FontWorkGalleryDialog::SetSdrObjectRef( SdrObject** ppSdrObject, SdrModel* pModel )
@@ -162,7 +139,11 @@ void FontWorkGalleryDialog::SetSdrObjectRef( SdrObject** ppSdrObject, SdrModel*
void FontWorkGalleryDialog::insertSelectedFontwork()
{
- sal_uInt16 nItemId = maCtlFavorites.GetSelectedItemId();
+ OUString sItemId = maCtlFavorites->get_selected_id();
+ if (sItemId.isEmpty())
+ return;
+
+ sal_Int32 nItemId = sItemId.toInt32();
if (nItemId == 0)
return;
@@ -244,10 +225,11 @@ IMPL_LINK_NOARG(FontWorkGalleryDialog, ClickOKHdl, weld::Button&, void)
m_xDialog->response(RET_OK);
}
-IMPL_LINK_NOARG(FontWorkGalleryDialog, DoubleClickFavoriteHdl, ValueSet*, void)
+IMPL_LINK_NOARG(FontWorkGalleryDialog, DoubleClickFavoriteHdl, weld::IconView&, bool)
{
insertSelectedFontwork();
m_xDialog->response(RET_OK);
+ return true;
}
namespace {
diff --git a/svx/uiconfig/ui/fontworkgallerydialog.ui b/svx/uiconfig/ui/fontworkgallerydialog.ui
index 683832e39d70..72cbdeff46cf 100644
--- a/svx/uiconfig/ui/fontworkgallerydialog.ui
+++ b/svx/uiconfig/ui/fontworkgallerydialog.ui
@@ -2,6 +2,16 @@
<!-- Generated with glade 3.22.1 -->
<interface domain="svx">
<requires lib="gtk+" version="3.20"/>
+ <object class="GtkTreeStore" id="liststore1">
+ <columns>
+ <!-- column-name expander -->
+ <column type="GdkPixbuf"/>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
<object class="GtkDialog" id="FontworkGalleryDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
@@ -98,25 +108,24 @@
</packing>
</child>
<child>
- <object class="GtkScrolledWindow" id="ctlFavoriteswin">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can_focus">True</property>
<property name="hexpand">True</property>
- <property name="hscrollbar_policy">never</property>
- <property name="vscrollbar_policy">never</property>
+ <property name="vexpand">True</property>
<property name="shadow_type">in</property>
<child>
- <object class="GtkViewport">
+ <object class="GtkIconView" id="ctlFavoriteswin">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkDrawingArea" id="ctlFavorites">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
- <property name="hexpand">True</property>
- </object>
- </child>
+ <property name="can_focus">True</property>
+ <property name="margin">6</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="model">liststore1</property>
+ <property name="columns">3</property>
+ <property name="item_width">100</property>
+ <property name="pixbuf-column">0</property>
+ <property name="text-column">1</property>
</object>
</child>
</object>
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index e8755eb5b1d5..0aa3db724e91 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -5115,6 +5115,47 @@ public:
enable_notify_events();
}
+ virtual void insert(int pos, const OUString* pStr, const OUString* pId,
+ const VirtualDevice* pIcon, weld::TreeIter* pRet) override
+ {
+ 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();
+ }
+
virtual OUString get_selected_id() const override
{
assert(m_xIconView->IsUpdateMode() && "don't request selection when frozen");
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 39c826823d01..0ef2b33239cf 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -12467,6 +12467,21 @@ private:
}
}
+ void insert_item(GtkTreeIter& iter, int pos, const OUString* pId, const OUString* pText, const VirtualDevice* pIcon)
+ {
+ gtk_tree_store_insert_with_values(m_pTreeStore, &iter, nullptr, pos,
+ m_nTextCol, !pText ? nullptr : OUStringToOString(*pText, RTL_TEXTENCODING_UTF8).getStr(),
+ m_nIdCol, !pId ? nullptr : OUStringToOString(*pId, RTL_TEXTENCODING_UTF8).getStr(),
+ -1);
+ if (pIcon)
+ {
+ GdkPixbuf* pixbuf = getPixbuf(*pIcon);
+ gtk_tree_store_set(m_pTreeStore, &iter, m_nImageCol, pixbuf, -1);
+ if (pixbuf)
+ g_object_unref(pixbuf);
+ }
+ }
+
OUString get(const GtkTreeIter& iter, int col) const
{
GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore);
@@ -12527,6 +12542,19 @@ public:
enable_notify_events();
}
+ virtual void insert(int pos, const OUString* pText, const OUString* pId, const VirtualDevice* pIcon, weld::TreeIter* pRet) override
+ {
+ disable_notify_events();
+ GtkTreeIter iter;
+ insert_item(iter, pos, pId, pText, pIcon);
+ if (pRet)
+ {
+ GtkInstanceTreeIter* pGtkRetIter = static_cast<GtkInstanceTreeIter*>(pRet);
+ pGtkRetIter->iter = iter;
+ }
+ enable_notify_events();
+ }
+
virtual OUString get_selected_id() const override
{
assert(gtk_icon_view_get_model(m_pIconView) && "don't request selection when frozen");
More information about the Libreoffice-commits
mailing list