diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-04-01 14:12:15 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-04-01 14:26:26 +0200 |
commit | 8701899950e0d0135ee7f66296714740406e4350 (patch) | |
tree | 8dbc28f6bce5499ae50535d270130395b18b6aae /cui | |
parent | 7bcf64c29a0f5d3d2d60fe98afadab6e48dbe8b3 (diff) |
Replace MailerProgramCfg_Impl with direct configuration access
Change-Id: I25486b4f7455eab72dd831f0f30eb17595e07681
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/options/optinet2.cxx | 135 |
1 files changed, 17 insertions, 118 deletions
diff --git a/cui/source/options/optinet2.cxx b/cui/source/options/optinet2.cxx index 382480f641e9..3d15501f61d7 100644 --- a/cui/source/options/optinet2.cxx +++ b/cui/source/options/optinet2.cxx @@ -19,6 +19,7 @@ #include <sal/config.h> +#include <officecfg/Office/Common.hxx> #include <officecfg/Office/Security.hxx> #include <tools/config.hxx> #include <vcl/msgbox.hxx> @@ -934,116 +935,18 @@ void SvxSecurityTabPage::Reset( const SfxItemSet* ) { } -class MailerProgramCfg_Impl : public utl::ConfigItem -{ - friend class SvxEMailTabPage; - // variables - OUString sProgram; - // readonly states - bool bROProgram; - - const Sequence<OUString> GetPropertyNames(); - - virtual void ImplCommit() SAL_OVERRIDE; - -public: - MailerProgramCfg_Impl(); - virtual ~MailerProgramCfg_Impl(); - - virtual void Notify( const com::sun::star::uno::Sequence< OUString >& _rPropertyNames) SAL_OVERRIDE; -}; - -/* -------------------------------------------------------------------------*/ - -MailerProgramCfg_Impl::MailerProgramCfg_Impl() : - utl::ConfigItem("Office.Common/ExternalMailer"), - bROProgram(false) -{ - const Sequence< OUString > aNames = GetPropertyNames(); - const Sequence< Any > aValues = GetProperties(aNames); - const Sequence< sal_Bool > aROStates = GetReadOnlyStates(aNames); - const Any* pValues = aValues.getConstArray(); - const sal_Bool* pROStates = aROStates.getConstArray(); - for(sal_Int32 nProp = 0; nProp < aValues.getLength(); nProp++) - { - if(pValues[nProp].hasValue()) - { - switch(nProp) - { - case 0 : - { - pValues[nProp] >>= sProgram; - bROProgram = pROStates[nProp]; - } - break; - } - } - } -} - -/* -------------------------------------------------------------------------*/ - -MailerProgramCfg_Impl::~MailerProgramCfg_Impl() -{ -} - -/* -------------------------------------------------------------------------*/ - -const Sequence<OUString> MailerProgramCfg_Impl::GetPropertyNames() -{ - Sequence<OUString> aRet(1); - OUString* pRet = aRet.getArray(); - pRet[0] = "Program"; - return aRet; -} - -/* -------------------------------------------------------------------------*/ - -void MailerProgramCfg_Impl::ImplCommit() -{ - const Sequence< OUString > aOrgNames = GetPropertyNames(); - sal_Int32 nOrgCount = aOrgNames.getLength(); - - Sequence< OUString > aNames(nOrgCount); - Sequence< Any > aValues(nOrgCount); - sal_Int32 nRealCount = 0; - - for(int nProp = 0; nProp < nOrgCount; nProp++) - { - switch(nProp) - { - case 0: - { - if (!bROProgram) - { - aNames[nRealCount] = aOrgNames[nProp]; - aValues[nRealCount] <<= sProgram; - ++nRealCount; - } - } - break; - } - } - - aNames.realloc(nRealCount); - aValues.realloc(nRealCount); - PutProperties(aNames, aValues); -} - -void MailerProgramCfg_Impl::Notify( const com::sun::star::uno::Sequence< OUString >& ) -{ -} - -/* -------------------------------------------------------------------------*/ - struct SvxEMailTabPage_Impl { SvxEMailTabPage_Impl(): + sProgram(officecfg::Office::Common::ExternalMailer::Program::get()), + bROProgram( + officecfg::Office::Common::ExternalMailer::Program::isReadOnly()), bHideContent( officecfg::Office::Security::HiddenContent::RemoveHiddenContent::get()) {} - MailerProgramCfg_Impl aMailConfig; + OUString sProgram; + bool bROProgram; bool bHideContent; }; @@ -1078,25 +981,21 @@ SfxTabPage* SvxEMailTabPage::Create( vcl::Window* pParent, const SfxItemSet* rA bool SvxEMailTabPage::FillItemSet( SfxItemSet* ) { - bool bMailModified = false; - if(!pImpl->aMailConfig.bROProgram && m_pMailerURLED->IsValueChangedFromSaved()) + std::shared_ptr<comphelper::ConfigurationChanges> batch( + comphelper::ConfigurationChanges::create()); + if (!pImpl->bROProgram && m_pMailerURLED->IsValueChangedFromSaved()) { - pImpl->aMailConfig.sProgram = m_pMailerURLED->GetText(); - bMailModified = true; + pImpl->sProgram = m_pMailerURLED->GetText(); + officecfg::Office::Common::ExternalMailer::Program::set( + pImpl->sProgram, batch); } - if ( bMailModified ) - pImpl->aMailConfig.Commit(); - if (pImpl->bHideContent != m_pSuppressHidden->IsChecked()) { pImpl->bHideContent = m_pSuppressHidden->IsChecked(); - std::shared_ptr<comphelper::ConfigurationChanges> batch( - comphelper::ConfigurationChanges::create()); officecfg::Office::Security::HiddenContent::RemoveHiddenContent::set( pImpl->bHideContent, batch); - batch->commit(); } - + batch->commit(); return false; } @@ -1107,13 +1006,13 @@ void SvxEMailTabPage::Reset( const SfxItemSet* ) m_pMailerURLED->Enable(true ); m_pMailerURLPB->Enable(true ); - if (pImpl->aMailConfig.bROProgram) + if (pImpl->bROProgram) m_pMailerURLFI->Show(); - m_pMailerURLED->SetText(pImpl->aMailConfig.sProgram); + m_pMailerURLED->SetText(pImpl->sProgram); m_pMailerURLED->SaveValue(); - m_pMailContainer->Enable(!pImpl->aMailConfig.bROProgram); + m_pMailContainer->Enable(!pImpl->bROProgram); m_pSuppressHidden->Check(pImpl->bHideContent); } @@ -1122,7 +1021,7 @@ void SvxEMailTabPage::Reset( const SfxItemSet* ) IMPL_LINK( SvxEMailTabPage, FileDialogHdl_Impl, PushButton*, pButton ) { - if (m_pMailerURLPB == pButton && !pImpl->aMailConfig.bROProgram) + if (m_pMailerURLPB == pButton && !pImpl->bROProgram) { FileDialogHelper aHelper( com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, |