private void ReadPictGroup(RTF rtf) { bool read_image_data = false; Picture picture = new Picture (); while (true) { rtf.GetToken (); if (rtf.CheckCM (TokenClass.Group, Major.EndGroup)) break; switch (minor) { case Minor.PngBlip: picture.ImageType = minor; read_image_data = true; break; case Minor.WinMetafile: picture.ImageType = minor; read_image_data = true; continue; case Minor.PicWid: continue; case Minor.PicHt: continue; case Minor.PicGoalWid: picture.SetWidthFromTwips (param); continue; case Minor.PicGoalHt: picture.SetHeightFromTwips (param); continue; } if (read_image_data && rtf.rtf_class == TokenClass.Text) { picture.Data.Seek (0, SeekOrigin.Begin); //char c = (char) rtf.major; uint digitValue1; uint digitValue2; char hexDigit1 = (char) rtf.major; char hexDigit2; while (true) { while (hexDigit1 == '\n' || hexDigit1 == '\r') { hexDigit1 = (char) source.Peek (); if (hexDigit1 == '}') break; hexDigit1 = (char) source.Read (); } hexDigit2 = (char) source.Peek (); if (hexDigit2 == '}') break; hexDigit2 = (char) source.Read (); while (hexDigit2 == '\n' || hexDigit2 == '\r') { hexDigit2 = (char) source.Peek (); if (hexDigit2 == '}') break; hexDigit2 = (char) source.Read (); } if (Char.IsDigit (hexDigit1)) digitValue1 = (uint) (hexDigit1 - '0'); else if (Char.IsLower (hexDigit1)) digitValue1 = (uint) (hexDigit1 - 'a' + 10); else if (Char.IsUpper (hexDigit1)) digitValue1 = (uint) (hexDigit1 - 'A' + 10); else if (hexDigit1 == '\n' || hexDigit1 == '\r') continue; else break; if (Char.IsDigit (hexDigit2)) digitValue2 = (uint) (hexDigit2 - '0'); else if (Char.IsLower (hexDigit2)) digitValue2 = (uint) (hexDigit2 - 'a' + 10); else if (Char.IsUpper (hexDigit2)) digitValue2 = (uint) (hexDigit2 - 'A' + 10); else if (hexDigit2 == '\n' || hexDigit2 == '\r') continue; else break; picture.Data.WriteByte ((byte) checked (digitValue1 * 16 + digitValue2)); // We get the first hex digit at the end, since in the very first // iteration we use rtf.major as the first hex digit hexDigit1 = (char) source.Peek (); if (hexDigit1 == '}') break; hexDigit1 = (char) source.Read (); } read_image_data = false; break; } } if (picture.ImageType != Minor.Undefined && !read_image_data) { this.picture = picture; SetToken (TokenClass.Control, Major.PictAttr, picture.ImageType, 0, String.Empty); } }
internal PictureTag (Line line, int start, RTF.Picture picture) : base (line, start) { this.picture = picture; }
private void ReadPictGroup(RTF rtf) { bool read_image_data = false; int groupDepth = 0; Picture picture = new Picture(); while (true) { rtf.GetToken(); if (rtf.CheckCM(TokenClass.Group, Major.BeginGroup)) { groupDepth++; } if (rtf.CheckCM(TokenClass.Group, Major.EndGroup)) { groupDepth--; } if (groupDepth < 0) { break; } switch (minor) { case Minor.PngBlip: case Minor.JpegBlip: case Minor.WinMetafile: case Minor.EnhancedMetafile: picture.ImageType = minor; read_image_data = true; continue; case Minor.PicWid: continue; case Minor.PicHt: continue; case Minor.PicGoalWid: picture.SetWidthFromTwips(param); continue; case Minor.PicGoalHt: picture.SetHeightFromTwips(param); continue; } if (read_image_data && rtf.rtf_class == TokenClass.Text) { picture.Data.Seek(0, SeekOrigin.Begin); //char c = (char) rtf.major; uint digitValue1; uint digitValue2; char hexDigit1 = (char)rtf.major; char hexDigit2; while (true) { while (hexDigit1 == '\n' || hexDigit1 == '\r') { hexDigit1 = (char)source.Peek(); if (hexDigit1 == '}') { break; } hexDigit1 = (char)source.Read(); } hexDigit2 = (char)source.Peek(); if (hexDigit2 == '}') { break; } hexDigit2 = (char)source.Read(); while (hexDigit2 == '\n' || hexDigit2 == '\r') { hexDigit2 = (char)source.Peek(); if (hexDigit2 == '}') { break; } hexDigit2 = (char)source.Read(); } if (Char.IsDigit(hexDigit1)) { digitValue1 = (uint)(hexDigit1 - '0'); } else if (Char.IsLower(hexDigit1)) { digitValue1 = (uint)(hexDigit1 - 'a' + 10); } else if (Char.IsUpper(hexDigit1)) { digitValue1 = (uint)(hexDigit1 - 'A' + 10); } else if (hexDigit1 == '\n' || hexDigit1 == '\r') { continue; } else { break; } if (Char.IsDigit(hexDigit2)) { digitValue2 = (uint)(hexDigit2 - '0'); } else if (Char.IsLower(hexDigit2)) { digitValue2 = (uint)(hexDigit2 - 'a' + 10); } else if (Char.IsUpper(hexDigit2)) { digitValue2 = (uint)(hexDigit2 - 'A' + 10); } else if (hexDigit2 == '\n' || hexDigit2 == '\r') { continue; } else { break; } picture.Data.WriteByte((byte)checked (digitValue1 * 16 + digitValue2)); // We get the first hex digit at the end, since in the very first // iteration we use rtf.major as the first hex digit hexDigit1 = (char)source.Peek(); if (hexDigit1 == '}') { break; } hexDigit1 = (char)source.Read(); } read_image_data = false; break; } } if (picture.ImageType != Minor.Undefined && !read_image_data) { this.picture = picture; SetToken(TokenClass.Control, Major.PictAttr, picture.ImageType, 0, String.Empty); } }