save/restore the entry text of the fontsize widget

instead of its value, because the min value is 2, but we set
empty text to indicate multiple values are selected in the underlying
text.

Change-Id: If4232b500cd177a264aa5e6ca0537021483db95f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90208
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara 2020-03-09 10:26:54 +00:00
parent ad85d0503b
commit 633b2f4dff
5 changed files with 14 additions and 10 deletions

View file

@ -766,7 +766,7 @@ void SvxCharNamePage::Reset_Impl( const SfxItemSet& rSet, LanguageGroup eLangGrp
} }
else else
{ {
pSizeBox->set_active_text( OUString() ); pSizeBox->set_entry_text( OUString() );
if ( eState <= SfxItemState::READONLY ) if ( eState <= SfxItemState::READONLY )
{ {
pSizeBox->set_sensitive(false); pSizeBox->set_sensitive(false);

View file

@ -438,7 +438,7 @@ public:
void connect_focus_out(const Link<weld::Widget&, void>& rLink) { m_aFocusOutHdl = rLink; } void connect_focus_out(const Link<weld::Widget&, void>& rLink) { m_aFocusOutHdl = rLink; }
void connect_key_press(const Link<const KeyEvent&, bool>& rLink) { m_xComboBox->connect_key_press(rLink); } void connect_key_press(const Link<const KeyEvent&, bool>& rLink) { m_xComboBox->connect_key_press(rLink); }
OUString get_active_text() const { return m_xComboBox->get_active_text(); } OUString get_active_text() const { return m_xComboBox->get_active_text(); }
void set_active_text(const OUString& rText) { m_xComboBox->set_active_text(rText); } void set_entry_text(const OUString& rText);
void set_sensitive(bool bSensitive) { m_xComboBox->set_sensitive(bSensitive); } void set_sensitive(bool bSensitive) { m_xComboBox->set_sensitive(bSensitive); }
int get_active() const { return m_xComboBox->get_active(); } int get_active() const { return m_xComboBox->get_active(); }
int get_value() const; int get_value() const;

View file

@ -868,6 +868,11 @@ FontSizeBox::FontSizeBox(std::unique_ptr<weld::ComboBox> p)
m_xComboBox->connect_changed(LINK(this, FontSizeBox, ModifyHdl)); m_xComboBox->connect_changed(LINK(this, FontSizeBox, ModifyHdl));
} }
void FontSizeBox::set_entry_text(const OUString& rText)
{
m_xComboBox->set_entry_text(rText);
}
IMPL_LINK(FontSizeBox, ReformatHdl, weld::Widget&, rWidget, void) IMPL_LINK(FontSizeBox, ReformatHdl, weld::Widget&, rWidget, void)
{ {
FontSizeNames aFontSizeNames(Application::GetSettings().GetUILanguageTag().getLanguageType()); FontSizeNames aFontSizeNames(Application::GetSettings().GetUILanguageTag().getLanguageType());
@ -1157,8 +1162,7 @@ void FontSizeBox::SetValue(int nNewValue, FieldUnit eInUnit)
const int nFound = m_xComboBox->find_text(aResult); const int nFound = m_xComboBox->find_text(aResult);
if (nFound != -1) if (nFound != -1)
m_xComboBox->set_active(nFound); m_xComboBox->set_active(nFound);
else m_xComboBox->set_entry_text(aResult);
m_xComboBox->set_entry_text(aResult);
} }
void FontSizeBox::set_value(int nNewValue) void FontSizeBox::set_value(int nNewValue)

View file

@ -133,7 +133,7 @@ SvxFontSizeBox_Impl::SvxFontSizeBox_Impl(
m_xWidget(new FontSizeBox(m_xBuilder->weld_combo_box("fontsizecombobox"))) m_xWidget(new FontSizeBox(m_xBuilder->weld_combo_box("fontsizecombobox")))
{ {
m_xWidget->set_value(0); m_xWidget->set_value(0);
m_xWidget->set_active_text(""); m_xWidget->set_entry_text("");
m_xWidget->disable_entry_completion(); m_xWidget->disable_entry_completion();
m_xWidget->connect_changed(LINK(this, SvxFontSizeBox_Impl, SelectHdl)); m_xWidget->connect_changed(LINK(this, SvxFontSizeBox_Impl, SelectHdl));
@ -217,9 +217,9 @@ void SvxFontSizeBox_Impl::statusChanged_Impl( long nPoint, bool bErase )
{ {
// delete value in the display // delete value in the display
m_xWidget->set_value(-1L); m_xWidget->set_value(-1L);
m_xWidget->set_active_text(""); m_xWidget->set_entry_text("");
} }
m_xWidget->save_value(); m_aCurText = m_xWidget->get_active_text();
} }
void SvxFontSizeBox_Impl::UpdateFont( const css::awt::FontDescriptor& rCurrentFont ) void SvxFontSizeBox_Impl::UpdateFont( const css::awt::FontDescriptor& rCurrentFont )
@ -260,7 +260,7 @@ IMPL_LINK(SvxFontSizeBox_Impl, KeyInputHdl, const KeyEvent&, rKEvt, bool)
break; break;
case KEY_ESCAPE: case KEY_ESCAPE:
m_xWidget->set_active_text(m_aCurText); m_xWidget->set_entry_text(m_aCurText);
if ( typeid( *GetParent() ) != typeid( sfx2::sidebar::SidebarToolBox ) ) if ( typeid( *GetParent() ) != typeid( sfx2::sidebar::SidebarToolBox ) )
ReleaseFocus_Impl(); ReleaseFocus_Impl();
bHandled = true; bHandled = true;
@ -273,7 +273,7 @@ IMPL_LINK(SvxFontSizeBox_Impl, KeyInputHdl, const KeyEvent&, rKEvt, bool)
IMPL_LINK_NOARG(SvxFontSizeBox_Impl, FocusOutHdl, weld::Widget&, void) IMPL_LINK_NOARG(SvxFontSizeBox_Impl, FocusOutHdl, weld::Widget&, void)
{ {
if (!m_xWidget->has_focus()) // a combobox can be comprised of different subwidget so double-check if none of those has focus if (!m_xWidget->has_focus()) // a combobox can be comprised of different subwidget so double-check if none of those has focus
m_xWidget->set_value(m_xWidget->get_saved_value()); m_xWidget->set_entry_text(m_aCurText);
} }
void SvxFontSizeBox_Impl::SetOptimalSize() void SvxFontSizeBox_Impl::SetOptimalSize()

View file

@ -5881,7 +5881,7 @@ public:
virtual bool changed_by_direct_pick() const override virtual bool changed_by_direct_pick() const override
{ {
return m_bInSelect && !m_xComboBox->IsModifyByKeyboard(); return m_bInSelect && !m_xComboBox->IsModifyByKeyboard() && !m_xComboBox->IsTravelSelect();
} }
virtual void set_entry_message_type(weld::EntryMessageType eType) override virtual void set_entry_message_type(weld::EntryMessageType eType) override