[Libreoffice-commits] core.git: 4 commits - include/oox include/sax oox/Library_oox.mk oox/source sax/Library_fastsax.mk sax/source

Kohei Yoshida kohei.yoshida at collabora.com
Mon Dec 2 16:31:39 PST 2013


 include/oox/core/fastparser.hxx      |   12 +
 include/oox/core/xmlfilterbase.hxx   |    2 
 include/sax/fastparser.hxx           |  180 +++++++++++++++++++++++++++
 oox/Library_oox.mk                   |    1 
 oox/source/core/fastparser.cxx       |   17 ++
 oox/source/core/fragmenthandler2.cxx |    6 
 oox/source/core/xmlfilterbase.cxx    |    5 
 sax/Library_fastsax.mk               |    1 
 sax/source/fastparser/facreg.cxx     |   81 ------------
 sax/source/fastparser/fastparser.cxx |  222 +++++++++++++++++++++++++++------
 sax/source/fastparser/fastparser.hxx |  233 -----------------------------------
 11 files changed, 403 insertions(+), 357 deletions(-)

New commits:
commit 532b2f48185c9ee3f389f1a3fbdfffcf113c15c0
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Dec 2 19:20:59 2013 -0500

    Add a means to check if a namespace exists.
    
    Useful when we just need to check if the stream has a certain namespace
    defined. Calling getNamespaceURL() may throw SAXException in such case.
    
    Change-Id: Ib2b7b202492390158270d87bab95d1793c9d8a70

diff --git a/include/oox/core/fastparser.hxx b/include/oox/core/fastparser.hxx
index fd98241..a673217 100644
--- a/include/oox/core/fastparser.hxx
+++ b/include/oox/core/fastparser.hxx
@@ -75,10 +75,12 @@ public:
     void                parseStream( StorageBase& rStorage, const OUString& rStreamName, bool bCloseStream = false )
                             throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException );
 
-     OUString getNamespaceURL( const OUString& rPrefix )
+    OUString getNamespaceURL( const OUString& rPrefix )
                         throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
 
-     sal_Int32 getNamespaceId( const OUString& aUrl );
+    bool hasNamespaceURL( const OUString& rPrefix ) const;
+
+    sal_Int32 getNamespaceId( const OUString& aUrl );
 
     ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastTokenHandler >
                getTokenHandler() const { return mxTokenHandler; }
diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx
index 76eb091..604f220 100644
--- a/include/oox/core/xmlfilterbase.hxx
+++ b/include/oox/core/xmlfilterbase.hxx
@@ -227,6 +227,8 @@ public:
 
     OUString getNamespaceURL( const OUString& rPrefix );
 
+    bool hasNamespaceURL( const OUString& rPrefix ) const;
+
     sal_Int32 getNamespaceId( const OUString& rUrl );
 
     void importDocumentProperties();
diff --git a/include/sax/fastparser.hxx b/include/sax/fastparser.hxx
index 3a8ae53..217893c 100644
--- a/include/sax/fastparser.hxx
+++ b/include/sax/fastparser.hxx
@@ -140,9 +140,12 @@ public:
     void pushEntity( const Entity& rEntity );
     void popEntity();
     Entity& getEntity();
+    const Entity& getEntity() const;
     void parse();
     void produce( CallbackType aType );
 
+    bool hasNamespaceURL( const OUString& rPrefix ) const;
+
 private:
     bool consume(EventList *);
     void deleteUsedEvents();
diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk
index b7e763c..0a4fc04 100644
--- a/oox/Library_oox.mk
+++ b/oox/Library_oox.mk
@@ -40,6 +40,7 @@ $(eval $(call gb_Library_use_libraries,oox,\
     cppuhelper \
     editeng \
     drawinglayer \
+    fastsax \
     msfilter \
     sal \
 	i18nlangtag \
diff --git a/oox/source/core/fastparser.cxx b/oox/source/core/fastparser.cxx
index 03fd60a..70e12a8 100644
--- a/oox/source/core/fastparser.cxx
+++ b/oox/source/core/fastparser.cxx
@@ -25,6 +25,8 @@
 #include "oox/helper/storagebase.hxx"
 #include "oox/token/namespacemap.hxx"
 
+#include "sax/fastparser.hxx"
+
 namespace oox {
 namespace core {
 
@@ -66,11 +68,13 @@ InputStreamCloseGuard::~InputStreamCloseGuard()
 // ============================================================================
 
 FastParser::FastParser( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) :
-    mrNamespaceMap( StaticNamespaceMap::get() )
+    mrNamespaceMap( StaticNamespaceMap::get() ),
+    mpParser(NULL)
 {
     // create a fast parser instance
     Reference< XMultiComponentFactory > xFactory( rxContext->getServiceManager(), UNO_SET_THROW );
     mxParser.set( xFactory->createInstanceWithContext( "com.sun.star.xml.sax.FastParser", rxContext ), UNO_QUERY_THROW );
+    mpParser = dynamic_cast<sax_fastparser::FastSaxParser*>(mxParser.get());
 
     // create the fast tokenhandler
     mxTokenHandler.set( new FastTokenHandler );
@@ -131,6 +135,17 @@ OUString FastParser::getNamespaceURL( const OUString& rPrefix ) throw( IllegalAr
     return mxParser->getNamespaceURL( rPrefix );
 }
 
+bool FastParser::hasNamespaceURL( const OUString& rPrefix ) const
+{
+    if (!mxParser.is())
+        throw RuntimeException();
+
+    if (!mpParser)
+        return false;
+
+    return mpParser->hasNamespaceURL(rPrefix);
+}
+
 sal_Int32 FastParser::getNamespaceId( const OUString& rUrl )
 {
     for( NamespaceMap::const_iterator aIt = mrNamespaceMap.begin(), aEnd = mrNamespaceMap.end(); aIt != aEnd; ++aIt )
diff --git a/oox/source/core/fragmenthandler2.cxx b/oox/source/core/fragmenthandler2.cxx
index 668eb7f..8133b73 100644
--- a/oox/source/core/fragmenthandler2.cxx
+++ b/oox/source/core/fragmenthandler2.cxx
@@ -67,6 +67,12 @@ bool FragmentHandler2::prepareMceContext( sal_Int32 nElement, const AttributeLis
         case MCE_TOKEN( Choice ):
             {
                 OUString aRequires = rAttribs.getString( ( XML_Requires ), OUString("none") );
+                if (!getFilter().hasNamespaceURL(aRequires))
+                    // Check to see if we have this namespace defined first,
+                    // because calling getNamespaceURL() would throw if the
+                    // namespace doesn't exist.
+                    return false;
+
                 aRequires = getFilter().getNamespaceURL( aRequires );
                 if( getFilter().getNamespaceId( aRequires ) > 0 && !aMceState.empty() && aMceState.back() == MCE_STARTED )
                     aMceState.back() = MCE_FOUND_CHOICE;
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index 30f3848..ea2cc07 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -300,6 +300,11 @@ OUString XmlFilterBase::getNamespaceURL( const OUString& rPrefix )
     return mxImpl->maFastParser.getNamespaceURL( rPrefix );
 }
 
+bool XmlFilterBase::hasNamespaceURL( const OUString& rPrefix ) const
+{
+    return mxImpl->maFastParser.hasNamespaceURL(rPrefix);
+}
+
 sal_Int32 XmlFilterBase::getNamespaceId( const OUString& rUrl )
 {
      return mxImpl->maFastParser.getNamespaceId( rUrl );
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx
index 9f60b72..9535902 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -859,6 +859,24 @@ void FastSaxParser::produce( CallbackType aType )
     }
 }
 
+bool FastSaxParser::hasNamespaceURL( const OUString& rPrefix ) const
+{
+    const Entity& rEntity = getEntity();
+
+    if (rEntity.maNamespaceCount.empty())
+        return false;
+
+    OString aPrefix = OUStringToOString(rPrefix, RTL_TEXTENCODING_UTF8);
+    sal_uInt32 nNamespace = rEntity.maNamespaceCount.top();
+    while (nNamespace--)
+    {
+        if (rEntity.maNamespaceDefines[nNamespace]->maPrefix == aPrefix)
+            return true;
+    }
+
+    return false;
+}
+
 bool FastSaxParser::consume(EventList *pEventList)
 {
     Entity& rEntity = getEntity();
@@ -924,6 +942,11 @@ Entity& FastSaxParser::getEntity()
     return maEntities.top();
 }
 
+const Entity& FastSaxParser::getEntity() const
+{
+    return maEntities.top();
+}
+
 // starts parsing with actual parser !
 void FastSaxParser::parse()
 {
commit 2130fd9d610bf12b09fe29bafd46a673b21e064d
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Dec 2 18:32:42 2013 -0500

    Move this header out into a public place.
    
    Change-Id: I356b26947d1018276d8a9ff6012fdad3ca2c0fd8

diff --git a/include/oox/core/fastparser.hxx b/include/oox/core/fastparser.hxx
index b454caf..fd98241 100644
--- a/include/oox/core/fastparser.hxx
+++ b/include/oox/core/fastparser.hxx
@@ -28,6 +28,10 @@ namespace oox {
     class StorageBase;
 }
 
+namespace sax_fastparser {
+    class FastSaxParser;
+}
+
 namespace oox {
 namespace core {
 
@@ -85,6 +89,8 @@ private:
     ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastTokenHandler >
                         mxTokenHandler;
     const NamespaceMap& mrNamespaceMap;
+
+    sax_fastparser::FastSaxParser* mpParser;
 };
 
 // ============================================================================
diff --git a/sax/source/fastparser/fastparser.hxx b/include/sax/fastparser.hxx
similarity index 75%
rename from sax/source/fastparser/fastparser.hxx
rename to include/sax/fastparser.hxx
index 2943509..3a8ae53 100644
--- a/sax/source/fastparser/fastparser.hxx
+++ b/include/sax/fastparser.hxx
@@ -17,8 +17,8 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#ifndef _SAX_FASTPARSER_HXX_
-#define _SAX_FASTPARSER_HXX_
+#ifndef INCLUDED_SAX_FASTPARSER_HXX
+#define INCLUDED_SAX_FASTPARSER_HXX
 
 #include <queue>
 #include <vector>
@@ -36,25 +36,23 @@
 #include <cppuhelper/implbase2.hxx>
 
 #include <expat.h>
-#include "xml2utf.hxx"
+#include "saxdllapi.h"
 
 #include <sax/fastattribs.hxx>
 
-#define PARSER_IMPLEMENTATION_NAME "com.sun.star.comp.extensions.xml.sax.FastParser"
-#define PARSER_SERVICE_NAME        "com.sun.star.xml.sax.FastParser"
-
 namespace sax_fastparser {
 
 struct Event;
 class FastLocatorImpl;
 struct NamespaceDefine;
+struct Entity;
 
 typedef ::boost::shared_ptr< NamespaceDefine > NamespaceDefineRef;
 
 typedef ::boost::unordered_map< OUString, sal_Int32,
         OUStringHash, ::std::equal_to< OUString > > NamespaceMap;
 
-struct NameWithToken
+struct SAX_DLLPUBLIC NameWithToken
 {
     OUString msName;
     sal_Int32 mnToken;
@@ -66,7 +64,8 @@ typedef std::vector<Event> EventList;
 
 enum CallbackType { INVALID, START_ELEMENT, END_ELEMENT, CHARACTERS, DONE, EXCEPTION };
 
-struct Event {
+struct Event
+{
     OUString msChars;
     sal_Int32 mnElementToken;
     OUString msNamespace;
@@ -88,7 +87,7 @@ struct SaxContext
 
 // --------------------------------------------------------------------
 
-struct ParserData
+struct SAX_DLLPUBLIC ParserData
 {
     ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastDocumentHandler > mxDocumentHandler;
     ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastTokenHandler >    mxTokenHandler;
@@ -103,63 +102,8 @@ struct ParserData
 
 // --------------------------------------------------------------------
 
-// Entity binds all information needed for a single file | single call of parseStream
-struct Entity : public ParserData
-{
-    // Amount of work producer sends to consumer in one iteration:
-    static const size_t mnEventListSize = 1000;
-
-    // unique for each Entity instance:
-
-    // Number of valid events in mpProducedEvents:
-    size_t mnProducedEventsSize;
-    EventList *mpProducedEvents;
-    std::queue< EventList * > maPendingEvents;
-    std::queue< EventList * > maUsedEvents;
-    osl::Mutex maEventProtector;
-
-    static const size_t mnEventLowWater = 4;
-    static const size_t mnEventHighWater = 8;
-    osl::Condition maConsumeResume;
-    osl::Condition maProduceResume;
-    // Event we use to store data if threading is disabled:
-    Event maSharedEvent;
-
-    // copied in copy constructor:
-
-    // Allow to disable threading for small documents:
-    bool                                    mbEnableThreads;
-    ::com::sun::star::xml::sax::InputSource maStructSource;
-    XML_Parser                              mpParser;
-    ::sax_expatwrap::XMLFile2UTFConverter   maConverter;
-
-    // Exceptions cannot be thrown through the C-XmlParser (possible resource leaks),
-    // therefore the exception must be saved somewhere.
-    ::com::sun::star::uno::Any              maSavedException;
-
-    ::std::stack< NameWithToken >           maNamespaceStack;
-    /* Context for main thread consuming events.
-     * startElement() stores the data, which characters() and endElement() uses
-     */
-    ::std::stack< SaxContext>               maContextStack;
-    // Determines which elements of maNamespaceDefines are valid in current context
-    ::std::stack< sal_uInt32 >              maNamespaceCount;
-    ::std::vector< NamespaceDefineRef >     maNamespaceDefines;
-
-    explicit Entity( const ParserData& rData );
-    Entity( const Entity& rEntity );
-    ~Entity();
-    void startElement( Event *pEvent );
-    void characters( const OUString& sChars );
-    void endElement();
-    EventList* getEventList();
-    Event& getEvent( CallbackType aType );
-};
-
-// --------------------------------------------------------------------
-
 // This class implements the external Parser interface
-class FastSaxParser : public ::cppu::WeakImplHelper2< ::com::sun::star::xml::sax::XFastParser, ::com::sun::star::lang::XServiceInfo >
+class SAX_DLLPUBLIC FastSaxParser : public ::cppu::WeakImplHelper2< ::com::sun::star::xml::sax::XFastParser, ::com::sun::star::lang::XServiceInfo >
 {
 public:
     FastSaxParser();
diff --git a/sax/Library_fastsax.mk b/sax/Library_fastsax.mk
index ab0c4e6..863336f 100644
--- a/sax/Library_fastsax.mk
+++ b/sax/Library_fastsax.mk
@@ -38,7 +38,6 @@ $(eval $(call gb_Library_use_static_libraries,fastsax,\
 ))
 
 $(eval $(call gb_Library_add_exception_objects,fastsax,\
-	sax/source/fastparser/facreg \
 	sax/source/fastparser/fastparser \
 ))
 
diff --git a/sax/source/fastparser/facreg.cxx b/sax/source/fastparser/facreg.cxx
deleted file mode 100644
index fbf746f..0000000
--- a/sax/source/fastparser/facreg.cxx
+++ /dev/null
@@ -1,81 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <cppuhelper/factory.hxx>
-#include <cppuhelper/weak.hxx>
-#include <cppuhelper/implbase2.hxx>
-
-#include "fastparser.hxx"
-
-using namespace sax_fastparser;
-using namespace ::cppu;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::registry;
-using namespace ::com::sun::star::lang;
-
-namespace sax_fastparser
-{
-
-Reference< XInterface > SAL_CALL FastSaxParser_CreateInstance(
-    SAL_UNUSED_PARAMETER const Reference< XMultiServiceFactory > & )
-    throw(Exception)
-{
-    FastSaxParser *p = new FastSaxParser;
-    return Reference< XInterface > ( (OWeakObject * ) p );
-}
-
-}
-
-extern "C"
-{
-
-SAL_DLLPUBLIC_EXPORT void * SAL_CALL fastsax_component_getFactory(
-    const sal_Char * pImplName, void * pServiceManager,
-    SAL_UNUSED_PARAMETER void * /*pRegistryKey*/ )
-{
-    void * pRet = 0;
-
-    if (pServiceManager )
-    {
-        Reference< XSingleServiceFactory > xRet;
-        Reference< XMultiServiceFactory > xSMgr( reinterpret_cast< XMultiServiceFactory * > ( pServiceManager ) );
-
-        OUString aImplementationName( OUString::createFromAscii( pImplName ) );
-
-        if ( aImplementationName == PARSER_IMPLEMENTATION_NAME  )
-        {
-            xRet = createSingleFactory( xSMgr, aImplementationName,
-                                        FastSaxParser_CreateInstance,
-                                        FastSaxParser::getSupportedServiceNames_Static() );
-        }
-
-        if (xRet.is())
-        {
-            xRet->acquire();
-            pRet = xRet.get();
-        }
-    }
-
-    return pRet;
-}
-
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx
index 75974b8..9f60b72 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -27,11 +27,17 @@
 #include <com/sun/star/xml/sax/SAXParseException.hpp>
 #include <com/sun/star/xml/sax/FastToken.hpp>
 #include <cppuhelper/supportsservice.hxx>
+#include <cppuhelper/factory.hxx>
 
-#include "fastparser.hxx"
+#include "sax/fastparser.hxx"
+
+#include "xml2utf.hxx"
 
 #include <string.h>
 
+#define PARSER_IMPLEMENTATION_NAME "com.sun.star.comp.extensions.xml.sax.FastParser"
+#define PARSER_SERVICE_NAME        "com.sun.star.xml.sax.FastParser"
+
 using namespace ::std;
 using namespace ::osl;
 using namespace ::cppu;
@@ -105,6 +111,59 @@ struct NamespaceDefine
     NamespaceDefine( const OString& rPrefix, sal_Int32 nToken, const OUString& rNamespaceURL ) : maPrefix( rPrefix ), mnToken( nToken ), maNamespaceURL( rNamespaceURL ) {}
 };
 
+// Entity binds all information needed for a single file | single call of parseStream
+struct Entity : public ParserData
+{
+    // Amount of work producer sends to consumer in one iteration:
+    static const size_t mnEventListSize = 1000;
+
+    // unique for each Entity instance:
+
+    // Number of valid events in mpProducedEvents:
+    size_t mnProducedEventsSize;
+    EventList *mpProducedEvents;
+    std::queue< EventList * > maPendingEvents;
+    std::queue< EventList * > maUsedEvents;
+    osl::Mutex maEventProtector;
+
+    static const size_t mnEventLowWater = 4;
+    static const size_t mnEventHighWater = 8;
+    osl::Condition maConsumeResume;
+    osl::Condition maProduceResume;
+    // Event we use to store data if threading is disabled:
+    Event maSharedEvent;
+
+    // copied in copy constructor:
+
+    // Allow to disable threading for small documents:
+    bool                                    mbEnableThreads;
+    ::com::sun::star::xml::sax::InputSource maStructSource;
+    XML_Parser                              mpParser;
+    ::sax_expatwrap::XMLFile2UTFConverter   maConverter;
+
+    // Exceptions cannot be thrown through the C-XmlParser (possible resource leaks),
+    // therefore the exception must be saved somewhere.
+    ::com::sun::star::uno::Any              maSavedException;
+
+    ::std::stack< NameWithToken >           maNamespaceStack;
+    /* Context for main thread consuming events.
+     * startElement() stores the data, which characters() and endElement() uses
+     */
+    ::std::stack< SaxContext>               maContextStack;
+    // Determines which elements of maNamespaceDefines are valid in current context
+    ::std::stack< sal_uInt32 >              maNamespaceCount;
+    ::std::vector< NamespaceDefineRef >     maNamespaceDefines;
+
+    explicit Entity( const ParserData& rData );
+    Entity( const Entity& rEntity );
+    ~Entity();
+    void startElement( Event *pEvent );
+    void characters( const OUString& sChars );
+    void endElement();
+    EventList* getEventList();
+    Event& getEvent( CallbackType aType );
+};
+
 class ParserThread: public salhelper::Thread
 {
     FastSaxParser *mpParser;
@@ -1182,4 +1241,47 @@ int FastSaxParser::callbackExternalEntityRef(
 
 } // namespace sax_fastparser
 
+Reference< XInterface > SAL_CALL FastSaxParser_CreateInstance(
+    SAL_UNUSED_PARAMETER const Reference< XMultiServiceFactory > & )
+    throw(Exception)
+{
+    sax_fastparser::FastSaxParser *p = new sax_fastparser::FastSaxParser;
+    return Reference< XInterface > ( (OWeakObject * ) p );
+}
+
+extern "C" {
+
+SAL_DLLPUBLIC_EXPORT void * SAL_CALL fastsax_component_getFactory(
+    const sal_Char * pImplName, void * pServiceManager,
+    SAL_UNUSED_PARAMETER void * /*pRegistryKey*/ )
+{
+    void * pRet = 0;
+
+    if (pServiceManager )
+    {
+        Reference< XSingleServiceFactory > xRet;
+        Reference< XMultiServiceFactory > xSMgr( reinterpret_cast< XMultiServiceFactory * > ( pServiceManager ) );
+
+        OUString aImplementationName( OUString::createFromAscii( pImplName ) );
+
+        if ( aImplementationName == PARSER_IMPLEMENTATION_NAME  )
+        {
+            xRet = createSingleFactory(
+                xSMgr, aImplementationName,
+                FastSaxParser_CreateInstance,
+                sax_fastparser::FastSaxParser::getSupportedServiceNames_Static() );
+        }
+
+        if (xRet.is())
+        {
+            xRet->acquire();
+            pRet = xRet.get();
+        }
+    }
+
+    return pRet;
+}
+
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 8ef9d651770ef8423651b9163007975d16449fd3
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Dec 2 17:22:14 2013 -0500

    Remove inline methods from the header.
    
    Change-Id: Ie2cff194c1db5eaa992c4bcaaa06ec9a419d85a7

diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx
index caf4ec1..75974b8 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -81,6 +81,9 @@ static int call_callbackExternalEntityRef( XML_Parser parser,
 
 namespace sax_fastparser {
 
+NameWithToken::NameWithToken(const OUString& sName, const sal_Int32& nToken) :
+    msName(sName), mnToken(nToken) {}
+
 SaxContext::SaxContext( sal_Int32 nElementToken, const OUString& aNamespace, const OUString& aElementName ):
         mnElementToken(nElementToken)
 {
@@ -847,6 +850,21 @@ bool FastSaxParser::consume(EventList *pEventList)
     return true;
 }
 
+void FastSaxParser::pushEntity( const Entity& rEntity )
+{
+    maEntities.push( rEntity );
+}
+
+void FastSaxParser::popEntity()
+{
+    maEntities.pop();
+}
+
+Entity& FastSaxParser::getEntity()
+{
+    return maEntities.top();
+}
+
 // starts parsing with actual parser !
 void FastSaxParser::parse()
 {
diff --git a/sax/source/fastparser/fastparser.hxx b/sax/source/fastparser/fastparser.hxx
index 6888cef..2943509 100644
--- a/sax/source/fastparser/fastparser.hxx
+++ b/sax/source/fastparser/fastparser.hxx
@@ -58,8 +58,8 @@ struct NameWithToken
 {
     OUString msName;
     sal_Int32 mnToken;
-    NameWithToken(const OUString& sName, const sal_Int32& nToken):
-        msName(sName), mnToken(nToken) {}
+
+    NameWithToken(const OUString& sName, const sal_Int32& nToken);
 };
 
 typedef std::vector<Event> EventList;
@@ -193,9 +193,9 @@ public:
             const XML_Char *systemId, const XML_Char *publicId,
             const XML_Char *notationName);
 
-    void pushEntity( const Entity& rEntity ) { maEntities.push( rEntity ); }
-    void popEntity()                         { maEntities.pop(); }
-    Entity& getEntity()                             { return maEntities.top(); }
+    void pushEntity( const Entity& rEntity );
+    void popEntity();
+    Entity& getEntity();
     void parse();
     void produce( CallbackType aType );
 
commit 4ba42fc8dfb085ffc1a79365917a05e007d5be32
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Dec 2 17:19:49 2013 -0500

    Move this out of the namespace scope.
    
    Change-Id: I4aec1d45edb47ea16adaa8d2ac23340b8f421bae

diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx
index afe9454..caf4ec1 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -40,6 +40,45 @@ using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::xml::sax;
 using namespace ::com::sun::star::io;
 
+extern "C" {
+
+static void call_callbackStartElement(void *userData, const XML_Char *name , const XML_Char **atts)
+{
+    sax_fastparser::FastSaxParser* pFastParser = reinterpret_cast<sax_fastparser::FastSaxParser*>( userData );
+    pFastParser->callbackStartElement( name, atts );
+}
+
+static void call_callbackEndElement(void *userData, const XML_Char *name)
+{
+    sax_fastparser::FastSaxParser* pFastParser = reinterpret_cast<sax_fastparser::FastSaxParser*>( userData );
+    pFastParser->callbackEndElement( name );
+}
+
+static void call_callbackCharacters( void *userData , const XML_Char *s , int nLen )
+{
+    sax_fastparser::FastSaxParser* pFastParser = reinterpret_cast<sax_fastparser::FastSaxParser*>( userData );
+    pFastParser->callbackCharacters( s, nLen );
+}
+
+static void call_callbackEntityDecl(void *userData, const XML_Char *entityName,
+        int is_parameter_entity, const XML_Char *value, int value_length,
+        const XML_Char *base, const XML_Char *systemId,
+        const XML_Char *publicId, const XML_Char *notationName)
+{
+    sax_fastparser::FastSaxParser* pFastParser = reinterpret_cast<sax_fastparser::FastSaxParser*>(userData);
+    pFastParser->callbackEntityDecl(entityName, is_parameter_entity, value,
+            value_length, base, systemId, publicId, notationName);
+}
+
+static int call_callbackExternalEntityRef( XML_Parser parser,
+        const XML_Char *openEntityNames, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId )
+{
+    sax_fastparser::FastSaxParser* pFastParser = reinterpret_cast<sax_fastparser::FastSaxParser*>( XML_GetUserData( parser ) );
+    return pFastParser->callbackExternalEntityRef( parser, openEntityNames, base, systemId, publicId );
+}
+
+} // extern "C"
+
 namespace sax_fastparser {
 
 SaxContext::SaxContext( sal_Int32 nElementToken, const OUString& aNamespace, const OUString& aElementName ):
@@ -115,44 +154,6 @@ private:
 // the implementation part
 //---------------------------------------------
 
-extern "C" {
-
-static void call_callbackStartElement(void *userData, const XML_Char *name , const XML_Char **atts)
-{
-    FastSaxParser* pFastParser = reinterpret_cast< FastSaxParser* >( userData );
-    pFastParser->callbackStartElement( name, atts );
-}
-
-static void call_callbackEndElement(void *userData, const XML_Char *name)
-{
-    FastSaxParser* pFastParser = reinterpret_cast< FastSaxParser* >( userData );
-    pFastParser->callbackEndElement( name );
-}
-
-static void call_callbackCharacters( void *userData , const XML_Char *s , int nLen )
-{
-    FastSaxParser* pFastParser = reinterpret_cast< FastSaxParser* >( userData );
-    pFastParser->callbackCharacters( s, nLen );
-}
-
-static void call_callbackEntityDecl(void *userData, const XML_Char *entityName,
-        int is_parameter_entity, const XML_Char *value, int value_length,
-        const XML_Char *base, const XML_Char *systemId,
-        const XML_Char *publicId, const XML_Char *notationName)
-{
-    FastSaxParser* pFastParser = reinterpret_cast<FastSaxParser*>(userData);
-    pFastParser->callbackEntityDecl(entityName, is_parameter_entity, value,
-            value_length, base, systemId, publicId, notationName);
-}
-
-static int call_callbackExternalEntityRef( XML_Parser parser,
-        const XML_Char *openEntityNames, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId )
-{
-    FastSaxParser* pFastParser = reinterpret_cast< FastSaxParser* >( XML_GetUserData( parser ) );
-    return pFastParser->callbackExternalEntityRef( parser, openEntityNames, base, systemId, publicId );
-}
-
-} // extern "C"
 
 // --------------------------------------------------------------------
 // FastLocatorImpl implementation
diff --git a/sax/source/fastparser/fastparser.hxx b/sax/source/fastparser/fastparser.hxx
index d2bf1a7..6888cef 100644
--- a/sax/source/fastparser/fastparser.hxx
+++ b/sax/source/fastparser/fastparser.hxx
@@ -193,8 +193,8 @@ public:
             const XML_Char *systemId, const XML_Char *publicId,
             const XML_Char *notationName);
 
-    inline void pushEntity( const Entity& rEntity ) { maEntities.push( rEntity ); }
-    inline void popEntity()                         { maEntities.pop(); }
+    void pushEntity( const Entity& rEntity ) { maEntities.push( rEntity ); }
+    void popEntity()                         { maEntities.pop(); }
     Entity& getEntity()                             { return maEntities.top(); }
     void parse();
     void produce( CallbackType aType );


More information about the Libreoffice-commits mailing list