summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Marek Glogowski <jan-marek.glogowski@extern.cib.de>2019-11-21 17:16:28 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-12-05 15:30:57 +0100
commitb5ad13a606f93955d983beef5baacac6a694b7cb (patch)
tree96234119bea03c7464280f4ed192c766254b4cab
parent3afd9bad338ffee53d2542e7417f05607b61f955 (diff)
tdf#43021 WIN opt-out of OS recent folder usage
The Microsoft documentation for SetFolder explicitly mentiones "In general, we do not recommended the use of this method. [...] SetDefaultFolder is the better method." If SetDefaultFolder is used the recently-used folder overwrites the value passed to SetDefaultFolder, which is shared between all file pickers. With this patch we rely on the LO internal mechanism to show the last used directory in the file picker. Regina's workaround basically does the same, as it just sets oRegistryKeyContent.WorkPathChanged, which triggers the internal path to use SetFolder instead of SetDefaultFolder. If you're wondering about the GetFolder() handling, the MS API docs have this: "Gets either the folder currently selected in the dialog, or, if the dialog is not currently displayed, the folder that is to be selected when the dialog is opened." So the call to GetFolder(), after the dialog is closed, returns the folder set by the SetFolder call, not the folder selected by the user, in case of the save dialog at least. Reviewed-on: https://gerrit.libreoffice.org/83409 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de> Tested-by: Jan-Marek Glogowski <glogow@fbihome.de> (cherry picked from commit ffa636ba74b04b3258ec9a696bc4eac33581fa24) Reviewed-on: https://gerrit.libreoffice.org/83839 Tested-by: Jenkins (cherry picked from commit a20e061d0a54e027a9cf3702fdc88b94e9ec8c18) Change-Id: Ia24f47848501df82727bfb2a99db723468bfe5b1 Reviewed-on: https://gerrit.libreoffice.org/84304 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r--cui/source/options/optpath.cxx8
-rw-r--r--fpicker/source/win32/filepicker/IVistaFilePickerInternalNotify.hxx2
-rw-r--r--fpicker/source/win32/filepicker/VistaFilePicker.cxx13
-rw-r--r--fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx1
-rw-r--r--fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx28
-rw-r--r--fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx4
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/Common.xcs12
7 files changed, 20 insertions, 48 deletions
diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx
index 59c93cf9d216..1118a2094eb7 100644
--- a/cui/source/options/optpath.cxx
+++ b/cui/source/options/optpath.cxx
@@ -514,14 +514,6 @@ void SvxPathTabPage::ChangeCurrentEntry( const OUString& _rFolder )
// Reset also last used dir in the sfx application instance
SfxApplication *pSfxApp = SfxGetpApp();
pSfxApp->ResetLastDir();
-
- // Set configuration flag to notify file picker that it's necessary
- // to take over the path provided.
- std::shared_ptr< comphelper::ConfigurationChanges > batch(
- comphelper::ConfigurationChanges::create());
- officecfg::Office::Common::Path::Info::WorkPathChanged::set(
- true, batch);
- batch->commit();
}
}
}
diff --git a/fpicker/source/win32/filepicker/IVistaFilePickerInternalNotify.hxx b/fpicker/source/win32/filepicker/IVistaFilePickerInternalNotify.hxx
index 3501a37c94f9..57f995715719 100644
--- a/fpicker/source/win32/filepicker/IVistaFilePickerInternalNotify.hxx
+++ b/fpicker/source/win32/filepicker/IVistaFilePickerInternalNotify.hxx
@@ -46,6 +46,8 @@ class IVistaFilePickerInternalNotify
virtual bool onFileTypeChanged( UINT nTypeIndex ) = 0;
+ virtual void onDirectoryChanged() = 0;
+
protected:
~IVistaFilePickerInternalNotify() {}
};
diff --git a/fpicker/source/win32/filepicker/VistaFilePicker.cxx b/fpicker/source/win32/filepicker/VistaFilePicker.cxx
index 17b6a566d8ce..f1018d90e0c6 100644
--- a/fpicker/source/win32/filepicker/VistaFilePicker.cxx
+++ b/fpicker/source/win32/filepicker/VistaFilePicker.cxx
@@ -170,22 +170,9 @@ void SAL_CALL VistaFilePicker::setDisplayDirectory(const OUString& sDirectory)
{
ensureInit();
- bool bChanged = officecfg::Office::Common::Path::Info::WorkPathChanged::get(
- comphelper::getComponentContext(m_xSMGR));
- if (bChanged )
- {
- std::shared_ptr< comphelper::ConfigurationChanges > batch(
- comphelper::ConfigurationChanges::create(
- comphelper::getComponentContext(m_xSMGR)));
- officecfg::Office::Common::Path::Info::WorkPathChanged::set(
- false, batch);
- batch->commit();
- }
-
RequestRef rRequest(new Request());
rRequest->setRequest (VistaFilePickerImpl::E_SET_DIRECTORY);
rRequest->setArgument(PROP_DIRECTORY, sDirectory);
- rRequest->setArgument(PROP_FORCE, bChanged);
m_aAsyncExecute.triggerRequestThreadAware(rRequest, AsyncRequests::NON_BLOCKED);
}
diff --git a/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx b/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx
index e736df90a40e..316ae1cf9c6b 100644
--- a/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx
+++ b/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx
@@ -113,6 +113,7 @@ STDMETHODIMP VistaFilePickerEventHandler::OnFolderChanging(IFileDialog* /*pDialo
STDMETHODIMP VistaFilePickerEventHandler::OnFolderChange(IFileDialog* /*pDialog*/)
{
impl_sendEvent(E_DIRECTORY_CHANGED, 0);
+ m_pInternalNotify->onDirectoryChanged();
return S_OK;
}
diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
index 5052a731db25..8ef2ec875c17 100644
--- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
+++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
@@ -757,7 +757,6 @@ void VistaFilePickerImpl::impl_sta_SetFileName(const RequestRef& rRequest)
void VistaFilePickerImpl::impl_sta_SetDirectory(const RequestRef& rRequest)
{
OUString sDirectory = rRequest->getArgumentOrDefault(PROP_DIRECTORY, OUString());
- bool bForce = rRequest->getArgumentOrDefault(PROP_FORCE, false);
if( !m_bInExecute)
{
@@ -779,27 +778,25 @@ void VistaFilePickerImpl::impl_sta_SetDirectory(const RequestRef& rRequest)
if ( !createFolderItem(sDirectory, pFolder) )
return;
- if ( m_bInExecute || bForce )
- iDialog->SetFolder(pFolder);
- else
- {
- // Use set default folder as Microsoft recommends in the IFileDialog documentation.
- iDialog->SetDefaultFolder(pFolder);
- }
+ iDialog->SetFolder(pFolder);
}
-void VistaFilePickerImpl::impl_sta_GetDirectory(const RequestRef& rRequest)
+OUString VistaFilePickerImpl::GetDirectory()
{
TFileDialog iDialog = impl_getBaseDialogInterface();
ComPtr< IShellItem > pFolder;
HRESULT hResult = iDialog->GetFolder( &pFolder );
if ( FAILED(hResult) )
- return;
- OUString sFolder = lcl_getURLFromShellItem ( pFolder );
- if( sFolder.getLength())
- rRequest->setArgument( PROP_DIRECTORY, sFolder );
+ return OUString();
+ return lcl_getURLFromShellItem(pFolder);
}
+void VistaFilePickerImpl::impl_sta_GetDirectory(const RequestRef& rRequest)
+{
+ const OUString sFolder = m_sDirectory.isEmpty() ? GetDirectory() : m_sDirectory;
+ if (!sFolder.isEmpty())
+ rRequest->setArgument(PROP_DIRECTORY, sFolder);
+}
void VistaFilePickerImpl::impl_sta_SetDefaultName(const RequestRef& rRequest)
{
@@ -1331,6 +1328,11 @@ bool VistaFilePickerImpl::onFileTypeChanged( UINT /*nTypeIndex*/ )
return true;
}
+void VistaFilePickerImpl::onDirectoryChanged()
+{
+ m_sDirectory = GetDirectory();
+}
+
} // namespace vista
} // namespace win32
} // namespace fpicker
diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx
index cb7468c9f09b..2b226e5fa5e3 100644
--- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx
+++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx
@@ -71,7 +71,6 @@ static const OUString PROP_FEATURES("features" ); // [sal_Int32]
static const OUString PROP_TEMPLATE_DESCR("templatedescription"); // [sal_Int32]
static const OUString PROP_FILTER_TITLE("filter_title" ); // [OUString]
static const OUString PROP_FILTER_VALUE("filter_value" ); // [OUString]
-static const OUString PROP_FORCE("force" ); // [sal_Bool]
static const OUString PROP_FILTER_GROUP("filter-group" ); // [seq< css:beans::StringPair >] contains a group of filters
static const OUString PROP_CONTROL_ID("control_id" ); // [sal_Int16]
@@ -147,9 +146,10 @@ class VistaFilePickerImpl : private ::cppu::BaseMutex
virtual void onAutoExtensionChanged (bool bChecked) override;
virtual bool onFileTypeChanged( UINT nTypeIndex ) override;
+ virtual void onDirectoryChanged() override;
private:
-
+ OUString GetDirectory();
/// implementation of request E_ADD_FILEPICKER_LISTENER
void impl_sta_addFilePickerListener(const RequestRef& rRequest);
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index 136005d5296a..3e9590a22977 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -1552,18 +1552,6 @@
<desc>Contains the current and default path settings used by the
Office.</desc>
</info>
- <group oor:name="Info">
- <info>
- <desc>Contains various properties information purpose only.</desc>
- </info>
- <prop oor:name="WorkPathChanged" oor:type="xs:boolean" oor:nillable="false">
- <info>
- <desc>A flag which is set by the tools options dialog whenever a
- user changed the work path.</desc>
- </info>
- <value>true</value>
- </prop>
- </group>
<group oor:name="Current">
<info>
<desc>Contains the global path settings, mainly those of the Options