[Libreoffice-commits] core.git: include/oox oox/source sc/source

Noel Grandin noel.grandin at collabora.co.uk
Tue Jan 24 08:27:41 UTC 2017


 include/oox/core/fastparser.hxx           |   17 ++++++++---------
 include/oox/core/xmlfilterbase.hxx        |    2 +-
 oox/source/core/fastparser.cxx            |    8 +++-----
 oox/source/core/filterdetect.cxx          |    2 +-
 oox/source/core/xmlfilterbase.cxx         |    7 +++----
 oox/source/docprop/ooxmldocpropimport.cxx |    2 +-
 sc/source/filter/oox/revisionfragment.cxx |    2 +-
 sc/source/filter/oox/workbookfragment.cxx |    4 ++--
 8 files changed, 20 insertions(+), 24 deletions(-)

New commits:
commit a449e0d2425fdedc02fae793a925dd0702d70319
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Jan 24 10:26:23 2017 +0200

    use rtl::Reference in FastParser
    
    instead of storing both a raw pointer and a uno::Reference
    
    Change-Id: I6b67a6098a3ccdce7e29ee8d601c743897032eaf

diff --git a/include/oox/core/fastparser.hxx b/include/oox/core/fastparser.hxx
index 69cc111..d28e724 100644
--- a/include/oox/core/fastparser.hxx
+++ b/include/oox/core/fastparser.hxx
@@ -26,6 +26,7 @@
 #include <com/sun/star/uno/RuntimeException.hpp>
 #include <com/sun/star/xml/sax/SAXException.hpp>
 #include <rtl/ustring.hxx>
+#include <rtl/ref.hxx>
 #include <sal/types.h>
 
 namespace com { namespace sun { namespace star {
@@ -57,10 +58,12 @@ class FastParser
 {
 public:
     /// @throws css::uno::RuntimeException
-    explicit            FastParser(
-                            const css::uno::Reference< css::uno::XComponentContext >& rxContext )
+    explicit            FastParser()
                             throw( css::uno::RuntimeException );
 
+                        FastParser(const FastParser&) = delete;
+                        FastParser& operator=(const FastParser&) = delete;
+
     virtual             ~FastParser();
 
     /** Registers an OOXML namespace at the parser.
@@ -110,13 +113,9 @@ public:
                getTokenHandler() const { return mxTokenHandler; }
 
 private:
-    css::uno::Reference< css::xml::sax::XFastParser >
-                        mxParser;
-    css::uno::Reference< css::xml::sax::XFastTokenHandler >
-                        mxTokenHandler;
-    const NamespaceMap& mrNamespaceMap;
-
-    sax_fastparser::FastSaxParser* mpParser;
+    css::uno::Reference<css::xml::sax::XFastTokenHandler>   mxTokenHandler;
+    const NamespaceMap&                                     mrNamespaceMap;
+    rtl::Reference<sax_fastparser::FastSaxParser>           mxParser;
 };
 
 
diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx
index c9769d7..5149783 100644
--- a/include/oox/core/xmlfilterbase.hxx
+++ b/include/oox/core/xmlfilterbase.hxx
@@ -230,7 +230,7 @@ public:
 
     void importDocumentProperties();
 
-    FastParser* createParser() const;
+    static FastParser* createParser();
 
     bool isMSO2007Document() const;
 
diff --git a/oox/source/core/fastparser.cxx b/oox/source/core/fastparser.cxx
index 54b07b1..ce0a6c0 100644
--- a/oox/source/core/fastparser.cxx
+++ b/oox/source/core/fastparser.cxx
@@ -63,13 +63,11 @@ InputStreamCloseGuard::~InputStreamCloseGuard()
 
 } // namespace
 
-FastParser::FastParser( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) :
-    mrNamespaceMap( StaticNamespaceMap::get() ),
-    mpParser(nullptr)
+FastParser::FastParser() throw( RuntimeException ) :
+    mrNamespaceMap( StaticNamespaceMap::get() )
 {
     // create a fast parser instance
-    mxParser = css::xml::sax::FastParser::create(rxContext);
-    mpParser = dynamic_cast<sax_fastparser::FastSaxParser*>(mxParser.get());
+    mxParser = new sax_fastparser::FastSaxParser;
 
     // create the fast tokenhandler
     mxTokenHandler.set( new FastTokenHandler );
diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx
index f7a8f81..c333db3 100644
--- a/oox/source/core/filterdetect.cxx
+++ b/oox/source/core/filterdetect.cxx
@@ -403,7 +403,7 @@ OUString SAL_CALL FilterDetect::detect( Sequence< PropertyValue >& rMediaDescSeq
         if( aZipStorage.isStorage() )
         {
             // create the fast parser, register the XML namespaces, set document handler
-            FastParser aParser( mxContext );
+            FastParser aParser;
             aParser.registerNamespace( NMSP_packageRel );
             aParser.registerNamespace( NMSP_officeRel );
             aParser.registerNamespace( NMSP_packageContentTypes );
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index 48da8c7..21f0b50 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -188,7 +188,6 @@ struct XmlFilterBaseImpl
 
 XmlFilterBaseImpl::XmlFilterBaseImpl( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) :
     mxContext(rxContext),
-    maFastParser( rxContext ),
     maBinSuffix( ".bin" ),
     mrNamespaceMap(StaticNamespaceMap::get())
 {
@@ -268,9 +267,9 @@ void XmlFilterBase::importDocumentProperties()
     checkDocumentProperties(xDocProps);
 }
 
-FastParser* XmlFilterBase::createParser() const
+FastParser* XmlFilterBase::createParser()
 {
-    FastParser* pParser = new FastParser(getComponentContext());
+    FastParser* pParser = new FastParser;
     registerNamespaces(*pParser);
     return pParser;
 }
@@ -305,7 +304,7 @@ OUString XmlFilterBase::getFragmentPathFromFirstTypeFromOfficeDoc( const OUStrin
 
 bool XmlFilterBase::importFragment( const rtl::Reference<FragmentHandler>& rxHandler )
 {
-    FastParser aParser(mxImpl->mxContext);
+    FastParser aParser;
     registerNamespaces(aParser);
     return importFragment(rxHandler, aParser);
 }
diff --git a/oox/source/docprop/ooxmldocpropimport.cxx b/oox/source/docprop/ooxmldocpropimport.cxx
index 1aa4c4a..2d78d30 100644
--- a/oox/source/docprop/ooxmldocpropimport.cxx
+++ b/oox/source/docprop/ooxmldocpropimport.cxx
@@ -159,7 +159,7 @@ void SAL_CALL DocumentPropertiesImport::importProperties(
         if( aCoreStreams.getLength() > 1 )
             throw IOException( "Unexpected core properties stream!" );
 
-        ::oox::core::FastParser aParser( mxContext );
+        ::oox::core::FastParser aParser;
         aParser.registerNamespace( NMSP_packageMetaCorePr );
         aParser.registerNamespace( NMSP_dc );
         aParser.registerNamespace( NMSP_dcTerms );
diff --git a/sc/source/filter/oox/revisionfragment.cxx b/sc/source/filter/oox/revisionfragment.cxx
index 928d71ec..6708b4e3 100644
--- a/sc/source/filter/oox/revisionfragment.cxx
+++ b/sc/source/filter/oox/revisionfragment.cxx
@@ -265,7 +265,7 @@ void RevisionHeadersFragment::finalizeImport()
         const RevisionMetadata& rData = it->second;
         pCT->SetUser(rData.maUserName);
         pCT->SetFixDateTimeLocal(rData.maDateTime);
-        std::unique_ptr<oox::core::FastParser> xParser(getOoxFilter().createParser());
+        std::unique_ptr<oox::core::FastParser> xParser(oox::core::XmlFilterBase::createParser());
         rtl::Reference<oox::core::FragmentHandler> xFragment(new RevisionLogFragment(*this, aPath, *pCT));
         importOoxFragment(xFragment, *xParser);
     }
diff --git a/sc/source/filter/oox/workbookfragment.cxx b/sc/source/filter/oox/workbookfragment.cxx
index add959c..bf19e87 100644
--- a/sc/source/filter/oox/workbookfragment.cxx
+++ b/sc/source/filter/oox/workbookfragment.cxx
@@ -244,7 +244,7 @@ public:
         SAL_INFO( "sc.filter",  "got solar\n" );
 
         std::unique_ptr<oox::core::FastParser> xParser(
-                mrWorkbookHandler.getOoxFilter().createParser() );
+                oox::core::XmlFilterBase::createParser() );
 
         SAL_INFO( "sc.filter",  "start import\n" );
         mrWorkbookHandler.importOoxFragment( mxHandler, *xParser );
@@ -504,7 +504,7 @@ void WorkbookFragment::finalizeImport()
     OUString aRevHeadersPath = getFragmentPathFromFirstType(CREATE_OFFICEDOC_RELATION_TYPE("revisionHeaders"));
     if (!aRevHeadersPath.isEmpty())
     {
-        std::unique_ptr<oox::core::FastParser> xParser(getOoxFilter().createParser());
+        std::unique_ptr<oox::core::FastParser> xParser(oox::core::XmlFilterBase::createParser());
         rtl::Reference<oox::core::FragmentHandler> xFragment(new RevisionHeadersFragment(*this, aRevHeadersPath));
         importOoxFragment(xFragment, *xParser);
     }


More information about the Libreoffice-commits mailing list