summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cui/source/options/optsave.cxx23
-rw-r--r--cui/source/options/optsave.hxx2
-rw-r--r--cui/uiconfig/ui/optsavepage.ui26
-rw-r--r--include/sfx2/docfile.hxx2
-rw-r--r--include/sfx2/sfxsids.hrc3
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/Common.xcs9
-rw-r--r--sfx2/source/appl/appcfg.cxx7
-rw-r--r--sfx2/source/doc/docfile.cxx17
-rw-r--r--sfx2/source/doc/objstor.cxx2
9 files changed, 83 insertions, 8 deletions
diff --git a/cui/source/options/optsave.cxx b/cui/source/options/optsave.cxx
index 743c6015b1d5..b60fe8da2594 100644
--- a/cui/source/options/optsave.cxx
+++ b/cui/source/options/optsave.cxx
@@ -84,6 +84,7 @@ SvxSaveTabPage::SvxSaveTabPage(weld::Container* pPage, weld::DialogController* p
, m_xLoadDocPrinterCB(m_xBuilder->weld_check_button("load_docprinter"))
, m_xDocInfoCB(m_xBuilder->weld_check_button("docinfo"))
, m_xBackupCB(m_xBuilder->weld_check_button("backup"))
+ , m_xBackupIntoDocumentFolderCB(m_xBuilder->weld_check_button("backupintodocumentfolder"))
, m_xAutoSaveCB(m_xBuilder->weld_check_button("autosave"))
, m_xAutoSaveEdit(m_xBuilder->weld_spin_button("autosave_spin"))
, m_xMinuteFT(m_xBuilder->weld_label("autosave_mins"))
@@ -123,6 +124,7 @@ SvxSaveTabPage::SvxSaveTabPage(weld::Container* pPage, weld::DialogController* p
m_xDocTypeLB->append(OUString::number(APP_MATH), aFilterClassesNode.getNodeValue("com.sun.star.formula.FormulaProperties/DisplayName").get<OUString>());
m_xAutoSaveCB->connect_toggled( LINK( this, SvxSaveTabPage, AutoClickHdl_Impl ) );
+ m_xBackupCB->connect_toggled(LINK(this, SvxSaveTabPage, BackupClickHdl_Impl));
SvtModuleOptions aModuleOpt;
if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::MATH ) )
@@ -215,6 +217,7 @@ void SvxSaveTabPage::DetectHiddenControls()
{
// hide controls of "Backup"
m_xBackupCB->hide();
+ m_xBackupIntoDocumentFolderCB->hide();
}
if ( aOptionsDlgOpt.IsOptionHidden( u"AutoSave", CFG_PAGE_AND_GROUP ) )
@@ -266,6 +269,14 @@ bool SvxSaveTabPage::FillItemSet( SfxItemSet* rSet )
bModified = true;
}
+ if (m_xBackupIntoDocumentFolderCB->get_sensitive()
+ && m_xBackupIntoDocumentFolderCB->get_state_changed_from_saved())
+ {
+ rSet->Put(
+ SfxBoolItem(SID_ATTR_BACKUP_BESIDE_ORIGINAL, m_xBackupIntoDocumentFolderCB->get_active()));
+ bModified = true;
+ }
+
if ( m_xAutoSaveCB->get_state_changed_from_saved() )
{
rSet->Put( SfxBoolItem( SID_ATTR_AUTOSAVE,
@@ -475,6 +486,12 @@ void SvxSaveTabPage::Reset( const SfxItemSet* )
m_xBackupCB->set_active(officecfg::Office::Common::Save::Document::CreateBackup::get());
m_xBackupCB->set_sensitive(!officecfg::Office::Common::Save::Document::CreateBackup::isReadOnly());
+ m_xBackupIntoDocumentFolderCB->set_active(
+ officecfg::Office::Common::Save::Document::BackupIntoDocumentFolder::get());
+ m_xBackupIntoDocumentFolderCB->set_sensitive(
+ !officecfg::Office::Common::Save::Document::BackupIntoDocumentFolder::isReadOnly()
+ && m_xBackupCB->get_active());
+
m_xAutoSaveCB->set_active(officecfg::Office::Recovery::AutoSave::Enabled::get());
m_xAutoSaveCB->set_sensitive(!officecfg::Office::Recovery::AutoSave::Enabled::isReadOnly());
@@ -503,6 +520,7 @@ void SvxSaveTabPage::Reset( const SfxItemSet* )
m_xDocInfoCB->save_state();
m_xBackupCB->save_state();
+ m_xBackupIntoDocumentFolderCB->save_state();
m_xWarnAlienFormatCB->save_state();
m_xAutoSaveCB->save_state();
m_xAutoSaveEdit->save_value();
@@ -533,6 +551,11 @@ IMPL_LINK(SvxSaveTabPage, AutoClickHdl_Impl, weld::Toggleable&, rBox, void)
}
}
+IMPL_LINK_NOARG(SvxSaveTabPage, BackupClickHdl_Impl, weld::Toggleable&, void)
+{
+ m_xBackupIntoDocumentFolderCB->set_sensitive(m_xBackupCB->get_active());
+}
+
static OUString lcl_ExtracUIName(const Sequence<PropertyValue> &rProperties, std::u16string_view rExtension)
{
OUString sName;
diff --git a/cui/source/options/optsave.hxx b/cui/source/options/optsave.hxx
index 1bc047985330..a4cb7630892a 100644
--- a/cui/source/options/optsave.hxx
+++ b/cui/source/options/optsave.hxx
@@ -46,6 +46,7 @@ private:
std::unique_ptr<weld::CheckButton> m_xLoadDocPrinterCB;
std::unique_ptr<weld::CheckButton> m_xDocInfoCB;
std::unique_ptr<weld::CheckButton> m_xBackupCB;
+ std::unique_ptr<weld::CheckButton> m_xBackupIntoDocumentFolderCB;
std::unique_ptr<weld::CheckButton> m_xAutoSaveCB;
std::unique_ptr<weld::SpinButton> m_xAutoSaveEdit;
std::unique_ptr<weld::Label> m_xMinuteFT;
@@ -61,6 +62,7 @@ private:
std::unique_ptr<weld::Label> m_xODFWarningFT;
DECL_LINK( AutoClickHdl_Impl, weld::Toggleable&, void );
+ DECL_LINK(BackupClickHdl_Impl, weld::Toggleable&, void);
DECL_LINK( FilterHdl_Impl, weld::ComboBox&, void );
DECL_LINK(ODFVersionHdl_Impl, weld::ComboBox&, void );
diff --git a/cui/uiconfig/ui/optsavepage.ui b/cui/uiconfig/ui/optsavepage.ui
index 5e93c38a5856..8ccb0c2948a1 100644
--- a/cui/uiconfig/ui/optsavepage.ui
+++ b/cui/uiconfig/ui/optsavepage.ui
@@ -185,7 +185,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="margin-start">12</property>
+ <property name="margin-start">18</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<child internal-child="accessible">
@@ -215,7 +215,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
</packing>
</child>
<child>
@@ -253,7 +253,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">5</property>
+ <property name="top_attach">6</property>
</packing>
</child>
<child>
@@ -275,6 +275,26 @@
<property name="top_attach">3</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="backupintodocumentfolder">
+ <property name="label" translatable="yes" context="optsavepage|backupintodocumentfolder">Place backup in same folder as document</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="margin-start">18</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="backupintodocumentfolder-atkobject">
+ <property name="AtkObject::accessible-description" translatable="yes" context="optsavepage|backupintodocumentfolder">Specifies if the backup copy should be stored in the same folder as the original document. If not selected, the backup copy is stored in the folder specified in Tools - Options - %PRODUCTNAME - Paths - Backups.</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">4</property>
+ </packing>
+ </child>
</object>
</child>
<child type="label">
diff --git a/include/sfx2/docfile.hxx b/include/sfx2/docfile.hxx
index 15ec85a5f928..e442f39d259a 100644
--- a/include/sfx2/docfile.hxx
+++ b/include/sfx2/docfile.hxx
@@ -250,7 +250,7 @@ public:
SAL_DLLPRIVATE void CanDisposeStorage_Impl( bool bDisposeStorage );
SAL_DLLPRIVATE bool WillDisposeStorageOnClose_Impl();
- SAL_DLLPRIVATE void DoBackup_Impl();
+ SAL_DLLPRIVATE void DoBackup_Impl(bool bForceUsingBackupPath);
SAL_DLLPRIVATE void DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalContent );
SAL_DLLPRIVATE void DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalContent,
std::u16string_view aPrefix,
diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index 86dccda1d4eb..e1d1cbca869c 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -526,7 +526,8 @@ class SvxZoomItem;
// SaveTabPage
#define SID_ATTR_DOCINFO TypedWhichId<SfxBoolItem>(SID_OPTIONS_START + 0)
#define SID_ATTR_BACKUP TypedWhichId<SfxBoolItem>(SID_OPTIONS_START + 1)
-#define SID_ATTR_AUTOSAVE TypedWhichId<SfxBoolItem>(SID_OPTIONS_START + 2)
+#define SID_ATTR_BACKUP_BESIDE_ORIGINAL TypedWhichId<SfxBoolItem>(SID_OPTIONS_START + 2)
+#define SID_ATTR_AUTOSAVE TypedWhichId<SfxBoolItem>(SID_OPTIONS_START + 3)
#define SID_ATTR_USERAUTOSAVE TypedWhichId<SfxBoolItem>(SID_OPTIONS_START + 4)
#define SID_ATTR_AUTOSAVEMINUTE TypedWhichId<SfxUInt16Item>(SID_OPTIONS_START + 5)
#define SID_ATTR_WORKINGSET TypedWhichId<SfxBoolItem>(SID_OPTIONS_START + 13)
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index 2e13f32a1fb3..b0b98d5f8cd4 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -2064,6 +2064,15 @@
</info>
<value>true</value>
</prop>
+ <prop oor:name="BackupIntoDocumentFolder" oor:type="xs:boolean" oor:nillable="false">
+ <!-- UIHints: Tools Options - General Save - [Section] Save -->
+ <info>
+ <desc>Specifies whether to save the backup copy into the same folder
+ as the original document.</desc>
+ <label>Place backup in same folder as document</label>
+ </info>
+ <value>false</value>
+ </prop>
<prop oor:name="EditProperty" oor:type="xs:boolean" oor:nillable="false">
<!-- UIHints: Tools Options - General Save - [Section] Save -->
<info>
diff --git a/sfx2/source/appl/appcfg.cxx b/sfx2/source/appl/appcfg.cxx
index 8b622f6b3e04..9ab34f68cfda 100644
--- a/sfx2/source/appl/appcfg.cxx
+++ b/sfx2/source/appl/appcfg.cxx
@@ -151,6 +151,10 @@ void SfxApplication::GetOptions( SfxItemSet& rSet )
(officecfg::Office::Common::Save::Document::CreateBackup::get() && !comphelper::LibreOfficeKit::isActive()) )))
bRet = false;
break;
+ case SID_ATTR_BACKUP_BESIDE_ORIGINAL:
+ bRet = toSet_ifRW<officecfg::Office::Common::Save::Document::BackupIntoDocumentFolder>(
+ rSet, SID_ATTR_BACKUP_BESIDE_ORIGINAL);
+ break;
case SID_ATTR_PRETTYPRINTING:
bRet = toSet_ifRW<officecfg::Office::Common::Save::Document::PrettyPrinting>(
rSet, SID_ATTR_PRETTYPRINTING);
@@ -328,6 +332,9 @@ void SfxApplication::SetOptions_Impl( const SfxItemSet& rSet )
toCfg_ifSet<officecfg::Office::Common::Save::Document::CreateBackup>(
rSet, SID_ATTR_BACKUP, batch);
+ toCfg_ifSet<officecfg::Office::Common::Save::Document::BackupIntoDocumentFolder>(
+ rSet, SID_ATTR_BACKUP_BESIDE_ORIGINAL, batch);
+
// PrettyPrinting
toCfg_ifSet<officecfg::Office::Common::Save::Document::PrettyPrinting>(
rSet, SID_ATTR_PRETTYPRINTING, batch);
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 0f14c4869207..93573acb827b 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -2641,7 +2641,7 @@ void SfxMedium::DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalCont
}
-void SfxMedium::DoBackup_Impl()
+void SfxMedium::DoBackup_Impl(bool bForceUsingBackupPath)
{
// source file name is the logical name of this medium
INetURLObject aSource( GetURLObject() );
@@ -2651,9 +2651,18 @@ void SfxMedium::DoBackup_Impl()
return;
bool bSuccess = false;
+ bool bOnErrorRetryUsingBackupPath = false;
// get path for backups
- OUString aBakDir = SvtPathOptions().GetBackupPath();
+ OUString aBakDir;
+ if (!bForceUsingBackupPath
+ && officecfg::Office::Common::Save::Document::BackupIntoDocumentFolder::get())
+ {
+ aBakDir = aSource.GetPartBeforeLastName();
+ bOnErrorRetryUsingBackupPath = true;
+ }
+ else
+ aBakDir = SvtPathOptions().GetBackupPath();
if( !aBakDir.isEmpty() )
{
// create content for the parent folder ( = backup folder )
@@ -2695,6 +2704,10 @@ void SfxMedium::DoBackup_Impl()
if ( !bSuccess )
{
+ // in case a webdav server prevents file creation, or a partition is full, or whatever...
+ if (bOnErrorRetryUsingBackupPath)
+ return DoBackup_Impl(/*bForceUsingBackupPath=*/true);
+
pImpl->m_eError = ERRCODE_SFX_CANTCREATEBACKUP;
}
}
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index a7d1eaee766f..bb8007a1abab 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -1246,7 +1246,7 @@ bool SfxObjectShell::SaveTo_Impl
const bool bDoBackup = officecfg::Office::Common::Save::Document::CreateBackup::get() && !comphelper::LibreOfficeKit::isActive();
if ( bDoBackup )
{
- rMedium.DoBackup_Impl();
+ rMedium.DoBackup_Impl(/*bForceUsingBackupPath=*/false);
if ( rMedium.GetError() )
{
SetError(rMedium.GetErrorCode());