reportdesign/source/filter/xml/xmlfilter.cxx |   96 ++++++++++++---------------
 reportdesign/source/filter/xml/xmlfilter.hxx |    5 -
 2 files changed, 43 insertions(+), 58 deletions(-)

New commits:
commit fc1f85127968d1c2e0a53dace51bf8a78f9e6ca5
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sun Jan 19 21:09:42 2020 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Jan 20 07:09:20 2020 +0100

    use more FastParser in ORptFilter
    
    Change-Id: I517a26a3ea64d86a1f494e3b9ea52ee28604e0b9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87046
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/reportdesign/source/filter/xml/xmlfilter.cxx 
b/reportdesign/source/filter/xml/xmlfilter.cxx
index 69d4251fc337..d6cedca1f54a 100644
--- a/reportdesign/source/filter/xml/xmlfilter.cxx
+++ b/reportdesign/source/filter/xml/xmlfilter.cxx
@@ -590,13 +590,20 @@ namespace {
 class RptXMLDocumentSettingsContext : public SvXMLImportContext
 {
 public:
-    RptXMLDocumentSettingsContext(SvXMLImport & rImport,
-           sal_uInt16 const nPrefix,
-           const OUString& rLocalName)
-        : SvXMLImportContext(rImport, nPrefix, rLocalName)
+    RptXMLDocumentSettingsContext(SvXMLImport & rImport)
+        : SvXMLImportContext(rImport)
     {
     }
 
+    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
+    {
+        return nullptr;
+    }
+
     virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 const nPrefix,
            const OUString& rLocalName,
            const uno::Reference<xml::sax::XAttributeList> & xAttrList) override
@@ -612,13 +619,20 @@ public:
 class RptXMLDocumentStylesContext : public SvXMLImportContext
 {
 public:
-    RptXMLDocumentStylesContext(SvXMLImport & rImport,
-            sal_uInt16 const nPrefix,
-            const OUString& rLocalName)
-        : SvXMLImportContext(rImport, nPrefix, rLocalName)
+    RptXMLDocumentStylesContext(SvXMLImport & rImport)
+        : SvXMLImportContext(rImport)
     {
     }
 
+    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
+    {
+        return nullptr;
+    }
+
     virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 const nPrefix,
         const OUString& rLocalName,
         const uno::Reference<xml::sax::XAttributeList> & xAttrList) override
@@ -687,13 +701,20 @@ namespace {
 class RptXMLDocumentContentContext : public SvXMLImportContext
 {
 public:
-    RptXMLDocumentContentContext(SvXMLImport & rImport,
-            sal_uInt16 const nPrefix,
-            const OUString& rLocalName)
-        : SvXMLImportContext(rImport, nPrefix, rLocalName)
+    RptXMLDocumentContentContext(SvXMLImport & rImport)
+        : SvXMLImportContext(rImport)
     {
     }
 
+    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
+    {
+        return nullptr;
+    }
+
     virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 const nPrefix,
         const OUString& rLocalName,
         const uno::Reference<xml::sax::XAttributeList> & xAttrList) override
@@ -725,30 +746,6 @@ public:
 
 }
 
-SvXMLImportContext* ORptFilter::CreateDocumentContext( sal_uInt16 nPrefix,
-                                      const OUString& rLocalName,
-                                      const uno::Reference< 
xml::sax::XAttributeList >& /*xAttrList*/ )
-{
-    SvXMLImportContext *pContext = nullptr;
-
-    const SvXMLTokenMap& rTokenMap = GetDocElemTokenMap();
-    switch( rTokenMap.Get( nPrefix, rLocalName ) )
-    {
-        case XML_TOK_DOC_SETTINGS:
-            GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
-            pContext = new RptXMLDocumentSettingsContext(*this, nPrefix, 
rLocalName);
-            break;
-        case XML_TOK_DOC_STYLES:
-            pContext = new RptXMLDocumentStylesContext(*this, nPrefix, 
rLocalName);
-            break;
-        case XML_TOK_DOC_CONTENT:
-            pContext = new RptXMLDocumentContentContext(*this, nPrefix, 
rLocalName);
-            break;
-    }
-
-    return pContext;
-}
-
 SvXMLImportContext *ORptFilter::CreateFastContext( sal_Int32 nElement,
         const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ )
 {
@@ -760,27 +757,20 @@ SvXMLImportContext *ORptFilter::CreateFastContext( 
sal_Int32 nElement,
             GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
             pContext = CreateMetaContext( nElement );
             break;
+        case XML_ELEMENT( OFFICE, XML_DOCUMENT_CONTENT ):
+            pContext = new RptXMLDocumentContentContext(*this);
+            break;
+        case XML_ELEMENT( OFFICE, XML_DOCUMENT_STYLES ):
+            pContext = new RptXMLDocumentStylesContext(*this);
+            break;
+        case XML_ELEMENT( OFFICE, XML_DOCUMENT_SETTINGS ):
+            GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
+            pContext = new RptXMLDocumentSettingsContext(*this);
+            break;
     }
     return pContext;
 }
 
-const SvXMLTokenMap& ORptFilter::GetDocElemTokenMap() const
-{
-    if (!m_pDocElemTokenMap)
-    {
-        static const SvXMLTokenMapEntry aElemTokenMap[]=
-        {
-            { XML_NAMESPACE_OFFICE, XML_DOCUMENT_SETTINGS,  
XML_TOK_DOC_SETTINGS    },
-            { XML_NAMESPACE_OFFICE, XML_DOCUMENT_CONTENT,   
XML_TOK_DOC_CONTENT     },
-            { XML_NAMESPACE_OFFICE, XML_DOCUMENT_STYLES,    XML_TOK_DOC_STYLES 
     },
-            { XML_NAMESPACE_OFFICE, XML_DOCUMENT_META,      XML_TOK_DOC_META   
     },
-            XML_TOKEN_MAP_END
-        };
-        m_pDocElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
-    }
-    return *m_pDocElemTokenMap;
-}
-
 const SvXMLTokenMap& ORptFilter::GetDocContentElemTokenMap() const
 {
     if (!m_pDocContentElemTokenMap)
diff --git a/reportdesign/source/filter/xml/xmlfilter.hxx 
b/reportdesign/source/filter/xml/xmlfilter.hxx
index 266198f46bfb..995a7268e149 100644
--- a/reportdesign/source/filter/xml/xmlfilter.hxx
+++ b/reportdesign/source/filter/xml/xmlfilter.hxx
@@ -101,10 +101,6 @@ public:
             const css::uno::Reference< css::xml::sax::XAttributeList > & 
xAttrList );
 protected:
     // SvXMLImport
-    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;
 
@@ -133,7 +129,6 @@ public:
     virtual void SAL_CALL startDocument() override;
     virtual void SAL_CALL endDocument() override;
 
-    const SvXMLTokenMap& GetDocElemTokenMap() const;
     const SvXMLTokenMap& GetDocContentElemTokenMap() const;
     const SvXMLTokenMap& GetReportElemTokenMap() const;
     const SvXMLTokenMap& GetGroupElemTokenMap() const;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to