[Libreoffice-commits] core.git: solenv/sanitizers sw/source sw/uiconfig sw/UIConfig_swriter.mk
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Sun Feb 16 19:18:22 UTC 2020
solenv/sanitizers/ui/modules/swriter.suppr | 1
sw/UIConfig_swriter.mk | 1
sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx | 104 ++++++++++++++++-----
sw/uiconfig/swriter/ui/editbox.ui | 25 +++++
4 files changed, 110 insertions(+), 21 deletions(-)
New commits:
commit 76e14924edcecc4312229b5a9b9b9a80f597695d
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Feb 16 16:39:01 2020 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Sun Feb 16 20:17:49 2020 +0100
weld CurrentEdit Item Window
Change-Id: I7ba2523f537542d71af62f47acf0f6b3ee4acde3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88815
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/solenv/sanitizers/ui/modules/swriter.suppr b/solenv/sanitizers/ui/modules/swriter.suppr
index 21e5736992a1..5aef0b32dc8f 100644
--- a/solenv/sanitizers/ui/modules/swriter.suppr
+++ b/solenv/sanitizers/ui/modules/swriter.suppr
@@ -32,6 +32,7 @@ sw/uiconfig/swriter/ui/createaddresslist.ui://GtkEntry[@id='SETNO-nospin'] no-la
sw/uiconfig/swriter/ui/createaddresslist.ui://GtkSpinButton[@id='SETNO'] no-labelled-by
sw/uiconfig/swriter/ui/customizeaddrlistdialog.ui://GtkButton[@id='down'] button-no-label
sw/uiconfig/swriter/ui/customizeaddrlistdialog.ui://GtkButton[@id='up'] button-no-label
+sw/uiconfig/swriter/ui/editbox.ui://GtkEntry[@id='entry'] no-labelled-by
sw/uiconfig/swriter/ui/editsectiondialog.ui://GtkEntry[@id='curname'] no-labelled-by
sw/uiconfig/swriter/ui/editsectiondialog.ui://GtkEntry[@id='filename'] duplicate-mnemonic
sw/uiconfig/swriter/ui/endnotepage.ui://GtkLabel[@id='label19'] orphan-label
diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk
index 851348613d60..9c61eb252c6b 100644
--- a/sw/UIConfig_swriter.mk
+++ b/sw/UIConfig_swriter.mk
@@ -128,6 +128,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\
sw/uiconfig/swriter/ui/dropcapspage \
sw/uiconfig/swriter/ui/dropdownfielddialog \
sw/uiconfig/swriter/ui/dropdownformfielddialog \
+ sw/uiconfig/swriter/ui/editbox \
sw/uiconfig/swriter/ui/editcategories \
sw/uiconfig/swriter/ui/editfielddialog \
sw/uiconfig/swriter/ui/editsectiondialog \
diff --git a/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx b/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx
index 84395b7cfc65..8c65bf55be8a 100644
--- a/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx
+++ b/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx
@@ -22,7 +22,6 @@
#include <svtools/toolboxcontroller.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <sfx2/InterimItemWindow.hxx>
-#include <vcl/edit.hxx>
#include <vcl/svapp.hxx>
#include <vcl/toolbox.hxx>
@@ -37,17 +36,82 @@ using namespace css;
namespace {
+class CurrentEdit final : public InterimItemWindow
+{
+private:
+ std::unique_ptr<weld::Entry> m_xWidget;
+
+ DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
+public:
+ CurrentEdit(vcl::Window* pParent)
+ : InterimItemWindow(pParent, "modules/swriter/ui/editbox.ui", "EditBox")
+ , m_xWidget(m_xBuilder->weld_entry("entry"))
+ {
+ m_xWidget->connect_key_press(LINK(this, CurrentEdit, KeyInputHdl));
+ SetSizePixel(m_xWidget->get_preferred_size());
+ }
+
+ virtual void dispose() override
+ {
+ m_xWidget.reset();
+ InterimItemWindow::dispose();
+ }
+
+ virtual void GetFocus() override
+ {
+ if (m_xWidget)
+ m_xWidget->grab_focus();
+ InterimItemWindow::GetFocus();
+ }
+
+ void set_sensitive(bool bSensitive)
+ {
+ Enable(bSensitive);
+ m_xWidget->set_sensitive(bSensitive);
+ }
+
+ bool get_sensitive() const
+ {
+ return m_xWidget->get_sensitive();
+ }
+
+ void set_text(const OUString& rText)
+ {
+ m_xWidget->set_text(rText);
+ }
+
+ OUString get_text() const
+ {
+ return m_xWidget->get_text();
+ }
+
+ void connect_activate(const Link<weld::Entry&, bool>& rLink)
+ {
+ m_xWidget->connect_activate(rLink);
+ }
+
+ virtual ~CurrentEdit() override
+ {
+ disposeOnce();
+ }
+};
+
+IMPL_LINK(CurrentEdit, KeyInputHdl, const KeyEvent&, rKEvt, bool)
+{
+ return ChildKeyInput(rKEvt);
+}
+
/// Controller for .uno:MailMergeCurrentEntry toolbar checkbox: creates the checkbox & handles the value.
class MMCurrentEntryController : public svt::ToolboxController, public lang::XServiceInfo
{
- VclPtr<Edit> m_pCurrentEdit;
+ VclPtr<CurrentEdit> m_xCurrentEdit;
- DECL_LINK(CurrentEditUpdatedHdl, Edit&, void);
+ DECL_LINK(CurrentEditUpdatedHdl, weld::Entry&, bool);
public:
explicit MMCurrentEntryController(const uno::Reference<uno::XComponentContext>& rContext)
: svt::ToolboxController(rContext, uno::Reference<frame::XFrame>(), ".uno:MailMergeCurrentEntry")
- , m_pCurrentEdit(nullptr)
+ , m_xCurrentEdit(nullptr)
{
}
@@ -218,7 +282,7 @@ void MMCurrentEntryController::dispose()
SolarMutexGuard aSolarMutexGuard;
svt::ToolboxController::dispose();
- m_pCurrentEdit.disposeAndClear();
+ m_xCurrentEdit.disposeAndClear();
}
uno::Reference<awt::XWindow> MMCurrentEntryController::createItemWindow(const uno::Reference<awt::XWindow>& rParent)
@@ -228,17 +292,14 @@ uno::Reference<awt::XWindow> MMCurrentEntryController::createItemWindow(const un
if (pToolbar)
{
// make it visible
- m_pCurrentEdit = VclPtr<Edit>::Create(pToolbar);
- m_pCurrentEdit->SetWidthInChars(4);
- m_pCurrentEdit->SetSizePixel(m_pCurrentEdit->GetOptimalSize());
-
- m_pCurrentEdit->SetModifyHdl(LINK(this, MMCurrentEntryController, CurrentEditUpdatedHdl));
+ m_xCurrentEdit = VclPtr<CurrentEdit>::Create(pToolbar);
+ m_xCurrentEdit->connect_activate(LINK(this, MMCurrentEntryController, CurrentEditUpdatedHdl));
}
- return VCLUnoHelper::GetInterface(m_pCurrentEdit);
+ return VCLUnoHelper::GetInterface(m_xCurrentEdit);
}
-IMPL_LINK(MMCurrentEntryController, CurrentEditUpdatedHdl, Edit&, rEdit, void)
+IMPL_LINK(MMCurrentEntryController, CurrentEditUpdatedHdl, weld::Entry&, rEdit, bool)
{
SwView* pView = ::GetActiveView();
std::shared_ptr<SwMailMergeConfigItem> xConfigItem;
@@ -246,9 +307,9 @@ IMPL_LINK(MMCurrentEntryController, CurrentEditUpdatedHdl, Edit&, rEdit, void)
xConfigItem = pView->GetMailMergeConfigItem();
if (!xConfigItem)
- return;
+ return true;
- OUString aText(rEdit.GetText());
+ OUString aText(rEdit.get_text());
sal_Int32 nEntry = aText.toInt32();
if (!aText.isEmpty() && nEntry != xConfigItem->GetResultSetPosition())
{
@@ -256,11 +317,12 @@ IMPL_LINK(MMCurrentEntryController, CurrentEditUpdatedHdl, Edit&, rEdit, void)
// notify about the change
dispatchCommand(".uno:MailMergeCurrentEntry", uno::Sequence<beans::PropertyValue>());
}
+ return true;
};
void MMCurrentEntryController::statusChanged(const frame::FeatureStateEvent& rEvent)
{
- if (!m_pCurrentEdit)
+ if (!m_xCurrentEdit)
return;
SwView* pView = ::GetActiveView();
@@ -270,16 +332,16 @@ void MMCurrentEntryController::statusChanged(const frame::FeatureStateEvent& rEv
if (!xConfigItem || !rEvent.IsEnabled)
{
- m_pCurrentEdit->Disable();
- m_pCurrentEdit->SetText("");
+ m_xCurrentEdit->set_sensitive(false);
+ m_xCurrentEdit->set_text("");
}
else
{
- sal_Int32 nEntry = m_pCurrentEdit->GetText().toInt32();
- if (!m_pCurrentEdit->IsEnabled() || nEntry != xConfigItem->GetResultSetPosition())
+ sal_Int32 nEntry = m_xCurrentEdit->get_text().toInt32();
+ if (!m_xCurrentEdit->get_sensitive() || nEntry != xConfigItem->GetResultSetPosition())
{
- m_pCurrentEdit->Enable();
- m_pCurrentEdit->SetText(OUString::number(xConfigItem->GetResultSetPosition()));
+ m_xCurrentEdit->set_sensitive(true);
+ m_xCurrentEdit->set_text(OUString::number(xConfigItem->GetResultSetPosition()));
}
}
}
diff --git a/sw/uiconfig/swriter/ui/editbox.ui b/sw/uiconfig/swriter/ui/editbox.ui
new file mode 100644
index 000000000000..903116990a70
--- /dev/null
+++ b/sw/uiconfig/swriter/ui/editbox.ui
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface domain="sc">
+ <requires lib="gtk+" version="3.18"/>
+ <object class="GtkBox" id="EditBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkEntry" id="entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="width_chars">4</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+</interface>
More information about the Libreoffice-commits
mailing list