Moving legacy contexts to FastContexts:
ScXMLNullDateContext ScXMLIterationContext ScXMLContentValidationContext ScXMLHelpMessageContext ScXMLErrorMessageContext ScXMLErrorMacroContext Change-Id: Ic2a4f038891aefbb94b1d9ada96da7c139c6c9fe Reviewed-on: https://gerrit.libreoffice.org/40012 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
This commit is contained in:
committed by
Michael Meeks
parent
ce00985e24
commit
42c8000e68
@@ -96,22 +96,18 @@ ScXMLCalculationSettingsContext::~ScXMLCalculationSettingsContext()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SvXMLImportContext *ScXMLCalculationSettingsContext::CreateChildContext( sal_uInt16 nPrefix,
|
uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLCalculationSettingsContext::createFastChildContext(
|
||||||
const OUString& rLName,
|
sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
|
||||||
const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList )
|
|
||||||
{
|
{
|
||||||
SvXMLImportContext *pContext = nullptr;
|
SvXMLImportContext *pContext = nullptr;
|
||||||
|
|
||||||
if (nPrefix == XML_NAMESPACE_TABLE)
|
if (nElement == XML_ELEMENT( TABLE, XML_NULL_DATE ))
|
||||||
{
|
pContext = new ScXMLNullDateContext(GetScImport(), nElement, xAttrList, this);
|
||||||
if (IsXMLToken(rLName, XML_NULL_DATE))
|
else if (nElement == XML_ELEMENT( TABLE, XML_ITERATION ))
|
||||||
pContext = new ScXMLNullDateContext(GetScImport(), nPrefix, rLName, xAttrList, this);
|
pContext = new ScXMLIterationContext(GetScImport(), nElement, xAttrList, this);
|
||||||
else if (IsXMLToken(rLName, XML_ITERATION))
|
|
||||||
pContext = new ScXMLIterationContext(GetScImport(), nPrefix, rLName, xAttrList, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !pContext )
|
if( !pContext )
|
||||||
pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
|
pContext = new SvXMLImportContext( GetImport() );
|
||||||
|
|
||||||
return pContext;
|
return pContext;
|
||||||
}
|
}
|
||||||
@@ -147,25 +143,21 @@ void SAL_CALL ScXMLCalculationSettingsContext::endFastElement( sal_Int32 /*nElem
|
|||||||
}
|
}
|
||||||
|
|
||||||
ScXMLNullDateContext::ScXMLNullDateContext( ScXMLImport& rImport,
|
ScXMLNullDateContext::ScXMLNullDateContext( ScXMLImport& rImport,
|
||||||
sal_uInt16 nPrfx,
|
sal_Int32 /*nElement*/,
|
||||||
const OUString& rLName,
|
const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
|
||||||
const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList,
|
|
||||||
ScXMLCalculationSettingsContext* pCalcSet) :
|
ScXMLCalculationSettingsContext* pCalcSet) :
|
||||||
ScXMLImportContext( rImport, nPrfx, rLName )
|
ScXMLImportContext( rImport )
|
||||||
{
|
{
|
||||||
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
|
if ( xAttrList.is() )
|
||||||
for( sal_Int16 i=0; i < nAttrCount; ++i )
|
|
||||||
{
|
{
|
||||||
const OUString& sAttrName(xAttrList->getNameByIndex( i ));
|
sax_fastparser::FastAttributeList *pAttribList =
|
||||||
OUString aLocalName;
|
sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList );
|
||||||
sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
|
|
||||||
sAttrName, &aLocalName );
|
|
||||||
const OUString& sValue(xAttrList->getValueByIndex( i ));
|
|
||||||
|
|
||||||
if (nPrefix == XML_NAMESPACE_TABLE && IsXMLToken(aLocalName, XML_DATE_VALUE))
|
auto &aIter( pAttribList->find( XML_ELEMENT( TABLE, XML_DATE_VALUE ) ) );
|
||||||
|
if (aIter != pAttribList->end())
|
||||||
{
|
{
|
||||||
util::DateTime aDateTime;
|
util::DateTime aDateTime;
|
||||||
::sax::Converter::parseDateTime(aDateTime, nullptr, sValue);
|
::sax::Converter::parseDateTime(aDateTime, nullptr, aIter.toString());
|
||||||
util::Date aDate;
|
util::Date aDate;
|
||||||
aDate.Day = aDateTime.Day;
|
aDate.Day = aDateTime.Day;
|
||||||
aDate.Month = aDateTime.Month;
|
aDate.Month = aDateTime.Month;
|
||||||
@@ -179,53 +171,39 @@ ScXMLNullDateContext::~ScXMLNullDateContext()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SvXMLImportContext *ScXMLNullDateContext::CreateChildContext( sal_uInt16 nPrefix,
|
uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLNullDateContext::createFastChildContext(
|
||||||
const OUString& rLName,
|
sal_Int32 /*nElement*/, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ )
|
||||||
const css::uno::Reference< css::xml::sax::XAttributeList>& /* xAttrList */ )
|
|
||||||
{
|
|
||||||
SvXMLImportContext *pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
|
|
||||||
|
|
||||||
return pContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScXMLNullDateContext::EndElement()
|
|
||||||
{
|
{
|
||||||
|
return new SvXMLImportContext( GetImport() );
|
||||||
}
|
}
|
||||||
|
|
||||||
ScXMLIterationContext::ScXMLIterationContext( ScXMLImport& rImport,
|
ScXMLIterationContext::ScXMLIterationContext( ScXMLImport& rImport,
|
||||||
sal_uInt16 nPrfx,
|
sal_Int32 /*nElement*/,
|
||||||
const OUString& rLName,
|
const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
|
||||||
const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList,
|
|
||||||
ScXMLCalculationSettingsContext* pCalcSet) :
|
ScXMLCalculationSettingsContext* pCalcSet) :
|
||||||
ScXMLImportContext( rImport, nPrfx, rLName )
|
ScXMLImportContext( rImport )
|
||||||
{
|
{
|
||||||
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
|
if ( xAttrList.is() )
|
||||||
for( sal_Int16 i=0; i < nAttrCount; ++i )
|
|
||||||
{
|
{
|
||||||
const OUString& sAttrName(xAttrList->getNameByIndex( i ));
|
sax_fastparser::FastAttributeList *pAttribList =
|
||||||
OUString aLocalName;
|
sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList );
|
||||||
sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
|
|
||||||
sAttrName, &aLocalName );
|
|
||||||
const OUString& sValue(xAttrList->getValueByIndex( i ));
|
|
||||||
|
|
||||||
if (nPrefix == XML_NAMESPACE_TABLE)
|
for (auto &aIter : *pAttribList)
|
||||||
{
|
{
|
||||||
if (IsXMLToken(aLocalName, XML_STATUS))
|
switch (aIter.getToken())
|
||||||
{
|
{
|
||||||
if (IsXMLToken(sValue, XML_ENABLE))
|
case XML_ELEMENT( TABLE, XML_STATUS ):
|
||||||
|
if (IsXMLToken(aIter, XML_ENABLE))
|
||||||
pCalcSet->SetIterationStatus(true);
|
pCalcSet->SetIterationStatus(true);
|
||||||
}
|
break;
|
||||||
else if (IsXMLToken(aLocalName, XML_STEPS))
|
case XML_ELEMENT( TABLE, XML_STEPS ):
|
||||||
{
|
pCalcSet->SetIterationCount(aIter.toInt32());
|
||||||
sal_Int32 nSteps;
|
break;
|
||||||
::sax::Converter::convertNumber(nSteps, sValue);
|
case XML_ELEMENT( TABLE, XML_MAXIMUM_DIFFERENCE ):
|
||||||
pCalcSet->SetIterationCount(nSteps);
|
|
||||||
}
|
|
||||||
else if (IsXMLToken(aLocalName, XML_MAXIMUM_DIFFERENCE))
|
|
||||||
{
|
|
||||||
double fDif;
|
double fDif;
|
||||||
::sax::Converter::convertDouble(fDif, sValue);
|
::sax::Converter::convertDouble(fDif, aIter.toString());
|
||||||
pCalcSet->SetIterationEpsilon(fDif);
|
pCalcSet->SetIterationEpsilon(fDif);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -235,17 +213,10 @@ ScXMLIterationContext::~ScXMLIterationContext()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SvXMLImportContext *ScXMLIterationContext::CreateChildContext( sal_uInt16 nPrefix,
|
uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLIterationContext::createFastChildContext(
|
||||||
const OUString& rLName,
|
sal_Int32 /*nElement*/, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ )
|
||||||
const css::uno::Reference< css::xml::sax::XAttributeList>& /* xAttrList */ )
|
|
||||||
{
|
|
||||||
SvXMLImportContext *pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
|
|
||||||
|
|
||||||
return pContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScXMLIterationContext::EndElement()
|
|
||||||
{
|
{
|
||||||
|
return new SvXMLImportContext( GetImport() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -46,9 +46,8 @@ public:
|
|||||||
|
|
||||||
virtual ~ScXMLCalculationSettingsContext() override;
|
virtual ~ScXMLCalculationSettingsContext() override;
|
||||||
|
|
||||||
virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
|
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
|
||||||
const OUString& rLocalName,
|
sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
|
||||||
const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) override;
|
|
||||||
|
|
||||||
void SetNullDate(const css::util::Date& aDate) { aNullDate = aDate; }
|
void SetNullDate(const css::util::Date& aDate) { aNullDate = aDate; }
|
||||||
void SetIterationStatus(const bool bValue) { bIsIterationEnabled = bValue; }
|
void SetIterationStatus(const bool bValue) { bIsIterationEnabled = bValue; }
|
||||||
@@ -60,33 +59,25 @@ public:
|
|||||||
class ScXMLNullDateContext : public ScXMLImportContext
|
class ScXMLNullDateContext : public ScXMLImportContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScXMLNullDateContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
|
ScXMLNullDateContext( ScXMLImport& rImport, sal_Int32 nElement,
|
||||||
const OUString& rLName,
|
const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, ScXMLCalculationSettingsContext* pCalcSet);
|
||||||
const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, ScXMLCalculationSettingsContext* pCalcSet);
|
|
||||||
|
|
||||||
virtual ~ScXMLNullDateContext() override;
|
virtual ~ScXMLNullDateContext() override;
|
||||||
|
|
||||||
virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
|
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
|
||||||
const OUString& rLocalName,
|
sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
|
||||||
const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) override;
|
|
||||||
|
|
||||||
virtual void EndElement() override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ScXMLIterationContext : public ScXMLImportContext
|
class ScXMLIterationContext : public ScXMLImportContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScXMLIterationContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
|
ScXMLIterationContext( ScXMLImport& rImport, sal_Int32 nElement,
|
||||||
const OUString& rLName,
|
const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, ScXMLCalculationSettingsContext* pCalcSet);
|
||||||
const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, ScXMLCalculationSettingsContext* pCalcSet);
|
|
||||||
|
|
||||||
virtual ~ScXMLIterationContext() override;
|
virtual ~ScXMLIterationContext() override;
|
||||||
|
|
||||||
virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
|
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
|
||||||
const OUString& rLocalName,
|
sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
|
||||||
const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) override;
|
|
||||||
|
|
||||||
virtual void EndElement() override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -58,15 +58,17 @@ class ScXMLContentValidationContext : public ScXMLImportContext
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ScXMLContentValidationContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
|
ScXMLContentValidationContext( ScXMLImport& rImport, sal_Int32 nElement,
|
||||||
const OUString& rLName,
|
const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList);
|
||||||
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList);
|
|
||||||
|
|
||||||
virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
|
virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
|
||||||
const OUString& rLocalName,
|
const OUString& rLocalName,
|
||||||
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
|
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
|
||||||
|
|
||||||
virtual void EndElement() 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;
|
||||||
|
|
||||||
|
virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
|
||||||
|
|
||||||
void SetHelpMessage(const OUString& sTitle, const OUString& sMessage, const bool bDisplay);
|
void SetHelpMessage(const OUString& sTitle, const OUString& sMessage, const bool bDisplay);
|
||||||
void SetErrorMessage(const OUString& sTitle, const OUString& sMessage, const OUString& sMessageType, const bool bDisplay);
|
void SetErrorMessage(const OUString& sTitle, const OUString& sMessage, const OUString& sMessageType, const bool bDisplay);
|
||||||
@@ -84,16 +86,15 @@ class ScXMLHelpMessageContext : public ScXMLImportContext
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ScXMLHelpMessageContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
|
ScXMLHelpMessageContext( ScXMLImport& rImport, sal_Int32 nElement,
|
||||||
const OUString& rLName,
|
const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList,
|
||||||
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList,
|
|
||||||
ScXMLContentValidationContext* pValidationContext);
|
ScXMLContentValidationContext* pValidationContext);
|
||||||
|
|
||||||
virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
|
virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
|
||||||
const OUString& rLocalName,
|
const OUString& rLocalName,
|
||||||
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
|
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
|
||||||
|
|
||||||
virtual void EndElement() override;
|
virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ScXMLErrorMessageContext : public ScXMLImportContext
|
class ScXMLErrorMessageContext : public ScXMLImportContext
|
||||||
@@ -108,16 +109,15 @@ class ScXMLErrorMessageContext : public ScXMLImportContext
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ScXMLErrorMessageContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
|
ScXMLErrorMessageContext( ScXMLImport& rImport, sal_Int32 nElement,
|
||||||
const OUString& rLName,
|
const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList,
|
||||||
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList,
|
|
||||||
ScXMLContentValidationContext* pValidationContext);
|
ScXMLContentValidationContext* pValidationContext);
|
||||||
|
|
||||||
virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
|
virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
|
||||||
const OUString& rLocalName,
|
const OUString& rLocalName,
|
||||||
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
|
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
|
||||||
|
|
||||||
virtual void EndElement() override;
|
virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ScXMLErrorMacroContext : public ScXMLImportContext
|
class ScXMLErrorMacroContext : public ScXMLImportContext
|
||||||
@@ -128,15 +128,14 @@ class ScXMLErrorMacroContext : public ScXMLImportContext
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ScXMLErrorMacroContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
|
ScXMLErrorMacroContext( ScXMLImport& rImport, sal_Int32 nElement,
|
||||||
const OUString& rLName,
|
const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList,
|
||||||
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList,
|
|
||||||
ScXMLContentValidationContext* pValidationContext);
|
ScXMLContentValidationContext* pValidationContext);
|
||||||
|
|
||||||
virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
|
virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
|
||||||
const OUString& rLocalName,
|
const OUString& rLocalName,
|
||||||
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
|
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
|
||||||
virtual void EndElement() override;
|
virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
ScXMLContentValidationsContext::ScXMLContentValidationsContext( ScXMLImport& rImport,
|
ScXMLContentValidationsContext::ScXMLContentValidationsContext( ScXMLImport& rImport,
|
||||||
@@ -151,17 +150,91 @@ ScXMLContentValidationsContext::~ScXMLContentValidationsContext()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SvXMLImportContext *ScXMLContentValidationsContext::CreateChildContext( sal_uInt16 nPrefix,
|
uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLContentValidationsContext::createFastChildContext(
|
||||||
const OUString& rLName,
|
sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
|
||||||
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList )
|
|
||||||
{
|
{
|
||||||
SvXMLImportContext *pContext = nullptr;
|
SvXMLImportContext *pContext = nullptr;
|
||||||
|
|
||||||
const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationsElemTokenMap();
|
switch (nElement)
|
||||||
|
{
|
||||||
|
case XML_ELEMENT( TABLE, XML_CONTENT_VALIDATION ):
|
||||||
|
pContext = new ScXMLContentValidationContext( GetScImport(), nElement, xAttrList);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !pContext )
|
||||||
|
pContext = new SvXMLImportContext( GetImport() );
|
||||||
|
|
||||||
|
return pContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScXMLContentValidationContext::ScXMLContentValidationContext( ScXMLImport& rImport,
|
||||||
|
sal_Int32 /*nElement*/,
|
||||||
|
const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) :
|
||||||
|
ScXMLImportContext( rImport ),
|
||||||
|
nShowList(sheet::TableValidationVisibility::UNSORTED),
|
||||||
|
bAllowEmptyCell(true),
|
||||||
|
bDisplayHelp(false),
|
||||||
|
bDisplayError(false)
|
||||||
|
{
|
||||||
|
if ( xAttrList.is() )
|
||||||
|
{
|
||||||
|
sax_fastparser::FastAttributeList *pAttribList =
|
||||||
|
sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList );
|
||||||
|
|
||||||
|
for (auto &aIter : *pAttribList)
|
||||||
|
{
|
||||||
|
switch (aIter.getToken())
|
||||||
|
{
|
||||||
|
case XML_ELEMENT( TABLE, XML_NAME ):
|
||||||
|
sName = aIter.toString();
|
||||||
|
break;
|
||||||
|
case XML_ELEMENT( TABLE, XML_CONDITION ):
|
||||||
|
sCondition = aIter.toString();
|
||||||
|
break;
|
||||||
|
case XML_ELEMENT( TABLE, XML_BASE_CELL_ADDRESS ):
|
||||||
|
sBaseCellAddress = aIter.toString();
|
||||||
|
break;
|
||||||
|
case XML_ELEMENT( TABLE, XML_ALLOW_EMPTY_CELL ):
|
||||||
|
if (IsXMLToken(aIter, XML_FALSE))
|
||||||
|
bAllowEmptyCell = false;
|
||||||
|
break;
|
||||||
|
case XML_ELEMENT( TABLE, XML_DISPLAY_LIST ):
|
||||||
|
if (IsXMLToken(aIter, XML_NO))
|
||||||
|
{
|
||||||
|
nShowList = sheet::TableValidationVisibility::INVISIBLE;
|
||||||
|
}
|
||||||
|
else if (IsXMLToken(aIter, XML_UNSORTED))
|
||||||
|
{
|
||||||
|
nShowList = sheet::TableValidationVisibility::UNSORTED;
|
||||||
|
}
|
||||||
|
else if (IsXMLToken(aIter, XML_SORT_ASCENDING))
|
||||||
|
{
|
||||||
|
nShowList = sheet::TableValidationVisibility::SORTEDASCENDING;
|
||||||
|
}
|
||||||
|
else if (IsXMLToken(aIter, XML_SORTED_ASCENDING))
|
||||||
|
{
|
||||||
|
// Read old wrong value, fdo#72548
|
||||||
|
nShowList = sheet::TableValidationVisibility::SORTEDASCENDING;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SvXMLImportContext *ScXMLContentValidationContext::CreateChildContext( sal_uInt16 nPrefix,
|
||||||
|
const OUString& rLName,
|
||||||
|
const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttrList*/ )
|
||||||
|
{
|
||||||
|
SvXMLImportContext *pContext = nullptr;
|
||||||
|
|
||||||
|
const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationElemTokenMap();
|
||||||
switch( rTokenMap.Get( nPrefix, rLName ) )
|
switch( rTokenMap.Get( nPrefix, rLName ) )
|
||||||
{
|
{
|
||||||
case XML_TOK_CONTENT_VALIDATION:
|
case XML_TOK_CONTENT_VALIDATION_ELEM_EVENT_LISTENERS:
|
||||||
pContext = new ScXMLContentValidationContext( GetScImport(), nPrefix, rLName, xAttrList);
|
pContext = new XMLEventsImportContext( GetImport(), nPrefix, rLName );
|
||||||
|
xEventContext = pContext;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,92 +244,26 @@ SvXMLImportContext *ScXMLContentValidationsContext::CreateChildContext( sal_uInt
|
|||||||
return pContext;
|
return pContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScXMLContentValidationContext::ScXMLContentValidationContext( ScXMLImport& rImport,
|
uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLContentValidationContext::createFastChildContext(
|
||||||
sal_uInt16 nPrfx,
|
sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
|
||||||
const OUString& rLName,
|
|
||||||
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList) :
|
|
||||||
ScXMLImportContext( rImport, nPrfx, rLName ),
|
|
||||||
nShowList(sheet::TableValidationVisibility::UNSORTED),
|
|
||||||
bAllowEmptyCell(true),
|
|
||||||
bDisplayHelp(false),
|
|
||||||
bDisplayError(false)
|
|
||||||
{
|
|
||||||
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
|
|
||||||
const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationAttrTokenMap();
|
|
||||||
for( sal_Int16 i=0; i < nAttrCount; ++i )
|
|
||||||
{
|
|
||||||
const OUString& sAttrName(xAttrList->getNameByIndex( i ));
|
|
||||||
OUString aLocalName;
|
|
||||||
sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
|
|
||||||
sAttrName, &aLocalName );
|
|
||||||
const OUString& sValue(xAttrList->getValueByIndex( i ));
|
|
||||||
|
|
||||||
switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
|
|
||||||
{
|
|
||||||
case XML_TOK_CONTENT_VALIDATION_NAME:
|
|
||||||
sName = sValue;
|
|
||||||
break;
|
|
||||||
case XML_TOK_CONTENT_VALIDATION_CONDITION:
|
|
||||||
sCondition = sValue;
|
|
||||||
break;
|
|
||||||
case XML_TOK_CONTENT_VALIDATION_BASE_CELL_ADDRESS:
|
|
||||||
sBaseCellAddress = sValue;
|
|
||||||
break;
|
|
||||||
case XML_TOK_CONTENT_VALIDATION_ALLOW_EMPTY_CELL:
|
|
||||||
if (IsXMLToken(sValue, XML_FALSE))
|
|
||||||
bAllowEmptyCell = false;
|
|
||||||
break;
|
|
||||||
case XML_TOK_CONTENT_VALIDATION_DISPLAY_LIST:
|
|
||||||
{
|
|
||||||
if (IsXMLToken(sValue, XML_NO))
|
|
||||||
{
|
|
||||||
nShowList = sheet::TableValidationVisibility::INVISIBLE;
|
|
||||||
}
|
|
||||||
else if (IsXMLToken(sValue, XML_UNSORTED))
|
|
||||||
{
|
|
||||||
nShowList = sheet::TableValidationVisibility::UNSORTED;
|
|
||||||
}
|
|
||||||
else if (IsXMLToken(sValue, XML_SORT_ASCENDING))
|
|
||||||
{
|
|
||||||
nShowList = sheet::TableValidationVisibility::SORTEDASCENDING;
|
|
||||||
}
|
|
||||||
else if (IsXMLToken(sValue, XML_SORTED_ASCENDING))
|
|
||||||
{
|
|
||||||
// Read old wrong value, fdo#72548
|
|
||||||
nShowList = sheet::TableValidationVisibility::SORTEDASCENDING;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SvXMLImportContext *ScXMLContentValidationContext::CreateChildContext( sal_uInt16 nPrefix,
|
|
||||||
const OUString& rLName,
|
|
||||||
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList )
|
|
||||||
{
|
{
|
||||||
SvXMLImportContext *pContext = nullptr;
|
SvXMLImportContext *pContext = nullptr;
|
||||||
|
|
||||||
const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationElemTokenMap();
|
switch (nElement)
|
||||||
switch( rTokenMap.Get( nPrefix, rLName ) )
|
|
||||||
{
|
{
|
||||||
case XML_TOK_CONTENT_VALIDATION_ELEM_HELP_MESSAGE:
|
case XML_ELEMENT( TABLE, XML_HELP_MESSAGE ):
|
||||||
pContext = new ScXMLHelpMessageContext( GetScImport(), nPrefix, rLName, xAttrList, this);
|
pContext = new ScXMLHelpMessageContext( GetScImport(), nElement, xAttrList, this);
|
||||||
break;
|
break;
|
||||||
case XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MESSAGE:
|
case XML_ELEMENT( TABLE, XML_ERROR_MESSAGE ):
|
||||||
pContext = new ScXMLErrorMessageContext( GetScImport(), nPrefix, rLName, xAttrList, this);
|
pContext = new ScXMLErrorMessageContext( GetScImport(), nElement, xAttrList, this);
|
||||||
break;
|
break;
|
||||||
case XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MACRO:
|
case XML_ELEMENT( TABLE, XML_ERROR_MACRO ):
|
||||||
pContext = new ScXMLErrorMacroContext( GetScImport(), nPrefix, rLName, xAttrList, this);
|
pContext = new ScXMLErrorMacroContext( GetScImport(), nElement, xAttrList, this);
|
||||||
break;
|
|
||||||
case XML_TOK_CONTENT_VALIDATION_ELEM_EVENT_LISTENERS:
|
|
||||||
pContext = new XMLEventsImportContext( GetImport(), nPrefix, rLName );
|
|
||||||
xEventContext = pContext;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !pContext )
|
if( !pContext )
|
||||||
pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
|
pContext = new SvXMLImportContext( GetImport() );
|
||||||
|
|
||||||
return pContext;
|
return pContext;
|
||||||
}
|
}
|
||||||
@@ -373,7 +380,7 @@ void ScXMLContentValidationContext::GetCondition( ScMyImportValidation& rValidat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScXMLContentValidationContext::EndElement()
|
void SAL_CALL ScXMLContentValidationContext::endFastElement( sal_Int32 /*nElement*/ )
|
||||||
{
|
{
|
||||||
// #i36650# event-listeners element moved up one level
|
// #i36650# event-listeners element moved up one level
|
||||||
if (xEventContext.is())
|
if (xEventContext.is())
|
||||||
@@ -436,38 +443,35 @@ void ScXMLContentValidationContext::SetErrorMacro(const bool bExecute)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ScXMLHelpMessageContext::ScXMLHelpMessageContext( ScXMLImport& rImport,
|
ScXMLHelpMessageContext::ScXMLHelpMessageContext( ScXMLImport& rImport,
|
||||||
sal_uInt16 nPrfx,
|
sal_Int32 /*nElement*/,
|
||||||
const OUString& rLName,
|
const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList,
|
||||||
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList,
|
|
||||||
ScXMLContentValidationContext* pTempValidationContext) :
|
ScXMLContentValidationContext* pTempValidationContext) :
|
||||||
ScXMLImportContext( rImport, nPrfx, rLName ),
|
ScXMLImportContext( rImport ),
|
||||||
sTitle(),
|
sTitle(),
|
||||||
sMessage(),
|
sMessage(),
|
||||||
nParagraphCount(0),
|
nParagraphCount(0),
|
||||||
bDisplay(false)
|
bDisplay(false)
|
||||||
{
|
{
|
||||||
pValidationContext = pTempValidationContext;
|
pValidationContext = pTempValidationContext;
|
||||||
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
|
if ( xAttrList.is() )
|
||||||
const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationHelpMessageAttrTokenMap();
|
|
||||||
for( sal_Int16 i=0; i < nAttrCount; ++i )
|
|
||||||
{
|
{
|
||||||
const OUString& sAttrName(xAttrList->getNameByIndex( i ));
|
sax_fastparser::FastAttributeList *pAttribList =
|
||||||
OUString aLocalName;
|
sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList );
|
||||||
sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
|
|
||||||
sAttrName, &aLocalName );
|
|
||||||
const OUString& sValue(xAttrList->getValueByIndex( i ));
|
|
||||||
|
|
||||||
switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
|
for (auto &aIter : *pAttribList)
|
||||||
{
|
{
|
||||||
case XML_TOK_HELP_MESSAGE_ATTR_TITLE:
|
switch (aIter.getToken())
|
||||||
sTitle = sValue;
|
{
|
||||||
|
case XML_ELEMENT( TABLE, XML_TITLE ):
|
||||||
|
sTitle = aIter.toString();
|
||||||
break;
|
break;
|
||||||
case XML_TOK_HELP_MESSAGE_ATTR_DISPLAY:
|
case XML_ELEMENT( TABLE, XML_DISPLAY ):
|
||||||
bDisplay = IsXMLToken(sValue, XML_TRUE);
|
bDisplay = IsXMLToken(aIter, XML_TRUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SvXMLImportContext *ScXMLHelpMessageContext::CreateChildContext( sal_uInt16 nPrefix,
|
SvXMLImportContext *ScXMLHelpMessageContext::CreateChildContext( sal_uInt16 nPrefix,
|
||||||
const OUString& rLName,
|
const OUString& rLName,
|
||||||
@@ -494,17 +498,16 @@ SvXMLImportContext *ScXMLHelpMessageContext::CreateChildContext( sal_uInt16 nPre
|
|||||||
return pContext;
|
return pContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScXMLHelpMessageContext::EndElement()
|
void SAL_CALL ScXMLHelpMessageContext::endFastElement( sal_Int32 /*nElement*/ )
|
||||||
{
|
{
|
||||||
pValidationContext->SetHelpMessage(sTitle, sMessage.makeStringAndClear(), bDisplay);
|
pValidationContext->SetHelpMessage(sTitle, sMessage.makeStringAndClear(), bDisplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScXMLErrorMessageContext::ScXMLErrorMessageContext( ScXMLImport& rImport,
|
ScXMLErrorMessageContext::ScXMLErrorMessageContext( ScXMLImport& rImport,
|
||||||
sal_uInt16 nPrfx,
|
sal_Int32 /*nElement*/,
|
||||||
const OUString& rLName,
|
const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList,
|
||||||
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList,
|
|
||||||
ScXMLContentValidationContext* pTempValidationContext) :
|
ScXMLContentValidationContext* pTempValidationContext) :
|
||||||
ScXMLImportContext( rImport, nPrfx, rLName ),
|
ScXMLImportContext( rImport ),
|
||||||
sTitle(),
|
sTitle(),
|
||||||
sMessage(),
|
sMessage(),
|
||||||
sMessageType(),
|
sMessageType(),
|
||||||
@@ -512,30 +515,28 @@ ScXMLErrorMessageContext::ScXMLErrorMessageContext( ScXMLImport& rImport,
|
|||||||
bDisplay(false)
|
bDisplay(false)
|
||||||
{
|
{
|
||||||
pValidationContext = pTempValidationContext;
|
pValidationContext = pTempValidationContext;
|
||||||
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
|
if ( xAttrList.is() )
|
||||||
const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationErrorMessageAttrTokenMap();
|
|
||||||
for( sal_Int16 i=0; i < nAttrCount; ++i )
|
|
||||||
{
|
{
|
||||||
const OUString& sAttrName(xAttrList->getNameByIndex( i ));
|
sax_fastparser::FastAttributeList *pAttribList =
|
||||||
OUString aLocalName;
|
sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList );
|
||||||
sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
|
|
||||||
sAttrName, &aLocalName );
|
|
||||||
const OUString& sValue(xAttrList->getValueByIndex( i ));
|
|
||||||
|
|
||||||
switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
|
for (auto &aIter : *pAttribList)
|
||||||
{
|
{
|
||||||
case XML_TOK_ERROR_MESSAGE_ATTR_TITLE:
|
switch (aIter.getToken())
|
||||||
sTitle = sValue;
|
{
|
||||||
|
case XML_ELEMENT( TABLE, XML_TITLE ):
|
||||||
|
sTitle = aIter.toString();
|
||||||
break;
|
break;
|
||||||
case XML_TOK_ERROR_MESSAGE_ATTR_MESSAGE_TYPE:
|
case XML_ELEMENT( TABLE, XML_MESSAGE_TYPE ):
|
||||||
sMessageType = sValue;
|
sMessageType = aIter.toString();
|
||||||
break;
|
break;
|
||||||
case XML_TOK_ERROR_MESSAGE_ATTR_DISPLAY:
|
case XML_ELEMENT( TABLE, XML_DISPLAY ):
|
||||||
bDisplay = IsXMLToken(sValue, XML_TRUE);
|
bDisplay = IsXMLToken(aIter, XML_TRUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SvXMLImportContext *ScXMLErrorMessageContext::CreateChildContext( sal_uInt16 nPrefix,
|
SvXMLImportContext *ScXMLErrorMessageContext::CreateChildContext( sal_uInt16 nPrefix,
|
||||||
const OUString& rLName,
|
const OUString& rLName,
|
||||||
@@ -562,42 +563,39 @@ SvXMLImportContext *ScXMLErrorMessageContext::CreateChildContext( sal_uInt16 nPr
|
|||||||
return pContext;
|
return pContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScXMLErrorMessageContext::EndElement()
|
void SAL_CALL ScXMLErrorMessageContext::endFastElement( sal_Int32 /*nElement*/ )
|
||||||
{
|
{
|
||||||
pValidationContext->SetErrorMessage(sTitle, sMessage.makeStringAndClear(), sMessageType, bDisplay);
|
pValidationContext->SetErrorMessage(sTitle, sMessage.makeStringAndClear(), sMessageType, bDisplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScXMLErrorMacroContext::ScXMLErrorMacroContext( ScXMLImport& rImport,
|
ScXMLErrorMacroContext::ScXMLErrorMacroContext( ScXMLImport& rImport,
|
||||||
sal_uInt16 nPrfx,
|
sal_Int32 /*nElement*/,
|
||||||
const OUString& rLName,
|
const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList,
|
||||||
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList,
|
|
||||||
ScXMLContentValidationContext* pTempValidationContext) :
|
ScXMLContentValidationContext* pTempValidationContext) :
|
||||||
ScXMLImportContext( rImport, nPrfx, rLName ),
|
ScXMLImportContext( rImport ),
|
||||||
sName(),
|
sName(),
|
||||||
bExecute(false)
|
bExecute(false)
|
||||||
{
|
{
|
||||||
pValidationContext = pTempValidationContext;
|
pValidationContext = pTempValidationContext;
|
||||||
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
|
if ( xAttrList.is() )
|
||||||
const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationErrorMacroAttrTokenMap();
|
|
||||||
for( sal_Int16 i=0; i < nAttrCount; ++i )
|
|
||||||
{
|
{
|
||||||
const OUString& sAttrName(xAttrList->getNameByIndex( i ));
|
sax_fastparser::FastAttributeList *pAttribList =
|
||||||
OUString aLocalName;
|
sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList );
|
||||||
sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
|
|
||||||
sAttrName, &aLocalName );
|
|
||||||
const OUString& sValue(xAttrList->getValueByIndex( i ));
|
|
||||||
|
|
||||||
switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
|
for (auto &aIter : *pAttribList)
|
||||||
{
|
{
|
||||||
case XML_TOK_ERROR_MACRO_ATTR_NAME:
|
switch (aIter.getToken())
|
||||||
sName = sValue;
|
{
|
||||||
|
case XML_ELEMENT( TABLE, XML_NAME ):
|
||||||
|
sName = aIter.toString();
|
||||||
break;
|
break;
|
||||||
case XML_TOK_ERROR_MACRO_ATTR_EXECUTE:
|
case XML_ELEMENT( TABLE, XML_EXECUTE ):
|
||||||
bExecute = IsXMLToken(sValue, XML_TRUE);
|
bExecute = IsXMLToken(aIter, XML_TRUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SvXMLImportContext *ScXMLErrorMacroContext::CreateChildContext( sal_uInt16 nPrefix,
|
SvXMLImportContext *ScXMLErrorMacroContext::CreateChildContext( sal_uInt16 nPrefix,
|
||||||
const OUString& rLName,
|
const OUString& rLName,
|
||||||
@@ -615,7 +613,7 @@ SvXMLImportContext *ScXMLErrorMacroContext::CreateChildContext( sal_uInt16 nPref
|
|||||||
return pContext;
|
return pContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScXMLErrorMacroContext::EndElement()
|
void SAL_CALL ScXMLErrorMacroContext::endFastElement( sal_Int32 /*nElement*/ )
|
||||||
{
|
{
|
||||||
pValidationContext->SetErrorMacro( bExecute );
|
pValidationContext->SetErrorMacro( bExecute );
|
||||||
}
|
}
|
||||||
|
@@ -37,9 +37,8 @@ public:
|
|||||||
|
|
||||||
virtual ~ScXMLContentValidationsContext() override;
|
virtual ~ScXMLContentValidationsContext() override;
|
||||||
|
|
||||||
virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
|
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
|
||||||
const OUString& rLocalName,
|
sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
|
||||||
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user