mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 02:57:38 +00:00
made chooseOutputFile() more complete; imaplemented QueryInterface() to return nsIFileSpec too
This commit is contained in:
parent
a029b3832e
commit
b5ce558746
@ -24,7 +24,33 @@
|
|||||||
#undef NS_FILE_FAILURE
|
#undef NS_FILE_FAILURE
|
||||||
#define NS_FILE_FAILURE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES,(0xFFFF))
|
#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);
|
static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID);
|
||||||
|
|
||||||
@ -76,9 +102,10 @@ NS_IMETHODIMP nsFileSpecWithUIImpl::ChooseOutputFile(
|
|||||||
|
|
||||||
nsFileDlgResults result = fileWidget->PutFile(nsnull, winTitle, spec);
|
nsFileDlgResults result = fileWidget->PutFile(nsnull, winTitle, spec);
|
||||||
if (result != nsFileDlgResults_OK)
|
if (result != nsFileDlgResults_OK)
|
||||||
return NS_FILE_FAILURE;
|
{
|
||||||
if (spec.Exists() && result != nsFileDlgResults_Replace)
|
if (spec.Exists() && result != nsFileDlgResults_Replace)
|
||||||
return NS_FILE_FAILURE;
|
return NS_FILE_FAILURE;
|
||||||
|
}
|
||||||
return mBaseFileSpec->SetFromFileSpec(spec);
|
return mBaseFileSpec->SetFromFileSpec(spec);
|
||||||
} // nsFileSpecImpl::ChooseOutputFile
|
} // nsFileSpecImpl::ChooseOutputFile
|
||||||
|
|
||||||
@ -115,31 +142,31 @@ void nsFileSpecWithUIImpl::SetFileWidgetFilterList(
|
|||||||
if (mask & eAllReadable)
|
if (mask & eAllReadable)
|
||||||
{
|
{
|
||||||
*nextTitle++ = "All Readable Files";
|
*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)
|
if (mask & eHTMLFiles)
|
||||||
{
|
{
|
||||||
*nextTitle++ = "HTML Files";
|
*nextTitle++ = "HTML Files (*.hml; *.html)";
|
||||||
*nextFilter++ = "*.htm; *.html";
|
*nextFilter++ = "*.htm; *.html";
|
||||||
}
|
}
|
||||||
if (mask & eXMLFiles)
|
if (mask & eXMLFiles)
|
||||||
{
|
{
|
||||||
*nextTitle++ = "XML Files";
|
*nextTitle++ = "XML Files (*.xml)";
|
||||||
*nextFilter++ = "*.xml";
|
*nextFilter++ = "*.xml";
|
||||||
}
|
}
|
||||||
if (mask & eImageFiles)
|
if (mask & eImageFiles)
|
||||||
{
|
{
|
||||||
*nextTitle++ = "Image Files";
|
*nextTitle++ = "Image Files (*.gif; *.jpg; *.jpeg; *.png)";
|
||||||
*nextFilter++ = "*.gif; *.jpg; *.jpeg; *.png";
|
*nextFilter++ = "*.gif; *.jpg; *.jpeg; *.png";
|
||||||
}
|
}
|
||||||
if (mask & eMailFiles)
|
|
||||||
{
|
|
||||||
*nextTitle++ = "Mail Files";
|
|
||||||
*nextFilter++ = "*.eml";
|
|
||||||
}
|
|
||||||
if (mask & eTextFiles)
|
if (mask & eTextFiles)
|
||||||
{
|
{
|
||||||
*nextTitle++ = "Text Files";
|
*nextTitle++ = "Text Files (*.txt)";
|
||||||
*nextFilter++ = "*.txt";
|
*nextFilter++ = "*.txt";
|
||||||
}
|
}
|
||||||
if (mask & eExtraFilter)
|
if (mask & eExtraFilter)
|
||||||
|
Loading…
Reference in New Issue
Block a user