Hi,
these patches removes the elementsof macro, defined in
<systools/win32/uwinapi.h>, and replaces it with the SAL_N_ELEMENTS
macro, defined in <sal/macros.h>
Kenneth
diff --git a/crashrep/source/win32/soreport.cpp b/crashrep/source/win32/soreport.cpp
index f7918ee..bb4821b 100644
--- a/crashrep/source/win32/soreport.cpp
+++ b/crashrep/source/win32/soreport.cpp
@@ -60,6 +60,7 @@
#endif
#include <systools/win32/uwinapi.h>
+#include <sal/macros.h>
#include <rtl/digest.h>
#include <rtl/bootstrap.hxx>
#include <osl/file.hxx>
@@ -155,7 +156,7 @@ static FILE *_tmpfile(void)
TCHAR szTempPath[MAX_PATH];
- if ( GetTempPath( elementsof(szTempPath), szTempPath ) )
+ if ( GetTempPath( SAL_N_ELEMENTS(szTempPath), szTempPath ) )
{
TCHAR szFileName[MAX_PATH];
@@ -397,27 +398,27 @@ void CrashReportParams::ReadFromEnvironment()
{
TCHAR szBuffer[2048];
- DWORD dwResult = GetEnvironmentVariable( TEXT("ERRORREPORT_HTTPPROXYSERVER"), szBuffer,
elementsof(szBuffer) );
+ DWORD dwResult = GetEnvironmentVariable( TEXT("ERRORREPORT_HTTPPROXYSERVER"), szBuffer,
SAL_N_ELEMENTS(szBuffer) );
- if ( dwResult && dwResult < elementsof(szBuffer) )
+ if ( dwResult && dwResult < SAL_N_ELEMENTS(szBuffer) )
sProxyServer = szBuffer;
- dwResult = GetEnvironmentVariable( TEXT("ERRORREPORT_HTTPPROXYPORT"), szBuffer,
elementsof(szBuffer) );
+ dwResult = GetEnvironmentVariable( TEXT("ERRORREPORT_HTTPPROXYPORT"), szBuffer,
SAL_N_ELEMENTS(szBuffer) );
- if ( dwResult && dwResult < elementsof(szBuffer) )
+ if ( dwResult && dwResult < SAL_N_ELEMENTS(szBuffer) )
sProxyPort = szBuffer;
- dwResult = GetEnvironmentVariable( TEXT("ERRORREPORT_RETURNADDRESS"), szBuffer,
elementsof(szBuffer) );
+ dwResult = GetEnvironmentVariable( TEXT("ERRORREPORT_RETURNADDRESS"), szBuffer,
SAL_N_ELEMENTS(szBuffer) );
- if ( dwResult && dwResult < elementsof(szBuffer) )
+ if ( dwResult && dwResult < SAL_N_ELEMENTS(szBuffer) )
{
sEmail = szBuffer;
// fAllowContact = TRUE;
}
- dwResult = GetEnvironmentVariable( TEXT("ERRORREPORT_HTTPCONNECTIONTYPE"), szBuffer,
elementsof(szBuffer) );
+ dwResult = GetEnvironmentVariable( TEXT("ERRORREPORT_HTTPCONNECTIONTYPE"), szBuffer,
SAL_N_ELEMENTS(szBuffer) );
- if ( dwResult && dwResult < elementsof(szBuffer) )
+ if ( dwResult && dwResult < SAL_N_ELEMENTS(szBuffer) )
{
if ( 0 == _tcsicmp( szBuffer, _T("DIRECT") ) )
uInternetConnection = 1;
@@ -427,15 +428,15 @@ void CrashReportParams::ReadFromEnvironment()
uInternetConnection = 0;
}
- dwResult = GetEnvironmentVariable( TEXT("ERRORREPORT_SUBJECT"), szBuffer, elementsof(szBuffer)
);
+ dwResult = GetEnvironmentVariable( TEXT("ERRORREPORT_SUBJECT"), szBuffer,
SAL_N_ELEMENTS(szBuffer) );
- if ( dwResult && dwResult < elementsof(szBuffer) )
+ if ( dwResult && dwResult < SAL_N_ELEMENTS(szBuffer) )
sTitle = szBuffer;
- dwResult = GetEnvironmentVariable( TEXT("ERRORREPORT_BODYFILE"), szBuffer,
elementsof(szBuffer) );
+ dwResult = GetEnvironmentVariable( TEXT("ERRORREPORT_BODYFILE"), szBuffer,
SAL_N_ELEMENTS(szBuffer) );
- if ( dwResult && dwResult < elementsof(szBuffer) )
+ if ( dwResult && dwResult < SAL_N_ELEMENTS(szBuffer) )
{
FILE *fp = _xfopen( szBuffer, _T("rb") );
@@ -446,11 +447,11 @@ void CrashReportParams::ReadFromEnvironment()
sComment = TEXT("");
- while ( 0 != (nBytesRead = fread( aUTF8Buffer, sizeof(aUTF8Buffer[0]),
elementsof(aUTF8Buffer), fp )) )
+ while ( 0 != (nBytesRead = fread( aUTF8Buffer, sizeof(aUTF8Buffer[0]),
SAL_N_ELEMENTS(aUTF8Buffer), fp )) )
{
TCHAR aBuffer[256+1];
- DWORD dwCharacters = MultiByteToWideChar( CP_UTF8, 0, aUTF8Buffer, nBytesRead,
aBuffer, elementsof(aBuffer) - 1 );
+ DWORD dwCharacters = MultiByteToWideChar( CP_UTF8, 0, aUTF8Buffer, nBytesRead,
aBuffer, SAL_N_ELEMENTS(aBuffer) - 1 );
aBuffer[dwCharacters] = 0;
sComment += aBuffer;
}
@@ -513,7 +514,7 @@ static int LoadAndFormatString( HINSTANCE hInstance, UINT uID, LPTSTR lpBuffer,
TCHAR szBuffer[FORMATBUFSIZE];
TCHAR szBuffer2[FORMATBUFSIZE];
- LoadString( hInstance, uID, szBuffer, elementsof(szBuffer) );
+ LoadString( hInstance, uID, szBuffer, SAL_N_ELEMENTS(szBuffer) );
LPCTSTR src;
LPTSTR dest;
@@ -622,7 +623,7 @@ static string GetModuleDirectory( HMODULE hModule )
CHAR szModuleNameUTF8[MAX_PATH] = "";
- WideCharToMultiByte( CP_UTF8, 0, szModuleName, -1, szModuleNameUTF8,
elementsof(szModuleNameUTF8), NULL, NULL );
+ WideCharToMultiByte( CP_UTF8, 0, szModuleName, -1, szModuleNameUTF8,
SAL_N_ELEMENTS(szModuleNameUTF8), NULL, NULL );
return string( szModuleNameUTF8 );
}
@@ -661,7 +662,7 @@ BOOL WriteReportFile( CrashReportParams *pParams )
BOOL fSuccess = FALSE;
TCHAR szTempPath[MAX_PATH];
- if ( GetTempPath( elementsof(szTempPath), szTempPath ) )
+ if ( GetTempPath( SAL_N_ELEMENTS(szTempPath), szTempPath ) )
{
TCHAR szFileName[MAX_PATH];
@@ -900,10 +901,10 @@ BOOL CALLBACK PreviewDialogProc(
HINSTANCE hInstance = (HINSTANCE)GetWindowLong( hwndDlg, GWL_HINSTANCE );
HWND hwndParent = (HWND)GetWindowLong( hwndDlg, GWL_HWNDPARENT );
- GetWindowText( hwndParent, szBuffer, elementsof(szBuffer) );
+ GetWindowText( hwndParent, szBuffer, SAL_N_ELEMENTS(szBuffer) );
SetWindowText( hwndDlg, szBuffer );
- LoadAndFormatString( hInstance, IDS_OK_BUTTON, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_OK_BUTTON, szBuffer, SAL_N_ELEMENTS(szBuffer) );
Button_SetText( GetDlgItem(hwndDlg, IDOK), szBuffer );
basic_string<TCHAR> aString;
@@ -919,11 +920,11 @@ BOOL CALLBACK PreviewDialogProc(
{
char buf[1024];
- while ( fgets( buf, elementsof(buf), fp ) != NULL )
+ while ( fgets( buf, SAL_N_ELEMENTS(buf), fp ) != NULL )
{
WCHAR bufW[1024];
- MultiByteToWideChar( CP_UTF8, 0, buf, -1, bufW, elementsof(bufW) );
+ MultiByteToWideChar( CP_UTF8, 0, buf, -1, bufW, SAL_N_ELEMENTS(bufW) );
aString.append( bufW );
}
@@ -950,10 +951,10 @@ BOOL CALLBACK PreviewDialogProc(
{
TCHAR output[16];
- _sntprintf( output, elementsof(output), _T("%02X\x20"), buf[i] );
+ _sntprintf( output, SAL_N_ELEMENTS(output), _T("%02X\x20"), buf[i] );
aString.append( output );
}
- for ( ; i < elementsof(buf); i++ )
+ for ( ; i < SAL_N_ELEMENTS(buf); i++ )
{
aString.append( _T("\x20\x20\x20") );
}
@@ -1052,31 +1053,31 @@ BOOL CALLBACK OptionsDialogProc(
pParams = (CrashReportParams *)lParam;
- LoadAndFormatString( hInstance, IDS_OPTIONS_CAPTION, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_OPTIONS_CAPTION, szBuffer,
SAL_N_ELEMENTS(szBuffer) );
SetWindowText( hwndDlg, szBuffer );
- LoadAndFormatString( hInstance, IDS_PROXY_SETTINGS_HEADER, szBuffer,
elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_PROXY_SETTINGS_HEADER, szBuffer,
SAL_N_ELEMENTS(szBuffer) );
Static_SetText( GetDlgItem(hwndDlg, IDC_PROXY_SETTINGS), szBuffer );
- LoadAndFormatString( hInstance, IDS_PROXY_SYSTEM, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_PROXY_SYSTEM, szBuffer, SAL_N_ELEMENTS(szBuffer) );
Button_SetText( GetDlgItem(hwndDlg, IDC_RADIO_SYSTEM), szBuffer );
- LoadAndFormatString( hInstance, IDS_PROXY_DIRECT, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_PROXY_DIRECT, szBuffer, SAL_N_ELEMENTS(szBuffer) );
Button_SetText( GetDlgItem(hwndDlg, IDC_RADIO_DIRECT), szBuffer );
- LoadAndFormatString( hInstance, IDS_PROXY_MANUAL, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_PROXY_MANUAL, szBuffer, SAL_N_ELEMENTS(szBuffer) );
Button_SetText( GetDlgItem(hwndDlg, IDC_RADIO_MANUAL), szBuffer );
- LoadAndFormatString( hInstance, IDS_LABEL_PROXYSERVER, szBuffer, elementsof(szBuffer)
);
+ LoadAndFormatString( hInstance, IDS_LABEL_PROXYSERVER, szBuffer,
SAL_N_ELEMENTS(szBuffer) );
Static_SetText( GetDlgItem(hwndDlg, IDC_LABEL_PROXYSERVER), szBuffer );
- LoadAndFormatString( hInstance, IDS_LABEL_PROXYPORT, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_LABEL_PROXYPORT, szBuffer,
SAL_N_ELEMENTS(szBuffer) );
Static_SetText( GetDlgItem(hwndDlg, IDC_LABEL_PROXYPORT), szBuffer );
- LoadAndFormatString( hInstance, IDS_OK_BUTTON, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_OK_BUTTON, szBuffer, SAL_N_ELEMENTS(szBuffer) );
Button_SetText( GetDlgItem(hwndDlg, IDOK), szBuffer );
- LoadAndFormatString( hInstance, IDS_CANCEL_BUTTON, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_CANCEL_BUTTON, szBuffer, SAL_N_ELEMENTS(szBuffer)
);
Button_SetText( GetDlgItem(hwndDlg, IDCANCEL), szBuffer );
Edit_SetText( GetDlgItem(hwndDlg, IDC_EDIT_PROXYSERVER), pParams->sProxyServer.c_str()
);
@@ -1089,7 +1090,7 @@ BOOL CALLBACK OptionsDialogProc(
EM_SETBKGNDCOLOR,
(WPARAM)FALSE,
GetSysColor( COLOR_3DFACE ) );
- LoadAndFormatString( hInstance, IDS_PROXY_DESCRIPTION, szBuffer, elementsof(szBuffer)
);
+ LoadAndFormatString( hInstance, IDS_PROXY_DESCRIPTION, szBuffer,
SAL_N_ELEMENTS(szBuffer) );
Edit_SetText( GetDlgItem(hwndDlg, IDC_PROXY_DESCRIPTION), szBuffer );
UpdateOptionsDialogControls( hwndDlg );
@@ -1108,10 +1109,10 @@ BOOL CALLBACK OptionsDialogProc(
{
TCHAR szBuffer[1024];
- Edit_GetText( GetDlgItem(hwndDlg, IDC_EDIT_PROXYSERVER), szBuffer,
elementsof(szBuffer) );
+ Edit_GetText( GetDlgItem(hwndDlg, IDC_EDIT_PROXYSERVER), szBuffer,
SAL_N_ELEMENTS(szBuffer) );
pParams->sProxyServer = szBuffer;
- Edit_GetText( GetDlgItem(hwndDlg, IDC_EDIT_PROXYPORT), szBuffer, elementsof(szBuffer)
);
+ Edit_GetText( GetDlgItem(hwndDlg, IDC_EDIT_PROXYPORT), szBuffer,
SAL_N_ELEMENTS(szBuffer) );
pParams->sProxyPort = szBuffer;
if ( Button_GetCheck( GetDlgItem(hwndDlg, IDC_RADIO_DIRECT) ) & BST_CHECKED )
@@ -1178,21 +1179,21 @@ BOOL CALLBACK ReportDialogProc(
HINSTANCE hInstance = (HINSTANCE)GetWindowLong(hwndDlg, GWL_HINSTANCE );
TCHAR szBuffer[FORMATBUFSIZE];
- LoadAndFormatString( hInstance, IDS_REPORT_INTRO, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_REPORT_INTRO, szBuffer, SAL_N_ELEMENTS(szBuffer) );
Static_SetText( GetDlgItem(hwndDlg, IDC_REPORT_INTRO), szBuffer );
Edit_SetText( GetDlgItem(hwndDlg, IDC_EDIT3), szBuffer );
- LoadAndFormatString( hInstance, IDS_ENTER_TITLE, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_ENTER_TITLE, szBuffer, SAL_N_ELEMENTS(szBuffer) );
Static_SetText( GetDlgItem(hwndDlg, IDC_ENTER_TITLE), szBuffer );
- LoadAndFormatString( hInstance, IDS_ENTER_DESCRIPTION, szBuffer, elementsof(szBuffer)
);
+ LoadAndFormatString( hInstance, IDS_ENTER_DESCRIPTION, szBuffer,
SAL_N_ELEMENTS(szBuffer) );
Static_SetText( GetDlgItem(hwndDlg, IDC_ENTER_DESCRIPTION), szBuffer );
- LoadAndFormatString( hInstance, IDS_SHOW_REPORT_BUTTON, szBuffer, elementsof(szBuffer)
);
+ LoadAndFormatString( hInstance, IDS_SHOW_REPORT_BUTTON, szBuffer,
SAL_N_ELEMENTS(szBuffer) );
Button_SetText( GetDlgItem(hwndDlg, IDC_SHOW_REPORT), szBuffer );
- LoadAndFormatString( hInstance, IDS_SAVE_REPORT_BUTTON, szBuffer, elementsof(szBuffer)
);
+ LoadAndFormatString( hInstance, IDS_SAVE_REPORT_BUTTON, szBuffer,
SAL_N_ELEMENTS(szBuffer) );
Button_SetText( GetDlgItem(hwndDlg, IDC_SAVE_REPORT), szBuffer );
const char *pszUserType = getenv( "STAROFFICE_USERTYPE" );
@@ -1201,14 +1202,14 @@ BOOL CALLBACK ReportDialogProc(
else
ShowWindow( GetDlgItem(hwndDlg, IDC_SAVE_REPORT), SW_HIDE );
- LoadAndFormatString( hInstance, IDS_OPTIONS_BUTTON, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_OPTIONS_BUTTON, szBuffer, SAL_N_ELEMENTS(szBuffer)
);
Button_SetText( GetDlgItem(hwndDlg, IDC_OPTIONS), szBuffer );
- LoadAndFormatString( hInstance, IDS_ALLOW_CONTACT, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_ALLOW_CONTACT, szBuffer, SAL_N_ELEMENTS(szBuffer)
);
Button_SetText( GetDlgItem(hwndDlg, IDC_ALLOW_CONTACT), szBuffer );
Button_SetCheck( GetDlgItem(hwndDlg, IDC_ALLOW_CONTACT), pParams->fAllowContact ?
BST_CHECKED : BST_UNCHECKED );
- LoadAndFormatString( hInstance, IDS_LABEL_EMAIL, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_LABEL_EMAIL, szBuffer, SAL_N_ELEMENTS(szBuffer) );
Button_SetText( GetDlgItem(hwndDlg, IDC_LABEL_EMAIL), szBuffer );
Edit_SetText( GetDlgItem(hwndDlg, IDC_EDIT_EMAIL), pParams->sEmail.c_str() );
@@ -1223,13 +1224,13 @@ BOOL CALLBACK ReportDialogProc(
CrashReportParams *pParams = (CrashReportParams*)GetWindowLong( GetParent(hwndDlg),
GWL_USERDATA );
TCHAR szBuffer[FORMATBUFSIZE];
- LoadAndFormatString( hInstance, IDS_REPORT_CAPTION, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_REPORT_CAPTION, szBuffer, SAL_N_ELEMENTS(szBuffer)
);
SetWindowText( GetParent(hwndDlg), szBuffer );
- LoadAndFormatString( hInstance, IDS_REPORT_HEADER, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_REPORT_HEADER, szBuffer, SAL_N_ELEMENTS(szBuffer)
);
SetWindowText( GetDlgItem(GetParent(hwndDlg), IDC_HEADER), szBuffer );
- LoadAndFormatString( hInstance, IDS_DONOT_SEND_BUTTON, szBuffer, elementsof(szBuffer)
);
+ LoadAndFormatString( hInstance, IDS_DONOT_SEND_BUTTON, szBuffer,
SAL_N_ELEMENTS(szBuffer) );
Button_SetText( GetDlgItem(GetParent(hwndDlg), IDCANCEL), szBuffer );
@@ -1260,13 +1261,13 @@ BOOL CALLBACK ReportDialogProc(
pParams->fAllowContact = Button_GetCheck( GetDlgItem(hwndDlg, IDC_ALLOW_CONTACT) )
? TRUE : FALSE;
- Edit_GetText( GetDlgItem(hwndDlg, IDC_EDIT_TITLE), szBuffer, elementsof(szBuffer)
);
+ Edit_GetText( GetDlgItem(hwndDlg, IDC_EDIT_TITLE), szBuffer,
SAL_N_ELEMENTS(szBuffer) );
pParams->sTitle = szBuffer;
- Edit_GetText( GetDlgItem(hwndDlg, IDC_EDIT_DESCRIPTION), szBuffer,
elementsof(szBuffer) );
+ Edit_GetText( GetDlgItem(hwndDlg, IDC_EDIT_DESCRIPTION), szBuffer,
SAL_N_ELEMENTS(szBuffer) );
pParams->sComment = szBuffer;
- Edit_GetText( GetDlgItem(hwndDlg, IDC_EDIT_EMAIL), szBuffer, elementsof(szBuffer)
);
+ Edit_GetText( GetDlgItem(hwndDlg, IDC_EDIT_EMAIL), szBuffer,
SAL_N_ELEMENTS(szBuffer) );
pParams->sEmail = szBuffer;
PreviewReport( GetParent(hwndDlg), pParams );
@@ -1317,16 +1318,16 @@ BOOL CALLBACK WelcomeDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam,
LPARAM
SendMessage( hwndRichEdit, EM_SETEVENTMASK, 0, ENM_LINK );
SendMessage( hwndRichEdit, EM_AUTOURLDETECT, TRUE, 0 );
- LoadAndFormatString( hInstance, IDS_WELCOME_BODY1, szBuffer, elementsof(szBuffer) );
- LoadAndFormatString( hInstance, IDS_WELCOME_BODY2, szBuffer2, elementsof(szBuffer2) );
- _tcsncat( szBuffer, szBuffer2, elementsof(szBuffer) );
- LoadAndFormatString( hInstance, IDS_WELCOME_BODY3, szBuffer2, elementsof(szBuffer2) );
- _tcsncat( szBuffer, szBuffer2, elementsof(szBuffer) );
- LoadString( hInstance, IDS_PRIVACY_URL, szURL, elementsof(szURL) );
- _tcsncat( szBuffer, szURL, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_WELCOME_BODY1, szBuffer, SAL_N_ELEMENTS(szBuffer)
);
+ LoadAndFormatString( hInstance, IDS_WELCOME_BODY2, szBuffer2,
SAL_N_ELEMENTS(szBuffer2) );
+ _tcsncat( szBuffer, szBuffer2, SAL_N_ELEMENTS(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_WELCOME_BODY3, szBuffer2,
SAL_N_ELEMENTS(szBuffer2) );
+ _tcsncat( szBuffer, szBuffer2, SAL_N_ELEMENTS(szBuffer) );
+ LoadString( hInstance, IDS_PRIVACY_URL, szURL, SAL_N_ELEMENTS(szURL) );
+ _tcsncat( szBuffer, szURL, SAL_N_ELEMENTS(szBuffer) );
SetWindowText( hwndRichEdit, szBuffer );
- LoadAndFormatString( hInstance, IDS_WELCOME_CAPTION, szCaption, elementsof(szCaption)
);
+ LoadAndFormatString( hInstance, IDS_WELCOME_CAPTION, szCaption,
SAL_N_ELEMENTS(szCaption) );
SetWindowText( GetParent(hwndDlg), szCaption );
}
@@ -1337,13 +1338,13 @@ BOOL CALLBACK WelcomeDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam,
LPARAM
HINSTANCE hInstance = (HINSTANCE)GetWindowLong(hwndDlg, GWL_HINSTANCE );
TCHAR szBuffer[FORMATBUFSIZE];
- LoadAndFormatString( hInstance, IDS_WELCOME_CAPTION, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_WELCOME_CAPTION, szBuffer,
SAL_N_ELEMENTS(szBuffer) );
SetWindowText( GetParent(hwndDlg), szBuffer );
- LoadAndFormatString( hInstance, IDS_WELCOME_HEADER, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_WELCOME_HEADER, szBuffer, SAL_N_ELEMENTS(szBuffer)
);
SetWindowText( GetDlgItem(GetParent(hwndDlg), IDC_HEADER), szBuffer );
- LoadAndFormatString( hInstance, IDS_CANCEL_BUTTON, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_CANCEL_BUTTON, szBuffer, SAL_N_ELEMENTS(szBuffer)
);
Button_SetText( GetDlgItem(GetParent(hwndDlg), IDCANCEL), szBuffer );
ShowWindow( GetDlgItem(GetParent(hwndDlg),IDBACK), FALSE );
@@ -1422,16 +1423,16 @@ BOOL CALLBACK DialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
lParam
SCF_ALL,
(LPARAM)&chfmt );
- LoadAndFormatString( hInstance, IDS_CANCEL_BUTTON, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_CANCEL_BUTTON, szBuffer, SAL_N_ELEMENTS(szBuffer)
);
Button_SetText( GetDlgItem(hwndDlg, IDCANCEL), szBuffer );
- LoadAndFormatString( hInstance, IDS_NEXT_BUTTON, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_NEXT_BUTTON, szBuffer, SAL_N_ELEMENTS(szBuffer) );
Button_SetText( GetDlgItem(hwndDlg, IDNEXT), szBuffer );
- LoadAndFormatString( hInstance, IDS_SEND_BUTTON, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_SEND_BUTTON, szBuffer, SAL_N_ELEMENTS(szBuffer) );
Button_SetText( GetDlgItem(hwndDlg, IDFINISH), szBuffer );
- LoadAndFormatString( hInstance, IDS_BACK_BUTTON, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_BACK_BUTTON, szBuffer, SAL_N_ELEMENTS(szBuffer) );
Button_SetText( GetDlgItem(hwndDlg, IDBACK), szBuffer );
ShowWindow( hwndPages[1], SW_HIDE );
@@ -1454,7 +1455,7 @@ BOOL CALLBACK DialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
lParam
}
return TRUE;
case IDNEXT:
- if ( iActualPage < elementsof(hwndPages) - 1 )
+ if ( iActualPage < SAL_N_ELEMENTS(hwndPages) - 1 )
{
ShowWindow( hwndPages[iActualPage], SW_HIDE );
ShowWindow( hwndPages[++iActualPage], SW_SHOW );
@@ -1467,20 +1468,20 @@ BOOL CALLBACK DialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
lParam
pParams->fAllowContact = Button_GetCheck( GetDlgItem(hwndPages[1],
IDC_ALLOW_CONTACT) ) ? TRUE : FALSE;
- Edit_GetText( GetDlgItem(hwndPages[1], IDC_EDIT_TITLE), szBuffer,
elementsof(szBuffer) );
+ Edit_GetText( GetDlgItem(hwndPages[1], IDC_EDIT_TITLE), szBuffer,
SAL_N_ELEMENTS(szBuffer) );
pParams->sTitle = szBuffer;
- Edit_GetText( GetDlgItem(hwndPages[1], IDC_EDIT_DESCRIPTION), szBuffer,
elementsof(szBuffer) );
+ Edit_GetText( GetDlgItem(hwndPages[1], IDC_EDIT_DESCRIPTION), szBuffer,
SAL_N_ELEMENTS(szBuffer) );
pParams->sComment = szBuffer;
- Edit_GetText( GetDlgItem(hwndPages[1], IDC_EDIT_EMAIL), szBuffer,
elementsof(szBuffer) );
+ Edit_GetText( GetDlgItem(hwndPages[1], IDC_EDIT_EMAIL), szBuffer,
SAL_N_ELEMENTS(szBuffer) );
pParams->sEmail = szBuffer;
if ( pParams->fAllowContact && !pParams->sEmail.length() )
{
TCHAR szMessage[MAX_TEXT_BUFFER];
- LoadAndFormatString( GetModuleHandle(NULL), IDS_ERROR_MSG_NOEMAILADDRESS,
szMessage, elementsof(szMessage) );
+ LoadAndFormatString( GetModuleHandle(NULL), IDS_ERROR_MSG_NOEMAILADDRESS,
szMessage, SAL_N_ELEMENTS(szMessage) );
MessageBox( hwndDlg, szMessage, NULL, MB_ICONERROR | MB_OK );
break; // Don't end the dialog
@@ -1523,7 +1524,7 @@ static void repatch_soffice_exe( void *pBuffer, size_t nBufSize )
wchar_t DescriptionBuffer[MAGIC_DESCRIPTION_COUNT];
memset( DescriptionBuffer, 0, sizeof(DescriptionBuffer) );
- wcsncpy( DescriptionBuffer, g_wstrProductKey.c_str(), elementsof(DescriptionBuffer) - 1 );
+ wcsncpy( DescriptionBuffer, g_wstrProductKey.c_str(), SAL_N_ELEMENTS(DescriptionBuffer) - 1 );
bool bPatched = false;
@@ -1920,7 +1921,7 @@ BOOL WriteDumpFile( DWORD dwProcessId, PEXCEPTION_POINTERS
pExceptionPointers, D
{
TCHAR szTempPath[MAX_PATH];
-// if ( GetTempPath( elementsof(szTempPath), szTempPath ) )
+// if ( GetTempPath( SAL_N_ELEMENTS(szTempPath), szTempPath ) )
if ( GetCrashDataPath( szTempPath ) )
{
TCHAR szFileName[MAX_PATH];
@@ -1998,7 +1999,7 @@ static DWORD FindProcessForImage( LPCTSTR lpImagePath )
DWORD dwSize = 0;
TCHAR szShortImagePath[MAX_PATH];
- if ( GetShortPathName( lpImagePath, szShortImagePath, elementsof(szShortImagePath) ) &&
+ if ( GetShortPathName( lpImagePath, szShortImagePath, SAL_N_ELEMENTS(szShortImagePath) ) &&
EnumProcesses( aProcesses, sizeof(aProcesses), &dwSize ) )
{
unsigned nProcesses = dwSize / sizeof(aProcesses[0]);
@@ -2015,7 +2016,7 @@ static DWORD FindProcessForImage( LPCTSTR lpImagePath )
{
TCHAR szShortModulePath[MAX_PATH];
- if ( GetShortPathName( szModulePath, szShortModulePath,
elementsof(szShortModulePath) ) )
+ if ( GetShortPathName( szModulePath, szShortModulePath,
SAL_N_ELEMENTS(szShortModulePath) ) )
{
if ( 0 == _tcsicmp( szShortModulePath, szShortImagePath ) )
dwProcessId = aProcesses[i];
@@ -2088,10 +2089,10 @@ static bool ParseCommandArgs( LPDWORD pdwProcessId, PEXCEPTION_POINTERS*
ppExcep
TCHAR szProcessDescription[FORMATBUFSIZE];
TCHAR szHelpDescription[FORMATBUFSIZE];
- LoadAndFormatString( hInstance, IDS_MSG_CMDLINE_USAGE, szUsage, elementsof(szUsage) );
- LoadAndFormatString( hInstance, IDS_MSG_PARAM_PROCESSID, szProcess,
elementsof(szProcess) );
- LoadAndFormatString( hInstance, IDS_MSG_PARAM_PROCESSID_DESCRIPTION,
szProcessDescription, elementsof(szProcessDescription) );
- LoadAndFormatString( hInstance, IDS_MSG_PARAM_HELP_DESCRIPTION, szHelpDescription,
elementsof(szHelpDescription) );
+ LoadAndFormatString( hInstance, IDS_MSG_CMDLINE_USAGE, szUsage,
SAL_N_ELEMENTS(szUsage) );
+ LoadAndFormatString( hInstance, IDS_MSG_PARAM_PROCESSID, szProcess,
SAL_N_ELEMENTS(szProcess) );
+ LoadAndFormatString( hInstance, IDS_MSG_PARAM_PROCESSID_DESCRIPTION,
szProcessDescription, SAL_N_ELEMENTS(szProcessDescription) );
+ LoadAndFormatString( hInstance, IDS_MSG_PARAM_HELP_DESCRIPTION, szHelpDescription,
SAL_N_ELEMENTS(szHelpDescription) );
_tprintf(
TEXT("\n%s: crashrep %s\n\n")
@@ -2184,7 +2185,7 @@ BOOL WriteCommentFile( LPCTSTR lpComment )
BOOL fSuccess = FALSE;
TCHAR szTempPath[MAX_PATH];
- if ( GetTempPath( elementsof(szTempPath), szTempPath ) )
+ if ( GetTempPath( SAL_N_ELEMENTS(szTempPath), szTempPath ) )
{
TCHAR szFileName[MAX_PATH];
@@ -2336,7 +2337,7 @@ static bool ReadBootstrapParams( CrashReportParams &rParams )
TEXT("ProductKey"),
TEXT("OpenOffice.org"),
szBuffer,
- elementsof(szBuffer),
+ SAL_N_ELEMENTS(szBuffer),
szModuleName )
)
{
@@ -2364,7 +2365,7 @@ static bool ReadBootstrapParams( CrashReportParams &rParams )
TEXT("Version"),
TEXT("buildid"),
TEXT("unknown"),
- g_szBuildId, elementsof(g_szBuildId),
+ g_szBuildId, SAL_N_ELEMENTS(g_szBuildId),
szModuleVersionName );
g_strDefaultLanguage = get_script_string( "instdb.inf", "DefaultLanguage" );
@@ -2373,7 +2374,7 @@ static bool ReadBootstrapParams( CrashReportParams &rParams )
TEXT("ErrorReport"),
TEXT("ErrorReportPort"),
TEXT("80"),
- szReportPort, elementsof(szReportPort),
+ szReportPort, SAL_N_ELEMENTS(szReportPort),
szModuleName
) )
{
@@ -2388,11 +2389,11 @@ static bool ReadBootstrapParams( CrashReportParams &rParams )
TEXT("ErrorReport"),
TEXT("ErrorReportServer"),
TEXT(""),
- szReportServer, elementsof(szReportServer),
+ szReportServer, SAL_N_ELEMENTS(szReportServer),
szModuleName
) )
{
- bSuccess = 0 != WideCharToMultiByte( CP_ACP, 0, szReportServer, -1, g_szReportServerA,
elementsof(g_szReportServerA), NULL, NULL );
+ bSuccess = 0 != WideCharToMultiByte( CP_ACP, 0, szReportServer, -1, g_szReportServerA,
SAL_N_ELEMENTS(g_szReportServerA), NULL, NULL );
}
LPCTSTR lpEnvString;
@@ -2625,13 +2626,13 @@ BOOL CALLBACK SendingStatusDialogProc(
pRequest = (RequestParams *)lParam;
- LoadAndFormatString( hInstance, IDS_SENDING_REPORT_HEADER, szBuffer,
elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_SENDING_REPORT_HEADER, szBuffer,
SAL_N_ELEMENTS(szBuffer) );
SetWindowText( hwndDlg, szBuffer );
- LoadAndFormatString( hInstance, IDS_SENDING_REPORT_STATUS, szBuffer,
elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_SENDING_REPORT_STATUS, szBuffer,
SAL_N_ELEMENTS(szBuffer) );
Static_SetText( GetDlgItem(hwndDlg, IDC_SENDING_REPORT_STATUS), szBuffer );
- LoadAndFormatString( hInstance, IDS_CANCEL_BUTTON, szBuffer, elementsof(szBuffer) );
+ LoadAndFormatString( hInstance, IDS_CANCEL_BUTTON, szBuffer, SAL_N_ELEMENTS(szBuffer)
);
Button_SetText( GetDlgItem(hwndDlg, IDCANCEL), szBuffer );
pRequest->hwndStatus = hwndDlg;
@@ -2768,7 +2769,7 @@ bool SendCrashReport( HWND hwndParent, const CrashReportParams &rParams )
{
TCHAR szMessage[1024];
- LoadAndFormatString( GetModuleHandle(NULL), IDS_ERROR_MSG_PROXY, szMessage,
elementsof(szMessage) );
+ LoadAndFormatString( GetModuleHandle(NULL), IDS_ERROR_MSG_PROXY, szMessage,
SAL_N_ELEMENTS(szMessage) );
MessageBox( hwndParent, szMessage, NULL, MB_ICONERROR | MB_OK );
}
@@ -2777,8 +2778,8 @@ bool SendCrashReport( HWND hwndParent, const CrashReportParams &rParams )
TCHAR szMessage[1024];
TCHAR szTitle[1024];
- LoadAndFormatString( GetModuleHandle(NULL),
IDS_SENDING_REPORT_STATUS_FINISHED, szMessage, elementsof(szMessage) );
- LoadAndFormatString( GetModuleHandle(NULL), IDS_SENDING_REPORT_HEADER,
szTitle, elementsof(szTitle) );
+ LoadAndFormatString( GetModuleHandle(NULL),
IDS_SENDING_REPORT_STATUS_FINISHED, szMessage, SAL_N_ELEMENTS(szMessage) );
+ LoadAndFormatString( GetModuleHandle(NULL), IDS_SENDING_REPORT_HEADER,
szTitle, SAL_N_ELEMENTS(szTitle) );
MessageBox( hwndParent, szMessage, szTitle, MB_ICONINFORMATION | MB_OK );
}
@@ -2796,14 +2797,14 @@ bool SendCrashReport( HWND hwndParent, const CrashReportParams &rParams )
{
TCHAR szMessage[1024];
- LoadAndFormatString( GetModuleHandle(NULL), IDS_ERROR_MSG_PROXY, szMessage,
elementsof(szMessage) );
+ LoadAndFormatString( GetModuleHandle(NULL), IDS_ERROR_MSG_PROXY, szMessage,
SAL_N_ELEMENTS(szMessage) );
_ftprintf( stderr, _T("ERROR: %s\n"), szMessage );
}
else
{
TCHAR szMessage[1024];
- LoadAndFormatString( GetModuleHandle(NULL), IDS_SENDING_REPORT_STATUS_FINISHED,
szMessage, elementsof(szMessage) );
+ LoadAndFormatString( GetModuleHandle(NULL), IDS_SENDING_REPORT_STATUS_FINISHED,
szMessage, SAL_N_ELEMENTS(szMessage) );
_ftprintf( stderr, _T("SUCCESS: %s\n"), szMessage );
}
@@ -2814,7 +2815,7 @@ bool SendCrashReport( HWND hwndParent, const CrashReportParams &rParams )
{
TCHAR szMessage[1024];
- LoadAndFormatString( GetModuleHandle(NULL), IDS_ERROR_MSG_DISK_FULL, szMessage,
elementsof(szMessage) );
+ LoadAndFormatString( GetModuleHandle(NULL), IDS_ERROR_MSG_DISK_FULL, szMessage,
SAL_N_ELEMENTS(szMessage) );
if ( hwndParent )
MessageBox( hwndParent, szMessage, NULL, MB_ICONERROR | MB_OK );
diff --git
a/setup_native/source/win32/customactions/languagepacks/checkrunningofficelanguagepack.cxx
b/setup_native/source/win32/customactions/languagepacks/checkrunningofficelanguagepack.cxx
index 9071b8c..998e304 100644
--- a/setup_native/source/win32/customactions/languagepacks/checkrunningofficelanguagepack.cxx
+++ b/setup_native/source/win32/customactions/languagepacks/checkrunningofficelanguagepack.cxx
@@ -53,6 +53,7 @@
#include <stdio.h>
#include <systools/win32/uwinapi.h>
+#include <sal/macros.h>
#include <../tools/seterror.hxx>
#define WININIT_FILENAME "wininit.ini"
@@ -65,7 +66,7 @@ inline void OutputDebugStringFormat( LPCTSTR pFormat, ... )
va_list args;
va_start( args, pFormat );
- _vsntprintf( buffer, elementsof(buffer), pFormat, args );
+ _vsntprintf( buffer, SAL_N_ELEMENTS(buffer), pFormat, args );
OutputDebugString( buffer );
}
#else
@@ -127,7 +128,7 @@ static BOOL MoveFileEx9x( LPCSTR lpExistingFileNameA, LPCSTR lpNewFileNameA, DWO
)
{
CHAR szBuffer[32767]; // The buffer size must not exceed 32K
- DWORD dwBufLen = GetPrivateProfileSectionA( RENAME_SECTION, szBuffer,
elementsof(szBuffer), WININIT_FILENAME );
+ DWORD dwBufLen = GetPrivateProfileSectionA( RENAME_SECTION, szBuffer,
SAL_N_ELEMENTS(szBuffer), WININIT_FILENAME );
CHAR szRename[MAX_PATH]; // This is enough for at most to times 67 chracters
strcpy( szRename, szNewFileNameA );
@@ -135,7 +136,7 @@ static BOOL MoveFileEx9x( LPCSTR lpExistingFileNameA, LPCSTR lpNewFileNameA, DWO
strcat( szRename, szExistingFileNameA );
size_t lnRename = strlen(szRename);
- if ( dwBufLen + lnRename + 2 <= elementsof(szBuffer) )
+ if ( dwBufLen + lnRename + 2 <= SAL_N_ELEMENTS(szBuffer) )
{
CopyMemory( &szBuffer[dwBufLen], szRename, lnRename );
szBuffer[dwBufLen + lnRename ] = 0;
diff --git a/setup_native/source/win32/customactions/languagepacks/respintest.cxx
b/setup_native/source/win32/customactions/languagepacks/respintest.cxx
index 4ff79de..0162189 100644
--- a/setup_native/source/win32/customactions/languagepacks/respintest.cxx
+++ b/setup_native/source/win32/customactions/languagepacks/respintest.cxx
@@ -47,6 +47,7 @@
#include <tchar.h>
#include <string>
#include <systools/win32/uwinapi.h>
+#include <sal/macros.h>
#include <../tools/seterror.hxx>
@@ -111,7 +112,7 @@ extern "C" UINT __stdcall GetUserInstallMode(MSIHANDLE handle)
TEXT("ProductCode"),
TEXT("INVALIDDIRECTORY"),
szValue,
- elementsof(szValue),
+ SAL_N_ELEMENTS(szValue),
sSetupiniPath.c_str()
);
@@ -133,7 +134,7 @@ extern "C" UINT __stdcall GetUserInstallMode(MSIHANDLE handle)
TEXT("buildid"),
TEXT("ISWRONGPRODUCT"),
szValue,
- elementsof(szValue),
+ SAL_N_ELEMENTS(szValue),
sSetupiniPath.c_str()
);
@@ -174,7 +175,7 @@ extern "C" UINT __stdcall GetUserInstallMode(MSIHANDLE handle)
TEXT("ProductBuildid"),
TEXT("8918"),
szValue,
- elementsof(szValue),
+ SAL_N_ELEMENTS(szValue),
sSetupiniPath.c_str()
);
@@ -198,7 +199,7 @@ extern "C" UINT __stdcall GetUserInstallMode(MSIHANDLE handle)
TEXT("ALLUSERS"),
TEXT(""),
szValue,
- elementsof(szValue),
+ SAL_N_ELEMENTS(szValue),
sSetupiniPath.c_str()
);
diff --git a/setup_native/source/win32/customactions/patch/swappatchfiles.cxx
b/setup_native/source/win32/customactions/patch/swappatchfiles.cxx
index 8249590..8c55bf6 100644
--- a/setup_native/source/win32/customactions/patch/swappatchfiles.cxx
+++ b/setup_native/source/win32/customactions/patch/swappatchfiles.cxx
@@ -53,6 +53,7 @@
#include <stdio.h>
#include <systools/win32/uwinapi.h>
+#include <sal/macros.h>
#include <../tools/seterror.hxx>
#define WININIT_FILENAME "wininit.ini"
@@ -65,7 +66,7 @@ inline void OutputDebugStringFormat( LPCTSTR pFormat, ... )
va_list args;
va_start( args, pFormat );
- _vsntprintf( buffer, elementsof(buffer), pFormat, args );
+ _vsntprintf( buffer, SAL_N_ELEMENTS(buffer), pFormat, args );
OutputDebugString( buffer );
}
#else
@@ -196,7 +197,7 @@ static BOOL MoveFileEx9x( LPCSTR lpExistingFileNameA, LPCSTR lpNewFileNameA, DWO
)
{
CHAR szBuffer[32767]; // The buffer size must not exceed 32K
- DWORD dwBufLen = GetPrivateProfileSectionA( RENAME_SECTION, szBuffer,
elementsof(szBuffer), WININIT_FILENAME );
+ DWORD dwBufLen = GetPrivateProfileSectionA( RENAME_SECTION, szBuffer,
SAL_N_ELEMENTS(szBuffer), WININIT_FILENAME );
CHAR szRename[MAX_PATH]; // This is enough for at most to times 67 chracters
strcpy( szRename, szNewFileNameA );
@@ -204,7 +205,7 @@ static BOOL MoveFileEx9x( LPCSTR lpExistingFileNameA, LPCSTR lpNewFileNameA, DWO
strcat( szRename, szExistingFileNameA );
size_t lnRename = strlen(szRename);
- if ( dwBufLen + lnRename + 2 <= elementsof(szBuffer) )
+ if ( dwBufLen + lnRename + 2 <= SAL_N_ELEMENTS(szBuffer) )
{
CopyMemory( &szBuffer[dwBufLen], szRename, lnRename );
szBuffer[dwBufLen + lnRename ] = 0;
@@ -735,7 +736,7 @@ extern "C" UINT __stdcall SetFeatureState( MSIHANDLE handle )
TEXT("ProductCode"),
TEXT("NOTFOUND"),
szProductCode,
- elementsof(szProductCode),
+ SAL_N_ELEMENTS(szProductCode),
sSetupiniPath.c_str()
);
diff --git a/setup_native/source/win32/customactions/shellextensions/checkrunningoffice.cxx
b/setup_native/source/win32/customactions/shellextensions/checkrunningoffice.cxx
index a3539f6..0f1a2b6 100644
--- a/setup_native/source/win32/customactions/shellextensions/checkrunningoffice.cxx
+++ b/setup_native/source/win32/customactions/shellextensions/checkrunningoffice.cxx
@@ -53,6 +53,7 @@
#include <stdio.h>
#include <systools/win32/uwinapi.h>
+#include <sal/macros.h>
#include <../tools/seterror.hxx>
#define WININIT_FILENAME "wininit.ini"
@@ -65,7 +66,7 @@ inline void OutputDebugStringFormat( LPCTSTR pFormat, ... )
va_list args;
va_start( args, pFormat );
- _vsntprintf( buffer, elementsof(buffer), pFormat, args );
+ _vsntprintf( buffer, SAL_N_ELEMENTS(buffer), pFormat, args );
OutputDebugString( buffer );
}
#else
@@ -127,7 +128,7 @@ static BOOL MoveFileEx9x( LPCSTR lpExistingFileNameA, LPCSTR lpNewFileNameA, DWO
)
{
CHAR szBuffer[32767]; // The buffer size must not exceed 32K
- DWORD dwBufLen = GetPrivateProfileSectionA( RENAME_SECTION, szBuffer,
elementsof(szBuffer), WININIT_FILENAME );
+ DWORD dwBufLen = GetPrivateProfileSectionA( RENAME_SECTION, szBuffer,
SAL_N_ELEMENTS(szBuffer), WININIT_FILENAME );
CHAR szRename[MAX_PATH]; // This is enough for at most to times 67 chracters
strcpy( szRename, szNewFileNameA );
@@ -135,7 +136,7 @@ static BOOL MoveFileEx9x( LPCSTR lpExistingFileNameA, LPCSTR lpNewFileNameA, DWO
strcat( szRename, szExistingFileNameA );
size_t lnRename = strlen(szRename);
- if ( dwBufLen + lnRename + 2 <= elementsof(szBuffer) )
+ if ( dwBufLen + lnRename + 2 <= SAL_N_ELEMENTS(szBuffer) )
{
CopyMemory( &szBuffer[dwBufLen], szRename, lnRename );
szBuffer[dwBufLen + lnRename ] = 0;
diff --git a/desktop/win32/source/guistdio/guistdio.inc b/desktop/win32/source/guistdio/guistdio.inc
index 7009b24..e4a82fa 100644
--- a/desktop/win32/source/guistdio/guistdio.inc
+++ b/desktop/win32/source/guistdio/guistdio.inc
@@ -41,6 +41,7 @@
#include <string.h>
#include <stdlib.h>
#include <systools/win32/uwinapi.h>
+#include <sal/macros.h>
#include <stdio.h>
#include <sal/macros.h>
@@ -411,13 +412,13 @@ int _tmain( int, _TCHAR ** )
};
#ifdef UNOPKG
- dwWaitResult = WaitForMultipleObjects( elementsof(hObjects), hObjects, TRUE, INFINITE );
+ dwWaitResult = WaitForMultipleObjects( SAL_N_ELEMENTS(hObjects), hObjects, TRUE, INFINITE
);
#else
bool bDetach = false;
int nOpenPipes = 2;
do
{
- dwWaitResult = WaitForMultipleObjects( elementsof(hObjects), hObjects,
FALSE, INFINITE );
+ dwWaitResult = WaitForMultipleObjects( SAL_N_ELEMENTS(hObjects), hObjects,
FALSE, INFINITE );
switch ( dwWaitResult )
{
diff --git a/desktop/win32/source/officeloader/officeloader.cxx
b/desktop/win32/source/officeloader/officeloader.cxx
index c5e34dc..66cea93 100644
--- a/desktop/win32/source/officeloader/officeloader.cxx
+++ b/desktop/win32/source/officeloader/officeloader.cxx
@@ -49,6 +49,7 @@
#include <string.h>
#include <stdlib.h>
#include <systools/win32/uwinapi.h>
+#include <sal/macros.h>
#include "rtl/string.h"
#include <sal/macros.h>
@@ -230,7 +231,7 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
TEXT("FastPipeCommunication"),
TEXT("0"),
szKey,
- elementsof(szKey),
+ SAL_N_ELEMENTS(szKey),
szPerfTuneIniFile
);
@@ -258,10 +259,10 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
fSuccess = ConvertSidToStringSid( pSid, &szUserIdent );
- _tcsncpy( szPipeName, PIPE_PREFIX, elementsof(szPipeName) );
- _tcsncat( szPipeName, szUserIdent, elementsof(szPipeName) - _tcslen(szPipeName) -
1 );
- _tcsncat( szPipeName, PIPE_POSTFIX, elementsof(szPipeName) - _tcslen(szPipeName) -
1 );
- _tcsncat( szPipeName, _ultot( SUPD, szSUPD, 10), elementsof(szPipeName) -
_tcslen(szPipeName) - 1 );
+ _tcsncpy( szPipeName, PIPE_PREFIX, SAL_N_ELEMENTS(szPipeName) );
+ _tcsncat( szPipeName, szUserIdent, SAL_N_ELEMENTS(szPipeName) -
_tcslen(szPipeName) - 1 );
+ _tcsncat( szPipeName, PIPE_POSTFIX, SAL_N_ELEMENTS(szPipeName) -
_tcslen(szPipeName) - 1 );
+ _tcsncat( szPipeName, _ultot( SUPD, szSUPD, 10), SAL_N_ELEMENTS(szPipeName) -
_tcslen(szPipeName) - 1 );
LocalFree( szUserIdent );
diff --git a/svx/source/dialog/sendreportw32.cxx b/svx/source/dialog/sendreportw32.cxx
index 1eba75c..b50dc0c 100644
--- a/svx/source/dialog/sendreportw32.cxx
+++ b/svx/source/dialog/sendreportw32.cxx
@@ -39,6 +39,7 @@
#include <tchar.h>
#include <stdio.h>
#include <systools/win32/uwinapi.h>
+#include <sal/macros.h>
// need to undef min and max macros from MS headers here to make
// the std::min and std::max from stl visible again
@@ -199,7 +200,7 @@ namespace svx{
TCHAR szTempPath[MAX_PATH];
TCHAR szFileName[MAX_PATH];
- GetTempPath( elementsof(szTempPath), szTempPath );
+ GetTempPath( SAL_N_ELEMENTS(szTempPath), szTempPath );
GetTempFileName( szTempPath, TEXT("DSC"), 0, szFileName );
FILE *fp = _tfopen( szFileName, _T("wb") );
@@ -226,7 +227,7 @@ namespace svx{
ZeroMemory( &StartupInfo, sizeof(StartupInfo) );
StartupInfo.cb = sizeof(StartupInfo.cb);
- sntprintf( szBuffer, elementsof(szBuffer),
+ sntprintf( szBuffer, SAL_N_ELEMENTS(szBuffer),
_T("%s -noui -load -send"),
szPath );
diff --git a/sysui/source/win32/QuickStart/QuickStart.cpp
b/sysui/source/win32/QuickStart/QuickStart.cpp
index 8e37560..f428d41 100644
--- a/sysui/source/win32/QuickStart/QuickStart.cpp
+++ b/sysui/source/win32/QuickStart/QuickStart.cpp
@@ -5,6 +5,7 @@
#include "stdafx.h"
#include "resource.h"
#include <systools/win32/uwinapi.h>
+#include <sal/macros.h>
#include <stdio.h>
#define MY_TASKBAR_NOTIFICATION WM_USER+1
@@ -102,11 +103,11 @@ void NotifyListener( HWND hWnd )
nid.cbSize = sizeof(NOTIFYICONDATA);
nid.hWnd = hWnd;
nid.uID = IDM_QUICKSTART;
- nid.szTip[elementsof(nid.szTip) - 1] = 0;
+ nid.szTip[SAL_N_ELEMENTS(nid.szTip) - 1] = 0;
// nid.hIcon = bTerminateVeto ? hIconActive : hIconInActive;
-// strncpy(nid.szTip, bTerminateVeto ? STRING_QUICKSTARTACTIVE : STRING_QUICKSTARTINACTIVE,
elementsof(nid.szTip) - 1 );
+// strncpy(nid.szTip, bTerminateVeto ? STRING_QUICKSTARTACTIVE : STRING_QUICKSTARTINACTIVE,
SAL_N_ELEMENTS(nid.szTip) - 1 );
nid.hIcon = hIconActive;
- strncpy(nid.szTip, szTooltipString, elementsof(nid.szTip) - 1);
+ strncpy(nid.szTip, szTooltipString, SAL_N_ELEMENTS(nid.szTip) - 1);
nid.uFlags = NIF_TIP|NIF_ICON;
// update systray
diff --git a/sal/inc/systools/win32/uwinapi.h b/sal/inc/systools/win32/uwinapi.h
index 6c19788..7fda61e 100644
--- a/sal/inc/systools/win32/uwinapi.h
+++ b/sal/inc/systools/win32/uwinapi.h
@@ -102,10 +102,6 @@ EXTERN_C WINBASEAPI DWORD WINAPI GetUserDomainW( LPWSTR lpBuffer, DWORD
nBuffser
EXTERN_C WINBASEAPI DWORD WINAPI GetProcessId( HANDLE hProcess );
-/* macro that calculates the count of elements of a static array */
-
-#define elementsof(buf) (sizeof(buf) / sizeof((buf)[0]))
-
#ifdef __cplusplus
inline bool IsValidHandle(HANDLE handle)
diff --git a/sal/osl/w32/security.c b/sal/osl/w32/security.c
index 4d9ee32..0fc22f1 100644
--- a/sal/osl/w32/security.c
+++ b/sal/osl/w32/security.c
@@ -33,6 +33,7 @@
#include <osl/thread.h>
#include <osl/file.h>
#include <systools/win32/uwinapi.h>
+#include <sal/macros.h>
#include "secimpl.h"
/*****************************************************************************/
@@ -756,7 +757,7 @@ static sal_Bool GetSpecialFolder(rtl_uString **strPath, int nFolder)
&hRegKey) == ERROR_SUCCESS)
{
LONG lRet;
- DWORD lSize = elementsof(PathA);
+ DWORD lSize = SAL_N_ELEMENTS(PathA);
DWORD Type = REG_SZ;
switch (nFolder)
diff --git a/sal/osl/w32/signal.cxx b/sal/osl/w32/signal.cxx
index 835fdc1..5f97f72 100644
--- a/sal/osl/w32/signal.cxx
+++ b/sal/osl/w32/signal.cxx
@@ -41,6 +41,7 @@
#endif
#include <ErrorRep.h>
#include <systools/win32/uwinapi.h>
+#include <sal/macros.h>
typedef struct _oslSignalHandlerImpl
{
@@ -187,7 +188,7 @@ static BOOL ReportCrash( LPEXCEPTION_POINTERS lpEP )
StartupInfo.cb = sizeof(StartupInfo.cb);
- sntprintf( szBuffer, elementsof(szBuffer),
+ sntprintf( szBuffer, SAL_N_ELEMENTS(szBuffer),
_T("%s -p %u -excp 0x%p -t %u%s"),
static_cast<sal_Char*>( aPath ),
GetCurrentProcessId(),
diff --git a/sal/systools/win32/kill/kill.cxx b/sal/systools/win32/kill/kill.cxx
index 1103950..55966d6 100644
--- a/sal/systools/win32/kill/kill.cxx
+++ b/sal/systools/win32/kill/kill.cxx
@@ -68,9 +68,6 @@ static inline bool IsValidHandle( HANDLE handle )
return INVALID_HANDLE_VALUE != handle && NULL != handle;
}
-
-#define elementsof( a ) (sizeof(a) / sizeof( (a)[0] ))
-
/////////////////////////////////////////////////////////////////////////////
// Retrieves function adress in another process
/////////////////////////////////////////////////////////////////////////////
@@ -91,7 +88,7 @@ FARPROC WINAPI GetProcAddressEx( HANDLE hProcess, HMODULE hModule, LPCSTR lpProc
FARPROC lpfnRemoteProcAddress = NULL;
TCHAR szBaseName[MAX_PATH];
- if ( GetModuleBaseName( GetCurrentProcess(), hModule, szBaseName,
elementsof(szBaseName) ) )
+ if ( GetModuleBaseName( GetCurrentProcess(), hModule, szBaseName,
SAL_N_ELEMENTS(szBaseName) ) )
{
HMODULE ahModules[MAX_MODULES];
DWORD cbNeeded = 0;
@@ -105,7 +102,7 @@ FARPROC WINAPI GetProcAddressEx( HANDLE hProcess, HMODULE hModule, LPCSTR lpProc
TCHAR szRemoteBaseName[MAX_PATH];
if ( GetModuleBaseName(
- hProcess, ahModules[n], szRemoteBaseName, elementsof(szRemoteBaseName)
) &&
+ hProcess, ahModules[n], szRemoteBaseName,
SAL_N_ELEMENTS(szRemoteBaseName) ) &&
0 == lstrcmpi( szRemoteBaseName, szBaseName )
)
{
@@ -257,7 +254,7 @@ static void ParseCommandArgs( LPDWORD lpProcesses, LPDWORD lpdwNumProcesses, int
SIG_ENTRY( KILL )
};
- const int NumSupportedSignals = elementsof(SupportedSignals);
+ const int NumSupportedSignals = SAL_N_ELEMENTS(SupportedSignals);
DWORD dwMaxProcesses = *lpdwNumProcesses;
int argc = __argc;
@@ -402,7 +399,7 @@ void OutputSystemMessage( DWORD dwErrorCode )
int _tmain()
{
DWORD dwProcessIds[1024];
- DWORD nProcesses = elementsof(dwProcessIds);
+ DWORD nProcesses = SAL_N_ELEMENTS(dwProcessIds);
int sig = SIGTERM;
diff --git a/sal/systools/win32/onlineupdate/onlinecheck.cxx
b/sal/systools/win32/onlineupdate/onlinecheck.cxx
index dfcf2de..1ea7232 100644
--- a/sal/systools/win32/onlineupdate/onlinecheck.cxx
+++ b/sal/systools/win32/onlineupdate/onlinecheck.cxx
@@ -46,8 +46,6 @@
#include <excpt.h>
#endif
-#define elementsof(a) (sizeof(a)/sizeof((a)[0]))
-
// #i71984
extern "C" sal_Bool SAL_CALL hasInternetConnection()
{
@@ -66,7 +64,7 @@ extern "C" sal_Bool SAL_CALL hasInternetConnection()
BOOL fIsConnected = InternetGetConnectedStateEx(
&dwFlags,
szConnectionName,
- elementsof(szConnectionName),
+ SAL_N_ELEMENTS(szConnectionName),
0 );
return fIsConnected ? sal_True : sal_False;
diff --git a/sal/systools/win32/uwinapi/MoveFileExA.cpp b/sal/systools/win32/uwinapi/MoveFileExA.cpp
index 4f7522f..6c47078 100644
--- a/sal/systools/win32/uwinapi/MoveFileExA.cpp
+++ b/sal/systools/win32/uwinapi/MoveFileExA.cpp
@@ -27,6 +27,7 @@
************************************************************************/
#include "macros.h"
+#include <sal/macros.h>
#define WININIT_FILENAME "wininit.ini"
#define RENAME_SECTION "rename"
@@ -50,7 +51,7 @@ IMPLEMENT_THUNK( kernel32, WINDOWS, BOOL, WINAPI, MoveFileExA, ( LPCSTR lpExisti
)
{
CHAR szBuffer[32767]; // The buffer size must not exceed 32K
- DWORD dwBufLen = GetPrivateProfileSectionA( RENAME_SECTION, szBuffer,
elementsof(szBuffer), WININIT_FILENAME );
+ DWORD dwBufLen = GetPrivateProfileSectionA( RENAME_SECTION, szBuffer,
SAL_N_ELEMENTS(szBuffer), WININIT_FILENAME );
CHAR szRename[MAX_PATH]; // This is enough for at most to times 67 chracters
strcpy( szRename, szNewFileNameA );
@@ -58,7 +59,7 @@ IMPLEMENT_THUNK( kernel32, WINDOWS, BOOL, WINAPI, MoveFileExA, ( LPCSTR lpExisti
strcat( szRename, szExistingFileNameA );
size_t lnRename = strlen(szRename);
- if ( dwBufLen + lnRename + 2 <= elementsof(szBuffer) )
+ if ( dwBufLen + lnRename + 2 <= SAL_N_ELEMENTS(szBuffer) )
{
CopyMemory( &szBuffer[dwBufLen], szRename, lnRename );
szBuffer[dwBufLen + lnRename ] = 0;
Context
- [Libreoffice] [PATCH] replaces elementsof with 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.