diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-11-24 20:23:19 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-11-25 08:42:54 +0100 |
commit | b563b61af9a8d9917845f52d2058b7d18ec6cdce (patch) | |
tree | bf1ec9a878acb5c66e24a5c7b20e6d7c335831f3 /xmloff/source/text/XMLIndexTOCContext.cxx | |
parent | 60d0cf170b637c01f76e354e8bf5a40cade11b69 (diff) |
fastparser in text index
Change-Id: Ia1811b6e913aabcb9f1fb138ab440f5cee8a9d74
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106548
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff/source/text/XMLIndexTOCContext.cxx')
-rw-r--r-- | xmloff/source/text/XMLIndexTOCContext.cxx | 124 |
1 files changed, 59 insertions, 65 deletions
diff --git a/xmloff/source/text/XMLIndexTOCContext.cxx b/xmloff/source/text/XMLIndexTOCContext.cxx index 8eb82b48311f..3c05f623d23a 100644 --- a/xmloff/source/text/XMLIndexTOCContext.cxx +++ b/xmloff/source/text/XMLIndexTOCContext.cxx @@ -273,79 +273,73 @@ void XMLIndexTOCContext::endFastElement(sal_Int32 ) } } -SvXMLImportContextRef XMLIndexTOCContext::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference<XAttributeList> & /*xAttrList*/ ) +css::uno::Reference< css::xml::sax::XFastContextHandler > XMLIndexTOCContext::createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) { SvXMLImportContextRef xContext; - if (bValid) + // not valid -> ignore + if (!bValid) + return nullptr; + + if (nElement == XML_ELEMENT(TEXT, XML_INDEX_BODY) ) { - if (XML_NAMESPACE_TEXT == nPrefix) + rtl::Reference<XMLIndexBodyContext> xNewBodyContext = new XMLIndexBodyContext(GetImport()); + xContext = xNewBodyContext; + if ( !xBodyContextRef.is() || !xBodyContextRef->HasContent() ) { - if ( IsXMLToken( rLocalName, XML_INDEX_BODY ) ) - { - rtl::Reference<XMLIndexBodyContext> xNewBodyContext = new XMLIndexBodyContext(GetImport(), nPrefix, - rLocalName); - xContext = xNewBodyContext; - if ( !xBodyContextRef.is() || !xBodyContextRef->HasContent() ) - { - xBodyContextRef = xNewBodyContext; - } - } - else if (IsXMLToken(rLocalName, aIndexSourceElementMap[eIndexType])) - { - // instantiate source context for the appropriate index type - switch (eIndexType) - { - case TEXT_INDEX_TOC: - xContext = new XMLIndexTOCSourceContext( - GetImport(), nPrefix, rLocalName, xTOCPropertySet); - break; - - case TEXT_INDEX_OBJECT: - xContext = new XMLIndexObjectSourceContext( - GetImport(), nPrefix, rLocalName, xTOCPropertySet); - break; - - case TEXT_INDEX_ALPHABETICAL: - xContext = new XMLIndexAlphabeticalSourceContext( - GetImport(), nPrefix, rLocalName, xTOCPropertySet); - break; - - case TEXT_INDEX_USER: - xContext = new XMLIndexUserSourceContext( - GetImport(), nPrefix, rLocalName, xTOCPropertySet); - break; - - case TEXT_INDEX_BIBLIOGRAPHY: - xContext = new XMLIndexBibliographySourceContext( - GetImport(), nPrefix, rLocalName, xTOCPropertySet); - break; - - case TEXT_INDEX_TABLE: - xContext = new XMLIndexTableSourceContext( - GetImport(), nPrefix, rLocalName, xTOCPropertySet); - break; - - case TEXT_INDEX_ILLUSTRATION: - xContext = new XMLIndexIllustrationSourceContext( - GetImport(), nPrefix, rLocalName, xTOCPropertySet); - break; - - default: - OSL_FAIL("index type not implemented"); - break; - } - } - // else: ignore + xBodyContextRef = xNewBodyContext; + } + } + else if (nElement == XML_ELEMENT(TEXT, aIndexSourceElementMap[eIndexType])) + { + // instantiate source context for the appropriate index type + switch (eIndexType) + { + case TEXT_INDEX_TOC: + xContext = new XMLIndexTOCSourceContext( + GetImport(), xTOCPropertySet); + break; + + case TEXT_INDEX_OBJECT: + xContext = new XMLIndexObjectSourceContext( + GetImport(), xTOCPropertySet); + break; + + case TEXT_INDEX_ALPHABETICAL: + xContext = new XMLIndexAlphabeticalSourceContext( + GetImport(), xTOCPropertySet); + break; + + case TEXT_INDEX_USER: + xContext = new XMLIndexUserSourceContext( + GetImport(), xTOCPropertySet); + break; + + case TEXT_INDEX_BIBLIOGRAPHY: + xContext = new XMLIndexBibliographySourceContext( + GetImport(), xTOCPropertySet); + break; + + case TEXT_INDEX_TABLE: + xContext = new XMLIndexTableSourceContext( + GetImport(), xTOCPropertySet); + break; + + case TEXT_INDEX_ILLUSTRATION: + xContext = new XMLIndexIllustrationSourceContext( + GetImport(), xTOCPropertySet); + break; + + default: + OSL_FAIL("index type not implemented"); + break; } - // else: no text: namespace -> ignore } - // else: not valid -> ignore + // else: ignore - return xContext; + return xContext.get(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |