[Libreoffice-commits] .: 2 commits - i18npool/source sax/inc sax/source

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Tue Nov 9 01:50:11 PST 2010


 i18npool/source/breakiterator/breakiteratorImpl.cxx |    1 
 sax/inc/sax/fshelper.hxx                            |   17 +-
 sax/source/tools/fastserializer.cxx                 |  134 +++++++++++++++-----
 sax/source/tools/fastserializer.hxx                 |   55 ++++++--
 sax/source/tools/fshelper.cxx                       |    4 
 5 files changed, 161 insertions(+), 50 deletions(-)

New commits:
commit 3e12ec1759893883ffab6717dc1cf681e047c648
Author: Cédric Bosdonnat <cedricbosdo at openoffice.org>
Date:   Sat Nov 6 15:20:20 2010 +0100

    DOCX export: order pPr children according to specs
    
    This is still a first attempt: the base is present and all the
    exported properties needs to be checked. rPr properties order needs to
    be checked as well.

diff --git a/sax/inc/sax/fshelper.hxx b/sax/inc/sax/fshelper.hxx
index 36a19a9..5d5668a 100644
--- a/sax/inc/sax/fshelper.hxx
+++ b/sax/inc/sax/fshelper.hxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -53,16 +53,16 @@ class SAX_DLLPUBLIC FastSerializerHelper
 public:
 
     FastSerializerHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutputStream );
-    
+
     ~FastSerializerHelper();
-    
+
     void startElement(const char* elementName, ...);
     void singleElement(const char* elementName, ...);
     void endElement(const char* elementName);
 
     void startElementV(sal_Int32 elementTokenId, va_list args);
     void singleElementV(sal_Int32 elementTokenId, va_list args);
-    
+
     inline void startElement(sal_Int32 elementTokenId, ...)
         { va_list args; va_start( args, elementTokenId ); startElementV( elementTokenId, args ); va_end( args ); }
     inline void singleElement(sal_Int32 elementTokenId, ...)
@@ -74,7 +74,7 @@ public:
     void endElement(sal_Int32 elementTokenId);
     inline void endElementNS(sal_Int32 namespaceTokenId, sal_Int32 elementTokenId)
         { endElement( FSNS( namespaceTokenId, elementTokenId ) ); }
-        
+
     void singleElement(const char* elementName, XFastAttributeListRef xAttrList);
     inline void singleElement(sal_Int32 elementTokenId, XFastAttributeListRef xAttrList)
         { singleElementV(elementTokenId, xAttrList); }
@@ -83,7 +83,7 @@ public:
         { singleElementV(FSNS( namespaceTokenId, elementTokenId), xAttrList); }
 
     void startElementV(sal_Int32 elementTokenId, XFastAttributeListRef xAttrList);
-    inline void startElementNS(sal_Int32 namespaceTokenId, sal_Int32 elementTokenId, XFastAttributeListRef xAttrList) 
+    inline void startElementNS(sal_Int32 namespaceTokenId, sal_Int32 elementTokenId, XFastAttributeListRef xAttrList)
         { startElementV( FSNS( namespaceTokenId, elementTokenId ), xAttrList ); }
 
     FastSerializerHelper* write(const char* value);
@@ -99,10 +99,11 @@ public:
     FastSerializerHelper* writeId(sal_Int32 tokenId);
 
     ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > getOutputStream();
-    
+
     FastAttributeList *createAttrList();
 
-    void mark();
+    void mark( ::com::sun::star::uno::Sequence< sal_Int32 > aOrder =
+            ::com::sun::star::uno::Sequence< sal_Int32 >() );
     void mergeTopMarks( MergeMarksEnum eMergeType = MERGE_MARKS_APPEND );
 
 private:
diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx
index b97381d..7e83940 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -104,12 +104,12 @@ namespace sax_fastparser {
         }
         return sBuf.makeStringAndClear();
     }
-    
+
     void FastSaxSerializer::write( const OUString& s )
     {
         OString sOutput( OUStringToOString( s, RTL_TEXTENCODING_UTF8 ) );
-        writeBytes( Sequence< sal_Int8 >( 
-                    reinterpret_cast< const sal_Int8*>( sOutput.getStr() ), 
+        writeBytes( Sequence< sal_Int8 >(
+                    reinterpret_cast< const sal_Int8*>( sOutput.getStr() ),
                     sOutput.getLength() ) );
     }
 
@@ -118,7 +118,7 @@ namespace sax_fastparser {
         if (!mxOutputStream.is())
             return;
     }
-    
+
     void SAL_CALL FastSaxSerializer::writeId( ::sal_Int32 nElement )
     {
         if( HAS_NAMESPACE( nElement ) ) {
@@ -135,6 +135,9 @@ namespace sax_fastparser {
         if (!mxOutputStream.is())
             return;
 
+        if ( !maMarkStack.empty() )
+            maMarkStack.top()->setCurrentElement( Element );
+
         writeBytes(toUnoSequence(aOpeningBracket));
 
         writeId(Element);
@@ -156,11 +159,11 @@ namespace sax_fastparser {
             write(Namespace);
             writeBytes(toUnoSequence(aColon));
         }
-        
+
         write(Name);
-        
+
         writeFastAttributeList(Attribs);
-            
+
         writeBytes(toUnoSequence(aClosingBracket));
     }
 
@@ -190,9 +193,9 @@ namespace sax_fastparser {
             write(Namespace);
             writeBytes(toUnoSequence(aColon));
         }
-        
+
         write(Name);
-        
+
         writeBytes(toUnoSequence(aClosingBracket));
     }
 
@@ -202,6 +205,9 @@ namespace sax_fastparser {
         if (!mxOutputStream.is())
             return;
 
+        if ( !maMarkStack.empty() )
+            maMarkStack.top()->setCurrentElement( Element );
+
         writeBytes(toUnoSequence(aOpeningBracket));
 
         writeId(Element);
@@ -223,11 +229,11 @@ namespace sax_fastparser {
             write(Namespace);
             writeBytes(toUnoSequence(aColon));
         }
-        
+
         write(Name);
 
         writeFastAttributeList(Attribs);
-            
+
         writeBytes(toUnoSequence(aSlashAndClosingBracket));
     }
 
@@ -239,7 +245,7 @@ namespace sax_fastparser {
 
         write( aChars );
     }
-    
+
     void SAL_CALL FastSaxSerializer::setOutputStream( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutputStream )
         throw (::com::sun::star::uno::RuntimeException)
     {
@@ -265,7 +271,7 @@ namespace sax_fastparser {
             write(escapeXml(pAttr[i].Value));
             writeBytes(toUnoSequence(aQuote));
         }
-        
+
         Sequence< FastAttribute > aFastAttrSeq = Attribs->getFastAttributes();
         const FastAttribute *pFastAttr = aFastAttrSeq.getConstArray();
         sal_Int32 nFastAttrLength = aFastAttrSeq.getLength();
@@ -275,11 +281,11 @@ namespace sax_fastparser {
 
             sal_Int32 nToken = pFastAttr[j].Token;
             writeId(nToken);
-            
+
             writeBytes(toUnoSequence(aEqualSignAndQuote));
-    
+
             write(escapeXml(Attribs->getValue(pFastAttr[j].Token)));
-            
+
             writeBytes(toUnoSequence(aQuote));
         }
     }
@@ -323,24 +329,31 @@ namespace sax_fastparser {
         return aRet;
     }
 
-    void FastSaxSerializer::mark()
+    void FastSaxSerializer::mark( Int32Sequence aOrder )
     {
-        maMarkStack.push( ForMerge() );
+        if ( aOrder.hasElements() )
+        {
+            boost::shared_ptr< ForMerge > pSort( new ForSort( aOrder ) );
+            maMarkStack.push( pSort );
+        }
+        else
+        {
+            boost::shared_ptr< ForMerge > pMerge( new ForMerge( ) );
+            maMarkStack.push( pMerge );
+        }
     }
 
 #if DEBUG
     void FastSaxSerializer::printMarkStack( )
     {
-        ::std::stack< ForMerge > aCopy( maMarkStack );
+        ::std::stack< boost::shared_ptr< ForMerge > > aCopy( maMarkStack );
         int nSize = aCopy.size();
         int i = 0;
         while ( !aCopy.empty() )
         {
             fprintf( stderr, "%d\n", nSize - i );
 
-            ForMerge aMarks = aCopy.top( );
-            aMarks.print();
-
+            aCopy.top( )->print( );
 
             fprintf( stderr, "\n" );
 
@@ -357,19 +370,19 @@ namespace sax_fastparser {
 
         if ( maMarkStack.size() == 1 )
         {
-            mxOutputStream->writeBytes( maMarkStack.top().getData() );
+            mxOutputStream->writeBytes( maMarkStack.top()->getData() );
             maMarkStack.pop();
             return;
         }
 
-        const Int8Sequence aMerge( maMarkStack.top().getData() );
+        const Int8Sequence aMerge( maMarkStack.top()->getData() );
         maMarkStack.pop();
 
         switch ( eMergeType )
         {
-            case MERGE_MARKS_APPEND:   maMarkStack.top().append( aMerge );   break;
-            case MERGE_MARKS_PREPEND:  maMarkStack.top().prepend( aMerge );  break;
-            case MERGE_MARKS_POSTPONE: maMarkStack.top().postpone( aMerge ); break;
+            case MERGE_MARKS_APPEND:   maMarkStack.top()->append( aMerge );   break;
+            case MERGE_MARKS_PREPEND:  maMarkStack.top()->prepend( aMerge );  break;
+            case MERGE_MARKS_POSTPONE: maMarkStack.top()->postpone( aMerge ); break;
         }
     }
 
@@ -378,14 +391,14 @@ namespace sax_fastparser {
         if ( maMarkStack.empty() )
             mxOutputStream->writeBytes( aData );
         else
-            maMarkStack.top().append( aData );
+            maMarkStack.top()->append( aData );
     }
 
     FastSaxSerializer::Int8Sequence& FastSaxSerializer::ForMerge::getData()
     {
         merge( maData, maPostponed, true );
         maPostponed.realloc( 0 );
-        
+
         return maData;
     }
 
@@ -445,6 +458,67 @@ namespace sax_fastparser {
         }
     }
 
+    void FastSaxSerializer::ForMerge::resetData( )
+    {
+        maData = Int8Sequence();
+    }
+
+    void FastSaxSerializer::ForSort::setCurrentElement( sal_Int32 nElement )
+    {
+        mnCurrentElement = nElement;
+        if ( maData.find( nElement ) == maData.end() )
+            maData[ nElement ] = Int8Sequence();
+    }
+
+    void FastSaxSerializer::ForSort::prepend( const Int8Sequence &rWhat )
+    {
+        append( rWhat );
+    }
+
+    void FastSaxSerializer::ForSort::append( const Int8Sequence &rWhat )
+    {
+        merge( maData[mnCurrentElement], rWhat, true );
+    }
+
+    void FastSaxSerializer::ForSort::sort()
+    {
+        // Clear the ForMerge data to avoid duplicate items
+        resetData();
+
+        // Sort it all
+        std::map< sal_Int32, Int8Sequence >::iterator iter;
+        for ( sal_Int32 i=0, len=maOrder.getLength(); i < len; i++ )
+        {
+            iter = maData.find( maOrder[i] );
+            if ( iter != maData.end() )
+                ForMerge::append( iter->second );
+        }
+    }
+
+    FastSaxSerializer::Int8Sequence& FastSaxSerializer::ForSort::getData()
+    {
+        sort( );
+        return ForMerge::getData();
+    }
+
+#if DEBUG
+    void FastSaxSerializer::ForSort::print( )
+    {
+        std::map< sal_Int32, Int8Sequence >::iterator iter = maData.begin();
+        while ( iter != maData.end( ) )
+        {
+            fprintf( stderr, "pair: %d, ", iter->first );
+            for ( sal_Int32 i=0, len=iter->second.getLength(); i < len; i++ )
+                fprintf( stderr, "%c", iter->second[i] );
+            fprintf( stderr, "\n" );
+            iter++;
+        }
+
+        sort( );
+        ForMerge::print();
+    }
+#endif
+
 } // namespace sax_fastparser
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sax/source/tools/fastserializer.hxx b/sax/source/tools/fastserializer.hxx
index 07a6ed5..dab9f82 100644
--- a/sax/source/tools/fastserializer.hxx
+++ b/sax/source/tools/fastserializer.hxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -36,6 +36,9 @@
 #include <cppuhelper/implbase2.hxx>
 
 #include <stack>
+#include <map>
+
+#include <boost/shared_ptr.hpp>
 
 #include "sax/dllapi.h"
 #include "sax/fshelper.hxx"
@@ -47,6 +50,9 @@ namespace sax_fastparser {
 
 class SAX_DLLPUBLIC FastSaxSerializer : public ::cppu::WeakImplHelper2< ::com::sun::star::xml::sax::XFastSerializer, ::com::sun::star::lang::XServiceInfo >
 {
+    typedef ::com::sun::star::uno::Sequence< ::sal_Int8 > Int8Sequence;
+    typedef ::com::sun::star::uno::Sequence< ::sal_Int32 > Int32Sequence;
+
 public:
     explicit            FastSaxSerializer(  );
     virtual             ~FastSaxSerializer();
@@ -102,7 +108,7 @@ public:
           mergeTopMarks( true ), mergeTopMarks(), /r, /p
         and you are done.
      */
-    void mark();
+    void mark( Int32Sequence aOrder = Int32Sequence() );
 
     /** Merge 2 topmost marks.
 
@@ -125,7 +131,6 @@ private:
     ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > mxOutputStream;
     ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastTokenHandler > mxFastTokenHandler;
 
-    typedef ::com::sun::star::uno::Sequence< ::sal_Int8 > Int8Sequence;
     class ForMerge
     {
         Int8Sequence maData;
@@ -134,24 +139,54 @@ private:
     public:
         ForMerge() : maData(), maPostponed() {}
 
-        Int8Sequence& getData();
+        virtual void setCurrentElement( ::sal_Int32 /*nToken*/ ) {}
+        virtual Int8Sequence& getData();
 #if DEBUG
-        void print();
+        virtual void print();
 #endif
 
-        void prepend( const Int8Sequence &rWhat );
-        void append( const Int8Sequence &rWhat );
+        virtual void prepend( const Int8Sequence &rWhat );
+        virtual void append( const Int8Sequence &rWhat );
         void postpone( const Int8Sequence &rWhat );
-        
-    private:
+
+    protected:
+        void resetData( );
         static void merge( Int8Sequence &rTop, const Int8Sequence &rMerge, bool bAppend );
     };
 
+    class ForSort : public ForMerge
+    {
+        std::map< ::sal_Int32, Int8Sequence > maData;
+        sal_Int32 mnCurrentElement;
+
+        Int32Sequence maOrder;
+
+    public:
+        ForSort( Int32Sequence aOrder ) :
+            ForMerge(),
+            maData(),
+            mnCurrentElement( 0 ),
+            maOrder( aOrder ) {}
+
+        void setCurrentElement( ::sal_Int32 nToken );
+
+        virtual Int8Sequence& getData();
+
+#if DEBUG
+        virtual void print();
+#endif
+
+        virtual void prepend( const Int8Sequence &rWhat );
+        virtual void append( const Int8Sequence &rWhat );
+    private:
+        void sort();
+    };
+
 #if DEBUG
         void printMarkStack( );
 #endif
 
-    ::std::stack< ForMerge > maMarkStack;
+    ::std::stack< boost::shared_ptr< ForMerge > > maMarkStack;
 
     void writeFastAttributeList( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs );
     void write( const ::rtl::OUString& s );
diff --git a/sax/source/tools/fshelper.cxx b/sax/source/tools/fshelper.cxx
index c9df021..0ea7cf6 100644
--- a/sax/source/tools/fshelper.cxx
+++ b/sax/source/tools/fshelper.cxx
@@ -183,9 +183,9 @@ FastSerializerHelper* FastSerializerHelper::writeId(sal_Int32 tokenId)
     return mpSerializer->getOutputStream();
 }
 
-void FastSerializerHelper::mark()
+void FastSerializerHelper::mark( Sequence< sal_Int32 > aOrder )
 {
-    mpSerializer->mark();
+    mpSerializer->mark( aOrder );
 }
 
 void FastSerializerHelper::mergeTopMarks( MergeMarksEnum eMergeType )
commit cb9aa439fbb0a85829b1e61e292b1553512b0cb5
Author: Mattias Johnsson <m.t.johnsson at gmail.com>
Date:   Thu Nov 4 23:25:02 2010 +1100

    An opening quote should not be counted as a word by word count tool

diff --git a/i18npool/source/breakiterator/breakiteratorImpl.cxx b/i18npool/source/breakiterator/breakiteratorImpl.cxx
index ec21299..c47f7be 100644
--- a/i18npool/source/breakiterator/breakiteratorImpl.cxx
+++ b/i18npool/source/breakiterator/breakiteratorImpl.cxx
@@ -459,6 +459,7 @@ static UBlock2Script scriptList[] = {
     {UBLOCK_CHEROKEE, UBLOCK_RUNIC, ScriptType::LATIN},
     {UBLOCK_KHMER, UBLOCK_MONGOLIAN, ScriptType::COMPLEX},
     {UBLOCK_LATIN_EXTENDED_ADDITIONAL, UBLOCK_GREEK_EXTENDED, ScriptType::LATIN},
+    {UBLOCK_GENERAL_PUNCTUATION, UBLOCK_GENERAL_PUNCTUATION, ScriptType::LATIN},
     {UBLOCK_CJK_RADICALS_SUPPLEMENT, UBLOCK_HANGUL_SYLLABLES, ScriptType::ASIAN},
     {UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS, UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS, ScriptType::ASIAN},
     {UBLOCK_ARABIC_PRESENTATION_FORMS_A, UBLOCK_ARABIC_PRESENTATION_FORMS_A, ScriptType::COMPLEX},


More information about the Libreoffice-commits mailing list