Rebased ref, commits from common ancestor:
commit 9c12d7f1afca56108cb9b4da6007482f4e29c56d
Author:     Thorsten Behrens <thorsten.behr...@allotropia.de>
AuthorDate: Wed Aug 18 22:48:46 2021 +0200
Commit:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
CommitDate: Wed Nov 24 11:43:17 2021 +0100

    Teach symstore more duplicated DLLs
    
    Amending commit b4dfba947768834ffecc09056992019878711c8b with
    adding the copied DLLs here, too (symstore complains otherwise)
    
    Change-Id: If5cc155cf2fe11b0f97cd152993609fd2c835316
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120686
    Tested-by: Thorsten Behrens <thorsten.behr...@allotropia.de>
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>

diff --git a/bin/symstore.sh b/bin/symstore.sh
index c4e9870c9aa5..2734f1b22a58 100755
--- a/bin/symstore.sh
+++ b/bin/symstore.sh
@@ -16,6 +16,8 @@ EXCLUDE_LIST="python.exe"
 #
 # Same format as for EXCLUDE_LIST above
 MOREPDBS_OKLIST="libcurl.dll
+libcrypto-1_1.dll
+libssl-1_1.dll
 freebl3.dll
 libeay32.dll
 nspr4.dll
commit 60aaa8d43e8afffcd23f9595b7df1798c00ccfb4
Author:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
AuthorDate: Thu Jul 15 16:04:16 2021 +0200
Commit:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
CommitDate: Wed Nov 24 11:43:17 2021 +0100

    Add missing include
    
    Change-Id: Ibd040ea1d6fa750a040b9f3eb87fd34877e56851
    (cherry picked from commit 920fba6c66831929d2f964dce58e04c95978205e)

diff --git a/cui/source/dialogs/SignSignatureLineDialog.cxx 
b/cui/source/dialogs/SignSignatureLineDialog.cxx
index a5a93239f021..7af20b36445a 100644
--- a/cui/source/dialogs/SignSignatureLineDialog.cxx
+++ b/cui/source/dialogs/SignSignatureLineDialog.cxx
@@ -17,6 +17,7 @@
 
 #include <comphelper/graphicmimetype.hxx>
 #include <comphelper/processfactory.hxx>
+#include <sfx2/filedlghelper.hxx>
 #include <sfx2/objsh.hxx>
 #include <svx/xoutbmp.hxx>
 #include <utility>
commit f37e86dd00f5af967dc17ebd1a65b649102ff90f
Author:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
AuthorDate: Tue Jul 13 14:03:44 2021 +0200
Commit:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
CommitDate: Wed Nov 24 11:43:17 2021 +0100

    Related tdf#tdf#126665 Fix image select dialog
    
    Use proper default (work dir, not internal gallery folder)
    
    Change-Id: I3a7a3558274ea066219e2c9f362890d2ab12212e
    (cherry picked from commit e935a98fd40aecb5b24da2eeb3c61ba19a3c6a87)

diff --git a/sfx2/source/appl/opengrf.cxx b/sfx2/source/appl/opengrf.cxx
index 71e46fd3181b..59bf0e13c261 100644
--- a/sfx2/source/appl/opengrf.cxx
+++ b/sfx2/source/appl/opengrf.cxx
@@ -84,6 +84,7 @@ SvxOpenGraphicDialog::SvxOpenGraphicDialog(const OUString& 
rTitle, weld::Window*
     : mpImpl(new SvxOpenGrf_Impl(pPreferredParent, 
ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW))
 {
     mpImpl->aFileDlg.SetTitle(rTitle);
+    mpImpl->aFileDlg.SetContext(sfx2::FileDialogHelper::InsertImage);
 }
 
 SvxOpenGraphicDialog::SvxOpenGraphicDialog(const OUString& rTitle, 
weld::Window* pPreferredParent,
diff --git a/sfx2/source/dialog/filedlghelper.cxx 
b/sfx2/source/dialog/filedlghelper.cxx
index b8b4b7ae133e..c8cf432ecac5 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -2198,7 +2198,7 @@ void FileDialogHelper_Impl::loadConfig()
         }
 
         if ( maPath.isEmpty() )
-            displayFolder( SvtPathOptions().GetGraphicPath() );
+            displayFolder( SvtPathOptions().GetWorkPath() );
     }
     else
     {
commit f93e8146a2d6389b7bfffd0f88f6fc54dace9533
Author:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
AuthorDate: Thu Jul 8 05:50:25 2021 +0200
Commit:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
CommitDate: Wed Nov 24 11:43:17 2021 +0100

    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.tie...@documentfoundation.org>
    Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
    (cherry picked from commit d157c1bd70d630a58db33910d550bb8dee9fe62e)
    (cherry picked from commit 30546bf6dc9bb62ba21e39da3078c254e058df52)

diff --git a/avmedia/source/viewer/mediawindow.cxx 
b/avmedia/source/viewer/mediawindow.cxx
index 0807de0f5a45..4ff32f636eb6 100644
--- a/avmedia/source/viewer/mediawindow.cxx
+++ b/avmedia/source/viewer/mediawindow.cxx
@@ -215,6 +215,7 @@ bool MediaWindow::executeMediaURLDialog(weld::Window* 
pParent, OUString& rURL, b
     static const char               aSeparator[] = ";";
     OUStringBuffer                  aAllTypes;
 
+    aDlg.SetContext(sfx2::FileDialogHelper::InsertMedia);
     aDlg.SetTitle( AvmResId( o_pbLink != nullptr
                 ? AVMEDIA_STR_INSERTMEDIA_DLG : AVMEDIA_STR_OPENMEDIA_DLG ) );
 
diff --git a/basctl/source/basicide/moduldl2.cxx 
b/basctl/source/basicide/moduldl2.cxx
index 168f4ff64ebc..3f45507b6e37 100644
--- a/basctl/source/basicide/moduldl2.cxx
+++ b/basctl/source/basicide/moduldl2.cxx
@@ -549,6 +549,7 @@ void LibPage::InsertLib()
     Reference< uno::XComponentContext > xContext( 
::comphelper::getProcessComponentContext() );
     // file open dialog
     sfx2::FileDialogHelper 
aDlg(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, 
m_pDialog->getDialog());
+    aDlg.SetContext(sfx2::FileDialogHelper::BasicInsertLib);
     const Reference <XFilePicker3>& xFP = aDlg.GetFilePicker();
 
     xFP->setTitle(IDEResId(RID_STR_APPENDLIBS));
@@ -568,16 +569,6 @@ void LibPage::InsertLib()
               ";*.sti;*.otp"             // presentation template
               ";*.sxm;*.odf" );          // formula
 
-    // set display directory and filter
-    OUString aPath(GetExtraData()->GetAddLibPath());
-    if ( !aPath.isEmpty() )
-        xFP->setDisplayDirectory( aPath );
-    else
-    {
-        // macro path from configuration management
-        xFP->setDisplayDirectory( SvtPathOptions().GetWorkPath() );
-    }
-
     OUString aLastFilter(GetExtraData()->GetAddLibFilter());
     if ( !aLastFilter.isEmpty() )
         xFP->setCurrentFilter( aLastFilter );
@@ -1010,6 +1001,7 @@ void LibPage::ExportAsPackage( const OUString& aLibName )
 {
     // file open dialog
     sfx2::FileDialogHelper 
aDlg(ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, FileDialogFlags::NONE, 
m_pDialog->getDialog());
+    aDlg.SetContext(sfx2::FileDialogHelper::BasicExportPackage);
     const Reference <XFilePicker3>& xFP = aDlg.GetFilePicker();
 
     Reference< uno::XComponentContext > xContext( 
::comphelper::getProcessComponentContext() );
@@ -1022,17 +1014,6 @@ void LibPage::ExportAsPackage( const OUString& aLibName )
     OUString aTitle(IDEResId(RID_STR_PACKAGE_BUNDLE));
     xFP->appendFilter( aTitle, "*.oxt" ); // library files
 
-    // set display directory and filter
-    OUString aPath = GetExtraData()->GetAddLibPath();
-    if ( !aPath.isEmpty() )
-    {
-        xFP->setDisplayDirectory( aPath );
-    }
-    else
-    {
-        // macro path from configuration management
-        xFP->setDisplayDirectory( SvtPathOptions().GetWorkPath() );
-    }
     xFP->setCurrentFilter( aTitle );
 
     if ( xFP->execute() != RET_OK )
diff --git a/cui/source/customize/acccfg.cxx b/cui/source/customize/acccfg.cxx
index 7a7965c903eb..d850da88f70b 100644
--- a/cui/source/customize/acccfg.cxx
+++ b/cui/source/customize/acccfg.cxx
@@ -1463,6 +1463,7 @@ void 
SfxAcceleratorConfigPage::StartFileDialog(StartFileDialogType nType, const
     m_pFileDlg->AddFilter(aFilterAllStr, FILEDIALOG_FILTER_ALL);
     m_pFileDlg->AddFilter(aFilterCfgStr, "*.cfg");
     m_pFileDlg->SetCurrentFilter(aFilterCfgStr);
+    m_pFileDlg->SetContext(sfx2::FileDialogHelper::AcceleratorConfig);
 
     Link<sfx2::FileDialogHelper*, void> aDlgClosedLink
         = bSave ? LINK(this, SfxAcceleratorConfigPage, SaveHdl)
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 25f973016043..57f6a467bc43 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -2874,6 +2874,7 @@ IMPL_LINK_NOARG(SvxIconSelectorDialog, ImportHdl, 
weld::Button&, void)
     sfx2::FileDialogHelper aImportDialog(
         css::ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW,
         FileDialogFlags::Graphic | FileDialogFlags::MultiSelection, 
m_xDialog.get());
+    aImportDialog.SetContext(sfx2::FileDialogHelper::IconImport);
 
     // disable the link checkbox in the dialog
     uno::Reference< css::ui::dialogs::XFilePickerControlAccess >
diff --git a/cui/source/dialogs/SignSignatureLineDialog.cxx 
b/cui/source/dialogs/SignSignatureLineDialog.cxx
index 58a4fd317065..a5a93239f021 100644
--- a/cui/source/dialogs/SignSignatureLineDialog.cxx
+++ b/cui/source/dialogs/SignSignatureLineDialog.cxx
@@ -121,8 +121,10 @@ 
SignSignatureLineDialog::SignSignatureLineDialog(weld::Widget* pParent, Referenc
 IMPL_LINK_NOARG(SignSignatureLineDialog, loadImage, weld::Button&, void)
 {
     Reference<XComponentContext> xContext = 
comphelper::getProcessComponentContext();
-    Reference<XFilePicker3> xFilePicker
-        = FilePicker::createWithMode(xContext, 
TemplateDescription::FILEOPEN_PREVIEW);
+    sfx2::FileDialogHelper aHelper(TemplateDescription::FILEOPEN_PREVIEW, 
FileDialogFlags::NONE,
+                                   m_xDialog.get());
+    aHelper.SetContext(sfx2::FileDialogHelper::SignatureLine);
+    Reference<XFilePicker3> xFilePicker = aHelper.GetFilePicker();
     if (!xFilePicker->execute())
         return;
 
diff --git a/cui/source/dialogs/insdlg.cxx b/cui/source/dialogs/insdlg.cxx
index 29c8d7cfb081..7e411d3c021d 100644
--- a/cui/source/dialogs/insdlg.cxx
+++ b/cui/source/dialogs/insdlg.cxx
@@ -85,6 +85,7 @@ IMPL_LINK_NOARG(SvInsertOleDlg, DoubleClickHdl, 
weld::TreeView&, bool)
 IMPL_LINK_NOARG(SvInsertOleDlg, BrowseHdl, weld::Button&, void)
 {
     sfx2::FileDialogHelper 
aHelper(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 
FileDialogFlags::NONE, m_xDialog.get());
+    aHelper.SetContext(sfx2::FileDialogHelper::InsertOLE);
     const Reference< XFilePicker3 >& xFilePicker = aHelper.GetFilePicker();
 
     // add filter
diff --git a/cui/source/dialogs/screenshotannotationdlg.cxx 
b/cui/source/dialogs/screenshotannotationdlg.cxx
index 4f02452a8ad7..4a93d7b16aad 100644
--- a/cui/source/dialogs/screenshotannotationdlg.cxx
+++ b/cui/source/dialogs/screenshotannotationdlg.cxx
@@ -282,6 +282,7 @@ IMPL_LINK_NOARG(ScreenshotAnnotationDlg_Impl, 
saveButtonHandler, weld::Button&,
 
     auto xFileDlg = 
std::make_unique<sfx2::FileDialogHelper>(ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,
                                                              
FileDialogFlags::NONE, mpParentWindow);
+    xFileDlg->SetContext(sfx2::FileDialogHelper::ScreenshotAnnotation);
 
     const uno::Reference< ui::dialogs::XFilePicker3 > xFilePicker = 
xFileDlg->GetFilePicker();
 
diff --git a/cui/source/options/optjava.cxx b/cui/source/options/optjava.cxx
index c074c9cf1ccb..9fee60e21872 100644
--- a/cui/source/options/optjava.cxx
+++ b/cui/source/options/optjava.cxx
@@ -780,15 +780,15 @@ IMPL_LINK_NOARG(SvxJavaClassPathDlg, AddArchiveHdl_Impl, 
weld::Button&, void)
     sfx2::FileDialogHelper aDlg(TemplateDescription::FILEOPEN_SIMPLE, 
FileDialogFlags::NONE, m_xDialog.get());
     aDlg.SetTitle( CuiResId( RID_SVXSTR_ARCHIVE_TITLE ) );
     aDlg.AddFilter( CuiResId( RID_SVXSTR_ARCHIVE_HEADLINE ), "*.jar;*.zip" );
+    aDlg.SetContext(sfx2::FileDialogHelper::JavaClassPath);
     OUString sFolder;
     if (m_xPathList->count_selected_rows() > 0)
     {
         
osl::FileBase::getFileURLFromSystemPath(m_xPathList->get_selected_text(), 
sFolder);
             // best effort
     }
-    if (sFolder.isEmpty())
-         sFolder = SvtPathOptions().GetWorkPath();
-    aDlg.SetDisplayDirectory( sFolder );
+    if (!sFolder.isEmpty())
+        aDlg.SetDisplayDirectory( sFolder );
     if ( aDlg.Execute() == ERRCODE_NONE )
     {
         OUString sURL = aDlg.GetPath();
diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx
index 5cad832dba79..2546eb0582d5 100644
--- a/cui/source/tabpages/numpages.cxx
+++ b/cui/source/tabpages/numpages.cxx
@@ -910,6 +910,7 @@ IMPL_LINK_NOARG(SvxBitmapPickTabPage, DoubleClickHdl_Impl, 
ValueSet*, void)
 IMPL_LINK_NOARG(SvxBitmapPickTabPage, ClickAddBrowseHdl_Impl, weld::Button&, 
void)
 {
     sfx2::FileDialogHelper aFileDialog(0, FileDialogFlags::NONE, 
GetFrameWeld());
+    aFileDialog.SetContext(sfx2::FileDialogHelper::BulletsAddImage);
     aFileDialog.SetTitle(CuiResId(RID_SVXSTR_ADD_IMAGE));
     if ( aFileDialog.Execute() != ERRCODE_NONE )
         return;
diff --git a/dbaccess/source/ui/app/AppController.cxx 
b/dbaccess/source/ui/app/AppController.cxx
index d2fd90d9ad7d..b704fdca97a9 100644
--- a/dbaccess/source/ui/app/AppController.cxx
+++ b/dbaccess/source/ui/app/AppController.cxx
@@ -1078,13 +1078,13 @@ void OApplicationController::Execute(sal_uInt16 _nId, 
const Sequence< PropertyVa
                     OUString sUrl;
                     if ( m_xModel.is() )
                         sUrl = m_xModel->getURL();
-                    if ( sUrl.isEmpty() )
-                        sUrl = SvtPathOptions().GetWorkPath();
 
                     ::sfx2::FileDialogHelper aFileDlg(
                         
ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,
                         FileDialogFlags::NONE, getFrameWeld());
-                    aFileDlg.SetDisplayDirectory( sUrl );
+                    aFileDlg.SetContext(sfx2::FileDialogHelper::BaseSaveAs);
+                    if (!sUrl.isEmpty())
+                        aFileDlg.SetDisplayDirectory( sUrl );
 
                     std::shared_ptr<const SfxFilter> pFilter = 
getStandardDatabaseFilter();
                     if ( pFilter )
diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx 
b/dbaccess/source/ui/dlg/dbwizsetup.cxx
index 1d9f89c8791f..7707408f4288 100644
--- a/dbaccess/source/ui/dlg/dbwizsetup.cxx
+++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx
@@ -772,15 +772,14 @@ bool ODbTypeWizDialogSetup::SaveDatabaseDocument()
         ::sfx2::FileDialogHelper aFileDlg(
                 ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,
                 FileDialogFlags::NONE, m_xAssistant.get());
+        aFileDlg.SetContext(sfx2::FileDialogHelper::BaseSaveAs);
         std::shared_ptr<const SfxFilter> pFilter = getStandardDatabaseFilter();
         if ( pFilter )
         {
-            INetURLObject aWorkURL( m_sWorkPath );
-            aFileDlg.SetDisplayFolder( aWorkURL.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ));
-
             OUString sDefaultName = DBA_RES( STR_DATABASEDEFAULTNAME );
             OUString sExtension = pFilter->GetDefaultExtension();
             sDefaultName += sExtension.replaceAt( 0, 1, OUString() );
+            INetURLObject aWorkURL( m_sWorkPath );
             aWorkURL.Append( sDefaultName );
             sDefaultName = createUniqueFileName( aWorkURL );
             aFileDlg.SetFileName( sDefaultName );
diff --git a/dbaccess/source/ui/dlg/generalpage.cxx 
b/dbaccess/source/ui/dlg/generalpage.cxx
index da41b8984d6f..27eb77dc78ab 100644
--- a/dbaccess/source/ui/dlg/generalpage.cxx
+++ b/dbaccess/source/ui/dlg/generalpage.cxx
@@ -664,6 +664,7 @@ namespace dbaui
         ::sfx2::FileDialogHelper aFileDlg(
                 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
                 FileDialogFlags::NONE, "sdatabase", SfxFilterFlags::NONE, 
SfxFilterFlags::NONE, GetFrameWeld());
+        aFileDlg.SetContext(sfx2::FileDialogHelper::BaseDataSource);
         std::shared_ptr<const SfxFilter> pFilter = getStandardDatabaseFilter();
         if ( pFilter )
         {
diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx 
b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
index 8b3f5099a083..2941d42668ac 100644
--- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx
+++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
@@ -613,12 +613,10 @@ bool ExtMgrDialog::acceptLicense( const uno::Reference< 
deployment::XPackage > &
 uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker()
 {
     sfx2::FileDialogHelper 
aDlgHelper(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 
FileDialogFlags::NONE, m_xDialog.get());
+    aDlgHelper.SetContext(sfx2::FileDialogHelper::ExtensionManager);
     const uno::Reference<ui::dialogs::XFilePicker3>& xFilePicker = 
aDlgHelper.GetFilePicker();
     xFilePicker->setTitle( m_sAddPackages );
 
-    if ( !m_sLastFolderURL.isEmpty() )
-        xFilePicker->setDisplayDirectory( m_sLastFolderURL );
-
     // collect and set filter list:
     typedef std::map< OUString, OUString > t_string2string;
     t_string2string title2filter;
@@ -673,7 +671,6 @@ uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker()
     if ( xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK )
         return uno::Sequence<OUString>(); // cancelled
 
-    m_sLastFolderURL = xFilePicker->getDisplayDirectory();
     uno::Sequence< OUString > files( xFilePicker->getSelectedFiles() );
     OSL_ASSERT( files.hasElements() );
     return files;
diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.hxx 
b/desktop/source/deployment/gui/dp_gui_dialog2.hxx
index 70e7626435a4..921b6f050b96 100644
--- a/desktop/source/deployment/gui/dp_gui_dialog2.hxx
+++ b/desktop/source/deployment/gui/dp_gui_dialog2.hxx
@@ -91,7 +91,6 @@ class ExtMgrDialog : public weld::GenericDialogController
 {
     const OUString       m_sAddPackages;
     OUString             m_sProgressText;
-    OUString             m_sLastFolderURL;
     ::osl::Mutex         m_aMutex;
     bool                 m_bHasProgress;
     bool                 m_bProgressChanged;
diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx 
b/extensions/source/propctrlr/formcomponenthandler.cxx
index 5631014ef211..3b02a1c7bdb7 100644
--- a/extensions/source/propctrlr/formcomponenthandler.cxx
+++ b/extensions/source/propctrlr/formcomponenthandler.cxx
@@ -2749,7 +2749,7 @@ namespace pcr
         ::sfx2::FileDialogHelper aFileDlg(
                 ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW,
                 FileDialogFlags::Graphic, pWin);
-
+        aFileDlg.SetContext(sfx2::FileDialogHelper::FormsInsertImage);
         aFileDlg.SetTitle(aStrTrans);
         // non-linked images ( e.g. those located in the document
         // stream ) only if document is available
diff --git a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx 
b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx
index c06a9ec1b5cc..41074c12aee1 100644
--- a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx
+++ b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx
@@ -847,6 +847,7 @@ void XMLFilterSettingsDialog::onSave()
     ::sfx2::FileDialogHelper aDlg(
         css::ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,
         FileDialogFlags::NONE, m_xDialog.get());
+    aDlg.SetContext(sfx2::FileDialogHelper::XMLFilterSettings);
 
     OUString aExtensions( "*.jar" );
     OUString aFilterName = XsltResId(STR_FILTER_PACKAGE) +
@@ -892,6 +893,7 @@ void XMLFilterSettingsDialog::onOpen()
     ::sfx2::FileDialogHelper aDlg(
     css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
     FileDialogFlags::NONE, m_xDialog.get());
+    aDlg.SetContext(sfx2::FileDialogHelper::XMLFilterSettings);
 
     OUString aExtensions( "*.jar" );
     OUString aFilterName = XsltResId(STR_FILTER_PACKAGE) +
diff --git a/forms/source/component/ImageControl.cxx 
b/forms/source/component/ImageControl.cxx
index 857c25a29ba3..f072f5929605 100644
--- a/forms/source/component/ImageControl.cxx
+++ b/forms/source/component/ImageControl.cxx
@@ -774,6 +774,7 @@ bool OImageControlControl::implInsertGraphics()
         Reference< XWindow > xWindow( static_cast< ::cppu::OWeakObject* >( 
this ), UNO_QUERY );
         ::sfx2::FileDialogHelper 
aDialog(TemplateDescription::FILEOPEN_LINK_PREVIEW, FileDialogFlags::Graphic,
                                          Application::GetFrameWeld(xWindow));
+        aDialog.SetContext(sfx2::FileDialogHelper::FormsInsertImage);
         aDialog.SetTitle( sTitle );
 
         Reference< XFilePickerControlAccess > xController( 
aDialog.GetFilePicker(), UNO_QUERY_THROW );
diff --git a/include/sfx2/filedlghelper.hxx b/include/sfx2/filedlghelper.hxx
index 4700d9c8173d..b0ad63bd799e 100644
--- a/include/sfx2/filedlghelper.hxx
+++ b/include/sfx2/filedlghelper.hxx
@@ -72,14 +72,64 @@ class FileDialogHelper_Impl;
 class SFX2_DLLPUBLIC FileDialogHelper
 {
 public:
-    enum Context                        // context where the FileDialogHelper 
is used
+    // context where the FileDialogHelper is used
+    enum Context
     {
-        UNKNOWN_CONTEXT,                // unknown context
-        SW_INSERT_GRAPHIC,              // insert graphic in writer
-        SD_EXPORT,                      // export in draw
-        SI_EXPORT,                      // export in impress
-        SW_EXPORT                       // export in writer
+        UnknownContext,
+        AcceleratorConfig,
+        AutoRedact,
+        BaseDataSource,
+        BaseSaveAs,
+        BasicExportPackage,
+        BasicInsertLib,
+        BulletsAddImage,
+        ExtensionManager,
+        CalcDataProvider,
+        CalcDataStream,
+        CalcExport,
+        CalcSaveAs,
+        CalcXMLSource,
+        DrawExport,
+        DrawImpressInsertFile,
+        DrawImpressOpenSound,
+        DrawSaveAs,
+        ExportImage,
+        FormsAddInstance,
+        FormsInsertImage,
+        IconImport,
+        ImpressClickAction,
+        ImpressExport,
+        ImpressPhotoDialog,
+        ImpressSaveAs,
+        LinkClientOLE,
+        LinkClientFile,
+        ImageMap,
+        InsertDoc,
+        InsertImage,
+        InsertMedia,
+        InsertOLE,
+        JavaClassPath,
+        ReportInsertImage,
+        ScreenshotAnnotation,
+        SignatureLine,
+        TemplateImport,
+        WriterCreateAddressList,
+        WriterInsertDoc,
+        WriterInsertImage,
+        WriterInsertScript,
+        WriterExport,
+        WriterImportAutotext,
+        WriterInsertHyperlink,
+        WriterLoadTemplate,
+        WriterMailMerge,
+        WriterMailMergeSaveAs,
+        WriterNewHTMLGlobalDoc,
+        WriterRegisterDataSource,
+        WriterSaveAs,
+        WriterSaveHTML,
+        XMLFilterSettings
     };
+    static OUString contextToString(Context context);
 
 private:
     Link<FileDialogHelper*,void>  m_aDialogClosedLink;
@@ -211,6 +261,8 @@ public:
     void                    CreateMatcher( const OUString& rName );
 
     /** sets the context of the dialog and trigger necessary actions e.g. 
loading config, setting help id
+        This will also store the last used directory for this context, so that 
the last directory
+        gets preselected on next filepicker launch (with the same context)
         @param _eNewContext
             New context for the dialog.
     */
diff --git a/officecfg/registry/data/org/openoffice/Office/Impress.xcu 
b/officecfg/registry/data/org/openoffice/Office/Impress.xcu
index b8323973c891..112a89e8521f 100644
--- a/officecfg/registry/data/org/openoffice/Office/Impress.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/Impress.xcu
@@ -200,9 +200,4 @@
       <value>$(work)</value>
     </prop>
   </node>
-  <node oor:name="Sound" oor:op="fuse">
-    <prop oor:name="Path">
-      <value>$(work)</value>
-    </prop>
-  </node>
 </oor:component-data>
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs 
b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index 56954ead6ffb..b5cc8182eb46 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -844,6 +844,16 @@
         <value/>
       </prop>
     </group>
+    <group oor:name="LastDirectory">
+      <info>
+        <desc>Stores the last selected directory for the filepicker for 
different contexts.</desc>
+      </info>
+      <prop oor:name="LastPath" oor:type="xs:string" oor:nillable="false">
+        <info>
+          <desc>The last used path for this context (context is the name of 
the parent node)</desc>
+        </info>
+      </prop>
+    </group>
   </templates>
   <component>
     <group oor:name="VCL">
@@ -5898,6 +5908,11 @@
           <desc>URL of the last used service in the remote file picker.</desc>
         </info>
       </prop>
+      <set oor:name="FilePickerLastDirectory" oor:node-type="LastDirectory">
+        <info>
+          <desc>Contains the last used directory for the filepicker for 
various contexts</desc>
+        </info>
+      </set>
       <prop oor:name="CmisServersUrls" oor:type="oor:string-list" 
oor:nillable="false">
         <info>
           <desc>List of sample URLs of the CMIS servers in the place edition 
dialog.</desc>
diff --git a/officecfg/registry/schema/org/openoffice/Office/Impress.xcs 
b/officecfg/registry/schema/org/openoffice/Office/Impress.xcs
index d8edf33b8c12..83d43c360a83 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Impress.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Impress.xcs
@@ -1644,19 +1644,5 @@
         <value>$(work)</value>
       </prop>
     </group>
-    <group oor:name="Sound">
-      <info>
-        <desc>Contains configuration items for Sound related functions.</desc>
-      </info>
-      <prop oor:name="Path" oor:type="xs:string" oor:nillable="false">
-        <info>
-          <desc>
-            Access path, where sounds were loaded last time.
-            The default is work directory.
-          </desc>
-        </info>
-        <value>$(work)</value>
-      </prop>
-    </group>
   </component>
 </oor:component-schema>
diff --git a/reportdesign/source/ui/report/ReportController.cxx 
b/reportdesign/source/ui/report/ReportController.cxx
index e08bc607b6ca..6fb716f73336 100644
--- a/reportdesign/source/ui/report/ReportController.cxx
+++ b/reportdesign/source/ui/report/ReportController.cxx
@@ -2997,6 +2997,7 @@ void OReportController::insertGraphic()
     {
         uno::Reference< report::XSection> xSection = 
getDesignView()->getCurrentSection();
         ::sfx2::FileDialogHelper 
aDialog(ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW, 
FileDialogFlags::Graphic, getFrameWeld());
+        aDialog.SetContext(sfx2::FileDialogHelper::ReportInsertImage);
         aDialog.SetTitle( sTitle );
 
         uno::Reference< ui::dialogs::XFilePickerControlAccess > 
xController(aDialog.GetFilePicker(), UNO_QUERY_THROW);
diff --git a/sc/source/ui/miscdlgs/datastreamdlg.cxx 
b/sc/source/ui/miscdlgs/datastreamdlg.cxx
index a713b9723a3e..cd03a3e66c53 100644
--- a/sc/source/ui/miscdlgs/datastreamdlg.cxx
+++ b/sc/source/ui/miscdlgs/datastreamdlg.cxx
@@ -51,6 +51,7 @@ DataStreamDlg::~DataStreamDlg() {}
 IMPL_LINK_NOARG(DataStreamDlg, BrowseHdl, weld::Button&, void)
 {
     sfx2::FileDialogHelper aFileDialog(0, FileDialogFlags::NONE, 
m_xDialog.get());
+    aFileDialog.SetContext(sfx2::FileDialogHelper::CalcDataStream);
     if (aFileDialog.Execute() != ERRCODE_NONE)
         return;
 
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx 
b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index edc8ca3d5dcb..0bbfa9d200b8 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -163,21 +163,16 @@ void ScXMLSourceDlg::SelectSourceFile()
 {
     sfx2::FileDialogHelper 
aDlgHelper(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
                                       FileDialogFlags::NONE, m_xDialog.get());
+    aDlgHelper.SetContext(sfx2::FileDialogHelper::CalcXMLSource);
 
     uno::Reference<ui::dialogs::XFilePicker3> xFilePicker = 
aDlgHelper.GetFilePicker();
 
-    if (maSrcPath.isEmpty())
-        // Use default path.
-        xFilePicker->setDisplayDirectory(SvtPathOptions().GetWorkPath());
-    else
-    {
-        // Use the directory of current source file.
-        INetURLObject aURL(maSrcPath);
-        aURL.removeSegment();
-        aURL.removeFinalSlash();
-        OUString aPath = aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE);
-        xFilePicker->setDisplayDirectory(aPath);
-    }
+    // Use the directory of current source file.
+    INetURLObject aURL(maSrcPath);
+    aURL.removeSegment();
+    aURL.removeFinalSlash();
+    OUString aPath = aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE);
+    xFilePicker->setDisplayDirectory(aPath);
 
     if (xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK)
         // File picker dialog cancelled.
diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.cxx 
b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
index 14e43dd75229..9c00afe4cdc4 100644
--- a/sd/source/ui/dlg/PhotoAlbumDialog.cxx
+++ b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
@@ -20,7 +20,6 @@
 
 #include <unotools/pathoptions.hxx>
 #include <unotools/ucbstreamhelper.hxx>
-#include <officecfg/Office/Impress.hxx>
 #include <vcl/graphicfilter.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/weld.hxx>
@@ -500,35 +499,16 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, FileHdl, 
weld::Button&, void)
     ::sfx2::FileDialogHelper aDlg(
         css::ui::dialogs::TemplateDescription::FILEOPEN_PREVIEW,
         FileDialogFlags::Graphic | FileDialogFlags::MultiSelection, 
m_xDialog.get());
-    // Read configuration
-    OUString sUrl(officecfg::Office::Impress::Pictures::Path::get());
-
-    INetURLObject aFile( SvtPathOptions().GetUserConfigPath() );
-    if (!sUrl.isEmpty())
-        aDlg.SetDisplayDirectory(sUrl);
-    else
-        aDlg.SetDisplayDirectory( aFile.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ) );
+    aDlg.SetContext(sfx2::FileDialogHelper::ImpressPhotoDialog);
 
     if ( aDlg.Execute() == ERRCODE_NONE )
     {
         const Sequence< OUString > aFilesArr = aDlg.GetSelectedFiles();
-        if( aFilesArr.hasElements() )
+        for ( const auto& rFile : aFilesArr )
         {
-            sUrl = aDlg.GetDisplayDirectory();
-            // Write out configuration
-            {
-                std::shared_ptr< comphelper::ConfigurationChanges > batch(
-                    comphelper::ConfigurationChanges::create());
-                officecfg::Office::Impress::Pictures::Path::set(sUrl, batch);
-                batch->commit();
-            }
-
-            for ( const auto& rFile : aFilesArr )
-            {
-                // Store full path, show filename only. Use INetURLObject to 
display spaces in filename correctly
-                INetURLObject aUrl(rFile);
-                
m_xImagesLst->append(aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE), 
aUrl.GetLastName(INetURLObject::DecodeMechanism::WithCharset), "");
-            }
+            // Store full path, show filename only. Use INetURLObject to 
display spaces in filename correctly
+            INetURLObject aUrl(rFile);
+            
m_xImagesLst->append(aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE), 
aUrl.GetLastName(INetURLObject::DecodeMechanism::WithCharset), "");
         }
     }
     EnableDisableButtons();
diff --git a/sd/source/ui/dlg/filedlg.cxx b/sd/source/ui/dlg/filedlg.cxx
index 05c4243dc539..a545f6dc946f 100644
--- a/sd/source/ui/dlg/filedlg.cxx
+++ b/sd/source/ui/dlg/filedlg.cxx
@@ -34,7 +34,6 @@
 #include <filedlg.hxx>
 #include <sdresid.hxx>
 #include <strings.hrc>
-#include <officecfg/Office/Impress.hxx>
 
 // -----------      SdFileDialog_Imp        ---------------------------
 
@@ -214,6 +213,7 @@ SdOpenSoundFileDialog::SdOpenSoundFileDialog(weld::Window 
*pParent)
 {
     OUString aDescr = SdResId(STR_ALL_FILES);
     mpImpl->AddFilter( aDescr, "*.*");
+    mpImpl->SetContext(sfx2::FileDialogHelper::DrawImpressOpenSound);
 
     // setup filter
 #if defined UNX
@@ -233,9 +233,6 @@ SdOpenSoundFileDialog::SdOpenSoundFileDialog(weld::Window 
*pParent)
     aDescr = SdResId(STR_MIDI_FILE);
     mpImpl->AddFilter( aDescr, "*.mid" );
 #endif
-
-    // Restore last selected path
-    
mpImpl->SetDisplayDirectory(officecfg::Office::Impress::Sound::Path::get());
 }
 
 SdOpenSoundFileDialog::~SdOpenSoundFileDialog()
@@ -249,12 +246,6 @@ ErrCode SdOpenSoundFileDialog::Execute()
 
 OUString SdOpenSoundFileDialog::GetPath() const
 {
-    // Save last selected path
-    std::shared_ptr<comphelper::ConfigurationChanges> batch(
-        comphelper::ConfigurationChanges::create());
-    officecfg::Office::Impress::Sound::Path::set(mpImpl->GetPath(), batch);
-    batch->commit();
-
     return mpImpl->GetPath();
 }
 
diff --git a/sd/source/ui/dlg/tpaction.cxx b/sd/source/ui/dlg/tpaction.cxx
index 63fd24cb91aa..4cd0cf68af9d 100644
--- a/sd/source/ui/dlg/tpaction.cxx
+++ b/sd/source/ui/dlg/tpaction.cxx
@@ -401,11 +401,7 @@ void SdTPAction::OpenFileDialog()
             sfx2::FileDialogHelper aFileDialog(
                 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
                 FileDialogFlags::NONE, GetFrameWeld());
-
-            if (bDocument && aFile.isEmpty())
-                aFile = SvtPathOptions().GetWorkPath();
-
-            aFileDialog.SetDisplayDirectory( aFile );
+            aFileDialog.SetContext(sfx2::FileDialogHelper::ImpressClickAction);
 
             // The following is a workaround for #i4306#:
             // The addition of the implicitly existing "all files"
diff --git a/sd/source/ui/func/fuinsfil.cxx b/sd/source/ui/func/fuinsfil.cxx
index ff890dfb5ec7..aec950b0c779 100644
--- a/sd/source/ui/func/fuinsfil.cxx
+++ b/sd/source/ui/func/fuinsfil.cxx
@@ -133,6 +133,7 @@ void FuInsertFile::DoExecute( SfxRequest& rReq )
         sfx2::FileDialogHelper      aFileDialog(
                 ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
                 FileDialogFlags::Insert, mpWindow ? mpWindow->GetFrameWeld() : 
nullptr);
+        aFileDialog.SetContext(sfx2::FileDialogHelper::DrawImpressInsertFile);
         Reference< XFilePicker >    xFilePicker( aFileDialog.GetFilePicker() );
         Reference< XFilterManager > xFilterManager( xFilePicker, UNO_QUERY );
         OUString aOwnCont;
diff --git a/sfx2/source/appl/fileobj.cxx b/sfx2/source/appl/fileobj.cxx
index ebfe57edf2a3..f58ffe086770 100644
--- a/sfx2/source/appl/fileobj.cxx
+++ b/sfx2/source/appl/fileobj.cxx
@@ -292,6 +292,7 @@ void SvFileObject::Edit(weld::Window* pParent, 
sfx2::SvBaseLink* pLink, const Li
 
             ::sfx2::FileDialogHelper & rFileDlg =
                 pLink->GetInsertFileDialog( OUString() );
+            rFileDlg.SetContext(sfx2::FileDialogHelper::LinkClientOLE);
             rFileDlg.StartExecuteModal(
                     LINK( this, SvFileObject, DialogClosedHdl ) );
         }
@@ -308,6 +309,7 @@ void SvFileObject::Edit(weld::Window* pParent, 
sfx2::SvBaseLink* pLink, const Li
 
             ::sfx2::FileDialogHelper & rFileDlg =
                 pLink->GetInsertFileDialog(sFactory);
+            rFileDlg.SetContext(sfx2::FileDialogHelper::LinkClientFile);
             rFileDlg.StartExecuteModal(
                     LINK( this, SvFileObject, DialogClosedHdl ) );
         }
diff --git a/sfx2/source/appl/opengrf.cxx b/sfx2/source/appl/opengrf.cxx
index fd547986d0da..71e46fd3181b 100644
--- a/sfx2/source/appl/opengrf.cxx
+++ b/sfx2/source/appl/opengrf.cxx
@@ -91,6 +91,7 @@ SvxOpenGraphicDialog::SvxOpenGraphicDialog(const OUString& 
rTitle, weld::Window*
     : mpImpl(new SvxOpenGrf_Impl(pPreferredParent, nDialogType))
 {
     mpImpl->aFileDlg.SetTitle(rTitle);
+    mpImpl->aFileDlg.SetContext(sfx2::FileDialogHelper::InsertImage);
 }
 
 SvxOpenGraphicDialog::~SvxOpenGraphicDialog()
diff --git a/sfx2/source/dialog/filedlghelper.cxx 
b/sfx2/source/dialog/filedlghelper.cxx
index f70ecec1146a..b8b4b7ae133e 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -37,12 +37,16 @@
 #include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
 #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/embed/ElementModes.hpp>
 #include <com/sun/star/container/XEnumeration.hpp>
 #include <com/sun/star/container/XContainerQuery.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
 #include <com/sun/star/task/InteractionHandler.hpp>
 #include <com/sun/star/task/XInteractionRequest.hpp>
 #include <com/sun/star/util/RevisionTag.hpp>
@@ -87,6 +91,7 @@
 #include <sal/log.hxx>
 #include <comphelper/sequence.hxx>
 #include <tools/diagnose_ex.h>
+#include <officecfg/Office/Common.hxx>
 
 #ifdef UNX
 #include <errno.h>
@@ -132,9 +137,9 @@ static std::optional<OUString> GetLastFilterConfigId( 
FileDialogHelper::Context
 
     switch( _eContext )
     {
-        case FileDialogHelper::SD_EXPORT: return aSD_EXPORT_IDENTIFIER;
-        case FileDialogHelper::SI_EXPORT: return aSI_EXPORT_IDENTIFIER;
-        case FileDialogHelper::SW_EXPORT: return aSW_EXPORT_IDENTIFIER;
+        case FileDialogHelper::DrawExport: return aSD_EXPORT_IDENTIFIER;
+        case FileDialogHelper::ImpressExport: return aSI_EXPORT_IDENTIFIER;
+        case FileDialogHelper::WriterExport: return aSW_EXPORT_IDENTIFIER;
         default: break;
     }
 
@@ -850,7 +855,7 @@ FileDialogHelper_Impl::FileDialogHelper_Impl(
     const css::uno::Sequence< OUString >& rDenyList
     )
     :m_nDialogType          ( nDialogType )
-    ,meContext              ( FileDialogHelper::UNKNOWN_CONTEXT )
+    ,meContext              ( FileDialogHelper::UnknownContext )
 {
     const char* pServiceName=nullptr;
     switch (nDialog)
@@ -1948,6 +1953,46 @@ static void SetToken( OUString& rOrigStr, sal_Int32 
nToken, sal_Unicode cTok, co
         rOrigStr = rOrigStr.replaceAt( nFirstChar, i-nFirstChar, rStr );
 }
 
+namespace
+{
+void SaveLastDirectory(OUString const& sContext, OUString const& sDirectory)
+{
+    if (sContext.isEmpty())
+        return;
+
+    std::shared_ptr<comphelper::ConfigurationChanges> batch(
+        comphelper::ConfigurationChanges::create());
+    Reference<container::XNameContainer> set(
+        officecfg::Office::Common::Misc::FilePickerLastDirectory::get(batch));
+
+    bool found;
+    Any v;
+    try
+    {
+        v = set->getByName(sContext);
+        found = true;
+    }
+    catch (container::NoSuchElementException&)
+    {
+        found = false;
+    }
+    if (found)
+    {
+        Reference<XPropertySet> el(v.get<Reference<XPropertySet>>(), 
UNO_SET_THROW);
+        el->setPropertyValue("LastPath", makeAny(sDirectory));
+    }
+    else
+    {
+        Reference<XPropertySet> el(
+            (Reference<lang::XSingleServiceFactory>(set, 
UNO_QUERY_THROW)->createInstance()),
+            UNO_QUERY_THROW);
+        el->setPropertyValue("LastPath", makeAny(sDirectory));
+        Any v2(makeAny(el));
+        set->insertByName(sContext, v2);
+    }
+    batch->commit();
+}
+}
 
 void FileDialogHelper_Impl::saveConfig()
 {
@@ -2038,43 +2083,67 @@ void FileDialogHelper_Impl::saveConfig()
             aDlgOpt.SetUserItem( USERITEM_NAME, makeAny( aUserData ) );
     }
 
-    SfxApplication *pSfxApp = SfxGetpApp();
-    pSfxApp->SetLastDir_Impl( getPath() );
+    // Store to config, if explicit context is set. Otherwise store in 
(global) runtime var.
+    if (meContext != FileDialogHelper::UnknownContext)
+    {
+        SaveLastDirectory(FileDialogHelper::contextToString(meContext), 
getPath());
+    }
+    else
+    {
+        SfxApplication *pSfxApp = SfxGetpApp();
+        pSfxApp->SetLastDir_Impl( getPath() );
+    }
 }
 
-namespace
+OUString FileDialogHelper_Impl::getInitPath(const OUString& _rFallback,
+                                            const sal_Int32 _nFallbackToken)
 {
-    OUString getInitPath( const OUString& _rFallback, const sal_Int32 
_nFallbackToken )
+    OUString sPath;
+    // Load from config, if explicit context is set. Otherwise load from 
(global) runtime var.
+    if (meContext != FileDialogHelper::UnknownContext)
+    {
+        OUString sContext = FileDialogHelper::contextToString(meContext);
+        Reference<XNameAccess> 
set(officecfg::Office::Common::Misc::FilePickerLastDirectory::get());
+        Any v;
+        try
+        {
+            v = set->getByName(sContext);
+            Reference<XPropertySet> el(v.get<Reference<XPropertySet>>(), 
UNO_SET_THROW);
+            sPath = el->getPropertyValue("LastPath").get<OUString>();
+        }
+        catch (NoSuchElementException&)
+        {
+        }
+    }
+    else
     {
         SfxApplication *pSfxApp = SfxGetpApp();
-        OUString sPath = pSfxApp->GetLastDir_Impl();
+        sPath = pSfxApp->GetLastDir_Impl();
+    }
 
-        if ( sPath.isEmpty() )
-            sPath = _rFallback.getToken( _nFallbackToken, ' ' );
+    if ( sPath.isEmpty() )
+        sPath = _rFallback.getToken( _nFallbackToken, ' ' );
 
-        // check if the path points to a valid (accessible) directory
-        bool bValid = false;
-        if ( !sPath.isEmpty() )
+    // check if the path points to a valid (accessible) directory
+    bool bValid = false;
+    if ( !sPath.isEmpty() )
+    {
+        OUString sPathCheck( sPath );
+        if ( sPathCheck[ sPathCheck.getLength() - 1 ] != '/' )
+            sPathCheck += "/";
+        sPathCheck += ".";
+        try
         {
-            OUString sPathCheck( sPath );
-            if ( sPathCheck[ sPathCheck.getLength() - 1 ] != '/' )
-                sPathCheck += "/";
-            sPathCheck += ".";
-            try
-            {
-                ::ucbhelper::Content aContent( sPathCheck,
-                                               
utl::UCBContentHelper::getDefaultCommandEnvironment(),
-                                               
comphelper::getProcessComponentContext() );
-                bValid = aContent.isFolder();
-            }
-            catch( const Exception& ) {}
+            ::ucbhelper::Content aContent( sPathCheck,
+                                            
utl::UCBContentHelper::getDefaultCommandEnvironment(),
+                                            
comphelper::getProcessComponentContext() );
+            bValid = aContent.isFolder();
         }
-
-        if ( !bValid )
-            sPath.clear();
-
-        return sPath;
+        catch( const Exception& ) {}
     }
+    if ( !bValid )
+        sPath.clear();
+    return sPath;
 }
 
 void FileDialogHelper_Impl::loadConfig()
@@ -2344,6 +2413,121 @@ void FileDialogHelper::SetContext( Context _eNewContext 
)
     mpImpl->SetContext( _eNewContext );
 }
 
+OUString FileDialogHelper::contextToString(Context context)
+{
+    // These strings are used in the configuration, to store the last used 
directory for each context.
+    // Please don't change them.
+    switch(context) {
+        case AcceleratorConfig:
+            return "AcceleratorConfig";
+        case AutoRedact:
+            return "AutoRedact";
+        case BaseDataSource:
+            return "BaseDataSource";
+        case BaseSaveAs:
+            return "BaseSaveAs";
+        case BasicExportPackage:
+            return "BasicExportPackage";
+        case BasicInsertLib:
+            return "BasicInsertLib";
+        case BulletsAddImage:
+            return "BulletsAddImage";
+        case CalcDataProvider:
+            return "CalcDataProvider";
+        case CalcDataStream:
+            return "CalcDataStream";
+        case CalcExport:
+            return "CalcExport";
+        case CalcSaveAs:
+            return "CalcSaveAs";
+        case CalcXMLSource:
+            return "CalcXMLSource";
+        case ExportImage:
+            return "ExportImage";
+        case ExtensionManager:
+            return "ExtensionManager";
+        case FormsAddInstance:
+            return "FormsAddInstance";
+        case FormsInsertImage:
+            return "FormsInsertImage";
+        case LinkClientOLE:
+            return "LinkClientOLE";
+        case LinkClientFile:
+            return "LinkClientFile";
+        case DrawImpressInsertFile:
+            return "DrawImpressInsertFile";
+        case DrawImpressOpenSound:
+            return "DrawImpressOpenSound";
+        case DrawExport:
+            return "DrawExport";
+        case DrawSaveAs:
+            return "DrawSaveAs";
+        case IconImport:
+            return "IconImport";
+        case ImpressClickAction:
+            return "ImpressClickAction";
+        case ImpressExport:
+            return "ImpressExport";
+        case ImpressPhotoDialog:
+            return "ImpressPhotoDialog";
+        case ImpressSaveAs:
+            return "ImpressSaveAs";
+        case ImageMap:
+            return "ImageMap";
+        case InsertDoc:
+            return "InsertDoc";
+        case InsertImage:
+            return "InsertImage";
+        case InsertOLE:
+            return "InsertOLE";
+        case InsertMedia:
+            return "InsertMedia";
+        case JavaClassPath:
+            return "JavaClassPath";
+        case ReportInsertImage:
+            return "ReportInsertImage";
+        case ScreenshotAnnotation:
+            return "ScreenshotAnnotation";
+        case SignatureLine:
+            return "SignatureLine";
+        case TemplateImport:
+            return "TemplateImport";
+        case WriterCreateAddressList:
+            return "WriterCreateAddressList";
+        case WriterExport:
+            return "WriterExport";
+        case WriterImportAutotext:
+            return "WriterImportAutotext";
+        case WriterInsertDoc:
+            return "WriterInsertDoc";
+        case WriterInsertHyperlink:
+            return "WriterInsertHyperlink";
+        case WriterInsertImage:
+            return "WriterInsertImage";
+        case WriterInsertScript:
+            return "WriterInsertScript";
+        case WriterLoadTemplate:
+            return "WriterLoadTemplate";
+        case WriterMailMerge:
+            return "WriterMailMerge";
+        case WriterMailMergeSaveAs:
+            return "WriterMailMergeSaveAs";
+        case WriterNewHTMLGlobalDoc:
+            return "WriterNewHTMLGlobalDoc";
+        case WriterRegisterDataSource:
+            return "WriterRegisterDataSource";
+        case WriterSaveAs:
+            return "WriterSaveAs";
+        case WriterSaveHTML:
+            return "WriterSaveHTML";
+        case XMLFilterSettings:
+            return "XMLFilterSettings";
+        case UnknownContext:
+        default:
+            return "";
+    }
+}
+
 IMPL_LINK_NOARG(FileDialogHelper, ExecuteSystemFilePicker, void*, void)
 {
     m_nError = mpImpl->execute();
diff --git a/sfx2/source/dialog/filedlgimpl.hxx 
b/sfx2/source/dialog/filedlgimpl.hxx
index e5e02e209748..9ae16de0994e 100644
--- a/sfx2/source/dialog/filedlgimpl.hxx
+++ b/sfx2/source/dialog/filedlgimpl.hxx
@@ -57,6 +57,7 @@ namespace sfx2
         ::std::vector< OUString > mlLastURLs;
 
         OUString             maPath;
+        OUString             maLastPath;
         OUString             maFileName;
         OUString             maCurFilter;
         OUString             maSelectFilter;
@@ -204,6 +205,7 @@ namespace sfx2
         OUString                getFilterWithExtension( std::u16string_view 
rFilter ) const;
 
         void                    SetContext( FileDialogHelper::Context 
_eNewContext );
+        OUString                getInitPath( const OUString& _rFallback, const 
sal_Int32 _nFallbackToken );
 
         bool             isSystemFilePicker() const { return mbSystemPicker; }
         bool             isPasswordEnabled() const { return mbIsPwdEnabled; }
diff --git a/sfx2/source/doc/autoredactdialog.cxx 
b/sfx2/source/doc/autoredactdialog.cxx
index eaa90476ea1f..0ccc622234e3 100644
--- a/sfx2/source/doc/autoredactdialog.cxx
+++ b/sfx2/source/doc/autoredactdialog.cxx
@@ -492,6 +492,7 @@ void 
SfxAutoRedactDialog::StartFileDialog(StartFileDialogType nType, const OUStr
     Link<sfx2::FileDialogHelper*, void> aDlgClosedLink
         = bSave ? LINK(this, SfxAutoRedactDialog, SaveHdl)
                 : LINK(this, SfxAutoRedactDialog, LoadHdl);
+    m_pFileDlg->SetContext(sfx2::FileDialogHelper::AutoRedact);
     m_pFileDlg->StartExecuteModal(aDlgClosedLink);
 }
 
diff --git a/sfx2/source/doc/docinsert.cxx b/sfx2/source/doc/docinsert.cxx
index 1cff1409d723..f9b757bac8ed 100644
--- a/sfx2/source/doc/docinsert.cxx
+++ b/sfx2/source/doc/docinsert.cxx
@@ -97,6 +97,7 @@ void DocumentInserter::StartExecuteModal( const 
Link<sfx2::FileDialogHelper*,voi
                 ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
                 m_nDlgFlags, m_sDocFactory, SfxFilterFlags::NONE, 
SfxFilterFlags::NONE, m_pParent ) );
     }
+    m_pFileDlg->SetContext(FileDialogHelper::InsertDoc);
     m_pFileDlg->StartExecuteModal( LINK( this, DocumentInserter, 
DialogClosedHdl ) );
 }
 
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index 16f287236c79..9e1d01c87dfc 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -881,15 +881,17 @@ bool ModelData_Impl::OutputFileDialog( sal_Int16 
nStoreMode,
             pFileDlg.reset(new sfx2::FileDialogHelper( aDialogMode, 
aDialogFlags, aDocServiceName, nDialog, nMust, nDont, rStandardDir, rDenyList, 
pFrameWin ));
         }
 
-        sfx2::FileDialogHelper::Context eCtxt = 
sfx2::FileDialogHelper::UNKNOWN_CONTEXT;
+        sfx2::FileDialogHelper::Context eCtxt = 
sfx2::FileDialogHelper::UnknownContext;
         if ( aDocServiceName == "com.sun.star.drawing.DrawingDocument" )
-            eCtxt = sfx2::FileDialogHelper::SD_EXPORT;
+            eCtxt = sfx2::FileDialogHelper::DrawExport;
         else if ( aDocServiceName == 
"com.sun.star.presentation.PresentationDocument" )
-            eCtxt = sfx2::FileDialogHelper::SI_EXPORT;
+            eCtxt = sfx2::FileDialogHelper::ImpressExport;
         else if ( aDocServiceName == "com.sun.star.text.TextDocument" )
-            eCtxt = sfx2::FileDialogHelper::SW_EXPORT;
+            eCtxt = sfx2::FileDialogHelper::WriterExport;
+        else if ( aDocServiceName == "com.sun.star.sheet.SpreadsheetDocument" )
+            eCtxt = sfx2::FileDialogHelper::CalcExport;
 
-        if ( eCtxt != sfx2::FileDialogHelper::UNKNOWN_CONTEXT )
+        if ( eCtxt != sfx2::FileDialogHelper::UnknownContext )
                pFileDlg->SetContext( eCtxt );
 
         pFileDlg->CreateMatcher( aDocServiceName );
@@ -905,10 +907,23 @@ bool ModelData_Impl::OutputFileDialog( sal_Int16 
nStoreMode,
     }
     else
     {
-        // This is the normal dialog
+        // This is the normal save as dialog
         pFileDlg.reset(new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, 
aDocServiceName, nDialog,
             nMust, nDont, rStandardDir, rDenyList, pFrameWin ));
         pFileDlg->CreateMatcher( aDocServiceName );
+
+        sfx2::FileDialogHelper::Context eCtxt = 
sfx2::FileDialogHelper::UnknownContext;
+        if ( aDocServiceName == "com.sun.star.drawing.DrawingDocument" )
+            eCtxt = sfx2::FileDialogHelper::DrawSaveAs;
+        else if ( aDocServiceName == 
"com.sun.star.presentation.PresentationDocument" )
+            eCtxt = sfx2::FileDialogHelper::ImpressSaveAs;
+        else if ( aDocServiceName == "com.sun.star.text.TextDocument" )
+            eCtxt = sfx2::FileDialogHelper::WriterSaveAs;
+        else if ( aDocServiceName == "com.sun.star.sheet.SpreadsheetDocument" )
+            eCtxt = sfx2::FileDialogHelper::CalcSaveAs;
+
+        if ( eCtxt != sfx2::FileDialogHelper::UnknownContext )
+               pFileDlg->SetContext( eCtxt );
     }
 
     OUString aAdjustToType;
@@ -1176,7 +1191,7 @@ OUString ModelData_Impl::GetRecommendedDir( const 
OUString& aSuggestedDir )
             }
 
             if ( aLocation.HasError() )
-                aLocation = INetURLObject( SvtPathOptions().GetWorkPath() );
+                aLocation = INetURLObject();
         }
 
         OUString sLocationURL( aLocation.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ) );
@@ -1199,7 +1214,7 @@ OUString ModelData_Impl::GetRecommendedDir( const 
OUString& aSuggestedDir )
 #endif
         // Suggest somewhere other than the system's temp directory
         if( bIsInTempPath )
-            aLocation = INetURLObject( SvtPathOptions().GetWorkPath() );
+            aLocation = INetURLObject();
 
         aLocation.setFinalSlash();
         if ( !aLocation.HasError() )
@@ -1208,7 +1223,7 @@ OUString ModelData_Impl::GetRecommendedDir( const 
OUString& aSuggestedDir )
         return OUString();
     }
 
-    return INetURLObject( SvtPathOptions().GetWorkPath() ).GetMainURL( 
INetURLObject::DecodeMechanism::NONE );
+    return OUString();
 }
 
 
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 033f3d24df4a..5030d3386772 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -963,6 +963,7 @@ void 
SfxTemplateManagerDlg::OnTemplateImportCategory(std::u16string_view sCatego
 {
     sfx2::FileDialogHelper 
aFileDlg(css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
                                     FileDialogFlags::MultiSelection, 
m_xDialog.get());
+    aFileDlg.SetContext(sfx2::FileDialogHelper::TemplateImport);
 
     // add "All" filter
     aFileDlg.AddFilter( SfxResId(STR_SFX_FILTERNAME_ALL),
diff --git a/svx/source/core/graphichelper.cxx 
b/svx/source/core/graphichelper.cxx
index 997644b6260a..de29e0bbbffc 100644
--- a/svx/source/core/graphichelper.cxx
+++ b/svx/source/core/graphichelper.cxx
@@ -227,7 +227,7 @@ OUString GraphicHelper::ExportGraphic(weld::Window* 
pParent, const Graphic& rGra
     aPath.SetSmartURL( sGraphicsPath );
 
     // fish out the graphic's name
-
+    aDialogHelper.SetContext(FileDialogHelper::ExportImage);
     aDialogHelper.SetTitle( SvxResId(RID_SVXSTR_EXPORT_GRAPHIC_TITLE));
     aDialogHelper.SetDisplayDirectory( 
aPath.GetMainURL(INetURLObject::DecodeMechanism::ToIUri) );
     INetURLObject aURL;
diff --git a/svx/source/dialog/imapdlg.cxx b/svx/source/dialog/imapdlg.cxx
index d0555edf6334..ee00d2b60e75 100644
--- a/svx/source/dialog/imapdlg.cxx
+++ b/svx/source/dialog/imapdlg.cxx
@@ -373,7 +373,7 @@ void SvxIMapDlg::DoOpen()
     aDlg.AddFilter( IMAP_BINARY_FILTER, IMAP_BINARY_TYPE );
 
     aDlg.SetCurrentFilter( aFilter );
-    aDlg.SetDisplayDirectory( SvtPathOptions().GetWorkPath() );
+    aDlg.SetContext(sfx2::FileDialogHelper::ImageMap);
 
     if( aDlg.Execute() != ERRCODE_NONE )
         return;
@@ -416,7 +416,7 @@ bool SvxIMapDlg::DoSave()
     aDlg.AddFilter( aBinFilter, IMAP_BINARY_TYPE );
 
     aDlg.SetCurrentFilter( aCERNFilter );
-    aDlg.SetDisplayDirectory( SvtPathOptions().GetWorkPath() );
+    aDlg.SetContext(sfx2::FileDialogHelper::ImageMap);
 
     if( aDlg.Execute() == ERRCODE_NONE )
     {
diff --git a/svx/source/form/datanavi.cxx b/svx/source/form/datanavi.cxx
index 56b85adbea38..e770c3ecd6ce 100644
--- a/svx/source/form/datanavi.cxx
+++ b/svx/source/form/datanavi.cxx
@@ -3069,13 +3069,12 @@ namespace svxform
         ::sfx2::FileDialogHelper aDlg(
             css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
             FileDialogFlags::NONE, m_xDialog.get());
-        INetURLObject aFile( SvtPathOptions().GetWorkPath() );
+        aDlg.SetContext(sfx2::FileDialogHelper::FormsAddInstance);
 
         aDlg.AddFilter( m_sAllFilterName, FILEDIALOG_FILTER_ALL );
         OUString sFilterName( "XML" );
         aDlg.AddFilter( sFilterName, "*.xml" );
         aDlg.SetCurrentFilter( sFilterName );
-        aDlg.SetDisplayDirectory( aFile.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ) );
 
         if (aDlg.Execute() == ERRCODE_NONE)
             m_xURLED->set_entry_text(aDlg.GetPath());
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 475388d2134e..e68df02d99c6 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);
commit 19a6184208cc8c15da15c80c3fe1490fc11865bb
Author:     Samuel Mehrbrodt <samuel.mehrbr...@cib.de>
AuthorDate: Thu Jan 12 16:47:40 2017 +0100
Commit:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
CommitDate: Wed Nov 24 11:43:16 2021 +0100

    Disable CrashReportUI
    
    since we don't offer upload - only want the dumps
    
    Change-Id: I6d084757d83204cb960905d7eb78571b13f8f875

diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index b0c4fac53e10..759231107ba1 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -874,7 +874,8 @@ namespace {
 #if HAVE_FEATURE_BREAKPAD
 void handleCrashReport()
 {
-    static constexpr OUStringLiteral SERVICENAME_CRASHREPORT = 
u"com.sun.star.comp.svx.CrashReportUI";
+    // Don't show the dialog since we don't offer upload - only want the dumps
+    /*static constexpr OUStringLiteral SERVICENAME_CRASHREPORT = 
u"com.sun.star.comp.svx.CrashReportUI";
 
     css::uno::Reference< css::uno::XComponentContext > xContext = 
::comphelper::getProcessComponentContext();
 
@@ -888,7 +889,7 @@ void handleCrashReport()
     css::util::URL aURL;
     css::uno::Any aRet = xRecoveryUI->dispatchWithReturnValue(aURL, 
css::uno::Sequence< css::beans::PropertyValue >());
     bool bRet = false;
-    aRet >>= bRet;
+    aRet >>= bRet;*/
 }
 #endif
 
commit dc47e4255d65be5727384d4aa72f1f12adb24d7d
Author:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
AuthorDate: Wed Oct 27 15:10:22 2021 +0200
Commit:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
CommitDate: Wed Nov 24 11:43:16 2021 +0100

    .gitreview: Update default branch
    
    Change-Id: I921d669fce624600c34898a344ee12776ea1b4e8

diff --git a/.gitreview b/.gitreview
index 0dc1cf997ec7..391c226512fe 100644
--- a/.gitreview
+++ b/.gitreview
@@ -3,5 +3,4 @@ host=gerrit.libreoffice.org
 port=29418
 project=core
 defaultremote=logerrit
-defaultbranch=libreoffice-7-2
-
+defaultbranch=feature/cib_contract6721c
commit bb3bbc2c579d22b5674ee1889f35e839e6e207f6
Author:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
AuthorDate: Tue Nov 23 16:19:43 2021 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Wed Nov 24 11:19:45 2021 +0100

    tdf#145852 Revert "Make "uno:Printer" actually work"
    
    This broke a macro (see tdf#145852)
    
    This reverts commit 3f4d96767fb510f07577ba4f28e60f05a370a5b2.
    
    Change-Id: Ic3b4f31182e2f4e13d33f2b7711fec9ae62b1fd7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125704
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
    (cherry picked from commit ecfce0ff23d9f1ed5a51b29b14a7043dce87b300)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125714
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 02e4658a4db9..e215a864c2b9 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -3267,7 +3267,7 @@ SfxVoidItem PrintDefault SID_PRINTDOCDIRECT
 
 
 SfxStringItem Printer SID_PRINTER_NAME
-(SfxStringItem PrinterName SID_PRINTER_NAME)
+
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
commit c6fbb0a9b4579af1f3d2429bda54bcae0cd6e38e
Author:     Heiko Tietze <tietze.he...@gmail.com>
AuthorDate: Mon Nov 22 11:03:47 2021 +0100
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Wed Nov 24 03:54:31 2021 +0100

    Resolves tdf#145801 - Uniform height for sidebar's panel titles
    
    Set height of all panel titles to the maximum height a panel title could 
need
    
    Change-Id: I1c023224fbca09b8f73151126b25df5f438260ce
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125650
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    (cherry picked from commit 90db4351138dec97f8dd2ebc350e8aef18a5358f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125712
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/sfx2/source/sidebar/PanelTitleBar.cxx 
b/sfx2/source/sidebar/PanelTitleBar.cxx
index c99672a0f1c5..86a92d2d71a1 100644
--- a/sfx2/source/sidebar/PanelTitleBar.cxx
+++ b/sfx2/source/sidebar/PanelTitleBar.cxx
@@ -42,10 +42,16 @@ PanelTitleBar::PanelTitleBar(const OUString& rsTitle,
     mxExpander->set_label(rsTitle);
     mxExpander->connect_expanded(LINK(this, PanelTitleBar, ExpandHdl));
 
+    // tdf#145801 lock the height to the size it needs with the "toolbar" 
button shown
+    // so all of the titlebars are the same height if the "toolbar" is hidden 
in some
+    // of them
+    mxToolBox->show();
+    mxTitlebar->set_size_request(-1, 
mxTitlebar->get_preferred_size().Height());
+    mxToolBox->hide();
+
     assert(mpPanel);
 
     UpdateExpandedState();
-
 }
 
 void PanelTitleBar::SetTitle(const OUString& rsTitle)
commit 6809461add683eaa49a11530445c1f4c4b3d8fe8
Author:     Justin Luth <justin_l...@sil.org>
AuthorDate: Tue Nov 23 09:18:20 2021 +0200
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Wed Nov 24 03:04:03 2021 +0100

    tdf#129638 print preview: use new paper size after switching page
    
    This is a partial revert of LO 6.3
    commit 2c23a96f7b6888c0e05fdc2aba57f03cd797b647.
    
    Change-Id: I17525d06d96779671caaa84e1e48629289453ad2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125685
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    (cherry picked from commit 324daa38a823477e1d1b650b5d91f3dc91c6a9af)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125466
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index c69799ed1c4e..251ce6002535 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -975,6 +975,7 @@ void PrintDialog::preparePreview( bool i_bMayUseCache )
     {
         PrinterController::PageSize aPageSize =
             maPController->getFilteredPageFile( mnCurPage, aMtf, 
i_bMayUseCache );
+        aCurPageSize = aPrt->PixelToLogic(aPrt->GetPaperSizePixel(), 
MapMode(MapUnit::Map100thMM));
         if( ! aPageSize.bFullPaper )
         {
             Point aOff( aPrt->PixelToLogic( aPrt->GetPageOffsetPixel(), 
aMapMode ) );
commit cad293c26215855578eb218d7154ec8300960969
Author:     Justin Luth <justin_l...@sil.org>
AuthorDate: Tue Nov 23 10:23:37 2021 +0200
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Wed Nov 24 03:03:09 2021 +0100

    tdf#131150 sw menu: use nSlotId=0 to avoid adding to set
    
    This fixes a regression in LO 6.4 caused by
    commit 86cb2a1f98c0585d2121e6ae34fe62f072ef9a63
    
    Not surprisingly, adding a new condition that multiple
    other items match on caused a regression.
    
    bFlag is always set to false at the top of the loop.
    In the above commit, bFlag was not set to true,
    and so thus it would always be false.
    So just set the SlotId to 0
    to avoid rSet.Put - like so many other cases already do.
    
    Change-Id: I02e9ca9d8dd75db519e801ad0e86fc8d541ae20a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125688
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
    Reviewed-by: Justin Luth <jl...@mail.com>
    (cherry picked from commit 87fafdb9dc045735e235cbba2ef37198043422c7)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125707
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/sw/source/uibase/shells/drwtxtex.cxx 
b/sw/source/uibase/shells/drwtxtex.cxx
index 770b46d7e7ba..8ac84122ff41 100644
--- a/sw/source/uibase/shells/drwtxtex.cxx
+++ b/sw/source/uibase/shells/drwtxtex.cxx
@@ -953,6 +953,7 @@ void SwDrawTextShell::GetState(SfxItemSet& rSet)
             {
                 if (!URLFieldHelper::IsCursorAtURLField(pOLV))
                     rSet.DisableItem(nWhich);
+                nSlotId = 0;
             }
             break;
             default:
@@ -960,7 +961,7 @@ void SwDrawTextShell::GetState(SfxItemSet& rSet)
                 break;
         }
 
-        if (nSlotId && bFlag)
+        if (nSlotId)
             rSet.Put(SfxBoolItem(nWhich, bFlag));
 
         nWhich = aIter.NextWhich();
commit 7836158294a5536bda4b2cf7193180f4a0ed8e05
Author:     Michael Meeks <michael.me...@collabora.com>
AuthorDate: Tue Nov 23 14:25:45 2021 +0000
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Tue Nov 23 22:30:05 2021 +0100

    Crash around help-windows.
    
    Seems a popular way to crash:
            vcl::Window::ImplCallMove()
                    vcl/source/window/event.cxx:555
            vcl::Window::Show(bool, ShowFlags) [clone .localalias]
                    /usr/include/c++/10/bits/unique_ptr.h:173
            vcl::Window::Show(bool, ShowFlags)
                    vcl/source/window/window.cxx:2345
            HelpTextWindow::ImplShow()
                    vcl/source/app/help.cxx:371
            Scheduler::ProcessTaskScheduling()
                    vcl/source/app/scheduler.cxx:495
    
    Change-Id: I33ca0059844395c41f4d76619cca22aec81df207
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125711
    Tested-by: Michael Meeks <michael.me...@collabora.com>
    Reviewed-by: Jan Holesovsky <ke...@collabora.com>

diff --git a/vcl/source/window/event.cxx b/vcl/source/window/event.cxx
index 9fa5b3d4c71e..82c901185387 100644
--- a/vcl/source/window/event.cxx
+++ b/vcl/source/window/event.cxx
@@ -535,7 +535,8 @@ void Window::ImplCallMove()
         vcl::Window *pParent = ImplGetParent();
         while( pParent )
         {
-            if( pParent->mpWindowImpl->mpFrame != mpWindowImpl->mpFrame )
+            if( pParent->mpWindowImpl &&
+                pParent->mpWindowImpl->mpFrame != mpWindowImpl->mpFrame )
             {
                 pParentFrame = pParent->mpWindowImpl->mpFrame;
                 break;
commit 9c0b3697084cdda149705789365f63e8293e0092
Author:     Kevin Suo <suokunl...@126.com>
AuthorDate: Fri Nov 19 16:13:09 2021 +0800
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Tue Nov 23 14:54:25 2021 +0100

    Change aboveWord and belowWord for Simplified Chinese locale
    
    Per Wechat discussion by our Simplified Chinese l10n team.
    
    上方 and 下方 are written languages which are more suitable for
    cross-reference context, while 上面 and 下面 are spoken languages.
    Also in this way they are consistent with MS Word.
    
    Change-Id: Iccf8c330b2e5a04be3916b810a29ea0d62f26225
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125533
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <er...@redhat.com>
    (cherry picked from commit 918b62bea6cf82ce952c8d225dcabd4d08a2abf7)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125461

diff --git a/i18npool/source/localedata/data/zh_CN.xml 
b/i18npool/source/localedata/data/zh_CN.xml
index 814c6db9ba48..1f33090d0ced 100644
--- a/i18npool/source/localedata/data/zh_CN.xml
+++ b/i18npool/source/localedata/data/zh_CN.xml
@@ -418,8 +418,8 @@
       <quarter2Word>第2季度</quarter2Word>
       <quarter3Word>第3季度</quarter3Word>
       <quarter4Word>第4季度</quarter4Word>
-      <aboveWord>上面</aboveWord>
-      <belowWord>下面</belowWord>
+      <aboveWord>上方</aboveWord>
+      <belowWord>下方</belowWord>
       <quarter1Abbreviation>Q1</quarter1Abbreviation>
       <quarter2Abbreviation>Q2</quarter2Abbreviation>
       <quarter3Abbreviation>Q3</quarter3Abbreviation>
commit 1ed00f2ad9bbc6e920248ba3d39c227acb06e0e6
Author:     Justin Luth <justin_l...@sil.org>
AuthorDate: Mon Nov 22 19:33:48 2021 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Nov 23 11:50:17 2021 +0100

    tdf#138223 oox: don't set highlight color if it is transparent
    
    Probably when this was first implemented in 6.4,
    it should have set a transparency threshold of when to accept
    the color as the background (perhaps at 50%).
    But since this has already been running for a while,
    I only cancel it if it is fully transparent.
    
    No existing unit tests matched this scenario.
    
    I'm not making a unit test because the color really
    ought to be set - it should just be transparent.
    LO doesn't seem to have a character highlight
    transparency capability, so this needs to be emulated.
    
    Change-Id: I7b295894e529f8345cadc9b30bc43598a9a02e2b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125670
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    (cherry picked from commit 283586c89a0542efb2d57a36ee3aad7cc5153ed5)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125465
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/oox/source/drawingml/textcharacterproperties.cxx 
b/oox/source/drawingml/textcharacterproperties.cxx
index 4eb5acaffb56..ca1d2af1360d 100644
--- a/oox/source/drawingml/textcharacterproperties.cxx
+++ b/oox/source/drawingml/textcharacterproperties.cxx
@@ -175,7 +175,7 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& 
rPropMap, const XmlFil
     }
     // TODO If bUnderlineFillFollowText uFillTx 
(CT_TextUnderlineFillFollowText) is set, fill color of the underline should be 
the same color as the text
 
-    if( maHighlightColor.isUsed() )
+    if (maHighlightColor.isUsed() && maHighlightColor.getTransparency() != 100)
         rPropMap.setProperty( PROP_CharBackColor, maHighlightColor.getColor( 
rFilter.getGraphicHelper() ));
     else
         rPropMap.setProperty( PROP_CharBackColor, sal_Int32(-1));
commit 13c0794e2040e3a29801a56c6eb9835f364f8f27
Author:     Justin Luth <justin_l...@sil.org>
AuthorDate: Sat Nov 20 20:29:17 2021 +0200
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Mon Nov 22 14:27:23 2021 +0100

    tdf#132470 tabbar: revert back to bold font on visible tab
    
    This is a partial regression to LO 6.3's
    commit fad98c8641342a77241124dd98e0cb781daef4ad.
    
    The current sheet is always selected, which is fairly
    distinctive. However, it is possible to select
    multiple sheets, and the current one should be
    distinctly marked to differentiate it from
    the other selected sheets.
    
    Change-Id: Ib160535cccebcfcabee94d17e5941cc3cd23bb15
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125601
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit fbda2f3b7b47021a140cbfd3288aa7de1b42e1fd)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125462
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/svtools/source/control/tabbar.cxx 
b/svtools/source/control/tabbar.cxx
index 4bca7ccbb99d..612686c50a73 100644
--- a/svtools/source/control/tabbar.cxx
+++ b/svtools/source/control/tabbar.cxx
@@ -1162,8 +1162,11 @@ void TabBar::Paint(vcl::RenderContext& rRenderContext, 
const tools::Rectangle& r
             aDrawer.mbProtect = pItem->mbProtect;
             aDrawer.drawTab();
 
-            // actual page is drawn using a bold font
-            rRenderContext.SetFont(aLightFont);
+            // currently visible sheet is drawn using a bold font
+            if (bCurrent)
+                rRenderContext.SetFont(aFont);
+            else
+                rRenderContext.SetFont(aLightFont);
 
             // Set the correct FillInBrush depending on status
 
commit 5fae86d3f4468cac9af32e44873d57a195a48ff4
Author:     Jim Raykowski <rayk...@gmail.com>
AuthorDate: Wed Nov 17 20:20:25 2021 -0900
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Nov 22 13:35:39 2021 +0100

    tdf#145207 Check for drawing object before Table to handle Tab key
    
    to fix crash that can occur if done the other way
    
    Change-Id: I378aa8444906d56647ab4fdde26d4ff1c9f511f5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125435
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    (cherry picked from commit 437d5a446733aca0a485218f29d8d7dcea4d3999)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125463
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/source/uibase/docvw/edtwin.cxx 
b/sw/source/uibase/docvw/edtwin.cxx
index 6bca7e62ee4c..5fea06590626 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -2055,6 +2055,15 @@ KEYINPUT_CHECKTABLE_INSDEL:
                             }
                         }
                     }
+                    else if (rSh.GetSelectionType() &
+                             (SelectionType::Graphic |
+                              SelectionType::Frame |
+                              SelectionType::Ole |
+                              SelectionType::DrawObject |
+                              SelectionType::DbForm))
+                    {
+                        eKeyState = SwKeyState::NextObject;
+                    }
                     else if ( rSh.GetTableFormat() )
                     {
                         if( rSh.HasSelection() || rSh.HasReadonlySel() )
@@ -2065,14 +2074,6 @@ KEYINPUT_CHECKTABLE_INSDEL:
                             eNextKeyState = SwKeyState::NextCell;
                         }
                     }
-                    else if ( rSh.GetSelectionType() &
-                                (SelectionType::Graphic |
-                                    SelectionType::Frame |
-                                    SelectionType::Ole |
-                                    SelectionType::DrawObject |
-                                    SelectionType::DbForm))
-
-                            eKeyState = SwKeyState::NextObject;
                     else
                     {
                         eKeyState = SwKeyState::InsTab;
@@ -2110,6 +2111,15 @@ KEYINPUT_CHECKTABLE_INSDEL:
                         else
                             eKeyState = SwKeyState::NumUp;
                     }
+                    else if (rSh.GetSelectionType() &
+                             (SelectionType::Graphic |
+                              SelectionType::Frame |
+                              SelectionType::Ole |
+                              SelectionType::DrawObject |
+                              SelectionType::DbForm))
+                    {
+                        eKeyState = SwKeyState::PrevObject;
+                    }
                     else if ( rSh.GetTableFormat() )
                     {
                         if( rSh.HasSelection() || rSh.HasReadonlySel() )
@@ -2120,14 +2130,6 @@ KEYINPUT_CHECKTABLE_INSDEL:
                             eNextKeyState = SwKeyState::PrevCell;
                         }
                     }
-                    else if ( rSh.GetSelectionType() &
-                                (SelectionType::Graphic |
-                                    SelectionType::Frame |
-                                    SelectionType::Ole |
-                                    SelectionType::DrawObject |
-                                    SelectionType::DbForm))
-
-                            eKeyState = SwKeyState::PrevObject;
                     else
                     {
                         eKeyState = SwKeyState::End;
commit b80b17884962c5e2f50c734f153825c0e37605e2
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sun Nov 21 19:53:47 2021 +0000
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Mon Nov 22 11:51:19 2021 +0100

    Related: tdf#145786 cooperate between our own grabs
    
    don't try to workaround a grab if the grab is done by another
    of our own popups, and on tearing down one of our popups, restore
    the grab of its parent if that parent was one of our own popups.
    
    This typically matters on X where we don't use GtkPopovers (unlike
    wayland, where Popovers can escape the parent window). Things to test
    are:
    
    writer's watermark dialog: click the color button to get the 1st level
    popup, then click the combobox to get the 2nd level one, select an entry
    to return to the 1st level.
    a) Clicking a valueset element should select that color, not dismiss the
    popup without selecting a color.
    b) Clicking the combobox to get the popup again should result in a popup
    where the focus still follows the mouse (i.e. the 1st level popup
    doesn't try and steal away the 2nd level grab)
    
    sidebar: same scenario as above, except a color popover parented to a
    sidebar pane and not a dialog.
    
    Change-Id: Ib5d765b22b8a9b6b1a7806676c8fe3cfb7709734
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125645
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 78c3b09789c1..4b1cd409fc48 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -9469,9 +9469,15 @@ private:
             return;
         if (!get_active())
         {
+            bool bHadFocus = gtk_window_has_toplevel_focus(m_pMenuHack);
+
             do_ungrab(GTK_WIDGET(m_pMenuHack));
 
             gtk_widget_hide(GTK_WIDGET(m_pMenuHack));
+
+            GdkSurface* pSurface = widget_get_surface(GTK_WIDGET(m_pMenuHack));
+            g_object_set_data(G_OBJECT(pSurface), "g-lo-InstancePopup", 
GINT_TO_POINTER(false));
+
             //put contents back from where the came from
             GtkWidget* pChild = gtk_bin_get_child(GTK_BIN(m_pMenuHack));
             g_object_ref(pChild);
@@ -9489,6 +9495,15 @@ private:
             GtkSalFrame* pFrame = pParent ? 
GtkSalFrame::getFromWindow(pParent) : nullptr;
             if (pFrame)
                 pFrame->UnblockTooltip();
+
+            if (bHadFocus)
+            {
+                GdkSurface* pParentSurface = pParent ? 
widget_get_surface(pParent) : nullptr;
+                void* pParentIsPopover = pParentSurface ? 
g_object_get_data(G_OBJECT(pParentSurface), "g-lo-InstancePopup") : nullptr;
+                if (pParentIsPopover)
+                    do_grab(GTK_WIDGET(m_pMenuButton));
+                gtk_widget_grab_focus(GTK_WIDGET(m_pMenuButton));
+            }
         }
         else
         {
@@ -9503,6 +9518,8 @@ private:
             g_object_unref(pChild);
 
             GtkPositionType ePosUsed = show_menu(m_pMenuHackAlign ? 
m_pMenuHackAlign : GTK_WIDGET(m_pMenuButton), m_pMenuHack);
+            GdkSurface* pSurface = widget_get_surface(GTK_WIDGET(m_pMenuHack));
+            g_object_set_data(G_OBJECT(pSurface), "g-lo-InstancePopup", 
GINT_TO_POINTER(true));
             // tdf#132540 keep the placeholder popover on this same side as 
the replacement menu
             
gtk_popover_set_position(gtk_menu_button_get_popover(m_pMenuButton), ePosUsed);
         }
@@ -9522,7 +9539,7 @@ private:
         {
             set_active(false);
         }
-        else
+        else if (!g_object_get_data(G_OBJECT(event->grab_window), 
"g-lo-InstancePopup")) // another LibreOffice popover took a grab
         {
             //try and regrab, so when we lose the grab to the menu of the 
color palette
             //combobox we regain it so the color palette doesn't itself 
disappear on next
@@ -17979,7 +17996,7 @@ private:
         {
             gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_pToggleButton), 
false);
         }
-        else
+        else if (!g_object_get_data(G_OBJECT(event->grab_window), 
"g-lo-InstancePopup")) // another LibreOffice popover took a grab
         {
             //try and regrab, so when we lose the grab to the menu of the 
color palette
             //combobox we regain it so the color palette doesn't itself 
disappear on next
@@ -19209,10 +19226,15 @@ private:
                 m_bHoverSelection = false;
             }
 
+            bool bHadFocus = gtk_window_has_toplevel_focus(m_pMenuWindow);
+
             do_ungrab(GTK_WIDGET(m_pMenuWindow));
 
             gtk_widget_hide(GTK_WIDGET(m_pMenuWindow));
 
+            GdkSurface* pSurface = 
widget_get_surface(GTK_WIDGET(m_pMenuWindow));
+            g_object_set_data(G_OBJECT(pSurface), "g-lo-InstancePopup", 
GINT_TO_POINTER(false));
+
             // so gdk_window_move_to_rect will work again the next time
             gtk_widget_unrealize(GTK_WIDGET(m_pMenuWindow));
 
@@ -19226,6 +19248,15 @@ private:
             GtkSalFrame* pFrame = pParent ? 
GtkSalFrame::getFromWindow(pParent) : nullptr;
             if (pFrame)
                 pFrame->UnblockTooltip();
+
+            if (bHadFocus)
+            {
+                GdkSurface* pParentSurface = pParent ? 
widget_get_surface(pParent) : nullptr;
+                void* pParentIsPopover = pParentSurface ? 
g_object_get_data(G_OBJECT(pParentSurface), "g-lo-InstancePopup") : nullptr;
+                if (pParentIsPopover)
+                    do_grab(m_pToggleButton);
+                gtk_widget_grab_focus(m_pToggleButton);
+            }
         }
         else
         {
@@ -19250,6 +19281,8 @@ private:
                 tree_view_set_cursor(0);
 
             show_menu(pComboBox, m_pMenuWindow);
+            GdkSurface* pSurface = 
widget_get_surface(GTK_WIDGET(m_pMenuWindow));
+            g_object_set_data(G_OBJECT(pSurface), "g-lo-InstancePopup", 
GINT_TO_POINTER(true));
         }
     }
 
@@ -19707,7 +19740,7 @@ private:
         {
             gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_pToggleButton), 
false);
         }
-        else
+        else if (!g_object_get_data(G_OBJECT(event->grab_window), 
"g-lo-InstancePopup")) // another LibreOffice popover took a grab
         {
             //try and regrab, so when we lose the grab to the menu of the 
color palette
             //combobox we regain it so the color palette doesn't itself 
disappear on next
commit 5853e4d137c3cb535571cba0233b05a48761ac52
Author:     Justin Luth <justin_l...@sil.org>
AuthorDate: Thu Nov 18 11:28:42 2021 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Fri Nov 19 17:08:05 2021 +0100

    tdf#135906 docxexport: set serializer before writing
    
    This fixes a 6.3 regresssion from
    commit aafaf1f55fa413ad49d4556cf7c0a713dd206ae4.
    
    Change-Id: Ia2d3d26fe2cfa2b213326021f6b97f8d40c6e98c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125441
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125537

diff --git a/sw/qa/extras/ooxmlexport/data/tdf135906.docx 
b/sw/qa/extras/ooxmlexport/data/tdf135906.docx
new file mode 100644
index 000000000000..701fccff5ed4
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf135906.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index f1726052ca02..c1c723fccb25 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -43,6 +43,11 @@ DECLARE_OOXMLEXPORT_TEST(testTdf135164_cancelledNumbering, 
"tdf135164_cancelledN
     CPPUNIT_ASSERT_EQUAL(OUString("i"), getProperty<OUString>(xPara, 
"ListLabelString"));
 }
 
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf135906, "tdf135906.docx")
+{
+    // just test round-tripping. The document was exported as corrupt and 
didn't re-load.
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf123642_BookmarkAtDocEnd, "tdf123642.docx")
 {
     // get bookmark interface
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx 
b/sw/source/filter/ww8/docxsdrexport.cxx
index 539eb63c20b1..fe284534ae64 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -1245,6 +1245,7 @@ void DocxSdrExport::writeDiagram(const SdrObject* 
sdrObject, const SwFrameFormat
     Size aSize(sdrObject->GetSnapRect().GetWidth(), 
sdrObject->GetSnapRect().GetHeight());
     startDMLAnchorInline(&rFrameFormat, aSize);
 
+    m_pImpl->getDrawingML()->SetFS(m_pImpl->getSerializer());
     m_pImpl->getDrawingML()->WriteDiagram(xShape, nDiagramId);
 
     endDMLAnchorInline(&rFrameFormat);
commit 91dbd398617244c6283d8b9654ba15ebb20c82c6
Author:     Michael Meeks <michael.me...@collabora.com>
AuthorDate: Wed Nov 17 17:18:16 2021 +0000
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri Nov 19 15:01:21 2021 +0100

    Crash when fetching clipboard data.
    
    Seems like some unusual corner-case around HTML export.
    
            sw::DocumentContentOperationsManager::CopyImplImpl(SwPaM&, 
SwPosition&, bool, SwPaM*, bool) const
                    
/sw/source/core/doc/DocumentContentOperationsManager.cxx:5068
            sw::DocumentContentOperationsManager::CopyImpl(SwPaM&, SwPosition&, 
bool, SwPaM*, bool) const
                    
/sw/source/core/doc/DocumentContentOperationsManager.cxx:4609
            sw::DocumentContentOperationsManager::CopyRange(SwPaM&, 
SwPosition&, bool, bool, bool) const
                    
/sw/source/core/doc/DocumentContentOperationsManager.cxx:1936
            SwEditShell::CopySelToDoc(SwDoc*)
                    /sw/inc/pam.hxx:193 (discriminator 2)
            SwFEShell::Copy(SwDoc*, rtl::OUString const*)
                    /sw/source/core/frmedt/fecopy.cxx:224
            (anonymous namespace)::lclOverWriteDoc(SwWrtShell&, SwDoc&)
                    /sw/source/uibase/dochdl/swdtflvr.cxx:413
            SwTransferable::GetData(com::sun::star::datatransfer::DataFlavor 
const&, rtl::OUString const&)
                    /include/sfx2/objsh.hxx:866
            
TransferableHelper::getTransferData2(com::sun::star::datatransfer::DataFlavor 
const&, rtl::OUString const&)
                    /include/com/sun/star/uno/Type.h:121
            
TransferableHelper::getTransferData(com::sun::star::datatransfer::DataFlavor 
const&)
                    /include/rtl/ustring.hxx:438
            getFromTransferrable.isra.0
                    /include/com/sun/star/uno/Any.hxx:151
            encodeImageAsHTML
                    /desktop/source/lib/init.cxx:4382
            doc_getTextSelection
    
    Change-Id: I1af52d827ebdc9bbc5278f56547d1b3fd1b87e7c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125456
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 5f06a273faf2..0390ad42b6d3 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -5119,8 +5119,11 @@ bool 
DocumentContentOperationsManager::CopyImplImpl(SwPaM& rPam, SwPosition& rPo
     //  and not the source has the page break
     if (rDoc.IsClipBoard() && (rPam.GetPageNum(pStt == rPam.GetPoint()) == 1) 
&& !bCopyPageSource)
     {
-        pDestTextNd->ResetAttr(RES_BREAK);        // remove the page-break
-        pDestTextNd->ResetAttr(RES_PAGEDESC);
+        if (pDestTextNd)
+        {
+            pDestTextNd->ResetAttr(RES_BREAK);        // remove the page-break
+            pDestTextNd->ResetAttr(RES_PAGEDESC);
+        }
     }
 
 
commit 67d8c6ecb3873a8dfc789221764d7688596f09cc
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Nov 18 17:53:46 2021 +0100
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Fri Nov 19 04:52:34 2021 +0100

    tdf#140086 svl: restore PasswordContainer to single-instance
    
    (regression from 7256ff08bc46840bb85fa255ace6541dca91329e)
    
    Change-Id: Ib640dea001fc787279761ca72bbc3db46d0102c2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125485
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Tested-by: Jenkins
    (cherry picked from commit dd43c74ee5778109f860e18419fc37fd9ab1c7dd)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125453
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/svl/source/passwordcontainer/passwordcontainer.component 
b/svl/source/passwordcontainer/passwordcontainer.component
index e928461fa96b..109f45c5021c 100644
--- a/svl/source/passwordcontainer/passwordcontainer.component
+++ b/svl/source/passwordcontainer/passwordcontainer.component
@@ -20,6 +20,7 @@
 <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
     xmlns="http://openoffice.org/2010/uno-components";>
   <implementation name="stardiv.svl.PasswordContainer"
+    single-instance="true"
     constructor="svl_PasswordContainer_get_implementation">
     <service name="com.sun.star.task.PasswordContainer"/>
   </implementation>
commit 8443576d96346b63e3c2f11f258d2b89c3538f9e
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu Nov 18 15:31:34 2021 +0000
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Nov 18 22:14:25 2021 +0100

    crashes seen in WriterInspectorTextPanel ctor
    
    null DocSh is likely
    
    Change-Id: I5aeb81ef01795b896ad594d7eb7f0cd657f5a690
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125451
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx 
b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
index a59143ba8d48..5d55176be2da 100644
--- a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
+++ b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
@@ -62,7 +62,7 @@ 
WriterInspectorTextPanel::WriterInspectorTextPanel(weld::Widget* pParent)
     : InspectorTextPanel(pParent)
 {
     SwDocShell* pDocSh = static_cast<SwDocShell*>(SfxObjectShell::Current());
-    m_pShell = pDocSh->GetWrtShell();

... etc. - the rest is truncated

Reply via email to