/** * The primary control word handler method. * Called by the parser once it has a control word and parameter if applicable. * * @param ctrlWordDataIn * The control word and associated parameter if applicable. * @return * <code>true</code> or <code>false</code> if the control word was handled. * @since 2.0.8 */ public bool HandleControlword(RtfCtrlWordData ctrlWordDataIn) { bool result = false; this.ctrlWordData = ctrlWordDataIn; RtfDestination dest = null; bool handled = false; this.ctrlWordData.prefix = this.ctrlWordPrefix; this.ctrlWordData.suffix = this.ctrlWordSuffix; this.ctrlWordData.newGroup = this.rtfParser.GetState().newGroup; this.ctrlWordData.ctrlWordType = this.ctrlWordType; this.ctrlWordData.specialHandler = this.specialHandler; if (!this.ctrlWordData.hasParam && this.passDefaultParameterValue) { this.ctrlWordData.hasParam = true; this.ctrlWordData.param = this.defaultParameterValue.ToString(); } if (debug) { PrintDebug("handleKeyword: [" + this.ctrlWordData.ctrlWord + "] param=" + ctrlWordDataIn.param); RtfParser.OutputDebug(this.rtfParser.GetRtfDocument(), this.rtfParser.GetLevel() + 1, "RtfCtrlWordHandler debug Start: " + this.ctrlWordData.ctrlWord + " "); } if (this.ctrlWordData.ctrlWord.Equals("*")) { return(true); } if (!BeforeControlWord()) { return(true); } switch (this.ctrlWordType) { case RtfCtrlWordType.FLAG: case RtfCtrlWordType.TOGGLE: case RtfCtrlWordType.VALUE: dest = this.rtfParser.GetCurrentDestination(); if (dest != null) { handled = dest.HandleControlWord(this.ctrlWordData); } break; case RtfCtrlWordType.SYMBOL: dest = this.rtfParser.GetCurrentDestination(); if (dest != null) { String data = null; // if doing an import, then put the control word in the output stream through the character handler if (this.rtfParser.IsImport()) { data = this.ctrlWordPrefix + this.ctrlWordData.ctrlWord + this.ctrlWordSuffix; } if (this.rtfParser.IsConvert()) { data = this.specialHandler; } // If there is a substitute character, process the character. // If no substitute character, then provide special handling in the destination for the ctrl word. if (data != null) { foreach (char cc in data.ToCharArray()) { handled = dest.HandleCharacter((int)cc); } } else { handled = dest.HandleControlWord(this.ctrlWordData); } } break; case RtfCtrlWordType.DESTINATION_EX: case RtfCtrlWordType.DESTINATION: // set the destination int x = 0; if (this.ctrlWord == "shppict" || this.ctrlWord == "nonshppict") { x++; } handled = this.rtfParser.SetCurrentDestination(this.ctrlWord); // let destination handle the ctrl word now. dest = this.rtfParser.GetCurrentDestination(); if (dest != null) { if (dest.GetNewTokeniserState() == RtfParser.TOKENISER_IGNORE_RESULT) { handled = dest.HandleControlWord(this.ctrlWordData); } else { this.rtfParser.SetTokeniserState(dest.GetNewTokeniserState()); } } break; } AfterControlWord(); if (debug) { RtfParser.OutputDebug(this.rtfParser.GetRtfDocument(), this.rtfParser.GetLevel() + 1, "RtfCtrlWordHandler debug End: " + this.ctrlWordData.ctrlWord + " "); } return(result); }