summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/Common.xcs12
-rw-r--r--sfx2/inc/sfx2/app.hxx1
-rw-r--r--sfx2/inc/sfx2/filedlghelper.hxx3
-rw-r--r--sfx2/source/appl/app.cxx8
-rw-r--r--sfx2/source/appl/shutdownicon.cxx6
-rw-r--r--svx/source/cui/optpath.cxx24
10 files changed, 200 insertions, 23 deletions
diff --git a/fpicker/source/win32/filepicker/VistaFilePicker.cxx b/fpicker/source/win32/filepicker/VistaFilePicker.cxx
index eb26f23952d7..84d17dbbc0b1 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 38ca768da08b..23467f148f4b 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 6046876207fc..b15b5c24c52d 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 ee7cd363794e..bd945a2d7939 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
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index 52045f4f9e62..b9bd1b56b4cc 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -1455,6 +1455,18 @@ Dymamic border coloring means that when the mouse is hovered over a control, and
<author>MBA</author>
<desc>Contains the current and default path settings used by the Office.</desc>
</info>
+ <group oor:name="Info">
+ <info>
+ <author>CD</author>
+ <desc>Contains various properties information purpose only.</desc>
+ </info>
+ <prop oor:name="WorkPathChanged" oor:type="xs:boolean">
+ <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>
<author>MBA</author>
diff --git a/sfx2/inc/sfx2/app.hxx b/sfx2/inc/sfx2/app.hxx
index ceac3c18ba5e..99deee0c97a3 100644
--- a/sfx2/inc/sfx2/app.hxx
+++ b/sfx2/inc/sfx2/app.hxx
@@ -262,6 +262,7 @@ public:
BOOL bActivate,
BOOL bForbidVisible = FALSE,
const String* pPostStr = 0);
+ void ResetLastDir();
//#if 0 // _SOLAR__PRIVATE
SAL_DLLPRIVATE static SfxApplication* Is_Impl() { return pApp;}
diff --git a/sfx2/inc/sfx2/filedlghelper.hxx b/sfx2/inc/sfx2/filedlghelper.hxx
index f9377f9908ea..2782fdc3bb0f 100644
--- a/sfx2/inc/sfx2/filedlghelper.hxx
+++ b/sfx2/inc/sfx2/filedlghelper.hxx
@@ -239,6 +239,9 @@ public:
/** Provides the selected files with full path information */
::com::sun::star::uno::Sequence< ::rtl::OUString > GetSelectedFiles() const;
+ /** Provides the selected files with full path information */
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > GetSelectedFiles() const;
+
void AddFilter( const String& rFilterName, const String& rExtension );
void SetCurrentFilter( const String& rFilter );
diff --git a/sfx2/source/appl/app.cxx b/sfx2/source/appl/app.cxx
index b7f0ab91feee..d74bbd0961d9 100644
--- a/sfx2/source/appl/app.cxx
+++ b/sfx2/source/appl/app.cxx
@@ -460,6 +460,14 @@ void SfxApplication::SetLastDir_Impl
//--------------------------------------------------------------------
+void SfxApplication::ResetLastDir()
+{
+ String aEmpty;
+ pAppData_Impl->aLastDir = aEmpty;
+}
+
+//--------------------------------------------------------------------
+
SfxDispatcher* SfxApplication::GetDispatcher_Impl()
{
return pAppData_Impl->pViewFrame? pAppData_Impl->pViewFrame->GetDispatcher(): pAppData_Impl->pAppDispat;
diff --git a/sfx2/source/appl/shutdownicon.cxx b/sfx2/source/appl/shutdownicon.cxx
index b4514976e48d..995b8250e072 100644
--- a/sfx2/source/appl/shutdownicon.cxx
+++ b/sfx2/source/appl/shutdownicon.cxx
@@ -494,6 +494,12 @@ IMPL_STATIC_LINK( ShutdownIcon, DialogClosedHdl_Impl, FileDialogHelper*, EMPTYAR
}
}
+#ifdef WNT
+ // #103346 Destroy dialog to prevent problems with custom controls
+ delete pThis->m_pFileDlg;
+ pThis->m_pFileDlg = NULL;
+#endif
+
LeaveModalMode();
return 0;
}
diff --git a/svx/source/cui/optpath.cxx b/svx/source/cui/optpath.cxx
index b31d56493aed..eeef9ec75fea 100644
--- a/svx/source/cui/optpath.cxx
+++ b/svx/source/cui/optpath.cxx
@@ -41,6 +41,7 @@
#include <tools/shl.hxx>
#include <vcl/msgbox.hxx>
#include <sfx2/filedlghelper.hxx>
+#include <sfx2/app.hxx>
#include <svtools/pickerhelper.hxx>
#include <svtools/aeitem.hxx>
#include <svtools/svtabbx.hxx>
@@ -52,6 +53,7 @@
#include <unotools/localfilehelper.hxx>
#include <svtools/pathoptions.hxx>
#include <svtools/moduleoptions.hxx>
+#include <svtools/viewoptions.hxx>
#define _SVX_OPTPATH_CXX
@@ -62,6 +64,7 @@
#include <svx/dialogs.hrc>
#include "helpid.hrc"
#include <comphelper/processfactory.hxx>
+#include <comphelper/configurationhelper.hxx>
#include <com/sun/star/uno/Exception.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
@@ -91,6 +94,7 @@ using namespace svx;
#define POSTFIX_WRITABLE String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "_writable" ) )
#define POSTFIX_READONLY String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "_readonly" ) )
#define VAR_ONE String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "%1" ) )
+#define IODLG_CONFIGNAME String(DEFINE_CONST_UNICODE("FilePicker_Save"))
// struct OptPath_Impl ---------------------------------------------------
@@ -536,6 +540,26 @@ void SvxPathTabPage::ChangeCurrentEntry( const String& _rFolder )
pPathImpl = (PathUserData_Impl*)pPathBox->GetEntry(nPos)->GetUserData();
pPathImpl->eState = SFX_ITEM_SET;
pPathImpl->sWritablePath = sNewPathStr;
+ if ( SvtPathOptions::PATH_WORK == pPathImpl->nRealId )
+ {
+ // Remove view options entry so the new work path
+ // will be used for the next open dialog.
+ SvtViewOptions aDlgOpt( E_DIALOG, IODLG_CONFIGNAME );
+ aDlgOpt.Delete();
+ // Reset also last used dir in the sfx application instance
+ SfxApplication *pSfxApp = SFX_APP();
+ pSfxApp->ResetLastDir();
+
+ // Set configuration flag to notify file picker that it's necessary
+ // to take over the path provided.
+ Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
+ ::comphelper::ConfigurationHelper::writeDirectKey(xFactory,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Common/")),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Path/Info")),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("WorkPathChanged")),
+ ::com::sun::star::uno::makeAny(true),
+ ::comphelper::ConfigurationHelper::E_STANDARD);
+ }
}
}