diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2018-02-01 12:28:54 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2018-05-31 19:08:23 +0200 |
commit | f15c4b0f3c2cdfa7a72c97301ff32cc1764c54da (patch) | |
tree | c617d896afc9b12095df05786e69e623793db574 /sc/inc/validat.hxx | |
parent | ff7e2868d61f2958ec86fbd53bb3e2957ca3da39 (diff) |
tdf#96698 - calc: add support for custom validation (through a formula)
Now it is possible to select a `custom` validation in the validation
dialog: this type of validation let's the user to define a formula,
the cell content is valid when the formula is evaluted to true, and
not valid when evaluated to false.
The `cutom` validation is correctly saved and restored for ods
documents, and is correctly imported and exported to xlsx documents
This patch contains an adaptation of a preliminary work of Justin Luth
for importing custom validation from xlsx documents. Thanks Justin!
Change-Id: Idc26654ba69a6f73d1b208d63acdad4b880c776d
Reviewed-on: https://gerrit.libreoffice.org/49084
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/inc/validat.hxx')
-rw-r--r-- | sc/inc/validat.hxx | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sc/inc/validat.hxx b/sc/inc/validat.hxx index bc13663a7e6d..92e87901fc9d 100644 --- a/sc/inc/validat.hxx +++ b/sc/inc/validat.hxx @@ -132,6 +132,26 @@ public: bool IsDataValid( const OUString& rTest, const ScPatternAttr& rPattern, const ScAddress& rPos ) const; + // Custom validations (SC_VALID_CUSTOM) should be validated using this specific method. + // Take care that internally this method commits to the to be validated cell the new input, + // in order to be able to interpret the validating boolean formula on the new input. + // After the formula has been evaluated the original cell content is restored. + // At present is only used in ScInputHandler::EnterHandler: handling this case in the + // regular IsDataValid method would have been unsafe since it can be invoked + // by ScFormulaCell::InterpretTail. + + struct CustomValidationPrivateAccess + { + // so IsDataValidCustom can be invoked only by ScInputHandler methods + friend class ScInputHandler; + private: + CustomValidationPrivateAccess() {} + }; + + bool IsDataValidCustom( + const OUString& rTest, const ScPatternAttr& rPattern, + const ScAddress& rPos, const CustomValidationPrivateAccess& ) const; + bool IsDataValid( ScRefCellValue& rCell, const ScAddress& rPos ) const; // TRUE -> break |