NS_IMETHODIMP PasteQuotationCommand::GetCommandStateParams(const char* aCommandName, nsICommandParams* aParams, nsISupports* aCommandRefCon) { nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon); if (!editor) { return NS_OK; } TextEditor* textEditor = editor->AsTextEditor(); MOZ_ASSERT(textEditor); bool enabled = false; textEditor->CanPaste(nsIClipboard::kGlobalClipboard, &enabled); aParams->AsCommandParams()->SetBool(STATE_ENABLED, enabled); return NS_OK; }
NS_IMETHODIMP PasteCommand::IsCommandEnabled(const char* aCommandName, nsISupports* aCommandRefCon, bool* aIsEnabled) { if (NS_WARN_IF(!aIsEnabled)) { return NS_ERROR_INVALID_ARG; } *aIsEnabled = false; nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon); if (!editor) { return NS_OK; } TextEditor* textEditor = editor->AsTextEditor(); MOZ_ASSERT(textEditor); if (!textEditor->IsSelectionEditable()) { return NS_OK; } return textEditor->CanPaste(nsIClipboard::kGlobalClipboard, aIsEnabled); }