summaryrefslogtreecommitdiff
path: root/sw/source/filter/xml/xmlimp.cxx
diff options
context:
space:
mode:
authorMohammed Abdul Azeem <azeemmysore@gmail.com>2017-10-01 14:11:11 +0530
committerMichael Meeks <michael.meeks@collabora.com>2018-03-14 14:12:08 +0100
commitbf46b46a1d734348096936284fb8a76e977936d0 (patch)
treea76c30897cf1e49491bf26580c823701b6d74778 /sw/source/filter/xml/xmlimp.cxx
parent1b61d0417bf46896ef1f1bd1e1a8209588fc157a (diff)
Moving XSAXDocumentBuilder2 to use XFastDocumentHandler:
This is used in parsing of meta Contexts across different modules. This also involved moving to XFastParser for parsing xml filters in sw, sd, starmath. Change-Id: Ic663aaac6cb20ee8ce5b97cae87c93220f5a2929 Reviewed-on: https://gerrit.libreoffice.org/42989 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sw/source/filter/xml/xmlimp.cxx')
-rw-r--r--sw/source/filter/xml/xmlimp.cxx90
1 files changed, 53 insertions, 37 deletions
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index 01460f6fe4c5..1a4988339d5a 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -196,9 +196,14 @@ public:
SwXMLDocContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx,
const OUString& rLName );
+ SwXMLDocContext_Impl( SwXMLImport& rImport );
+
virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix,
const OUString& rLocalName,
const Reference< 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;
};
SwXMLDocContext_Impl::SwXMLDocContext_Impl( SwXMLImport& rImport,
@@ -207,6 +212,17 @@ SwXMLDocContext_Impl::SwXMLDocContext_Impl( SwXMLImport& rImport,
{
}
+SwXMLDocContext_Impl::SwXMLDocContext_Impl( SwXMLImport& rImport ) :
+ SvXMLImportContext( rImport )
+{
+}
+
+uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SwXMLDocContext_Impl::createFastChildContext(
+ sal_Int32 /*nElement*/, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ )
+{
+ return new SvXMLImportContext( GetImport() );
+}
+
SvXMLImportContextRef SwXMLDocContext_Impl::CreateChildContext(
sal_uInt16 nPrefix,
const OUString& rLocalName,
@@ -271,51 +287,41 @@ class SwXMLOfficeDocContext_Impl :
public:
SwXMLOfficeDocContext_Impl( SwXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLName,
const Reference< document::XDocumentProperties >& xDocProps);
- virtual SvXMLImportContextRef CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const Reference< 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 >& Attribs ) override;
};
SwXMLOfficeDocContext_Impl::SwXMLOfficeDocContext_Impl(
SwXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLName,
const Reference< document::XDocumentProperties >& xDocProps) :
- SvXMLImportContext( rImport, nPrfx, rLName ),
- SwXMLDocContext_Impl( rImport, nPrfx, rLName ),
- SvXMLMetaDocumentContext( rImport, nPrfx, rLName, xDocProps)
+ SvXMLImportContext( rImport ),
+ SwXMLDocContext_Impl( rImport ),
+ SvXMLMetaDocumentContext( rImport, xDocProps )
{
}
-SvXMLImportContextRef SwXMLOfficeDocContext_Impl::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const Reference< xml::sax::XAttributeList > & xAttrList )
+uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SwXMLOfficeDocContext_Impl::createFastChildContext(
+ sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
{
- const SvXMLTokenMap& rTokenMap = GetSwImport().GetDocElemTokenMap();
-
// assign paragraph styles to list levels of outline style after all styles
// are imported and finished. This is the case, when <office:body> starts
// in flat OpenDocument file format.
{
- if ( rTokenMap.Get( nPrefix, rLocalName ) == XML_TOK_DOC_BODY )
+ if( nElement == XML_ELEMENT( OFFICE, XML_BODY ) )
{
GetImport().GetTextImport()->SetOutlineStyles( true );
}
}
// behave like meta base class iff we encounter office:meta
- if ( XML_TOK_DOC_META == rTokenMap.Get( nPrefix, rLocalName ) ) {
- return SvXMLMetaDocumentContext::CreateChildContext(
- nPrefix, rLocalName, xAttrList );
+ if ( nElement == XML_ELEMENT( OFFICE, XML_META ) ) {
+ return SvXMLMetaDocumentContext::createFastChildContext(
+ nElement, xAttrList );
} else {
- return SwXMLDocContext_Impl::CreateChildContext(
- nPrefix, rLocalName, xAttrList );
+ return SwXMLDocContext_Impl::createFastChildContext(
+ nElement, xAttrList );
}
}
@@ -370,30 +376,40 @@ SvXMLImportContext *SwXMLImport::CreateDocumentContext(
IsXMLToken( rLocalName, XML_DOCUMENT_CONTENT ) ))
pContext = new SwXMLDocContext_Impl( *this, nPrefix, rLocalName );
else if ( XML_NAMESPACE_OFFICE==nPrefix &&
- IsXMLToken( rLocalName, XML_DOCUMENT_META ) )
- {
- pContext = CreateMetaContext(rLocalName);
- }
- else if ( XML_NAMESPACE_OFFICE==nPrefix &&
IsXMLToken( rLocalName, XML_DOCUMENT_STYLES ) )
{
pContext = new SwXMLDocStylesContext_Impl( *this, nPrefix, rLocalName );
}
- else if ( XML_NAMESPACE_OFFICE==nPrefix &&
- IsXMLToken( rLocalName, XML_DOCUMENT ) )
- {
- uno::Reference<document::XDocumentProperties> const xDocProps(
- GetDocumentProperties());
- // flat OpenDocument file format
- pContext = new SwXMLOfficeDocContext_Impl( *this, nPrefix, rLocalName,
- xDocProps);
- }
else
pContext = SvXMLImport::CreateDocumentContext(nPrefix, rLocalName, xAttrList);
return pContext;
}
+SvXMLImportContext *SwXMLImport::CreateFastContext( sal_Int32 nElement,
+ const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ )
+{
+ SvXMLImportContext *pContext = nullptr;
+
+ switch (nElement)
+ {
+ case XML_ELEMENT( OFFICE, XML_DOCUMENT_META ):
+ pContext = CreateMetaContext(nElement);
+ break;
+ case XML_ELEMENT( OFFICE, XML_DOCUMENT ):
+ {
+ uno::Reference<document::XDocumentProperties> const xDocProps(
+ GetDocumentProperties());
+ // flat OpenDocument file format
+ pContext = new SwXMLOfficeDocContext_Impl( *this, xDocProps );
+ }
+ break;
+ default:
+ pContext = new SvXMLImportContext( *this );
+ }
+ return pContext;
+}
+
SwXMLImport::SwXMLImport(
const uno::Reference< uno::XComponentContext >& rContext,
OUString const & implementationName, SvXMLImportFlags nImportFlags)