[Libreoffice-commits] core.git: solenv/sanitizers sw/inc sw/source sw/uiconfig sw/UIConfig_swriter.mk

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Sun Feb 16 19:18:01 UTC 2020


 solenv/sanitizers/ui/modules/swriter.suppr         |    1 
 sw/UIConfig_swriter.mk                             |    1 
 sw/inc/pch/precompiled_sw.hxx                      |    6 +
 sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx |   89 ++++++++++++++++-----
 sw/source/uibase/inc/actctrl.hxx                   |    7 +
 sw/uiconfig/swriter/ui/checkbox.ui                 |   27 ++++++
 6 files changed, 112 insertions(+), 19 deletions(-)

New commits:
commit 83c0b9940057eb734a247a5f44386452a6a1a9e9
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Feb 16 16:28:33 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Sun Feb 16 20:17:26 2020 +0100

    weld ExcludeCheckBox Item Window
    
    Change-Id: Ic9aba102f7a6ac2112cf1f6d1c2f0a0b1beb8c2f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88814
    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 d60e64493575..21e5736992a1 100644
--- a/solenv/sanitizers/ui/modules/swriter.suppr
+++ b/solenv/sanitizers/ui/modules/swriter.suppr
@@ -22,6 +22,7 @@ sw/uiconfig/swriter/ui/businessdatapage.ui://GtkEntry[@id='state'] no-labelled-b
 sw/uiconfig/swriter/ui/cardmediumpage.ui://GtkLabel[@id='formatinfo'] orphan-label
 sw/uiconfig/swriter/ui/cardmediumpage.ui://GtkComboBoxText[@id='hiddentype'] no-labelled-by
 sw/uiconfig/swriter/ui/ccdialog.ui://GtkLabel[@id='label4'] orphan-label
+sw/uiconfig/swriter/ui/checkbox.ui://GtkCheckButton[@id='checkbutton'] button-no-label
 sw/uiconfig/swriter/ui/columnpage.ui://GtkSpinButton[@id='width3mf'] labelled-by-and-mnemonic
 sw/uiconfig/swriter/ui/columnpage.ui://GtkSpinButton[@id='width2mf'] labelled-by-and-mnemonic
 sw/uiconfig/swriter/ui/columnpage.ui://GtkSpinButton[@id='width1mf'] labelled-by-and-mnemonic
diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk
index 11fc70e9048b..851348613d60 100644
--- a/sw/UIConfig_swriter.mk
+++ b/sw/UIConfig_swriter.mk
@@ -111,6 +111,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\
 	sw/uiconfig/swriter/ui/ccdialog \
 	sw/uiconfig/swriter/ui/characterproperties \
 	sw/uiconfig/swriter/ui/charurlpage \
+	sw/uiconfig/swriter/ui/checkbox \
 	sw/uiconfig/swriter/ui/columndialog \
 	sw/uiconfig/swriter/ui/columnpage \
 	sw/uiconfig/swriter/ui/columnwidth \
diff --git a/sw/inc/pch/precompiled_sw.hxx b/sw/inc/pch/precompiled_sw.hxx
index ff6d99eaff68..78e52e5f430e 100644
--- a/sw/inc/pch/precompiled_sw.hxx
+++ b/sw/inc/pch/precompiled_sw.hxx
@@ -13,7 +13,7 @@
  manual changes will be rewritten by the next run of update_pch.sh (which presumably
  also fixes all possible problems, so it's usually better to use it).
 
- Generated on 2020-02-14 09:24:22 using:
+ Generated on 2020-02-16 16:30:24 using:
  ./bin/update_pch sw sw --cutoff=7 --exclude:system --exclude:module --include:local
 
  If after updating build fails, use the following command to locate conflicting headers:
@@ -68,6 +68,9 @@
 #include <rtl/math.hxx>
 #include <rtl/ref.hxx>
 #include <rtl/strbuf.hxx>
+#include <rtl/string.h>
+#include <rtl/stringconcat.hxx>
+#include <rtl/stringutils.hxx>
 #include <rtl/tencinfo.h>
 #include <rtl/textenc.h>
 #include <rtl/unload.h>
@@ -411,6 +414,7 @@
 #include <unotools/unotoolsdllapi.h>
 #include <unotools/useroptions.hxx>
 #include <xmloff/dllapi.h>
+#include <xmloff/families.hxx>
 #include <xmloff/nmspmap.hxx>
 #include <xmloff/odffields.hxx>
 #include <xmloff/xmlictxt.hxx>
diff --git a/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx b/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx
index 854a2c0c6a94..84395b7cfc65 100644
--- a/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx
+++ b/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx
@@ -21,7 +21,7 @@
 #include <cppuhelper/supportsservice.hxx>
 #include <svtools/toolboxcontroller.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
-#include <vcl/button.hxx>
+#include <sfx2/InterimItemWindow.hxx>
 #include <vcl/edit.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/toolbox.hxx>
@@ -97,17 +97,73 @@ public:
     virtual void SAL_CALL statusChanged(const frame::FeatureStateEvent& rEvent) override;
 };
 
+class ExcludeCheckBox final : public InterimItemWindow
+{
+private:
+    std::unique_ptr<weld::CheckButton> m_xWidget;
+
+    DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
+public:
+    ExcludeCheckBox(vcl::Window* pParent)
+        : InterimItemWindow(pParent, "modules/swriter/ui/checkbox.ui", "CheckBox")
+        , m_xWidget(m_xBuilder->weld_check_button("checkbutton"))
+    {
+        m_xWidget->set_label(SwResId(ST_EXCLUDE));
+        m_xWidget->connect_key_press(LINK(this, ExcludeCheckBox, 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);
+    }
+
+    void set_active(bool bActive)
+    {
+        m_xWidget->set_active(bActive);
+    }
+
+    void connect_toggled(const Link<weld::ToggleButton&, void>& rLink)
+    {
+        m_xWidget->connect_toggled(rLink);
+    }
+
+    virtual ~ExcludeCheckBox() override
+    {
+        disposeOnce();
+    }
+};
+
+IMPL_LINK(ExcludeCheckBox, KeyInputHdl, const KeyEvent&, rKEvt, bool)
+{
+    return ChildKeyInput(rKEvt);
+}
+
 /// Controller for .uno:MailMergeExcludeEntry toolbar checkbox: creates the checkbox & handles the value.
 class MMExcludeEntryController : public svt::ToolboxController, public lang::XServiceInfo
 {
-    VclPtr<CheckBox> m_pExcludeCheckbox;
+    VclPtr<ExcludeCheckBox> m_xExcludeCheckbox;
 
-    DECL_STATIC_LINK(MMExcludeEntryController, ExcludeHdl, CheckBox&, void);
+    DECL_STATIC_LINK(MMExcludeEntryController, ExcludeHdl, weld::ToggleButton&, void);
 
 public:
     explicit MMExcludeEntryController(const uno::Reference<uno::XComponentContext>& rContext)
         : svt::ToolboxController(rContext, uno::Reference<frame::XFrame>(), ".uno:MailMergeExcludeEntry")
-        , m_pExcludeCheckbox(nullptr)
+        , m_xExcludeCheckbox(nullptr)
     {
     }
 
@@ -233,7 +289,7 @@ void MMExcludeEntryController::dispose()
     SolarMutexGuard aSolarMutexGuard;
 
     svt::ToolboxController::dispose();
-    m_pExcludeCheckbox.disposeAndClear();
+    m_xExcludeCheckbox.disposeAndClear();
 }
 
 uno::Reference<awt::XWindow> MMExcludeEntryController::createItemWindow(const uno::Reference<awt::XWindow>& rParent)
@@ -243,17 +299,14 @@ uno::Reference<awt::XWindow> MMExcludeEntryController::createItemWindow(const un
     if (pToolbar)
     {
         // make it visible
-        m_pExcludeCheckbox = VclPtr<CheckBox>::Create(pToolbar);
-        m_pExcludeCheckbox->SetText(SwResId(ST_EXCLUDE));
-        m_pExcludeCheckbox->SetSizePixel(m_pExcludeCheckbox->GetOptimalSize());
-
-        m_pExcludeCheckbox->SetToggleHdl(LINK(this, MMExcludeEntryController, ExcludeHdl));
+        m_xExcludeCheckbox = VclPtr<ExcludeCheckBox>::Create(pToolbar);
+        m_xExcludeCheckbox->connect_toggled(LINK(this, MMExcludeEntryController, ExcludeHdl));
     }
 
-    return VCLUnoHelper::GetInterface(m_pExcludeCheckbox);
+    return VCLUnoHelper::GetInterface(m_xExcludeCheckbox);
 }
 
-IMPL_STATIC_LINK(MMExcludeEntryController, ExcludeHdl, CheckBox&, rCheckbox, void)
+IMPL_STATIC_LINK(MMExcludeEntryController, ExcludeHdl, weld::ToggleButton&, rCheckbox, void)
 {
     SwView* pView = ::GetActiveView();
     std::shared_ptr<SwMailMergeConfigItem> xConfigItem;
@@ -261,12 +314,12 @@ IMPL_STATIC_LINK(MMExcludeEntryController, ExcludeHdl, CheckBox&, rCheckbox, voi
         xConfigItem = pView->GetMailMergeConfigItem();
 
     if (xConfigItem)
-        xConfigItem->ExcludeRecord(xConfigItem->GetResultSetPosition(), rCheckbox.IsChecked());
+        xConfigItem->ExcludeRecord(xConfigItem->GetResultSetPosition(), rCheckbox.get_active());
 };
 
 void MMExcludeEntryController::statusChanged(const frame::FeatureStateEvent& rEvent)
 {
-    if (!m_pExcludeCheckbox)
+    if (!m_xExcludeCheckbox)
         return;
 
     SwView* pView = ::GetActiveView();
@@ -276,13 +329,13 @@ void MMExcludeEntryController::statusChanged(const frame::FeatureStateEvent& rEv
 
     if (!xConfigItem || !rEvent.IsEnabled)
     {
-        m_pExcludeCheckbox->Disable();
-        m_pExcludeCheckbox->Check(false);
+        m_xExcludeCheckbox->set_sensitive(false);
+        m_xExcludeCheckbox->set_active(false);
     }
     else
     {
-        m_pExcludeCheckbox->Enable();
-        m_pExcludeCheckbox->Check(xConfigItem->IsRecordExcluded(xConfigItem->GetResultSetPosition()));
+        m_xExcludeCheckbox->set_sensitive(false);
+        m_xExcludeCheckbox->set_active(xConfigItem->IsRecordExcluded(xConfigItem->GetResultSetPosition()));
     }
 }
 
diff --git a/sw/source/uibase/inc/actctrl.hxx b/sw/source/uibase/inc/actctrl.hxx
index 76fe1ca0fe6d..fdb2feb7109b 100644
--- a/sw/source/uibase/inc/actctrl.hxx
+++ b/sw/source/uibase/inc/actctrl.hxx
@@ -45,6 +45,13 @@ public:
         disposeOnce();
     }
 
+    virtual void GetFocus() override
+    {
+        if (m_xWidget)
+            m_xWidget->grab_focus();
+        InterimItemWindow::GetFocus();
+    }
+
     void connect_value_changed(const Link<weld::SpinButton&, void>& rLink)
     {
         m_xWidget->connect_value_changed(rLink);
diff --git a/sw/uiconfig/swriter/ui/checkbox.ui b/sw/uiconfig/swriter/ui/checkbox.ui
new file mode 100644
index 000000000000..02dece622bcf
--- /dev/null
+++ b/sw/uiconfig/swriter/ui/checkbox.ui
@@ -0,0 +1,27 @@
+<?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="CheckBox">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="hexpand">True</property>
+    <property name="spacing">6</property>
+    <child>
+      <object class="GtkCheckButton" id="checkbutton">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="receives_default">False</property>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
+        <property name="use_underline">True</property>
+        <property name="draw_indicator">True</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