Back to index

lightning-sunbird  0.9+nobinonly
Static Public Member Functions | Static Private Member Functions
nsEditorHookUtils Class Reference

#include <nsEditorUtils.h>

List of all members.

Static Public Member Functions

static PRBool DoAllowDragHook (nsIDOMDocument *aDoc, nsIDOMEvent *aEvent)
static PRBool DoDragHook (nsIDOMDocument *aDoc, nsIDOMEvent *aEvent, nsITransferable *aTrans)
static PRBool DoAllowDropHook (nsIDOMDocument *aDoc, nsIDOMEvent *aEvent, nsIDragSession *aSession)
static PRBool DoInsertionHook (nsIDOMDocument *aDoc, nsIDOMEvent *aEvent, nsITransferable *aTrans)

Static Private Member Functions

static nsresult GetHookEnumeratorFromDocument (nsIDOMDocument *aDoc, nsISimpleEnumerator **aEnumerator)

Detailed Description

Definition at line 274 of file nsEditorUtils.h.


Member Function Documentation

Definition at line 254 of file nsEditorUtils.cpp.

{
  nsCOMPtr<nsISimpleEnumerator> enumerator;
  GetHookEnumeratorFromDocument(aDoc, getter_AddRefs(enumerator));
  if (!enumerator)
    return PR_TRUE;

  PRBool hasMoreHooks = PR_FALSE;
  while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMoreHooks)) && hasMoreHooks)
  {
    nsCOMPtr<nsISupports> isupp;
    if (NS_FAILED(enumerator->GetNext(getter_AddRefs(isupp))))
      break;

    nsCOMPtr<nsIClipboardDragDropHooks> override = do_QueryInterface(isupp);
    if (override)
    {
      PRBool canDrag = PR_TRUE;
      nsresult hookres = override->AllowStartDrag(aDragEvent, &canDrag);
      NS_ASSERTION(NS_SUCCEEDED(hookres), "hook failure in AllowStartDrag");
      if (!canDrag)
        return PR_FALSE;
    }
  }

  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsEditorHookUtils::DoAllowDropHook ( nsIDOMDocument aDoc,
nsIDOMEvent aEvent,
nsIDragSession aSession 
) [static]

Definition at line 313 of file nsEditorUtils.cpp.

{
  nsCOMPtr<nsISimpleEnumerator> enumerator;
  GetHookEnumeratorFromDocument(aDoc, getter_AddRefs(enumerator));
  if (!enumerator)
    return PR_TRUE;

  PRBool hasMoreHooks = PR_FALSE;
  while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMoreHooks)) && hasMoreHooks)
  {
    nsCOMPtr<nsISupports> isupp;
    if (NS_FAILED(enumerator->GetNext(getter_AddRefs(isupp))))
      break;

    nsCOMPtr<nsIClipboardDragDropHooks> override = do_QueryInterface(isupp);
    if (override)
    {
      PRBool allowDrop = PR_TRUE;
      nsresult hookResult = override->AllowDrop(aEvent, aSession, &allowDrop);
      NS_ASSERTION(NS_SUCCEEDED(hookResult), "hook failure in AllowDrop");
      if (!allowDrop)
        return PR_FALSE;
    }
  }

  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsEditorHookUtils::DoDragHook ( nsIDOMDocument aDoc,
nsIDOMEvent aEvent,
nsITransferable aTrans 
) [static]

Definition at line 283 of file nsEditorUtils.cpp.

{
  nsCOMPtr<nsISimpleEnumerator> enumerator;
  GetHookEnumeratorFromDocument(aDoc, getter_AddRefs(enumerator));
  if (!enumerator)
    return PR_TRUE;

  PRBool hasMoreHooks = PR_FALSE;
  while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMoreHooks)) && hasMoreHooks)
  {
    nsCOMPtr<nsISupports> isupp;
    if (NS_FAILED(enumerator->GetNext(getter_AddRefs(isupp))))
      break;

    nsCOMPtr<nsIClipboardDragDropHooks> override = do_QueryInterface(isupp);
    if (override)
    {
      PRBool canInvokeDrag = PR_TRUE;
      nsresult hookResult = override->OnCopyOrDrag(aEvent, aTrans, &canInvokeDrag);
      NS_ASSERTION(NS_SUCCEEDED(hookResult), "hook failure in OnCopyOrDrag");
      if (!canInvokeDrag)
        return PR_FALSE;
    }
  }

  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsEditorHookUtils::DoInsertionHook ( nsIDOMDocument aDoc,
nsIDOMEvent aEvent,
nsITransferable aTrans 
) [static]

Definition at line 343 of file nsEditorUtils.cpp.

{
  nsCOMPtr<nsISimpleEnumerator> enumerator;
  GetHookEnumeratorFromDocument(aDoc, getter_AddRefs(enumerator));
  if (!enumerator)
    return PR_TRUE;

  PRBool hasMoreHooks = PR_FALSE;
  while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMoreHooks)) && hasMoreHooks)
  {
    nsCOMPtr<nsISupports> isupp;
    if (NS_FAILED(enumerator->GetNext(getter_AddRefs(isupp))))
      break;

    nsCOMPtr<nsIClipboardDragDropHooks> override = do_QueryInterface(isupp);
    if (override)
    {
      PRBool doInsert = PR_TRUE;
      nsresult hookResult = override->OnPasteOrDrop(aDropEvent, aTrans, &doInsert);
      NS_ASSERTION(NS_SUCCEEDED(hookResult), "hook failure in OnPasteOrDrop");
      if (!doInsert)
        return PR_FALSE;
    }
  }

  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 239 of file nsEditorUtils.cpp.

{
  nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDoc);
  if (!doc) return NS_ERROR_FAILURE;

  nsCOMPtr<nsISupports> container = doc->GetContainer();
  nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(container);
  nsCOMPtr<nsIClipboardDragDropHookList> hookObj = do_GetInterface(docShell);
  if (!hookObj) return NS_ERROR_FAILURE;

  return hookObj->GetHookEnumerator(aResult);
}

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files: