summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-07-28 19:25:29 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-07-28 22:18:35 +0200
commit9b2dce4518db89cadbd54a34d1f6375128c3c8a6 (patch)
tree75f4097a28f27277302482d31ca956f3c6fb776a /svx
parent3b8c893b487a3ee27bac710da74856225fb72950 (diff)
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@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx45
1 files changed, 37 insertions, 8 deletions
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)