From 5cfaaa1ec68a884444de4e7805d0d314cb3dd399 Mon Sep 17 00:00:00 2001 From: "pavlov%netscape.com" Date: Thu, 23 Mar 2000 01:11:34 +0000 Subject: [PATCH] updates for filtering --- widget/src/windows/nsFilePicker.cpp | 45 +++++++---------------------- widget/src/windows/nsFilePicker.h | 4 +-- 2 files changed, 12 insertions(+), 37 deletions(-) diff --git a/widget/src/windows/nsFilePicker.cpp b/widget/src/windows/nsFilePicker.cpp index a9e7b9a06091..686be079d66e 100644 --- a/widget/src/windows/nsFilePicker.cpp +++ b/widget/src/windows/nsFilePicker.cpp @@ -49,7 +49,6 @@ nsFilePicker::nsFilePicker() { NS_INIT_REFCNT(); mWnd = NULL; - mNumberOfFilters = 0; mUnicodeEncoder = nsnull; mUnicodeDecoder = nsnull; mDisplayDirectory = do_CreateInstance("component://mozilla/file/local"); @@ -91,9 +90,7 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *retval) ofn.lStructSize = sizeof(ofn); - nsString filterList; - GetFilterListArray(filterList); - char *filterBuffer = filterList.ToNewCString(); + char *filterBuffer = mFilterList.ToNewCString(); char *title = ConvertToFileSystemCharset(mTitle.GetUnicode()); if (nsnull == title) title = mTitle.ToNewCString(); @@ -161,15 +158,21 @@ NS_IMETHODIMP nsFilePicker::SetFilterList(PRUint32 aNumberOfFilters, const PRUnichar **aTitles, const PRUnichar **aFilters) { - mNumberOfFilters = aNumberOfFilters; - mTitles = aTitles; - mFilters = aFilters; + mFilterList.SetLength(0); + for (PRUint32 i = 0; i < aNumberOfFilters; i++) { + mFilterList.Append(aTitles[i]); + mFilterList.Append('\0'); + mFilterList.Append(aFilters[i]); + mFilterList.Append('\0'); + } + mFilterList.Append('\0'); + return NS_OK; } NS_IMETHODIMP nsFilePicker::GetFile(nsILocalFile **aFile) { - NS_ENSURE_ARG_POINTER(*aFile); + /*NS_ENSURE_ARG_POINTER(*aFile); */ nsCOMPtr file(do_CreateInstance("component://mozilla/file/local")); @@ -251,32 +254,6 @@ NS_IMETHODIMP nsFilePicker::CreateNative(nsIWidget *aParent, } - -//------------------------------------------------------------------------- -// -// Convert filter titles + filters into a Windows filter string -// -//------------------------------------------------------------------------- - -void nsFilePicker::GetFilterListArray(nsString& aFilterList) -{ - aFilterList.SetLength(0); - for (PRUint32 i = 0; i < mNumberOfFilters; i++) { - const nsString& title = mTitles[i]; - const nsString& filter = nsAutoString(mFilters[i]); - - aFilterList.Append(title); - aFilterList.Append('\0'); - aFilterList.Append(filter); - aFilterList.Append('\0'); - } - aFilterList.Append('\0'); -} - - - - - //------------------------------------------------------------------------- void nsFilePicker::GetFileSystemCharset(nsString & fileSystemCharset) { diff --git a/widget/src/windows/nsFilePicker.h b/widget/src/windows/nsFilePicker.h index 8a37e16f217c..fea03c4c63a3 100644 --- a/widget/src/windows/nsFilePicker.h +++ b/widget/src/windows/nsFilePicker.h @@ -60,9 +60,7 @@ protected: nsString mTitle; PRInt16 mMode; nsString mFile; - PRUint32 mNumberOfFilters; - const PRUnichar** mTitles; - const PRUnichar** mFilters; + nsString mFilterList; nsString mDefault; nsIUnicodeEncoder* mUnicodeEncoder; nsIUnicodeDecoder* mUnicodeDecoder;