include/xmloff/XMLEventsImportContext.hxx | 2 sc/source/filter/xml/xmlcvali.cxx | 78 +++++++++++++++--------- sc/source/filter/xml/xmlimprt.cxx | 37 +++++++++++ sc/source/filter/xml/xmlimprt.hxx | 16 ++++ xmloff/source/script/XMLEventsImportContext.cxx | 5 - 5 files changed, 103 insertions(+), 35 deletions(-)
New commits: commit 11332f543a2ecd1a83066d49c040f2b51cbccc97 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Thu Apr 29 09:33:35 2021 +0200 Commit: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> CommitDate: Wed May 5 19:41:37 2021 +0200 tdf#137945: Revert "use more FastParser in ScXMLContentValidationContext" This reverts commit ae854970bf9c734df132797c0f23a7829efd167c. This is only reverted in libreoffice-7-0 branch. See https://bugs.documentfoundation.org/show_bug.cgi?id=137945#c2 Besides, this commit partially reverts d32289d715f7182b9e82a4d3fde9cfcf87517da3 < loplugin:unusedmethods > and be9f45ad69a510185971957e7643fd64b873e98d < loplugin:unusedenumconstants > since some methods and enumerations are needed after reverting the commit Change-Id: Ia71257a37d384e7eb6ba904a6a13f8ae5603a79b Change-Id: I04c74ceb6e38c54ea41464b8337016bb5f81d90d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114882 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> (cherry picked from commit 6ac038c54121ec307ed75f8fb45f591cca9f8519) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114869 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> Tested-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> diff --git a/include/xmloff/XMLEventsImportContext.hxx b/include/xmloff/XMLEventsImportContext.hxx index 4fb08ffb9d40..b85363e1b57d 100644 --- a/include/xmloff/XMLEventsImportContext.hxx +++ b/include/xmloff/XMLEventsImportContext.hxx @@ -67,8 +67,6 @@ public: sal_uInt16 nPrfx, const OUString& rLocalName); - XMLEventsImportContext(SvXMLImport& rImport); - XMLEventsImportContext( SvXMLImport& rImport, sal_uInt16 nPrfx, diff --git a/sc/source/filter/xml/xmlcvali.cxx b/sc/source/filter/xml/xmlcvali.cxx index 658f8007d0e7..e6835fb80c4a 100644 --- a/sc/source/filter/xml/xmlcvali.cxx +++ b/sc/source/filter/xml/xmlcvali.cxx @@ -62,6 +62,10 @@ public: ScXMLContentValidationContext( ScXMLImport& rImport, const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList ); + virtual SvXMLImportContextRef 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; @@ -87,9 +91,9 @@ public: const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList, ScXMLContentValidationContext* pValidationContext); - 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 SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, + const OUString& rLocalName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override; virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override; }; @@ -110,9 +114,9 @@ public: const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList, ScXMLContentValidationContext* pValidationContext); - 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 SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, + const OUString& rLocalName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override; virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override; }; @@ -128,9 +132,9 @@ public: const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList, ScXMLContentValidationContext* pValidationContext); - 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 SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, + const OUString& rLocalName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override; virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override; }; @@ -214,6 +218,24 @@ ScXMLContentValidationContext::ScXMLContentValidationContext( ScXMLImport& rImpo } } +SvXMLImportContextRef 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 ) ) + { + case XML_TOK_CONTENT_VALIDATION_ELEM_EVENT_LISTENERS: + pContext = new XMLEventsImportContext( GetImport(), nPrefix, rLName ); + xEventContext = pContext; + break; + } + + return pContext; +} + uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLContentValidationContext::createFastChildContext( sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList ) { @@ -232,9 +254,6 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLContentValidationC case XML_ELEMENT( TABLE, XML_ERROR_MACRO ): pContext = new ScXMLErrorMacroContext( GetScImport(), pAttribList, this); break; - case XML_ELEMENT(OFFICE, XML_EVENT_LISTENERS): - pContext = new XMLEventsImportContext( GetImport() ); - xEventContext = pContext; } return pContext; @@ -436,20 +455,21 @@ ScXMLHelpMessageContext::ScXMLHelpMessageContext( ScXMLImport& rImport, } } -css::uno::Reference< css::xml::sax::XFastContextHandler > ScXMLHelpMessageContext::createFastChildContext( - sal_Int32 nElement, - const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ ) +SvXMLImportContextRef ScXMLHelpMessageContext::CreateChildContext( sal_uInt16 nPrefix, + const OUString& rLName, + const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttrList*/ ) { SvXMLImportContext *pContext = nullptr; - switch( nElement ) + const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationMessageElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) { - case XML_ELEMENT(TEXT, XML_P): + case XML_TOK_P: { if(nParagraphCount) sMessage.append('\n'); ++nParagraphCount; - pContext = new ScXMLContentContext( GetScImport(), sMessage ); + pContext = new ScXMLContentContext( GetScImport(), nPrefix, rLName, sMessage); } break; } @@ -493,20 +513,21 @@ ScXMLErrorMessageContext::ScXMLErrorMessageContext( ScXMLImport& rImport, } } -css::uno::Reference< css::xml::sax::XFastContextHandler > ScXMLErrorMessageContext::createFastChildContext( - sal_Int32 nElement, - const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ ) +SvXMLImportContextRef ScXMLErrorMessageContext::CreateChildContext( sal_uInt16 nPrefix, + const OUString& rLName, + const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttrList*/ ) { SvXMLImportContext *pContext = nullptr; - switch( nElement ) + const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationMessageElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) { - case XML_ELEMENT(TEXT, XML_P): + case XML_TOK_P: { if(nParagraphCount) sMessage.append('\n'); ++nParagraphCount; - pContext = new ScXMLContentContext( GetScImport(), sMessage); + pContext = new ScXMLContentContext( GetScImport(), nPrefix, rLName, sMessage); } break; } @@ -542,14 +563,15 @@ ScXMLErrorMacroContext::ScXMLErrorMacroContext( ScXMLImport& rImport, } } -css::uno::Reference< css::xml::sax::XFastContextHandler > ScXMLErrorMacroContext::createFastChildContext( - sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ ) +SvXMLImportContextRef ScXMLErrorMacroContext::CreateChildContext( sal_uInt16 nPrefix, + const OUString& rLName, + const css::uno::Reference<css::xml::sax::XAttributeList>& /* xAttrList */ ) { SvXMLImportContext *pContext = nullptr; - if (nElement == XML_ELEMENT(SCRIPT, XML_EVENTS)) + if ((nPrefix == XML_NAMESPACE_SCRIPT) && IsXMLToken(rLName, XML_EVENTS)) { - pContext = new XMLEventsImportContext(GetImport()); + pContext = new XMLEventsImportContext(GetImport(), nPrefix, rLName); } return pContext; diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index 84931b6de44f..a9312c791962 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -398,6 +398,41 @@ void SAL_CALL ScXMLDocContext_Impl::characters(const OUString &) { } +const SvXMLTokenMap& ScXMLImport::GetContentValidationElemTokenMap() +{ + if( !pContentValidationElemTokenMap ) + { + static const SvXMLTokenMapEntry aContentValidationElemTokenMap[] = + { + { XML_NAMESPACE_TABLE, XML_HELP_MESSAGE, XML_TOK_CONTENT_VALIDATION_ELEM_HELP_MESSAGE }, + { XML_NAMESPACE_TABLE, XML_ERROR_MESSAGE, XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MESSAGE }, + { XML_NAMESPACE_TABLE, XML_ERROR_MACRO, XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MACRO }, + { XML_NAMESPACE_OFFICE, XML_EVENT_LISTENERS, XML_TOK_CONTENT_VALIDATION_ELEM_EVENT_LISTENERS }, + XML_TOKEN_MAP_END + }; + + pContentValidationElemTokenMap.reset(new SvXMLTokenMap( aContentValidationElemTokenMap )); + } // if( !pContentValidationElemTokenMap ) + + return *pContentValidationElemTokenMap; +} + +const SvXMLTokenMap& ScXMLImport::GetContentValidationMessageElemTokenMap() +{ + if( !pContentValidationMessageElemTokenMap ) + { + static const SvXMLTokenMapEntry aContentValidationMessageElemTokenMap[] = + { + { XML_NAMESPACE_TEXT, XML_P, XML_TOK_P }, + XML_TOKEN_MAP_END + }; + + pContentValidationMessageElemTokenMap.reset(new SvXMLTokenMap( aContentValidationMessageElemTokenMap )); + } // if( !pContentValidationMessageElemTokenMap ) + + return *pContentValidationMessageElemTokenMap; +} + const SvXMLTokenMap& ScXMLImport::GetTableElemTokenMap() { if( !pTableElemTokenMap ) @@ -616,6 +651,8 @@ ScXMLImport::ScXMLImport( ScXMLImport::~ScXMLImport() throw() { // delete pI18NMap; + pContentValidationElemTokenMap.reset(); + pContentValidationMessageElemTokenMap.reset(); pTableElemTokenMap.reset(); pTableRowsElemTokenMap.reset(); pTableRowElemTokenMap.reset(); diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx index 0523d437cfd6..250c49a9e545 100644 --- a/sc/source/filter/xml/xmlimprt.hxx +++ b/sc/source/filter/xml/xmlimprt.hxx @@ -55,6 +55,18 @@ struct ImportPostProcessData; struct PivotTableSources; } +enum ScXMLContentValidationElemTokens +{ + XML_TOK_CONTENT_VALIDATION_ELEM_HELP_MESSAGE, + XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MESSAGE, + XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MACRO, + XML_TOK_CONTENT_VALIDATION_ELEM_EVENT_LISTENERS +}; + +enum ScXMLContentValidationMessageElemTokens +{ + XML_TOK_P +}; enum ScXMLTableTokens { @@ -217,6 +229,8 @@ class ScXMLImport: public SvXMLImport rtl::Reference < XMLPropertySetMapper > xRowStylesPropertySetMapper; rtl::Reference < XMLPropertySetMapper > xTableStylesPropertySetMapper; + std::unique_ptr<SvXMLTokenMap> pContentValidationElemTokenMap; + std::unique_ptr<SvXMLTokenMap> pContentValidationMessageElemTokenMap; std::unique_ptr<SvXMLTokenMap> pTableElemTokenMap; std::unique_ptr<SvXMLTokenMap> pTableRowsElemTokenMap; std::unique_ptr<SvXMLTokenMap> pTableRowElemTokenMap; @@ -308,6 +322,8 @@ public: const rtl::Reference < XMLPropertySetMapper >& GetRowStylesPropertySetMapper() const { return xRowStylesPropertySetMapper; } const rtl::Reference < XMLPropertySetMapper >& GetTableStylesPropertySetMapper() const { return xTableStylesPropertySetMapper; } + const SvXMLTokenMap& GetContentValidationElemTokenMap(); + const SvXMLTokenMap& GetContentValidationMessageElemTokenMap(); const SvXMLTokenMap& GetTableElemTokenMap(); const SvXMLTokenMap& GetTableRowsElemTokenMap(); const SvXMLTokenMap& GetTableRowElemTokenMap(); diff --git a/xmloff/source/script/XMLEventsImportContext.cxx b/xmloff/source/script/XMLEventsImportContext.cxx index a5a8837ec423..374d67b0f5e1 100644 --- a/xmloff/source/script/XMLEventsImportContext.cxx +++ b/xmloff/source/script/XMLEventsImportContext.cxx @@ -47,11 +47,6 @@ XMLEventsImportContext::XMLEventsImportContext( { } -XMLEventsImportContext::XMLEventsImportContext(SvXMLImport& rImport) : - SvXMLImportContext(rImport) -{ -} - XMLEventsImportContext::XMLEventsImportContext( SvXMLImport& rImport, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits