2000-03-22 10:43:43 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2000-03-22 10:43:43 +03:00
|
|
|
|
|
|
|
#ifndef nsFilePicker_h__
|
|
|
|
#define nsFilePicker_h__
|
|
|
|
|
2011-12-15 01:22:28 +04:00
|
|
|
#include <windows.h>
|
|
|
|
|
2012-06-06 06:08:30 +04:00
|
|
|
#include "nsIFile.h"
|
2011-12-15 01:22:28 +04:00
|
|
|
#include "nsITimer.h"
|
2002-09-07 09:23:45 +04:00
|
|
|
#include "nsISimpleEnumerator.h"
|
2009-03-30 22:08:06 +04:00
|
|
|
#include "nsCOMArray.h"
|
2000-03-22 10:43:43 +03:00
|
|
|
#include "nsBaseFilePicker.h"
|
|
|
|
#include "nsString.h"
|
2000-03-22 13:19:48 +03:00
|
|
|
#include "nsdefs.h"
|
2011-12-07 23:01:48 +04:00
|
|
|
#include <commdlg.h>
|
2011-12-15 01:22:28 +04:00
|
|
|
#include <shobjidl.h>
|
2013-12-16 04:00:54 +04:00
|
|
|
#undef LogSeverity // SetupAPI.h #defines this as DWORD
|
2011-12-15 01:22:28 +04:00
|
|
|
|
2012-04-09 23:53:46 +04:00
|
|
|
class nsILoadContext;
|
|
|
|
|
2012-09-03 19:25:08 +04:00
|
|
|
class nsBaseWinFilePicker :
|
|
|
|
public nsBaseFilePicker
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_IMETHOD GetDefaultString(nsAString& aDefaultString);
|
|
|
|
NS_IMETHOD SetDefaultString(const nsAString& aDefaultString);
|
|
|
|
NS_IMETHOD GetDefaultExtension(nsAString& aDefaultExtension);
|
|
|
|
NS_IMETHOD SetDefaultExtension(const nsAString& aDefaultExtension);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
nsString mDefaultFilePath;
|
|
|
|
nsString mDefaultFilename;
|
|
|
|
nsString mDefaultExtension;
|
|
|
|
};
|
|
|
|
|
2000-03-22 10:43:43 +03:00
|
|
|
/**
|
|
|
|
* Native Windows FileSelector wrapper
|
|
|
|
*/
|
|
|
|
|
2012-02-17 04:36:04 +04:00
|
|
|
class nsFilePicker :
|
2012-09-03 19:25:08 +04:00
|
|
|
public IFileDialogEvents,
|
|
|
|
public nsBaseWinFilePicker
|
2000-03-22 10:43:43 +03:00
|
|
|
{
|
2014-07-16 00:40:41 +04:00
|
|
|
virtual ~nsFilePicker();
|
2000-03-22 10:43:43 +03:00
|
|
|
public:
|
2016-07-22 11:56:13 +03:00
|
|
|
nsFilePicker();
|
2000-03-22 10:43:43 +03:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
NS_IMETHOD Init(mozIDOMWindowProxy *aParent, const nsAString& aTitle, int16_t aMode);
|
2016-07-22 11:56:13 +03:00
|
|
|
|
2000-03-22 10:43:43 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
2016-07-22 11:56:13 +03:00
|
|
|
|
2011-12-15 01:22:28 +04:00
|
|
|
// IUnknown's QueryInterface
|
|
|
|
STDMETHODIMP QueryInterface(REFIID refiid, void** ppvResult);
|
2000-08-25 06:17:53 +04:00
|
|
|
|
2012-09-03 19:25:08 +04:00
|
|
|
// nsIFilePicker (less what's in nsBaseFilePicker and nsBaseWinFilePicker)
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHOD GetFilterIndex(int32_t *aFilterIndex);
|
|
|
|
NS_IMETHOD SetFilterIndex(int32_t aFilterIndex);
|
2012-06-06 06:08:30 +04:00
|
|
|
NS_IMETHOD GetFile(nsIFile * *aFile);
|
2008-02-26 19:12:17 +03:00
|
|
|
NS_IMETHOD GetFileURL(nsIURI * *aFileURL);
|
2002-09-07 09:23:45 +04:00
|
|
|
NS_IMETHOD GetFiles(nsISimpleEnumerator **aFiles);
|
2004-04-22 03:38:22 +04:00
|
|
|
NS_IMETHOD AppendFilter(const nsAString& aTitle, const nsAString& aFilter);
|
2000-03-22 10:43:43 +03:00
|
|
|
|
2011-12-15 01:22:28 +04:00
|
|
|
// IFileDialogEvents
|
|
|
|
HRESULT STDMETHODCALLTYPE OnFileOk(IFileDialog *pfd);
|
|
|
|
HRESULT STDMETHODCALLTYPE OnFolderChanging(IFileDialog *pfd, IShellItem *psiFolder);
|
|
|
|
HRESULT STDMETHODCALLTYPE OnFolderChange(IFileDialog *pfd);
|
|
|
|
HRESULT STDMETHODCALLTYPE OnSelectionChange(IFileDialog *pfd);
|
|
|
|
HRESULT STDMETHODCALLTYPE OnShareViolation(IFileDialog *pfd, IShellItem *psi, FDE_SHAREVIOLATION_RESPONSE *pResponse);
|
|
|
|
HRESULT STDMETHODCALLTYPE OnTypeChange(IFileDialog *pfd);
|
|
|
|
HRESULT STDMETHODCALLTYPE OnOverwrite(IFileDialog *pfd, IShellItem *psi, FDE_OVERWRITE_RESPONSE *pResponse);
|
|
|
|
|
2000-03-22 10:43:43 +03:00
|
|
|
protected:
|
|
|
|
/* method from nsBaseFilePicker */
|
2004-04-22 03:38:22 +04:00
|
|
|
virtual void InitNative(nsIWidget *aParent,
|
2017-08-06 07:15:31 +03:00
|
|
|
const nsAString& aTitle) override;
|
|
|
|
nsresult Show(int16_t *aReturnVal) override;
|
|
|
|
nsresult ShowW(int16_t *aReturnVal);
|
2000-03-22 13:19:48 +03:00
|
|
|
void GetFilterListArray(nsString& aFilterList);
|
2016-12-23 05:13:31 +03:00
|
|
|
bool ShowFolderPicker(const nsString& aInitialDir);
|
|
|
|
bool ShowFilePicker(const nsString& aInitialDir);
|
2011-12-15 01:22:16 +04:00
|
|
|
void RememberLastUsedDirectory();
|
|
|
|
bool IsPrivacyModeEnabled();
|
|
|
|
bool IsDefaultPathLink();
|
|
|
|
bool IsDefaultPathHtml();
|
2011-12-15 01:22:28 +04:00
|
|
|
void SetDialogHandle(HWND aWnd);
|
2016-12-23 05:13:31 +03:00
|
|
|
bool ClosePickerIfNeeded();
|
2011-12-15 01:22:28 +04:00
|
|
|
static void PickerCallbackTimerFunc(nsITimer *aTimer, void *aPicker);
|
2000-03-22 10:43:43 +03:00
|
|
|
|
2012-04-09 23:53:46 +04:00
|
|
|
nsCOMPtr<nsILoadContext> mLoadContext;
|
2004-04-22 03:38:22 +04:00
|
|
|
nsCOMPtr<nsIWidget> mParentWidget;
|
2000-03-22 10:43:43 +03:00
|
|
|
nsString mTitle;
|
2000-04-19 03:49:17 +04:00
|
|
|
nsCString mFile;
|
2000-08-25 06:17:53 +04:00
|
|
|
nsString mFilterList;
|
2012-08-22 19:56:38 +04:00
|
|
|
int16_t mSelectedType;
|
2012-06-06 06:08:30 +04:00
|
|
|
nsCOMArray<nsIFile> mFiles;
|
2002-02-02 02:58:55 +03:00
|
|
|
static char mLastUsedDirectory[];
|
2002-07-03 04:55:47 +04:00
|
|
|
nsString mUnicodeFile;
|
2014-01-04 19:02:17 +04:00
|
|
|
static char16_t *mLastUsedUnicodeDirectory;
|
2011-12-15 01:22:28 +04:00
|
|
|
HWND mDlgWnd;
|
2011-12-15 01:22:28 +04:00
|
|
|
|
|
|
|
class ComDlgFilterSpec
|
|
|
|
{
|
|
|
|
public:
|
2012-01-05 00:30:57 +04:00
|
|
|
ComDlgFilterSpec() {}
|
|
|
|
~ComDlgFilterSpec() {}
|
2016-07-22 11:56:13 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
const uint32_t Length() {
|
2012-01-05 00:30:57 +04:00
|
|
|
return mSpecList.Length();
|
2011-12-15 01:22:28 +04:00
|
|
|
}
|
|
|
|
|
2011-12-15 01:22:28 +04:00
|
|
|
const bool IsEmpty() {
|
2012-01-05 00:30:57 +04:00
|
|
|
return (mSpecList.Length() == 0);
|
2011-12-15 01:22:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
const COMDLG_FILTERSPEC* get() {
|
2012-01-05 00:30:57 +04:00
|
|
|
return mSpecList.Elements();
|
2011-12-15 01:22:28 +04:00
|
|
|
}
|
2016-07-22 11:56:13 +03:00
|
|
|
|
2011-12-15 01:22:28 +04:00
|
|
|
void Append(const nsAString& aTitle, const nsAString& aFilter);
|
|
|
|
private:
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<COMDLG_FILTERSPEC, 1> mSpecList;
|
|
|
|
AutoTArray<nsString, 2> mStrings;
|
2011-12-15 01:22:28 +04:00
|
|
|
};
|
|
|
|
|
2011-12-15 01:22:28 +04:00
|
|
|
ComDlgFilterSpec mComFilterList;
|
|
|
|
DWORD mFDECookie;
|
2000-03-22 10:43:43 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsFilePicker_h__
|