diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-06-07 14:43:34 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-06-07 18:06:03 +0200 |
commit | f0fdee8abf7d46f9afb90e5d7c78037fff5b34b1 (patch) | |
tree | 598fcde86b4669f7eca70ff2703d93ec24f76e45 | |
parent | effb5781dd0414b04dda4358605519e88a8ed3ac (diff) |
oox: replace redundant STATIC_ARRAY_SIZE macro with SAL_N_ELEMENTS
Change-Id: I8cf274902bb5fda9fa70ab2af9e399db82d85d1d
-rw-r--r-- | include/oox/helper/helper.hxx | 9 | ||||
-rw-r--r-- | oox/source/core/xmlfilterbase.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/oox/defnamesbuffer.cxx | 8 | ||||
-rw-r--r-- | sc/source/filter/oox/drawingmanager.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/oox/stylesbuffer.cxx | 2 |
5 files changed, 10 insertions, 13 deletions
diff --git a/include/oox/helper/helper.hxx b/include/oox/helper/helper.hxx index a5563f40ac35..1f5942b80cb1 100644 --- a/include/oox/helper/helper.hxx +++ b/include/oox/helper/helper.hxx @@ -23,6 +23,7 @@ #include <algorithm> #include <limits> #include <boost/static_assert.hpp> +#include <sal/macros.h> #include <osl/endian.h> #include <rtl/math.hxx> #include <rtl/string.hxx> @@ -33,19 +34,15 @@ namespace oox { // Helper macros ============================================================== -/** Expands to the number of elements in a STATIC data array. */ -#define STATIC_ARRAY_SIZE( array ) \ - (sizeof(array)/sizeof(*(array))) - /** Expands to a pointer behind the last element of a STATIC data array (like STL end()). */ #define STATIC_ARRAY_END( array ) \ - ((array)+STATIC_ARRAY_SIZE(array)) + ((array)+SAL_N_ELEMENTS(array)) /** Expands to the 'index'-th element of a STATIC data array, or to 'def', if 'index' is out of the array limits. */ #define STATIC_ARRAY_SELECT( array, index, def ) \ - ((static_cast<size_t>(index) < STATIC_ARRAY_SIZE(array)) ? ((array)[static_cast<size_t>(index)]) : (def)) + ((static_cast<size_t>(index) < SAL_N_ELEMENTS(array)) ? ((array)[static_cast<size_t>(index)]) : (def)) /** Expands to a temporary OString, created from a literal(!) character array. */ diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index 746ba2ed913b..8dd5cfe99f65 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -142,7 +142,7 @@ struct NamespaceIds: public rtl::StaticWithInit< NMSP_xlsExtLst }; - Sequence< beans::Pair< OUString, sal_Int32 > > aRet(STATIC_ARRAY_SIZE(namespaceIds)); + Sequence< beans::Pair< OUString, sal_Int32 > > aRet(SAL_N_ELEMENTS(namespaceIds)); for( sal_Int32 i=0; i<aRet.getLength(); ++i ) aRet[i] = make_Pair( OUString::createFromAscii(namespaceURIs[i]), diff --git a/sc/source/filter/oox/defnamesbuffer.cxx b/sc/source/filter/oox/defnamesbuffer.cxx index f68799f6d5c5..d153dfe3df5f 100644 --- a/sc/source/filter/oox/defnamesbuffer.cxx +++ b/sc/source/filter/oox/defnamesbuffer.cxx @@ -81,9 +81,9 @@ const sal_Char* const sppcBaseNames[] = OUString lclGetBaseName( sal_Unicode cBuiltinId ) { - OSL_ENSURE( cBuiltinId < STATIC_ARRAY_SIZE( sppcBaseNames ), "lclGetBaseName - unsupported built-in identifier" ); + OSL_ENSURE( cBuiltinId < SAL_N_ELEMENTS( sppcBaseNames ), "lclGetBaseName - unsupported built-in identifier" ); OUStringBuffer aBuffer; - if( cBuiltinId < STATIC_ARRAY_SIZE( sppcBaseNames ) ) + if( cBuiltinId < SAL_N_ELEMENTS( sppcBaseNames ) ) aBuffer.appendAscii( sppcBaseNames[ cBuiltinId ] ); else aBuffer.append( static_cast< sal_Int32 >( cBuiltinId ) ); @@ -102,7 +102,7 @@ sal_Unicode lclGetBuiltinIdFromPrefixedName( const OUString& rModelName ) sal_Int32 nPrefixLen = aPrefix.getLength(); if( rModelName.matchIgnoreAsciiCase( aPrefix ) ) { - for( sal_Unicode cBuiltinId = 0; cBuiltinId < STATIC_ARRAY_SIZE( sppcBaseNames ); ++cBuiltinId ) + for( sal_Unicode cBuiltinId = 0; cBuiltinId < SAL_N_ELEMENTS( sppcBaseNames ); ++cBuiltinId ) { OUString aBaseName = lclGetBaseName( cBuiltinId ); sal_Int32 nBaseNameLen = aBaseName.getLength(); @@ -116,7 +116,7 @@ sal_Unicode lclGetBuiltinIdFromPrefixedName( const OUString& rModelName ) /** returns the built-in name identifier from a built-in base name, e.g. 'Print_Area'. */ sal_Unicode lclGetBuiltinIdFromBaseName( const OUString& rModelName ) { - for( sal_Unicode cBuiltinId = 0; cBuiltinId < STATIC_ARRAY_SIZE( sppcBaseNames ); ++cBuiltinId ) + for( sal_Unicode cBuiltinId = 0; cBuiltinId < SAL_N_ELEMENTS( sppcBaseNames ); ++cBuiltinId ) if( rModelName.equalsIgnoreAsciiCaseAscii( sppcBaseNames[ cBuiltinId ] ) ) return cBuiltinId; return BIFF_DEFNAME_UNKNOWN; diff --git a/sc/source/filter/oox/drawingmanager.cxx b/sc/source/filter/oox/drawingmanager.cxx index c928aa52703e..5ca80ac07d14 100644 --- a/sc/source/filter/oox/drawingmanager.cxx +++ b/sc/source/filter/oox/drawingmanager.cxx @@ -337,7 +337,7 @@ void BiffDrawingObjectBase::convertFillProperties( ShapePropertyMap& rPropMap, c { 0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00 }, { 0x80, 0x00, 0x08, 0x00, 0x80, 0x00, 0x08, 0x00 } }; - const sal_uInt8* const pnPattern = sppnPatterns[ ::std::min< size_t >( rFillData.mnPattern - 2, STATIC_ARRAY_SIZE( sppnPatterns ) ) ]; + const sal_uInt8* const pnPattern = sppnPatterns[ ::std::min< size_t >( rFillData.mnPattern - 2, SAL_N_ELEMENTS( sppnPatterns ) ) ]; // create 2-colored 8x8 DIB SvMemoryStream aMemStrm; // { 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x01, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00 } diff --git a/sc/source/filter/oox/stylesbuffer.cxx b/sc/source/filter/oox/stylesbuffer.cxx index dc2f589cc6f9..628db5e915d6 100644 --- a/sc/source/filter/oox/stylesbuffer.cxx +++ b/sc/source/filter/oox/stylesbuffer.cxx @@ -2503,7 +2503,7 @@ const sal_Char* const sppcStyleNames[] = "60% - Accent6", "Explanatory Text" }; -const sal_Int32 snStyleNamesCount = static_cast< sal_Int32 >( STATIC_ARRAY_SIZE( sppcStyleNames ) ); +const sal_Int32 snStyleNamesCount = static_cast< sal_Int32 >( SAL_N_ELEMENTS( sppcStyleNames ) ); OUString lclGetBuiltinStyleName( sal_Int32 nBuiltinId, const OUString& rName, sal_Int32 nLevel = 0 ) { |