include/xmloff/xmltoken.hxx | 1 + offapi/com/sun/star/sheet/ValidationAlertStyle.idl | 7 ++++++- offapi/type_reference/offapi.idl | 3 ++- sc/inc/validat.hxx | 4 +++- sc/source/core/data/validat.cxx | 2 +- sc/source/filter/xml/XMLStylesExportHelper.cxx | 6 ++++++ sc/source/filter/xml/xmlcelli.cxx | 1 + sc/source/filter/xml/xmlcvali.cxx | 2 ++ sc/source/ui/app/inputhdl.cxx | 2 +- sc/source/ui/dbgui/validate.cxx | 21 +++++++++++---------- sc/source/ui/unoobj/fmtuno.cxx | 2 ++ sc/uiconfig/scalc/ui/erroralerttabpage.ui | 3 ++- xmloff/source/core/xmltoken.cxx | 1 + xmloff/source/token/tokens.txt | 1 + 14 files changed, 40 insertions(+), 16 deletions(-)
New commits: commit 2ce3901e754a8968bf667dbcfca3846e8acf5229 Author: Heiko Tietze <[email protected]> AuthorDate: Fri Dec 12 14:33:49 2025 +0100 Commit: Heiko Tietze <[email protected]> CommitDate: Fri Dec 19 10:22:52 2025 +0100 Resolves tdf#160096 [API CHANGE] - Improve data validity handling * Introduces a new option ValidationAlertStyle_NONE/SC_VALERR_NONE to silently reject invalid values (This is the behavior before c869fb5ea2fa1dbbfa7c17754aeac48ed7f77cc4) * Sets the disabled state depending on "[ ] Handle invalid values" (previously "Show Error on loading") The patch is motivated by bug 159595 respectively the inconsistent solution. Excel either allows invalid data or shows a message that allows to change/reject/accept the input. But there is not way to silently reject invalid data. The new option does not survive round trips and will be reset to Stop. Change-Id: I33c965aa7ba999e5850b80d35964b5383928349d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195563 Tested-by: Jenkins Reviewed-by: Heiko Tietze <[email protected]> diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx index cd1cb76a3cd7..1a1e23730e8f 100644 --- a/include/xmloff/xmltoken.hxx +++ b/include/xmloff/xmltoken.hxx @@ -2313,6 +2313,7 @@ namespace xmloff::token { XML_NOTIFY_ON_UPDATE_OF_RANGES, XML_BYTE, XML_MACRO, + XML_REJECT, XML_LOCATION, XML_APPLICATION, XML_SYMBOL_IMAGE, diff --git a/offapi/com/sun/star/sheet/ValidationAlertStyle.idl b/offapi/com/sun/star/sheet/ValidationAlertStyle.idl index a53933d0fae8..5c38c381d79f 100644 --- a/offapi/com/sun/star/sheet/ValidationAlertStyle.idl +++ b/offapi/com/sun/star/sheet/ValidationAlertStyle.idl @@ -45,8 +45,13 @@ published enum ValidationAlertStyle /** macro is executed. */ - MACRO + MACRO, + /** silently reject + + @since LibreOffice 26.2 + */ + NONE }; diff --git a/offapi/type_reference/offapi.idl b/offapi/type_reference/offapi.idl index 369ca0550221..12302afc524d 100644 --- a/offapi/type_reference/offapi.idl +++ b/offapi/type_reference/offapi.idl @@ -13265,7 +13265,8 @@ module com { STOP = 0, WARNING = 1, INFO = 2, - MACRO = 3 + MACRO = 3, + NONE = 4 }; published enum ValidationType { ANY = 0, diff --git a/sc/inc/validat.hxx b/sc/inc/validat.hxx index b79b294643c9..a56e590a59a0 100644 --- a/sc/inc/validat.hxx +++ b/sc/inc/validat.hxx @@ -54,7 +54,8 @@ enum ScValidErrorStyle SC_VALERR_STOP, SC_VALERR_WARNING, SC_VALERR_INFO, - SC_VALERR_MACRO + SC_VALERR_MACRO, + SC_VALERR_NONE }; // Entry for validation (only one condition exists) @@ -114,6 +115,7 @@ public: SC_DLLPUBLIC bool GetErrMsg( OUString& rTitle, OUString& rMsg, ScValidErrorStyle& rStyle ) const; ScValidationMode GetDataMode() const { return eDataMode; } + bool HasErrMsg() const { return bShowError; } sal_Int16 GetListType() const { return mnListType; } void SetListType( sal_Int16 nListType ) { mnListType = nListType; } diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx index 6c1c99ecff7d..ab1d451c58bc 100644 --- a/sc/source/core/data/validat.cxx +++ b/sc/source/core/data/validat.cxx @@ -382,7 +382,7 @@ void ScValidationData::DoError(weld::Window* pParent, const OUString& rInput, co return; } - if (!bShowError) { + if (eErrorStyle == SC_VALERR_NONE) { callback(true); return; } diff --git a/sc/source/filter/xml/XMLStylesExportHelper.cxx b/sc/source/filter/xml/XMLStylesExportHelper.cxx index 4daac20f73df..12fafe861c7a 100644 --- a/sc/source/filter/xml/XMLStylesExportHelper.cxx +++ b/sc/source/filter/xml/XMLStylesExportHelper.cxx @@ -402,6 +402,12 @@ void ScMyValidationsContainer::WriteValidations(const ScDocument& rDoc, ScXMLExp } } break; + case sheet::ValidationAlertStyle_NONE : + { + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MESSAGE_TYPE, XML_REJECT); + WriteMessage(rExport, "", "", rValidation.bShowErrorMessage, false); + } + break; default: { // added to avoid warnings diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index de7a16928f62..5f68c14a2e39 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -760,6 +760,7 @@ ScValidErrorStyle validAlertToValidError( const sheet::ValidationAlertStyle eVAl case sheet::ValidationAlertStyle_STOP: eVErrStyle = SC_VALERR_STOP; break; case sheet::ValidationAlertStyle_WARNING: eVErrStyle = SC_VALERR_WARNING; break; case sheet::ValidationAlertStyle_MACRO: eVErrStyle = SC_VALERR_MACRO; break; + case sheet::ValidationAlertStyle_NONE: eVErrStyle = SC_VALERR_NONE; break; default: eVErrStyle = SC_VALERR_INFO; break; //should INFO be the default? seems to be the most unobtrusive choice. } diff --git a/sc/source/filter/xml/xmlcvali.cxx b/sc/source/filter/xml/xmlcvali.cxx index ec7a1ea70b3d..3a364b4babca 100644 --- a/sc/source/filter/xml/xmlcvali.cxx +++ b/sc/source/filter/xml/xmlcvali.cxx @@ -247,6 +247,8 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLContentValidationC sheet::ValidationAlertStyle ScXMLContentValidationContext::GetAlertStyle() const { + if (IsXMLToken(sErrorMessageType, XML_REJECT)) + return sheet::ValidationAlertStyle_NONE; if (IsXMLToken(sErrorMessageType, XML_MACRO)) return sheet::ValidationAlertStyle_MACRO; if (IsXMLToken(sErrorMessageType, XML_STOP)) diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index cf7b8d0c8d78..a9c3bb76f500 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -3190,7 +3190,7 @@ void ScInputHandler::EnterHandler( ScEnterMode nBlockMode, bool bBeforeSavingInL { ScDocument& rDoc = pActiveViewSh->GetViewData().GetDocument(); const ScValidationData* pData = rDoc.GetValidationEntry( nValidation ); - if (pData) + if (pData && pData->HasErrMsg()) { // #i67990# don't use pLastPattern in EnterHandler const ScPatternAttr* pPattern = rDoc.GetPattern( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab() ); diff --git a/sc/source/ui/dbgui/validate.cxx b/sc/source/ui/dbgui/validate.cxx index 6632b1be1e39..515a595354a2 100644 --- a/sc/source/ui/dbgui/validate.cxx +++ b/sc/source/ui/dbgui/validate.cxx @@ -846,23 +846,24 @@ bool ScTPValidationError::FillItemSet( SfxItemSet* rArgSet ) IMPL_LINK_NOARG(ScTPValidationError, ToggleErrorMessage, weld::Toggleable&, void) { - bool const bEnable(m_xTsbShow->get_active()); - m_xLbAction->set_sensitive(bEnable); - m_xEdtTitle->set_sensitive(bEnable); - m_xEdError->set_sensitive(bEnable); - m_xFtError->set_sensitive(bEnable); - m_xFtTitle->set_sensitive(bEnable); - m_xFtAction->set_sensitive(bEnable); + SelectActionHdl(*m_xLbAction); } IMPL_LINK_NOARG(ScTPValidationError, SelectActionHdl, weld::ComboBox&, void) { + bool const bEnable(m_xTsbShow->get_active()); + ScValidErrorStyle eStyle = static_cast<ScValidErrorStyle>(m_xLbAction->get_active()); bool bMacro = ( eStyle == SC_VALERR_MACRO ); + bool bNone = ( eStyle == SC_VALERR_NONE ); - m_xBtnSearch->set_sensitive( bMacro ); - m_xFtError->set_sensitive( !bMacro ); - m_xEdError->set_sensitive( !bMacro ); + m_xFtTitle->set_sensitive( bEnable && !bNone ); + m_xLbAction->set_sensitive(bEnable); + m_xFtAction->set_sensitive(bEnable); + m_xEdtTitle->set_sensitive( bEnable && !bNone ); + m_xBtnSearch->set_sensitive( bEnable && bMacro); + m_xFtError->set_sensitive( bEnable && !bMacro && !bNone ); + m_xEdError->set_sensitive( bEnable && !bMacro && !bNone ); } IMPL_LINK_NOARG(ScTPValidationError, ClickSearchHdl, weld::Button&, void) diff --git a/sc/source/ui/unoobj/fmtuno.cxx b/sc/source/ui/unoobj/fmtuno.cxx index 44b2ad31efd9..e093f73d77df 100644 --- a/sc/source/ui/unoobj/fmtuno.cxx +++ b/sc/source/ui/unoobj/fmtuno.cxx @@ -820,6 +820,7 @@ void SAL_CALL ScTableValidationObj::setPropertyValue( case sheet::ValidationAlertStyle_WARNING: nErrorStyle = SC_VALERR_WARNING; break; case sheet::ValidationAlertStyle_INFO: nErrorStyle = SC_VALERR_INFO; break; case sheet::ValidationAlertStyle_MACRO: nErrorStyle = SC_VALERR_MACRO; break; + case sheet::ValidationAlertStyle_NONE: nErrorStyle = SC_VALERR_NONE; break; default: { // added to avoid warnings @@ -907,6 +908,7 @@ uno::Any SAL_CALL ScTableValidationObj::getPropertyValue( const OUString& aPrope case SC_VALERR_WARNING: eStyle = sheet::ValidationAlertStyle_WARNING; break; case SC_VALERR_INFO: eStyle = sheet::ValidationAlertStyle_INFO; break; case SC_VALERR_MACRO: eStyle = sheet::ValidationAlertStyle_MACRO; break; + case SC_VALERR_NONE: eStyle = sheet::ValidationAlertStyle_NONE; break; } aRet <<= eStyle; } diff --git a/sc/uiconfig/scalc/ui/erroralerttabpage.ui b/sc/uiconfig/scalc/ui/erroralerttabpage.ui index 586181da461a..8915b71da84d 100644 --- a/sc/uiconfig/scalc/ui/erroralerttabpage.ui +++ b/sc/uiconfig/scalc/ui/erroralerttabpage.ui @@ -12,7 +12,7 @@ <property name="spacing">12</property> <child> <object class="GtkCheckButton" id="tsbshow"> - <property name="label" translatable="yes" context="erroralerttabpage|tsbshow">Show error _message when invalid values are entered</property> + <property name="label" translatable="yes" context="erroralerttabpage|tsbshow">Handle invalid values</property> <property name="visible">True</property> <property name="can-focus">True</property> <property name="receives-default">False</property> @@ -153,6 +153,7 @@ <item translatable="yes" context="erroralerttabpage|actionCB">Warning</item> <item translatable="yes" context="erroralerttabpage|actionCB">Information</item> <item translatable="yes" context="erroralerttabpage|actionCB">Macro</item> + <item translatable="yes" context="erroralerttabpage|actionCB">Reject silently</item> </items> <child internal-child="accessible"> <object class="AtkObject" id="actionCB-atkobject"> diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index f8cfdddf335a..4da955e16d30 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -2328,6 +2328,7 @@ namespace xmloff::token { TOKEN( "byte", XML_BYTE ), TOKEN( "macro", XML_MACRO ), + TOKEN( "reject", XML_REJECT ), TOKEN( "location", XML_LOCATION ), TOKEN( "application", XML_APPLICATION ), diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt index 28317a175325..f8e41ff95794 100644 --- a/xmloff/source/token/tokens.txt +++ b/xmloff/source/token/tokens.txt @@ -2219,6 +2219,7 @@ horizontal-checkerboard notify-on-update-of-ranges byte macro +reject location application symbol-image
