Fix bug 196704: implement commands to get the selected text, and insert text, to allow for embedders (like Camino) to use them, e.g. for the Mac OS X services menu. Also fix image copy. r=brade, sr=kin.

This commit is contained in:
sfraser%netscape.com 2003-04-22 18:11:12 +00:00
parent 504016ebf5
commit 352be220ed
12 changed files with 294 additions and 61 deletions

View File

@ -1129,10 +1129,10 @@ const char kDirServiceContractID[] = "@mozilla.org/file/directory_service;1";
nsCOMPtr<nsICommandParams> params = do_CreateInstance(NS_COMMAND_PARAMS_CONTRACTID);
if (!params) return NO;
params->SetStringValue("format", NS_LITERAL_STRING("text/plain"));
params->SetCStringValue("format", "text/plain");
params->SetBooleanValue("selection_only", PR_TRUE);
nsresult rv = cmdManager->DoCommand("cmd_GetContents", params, nsnull);
nsresult rv = cmdManager->DoCommand("cmd_getContents", params, nsnull);
if (NS_FAILED(rv))
return NO;
@ -1163,7 +1163,7 @@ const char kDirServiceContractID[] = "@mozilla.org/file/directory_service;1";
nsCOMPtr<nsICommandParams> params = do_CreateInstance(NS_COMMAND_PARAMS_CONTRACTID);
if (!params) return NO;
params->SetStringValue("data", textString);
params->SetStringValue("state_data", textString);
nsresult rv = cmdManager->DoCommand("cmd_insertText", params, nsnull);
return (BOOL)NS_SUCCEEDED(rv);

View File

@ -2095,6 +2095,29 @@ NS_IMETHODIMP DocumentViewerImpl::GetPasteable(PRBool *aPasteable)
return NS_OK;
}
/* AString getContents (in string mimeType, in boolean selectionOnly); */
NS_IMETHODIMP DocumentViewerImpl::GetContents(const char *mimeType, PRBool selectionOnly, nsAString& aOutValue)
{
NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_INITIALIZED);
return mPresShell->DoGetContents(nsDependentCString(mimeType), 0, selectionOnly, aOutValue);
}
/* readonly attribute boolean canGetContents; */
NS_IMETHODIMP DocumentViewerImpl::GetCanGetContents(PRBool *aCanGetContents)
{
NS_ENSURE_ARG_POINTER(aCanGetContents);
nsCOMPtr<nsISelection> selection;
nsresult rv = GetDocumentSelection(getter_AddRefs(selection));
if (NS_FAILED(rv)) return rv;
PRBool isCollapsed;
selection->GetIsCollapsed(&isCollapsed);
*aCanGetContents = !isCollapsed;
return NS_OK;
}
#ifdef XP_MAC
#pragma mark -
#endif

View File

@ -43,6 +43,7 @@
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsCRT.h"
#include "nsString.h"
#include "nsIControllerCommandTable.h"
#include "nsICommandParams.h"
@ -401,7 +402,7 @@ public:
protected:
virtual nsresult IsClipboardCommandEnabled(const char * aCommandName, nsIContentViewerEdit* aEdit, PRBool *outCmdEnabled) = 0;
virtual nsresult DoClipboardCommand(const char *aCommandName, nsIContentViewerEdit* aEdit) = 0;
virtual nsresult DoClipboardCommand(const char *aCommandName, nsIContentViewerEdit* aEdit, nsICommandParams* aParams) = 0;
static nsresult GetContentViewerEditFromContext(nsISupports *aContext, nsIContentViewerEdit **aEditInterface);
@ -441,7 +442,7 @@ nsClipboardBaseCommand::DoCommand(const char *aCommandName,
GetContentViewerEditFromContext(aCommandContext, getter_AddRefs(contentEdit));
NS_ENSURE_TRUE(contentEdit, NS_ERROR_NOT_INITIALIZED);
return DoClipboardCommand(aCommandName, contentEdit);
return DoClipboardCommand(aCommandName, contentEdit, nsnull);
}
NS_IMETHODIMP
@ -457,7 +458,11 @@ nsClipboardBaseCommand::DoCommandParams(const char *aCommandName,
nsICommandParams *aParams,
nsISupports *aCommandContext)
{
return DoCommand(aCommandName, aCommandContext);
nsCOMPtr<nsIContentViewerEdit> contentEdit;
GetContentViewerEditFromContext(aCommandContext, getter_AddRefs(contentEdit));
NS_ENSURE_TRUE(contentEdit, NS_ERROR_NOT_INITIALIZED);
return DoClipboardCommand(aCommandName, contentEdit, aParams);
}
nsresult
@ -499,7 +504,7 @@ protected:
virtual nsresult IsClipboardCommandEnabled(const char* aCommandName, \
nsIContentViewerEdit* aEdit, PRBool *outCmdEnabled); \
virtual nsresult DoClipboardCommand(const char* aCommandName, \
nsIContentViewerEdit* aEdit); \
nsIContentViewerEdit* aEdit, nsICommandParams* aParams); \
/* no member variables, please, we're stateless! */ \
};
@ -509,6 +514,7 @@ NS_DECL_CLIPBOARD_COMMAND(nsClipboardPasteCommand)
NS_DECL_CLIPBOARD_COMMAND(nsClipboardCopyLinkCommand)
NS_DECL_CLIPBOARD_COMMAND(nsClipboardImageCommands)
NS_DECL_CLIPBOARD_COMMAND(nsClipboardSelectAllNoneCommands)
NS_DECL_CLIPBOARD_COMMAND(nsClipboardGetContentsCommand)
#if 0
#pragma mark -
@ -522,7 +528,7 @@ nsClipboardCutCommand::IsClipboardCommandEnabled(const char* aCommandName, nsICo
}
nsresult
nsClipboardCutCommand::DoClipboardCommand(const char* aCommandName, nsIContentViewerEdit* aEdit)
nsClipboardCutCommand::DoClipboardCommand(const char *aCommandName, nsIContentViewerEdit* aEdit, nsICommandParams* aParams)
{
return aEdit->CutSelection();
}
@ -538,7 +544,7 @@ nsClipboardCopyCommand::IsClipboardCommandEnabled(const char* aCommandName, nsIC
}
nsresult
nsClipboardCopyCommand::DoClipboardCommand(const char* aCommandName, nsIContentViewerEdit* aEdit)
nsClipboardCopyCommand::DoClipboardCommand(const char *aCommandName, nsIContentViewerEdit* aEdit, nsICommandParams* aParams)
{
return aEdit->CopySelection();
}
@ -554,7 +560,7 @@ nsClipboardPasteCommand::IsClipboardCommandEnabled(const char* aCommandName, nsI
}
nsresult
nsClipboardPasteCommand::DoClipboardCommand(const char* aCommandName, nsIContentViewerEdit* aEdit)
nsClipboardPasteCommand::DoClipboardCommand(const char *aCommandName, nsIContentViewerEdit* aEdit, nsICommandParams* aParams)
{
return aEdit->Paste();
}
@ -571,7 +577,7 @@ nsClipboardCopyLinkCommand::IsClipboardCommandEnabled(const char* aCommandName,
}
nsresult
nsClipboardCopyLinkCommand::DoClipboardCommand(const char* aCommandName, nsIContentViewerEdit* aEdit)
nsClipboardCopyLinkCommand::DoClipboardCommand(const char *aCommandName, nsIContentViewerEdit* aEdit, nsICommandParams* aParams)
{
return aEdit->CopyLinkLocation();
}
@ -587,7 +593,7 @@ nsClipboardImageCommands::IsClipboardCommandEnabled(const char* aCommandName, ns
}
nsresult
nsClipboardImageCommands::DoClipboardCommand(const char* aCommandName, nsIContentViewerEdit* aEdit)
nsClipboardImageCommands::DoClipboardCommand(const char *aCommandName, nsIContentViewerEdit* aEdit, nsICommandParams* aParams)
{
if (!nsCRT::strcmp(sCopyImageLocationString, aCommandName))
return aEdit->CopyImageLocation();
@ -607,7 +613,7 @@ nsClipboardSelectAllNoneCommands::IsClipboardCommandEnabled(const char* aCommand
}
nsresult
nsClipboardSelectAllNoneCommands::DoClipboardCommand(const char* aCommandName, nsIContentViewerEdit* aEdit)
nsClipboardSelectAllNoneCommands::DoClipboardCommand(const char *aCommandName, nsIContentViewerEdit* aEdit, nsICommandParams* aParams)
{
if (!nsCRT::strcmp(sSelectAllString, aCommandName))
return aEdit->SelectAll();
@ -616,6 +622,39 @@ nsClipboardSelectAllNoneCommands::DoClipboardCommand(const char* aCommandName, n
}
#if 0
#pragma mark -
#endif
nsresult
nsClipboardGetContentsCommand::IsClipboardCommandEnabled(const char* aCommandName, nsIContentViewerEdit* aEdit, PRBool *outCmdEnabled)
{
return aEdit->GetCanGetContents(outCmdEnabled);
}
nsresult
nsClipboardGetContentsCommand::DoClipboardCommand(const char *aCommandName, nsIContentViewerEdit* aEdit, nsICommandParams* aParams)
{
NS_ENSURE_ARG(aParams);
nsCAutoString mimeType("text/plain");
nsXPIDLCString format; // nsICommandParams needs to use nsACString
if (NS_SUCCEEDED(aParams->GetCStringValue("format", getter_Copies(format))))
mimeType.Assign(format);
PRBool selectionOnly = PR_FALSE;
aParams->GetBooleanValue("selection_only", &selectionOnly);
nsAutoString contents;
nsresult rv = aEdit->GetContents(mimeType.get(), selectionOnly, contents);
if (NS_FAILED(rv))
return rv;
return aParams->SetStringValue("result", contents);
}
#if 0
#pragma mark -
#endif
@ -918,6 +957,8 @@ nsWindowCommandRegistration::RegisterWindowCommands(
NS_REGISTER_FIRST_COMMAND(nsClipboardSelectAllNoneCommands, sSelectAllString);
NS_REGISTER_LAST_COMMAND(nsClipboardSelectAllNoneCommands, sSelectNoneString);
NS_REGISTER_ONE_COMMAND(nsClipboardGetContentsCommand, "cmd_getContents");
NS_REGISTER_ONE_COMMAND(nsGoBackCommand, "cmd_browserBack");
NS_REGISTER_ONE_COMMAND(nsGoForwardCommand, "cmd_browserForward");

View File

@ -107,6 +107,11 @@ interface nsIPlaintextEditor : nsISupports
*/
void insertText(in DOMString aStringToInsert);
/**
* True if the document is modifiable.
*/
readonly attribute boolean canModify;
/**
* Insert a line break into the content model.
* The interpretation of a break is up to the implementation:

View File

@ -660,8 +660,15 @@ nsInsertPlaintextCommand::IsCommandEnabled(const char * aCommandName,
{
NS_ENSURE_ARG_POINTER(outCmdEnabled);
nsCOMPtr<nsIPlaintextEditor> editor = do_QueryInterface(refCon);
*outCmdEnabled = editor ? PR_TRUE : PR_FALSE;
if (editor)
{
PRBool canInsert = PR_TRUE;
editor->GetCanModify(&canInsert);
*outCmdEnabled = canInsert;
}
else
*outCmdEnabled = PR_FALSE;
return NS_OK;
}

View File

@ -1009,6 +1009,14 @@ NS_IMETHODIMP nsPlaintextEditor::InsertText(const nsAString &aStringToInsert)
return result;
}
NS_IMETHODIMP nsPlaintextEditor::GetCanModify(PRBool *aCanModify)
{
NS_ENSURE_ARG_POINTER(aCanModify);
*aCanModify = IsModifiable();
return NS_OK;
}
NS_IMETHODIMP nsPlaintextEditor::InsertLineBreak()
{

View File

@ -2095,6 +2095,29 @@ NS_IMETHODIMP DocumentViewerImpl::GetPasteable(PRBool *aPasteable)
return NS_OK;
}
/* AString getContents (in string mimeType, in boolean selectionOnly); */
NS_IMETHODIMP DocumentViewerImpl::GetContents(const char *mimeType, PRBool selectionOnly, nsAString& aOutValue)
{
NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_INITIALIZED);
return mPresShell->DoGetContents(nsDependentCString(mimeType), 0, selectionOnly, aOutValue);
}
/* readonly attribute boolean canGetContents; */
NS_IMETHODIMP DocumentViewerImpl::GetCanGetContents(PRBool *aCanGetContents)
{
NS_ENSURE_ARG_POINTER(aCanGetContents);
nsCOMPtr<nsISelection> selection;
nsresult rv = GetDocumentSelection(getter_AddRefs(selection));
if (NS_FAILED(rv)) return rv;
PRBool isCollapsed;
selection->GetIsCollapsed(&isCollapsed);
*aCanGetContents = !isCollapsed;
return NS_OK;
}
#ifdef XP_MAC
#pragma mark -
#endif

View File

@ -424,6 +424,11 @@ public:
*/
NS_IMETHOD DoCopyImageContents(nsIDOMNode* aNode) = 0;
/**
* Get the doc or the selection as text or html.
*/
NS_IMETHOD DoGetContents(const nsACString& aMimeType, PRUint32 aFlags, PRBool aSelectionOnly, nsAString& outValue) = 0;
/**
* Get the caret, if it exists. AddRefs it.
*/

View File

@ -1140,6 +1140,7 @@ public:
NS_IMETHOD GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocationString);
NS_IMETHOD GetImageLocation(nsIDOMNode* aNode, nsAString& aLocationString);
NS_IMETHOD DoCopyImageContents(nsIDOMNode* aNode);
NS_IMETHOD DoGetContents(const nsACString& aMimeType, PRUint32 aFlags, PRBool aSelectionOnly, nsAString& outValue);
NS_IMETHOD CaptureHistoryState(nsILayoutHistoryState** aLayoutHistoryState, PRBool aLeavingPage);
NS_IMETHOD GetHistoryState(nsILayoutHistoryState** aLayoutHistoryState);
@ -1292,6 +1293,8 @@ protected:
nsresult SetPrefLinkRules(void);
nsresult SetPrefFocusRules(void);
nsresult GetSelectionForCopy(nsISelection** outSelection);
// IMPORTANT: The ownership implicit in the following member variables has been
// explicitly checked and set using nsCOMPtr for owning pointers and raw COM interface
// pointers for weak (ie, non owning) references. If you add any members to this
@ -4550,29 +4553,37 @@ PresShell::GetImageLocation(nsIDOMNode* aNode, nsAString& aLocationString)
// DoCopyImageContents: copy image contents to clipboard
NS_IMETHODIMP PresShell::DoCopyImageContents(nsIDOMNode* aNode)
{
// XXX dr: platform-specific widget code works on windows and mac.
// when linux copy image contents works, this should get written
// and hooked up to the front end, similarly to cmd_copyImageLocation.
return NS_ERROR_NOT_IMPLEMENTED;
NS_ENSURE_ARG_POINTER(aNode);
nsresult rv;
// are we an image?
nsCOMPtr<nsIDOMHTMLImageElement> img(do_QueryInterface(aNode, &rv));
NS_ENSURE_SUCCESS(rv, rv);
if (img) {
// call the copy code
return nsCopySupport::ImageCopy(img, nsIClipboard::kGlobalClipboard);
}
// if no image, fail.
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
PresShell::DoCopy()
nsresult
PresShell::GetSelectionForCopy(nsISelection** outSelection)
{
*outSelection = nsnull;
nsCOMPtr<nsIDocument> doc;
GetDocument(getter_AddRefs(doc));
if (!doc) return NS_ERROR_FAILURE;
nsresult rv;
nsCOMPtr<nsISelection> sel;
nsCOMPtr<nsIEventStateManager> manager;
nsCOMPtr<nsIContent> content;
rv = mPresContext->GetEventStateManager(getter_AddRefs(manager));
if (NS_FAILED(rv))
return rv;
if (!manager)
return NS_ERROR_FAILURE;
nsresult rv = mPresContext->GetEventStateManager(getter_AddRefs(manager));
if (NS_FAILED(rv)) return rv;
if (!manager) return NS_ERROR_FAILURE;
nsCOMPtr<nsISelection> sel;
nsCOMPtr<nsIContent> content;
rv = manager->GetFocusedContent(getter_AddRefs(content));
if (NS_SUCCEEDED(rv) && content)
{
@ -4584,24 +4595,64 @@ PresShell::DoCopy()
{
nsIFrame *htmlInputFrame;
rv = GetPrimaryFrameFor(content, &htmlInputFrame);
if (NS_FAILED(rv))
return rv;
if (!htmlInputFrame)
return NS_ERROR_FAILURE;
if (NS_FAILED(rv)) return rv;
if (!htmlInputFrame) return NS_ERROR_FAILURE;
nsCOMPtr<nsISelectionController> selCon;
rv = htmlInputFrame->GetSelectionController(mPresContext,getter_AddRefs(selCon));
if (NS_FAILED(rv))
return rv;
if (!selCon)
return NS_ERROR_FAILURE;
if (NS_FAILED(rv)) return rv;
if (!selCon) return NS_ERROR_FAILURE;
rv = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(sel));
}
}
if (!sel) //get selection from this PresShell
rv = GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(sel));
*outSelection = sel;
NS_IF_ADDREF(*outSelection);
return rv;
}
NS_IMETHODIMP
PresShell::DoGetContents(const nsACString& aMimeType, PRUint32 aFlags, PRBool aSelectionOnly, nsAString& aOutValue)
{
aOutValue.Truncate();
nsCOMPtr<nsIDocument> doc;
GetDocument(getter_AddRefs(doc));
if (!doc) return NS_ERROR_FAILURE;
nsresult rv;
nsCOMPtr<nsISelection> sel;
// Now we have the selection. Make sure it's nonzero:
if (aSelectionOnly)
{
rv = GetSelectionForCopy(getter_AddRefs(sel));
if (NS_FAILED(rv)) return rv;
if (!sel) return NS_ERROR_FAILURE;
PRBool isCollapsed;
sel->GetIsCollapsed(&isCollapsed);
if (isCollapsed)
return NS_OK;
}
// call the copy code
return nsCopySupport::GetContents(aMimeType, aFlags, sel, doc, aOutValue);
}
NS_IMETHODIMP
PresShell::DoCopy()
{
nsCOMPtr<nsIDocument> doc;
GetDocument(getter_AddRefs(doc));
if (!doc) return NS_ERROR_FAILURE;
nsCOMPtr<nsISelection> sel;
nsresult rv = GetSelectionForCopy(getter_AddRefs(sel));
if (NS_FAILED(rv))
return rv;
if (!sel)

View File

@ -424,6 +424,11 @@ public:
*/
NS_IMETHOD DoCopyImageContents(nsIDOMNode* aNode) = 0;
/**
* Get the doc or the selection as text or html.
*/
NS_IMETHOD DoGetContents(const nsACString& aMimeType, PRUint32 aFlags, PRBool aSelectionOnly, nsAString& outValue) = 0;
/**
* Get the caret, if it exists. AddRefs it.
*/

View File

@ -1140,6 +1140,7 @@ public:
NS_IMETHOD GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocationString);
NS_IMETHOD GetImageLocation(nsIDOMNode* aNode, nsAString& aLocationString);
NS_IMETHOD DoCopyImageContents(nsIDOMNode* aNode);
NS_IMETHOD DoGetContents(const nsACString& aMimeType, PRUint32 aFlags, PRBool aSelectionOnly, nsAString& outValue);
NS_IMETHOD CaptureHistoryState(nsILayoutHistoryState** aLayoutHistoryState, PRBool aLeavingPage);
NS_IMETHOD GetHistoryState(nsILayoutHistoryState** aLayoutHistoryState);
@ -1292,6 +1293,8 @@ protected:
nsresult SetPrefLinkRules(void);
nsresult SetPrefFocusRules(void);
nsresult GetSelectionForCopy(nsISelection** outSelection);
// IMPORTANT: The ownership implicit in the following member variables has been
// explicitly checked and set using nsCOMPtr for owning pointers and raw COM interface
// pointers for weak (ie, non owning) references. If you add any members to this
@ -4550,29 +4553,37 @@ PresShell::GetImageLocation(nsIDOMNode* aNode, nsAString& aLocationString)
// DoCopyImageContents: copy image contents to clipboard
NS_IMETHODIMP PresShell::DoCopyImageContents(nsIDOMNode* aNode)
{
// XXX dr: platform-specific widget code works on windows and mac.
// when linux copy image contents works, this should get written
// and hooked up to the front end, similarly to cmd_copyImageLocation.
return NS_ERROR_NOT_IMPLEMENTED;
NS_ENSURE_ARG_POINTER(aNode);
nsresult rv;
// are we an image?
nsCOMPtr<nsIDOMHTMLImageElement> img(do_QueryInterface(aNode, &rv));
NS_ENSURE_SUCCESS(rv, rv);
if (img) {
// call the copy code
return nsCopySupport::ImageCopy(img, nsIClipboard::kGlobalClipboard);
}
// if no image, fail.
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
PresShell::DoCopy()
nsresult
PresShell::GetSelectionForCopy(nsISelection** outSelection)
{
*outSelection = nsnull;
nsCOMPtr<nsIDocument> doc;
GetDocument(getter_AddRefs(doc));
if (!doc) return NS_ERROR_FAILURE;
nsresult rv;
nsCOMPtr<nsISelection> sel;
nsCOMPtr<nsIEventStateManager> manager;
nsCOMPtr<nsIContent> content;
rv = mPresContext->GetEventStateManager(getter_AddRefs(manager));
if (NS_FAILED(rv))
return rv;
if (!manager)
return NS_ERROR_FAILURE;
nsresult rv = mPresContext->GetEventStateManager(getter_AddRefs(manager));
if (NS_FAILED(rv)) return rv;
if (!manager) return NS_ERROR_FAILURE;
nsCOMPtr<nsISelection> sel;
nsCOMPtr<nsIContent> content;
rv = manager->GetFocusedContent(getter_AddRefs(content));
if (NS_SUCCEEDED(rv) && content)
{
@ -4584,24 +4595,64 @@ PresShell::DoCopy()
{
nsIFrame *htmlInputFrame;
rv = GetPrimaryFrameFor(content, &htmlInputFrame);
if (NS_FAILED(rv))
return rv;
if (!htmlInputFrame)
return NS_ERROR_FAILURE;
if (NS_FAILED(rv)) return rv;
if (!htmlInputFrame) return NS_ERROR_FAILURE;
nsCOMPtr<nsISelectionController> selCon;
rv = htmlInputFrame->GetSelectionController(mPresContext,getter_AddRefs(selCon));
if (NS_FAILED(rv))
return rv;
if (!selCon)
return NS_ERROR_FAILURE;
if (NS_FAILED(rv)) return rv;
if (!selCon) return NS_ERROR_FAILURE;
rv = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(sel));
}
}
if (!sel) //get selection from this PresShell
rv = GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(sel));
*outSelection = sel;
NS_IF_ADDREF(*outSelection);
return rv;
}
NS_IMETHODIMP
PresShell::DoGetContents(const nsACString& aMimeType, PRUint32 aFlags, PRBool aSelectionOnly, nsAString& aOutValue)
{
aOutValue.Truncate();
nsCOMPtr<nsIDocument> doc;
GetDocument(getter_AddRefs(doc));
if (!doc) return NS_ERROR_FAILURE;
nsresult rv;
nsCOMPtr<nsISelection> sel;
// Now we have the selection. Make sure it's nonzero:
if (aSelectionOnly)
{
rv = GetSelectionForCopy(getter_AddRefs(sel));
if (NS_FAILED(rv)) return rv;
if (!sel) return NS_ERROR_FAILURE;
PRBool isCollapsed;
sel->GetIsCollapsed(&isCollapsed);
if (isCollapsed)
return NS_OK;
}
// call the copy code
return nsCopySupport::GetContents(aMimeType, aFlags, sel, doc, aOutValue);
}
NS_IMETHODIMP
PresShell::DoCopy()
{
nsCOMPtr<nsIDocument> doc;
GetDocument(getter_AddRefs(doc));
if (!doc) return NS_ERROR_FAILURE;
nsCOMPtr<nsISelection> sel;
nsresult rv = GetSelectionForCopy(getter_AddRefs(sel));
if (NS_FAILED(rv))
return rv;
if (!sel)

View File

@ -820,6 +820,20 @@ NS_IMETHODIMP PluginViewerImpl::GetPasteable(PRBool *aPasteable)
return NS_ERROR_NOT_IMPLEMENTED;
}
/* AString getContents (in string mimeType, in boolean selectionOnly); */
NS_IMETHODIMP PluginViewerImpl::GetContents(const char *mimeType, PRBool selectionOnly, nsAString & _retval)
{
NS_ASSERTION(0, "NOT IMPLEMENTED");
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute boolean canGetContents; */
NS_IMETHODIMP PluginViewerImpl::GetCanGetContents(PRBool *aCanGetContents)
{
NS_ASSERTION(0, "NOT IMPLEMENTED");
return NS_ERROR_NOT_IMPLEMENTED;
}
/* ========================================================================================
* nsIWebBrowserPrint
* ======================================================================================== */