summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorDaniel Sikeler <d.sikeler94@gmail.com>2014-10-24 07:22:31 +0000
committerMatúš Kukan <matus.kukan@collabora.com>2014-10-31 09:22:30 +0100
commitc0a5d390e519603dbc19a38c610d0a114b80cfa1 (patch)
treee68c3f55c9718d2d3f290be154c83a5a6121a6fc /xmloff
parent4482f50197f8787f8e187def2cc96758e3c31800 (diff)
fdo#80403: Import baseclasses implement FastParser interfaces
SvXMLImportContext implements XFastContextHandler SvXMLImport implements XFastDocumentHandler Change-Id: Id400260af112f4a448fe469c9580f0ebacec4ab6
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/core/xmlictxt.cxx47
-rw-r--r--xmloff/source/core/xmlimp.cxx77
2 files changed, 124 insertions, 0 deletions
diff --git a/xmloff/source/core/xmlictxt.cxx b/xmloff/source/core/xmlictxt.cxx
index 6b7f257adfe6..8340a071ae07 100644
--- a/xmloff/source/core/xmlictxt.cxx
+++ b/xmloff/source/core/xmlictxt.cxx
@@ -39,6 +39,12 @@ SvXMLImportContext::SvXMLImportContext( SvXMLImport& rImp, sal_uInt16 nPrfx,
{
}
+SvXMLImportContext::SvXMLImportContext( SvXMLImport& rImp ) :
+ mrImport( rImp ),
+ mpRewindMap( 0 )
+{
+}
+
SvXMLImportContext::~SvXMLImportContext()
{
}
@@ -62,6 +68,47 @@ void SvXMLImportContext::Characters( const OUString& )
{
}
+// ::com::sun::star::xml::sax::XFastContextHandler:
+void SAL_CALL SvXMLImportContext::startFastElement(sal_Int32, const uno::Reference< xml::sax::XFastAttributeList > &)
+ throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
+{
+}
+
+void SAL_CALL SvXMLImportContext::startUnknownElement(const OUString &, const OUString &,
+ const uno::Reference< xml::sax::XFastAttributeList > &)
+ throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
+{
+}
+
+void SAL_CALL SvXMLImportContext::endFastElement(sal_Int32)
+ throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
+{
+}
+
+void SAL_CALL SvXMLImportContext::endUnknownElement (const OUString & , const OUString & )
+ throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
+{
+}
+
+uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SvXMLImportContext::createFastChildContext
+ (sal_Int32 Element, const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
+ throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
+{
+ return mrImport.CreateFastContext( Element, Attribs );
+}
+
+uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SvXMLImportContext::createUnknownChildContext
+ (const OUString &, const OUString &, const uno::Reference< xml::sax::XFastAttributeList > &)
+ throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
+{
+ return 0;
+}
+
+void SAL_CALL SvXMLImportContext::characters(const OUString &)
+ throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
+{
+}
+
void SvXMLImportContext::onDemandRescueUsefulDataFromTemporary( const SvXMLImportContext& )
{
}
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index 97df9ab5aaba..d688e8fe837b 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -346,6 +346,12 @@ SvXMLImportContext *SvXMLImport::CreateContext( sal_uInt16 nPrefix,
return new SvXMLImportContext( *this, nPrefix, rLocalName );
}
+SvXMLImportContext *SvXMLImport::CreateFastContext( sal_Int32 /*Element*/,
+ const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ )
+{
+ return new SvXMLImportContext( *this );
+}
+
void SvXMLImport::_InitCtor()
{
if( mnImportFlags != 0 )
@@ -415,6 +421,7 @@ SvXMLImport::SvXMLImport(
util::MeasureUnit::MM_100TH, util::MeasureUnit::MM_100TH) ),
mpContexts( new SvXMLImportContexts_Impl ),
+ mpFastContexts( new FastSvXMLImportContexts_Impl ),
mpNumImport( NULL ),
mpProgressBarHelper( NULL ),
mpEventImportHelper( NULL ),
@@ -780,6 +787,10 @@ void SAL_CALL SvXMLImport::characters( const OUString& rChars )
{
mpContexts->back()->Characters( rChars );
}
+ else if ( !mpFastContexts->empty() )
+ {
+ mpFastContexts->back()->characters( rChars );
+ }
}
void SAL_CALL SvXMLImport::ignorableWhitespace( const OUString& )
@@ -799,6 +810,72 @@ void SAL_CALL SvXMLImport::setDocumentLocator( const uno::Reference< xml::sax::X
mxLocator = rLocator;
}
+// XFastContextHandler
+void SAL_CALL SvXMLImport::startFastElement (sal_Int32 Element,
+ const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
+ throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
+{
+ //Namespace handling is unnecessary. It is done by the fastparser itself.
+ uno::Reference<XFastContextHandler> xContext;
+ sal_uInt16 nCount = mpFastContexts->size();
+ if( nCount > 0 )
+ {
+ uno::Reference< XFastContextHandler > pHandler = (*mpFastContexts)[nCount - 1];
+ xContext = pHandler->createFastChildContext( Element, Attribs );
+ }
+ else
+ xContext.set( CreateFastContext( Element, Attribs ) );
+
+ if ( !xContext.is() )
+ xContext.set( new SvXMLImportContext( *this ) );
+
+ // Call a startElement at the new context.
+ xContext->startFastElement( Element, Attribs );
+
+ // Push context on stack.
+ mpFastContexts->push_back( xContext );
+}
+
+void SAL_CALL SvXMLImport::startUnknownElement (const OUString &, const OUString &,
+ const uno::Reference< xml::sax::XFastAttributeList > &)
+ throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
+{
+}
+
+void SAL_CALL SvXMLImport::endFastElement (sal_Int32 Element)
+ throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
+{
+ sal_uInt16 nCount = mpFastContexts->size();
+ if( nCount > 0 )
+ {
+ uno::Reference< XFastContextHandler > xContext = mpFastContexts->back();
+ mpFastContexts->pop_back();
+ xContext->endFastElement( Element );
+ xContext = 0;
+ }
+}
+
+void SAL_CALL SvXMLImport::endUnknownElement (const OUString &, const OUString &)
+ throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
+{
+}
+
+uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
+ SvXMLImport::createFastChildContext (sal_Int32,
+ const uno::Reference< xml::sax::XFastAttributeList > &)
+ throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
+{
+ return this;
+}
+
+uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
+ SvXMLImport::createUnknownChildContext (const OUString &, const OUString &,
+ const uno::Reference< xml::sax::XFastAttributeList > &)
+ throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
+{
+ return this;
+}
+
// XExtendedDocumentHandler
void SAL_CALL SvXMLImport::startCDATA( void ) throw(xml::sax::SAXException, uno::RuntimeException, std::exception)
{