summaryrefslogtreecommitdiff
path: root/fpicker/source
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2009-07-30 10:30:12 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2009-07-30 10:30:12 +0000
commit2882ddb948aa65f88031bba5905652862168723c (patch)
treeb7c17017eb496543e4e81e03223ec17a8dcd0c2f /fpicker/source
parent134f7be2681e0fdfb94039cfeb77d634a9382dc5 (diff)
CWS-TOOLING: integrate CWS filepicker02
2009-07-24 16:20:33 +0200 cd r274312 : #i95152# Use trimTrailingBlanks() correctly 2009-07-21 14:41:50 +0200 cd r274197 : #i103566# Makes fixes for MinGW port 2009-07-20 10:45:57 +0200 cd r274112 : #i95152# Return empty string when there are only blanks 2009-07-17 14:53:51 +0200 cd r274093 : #i95152# Old Windows file picker implementation now trims trailing blanks like the new Vista file picker 2009-07-17 09:45:38 +0200 cd r274080 : #i99759# Apply stability fixes from CWS filepicker01 to help QA 2009-07-17 09:00:26 +0200 cd r274078 : #i95336# Extend SfxApplication to reset last used directory 2009-07-17 08:59:10 +0200 cd r274077 : #i99759# Apply fix from filepicker01 to filepicker02 to help QA 2009-07-17 08:58:45 +0200 cd r274076 : #i99759# Apply fix from filepicker01 to filepicker02 to help QA 2009-07-16 16:08:17 +0200 cd r274059 : #103566# Use AddPlace as a fallback for directories which are not change the current folder 2009-07-16 11:54:26 +0200 cd r274038 : #i103566# Use provided folder and filename to decide to set the folder in the file dialog 2009-07-15 17:19:47 +0200 cd r274016 : #i95336# Set flag to true to force the file picker to use the default working path. 2009-07-14 14:49:48 +0200 cd r273977 : #i103346# Set work path flag to indicate file picker to use work path once 2009-07-14 14:47:49 +0200 cd r273976 : #i95336# New configuration entry for work path changes via Tools-Options 2009-07-14 14:46:19 +0200 cd r273975 : #i95336# Force file picker to use a changed work path once 2009-07-14 10:19:54 +0200 cd r273961 : #i103346# Add new advice for file picker usage. Especially for Windows Vista and higher. 2009-07-09 10:32:08 +0200 cd r273852 : #i97053# Use SetFolder()/AddPlace() for Open dialog, too. 2009-07-06 14:59:06 +0200 cd r273746 : #i103346# Destroy dialog instance within close handler to prevent problems with custom controls under Windows 2009-07-03 15:25:48 +0200 cd r273707 : #i94054# Add resource access to read localized labels for custom controls. Use SetControlLabel to set the localized label
Diffstat (limited to 'fpicker/source')
-rw-r--r--fpicker/source/win32/filepicker/VistaFilePicker.cxx16
-rw-r--r--fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx125
-rw-r--r--fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx5
-rw-r--r--fpicker/source/win32/filepicker/filepickerstate.cxx23
4 files changed, 146 insertions, 23 deletions
diff --git a/fpicker/source/win32/filepicker/VistaFilePicker.cxx b/fpicker/source/win32/filepicker/VistaFilePicker.cxx
index fe6ebbfde0..a80604c18f 100644
--- a/fpicker/source/win32/filepicker/VistaFilePicker.cxx
+++ b/fpicker/source/win32/filepicker/VistaFilePicker.cxx
@@ -51,6 +51,7 @@
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
#include <cppuhelper/interfacecontainer.h>
+#include <comphelper/configurationhelper.hxx>
#include <osl/diagnose.h>
#include <osl/mutex.hxx>
#include <osl/file.hxx>
@@ -294,9 +295,24 @@ void SAL_CALL VistaFilePicker::setDisplayDirectory(const ::rtl::OUString& sDirec
throw (css::lang::IllegalArgumentException,
css::uno::RuntimeException )
{
+ const ::rtl::OUString aPackage( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Common/"));
+ const ::rtl::OUString aRelPath( RTL_CONSTASCII_USTRINGPARAM("Path/Info"));
+ const ::rtl::OUString aKey( RTL_CONSTASCII_USTRINGPARAM("WorkPathChanged"));
+
+ css::uno::Any aValue = ::comphelper::ConfigurationHelper::readDirectKey(
+ m_xSMGR, aPackage, aRelPath, aKey, ::comphelper::ConfigurationHelper::E_READONLY);
+
+ bool bChanged(false);
+ if (( aValue >>= bChanged ) && bChanged )
+ {
+ ::comphelper::ConfigurationHelper::writeDirectKey(
+ m_xSMGR, aPackage, aRelPath, aKey, css::uno::makeAny(false), ::comphelper::ConfigurationHelper::E_STANDARD);
+ }
+
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/VistaFilePickerImpl.cxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
index 70c906a6fd..0be04ecfeb 100644
--- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
+++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
@@ -40,6 +40,7 @@
#include <comphelper/sequenceasvector.hxx>
#include <osl/file.hxx>
#include <osl/mutex.hxx>
+#include "..\misc\WinImplHelper.hxx"
inline bool is_current_process_window(HWND hwnd)
{
@@ -461,6 +462,14 @@ static const ::sal_Int32 GROUP_IMAGETEMPLATE = 3;
static const ::sal_Int32 GROUP_CHECKBOXES = 4;
//-------------------------------------------------------------------------------
+static void setLabelToControl(CResourceProvider& rResourceProvider, TFileDialogCustomize iCustom, sal_uInt16 nControlId)
+{
+ ::rtl::OUString aLabel = rResourceProvider.getResString(nControlId);
+ aLabel = SOfficeToWindowsLabel(aLabel);
+ iCustom->SetControlLabel(nControlId, reinterpret_cast<LPCWSTR>(aLabel.getStr()) );
+}
+
+//-------------------------------------------------------------------------------
void VistaFilePickerImpl::impl_sta_enableFeatures(::sal_Int32 nFeatures, ::sal_Int32 nTemplate)
{
GUID aGUID = {};
@@ -535,23 +544,48 @@ void VistaFilePickerImpl::impl_sta_enableFeatures(::sal_Int32 nFeatures, ::sal_I
iCustom->StartVisualGroup (GROUP_CHECKBOXES, L"");
+ sal_uInt16 nControlId(0);
if ((nFeatures & FEATURE_AUTOEXTENSION) == FEATURE_AUTOEXTENSION)
- iCustom->AddCheckButton (css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, L"Auto Extension", true);
+ {
+ nControlId = css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION;
+ iCustom->AddCheckButton (nControlId, L"Auto Extension", true);
+ setLabelToControl(m_ResProvider, iCustom, nControlId);
+ }
if ((nFeatures & FEATURE_PASSWORD) == FEATURE_PASSWORD)
- iCustom->AddCheckButton (css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, L"Password", false);
+ {
+ nControlId = css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_PASSWORD;
+ iCustom->AddCheckButton (nControlId, L"Password", false);
+ setLabelToControl(m_ResProvider, iCustom, nControlId);
+ }
if ((nFeatures & FEATURE_READONLY) == FEATURE_READONLY)
- iCustom->AddCheckButton (css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_READONLY, L"Readonly", false);
+ {
+ nControlId = css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_READONLY;
+ iCustom->AddCheckButton (nControlId, L"Readonly", false);
+ setLabelToControl(m_ResProvider, iCustom, nControlId);
+ }
if ((nFeatures & FEATURE_FILTEROPTIONS) == FEATURE_FILTEROPTIONS)
- iCustom->AddCheckButton (css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS, L"Filter Options", false);
+ {
+ nControlId = css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS;
+ iCustom->AddCheckButton (nControlId, L"Filter Options", false);
+ setLabelToControl(m_ResProvider, iCustom, nControlId);
+ }
if ((nFeatures & FEATURE_LINK) == FEATURE_LINK)
- iCustom->AddCheckButton (css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, L"Link", false);
+ {
+ nControlId = css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK;
+ iCustom->AddCheckButton (nControlId, L"Link", false);
+ setLabelToControl(m_ResProvider, iCustom, nControlId);
+ }
if ((nFeatures & FEATURE_SELECTION) == FEATURE_SELECTION)
- iCustom->AddCheckButton (css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_SELECTION, L"Selection", false);
+ {
+ nControlId = css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_SELECTION;
+ iCustom->AddCheckButton (nControlId, L"Selection", false);
+ setLabelToControl(m_ResProvider, iCustom, nControlId);
+ }
/* can be ignored ... new COM dialog supports preview native now !
if ((nFeatures & FEATURE_PREVIEW) == FEATURE_PREVIEW)
@@ -619,8 +653,9 @@ void VistaFilePickerImpl::impl_sta_SetFileName(const RequestRef& rRequest)
void VistaFilePickerImpl::impl_sta_SetDirectory(const RequestRef& rRequest)
{
::rtl::OUString sDirectory = rRequest->getArgumentOrDefault(PROP_DIRECTORY, ::rtl::OUString());
+ bool bForce = rRequest->getArgumentOrDefault(PROP_FORCE, false);
- if( !m_bInExecute )
+ if( !m_bInExecute)
{
// Vista stores last used folders for file dialogs
// so we don't want the application to change the folder
@@ -628,7 +663,6 @@ void VistaFilePickerImpl::impl_sta_SetDirectory(const RequestRef& rRequest)
// Store the requested folder in the mean time and decide later
// what to do
m_sDirectory = sDirectory;
- return;
}
// SYNCHRONIZED->
@@ -646,7 +680,13 @@ void VistaFilePickerImpl::impl_sta_SetDirectory(const RequestRef& rRequest)
if ( FAILED(hResult) )
return;
- iDialog->SetFolder(pFolder);
+ if ( m_bInExecute || bForce )
+ iDialog->SetFolder(pFolder);
+ else
+ {
+ // Use set default folder as Microsoft recommends in the IFileDialog documentation.
+ iDialog->SetDefaultFolder(pFolder);
+ }
}
void VistaFilePickerImpl::impl_sta_GetDirectory(const RequestRef& rRequest)
@@ -814,21 +854,62 @@ void VistaFilePickerImpl::impl_sta_ShowDialogModal(const RequestRef& rRequest)
aLock.clear();
// <- SYNCHRONIZED
+ // we set the directory only if we have a save dialog and a filename
+ // for the other cases, the file dialog remembers its last location
+ // according to its client guid.
if( m_sDirectory.getLength())
{
- // we set the directory only if we have a save dialog and a filename
- // for the other cases, the file dialog remembers its last location
- // according to its client guid.
- if (iSave.is() && m_sFilename.getLength())
+ ComPtr< IShellItem > pFolder;
+ #ifdef __MINGW32__
+ HRESULT hResult = SHCreateItemFromParsingName ( reinterpret_cast<LPCTSTR>(m_sDirectory.getStr()), NULL, IID_IShellItem, (void**)(&pFolder) );
+ #else
+ HRESULT hResult = SHCreateItemFromParsingName ( m_sDirectory, NULL, IID_PPV_ARGS(&pFolder) );
+ #endif
+ if ( SUCCEEDED(hResult) )
{
- ComPtr< IShellItem > pFolder;
- #ifdef __MINGW32__
- HRESULT hResult = SHCreateItemFromParsingName ( reinterpret_cast<LPCTSTR>(m_sDirectory.getStr()), NULL, IID_IShellItem, (void**)(&pFolder) );
- #else
- HRESULT hResult = SHCreateItemFromParsingName ( m_sDirectory, NULL, IID_PPV_ARGS(&pFolder) );
- #endif
- if ( SUCCEEDED(hResult) )
- iDialog->SetFolder(pFolder);
+ if (m_sFilename.getLength())
+ {
+ ::rtl::OUString aFileURL(m_sDirectory);
+ sal_Int32 nIndex = aFileURL.lastIndexOf('/');
+ if (nIndex != aFileURL.getLength()-1)
+ aFileURL += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/"));
+ aFileURL += m_sFilename;
+
+ TFileDialogCustomize iCustom = impl_getCustomizeInterface();
+
+ BOOL bValue = FALSE;
+ HRESULT hResult = iCustom->GetCheckButtonState( css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, &bValue);
+ if ( bValue )
+ {
+ ::rtl::OUString aExt;
+ UINT nFileType;
+ hResult = iDialog->GetFileTypeIndex(&nFileType);
+ if ( SUCCEEDED(hResult) )
+ {
+ ::std::vector< COMDLG_FILTERSPEC > lFilters = lcl_buildFilterList(m_lFilters);
+ LPCWSTR lpFilterExt = lFilters[nFileType].pszSpec;
+
+ lpFilterExt = wcsrchr( lpFilterExt, '.' );
+ if ( lpFilterExt )
+ aFileURL += reinterpret_cast<const sal_Unicode*>(lpFilterExt);
+ }
+ }
+
+ // Check existence of file. Set folder only for this special case
+ ::rtl::OUString aSystemPath;
+ osl_getSystemPathFromFileURL( aFileURL.pData, &aSystemPath.pData );
+
+ WIN32_FIND_DATA aFindFileData;
+ HANDLE hFind = FindFirstFile( reinterpret_cast<LPCWSTR>(aSystemPath.getStr()), &aFindFileData );
+ if (hFind != INVALID_HANDLE_VALUE)
+ iDialog->SetFolder(pFolder);
+ else
+ hResult = iDialog->AddPlace(pFolder, FDAP_TOP);
+
+ FindClose( hFind );
+ }
+ else
+ hResult = iDialog->AddPlace(pFolder, FDAP_TOP);
}
}
@@ -1047,7 +1128,7 @@ void VistaFilePickerImpl::impl_sta_SetControlLabel(const RequestRef& rRequest)
}
//-------------------------------------------------------------------------------
-void VistaFilePickerImpl::impl_sta_GetControlLabel(const RequestRef& rRequest)
+void VistaFilePickerImpl::impl_sta_GetControlLabel(const RequestRef& /*rRequest*/)
{
}
diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx
index 4a0145a241..6f660ee7ab 100644
--- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx
+++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx
@@ -42,6 +42,7 @@
#include "FilterContainer.hxx"
#include "VistaFilePickerEventHandler.hxx"
#include "IVistaFilePickerInternalNotify.hxx"
+#include "..\misc\resourceprovider.hxx"
#include <com/sun/star/uno/Sequence.hxx>
@@ -101,6 +102,7 @@ static const ::rtl::OUString PROP_FEATURES = ::rtl::OUString::createF
static const ::rtl::OUString PROP_TEMPLATE_DESCR = ::rtl::OUString::createFromAscii("templatedescription"); // [sal_Int32]
static const ::rtl::OUString PROP_FILTER_TITLE = ::rtl::OUString::createFromAscii("filter_title" ); // [OUString]
static const ::rtl::OUString PROP_FILTER_VALUE = ::rtl::OUString::createFromAscii("filter_value" ); // [OUString]
+static const ::rtl::OUString PROP_FORCE = ::rtl::OUString::createFromAscii("force" ); // [sal_Bool]
static const ::rtl::OUString PROP_CONTROL_ID = ::rtl::OUString::createFromAscii("control_id" ); // [sal_Int16]
static const ::rtl::OUString PROP_CONTROL_ACTION = ::rtl::OUString::createFromAscii("control_action" ); // [sal_Int16]
@@ -334,6 +336,9 @@ class VistaFilePickerImpl : private ::cppu::BaseMutex
//
::rtl::OUString m_sFilename;
+
+ // Resource provider
+ CResourceProvider m_ResProvider;
};
} // namespace vista
diff --git a/fpicker/source/win32/filepicker/filepickerstate.cxx b/fpicker/source/win32/filepicker/filepickerstate.cxx
index 4fbf9f7d56..dc0858a63a 100644
--- a/fpicker/source/win32/filepicker/filepickerstate.cxx
+++ b/fpicker/source/win32/filepicker/filepickerstate.cxx
@@ -220,6 +220,26 @@ OUString MatchFixBrokenPath(const OUString& path)
return path;
}
+//-----------------------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------------------
+static ::rtl::OUString trimTrailingSpaces(const ::rtl::OUString& rString)
+{
+ rtl::OUString aResult(rString);
+
+ sal_Int32 nIndex = rString.lastIndexOf(' ');
+ if (nIndex == rString.getLength()-1)
+ {
+ while (nIndex >= 0 && rString[nIndex] == ' ')
+ nIndex--;
+ if (nIndex >= 0)
+ aResult = rString.copy(0,nIndex+1);
+ else
+ aResult = ::rtl::OUString();
+ }
+ return aResult;
+}
+
Sequence< OUString > SAL_CALL CNonExecuteFilePickerState::getFiles( CFileOpenDialog* aFileOpenDialog )
{
OSL_PRECOND( aFileOpenDialog, "invalid parameter" );
@@ -258,8 +278,9 @@ Sequence< OUString > SAL_CALL CNonExecuteFilePickerState::getFiles( CFileOpenDia
for ( sal_Int32 i = 0; i < lenFileList; i++ )
{
+ aFilePath = trimTrailingSpaces(aFilePathList[i]);
rc = ::osl::FileBase::getFileURLFromSystemPath(
- aFilePathList[i], aFilePathURL );
+ aFilePath, aFilePathURL );
// we do return all or nothing, that means
// in case of failures we destroy the sequence