[Libreoffice-commits] core.git: sc/qa sc/source vcl/source
Andreas Heinisch (via logerrit)
logerrit at kemper.freedesktop.org
Mon Apr 12 06:40:25 UTC 2021
sc/qa/uitest/range_name/tdf86214.py | 10 ++++++----
sc/source/ui/namedlg/namedefdlg.cxx | 34 +++++++++++++++-------------------
vcl/source/uitest/uiobject.cxx | 1 +
3 files changed, 22 insertions(+), 23 deletions(-)
New commits:
commit 58dcf2a88af215df4e912f0cfcb32908c6a298a0
Author: Andreas Heinisch <andreas.heinisch at yahoo.de>
AuthorDate: Fri Apr 2 13:23:46 2021 +0200
Commit: Heiko Tietze <heiko.tietze at documentfoundation.org>
CommitDate: Mon Apr 12 08:39:47 2021 +0200
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 at documentfoundation.org>
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()
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx
index fc72053074c6..4d8390e212a2 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -785,6 +785,7 @@ StringMap EditUIObject::get_state()
{
StringMap aMap = WindowUIObject::get_state();
aMap["MaxTextLength"] = OUString::number(mxEdit->GetMaxTextLen());
+ aMap["QuickHelpText"] = mxEdit->GetQuickHelpText();
aMap["SelectedText"] = mxEdit->GetSelected();
aMap["Text"] = mxEdit->GetText();
More information about the Libreoffice-commits
mailing list