Hide --enable-online-updaet-mar GUI behind ExperimentalMode for now

(and rename SvxOnlineUpdateTabPage's is...OnlineUpdateEnabled predicates to
is...OnlineUpdaetAvailable, to avoid the overloaded term "enabled" here)

Change-Id: I639ac72a17b98c883ff3082747b8576099299867
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160975
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
(cherry picked from commit 7efdb261bdb11e669e80d62834985d04cb90bde9)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160947
diff --git a/cui/source/options/optupdt.cxx b/cui/source/options/optupdt.cxx
index e8f4ee2..e3b855b 100644
--- a/cui/source/options/optupdt.cxx
+++ b/cui/source/options/optupdt.cxx
@@ -52,7 +52,8 @@ using namespace ::css;

SvxOnlineUpdateTabPage::SvxOnlineUpdateTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
    : SfxTabPage(pPage, pController, "cui/ui/optonlineupdatepage.ui", "OptOnlineUpdatePage", &rSet)
    , m_showTraditionalOnlineUpdate(isTraditionalOnlineUpdateEnabled())
    , m_showTraditionalOnlineUpdate(isTraditionalOnlineUpdateAvailable())
    , m_showMarOnlineUpdate(isMarOnlineUpdateAvailable())
    , m_xNeverChecked(m_xBuilder->weld_label("neverchecked"))
    , m_xAutoCheckCheckBox(m_xBuilder->weld_check_button("autocheck"))
    , m_xAutoCheckImg(m_xBuilder->weld_widget("lockautocheck"))
@@ -121,12 +122,12 @@ SvxOnlineUpdateTabPage::SvxOnlineUpdateTabPage(weld::Container* pPage, weld::Dia
        m_xPrivacyPolicyButton->hide();
    }

#if HAVE_FEATURE_UPDATE_MAR
    m_xMar->show();
    m_xEnableMar->set_sensitive(!officecfg::Office::Update::Update::Enabled::isReadOnly());
#else
    m_xMar->hide();
#endif
    if (m_showMarOnlineUpdate) {
        m_xMar->show();
        m_xEnableMar->set_sensitive(!officecfg::Office::Update::Update::Enabled::isReadOnly());
    } else {
        m_xMar->hide();
    }
}

SvxOnlineUpdateTabPage::~SvxOnlineUpdateTabPage()
@@ -325,14 +326,12 @@ bool SvxOnlineUpdateTabPage::FillItemSet( SfxItemSet* )
            xChangesBatch->commitChanges();
    }

#if HAVE_FEATURE_UPDATE_MAR
    if (m_xEnableMar->get_state_changed_from_saved()) {
    if (m_showMarOnlineUpdate && m_xEnableMar->get_state_changed_from_saved()) {
        auto batch(comphelper::ConfigurationChanges::create());
        officecfg::Office::Update::Update::Enabled::set(m_xEnableMar->get_active(), batch);
        batch->commit();
        bModified = true;
    }
#endif

    return bModified;
}
@@ -400,10 +399,10 @@ void SvxOnlineUpdateTabPage::Reset( const SfxItemSet* )
        m_xAutoDownloadCheckBox->save_state();
    }

#if HAVE_FEATURE_UPDATE_MAR
    m_xEnableMar->set_active(officecfg::Office::Update::Update::Enabled::get());
    m_xEnableMar->save_state();
#endif
    if (m_showMarOnlineUpdate) {
        m_xEnableMar->set_active(officecfg::Office::Update::Update::Enabled::get());
        m_xEnableMar->save_state();
    }
}

void SvxOnlineUpdateTabPage::FillUserData()
@@ -493,7 +492,7 @@ IMPL_LINK_NOARG(SvxOnlineUpdateTabPage, CheckNowHdl_Impl, weld::Button&, void)
    }
}

bool SvxOnlineUpdateTabPage::isTraditionalOnlineUpdateEnabled() {
bool SvxOnlineUpdateTabPage::isTraditionalOnlineUpdateAvailable() {
    try
    {
        css::uno::Reference < css::uno::XInterface > xService( setup::UpdateCheck::create( ::comphelper::getProcessComponentContext() ) );
@@ -506,4 +505,12 @@ bool SvxOnlineUpdateTabPage::isTraditionalOnlineUpdateEnabled() {
    return false;
}

bool SvxOnlineUpdateTabPage::isMarOnlineUpdateAvailable() {
#if HAVE_FEATURE_UPDATE_MAR
    return officecfg::Office::Common::Misc::ExperimentalMode::get();
#else
    return false;
#endif
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/options/optupdt.hxx b/cui/source/options/optupdt.hxx
index b6e7e4c..48113c8 100644
--- a/cui/source/options/optupdt.hxx
+++ b/cui/source/options/optupdt.hxx
@@ -29,6 +29,7 @@ class SvxOnlineUpdateTabPage : public SfxTabPage
{
private:
    bool m_showTraditionalOnlineUpdate;
    bool m_showMarOnlineUpdate;

    OUString       m_aNeverChecked;
    OUString       m_aLastCheckedTemplate;
@@ -79,7 +80,8 @@ public:
    virtual void            Reset( const SfxItemSet* rSet ) override;
    virtual void            FillUserData() override;

    static bool isTraditionalOnlineUpdateEnabled();
    static bool isTraditionalOnlineUpdateAvailable();
    static bool isMarOnlineUpdateAvailable();
};

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index c0a4299..b4b9e98 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -1734,14 +1734,13 @@ void OfaTreeOptionsDialog::generalOptions(const std::vector<sal_uInt16>& vPageId
            if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
                continue;

#if !HAVE_FEATURE_UPDATE_MAR
            // Disable Online Update page if service not installed
            // Disable Online Update page if neither mode is available
            if( RID_SVXPAGE_ONLINEUPDATE == nPageId
                && !SvxOnlineUpdateTabPage::isTraditionalOnlineUpdateEnabled() )
                && !(SvxOnlineUpdateTabPage::isTraditionalOnlineUpdateAvailable()
                     || SvxOnlineUpdateTabPage::isMarOnlineUpdateAvailable()) )
            {
                continue;
            }
#endif

            // Disable Basic IDE options, if experimental features are not enabled
            if( RID_SVXPAGE_BASICIDE_OPTIONS == nPageId )