public override bool HandleControlWord(RtfCtrlWordData ctrlWordData) { if (ctrlWordData.CtrlWord.Equals("blue")) { setBlue(ctrlWordData.IntValue()); } if (ctrlWordData.CtrlWord.Equals("red")) { setRed(ctrlWordData.IntValue()); } if (ctrlWordData.CtrlWord.Equals("green")) { setGreen(ctrlWordData.IntValue()); } if (ctrlWordData.CtrlWord.Equals("cshade")) { setShade(ctrlWordData.IntValue()); } if (ctrlWordData.CtrlWord.Equals("ctint")) { setTint(ctrlWordData.IntValue()); } //if(ctrlWordData.ctrlWord.Equals("cmaindarkone")) this.SetThemeColor(ctrlWordData.ctrlWord); //if(ctrlWordData.ctrlWord.Equals("cmainlightone")) this.SetThemeColor(ctrlWordData.ctrlWord); //if(ctrlWordData.ctrlWord.Equals("cmaindarktwo")) this.SetThemeColor(ctrlWordData.ctrlWord); //if(ctrlWordData.ctrlWord.Equals("cmainlighttwo")) this.SetThemeColor(ctrlWordData.ctrlWord); //if(ctrlWordData.ctrlWord.Equals("caccentone")) this.SetThemeColor(ctrlWordData.ctrlWord); //if(ctrlWordData.ctrlWord.Equals("caccenttwo")) this.SetThemeColor(ctrlWordData.ctrlWord); //if(ctrlWordData.ctrlWord.Equals("caccentthree")) this.SetThemeColor(ctrlWordData.ctrlWord); //if(ctrlWordData.ctrlWord.Equals("caccentfour")) this.SetThemeColor(ctrlWordData.ctrlWord); //if(ctrlWordData.ctrlWord.Equals("caccentfive")) this.SetThemeColor(ctrlWordData.ctrlWord); //if(ctrlWordData.ctrlWord.Equals("caccentsix")) this.SetThemeColor(ctrlWordData.ctrlWord); //if(ctrlWordData.ctrlWord.Equals("chyperlink")) this.SetThemeColor(ctrlWordData.ctrlWord); //if(ctrlWordData.ctrlWord.Equals("cfollowedhyperlink")) this.SetThemeColor(ctrlWordData.ctrlWord); //if(ctrlWordData.ctrlWord.Equals("cbackgroundone")) this.SetThemeColor(ctrlWordData.ctrlWord); //if(ctrlWordData.ctrlWord.Equals("ctextone")) this.SetThemeColor(ctrlWordData.ctrlWord); //if(ctrlWordData.ctrlWord.Equals("cbacgroundtwo")) this.SetThemeColor(ctrlWordData.ctrlWord); //if(ctrlWordData.ctrlWord.Equals("ctexttwo")) this.SetThemeColor(ctrlWordData.ctrlWord); return(true); }
public override bool HandleControlWord(RtfCtrlWordData ctrlWordData) { bool result = true; bool skipCtrlWord = false; if (this.rtfParser.IsImport()) { skipCtrlWord = true; if (ctrlWordData.ctrlWord.Equals("listtable")) { result = true; this.currentListMappingNumber = 0; } else /* Picture info for icons/images for lists */ if (ctrlWordData.ctrlWord.Equals("listpicture")) /* DESTINATION */ { skipCtrlWord = true; // this.rtfParser.SetTokeniserStateSkipGroup(); result = true; } else /* list */ if (ctrlWordData.ctrlWord.Equals("list")) /* DESTINATION */ { skipCtrlWord = true; this.newList = new RtfList(this.rtfParser.GetRtfDocument()); this.newList.SetListType(RtfList.LIST_TYPE_NORMAL); // set default this.currentLevel = -1; this.currentListMappingNumber++; this.currentSubGroupCount = 0; result = true; } else if (ctrlWordData.ctrlWord.Equals("listtemplateid")) /* // List item*/ { // ignore this because it gets regenerated in every document skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("listsimple")) /* // List item*/ { // is value 0 or 1 if (ctrlWordData.hasParam && ctrlWordData.param == "1") { this.newList.SetListType(RtfList.LIST_TYPE_SIMPLE); } else { this.newList.SetListType(RtfList.LIST_TYPE_NORMAL); } skipCtrlWord = true; result = true; // this gets set internally. Don't think it should be imported } else if (ctrlWordData.ctrlWord.Equals("listhybrid")) /* // List item*/ { this.newList.SetListType(RtfList.LIST_TYPE_HYBRID); skipCtrlWord = true; result = true; // this gets set internally. Don't think it should be imported } else if (ctrlWordData.ctrlWord.Equals("listrestarthdn")) /* // List item*/ { skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("listid")) // List item cannot be between -1 and -5 // needs to be mapped for imports and is recreated // we have the new id and the old id. Just add it to the mapping table here. { skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("listname")) /* // List item*/ { this.newList.SetName(ctrlWordData.param); skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("liststyleid")) /* // List item*/ { skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("liststylename")) /* // List item*/ { skipCtrlWord = true; result = true; } else /* listlevel */ if (ctrlWordData.ctrlWord.Equals("listlevel")) /* DESTINATION There are 1 or 9 listlevels per list */ { this.currentLevel++; this.currentListLevel = this.newList.GetListLevel(this.currentLevel); this.currentListLevel.SetTentative(false); skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("leveljc")) // listlevel item justify // this is the old number. Only use it if the current type is not set { if (this.currentListLevel.GetAlignment() == RtfListLevel.LIST_TYPE_UNKNOWN) { switch (ctrlWordData.IntValue()) { case 0: this.currentListLevel.SetAlignment(Element.ALIGN_LEFT); break; case 1: this.currentListLevel.SetAlignment(Element.ALIGN_CENTER); break; case 2: this.currentListLevel.SetAlignment(Element.ALIGN_RIGHT); break; } } skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("leveljcn")) // listlevel item //justify // if this exists, use it and it overrides the old setting { switch (ctrlWordData.IntValue()) { case 0: this.currentListLevel.SetAlignment(Element.ALIGN_LEFT); break; case 1: this.currentListLevel.SetAlignment(Element.ALIGN_CENTER); break; case 2: this.currentListLevel.SetAlignment(Element.ALIGN_RIGHT); break; } skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("levelstartat")) { this.currentListLevel.SetListStartAt(ctrlWordData.IntValue()); skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("lvltentative")) { this.currentListLevel.SetTentative(true); skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("levelold")) { // old style. ignore skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("levelprev")) { // old style. ignore skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("levelprevspace")) { // old style. ignore skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("levelspace")) { skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("levelindent")) { skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("leveltext")) /* FIX */ { skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("levelfollow")) { this.currentListLevel.SetLevelFollowValue(ctrlWordData.IntValue()); skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("levellegal")) { this.currentListLevel.SetLegal(ctrlWordData.param == "1"?true:false); skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("levelnorestart")) { skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("chrfmt")) /* FIX */ // set an attribute pair { skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("levelpicture")) { skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("li")) { // set an attribute pair skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("fi")) { // set an attribute pair skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("jclisttab")) { // set an attribute pair skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("tx")) { // set an attribute pair skipCtrlWord = true; result = true; } else /* number */ if (ctrlWordData.ctrlWord.Equals("levelnfc")) /* old style */ { if (this.currentListLevel.GetListType() == RtfListLevel.LIST_TYPE_UNKNOWN) { this.currentListLevel.SetListType(ctrlWordData.IntValue() + RtfListLevel.LIST_TYPE_BASE); } skipCtrlWord = true; result = true; } else if (ctrlWordData.ctrlWord.Equals("levelnfcn")) /* new style takes priority over levelnfc.*/ { this.currentListLevel.SetListType(ctrlWordData.IntValue() + RtfListLevel.LIST_TYPE_BASE); skipCtrlWord = true; result = true; } else /* level text */ if (ctrlWordData.ctrlWord.Equals("leveltemplateid")) { // ignore. this value is regenerated in each document. skipCtrlWord = true; result = true; } else /* levelnumber */ if (ctrlWordData.ctrlWord.Equals("levelnumbers")) { skipCtrlWord = true; result = true; } } if (this.rtfParser.IsConvert()) { if (ctrlWordData.ctrlWord.Equals("shppict")) { result = true; } if (ctrlWordData.ctrlWord.Equals("nonshppict")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true; } } if (!skipCtrlWord) { switch (this.rtfParser.GetConversionType()) { case RtfParser.TYPE_IMPORT_FULL: // WriteBuffer(); // WriteText(ctrlWordData.ToString()); result = true; break; case RtfParser.TYPE_IMPORT_FRAGMENT: // WriteBuffer(); // WriteText(ctrlWordData.ToString()); result = true; break; case RtfParser.TYPE_CONVERT: result = true; break; default: // error because is should be an import or convert result = false; break; } } return(result); }
public override bool HandleControlWord(RtfCtrlWordData ctrlWordData) { bool result = false; bool skipCtrlWord = false; if (this.rtfParser.IsImport()) { skipCtrlWord = true; if (ctrlWordData.ctrlWord.Equals("shppict")) { result = true; } if (ctrlWordData.ctrlWord.Equals("nonshppict")) // never gets here because this is a destination set to null { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true; } if (ctrlWordData.ctrlWord.Equals("blipuid")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true; } if (ctrlWordData.ctrlWord.Equals("picprop")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true; } if (ctrlWordData.ctrlWord.Equals("pict")) { result = true; } if (ctrlWordData.ctrlWord.Equals("emfblip")) { result = true; pictureType = Image.ORIGINAL_NONE; } if (ctrlWordData.ctrlWord.Equals("pngblip")) { result = true; pictureType = Image.ORIGINAL_PNG; } if (ctrlWordData.ctrlWord.Equals("jepgblip")) { result = true; pictureType = Image.ORIGINAL_JPEG; } if (ctrlWordData.ctrlWord.Equals("macpict")) { result = true; pictureType = Image.ORIGINAL_NONE; } if (ctrlWordData.ctrlWord.Equals("pmmetafile")) { result = true; pictureType = Image.ORIGINAL_NONE; } if (ctrlWordData.ctrlWord.Equals("wmetafile")) { result = true; pictureType = Image.ORIGINAL_WMF; } if (ctrlWordData.ctrlWord.Equals("dibitmap")) { result = true; pictureType = Image.ORIGINAL_NONE; } if (ctrlWordData.ctrlWord.Equals("wbitmap")) { result = true; pictureType = Image.ORIGINAL_BMP; } /* bitmap information */ if (ctrlWordData.ctrlWord.Equals("wbmbitspixel")) { result = true; } if (ctrlWordData.ctrlWord.Equals("wbmplanes")) { result = true; } if (ctrlWordData.ctrlWord.Equals("wbmwidthbytes")) { result = true; } /* picture size, scaling and cropping */ if (ctrlWordData.ctrlWord.Equals("picw")) { this.width = ctrlWordData.LongValue(); result = true; } if (ctrlWordData.ctrlWord.Equals("pich")) { this.height = ctrlWordData.LongValue(); result = true; } if (ctrlWordData.ctrlWord.Equals("picwgoal")) { this.desiredWidth = ctrlWordData.LongValue(); result = true; } if (ctrlWordData.ctrlWord.Equals("pichgoal")) { this.desiredHeight = ctrlWordData.LongValue(); result = true; } if (ctrlWordData.ctrlWord.Equals("picscalex")) { this.scaleX = ctrlWordData.IntValue(); result = true; } if (ctrlWordData.ctrlWord.Equals("picscaley")) { this.scaleY = ctrlWordData.IntValue(); result = true; } if (ctrlWordData.ctrlWord.Equals("picscaled")) { result = true; } if (ctrlWordData.ctrlWord.Equals("picprop")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true; } if (ctrlWordData.ctrlWord.Equals("defshp")) { result = true; } if (ctrlWordData.ctrlWord.Equals("piccropt")) { this.cropTop = ctrlWordData.IntValue(); result = true; } if (ctrlWordData.ctrlWord.Equals("piccropb")) { this.cropBottom = ctrlWordData.IntValue(); result = true; } if (ctrlWordData.ctrlWord.Equals("piccropl")) { this.cropLeft = ctrlWordData.IntValue(); result = true; } if (ctrlWordData.ctrlWord.Equals("piccropr")) { this.cropRight = ctrlWordData.IntValue(); result = true; } /* metafile information */ if (ctrlWordData.ctrlWord.Equals("picbmp")) { result = true; } if (ctrlWordData.ctrlWord.Equals("picbpp")) { result = true; } /* picture data */ if (ctrlWordData.ctrlWord.Equals("bin")) { this.dataFormat = FORMAT_BINARY; // set length to param this.binaryLength = ctrlWordData.LongValue(); this.rtfParser.SetTokeniserStateBinary(binaryLength); result = true; } if (ctrlWordData.ctrlWord.Equals("blipupi")) { result = true; } if (ctrlWordData.ctrlWord.Equals("blipuid")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true; } if (ctrlWordData.ctrlWord.Equals("bliptag")) { result = true; } } if (this.rtfParser.IsConvert()) { if (ctrlWordData.ctrlWord.Equals("shppict")) { result = true; } if (ctrlWordData.ctrlWord.Equals("nonshppict")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true; } if (ctrlWordData.ctrlWord.Equals("blipuid")) { result = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true; } if (ctrlWordData.ctrlWord.Equals("pict")) { result = true; } if (ctrlWordData.ctrlWord.Equals("emfblip")) { result = true; } if (ctrlWordData.ctrlWord.Equals("pngblip")) { result = true; } if (ctrlWordData.ctrlWord.Equals("jepgblip")) { result = true; } if (ctrlWordData.ctrlWord.Equals("macpict")) { result = true; } if (ctrlWordData.ctrlWord.Equals("pmmetafile")) { result = true; } if (ctrlWordData.ctrlWord.Equals("wmetafile")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true; } if (ctrlWordData.ctrlWord.Equals("dibitmap")) { result = true; } if (ctrlWordData.ctrlWord.Equals("wbitmap")) { result = true; } /* bitmap information */ if (ctrlWordData.ctrlWord.Equals("wbmbitspixel")) { result = true; } if (ctrlWordData.ctrlWord.Equals("wbmplanes")) { result = true; } if (ctrlWordData.ctrlWord.Equals("wbmwidthbytes")) { result = true; } /* picture size, scaling and cropping */ if (ctrlWordData.ctrlWord.Equals("picw")) { this.width = ctrlWordData.LongValue(); result = true; } if (ctrlWordData.ctrlWord.Equals("pich")) { this.height = ctrlWordData.LongValue(); result = true; } if (ctrlWordData.ctrlWord.Equals("picwgoal")) { this.desiredWidth = ctrlWordData.LongValue(); result = true; } if (ctrlWordData.ctrlWord.Equals("pichgoal")) { this.desiredHeight = ctrlWordData.LongValue(); result = true; } if (ctrlWordData.ctrlWord.Equals("picscalex")) { this.scaleX = ctrlWordData.IntValue(); result = true; } if (ctrlWordData.ctrlWord.Equals("picscaley")) { this.scaleY = ctrlWordData.IntValue(); result = true; } if (ctrlWordData.ctrlWord.Equals("picscaled")) { result = true; } if (ctrlWordData.ctrlWord.Equals("picprop")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true; } if (ctrlWordData.ctrlWord.Equals("defshp")) { result = true; } if (ctrlWordData.ctrlWord.Equals("piccropt")) { this.cropTop = ctrlWordData.IntValue(); result = true; } if (ctrlWordData.ctrlWord.Equals("piccropb")) { this.cropBottom = ctrlWordData.IntValue(); result = true; } if (ctrlWordData.ctrlWord.Equals("piccropl")) { this.cropLeft = ctrlWordData.IntValue(); result = true; } if (ctrlWordData.ctrlWord.Equals("piccropr")) { this.cropRight = ctrlWordData.IntValue(); result = true; } /* metafile information */ if (ctrlWordData.ctrlWord.Equals("picbmp")) { result = true; } if (ctrlWordData.ctrlWord.Equals("picbpp")) { result = true; } /* picture data */ if (ctrlWordData.ctrlWord.Equals("bin")) { dataFormat = FORMAT_BINARY; result = true; } if (ctrlWordData.ctrlWord.Equals("blipupi")) { result = true; } if (ctrlWordData.ctrlWord.Equals("blipuid")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true; } if (ctrlWordData.ctrlWord.Equals("bliptag")) { result = true; } } if (!skipCtrlWord) { switch (this.rtfParser.GetConversionType()) { case RtfParser.TYPE_IMPORT_FULL: WriteBuffer(); WriteText(ctrlWordData.ToString()); result = true; break; case RtfParser.TYPE_IMPORT_FRAGMENT: WriteBuffer(); WriteText(ctrlWordData.ToString()); result = true; break; case RtfParser.TYPE_CONVERT: result = true; break; default: // error because is should be an import or convert result = false; break; } } return(result); }