[Libreoffice-commits] core.git: Branch 'feature/perfwork' - 3 commits - include/sax sax/source

Matúš Kukan matus.kukan at collabora.com
Mon Sep 29 12:43:03 PDT 2014


 include/sax/fastattribs.hxx         |    6 +-
 include/sax/fshelper.hxx            |    5 --
 sax/source/tools/fastattribs.cxx    |   20 +++-----
 sax/source/tools/fastserializer.cxx |   84 ++++++++++++------------------------
 sax/source/tools/fastserializer.hxx |   52 +++++++++-------------
 sax/source/tools/fshelper.cxx       |   35 ++++++++-------
 6 files changed, 82 insertions(+), 120 deletions(-)

New commits:
commit d3fbcc1ef51c9f5c8ac1fead0bc4d894207e9b8b
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Sun Sep 28 00:09:16 2014 +0200

    FastSerializer: avoid some more OStrings
    
    Change-Id: I2d5dbe9adccdd231cc16a1f83a90a4adeb965c64

diff --git a/include/sax/fastattribs.hxx b/include/sax/fastattribs.hxx
index 5255481..85a1218 100644
--- a/include/sax/fastattribs.hxx
+++ b/include/sax/fastattribs.hxx
@@ -87,6 +87,7 @@ public:
     void addUnknown( const OString& rName, const sal_Char* pValue );
     const std::vector< sal_Int32 >&  getFastAttributeTokens() const { return maAttributeTokens; }
     const char* getFastAttributeValue(size_t nIndex) const { return mpChunk + maAttributeValues[nIndex]; }
+    sal_Int32 AttributeValueLength(size_t i) const { return maAttributeValues[i + 1] - maAttributeValues[i] - 1; }
 
     // performance sensitive shortcuts to avoid allocation ...
     bool getAsInteger( sal_Int32 nToken, sal_Int32 &rInt);
@@ -103,9 +104,6 @@ public:
     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::xml::FastAttribute > SAL_CALL getFastAttributes() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
 
 private:
-    inline sal_Int32 AttributeValueLength(sal_Int32 i);
-
-private:
     sal_Char *mpChunk; ///< buffer to store all attribute values - null terminated strings
     sal_Int32 mnChunkLength; ///< size of allocated memory for mpChunk
     // maAttributeValues stores pointers, relative to mpChunk, for each attribute value string
diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx
index 67f3196..e2cbcc6 100644
--- a/sax/source/tools/fastattribs.cxx
+++ b/sax/source/tools/fastattribs.cxx
@@ -225,12 +225,6 @@ Sequence< FastAttribute > FastAttributeList::getFastAttributes(  ) throw (Runtim
     return aSeq;
 }
 
-sal_Int32 FastAttributeList::AttributeValueLength(sal_Int32 i)
-{
-    // Pointers to null terminated strings
-    return maAttributeValues[i + 1] - maAttributeValues[i] - 1;
-}
-
 sal_Int32 FastTokenHandlerBase::getTokenFromChars(
         const css::uno::Reference< css::xml::sax::XFastTokenHandler > &xTokenHandler,
         FastTokenHandlerBase *pTokenHandler,
diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx
index 3a8b770..d6c1a94 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -83,14 +83,20 @@ namespace sax_fastparser {
 
     void FastSaxSerializer::write( const OString& sOutput, bool bEscape )
     {
+        write( sOutput.getStr(), sOutput.getLength(), bEscape );
+    }
+
+    void FastSaxSerializer::write( const char* pStr, sal_Int32 nLen, bool bEscape )
+    {
+        if (nLen == 0)
+            nLen = strlen(pStr);
+
         if (!bEscape)
         {
-            writeBytes( sOutput.getStr(), sOutput.getLength() );
+            writeBytes( pStr, nLen );
             return;
         }
 
-        const char* pStr = sOutput.getStr();
-        sal_Int32 nLen = sOutput.getLength();
         for (sal_Int32 i = 0; i < nLen; ++i)
         {
             char c = pStr[ i ];
@@ -222,7 +228,7 @@ namespace sax_fastparser {
 
             writeBytes(sEqualSignAndQuote, N_CHARS(sEqualSignAndQuote));
 
-            write(pAttrList->getFastAttributeValue(j), true);
+            write(pAttrList->getFastAttributeValue(j), pAttrList->AttributeValueLength(j), true);
 
             writeBytes(sQuote, N_CHARS(sQuote));
         }
diff --git a/sax/source/tools/fastserializer.hxx b/sax/source/tools/fastserializer.hxx
index 089348a..05db2c7 100644
--- a/sax/source/tools/fastserializer.hxx
+++ b/sax/source/tools/fastserializer.hxx
@@ -105,6 +105,7 @@ public:
 
     void write( const OUString& s, bool bEscape = false );
     void write( const OString& s, bool bEscape = false );
+    void write( const char* pStr, sal_Int32 nLen, bool bEscape = false );
 
 public:
     /** From now on, don't write directly to the stream, but to top of a stack.
diff --git a/sax/source/tools/fshelper.cxx b/sax/source/tools/fshelper.cxx
index 30e5932..c6ac390 100644
--- a/sax/source/tools/fshelper.cxx
+++ b/sax/source/tools/fshelper.cxx
@@ -109,7 +109,8 @@ void FastSerializerHelper::singleElement(sal_Int32 elementTokenId, XFastAttribut
 
 FastSerializerHelper* FastSerializerHelper::write(const char* value)
 {
-    return write(OString(value));
+    mpSerializer->write(value, 0, false);
+    return this;
 }
 
 FastSerializerHelper* FastSerializerHelper::write(const OUString& value)
@@ -141,7 +142,7 @@ FastSerializerHelper* FastSerializerHelper::write(double value)
 
 FastSerializerHelper* FastSerializerHelper::writeEscaped(const char* value)
 {
-    mpSerializer->write(OString(value), true);
+    mpSerializer->write(value, 0, true);
     return this;
 }
 
commit 501f855ae63d429babe35d18ae5390960efd9665
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Sat Sep 27 21:46:36 2014 +0200

    FastSerializer: Use FastAttributeList directly to write faster.
    
    Change-Id: I28085d4e060bcf052e6aa97a0822a4d653d7c066

diff --git a/include/sax/fastattribs.hxx b/include/sax/fastattribs.hxx
index 6d9c7a4..5255481 100644
--- a/include/sax/fastattribs.hxx
+++ b/include/sax/fastattribs.hxx
@@ -85,6 +85,8 @@ public:
     void addNS( sal_Int32 nNamespaceToken, sal_Int32 nToken, const OString& rValue );
     void addUnknown( const OUString& rNamespaceURL, const OString& rName, const sal_Char* pValue );
     void addUnknown( const OString& rName, const sal_Char* pValue );
+    const std::vector< sal_Int32 >&  getFastAttributeTokens() const { return maAttributeTokens; }
+    const char* getFastAttributeValue(size_t nIndex) const { return mpChunk + maAttributeValues[nIndex]; }
 
     // performance sensitive shortcuts to avoid allocation ...
     bool getAsInteger( sal_Int32 nToken, sal_Int32 &rInt);
diff --git a/include/sax/fshelper.hxx b/include/sax/fshelper.hxx
index d83ce78..5630910 100644
--- a/include/sax/fshelper.hxx
+++ b/include/sax/fshelper.hxx
@@ -20,9 +20,7 @@
 #ifndef INCLUDED_SAX_FSHELPER_HXX
 #define INCLUDED_SAX_FSHELPER_HXX
 
-#include <com/sun/star/uno/XReference.hpp>
 #include <com/sun/star/io/XOutputStream.hpp>
-#include <com/sun/star/xml/sax/XFastTokenHandler.hpp>
 #include <stdarg.h>
 #include <boost/shared_ptr.hpp>
 #include <sax/fastattribs.hxx>
@@ -185,8 +183,7 @@ private:
     void singleElementInternal(sal_Int32 elementTokenId, ...);
 
     FastSaxSerializer* mpSerializer;
-    com::sun::star::uno::Reference<com::sun::star::xml::sax::XFastTokenHandler> mxTokenHandler;
-
+    FastAttributeList maAttrList;
 };
 
 typedef boost::shared_ptr< FastSerializerHelper > FSHelperPtr;
diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx
index 45887b5..67f3196 100644
--- a/sax/source/tools/fastattribs.cxx
+++ b/sax/source/tools/fastattribs.cxx
@@ -129,7 +129,7 @@ sal_Int32 FastAttributeList::getValueToken( ::sal_Int32 Token ) throw (SAXExcept
         if (maAttributeTokens[i] == Token)
             return FastTokenHandlerBase::getTokenFromChars(
                        mxTokenHandler, mpTokenHandler,
-                       mpChunk + maAttributeValues[ i ],
+                       getFastAttributeValue(i),
                        AttributeValueLength( i ) );
 
     throw SAXException();
@@ -141,7 +141,7 @@ sal_Int32 FastAttributeList::getOptionalValueToken( ::sal_Int32 Token, ::sal_Int
         if (maAttributeTokens[i] == Token)
             return FastTokenHandlerBase::getTokenFromChars(
                        mxTokenHandler, mpTokenHandler,
-                       mpChunk + maAttributeValues[ i ],
+                       getFastAttributeValue(i),
                        AttributeValueLength( i ) );
 
     return Default;
@@ -154,7 +154,7 @@ bool FastAttributeList::getAsInteger( sal_Int32 nToken, sal_Int32 &rInt)
     for (size_t i = 0; i < maAttributeTokens.size(); ++i)
         if (maAttributeTokens[i] == nToken)
         {
-            rInt = rtl_str_toInt32( mpChunk + maAttributeValues[i], 10 );
+            rInt = rtl_str_toInt32( getFastAttributeValue(i), 10 );
             return true;
         }
     return false;
@@ -166,7 +166,7 @@ bool FastAttributeList::getAsDouble( sal_Int32 nToken, double &rDouble)
     for (size_t i = 0; i < maAttributeTokens.size(); ++i)
         if (maAttributeTokens[i] == nToken)
         {
-            rDouble = rtl_str_toDouble( mpChunk + maAttributeValues[i] );
+            rDouble = rtl_str_toDouble( getFastAttributeValue(i) );
             return true;
         }
     return false;
@@ -191,7 +191,7 @@ OUString FastAttributeList::getValue( ::sal_Int32 Token ) throw (SAXException, R
 {
     for (size_t i = 0; i < maAttributeTokens.size(); ++i)
         if (maAttributeTokens[i] == Token)
-            return OUString( mpChunk + maAttributeValues[i], AttributeValueLength(i), RTL_TEXTENCODING_UTF8 );
+            return OUString( getFastAttributeValue(i), AttributeValueLength(i), RTL_TEXTENCODING_UTF8 );
 
     throw SAXException();
 }
@@ -200,7 +200,7 @@ OUString FastAttributeList::getOptionalValue( ::sal_Int32 Token ) throw (Runtime
 {
     for (size_t i = 0; i < maAttributeTokens.size(); ++i)
         if (maAttributeTokens[i] == Token)
-            return OUString( mpChunk + maAttributeValues[i], AttributeValueLength(i), RTL_TEXTENCODING_UTF8 );
+            return OUString( getFastAttributeValue(i), AttributeValueLength(i), RTL_TEXTENCODING_UTF8 );
 
     return OUString();
 }
@@ -219,7 +219,7 @@ Sequence< FastAttribute > FastAttributeList::getFastAttributes(  ) throw (Runtim
     for (size_t i = 0; i < maAttributeTokens.size(); ++i)
     {
         pAttr->Token = maAttributeTokens[i];
-        pAttr->Value = OUString( mpChunk + maAttributeValues[i], AttributeValueLength(i), RTL_TEXTENCODING_UTF8 );
+        pAttr->Value = OUString( getFastAttributeValue(i), AttributeValueLength(i), RTL_TEXTENCODING_UTF8 );
         pAttr++;
     }
     return aSeq;
diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx
index f2f8bc6..3a8b770 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -21,7 +21,6 @@
 
 #include <com/sun/star/xml/Attribute.hpp>
 #include <com/sun/star/xml/FastAttribute.hpp>
-#include <com/sun/star/xml/sax/XFastAttributeList.hpp>
 
 #include <rtl/ustrbuf.hxx>
 #include <comphelper/sequenceasvector.hxx>
@@ -40,7 +39,6 @@ using ::com::sun::star::uno::Sequence;
 using ::com::sun::star::xml::FastAttribute;
 using ::com::sun::star::xml::Attribute;
 using ::com::sun::star::xml::sax::SAXException;
-using ::com::sun::star::xml::sax::XFastAttributeList;
 using ::com::sun::star::io::XOutputStream;
 using ::com::sun::star::io::NotConnectedException;
 using ::com::sun::star::io::IOException;
@@ -145,7 +143,7 @@ namespace sax_fastparser {
     }
 #endif
 
-    void FastSaxSerializer::startFastElement( ::sal_Int32 Element, const Reference< XFastAttributeList >& Attribs )
+    void FastSaxSerializer::startFastElement( ::sal_Int32 Element, FastAttributeList* pAttrList )
     {
         if ( !maMarkStack.empty() )
             maMarkStack.top()->setCurrentElement( Element );
@@ -157,7 +155,7 @@ namespace sax_fastparser {
         writeBytes(sOpeningBracket, N_CHARS(sOpeningBracket));
 
         writeId(Element);
-        writeFastAttributeList(Attribs);
+        writeFastAttributeList(pAttrList);
 
         writeBytes(sClosingBracket, N_CHARS(sClosingBracket));
     }
@@ -178,7 +176,7 @@ namespace sax_fastparser {
         writeBytes(sClosingBracket, N_CHARS(sClosingBracket));
     }
 
-    void FastSaxSerializer::singleFastElement( ::sal_Int32 Element, const Reference< XFastAttributeList >& Attribs )
+    void FastSaxSerializer::singleFastElement( ::sal_Int32 Element, FastAttributeList* pAttrList )
     {
         if ( !maMarkStack.empty() )
             maMarkStack.top()->setCurrentElement( Element );
@@ -186,7 +184,7 @@ namespace sax_fastparser {
         writeBytes(sOpeningBracket, N_CHARS(sOpeningBracket));
 
         writeId(Element);
-        writeFastAttributeList(Attribs);
+        writeFastAttributeList(pAttrList);
 
         writeBytes(sSlashAndClosingBracket, N_CHARS(sSlashAndClosingBracket));
     }
@@ -200,38 +198,18 @@ namespace sax_fastparser {
     {
         mxFastTokenHandler = xFastTokenHandler;
     }
-    void FastSaxSerializer::writeFastAttributeList( const Reference< XFastAttributeList >& Attribs )
+
+    void FastSaxSerializer::writeFastAttributeList( FastAttributeList* pAttrList )
     {
 #ifdef DBG_UTIL
         ::std::set<OUString> DebugAttributes;
 #endif
-        Sequence< Attribute > aAttrSeq = Attribs->getUnknownAttributes();
-        const Attribute *pAttr = aAttrSeq.getConstArray();
-        sal_Int32 nAttrLength = aAttrSeq.getLength();
-        for (sal_Int32 i = 0; i < nAttrLength; i++)
-        {
-            writeBytes(sSpace, N_CHARS(sSpace));
-
-            OUString const& rAttrName(pAttr[i].Name);
-#ifdef DBG_UTIL
-            // Well-formedness constraint: Unique Att Spec
-            assert(DebugAttributes.find(rAttrName) == DebugAttributes.end());
-            DebugAttributes.insert(rAttrName);
-#endif
-            write(rAttrName);
-            writeBytes(sEqualSignAndQuote, N_CHARS(sEqualSignAndQuote));
-            write(pAttr[i].Value, true);
-            writeBytes(sQuote, N_CHARS(sQuote));
-        }
-
-        Sequence< FastAttribute > aFastAttrSeq = Attribs->getFastAttributes();
-        const FastAttribute *pFastAttr = aFastAttrSeq.getConstArray();
-        sal_Int32 nFastAttrLength = aFastAttrSeq.getLength();
-        for (sal_Int32 j = 0; j < nFastAttrLength; j++)
+        const std::vector< sal_Int32 >& Tokens = pAttrList->getFastAttributeTokens();
+        for (size_t j = 0; j < Tokens.size(); j++)
         {
             writeBytes(sSpace, N_CHARS(sSpace));
 
-            sal_Int32 nToken = pFastAttr[j].Token;
+            sal_Int32 nToken = Tokens[j];
             writeId(nToken);
 
 #ifdef DBG_UTIL
@@ -244,7 +222,7 @@ namespace sax_fastparser {
 
             writeBytes(sEqualSignAndQuote, N_CHARS(sEqualSignAndQuote));
 
-            write(pFastAttr[j].Value, true);
+            write(pAttrList->getFastAttributeValue(j), true);
 
             writeBytes(sQuote, N_CHARS(sQuote));
         }
diff --git a/sax/source/tools/fastserializer.hxx b/sax/source/tools/fastserializer.hxx
index 82e9eea..089348a 100644
--- a/sax/source/tools/fastserializer.hxx
+++ b/sax/source/tools/fastserializer.hxx
@@ -22,16 +22,15 @@
 
 #include <com/sun/star/xml/sax/XFastTokenHandler.hpp>
 #include <com/sun/star/io/XOutputStream.hpp>
-#include <rtl/byteseq.hxx>
+
+#include <comphelper/seqstream.hxx>
+#include <sax/fastattribs.hxx>
+#include <sax/fshelper.hxx>
 
 #include <stack>
 #include <map>
-
 #include <boost/shared_ptr.hpp>
 
-#include <comphelper/seqstream.hxx>
-#include "sax/fshelper.hxx"
-
 namespace sax_fastparser {
 
 /// Receives notification of sax document events to write into an XOutputStream.
@@ -67,11 +66,11 @@ public:
             <b>or</b> operation.
 
         @param Attribs
-            Contains a <type>XFastAttrbitueList</type> to access the attributes
+            Contains a <type>FastAttributeList</type> to access the attributes
             from the element.
 
     */
-    void startFastElement( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs );
+    void startFastElement( ::sal_Int32 Element, FastAttributeList* Attribs );
 
     /** receives notification of the end of an known element.
         @see startFastElement
@@ -91,11 +90,11 @@ public:
             <b>or</b> operation.
 
         @param Attribs
-            Contains a <type>XFastAttrbitueList</type> to access the attributes
+            Contains a <type>FastAttributeList</type> to access the attributes
             from the element.
 
     */
-    void singleFastElement( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs );
+    void singleFastElement( ::sal_Int32 Element, FastAttributeList* Attribs );
 
     void setOutputStream( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutputStream );
     void setFastTokenHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastTokenHandler >& xFastTokenHandler );
@@ -206,7 +205,7 @@ private:
     ::std::stack<sal_Int32> m_DebugStartedElements;
 #endif
 
-    void writeFastAttributeList( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs );
+    void writeFastAttributeList( FastAttributeList* pAttrList );
     /// Write to maOutputData and if it's big enough flush that to mxOutputStream
     void writeOutput( const sal_Int8* pStr, size_t nLen );
     void writeOutput( const css::uno::Sequence< ::sal_Int8 >& aData );
diff --git a/sax/source/tools/fshelper.cxx b/sax/source/tools/fshelper.cxx
index 0e5df28..30e5932 100644
--- a/sax/source/tools/fshelper.cxx
+++ b/sax/source/tools/fshelper.cxx
@@ -20,6 +20,7 @@
 #include <sax/fshelper.hxx>
 #include "fastserializer.hxx"
 #include <com/sun/star/xml/sax/FastTokenHandler.hpp>
+#include <com/sun/star/xml/sax/XFastTokenHandler.hpp>
 #include <comphelper/processfactory.hxx>
 #include <rtl/ustrbuf.hxx>
 
@@ -30,11 +31,10 @@ namespace sax_fastparser {
 
 FastSerializerHelper::FastSerializerHelper(const Reference< io::XOutputStream >& xOutputStream, bool bWriteHeader ) :
     mpSerializer(new FastSaxSerializer())
+  , maAttrList(Reference< xml::sax::XFastTokenHandler >())
 {
     Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext(), UNO_SET_THROW );
-    mxTokenHandler = css::xml::sax::FastTokenHandler::create(xContext);
-
-    mpSerializer->setFastTokenHandler( mxTokenHandler );
+    mpSerializer->setFastTokenHandler( css::xml::sax::FastTokenHandler::create(xContext) );
     assert(xOutputStream.is()); // cannot do anything without that
     mpSerializer->setOutputStream( xOutputStream );
     if( bWriteHeader )
@@ -51,7 +51,7 @@ void FastSerializerHelper::startElementInternal(sal_Int32 elementTokenId, ...)
 {
     va_list args;
     va_start( args, elementTokenId );
-    FastAttributeList* pAttrList = new FastAttributeList( mxTokenHandler );
+    maAttrList.clear();
 
     while (true)
     {
@@ -60,11 +60,10 @@ void FastSerializerHelper::startElementInternal(sal_Int32 elementTokenId, ...)
             break;
         const char* pValue = va_arg(args, const char*);
         if (pValue)
-            pAttrList->add(nName, pValue);
+            maAttrList.add(nName, pValue);
     }
 
-    const com::sun::star::uno::Reference<com::sun::star::xml::sax::XFastAttributeList> xAttrList(pAttrList);
-    mpSerializer->startFastElement(elementTokenId, xAttrList);
+    mpSerializer->startFastElement(elementTokenId, &maAttrList);
     va_end( args );
 }
 
@@ -72,7 +71,7 @@ void FastSerializerHelper::singleElementInternal(sal_Int32 elementTokenId, ...)
 {
     va_list args;
     va_start( args, elementTokenId );
-    FastAttributeList* pAttrList = new FastAttributeList( mxTokenHandler );
+    maAttrList.clear();
 
     while (true)
     {
@@ -81,11 +80,10 @@ void FastSerializerHelper::singleElementInternal(sal_Int32 elementTokenId, ...)
             break;
         const char* pValue = va_arg(args, const char*);
         if  (pValue)
-            pAttrList->add(nName, pValue);
+            maAttrList.add(nName, pValue);
     }
 
-    const com::sun::star::uno::Reference<com::sun::star::xml::sax::XFastAttributeList> xAttrList(pAttrList);
-    mpSerializer->singleFastElement(elementTokenId, xAttrList);
+    mpSerializer->singleFastElement(elementTokenId, &maAttrList);
     va_end( args );
 }
 
@@ -96,13 +94,17 @@ void FastSerializerHelper::endElement(sal_Int32 elementTokenId)
 
 void FastSerializerHelper::startElement(sal_Int32 elementTokenId, XFastAttributeListRef xAttrList)
 {
-    mpSerializer->startFastElement(elementTokenId, xAttrList);
+    FastAttributeList* pAttrList = dynamic_cast< FastAttributeList* >(xAttrList.get());
+    assert(pAttrList);
+    mpSerializer->startFastElement(elementTokenId, pAttrList);
 }
 
 
 void FastSerializerHelper::singleElement(sal_Int32 elementTokenId, XFastAttributeListRef xAttrList)
 {
-    mpSerializer->singleFastElement(elementTokenId, xAttrList);
+    FastAttributeList* pAttrList = dynamic_cast< FastAttributeList* >(xAttrList.get());
+    assert(pAttrList);
+    mpSerializer->singleFastElement(elementTokenId, pAttrList);
 }
 
 FastSerializerHelper* FastSerializerHelper::write(const char* value)
@@ -172,7 +174,7 @@ void FastSerializerHelper::mergeTopMarks( MergeMarksEnum eMergeType )
 
 FastAttributeList * FastSerializerHelper::createAttrList()
 {
-    return new FastAttributeList( mxTokenHandler );
+    return new FastAttributeList( Reference< xml::sax::XFastTokenHandler >() );
 }
 
 
commit be1a853748a96b91128563967bba96a38073a6df
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Sat Sep 27 22:04:13 2014 +0200

    FastSerializer: Remove throw specs; this is not UNO implementation
    
    Change-Id: I462f8ed89de48174ed7aa6e008709963bec50649

diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx
index 455df0b..f2f8bc6 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -18,14 +18,14 @@
  */
 
 #include "fastserializer.hxx"
-#include <rtl/ustrbuf.hxx>
-
-#include <comphelper/sequenceasvector.hxx>
 
 #include <com/sun/star/xml/Attribute.hpp>
 #include <com/sun/star/xml/FastAttribute.hpp>
 #include <com/sun/star/xml/sax/XFastAttributeList.hpp>
 
+#include <rtl/ustrbuf.hxx>
+#include <comphelper/sequenceasvector.hxx>
+
 #include <string.h>
 
 #if OSL_DEBUG_LEVEL > 0
@@ -73,7 +73,7 @@ namespace sax_fastparser {
     }
     FastSaxSerializer::~FastSaxSerializer() {}
 
-    void SAL_CALL FastSaxSerializer::startDocument(  ) throw (SAXException, RuntimeException)
+    void FastSaxSerializer::startDocument()
     {
         writeBytes(sXmlHeader, N_CHARS(sXmlHeader));
     }
@@ -110,13 +110,13 @@ namespace sax_fastparser {
         }
     }
 
-    void SAL_CALL FastSaxSerializer::endDocument(  ) throw (SAXException, RuntimeException)
+    void FastSaxSerializer::endDocument()
     {
         maOutputStream.flush();
         mxOutputStream->writeBytes(maOutputData);
     }
 
-    void SAL_CALL FastSaxSerializer::writeId( ::sal_Int32 nElement )
+    void FastSaxSerializer::writeId( ::sal_Int32 nElement )
     {
         if( HAS_NAMESPACE( nElement ) ) {
             writeBytes(mxFastTokenHandler->getUTF8Identifier(NAMESPACE(nElement)));
@@ -127,7 +127,7 @@ namespace sax_fastparser {
     }
 
 #ifdef DBG_UTIL
-    OString SAL_CALL FastSaxSerializer::getId( ::sal_Int32 nElement )
+    OString FastSaxSerializer::getId( ::sal_Int32 nElement )
     {
         if (HAS_NAMESPACE(nElement)) {
             Sequence<sal_Int8> const ns(
@@ -145,8 +145,7 @@ namespace sax_fastparser {
     }
 #endif
 
-    void SAL_CALL FastSaxSerializer::startFastElement( ::sal_Int32 Element, const Reference< XFastAttributeList >& Attribs )
-        throw (SAXException, RuntimeException)
+    void FastSaxSerializer::startFastElement( ::sal_Int32 Element, const Reference< XFastAttributeList >& Attribs )
     {
         if ( !maMarkStack.empty() )
             maMarkStack.top()->setCurrentElement( Element );
@@ -163,8 +162,7 @@ namespace sax_fastparser {
         writeBytes(sClosingBracket, N_CHARS(sClosingBracket));
     }
 
-    void SAL_CALL FastSaxSerializer::endFastElement( ::sal_Int32 Element )
-        throw (SAXException, RuntimeException)
+    void FastSaxSerializer::endFastElement( ::sal_Int32 Element )
     {
 #ifdef DBG_UTIL
         assert(!m_DebugStartedElements.empty());
@@ -180,8 +178,7 @@ namespace sax_fastparser {
         writeBytes(sClosingBracket, N_CHARS(sClosingBracket));
     }
 
-    void SAL_CALL FastSaxSerializer::singleFastElement( ::sal_Int32 Element, const Reference< XFastAttributeList >& Attribs )
-        throw (SAXException, RuntimeException)
+    void FastSaxSerializer::singleFastElement( ::sal_Int32 Element, const Reference< XFastAttributeList >& Attribs )
     {
         if ( !maMarkStack.empty() )
             maMarkStack.top()->setCurrentElement( Element );
@@ -194,14 +191,12 @@ namespace sax_fastparser {
         writeBytes(sSlashAndClosingBracket, N_CHARS(sSlashAndClosingBracket));
     }
 
-    void SAL_CALL FastSaxSerializer::setOutputStream( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutputStream )
-        throw (::com::sun::star::uno::RuntimeException)
+    void FastSaxSerializer::setOutputStream( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutputStream )
     {
         mxOutputStream = xOutputStream;
     }
 
-    void SAL_CALL FastSaxSerializer::setFastTokenHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastTokenHandler >& xFastTokenHandler )
-        throw (::com::sun::star::uno::RuntimeException)
+    void FastSaxSerializer::setFastTokenHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastTokenHandler >& xFastTokenHandler )
     {
         mxFastTokenHandler = xFastTokenHandler;
     }
@@ -295,13 +290,11 @@ namespace sax_fastparser {
     }
 
     void FastSaxSerializer::writeBytes( const Sequence< sal_Int8 >& rData )
-        throw ( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException )
     {
         writeBytes( reinterpret_cast<const char*>(rData.getConstArray()), rData.getLength() );
     }
 
     void FastSaxSerializer::writeBytes( const char* pStr, size_t nLen )
-        throw ( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException )
     {
         if ( maMarkStack.empty() )
             writeOutput( reinterpret_cast<const sal_Int8*>(pStr), nLen );
@@ -310,13 +303,12 @@ namespace sax_fastparser {
                 reinterpret_cast<const sal_Int8*>(pStr), nLen) );
     }
 
-    void FastSaxSerializer::writeOutput( const Sequence< ::sal_Int8 >& aData ) throw ( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException )
+    void FastSaxSerializer::writeOutput( const Sequence< ::sal_Int8 >& aData )
     {
         writeOutput( aData.getConstArray(), aData.getLength() );
     }
 
     void FastSaxSerializer::writeOutput( const sal_Int8* pStr, size_t nLen )
-        throw ( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException )
     {
         maOutputStream.writeBytes( pStr, nLen );
         // Write when the sequence gets big enough
diff --git a/sax/source/tools/fastserializer.hxx b/sax/source/tools/fastserializer.hxx
index b84c1cc..82e9eea 100644
--- a/sax/source/tools/fastserializer.hxx
+++ b/sax/source/tools/fastserializer.hxx
@@ -41,18 +41,18 @@ class FastSaxSerializer
     typedef ::com::sun::star::uno::Sequence< ::sal_Int32 > Int32Sequence;
 
 public:
-    explicit FastSaxSerializer();
+    FastSaxSerializer();
     ~FastSaxSerializer();
 
     ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > getOutputStream() {return mxOutputStream;}
 
     /** called by the parser when parsing of an XML stream is started.
      */
-    void SAL_CALL startDocument(  ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+    void startDocument();
 
     /** called by the parser after the last XML element of a stream is processed.
      */
-    void SAL_CALL endDocument(  ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+    void endDocument();
 
     /** receives notification of the beginning of an element.
 
@@ -71,14 +71,12 @@ public:
             from the element.
 
     */
-    void SAL_CALL startFastElement( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs )
-        throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+    void startFastElement( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs );
 
     /** receives notification of the end of an known element.
         @see startFastElement
      */
-    void SAL_CALL endFastElement( ::sal_Int32 Element )
-        throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+    void endFastElement( ::sal_Int32 Element );
 
     /** receives notification of the beginning of a single element.
 
@@ -97,18 +95,14 @@ public:
             from the element.
 
     */
-    void SAL_CALL singleFastElement( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs )
-        throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+    void singleFastElement( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs );
 
-    void SAL_CALL setOutputStream( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutputStream )
-        throw (::com::sun::star::uno::RuntimeException);
-
-    void SAL_CALL setFastTokenHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastTokenHandler >& xFastTokenHandler )
-        throw (::com::sun::star::uno::RuntimeException);
+    void setOutputStream( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutputStream );
+    void setFastTokenHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastTokenHandler >& xFastTokenHandler );
 
     // C++ helpers
-    void SAL_CALL writeId( ::sal_Int32 Element );
-    OString SAL_CALL getId( ::sal_Int32 Element );
+    void writeId( ::sal_Int32 Element );
+    OString getId( ::sal_Int32 Element );
 
     void write( const OUString& s, bool bEscape = false );
     void write( const OString& s, bool bEscape = false );
@@ -214,17 +208,15 @@ private:
 
     void writeFastAttributeList( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs );
     /// Write to maOutputData and if it's big enough flush that to mxOutputStream
-    void writeOutput( const sal_Int8* pStr, size_t nLen )
-        throw (css::io::NotConnectedException, css::io::BufferSizeExceededException, css::io::IOException, css::uno::RuntimeException);
-    void writeOutput( const css::uno::Sequence< ::sal_Int8 >& aData )
-        throw (css::io::NotConnectedException, css::io::BufferSizeExceededException, css::io::IOException, css::uno::RuntimeException);
+    void writeOutput( const sal_Int8* pStr, size_t nLen );
+    void writeOutput( const css::uno::Sequence< ::sal_Int8 >& aData );
 
     /** Forward the call to the output stream, or write to the stack.
 
         The latter in the case that we are inside a mark().
      */
-    void writeBytes( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
-    void writeBytes( const char* pStr, size_t nLen ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+    void writeBytes( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData );
+    void writeBytes( const char* pStr, size_t nLen );
 };
 
 } // namespace sax_fastparser


More information about the Libreoffice-commits mailing list