Kaydet (Commit) f0fdee8a authored tarafından Miklos Vajna's avatar Miklos Vajna

oox: replace redundant STATIC_ARRAY_SIZE macro with SAL_N_ELEMENTS

Change-Id: I8cf274902bb5fda9fa70ab2af9e399db82d85d1d
üst effb5781
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <algorithm> #include <algorithm>
#include <limits> #include <limits>
#include <boost/static_assert.hpp> #include <boost/static_assert.hpp>
#include <sal/macros.h>
#include <osl/endian.h> #include <osl/endian.h>
#include <rtl/math.hxx> #include <rtl/math.hxx>
#include <rtl/string.hxx> #include <rtl/string.hxx>
...@@ -33,19 +34,15 @@ namespace oox { ...@@ -33,19 +34,15 @@ namespace oox {
// Helper macros ============================================================== // 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 /** Expands to a pointer behind the last element of a STATIC data array (like
STL end()). */ STL end()). */
#define STATIC_ARRAY_END( array ) \ #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 /** Expands to the 'index'-th element of a STATIC data array, or to 'def', if
'index' is out of the array limits. */ 'index' is out of the array limits. */
#define STATIC_ARRAY_SELECT( array, index, def ) \ #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 /** Expands to a temporary OString, created from a literal(!) character
array. */ array. */
......
...@@ -142,7 +142,7 @@ struct NamespaceIds: public rtl::StaticWithInit< ...@@ -142,7 +142,7 @@ struct NamespaceIds: public rtl::StaticWithInit<
NMSP_xlsExtLst 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 ) for( sal_Int32 i=0; i<aRet.getLength(); ++i )
aRet[i] = make_Pair( aRet[i] = make_Pair(
OUString::createFromAscii(namespaceURIs[i]), OUString::createFromAscii(namespaceURIs[i]),
......
...@@ -81,9 +81,9 @@ const sal_Char* const sppcBaseNames[] = ...@@ -81,9 +81,9 @@ const sal_Char* const sppcBaseNames[] =
OUString lclGetBaseName( sal_Unicode cBuiltinId ) 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; OUStringBuffer aBuffer;
if( cBuiltinId < STATIC_ARRAY_SIZE( sppcBaseNames ) ) if( cBuiltinId < SAL_N_ELEMENTS( sppcBaseNames ) )
aBuffer.appendAscii( sppcBaseNames[ cBuiltinId ] ); aBuffer.appendAscii( sppcBaseNames[ cBuiltinId ] );
else else
aBuffer.append( static_cast< sal_Int32 >( cBuiltinId ) ); aBuffer.append( static_cast< sal_Int32 >( cBuiltinId ) );
...@@ -102,7 +102,7 @@ sal_Unicode lclGetBuiltinIdFromPrefixedName( const OUString& rModelName ) ...@@ -102,7 +102,7 @@ sal_Unicode lclGetBuiltinIdFromPrefixedName( const OUString& rModelName )
sal_Int32 nPrefixLen = aPrefix.getLength(); sal_Int32 nPrefixLen = aPrefix.getLength();
if( rModelName.matchIgnoreAsciiCase( aPrefix ) ) 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 ); OUString aBaseName = lclGetBaseName( cBuiltinId );
sal_Int32 nBaseNameLen = aBaseName.getLength(); sal_Int32 nBaseNameLen = aBaseName.getLength();
...@@ -116,7 +116,7 @@ sal_Unicode lclGetBuiltinIdFromPrefixedName( const OUString& rModelName ) ...@@ -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'. */ /** returns the built-in name identifier from a built-in base name, e.g. 'Print_Area'. */
sal_Unicode lclGetBuiltinIdFromBaseName( const OUString& rModelName ) 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 ] ) ) if( rModelName.equalsIgnoreAsciiCaseAscii( sppcBaseNames[ cBuiltinId ] ) )
return cBuiltinId; return cBuiltinId;
return BIFF_DEFNAME_UNKNOWN; return BIFF_DEFNAME_UNKNOWN;
......
...@@ -337,7 +337,7 @@ void BiffDrawingObjectBase::convertFillProperties( ShapePropertyMap& rPropMap, c ...@@ -337,7 +337,7 @@ void BiffDrawingObjectBase::convertFillProperties( ShapePropertyMap& rPropMap, c
{ 0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00 }, { 0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00 },
{ 0x80, 0x00, 0x08, 0x00, 0x80, 0x00, 0x08, 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 // create 2-colored 8x8 DIB
SvMemoryStream aMemStrm; SvMemoryStream aMemStrm;
// { 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x01, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00 } // { 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x01, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00 }
......
...@@ -2503,7 +2503,7 @@ const sal_Char* const sppcStyleNames[] = ...@@ -2503,7 +2503,7 @@ const sal_Char* const sppcStyleNames[] =
"60% - Accent6", "60% - Accent6",
"Explanatory Text" "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 ) OUString lclGetBuiltinStyleName( sal_Int32 nBuiltinId, const OUString& rName, sal_Int32 nLevel = 0 )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment