tdf#165392 Save as should default to current document directory as well

As done in 3fa39a4dadc8e2777185465a6f7c9968c8cf44d1 for Export,
do the same for "Save as"/"Save a copy" as well.

Change-Id: I5135cff0f74d6673fcfc7fa090ed752bea1d59cb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184542
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
Tested-by: Jenkins
This commit is contained in:
Samuel Mehrbrodt 2025-04-24 11:01:48 +02:00
parent d57d5826db
commit 5683376d06
2 changed files with 6 additions and 9 deletions

View File

@ -449,7 +449,7 @@ service MediaDescriptor
*/ */
[optional,property] string SuggestedSaveAsName; [optional,property] string SuggestedSaveAsName;
/** Directory to be used when exporting (to PDF, epub, ...). /** Directory to be used when saving (save as, save a copy) or exporting (to PDF, epub, ...).
Defaults to the current document directory. Defaults to the current document directory.
*/ */
[optional,property] string ExportDirectory; [optional,property] string ExportDirectory;

View File

@ -954,16 +954,13 @@ bool ModelData_Impl::OutputFileDialog( sal_Int16 nStoreMode,
SfxFilterFlags nMust = getMustFlags( nStoreMode ); SfxFilterFlags nMust = getMustFlags( nStoreMode );
SfxFilterFlags nDont = getDontFlags( nStoreMode ); SfxFilterFlags nDont = getDontFlags( nStoreMode );
weld::Window* pFrameWin = SfxStoringHelper::GetModelWindow(m_xModel); weld::Window* pFrameWin = SfxStoringHelper::GetModelWindow(m_xModel);
OUString sPreselectedDir; OUString sPreselectedDir = GetDocProps().getUnpackedValueOrDefault(
"ExportDirectory", GetDocProps().getUnpackedValueOrDefault("DocumentBaseURL", OUString()));
INetURLObject aObj(sPreselectedDir);
aObj.removeSegment(); // remove file name from URL
sPreselectedDir = aObj.GetMainURL(INetURLObject::DecodeMechanism::NONE);
if ( ( nStoreMode & EXPORT_REQUESTED ) && !( nStoreMode & WIDEEXPORT_REQUESTED ) ) if ( ( nStoreMode & EXPORT_REQUESTED ) && !( nStoreMode & WIDEEXPORT_REQUESTED ) )
{ {
const OUString aBaseUrl = GetDocProps().getUnpackedValueOrDefault("DocumentBaseURL", OUString());
OUString aExportDir = GetDocProps().getUnpackedValueOrDefault("ExportDirectory", aBaseUrl);
INetURLObject aObj( aExportDir );
aObj.removeSegment();
aExportDir = aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
if (!aExportDir.isEmpty())
sPreselectedDir = aExportDir;
if ( ( nStoreMode & PDFEXPORT_REQUESTED ) && !aPreselectedFilterPropsHM.empty() ) if ( ( nStoreMode & PDFEXPORT_REQUESTED ) && !aPreselectedFilterPropsHM.empty() )
{ {
// this is a PDF export // this is a PDF export