* @since 2.0.8
*/
public final boolean handleControlword(RtfCtrlWordData ctrlWordDataIn){
boolean result = false;
this.ctrlWordData = ctrlWordDataIn;
RtfDestination dest = null;
boolean 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 = Integer.toString(this.defaultParameterValue);
}
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) {
for(int idx=0; idx< data.length(); idx++) {
handled = dest.handleCharacter(data.charAt(idx));
}
} else {
handled = dest.handleControlWord(this.ctrlWordData);
}
}
break;
case RtfCtrlWordType.DESTINATION_EX:
case RtfCtrlWordType.DESTINATION:
// set the destination
int x=0;
if("shppict".equals(this.ctrlWord) || "nonshppict".equals(this.ctrlWord)) {
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;
}