tdf#116491: Customize: Hide experimental commands when not in experimental mode

Change-Id: Ibc88e9c90b261b5294fab8041e0b530016f45f33
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116006
Tested-by: Jenkins
Reviewed-by: Muhammet Kara <muhammet.kara@collabora.com>
diff --git a/cui/source/customize/CommandCategoryListBox.cxx b/cui/source/customize/CommandCategoryListBox.cxx
index 5b8903f..7823607 100644
--- a/cui/source/customize/CommandCategoryListBox.cxx
+++ b/cui/source/customize/CommandCategoryListBox.cxx
@@ -44,6 +44,7 @@
#include <comphelper/sequenceashashmap.hxx>
#include <comphelper/SetFlagContextHelper.hxx>
#include <comphelper/string.hxx>
#include <officecfg/Office/Common.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <i18nutil/searchopt.hxx>
#include <sal/log.hxx>
@@ -222,6 +223,7 @@ void CommandCategoryListBox::FillFunctionsList(
    // Setup search filter parameters
    m_searchOptions.searchString = filterTerm;
    utl::TextSearch textSearch(m_searchOptions);
    const bool bInExperimentalMode = officecfg::Office::Common::Misc::ExperimentalMode::get();

    for (const auto& rInfo : xCommands)
    {
@@ -234,11 +236,17 @@ void CommandCategoryListBox::FillFunctionsList(
            = vcl::CommandInfoProvider::GetTooltipForCommand(rInfo.Command, aProperties, m_xFrame);
        OUString sPopupLabel = (vcl::CommandInfoProvider::GetPopupLabelForCommand(aProperties))
                                   .replaceFirst("~", "");
        bool bIsExperimental
            = vcl::CommandInfoProvider::IsExperimental(rInfo.Command, m_sModuleLongName);

        // Hide experimental commands when not in experimental mode
        bool bHideExperimental = bIsExperimental && !bInExperimentalMode;

        // Apply the search filter
        if (!filterTerm.isEmpty() && !textSearch.searchForward(sUIName)
            && !textSearch.searchForward(sLabel) && !textSearch.searchForward(sTooltipLabel)
            && !textSearch.searchForward(sPopupLabel))
        if (bHideExperimental
            || (!filterTerm.isEmpty() && !textSearch.searchForward(sUIName)
                && !textSearch.searchForward(sLabel) && !textSearch.searchForward(sTooltipLabel)
                && !textSearch.searchForward(sPopupLabel)))
        {
            continue;
        }