summaryrefslogtreecommitdiff
path: root/xmloff/source/meta
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 /xmloff/source/meta
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 'xmloff/source/meta')
-rw-r--r--xmloff/source/meta/MetaImportComponent.cxx21
-rw-r--r--xmloff/source/meta/xmlmetai.cxx121
2 files changed, 63 insertions, 79 deletions
diff --git a/xmloff/source/meta/MetaImportComponent.cxx b/xmloff/source/meta/MetaImportComponent.cxx
index d10d9c8f9bd0..6f5d7c0d1a5f 100644
--- a/xmloff/source/meta/MetaImportComponent.cxx
+++ b/xmloff/source/meta/MetaImportComponent.cxx
@@ -43,10 +43,8 @@ public:
protected:
- virtual SvXMLImportContext* CreateDocumentContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override;
+ virtual SvXMLImportContext *CreateFastContext( sal_Int32 nElement,
+ const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList >& xAttrList ) override;
// XImporter
virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
@@ -68,25 +66,22 @@ XMLMetaImportComponent::XMLMetaImportComponent(
{
}
-SvXMLImportContext* XMLMetaImportComponent::CreateDocumentContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<xml::sax::XAttributeList > & xAttrList )
+SvXMLImportContext *XMLMetaImportComponent::CreateFastContext( sal_Int32 nElement,
+ const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
{
- if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
- IsXMLToken(rLocalName, XML_DOCUMENT_META) )
+ if (nElement == XML_ELEMENT( OFFICE, XML_DOCUMENT_META ))
{
if (!mxDocProps.is()) {
throw uno::RuntimeException(
- "XMLMetaImportComponent::CreateContext: setTargetDocument "
+ "XMLMetaImportComponent::CreateFastContext: setTargetDocument "
"has not been called", *this);
}
return new SvXMLMetaDocumentContext(
- *this, nPrefix, rLocalName, mxDocProps);
+ *this, mxDocProps);
}
else
{
- return SvXMLImport::CreateDocumentContext(nPrefix, rLocalName, xAttrList);
+ return SvXMLImport::CreateFastContext(nElement, xAttrList);
}
}
diff --git a/xmloff/source/meta/xmlmetai.cxx b/xmloff/source/meta/xmlmetai.cxx
index 1f9a1b9604e2..10f60b7717dd 100644
--- a/xmloff/source/meta/xmlmetai.cxx
+++ b/xmloff/source/meta/xmlmetai.cxx
@@ -41,57 +41,66 @@ private:
css::uno::Reference< css::xml::dom::XSAXDocumentBuilder2> mxDocBuilder;
public:
- XMLDocumentBuilderContext(SvXMLImport& rImport, sal_uInt16 nPrfx,
- const OUString& rLName,
- const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList,
+ XMLDocumentBuilderContext(SvXMLImport& rImport, sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
const css::uno::Reference< css::xml::dom::XSAXDocumentBuilder2>& rDocBuilder);
- virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) override;
+ virtual void SAL_CALL characters( const OUString& aChars ) override;
- virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
+ virtual void SAL_CALL startFastElement( sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
- virtual void Characters( const OUString& rChars ) override;
+ virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
+
+ virtual void SAL_CALL startUnknownElement( const OUString& Namespace, const OUString& Name,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs ) override;
+
+ virtual void SAL_CALL endUnknownElement( const OUString& Namespace, const OUString& Name ) 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 EndElement() override;
};
XMLDocumentBuilderContext::XMLDocumentBuilderContext(SvXMLImport& rImport,
- sal_uInt16 nPrfx, const OUString& rLName,
- const uno::Reference<xml::sax::XAttributeList>&,
+ sal_Int32 /*nElement*/, const uno::Reference<xml::sax::XFastAttributeList>&,
const uno::Reference<xml::dom::XSAXDocumentBuilder2>& rDocBuilder) :
- SvXMLImportContext( rImport, nPrfx, rLName ),
+ SvXMLImportContext( rImport ),
mxDocBuilder(rDocBuilder)
{
}
-SvXMLImportContextRef
-XMLDocumentBuilderContext::CreateChildContext( sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList>& rAttrs)
+void SAL_CALL XMLDocumentBuilderContext::startFastElement( sal_Int32 nElement,
+ const uno::Reference< xml::sax::XFastAttributeList >& xAttribs )
+{
+ mxDocBuilder->startFastElement(nElement, xAttribs);
+}
+
+void SAL_CALL XMLDocumentBuilderContext::endFastElement( sal_Int32 nElement )
+{
+ mxDocBuilder->endFastElement(nElement);
+}
+
+void SAL_CALL XMLDocumentBuilderContext::startUnknownElement( const OUString& rNamespace,
+ const OUString& rName, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
{
- return new XMLDocumentBuilderContext(
- GetImport(), nPrefix, rLocalName, rAttrs, mxDocBuilder);
+ mxDocBuilder->startUnknownElement(rNamespace, rName, xAttrList);
}
-void XMLDocumentBuilderContext::StartElement(
- const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+void SAL_CALL XMLDocumentBuilderContext::endUnknownElement( const OUString& rNamespace, const OUString& rName )
{
- mxDocBuilder->startElement(
- GetImport().GetNamespaceMap().GetQNameByKey(GetPrefix(), GetLocalName()),
- xAttrList);
+ mxDocBuilder->endUnknownElement(rNamespace, rName);
}
-void XMLDocumentBuilderContext::Characters( const OUString& rChars )
+void SAL_CALL XMLDocumentBuilderContext::characters( const OUString& rChars )
{
mxDocBuilder->characters(rChars);
}
-void XMLDocumentBuilderContext::EndElement()
+uno::Reference< xml::sax::XFastContextHandler > SAL_CALL XMLDocumentBuilderContext::createFastChildContext(
+ sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
{
- mxDocBuilder->endElement(
- GetImport().GetNamespaceMap().GetQNameByKey(GetPrefix(), GetLocalName()));
+ return new XMLDocumentBuilderContext( GetImport(), nElement, xAttrList, mxDocBuilder );
}
static void
@@ -150,19 +159,6 @@ lcl_initGenerator(SvXMLImport & rImport,
}
SvXMLMetaDocumentContext::SvXMLMetaDocumentContext(SvXMLImport& rImport,
- sal_uInt16 nPrfx, const OUString& rLName,
- const uno::Reference<document::XDocumentProperties>& xDocProps) :
- SvXMLImportContext( rImport, nPrfx, rLName ),
- mxDocProps(xDocProps),
- mxDocBuilder(
- xml::dom::SAXDocumentBuilder::create(
- comphelper::getProcessComponentContext()))
-{
-// #i103539#: must always read meta.xml for generator, xDocProps unwanted then
-// OSL_ENSURE(xDocProps.is(), "SvXMLMetaDocumentContext: no document props");
-}
-
-SvXMLMetaDocumentContext::SvXMLMetaDocumentContext(SvXMLImport& rImport,
const uno::Reference<document::XDocumentProperties>& xDocProps) :
SvXMLImportContext( rImport ),
mxDocProps(xDocProps),
@@ -178,39 +174,18 @@ SvXMLMetaDocumentContext::~SvXMLMetaDocumentContext()
{
}
-SvXMLImportContextRef SvXMLMetaDocumentContext::CreateChildContext(
- sal_uInt16 nPrefix, const OUString& rLocalName,
- const uno::Reference<xml::sax::XAttributeList>& rAttrs)
-{
- if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
- IsXMLToken(rLocalName, XML_META) )
- {
- return new XMLDocumentBuilderContext(
- GetImport(), nPrefix, rLocalName, rAttrs, mxDocBuilder);
- }
- else
- {
- return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
- }
-}
-
-void SvXMLMetaDocumentContext::StartElement(
- const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+void SAL_CALL SvXMLMetaDocumentContext::startFastElement( sal_Int32 nElement,
+ const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
{
mxDocBuilder->startDocument();
// hardcode office:document-meta (necessary in case of flat file ODF)
- mxDocBuilder->startElement(
- GetImport().GetNamespaceMap().GetQNameByKey(GetPrefix(),
- GetXMLToken(XML_DOCUMENT_META)), xAttrList);
-
+ mxDocBuilder->startFastElement( ( nElement & NMSP_MASK ) | XML_DOCUMENT_META, xAttrList );
}
-void SvXMLMetaDocumentContext::EndElement()
+void SAL_CALL SvXMLMetaDocumentContext::endFastElement( sal_Int32 nElement )
{
// hardcode office:document-meta (necessary in case of flat file ODF)
- mxDocBuilder->endElement(
- GetImport().GetNamespaceMap().GetQNameByKey(GetPrefix(),
- GetXMLToken(XML_DOCUMENT_META)));
+ mxDocBuilder->endFastElement( ( nElement & NMSP_MASK ) | XML_DOCUMENT_META );
mxDocBuilder->endDocument();
if (mxDocProps.is())
{
@@ -222,6 +197,20 @@ void SvXMLMetaDocumentContext::EndElement()
}
}
+void SAL_CALL SvXMLMetaDocumentContext::characters( const OUString& /*rChars*/ )
+{
+}
+
+uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SvXMLMetaDocumentContext::createFastChildContext(
+ sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
+{
+ if ( nElement == ( NAMESPACE_TOKEN( XML_NAMESPACE_OFFICE ) | XML_META ) )
+ return new XMLDocumentBuilderContext(
+ GetImport(), nElement, xAttrList, mxDocBuilder);
+ else
+ return new SvXMLImportContext( GetImport() );
+}
+
void SvXMLMetaDocumentContext::setBuildId(OUString const& i_rBuildId, const uno::Reference<beans::XPropertySet>& xImportInfo )
{
OUString sBuildId;