[Libreoffice-commits] core.git: 3 commits - connectivity/source svl/inc svl/Package_inc.mk svl/source

Thomas Arnhold thomas at arnhold.org
Mon Mar 11 09:18:26 PDT 2013


 connectivity/source/drivers/hsqldb/HDriver.cxx |    2 
 svl/Package_inc.mk                             |    1 
 svl/inc/svl/nranges.hxx                        |   50 +----
 svl/inc/svl/rngitem.hxx                        |   50 ++---
 svl/source/items/itemset.cxx                   |    4 
 svl/source/items/nranges.cxx                   |  174 ++++++++++----------
 svl/source/items/rngitem.cxx                   |  190 +++++++++++++++++++++-
 svl/source/items/rngitem_inc.cxx               |  212 -------------------------
 8 files changed, 301 insertions(+), 382 deletions(-)

New commits:
commit 224fbad7ab4cbedec53910f05e2b4a71771cfec5
Author: Thomas Arnhold <thomas at arnhold.org>
Date:   Mon Mar 11 17:16:34 2013 +0100

    fix my previous commit (compareToAscii)
    
    Change-Id: I06885691c1fb3cfa0824f2ac1307ae4d9f3c9d40

diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx b/connectivity/source/drivers/hsqldb/HDriver.cxx
index d58c8f5..695c593 100644
--- a/connectivity/source/drivers/hsqldb/HDriver.cxx
+++ b/connectivity/source/drivers/hsqldb/HDriver.cxx
@@ -399,7 +399,7 @@ namespace connectivity
     {
         sal_Bool bEnabled = sal_False;
         OSL_VERIFY_EQUALS( jfw_getEnabled( &bEnabled ), JFW_E_NONE, "error in jfw_getEnabled" );
-        return bEnabled  && url.startsWith("sdbc:embedded:hsqldb");
+        return bEnabled  && url.equals("sdbc:embedded:hsqldb");
     }
 
     //--------------------------------------------------------------------
commit 7050fc44a7a02efdec005337ee9d286d27964e47
Author: Thomas Arnhold <thomas at arnhold.org>
Date:   Mon Mar 11 16:56:46 2013 +0100

    reduce some uglyness II
    
    NUMTYPE is never defined outside this header. So this complexity can go.
    
    There is no need to deliver nranges.hxx as there is only itemset.cxx using it.
    
    NUMTYPE -> sal_uInt16
    NUMTYPE_ARG -> int
    SfxNumRanges -> SfxUShortRanges
    
    Change-Id: I27027f9ec83ebf456bb545763954884d5de227b3

diff --git a/svl/Package_inc.mk b/svl/Package_inc.mk
index 5ac424d..b3fe708 100644
--- a/svl/Package_inc.mk
+++ b/svl/Package_inc.mk
@@ -73,7 +73,6 @@ $(eval $(call gb_Package_add_file,svl_inc,inc/svl/metitem.hxx,svl/metitem.hxx))
 $(eval $(call gb_Package_add_file,svl_inc,inc/svl/nfkeytab.hxx,svl/nfkeytab.hxx))
 $(eval $(call gb_Package_add_file,svl_inc,inc/svl/nfsymbol.hxx,svl/nfsymbol.hxx))
 $(eval $(call gb_Package_add_file,svl_inc,inc/svl/nfversi.hxx,svl/nfversi.hxx))
-$(eval $(call gb_Package_add_file,svl_inc,inc/svl/nranges.hxx,svl/nranges.hxx))
 $(eval $(call gb_Package_add_file,svl_inc,inc/svl/numuno.hxx,svl/numuno.hxx))
 $(eval $(call gb_Package_add_file,svl_inc,inc/svl/ondemand.hxx,svl/ondemand.hxx))
 $(eval $(call gb_Package_add_file,svl_inc,inc/svl/outstrm.hxx,svl/outstrm.hxx))
diff --git a/svl/inc/svl/nranges.hxx b/svl/inc/svl/nranges.hxx
index eabe9d2..3e92331 100644
--- a/svl/inc/svl/nranges.hxx
+++ b/svl/inc/svl/nranges.hxx
@@ -25,58 +25,40 @@
 
 #ifndef _SFXNRANGES_HXX
 
-#ifndef NUMTYPE
-
-#define NUMTYPE sal_uInt16
-#define SfxNumRanges SfxUShortRanges
-#include <svl/nranges.hxx>
-
-#undef NUMTYPE
-
-#define _SFXNRANGES_HXX
-
-#else
 #include <tools/solar.h>
 
 //========================================================================
 
-#define NUMTYPE_ARG int
-
-class SfxNumRanges
+class SfxUShortRanges
 {
-    NUMTYPE*                    _pRanges; // 0-terminated array of NUMTYPE-pairs
+    sal_uInt16*                 _pRanges; // 0-terminated array of sal_uInt16-pairs
 
 public:
-                                SfxNumRanges() : _pRanges( 0 ) {}
-                                SfxNumRanges( const SfxNumRanges &rOrig );
-                                SfxNumRanges( NUMTYPE nWhich1, NUMTYPE nWhich2 );
-                                SfxNumRanges( const NUMTYPE* nNumTable );
-                                ~SfxNumRanges()
+                                SfxUShortRanges() : _pRanges( 0 ) {}
+                                SfxUShortRanges( const SfxUShortRanges &rOrig );
+                                SfxUShortRanges( sal_uInt16 nWhich1, sal_uInt16 nWhich2 );
+                                SfxUShortRanges( const sal_uInt16* nNumTable );
+                                ~SfxUShortRanges()
                                 { delete [] _pRanges; }
 
-    sal_Bool                        operator == ( const SfxNumRanges & ) const;
-    sal_Bool                        operator != ( const SfxNumRanges & rRanges ) const
+    sal_Bool                    operator == ( const SfxUShortRanges & ) const;
+    sal_Bool                    operator != ( const SfxUShortRanges & rRanges ) const
                                 { return !( *this == rRanges ); }
 
-    SfxNumRanges&               operator = ( const SfxNumRanges & );
+    SfxUShortRanges&            operator = ( const SfxUShortRanges & );
 
-    SfxNumRanges&               operator += ( const SfxNumRanges & );
-    SfxNumRanges&               operator -= ( const SfxNumRanges & );
-    SfxNumRanges&               operator /= ( const SfxNumRanges & );
+    SfxUShortRanges&            operator += ( const SfxUShortRanges & );
+    SfxUShortRanges&            operator -= ( const SfxUShortRanges & );
+    SfxUShortRanges&            operator /= ( const SfxUShortRanges & );
 
-    NUMTYPE                     Count() const;
-    sal_Bool                        IsEmpty() const
+    sal_uInt16                  Count() const;
+    sal_Bool                    IsEmpty() const
                                 { return !_pRanges || 0 == *_pRanges; }
 
-                                operator const NUMTYPE* () const
+                                operator const sal_uInt16* () const
                                 { return _pRanges; }
 };
 
-#undef NUMTYPE
-#undef SfxNumRanges
-
-#endif
-
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index ae63c18..aaebeb8 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -43,11 +43,7 @@ DBG_NAME(SfxItemSet)
 
 //========================================================================
 
-#define NUMTYPE         sal_uInt16
-#define SfxNumRanges    SfxUShortRanges
 #include "nranges.cxx"
-#undef NUMTYPE
-#undef SfxNumRanges
 
 //========================================================================
 
diff --git a/svl/source/items/nranges.cxx b/svl/source/items/nranges.cxx
index c2c08cd..69ae5d7 100644
--- a/svl/source/items/nranges.cxx
+++ b/svl/source/items/nranges.cxx
@@ -25,8 +25,8 @@
 
 #ifdef DBG_UTIL
 
-#define DBG_CHECK_RANGES(NUMTYPE, pArr)                                 \
-    for ( const NUMTYPE *pRange = pArr; *pRange; pRange += 2 )          \
+#define DBG_CHECK_RANGES(sal_uInt16, pArr)                                 \
+    for ( const sal_uInt16 *pRange = pArr; *pRange; pRange += 2 )          \
     {                                                                   \
         DBG_ASSERT( pRange[0] <= pRange[1], "ranges must be sorted" );  \
         DBG_ASSERT( !pRange[2] || ( pRange[2] - pRange[1] ) > 1,        \
@@ -35,22 +35,22 @@
 
 #else
 
-#define DBG_CHECK_RANGES(NUMTYPE,pArr)
+#define DBG_CHECK_RANGES(sal_uInt16,pArr)
 
 #endif
 
 //============================================================================
-inline void Swap_Impl(const NUMTYPE *& rp1, const NUMTYPE *& rp2)
+inline void Swap_Impl(const sal_uInt16 *& rp1, const sal_uInt16 *& rp2)
 {
-    const NUMTYPE * pTemp = rp1;
+    const sal_uInt16 * pTemp = rp1;
     rp1 = rp2;
     rp2 = pTemp;
 }
 
 //========================================================================
 
-NUMTYPE InitializeRanges_Impl( NUMTYPE *&rpRanges, va_list pArgs,
-                               NUMTYPE nWh1, NUMTYPE nWh2, NUMTYPE nNull )
+sal_uInt16 InitializeRanges_Impl( sal_uInt16 *&rpRanges, va_list pArgs,
+                               sal_uInt16 nWh1, sal_uInt16 nWh2, sal_uInt16 nNull )
 
 /** <H3>Description</H3>
 
@@ -58,13 +58,13 @@ NUMTYPE InitializeRanges_Impl( NUMTYPE *&rpRanges, va_list pArgs,
     first range, 'nNull' as terminator or start of 2nd range and 'pArgs' as
     remaider.
 
-    It returns the number of NUMTYPEs which are contained in the described
-    set of NUMTYPEs.
+    It returns the number of sal_uInt16s which are contained in the described
+    set of sal_uInt16s.
 */
 
 {
-    NUMTYPE nSize = 0, nIns = 0;
-    std::vector<NUMTYPE> aNumArr;
+    sal_uInt16 nSize = 0, nIns = 0;
+    std::vector<sal_uInt16> aNumArr;
     aNumArr.push_back( nWh1 );
     aNumArr.push_back( nWh2 );
     DBG_ASSERT( nWh1 <= nWh2, "Ungueltiger Bereich" );
@@ -73,13 +73,13 @@ NUMTYPE InitializeRanges_Impl( NUMTYPE *&rpRanges, va_list pArgs,
     bool bEndOfRange = false;
     while ( 0 !=
             ( nIns =
-              sal::static_int_cast< NUMTYPE >(
-                  va_arg( pArgs, NUMTYPE_ARG ) ) ) )
+              sal::static_int_cast< sal_uInt16 >(
+                  va_arg( pArgs, int ) ) ) )
     {
         bEndOfRange = !bEndOfRange;
         if ( bEndOfRange )
         {
-            const NUMTYPE nPrev(*aNumArr.rbegin());
+            const sal_uInt16 nPrev(*aNumArr.rbegin());
             DBG_ASSERT( nPrev <= nIns, "Ungueltiger Bereich" );
             nSize += nIns - nPrev + 1;
         }
@@ -89,7 +89,7 @@ NUMTYPE InitializeRanges_Impl( NUMTYPE *&rpRanges, va_list pArgs,
     assert( bEndOfRange ); // odd number of Which-IDs
 
     // so, jetzt sind alle Bereiche vorhanden und
-    rpRanges = new NUMTYPE[ aNumArr.size() + 1 ];
+    rpRanges = new sal_uInt16[ aNumArr.size() + 1 ];
     std::copy( aNumArr.begin(), aNumArr.end(), rpRanges);
     *(rpRanges + aNumArr.size()) = 0;
 
@@ -98,16 +98,16 @@ NUMTYPE InitializeRanges_Impl( NUMTYPE *&rpRanges, va_list pArgs,
 
 //------------------------------------------------------------------------
 
-NUMTYPE Count_Impl( const NUMTYPE *pRanges )
+sal_uInt16 Count_Impl( const sal_uInt16 *pRanges )
 
 /** <H3>Description</H3>
 
-    Determines the number of NUMTYPEs in an 0-terminated array of pairs of
-    NUMTYPEs. The terminating 0 is not included in the count.
+    Determines the number of sal_uInt16s in an 0-terminated array of pairs of
+    sal_uInt16s. The terminating 0 is not included in the count.
 */
 
 {
-    NUMTYPE nCount = 0;
+    sal_uInt16 nCount = 0;
     while ( *pRanges )
     {
         nCount += 2;
@@ -118,16 +118,16 @@ NUMTYPE Count_Impl( const NUMTYPE *pRanges )
 
 //------------------------------------------------------------------------
 
-NUMTYPE Capacity_Impl( const NUMTYPE *pRanges )
+sal_uInt16 Capacity_Impl( const sal_uInt16 *pRanges )
 
 /** <H3>Description</H3>
 
-    Determines the total number of NUMTYPEs described in an 0-terminated
-    array of pairs of NUMTYPEs, each representing an range of NUMTYPEs.
+    Determines the total number of sal_uInt16s described in an 0-terminated
+    array of pairs of sal_uInt16s, each representing an range of sal_uInt16s.
 */
 
 {
-    NUMTYPE nCount = 0;
+    sal_uInt16 nCount = 0;
 
     if ( pRanges )
     {
@@ -142,7 +142,7 @@ NUMTYPE Capacity_Impl( const NUMTYPE *pRanges )
 
 //------------------------------------------------------------------------
 
-SfxNumRanges::SfxNumRanges( const SfxNumRanges &rOrig )
+SfxUShortRanges::SfxUShortRanges( const SfxUShortRanges &rOrig )
 
 /** <H3>Description</H3>
 
@@ -152,9 +152,9 @@ SfxNumRanges::SfxNumRanges( const SfxNumRanges &rOrig )
 {
     if ( rOrig._pRanges )
     {
-        NUMTYPE nCount = Count_Impl( rOrig._pRanges ) + 1;
-        _pRanges = new NUMTYPE[nCount];
-        memcpy( _pRanges, rOrig._pRanges, sizeof(NUMTYPE) * nCount );
+        sal_uInt16 nCount = Count_Impl( rOrig._pRanges ) + 1;
+        _pRanges = new sal_uInt16[nCount];
+        memcpy( _pRanges, rOrig._pRanges, sizeof(sal_uInt16) * nCount );
     }
     else
         _pRanges = 0;
@@ -162,17 +162,17 @@ SfxNumRanges::SfxNumRanges( const SfxNumRanges &rOrig )
 
 //------------------------------------------------------------------------
 
-SfxNumRanges::SfxNumRanges( NUMTYPE nWhich1, NUMTYPE nWhich2 )
+SfxUShortRanges::SfxUShortRanges( sal_uInt16 nWhich1, sal_uInt16 nWhich2 )
 
 /** <H3>Description</H3>
 
-    Constructs an SfxNumRanges-instance from one range of NUMTYPEs.
+    Constructs an SfxUShortRanges-instance from one range of sal_uInt16s.
 
     precondition:
         nWhich1 <= nWhich2
 */
 
-:   _pRanges( new NUMTYPE[3] )
+:   _pRanges( new sal_uInt16[3] )
 {
     _pRanges[0] = nWhich1;
     _pRanges[1] = nWhich2;
@@ -181,11 +181,11 @@ SfxNumRanges::SfxNumRanges( NUMTYPE nWhich1, NUMTYPE nWhich2 )
 
 //------------------------------------------------------------------------
 
-SfxNumRanges::SfxNumRanges( const NUMTYPE* pArr )
+SfxUShortRanges::SfxUShortRanges( const sal_uInt16* pArr )
 
 /** <H3>Description</H3>
 
-    Constcurts an SfxNumRanges-instance from an sorted ranges of NUMTYPEs,
+    Constcurts an SfxUShortRanges-instance from an sorted ranges of sal_uInt16s,
     terminates with on 0.
 
     precondition: for each n >= 0 && n < (sizeof(pArr)-1)
@@ -193,15 +193,15 @@ SfxNumRanges::SfxNumRanges( const NUMTYPE* pArr )
 */
 
 {
-    DBG_CHECK_RANGES(NUMTYPE, pArr);
-    NUMTYPE nCount = Count_Impl(pArr) + 1;
-    _pRanges = new NUMTYPE[ nCount ];
-    memcpy( _pRanges, pArr, sizeof(NUMTYPE) * nCount );
+    DBG_CHECK_RANGES(sal_uInt16, pArr);
+    sal_uInt16 nCount = Count_Impl(pArr) + 1;
+    _pRanges = new sal_uInt16[ nCount ];
+    memcpy( _pRanges, pArr, sizeof(sal_uInt16) * nCount );
 }
 
 //------------------------------------------------------------------------
 
-sal_Bool SfxNumRanges::operator==( const SfxNumRanges &rOther ) const
+sal_Bool SfxUShortRanges::operator==( const SfxUShortRanges &rOther ) const
 {
     // Object pointers equal?
     if ( this == &rOther )
@@ -212,12 +212,12 @@ sal_Bool SfxNumRanges::operator==( const SfxNumRanges &rOther ) const
         return sal_True;
 
     // Counts equal?
-    NUMTYPE nCount = Count();
+    sal_uInt16 nCount = Count();
     if ( nCount != rOther.Count() )
         return sal_False;
 
     // Check arrays.
-    NUMTYPE n = 0;
+    sal_uInt16 n = 0;
     while( _pRanges[ n ] != 0 )
     {
         // Elements at current position equal?
@@ -232,9 +232,9 @@ sal_Bool SfxNumRanges::operator==( const SfxNumRanges &rOther ) const
 
 //------------------------------------------------------------------------
 
-SfxNumRanges& SfxNumRanges::operator =
+SfxUShortRanges& SfxUShortRanges::operator =
 (
-    const SfxNumRanges &rRanges
+    const SfxUShortRanges &rRanges
 )
 
 /** <H3>Description</H3>
@@ -255,25 +255,25 @@ SfxNumRanges& SfxNumRanges::operator =
     else
     {
         // copy ranges
-        NUMTYPE nCount = Count_Impl( rRanges._pRanges ) + 1;
-        _pRanges = new NUMTYPE[ nCount ];
-        memcpy( _pRanges, rRanges._pRanges, sizeof(NUMTYPE) * nCount );
+        sal_uInt16 nCount = Count_Impl( rRanges._pRanges ) + 1;
+        _pRanges = new sal_uInt16[ nCount ];
+        memcpy( _pRanges, rRanges._pRanges, sizeof(sal_uInt16) * nCount );
     }
     return *this;
 }
 
 //------------------------------------------------------------------------
 
-SfxNumRanges& SfxNumRanges::operator +=
+SfxUShortRanges& SfxUShortRanges::operator +=
 (
-    const SfxNumRanges &rRanges
+    const SfxUShortRanges &rRanges
 )
 
 /** <H3>Description</H3>
 
     Merges *this with 'rRanges'.
 
-    for each NUMTYPE n:
+    for each sal_uInt16 n:
         this->Contains( n ) || rRanges.Contains( n ) => this'->Contains( n )
         !this->Contains( n ) && !rRanges.Contains( n ) => !this'->Contains( n )
 */
@@ -287,9 +287,9 @@ SfxNumRanges& SfxNumRanges::operator +=
 
     // First, run thru _pRanges and rRanges._pRanges and determine the size of
     // the new, merged ranges:
-    NUMTYPE nCount = 0;
-    const NUMTYPE * pRA = _pRanges;
-    const NUMTYPE * pRB = rRanges._pRanges;
+    sal_uInt16 nCount = 0;
+    const sal_uInt16 * pRA = _pRanges;
+    const sal_uInt16 * pRB = rRanges._pRanges;
 
     for (;;)
     {
@@ -348,10 +348,10 @@ count_rest:
     // Now, create new ranges of the correct size and, on a second run thru
     // _pRanges and rRanges._pRanges, copy the merged pairs into the new
     // ranges:
-    NUMTYPE * pNew = new NUMTYPE[nCount + 1];
+    sal_uInt16 * pNew = new sal_uInt16[nCount + 1];
     pRA = _pRanges;
     pRB = rRanges._pRanges;
-    NUMTYPE * pRN = pNew;
+    sal_uInt16 * pRN = pNew;
 
     for (;;)
     {
@@ -424,16 +424,16 @@ copy_rest:
 
 //------------------------------------------------------------------------
 
-SfxNumRanges& SfxNumRanges::operator -=
+SfxUShortRanges& SfxUShortRanges::operator -=
 (
-    const SfxNumRanges &rRanges
+    const SfxUShortRanges &rRanges
 )
 
 /** <H3>Description</H3>
 
     Removes 'rRanges' from '*this'.
 
-    for each NUMTYPE n:
+    for each sal_uInt16 n:
         this->Contains( n ) && rRanges.Contains( n ) => !this'->Contains( n )
         this->Contains( n ) && !rRanges.Contains( n ) => this'->Contains( n )
         !this->Contains( n ) => !this'->Contains( n )
@@ -446,19 +446,19 @@ SfxNumRanges& SfxNumRanges::operator -=
 
     // differentiate 'rRanges' in a temporary copy of '*this'
     // (size is computed for maximal possibly split-count plus terminating 0)
-    NUMTYPE nThisSize = Count_Impl(_pRanges);
-    NUMTYPE nTargetSize = 1 + (  nThisSize + Count_Impl(rRanges._pRanges) );
-    NUMTYPE *pTarget = new NUMTYPE[ nTargetSize ];
-    memset( pTarget, 0, sizeof(NUMTYPE)*nTargetSize );
-    memcpy( pTarget, _pRanges, sizeof(NUMTYPE)*nThisSize );
+    sal_uInt16 nThisSize = Count_Impl(_pRanges);
+    sal_uInt16 nTargetSize = 1 + (  nThisSize + Count_Impl(rRanges._pRanges) );
+    sal_uInt16 *pTarget = new sal_uInt16[ nTargetSize ];
+    memset( pTarget, 0, sizeof(sal_uInt16)*nTargetSize );
+    memcpy( pTarget, _pRanges, sizeof(sal_uInt16)*nThisSize );
 
-    NUMTYPE nPos1 = 0, nPos2 = 0, nTargetPos = 0;
+    sal_uInt16 nPos1 = 0, nPos2 = 0, nTargetPos = 0;
     while( _pRanges[ nPos1 ] )
     {
-        NUMTYPE l1 = _pRanges[ nPos1 ];      // lower bound of interval 1
-        NUMTYPE u1 = _pRanges[ nPos1+1 ];    // upper bound of interval 1
-        NUMTYPE l2 = rRanges._pRanges[ nPos2 ];      // lower bound of interval 2
-        NUMTYPE u2 = rRanges._pRanges[ nPos2+1 ];    // upper bound of interval 2
+        sal_uInt16 l1 = _pRanges[ nPos1 ];      // lower bound of interval 1
+        sal_uInt16 u1 = _pRanges[ nPos1+1 ];    // upper bound of interval 1
+        sal_uInt16 l2 = rRanges._pRanges[ nPos2 ];      // lower bound of interval 2
+        sal_uInt16 u2 = rRanges._pRanges[ nPos2+1 ];    // upper bound of interval 2
 
         // boundary cases
         // * subtrahend is empty -> copy the minuend
@@ -544,7 +544,7 @@ SfxNumRanges& SfxNumRanges::operator -=
         }
 
         // we should never be here
-        OSL_FAIL( "SfxNumRanges::operator-=: internal error" );
+        OSL_FAIL( "SfxUShortRanges::operator-=: internal error" );
     } // while
 
     pTarget[ nTargetPos ] = 0;
@@ -552,11 +552,11 @@ SfxNumRanges& SfxNumRanges::operator -=
     // assign the differentiated ranges
     delete[] _pRanges;
 
-    NUMTYPE nUShorts = Count_Impl(pTarget) + 1;
+    sal_uInt16 nUShorts = Count_Impl(pTarget) + 1;
     if ( 1 != nUShorts )
     {
-        _pRanges = new NUMTYPE[ nUShorts ];
-        memcpy( _pRanges, pTarget, nUShorts * sizeof(NUMTYPE) );
+        _pRanges = new sal_uInt16[ nUShorts ];
+        memcpy( _pRanges, pTarget, nUShorts * sizeof(sal_uInt16) );
     }
     else
         _pRanges = 0;
@@ -567,16 +567,16 @@ SfxNumRanges& SfxNumRanges::operator -=
 
 //------------------------------------------------------------------------
 
-SfxNumRanges& SfxNumRanges::operator /=
+SfxUShortRanges& SfxUShortRanges::operator /=
 (
-    const SfxNumRanges &rRanges
+    const SfxUShortRanges &rRanges
 )
 
 /** <H3>Description</H3>
 
     Determines intersection of '*this' with 'rRanges'.
 
-    for each NUMTYPE n:
+    for each sal_uInt16 n:
         this->Contains( n ) && rRanges.Contains( n ) => this'->Contains( n )
         !this->Contains( n ) => !this'->Contains( n )
         !rRanges.Contains( n ) => !this'->Contains( n )
@@ -590,7 +590,7 @@ SfxNumRanges& SfxNumRanges::operator /=
     {
         delete[] _pRanges;
 
-        _pRanges = new NUMTYPE[1];
+        _pRanges = new sal_uInt16[1];
         _pRanges[0] = 0;
 
         return *this;
@@ -598,19 +598,19 @@ SfxNumRanges& SfxNumRanges::operator /=
 
     // intersect 'rRanges' in a temporary copy of '*this'
     // (size is computed for maximal possibly split-count plus terminating 0)
-    NUMTYPE nThisSize = Count_Impl(_pRanges);
-    NUMTYPE nTargetSize = 1 + (  nThisSize + Count_Impl(rRanges._pRanges) );
-    NUMTYPE *pTarget = new NUMTYPE[ nTargetSize ];
-    memset( pTarget, 0, sizeof(NUMTYPE)*nTargetSize );
-    memcpy( pTarget, _pRanges, sizeof(NUMTYPE)*nThisSize );
+    sal_uInt16 nThisSize = Count_Impl(_pRanges);
+    sal_uInt16 nTargetSize = 1 + (  nThisSize + Count_Impl(rRanges._pRanges) );
+    sal_uInt16 *pTarget = new sal_uInt16[ nTargetSize ];
+    memset( pTarget, 0, sizeof(sal_uInt16)*nTargetSize );
+    memcpy( pTarget, _pRanges, sizeof(sal_uInt16)*nThisSize );
 
-    NUMTYPE nPos1 = 0, nPos2 = 0, nTargetPos = 0;
+    sal_uInt16 nPos1 = 0, nPos2 = 0, nTargetPos = 0;
     while( _pRanges[ nPos1 ] != 0 && rRanges._pRanges[ nPos2 ] != 0 )
     {
-        NUMTYPE l1 = _pRanges[ nPos1 ];      // lower bound of interval 1
-        NUMTYPE u1 = _pRanges[ nPos1+1 ];    // upper bound of interval 1
-        NUMTYPE l2 = rRanges._pRanges[ nPos2 ];      // lower bound of interval 2
-        NUMTYPE u2 = rRanges._pRanges[ nPos2+1 ];    // upper bound of interval 2
+        sal_uInt16 l1 = _pRanges[ nPos1 ];      // lower bound of interval 1
+        sal_uInt16 u1 = _pRanges[ nPos1+1 ];    // upper bound of interval 1
+        sal_uInt16 l2 = rRanges._pRanges[ nPos2 ];      // lower bound of interval 2
+        sal_uInt16 u2 = rRanges._pRanges[ nPos2+1 ];    // upper bound of interval 2
 
         if( u1 < l2 )
         {
@@ -672,11 +672,11 @@ SfxNumRanges& SfxNumRanges::operator /=
     // assign the intersected ranges
     delete[] _pRanges;
 
-    NUMTYPE nUShorts = Count_Impl(pTarget) + 1;
+    sal_uInt16 nUShorts = Count_Impl(pTarget) + 1;
     if ( 1 != nUShorts )
     {
-        _pRanges = new NUMTYPE[ nUShorts ];
-        memcpy( _pRanges, pTarget, nUShorts * sizeof(NUMTYPE) );
+        _pRanges = new sal_uInt16[ nUShorts ];
+        memcpy( _pRanges, pTarget, nUShorts * sizeof(sal_uInt16) );
     }
     else
         _pRanges = 0;
@@ -687,7 +687,7 @@ SfxNumRanges& SfxNumRanges::operator /=
 
 //------------------------------------------------------------------------
 
-NUMTYPE SfxNumRanges::Count() const
+sal_uInt16 SfxUShortRanges::Count() const
 
 /** <H3>Description</H3>
 
commit 84dc8e5b5504e5f54fba695d4338d022681d85cf
Author: Thomas Arnhold <thomas at arnhold.org>
Date:   Mon Mar 11 13:07:34 2013 +0100

    reduce some uglyness
    
    As there are no other users of this files, those macros can be expanded:
    
    NUMTYPE -> sal_uInt16
    SfxXRangeItem -> SfxRangeItem
    SfxXRangesItem -> SfxUShortRangesItem
    
    Change-Id: I35361e0622a8787d938fc6c6745c4169ad6d909f

diff --git a/svl/inc/svl/rngitem.hxx b/svl/inc/svl/rngitem.hxx
index 698641d..cf23e9c 100644
--- a/svl/inc/svl/rngitem.hxx
+++ b/svl/inc/svl/rngitem.hxx
@@ -19,19 +19,6 @@
 
 #ifndef _SFXRNGITEM_HXX
 
-#ifndef NUMTYPE
-
-#define NUMTYPE sal_uInt16
-#define SfxXRangeItem SfxRangeItem
-#define SfxXRangesItem SfxUShortRangesItem
-#include <svl/rngitem.hxx>
-#undef NUMTYPE
-#undef SfxXRangeItem
-#undef SfxXRangesItem
-
-#define _SFXRNGITEM_HXX
-
-#else
 #include "svl/svldllapi.h"
 #include <svl/poolitem.hxx>
 
@@ -39,16 +26,16 @@ class SvStream;
 
 // -----------------------------------------------------------------------
 
-class SVL_DLLPUBLIC SfxXRangeItem : public SfxPoolItem
+class SVL_DLLPUBLIC SfxRangeItem : public SfxPoolItem
 {
 private:
-    NUMTYPE                     nFrom;
-    NUMTYPE                     nTo;
+    sal_uInt16                  nFrom;
+    sal_uInt16                  nTo;
 public:
                                 TYPEINFO();
-                                SfxXRangeItem();
-                                SfxXRangeItem( sal_uInt16 nWID, NUMTYPE nFrom, NUMTYPE nTo );
-                                SfxXRangeItem( const SfxXRangeItem& rItem );
+                                SfxRangeItem();
+                                SfxRangeItem( sal_uInt16 nWID, sal_uInt16 nFrom, sal_uInt16 nTo );
+                                SfxRangeItem( const SfxRangeItem& rItem );
     virtual int                 operator==( const SfxPoolItem& ) const;
     virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
                                     SfxMapUnit eCoreMetric,
@@ -56,28 +43,28 @@ public:
                                     OUString &rText,
                                     const IntlWrapper * = 0 ) const;
     virtual SfxPoolItem*        Clone( SfxItemPool *pPool = 0 ) const;
-    inline NUMTYPE&             From() { return nFrom; }
-    inline NUMTYPE              From() const { return nFrom; }
-    inline NUMTYPE&             To() { return nTo; }
-    inline NUMTYPE              To() const { return nTo; }
-    inline sal_Bool                 HasRange() const { return nTo>nFrom; }
+    inline sal_uInt16&          From() { return nFrom; }
+    inline sal_uInt16           From() const { return nFrom; }
+    inline sal_uInt16&          To() { return nTo; }
+    inline sal_uInt16           To() const { return nTo; }
+    inline sal_Bool             HasRange() const { return nTo>nFrom; }
     virtual SfxPoolItem*        Create( SvStream &, sal_uInt16 nVersion ) const;
     virtual SvStream&           Store( SvStream &, sal_uInt16 nItemVersion ) const;
 };
 
 // -----------------------------------------------------------------------
 
-class SVL_DLLPUBLIC SfxXRangesItem : public SfxPoolItem
+class SVL_DLLPUBLIC SfxUShortRangesItem : public SfxPoolItem
 {
 private:
-    NUMTYPE*                    _pRanges;
+    sal_uInt16*                 _pRanges;
 
 public:
                                 TYPEINFO();
-                                SfxXRangesItem();
-                                SfxXRangesItem( sal_uInt16 nWID, SvStream &rStream );
-                                SfxXRangesItem( const SfxXRangesItem& rItem );
-    virtual                     ~SfxXRangesItem();
+                                SfxUShortRangesItem();
+                                SfxUShortRangesItem( sal_uInt16 nWID, SvStream &rStream );
+                                SfxUShortRangesItem( const SfxUShortRangesItem& rItem );
+    virtual                     ~SfxUShortRangesItem();
     virtual int                 operator==( const SfxPoolItem& ) const;
     virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
                                     SfxMapUnit eCoreMetric,
@@ -85,12 +72,11 @@ public:
                                     OUString &rText,
                                     const IntlWrapper * = 0 ) const;
     virtual SfxPoolItem*        Clone( SfxItemPool *pPool = 0 ) const;
-    inline const NUMTYPE*       GetRanges() const { return _pRanges; }
+    inline const sal_uInt16*    GetRanges() const { return _pRanges; }
     virtual SfxPoolItem*        Create( SvStream &, sal_uInt16 nVersion ) const;
     virtual SvStream&           Store( SvStream &, sal_uInt16 nItemVersion ) const;
 };
 
 #endif
-#endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/items/rngitem.cxx b/svl/source/items/rngitem.cxx
index 72f890d..645c543 100644
--- a/svl/source/items/rngitem.cxx
+++ b/svl/source/items/rngitem.cxx
@@ -18,22 +18,190 @@
  */
 
 #include <tools/stream.hxx>
+#include <svl/rngitem.hxx>
 
-#ifndef NUMTYPE
+static inline sal_uInt16 Count_Impl(const sal_uInt16 * pRanges)
+{
+    sal_uInt16 nCount = 0;
+    for (; *pRanges; pRanges += 2) nCount += 2;
+    return nCount;
+}
 
-#define NUMTYPE sal_uInt16
-#define SfxXRangeItem SfxRangeItem
-#define SfxXRangesItem SfxUShortRangesItem
-#include <svl/rngitem.hxx>
-#include "rngitem_inc.cxx"
+// -----------------------------------------------------------------------
+
+TYPEINIT1_AUTOFACTORY(SfxRangeItem, SfxPoolItem);
+TYPEINIT1_AUTOFACTORY(SfxUShortRangesItem, SfxPoolItem);
+
+sal_uInt16 Count_Impl( const sal_uInt16 *pRanges );
+
+// -----------------------------------------------------------------------
+
+SfxRangeItem::SfxRangeItem()
+{
+    nFrom = 0;
+    nTo = 0;
+}
+
+// -----------------------------------------------------------------------
+
+SfxRangeItem::SfxRangeItem( sal_uInt16 which, sal_uInt16 from, sal_uInt16 to ):
+    SfxPoolItem( which ),
+    nFrom( from ),
+    nTo( to )
+{
+}
+
+// -----------------------------------------------------------------------
+
+SfxRangeItem::SfxRangeItem( const SfxRangeItem& rItem ) :
+    SfxPoolItem( rItem )
+{
+    nFrom = rItem.nFrom;
+    nTo = rItem.nTo;
+}
+
+// -----------------------------------------------------------------------
+
+SfxItemPresentation SfxRangeItem::GetPresentation
+(
+    SfxItemPresentation     /*ePresentation*/,
+    SfxMapUnit              /*eCoreMetric*/,
+    SfxMapUnit              /*ePresentationMetric*/,
+    OUString&               rText,
+    const IntlWrapper *
+)   const
+{
+    rText = OUString::number(nFrom) + ":" + OUString::number(nTo);
+    return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+// -----------------------------------------------------------------------
+
+int SfxRangeItem::operator==( const SfxPoolItem& rItem ) const
+{
+    DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+    SfxRangeItem* pT = (SfxRangeItem*)&rItem;
+    if( nFrom==pT->nFrom && nTo==pT->nTo )
+        return 1;
+    return 0;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxRangeItem::Clone(SfxItemPool *) const
+{
+    return new SfxRangeItem( Which(), nFrom, nTo );
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SfxRangeItem::Create(SvStream &rStream, sal_uInt16) const
+{
+    sal_uInt16 nVon(0), nBis(0);
+    rStream >> nVon;
+    rStream >> nBis;
+    return new SfxRangeItem( Which(), nVon, nBis );
+}
+
+// -----------------------------------------------------------------------
+
+SvStream& SfxRangeItem::Store(SvStream &rStream, sal_uInt16) const
+{
+    rStream << nFrom;
+    rStream << nTo;
+    return rStream;
+}
+
+//=========================================================================
+
+SfxUShortRangesItem::SfxUShortRangesItem()
+:   _pRanges(0)
+{
+}
+
+//-------------------------------------------------------------------------
+
+SfxUShortRangesItem::SfxUShortRangesItem( sal_uInt16 nWID, SvStream &rStream )
+:   SfxPoolItem( nWID )
+{
+    sal_uInt16 nCount(0);
+    rStream >> nCount;
+    _pRanges = new sal_uInt16[nCount + 1];
+    for ( sal_uInt16 n = 0; n < nCount; ++n )
+        rStream >> _pRanges[n];
+    _pRanges[nCount] = 0;
+}
+
+//-------------------------------------------------------------------------
+
+SfxUShortRangesItem::SfxUShortRangesItem( const SfxUShortRangesItem& rItem )
+:   SfxPoolItem( rItem )
+{
+    sal_uInt16 nCount = Count_Impl(rItem._pRanges) + 1;
+    _pRanges = new sal_uInt16[nCount];
+    memcpy( _pRanges, rItem._pRanges, sizeof(sal_uInt16) * nCount );
+}
+
+//-------------------------------------------------------------------------
+
+SfxUShortRangesItem::~SfxUShortRangesItem()
+{
+    delete _pRanges;
+}
+
+//-------------------------------------------------------------------------
+
+int SfxUShortRangesItem::operator==( const SfxPoolItem &rItem ) const
+{
+    const SfxUShortRangesItem &rOther = (const SfxUShortRangesItem&) rItem;
+    if ( !_pRanges && !rOther._pRanges )
+        return sal_True;
+    if ( _pRanges || rOther._pRanges )
+        return sal_False;
+
+    sal_uInt16 n;
+    for ( n = 0; _pRanges[n] && rOther._pRanges[n]; ++n )
+        if ( *_pRanges != rOther._pRanges[n] )
+            return 0;
+
+    return !_pRanges[n] && !rOther._pRanges[n];
+}
+
+//-------------------------------------------------------------------------
+
+SfxItemPresentation SfxUShortRangesItem::GetPresentation( SfxItemPresentation /*ePres*/,
+                                    SfxMapUnit /*eCoreMetric*/,
+                                    SfxMapUnit /*ePresMetric*/,
+                                    OUString & /*rText*/,
+                                    const IntlWrapper * ) const
+{
+    // not implemented
+    return SFX_ITEM_PRESENTATION_NONE;
+}
+
+//-------------------------------------------------------------------------
+
+SfxPoolItem* SfxUShortRangesItem::Clone( SfxItemPool * ) const
+{
+    return new SfxUShortRangesItem( *this );
+}
 
-#else
+//-------------------------------------------------------------------------
 
-// We leave this condition just in case NUMTYPE has been defined externally to this
-// file and we are supposed to define the SfxXRangeItem based on that.
+SfxPoolItem* SfxUShortRangesItem::Create( SvStream &rStream, sal_uInt16 ) const
+{
+    return new SfxUShortRangesItem( Which(), rStream );
+}
 
-#include "rngitem_inc.cxx"
+//-------------------------------------------------------------------------
 
-#endif
+SvStream& SfxUShortRangesItem::Store( SvStream &rStream, sal_uInt16 ) const
+{
+    sal_uInt16 nCount = Count_Impl( _pRanges );
+    rStream >> nCount;
+    for ( sal_uInt16 n = 0; _pRanges[n]; ++n )
+        rStream >> _pRanges[n];
+    return rStream;
+}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/items/rngitem_inc.cxx b/svl/source/items/rngitem_inc.cxx
deleted file mode 100644
index 572c89e..0000000
--- a/svl/source/items/rngitem_inc.cxx
+++ /dev/null
@@ -1,212 +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 .
- */
-
-// This snippet of code is included by rngitem.cxx but not compiled directly.
-// Ugly hack, probably due to lack of templates in the 20th century.
-
-static inline NUMTYPE Count_Impl(const NUMTYPE * pRanges)
-{
-    NUMTYPE nCount = 0;
-    for (; *pRanges; pRanges += 2) nCount += 2;
-    return nCount;
-}
-
-// -----------------------------------------------------------------------
-
-TYPEINIT1_AUTOFACTORY(SfxXRangeItem, SfxPoolItem);
-TYPEINIT1_AUTOFACTORY(SfxXRangesItem, SfxPoolItem);
-
-NUMTYPE Count_Impl( const NUMTYPE *pRanges );
-
-// -----------------------------------------------------------------------
-
-SfxXRangeItem::SfxXRangeItem()
-{
-    nFrom = 0;
-    nTo = 0;
-}
-
-// -----------------------------------------------------------------------
-
-SfxXRangeItem::SfxXRangeItem( sal_uInt16 which, NUMTYPE from, NUMTYPE to ):
-    SfxPoolItem( which ),
-    nFrom( from ),
-    nTo( to )
-{
-}
-
-// -----------------------------------------------------------------------
-
-SfxXRangeItem::SfxXRangeItem( const SfxXRangeItem& rItem ) :
-    SfxPoolItem( rItem )
-{
-    nFrom = rItem.nFrom;
-    nTo = rItem.nTo;
-}
-
-// -----------------------------------------------------------------------
-
-SfxItemPresentation SfxXRangeItem::GetPresentation
-(
-    SfxItemPresentation     /*ePresentation*/,
-    SfxMapUnit              /*eCoreMetric*/,
-    SfxMapUnit              /*ePresentationMetric*/,
-    OUString&               rText,
-    const IntlWrapper *
-)   const
-{
-    rText = OUString::number(nFrom) + ":" + OUString::number(nTo);
-    return SFX_ITEM_PRESENTATION_NAMELESS;
-}
-
-// -----------------------------------------------------------------------
-
-int SfxXRangeItem::operator==( const SfxPoolItem& rItem ) const
-{
-    DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
-    SfxXRangeItem* pT = (SfxXRangeItem*)&rItem;
-    if( nFrom==pT->nFrom && nTo==pT->nTo )
-        return 1;
-    return 0;
-}
-
-// -----------------------------------------------------------------------
-
-SfxPoolItem* SfxXRangeItem::Clone(SfxItemPool *) const
-{
-    return new SfxXRangeItem( Which(), nFrom, nTo );
-}
-
-// -----------------------------------------------------------------------
-
-SfxPoolItem* SfxXRangeItem::Create(SvStream &rStream, sal_uInt16) const
-{
-    NUMTYPE nVon(0), nBis(0);
-    rStream >> nVon;
-    rStream >> nBis;
-    return new SfxXRangeItem( Which(), nVon, nBis );
-}
-
-// -----------------------------------------------------------------------
-
-SvStream& SfxXRangeItem::Store(SvStream &rStream, sal_uInt16) const
-{
-    rStream << nFrom;
-    rStream << nTo;
-    return rStream;
-}
-
-//=========================================================================
-
-SfxXRangesItem::SfxXRangesItem()
-:   _pRanges(0)
-{
-}
-
-//-------------------------------------------------------------------------
-
-SfxXRangesItem::SfxXRangesItem( sal_uInt16 nWID, SvStream &rStream )
-:   SfxPoolItem( nWID )
-{
-    NUMTYPE nCount(0);
-    rStream >> nCount;
-    _pRanges = new NUMTYPE[nCount + 1];
-    for ( NUMTYPE n = 0; n < nCount; ++n )
-        rStream >> _pRanges[n];
-    _pRanges[nCount] = 0;
-}
-
-//-------------------------------------------------------------------------
-
-SfxXRangesItem::SfxXRangesItem( const SfxXRangesItem& rItem )
-:   SfxPoolItem( rItem )
-{
-    NUMTYPE nCount = Count_Impl(rItem._pRanges) + 1;
-    _pRanges = new NUMTYPE[nCount];
-    memcpy( _pRanges, rItem._pRanges, sizeof(NUMTYPE) * nCount );
-}
-
-//-------------------------------------------------------------------------
-
-SfxXRangesItem::~SfxXRangesItem()
-{
-    delete _pRanges;
-}
-
-//-------------------------------------------------------------------------
-
-int SfxXRangesItem::operator==( const SfxPoolItem &rItem ) const
-{
-    const SfxXRangesItem &rOther = (const SfxXRangesItem&) rItem;
-    if ( !_pRanges && !rOther._pRanges )
-        return sal_True;
-    if ( _pRanges || rOther._pRanges )
-        return sal_False;
-
-    NUMTYPE n;
-    for ( n = 0; _pRanges[n] && rOther._pRanges[n]; ++n )
-        if ( *_pRanges != rOther._pRanges[n] )
-            return 0;
-
-    return !_pRanges[n] && !rOther._pRanges[n];
-}
-
-//-------------------------------------------------------------------------
-
-SfxItemPresentation SfxXRangesItem::GetPresentation( SfxItemPresentation /*ePres*/,
-                                    SfxMapUnit /*eCoreMetric*/,
-                                    SfxMapUnit /*ePresMetric*/,
-                                    OUString & /*rText*/,
-                                    const IntlWrapper * ) const
-{
-    // not implemented
-    return SFX_ITEM_PRESENTATION_NONE;
-}
-
-//-------------------------------------------------------------------------
-
-SfxPoolItem* SfxXRangesItem::Clone( SfxItemPool * ) const
-{
-    return new SfxXRangesItem( *this );
-}
-
-//-------------------------------------------------------------------------
-
-SfxPoolItem* SfxXRangesItem::Create( SvStream &rStream, sal_uInt16 ) const
-{
-    return new SfxXRangesItem( Which(), rStream );
-}
-
-//-------------------------------------------------------------------------
-
-SvStream& SfxXRangesItem::Store( SvStream &rStream, sal_uInt16 ) const
-{
-    NUMTYPE nCount = Count_Impl( _pRanges );
-    rStream >> nCount;
-    for ( NUMTYPE n = 0; _pRanges[n]; ++n )
-        rStream >> _pRanges[n];
-    return rStream;
-}
-
-
-#undef NUMTYPE
-#undef SfxXRangeItem
-#undef SfxXRangesItem
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list