/// <summary> /// Constructs a new RtfDestinationDocument using /// the parameters to initialize the object. /// </summary> public RtfDestinationDocument(RtfParser parser) : base(parser) { _rtfDoc = parser.GetRtfDocument(); _doc = parser.GetDocument(); _conversionType = parser.GetConversionType(); SetToDefaults(); if (RtfParser.IsConvert()) { RtfParser.GetState().Properties.AddRtfPropertyListener(this); } }
public override void SetParser(RtfParser parser) { RtfParser = parser; _rtfDoc = parser.GetRtfDocument(); _doc = parser.GetDocument(); _conversionType = parser.GetConversionType(); SetToDefaults(); if (RtfParser.IsConvert()) { RtfParser.GetState().Properties.AddRtfPropertyListener(this); } }
public override bool HandleControlWord(RtfCtrlWordData ctrlWordData) { var result = true; var skipCtrlWord = false; if (RtfParser.IsImport()) { skipCtrlWord = true; if (ctrlWordData.CtrlWord.Equals("listtable")) { result = true; _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; _newList = new RtfList(RtfParser.GetRtfDocument()); _newList.SetListType(RtfList.LIST_TYPE_NORMAL); // set default _currentLevel = -1; _currentListMappingNumber++; _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") { _newList.SetListType(RtfList.LIST_TYPE_SIMPLE); } else { _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*/ { _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*/ { _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 */ { _currentLevel++; _currentListLevel = _newList.GetListLevel(_currentLevel); _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 (_currentListLevel.GetAlignment() == RtfListLevel.LIST_TYPE_UNKNOWN) { switch (ctrlWordData.IntValue()) { case 0: _currentListLevel.SetAlignment(Element.ALIGN_LEFT); break; case 1: _currentListLevel.SetAlignment(Element.ALIGN_CENTER); break; case 2: _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: _currentListLevel.SetAlignment(Element.ALIGN_LEFT); break; case 1: _currentListLevel.SetAlignment(Element.ALIGN_CENTER); break; case 2: _currentListLevel.SetAlignment(Element.ALIGN_RIGHT); break; } skipCtrlWord = true; result = true; } else if (ctrlWordData.CtrlWord.Equals("levelstartat")) { _currentListLevel.SetListStartAt(ctrlWordData.IntValue()); skipCtrlWord = true; result = true; } else if (ctrlWordData.CtrlWord.Equals("lvltentative")) { _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")) { _currentListLevel.SetLevelFollowValue(ctrlWordData.IntValue()); skipCtrlWord = true; result = true; } else if (ctrlWordData.CtrlWord.Equals("levellegal")) { _currentListLevel.SetLegal(ctrlWordData.Param == "1"); 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 (_currentListLevel.GetListType() == RtfListLevel.LIST_TYPE_UNKNOWN) { _currentListLevel.SetListType(ctrlWordData.IntValue() + RtfListLevel.LIST_TYPE_BASE); } skipCtrlWord = true; result = true; } else if (ctrlWordData.CtrlWord.Equals("levelnfcn")) /* new style takes priority over levelnfc.*/ { _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 (RtfParser.IsConvert()) { if (ctrlWordData.CtrlWord.Equals("shppict")) { result = true; } if (ctrlWordData.CtrlWord.Equals("nonshppict")) { skipCtrlWord = true; RtfParser.SetTokeniserStateSkipGroup(); result = true; } } if (!skipCtrlWord) { switch (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) { var result = true; OnCtrlWord(ctrlWordData); // event handler if (RtfParser.IsImport()) { // information if (ctrlWordData.CtrlWord.Equals("s")) { } if (ctrlWordData.CtrlWord.Equals("cs")) { } if (ctrlWordData.CtrlWord.Equals("ds")) { } if (ctrlWordData.CtrlWord.Equals("ts")) { } if (ctrlWordData.CtrlWord.Equals("tsrowd")) { } if (ctrlWordData.CtrlWord.Equals("keycode")) { } if (ctrlWordData.CtrlWord.Equals("shift")) { } if (ctrlWordData.CtrlWord.Equals("ctrl")) { } if (ctrlWordData.CtrlWord.Equals("alt")) { } //cells if (ctrlWordData.CtrlWord.Equals("fn")) { } if (ctrlWordData.CtrlWord.Equals("additive")) { } if (ctrlWordData.CtrlWord.Equals("sbasedon")) { } if (ctrlWordData.CtrlWord.Equals("snext")) { } if (ctrlWordData.CtrlWord.Equals("sautoupd")) { } if (ctrlWordData.CtrlWord.Equals("shidden")) { } if (ctrlWordData.CtrlWord.Equals("slink")) { } if (ctrlWordData.CtrlWord.Equals("slocked")) { } if (ctrlWordData.CtrlWord.Equals("spersonal")) { } if (ctrlWordData.CtrlWord.Equals("scompose")) { } if (ctrlWordData.CtrlWord.Equals("sreply")) { } /* FORMATTING */ // brdrdef/parfmt/apoctl/tabdef/shading/chrfmt if (ctrlWordData.CtrlWord.Equals("styrsid")) { } if (ctrlWordData.CtrlWord.Equals("ssemihidden")) { } if (ctrlWordData.CtrlWord.Equals("sqformat")) { } if (ctrlWordData.CtrlWord.Equals("spriority")) { } if (ctrlWordData.CtrlWord.Equals("sunhideused")) { } /* TABLE STYLES */ if (ctrlWordData.CtrlWord.Equals("tscellwidth")) { } if (ctrlWordData.CtrlWord.Equals("tscellwidthfts")) { } if (ctrlWordData.CtrlWord.Equals("tscellpaddt")) { } if (ctrlWordData.CtrlWord.Equals("tscellpaddl")) { } if (ctrlWordData.CtrlWord.Equals("tscellpaddr")) { } if (ctrlWordData.CtrlWord.Equals("tscellpaddb")) { } if (ctrlWordData.CtrlWord.Equals("tscellpaddft"))/*0-auto, 3-twips*/ { } if (ctrlWordData.CtrlWord.Equals("tscellpaddfl"))/*0-auto, 3-twips*/ { } if (ctrlWordData.CtrlWord.Equals("tscellpaddfr"))/*0-auto, 3-twips*/ { } if (ctrlWordData.CtrlWord.Equals("tscellpaddfb"))/*0-auto, 3-twips*/ { } if (ctrlWordData.CtrlWord.Equals("tsvertalt")) { } if (ctrlWordData.CtrlWord.Equals("tsvertalc")) { } if (ctrlWordData.CtrlWord.Equals("tsvertalb")) { } if (ctrlWordData.CtrlWord.Equals("tsnowrap")) { } if (ctrlWordData.CtrlWord.Equals("tscellcfpat")) { } if (ctrlWordData.CtrlWord.Equals("tscellcbpat")) { } if (ctrlWordData.CtrlWord.Equals("tsbgbdiag")) { } if (ctrlWordData.CtrlWord.Equals("tsbgfdiag")) { } if (ctrlWordData.CtrlWord.Equals("tsbgcross")) { } if (ctrlWordData.CtrlWord.Equals("tsbgdcross")) { } if (ctrlWordData.CtrlWord.Equals("tsbgdkcross ")) { } if (ctrlWordData.CtrlWord.Equals("tsbgdkdcross")) { } if (ctrlWordData.CtrlWord.Equals("tsbghoriz")) { } if (ctrlWordData.CtrlWord.Equals("tsbgvert")) { } if (ctrlWordData.CtrlWord.Equals("tsbgdkhor")) { } if (ctrlWordData.CtrlWord.Equals("tsbgdkvert")) { } if (ctrlWordData.CtrlWord.Equals("tsbrdrt")) { } if (ctrlWordData.CtrlWord.Equals("tsbrdrb")) { } if (ctrlWordData.CtrlWord.Equals("tsbrdrl")) { } if (ctrlWordData.CtrlWord.Equals("tsbrdrr")) { } if (ctrlWordData.CtrlWord.Equals("tsbrdrh")) { } if (ctrlWordData.CtrlWord.Equals("tsbrdrv")) { } if (ctrlWordData.CtrlWord.Equals("tsbrdrdgl")) { } if (ctrlWordData.CtrlWord.Equals("tsbrdrdgr")) { } if (ctrlWordData.CtrlWord.Equals("tscbandsh")) { } if (ctrlWordData.CtrlWord.Equals("tscbandsv")) { } } if (ctrlWordData.CtrlWordType == RtfCtrlWordType.FLAG || ctrlWordData.CtrlWordType == RtfCtrlWordType.TOGGLE || ctrlWordData.CtrlWordType == RtfCtrlWordType.VALUE) { RtfParser.GetState().Properties.SetProperty(ctrlWordData); } switch (RtfParser.GetConversionType()) { case RtfParser.TYPE_IMPORT_FULL: result = true; break; case RtfParser.TYPE_IMPORT_FRAGMENT: 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) { var result = false; var skipCtrlWord = false; if (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; RtfParser.SetTokeniserStateSkipGroup(); result = true; } if (ctrlWordData.CtrlWord.Equals("blipuid")) { skipCtrlWord = true; RtfParser.SetTokeniserStateSkipGroup(); result = true; } if (ctrlWordData.CtrlWord.Equals("picprop")) { skipCtrlWord = true; 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")) { _width = ctrlWordData.LongValue(); result = true; } if (ctrlWordData.CtrlWord.Equals("pich")) { _height = ctrlWordData.LongValue(); result = true; } if (ctrlWordData.CtrlWord.Equals("picwgoal")) { _desiredWidth = ctrlWordData.LongValue(); result = true; } if (ctrlWordData.CtrlWord.Equals("pichgoal")) { _desiredHeight = ctrlWordData.LongValue(); result = true; } if (ctrlWordData.CtrlWord.Equals("picscalex")) { _scaleX = ctrlWordData.IntValue(); result = true; } if (ctrlWordData.CtrlWord.Equals("picscaley")) { _scaleY = ctrlWordData.IntValue(); result = true; } if (ctrlWordData.CtrlWord.Equals("picscaled")) { result = true; } if (ctrlWordData.CtrlWord.Equals("picprop")) { skipCtrlWord = true; RtfParser.SetTokeniserStateSkipGroup(); result = true; } if (ctrlWordData.CtrlWord.Equals("defshp")) { result = true; } if (ctrlWordData.CtrlWord.Equals("piccropt")) { _cropTop = ctrlWordData.IntValue(); result = true; } if (ctrlWordData.CtrlWord.Equals("piccropb")) { _cropBottom = ctrlWordData.IntValue(); result = true; } if (ctrlWordData.CtrlWord.Equals("piccropl")) { _cropLeft = ctrlWordData.IntValue(); result = true; } if (ctrlWordData.CtrlWord.Equals("piccropr")) { _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; // set length to param _binaryLength = ctrlWordData.LongValue(); RtfParser.SetTokeniserStateBinary(_binaryLength); result = true; } if (ctrlWordData.CtrlWord.Equals("blipupi")) { result = true; } if (ctrlWordData.CtrlWord.Equals("blipuid")) { skipCtrlWord = true; RtfParser.SetTokeniserStateSkipGroup(); result = true; } if (ctrlWordData.CtrlWord.Equals("bliptag")) { result = true; } } if (RtfParser.IsConvert()) { if (ctrlWordData.CtrlWord.Equals("shppict")) { result = true; } if (ctrlWordData.CtrlWord.Equals("nonshppict")) { skipCtrlWord = true; RtfParser.SetTokeniserStateSkipGroup(); result = true; } if (ctrlWordData.CtrlWord.Equals("blipuid")) { result = true; 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; 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")) { _width = ctrlWordData.LongValue(); result = true; } if (ctrlWordData.CtrlWord.Equals("pich")) { _height = ctrlWordData.LongValue(); result = true; } if (ctrlWordData.CtrlWord.Equals("picwgoal")) { _desiredWidth = ctrlWordData.LongValue(); result = true; } if (ctrlWordData.CtrlWord.Equals("pichgoal")) { _desiredHeight = ctrlWordData.LongValue(); result = true; } if (ctrlWordData.CtrlWord.Equals("picscalex")) { _scaleX = ctrlWordData.IntValue(); result = true; } if (ctrlWordData.CtrlWord.Equals("picscaley")) { _scaleY = ctrlWordData.IntValue(); result = true; } if (ctrlWordData.CtrlWord.Equals("picscaled")) { result = true; } if (ctrlWordData.CtrlWord.Equals("picprop")) { skipCtrlWord = true; RtfParser.SetTokeniserStateSkipGroup(); result = true; } if (ctrlWordData.CtrlWord.Equals("defshp")) { result = true; } if (ctrlWordData.CtrlWord.Equals("piccropt")) { _cropTop = ctrlWordData.IntValue(); result = true; } if (ctrlWordData.CtrlWord.Equals("piccropb")) { _cropBottom = ctrlWordData.IntValue(); result = true; } if (ctrlWordData.CtrlWord.Equals("piccropl")) { _cropLeft = ctrlWordData.IntValue(); result = true; } if (ctrlWordData.CtrlWord.Equals("piccropr")) { _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; RtfParser.SetTokeniserStateSkipGroup(); result = true; } if (ctrlWordData.CtrlWord.Equals("bliptag")) { result = true; } } if (!skipCtrlWord) { switch (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); }