use FastParser for SchXMLImport
Change-Id: Ib43f109dce8226d29b19c141010e4480147933ad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86825 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
parent
b43f64f430
commit
dde274e70c
4 changed files with 44 additions and 94 deletions
|
@ -152,11 +152,6 @@ class SchXMLImport final : public SvXMLImport
|
|||
private:
|
||||
rtl::Reference<SchXMLImportHelper> maImportHelper;
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -498,38 +498,6 @@ SchXMLImport::~SchXMLImport() throw ()
|
|||
|
||||
// create the main context (subcontexts are created
|
||||
// by the one created here)
|
||||
SvXMLImportContext *SchXMLImport::CreateDocumentContext(sal_uInt16 const nPrefix,
|
||||
const OUString& rLocalName,
|
||||
const Reference< xml::sax::XAttributeList >& xAttrList )
|
||||
{
|
||||
SvXMLImportContext* pContext = nullptr;
|
||||
|
||||
// accept <office:document>
|
||||
if( XML_NAMESPACE_OFFICE == nPrefix &&
|
||||
( IsXMLToken( rLocalName, XML_DOCUMENT_STYLES) ||
|
||||
IsXMLToken( rLocalName, XML_DOCUMENT_CONTENT) ))
|
||||
{
|
||||
pContext = new SchXMLDocContext(*maImportHelper, *this, nPrefix, rLocalName);
|
||||
} else if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
|
||||
( IsXMLToken(rLocalName, XML_DOCUMENT) ||
|
||||
(IsXMLToken(rLocalName, XML_DOCUMENT_META)
|
||||
&& (getImportFlags() & SvXMLImportFlags::META) )) )
|
||||
{
|
||||
uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
|
||||
GetModel(), uno::UNO_QUERY);
|
||||
// mst@: right now, this seems to be not supported, so it is untested
|
||||
if (!xDPS.is()) {
|
||||
pContext = (IsXMLToken(rLocalName, XML_DOCUMENT_META))
|
||||
? SvXMLImport::CreateDocumentContext(nPrefix, rLocalName, xAttrList)
|
||||
: new SchXMLDocContext(*maImportHelper, *this, nPrefix, rLocalName);
|
||||
}
|
||||
} else {
|
||||
pContext = SvXMLImport::CreateDocumentContext(nPrefix, rLocalName, xAttrList);
|
||||
}
|
||||
|
||||
return pContext;
|
||||
}
|
||||
|
||||
SvXMLImportContext *SchXMLImport::CreateFastContext( sal_Int32 nElement,
|
||||
const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ )
|
||||
{
|
||||
|
@ -552,7 +520,11 @@ SvXMLImportContext *SchXMLImport::CreateFastContext( sal_Int32 nElement,
|
|||
}
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
// accept <office:document>
|
||||
case XML_ELEMENT(OFFICE, XML_DOCUMENT_STYLES):
|
||||
case XML_ELEMENT(OFFICE, XML_DOCUMENT_CONTENT):
|
||||
pContext = new SchXMLDocContext(*maImportHelper, *this, nElement);
|
||||
break;
|
||||
}
|
||||
return pContext;
|
||||
}
|
||||
|
|
|
@ -41,45 +41,28 @@ private:
|
|||
public:
|
||||
|
||||
SchXMLBodyContext_Impl( SchXMLImportHelper& rImpHelper,
|
||||
SvXMLImport& rImport, sal_uInt16 nPrfx,
|
||||
const OUString& rLName );
|
||||
SvXMLImport& rImport );
|
||||
|
||||
virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix,
|
||||
const OUString& rLocalName,
|
||||
const uno::Reference< xml::sax::XAttributeList > & xAttrList ) override;
|
||||
virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/,
|
||||
const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) 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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
SchXMLBodyContext_Impl::SchXMLBodyContext_Impl(
|
||||
SchXMLImportHelper& rImpHelper, SvXMLImport& rImport,
|
||||
sal_uInt16 nPrfx, const OUString& rLName ) :
|
||||
SvXMLImportContext( rImport, nPrfx, rLName ),
|
||||
SchXMLImportHelper& rImpHelper, SvXMLImport& rImport ) :
|
||||
SvXMLImportContext( rImport ),
|
||||
mrImportHelper( rImpHelper )
|
||||
{
|
||||
}
|
||||
|
||||
SvXMLImportContextRef SchXMLBodyContext_Impl::CreateChildContext(
|
||||
sal_uInt16 nPrefix,
|
||||
const OUString& rLocalName,
|
||||
const uno::Reference< xml::sax::XAttributeList > & )
|
||||
uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SchXMLBodyContext_Impl::createFastChildContext(
|
||||
sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ )
|
||||
{
|
||||
return new SchXMLBodyContext( mrImportHelper, GetImport(), nPrefix,
|
||||
rLocalName );
|
||||
}
|
||||
|
||||
SchXMLDocContext::SchXMLDocContext( SchXMLImportHelper& rImpHelper,
|
||||
SvXMLImport& rImport,
|
||||
sal_uInt16 nPrefix,
|
||||
const OUString& rLName ) :
|
||||
SvXMLImportContext( rImport, nPrefix, rLName ),
|
||||
mrImportHelper( rImpHelper )
|
||||
{
|
||||
SAL_WARN_IF( (XML_NAMESPACE_OFFICE != nPrefix) ||
|
||||
( !IsXMLToken( rLName, XML_DOCUMENT ) &&
|
||||
!IsXMLToken( rLName, XML_DOCUMENT_META) &&
|
||||
!IsXMLToken( rLName, XML_DOCUMENT_STYLES) &&
|
||||
!IsXMLToken( rLName, XML_DOCUMENT_CONTENT) ), "xmloff.chart", "SchXMLDocContext instantiated with no <office:document> element" );
|
||||
return new SchXMLBodyContext( mrImportHelper, GetImport(), nElement );
|
||||
}
|
||||
|
||||
SchXMLDocContext::SchXMLDocContext( SchXMLImportHelper& rImpHelper,
|
||||
|
@ -126,22 +109,21 @@ SvXMLImportContextRef SchXMLDocContext::CreateChildContext(
|
|||
// if XDocumentPropertiesSupplier is not supported at the model
|
||||
xContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
|
||||
break;
|
||||
case XML_TOK_DOC_BODY:
|
||||
if( nFlags & SvXMLImportFlags::CONTENT )
|
||||
xContext = new SchXMLBodyContext_Impl( mrImportHelper, GetImport(), nPrefix, rLocalName );
|
||||
break;
|
||||
}
|
||||
|
||||
// call parent when no own context was created
|
||||
if (!xContext)
|
||||
xContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
|
||||
|
||||
return xContext;
|
||||
}
|
||||
|
||||
uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SchXMLDocContext::createFastChildContext(
|
||||
sal_Int32 /*nElement*/, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ )
|
||||
sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ )
|
||||
{
|
||||
SvXMLImportFlags nFlags = GetImport().getImportFlags();
|
||||
switch (nElement)
|
||||
{
|
||||
case XML_ELEMENT(OFFICE, XML_BODY):
|
||||
if( nFlags & SvXMLImportFlags::CONTENT )
|
||||
return new SchXMLBodyContext_Impl( mrImportHelper, GetImport() );
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -171,20 +153,20 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SchXMLFlatDocContext_Im
|
|||
|
||||
SchXMLBodyContext::SchXMLBodyContext( SchXMLImportHelper& rImpHelper,
|
||||
SvXMLImport& rImport,
|
||||
sal_uInt16 nPrefix,
|
||||
const OUString& rLName ) :
|
||||
SvXMLImportContext( rImport, nPrefix, rLName ),
|
||||
sal_Int32 nElement ) :
|
||||
SvXMLImportContext( rImport ),
|
||||
mrImportHelper( rImpHelper )
|
||||
{
|
||||
SAL_WARN_IF( (XML_NAMESPACE_OFFICE != nPrefix) ||
|
||||
!IsXMLToken( rLName, XML_CHART ), "xmloff.chart", "SchXMLBodyContext instantiated with no <office:chart> element" );
|
||||
SAL_WARN_IF( nElement != XML_ELEMENT(OFFICE, XML_CHART), "xmloff.chart", "SchXMLBodyContext instantiated with no <office:chart> element" );
|
||||
}
|
||||
|
||||
SchXMLBodyContext::~SchXMLBodyContext()
|
||||
{}
|
||||
|
||||
void SchXMLBodyContext::EndElement()
|
||||
css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLBodyContext::createFastChildContext(
|
||||
sal_Int32 /*nElement*/, const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ )
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SvXMLImportContextRef SchXMLBodyContext::CreateChildContext(
|
||||
|
@ -209,10 +191,6 @@ SvXMLImportContextRef SchXMLBodyContext::CreateChildContext(
|
|||
// i99104 handle null date correctly
|
||||
xContext = new SchXMLCalculationSettingsContext ( GetImport(), nPrefix, rLocalName, xAttrList);
|
||||
}
|
||||
else
|
||||
{
|
||||
xContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
|
||||
}
|
||||
|
||||
return xContext;
|
||||
}
|
||||
|
|
|
@ -40,12 +40,6 @@ protected:
|
|||
SchXMLImportHelper& mrImportHelper;
|
||||
|
||||
public:
|
||||
SchXMLDocContext(
|
||||
SchXMLImportHelper& rImpHelper,
|
||||
SvXMLImport& rImport,
|
||||
sal_uInt16 nPrefix,
|
||||
const OUString& rLName );
|
||||
|
||||
SchXMLDocContext(
|
||||
SchXMLImportHelper& rImpHelper,
|
||||
SvXMLImport& rImport,
|
||||
|
@ -53,6 +47,9 @@ public:
|
|||
|
||||
virtual ~SchXMLDocContext() override;
|
||||
|
||||
virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/,
|
||||
const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {}
|
||||
|
||||
virtual SvXMLImportContextRef CreateChildContext(
|
||||
sal_uInt16 nPrefix,
|
||||
const OUString& rLocalName,
|
||||
|
@ -73,6 +70,10 @@ public:
|
|||
sal_Int32 i_nElement,
|
||||
const css::uno::Reference<css::document::XDocumentProperties>& i_xDocProps);
|
||||
|
||||
virtual void SAL_CALL startFastElement( sal_Int32 nElement,
|
||||
const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override
|
||||
{ SvXMLMetaDocumentContext::startFastElement(nElement, xAttrList); }
|
||||
|
||||
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
|
||||
sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
|
||||
};
|
||||
|
@ -86,11 +87,15 @@ public:
|
|||
SchXMLBodyContext(
|
||||
SchXMLImportHelper& rImpHelper,
|
||||
SvXMLImport& rImport,
|
||||
sal_uInt16 nPrefix,
|
||||
const OUString& rLName );
|
||||
sal_Int32 nElement );
|
||||
virtual ~SchXMLBodyContext() override;
|
||||
|
||||
virtual void EndElement() override;
|
||||
virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/,
|
||||
const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) 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 SvXMLImportContextRef CreateChildContext(
|
||||
sal_uInt16 nPrefix,
|
||||
const OUString& rLocalName,
|
||||
|
|
Loading…
Reference in a new issue