diff --git a/offapi/com/sun/star/document/MediaDescriptor.idl b/offapi/com/sun/star/document/MediaDescriptor.idl index e6f73d3afdcd..6cf7c8cc870c 100644 --- a/offapi/com/sun/star/document/MediaDescriptor.idl +++ b/offapi/com/sun/star/document/MediaDescriptor.idl @@ -449,7 +449,7 @@ service MediaDescriptor */ [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. */ [optional,property] string ExportDirectory; diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index fe2c519e3fcb..6c346111cc73 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -954,16 +954,13 @@ bool ModelData_Impl::OutputFileDialog( sal_Int16 nStoreMode, SfxFilterFlags nMust = getMustFlags( nStoreMode ); SfxFilterFlags nDont = getDontFlags( nStoreMode ); 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 ) ) { - 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() ) { // this is a PDF export