made chooseOutputFile() more complete; imaplemented QueryInterface() to return nsIFileSpec too

This commit is contained in:
jefft%netscape.com 1999-09-03 05:30:33 +00:00
parent a029b3832e
commit b5ce558746

View File

@ -24,7 +24,33 @@
#undef NS_FILE_FAILURE
#define NS_FILE_FAILURE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES,(0xFFFF))
NS_IMPL_ISUPPORTS(nsFileSpecWithUIImpl, nsCOMTypeInfo<nsIFileSpecWithUI>::GetIID())
NS_IMPL_ADDREF(nsFileSpecWithUIImpl)
NS_IMPL_RELEASE(nsFileSpecWithUIImpl)
NS_IMETHODIMP nsFileSpecWithUIImpl::QueryInterface(REFNSIID aIID,
void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
*aInstancePtr = NULL;
static NS_DEFINE_IID(kClassIID, nsCOMTypeInfo<nsIFileSpecWithUI>::GetIID());
if (aIID.Equals(kClassIID))
*aInstancePtr = (void*) this;
else if (aIID.Equals(nsCOMTypeInfo<nsIFileSpec>::GetIID()))
*aInstancePtr = (void*) this;
else if (aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID()))
*aInstancePtr = (void*) ((nsISupports*)this);
if (*aInstancePtr)
{
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID);
@ -76,9 +102,10 @@ NS_IMETHODIMP nsFileSpecWithUIImpl::ChooseOutputFile(
nsFileDlgResults result = fileWidget->PutFile(nsnull, winTitle, spec);
if (result != nsFileDlgResults_OK)
return NS_FILE_FAILURE;
if (spec.Exists() && result != nsFileDlgResults_Replace)
return NS_FILE_FAILURE;
{
if (spec.Exists() && result != nsFileDlgResults_Replace)
return NS_FILE_FAILURE;
}
return mBaseFileSpec->SetFromFileSpec(spec);
} // nsFileSpecImpl::ChooseOutputFile
@ -115,31 +142,31 @@ void nsFileSpecWithUIImpl::SetFileWidgetFilterList(
if (mask & eAllReadable)
{
*nextTitle++ = "All Readable Files";
*nextFilter++ = "*.htm; *.html; *.xml; *.gif; *.jpg; *.jpeg; *.png";
*nextFilter++ = "*.eml; *.txt; *.htm; *.html; *.xml; *.gif; *.jpg; *.jpeg; *.png";
}
if (mask & eMailFiles)
{
*nextTitle++ = "Mail Files (*.eml)";
*nextFilter++ = "*.eml";
}
if (mask & eHTMLFiles)
{
*nextTitle++ = "HTML Files";
*nextTitle++ = "HTML Files (*.hml; *.html)";
*nextFilter++ = "*.htm; *.html";
}
if (mask & eXMLFiles)
{
*nextTitle++ = "XML Files";
*nextTitle++ = "XML Files (*.xml)";
*nextFilter++ = "*.xml";
}
if (mask & eImageFiles)
{
*nextTitle++ = "Image Files";
*nextTitle++ = "Image Files (*.gif; *.jpg; *.jpeg; *.png)";
*nextFilter++ = "*.gif; *.jpg; *.jpeg; *.png";
}
if (mask & eMailFiles)
{
*nextTitle++ = "Mail Files";
*nextFilter++ = "*.eml";
}
if (mask & eTextFiles)
{
*nextTitle++ = "Text Files";
*nextTitle++ = "Text Files (*.txt)";
*nextFilter++ = "*.txt";
}
if (mask & eExtraFilter)