cui/uiconfig/ui/colorpage.ui | 1 + include/svx/hexcolorcontrol.hxx | 7 ++++++- svx/source/dialog/hexcolorcontrol.cxx | 29 ++++++++++++++++++++++++++++- vcl/source/control/edit.cxx | 14 ++++++++++++-- 4 files changed, 47 insertions(+), 4 deletions(-)
New commits: commit 0198259e4301a45c339fcdda688892e1e6a3ad9f Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Mar 26 15:39:32 2019 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Fri Mar 29 22:24:18 2019 +0100 Resolves: tdf#123291 set hex input to overwrite by default and ensure the modify arrives after the input text has been filtered Change-Id: I16c0bd095700e7d9858e3e74884b5a1ad3eb7e4c Reviewed-on: https://gerrit.libreoffice.org/69764 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> (cherry picked from commit f1e52cbdd4a9753a9b9d562ef280a00e52db1dae) support overwrite-mode Change-Id: I6133aedbebd3ca358e2b916469873c38fc7453cb Reviewed-on: https://gerrit.libreoffice.org/69761 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> (cherry picked from commit 2f70e6111b61d52bbdfa753257370cb82bfd30eb) Related: tdf#123291 treat overwrite like a selection of 1 for input into ImplTruncateToMaxLen like we do for the following erase Change-Id: I8cd02ff1ba76f61ddc614922068cbe2bc9bc4cb8 Reviewed-on: https://gerrit.libreoffice.org/69763 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> (cherry picked from commit 8622dc09954a1a26661e3524c99e7ed0f456cf6e) Reviewed-on: https://gerrit.libreoffice.org/69800 Tested-by: Xisco Faulí <xiscofa...@libreoffice.org> diff --git a/cui/uiconfig/ui/colorpage.ui b/cui/uiconfig/ui/colorpage.ui index b801bc787b66..c35cfd4babef 100644 --- a/cui/uiconfig/ui/colorpage.ui +++ b/cui/uiconfig/ui/colorpage.ui @@ -788,6 +788,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="activates_default">True</property> + <property name="overwrite_mode">True</property> </object> <packing> <property name="left_attach">1</property> diff --git a/include/svx/hexcolorcontrol.hxx b/include/svx/hexcolorcontrol.hxx index 91960d9f7f9b..f47f50fb1e82 100644 --- a/include/svx/hexcolorcontrol.hxx +++ b/include/svx/hexcolorcontrol.hxx @@ -34,12 +34,17 @@ class SVX_DLLPUBLIC HexColorControl { private: std::unique_ptr<weld::Entry> m_xEntry; + Link<weld::Entry&, void> m_aModifyHdl; + ImplSVEvent* m_nAsyncModifyEvent; DECL_STATIC_LINK(HexColorControl, ImplProcessInputHdl, OUString&, bool); + DECL_LINK(ImplProcessModifyHdl, weld::Entry&, void); + DECL_LINK(OnAsyncModifyHdl, void*, void); public: HexColorControl(std::unique_ptr<weld::Entry> pEdit); + ~HexColorControl(); - void connect_changed(const Link<Entry&, void>& rLink) { m_xEntry->connect_changed(rLink); } + void connect_changed(const Link<weld::Entry&, void>& rLink) { m_aModifyHdl = rLink; } void SetColor( ::Color nColor ); ::Color GetColor(); diff --git a/svx/source/dialog/hexcolorcontrol.cxx b/svx/source/dialog/hexcolorcontrol.cxx index e9ddfb553a43..70e32e540827 100644 --- a/svx/source/dialog/hexcolorcontrol.cxx +++ b/svx/source/dialog/hexcolorcontrol.cxx @@ -19,22 +19,49 @@ #include <svx/hexcolorcontrol.hxx> #include <rtl/character.hxx> +#include <vcl/svapp.hxx> namespace weld { HexColorControl::HexColorControl(std::unique_ptr<weld::Entry> pEntry) : m_xEntry(std::move(pEntry)) + , m_nAsyncModifyEvent(nullptr) { m_xEntry->set_max_length(6); m_xEntry->set_width_chars(6); m_xEntry->connect_insert_text(LINK(this, HexColorControl, ImplProcessInputHdl)); + m_xEntry->connect_changed(LINK(this, HexColorControl, ImplProcessModifyHdl)); +} + +HexColorControl::~HexColorControl() +{ + if (m_nAsyncModifyEvent) + Application::RemoveUserEvent(m_nAsyncModifyEvent); +} + +IMPL_LINK_NOARG(HexColorControl, OnAsyncModifyHdl, void*, void) +{ + m_nAsyncModifyEvent = nullptr; + m_aModifyHdl.Call(*m_xEntry); +} + +// tdf#123291 resend it async so it arrives after ImplProcessInputHdl has been +// processed +IMPL_LINK_NOARG(HexColorControl, ImplProcessModifyHdl, weld::Entry&, void) +{ + if (m_nAsyncModifyEvent) + Application::RemoveUserEvent(m_nAsyncModifyEvent); + m_nAsyncModifyEvent = Application::PostUserEvent(LINK(this, HexColorControl, OnAsyncModifyHdl)); } void HexColorControl::SetColor(Color nColor) { OUStringBuffer aBuffer; sax::Converter::convertColor(aBuffer, nColor); - m_xEntry->set_text(aBuffer.makeStringAndClear().copy(1)); + OUString sColor = aBuffer.makeStringAndClear().copy(1); + if (sColor == m_xEntry->get_text()) + return; + m_xEntry->set_text(sColor); } Color HexColorControl::GetColor() diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index 00e44a98e39c..547f9464186d 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -194,6 +194,10 @@ bool Edit::set_property(const OString &rKey, const OUString &rValue) { SetReadOnly(!toBool(rValue)); } + else if (rKey == "overwrite-mode") + { + SetInsertMode(!toBool(rValue)); + } else if (rKey == "visibility") { mbPassword = false; @@ -788,13 +792,19 @@ void Edit::ImplInsertText( const OUString& rStr, const Selection* pNewSel, bool aSelection.Justify(); OUString aNewText( ImplGetValidString( rStr ) ); - ImplTruncateToMaxLen( aNewText, aSelection.Len() ); + + // as below, if there's no selection, but we're in overwrite mode and not beyond + // the end of the existing text then that's like a selection of 1 + auto nSelectionLen = aSelection.Len(); + if (!nSelectionLen && !mbInsertMode && aSelection.Max() < maText.getLength()) + nSelectionLen = 1; + ImplTruncateToMaxLen( aNewText, nSelectionLen ); ImplClearLayoutData(); if ( aSelection.Len() ) maText.remove( static_cast<sal_Int32>(aSelection.Min()), static_cast<sal_Int32>(aSelection.Len()) ); - else if ( !mbInsertMode && (aSelection.Max() < maText.getLength()) ) + else if (!mbInsertMode && aSelection.Max() < maText.getLength()) maText.remove( static_cast<sal_Int32>(aSelection.Max()), 1 ); // take care of input-sequence-checking now _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits