[Libreoffice-commits] core.git: include/comphelper sw/qa sw/source toolkit/source tools/source ucb/source unotools/source vcl/source vcl/unx writerfilter/source xmloff/source

Noel Grandin noel.grandin at collabora.co.uk
Wed Jun 14 12:17:38 UTC 2017


 include/comphelper/sequence.hxx                   |   15 ++-
 sw/qa/extras/ww8export/ww8export.cxx              |    2 
 sw/source/core/bastyp/calc.cxx                    |    2 
 sw/source/core/doc/SwStyleNameMapper.cxx          |   24 ++---
 sw/source/filter/ww8/docxattributeoutput.cxx      |   36 +-------
 sw/source/filter/ww8/ww8par.cxx                   |   11 --
 sw/source/filter/ww8/ww8par5.cxx                  |    3 
 sw/source/uibase/config/dbconfig.cxx              |   26 +-----
 sw/source/uibase/config/fontcfg.cxx               |   78 +++++++-----------
 sw/source/uibase/dbui/mmconfigitem.cxx            |   95 +++++++++-------------
 sw/source/uibase/fldui/fldmgr.cxx                 |    2 
 sw/source/uibase/inc/fontcfg.hxx                  |    2 
 sw/source/uibase/uiview/view.cxx                  |    8 -
 toolkit/source/awt/vclxprinter.cxx                |    2 
 toolkit/source/awt/vclxtoolkit.cxx                |    4 
 toolkit/source/helper/property.cxx                |    2 
 tools/source/generic/color.cxx                    |    2 
 ucb/source/ucp/expand/ucpexpand.cxx               |    4 
 unotools/source/config/defaultoptions.cxx         |    2 
 unotools/source/config/pathoptions.cxx            |   13 +--
 unotools/source/config/saveopt.cxx                |    2 
 vcl/source/app/svapp.cxx                          |    2 
 vcl/source/font/fontcharmap.cxx                   |    4 
 vcl/source/fontsubset/cff.cxx                     |    2 
 vcl/source/outdev/font.cxx                        |    2 
 vcl/unx/gtk/a11y/atktextattributes.cxx            |   12 --
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |    2 
 writerfilter/source/dmapper/NumberingManager.cxx  |    2 
 xmloff/source/draw/EnhancedCustomShapeToken.cxx   |    8 -
 xmloff/source/style/weighhdl.cxx                  |    9 --
 30 files changed, 155 insertions(+), 223 deletions(-)

New commits:
commit b70fa47aec65fe95da94fc17640dda27650e9677
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Jun 14 09:35:16 2017 +0200

    use more SAL_N_ELEMENTS part 1
    
    - teach comphelper::containerToSequence to handle sized arrays
    - also use range based for-loop where appropriate.
    
    Change-Id: I73ba9b6295e7b29c872ee53de7a9340969e07f99
    Reviewed-on: https://gerrit.libreoffice.org/38769
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/comphelper/sequence.hxx b/include/comphelper/sequence.hxx
index 68c361c6282f..8fba7b8722b1 100644
--- a/include/comphelper/sequence.hxx
+++ b/include/comphelper/sequence.hxx
@@ -283,10 +283,10 @@ namespace comphelper
         truncated. There's currently no measure to prevent or detect
         precision loss, overflow or truncation.
      */
-    template < typename DstType, typename SrcType >
-    inline css::uno::Sequence< DstType > containerToSequence( const SrcType& i_Container )
+    template < typename DstElementType, typename SrcType >
+    inline css::uno::Sequence< DstElementType > containerToSequence( const SrcType& i_Container )
     {
-        css::uno::Sequence< DstType > result( i_Container.size() );
+        css::uno::Sequence< DstElementType > result( i_Container.size() );
         ::std::copy( i_Container.begin(), i_Container.end(), result.getArray() );
         return result;
     }
@@ -300,6 +300,15 @@ namespace comphelper
         return result;
     }
 
+    // handle arrays
+    template<typename SrcElementType, std::size_t SrcSize>
+    inline css::uno::Sequence< SrcElementType > containerToSequence( SrcElementType const (&i_Array)[ SrcSize ] )
+    {
+        css::uno::Sequence< SrcElementType > result( SrcSize );
+        ::std::copy( std::begin(i_Array), std::end(i_Array), result.getArray() );
+        return result;
+    }
+
     template <typename T>
     inline css::uno::Sequence<T> containerToSequence(
         ::std::vector<T> const& v )
diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx
index ebb49f6ae2d1..2af0b8fde045 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -1241,7 +1241,7 @@ DECLARE_WW8EXPORT_TEST(testCommentExport, "comment-export.odt")
 
     OUString sNames[6];
 
-    const int nNumberOfTextPortions = sizeof(aTextPortions) / (sizeof(TextPortionInfo));
+    const int nNumberOfTextPortions = SAL_N_ELEMENTS(aTextPortions);
 
     uno::Reference<text::XTextRange> xPara = getParagraph(1);
 
diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx
index b04106f0bee4..85add0f5807a 100644
--- a/sw/source/core/bastyp/calc.cxx
+++ b/sw/source/core/bastyp/calc.cxx
@@ -178,7 +178,7 @@ CalcOp* FindOperator( const OUString& rSrch )
 
     return static_cast<CalcOp*>(bsearch( static_cast<void*>(&aSrch),
                               static_cast<void const *>(aOpTable),
-                              sizeof( aOpTable ) / sizeof( CalcOp ),
+                              SAL_N_ELEMENTS( aOpTable ),
                               sizeof( CalcOp ),
                               OperatorCompare ));
 }
diff --git a/sw/source/core/doc/SwStyleNameMapper.cxx b/sw/source/core/doc/SwStyleNameMapper.cxx
index eab9bb0e781d..6d3ae176c6fc 100644
--- a/sw/source/core/doc/SwStyleNameMapper.cxx
+++ b/sw/source/core/doc/SwStyleNameMapper.cxx
@@ -877,7 +877,7 @@ const std::vector<OUString>& SwStyleNameMapper::GetTextProgNameArray()
 {
     if (!s_pTextProgNameArray)
         s_pTextProgNameArray = lcl_NewProgNameArray(TextProgNameTable,
-            sizeof ( TextProgNameTable ) / sizeof ( SwTableEntry ) );
+            SAL_N_ELEMENTS ( TextProgNameTable ) );
     return *s_pTextProgNameArray;
 }
 
@@ -885,7 +885,7 @@ const std::vector<OUString>& SwStyleNameMapper::GetListsProgNameArray()
 {
     if (!s_pListsProgNameArray)
         s_pListsProgNameArray = lcl_NewProgNameArray( ListsProgNameTable,
-            sizeof ( ListsProgNameTable ) / sizeof ( SwTableEntry ) );
+            SAL_N_ELEMENTS ( ListsProgNameTable ) );
     return *s_pListsProgNameArray;
 }
 
@@ -893,7 +893,7 @@ const std::vector<OUString>& SwStyleNameMapper::GetExtraProgNameArray()
 {
     if (!s_pExtraProgNameArray)
         s_pExtraProgNameArray = lcl_NewProgNameArray( ExtraProgNameTable,
-            sizeof ( ExtraProgNameTable ) / sizeof ( SwTableEntry ) );
+            SAL_N_ELEMENTS ( ExtraProgNameTable ) );
     return *s_pExtraProgNameArray;
 }
 
@@ -901,7 +901,7 @@ const std::vector<OUString>& SwStyleNameMapper::GetRegisterProgNameArray()
 {
     if (!s_pRegisterProgNameArray)
         s_pRegisterProgNameArray = lcl_NewProgNameArray( RegisterProgNameTable,
-            sizeof ( RegisterProgNameTable ) / sizeof ( SwTableEntry ) );
+            SAL_N_ELEMENTS ( RegisterProgNameTable ) );
     return *s_pRegisterProgNameArray;
 }
 
@@ -909,7 +909,7 @@ const std::vector<OUString>& SwStyleNameMapper::GetDocProgNameArray()
 {
     if (!s_pDocProgNameArray)
         s_pDocProgNameArray = lcl_NewProgNameArray( DocProgNameTable,
-            sizeof ( DocProgNameTable ) / sizeof ( SwTableEntry ) );
+            SAL_N_ELEMENTS ( DocProgNameTable ) );
     return *s_pDocProgNameArray;
 }
 
@@ -917,7 +917,7 @@ const std::vector<OUString>& SwStyleNameMapper::GetHTMLProgNameArray()
 {
     if (!s_pHTMLProgNameArray)
         s_pHTMLProgNameArray = lcl_NewProgNameArray( HTMLProgNameTable,
-            sizeof ( HTMLProgNameTable ) / sizeof ( SwTableEntry ) );
+            SAL_N_ELEMENTS ( HTMLProgNameTable ) );
     return *s_pHTMLProgNameArray;
 }
 
@@ -925,7 +925,7 @@ const std::vector<OUString>& SwStyleNameMapper::GetFrameFormatProgNameArray()
 {
     if (!s_pFrameFormatProgNameArray)
         s_pFrameFormatProgNameArray = lcl_NewProgNameArray( FrameFormatProgNameTable,
-            sizeof ( FrameFormatProgNameTable ) / sizeof ( SwTableEntry ) );
+            SAL_N_ELEMENTS ( FrameFormatProgNameTable ) );
     return *s_pFrameFormatProgNameArray;
 }
 
@@ -933,7 +933,7 @@ const std::vector<OUString>& SwStyleNameMapper::GetChrFormatProgNameArray()
 {
     if (!s_pChrFormatProgNameArray)
         s_pChrFormatProgNameArray = lcl_NewProgNameArray( ChrFormatProgNameTable,
-            sizeof ( ChrFormatProgNameTable ) / sizeof ( SwTableEntry ) );
+            SAL_N_ELEMENTS ( ChrFormatProgNameTable ) );
     return *s_pChrFormatProgNameArray;
 }
 
@@ -941,7 +941,7 @@ const std::vector<OUString>& SwStyleNameMapper::GetHTMLChrFormatProgNameArray()
 {
     if (!s_pHTMLChrFormatProgNameArray)
         s_pHTMLChrFormatProgNameArray = lcl_NewProgNameArray( HTMLChrFormatProgNameTable,
-            sizeof ( HTMLChrFormatProgNameTable ) / sizeof ( SwTableEntry ) );
+            SAL_N_ELEMENTS ( HTMLChrFormatProgNameTable ) );
     return *s_pHTMLChrFormatProgNameArray;
 }
 
@@ -949,7 +949,7 @@ const std::vector<OUString>& SwStyleNameMapper::GetPageDescProgNameArray()
 {
     if (!s_pPageDescProgNameArray)
         s_pPageDescProgNameArray = lcl_NewProgNameArray( PageDescProgNameTable,
-            sizeof ( PageDescProgNameTable ) / sizeof ( SwTableEntry ) );
+            SAL_N_ELEMENTS ( PageDescProgNameTable ) );
     return *s_pPageDescProgNameArray;
 }
 
@@ -957,7 +957,7 @@ const std::vector<OUString>& SwStyleNameMapper::GetNumRuleProgNameArray()
 {
     if (!s_pNumRuleProgNameArray)
         s_pNumRuleProgNameArray = lcl_NewProgNameArray( NumRuleProgNameTable,
-            sizeof ( NumRuleProgNameTable ) / sizeof ( SwTableEntry ) );
+            SAL_N_ELEMENTS ( NumRuleProgNameTable ) );
     return *s_pNumRuleProgNameArray;
 }
 
@@ -965,7 +965,7 @@ const std::vector<OUString>& SwStyleNameMapper::GetTableStyleProgNameArray()
 {
     if (!s_pTableStyleProgNameArray)
         s_pTableStyleProgNameArray = lcl_NewProgNameArray( TableStyleProgNameTable,
-            sizeof ( TableStyleProgNameTable ) / sizeof ( SwTableEntry ) );
+            SAL_N_ELEMENTS ( TableStyleProgNameTable ) );
     return *s_pTableStyleProgNameArray;
 }
 
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index f96a1e7465bc..46691f5fec8b 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -43,6 +43,7 @@
 #include <comphelper/random.hxx>
 #include <comphelper/string.hxx>
 #include <comphelper/flagguard.hxx>
+#include <comphelper/sequence.hxx>
 #include <oox/token/namespaces.hxx>
 #include <oox/token/tokens.hxx>
 #include <oox/export/utils.hxx>
@@ -882,12 +883,7 @@ void DocxAttributeOutput::InitCollectedParagraphProperties()
 
     // postpone the output so that we can later [in EndParagraphProperties()]
     // prepend the properties before the run
-    sal_Int32 len = sizeof ( aOrder ) / sizeof( sal_Int32 );
-    uno::Sequence< sal_Int32 > aSeqOrder( len );
-    for ( sal_Int32 i = 0; i < len; i++ )
-        aSeqOrder[i] = aOrder[i];
-
-    m_pSerializer->mark(Tag_InitCollectedParagraphProperties, aSeqOrder);
+    m_pSerializer->mark(Tag_InitCollectedParagraphProperties, comphelper::containerToSequence(aOrder));
 }
 
 void DocxAttributeOutput::WriteCollectedParagraphProperties()
@@ -1810,12 +1806,7 @@ void DocxAttributeOutput::InitCollectedRunProperties()
 
     // postpone the output so that we can later [in EndParagraphProperties()]
     // prepend the properties before the run
-    sal_Int32 len = sizeof ( aOrder ) / sizeof( sal_Int32 );
-    uno::Sequence< sal_Int32 > aSeqOrder( len );
-    for ( sal_Int32 i = 0; i < len; i++ )
-        aSeqOrder[i] = aOrder[i];
-
-    m_pSerializer->mark(Tag_InitCollectedRunProperties, aSeqOrder);
+    m_pSerializer->mark(Tag_InitCollectedRunProperties, comphelper::containerToSequence(aOrder));
 }
 
 namespace
@@ -1917,12 +1908,11 @@ const NameToId constNameToIdMapping[] =
 
 boost::optional<sal_Int32> lclGetElementIdForName(const OUString& rName)
 {
-    sal_Int32 aLength = sizeof (constNameToIdMapping) / sizeof(NameToId);
-    for (sal_Int32 i=0; i < aLength; ++i)
+    for (auto const & i : constNameToIdMapping)
     {
-        if (rName == constNameToIdMapping[i].maName)
+        if (rName == i.maName)
         {
-            return constNameToIdMapping[i].maId;
+            return i.maId;
         }
     }
     return boost::optional<sal_Int32>();
@@ -3272,12 +3262,7 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
 
     // postpone the output so that we can later []
     // prepend the properties before the run
-    sal_Int32 len = sizeof ( aOrder ) / sizeof( sal_Int32 );
-    uno::Sequence< sal_Int32 > aSeqOrder( len );
-    for ( sal_Int32 i = 0; i < len; i++ )
-        aSeqOrder[i] = aOrder[i];
-
-    m_pSerializer->mark(Tag_TableDefinition, aSeqOrder);
+    m_pSerializer->mark(Tag_TableDefinition, comphelper::containerToSequence(aOrder));
 
     long nPageSize = 0;
     const char* widthType = "dxa";
@@ -5611,12 +5596,7 @@ void DocxAttributeOutput::StartSection()
 
     // postpone the output so that we can later [in EndParagraphProperties()]
     // prepend the properties before the run
-    sal_Int32 len = sizeof ( aOrder ) / sizeof( sal_Int32 );
-    uno::Sequence< sal_Int32 > aSeqOrder( len );
-    for ( sal_Int32 i = 0; i < len; i++ )
-        aSeqOrder[i] = aOrder[i];
-
-    m_pSerializer->mark(Tag_StartSection, aSeqOrder);
+    m_pSerializer->mark(Tag_StartSection, comphelper::containerToSequence(aOrder));
     m_bHadSectPr = true;
 }
 
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 530a199cee5b..f80ce894dad6 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -147,17 +147,6 @@ using namespace nsHdFtFlags;
 #include <comphelper/storagehelper.hxx>
 #include <sfx2/DocumentMetadataAccess.hxx>
 
-//#define VT_EMPTY            0
-//#define VT_I4               3
-//#define VT_LPSTR            30
-//#define VT_LPWSTR           31
-//#define VT_BLOB             65
-//#define VT_TYPEMASK         0xFFF
-/** Expands to a pointer after the last element of a STATIC data array (like STL end()). */
-//#define STATIC_TABLE_END( array )   ((array)+STATIC_TABLE_SIZE(array))
-/** Expands to the size of a STATIC data array. */
-//#define STATIC_TABLE_SIZE( array )  (sizeof(array)/sizeof(*(array)))
-
 SwMacroInfo* GetMacroInfo( SdrObject* pObj, bool bCreate )             // static
 {
     if ( pObj )
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 3a8fe2915114..669b0522b685 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -837,8 +837,7 @@ long SwWW8ImplReader::Read_Field(WW8PLCFManResult* pRes)
         &SwWW8ImplReader::Read_F_Shape,             // 95
         nullptr                                           // eMax - Dummy empty method
     };
-    OSL_ENSURE( ( sizeof( aWW8FieldTab ) / sizeof( *aWW8FieldTab ) == eMax+1 ),
-            "FeldFunc-Tabelle stimmt nicht" );
+    OSL_ENSURE( SAL_N_ELEMENTS( aWW8FieldTab ) == eMax+1, "FeldFunc-Tabelle stimmt nicht" );
 
     WW8PLCFx_FLD* pF = m_pPlcxMan->GetField();
     OSL_ENSURE(pF, "WW8PLCFx_FLD - Pointer nicht da");
diff --git a/sw/source/uibase/config/dbconfig.cxx b/sw/source/uibase/config/dbconfig.cxx
index ea9e7d56e901..91b24488bf36 100644
--- a/sw/source/uibase/config/dbconfig.cxx
+++ b/sw/source/uibase/config/dbconfig.cxx
@@ -29,24 +29,14 @@ using namespace com::sun::star::uno;
 
 const Sequence<OUString>& SwDBConfig::GetPropertyNames()
 {
-    static Sequence<OUString> aNames;
-    if(!aNames.getLength())
-    {
-        static const char* aPropNames[] =
-        {
-            "AddressBook/DataSourceName",        //  0
-            "AddressBook/Command",              //  1
-            "AddressBook/CommandType",          //  2
-            "Bibliography/CurrentDataSource/DataSourceName",        //  4
-            "Bibliography/CurrentDataSource/Command",              //  5
-            "Bibliography/CurrentDataSource/CommandType"          //  6
-        };
-        const int nCount = sizeof(aPropNames)/sizeof(const char*);
-        aNames.realloc(nCount);
-        OUString* pNames = aNames.getArray();
-        for(int i = 0; i < nCount; i++)
-            pNames[i] = OUString::createFromAscii(aPropNames[i]);
-    }
+    static Sequence<OUString> aNames {
+        "AddressBook/DataSourceName",        //  0
+        "AddressBook/Command",               //  1
+        "AddressBook/CommandType",           //  2
+        "Bibliography/CurrentDataSource/DataSourceName",    //  4
+        "Bibliography/CurrentDataSource/Command",           //  5
+        "Bibliography/CurrentDataSource/CommandType"        //  6
+    };
     return aNames;
 }
 
diff --git a/sw/source/uibase/config/fontcfg.cxx b/sw/source/uibase/config/fontcfg.cxx
index 31a02531bf3c..807762a80db1 100644
--- a/sw/source/uibase/config/fontcfg.cxx
+++ b/sw/source/uibase/config/fontcfg.cxx
@@ -38,52 +38,40 @@ static inline LanguageType lcl_LanguageOfType(sal_Int16 nType, LanguageType eWes
            : nType >= FONT_STANDARD_CTL ? eCTL : eCJK;
 }
 
-Sequence<OUString> SwStdFontConfig::GetPropertyNames()
+Sequence<OUString> const & SwStdFontConfig::GetPropertyNames()
 {
-    Sequence<OUString> aNames;
-    if(!aNames.getLength())
-    {
-        static const char* aPropNames[] =
-        {
-            "DefaultFont/Standard",    // 0
-            "DefaultFont/Heading",     // 1
-            "DefaultFont/List",        // 2
-            "DefaultFont/Caption",     // 3
-            "DefaultFont/Index",       // 4
-            "DefaultFontCJK/Standard", // 5
-            "DefaultFontCJK/Heading",  // 6
-            "DefaultFontCJK/List",     // 7
-            "DefaultFontCJK/Caption",  // 8
-            "DefaultFontCJK/Index",    // 9
-            "DefaultFontCTL/Standard", // 10
-            "DefaultFontCTL/Heading",  // 11
-            "DefaultFontCTL/List",     // 12
-            "DefaultFontCTL/Caption",  // 13
-            "DefaultFontCTL/Index",    // 14
-            "DefaultFont/StandardHeight",    // 15
-            "DefaultFont/HeadingHeight",     // 16
-            "DefaultFont/ListHeight",        // 17
-            "DefaultFont/CaptionHeight",     // 18
-            "DefaultFont/IndexHeight",       // 19
-            "DefaultFontCJK/StandardHeight", // 20
-            "DefaultFontCJK/HeadingHeight",  // 21
-            "DefaultFontCJK/ListHeight",     // 22
-            "DefaultFontCJK/CaptionHeight",  // 23
-            "DefaultFontCJK/IndexHeight",    // 24
-            "DefaultFontCTL/StandardHeight", // 25
-            "DefaultFontCTL/HeadingHeight",  // 26
-            "DefaultFontCTL/ListHeight",     // 27
-            "DefaultFontCTL/CaptionHeight",  // 28
-            "DefaultFontCTL/IndexHeight"     // 29
-        };
-        const int nCount = sizeof(aPropNames)/sizeof(const char*);
-        aNames.realloc(nCount);
-        OUString* pNames = aNames.getArray();
-        for(int i = 0; i < nCount; i++)
-        {
-            pNames[i] = OUString::createFromAscii(aPropNames[i]);
-        }
-    }
+    static Sequence<OUString> aNames {
+        "DefaultFont/Standard",    // 0
+        "DefaultFont/Heading",     // 1
+        "DefaultFont/List",        // 2
+        "DefaultFont/Caption",     // 3
+        "DefaultFont/Index",       // 4
+        "DefaultFontCJK/Standard", // 5
+        "DefaultFontCJK/Heading",  // 6
+        "DefaultFontCJK/List",     // 7
+        "DefaultFontCJK/Caption",  // 8
+        "DefaultFontCJK/Index",    // 9
+        "DefaultFontCTL/Standard", // 10
+        "DefaultFontCTL/Heading",  // 11
+        "DefaultFontCTL/List",     // 12
+        "DefaultFontCTL/Caption",  // 13
+        "DefaultFontCTL/Index",    // 14
+        "DefaultFont/StandardHeight",    // 15
+        "DefaultFont/HeadingHeight",     // 16
+        "DefaultFont/ListHeight",        // 17
+        "DefaultFont/CaptionHeight",     // 18
+        "DefaultFont/IndexHeight",       // 19
+        "DefaultFontCJK/StandardHeight", // 20
+        "DefaultFontCJK/HeadingHeight",  // 21
+        "DefaultFontCJK/ListHeight",     // 22
+        "DefaultFontCJK/CaptionHeight",  // 23
+        "DefaultFontCJK/IndexHeight",    // 24
+        "DefaultFontCTL/StandardHeight", // 25
+        "DefaultFontCTL/HeadingHeight",  // 26
+        "DefaultFontCTL/ListHeight",     // 27
+        "DefaultFontCTL/CaptionHeight",  // 28
+        "DefaultFontCTL/IndexHeight"     // 29
+    };
     return aNames;
 }
 
diff --git a/sw/source/uibase/dbui/mmconfigitem.cxx b/sw/source/uibase/dbui/mmconfigitem.cxx
index cabe4be6bbb0..86e9567f756e 100644
--- a/sw/source/uibase/dbui/mmconfigitem.cxx
+++ b/sw/source/uibase/dbui/mmconfigitem.cxx
@@ -426,59 +426,48 @@ static void lcl_ConvertFromNumbers(OUString& rBlock, const ResStringArray& rHead
 
 const Sequence<OUString>& SwMailMergeConfigItem_Impl::GetPropertyNames()
 {
-    static Sequence<OUString> aNames;
-    if(!aNames.getLength())
-    {
-        static const char* aPropNames[] =
-        {
-            "OutputToLetter",           // 0
-            "IncludeCountry",           // 1
-            "ExcludeCountry",           // 2
-            "AddressBlockSettings",     // 3
-            "IsAddressBlock",          // 4
-            "IsGreetingLine",           // 5
-            "IsIndividualGreetingLine", // 6
-            "FemaleGreetingLines",      // 7
-            "MaleGreetingLines",        // 8
-            "NeutralGreetingLines",     // 9
-            "CurrentFemaleGreeting",    // 10
-            "CurrentMaleGreeting",      // 11
-            "CurrentNeutralGreeting",   // 12
-            "FemaleGenderValue",        // 13
-            "MailDisplayName",          // 14
-            "MailAddress",              // 15
-            "IsMailReplyTo",            // 16
-            "MailReplyTo",              // 17
-            "MailServer",               // 18
-            "MailPort",                 // 19
-            "IsSecureConnection",       // 20
-            "IsAuthentication",         // 21
-            "MailUserName",             // 22
-            "MailPassword",             // 23
-            "DataSource/DataSourceName",// 24
-            "DataSource/DataTableName", // 25
-            "DataSource/DataCommandType",// 26
-            "Filter",                   // 27
-            "SavedDocuments",           // 28
-            "EMailSupported",            // 29
-            "IsEMailGreetingLine",              //30
-            "IsEMailIndividualGreetingLine",     //31
-            "IsSMPTAfterPOP",                    //32
-            "InServerName",                      //33
-            "InServerPort",                      //34
-            "InServerIsPOP",                     //35
-            "InServerUserName",                  //36
-            "InServerPassword",                   //37
-            "IsHideEmptyParagraphs",             //38
-            "CurrentAddressBlock"               //39
-
-        };
-        const int nCount = sizeof(aPropNames)/sizeof(const char*);
-        aNames.realloc(nCount);
-        OUString* pNames = aNames.getArray();
-        for(int i = 0; i < nCount; i++)
-            pNames[i] = OUString::createFromAscii(aPropNames[i]);
-    }
+    static Sequence<OUString> aNames {
+        "OutputToLetter",            // 0
+        "IncludeCountry",            // 1
+        "ExcludeCountry",            // 2
+        "AddressBlockSettings",      // 3
+        "IsAddressBlock",            // 4
+        "IsGreetingLine",            // 5
+        "IsIndividualGreetingLine",  // 6
+        "FemaleGreetingLines",       // 7
+        "MaleGreetingLines",         // 8
+        "NeutralGreetingLines",      // 9
+        "CurrentFemaleGreeting",     // 10
+        "CurrentMaleGreeting",       // 11
+        "CurrentNeutralGreeting",    // 12
+        "FemaleGenderValue",         // 13
+        "MailDisplayName",           // 14
+        "MailAddress",               // 15
+        "IsMailReplyTo",             // 16
+        "MailReplyTo",               // 17
+        "MailServer",                // 18
+        "MailPort",                  // 19
+        "IsSecureConnection",        // 20
+        "IsAuthentication",          // 21
+        "MailUserName",              // 22
+        "MailPassword",              // 23
+        "DataSource/DataSourceName", // 24
+        "DataSource/DataTableName",  // 25
+        "DataSource/DataCommandType",// 26
+        "Filter",                    // 27
+        "SavedDocuments",            // 28
+        "EMailSupported",            // 29
+        "IsEMailGreetingLine",               //30
+        "IsEMailIndividualGreetingLine",     //31
+        "IsSMPTAfterPOP",                    //32
+        "InServerName",                      //33
+        "InServerPort",                      //34
+        "InServerIsPOP",                     //35
+        "InServerUserName",                  //36
+        "InServerPassword",                  //37
+        "IsHideEmptyParagraphs",             //38
+        "CurrentAddressBlock"                //39
+    };
     return aNames;
 }
 
diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx
index 49ed1f7a7395..2d275b3e5f29 100644
--- a/sw/source/uibase/fldui/fldmgr.cxx
+++ b/sw/source/uibase/fldui/fldmgr.cxx
@@ -212,7 +212,7 @@ static SwWrtShell* lcl_GetShell()
     return nullptr;
 }
 
-inline sal_uInt16 GetPackCount() {  return sizeof(aSwFields) / sizeof(SwFieldPack); }
+inline sal_uInt16 GetPackCount() {  return SAL_N_ELEMENTS(aSwFields); }
 
 // FieldManager controls inserting and updating of fields
 SwFieldMgr::SwFieldMgr(SwWrtShell* pSh ) :
diff --git a/sw/source/uibase/inc/fontcfg.hxx b/sw/source/uibase/inc/fontcfg.hxx
index 72e113baab33..111846b6066c 100644
--- a/sw/source/uibase/inc/fontcfg.hxx
+++ b/sw/source/uibase/inc/fontcfg.hxx
@@ -58,7 +58,7 @@ class SW_DLLPUBLIC SwStdFontConfig : public utl::ConfigItem
     OUString    sDefaultFonts[DEF_FONT_COUNT];
     sal_Int32   nDefaultFontHeight[DEF_FONT_COUNT];
 
-    SAL_DLLPRIVATE static css::uno::Sequence<OUString> GetPropertyNames();
+    SAL_DLLPRIVATE static css::uno::Sequence<OUString> const & GetPropertyNames();
 
     void ChangeString(sal_uInt16 nFontType, const OUString& rSet)
         {
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 3f4758540ab6..08f69fe9c533 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -583,12 +583,12 @@ void SwView::CheckReadonlyState()
         static bool bFirst = true;
         if ( bFirst )
         {
-            qsort( static_cast<void*>(aROIds), sizeof(aROIds)/sizeof(sal_uInt16), sizeof(sal_uInt16), lcl_CmpIds );
+            qsort( static_cast<void*>(aROIds), SAL_N_ELEMENTS(aROIds), sizeof(sal_uInt16), lcl_CmpIds );
             bFirst = false;
         }
         if ( SfxItemState::DISABLED == eStateRO )
         {
-            rDis.SetSlotFilter( SfxSlotFilterState::ENABLED_READONLY, sizeof(aROIds)/sizeof(sal_uInt16), aROIds );
+            rDis.SetSlotFilter( SfxSlotFilterState::ENABLED_READONLY, SAL_N_ELEMENTS(aROIds), aROIds );
             bChgd = true;
         }
     }
@@ -600,11 +600,11 @@ void SwView::CheckReadonlyState()
             static bool bAllProtFirst = true;
             if ( bAllProtFirst )
             {
-                qsort( static_cast<void*>(aAllProtIds), sizeof(aAllProtIds)/sizeof(sal_uInt16), sizeof(sal_uInt16), lcl_CmpIds );
+                qsort( static_cast<void*>(aAllProtIds), SAL_N_ELEMENTS(aAllProtIds), sizeof(sal_uInt16), lcl_CmpIds );
                 bAllProtFirst = false;
             }
             rDis.SetSlotFilter( SfxSlotFilterState::ENABLED_READONLY,
-                                sizeof(aAllProtIds)/sizeof(sal_uInt16),
+                                SAL_N_ELEMENTS(aAllProtIds),
                                 aAllProtIds );
             bChgd = true;
         }
diff --git a/toolkit/source/awt/vclxprinter.cxx b/toolkit/source/awt/vclxprinter.cxx
index fe4a8f089fe1..b2f3ac103bba 100644
--- a/toolkit/source/awt/vclxprinter.cxx
+++ b/toolkit/source/awt/vclxprinter.cxx
@@ -55,7 +55,7 @@ css::beans::Property* ImplGetProperties( sal_uInt16& rElementCount )
                 css::beans::Property( "Horizontal", PROPERTY_Horizontal, cppu::UnoType<bool>::get(), 0 )
             };
             pProperties = aPropTable;
-            nElements = sizeof( aPropTable ) / sizeof( css::beans::Property );
+            nElements = SAL_N_ELEMENTS( aPropTable );
         }
     }
     rElementCount = nElements;
diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx
index 5c781f5ef6ab..380abb76af30 100644
--- a/toolkit/source/awt/vclxtoolkit.cxx
+++ b/toolkit/source/awt/vclxtoolkit.cxx
@@ -511,7 +511,7 @@ WindowType ImplGetComponentType( const OUString& rServiceName )
     if( !bSorted )
     {
         qsort(  static_cast<void*>(aComponentInfos),
-                sizeof( aComponentInfos ) / sizeof( ComponentInfo ),
+                SAL_N_ELEMENTS( aComponentInfos ),
                 sizeof( ComponentInfo ),
                 ComponentInfoCompare );
         bSorted = true;
@@ -527,7 +527,7 @@ WindowType ImplGetComponentType( const OUString& rServiceName )
 
     ComponentInfo* pInf = static_cast<ComponentInfo*>(bsearch( &aSearch,
                         static_cast<void*>(aComponentInfos),
-                        sizeof( aComponentInfos ) / sizeof( ComponentInfo ),
+                        SAL_N_ELEMENTS( aComponentInfos ),
                         sizeof( ComponentInfo ),
                         ComponentInfoCompare ));
 
diff --git a/toolkit/source/helper/property.cxx b/toolkit/source/helper/property.cxx
index 7b98d1d80611..3ace75837bcb 100644
--- a/toolkit/source/helper/property.cxx
+++ b/toolkit/source/helper/property.cxx
@@ -285,7 +285,7 @@ ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount )
             DECL_PROP_3     ( "InactiveSelectionTextColor",         INACTIVE_SEL_TEXT_COLOR,        sal_Int32,  BOUND, MAYBEDEFAULT, MAYBEVOID ),
     };
             pPropertyInfos = aImplPropertyInfos;
-            nElements = sizeof( aImplPropertyInfos ) / sizeof( ImplPropertyInfo );
+            nElements = SAL_N_ELEMENTS( aImplPropertyInfos );
         }
     }
     rElementCount = nElements;
diff --git a/tools/source/generic/color.cxx b/tools/source/generic/color.cxx
index c635ce27f16f..c1055885ab76 100644
--- a/tools/source/generic/color.cxx
+++ b/tools/source/generic/color.cxx
@@ -259,7 +259,7 @@ SvStream& ReadColor( SvStream& rIStream, Color& rColor )
             COL_BLACK                           // COL_FIELDTEXT
         };
 
-        if ( nColorName < (sizeof( aColAry )/sizeof(ColorData)) )
+        if ( nColorName < SAL_N_ELEMENTS( aColAry ) )
             rColor.mnColor = aColAry[nColorName];
         else
             rColor.mnColor = COL_BLACK;
diff --git a/ucb/source/ucp/expand/ucpexpand.cxx b/ucb/source/ucp/expand/ucpexpand.cxx
index 9951fb28ff77..0cc5f145ee5a 100644
--- a/ucb/source/ucp/expand/ucpexpand.cxx
+++ b/ucb/source/ucp/expand/ucpexpand.cxx
@@ -35,7 +35,6 @@
 #include "com/sun/star/ucb/XContentProvider.hpp"
 
 #define EXPAND_PROTOCOL "vnd.sun.star.expand"
-#define ARLEN(x) sizeof (x) / sizeof *(x)
 
 
 using namespace ::com::sun::star;
@@ -120,11 +119,10 @@ OUString SAL_CALL implName()
 
 uno::Sequence< OUString > SAL_CALL supportedServices()
 {
-    OUString names [] = {
+    return uno::Sequence< OUString > {
         OUString("com.sun.star.ucb.ExpandContentProvider"),
         OUString("com.sun.star.ucb.ContentProvider")
     };
-    return uno::Sequence< OUString >( names, ARLEN(names) );
 }
 
 // XServiceInfo
diff --git a/unotools/source/config/defaultoptions.cxx b/unotools/source/config/defaultoptions.cxx
index 47f1ce54e291..c338a741e24c 100644
--- a/unotools/source/config/defaultoptions.cxx
+++ b/unotools/source/config/defaultoptions.cxx
@@ -174,7 +174,7 @@ Sequence< OUString > GetDefaultPropertyNames()
         "Classification"    // PATH_CLASSIFICATION
     };
 
-    const int nCount = sizeof( aPropNames ) / sizeof( const char* );
+    const int nCount = SAL_N_ELEMENTS( aPropNames );
     Sequence< OUString > aNames( nCount );
     OUString* pNames = aNames.getArray();
     for ( int i = 0; i < nCount; i++ )
diff --git a/unotools/source/config/pathoptions.cxx b/unotools/source/config/pathoptions.cxx
index 7b42f63b98fe..d6675cd31333 100644
--- a/unotools/source/config/pathoptions.cxx
+++ b/unotools/source/config/pathoptions.cxx
@@ -416,26 +416,23 @@ SvtPathOptions_Impl::SvtPathOptions_Impl() :
     }
 
     // Create mapping between internal enum (SvtPathOptions::Paths) and property handle
-    sal_Int32 nCount = sizeof( aPropNames ) / sizeof( PropertyStruct );
-    sal_Int32 i;
-    for ( i = 0; i < nCount; i++ )
+    for ( auto const & p : aPropNames )
     {
         NameToHandleMap::const_iterator pIter =
-            aTempHashMap.find( OUString::createFromAscii( aPropNames[i].pPropName ));
+            aTempHashMap.find( OUString::createFromAscii( p.pPropName ));
 
         if ( pIter != aTempHashMap.end() )
         {
             sal_Int32 nHandle   = pIter->second;
-            sal_Int32 nEnum     = aPropNames[i].ePath;
+            sal_Int32 nEnum     = p.ePath;
             m_aMapEnumToPropHandle.insert( EnumToHandleMap::value_type( nEnum, nHandle ));
         }
     }
 
     // Create hash map for path variables that need a system path as a return value!
-    nCount = sizeof( aVarNameAttribute ) / sizeof( VarNameAttribute );
-    for ( i = 0; i < nCount; i++ )
+    for ( auto const & i : aVarNameAttribute )
     {
-        m_aSystemPathVarNames.insert( OUString::createFromAscii( aVarNameAttribute[i].pVarName ) );
+        m_aSystemPathVarNames.insert( OUString::createFromAscii( i.pVarName ) );
     }
 }
 
diff --git a/unotools/source/config/saveopt.cxx b/unotools/source/config/saveopt.cxx
index 1dff44cee452..7fa55766aa5b 100644
--- a/unotools/source/config/saveopt.cxx
+++ b/unotools/source/config/saveopt.cxx
@@ -375,7 +375,7 @@ Sequence< OUString > GetPropertyNames()
         "ODF/UseBlowfishInODF12"
     };
 
-    const int nCount = sizeof( aPropNames ) / sizeof( const char* );
+    const int nCount = SAL_N_ELEMENTS( aPropNames );
     Sequence< OUString > aNames( nCount );
     OUString* pNames = aNames.getArray();
     for ( int i = 0; i < nCount; i++ )
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 00255a1a63bb..585428809bc6 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -135,7 +135,7 @@ namespace
             static ReservedKeys aKeys
             (
                 &ImplReservedKeys[0],
-                sizeof(ImplReservedKeys) / sizeof(ImplReservedKey)
+                SAL_N_ELEMENTS(ImplReservedKeys)
             );
             return &aKeys;
         }
diff --git a/vcl/source/font/fontcharmap.cxx b/vcl/source/font/fontcharmap.cxx
index f30c4e670242..b1a6fef9d4ff 100644
--- a/vcl/source/font/fontcharmap.cxx
+++ b/vcl/source/font/fontcharmap.cxx
@@ -64,11 +64,11 @@ ImplFontCharMap::ImplFontCharMap( const CmapResult& rCR )
 ImplFontCharMapRef const & ImplFontCharMap::getDefaultMap( bool bSymbols )
 {
     const sal_UCS4* pRangeCodes = aDefaultUnicodeRanges;
-    int nCodesCount = sizeof(aDefaultUnicodeRanges) / sizeof(*pRangeCodes);
+    int nCodesCount = SAL_N_ELEMENTS(aDefaultUnicodeRanges);
     if( bSymbols )
     {
         pRangeCodes = aDefaultSymbolRanges;
-        nCodesCount = sizeof(aDefaultSymbolRanges) / sizeof(*pRangeCodes);
+        nCodesCount = SAL_N_ELEMENTS(aDefaultSymbolRanges);
     }
 
     CmapResult aDefaultCR( bSymbols, pRangeCodes, nCodesCount/2 );
diff --git a/vcl/source/fontsubset/cff.cxx b/vcl/source/fontsubset/cff.cxx
index f7d3cdd3d8ca..f01bf6446305 100644
--- a/vcl/source/fontsubset/cff.cxx
+++ b/vcl/source/fontsubset/cff.cxx
@@ -1501,7 +1501,7 @@ bool CffSubsetterContext::initialCffRead()
 const char* CffSubsetterContext::getString( int nStringID)
 {
     // get a standard string if possible
-    const static int nStdStrings = sizeof(pStringIds)/sizeof(*pStringIds);
+    const static int nStdStrings = SAL_N_ELEMENTS(pStringIds);
     if( (nStringID >= 0) && (nStringID < nStdStrings))
         return pStringIds[ nStringID];
 
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index f588853feb3c..f8438335062b 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -420,7 +420,7 @@ void OutputDevice::ImplGetEmphasisMark( tools::PolyPolygon& rPolyPoly, bool& rPo
             }
             else
             {
-                tools::Polygon aPoly( sizeof( aAccentPos ) / sizeof( long ) / 2,
+                tools::Polygon aPoly( SAL_N_ELEMENTS( aAccentPos ) / 2,
                                       reinterpret_cast<const Point*>(aAccentPos),
                                       aAccentPolyFlags );
                 double dScale = ((double)nDotSize)/1000.0;
diff --git a/vcl/unx/gtk/a11y/atktextattributes.cxx b/vcl/unx/gtk/a11y/atktextattributes.cxx
index 5a1819b2319f..840106a6d5db 100644
--- a/vcl/unx/gtk/a11y/atktextattributes.cxx
+++ b/vcl/unx/gtk/a11y/atktextattributes.cxx
@@ -448,14 +448,12 @@ const gchar * const font_strikethrough[] = {
     "with X"  // FontStrikeout::X
 };
 
-const sal_Int16 n_strikeout_constants = sizeof(font_strikethrough) / sizeof(gchar*);
-
 static gchar*
 Strikeout2String(const uno::Any& rAny)
 {
     sal_Int16 n = rAny.get<sal_Int16>();
 
-    if( n >= 0 && n < n_strikeout_constants )
+    if( n >= 0 && n < sal_Int16(SAL_N_ELEMENTS(font_strikethrough)) )
         return g_strdup( font_strikethrough[n] );
 
     return nullptr;
@@ -464,7 +462,7 @@ Strikeout2String(const uno::Any& rAny)
 static bool
 String2Strikeout( uno::Any& rAny, const gchar * value )
 {
-    for( sal_Int16 n=0; n < n_strikeout_constants; ++n )
+    for( sal_Int16 n=0; n < sal_Int16(SAL_N_ELEMENTS(font_strikethrough)); ++n )
     {
         if( ( nullptr != font_strikethrough[n] ) &&
             0 == strncmp( value, font_strikethrough[n], strlen( font_strikethrough[n] ) ) )
@@ -1340,8 +1338,6 @@ const AtkTextAttrMapping g_TextAttrMap[] =
     { "CharPosture", Style2FontSlant }          // ATK_TEXT_ATTR_STYLE
 };
 
-static const sal_Int32 g_TextAttrMapSize = sizeof( g_TextAttrMap ) / sizeof( AtkTextAttrMapping );
-
 /*****************************************************************************/
 
 bool
@@ -1350,7 +1346,7 @@ attribute_set_map_to_property_values(
     uno::Sequence< beans::PropertyValue >& rValueList )
 {
     // Ensure enough space ..
-    uno::Sequence< beans::PropertyValue > aAttributeList (g_TextAttrMapSize);
+    uno::Sequence< beans::PropertyValue > aAttributeList (SAL_N_ELEMENTS(g_TextAttrMap));
 
     sal_Int32 nIndex = 0;
     for( GSList * item = attribute_set; item != nullptr; item = g_slist_next( item ) )
@@ -1358,7 +1354,7 @@ attribute_set_map_to_property_values(
         AtkAttribute* attribute = reinterpret_cast<AtkAttribute *>(item);
 
         AtkTextAttribute text_attr = atk_text_attribute_for_name( attribute->name );
-        if( text_attr < g_TextAttrMapSize )
+        if( text_attr < SAL_N_ELEMENTS(g_TextAttrMap) )
         {
             if( g_TextAttrMap[text_attr].name[0] != '\0' )
             {
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index c98432a0b05e..4c29c1f7cc34 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -786,7 +786,7 @@ void lcl_MoveBorderPropertiesToFrame(std::vector<beans::PropertyValue>& rFramePr
             PROP_BOTTOM_BORDER_DISTANCE
         };
 
-        sal_uInt32 nBorderPropertyCount = sizeof( aBorderProperties ) / sizeof(PropertyIds);
+        sal_uInt32 const nBorderPropertyCount = SAL_N_ELEMENTS( aBorderProperties );
 
         for( sal_uInt32 nProperty = 0; nProperty < nBorderPropertyCount; ++nProperty)
         {
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index ee2c8afe3370..05b20a31817e 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -255,7 +255,7 @@ uno::Sequence< beans::PropertyValue > ListLevel::GetLevelProperties( )
         aNumberingProperties.push_back(lcl_makePropVal(PROP_NUMBERING_TYPE, nNumberFormat));
     }
 
-    if( m_nJC >= 0 && m_nJC <= sal::static_int_cast<sal_Int32>(sizeof(aWWToUnoAdjust) / sizeof(sal_Int16)) )
+    if( m_nJC >= 0 && m_nJC <= sal::static_int_cast<sal_Int32>(SAL_N_ELEMENTS(aWWToUnoAdjust)) )
         aNumberingProperties.push_back(lcl_makePropVal(PROP_ADJUST, aWWToUnoAdjust[m_nJC]));
 
     if( !isOutlineNumbering())
diff --git a/xmloff/source/draw/EnhancedCustomShapeToken.cxx b/xmloff/source/draw/EnhancedCustomShapeToken.cxx
index 076ae2728fbd..cf644e34e7f6 100644
--- a/xmloff/source/draw/EnhancedCustomShapeToken.cxx
+++ b/xmloff/source/draw/EnhancedCustomShapeToken.cxx
@@ -141,7 +141,7 @@ static const TokenTable pTokenTableArray[] =
     { "Origin",                             EAS_Origin },
     { "Color",                              EAS_Color },
     { "Switched",                           EAS_Switched },
-     { "Polar",                             EAS_Polar },
+    { "Polar",                              EAS_Polar },
     { "RangeXMinimum",                      EAS_RangeXMinimum },
     { "RangeXMaximum",                      EAS_RangeXMaximum },
     { "RangeYMinimum",                      EAS_RangeYMinimum },
@@ -175,10 +175,8 @@ EnhancedCustomShapeTokenEnum EASGet( const OUString& rShapeType )
         if ( !pHashMap )
         {
             TypeNameHashMap* pH = new TypeNameHashMap;
-            const TokenTable* pPtr = pTokenTableArray;
-            const TokenTable* pEnd = pPtr + ( sizeof( pTokenTableArray ) / sizeof( TokenTable ) );
-            for ( ; pPtr < pEnd; pPtr++ )
-                (*pH)[ pPtr->pS ] = pPtr->pE;
+            for (auto const & pair : pTokenTableArray)
+                (*pH)[pair.pS] = pair.pE;
             pHashMap = pH;
         }
     }
diff --git a/xmloff/source/style/weighhdl.cxx b/xmloff/source/style/weighhdl.cxx
index 7181dbcd13a6..52aa20f7f370 100644
--- a/xmloff/source/style/weighhdl.cxx
+++ b/xmloff/source/style/weighhdl.cxx
@@ -89,7 +89,7 @@ bool XMLFontWeightPropHdl::importXML( const OUString& rStrImpValue, Any& rValue,
     if( bRet )
     {
         bRet = false;
-        static int nCount = sizeof(aFontWeightMap)/sizeof(FontWeightMapper);
+        int const nCount = SAL_N_ELEMENTS(aFontWeightMap);
         for (int i = 0; i < (nCount-1); ++i)
         {
             if( (nWeight >= aFontWeightMap[i].nValue) && (nWeight <= aFontWeightMap[i+1].nValue) )
@@ -131,12 +131,11 @@ bool XMLFontWeightPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue,
     if( bRet )
     {
         sal_uInt16 nWeight = 0;
-        static int nCount = sizeof(aFontWeightMap)/sizeof(FontWeightMapper);
-        for( int i=0; i<nCount; i++ )
+        for( auto const & pair : aFontWeightMap )
         {
-            if( fValue <= aFontWeightMap[i].fWeight )
+            if( fValue <= pair.fWeight )
             {
-                 nWeight = aFontWeightMap[i].nValue;
+                 nWeight = pair.nValue;
                  break;
             }
         }


More information about the Libreoffice-commits mailing list