sc/source/ui/inc/tpformula.hxx | 4 ++ sc/source/ui/optdlg/tpformula.cxx | 51 +++++++++++++++++++++---------------- sc/uiconfig/scalc/ui/optformula.ui | 3 ++ 3 files changed, 36 insertions(+), 22 deletions(-)
New commits: commit aad738a6bb1155365321ac6bf119aaedd4e749ec Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Fri Dec 20 10:40:53 2019 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Fri Dec 20 16:01:17 2019 +0100 Resolves: tdf#129501 cannot change formula separators in options Change-Id: I5cf5736f8ad3d5e28f2c31ffa88dafac59df8a8e Reviewed-on: https://gerrit.libreoffice.org/85587 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/sc/source/ui/inc/tpformula.hxx b/sc/source/ui/inc/tpformula.hxx index 4de05560cfd3..3cda79900d0e 100644 --- a/sc/source/ui/inc/tpformula.hxx +++ b/sc/source/ui/inc/tpformula.hxx @@ -43,9 +43,11 @@ private: void LaunchCustomCalcSettings(); bool IsValidSeparator(const OUString& rSep) const; - bool IsValidSeparatorSet() const; DECL_LINK( ButtonHdl, weld::Button&, void ); + DECL_LINK( SepInsertTextHdl, OUString&, bool ); + DECL_LINK( ColSepInsertTextHdl, OUString&, bool ); + DECL_LINK( RowSepInsertTextHdl, OUString&, bool ); DECL_LINK( SepModifyHdl, weld::Entry&, void ); DECL_LINK( SepEditOnFocusHdl, weld::Widget&, void ); diff --git a/sc/source/ui/optdlg/tpformula.cxx b/sc/source/ui/optdlg/tpformula.cxx index b4825149ae58..5bf50dea60b9 100644 --- a/sc/source/ui/optdlg/tpformula.cxx +++ b/sc/source/ui/optdlg/tpformula.cxx @@ -56,6 +56,10 @@ ScTpFormulaOptions::ScTpFormulaOptions(weld::Container* pPage, weld::DialogContr mxBtnCustomCalcCustom->connect_clicked(aLink2); mxBtnCustomCalcDetails->connect_clicked(aLink2); + mxEdSepFuncArg->connect_insert_text(LINK( this, ScTpFormulaOptions, SepInsertTextHdl )); + mxEdSepArrayCol->connect_insert_text(LINK( this, ScTpFormulaOptions, ColSepInsertTextHdl )); + mxEdSepArrayRow->connect_insert_text(LINK( this, ScTpFormulaOptions, RowSepInsertTextHdl )); + Link<weld::Entry&,void> aLink = LINK( this, ScTpFormulaOptions, SepModifyHdl ); mxEdSepFuncArg->connect_changed(aLink); mxEdSepArrayCol->connect_changed(aLink); @@ -94,7 +98,9 @@ void ScTpFormulaOptions::OnFocusSeparatorInput(weld::Entry* pEdit) // Make sure the entire text is selected. pEdit->select_region(0, -1); - maOldSepValue = pEdit->get_text(); + OUString sSepValue = pEdit->get_text(); + if (!sSepValue.isEmpty()) + maOldSepValue = sSepValue; } void ScTpFormulaOptions::UpdateCustomCalcRadioButtons(bool bDefault) @@ -161,14 +167,6 @@ bool ScTpFormulaOptions::IsValidSeparator(const OUString& rSep) const return true; } -bool ScTpFormulaOptions::IsValidSeparatorSet() const -{ - // Make sure the column and row separators are different. - OUString aColStr = mxEdSepArrayCol->get_text(); - OUString aRowStr = mxEdSepArrayRow->get_text(); - return aColStr != aRowStr; -} - IMPL_LINK( ScTpFormulaOptions, ButtonHdl, weld::Button&, rBtn, void ) { if (&rBtn == mxBtnSepReset.get()) @@ -181,21 +179,32 @@ IMPL_LINK( ScTpFormulaOptions, ButtonHdl, weld::Button&, rBtn, void ) LaunchCustomCalcSettings(); } -IMPL_LINK( ScTpFormulaOptions, SepModifyHdl, weld::Entry&, rEdit, void ) +IMPL_LINK(ScTpFormulaOptions, SepInsertTextHdl, OUString&, rTest, bool) { - OUString aStr = rEdit.get_text(); - if (aStr.getLength() > 1) - { - // In case the string is more than one character long, only grab the - // first character. - aStr = aStr.copy(0, 1); - rEdit.set_text(aStr); - } - - if ((!IsValidSeparator(aStr) || !IsValidSeparatorSet()) && !maOldSepValue.isEmpty()) + if (!IsValidSeparator(rTest) && !maOldSepValue.isEmpty()) // Invalid separator. Restore the old value. - rEdit.set_text(maOldSepValue); + rTest = maOldSepValue; + return true; +} +IMPL_LINK(ScTpFormulaOptions, RowSepInsertTextHdl, OUString&, rTest, bool) +{ + // Invalid separator or same as ColStr - Restore the old value. + if ((!IsValidSeparator(rTest) || rTest == mxEdSepArrayCol->get_text()) && !maOldSepValue.isEmpty()) + rTest = maOldSepValue; + return true; +} + +IMPL_LINK(ScTpFormulaOptions, ColSepInsertTextHdl, OUString&, rTest, bool) +{ + // Invalid separator or same as RowStr - Restore the old value. + if ((!IsValidSeparator(rTest) || rTest == mxEdSepArrayRow->get_text()) && !maOldSepValue.isEmpty()) + rTest = maOldSepValue; + return true; +} + +IMPL_LINK( ScTpFormulaOptions, SepModifyHdl, weld::Entry&, rEdit, void ) +{ OnFocusSeparatorInput(&rEdit); } diff --git a/sc/uiconfig/scalc/ui/optformula.ui b/sc/uiconfig/scalc/ui/optformula.ui index 8b8f2a8dfa6f..ceae62e26a70 100644 --- a/sc/uiconfig/scalc/ui/optformula.ui +++ b/sc/uiconfig/scalc/ui/optformula.ui @@ -357,6 +357,7 @@ <object class="GtkEntry" id="function"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="max_length">1</property> <property name="activates_default">True</property> <property name="width_chars">5</property> <property name="max_width_chars">1</property> @@ -370,6 +371,7 @@ <object class="GtkEntry" id="arraycolumn"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="max_length">1</property> <property name="activates_default">True</property> <property name="width_chars">5</property> <property name="max_width_chars">1</property> @@ -383,6 +385,7 @@ <object class="GtkEntry" id="arrayrow"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="max_length">1</property> <property name="activates_default">True</property> <property name="width_chars">5</property> <property name="max_width_chars">1</property> _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits