[Libreoffice-commits] core.git: svx/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Jul 28 20:19:19 UTC 2020


 svx/source/tbxctrls/tbcontrl.cxx |   45 ++++++++++++++++++++++++++++++++-------
 1 file changed, 37 insertions(+), 8 deletions(-)

New commits:
commit 9b2dce4518db89cadbd54a34d1f6375128c3c8a6
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Jul 28 19:25:29 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Jul 28 22:18:35 2020 +0200

    Resolves: tdf#134660 listen for 'ShowFontBoxWYSIWYG' config changes
    
    instead of checking for changes to them when the fontbox get focus, its now too
    late at that point to update ComboBox WYSIWYG mode
    
    Change-Id: Ieea6a4c00be2eb46909d46af29ddd615fff002d5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99646
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 2132939cc141..c8631acb28f3 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -20,6 +20,7 @@
 #include <typeinfo>
 #include <utility>
 
+#include <comphelper/configurationlistener.hxx>
 #include <comphelper/propertysequence.hxx>
 #include <tools/color.hxx>
 #include <svl/poolitem.hxx>
@@ -296,8 +297,27 @@ private:
     SvxFontNameBox_Base* m_pBox;
 };
 
+class FontOptionsListener final : public comphelper::ConfigurationListenerProperty<bool>
+{
+private:
+    SvxFontNameBox_Base& m_rBox;
+
+    virtual void setProperty(const css::uno::Any &rProperty) override;
+public:
+    FontOptionsListener(const rtl::Reference<comphelper::ConfigurationListener>& rListener, const OUString& rProp, SvxFontNameBox_Base& rBox)
+        : comphelper::ConfigurationListenerProperty<bool>(rListener, rProp)
+        , m_rBox(rBox)
+    {
+    }
+};
+
 class SvxFontNameBox_Base
 {
+private:
+    rtl::Reference<comphelper::ConfigurationListener> m_xListener;
+    FontOptionsListener m_aWYSIWYG;
+    FontOptionsListener m_aHistory;
+
 protected:
     SvxFontNameToolBoxControl& m_rCtrl;
 
@@ -312,7 +332,6 @@ protected:
     bool            mbCheckingUnknownFont;
 
     void            ReleaseFocus_Impl();
-    void            EnableControls_Impl();
 
     void            Select(bool bNonTravelSelect);
 
@@ -330,6 +349,7 @@ public:
                         const Reference<XFrame>& rFrame, SvxFontNameToolBoxControl& rCtrl);
     virtual ~SvxFontNameBox_Base()
     {
+        m_xListener->dispose();
     }
 
     void            FillList();
@@ -355,6 +375,8 @@ public:
 
     virtual bool DoKeyInput(const KeyEvent& rKEvt);
 
+    void EnableControls();
+
     DECL_LINK(SelectHdl, weld::ComboBox&, void);
     DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
     DECL_LINK(ActivateHdl, weld::ComboBox&, bool);
@@ -363,6 +385,12 @@ public:
     DECL_LINK(DumpAsPropertyTreeHdl, tools::JsonWriter&, void);
 };
 
+void FontOptionsListener::setProperty(const css::uno::Any &rProperty)
+{
+    comphelper::ConfigurationListenerProperty<bool>::setProperty(rProperty);
+    m_rBox.EnableControls();
+}
+
 class SvxFontNameBox_Impl final : public InterimItemWindow
                                 , public SvxFontNameBox_Base
 {
@@ -1438,7 +1466,10 @@ SvxFontNameBox_Base::SvxFontNameBox_Base(std::unique_ptr<weld::ComboBox> xWidget
                                          const Reference<XDispatchProvider>& rDispatchProvider,
                                          const Reference<XFrame>& rFrame,
                                          SvxFontNameToolBoxControl& rCtrl)
-    : m_rCtrl(rCtrl)
+    : m_xListener(new comphelper::ConfigurationListener("/org.openoffice.Office.Common/Font/View"))
+    , m_aWYSIWYG(m_xListener, "ShowFontBoxWYSIWYG", *this)
+    , m_aHistory(m_xListener, "History", *this)
+    , m_rCtrl(rCtrl)
     , m_xWidget(new FontNameBox(std::move(xWidget)))
     , pFontList(nullptr)
     , nFtCount(0)
@@ -1447,7 +1478,7 @@ SvxFontNameBox_Base::SvxFontNameBox_Base(std::unique_ptr<weld::ComboBox> xWidget
     , m_xFrame(rFrame)
     , mbCheckingUnknownFont(false)
 {
-    EnableControls_Impl();
+    EnableControls();
 
     m_xWidget->connect_changed(LINK(this, SvxFontNameBox_Base, SelectHdl));
     m_xWidget->connect_key_press(LINK(this, SvxFontNameBox_Base, KeyInputHdl));
@@ -1536,7 +1567,6 @@ void SvxFontNameBox_Base::set_active_or_entry_text(const OUString& rText)
 
 IMPL_LINK_NOARG(SvxFontNameBox_Base, FocusInHdl, weld::Widget&, void)
 {
-    EnableControls_Impl();
     FillList();
 }
 
@@ -1625,13 +1655,12 @@ void SvxFontNameBox_Base::ReleaseFocus_Impl()
         m_xFrame->getContainerWindow()->setFocus();
 }
 
-void SvxFontNameBox_Base::EnableControls_Impl()
+void SvxFontNameBox_Base::EnableControls()
 {
-    SvtFontOptions aFontOpt;
-    bool bEnableMRU = aFontOpt.IsFontHistoryEnabled();
+    bool bEnableMRU = m_aHistory.get();
     sal_uInt16 nEntries = bEnableMRU ? MAX_MRU_FONTNAME_ENTRIES : 0;
 
-    bool bNewWYSIWYG = aFontOpt.IsFontWYSIWYGEnabled();
+    bool bNewWYSIWYG = m_aWYSIWYG.get();
     bool bOldWYSIWYG = m_xWidget->IsWYSIWYGEnabled();
 
     if (m_xWidget->get_max_mru_count() != nEntries || bNewWYSIWYG != bOldWYSIWYG)


More information about the Libreoffice-commits mailing list