diff options
author | Andreas Heinisch <andreas.heinisch@yahoo.de> | 2021-04-02 13:23:46 +0200 |
---|---|---|
committer | Heiko Tietze <heiko.tietze@documentfoundation.org> | 2021-04-12 08:39:47 +0200 |
commit | 58dcf2a88af215df4e912f0cfcb32908c6a298a0 (patch) | |
tree | eeb26453c61e050d1b6414881a3677cb472e8330 /sc | |
parent | f9fae84cbd9663d6a394aa8e4e4b927c11384815 (diff) |
tdf#132869 - Show the error message in a tooltip
In the define name dialog, the input itself should show the error
message in a tooltip. In addition, the possibility to test the tooltip
text in python was added.
Change-Id: I9bd7d2b2be8300aa366971f8a1f115e8ae19fb98
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113513
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/uitest/range_name/tdf86214.py | 10 | ||||
-rw-r--r-- | sc/source/ui/namedlg/namedefdlg.cxx | 34 |
2 files changed, 21 insertions, 23 deletions
diff --git a/sc/qa/uitest/range_name/tdf86214.py b/sc/qa/uitest/range_name/tdf86214.py index d529a47b9dd1..48817e0bcc64 100644 --- a/sc/qa/uitest/range_name/tdf86214.py +++ b/sc/qa/uitest/range_name/tdf86214.py @@ -39,16 +39,18 @@ class InvalidNames(UITestCase): select_all(xEdit) type_text(xEdit, name) - new_text = get_state_as_dict(xLabel)["Text"] - self.assertNotEqual(success_text, new_text) + # tdf#132869 - Without the fix in place, this test would have failed with + # - Expected: "Invalid name. Start with a letter, use only letters, numbers and underscore." + # - Actual : "" + self.assertNotEqual(success_text, get_state_as_dict(xEdit)["QuickHelpText"]) self.assertEqual(get_state_as_dict(xAddBtn)["Enabled"], "false") select_all(xEdit) type_text(xEdit, "valid_name") - new_text = get_state_as_dict(xLabel)["Text"] - self.assertEqual(success_text, new_text) + self.assertEqual(success_text, get_state_as_dict(xLabel)["Text"]) + self.assertEqual(success_text, get_state_as_dict(xEdit)["QuickHelpText"]) self.assertEqual(get_state_as_dict(xAddBtn)["Enabled"], "true") self.ui_test.close_dialog_through_button(xAddBtn) diff --git a/sc/source/ui/namedlg/namedefdlg.cxx b/sc/source/ui/namedlg/namedefdlg.cxx index 25ff6e132a61..658026652c6b 100644 --- a/sc/source/ui/namedlg/namedefdlg.cxx +++ b/sc/source/ui/namedlg/namedefdlg.cxx @@ -120,6 +120,9 @@ bool ScNameDefDlg::IsNameValid() OUString aScope = m_xLbScope->get_active_text(); OUString aName = m_xEdName->get_text(); + bool bIsNameValid = true; + OUString aHelpText = maStrInfoDefault; + ScRangeName* pRangeName = nullptr; if(aScope == maGlobalNameStr) { @@ -131,46 +134,39 @@ bool ScNameDefDlg::IsNameValid() } ScRangeData::IsNameValidType eType; - m_xFtInfo->set_label_type(weld::LabelType::Normal); if ( aName.isEmpty() ) { - m_xBtnAdd->set_sensitive(false); - m_xFtInfo->set_label(maStrInfoDefault); - return false; + bIsNameValid = false; } else if ((eType = ScRangeData::IsNameValid(aName, mrDoc)) != ScRangeData::IsNameValidType::NAME_VALID) { - m_xFtInfo->set_label_type(weld::LabelType::Error); if (eType == ScRangeData::IsNameValidType::NAME_INVALID_BAD_STRING) { - m_xFtInfo->set_label(maErrInvalidNameStr); + aHelpText = maErrInvalidNameStr; } else if (eType == ScRangeData::IsNameValidType::NAME_INVALID_CELL_REF) { - m_xFtInfo->set_label(maErrInvalidNameCellRefStr); + aHelpText = maErrInvalidNameCellRefStr; } - m_xBtnAdd->set_sensitive(false); - return false; + bIsNameValid = false; } else if (pRangeName->findByUpperName(ScGlobal::getCharClassPtr()->uppercase(aName))) { - m_xFtInfo->set_label_type(weld::LabelType::Error); - m_xFtInfo->set_label(maErrNameInUse); - m_xBtnAdd->set_sensitive(false); - return false; + aHelpText = maErrNameInUse; + bIsNameValid = false; } if (!IsFormulaValid()) { - m_xFtInfo->set_label_type(weld::LabelType::Error); - m_xBtnAdd->set_sensitive(false); - return false; + bIsNameValid = false; } - m_xFtInfo->set_label(maStrInfoDefault); - m_xBtnAdd->set_sensitive(true); - return true; + m_xEdName->set_tooltip_text(aHelpText); + m_xEdName->set_message_type(bIsNameValid || aName.isEmpty() ? weld::EntryMessageType::Normal + : weld::EntryMessageType::Error); + m_xBtnAdd->set_sensitive(bIsNameValid); + return bIsNameValid; } void ScNameDefDlg::AddPushed() |