diff options
author | Krisztian Pinter <pin.terminator@gmail.com> | 2013-02-26 16:43:48 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2013-03-07 10:11:47 +0100 |
commit | 895898596c72fd14db2abec3aeaab74d583769e5 (patch) | |
tree | 61587b3cb2638b20931ede8114b6fc3ae5a32f87 /unotools/source/config | |
parent | 98645ae6d4bc7b85730a0a9f00bd2de86dd09be9 (diff) |
WIP: fdo#47011 autosave feature
Change-Id: Ib2cbcc33e6188c60c183b5f47e9ae9c9d4c91b95
Diffstat (limited to 'unotools/source/config')
-rw-r--r-- | unotools/source/config/saveopt.cxx | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/unotools/source/config/saveopt.cxx b/unotools/source/config/saveopt.cxx index a6e27a6c9e9e..452fccae9d84 100644 --- a/unotools/source/config/saveopt.cxx +++ b/unotools/source/config/saveopt.cxx @@ -57,6 +57,7 @@ class SvtSaveOptions_Impl : public utl::ConfigItem bBackup, bAutoSave, bAutoSavePrompt, + bUserAutoSave, bDocInfSave, bSaveWorkingSet, bSaveDocView, @@ -76,6 +77,7 @@ class SvtSaveOptions_Impl : public utl::ConfigItem bROBackup, bROAutoSave, bROAutoSavePrompt, + bROUserAutoSave, bRODocInfSave, bROSaveWorkingSet, bROSaveDocView, @@ -101,6 +103,7 @@ public: sal_Bool IsBackup() const { return bBackup; } sal_Bool IsAutoSave() const { return bAutoSave; } sal_Bool IsAutoSavePrompt() const { return bAutoSavePrompt; } + sal_Bool IsUserAutoSave() const { return bUserAutoSave; } sal_Bool IsDocInfoSave() const { return bDocInfSave; } sal_Bool IsSaveWorkingSet() const { return bSaveWorkingSet; } sal_Bool IsSaveDocView() const { return bSaveDocView; } @@ -121,6 +124,7 @@ public: void SetBackup( sal_Bool b ); void SetAutoSave( sal_Bool b ); void SetAutoSavePrompt( sal_Bool b ); + void SetUserAutoSave( sal_Bool b ); void SetDocInfoSave( sal_Bool b ); void SetSaveWorkingSet( sal_Bool b ); void SetSaveDocView( sal_Bool b ); @@ -181,6 +185,16 @@ void SvtSaveOptions_Impl::SetAutoSavePrompt( sal_Bool b ) } } +void SvtSaveOptions_Impl::SetUserAutoSave( sal_Bool b ) +{ + if (!bROUserAutoSave && bUserAutoSave!=b) + { + bUserAutoSave = b; + SetModified(); + Commit(); + } +} + void SvtSaveOptions_Impl::SetDocInfoSave(sal_Bool b) { if (!bRODocInfSave && bDocInfSave!=b) @@ -282,6 +296,9 @@ sal_Bool SvtSaveOptions_Impl::IsReadOnly( SvtSaveOptions::EOption eOption ) cons case SvtSaveOptions::E_AUTOSAVEPROMPT : bReadOnly = bROAutoSavePrompt; break; + case SvtSaveOptions::E_USERAUTOSAVE : + bReadOnly = bROUserAutoSave; + break; case SvtSaveOptions::E_DOCINFSAVE : bReadOnly = bRODocInfSave; break; @@ -340,6 +357,7 @@ sal_Bool SvtSaveOptions_Impl::IsReadOnly( SvtSaveOptions::EOption eOption ) cons #define ODFDEFAULTVERSION 15 #define USESHA1INODF12 16 #define USEBLOWFISHINODF12 17 +#define USERAUTOSAVE 18 Sequence< OUString > GetPropertyNames() { @@ -362,7 +380,8 @@ Sequence< OUString > GetPropertyNames() "WorkingSet", "ODF/DefaultVersion", "ODF/UseSHA1InODF12", - "ODF/UseBlowfishInODF12" + "ODF/UseBlowfishInODF12", + "Document/UserAutoSave" }; const int nCount = sizeof( aPropNames ) / sizeof( const char* ); @@ -383,6 +402,7 @@ SvtSaveOptions_Impl::SvtSaveOptions_Impl() , bBackup( sal_False ) , bAutoSave( sal_False ) , bAutoSavePrompt( sal_False ) + , bUserAutoSave( sal_False ) , bDocInfSave( sal_False ) , bSaveWorkingSet( sal_False ) , bSaveDocView( sal_False ) @@ -400,6 +420,7 @@ SvtSaveOptions_Impl::SvtSaveOptions_Impl() , bROBackup( CFG_READONLY_DEFAULT ) , bROAutoSave( CFG_READONLY_DEFAULT ) , bROAutoSavePrompt( CFG_READONLY_DEFAULT ) + , bROUserAutoSave( CFG_READONLY_DEFAULT ) , bRODocInfSave( CFG_READONLY_DEFAULT ) , bROSaveWorkingSet( CFG_READONLY_DEFAULT ) , bROSaveDocView( CFG_READONLY_DEFAULT ) @@ -479,6 +500,10 @@ SvtSaveOptions_Impl::SvtSaveOptions_Impl() bAutoSave = bTemp; bROAutoSave = pROStates[nProp]; break; + case USERAUTOSAVE : + bUserAutoSave = bTemp; + bROUserAutoSave = pROStates[nProp]; + break; case PROMPT : bAutoSavePrompt = bTemp; bROAutoSavePrompt = pROStates[nProp]; @@ -563,6 +588,11 @@ SvtSaveOptions_Impl::SvtSaveOptions_Impl() xCFG, ::rtl::OUString("AutoSave"), ::rtl::OUString("TimeIntervall")) >>= nAutoSaveTime; + + ::comphelper::ConfigurationHelper::readRelativeKey( + xCFG, + ::rtl::OUString("AutoSave"), + ::rtl::OUString("UserAutoSaveEnabled")) >>= bUserAutoSave; } catch(const css::uno::Exception&) { OSL_FAIL("Could not find needed information for AutoSave feature."); } @@ -630,6 +660,14 @@ void SvtSaveOptions_Impl::Commit() ++nRealCount; } break; + case USERAUTOSAVE : + if (!bROUserAutoSave) + { + pValues[nRealCount] <<= bUserAutoSave; + pNames[nRealCount] = pOrgNames[i]; + ++nRealCount; + } + break; case EDITPROPERTY : if (!bRODocInfSave) { @@ -753,6 +791,12 @@ void SvtSaveOptions_Impl::Commit() ::rtl::OUString("Enabled"), css::uno::makeAny(bAutoSave)); + ::comphelper::ConfigurationHelper::writeRelativeKey( + xCFG, + ::rtl::OUString("AutoSave"), + ::rtl::OUString("UserAutoSaveEnabled"), + css::uno::makeAny(bUserAutoSave)); + ::comphelper::ConfigurationHelper::flush(xCFG); } @@ -908,6 +952,16 @@ sal_Bool SvtSaveOptions::IsAutoSavePrompt() const return pImp->pSaveOpt->IsAutoSavePrompt(); } +void SvtSaveOptions::SetUserAutoSave( sal_Bool b ) +{ + pImp->pSaveOpt->SetUserAutoSave( b ); +} + +sal_Bool SvtSaveOptions::IsUserAutoSave() const +{ + return pImp->pSaveOpt->IsUserAutoSave(); +} + void SvtSaveOptions::SetDocInfoSave(sal_Bool b) { pImp->pSaveOpt->SetDocInfoSave( b ); |