diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-14 10:46:05 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-14 15:14:27 +0200 |
commit | 546c35519125a769755330c961c7b8fc61e24d89 (patch) | |
tree | 0b73735081bd279b89b93dabc5c35dee6ec08b94 | |
parent | Avoid use of FormulaTokenArray::First() and Next() in another place (diff) | |
download | core-546c35519125a769755330c961c7b8fc61e24d89.tar.gz core-546c35519125a769755330c961c7b8fc61e24d89.zip |
use more SAL_N_ELEMENTS part 2
Change-Id: If00e371c3cd3ae616309a172c875faed016e391b
Reviewed-on: https://gerrit.libreoffice.org/38773
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
22 files changed, 64 insertions, 126 deletions
diff --git a/oox/source/drawingml/textbodyproperties.cxx b/oox/source/drawingml/textbodyproperties.cxx index c9914fd3af7e..0ddc59435d2b 100644 --- a/oox/source/drawingml/textbodyproperties.cxx +++ b/oox/source/drawingml/textbodyproperties.cxx @@ -62,8 +62,8 @@ void TextBodyProperties::pushVertSimulation() void TextBodyProperties::pushRotationAdjustments() { sal_Int32 nOff = 0; - sal_Int32 aProps[] = { PROP_TextLeftDistance, PROP_TextUpperDistance, PROP_TextRightDistance, PROP_TextLowerDistance }; - sal_Int32 n = ( sal_Int32 )( sizeof( aProps ) / sizeof( sal_Int32 ) ); + static sal_Int32 const aProps[] { PROP_TextLeftDistance, PROP_TextUpperDistance, PROP_TextRightDistance, PROP_TextLowerDistance }; + sal_Int32 n = SAL_N_ELEMENTS( aProps ); switch( moRotation.get(0) ) { diff --git a/sal/osl/unx/signal.cxx b/sal/osl/unx/signal.cxx index f4c9a9ce5171..bc13b7947e8b 100644 --- a/sal/osl/unx/signal.cxx +++ b/sal/osl/unx/signal.cxx @@ -134,7 +134,7 @@ what looks like a bug in the new handler*/ { SIGXCPU, ACT_ABORT, SIG_DFL, false }, /* exceeded cpu limit */ { SIGXFSZ, ACT_ABORT, SIG_DFL, false } /* exceeded file size limit */ }; -const int NoSignals = sizeof(Signals) / sizeof(struct SignalAction); +const int NoSignals = SAL_N_ELEMENTS(Signals); bool bSetSEGVHandler = false; bool bSetWINCHHandler = false; diff --git a/sal/qa/rtl/digest/rtl_digest.cxx b/sal/qa/rtl/digest/rtl_digest.cxx index b61ce9be3fcd..f5c088b6c3ad 100644 --- a/sal/qa/rtl/digest/rtl_digest.cxx +++ b/sal/qa/rtl/digest/rtl_digest.cxx @@ -109,9 +109,7 @@ class DigestTest : public CppUnit::TestFixture public: void testCreate() { - int aAlgorithmSize = sizeof(constDigestAlgorithms) / sizeof(constDigestAlgorithms[0]); - - for (int i = 0; i < aAlgorithmSize; i++) + for (size_t i = 0; i < SAL_N_ELEMENTS(constDigestAlgorithms); i++) { rtlDigest handle = rtl_digest_create( constDigestAlgorithms[i] ); CPPUNIT_ASSERT_MESSAGE("create digest", handle != nullptr); @@ -125,9 +123,7 @@ public: void testQuery() { - int aAlgorithmSize = sizeof(constDigestAlgorithms) / sizeof(constDigestAlgorithms[0]); - - for (int i = 0; i < aAlgorithmSize; i++) + for (size_t i = 0; i < SAL_N_ELEMENTS(constDigestAlgorithms); i++) { rtlDigest handle = rtl_digest_create(constDigestAlgorithms[i]); rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle); @@ -139,11 +135,10 @@ public: void testQueryLength() { - int aAlgorithmSize = sizeof(constDigestAlgorithms) / sizeof(constDigestAlgorithms[0]); rtlDigest handle; sal_uInt32 nAlgoLength; - for (int i = 0; i < aAlgorithmSize; i++) + for (size_t i = 0; i < SAL_N_ELEMENTS(constDigestAlgorithms); i++) { handle = rtl_digest_create(constDigestAlgorithms[i]); nAlgoLength = rtl_digest_queryLength(handle); @@ -171,9 +166,7 @@ public: CPPUNIT_ASSERT_EQUAL_MESSAGE("init(handle, 0, 0)", rtl_Digest_E_None, aError); rtl_digest_destroy( handle ); - int aAlgorithmSize = sizeof(constDigestAlgorithms) / sizeof(constDigestAlgorithms[0]); - - for (int i = 0; i < aAlgorithmSize; i++) + for (size_t i = 0; i < SAL_N_ELEMENTS(constDigestAlgorithms); i++) { handle = rtl_digest_create(constDigestAlgorithms[i]); @@ -223,9 +216,7 @@ public: void testCheckSum() { - int aAlgorithmSize = sizeof(constDigestAlgorithms) / sizeof(constDigestAlgorithms[0]); - - for (int i = 0; i < aAlgorithmSize; i++) + for (size_t i = 0; i < SAL_N_ELEMENTS(constDigestAlgorithms); i++) { OString aSum = getDigest(sSampleString, constDigestAlgorithms[i]); CPPUNIT_ASSERT_EQUAL_MESSAGE("Checksum of sample string is wrong.", constSampleStringSums[i], aSum); diff --git a/sal/qa/rtl/oustring/rtl_OUString2.cxx b/sal/qa/rtl/oustring/rtl_OUString2.cxx index 15748fcf8d2f..c345bc31b8bb 100644 --- a/sal/qa/rtl/oustring/rtl_OUString2.cxx +++ b/sal/qa/rtl/oustring/rtl_OUString2.cxx @@ -987,7 +987,7 @@ void createFromCodePoints::test() { sal_Int32(0), rtl::OUString(static_cast< sal_uInt32 const * >(nullptr), 0).getLength()); static sal_uInt32 const cp[] = { 0, 0xD800, 0xFFFF, 0x10000, 0x10FFFF }; - rtl::OUString s(cp, sizeof cp / sizeof (sal_uInt32)); + rtl::OUString s(cp, SAL_N_ELEMENTS(cp)); CPPUNIT_ASSERT_EQUAL(sal_Int32(7), s.getLength()); CPPUNIT_ASSERT_EQUAL(u'\0', s[0]); CPPUNIT_ASSERT_EQUAL(u'\xD800', s[1]); @@ -1010,7 +1010,7 @@ public: void iterateCodePoints::testNotWellFormed() { static sal_Unicode const utf16[] = { 0xD800, 0xDC00, 0x0041, 0xDBFF, 0xDFFF, 0xDDEF, 0xD9AB }; - rtl::OUString s(utf16, sizeof utf16 / sizeof (sal_Unicode)); + rtl::OUString s(utf16, SAL_N_ELEMENTS(utf16)); sal_Int32 i = 0; CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x10000), s.iterateCodePoints(&i)); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), i); diff --git a/sal/qa/rtl/textenc/rtl_textcvt.cxx b/sal/qa/rtl/textenc/rtl_textcvt.cxx index c9d7e5f08117..34e5208ae890 100644 --- a/sal/qa/rtl/textenc/rtl_textcvt.cxx +++ b/sal/qa/rtl/textenc/rtl_textcvt.cxx @@ -2678,7 +2678,7 @@ void Test::testSRCBUFFERTOSMALL() { CPPUNIT_ASSERT_EQUAL( sal_Size(0), rtl_convertTextToUnicode( - cv, cx, &src, 1, dst, sizeof dst / sizeof (sal_Unicode), + cv, cx, &src, 1, dst, SAL_N_ELEMENTS(dst), (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR | RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR), diff --git a/sal/qa/rtl/uri/rtl_testuri.cxx b/sal/qa/rtl/uri/rtl_testuri.cxx index e60797731d2f..ac0728413b1d 100644 --- a/sal/qa/rtl/uri/rtl_testuri.cxx +++ b/sal/qa/rtl/uri/rtl_testuri.cxx @@ -335,7 +335,8 @@ void Test::test_Uri() { { "http://a/b/c", "d", "http://a/b/d" }, { "http://a/b/c/", "d", "http://a/b/c/d" }, { "http://a/b/c//", "d", "http://a/b/c//d" } }; - for (std::size_t i = 0; i < sizeof aRelToAbsTest / sizeof (RelToAbsTest); ++i) + + for (std::size_t i = 0; i < SAL_N_ELEMENTS(aRelToAbsTest); ++i) { rtl::OUString aAbs; bool bMalformed = false; diff --git a/sal/textenc/convertadobe.tab b/sal/textenc/convertadobe.tab index 37cf080a4130..568ccd6be44b 100644 --- a/sal/textenc/convertadobe.tab +++ b/sal/textenc/convertadobe.tab @@ -281,7 +281,7 @@ adobeDingbatsEncodingConverterData = { 0x27A8, 0x27A9, 0x27AA, 0x27AB, 0x27AC, 0x27AD, 0x27AE, 0x27AF, 0xFFFF, 0x27B1, 0x27B2, 0x27B3, 0x27B4, 0x27B5, 0x27B6, 0x27B7, // 0xF0 0x27B8, 0x27B9, 0x27BA, 0x27BB, 0x27BC, 0x27BD, 0x27BE, 0xFFFF }, - (sizeof(unicodeToAdobeDingbatsEncoding) / sizeof(*unicodeToAdobeDingbatsEncoding)), + SAL_N_ELEMENTS(unicodeToAdobeDingbatsEncoding), unicodeToAdobeDingbatsEncoding }; ImplTextEncodingData const adobeStandardEncodingData diff --git a/sal/textenc/convertsimple.cxx b/sal/textenc/convertsimple.cxx index 99689f6d3d32..507e20907346 100644 --- a/sal/textenc/convertsimple.cxx +++ b/sal/textenc/convertsimple.cxx @@ -326,7 +326,7 @@ sal_uInt16 ImplGetReplaceChar( sal_Unicode c ) const ImplReplaceCharData* pCharData; nLow = 0; - nHigh = (sizeof( aImplRepCharTab )/sizeof( ImplReplaceCharData ))-1; + nHigh = SAL_N_ELEMENTS( aImplRepCharTab ) - 1; do { nMid = (nLow+nHigh)/2; @@ -418,7 +418,7 @@ const sal_uInt16* ImplGetReplaceString( sal_Unicode c ) const ImplReplaceCharStrData* pCharData; nLow = 0; - nHigh = (sizeof( aImplRepCharStrTab )/sizeof( ImplReplaceCharStrData ))-1; + nHigh = SAL_N_ELEMENTS( aImplRepCharStrTab ) - 1; do { nMid = (nLow+nHigh)/2; diff --git a/sax/qa/cppunit/xmlimport.cxx b/sax/qa/cppunit/xmlimport.cxx index 3e362e890111..f08c0357af28 100644 --- a/sax/qa/cppunit/xmlimport.cxx +++ b/sax/qa/cppunit/xmlimport.cxx @@ -383,7 +383,7 @@ void XMLImportTest::parse() "multiplens.xml", "multiplepfx.xml", "nstoattributes.xml", "nestedns.xml", "testthreading.xml"}; - for (sal_uInt16 i = 0; i < sizeof( fileNames ) / sizeof( OUString ); i++) + for (sal_uInt16 i = 0; i < SAL_N_ELEMENTS( fileNames ); i++) { InputSource source; source.sSystemId = "internal"; @@ -412,7 +412,7 @@ void XMLImportTest::testMissingNamespaceDeclaration() args[0] <<= OUString("IgnoreMissingNSDecl"); xInit->initialize( args ); - for (sal_uInt16 i = 0; i < sizeof( fileNames ) / sizeof( OUString ); i++) + for (sal_uInt16 i = 0; i < SAL_N_ELEMENTS( fileNames ); i++) { try { diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index c9fa796a551f..0cce79baa8b5 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -8580,7 +8580,6 @@ static const UBlockScript scriptList[] = { {UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B, UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT}, {UBLOCK_CJK_STROKES, UBLOCK_CJK_STROKES} }; -#define scriptListCount sizeof (scriptList) / sizeof (UBlockScript) bool SAL_CALL lcl_getScriptClass(sal_uInt32 currentChar) { // for the locale of ja-JP, character U+0x005c and U+0x20ac should be ScriptType::Asian @@ -8590,10 +8589,10 @@ bool SAL_CALL lcl_getScriptClass(sal_uInt32 currentChar) sal_uInt16 i; static bool bRet = false; UBlockCode block = ublock_getCode(currentChar); - for ( i = 0; i < scriptListCount; i++) { + for ( i = 0; i < SAL_N_ELEMENTS(scriptList); i++) { if (block <= scriptList[i].to) break; } - bRet = (i < scriptListCount && block >= scriptList[i].from); + bRet = (i < SAL_N_ELEMENTS(scriptList) && block >= scriptList[i].from); return bRet; } bool IsDBCS(sal_Unicode ch) diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index a5be80b54a95..d955373ed503 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -727,7 +727,7 @@ void SdImportTest::testFdo71075() uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSeqCnt(xSource->getDataSequences()); CPPUNIT_ASSERT_EQUAL_MESSAGE( "Invalid Series count", static_cast<sal_Int32>(1), aSeqCnt.getLength()); uno::Reference< chart2::data::XDataSequence > xValueSeq( aSeqCnt[0]->getValues() ); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Invalid Data count", static_cast<sal_Int32>(sizeof(values)/(sizeof(double))), xValueSeq->getData().getLength()); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Invalid Data count", static_cast<sal_Int32>(SAL_N_ELEMENTS(values)), xValueSeq->getData().getLength()); uno::Reference< chart2::data::XNumericalDataSequence > xNumSeq( xValueSeq, uno::UNO_QUERY ); uno::Sequence< double > aValues( xNumSeq->getNumericalData()); for(sal_Int32 i=0;i<xValueSeq->getData().getLength();i++) @@ -1358,7 +1358,7 @@ void SdImportTest::testTdf99729() { const char* filenames[] = { "/sd/qa/unit/data/odp/tdf99729-new.odp", "/sd/qa/unit/data/odp/tdf99729-legacy.odp" }; int nonwhitecounts[] = { 0, 0 }; - for (unsigned int i = 0; i < sizeof(filenames)/sizeof(filenames[0]); ++i) + for (unsigned int i = 0; i < SAL_N_ELEMENTS(filenames); ++i) { // 1st check for new behaviour - having AnchoredTextOverflowLegacy compatibility flag set to false in settings.xml sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(filenames[i]), ODP); diff --git a/sd/source/ui/slideshow/slideshowimpl.cxx b/sd/source/ui/slideshow/slideshowimpl.cxx index 4d56ea0029b9..6174640dc8f5 100644 --- a/sd/source/ui/slideshow/slideshowimpl.cxx +++ b/sd/source/ui/slideshow/slideshowimpl.cxx @@ -925,7 +925,7 @@ bool SlideshowImpl::startShow( PresentationSettingsEx* pPresSettings ) // these Slots are forbidden in other views for this document if( mpDocSh ) { - mpDocSh->SetSlotFilter( true, sizeof( pAllowed ) / sizeof( sal_uInt16 ), pAllowed ); + mpDocSh->SetSlotFilter( true, SAL_N_ELEMENTS( pAllowed ), pAllowed ); mpDocSh->ApplySlotFilter(); } @@ -2453,7 +2453,7 @@ void SAL_CALL SlideshowImpl::activate() if( pDispatcher ) { // filter all forbidden slots - pDispatcher->SetSlotFilter( SfxSlotFilterState::ENABLED, sizeof(pAllowed) / sizeof(sal_uInt16), pAllowed ); + pDispatcher->SetSlotFilter( SfxSlotFilterState::ENABLED, SAL_N_ELEMENTS(pAllowed), pAllowed ); } if( getBindings() ) diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index b290eb764122..e79e1177c52e 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -105,7 +105,7 @@ SfxFormalArgument const aFormalArgs[] = { { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "SaveACopy", SID_SAVEACOPYITEM }, }; -static sal_uInt16 nMediaArgsCount = sizeof(aFormalArgs) / sizeof (SfxFormalArgument); +static sal_uInt16 nMediaArgsCount = SAL_N_ELEMENTS(aFormalArgs); static char const sTemplateRegionName[] = "TemplateRegionName"; static char const sTemplateName[] = "TemplateName"; diff --git a/svl/source/misc/inettype.cxx b/svl/source/misc/inettype.cxx index 34d2ba238e86..b073e8b9b0ba 100644 --- a/svl/source/misc/inettype.cxx +++ b/svl/source/misc/inettype.cxx @@ -622,7 +622,7 @@ OUString INetContentTypes::GetPresentation(INetContentType eTypeID, INetContentType INetContentTypes::GetContentType4Extension(OUString const & rExtension) { MediaTypeEntry const * pEntry = seekEntry(rExtension, aStaticExtensionMap, - sizeof aStaticExtensionMap / sizeof (MediaTypeEntry)); + SAL_N_ELEMENTS(aStaticExtensionMap)); if (pEntry) return pEntry->m_eTypeID; INetContentType eTypeID = Registration::GetContentType4Extension(rExtension); diff --git a/svtools/source/config/helpopt.cxx b/svtools/source/config/helpopt.cxx index c25f51d5161c..381d67f7f0a4 100644 --- a/svtools/source/config/helpopt.cxx +++ b/svtools/source/config/helpopt.cxx @@ -58,7 +58,7 @@ class SvtHelpOptions_Impl : public utl::ConfigItem OUString aSystem; OUString sHelpStyleSheet; - static Sequence< OUString > GetPropertyNames(); + static Sequence< OUString > const & GetPropertyNames(); virtual void ImplCommit() final override; @@ -82,9 +82,9 @@ public: static ::osl::Mutex & getInitMutex(); }; -Sequence< OUString > SvtHelpOptions_Impl::GetPropertyNames() +Sequence< OUString > const & SvtHelpOptions_Impl::GetPropertyNames() { - static const char* aPropNames[] = + static Sequence<OUString> const aNames { "ExtendedTip", "Tip", @@ -93,12 +93,6 @@ Sequence< OUString > SvtHelpOptions_Impl::GetPropertyNames() "HelpStyleSheet" }; - const int nCount = sizeof( aPropNames ) / sizeof( const char* ); - Sequence< OUString > aNames( nCount ); - OUString* pNames = aNames.getArray(); - for ( int i = 0; i < nCount; i++ ) - pNames[i] = OUString::createFromAscii( aPropNames[i] ); - return aNames; } diff --git a/svtools/source/misc/sampletext.cxx b/svtools/source/misc/sampletext.cxx index cb131e28d85c..b3a96864e2fb 100644 --- a/svtools/source/misc/sampletext.cxx +++ b/svtools/source/misc/sampletext.cxx @@ -175,7 +175,7 @@ OUString makeShortRepresentativeSymbolTextForSelectedFont(OutputDevice &rDevice) // start just above the PUA used by most symbol fonts sal_uInt32 cNewChar = 0xFF00; - const int nMaxCount = sizeof(aText)/sizeof(*aText) - 1; + const int nMaxCount = SAL_N_ELEMENTS(aText) - 1; int nSkip = xFontCharMap->GetCharCount() / nMaxCount; if( nSkip > 10 ) nSkip = 10; diff --git a/svtools/source/svhtml/htmlkywd.cxx b/svtools/source/svhtml/htmlkywd.cxx index 339cb36c0737..b345a48e5cfc 100644 --- a/svtools/source/svhtml/htmlkywd.cxx +++ b/svtools/source/svhtml/htmlkywd.cxx @@ -192,7 +192,7 @@ HtmlTokenId GetHTMLToken( const OUString& rName ) if( !bSortKeyWords ) { qsort( static_cast<void*>(aHTMLTokenTab), - sizeof( aHTMLTokenTab ) / sizeof( HTML_TokenEntry ), + SAL_N_ELEMENTS( aHTMLTokenTab ), sizeof( HTML_TokenEntry ), HTMLKeyCompare ); bSortKeyWords = true; @@ -210,7 +210,7 @@ HtmlTokenId GetHTMLToken( const OUString& rName ) pFound = bsearch( &aSrch, static_cast<void*>(aHTMLTokenTab), - sizeof( aHTMLTokenTab ) / sizeof( HTML_TokenEntry ), + SAL_N_ELEMENTS( aHTMLTokenTab ), sizeof( HTML_TokenEntry ), HTMLKeyCompare ); if( nullptr != pFound ) @@ -529,7 +529,7 @@ sal_Unicode GetHTMLCharName( const OUString& rName ) if( !bSortCharKeyWords ) { qsort( static_cast<void*>(aHTMLCharNameTab), - sizeof( aHTMLCharNameTab ) / sizeof( HTML_CharEntry ), + SAL_N_ELEMENTS( aHTMLCharNameTab ), sizeof( HTML_CharEntry ), HTMLCharNameCompare ); bSortCharKeyWords = true; @@ -543,7 +543,7 @@ sal_Unicode GetHTMLCharName( const OUString& rName ) if( nullptr != ( pFound = bsearch( &aSrch, static_cast<void*>(aHTMLCharNameTab), - sizeof( aHTMLCharNameTab) / sizeof( HTML_CharEntry ), + SAL_N_ELEMENTS( aHTMLCharNameTab), sizeof( HTML_CharEntry ), HTMLCharNameCompare ))) cRet = static_cast<HTML_CharEntry*>(pFound)->cChar; @@ -722,7 +722,7 @@ HtmlOptionId GetHTMLOption( const OUString& rName ) if( !bSortOptionKeyWords ) { qsort( static_cast<void*>(aHTMLOptionTab), - sizeof( aHTMLOptionTab ) / sizeof( HTML_OptionEntry ), + SAL_N_ELEMENTS( aHTMLOptionTab ), sizeof( HTML_OptionEntry ), HTMLKeyCompare ); bSortOptionKeyWords = true; @@ -736,7 +736,7 @@ HtmlOptionId GetHTMLOption( const OUString& rName ) if( nullptr != ( pFound = bsearch( &aSrch, static_cast<void*>(aHTMLOptionTab), - sizeof( aHTMLOptionTab ) / sizeof( HTML_OptionEntry ), + SAL_N_ELEMENTS( aHTMLOptionTab ), sizeof( HTML_OptionEntry ), HTMLKeyCompare ))) nRet = static_cast<HTML_OptionEntry*>(pFound)->nToken; @@ -938,7 +938,7 @@ sal_uInt32 GetHTMLColor( const OUString& rName ) if( !bSortColorKeyWords ) { qsort( static_cast<void*>(aHTMLColorNameTab), - sizeof( aHTMLColorNameTab ) / sizeof( HTML_ColorEntry ), + SAL_N_ELEMENTS( aHTMLColorNameTab ), sizeof( HTML_ColorEntry ), HTMLColorNameCompare ); bSortColorKeyWords = true; @@ -954,7 +954,7 @@ sal_uInt32 GetHTMLColor( const OUString& rName ) if( nullptr != ( pFound = bsearch( &aSrch, static_cast<void*>(aHTMLColorNameTab), - sizeof( aHTMLColorNameTab) / sizeof( HTML_ColorEntry ), + SAL_N_ELEMENTS( aHTMLColorNameTab), sizeof( HTML_ColorEntry ), HTMLColorNameCompare ))) nRet = static_cast<HTML_ColorEntry*>(pFound)->nColor; diff --git a/svtools/source/svrtf/rtfkeywd.cxx b/svtools/source/svrtf/rtfkeywd.cxx index a0b2ffe48e49..8ce750686236 100644 --- a/svtools/source/svrtf/rtfkeywd.cxx +++ b/svtools/source/svrtf/rtfkeywd.cxx @@ -1209,7 +1209,7 @@ int GetRTFToken( const OUString& rSearch ) if( !bSortKeyWords ) { qsort( static_cast<void*>(aRTFTokenTab), - sizeof( aRTFTokenTab ) / sizeof( RTF_TokenEntry ), + SAL_N_ELEMENTS( aRTFTokenTab ), sizeof( RTF_TokenEntry ), RTFKeyCompare ); bSortKeyWords = true; @@ -1223,7 +1223,7 @@ int GetRTFToken( const OUString& rSearch ) if( nullptr != ( pFound = bsearch( &aSrch, static_cast<void*>(aRTFTokenTab), - sizeof( aRTFTokenTab ) / sizeof( RTF_TokenEntry ), + SAL_N_ELEMENTS( aRTFTokenTab ), sizeof( RTF_TokenEntry ), RTFKeyCompare ))) nRet = static_cast<RTF_TokenEntry*>(pFound)->nToken; diff --git a/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx b/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx index c2f8109af231..72cc92e3f479 100644 --- a/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx @@ -4657,15 +4657,15 @@ static const SvxMSDffHandle mso_sptEllipseRibbonHandle[] = static const mso_CustomShape msosptEllipseRibbon = { - const_cast<SvxMSDffVertPair*>(mso_sptEllipseRibbonVert), sizeof( mso_sptEllipseRibbonVert ) / sizeof( SvxMSDffVertPair ), + const_cast<SvxMSDffVertPair*>(mso_sptEllipseRibbonVert), SAL_N_ELEMENTS( mso_sptEllipseRibbonVert ), const_cast<sal_uInt16*>(mso_sptEllipseRibbonSegm), sizeof( mso_sptEllipseRibbonSegm ) >> 1, - const_cast<SvxMSDffCalculationData*>(mso_sptEllipseRibbonCalc), sizeof( mso_sptEllipseRibbonCalc ) / sizeof( SvxMSDffCalculationData ), + const_cast<SvxMSDffCalculationData*>(mso_sptEllipseRibbonCalc), SAL_N_ELEMENTS( mso_sptEllipseRibbonCalc ), const_cast<sal_Int32*>(mso_sptEllipseRibbonDefault), - const_cast<SvxMSDffTextRectangles*>(mso_sptEllipseRibbonTextRect), sizeof( mso_sptEllipseRibbonTextRect ) / sizeof( SvxMSDffTextRectangles ), + const_cast<SvxMSDffTextRectangles*>(mso_sptEllipseRibbonTextRect), SAL_N_ELEMENTS( mso_sptEllipseRibbonTextRect ), 21600, 21600, MIN_INT32, MIN_INT32, nullptr, 0, - const_cast<SvxMSDffHandle*>(mso_sptEllipseRibbonHandle), sizeof( mso_sptEllipseRibbonHandle ) / sizeof( SvxMSDffHandle ) + const_cast<SvxMSDffHandle*>(mso_sptEllipseRibbonHandle), SAL_N_ELEMENTS( mso_sptEllipseRibbonHandle ) }; //msosptEllipseRibbon2 @@ -4797,15 +4797,15 @@ static const SvxMSDffHandle mso_sptEllipseRibbon2Handle[] = static const mso_CustomShape msosptEllipseRibbon2 = { - const_cast<SvxMSDffVertPair*>(mso_sptEllipseRibbon2Vert), sizeof( mso_sptEllipseRibbon2Vert ) / sizeof( SvxMSDffVertPair ), + const_cast<SvxMSDffVertPair*>(mso_sptEllipseRibbon2Vert), SAL_N_ELEMENTS( mso_sptEllipseRibbon2Vert ), const_cast<sal_uInt16*>(mso_sptEllipseRibbon2Segm), sizeof( mso_sptEllipseRibbon2Segm ) >> 1, - const_cast<SvxMSDffCalculationData*>(mso_sptEllipseRibbon2Calc), sizeof( mso_sptEllipseRibbon2Calc ) / sizeof( SvxMSDffCalculationData ), + const_cast<SvxMSDffCalculationData*>(mso_sptEllipseRibbon2Calc), SAL_N_ELEMENTS( mso_sptEllipseRibbon2Calc ), const_cast<sal_Int32*>(mso_sptEllipseRibbon2Default), - const_cast<SvxMSDffTextRectangles*>(mso_sptEllipseRibbon2TextRect), sizeof( mso_sptEllipseRibbon2TextRect ) / sizeof( SvxMSDffTextRectangles ), + const_cast<SvxMSDffTextRectangles*>(mso_sptEllipseRibbon2TextRect), SAL_N_ELEMENTS( mso_sptEllipseRibbon2TextRect ), 21600, 21600, MIN_INT32, MIN_INT32, nullptr, 0, - const_cast<SvxMSDffHandle*>(mso_sptEllipseRibbon2Handle), sizeof( mso_sptEllipseRibbon2Handle ) / sizeof( SvxMSDffHandle ) + const_cast<SvxMSDffHandle*>(mso_sptEllipseRibbon2Handle), SAL_N_ELEMENTS( mso_sptEllipseRibbon2Handle ) }; // End static const SvxMSDffVertPair mso_sptVerticalScrollVert[] = // adjustment1 : 0 - 5400 @@ -6488,15 +6488,15 @@ static const SvxMSDffHandle mso_sptTextRingInsideHandle[] = }; static const mso_CustomShape msoTextRingInside = { - const_cast<SvxMSDffVertPair*>(mso_sptTextRingInsideVert), sizeof( mso_sptTextRingInsideVert ) / sizeof( SvxMSDffVertPair ), + const_cast<SvxMSDffVertPair*>(mso_sptTextRingInsideVert), SAL_N_ELEMENTS( mso_sptTextRingInsideVert ), const_cast<sal_uInt16*>(mso_sptTextRingInsideSegm), sizeof( mso_sptTextRingInsideSegm ) >> 1, - const_cast<SvxMSDffCalculationData*>(mso_sptTextRingInsideCalc), sizeof( mso_sptTextRingInsideCalc ) / sizeof( SvxMSDffCalculationData ), + const_cast<SvxMSDffCalculationData*>(mso_sptTextRingInsideCalc), SAL_N_ELEMENTS( mso_sptTextRingInsideCalc ), const_cast<sal_Int32*>(mso_sptDefault13500), - const_cast<SvxMSDffTextRectangles*>(mso_sptFontWorkTextRect), sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ), + const_cast<SvxMSDffTextRectangles*>(mso_sptFontWorkTextRect), SAL_N_ELEMENTS( mso_sptFontWorkTextRect ), 21600, 21600, MIN_INT32, MIN_INT32, nullptr, 0, - const_cast<SvxMSDffHandle*>(mso_sptTextRingInsideHandle), sizeof( mso_sptTextRingInsideHandle ) / sizeof( SvxMSDffHandle ) + const_cast<SvxMSDffHandle*>(mso_sptTextRingInsideHandle), SAL_N_ELEMENTS( mso_sptTextRingInsideHandle ) }; //mso_sptTextRingOutside //path = U 10800 ?f0 21600 ?f2 180 539 N U 10800 ?f1 21600 ?f2 180 539 N @@ -8334,15 +8334,15 @@ static const sal_Int32 mso_sptTearDropDefault[] = static const mso_CustomShape msoTearDrop = { - const_cast<SvxMSDffVertPair*>(mso_sptTearDropVert), sizeof( mso_sptTearDropVert ) / sizeof( SvxMSDffVertPair ), + const_cast<SvxMSDffVertPair*>(mso_sptTearDropVert), SAL_N_ELEMENTS( mso_sptTearDropVert ), const_cast<sal_uInt16*>(mso_sptTearDropSegm), sizeof( mso_sptTearDropSegm ) >> 1, - const_cast<SvxMSDffCalculationData*>(mso_sptTearDropCalc), sizeof(mso_sptTearDropCalc)/sizeof(SvxMSDffCalculationData), + const_cast<SvxMSDffCalculationData*>(mso_sptTearDropCalc), SAL_N_ELEMENTS(mso_sptTearDropCalc), const_cast<sal_Int32*>(mso_sptTearDropDefault), - const_cast<SvxMSDffTextRectangles*>(mso_sptTearDropTextRect), sizeof( mso_sptTearDropTextRect ) / sizeof( SvxMSDffTextRectangles ), + const_cast<SvxMSDffTextRectangles*>(mso_sptTearDropTextRect), SAL_N_ELEMENTS( mso_sptTearDropTextRect ), 21600, 21600, MIN_INT32, MIN_INT32, nullptr, 0, - const_cast<SvxMSDffHandle*>(mso_sptTearDropHandle), sizeof(mso_sptTearDropHandle)/sizeof(SvxMSDffHandle) // handles + const_cast<SvxMSDffHandle*>(mso_sptTearDropHandle), SAL_N_ELEMENTS(mso_sptTearDropHandle) // handles }; diff --git a/svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx b/svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx index 4ff01ba4ca22..4e48445c0c89 100644 --- a/svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx @@ -281,7 +281,7 @@ MSO_SPT EnhancedCustomShapeTypeNames::Get( const OUString& rShapeType ) { TypeNameHashMap* pH = new TypeNameHashMap; const NameTypeTable* pPtr = pNameTypeTableArray; - const NameTypeTable* pEnd = pPtr + ( sizeof( pNameTypeTableArray ) / sizeof( NameTypeTable ) ); + const NameTypeTable* pEnd = pPtr + SAL_N_ELEMENTS( pNameTypeTableArray ); for ( ; pPtr < pEnd; pPtr++ ) (*pH)[ pPtr->pS ] = pPtr->pE; pHashMap = pH; @@ -536,7 +536,7 @@ OUString EnhancedCustomShapeTypeNames::GetAccName( const OUString& rShapeType ) { TypeACCNameHashMap* pH = new TypeACCNameHashMap; const ACCNameTypeTable* pPtr = pACCNameTypeTableArray; - const ACCNameTypeTable* pEnd = pPtr + ( sizeof( pACCNameTypeTableArray ) / sizeof( ACCNameTypeTable ) ); + const ACCNameTypeTable* pEnd = pPtr + SAL_N_ELEMENTS( pACCNameTypeTableArray ); for ( ; pPtr < pEnd; pPtr++ ) (*pH)[ pPtr->pS ] = pPtr->pE; pACCHashMap = pH; diff --git a/svx/source/sidebar/nbdtmg.cxx b/svx/source/sidebar/nbdtmg.cxx index 7dac15f83f22..a23d69a54305 100644 --- a/svx/source/sidebar/nbdtmg.cxx +++ b/svx/source/sidebar/nbdtmg.cxx @@ -285,33 +285,6 @@ sal_uInt16 BulletsTypeMgr::GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLe SvxNumberFormat aFmt(aNum.GetLevel(nActLv)); sal_Unicode cChar = aFmt.GetBulletChar(); - //const vcl::Font* pFont = aFmt.GetBulletFont(); - //sal_uInt16 nLength = 0; - /*if( AllSettings::GetLayoutRTL() ) - { - nLength = sizeof(aDynamicRTLBulletTypes)/sizeof(sal_Unicode); - for(sal_uInt16 i = 0; i < nLength; i++) - { - if ( cChar == aDynamicRTLBulletTypes[i] || - (cChar == 9830 && 57356 == aDynamicRTLBulletTypes[i]) || - (cChar == 9632 && 57354 == aDynamicRTLBulletTypes[i]) ) - { - return i+1; - } - } - } else - { - nLength = sizeof(aDynamicBulletTypes)/sizeof(sal_Unicode); - for(sal_uInt16 i = 0; i < nLength; i++) - { - if ( cChar == aDynamicBulletTypes[i] || - (cChar == 9830 && 57356 == aDynamicBulletTypes[i]) || - (cChar == 9632 && 57354 == aDynamicBulletTypes[i]) ) - { - return i+1; - } - } - }*/ for(sal_uInt16 i = nFromIndex; i < DEFAULT_BULLET_TYPES; i++) { if ( (cChar == pActualBullets[i]->cBulletChar|| @@ -341,24 +314,6 @@ void BulletsTypeMgr::RelplaceNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uI SvxNumberFormat aFmt(aNum.GetLevel(nActLv)); sal_Unicode cChar = aFmt.GetBulletChar(); const vcl::Font* pFont = aFmt.GetBulletFont(); - //sal_uInt16 nLength = 0; - /*if( AllSettings::GetLayoutRTL() ) - { - nLength = sizeof(aDynamicRTLBulletTypes)/sizeof(sal_Unicode); - - if ( nIndex >= nLength ) - return sal_False; - - aDynamicRTLBulletTypes[nIndex] = cChar; - } else - { - nLength = sizeof(aDynamicBulletTypes)/sizeof(sal_Unicode); - - if ( nIndex >= nLength ) - return sal_False; - - aDynamicBulletTypes[nIndex] = cChar; - }*/ if ( nIndex >= DEFAULT_BULLET_TYPES ) return; @@ -675,7 +630,7 @@ void OutlineTypeMgr::Init() sal_uInt16 OutlineTypeMgr::GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 /*mLevel*/,sal_uInt16 nFromIndex) { - sal_uInt16 nLength = sizeof(pOutlineSettingsArrs)/sizeof(OutlineSettings_Impl*); + sal_uInt16 nLength = SAL_N_ELEMENTS(pOutlineSettingsArrs); for(sal_uInt16 iDex = nFromIndex; iDex < nLength; iDex++) { bool bNotMatch = false; @@ -749,7 +704,7 @@ sal_uInt16 OutlineTypeMgr::GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 /*m void OutlineTypeMgr::RelplaceNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel) { - sal_uInt16 nLength = sizeof(pOutlineSettingsArrs)/sizeof(OutlineSettings_Impl*); + sal_uInt16 nLength = SAL_N_ELEMENTS(pOutlineSettingsArrs); if ( nIndex >= nLength ) return; @@ -925,8 +880,7 @@ void OutlineTypeMgr::ApplyNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt1 OUString OutlineTypeMgr::GetDescription(sal_uInt16 nIndex, bool isDefault) { OUString sRet; - sal_uInt16 nLength = 0; - nLength = sizeof(pOutlineSettingsArrs)/sizeof(OutlineSettings_Impl*); + sal_uInt16 nLength = SAL_N_ELEMENTS(pOutlineSettingsArrs); if ( nIndex >= nLength ) return sRet; @@ -946,8 +900,7 @@ bool OutlineTypeMgr::IsCustomized(sal_uInt16 nIndex) { bool bRet = false; - sal_uInt16 nLength = 0; - nLength = sizeof(pOutlineSettingsArrs)/sizeof(OutlineSettings_Impl*); + sal_uInt16 nLength = SAL_N_ELEMENTS(pOutlineSettingsArrs); if ( nIndex >= nLength ) return bRet; diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx index c3cb7b9a23f3..0329d9018254 100644 --- a/svx/source/unodraw/unoprov.cxx +++ b/svx/source/unodraw/unoprov.cxx @@ -1276,7 +1276,7 @@ OUString SvxUnogetApiNameForItem(const sal_Int16 nWhich, const OUString& rIntern if( nWhich == XATTR_LINECOLOR ) { - if( SvxUnoConvertResourceString( SvxUnoColorNameResId, SvxUnoColorNameDefResId, sizeof( SvxUnoColorNameResId ) / sizeof( sal_uInt16 ), aNew ) ) + if( SvxUnoConvertResourceString( SvxUnoColorNameResId, SvxUnoColorNameDefResId, SAL_N_ELEMENTS( SvxUnoColorNameResId ), aNew ) ) { return aNew; } @@ -1309,7 +1309,7 @@ OUString SvxUnogetInternalNameForItem(const sal_Int16 nWhich, const OUString& rA if( nWhich == XATTR_LINECOLOR ) { - if( SvxUnoConvertResourceString( SvxUnoColorNameDefResId, SvxUnoColorNameResId, sizeof( SvxUnoColorNameResId ) / sizeof( sal_uInt16 ), aNew ) ) + if( SvxUnoConvertResourceString( SvxUnoColorNameDefResId, SvxUnoColorNameResId, SAL_N_ELEMENTS( SvxUnoColorNameResId ), aNew ) ) { return aNew; } |