[Libreoffice-commits] .: sc/source

Norbert Thiebaud nthiebaud at kemper.freedesktop.org
Sat Oct 9 11:59:13 PDT 2010


 sc/source/core/data/cell2.cxx           |    2 +-
 sc/source/core/data/dpobject.cxx        |    2 +-
 sc/source/core/tool/compiler.cxx        |    2 +-
 sc/source/core/tool/interpr2.cxx        |    4 ++--
 sc/source/core/tool/odffmap.cxx         |    2 +-
 sc/source/filter/qpro/qproform.cxx      |    2 +-
 sc/source/filter/xml/xmlimprt.cxx       |    2 +-
 sc/source/ui/miscdlgs/protectiondlg.cxx |    2 +-
 sc/source/ui/unoobj/scdetect.cxx        |    4 ++--
 sc/source/ui/unoobj/servuno.cxx         |    6 +++---
 sc/source/ui/unoobj/tokenuno.cxx        |    2 +-
 sc/source/ui/vba/vbaborders.cxx         |    3 +--
 sc/source/ui/vba/vbadialog.cxx          |    2 +-
 sc/source/ui/vba/vbaglobals.cxx         |    3 +--
 sc/source/ui/vba/vbapalette.cxx         |    2 +-
 15 files changed, 19 insertions(+), 21 deletions(-)

New commits:
commit 7b8d6eb623cb41413c126cb42c066c572800b268
Author: Kayo Hamid <revol.code at yahoo.com>
Date:   Sat Oct 9 13:46:58 2010 -0500

    Use SAL_N_ELEMENTS macro

diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx
index d3b3621..d2a5e12 100644
--- a/sc/source/core/data/cell2.cxx
+++ b/sc/source/core/data/cell2.cxx
@@ -152,7 +152,7 @@ void ScEditCell::RemoveCharAttribs( const ScPatternAttr& rAttr )
         { ATTR_FONT_WEIGHT, EE_CHAR_WEIGHT },
         { ATTR_FONT_COLOR,  EE_CHAR_COLOR }
     };
-    USHORT nMapCount = sizeof(AttrTypeMap) / sizeof(AttrTypeMap[0]);
+    USHORT nMapCount = SAL_N_ELEMENTS(AttrTypeMap);
 
     const SfxItemSet& rSet = rAttr.GetItemSet();
     const SfxPoolItem* pItem;
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 8048f0e..839b58d 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -1184,7 +1184,7 @@ bool lcl_ParseFunction( const String& rList, xub_StrLen nStartPos, xub_StrLen& r
     {
         aFuncStr.EraseLeadingAndTrailingChars( ' ' );
 
-        const sal_Int32 nFuncCount = sizeof(aFunctions) / sizeof(aFunctions[0]);
+        const sal_Int32 nFuncCount = SAL_N_ELEMENTS(aFunctions);
         for ( sal_Int32 nFunc=0; nFunc<nFuncCount && !bFound; nFunc++ )
         {
             if ( aFuncStr.EqualsIgnoreCaseAscii( aFunctions[nFunc].pName ) )
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 606b2b5..e55a94b 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -2538,7 +2538,7 @@ BOOL ScCompiler::IsOpCode( const String& rName, bool bInArray )
             { "LEGACY.TDIST",                   ocTDist },          // TDIST -> LEGACY.TDIST
             { "ORG.OPENOFFICE.EASTERSUNDAY",    ocEasterSunday }    // EASTERSUNDAY -> ORG.OPENOFFICE.EASTERSUNDAY
         };
-        static const size_t nOdffAliases = sizeof(aOdffAliases) / sizeof(aOdffAliases[0]);
+        static const size_t nOdffAliases = SAL_N_ELEMENTS(aOdffAliases);
         for (size_t i=0; i<nOdffAliases; ++i)
         {
             if (rName.EqualsIgnoreCaseAscii( aOdffAliases[i].pName))
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index b560f93..e7f5bff 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -2442,7 +2442,7 @@ void ScInterpreter::ScRoman()
         {
             static const sal_Unicode pChars[] = { 'M', 'D', 'C', 'L', 'X', 'V', 'I' };
             static const USHORT pValues[] = { 1000, 500, 100, 50, 10, 5, 1 };
-            static const USHORT nMaxIndex = (USHORT)(sizeof(pValues) / sizeof(pValues[0]) - 1);
+            static const USHORT nMaxIndex = (USHORT)(SAL_N_ELEMENTS(pValues) - 1);
 
             String aRoman;
             USHORT nVal = (USHORT) fVal;
@@ -2675,7 +2675,7 @@ BOOL lclConvertMoney( const String& aSearchUnit, double& rfRate, int& rnDec )
         { "SKK", 30.1260,  2 }
     };
 
-    const size_t nConversionCount = sizeof( aConvertTable ) / sizeof( aConvertTable[0] );
+    const size_t nConversionCount = SAL_N_ELEMENTS(aConvertTable);
     for ( size_t i = 0; i < nConversionCount; i++ )
         if ( aSearchUnit.EqualsIgnoreCaseAscii( aConvertTable[i].pCurrText ) )
         {
diff --git a/sc/source/core/tool/odffmap.cxx b/sc/source/core/tool/odffmap.cxx
index 4966eb6..5c06aa5 100644
--- a/sc/source/core/tool/odffmap.cxx
+++ b/sc/source/core/tool/odffmap.cxx
@@ -145,5 +145,5 @@ const ScCompiler::AddInMap* ScCompiler::GetAddInMap()
 // static
 size_t ScCompiler::GetAddInMapCount()
 {
-    return sizeof(maAddInMap)/sizeof(maAddInMap[0]);
+    return SAL_N_ELEMENTS(maAddInMap);
 }
diff --git a/sc/source/filter/qpro/qproform.cxx b/sc/source/filter/qpro/qproform.cxx
index 0d5d062..f1cccab 100644
--- a/sc/source/filter/qpro/qproform.cxx
+++ b/sc/source/filter/qpro/qproform.cxx
@@ -556,7 +556,7 @@ static const struct
     { ocNoName, FT_NotImpl }   // gives properties of DOS menus
 };
 
-const int nIndexCount = sizeof( aFuncMap ) / sizeof( aFuncMap[ 0 ] );
+const int nIndexCount = SAL_N_ELEMENTS(aFuncMap);
 
 DefTokenId QProToSc::IndexToToken( sal_uInt16 nIndex )
 {
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index 16bdcad..003ff23 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -1781,7 +1781,7 @@ ScXMLImport::ScXMLImport(
         { XML_CURRENCY,     util::NumberFormat::CURRENCY },
         { XML_BOOLEAN,      util::NumberFormat::LOGICAL }
     };
-    size_t n = sizeof(aCellTypePairs)/sizeof(aCellTypePairs[0]);
+    size_t n = SAL_N_ELEMENTS(aCellTypePairs);
     for (size_t i = 0; i < n; ++i)
     {
         aCellTypeMap.insert(
diff --git a/sc/source/ui/miscdlgs/protectiondlg.cxx b/sc/source/ui/miscdlgs/protectiondlg.cxx
index 79d53b9..9edb9f0 100644
--- a/sc/source/ui/miscdlgs/protectiondlg.cxx
+++ b/sc/source/ui/miscdlgs/protectiondlg.cxx
@@ -41,7 +41,7 @@ static const ScTableProtection::Option aOptions[] = {
     ScTableProtection::SELECT_LOCKED_CELLS,
     ScTableProtection::SELECT_UNLOCKED_CELLS,
 };
-static const USHORT nOptionCount = sizeof(aOptions)/sizeof(aOptions[0]);
+static const USHORT nOptionCount = SAL_N_ELEMENTS(aOptions);
 
 
 ScTableProtectionDlg::ScTableProtectionDlg(Window* pParent) :
diff --git a/sc/source/ui/unoobj/scdetect.cxx b/sc/source/ui/unoobj/scdetect.cxx
index 1b8ce06..ac87552 100644
--- a/sc/source/ui/unoobj/scdetect.cxx
+++ b/sc/source/ui/unoobj/scdetect.cxx
@@ -165,7 +165,7 @@ static BOOL lcl_MayBeDBase( SvStream& rStream )
     rStream.Seek(STREAM_SEEK_TO_BEGIN);
     rStream >> nMark;
     bool bValidMark = false;
-    for (size_t i=0; i < sizeof(nValidMarks)/sizeof(nValidMarks[0]) && !bValidMark; ++i)
+    for (size_t i=0; i < SAL_N_ELEMENTS(nValidMarks) && !bValidMark; ++i)
     {
         if (nValidMarks[i] == nMark)
             bValidMark = true;
@@ -631,7 +631,7 @@ static BOOL lcl_IsAnyXMLFilter( const SfxFilter* pFilter )
                             pLotus2,
                             pQPro
                             };
-                        const UINT16 nFilterCount = sizeof(ppFilterPatterns) / sizeof(ppFilterPatterns[0]);
+                        const UINT16 nFilterCount = SAL_N_ELEMENTS(ppFilterPatterns);
 
                         static const sal_Char* const pFilterName[] =     // zugehoerige Filter
                             {
diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx
index a12ca58..a30c270 100644
--- a/sc/source/ui/unoobj/servuno.cxx
+++ b/sc/source/ui/unoobj/servuno.cxx
@@ -355,8 +355,8 @@ sal_uInt16 ScServiceProvider::GetProviderType(const String& rServiceName)
 {
     if (rServiceName.Len())
     {
-        const sal_uInt16 nEntries =
-            sizeof(aProvNamesId) / sizeof(aProvNamesId[0]);
+        const sal_uInt16 nEntries = SAL_N_ELEMENTS(aProvNamesId);
+
         for (sal_uInt16 i = 0; i < nEntries; i++)
         {
             if (rServiceName.EqualsAscii( aProvNamesId[i].pName ))
@@ -576,7 +576,7 @@ uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance(
 
 uno::Sequence<rtl::OUString> ScServiceProvider::GetAllServiceNames()
 {
-    const sal_uInt16 nEntries = sizeof(aProvNamesId) / sizeof(aProvNamesId[0]);
+    const sal_uInt16 nEntries = SAL_N_ELEMENTS(aProvNamesId);
     uno::Sequence<rtl::OUString> aRet(nEntries);
     rtl::OUString* pArray = aRet.getArray();
     for (sal_uInt16 i = 0; i < nEntries; i++)
diff --git a/sc/source/ui/unoobj/tokenuno.cxx b/sc/source/ui/unoobj/tokenuno.cxx
index 91f7fed..350c744 100644
--- a/sc/source/ui/unoobj/tokenuno.cxx
+++ b/sc/source/ui/unoobj/tokenuno.cxx
@@ -105,7 +105,7 @@ void ScFormulaParserObj::SetCompilerFlags( ScCompiler& rCompiler ) const
         formula::FormulaGrammar::CONV_XL_OOX,     // <- AddressConvention::XL_OOX
         formula::FormulaGrammar::CONV_LOTUS_A1    // <- AddressConvention::LOTUS_A1
     };
-    static const sal_Int16 nConvMapCount = sizeof(aConvMap)/sizeof(aConvMap[0]);
+    static const sal_Int16 nConvMapCount = SAL_N_ELEMENTS(aConvMap);
 
     // If mxOpCodeMap is not empty it overrides mbEnglish, and vice versa. We
     // don't need to initialize things twice.
diff --git a/sc/source/ui/vba/vbaborders.cxx b/sc/source/ui/vba/vbaborders.cxx
index 5ecdc5f..3da3f2b 100644
--- a/sc/source/ui/vba/vbaborders.cxx
+++ b/sc/source/ui/vba/vbaborders.cxx
@@ -34,7 +34,6 @@
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/table/TableBorder.hpp>
 #include <com/sun/star/table/XColumnRowRange.hpp>
-
 #include "vbapalette.hxx"
 
 using namespace ::com::sun::star;
@@ -332,7 +331,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/sc/source/ui/vba/vbadialog.cxx b/sc/source/ui/vba/vbadialog.cxx
index 891ac75..6fe0a3e 100644
--- a/sc/source/ui/vba/vbadialog.cxx
+++ b/sc/source/ui/vba/vbadialog.cxx
@@ -58,7 +58,7 @@ static const rtl::OUString aStringList[]=
     rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AutoFormat" ) )	
 };
 
-const sal_Int32 nDialogSize = sizeof( aStringList ) / sizeof( aStringList[ 0 ] );
+const sal_Int32 nDialogSize = SAL_N_ELEMENTS( aStringList ) ;
 
 rtl::OUString 
 ScVbaDialog::mapIndexToName( sal_Int32 nIndex )
diff --git a/sc/source/ui/vba/vbaglobals.cxx b/sc/source/ui/vba/vbaglobals.cxx
index adb9b7f..8c7e3d3 100644
--- a/sc/source/ui/vba/vbaglobals.cxx
+++ b/sc/source/ui/vba/vbaglobals.cxx
@@ -32,7 +32,6 @@
 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <cppuhelper/component_context.hxx>
-
 #include "vbaapplication.hxx"
 #include "vbaworksheet.hxx"
 #include "vbarange.hxx"
@@ -263,7 +262,7 @@ ScVbaGlobals::getAvailableServiceNames(  ) throw (uno::RuntimeException)
             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Hyperlink" ) ),
             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.script.vba.VBASpreadsheetEventProcessor" ) )
           };
-        sal_Int32 nExcelServices = ( sizeof( names )/ sizeof( names[0] ) );
+        sal_Int32 nExcelServices = ( SAL_N_ELEMENTS(names) );
         sal_Int32 startIndex = serviceNames.getLength();
         serviceNames.realloc( serviceNames.getLength() + nExcelServices );
         for ( sal_Int32 index = 0; index < nExcelServices; ++index )
diff --git a/sc/source/ui/vba/vbapalette.cxx b/sc/source/ui/vba/vbapalette.cxx
index 92b33de..441d605 100644
--- a/sc/source/ui/vba/vbapalette.cxx
+++ b/sc/source/ui/vba/vbapalette.cxx
@@ -62,7 +62,7 @@ public:
     // Methods XIndexAccess
     virtual ::sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException)
     {
-        return sizeof(spnDefColorTable8) / sizeof(spnDefColorTable8[0]);
+        return SAL_N_ELEMENTS(spnDefColorTable8);
     }
 
     virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)


More information about the Libreoffice-commits mailing list