Beispiel #1
0
		public Test() {
			MemoryStream	stream;
			RTF		rtf;
			byte[]		buffer;

			text = new TextMap();
			TextMap.SetupStandardTable(text.Table);

			buffer = new byte[rtf_string.Length];
			for (int i = 0; i < buffer.Length; i++) {
				buffer[i] = (byte)rtf_string[i];
			}
			stream = new MemoryStream(buffer);
			rtf = new RTF(stream);

			skip_width = 0;
			skip_count = 0;

			rtf.ClassCallback[TokenClass.Text] = new ClassDelegate(HandleText);
			rtf.ClassCallback[TokenClass.Control] = new ClassDelegate(HandleControl);

			rtf.Read();

			stream.Close();
		}
Beispiel #2
0
		void Init ()
		{
			rtf = new RTF (Stream);

			if (text_map == null) {
				text_map = new TextMap ();
				TextMap.SetupStandardTable(text_map.Table);
			}

			sb = new StringBuilder ();
			sb.Length = 0;
			group_stack = new Stack<bool> ();
			current_is_hot = false;

			skip_width = 0;
			skip_count = 0;
		}
Beispiel #3
0
		public Test(string[] args) {
			if (args.Length == 0)
				throw new Exception ("Program needs path to rtf file as argument");

			FileStream	stream;
			RTF		rtf;

			text = new TextMap();
			TextMap.SetupStandardTable(text.Table);

			stream = new FileStream (@"../test.rtf", FileMode.Open);
			rtf = new RTF(stream);

			skip_width = 0;
			skip_count = 0;

			rtf.ClassCallback[TokenClass.Text] = new ClassDelegate(HandleText);
			rtf.ClassCallback[TokenClass.Control] = new ClassDelegate(HandleControl);

			rtf.Read();

			stream.Close();
		}
Beispiel #4
0
		private void InsertRTFFromStream(Stream data, int cursor_x, int cursor_y, out int to_x, out int to_y, out int chars) {
			RTF.RTF		rtf;

			rtf = new RTF.RTF(data);

			// Prepare
			rtf.ClassCallback[RTF.TokenClass.Text] = new RTF.ClassDelegate(HandleText);
			rtf.ClassCallback[RTF.TokenClass.Control] = new RTF.ClassDelegate(HandleControl);
			rtf.ClassCallback[RTF.TokenClass.Group] = new RTF.ClassDelegate(HandleGroup);

			rtf_skip_count = 0;
			rtf_line = new StringBuilder();
			rtf_style.rtf_color = Color.Empty;
			rtf_style.rtf_rtffont_size = (int)this.Font.Size;
			rtf_style.rtf_rtfalign = HorizontalAlignment.Left;
			rtf_style.rtf_rtfstyle = FontStyle.Regular;
			rtf_style.rtf_rtffont = null;
			rtf_style.rtf_visible = true;
			rtf_style.rtf_skip_width = 1;
			rtf_cursor_x = cursor_x;
			rtf_cursor_y = cursor_y;
			rtf_chars = 0;
			rtf.DefaultFont(this.Font.Name);

			rtf_text_map = new RTF.TextMap();
			RTF.TextMap.SetupStandardTable(rtf_text_map.Table);

			document.SuspendRecalc ();

			try {
				rtf.Read();	// That's it
				FlushText(rtf, false);

			}


			catch (RTF.RTFException e) {
#if DEBUG
				throw e;
#endif
				// Seems to be plain text or broken RTF
				Console.WriteLine("RTF Parsing failure: {0}", e.Message);
			}                     

			to_x = rtf_cursor_x;
			to_y = rtf_cursor_y;
			chars = rtf_chars;

			// clear the section stack if it was used
			if (rtf_section_stack != null)
				rtf_section_stack.Clear();

			document.RecalculateDocument(CreateGraphicsInternal(), cursor_y, document.Lines, false);
			document.ResumeRecalc (true);

			document.Invalidate (document.GetLine(cursor_y), 0, document.GetLine(document.Lines), -1);
		}