diff options
author | Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> | 2021-07-08 05:50:25 +0200 |
---|---|---|
committer | Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> | 2021-07-12 14:31:20 +0200 |
commit | d157c1bd70d630a58db33910d550bb8dee9fe62e (patch) | |
tree | 6a7d4a63cc524fcbbdcdfd8c4271fcbb7cd3c983 /sw | |
parent | c62bb20032cef7479e9293e84a8d57a2c74399d0 (diff) |
tdf#126665 Remember last used file picker directory
This introduces internal tracking of last used directories.
Each caller of the file picker can pass a "context". The selected
directory will then be saved & restored when opening the file picker
with the same context again.
After ffa636ba74b04b3258ec9a696bc4eac33581fa24 , the Windows file picker
no longer tracks the last used directory itself.
This is a replacement and an improvement at the same time, since there is not
one global last used directory, but one per context.
Change-Id: I10650cfb9359922690954fa65c89b4e47477e2c5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118597
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/ui/chrdlg/chardlg.cxx | 1 | ||||
-rw-r--r-- | sw/source/ui/dbui/createaddresslistdialog.cxx | 4 | ||||
-rw-r--r-- | sw/source/ui/dbui/mmdocselectpage.cxx | 3 | ||||
-rw-r--r-- | sw/source/ui/fldui/javaedit.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/misc/glossary.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/app/docsh2.cxx | 6 | ||||
-rw-r--r-- | sw/source/uibase/dbui/dbmgr.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/dbui/mailmergehelper.cxx | 1 | ||||
-rw-r--r-- | sw/source/uibase/uiview/srcview.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/uiview/view2.cxx | 2 |
10 files changed, 11 insertions, 18 deletions
diff --git a/sw/source/ui/chrdlg/chardlg.cxx b/sw/source/ui/chrdlg/chardlg.cxx index f81bfa7c13b3..ab59691668b1 100644 --- a/sw/source/ui/chrdlg/chardlg.cxx +++ b/sw/source/ui/chrdlg/chardlg.cxx @@ -294,6 +294,7 @@ IMPL_LINK_NOARG(SwCharURLPage, InsertFileHdl, weld::Button&, void) { FileDialogHelper aDlgHelper(TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, GetFrameWeld()); + aDlgHelper.SetContext(FileDialogHelper::WriterInsertHyperlink); if( aDlgHelper.Execute() == ERRCODE_NONE ) { const Reference<XFilePicker3>& xFP = aDlgHelper.GetFilePicker(); diff --git a/sw/source/ui/dbui/createaddresslistdialog.cxx b/sw/source/ui/dbui/createaddresslistdialog.cxx index 068a8347cfdb..36803bcde5b6 100644 --- a/sw/source/ui/dbui/createaddresslistdialog.cxx +++ b/sw/source/ui/dbui/createaddresslistdialog.cxx @@ -420,10 +420,8 @@ IMPL_LINK_NOARG(SwCreateAddressListDialog, OkHdl_Impl, weld::Button&, void) { sfx2::FileDialogHelper aDlgHelper(TemplateDescription::FILESAVE_SIMPLE, FileDialogFlags::NONE, m_xDialog.get()); + aDlgHelper.SetContext(sfx2::FileDialogHelper::WriterCreateAddressList); uno::Reference < XFilePicker3 > xFP = aDlgHelper.GetFilePicker(); - - const OUString sPath( SvtPathOptions().SubstituteVariable("$(userurl)/database") ); - aDlgHelper.SetDisplayDirectory( sPath ); xFP->appendFilter( m_sAddressListFilterName, "*.csv" ); xFP->setCurrentFilter( m_sAddressListFilterName ) ; diff --git a/sw/source/ui/dbui/mmdocselectpage.cxx b/sw/source/ui/dbui/mmdocselectpage.cxx index cfed29e5a49d..7e92af1a02ad 100644 --- a/sw/source/ui/dbui/mmdocselectpage.cxx +++ b/sw/source/ui/dbui/mmdocselectpage.cxx @@ -133,10 +133,9 @@ IMPL_LINK(SwMailMergeDocSelectPage, FileSelectHdl, weld::Button&, rButton, void) { sfx2::FileDialogHelper aDlgHelper(TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, m_pWizard->getDialog()); + aDlgHelper.SetContext(sfx2::FileDialogHelper::WriterMailMerge); Reference < XFilePicker3 > xFP = aDlgHelper.GetFilePicker(); - xFP->setDisplayDirectory( SvtPathOptions().GetWorkPath() ); - SfxObjectFactory &rFact = m_pWizard->GetSwView()->GetDocShell()->GetFactory(); SfxFilterMatcher aMatcher( rFact.GetFactoryName() ); SfxFilterMatcherIter aIter( aMatcher ); diff --git a/sw/source/ui/fldui/javaedit.cxx b/sw/source/ui/fldui/javaedit.cxx index 15f2544fa81a..b13c9828d8c5 100644 --- a/sw/source/ui/fldui/javaedit.cxx +++ b/sw/source/ui/fldui/javaedit.cxx @@ -231,7 +231,7 @@ IMPL_LINK_NOARG( SwJavaEditDialog, InsertFileHdl, weld::Button&, void ) ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::Insert, "swriter", SfxFilterFlags::NONE, SfxFilterFlags::NONE, m_xDialog.get())); } - + m_pFileDlg->SetContext(sfx2::FileDialogHelper::WriterInsertScript); m_pFileDlg->StartExecuteModal( LINK( this, SwJavaEditDialog, DlgClosedHdl ) ); } diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx index 75da931ab6bc..e16564a24b59 100644 --- a/sw/source/ui/misc/glossary.cxx +++ b/sw/source/ui/misc/glossary.cxx @@ -563,11 +563,9 @@ IMPL_LINK(SwGlossaryDlg, MenuHdl, const OString&, rItemIdent, void) // call the FileOpenDialog do find WinWord - Files with templates FileDialogHelper aDlgHelper(TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, m_xDialog.get()); + aDlgHelper.SetContext(FileDialogHelper::WriterImportAutotext); uno::Reference < XFilePicker3 > xFP = aDlgHelper.GetFilePicker(); - SvtPathOptions aPathOpt; - xFP->setDisplayDirectory(aPathOpt.GetWorkPath() ); - SfxFilterMatcher aMatcher( SwDocShell::Factory().GetFactoryName() ); SfxFilterMatcherIter aIter( aMatcher ); std::shared_ptr<const SfxFilter> pFilter = aIter.First(); diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx index 30b31f90cdc7..4fa73d0349d7 100644 --- a/sw/source/uibase/app/docsh2.cxx +++ b/sw/source/uibase/app/docsh2.cxx @@ -546,7 +546,6 @@ void SwDocShell::Execute(SfxRequest& rReq) if ( aFileName.isEmpty() ) { - SvtPathOptions aPathOpt; SfxNewFileDialog aNewFileDlg(GetView()->GetFrameWeld(), SfxNewFileDialogMode::LoadTemplate); aNewFileDlg.SetTemplateFlags(nFlags); @@ -555,10 +554,9 @@ void SwDocShell::Execute(SfxRequest& rReq) { FileDialogHelper aDlgHelper(TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, GetView()->GetFrameWeld()); + aDlgHelper.SetContext(FileDialogHelper::WriterLoadTemplate); uno::Reference < XFilePicker3 > xFP = aDlgHelper.GetFilePicker(); - xFP->setDisplayDirectory( aPathOpt.GetWorkPath() ); - SfxObjectFactory &rFact = GetFactory(); SfxFilterMatcher aMatcher( rFact.GetFactoryName() ); SfxFilterMatcherIter aIter( aMatcher ); @@ -671,6 +669,7 @@ void SwDocShell::Execute(SfxRequest& rReq) FileDialogHelper aDlgHelper(TemplateDescription::FILESAVE_AUTOEXTENSION, FileDialogFlags::NONE, GetView()->GetFrameWeld()); + aDlgHelper.SetContext(FileDialogHelper::WriterSaveHTML); aDlgHelper.AddFilter( pHtmlFlt->GetFilterName(), pHtmlFlt->GetDefaultExtension() ); aDlgHelper.SetCurrentFilter( pHtmlFlt->GetFilterName() ); if( ERRCODE_NONE != aDlgHelper.Execute()) @@ -926,6 +925,7 @@ void SwDocShell::Execute(SfxRequest& rReq) FileDialogHelper aDlgHelper(TemplateDescription::FILESAVE_AUTOEXTENSION_TEMPLATE, FileDialogFlags::NONE, GetView()->GetFrameWeld()); + aDlgHelper.SetContext(FileDialogHelper::WriterNewHTMLGlobalDoc); const sal_Int16 nControlIds[] = { CommonFilePickerElementIds::PUSHBUTTON_OK, diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 9aad1ea7ed64..132743c030fd 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -2780,11 +2780,9 @@ OUString ConstructVndSunStarPkgUrl(const OUString& rMainURL, std::u16string_view OUString SwDBManager::LoadAndRegisterDataSource(weld::Window* pParent, SwDocShell* pDocShell) { sfx2::FileDialogHelper aDlgHelper(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, pParent); + aDlgHelper.SetContext(sfx2::FileDialogHelper::WriterRegisterDataSource); uno::Reference < ui::dialogs::XFilePicker3 > xFP = aDlgHelper.GetFilePicker(); - OUString sHomePath(SvtPathOptions().GetWorkPath()); - aDlgHelper.SetDisplayDirectory( sHomePath ); - OUString sFilterAll(SwResId(STR_FILTER_ALL)); OUString sFilterAllData(SwResId(STR_FILTER_ALL_DATA)); OUString sFilterSXB(SwResId(STR_FILTER_SXB)); diff --git a/sw/source/uibase/dbui/mailmergehelper.cxx b/sw/source/uibase/dbui/mailmergehelper.cxx index 17abf70db7c4..4f420bb83079 100644 --- a/sw/source/uibase/dbui/mailmergehelper.cxx +++ b/sw/source/uibase/dbui/mailmergehelper.cxx @@ -59,6 +59,7 @@ OUString CallSaveAsDialog(weld::Window* pParent, OUString& rFilter) ::sfx2::FileDialogHelper aDialog( ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION, FileDialogFlags::NONE, SwDocShell::Factory().GetFactoryName(), SfxFilterFlags::NONE, SfxFilterFlags::NONE, pParent); + aDialog.SetContext(sfx2::FileDialogHelper::WriterMailMergeSaveAs); if (aDialog.Execute()!=ERRCODE_NONE) { diff --git a/sw/source/uibase/uiview/srcview.cxx b/sw/source/uibase/uiview/srcview.cxx index 1754dd11d56b..1a7816c33223 100644 --- a/sw/source/uibase/uiview/srcview.cxx +++ b/sw/source/uibase/uiview/srcview.cxx @@ -268,7 +268,6 @@ void SwSrcView::Execute(SfxRequest& rReq) case SID_SAVEACOPY: case SID_SAVEASDOC: { - SvtPathOptions aPathOpt; // filesave dialog with autoextension FileDialogHelper aDlgHelper( TemplateDescription::FILESAVE_AUTOEXTENSION, @@ -295,7 +294,6 @@ void SwSrcView::Execute(SfxRequest& rReq) xFP->setCurrentFilter( sHtml ) ; } - xFP->setDisplayDirectory( aPathOpt.GetWorkPath() ); if( aDlgHelper.Execute() == ERRCODE_NONE) { SfxMedium aMedium( xFP->getSelectedFiles().getConstArray()[0], diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx index 0e9694534c44..461b9150e59b 100644 --- a/sw/source/uibase/uiview/view2.cxx +++ b/sw/source/uibase/uiview/view2.cxx @@ -311,7 +311,7 @@ bool SwView::InsertGraphicDlg( SfxRequest& rReq ) ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE, FileDialogFlags::Graphic, GetFrameWeld())); pFileDlg->SetTitle(SwResId(STR_INSERT_GRAPHIC )); - pFileDlg->SetContext( FileDialogHelper::SW_INSERT_GRAPHIC ); + pFileDlg->SetContext( FileDialogHelper::WriterInsertImage ); uno::Reference < XFilePicker3 > xFP = pFileDlg->GetFilePicker(); uno::Reference < XFilePickerControlAccess > xCtrlAcc(xFP, UNO_QUERY); |