Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Style.cs « System.Windows.Forms.RTF « Managed.Windows.Forms « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9e8ed79efc22419181350f4588bf080cfdcf071f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
//
// Authors:
//	Peter Bartok	(pbartok@novell.com)
//
//

// COMPLETE

namespace System.Windows.Forms.RTF {
	internal class Style {
		#region Local Variables
		public const int	NoStyleNum = 222;
		public const int	NormalStyleNum = 0;

		private string		name;
		private StyleType	type;
		private bool		additive;
		private int		num;
		private int		based_on;
		private int		next_par;
		private int		se_list;
		private bool		expanding;
		private StyleElement	elements;
		private Style		next;
		#endregion Local Variables

		#region Constructors
		public Style(RTF rtf) {
			num = -1;
			type = StyleType.Paragraph;
			based_on = NoStyleNum;
			next_par = -1;

			lock (rtf) {
				if (rtf.Styles == null) {
					rtf.Styles = this;
				} else {
					Style s = rtf.Styles;
					while (s.next != null)
						s = s.next;
					s.next = this;
				}
			}
		}
		#endregion	// Constructors

		#region Properties
		public string Name {
			get {
				return name;
			}

			set {
				name = value;
			}
		}

		public StyleType Type {
			get {
				return type;
			}

			set {
				type = value;
			}
		}

		public bool Additive {
			get {
				return additive;
			}

			set {
				additive = value;
			}
		}

		public int BasedOn {
			get {
				return based_on;
			}

			set {
				based_on = value;
			}
		}

		public StyleElement Elements {
			get {
				return elements;
			}

			set {
				elements = value;
			}
		}

		public bool Expanding {
			get {
				return expanding;
			}

			set {
				expanding = value;
			}
		}

		public int NextPar {
			get {
				return next_par;
			}

			set {
				next_par = value;
			}
		}

		public int Num {
			get {
				return num;
			}

			set {
				num = value;
			}
		}
		#endregion	// Properties

		#region Methods
		public void Expand(RTF rtf) {
			StyleElement	se;

			if (num == -1) {
				return;
			}

			if (expanding) {
				throw new Exception("Recursive style expansion");
			}
			expanding = true;

			if (num != based_on) {
				rtf.SetToken(TokenClass.Control, Major.ParAttr, Minor.StyleNum, based_on, "\\s");
				rtf.RouteToken();
			}

			se = elements;
			while (se != null) {
				rtf.TokenClass = se.TokenClass;
				rtf.Major = se.Major;
				rtf.Minor = se.Minor;
				rtf.Param = se.Param;
				rtf.Text = se.Text;
				rtf.RouteToken();
			}

			expanding = false;
		}

		static public Style GetStyle(RTF rtf, int style_number) {
			Style s;

			lock (rtf) {
				s = GetStyle(rtf.Styles, style_number);
			}
			return s;
		}

		static public Style GetStyle(Style start, int style_number) {
			Style	s;

			if (style_number == -1) {
				return start;
			}

			s = start;

			while ((s != null) && (s.num != style_number)) {
				s = s.next;
			}
			return s;
		}
		#endregion	// Methods
	}
}