extensions/source/propctrlr/formcomponenthandler.cxx |    4 ++--
 sfx2/source/doc/doctempl.cxx                         |    2 +-
 svx/source/form/fmshimp.cxx                          |    2 +-
 svx/source/tbxctrls/extrusioncontrols.cxx            |    2 +-
 sw/source/uibase/utlui/initui.cxx                    |    2 +-
 vcl/source/gdi/print.cxx                             |    2 +-
 6 files changed, 7 insertions(+), 7 deletions(-)

New commits:
commit 23c8da878529f85ba5045db6f7ea7956a64dfc72
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Wed Nov 3 09:22:57 2021 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Wed Nov 3 11:57:03 2021 +0100

    put the message into static_assert
    
    and use more static_assert where its obviously possible
    
    Change-Id: I9466130809acab12505f0760f970793991564165
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124633
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx 
b/extensions/source/propctrlr/formcomponenthandler.cxx
index a783f1e49bd0..ebb30470a6db 100644
--- a/extensions/source/propctrlr/formcomponenthandler.cxx
+++ b/extensions/source/propctrlr/formcomponenthandler.cxx
@@ -519,7 +519,7 @@ namespace pcr
             if( ! (_rControlValue >>= sControlValue) )
                 SAL_WARN("extensions.propctrlr", "convertToControlValue: 
unable to get property for Show/Hide");
 
-            assert(SAL_N_ELEMENTS(RID_RSC_ENUM_SHOWHIDE) == 2 && 
"FormComponentPropertyHandler::convertToPropertyValue: broken resource for 
Show/Hide!");
+            static_assert(SAL_N_ELEMENTS(RID_RSC_ENUM_SHOWHIDE), 
"FormComponentPropertyHandler::convertToPropertyValue: broken resource for 
Show/Hide!");
             bool bShow = sControlValue == PcrRes(RID_RSC_ENUM_SHOWHIDE[1]);
 
             aPropertyValue <<= bShow;
@@ -627,7 +627,7 @@ namespace pcr
         case PROPERTY_ID_SHOW_RECORDACTIONS:
         case PROPERTY_ID_SHOW_FILTERSORT:
         {
-            assert(SAL_N_ELEMENTS(RID_RSC_ENUM_SHOWHIDE) == 2 && 
"FormComponentPropertyHandler::convertToPropertyValue: broken resource for 
Show/Hide!");
+            static_assert(SAL_N_ELEMENTS(RID_RSC_ENUM_SHOWHIDE) == 2, 
"FormComponentPropertyHandler::convertToPropertyValue: broken resource for 
Show/Hide!");
             OUString sControlValue =     ::comphelper::getBOOL(_rPropertyValue)
                                             ? PcrRes(RID_RSC_ENUM_SHOWHIDE[1])
                                             : PcrRes(RID_RSC_ENUM_SHOWHIDE[0]);
diff --git a/sfx2/source/doc/doctempl.cxx b/sfx2/source/doc/doctempl.cxx
index 04c997564405..a7fcb4c8b3fd 100644
--- a/sfx2/source/doc/doctempl.cxx
+++ b/sfx2/source/doc/doctempl.cxx
@@ -529,7 +529,7 @@ OUString SfxDocumentTemplates::ConvertResourceString(const 
OUString& rString)
         STR_TEMPLATE_NAME30
     };
 
-    assert(SAL_N_ELEMENTS(aTemplateNames) == 
SAL_N_ELEMENTS(STR_TEMPLATE_NAME));
+    static_assert(SAL_N_ELEMENTS(aTemplateNames) == 
SAL_N_ELEMENTS(STR_TEMPLATE_NAME));
 
     for (size_t i = 0; i < SAL_N_ELEMENTS(STR_TEMPLATE_NAME); ++i)
     {
diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx
index d974e9ad9484..cfaab66fa28b 100644
--- a/svx/source/form/fmshimp.cxx
+++ b/svx/source/form/fmshimp.cxx
@@ -1021,7 +1021,7 @@ void FmXFormShell::GetConversionMenu_Lock(weld::Menu& 
rNewMenu)
 
 OString FmXFormShell::SlotToIdent(sal_uInt16 nSlot)
 {
-    assert(SAL_N_ELEMENTS(SelObjectSlotMap) >= SAL_N_ELEMENTS(aConvertSlots));
+    static_assert(SAL_N_ELEMENTS(SelObjectSlotMap) >= 
SAL_N_ELEMENTS(aConvertSlots));
 
     for (size_t i = 0; i < SAL_N_ELEMENTS(aConvertSlots); ++i)
     {
diff --git a/svx/source/tbxctrls/extrusioncontrols.cxx 
b/svx/source/tbxctrls/extrusioncontrols.cxx
index f30c123a42b0..ec639f77737b 100644
--- a/svx/source/tbxctrls/extrusioncontrols.cxx
+++ b/svx/source/tbxctrls/extrusioncontrols.cxx
@@ -402,7 +402,7 @@ void ExtrusionDepthWindow::implFillStrings( FieldUnit eUnit 
)
         RID_SVXSTR_DEPTH_4_INCH
     };
 
-    assert(SAL_N_ELEMENTS(aDepths) == SAL_N_ELEMENTS(aDepthsInch));
+    static_assert(SAL_N_ELEMENTS(aDepths) == SAL_N_ELEMENTS(aDepthsInch));
 
     const TranslateId* pResource = IsMetric(eUnit) ? aDepths : aDepthsInch;
 
diff --git a/sw/source/uibase/utlui/initui.cxx 
b/sw/source/uibase/utlui/initui.cxx
index 740152dd89ad..4438935585b9 100644
--- a/sw/source/uibase/utlui/initui.cxx
+++ b/sw/source/uibase/utlui/initui.cxx
@@ -185,7 +185,7 @@ void ShellResource::GetAutoFormatNameLst_() const
     mxAutoFormatNameLst.emplace();
     mxAutoFormatNameLst->reserve(STR_AUTOFMTREDL_END);
 
-    assert(SAL_N_ELEMENTS(RID_SHELLRES_AUTOFMTSTRS) == STR_AUTOFMTREDL_END);
+    static_assert(SAL_N_ELEMENTS(RID_SHELLRES_AUTOFMTSTRS) == 
STR_AUTOFMTREDL_END);
     for (sal_uInt16 n = 0; n < STR_AUTOFMTREDL_END; ++n)
     {
         OUString p(SwResId(RID_SHELLRES_AUTOFMTSTRS[n]));
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index 2e2a6505ed8f..88143e27ce29 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -1404,7 +1404,7 @@ OUString Printer::GetPaperName( Paper ePaper )
             PAPER_ARCHE, PAPER_SCREEN_16_9, PAPER_SCREEN_16_10, 
PAPER_16K_195x270, PAPER_16K_197x273,
             PAPER_WIDESCREEN, PAPER_ONSCREENSHOW_4_3, PAPER_ONSCREENSHOW_16_9, 
PAPER_ONSCREENSHOW_16_10
         };
-        static_assert(SAL_N_ELEMENTS(PaperIndex) == 
SAL_N_ELEMENTS(RID_STR_PAPERNAMES)); // ensure localized paper name count is 
correct
+        static_assert(SAL_N_ELEMENTS(PaperIndex) == 
SAL_N_ELEMENTS(RID_STR_PAPERNAMES), "localized paper name count wrong");
         for (size_t i = 0; i < SAL_N_ELEMENTS(PaperIndex); ++i)
             pSVData->maPaperNames[PaperIndex[i]] = 
VclResId(RID_STR_PAPERNAMES[i]);
     }

Reply via email to