Moved the clipboard methods from nsIWebShell into a new interface called nsIClipboardCommands...

This commit is contained in:
rpotts%netscape.com 1998-11-04 08:48:22 +00:00
Родитель e5faf4e3e9
Коммит 3267ac2e2a
3 изменённых файлов: 142 добавлений и 116 удалений

Просмотреть файл

@ -20,6 +20,7 @@
#include "nsIDocumentLoader.h"
#include "nsIContentViewer.h"
#include "nsIDocumentViewer.h"
#include "nsIClipboardCommands.h"
#include "nsIDeviceContext.h"
#include "nsILinkHandler.h"
#include "nsIStreamListener.h"
@ -103,7 +104,8 @@ class nsWebShell : public nsIWebShell,
public nsIDocumentLoaderObserver,
public nsIRefreshUrl,
public nsINetSupport,
public nsIStreamObserver
public nsIStreamObserver,
public nsIClipboardCommands
{
public:
nsWebShell();
@ -233,14 +235,18 @@ public:
NS_IMETHOD_(PRBool) PromptPassword(const nsString &aText,
nsString &aPassword);
// Selection methods
NS_IMETHOD IsSelection(PRBool & aIsSelection);
NS_IMETHOD IsSelectionCutable(PRBool & aIsSelection);
NS_IMETHOD IsSelectionPastable(PRBool & aIsSelection);
NS_IMETHOD GetSelection(PRUnichar *& aSelection);
NS_IMETHOD CutSelection(PRUnichar *& aSelection);
NS_IMETHOD PasteSelection(const PRUnichar * aSelection);
NS_IMETHOD SelectAll();
// nsIClipboardCommands
NS_IMETHOD CanCutSelection (PRBool* aResult);
NS_IMETHOD CanCopySelection (PRBool* aResult);
NS_IMETHOD CanPasteSelection(PRBool* aResult);
NS_IMETHOD CutSelection (void);
NS_IMETHOD CopySelection (void);
NS_IMETHOD PasteSelection(void);
NS_IMETHOD SelectAll(void);
NS_IMETHOD SelectNone(void);
NS_IMETHOD FindNext(const PRUnichar * aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound);
// nsWebShell
@ -327,6 +333,7 @@ static NS_DEFINE_IID(kRefreshURLIID, NS_IREFRESHURL_IID);
static NS_DEFINE_IID(kITimerCallbackIID, NS_ITIMERCALLBACK_IID);
static NS_DEFINE_IID(kIWebShellContainerIID, NS_IWEB_SHELL_CONTAINER_IID);
static NS_DEFINE_IID(kIBrowserWindowIID, NS_IBROWSER_WINDOW_IID);
static NS_DEFINE_IID(kIClipboardCommandsIID, NS_ICLIPBOARDCOMMANDS_IID);
// XXX not sure
static NS_DEFINE_IID(kILinkHandlerIID, NS_ILINKHANDLER_IID);
@ -501,6 +508,11 @@ nsWebShell::QueryInterface(REFNSIID aIID, void** aInstancePtr)
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIClipboardCommandsIID)) {
*aInstancePtr = (void*) ((nsIClipboardCommands*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*)(nsISupports*)(nsIWebShell*)this;
NS_ADDREF_THIS();
@ -1989,54 +2001,73 @@ nsWebShell::PromptPassword(const nsString &aText,
//----------------------------------------------------
NS_IMETHODIMP
nsWebShell::IsSelection(PRBool & aIsSelection)
nsWebShell::CanCutSelection(PRBool* aResult)
{
aIsSelection = PR_FALSE;
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
if (nsnull == aResult) {
rv = NS_ERROR_NULL_POINTER;
} else {
*aResult = PR_FALSE;
}
return rv;
}
//----------------------------------------------------
NS_IMETHODIMP
nsWebShell::IsSelectionCutable(PRBool & aIsSelection)
nsWebShell::CanCopySelection(PRBool* aResult)
{
aIsSelection = PR_FALSE;
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
if (nsnull == aResult) {
rv = NS_ERROR_NULL_POINTER;
} else {
*aResult = PR_FALSE;
}
return rv;
}
//----------------------------------------------------
NS_IMETHODIMP
nsWebShell::IsSelectionPastable(PRBool & aIsSelection)
nsWebShell::CanPasteSelection(PRBool* aResult)
{
aIsSelection = PR_FALSE;
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
if (nsnull == aResult) {
rv = NS_ERROR_NULL_POINTER;
} else {
*aResult = PR_FALSE;
}
return rv;
}
//----------------------------------------------------
NS_IMETHODIMP
nsWebShell::GetSelection(PRUnichar *& aSelection)
{
aSelection = nsnull;
return NS_ERROR_FAILURE;
}
//----------------------------------------------------
NS_IMETHODIMP
nsWebShell::CutSelection(PRUnichar *& aSelection)
{
aSelection = nsnull;
return NS_ERROR_FAILURE;
}
//----------------------------------------------------
NS_IMETHODIMP
nsWebShell::PasteSelection(const PRUnichar * aSelection)
nsWebShell::CutSelection(void)
{
return NS_ERROR_FAILURE;
}
//----------------------------------------------------
NS_IMETHODIMP
nsWebShell::SelectAll()
nsWebShell::CopySelection(void)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsWebShell::PasteSelection(void)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsWebShell::SelectAll(void)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsWebShell::SelectNone(void)
{
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -283,42 +283,6 @@ public:
NS_IMETHOD GetMarginHeight(PRInt32& aWidth) = 0;
NS_IMETHOD SetMarginHeight(PRInt32 aHeight) = 0;
// Selection Related Methods
/**
* Returns the whether there is a selection or not
*/
NS_IMETHOD IsSelection(PRBool & aIsSelection) = 0;
/**
* Returns the whether the selection can be cut (editor or a form control)
*/
NS_IMETHOD IsSelectionCutable(PRBool & aIsSelection) = 0;
/**
* Returns whether the data can be pasted (editor or a form control)
*/
NS_IMETHOD IsSelectionPastable(PRBool & aIsSelection) = 0;
/**
* Copies the Selection from the content or a form control
*/
NS_IMETHOD GetSelection(PRUnichar *& aSelection) = 0;
/**
* Cuts the Selection from the content or a form control
*/
NS_IMETHOD CutSelection(PRUnichar *& aSelection) = 0;
/**
* Pastes the Selection into the content or a form control
*/
NS_IMETHOD PasteSelection(const PRUnichar * aSelection) = 0;
/**
* Selects all the Content
*/
NS_IMETHOD SelectAll() = 0;
/**
* Finds text in content
*/

Просмотреть файл

@ -20,6 +20,7 @@
#include "nsIDocumentLoader.h"
#include "nsIContentViewer.h"
#include "nsIDocumentViewer.h"
#include "nsIClipboardCommands.h"
#include "nsIDeviceContext.h"
#include "nsILinkHandler.h"
#include "nsIStreamListener.h"
@ -103,7 +104,8 @@ class nsWebShell : public nsIWebShell,
public nsIDocumentLoaderObserver,
public nsIRefreshUrl,
public nsINetSupport,
public nsIStreamObserver
public nsIStreamObserver,
public nsIClipboardCommands
{
public:
nsWebShell();
@ -233,14 +235,18 @@ public:
NS_IMETHOD_(PRBool) PromptPassword(const nsString &aText,
nsString &aPassword);
// Selection methods
NS_IMETHOD IsSelection(PRBool & aIsSelection);
NS_IMETHOD IsSelectionCutable(PRBool & aIsSelection);
NS_IMETHOD IsSelectionPastable(PRBool & aIsSelection);
NS_IMETHOD GetSelection(PRUnichar *& aSelection);
NS_IMETHOD CutSelection(PRUnichar *& aSelection);
NS_IMETHOD PasteSelection(const PRUnichar * aSelection);
NS_IMETHOD SelectAll();
// nsIClipboardCommands
NS_IMETHOD CanCutSelection (PRBool* aResult);
NS_IMETHOD CanCopySelection (PRBool* aResult);
NS_IMETHOD CanPasteSelection(PRBool* aResult);
NS_IMETHOD CutSelection (void);
NS_IMETHOD CopySelection (void);
NS_IMETHOD PasteSelection(void);
NS_IMETHOD SelectAll(void);
NS_IMETHOD SelectNone(void);
NS_IMETHOD FindNext(const PRUnichar * aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound);
// nsWebShell
@ -327,6 +333,7 @@ static NS_DEFINE_IID(kRefreshURLIID, NS_IREFRESHURL_IID);
static NS_DEFINE_IID(kITimerCallbackIID, NS_ITIMERCALLBACK_IID);
static NS_DEFINE_IID(kIWebShellContainerIID, NS_IWEB_SHELL_CONTAINER_IID);
static NS_DEFINE_IID(kIBrowserWindowIID, NS_IBROWSER_WINDOW_IID);
static NS_DEFINE_IID(kIClipboardCommandsIID, NS_ICLIPBOARDCOMMANDS_IID);
// XXX not sure
static NS_DEFINE_IID(kILinkHandlerIID, NS_ILINKHANDLER_IID);
@ -501,6 +508,11 @@ nsWebShell::QueryInterface(REFNSIID aIID, void** aInstancePtr)
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIClipboardCommandsIID)) {
*aInstancePtr = (void*) ((nsIClipboardCommands*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*)(nsISupports*)(nsIWebShell*)this;
NS_ADDREF_THIS();
@ -1989,54 +2001,73 @@ nsWebShell::PromptPassword(const nsString &aText,
//----------------------------------------------------
NS_IMETHODIMP
nsWebShell::IsSelection(PRBool & aIsSelection)
nsWebShell::CanCutSelection(PRBool* aResult)
{
aIsSelection = PR_FALSE;
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
if (nsnull == aResult) {
rv = NS_ERROR_NULL_POINTER;
} else {
*aResult = PR_FALSE;
}
return rv;
}
//----------------------------------------------------
NS_IMETHODIMP
nsWebShell::IsSelectionCutable(PRBool & aIsSelection)
nsWebShell::CanCopySelection(PRBool* aResult)
{
aIsSelection = PR_FALSE;
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
if (nsnull == aResult) {
rv = NS_ERROR_NULL_POINTER;
} else {
*aResult = PR_FALSE;
}
return rv;
}
//----------------------------------------------------
NS_IMETHODIMP
nsWebShell::IsSelectionPastable(PRBool & aIsSelection)
nsWebShell::CanPasteSelection(PRBool* aResult)
{
aIsSelection = PR_FALSE;
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
if (nsnull == aResult) {
rv = NS_ERROR_NULL_POINTER;
} else {
*aResult = PR_FALSE;
}
return rv;
}
//----------------------------------------------------
NS_IMETHODIMP
nsWebShell::GetSelection(PRUnichar *& aSelection)
{
aSelection = nsnull;
return NS_ERROR_FAILURE;
}
//----------------------------------------------------
NS_IMETHODIMP
nsWebShell::CutSelection(PRUnichar *& aSelection)
{
aSelection = nsnull;
return NS_ERROR_FAILURE;
}
//----------------------------------------------------
NS_IMETHODIMP
nsWebShell::PasteSelection(const PRUnichar * aSelection)
nsWebShell::CutSelection(void)
{
return NS_ERROR_FAILURE;
}
//----------------------------------------------------
NS_IMETHODIMP
nsWebShell::SelectAll()
nsWebShell::CopySelection(void)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsWebShell::PasteSelection(void)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsWebShell::SelectAll(void)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsWebShell::SelectNone(void)
{
return NS_ERROR_FAILURE;
}