sc/source/filter/xml/XMLCalculationSettingsContext.cxx | 107 ++----- sc/source/filter/xml/XMLCalculationSettingsContext.hxx | 29 - sc/source/filter/xml/xmlcvali.cxx | 258 ++++++++--------- sc/source/filter/xml/xmlcvali.hxx | 5 4 files changed, 179 insertions(+), 220 deletions(-)
New commits: commit 42c8000e68ab9d04f12a71bdaacb3718cb35bbd3 Author: Mohammed Abdul Azeem <azeemmys...@gmail.com> Date: Sun Jul 16 23:18:02 2017 +0530 Moving legacy contexts to FastContexts: ScXMLNullDateContext ScXMLIterationContext ScXMLContentValidationContext ScXMLHelpMessageContext ScXMLErrorMessageContext ScXMLErrorMacroContext Change-Id: Ic2a4f038891aefbb94b1d9ada96da7c139c6c9fe Reviewed-on: https://gerrit.libreoffice.org/40012 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Eike Rathke <er...@redhat.com> Reviewed-by: Michael Meeks <michael.me...@collabora.com> diff --git a/sc/source/filter/xml/XMLCalculationSettingsContext.cxx b/sc/source/filter/xml/XMLCalculationSettingsContext.cxx index 1347c299ff29..0617d2654b14 100644 --- a/sc/source/filter/xml/XMLCalculationSettingsContext.cxx +++ b/sc/source/filter/xml/XMLCalculationSettingsContext.cxx @@ -96,22 +96,18 @@ ScXMLCalculationSettingsContext::~ScXMLCalculationSettingsContext() { } -SvXMLImportContext *ScXMLCalculationSettingsContext::CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) +uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLCalculationSettingsContext::createFastChildContext( + sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList ) { SvXMLImportContext *pContext = nullptr; - if (nPrefix == XML_NAMESPACE_TABLE) - { - if (IsXMLToken(rLName, XML_NULL_DATE)) - pContext = new ScXMLNullDateContext(GetScImport(), nPrefix, rLName, xAttrList, this); - else if (IsXMLToken(rLName, XML_ITERATION)) - pContext = new ScXMLIterationContext(GetScImport(), nPrefix, rLName, xAttrList, this); - } + if (nElement == XML_ELEMENT( TABLE, XML_NULL_DATE )) + pContext = new ScXMLNullDateContext(GetScImport(), nElement, xAttrList, this); + else if (nElement == XML_ELEMENT( TABLE, XML_ITERATION )) + pContext = new ScXMLIterationContext(GetScImport(), nElement, xAttrList, this); if( !pContext ) - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + pContext = new SvXMLImportContext( GetImport() ); return pContext; } @@ -147,25 +143,21 @@ void SAL_CALL ScXMLCalculationSettingsContext::endFastElement( sal_Int32 /*nElem } ScXMLNullDateContext::ScXMLNullDateContext( ScXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, ScXMLCalculationSettingsContext* pCalcSet) : - ScXMLImportContext( rImport, nPrfx, rLName ) + ScXMLImportContext( rImport ) { - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for( sal_Int16 i=0; i < nAttrCount; ++i ) + if ( xAttrList.is() ) { - const OUString& sAttrName(xAttrList->getNameByIndex( i )); - OUString aLocalName; - sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( - sAttrName, &aLocalName ); - const OUString& sValue(xAttrList->getValueByIndex( i )); + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList ); - 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; - ::sax::Converter::parseDateTime(aDateTime, nullptr, sValue); + ::sax::Converter::parseDateTime(aDateTime, nullptr, aIter.toString()); util::Date aDate; aDate.Day = aDateTime.Day; aDate.Month = aDateTime.Month; @@ -179,53 +171,39 @@ ScXMLNullDateContext::~ScXMLNullDateContext() { } -SvXMLImportContext *ScXMLNullDateContext::CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList>& /* xAttrList */ ) -{ - SvXMLImportContext *pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); - - return pContext; -} - -void ScXMLNullDateContext::EndElement() +uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLNullDateContext::createFastChildContext( + sal_Int32 /*nElement*/, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) { + return new SvXMLImportContext( GetImport() ); } ScXMLIterationContext::ScXMLIterationContext( ScXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, ScXMLCalculationSettingsContext* pCalcSet) : - ScXMLImportContext( rImport, nPrfx, rLName ) + ScXMLImportContext( rImport ) { - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for( sal_Int16 i=0; i < nAttrCount; ++i ) + if ( xAttrList.is() ) { - const OUString& sAttrName(xAttrList->getNameByIndex( i )); - OUString aLocalName; - sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( - sAttrName, &aLocalName ); - const OUString& sValue(xAttrList->getValueByIndex( i )); + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList ); - 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); - } - else if (IsXMLToken(aLocalName, XML_STEPS)) - { - sal_Int32 nSteps; - ::sax::Converter::convertNumber(nSteps, sValue); - pCalcSet->SetIterationCount(nSteps); - } - else if (IsXMLToken(aLocalName, XML_MAXIMUM_DIFFERENCE)) - { + break; + case XML_ELEMENT( TABLE, XML_STEPS ): + pCalcSet->SetIterationCount(aIter.toInt32()); + break; + case XML_ELEMENT( TABLE, XML_MAXIMUM_DIFFERENCE ): double fDif; - ::sax::Converter::convertDouble(fDif, sValue); + ::sax::Converter::convertDouble(fDif, aIter.toString()); pCalcSet->SetIterationEpsilon(fDif); + break; } } } @@ -235,17 +213,10 @@ ScXMLIterationContext::~ScXMLIterationContext() { } -SvXMLImportContext *ScXMLIterationContext::CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList>& /* xAttrList */ ) -{ - SvXMLImportContext *pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); - - return pContext; -} - -void ScXMLIterationContext::EndElement() +uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLIterationContext::createFastChildContext( + sal_Int32 /*nElement*/, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) { + return new SvXMLImportContext( GetImport() ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/filter/xml/XMLCalculationSettingsContext.hxx b/sc/source/filter/xml/XMLCalculationSettingsContext.hxx index fb0cd553a673..08c4e03cebd0 100644 --- a/sc/source/filter/xml/XMLCalculationSettingsContext.hxx +++ b/sc/source/filter/xml/XMLCalculationSettingsContext.hxx @@ -46,9 +46,8 @@ public: virtual ~ScXMLCalculationSettingsContext() override; - virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) 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; void SetNullDate(const css::util::Date& aDate) { aNullDate = aDate; } void SetIterationStatus(const bool bValue) { bIsIterationEnabled = bValue; } @@ -60,33 +59,25 @@ public: class ScXMLNullDateContext : public ScXMLImportContext { public: - ScXMLNullDateContext( ScXMLImport& rImport, sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, ScXMLCalculationSettingsContext* pCalcSet); + ScXMLNullDateContext( ScXMLImport& rImport, sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, ScXMLCalculationSettingsContext* pCalcSet); virtual ~ScXMLNullDateContext() override; - virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - 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; }; class ScXMLIterationContext : public ScXMLImportContext { public: - ScXMLIterationContext( ScXMLImport& rImport, sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, ScXMLCalculationSettingsContext* pCalcSet); + ScXMLIterationContext( ScXMLImport& rImport, sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, ScXMLCalculationSettingsContext* pCalcSet); virtual ~ScXMLIterationContext() override; - virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - 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; }; #endif diff --git a/sc/source/filter/xml/xmlcvali.cxx b/sc/source/filter/xml/xmlcvali.cxx index 286928e35bdd..71e2b5f08eab 100644 --- a/sc/source/filter/xml/xmlcvali.cxx +++ b/sc/source/filter/xml/xmlcvali.cxx @@ -58,15 +58,17 @@ class ScXMLContentValidationContext : public ScXMLImportContext public: - ScXMLContentValidationContext( ScXMLImport& rImport, sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList); + ScXMLContentValidationContext( ScXMLImport& rImport, sal_Int32 nElement, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList); virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, 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 SetErrorMessage(const OUString& sTitle, const OUString& sMessage, const OUString& sMessageType, const bool bDisplay); @@ -84,16 +86,15 @@ class ScXMLHelpMessageContext : public ScXMLImportContext public: - ScXMLHelpMessageContext( ScXMLImport& rImport, sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList, + ScXMLHelpMessageContext( ScXMLImport& rImport, sal_Int32 nElement, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList, ScXMLContentValidationContext* pValidationContext); virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, 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 @@ -108,16 +109,15 @@ class ScXMLErrorMessageContext : public ScXMLImportContext public: - ScXMLErrorMessageContext( ScXMLImport& rImport, sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList, + ScXMLErrorMessageContext( ScXMLImport& rImport, sal_Int32 nElement, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList, ScXMLContentValidationContext* pValidationContext); virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, 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 @@ -128,15 +128,14 @@ class ScXMLErrorMacroContext : public ScXMLImportContext public: - ScXMLErrorMacroContext( ScXMLImport& rImport, sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList, + ScXMLErrorMacroContext( ScXMLImport& rImport, sal_Int32 nElement, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList, ScXMLContentValidationContext* pValidationContext); virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, 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, @@ -151,104 +150,88 @@ ScXMLContentValidationsContext::~ScXMLContentValidationsContext() { } -SvXMLImportContext *ScXMLContentValidationsContext::CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLName, - const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) +uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLContentValidationsContext::createFastChildContext( + sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList ) { SvXMLImportContext *pContext = nullptr; - const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationsElemTokenMap(); - switch( rTokenMap.Get( nPrefix, rLName ) ) + switch (nElement) { - case XML_TOK_CONTENT_VALIDATION: - pContext = new ScXMLContentValidationContext( GetScImport(), nPrefix, rLName, xAttrList); + case XML_ELEMENT( TABLE, XML_CONTENT_VALIDATION ): + pContext = new ScXMLContentValidationContext( GetScImport(), nElement, xAttrList); break; } if( !pContext ) - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + pContext = new SvXMLImportContext( GetImport() ); return pContext; } ScXMLContentValidationContext::ScXMLContentValidationContext( ScXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList) : - ScXMLImportContext( rImport, nPrfx, rLName ), + sal_Int32 /*nElement*/, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) : + ScXMLImportContext( rImport ), 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 ) + if ( xAttrList.is() ) { - const OUString& sAttrName(xAttrList->getNameByIndex( i )); - OUString aLocalName; - sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( - sAttrName, &aLocalName ); - const OUString& sValue(xAttrList->getValueByIndex( i )); + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList ); - switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + for (auto &aIter : *pAttribList) { - 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: + switch (aIter.getToken()) { - if (IsXMLToken(sValue, XML_NO)) + 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(sValue, XML_UNSORTED)) + else if (IsXMLToken(aIter, XML_UNSORTED)) { nShowList = sheet::TableValidationVisibility::UNSORTED; } - else if (IsXMLToken(sValue, XML_SORT_ASCENDING)) + else if (IsXMLToken(aIter, XML_SORT_ASCENDING)) { nShowList = sheet::TableValidationVisibility::SORTEDASCENDING; } - else if (IsXMLToken(sValue, XML_SORTED_ASCENDING)) + else if (IsXMLToken(aIter, XML_SORTED_ASCENDING)) { // Read old wrong value, fdo#72548 nShowList = sheet::TableValidationVisibility::SORTEDASCENDING; } + break; } - break; } } } SvXMLImportContext *ScXMLContentValidationContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLName, - const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) + const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttrList*/ ) { SvXMLImportContext *pContext = nullptr; const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationElemTokenMap(); switch( rTokenMap.Get( nPrefix, rLName ) ) { - case XML_TOK_CONTENT_VALIDATION_ELEM_HELP_MESSAGE: - pContext = new ScXMLHelpMessageContext( GetScImport(), nPrefix, rLName, xAttrList, this); - break; - case XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MESSAGE: - pContext = new ScXMLErrorMessageContext( GetScImport(), nPrefix, rLName, xAttrList, this); - break; - case XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MACRO: - pContext = new ScXMLErrorMacroContext( GetScImport(), nPrefix, rLName, xAttrList, this); - break; case XML_TOK_CONTENT_VALIDATION_ELEM_EVENT_LISTENERS: pContext = new XMLEventsImportContext( GetImport(), nPrefix, rLName ); xEventContext = pContext; @@ -261,6 +244,30 @@ SvXMLImportContext *ScXMLContentValidationContext::CreateChildContext( sal_uInt1 return pContext; } +uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLContentValidationContext::createFastChildContext( + sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList ) +{ + SvXMLImportContext *pContext = nullptr; + + switch (nElement) + { + case XML_ELEMENT( TABLE, XML_HELP_MESSAGE ): + pContext = new ScXMLHelpMessageContext( GetScImport(), nElement, xAttrList, this); + break; + case XML_ELEMENT( TABLE, XML_ERROR_MESSAGE ): + pContext = new ScXMLErrorMessageContext( GetScImport(), nElement, xAttrList, this); + break; + case XML_ELEMENT( TABLE, XML_ERROR_MACRO ): + pContext = new ScXMLErrorMacroContext( GetScImport(), nElement, xAttrList, this); + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport() ); + + return pContext; +} + sheet::ValidationAlertStyle ScXMLContentValidationContext::GetAlertStyle() const { if (IsXMLToken(sErrorMessageType, XML_MACRO)) @@ -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 if (xEventContext.is()) @@ -436,35 +443,32 @@ void ScXMLContentValidationContext::SetErrorMacro(const bool bExecute) } ScXMLHelpMessageContext::ScXMLHelpMessageContext( ScXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList, + sal_Int32 /*nElement*/, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList, ScXMLContentValidationContext* pTempValidationContext) : - ScXMLImportContext( rImport, nPrfx, rLName ), + ScXMLImportContext( rImport ), sTitle(), sMessage(), nParagraphCount(0), bDisplay(false) { pValidationContext = pTempValidationContext; - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationHelpMessageAttrTokenMap(); - for( sal_Int16 i=0; i < nAttrCount; ++i ) + if ( xAttrList.is() ) { - const OUString& sAttrName(xAttrList->getNameByIndex( i )); - OUString aLocalName; - sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( - sAttrName, &aLocalName ); - const OUString& sValue(xAttrList->getValueByIndex( i )); + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList ); - switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + for (auto &aIter : *pAttribList) { - case XML_TOK_HELP_MESSAGE_ATTR_TITLE: - sTitle = sValue; - break; - case XML_TOK_HELP_MESSAGE_ATTR_DISPLAY: - bDisplay = IsXMLToken(sValue, XML_TRUE); - break; + switch (aIter.getToken()) + { + case XML_ELEMENT( TABLE, XML_TITLE ): + sTitle = aIter.toString(); + break; + case XML_ELEMENT( TABLE, XML_DISPLAY ): + bDisplay = IsXMLToken(aIter, XML_TRUE); + break; + } } } } @@ -494,17 +498,16 @@ SvXMLImportContext *ScXMLHelpMessageContext::CreateChildContext( sal_uInt16 nPre return pContext; } -void ScXMLHelpMessageContext::EndElement() +void SAL_CALL ScXMLHelpMessageContext::endFastElement( sal_Int32 /*nElement*/ ) { pValidationContext->SetHelpMessage(sTitle, sMessage.makeStringAndClear(), bDisplay); } ScXMLErrorMessageContext::ScXMLErrorMessageContext( ScXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList, + sal_Int32 /*nElement*/, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList, ScXMLContentValidationContext* pTempValidationContext) : - ScXMLImportContext( rImport, nPrfx, rLName ), + ScXMLImportContext( rImport ), sTitle(), sMessage(), sMessageType(), @@ -512,27 +515,25 @@ ScXMLErrorMessageContext::ScXMLErrorMessageContext( ScXMLImport& rImport, bDisplay(false) { pValidationContext = pTempValidationContext; - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationErrorMessageAttrTokenMap(); - for( sal_Int16 i=0; i < nAttrCount; ++i ) + if ( xAttrList.is() ) { - const OUString& sAttrName(xAttrList->getNameByIndex( i )); - OUString aLocalName; - sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( - sAttrName, &aLocalName ); - const OUString& sValue(xAttrList->getValueByIndex( i )); + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList ); - switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + for (auto &aIter : *pAttribList) { - case XML_TOK_ERROR_MESSAGE_ATTR_TITLE: - sTitle = sValue; - break; - case XML_TOK_ERROR_MESSAGE_ATTR_MESSAGE_TYPE: - sMessageType = sValue; - break; - case XML_TOK_ERROR_MESSAGE_ATTR_DISPLAY: - bDisplay = IsXMLToken(sValue, XML_TRUE); - break; + switch (aIter.getToken()) + { + case XML_ELEMENT( TABLE, XML_TITLE ): + sTitle = aIter.toString(); + break; + case XML_ELEMENT( TABLE, XML_MESSAGE_TYPE ): + sMessageType = aIter.toString(); + break; + case XML_ELEMENT( TABLE, XML_DISPLAY ): + bDisplay = IsXMLToken(aIter, XML_TRUE); + break; + } } } } @@ -562,39 +563,36 @@ SvXMLImportContext *ScXMLErrorMessageContext::CreateChildContext( sal_uInt16 nPr return pContext; } -void ScXMLErrorMessageContext::EndElement() +void SAL_CALL ScXMLErrorMessageContext::endFastElement( sal_Int32 /*nElement*/ ) { pValidationContext->SetErrorMessage(sTitle, sMessage.makeStringAndClear(), sMessageType, bDisplay); } ScXMLErrorMacroContext::ScXMLErrorMacroContext( ScXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList, + sal_Int32 /*nElement*/, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList, ScXMLContentValidationContext* pTempValidationContext) : - ScXMLImportContext( rImport, nPrfx, rLName ), + ScXMLImportContext( rImport ), sName(), bExecute(false) { pValidationContext = pTempValidationContext; - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationErrorMacroAttrTokenMap(); - for( sal_Int16 i=0; i < nAttrCount; ++i ) + if ( xAttrList.is() ) { - const OUString& sAttrName(xAttrList->getNameByIndex( i )); - OUString aLocalName; - sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( - sAttrName, &aLocalName ); - const OUString& sValue(xAttrList->getValueByIndex( i )); + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList ); - switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + for (auto &aIter : *pAttribList) { - case XML_TOK_ERROR_MACRO_ATTR_NAME: - sName = sValue; - break; - case XML_TOK_ERROR_MACRO_ATTR_EXECUTE: - bExecute = IsXMLToken(sValue, XML_TRUE); - break; + switch (aIter.getToken()) + { + case XML_ELEMENT( TABLE, XML_NAME ): + sName = aIter.toString(); + break; + case XML_ELEMENT( TABLE, XML_EXECUTE ): + bExecute = IsXMLToken(aIter, XML_TRUE); + break; + } } } } @@ -615,7 +613,7 @@ SvXMLImportContext *ScXMLErrorMacroContext::CreateChildContext( sal_uInt16 nPref return pContext; } -void ScXMLErrorMacroContext::EndElement() +void SAL_CALL ScXMLErrorMacroContext::endFastElement( sal_Int32 /*nElement*/ ) { pValidationContext->SetErrorMacro( bExecute ); } diff --git a/sc/source/filter/xml/xmlcvali.hxx b/sc/source/filter/xml/xmlcvali.hxx index c19a9fa5849a..f633e96ca933 100644 --- a/sc/source/filter/xml/xmlcvali.hxx +++ b/sc/source/filter/xml/xmlcvali.hxx @@ -37,9 +37,8 @@ public: virtual ~ScXMLContentValidationsContext() override; - virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) 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; }; #endif _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits