Hi,
some patches to fix EASY HACK 2.6
found some equivalent macros:
- elementsof
- ELEMENTS_OF_ARRAY
- bufsizeof
i'll try and replace them all with SAL_N_ELEMENTS tomorrow.
diff --git a/connectivity/source/drivers/dbase/DTable.cxx
b/connectivity/source/drivers/dbase/DTable.cxx
index 75c9922..621b5a1 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -183,7 +183,7 @@ void lcl_CalDate(sal_Int32 _nJulianDate,sal_Int32 _nJulianTime,com::sun::star::u
_rDateTime.Year = static_cast<sal_uInt16>(kc - 4716);
else
_rDateTime.Year = static_cast<sal_uInt16>(kc - 4715);
- } // if ( _nJulianDate )
+ }
if ( _nJulianTime )
{
@@ -192,26 +192,6 @@ void lcl_CalDate(sal_Int32 _nJulianDate,sal_Int32
_nJulianTime,com::sun::star::u
double d_h = d_m / 60;
_rDateTime.Hours = (sal_uInt16) (d_h);
_rDateTime.Minutes = (sal_uInt16) d_m; // integer _aDateTime.Minutes
- //// weird: time fix
- // int test = (_rDateTime.Hours % 3) * 100 + _rDateTime.Minutes;
- //int test_tbl[] = {0, 1, 2, 11, 12, 13, 22, 23, 24, 25, 34, 35, 36,
- // 45, 46, 47, 56, 57, 58, 107, 108, 109, 110, 119, 120, 121,
- // 130, 131, 132, 141, 142, 143, 152, 153, 154, 155, 204, 205,
- // 206, 215, 216, 217, 226, 227, 228, 237, 238, 239, 240, 249,
- // 250, 251};
- // for (int i = 0; i < sizeof(test_tbl)/sizeof(test_tbl[0]); i++)
- //{
- // if (test == test_tbl[i])
- // {
- // // frac += 0.000012;
- // //d_hour = frac * 24.0;
- // _rDateTime.Hours = (sal_uInt16)d_hour;
- // d_minute = (d_hour - (double)_rDateTime.Hours) * 60.0;
- // _rDateTime.Minutes = (sal_uInt16)d_minute;
- // break;
- // }
- // }
-
_rDateTime.Seconds = static_cast<sal_uInt16>(( d_m - (double) _rDateTime.Minutes ) * 60.0);
}
}
diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y
index 84e9aa2..a002e16 100644
--- a/connectivity/source/parse/sqlbison.y
+++ b/connectivity/source/parse/sqlbison.y
@@ -87,6 +87,7 @@
#include "connectivity/dbconversion.hxx"
#endif
#include <rtl/ustrbuf.hxx>
+#include <sal/macros.h>
#if defined __GNUC__
#pragma GCC system_header
@@ -4007,7 +4008,7 @@ IParseContext::InternationalKeyCode OParseContext::getIntlKeyCode(const
::rtl::O
KEY_VAR_POP,KEY_COLLECT,KEY_FUSION,KEY_INTERSECTION
};
- sal_uInt32 nCount = sizeof Intl_TokenID / sizeof Intl_TokenID[0];
+ sal_uInt32 nCount = SAL_N_ELEMENTS( Intl_TokenID );
for (sal_uInt32 i = 0; i < nCount; i++)
{
::rtl::OString aKey = getIntlKeywordAscii(Intl_TokenID[i]);
@@ -4221,7 +4222,7 @@ OSQLParseNode* OSQLParser::parseTree(::rtl::OUString& rErrorMessage,
//-----------------------------------------------------------------------------
::rtl::OUString OSQLParser::RuleIDToStr(sal_uInt32 nRuleID)
{
- OSL_ENSURE(nRuleID < (sizeof yytname/sizeof yytname[0]), "OSQLParser::RuleIDToStr: Invalid
nRuleId!");
+ OSL_ENSURE(nRuleID < SAL_N_ELEMENTS(yytname), "OSQLParser::RuleIDToStr: Invalid nRuleId!");
return ::rtl::OUString::createFromAscii(yytname[nRuleID]);
}
@@ -4230,7 +4231,7 @@ sal_uInt32 OSQLParser::StrToRuleID(const ::rtl::OString & rValue)
{
// In yysvar nach dem angegebenen Namen suchen, den Index zurueckliefern
// (oder 0, wenn nicht gefunden)
- static sal_uInt32 nLen = sizeof(yytname)/sizeof(yytname[0]);
+ static sal_uInt32 nLen = SAL_N_ELEMENTS(yytname);
for (sal_uInt32 i = YYTRANSLATE(SQL_TOKEN_INVALIDSYMBOL); i < (nLen-1); i++)
{
if (yytname && rValue == yytname[i])
diff --git a/desktop/win32/source/guistdio/guistdio.inc b/desktop/win32/source/guistdio/guistdio.inc
index 7f2bbe9..7009b24 100644
--- a/desktop/win32/source/guistdio/guistdio.inc
+++ b/desktop/win32/source/guistdio/guistdio.inc
@@ -43,6 +43,7 @@
#include <systools/win32/uwinapi.h>
#include <stdio.h>
+#include <sal/macros.h>
#ifdef UNOPKG
@@ -358,7 +359,7 @@ int _tmain( int, _TCHAR ** )
{
size_t len = lpLastDot - szModuleFileName;
_tcsncpy( szTargetFileName, szModuleFileName, len );
- _tcsncpy( szTargetFileName + len, _T(".EXE"),
sizeof(szTargetFileName)/sizeof(szTargetFileName[0]) - len );
+ _tcsncpy( szTargetFileName + len, _T(".EXE"), SAL_N_ELEMENTS(szTargetFileName) -
len );
}
// Create process with same command line, environment and stdio handles which
diff --git a/desktop/win32/source/officeloader/officeloader.cxx
b/desktop/win32/source/officeloader/officeloader.cxx
index 094d7fd..c5e34dc 100644
--- a/desktop/win32/source/officeloader/officeloader.cxx
+++ b/desktop/win32/source/officeloader/officeloader.cxx
@@ -51,6 +51,7 @@
#include <systools/win32/uwinapi.h>
#include "rtl/string.h"
+#include <sal/macros.h>
#include "../../../source/inc/exithelper.hxx"
#include "../extendloaderenvironment.hxx"
@@ -201,7 +202,7 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
{
size_t len = lpLastSlash - szModuleFileName + 1;
_tcsncpy( szPerfTuneIniFile, szModuleFileName, len );
- _tcsncpy( szPerfTuneIniFile + len, _T("perftune.ini"),
sizeof(szPerfTuneIniFile)/sizeof(szPerfTuneIniFile[0]) - len );
+ _tcsncpy( szPerfTuneIniFile + len, _T("perftune.ini"), SAL_N_ELEMENTS(szPerfTuneIniFile) -
len );
}
// Create process with same command line, environment and stdio handles which
diff --git a/desktop/win32/source/rebase/rebase.cxx b/desktop/win32/source/rebase/rebase.cxx
index 5afc00b..e712c8d 100644
--- a/desktop/win32/source/rebase/rebase.cxx
+++ b/desktop/win32/source/rebase/rebase.cxx
@@ -44,6 +44,7 @@
#include <time.h>
#include "sal/config.h"
+#include <sal/macros.h>
#include "tools/pathutils.hxx"
#define MY_LENGTH(s) (sizeof (s) / sizeof *(s) - 1)
@@ -120,7 +121,7 @@ void rebaseImagesInFolder( wchar_t* pszFolder, DWORD nNewImageBase )
{
size_t len = lpLastSlash - pszFolder + 1;
wcsncpy( szPattern, pszFolder, len );
- wcsncpy( szPattern + len, TEXT("*.dll"), sizeof(szPattern)/sizeof(szPattern[0]) - len );
+ wcsncpy( szPattern + len, TEXT("*.dll"), SAL_N_ELEMENTS(szPattern) - len );
}
WIN32_FIND_DATA aFindFileData;
@@ -138,7 +139,7 @@ void rebaseImagesInFolder( wchar_t* pszFolder, DWORD nNewImageBase )
{
size_t len = lpLastSlash - pszFolder + 1;
wcsncpy( szLibFilePath, pszFolder, len );
- wcsncpy( szLibFilePath + len, aFindFileData.cFileName,
sizeof(szLibFilePath)/sizeof(szLibFilePath[0]) - len );
+ wcsncpy( szLibFilePath + len, aFindFileData.cFileName,
SAL_N_ELEMENTS(szLibFilePath) - len );
}
rebaseImage( szLibFilePath, nNewImageBase );
diff --git a/sfx2/source/appl/shutdowniconaqua.mm b/sfx2/source/appl/shutdowniconaqua.mm
index 14f12c7..a5bca0c 100644
--- a/sfx2/source/appl/shutdowniconaqua.mm
+++ b/sfx2/source/appl/shutdowniconaqua.mm
@@ -36,6 +36,7 @@
#include "comphelper/sequenceashashmap.hxx"
#include "vos/mutex.hxx"
#include "sfx2/app.hxx"
+#include <sal/macros.h>
#include "app.hrc"
#define USE_APP_SHORTCUTS
#include "shutdownicon.hxx"
@@ -454,7 +455,7 @@ void aqua_init_systray()
}
// insert the menu entries for launching the applications
- for ( size_t i = 0; i < sizeof( aMenuItems ) / sizeof( aMenuItems[0] ); ++i )
+ for ( size_t i = 0; i < SAL_N_ELEMENTS( aMenuItems ); ++i )
{
if ( !aModuleOptions.IsModuleInstalled( aMenuItems[i].eModuleIdentifier ) )
// the complete application is not even installed
diff --git a/shell/source/win32/SysShExec.cxx b/shell/source/win32/SysShExec.cxx
index e89ebfb..729812f 100644
--- a/shell/source/win32/SysShExec.cxx
+++ b/shell/source/win32/SysShExec.cxx
@@ -35,6 +35,7 @@
#include <osl/diagnose.h>
#include "SysShExec.hxx"
#include <osl/file.hxx>
+#include <sal/macros.h>
#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
@@ -145,7 +146,7 @@ namespace // private
};
/* size of the table */
- #define ERRTABLESIZE (sizeof(errtable)/sizeof(errtable[0]))
+ #define ERRTABLESIZE (SAL_N_ELEMENTS(errtable))
/* The following two constants must be the minimum and maximum
values in the (contiguous) range of osl_File_E_xec Failure errors. */
diff --git a/sal/osl/os2/file.cxx b/sal/osl/os2/file.cxx
index 78243e7..349d9f5 100644
--- a/sal/osl/os2/file.cxx
+++ b/sal/osl/os2/file.cxx
@@ -54,6 +54,7 @@
#include <osl/diagnose.h>
#include "file_error_transl.h"
#include <osl/time.h>
+#include <sal/macros.h>
#include "file_url.h"
@@ -130,12 +131,10 @@ extern "C" oslFileHandle osl_createFileHandleFromFD( int fd );
//{ ERROR_NOT_ENOUGH_QUOTA, osl_File_E_NOMEM } /* 1816 */
};
- #define ELEMENTS_OF_ARRAY(arr) (sizeof(arr)/(sizeof((arr)[0])))
-
//#####################################################
oslFileError MapError(APIRET dwError)
{
- for (int i = 0; i < ELEMENTS_OF_ARRAY(errtable); ++i )
+ for (int i = 0; i < SAL_N_ELEMENTS(errtable); ++i )
{
if (dwError == errtable[i].oscode)
return static_cast<oslFileError>(errtable[i].errnocode);
diff --git a/sal/osl/os2/profile.c b/sal/osl/os2/profile.c
index ca2e70c..33fc557 100644
--- a/sal/osl/os2/profile.c
+++ b/sal/osl/os2/profile.c
@@ -1986,7 +1986,7 @@ static sal_Bool releaseProfile(osl_TProfileImpl* pProfile)
}
#if 0 // YD
-
+#include <sal/macros.h>
static sal_Bool lookupProfile(const sal_Char *pszPath, const sal_Char *pszFile, sal_Char *pPath)
{
sal_Char *pChr, *pStr;
@@ -2169,7 +2169,7 @@ static sal_Bool lookupProfile(const sal_Char *pszPath, const sal_Char
*pszFile,
int i = 0;
- for (i = 0; i < (sizeof(SubDirs) / sizeof(SubDirs[0])); i++)
+ for (i = 0; i < SAL_N_ELEMENTS(SubDirs); i++)
if (strnicmp(pStr + 1, SubDirs[i], strlen(SubDirs[i])) == 0)
{
if ( strlen(pszPath) <= 0)
diff --git a/sal/osl/unx/signal.c b/sal/osl/unx/signal.c
index 3f81f2d..0d5ee2b 100644
--- a/sal/osl/unx/signal.c
+++ b/sal/osl/unx/signal.c
@@ -68,6 +68,7 @@
#include <osl/signal.h>
#include <osl/process.h>
#include <osl/thread.h>
+#include <sal/macros.h>
#include <rtl/bootstrap.h>
#include <rtl/digest.h>
@@ -572,7 +573,7 @@ static int ReportCrash( int Signal )
void *stackframes[MAX_STACK_FRAMES];
int iFrame;
- int nFrames = backtrace( stackframes, sizeof(stackframes)/sizeof(stackframes[0]));
+ int nFrames = backtrace( stackframes, SAL_N_ELEMENTS(stackframes);
FILE *xmlout = NULL, *stackout = NULL, *checksumout = NULL;
int fdxml, fdstk, fdchksum;
@@ -755,7 +756,7 @@ static int ReportCrash( int Signal )
rtl_uString_release(crashrep_url);
rtl_uString_release(crashrep_path);
#if defined INCLUDE_BACKTRACE && (defined LINUX || defined MACOSX)
- snprintf( szShellCmd, sizeof(szShellCmd)/sizeof(szShellCmd[0]),
+ snprintf( szShellCmd, SAL_N_ELEMENTS(szShellCmd),
"%s -p %d -s %d -xml %s -chksum %s -stack %s -noui%s",
rtl_string_getStr(crashrep_path_system),
getpid(),
@@ -765,7 +766,7 @@ static int ReportCrash( int Signal )
pStackTempName,
bAutoCrashReport ? " -send" : "" );
#elif defined INCLUDE_BACKTRACE && defined SOLARIS
- snprintf( szShellCmd, sizeof(szShellCmd)/sizeof(szShellCmd[0]),
+ snprintf( szShellCmd, SAL_N_ELEMENTS(szShellCmd),
"%s -p %d -s %d -xml %s -chksum %s -noui%s",
rtl_string_getStr(crashrep_path_system),
getpid(),
@@ -774,7 +775,7 @@ static int ReportCrash( int Signal )
pChecksumTempName,
bAutoCrashReport ? " -send" : "" );
#else
- snprintf( szShellCmd, sizeof(szShellCmd)/sizeof(szShellCmd[0]),
+ snprintf( szShellCmd, SAL_N_ELEMENTS(szShellCmd),
"%s -p %d -s %d -noui%s",
rtl_string_getStr(crashrep_path_system),
getpid(), Signal, bAutoCrashReport ? " -send" : "" );
@@ -820,7 +821,7 @@ static void PrintStack( int sig )
{
#if ! defined(MACOSX) || defined(INCLUDE_BACKTRACE)
void *buffer[MAX_STACK_FRAMES];
- int size = backtrace( buffer, sizeof(buffer) / sizeof(buffer[0]) );
+ int size = backtrace( buffer, SAL_N_ELEMENTS(buffer) );
#endif
fprintf( stderr, "\n\nFatal exception: Signal %d\n", sig );
diff --git a/sal/qa/rtl/textenc/rtl_textcvt.cxx b/sal/qa/rtl/textenc/rtl_textcvt.cxx
index 2d35b6e..5adafc5 100644
--- a/sal/qa/rtl/textenc/rtl_textcvt.cxx
+++ b/sal/qa/rtl/textenc/rtl_textcvt.cxx
@@ -40,6 +40,7 @@
#include "rtl/textcvt.h"
#include "rtl/textenc.h"
#include "sal/types.h"
+#include <sal/macros.h>
namespace {
@@ -1278,7 +1279,7 @@ void Test::testSingleByte() {
0x0438,0x0439,0x043A,0x043B,0x043C,0x043D,0x043E,0x043F,
0x0440,0x0441,0x0442,0x0443,0x0444,0x0445,0x0446,0x0447,
0x0448,0x0449,0x044A,0x044B,0x044C,0x044D,0x044E,0x044F } } };
- for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) {
+ for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
testSingleByteCharSet(data[i]);
}
}
@@ -2506,7 +2507,7 @@ void Test::testComplex() {
false,
RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR }
};
- for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) {
+ for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
doComplexCharSetTest(data[i]);
}
}
@@ -2594,7 +2595,7 @@ void Test::testComplexCut() {
false,
false,
RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR } */ };
- for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) {
+ for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
doComplexCharSetCutTest(data[i]);
}
}
@@ -2721,7 +2722,7 @@ void Test::testMime() {
{ "CP154", RTL_TEXTENCODING_PT154, false },
{ "Cyrillic-Asian", RTL_TEXTENCODING_PT154, false }
};
- for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) {
+ for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
if (data[i].mime == 0) {
OSL_ASSERT(data[i].reverse);
CPPUNIT_ASSERT_EQUAL(
@@ -2821,7 +2822,7 @@ void Test::testWindows() {
{ 0, RTL_TEXTENCODING_UCS2, true },
{ 0, RTL_TEXTENCODING_ISCII_DEVANAGARI, true }
};
- for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) {
+ for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
OSL_ASSERT(data[i].codePage != 0 || data[i].reverse);
if (data[i].codePage != 0) {
CPPUNIT_ASSERT_EQUAL(
@@ -2887,7 +2888,7 @@ void Test::testInfo() {
{ RTL_TEXTENCODING_PT154, RTL_TEXTENCODING_INFO_ASCII, true },
{ RTL_TEXTENCODING_PT154, RTL_TEXTENCODING_INFO_MIME, true }
};
- for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) {
+ for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
rtl_TextEncodingInfo info;
info.StructSize = sizeof info;
CPPUNIT_ASSERT(rtl_getTextEncodingInfo(data[i].encoding, &info));
diff --git a/sal/rtl/source/uri.cxx b/sal/rtl/source/uri.cxx
index 8ada853..f06a7e5 100644
--- a/sal/rtl/source/uri.cxx
+++ b/sal/rtl/source/uri.cxx
@@ -43,6 +43,7 @@
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
#include "sal/types.h"
+#include "sal/macros.h"
#include <cstddef>
@@ -198,7 +199,7 @@ sal_uInt32 readUcs4(sal_Unicode const ** pBegin, sal_Unicode const * pEnd,
sal_Size nConverted;
sal_Size nDstSize = rtl_convertTextToUnicode(
aConverter, 0, aBuf.getStr(), aBuf.getLength(), aDst,
- sizeof aDst / sizeof aDst[0],
+ SAL_N_ELEMENTS( aDst ),
(RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
| RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
| RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR),
@@ -592,7 +593,7 @@ sal_Bool const * SAL_CALL rtl_getUriCharClass(rtl_UriCharClass eCharClass)
OSL_ENSURE(
(eCharClass >= 0
&& (sal::static_int_cast< std::size_t >(eCharClass)
- < sizeof aCharClass / sizeof aCharClass[0])),
+ < SAL_N_ELEMENTS(aCharClass))),
"bad eCharClass");
return aCharClass[eCharClass];
}
diff --git a/stoc/test/uriproc/test_uriproc.cxx b/stoc/test/uriproc/test_uriproc.cxx
index ee7d02a..fb6fb1b 100644
--- a/stoc/test/uriproc/test_uriproc.cxx
+++ b/stoc/test/uriproc/test_uriproc.cxx
@@ -55,6 +55,7 @@
#include "rtl/ustrbuf.hxx"
#include "rtl/ustring.hxx"
#include "sal/types.h"
+#include <sal/macros.h>
#include <cstdlib>
@@ -205,7 +206,7 @@ void Test::testParse() {
"/", false, 1, "", "", "", "", "", 0, 0 },
{ "////", 0, "////", true, "",
"//", false, 2, "", "", "", "", "", 0, 0 } };
- for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) {
+ for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
css::uno::Reference< css::uri::XUriReference > uriRef(
m_uriFactory->parse(
rtl::OUString::createFromAscii(data[i].uriReference)));
@@ -595,7 +596,7 @@ void Test::testMakeAbsolute() {
css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a#s" },
{ "scheme://a#s1", "#s2", true,
css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a#s2" } };
- for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) {
+ for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
css::uno::Reference< css::uri::XUriReference > baseUriRef(
m_uriFactory->parse(
rtl::OUString::createFromAscii(data[i].baseUriReference)));
@@ -700,7 +701,7 @@ void Test::testMakeRelative() {
0 },
{ "scheme://auth/a/b", "scheme://auth/c/d", true, false, false,
"../c/d", 0 } };
- for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) {
+ for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
css::uno::Reference< css::uri::XUriReference > baseUriRef(
m_uriFactory->parse(
rtl::OUString::createFromAscii(data[i].baseUriReference)));
@@ -753,7 +754,7 @@ void Test::testVndSunStarExpand() {
RTL_CONSTASCII_USTRINGPARAM(
"/singletons/com.sun.star.util.theMacroExpander"))),
css::uno::UNO_QUERY_THROW);
- for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) {
+ for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
css::uno::Reference< css::uri::XUriReference > uriRef(
m_uriFactory->parse(
rtl::OUString::createFromAscii(data[i].uriReference)));
@@ -793,7 +794,7 @@ void Test::testVndSunStarScript() {
{ "vnd.sun.star.script:name?a=&", 0, true, {} },
{ "vnd.sun.star.script:name?key1=&%26=%3D&key1=hello", "name", true,
{ { "key1", "" }, { "key2", 0 }, { "&", "=" } } } };
- for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) {
+ for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
css::uno::Reference< css::uri::XUriReference > uriRef(
m_uriFactory->parse(
rtl::OUString::createFromAscii(data[i].uriReference)));
@@ -950,7 +951,7 @@ void Test::testTranslator() {
{ "file:///abc/%25ef", "file:///abc/%25ef", true } };
css::uno::Reference< css::uri::XExternalUriReferenceTranslator >
translator(css::uri::ExternalUriReferenceTranslator::create(m_context));
- for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) {
+ for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
if (data[i].toInternal) {
TEST_ASSERT_EQUAL(
"testTranslator, translateToInternal", i,
@@ -981,7 +982,7 @@ void Test::testPkgUrlFactory() {
"vnd.sun.star.pkg://file:%2F%2F%2Fa%2525b%252fc%2Fd~e&f@g%3Fh" } };
css::uno::Reference< css::uri::XVndSunStarPkgUrlReferenceFactory > factory(
css::uri::VndSunStarPkgUrlReferenceFactory::create(m_context));
- for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) {
+ for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
css::uno::Reference< css::uri::XUriReference > url(
factory->createVndSunStarPkgUrlReference(
m_uriFactory->parse(
diff --git a/store/source/storcach.cxx b/store/source/storcach.cxx
index 201f997..81863fc 100644
--- a/store/source/storcach.cxx
+++ b/store/source/storcach.cxx
@@ -32,6 +32,7 @@
#include "storcach.hxx"
#include "sal/types.h"
+#include "sal/macros.h"
#include "rtl/alloc.h"
#include "osl/diagnose.h"
@@ -342,7 +343,7 @@ PageCache_Impl::PageCache_Impl (sal_uInt16 nPageSize)
m_nHit (0),
m_nMissed (0)
{
- static size_t const theSize = sizeof(m_hash_table_0) / sizeof(m_hash_table_0[0]);
+ static size_t const theSize = SAL_N_ELEMENTS(m_hash_table_0);
STORE_STATIC_ASSERT(theSize == theTableSize);
memset(m_hash_table_0, 0, sizeof(m_hash_table_0));
}
diff --git a/ure/source/uretest/cppmain.cc b/ure/source/uretest/cppmain.cc
index 0be81b6..eeb0be1 100644
--- a/ure/source/uretest/cppmain.cc
+++ b/ure/source/uretest/cppmain.cc
@@ -26,6 +26,7 @@
************************************************************************/
#include "sal/config.h"
+#include "sal/macros.h"
#include <cstddef>
#include <functional>
@@ -179,7 +180,7 @@ private:
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("no service manager")),
static_cast< ::cppu::OWeakObject * >(this));
}
- for (::std::size_t i = 0; i < sizeof services / sizeof services[0]; ++i) {
+ for (::std::size_t i = 0; i < SAL_N_ELEMENTS(services); ++i) {
::css::uno::Reference< ::css::uno::XInterface > instance;
try {
instance = manager->createInstanceWithContext(
@@ -200,7 +201,7 @@ private:
}
static char const * const singletons[] = {
"com.sun.star.util.theMacroExpander" };
- for (::std::size_t i = 0; i < sizeof singletons / sizeof singletons[0]; ++i)
+ for (::std::size_t i = 0; i < SAL_N_ELEMENTS(singletons); ++i)
{
::rtl::OUStringBuffer b;
b.appendAscii(RTL_CONSTASCII_STRINGPARAM("/singletons/"));
diff --git a/sw/source/ui/lingu/olmenu.cxx b/sw/source/ui/lingu/olmenu.cxx
index e0f99dd..f97c231 100644
--- a/sw/source/ui/lingu/olmenu.cxx
+++ b/sw/source/ui/lingu/olmenu.cxx
@@ -91,6 +91,7 @@
#include <vcl/msgbox.hxx>
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
+#include <sal/macros.h>
#include <map>
@@ -179,7 +180,7 @@ LanguageType lcl_CheckLanguage(
lang::Locale a3( SvxCreateLocale( aLangList[3] ) );
#endif
- INT32 nCount = sizeof(aLangList) / sizeof(aLangList[0]);
+ INT32 nCount = SAL_N_ELEMENTS(aLangList);
for (INT32 i = 0; i < nCount; i++)
{
INT16 nTmpLang = aLangList[i];
diff --git a/sw/source/ui/misc/pgfnote.cxx b/sw/source/ui/misc/pgfnote.cxx
index 03ec907..018047d 100644
--- a/sw/source/ui/misc/pgfnote.cxx
+++ b/sw/source/ui/misc/pgfnote.cxx
@@ -39,6 +39,7 @@
#include <hintids.hxx>
#include <tools/ref.hxx>
#include <svx/dialogs.hrc>
+#include <sal/macros.h>
#include <vcl/field.hxx>
#include <vcl/svapp.hxx>
#include <unotools/localedatawrapper.hxx>
@@ -70,7 +71,7 @@ static const USHORT __FAR_DATA nLines[] = {
500
};
-static const USHORT nLineCount = sizeof(nLines) / sizeof(nLines[0]);
+static const USHORT nLineCount = SAL_N_ELEMENTS(nLines);
static USHORT __FAR_DATA aPageRg[] = {
FN_PARAM_FTN_INFO, FN_PARAM_FTN_INFO,
diff --git a/sw/source/ui/uiview/viewsrch.cxx b/sw/source/ui/uiview/viewsrch.cxx
index 9f4323d..97e4ac3 100644
--- a/sw/source/ui/uiview/viewsrch.cxx
+++ b/sw/source/ui/uiview/viewsrch.cxx
@@ -43,6 +43,7 @@
#include <svl/itempool.hxx>
#include <svl/eitem.hxx>
#include <svl/srchitem.hxx>
+#include <sal/macros.h>
#include <sfx2/request.hxx>
#include <svx/srchdlg.hxx>
#include <vcl/msgbox.hxx>
@@ -380,16 +381,16 @@ void SwView::ExecSearch(SfxRequest& rReq, BOOL bNoMessage)
SvUShorts aArr( 0, 16 );
aArr.Insert( aNormalAttr,
- sizeof( aNormalAttr ) / sizeof( aNormalAttr[0] ),
+ SAL_N_ELEMENTS( aNormalAttr ),
0 );
if( SW_MOD()->GetCTLOptions().IsCTLFontEnabled() )
aArr.Insert( aCTLAttr,
- sizeof( aCTLAttr ) / sizeof( aCTLAttr[0] ),
+ SAL_N_ELEMENTS( aCTLAttr ),
14 );
SvtCJKOptions aCJKOpt;
if( aCJKOpt.IsAnyEnabled() )
aArr.Insert( aCJKAttr,
- sizeof( aCJKAttr ) / sizeof( aCJKAttr[0] ),
+ SAL_N_ELEMENTS( aCJKAttr ),
14 );
SfxItemSet aSet( pWrtShell->GetAttrPool(), aArr.GetData() );
diff --git a/sw/source/ui/vba/vbaborders.cxx b/sw/source/ui/vba/vbaborders.cxx
index 43a28b2..0170eb8 100644
--- a/sw/source/ui/vba/vbaborders.cxx
+++ b/sw/source/ui/vba/vbaborders.cxx
@@ -29,6 +29,7 @@
#include <ooo/vba/word/XBorder.hpp>
#include <ooo/vba/word/WdBorderType.hpp>
#include <ooo/vba/word/WdLineStyle.hpp>
+#include <sal/macros.h>
#include <cppuhelper/implbase3.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/table/TableBorder.hpp>
@@ -269,7 +270,7 @@ public:
// XIndexAccess
virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException)
{
- return sizeof( supportedIndexTable ) / sizeof( supportedIndexTable[0] );
+ return SAL_N_ELEMENTS( supportedIndexTable );
}
virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw
(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
{
diff --git a/sw/source/ui/vba/vbafont.cxx b/sw/source/ui/vba/vbafont.cxx
index c7b140d..91fa3d6 100644
--- a/sw/source/ui/vba/vbafont.cxx
+++ b/sw/source/ui/vba/vbafont.cxx
@@ -3,6 +3,7 @@
#include <com/sun/star/awt/FontUnderline.hpp>
#include <ooo/vba/word/WdUnderline.hpp>
#include <hash_map>
+#include <sal/macros.h>
#include <ooo/vba/word/WdColorIndex.hpp>
using namespace ::ooo::vba;
@@ -46,7 +47,7 @@ class UnderLineMapper
private:
UnderLineMapper()
{
- sal_Int32 nLen = sizeof( UnderLineTable )/ sizeof( UnderLineTable[0] );
+ sal_Int32 nLen = SAL_N_ELEMENTS( UnderLineTable );
for ( sal_Int32 index=0; index<nLen; ++index )
{
diff --git a/sw/source/ui/vba/vbaglobals.cxx b/sw/source/ui/vba/vbaglobals.cxx
index 54edbcd..efc42e0 100644
--- a/sw/source/ui/vba/vbaglobals.cxx
+++ b/sw/source/ui/vba/vbaglobals.cxx
@@ -27,7 +27,7 @@
************************************************************************/
#include <vbahelper/helperdecl.hxx>
#include "vbaglobals.hxx"
-
+#include <sal/macros.h>
#include <comphelper/unwrapargs.hxx>
#include <com/sun/star/lang/XMultiComponentFactory.hpp>
@@ -178,7 +178,7 @@ SwVbaGlobals::getAvailableServiceNames( ) throw (uno::RuntimeException)
// #FIXME #TODO make Application a proper service
// ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.word.Application" ) ),
};
- sal_Int32 nWordServices = ( sizeof( names )/ sizeof( names[0] ) );
+ sal_Int32 nWordServices = SAL_N_ELEMENTS( names );
sal_Int32 startIndex = serviceNames.getLength();
serviceNames.realloc( serviceNames.getLength() + nWordServices );
for ( sal_Int32 index = 0; index < nWordServices; ++index )
diff --git a/sw/source/ui/vba/vbapalette.cxx b/sw/source/ui/vba/vbapalette.cxx
index 8a7da2d..e99349d 100644
--- a/sw/source/ui/vba/vbapalette.cxx
+++ b/sw/source/ui/vba/vbapalette.cxx
@@ -40,7 +40,7 @@ public:
// Methods XIndexAccess
virtual ::sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException)
{
- return sizeof(ColorTable) / sizeof(ColorTable[0]);
+ return SAL_N_ELEMENTS(ColorTable);
}
virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw
(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
Context
- [Libreoffice] [PATCH]SAL_N_ELEMENTS · Kenneth Venken
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.