23#include <document.hxx>
29#include <com/sun/star/sheet/TableValidationVisibility.hpp>
41 OUString sHelpMessage;
43 OUString sErrorMessage;
44 OUString sErrorMessageType;
45 OUString sBaseCellAddress;
54 css::sheet::ValidationAlertStyle GetAlertStyle()
const;
55 void SetFormula( OUString& rFormula, OUString& rFormulaNmsp, FormulaGrammar::Grammar& reGrammar,
56 const OUString& rCondition,
const OUString& rGlobNmsp, FormulaGrammar::Grammar eGlobGrammar,
bool bHasNmsp )
const;
61 ScXMLContentValidationContext(
ScXMLImport& rImport,
65 sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
override;
67 virtual void SAL_CALL
endFastElement( sal_Int32 nElement )
override;
69 void SetHelpMessage(
const OUString& sTitle,
const OUString& sMessage,
const bool bDisplay);
70 void SetErrorMessage(
const OUString& sTitle,
const OUString& sMessage,
const OUString& sMessageType,
const bool bDisplay);
71 void SetErrorMacro(
const bool bExecute);
78 sal_Int32 nParagraphCount;
81 ScXMLContentValidationContext* pValidationContext;
87 ScXMLContentValidationContext* pValidationContext);
91 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
override;
93 virtual void SAL_CALL
endFastElement( sal_Int32 nElement )
override;
100 OUString sMessageType;
101 sal_Int32 nParagraphCount;
104 ScXMLContentValidationContext* pValidationContext;
110 ScXMLContentValidationContext* pValidationContext);
114 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
override;
116 virtual void SAL_CALL
endFastElement( sal_Int32 nElement )
override;
122 ScXMLContentValidationContext* pValidationContext;
128 ScXMLContentValidationContext* pValidationContext);
132 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
override;
133 virtual void SAL_CALL
endFastElement( sal_Int32 nElement )
override;
149 sal_Int32 nElement,
const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
158 pContext =
new ScXMLContentValidationContext(
GetScImport(), pAttribList );
165ScXMLContentValidationContext::ScXMLContentValidationContext(
ScXMLImport& rImport,
168 nShowList(sheet::TableValidationVisibility::UNSORTED),
169 bAllowEmptyCell(true),
173 if ( !rAttrList.is() )
176 for (
auto &aIter : *rAttrList)
178 switch (aIter.getToken())
187 sBaseCellAddress = aIter.
toString();
191 bAllowEmptyCell = false;
196 nShowList = sheet::TableValidationVisibility::INVISIBLE;
200 nShowList = sheet::TableValidationVisibility::UNSORTED;
202 else if (
IsXMLToken(aIter, XML_SORT_ASCENDING))
204 nShowList = sheet::TableValidationVisibility::SORTEDASCENDING;
206 else if (
IsXMLToken(aIter, XML_SORTED_ASCENDING))
209 nShowList = sheet::TableValidationVisibility::SORTEDASCENDING;
216uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLContentValidationContext::createFastChildContext(
217 sal_Int32 nElement,
const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
226 pContext = new ScXMLHelpMessageContext( GetScImport(), pAttribList, this);
229 pContext = new ScXMLErrorMessageContext( GetScImport(), pAttribList, this);
232 pContext = new ScXMLErrorMacroContext( GetScImport(), pAttribList, this);
236 xEventContext = pContext;
242sheet::ValidationAlertStyle ScXMLContentValidationContext::GetAlertStyle()
const
245 return sheet::ValidationAlertStyle_MACRO;
247 return sheet::ValidationAlertStyle_STOP;
248 if (
IsXMLToken(sErrorMessageType, XML_WARNING))
249 return sheet::ValidationAlertStyle_WARNING;
250 if (
IsXMLToken(sErrorMessageType, XML_INFORMATION))
251 return sheet::ValidationAlertStyle_INFO;
253 return sheet::ValidationAlertStyle_STOP;
256void ScXMLContentValidationContext::SetFormula( OUString& rFormula, OUString& rFormulaNmsp, FormulaGrammar::Grammar& reGrammar,
257 const OUString& rCondition,
const OUString& rGlobNmsp, FormulaGrammar::Grammar eGlobGrammar,
bool bHasNmsp )
const
259 reGrammar = FormulaGrammar::GRAM_UNSPECIFIED;
263 rFormula = rCondition;
264 rFormulaNmsp = rGlobNmsp;
265 reGrammar = eGlobGrammar;
270 GetScImport().ExtractFormulaNamespaceGrammar( rFormula, rFormulaNmsp, reGrammar, rCondition,
true );
271 if( reGrammar != FormulaGrammar::GRAM_EXTERNAL )
272 reGrammar = eGlobGrammar;
279 rValidation.
aOperator = sheet::ConditionOperator_NONE;
281 if( sCondition.isEmpty() )
285 OUString aCondition, aConditionNmsp;
286 FormulaGrammar::Grammar eGrammar = FormulaGrammar::GRAM_UNSPECIFIED;
287 GetScImport().ExtractFormulaNamespaceGrammar( aCondition, aConditionNmsp, eGrammar, sCondition );
288 bool bHasNmsp = aCondition.getLength() < sCondition.getLength();
297 bool bSecondaryPart =
false;
314 bSecondaryPart =
true;
342 if( rValidation.
aOperator == sheet::ConditionOperator_NONE )
349 aParseResult.
maOperand1, aConditionNmsp, eGrammar, bHasNmsp );
351 aParseResult.
maOperand2, aConditionNmsp, eGrammar, bHasNmsp );
355void SAL_CALL ScXMLContentValidationContext::endFastElement( sal_Int32 )
358 if (xEventContext.is())
362 uno::Sequence<beans::PropertyValue> aValues;
365 auto pValue = std::find_if(std::cbegin(aValues), std::cend(aValues),
366 [](
const beans::PropertyValue& rValue) {
367 return rValue.Name ==
"MacroName" || rValue.Name ==
"Script"; });
368 if (pValue != std::cend(aValues))
369 pValue->Value >>= sErrorTitle;
373 aValidation.
eGrammar1 = aValidation.
eGrammar2 = GetScImport().GetDocument()->GetStorageGrammar();
380 GetCondition( aValidation );
386 GetScImport().AddValidation(aValidation);
389void ScXMLContentValidationContext::SetHelpMessage(
const OUString& sTitle,
const OUString& sMessage,
const bool bDisplay)
393 bDisplayHelp = bDisplay;
396void ScXMLContentValidationContext::SetErrorMessage(
const OUString& sTitle,
const OUString& sMessage,
397 const OUString& sMessageType,
const bool bDisplay)
399 sErrorTitle = sTitle;
401 sErrorMessageType = sMessageType;
402 bDisplayError = bDisplay;
405void ScXMLContentValidationContext::SetErrorMacro(
const bool bExecute)
407 sErrorMessageType =
"macro";
408 bDisplayError = bExecute;
411ScXMLHelpMessageContext::ScXMLHelpMessageContext(
ScXMLImport& rImport,
413 ScXMLContentValidationContext* pTempValidationContext) :
418 pValidationContext = pTempValidationContext;
419 if ( !rAttrList.is() )
422 for (
auto &aIter : *rAttrList)
424 switch (aIter.getToken())
436css::uno::Reference< css::xml::sax::XFastContextHandler > ScXMLHelpMessageContext::createFastChildContext(
438 const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
457void SAL_CALL ScXMLHelpMessageContext::endFastElement( sal_Int32 )
459 pValidationContext->SetHelpMessage(sTitle,
sMessage.makeStringAndClear(), bDisplay);
462ScXMLErrorMessageContext::ScXMLErrorMessageContext(
ScXMLImport& rImport,
464 ScXMLContentValidationContext* pTempValidationContext) :
469 pValidationContext = pTempValidationContext;
470 if ( !rAttrList.is() )
473 for (
auto &aIter : *rAttrList)
475 switch (aIter.getToken())
490css::uno::Reference< css::xml::sax::XFastContextHandler > ScXMLErrorMessageContext::createFastChildContext(
492 const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
511void SAL_CALL ScXMLErrorMessageContext::endFastElement( sal_Int32 )
513 pValidationContext->SetErrorMessage(sTitle,
sMessage.makeStringAndClear(), sMessageType, bDisplay);
516ScXMLErrorMacroContext::ScXMLErrorMacroContext(
ScXMLImport& rImport,
518 ScXMLContentValidationContext* pTempValidationContext) :
522 pValidationContext = pTempValidationContext;
523 if ( !rAttrList.is() )
526 for (
auto &aIter : *rAttrList)
528 switch (aIter.getToken())
539css::uno::Reference< css::xml::sax::XFastContextHandler > ScXMLErrorMacroContext::createFastChildContext(
540 sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
552void SAL_CALL ScXMLErrorMacroContext::endFastElement( sal_Int32 )
554 pValidationContext->SetErrorMacro( bExecute );
@ XML_COND_ISNOTBETWEEN
The 'cell-content-is-between' token.
@ XML_COND_ISTIME
The 'cell-content-is-date' token.
@ XML_COND_AND
Token not recognized.
@ XML_COND_CELLCONTENT
The 'and' token.
@ XML_COND_TEXTLENGTH
The 'cell-content-is-in-list' token.
@ XML_COND_TEXTLENGTH_ISBETWEEN
The 'cell-content-text-length' token.
@ XML_COND_ISTRUEFORMULA
The 'cell-content-text-length-is-not-between' token.
@ XML_COND_ISWHOLENUMBER
The 'cell-content-is-not-between' token.
@ XML_COND_ISINLIST
The 'cell-content-is-time' token.
@ XML_COND_ISBETWEEN
The 'cell-content' token.
@ XML_COND_ISDATE
The 'cell-content-is-decimal-number' token.
@ XML_COND_ISDECIMALNUMBER
The 'cell-content-is-whole-number' token.
@ XML_COND_TEXTLENGTH_ISNOTBETWEEN
The 'cell-content-text-length-is-between' token.
virtual ~ScXMLContentValidationsContext() override
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
ScXMLContentValidationsContext(ScXMLImport &rImport)
This class exists only to provide GetScImport() to its derived classes.
ScXMLImport & GetScImport()
virtual void SAL_CALL endFastElement(sal_Int32 Element) override
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
void GetEventSequence(const OUString &rName, css::uno::Sequence< css::beans::PropertyValue > &rSequence)
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
void parseCondition(ScXMLConditionParseResult &rParseResult, const OUString &rAttribute, sal_Int32 nStartIndex)
Parses the next condition in a 'condition' attribute value of e.g.
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
OUString toString(OptionInfo const *info)
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
formula::FormulaGrammar::Grammar eGrammar2
css::sheet::ValidationType aValidationType
css::sheet::ConditionOperator aOperator
css::sheet::ValidationAlertStyle aAlertStyle
OUString sBaseCellAddress
formula::FormulaGrammar::Grammar eGrammar1
Result of an attempt to parse a single condition in a 'condition' attribute value of e....
OUString maOperand2
First operand of the token or comparison value.
css::sheet::ValidationType meValidation
The leading condition token.
OUString maOperand1
A comparison operator if existing.
css::sheet::ConditionOperator meOperator
A data validation type if existing.
sal_Int32 mnEndIndex
Second operand of 'between' conditions.
ScXMLConditionToken meToken
#define XML_ELEMENT(prefix, name)