From 6d56b78e872530bbb3dde0e40040e0c50ca04c67 Mon Sep 17 00:00:00 2001 From: "sfraser%netscape.com" Date: Fri, 11 Jun 1999 19:03:05 +0000 Subject: [PATCH] GetLocalFileURL has moved to the editorShell git-svn-id: svn://10.0.0.236/trunk@34819 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/editor/base/nsHTMLEditor.cpp | 63 +------------------ mozilla/editor/base/nsHTMLEditor.h | 2 - .../editor/libeditor/html/nsHTMLEditor.cpp | 63 +------------------ mozilla/editor/libeditor/html/nsHTMLEditor.h | 2 - mozilla/editor/public/nsIHTMLEditor.h | 2 - 5 files changed, 4 insertions(+), 128 deletions(-) diff --git a/mozilla/editor/base/nsHTMLEditor.cpp b/mozilla/editor/base/nsHTMLEditor.cpp index a344a4e278f..834229a61ab 100644 --- a/mozilla/editor/base/nsHTMLEditor.cpp +++ b/mozilla/editor/base/nsHTMLEditor.cpp @@ -1946,7 +1946,7 @@ nsHTMLEditor::InsertImage(nsString& aURL, nsCOMPtr parentNode; PRInt32 offsetOfNewNode; - res = nsEditor::DeleteSelectionAndPrepareToCreateNode(parentNode, + res = DeleteSelectionAndPrepareToCreateNode(parentNode, offsetOfNewNode); if (NS_SUCCEEDED(res)) { @@ -2168,7 +2168,7 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection) mJSEditorLog->InsertElement(aElement, aDeleteSelection); #endif // ENABLE_JS_EDITOR_LOG - nsresult res=NS_ERROR_NOT_INITIALIZED; + nsresult res = NS_ERROR_NOT_INITIALIZED; if (!aElement) return NS_ERROR_NULL_POINTER; @@ -2485,65 +2485,6 @@ NS_IMETHODIMP nsHTMLEditor::SetCompositionString(const nsString& aCompositionStr return nsTextEditor::SetCompositionString(aCompositionString); } -// Call the platform-specific file picker and convert it to URL format -NS_IMETHODIMP nsHTMLEditor::GetLocalFileURL(nsIDOMWindow* aParent, const nsString& aFilterType, nsString& aReturn) -{ - PRBool htmlFilter = aFilterType.EqualsIgnoreCase("html"); - PRBool imgFilter = aFilterType.EqualsIgnoreCase("img"); - - aReturn = ""; - - // TODO: DON'T ACCEPT NULL PARENT AFTER WIDGET IS FIXED - if (/*!aParent||*/ !(htmlFilter || imgFilter)) - return NS_ERROR_NOT_INITIALIZED; - - - nsCOMPtr fileWidget; - // TODO: WHERE TO WE PUT GLOBAL STRINGS TO BE LOCALIZED? - nsString title(htmlFilter ? "Open HTML file" : "Select Image File"); - nsFileSpec fileSpec; - // TODO: GET THE DEFAULT DIRECTORY FOR DIFFERENT TYPES FROM PREFERENCES - nsFileSpec aDisplayDirectory; - - nsresult res = nsComponentManager::CreateInstance(kFileWidgetCID, - nsnull, - nsIFileWidget::GetIID(), - (void**)&fileWidget); - - if (NS_SUCCEEDED(res)) - { - nsFileDlgResults dialogResult; - if (htmlFilter) - { - nsAutoString titles[] = {"HTML Files"}; - nsAutoString filters[] = {"*.htm; *.html; *.shtml"}; - fileWidget->SetFilterList(1, titles, filters); - dialogResult = fileWidget->GetFile(nsnull, title, fileSpec); - } else { - nsAutoString titles[] = {"Image Files"}; - nsAutoString filters[] = {"*.gif; *.jpg; *.jpeg; *.png"}; - fileWidget->SetFilterList(1, titles, filters); - dialogResult = fileWidget->GetFile(nsnull, title, fileSpec); - } - // Do this after we get this from preferences - //fileWidget->SetDisplayDirectory(aDisplayDirectory); - // First param should be Parent window, but type is nsIWidget* - // Bug is filed to change this to a more suitable window type - if (dialogResult != nsFileDlgResults_Cancel) - { - // Get the platform-specific format - // Convert it to the string version of the URL format - // NOTE: THIS CRASHES IF fileSpec is empty - nsFileURL url(fileSpec); - aReturn = url.GetURLString(); - } - // TODO: SAVE THIS TO THE PREFS? - fileWidget->GetDisplayDirectory(aDisplayDirectory); - } - - return res; -} - NS_IMETHODIMP nsHTMLEditor::DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed) { diff --git a/mozilla/editor/base/nsHTMLEditor.h b/mozilla/editor/base/nsHTMLEditor.h index b586fc9c24d..7f8281325e1 100644 --- a/mozilla/editor/base/nsHTMLEditor.h +++ b/mozilla/editor/base/nsHTMLEditor.h @@ -164,8 +164,6 @@ public: NS_IMETHOD DeleteTableRow(PRInt32 aNumber); NS_IMETHOD JoinTableCells(PRBool aCellToRight); - NS_IMETHOD GetLocalFileURL(nsIDOMWindow* aParent, const nsString& aFilterType, nsString& aReturn); - // Data members protected: diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp index a344a4e278f..834229a61ab 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp @@ -1946,7 +1946,7 @@ nsHTMLEditor::InsertImage(nsString& aURL, nsCOMPtr parentNode; PRInt32 offsetOfNewNode; - res = nsEditor::DeleteSelectionAndPrepareToCreateNode(parentNode, + res = DeleteSelectionAndPrepareToCreateNode(parentNode, offsetOfNewNode); if (NS_SUCCEEDED(res)) { @@ -2168,7 +2168,7 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection) mJSEditorLog->InsertElement(aElement, aDeleteSelection); #endif // ENABLE_JS_EDITOR_LOG - nsresult res=NS_ERROR_NOT_INITIALIZED; + nsresult res = NS_ERROR_NOT_INITIALIZED; if (!aElement) return NS_ERROR_NULL_POINTER; @@ -2485,65 +2485,6 @@ NS_IMETHODIMP nsHTMLEditor::SetCompositionString(const nsString& aCompositionStr return nsTextEditor::SetCompositionString(aCompositionString); } -// Call the platform-specific file picker and convert it to URL format -NS_IMETHODIMP nsHTMLEditor::GetLocalFileURL(nsIDOMWindow* aParent, const nsString& aFilterType, nsString& aReturn) -{ - PRBool htmlFilter = aFilterType.EqualsIgnoreCase("html"); - PRBool imgFilter = aFilterType.EqualsIgnoreCase("img"); - - aReturn = ""; - - // TODO: DON'T ACCEPT NULL PARENT AFTER WIDGET IS FIXED - if (/*!aParent||*/ !(htmlFilter || imgFilter)) - return NS_ERROR_NOT_INITIALIZED; - - - nsCOMPtr fileWidget; - // TODO: WHERE TO WE PUT GLOBAL STRINGS TO BE LOCALIZED? - nsString title(htmlFilter ? "Open HTML file" : "Select Image File"); - nsFileSpec fileSpec; - // TODO: GET THE DEFAULT DIRECTORY FOR DIFFERENT TYPES FROM PREFERENCES - nsFileSpec aDisplayDirectory; - - nsresult res = nsComponentManager::CreateInstance(kFileWidgetCID, - nsnull, - nsIFileWidget::GetIID(), - (void**)&fileWidget); - - if (NS_SUCCEEDED(res)) - { - nsFileDlgResults dialogResult; - if (htmlFilter) - { - nsAutoString titles[] = {"HTML Files"}; - nsAutoString filters[] = {"*.htm; *.html; *.shtml"}; - fileWidget->SetFilterList(1, titles, filters); - dialogResult = fileWidget->GetFile(nsnull, title, fileSpec); - } else { - nsAutoString titles[] = {"Image Files"}; - nsAutoString filters[] = {"*.gif; *.jpg; *.jpeg; *.png"}; - fileWidget->SetFilterList(1, titles, filters); - dialogResult = fileWidget->GetFile(nsnull, title, fileSpec); - } - // Do this after we get this from preferences - //fileWidget->SetDisplayDirectory(aDisplayDirectory); - // First param should be Parent window, but type is nsIWidget* - // Bug is filed to change this to a more suitable window type - if (dialogResult != nsFileDlgResults_Cancel) - { - // Get the platform-specific format - // Convert it to the string version of the URL format - // NOTE: THIS CRASHES IF fileSpec is empty - nsFileURL url(fileSpec); - aReturn = url.GetURLString(); - } - // TODO: SAVE THIS TO THE PREFS? - fileWidget->GetDisplayDirectory(aDisplayDirectory); - } - - return res; -} - NS_IMETHODIMP nsHTMLEditor::DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed) { diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.h b/mozilla/editor/libeditor/html/nsHTMLEditor.h index b586fc9c24d..7f8281325e1 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.h +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.h @@ -164,8 +164,6 @@ public: NS_IMETHOD DeleteTableRow(PRInt32 aNumber); NS_IMETHOD JoinTableCells(PRBool aCellToRight); - NS_IMETHOD GetLocalFileURL(nsIDOMWindow* aParent, const nsString& aFilterType, nsString& aReturn); - // Data members protected: diff --git a/mozilla/editor/public/nsIHTMLEditor.h b/mozilla/editor/public/nsIHTMLEditor.h index 15e7920a743..18b115250ac 100644 --- a/mozilla/editor/public/nsIHTMLEditor.h +++ b/mozilla/editor/public/nsIHTMLEditor.h @@ -107,8 +107,6 @@ public: NS_IMETHOD OutputTextToStream(nsIOutputStream* aOutputStream, nsString* aCharsetOverride = nsnull)=0; NS_IMETHOD OutputHTMLToStream(nsIOutputStream* aOutputStream, nsString* aCharsetOverride = nsnull)=0; - NS_IMETHOD GetLocalFileURL(nsIDOMWindow* aParent, const nsString& aFilterType, nsString& aReturn)=0; - // Miscellaneous Methods /** Set the background color of the selected table cell, row, columne, or table, * or the document background if not in a table