Hi, I have submitted a patch for review:
https://gerrit.libreoffice.org/2480 To pull it, you can do: git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/80/2480/1 autosave feature progress Change-Id: I58e4d2e9d017ad6d6d0fda21c68447373dab12d4 --- M cui/source/options/optsave.cxx M cui/source/options/optsave.hrc M cui/source/options/optsave.hxx M cui/source/options/optsave.src M framework/inc/services/autorecovery.hxx M framework/source/services/autorecovery.cxx M sfx2/inc/sfx2/sfxsids.hrc M sfx2/source/appl/appcfg.cxx M unotools/inc/unotools/saveopt.hxx M unotools/source/config/saveopt.cxx 10 files changed, 150 insertions(+), 20 deletions(-) diff --git a/cui/source/options/optsave.cxx b/cui/source/options/optsave.cxx index d977cac..2ada021 100644 --- a/cui/source/options/optsave.cxx +++ b/cui/source/options/optsave.cxx @@ -55,8 +55,9 @@ #define CFG_PAGE_AND_GROUP OUString("General"), OUString("LoadSave") // !! you have to update these index, if you changed the list of the child windows !! -#define WININDEX_AUTOSAVE ((sal_uInt16)6) -#define WININDEX_SAVEURL_RELFSYS ((sal_uInt16)9) +#define WININDEX_AUTOSAVE ((sal_uInt16) 6) +#define WININDEX_USERAUTOSAVE ((sal_uInt16) 9) +#define WININDEX_SAVEURL_RELFSYS ((sal_uInt16)10) // ---------------------------------------------------------------------- @@ -102,6 +103,7 @@ aMinuteFT ( this, CUI_RES( FT_MINUTE ) ), aRelativeFsysCB ( this, CUI_RES( BTN_RELATIVE_FSYS ) ), aRelativeInetCB ( this, CUI_RES( BTN_RELATIVE_INET ) ), + aUserAutoSaveCB ( this, CUI_RES( BTN_USERAUTOSAVE ) ), aDefaultFormatFL ( this, CUI_RES( FL_FILTER ) ), aODFVersionFT ( this, CUI_RES( FT_ODF_VERSION ) ), @@ -239,11 +241,22 @@ aAutoSaveEdit.Hide(); aMinuteFT.Hide(); // the other controls have to move upwards the height of checkbox + space - nDelta += aRelativeFsysCB.GetPosPixel().Y() - aAutoSaveCB.GetPosPixel().Y(); + nDelta += aUserAutoSaveCB.GetPosPixel().Y() - aAutoSaveCB.GetPosPixel().Y(); } else if ( nDelta > 0 ) // the "AutoSave" controls have to move upwards too nWinIndex = WININDEX_AUTOSAVE; + + if ( aOptionsDlgOpt.IsOptionHidden( "UserAutoSave", CFG_PAGE_AND_GROUP ) ) + { + // hide controls of "UserAutoSave" + aUserAutoSaveCB.Hide(); + // the other controls have to move upwards the height of checkbox + space + nDelta += aRelativeFsysCB.GetPosPixel().Y() - aUserAutoSaveCB.GetPosPixel().Y(); + } + else if ( nDelta > 0 ) + // the "UserAutoSave" controls have to move upwards too + nWinIndex = WININDEX_USERAUTOSAVE; if ( nDelta > 0 ) { @@ -313,6 +326,13 @@ { rSet.Put( SfxUInt16Item( GetWhich( SID_ATTR_AUTOSAVEMINUTE ), (sal_uInt16)aAutoSaveEdit.GetValue() ) ); + bModified |= sal_True; + } + + if ( aUserAutoSaveCB.IsChecked() != aUserAutoSaveCB.GetSavedValue() ) + { + rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_USERAUTOSAVE ), + aUserAutoSaveCB.IsChecked() ) ); bModified |= sal_True; } // save relatively @@ -489,6 +509,7 @@ aBackupFI.Show(bBackupRO); aAutoSaveCB.Check(aSaveOpt.IsAutoSave()); + aUserAutoSaveCB.Check(aSaveOpt.IsUserAutoSave()); aWarnAlienFormatCB.Check(aSaveOpt.IsWarnAlienFormat()); aWarnAlienFormatCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_WARNALIENFORMAT)); @@ -515,6 +536,8 @@ aAutoSaveCB.SaveValue(); aAutoSaveEdit.SaveValue(); + aUserAutoSaveCB.SaveValue(); + aRelativeFsysCB.SaveValue(); aRelativeInetCB.SaveValue(); aODFVersionLB.SaveValue(); @@ -530,11 +553,13 @@ { aAutoSaveEdit.Enable(); aMinuteFT.Enable(); + aUserAutoSaveCB.Enable(); } else { aAutoSaveEdit.Disable(); aMinuteFT.Disable(); + aUserAutoSaveCB.Disable(); } } return 0; diff --git a/cui/source/options/optsave.hrc b/cui/source/options/optsave.hrc index 16891bc..36a95b6 100644 --- a/cui/source/options/optsave.hrc +++ b/cui/source/options/optsave.hrc @@ -29,6 +29,7 @@ #define BTN_AUTOSAVE 16 #define ED_AUTOSAVE 17 #define FT_MINUTE 18 +#define BTN_USERAUTOSAVE 19 #define BTN_NOPRETTYPRINTING 20 #define FI_BACKUP 21 #define BTN_WARNALIENFORMAT 22 diff --git a/cui/source/options/optsave.hxx b/cui/source/options/optsave.hxx index 4ab3082..00cb63f 100644 --- a/cui/source/options/optsave.hxx +++ b/cui/source/options/optsave.hxx @@ -54,6 +54,7 @@ CheckBox aAutoSaveCB; NumericField aAutoSaveEdit; FixedText aMinuteFT; + CheckBox aUserAutoSaveCB; CheckBox aRelativeFsysCB; CheckBox aRelativeInetCB; diff --git a/cui/source/options/optsave.src b/cui/source/options/optsave.src index 6dc878e..d92df79 100644 --- a/cui/source/options/optsave.src +++ b/cui/source/options/optsave.src @@ -110,36 +110,43 @@ Size = MAP_APPFONT ( 65 , 8 ) ; Text [ en-US ] = "Minutes" ; }; + CheckBox BTN_USERAUTOSAVE + { + HelpID = "cui:CheckBox:RID_SFXPAGE_SAVE:BTN_USERAUTOSAVE"; //? FIX ME + Pos = MAP_APPFONT ( 12 , 74 ) ; + Size = MAP_APPFONT ( 163 , 10 ) ; + Text [ en-US ] = "Save document when saving ~AutoRecovery information" ; + }; CheckBox BTN_RELATIVE_FSYS { HelpID = "cui:CheckBox:RID_SFXPAGE_SAVE:BTN_RELATIVE_FSYS"; - Pos = MAP_APPFONT ( 12 , 74 ) ; + Pos = MAP_APPFONT ( 12 , 85 ) ; Size = MAP_APPFONT ( 236 , 10 ) ; Text [ en-US ] = "Save URLs relative to file system" ; }; CheckBox BTN_RELATIVE_INET { HelpID = "cui:CheckBox:RID_SFXPAGE_SAVE:BTN_RELATIVE_INET"; - Pos = MAP_APPFONT ( 12 , 85 ) ; + Pos = MAP_APPFONT ( 12 , 96 ) ; Size = MAP_APPFONT ( 248 , 10 ) ; Text [ en-US ] = "Save URLs relative to internet" ; }; FixedLine FL_FILTER { - Pos = MAP_APPFONT ( 6 , 97 ) ; + Pos = MAP_APPFONT ( 6 , 108 ) ; Size = MAP_APPFONT ( 248 , 8 ) ; Text [ en-US ] = "Default file format and ODF settings" ; }; FixedText FT_ODF_VERSION { - Pos = MAP_APPFONT ( 12 , 107 ) ; + Pos = MAP_APPFONT ( 12 , 118 ) ; Size = MAP_APPFONT ( 121 , 8 ) ; Text [ en-US ] = "ODF format version" ; }; ListBox LB_ODF_VERSION { HelpID = "cui:ListBox:RID_SFXPAGE_SAVE:LB_ODF_VERSION"; - Pos = MAP_APPFONT ( 136 , 105 ) ; + Pos = MAP_APPFONT ( 136 , 116 ) ; Size = MAP_APPFONT ( 108 , 58 ) ; Border = TRUE; DropDown = TRUE; @@ -154,33 +161,33 @@ CheckBox BTN_NOPRETTYPRINTING { HelpID = "cui:CheckBox:RID_SFXPAGE_SAVE:BTN_NOPRETTYPRINTING"; - Pos = MAP_APPFONT ( 12 , 120 ) ; + Pos = MAP_APPFONT ( 12 , 131 ) ; Size = MAP_APPFONT ( 248 , 10 ) ; Text [ en-US ] = "Size optimization for ODF format" ; }; CheckBox BTN_WARNALIENFORMAT { HelpID = "cui:CheckBox:RID_SFXPAGE_SAVE:BTN_WARNALIENFORMAT"; - Pos = MAP_APPFONT ( 12 , 131 ) ; + Pos = MAP_APPFONT ( 12 , 142 ) ; Size = MAP_APPFONT ( 248 , 10 ) ; Text [ en-US ] = "Warn when not saving in ODF or default format" ; }; FixedText FT_APP { - Pos = MAP_APPFONT ( 12 , 142 ) ; + Pos = MAP_APPFONT ( 12 , 153 ) ; Size = MAP_APPFONT ( 120 , 8 ) ; Text [ en-US ] = "D~ocument type"; }; FixedText FT_FILTER { - Pos = MAP_APPFONT ( 136 , 142 ) ; + Pos = MAP_APPFONT ( 136 , 153 ) ; Size = MAP_APPFONT ( 120 , 8 ) ; Text [ en-US ] = "Always sa~ve as"; }; ListBox LB_APP { HelpID = "cui:ListBox:RID_SFXPAGE_SAVE:LB_APP"; - Pos = MAP_APPFONT ( 12 , 153 ) ; + Pos = MAP_APPFONT ( 12 , 164 ) ; Size = MAP_APPFONT ( 108 , 58 ) ; Border = TRUE; DropDown = TRUE; @@ -197,14 +204,14 @@ }; FixedImage FI_FILTER { - Pos = MAP_APPFONT ( 129, 154 ) ; + Pos = MAP_APPFONT ( 129, 165 ) ; Size = MAP_APPFONT ( 6 , 6 ) ; Hide = TRUE; }; ListBox LB_FILTER { HelpID = "cui:ListBox:RID_SFXPAGE_SAVE:LB_FILTER"; - Pos = MAP_APPFONT ( 136 , 153 ) ; + Pos = MAP_APPFONT ( 136 , 164 ) ; Size = MAP_APPFONT ( 108 , 58 ) ; Border = TRUE; Sort = TRUE; @@ -212,13 +219,13 @@ }; FixedImage FI_ODF_WARNING { - Pos = MAP_APPFONT ( 12, 169 ) ; + Pos = MAP_APPFONT ( 12, 170 ) ; Size = MAP_APPFONT ( 8 , 8 ) ; Hide = TRUE; }; FixedText FT_WARN { - Pos = MAP_APPFONT ( 23 , 169 ) ; + Pos = MAP_APPFONT ( 23 , 170 ) ; Size = MAP_APPFONT ( 239 , 8 ) ; Hide = TRUE; Text [ en-US ] = "Not using ODF 1.2 Extended may cause information to be lost."; diff --git a/framework/inc/services/autorecovery.hxx b/framework/inc/services/autorecovery.hxx index 9ef0a2f..90e98e7 100644 --- a/framework/inc/services/autorecovery.hxx +++ b/framework/inc/services/autorecovery.hxx @@ -213,7 +213,8 @@ E_SESSION_RESTORE = 128, E_DISABLE_AUTORECOVERY = 256, E_SET_AUTOSAVE_STATE = 512, - E_SESSION_QUIET_QUIT = 1024 + E_SESSION_QUIET_QUIT = 1024, + E_USER_AUTO_SAVE = 2048 }; //--------------------------------------- diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx index e1415df..c9c14f9 100644 --- a/framework/source/services/autorecovery.cxx +++ b/framework/source/services/autorecovery.cxx @@ -124,6 +124,8 @@ static const char CFG_ENTRY_AUTOSAVE_ENABLED[] = "AutoSave/Enabled"; static const char CFG_ENTRY_AUTOSAVE_TIMEINTERVALL[] = "AutoSave/TimeIntervall"; //sic! +static const char CFG_ENTRY_USERAUTOSAVE_ENABLED[] = "UserAutoSave/Enabled"; + static const char CFG_PATH_AUTOSAVE[] = "AutoSave"; static const char CFG_ENTRY_MINSPACE_DOCSAVE[] = "MinSpaceDocSave"; static const char CFG_ENTRY_MINSPACE_CONFIGSAVE[] = "MinSpaceConfigSave"; @@ -977,12 +979,25 @@ sal_Bool bEnabled = sal_False; xCommonRegistry->getByHierarchicalName(rtl::OUString(CFG_ENTRY_AUTOSAVE_ENABLED)) >>= bEnabled; + // UserAutoSave [bool] + sal_Bool bUserEnabled = sal_False; + xCommonRegistry->getByHierarchicalName(rtl::OUString(CFG_ENTRY_USERAUTOSAVE_ENABLED)) >>= bUserEnabled; + // SAFE -> ------------------------------ WriteGuard aWriteLock(m_aLock); if (bEnabled) { m_eJob |= AutoRecovery::E_AUTO_SAVE; m_eTimerType = AutoRecovery::E_NORMAL_AUTOSAVE_INTERVALL; + + if (bUserEnabled) + { + m_eJob |= AutoRecovery::E_USER_AUTO_SAVE; + } + else + { + m_eJob &= ~AutoRecovery::E_USER_AUTO_SAVE; + } } else { @@ -2342,6 +2357,12 @@ { xDocRecover->storeToRecoveryFile( rInfo.NewTempURL, lNewArgs.getAsConstPropertyValueList() ); + //if userautosave is enabled, also save to the original file + if((m_eJob & AutoRecovery::E_AUTO_SAVE) == AutoRecovery::E_AUTO_SAVE) + { + //dispatchURL( rtl::OUString( ".uno:Save" ), rtl::OUString(), xFrame, aArgs ); + } + #ifdef TRIGGER_FULL_DISC_CHECK throw css::uno::Exception(); #else // TRIGGER_FULL_DISC_CHECK diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index d379d9f..33be620 100644 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -514,6 +514,7 @@ #define SID_ATTR_AUTOSAVE (SID_OPTIONS_START + 2) #define SID_ATTR_AUTOSAVEPROMPT (SID_OPTIONS_START + 3) #define SID_ATTR_AUTOSAVEMINUTE (SID_OPTIONS_START + 5) +#define SID_ATTR_USERAUTOSAVE (SID_OPTIONS_START + 6) #define SID_ATTR_WORKINGSET (SID_OPTIONS_START + 13) #define SID_ATTR_UNDO_COUNT (SID_OPTIONS_START + 16) // unused diff --git a/sfx2/source/appl/appcfg.cxx b/sfx2/source/appl/appcfg.cxx index 11441cd..061f697 100644 --- a/sfx2/source/appl/appcfg.cxx +++ b/sfx2/source/appl/appcfg.cxx @@ -226,6 +226,14 @@ bRet = sal_False; } break; + case SID_ATTR_USERAUTOSAVE : + { + bRet = sal_True; + if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_USERAUTOSAVE)) + if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_USERAUTOSAVE ), aSaveOptions.IsUserAutoSave()))) + bRet = sal_False; + } + break; case SID_ATTR_DOCINFO : { bRet = sal_True; @@ -582,6 +590,13 @@ aSaveOptions.SetAutoSaveTime(((const SfxUInt16Item *)pItem)->GetValue()); } + // UserAutoSave + if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_USERAUTOSAVE), sal_True, &pItem)) + { + DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected"); + aSaveOptions.SetUserAutoSave( ( (const SfxBoolItem*)pItem )->GetValue() ); + } + // DocInfo if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_DOCINFO), sal_True, &pItem)) { diff --git a/unotools/inc/unotools/saveopt.hxx b/unotools/inc/unotools/saveopt.hxx index 349b5e6..771c721 100644 --- a/unotools/inc/unotools/saveopt.hxx +++ b/unotools/inc/unotools/saveopt.hxx @@ -47,7 +47,8 @@ E_LOADDOCPRINTER, E_ODFDEFAULTVERSION, E_USESHA1INODF12, - E_USEBLOWFISHINODF12 + E_USEBLOWFISHINODF12, + E_USERAUTOSAVE, }; // keep enum values sorted that a less or greater compare maps to older and newer versions! @@ -81,6 +82,9 @@ void SetAutoSavePrompt( sal_Bool b ); sal_Bool IsAutoSavePrompt() const; + void SetUserAutoSave( sal_Bool b ); + sal_Bool IsUserAutoSave() const; + void SetDocInfoSave(sal_Bool b); sal_Bool IsDocInfoSave() const; diff --git a/unotools/source/config/saveopt.cxx b/unotools/source/config/saveopt.cxx index 1618638..13b4d98 100644 --- a/unotools/source/config/saveopt.cxx +++ b/unotools/source/config/saveopt.cxx @@ -57,6 +57,7 @@ bBackup, bAutoSave, bAutoSavePrompt, + bUserAutoSave, bDocInfSave, bSaveWorkingSet, bSaveDocView, @@ -76,6 +77,7 @@ bROBackup, bROAutoSave, bROAutoSavePrompt, + bROUserAutoSave, bRODocInfSave, bROSaveWorkingSet, bROSaveDocView, @@ -101,6 +103,7 @@ 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 @@ 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 ); @@ -178,6 +182,16 @@ { bAutoSavePrompt = b; SetModified(); + } +} + +void SvtSaveOptions_Impl::SetUserAutoSave( sal_Bool b ) +{ + if (!bROUserAutoSave && bUserAutoSave!=b) + { + bUserAutoSave = b; + SetModified(); + Commit(); } } @@ -282,6 +296,9 @@ 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 @@ #define ODFDEFAULTVERSION 15 #define USESHA1INODF12 16 #define USEBLOWFISHINODF12 17 +#define USERAUTOSAVE 18 Sequence< OUString > GetPropertyNames() { @@ -362,7 +380,8 @@ "WorkingSet", "ODF/DefaultVersion", "ODF/UseSHA1InODF12", - "ODF/UseBlowfishInODF12" + "ODF/UseBlowfishInODF12", + "Document/UserAutoSave" }; const int nCount = sizeof( aPropNames ) / sizeof( const char* ); @@ -383,6 +402,7 @@ , 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 @@ , 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 ) @@ -478,6 +499,10 @@ case AUTOSAVE : bAutoSave = bTemp; bROAutoSave = pROStates[nProp]; + break; + case USERAUTOSAVE : + bUserAutoSave = bTemp; + bROUserAutoSave = pROStates[nProp]; break; case PROMPT : bAutoSavePrompt = bTemp; @@ -563,6 +588,11 @@ xCFG, ::rtl::OUString("AutoSave"), ::rtl::OUString("TimeIntervall")) >>= nAutoSaveTime; + + ::comphelper::ConfigurationHelper::readRelativeKey( + xCFG, + ::rtl::OUString("UserAutoSave"), + ::rtl::OUString("Enabled")) >>= bUserAutoSave; } catch(const css::uno::Exception&) { OSL_FAIL("Could not find needed informations for AutoSave feature."); } @@ -626,6 +656,14 @@ if (!bROAutoSavePrompt) { pValues[nRealCount] <<= bAutoSavePrompt; + pNames[nRealCount] = pOrgNames[i]; + ++nRealCount; + } + break; + case USERAUTOSAVE : + if (!bROUserAutoSave) + { + pValues[nRealCount] <<= bUserAutoSave; pNames[nRealCount] = pOrgNames[i]; ++nRealCount; } @@ -752,6 +790,12 @@ ::rtl::OUString("AutoSave"), ::rtl::OUString("Enabled"), css::uno::makeAny(bAutoSave)); + + ::comphelper::ConfigurationHelper::writeRelativeKey( + xCFG, + ::rtl::OUString("UserAutoSave"), + ::rtl::OUString("Enabled"), + css::uno::makeAny(bUserAutoSave)); ::comphelper::ConfigurationHelper::flush(xCFG); } @@ -908,6 +952,16 @@ 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 ); -- To view, visit https://gerrit.libreoffice.org/2480 To unsubscribe, visit https://gerrit.libreoffice.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I58e4d2e9d017ad6d6d0fda21c68447373dab12d4 Gerrit-PatchSet: 1 Gerrit-Project: core Gerrit-Branch: master Gerrit-Owner: Krisztian Pinter <pin.termina...@gmail.com> _______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice