NS_IMETHODIMP nsTextEditRules::WillDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel, PRBool *aHandled) { // null selection is legal if (!aInfo || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } #if defined(DEBUG_ftang) printf("nsTextEditRules::WillDoAction action= %d", aInfo->action); #endif *aCancel = PR_FALSE; *aHandled = PR_FALSE; // my kingdom for dynamic cast nsTextRulesInfo *info = static_cast<nsTextRulesInfo*>(aInfo); switch (info->action) { case kInsertBreak: return WillInsertBreak(aSelection, aCancel, aHandled, info->maxLength); case kInsertText: case kInsertTextIME: return WillInsertText(info->action, aSelection, aCancel, aHandled, info->inString, info->outString, info->maxLength); case kDeleteSelection: return WillDeleteSelection(aSelection, info->collapsedAction, aCancel, aHandled); case kUndo: return WillUndo(aSelection, aCancel, aHandled); case kRedo: return WillRedo(aSelection, aCancel, aHandled); case kSetTextProperty: return WillSetTextProperty(aSelection, aCancel, aHandled); case kRemoveTextProperty: return WillRemoveTextProperty(aSelection, aCancel, aHandled); case kOutputText: return WillOutputText(aSelection, info->outputFormat, info->outString, aCancel, aHandled); case kInsertElement: // i had thought this would be html rules only. but we put pre elements // into plaintext mail when doing quoting for reply! doh! return WillInsert(aSelection, aCancel); } return NS_ERROR_FAILURE; }
NS_IMETHODIMP TextEditRules::WillDoAction(Selection* aSelection, RulesInfo* aInfo, bool* aCancel, bool* aHandled) { // null selection is legal MOZ_ASSERT(aInfo && aCancel && aHandled); *aCancel = false; *aHandled = false; // my kingdom for dynamic cast TextRulesInfo* info = static_cast<TextRulesInfo*>(aInfo); switch (info->action) { case EditAction::insertBreak: UndefineCaretBidiLevel(aSelection); return WillInsertBreak(aSelection, aCancel, aHandled, info->maxLength); case EditAction::insertText: case EditAction::insertIMEText: UndefineCaretBidiLevel(aSelection); return WillInsertText(info->action, aSelection, aCancel, aHandled, info->inString, info->outString, info->maxLength); case EditAction::setText: UndefineCaretBidiLevel(aSelection); return WillSetText(*aSelection, aCancel, aHandled, info->inString, info->maxLength); case EditAction::deleteSelection: return WillDeleteSelection(aSelection, info->collapsedAction, aCancel, aHandled); case EditAction::undo: return WillUndo(aSelection, aCancel, aHandled); case EditAction::redo: return WillRedo(aSelection, aCancel, aHandled); case EditAction::setTextProperty: return WillSetTextProperty(aSelection, aCancel, aHandled); case EditAction::removeTextProperty: return WillRemoveTextProperty(aSelection, aCancel, aHandled); case EditAction::outputText: return WillOutputText(aSelection, info->outputFormat, info->outString, info->flags, aCancel, aHandled); case EditAction::insertElement: // i had thought this would be html rules only. but we put pre elements // into plaintext mail when doing quoting for reply! doh! WillInsert(*aSelection, aCancel); return NS_OK; default: return NS_ERROR_FAILURE; } }