use officecfg to retrieve UseUserData

Change-Id: Ic77555520f2451b12c01423179d3f201daad35b3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119472
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2021-07-24 13:38:46 +02:00
parent 1d2fb25e26
commit 60fc68e547
4 changed files with 11 additions and 70 deletions

View file

@ -34,6 +34,7 @@
#include <svl/intitem.hxx>
#include <vcl/settings.hxx>
#include <officecfg/Office/Common.hxx>
#include <unotools/useroptions.hxx>
#include <cuioptgenrl.hxx>
#include <svx/svxids.hrc>
@ -349,10 +350,11 @@ bool SvxGeneralTabPage::FillItemSet( SfxItemSet* )
bool bModified = false;
bModified |= GetData_Impl();
SvtSaveOptions aSaveOpt;
if (m_xUseDataCB->get_active() != aSaveOpt.IsUseUserData())
if (m_xUseDataCB->get_active() != officecfg::Office::Common::Save::Document::UseUserData::get())
{
aSaveOpt.SetUseUserData(m_xUseDataCB->get_active());
auto xChanges = comphelper::ConfigurationChanges::create();
officecfg::Office::Common::Save::Document::UseUserData::set(m_xUseDataCB->get_active(), xChanges);
xChanges->commit();
bModified = true;
}
return bModified;
@ -377,7 +379,7 @@ void SvxGeneralTabPage::Reset( const SfxItemSet* rSet )
vFields.front()->xEdit->grab_focus();
}
m_xUseDataCB->set_active(SvtSaveOptions().IsUseUserData());
m_xUseDataCB->set_active(officecfg::Office::Common::Save::Document::UseUserData::get());
}

View file

@ -41,6 +41,7 @@
#include <tools/diagnose_ex.h>
#include <officecfg/Office/Common.hxx>
#include <officecfg/Office/Recovery.hxx>
#include <officecfg/Office/Common.hxx>
#include <sfx2/fcontnr.hxx>

View file

@ -31,7 +31,6 @@ public:
enum class EOption
{
UseUserData,
OdfDefaultVersion
};
@ -78,9 +77,6 @@ public:
SvtSaveOptions();
virtual ~SvtSaveOptions() override;
void SetUseUserData( bool b );
bool IsUseUserData() const;
void SetLoadUserSettings(bool b);
bool IsLoadUserSettings() const;

View file

@ -59,13 +59,11 @@ namespace {
class SvtSaveOptions_Impl : public utl::ConfigItem
{
sal_Int32 nAutoSaveTime;
bool bUseUserData,
bAutoSave;
bool bAutoSave;
SvtSaveOptions::ODFDefaultVersion eODFDefaultVersion;
bool bROUseUserData,
bROODFDefaultVersion;
bool bROODFDefaultVersion;
virtual void ImplCommit() override;
@ -74,12 +72,9 @@ public:
virtual void Notify( const css::uno::Sequence< OUString >& aPropertyNames ) override;
bool IsUseUserData() const { return bUseUserData; }
SvtSaveOptions::ODFDefaultVersion
GetODFDefaultVersion() const { return eODFDefaultVersion; }
void SetUseUserData( bool b );
void SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eNew );
bool IsReadOnly( SvtSaveOptions::EOption eOption ) const;
@ -87,15 +82,6 @@ public:
}
void SvtSaveOptions_Impl::SetUseUserData( bool b )
{
if (!bROUseUserData && bUseUserData!=b)
{
bUseUserData = b;
SetModified();
}
}
void SvtSaveOptions_Impl::SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eNew )
{
if ( !bROODFDefaultVersion && eODFDefaultVersion != eNew )
@ -110,9 +96,6 @@ bool SvtSaveOptions_Impl::IsReadOnly( SvtSaveOptions::EOption eOption ) const
bool bReadOnly = CFG_READONLY_DEFAULT;
switch(eOption)
{
case SvtSaveOptions::EOption::UseUserData :
bReadOnly = bROUseUserData;
break;
case SvtSaveOptions::EOption::OdfDefaultVersion :
bReadOnly = bROODFDefaultVersion;
break;
@ -121,15 +104,13 @@ bool SvtSaveOptions_Impl::IsReadOnly( SvtSaveOptions::EOption eOption ) const
}
#define FORMAT 0
#define USEUSERDATA 1
#define ODFDEFAULTVERSION 2
#define ODFDEFAULTVERSION 1
static Sequence< OUString > GetPropertyNames()
{
static const char* aPropNames[] =
{
"Graphic/Format",
"Document/UseUserData",
"ODF/DefaultVersion"
};
@ -145,9 +126,7 @@ static Sequence< OUString > GetPropertyNames()
SvtSaveOptions_Impl::SvtSaveOptions_Impl()
: ConfigItem( "Office.Common/Save" )
, nAutoSaveTime( 0 )
, bUseUserData( false )
, eODFDefaultVersion( SvtSaveOptions::ODFVER_LATEST )
, bROUseUserData( CFG_READONLY_DEFAULT )
, bROODFDefaultVersion( CFG_READONLY_DEFAULT )
{
Sequence< OUString > aNames = GetPropertyNames();
@ -188,26 +167,7 @@ SvtSaveOptions_Impl::SvtSaveOptions_Impl()
}
default:
{
bool bTemp = bool();
if ( pValues[nProp] >>= bTemp )
{
switch ( nProp )
{
case USEUSERDATA :
bUseUserData = bTemp;
bROUseUserData = pROStates[nProp];
break;
default :
SAL_WARN( "unotools.config", "invalid index to load a path" );
}
}
else
{
OSL_FAIL( "Wrong Type!" );
}
}
OSL_FAIL( "Wrong Type!" );
}
}
}
@ -244,14 +204,6 @@ void SvtSaveOptions_Impl::ImplCommit()
case FORMAT:
// not supported anymore
break;
case USEUSERDATA :
if (!bROUseUserData)
{
pValues[nRealCount] <<= bUseUserData;
pNames[nRealCount] = pOrgNames[i];
++nRealCount;
}
break;
case ODFDEFAULTVERSION:
if (!bROODFDefaultVersion)
{
@ -362,16 +314,6 @@ SvtSaveOptions::~SvtSaveOptions()
}
}
void SvtSaveOptions::SetUseUserData( bool b )
{
pImp->pSaveOpt->SetUseUserData( b );
}
bool SvtSaveOptions::IsUseUserData() const
{
return pImp->pSaveOpt->IsUseUserData();
}
void SvtSaveOptions::SetLoadUserSettings(bool b)
{
pImp->pLoadOpt->SetLoadUserSettings(b);