Subversion Repositories DevTools

Rev

Rev 2128 | Rev 2134 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2128 Rev 2130
Line 1... Line 1...
1
using System;
1
using System;
2
using System.Collections;
2
using System.Collections;
3
using System.Text;
3
using System.Text;
4
using Word;
4
using Word;
-
 
5
using Microsoft.Office.Core;
-
 
6
 
5
 
7
 
6
// TODO
8
// TODO
7
//
9
//
8
// 1) Make more efficient by using style IDs instead of names
-
 
9
// 2) Possible let user and a tag simply with </>
10
// 1) Possible let user and a tag simply with </>
10
 
11
 
11
 
12
 
12
 
13
 
13
namespace EA_DocGen
14
namespace EA_DocGen
14
{
15
{
15
	/// <summary>
16
	/// <summary>
16
	/// Summary description for TextParser.
17
	/// Summary description for TextParser.
17
	/// </summary>
18
	/// </summary>
18
	public class TextParser
19
   public class TextParser
19
	{
20
   {
20
      // An embedded formatting tag can be one of two types
21
      // An embedded formatting tag can be one of two types
21
      // * An EA_DocGen special format
22
      // * An EA_DocGen special format
22
      // * An MS-Word Style based format
23
      // * An MS-Word Style based format
23
      private enum style_type_e
24
      private enum style_type_e
24
      {
25
      {
25
         STYLE_EA_DOCGEN = 0,
26
         STYLE_EA_DOCGEN = 0,    // style is an EA_DocGen specific style or pattern 
26
         STYLE_MS_WORD,
27
         STYLE_MS_WORD,          // style is an MS-WORD style of character/font attribute
27
         STYLE_UNKNOWN = -1
28
         STYLE_UNKNOWN = -1
28
      };
29
      };
-
 
30
 
-
 
31
      private enum style_handling_e
29
    
32
      {
-
 
33
         STYLE_POST_FORMAT,      // text will require formatting AFTER the entire string has been serialised.
-
 
34
         STYLE_USE_TAG_STYLE,    // text will require the tag-implied style to be applied to it.
-
 
35
         STYLE_USE_CALLER_STYLE  // text will require the callers specified style to be applied to it.
-
 
36
      };
-
 
37
 
-
 
38
      // IDs for all of the styles we will process.
-
 
39
      // Note that the arrangement of enum values in the following type, has been made to allow
-
 
40
      // for some simple comparison tests during parsing, so do not re-arrange these enums without
-
 
41
      // addressing the necessary code changes in the parsing function.
-
 
42
      private enum style_id_e
-
 
43
      {
-
 
44
         // EA_DocGen styles (0..99)
-
 
45
         STYLE_ID_TABLE = 0,
-
 
46
         // add more EA_DocGen styles here when we need to
-
 
47
 
-
 
48
         // MS-WORD styles (100..)
-
 
49
         STYLE_ID_BODY1 = 100,
-
 
50
         STYLE_ID_BOLD,
-
 
51
         STYLE_ID_ITALIC,
-
 
52
         STYLE_ID_UNDERLINE,
-
 
53
         STYLE_ID_NORMAL,
-
 
54
         STYLE_ID_WARNING,
-
 
55
         STYLE_ID_NOTE,
-
 
56
         STYLE_ID_CODETEXT,
-
 
57
         // add more MS-WORD styles here when we need to
-
 
58
 
-
 
59
         // ALL bullet/list styles must be >= 200 for easy detection during post-formatting
-
 
60
         STYLE_ID_LIST_BULLET_0 = 200,
-
 
61
         STYLE_ID_LIST_BULLET_1,
-
 
62
         STYLE_ID_LIST_BULLET_2,
-
 
63
         STYLE_ID_LIST_BULLET_3,
-
 
64
         STYLE_ID_LIST_BULLET_4,
-
 
65
         STYLE_ID_LIST_INDENT_0,
-
 
66
         STYLE_ID_LIST_INDENT_1,
-
 
67
         STYLE_ID_LIST_INDENT_2,
-
 
68
         STYLE_ID_LIST_INDENT_3,
-
 
69
         STYLE_ID_LIST_INDENT_4,
-
 
70
         // Below here go lists that display numbering or lettering and so "restart numbering"
-
 
71
         // attributes are important
-
 
72
         STYLE_ID_LIST_NUMBER_0,
-
 
73
         STYLE_ID_LIST_NUMBER_1,
-
 
74
         STYLE_ID_LIST_NUMBER_2,
-
 
75
         STYLE_ID_LIST_NUMBER_3,
-
 
76
         STYLE_ID_LIST_NUMBER_4,
-
 
77
         STYLE_ID_LIST_ALPHA_0,
-
 
78
         STYLE_ID_LIST_ALPHA_1,
-
 
79
         STYLE_ID_LIST_ALPHA_2,
-
 
80
         STYLE_ID_LIST_ALPHA_3,
-
 
81
         STYLE_ID_LIST_ALPHA_4
-
 
82
         // do not put anything below here
-
 
83
      };
-
 
84
 
30
      // A token is a block of text associated with a tag (style) name and type
85
      // A token is a block of text associated with a tag (style) name and type
31
      private struct token_type
86
      private struct token_type
32
      {
87
      {
33
         public string txt;
88
         public string txt;                     // This is the text content enclosed by the tag
34
         public style_type_e styleType;
89
         public style_type_e styleType;         // The type MS-WORD or EA_DocGen
35
         public string styleName;
90
         public string styleName;               // The name of the style
36
         public int gen1;
91
         public style_id_e styleId;             // The id of the style
-
 
92
         public int level;                      // level (for list items only)
-
 
93
         public style_handling_e styleHandling; // Handling attribute for the style
37
      };
94
      };
38
 
95
 
39
      // Some formatting has to be applied after ALL the text of a description has been 
96
      // Some formatting has to be applied after ALL the text of a description has been
40
      // appended to the word document. For this formatting, we need to remember the word
97
      // appended to the word document. For this formatting, we need to remember the word
41
      // ranges that denote the text and the style name to apply.
98
      // ranges that denote the text and the style name to apply. So we do it in a list of
-
 
99
      // the following item.
42
      private struct postFormat_type
100
      private struct postFormat_type
43
      {
101
      {
44
         public postFormat_type(Word.Range wr, token_type tk)
102
         public postFormat_type(Word.Range wr, token_type tk)
45
         {
103
         {
46
            m_wr = wr;
104
            m_wr = wr;
Line 62... Line 120...
62
      {
120
      {
63
         // initialsie the hash table
121
         // initialsie the hash table
64
         styleDefs = new Hashtable();
122
         styleDefs = new Hashtable();
65
 
123
 
66
         // This list dictates what tags a user can use in the notes text of an EA element. When adding new items
124
         // This list dictates what tags a user can use in the notes text of an EA element. When adding new items
67
         // to this list, we have to update the parsing function obviously.
125
         // to this list, we may have to update the parsing function obviously.
68
 
126
 
69
         // The hash key is the short tag name that end-users will use in their descriptions. Tags found in 
127
         // The hash key is the short tag name that end-users will use in their descriptions. Tags found in
70
         // user text is matched to these keys, and the style definition if found can then be used.
128
         // user text is matched to these keys, and the style definition if found can then be used.
71
 
129
 
72
         // EA_DocGen tags
130
         // EA_DocGen tags
73
         styleDefs.Add( EA_Constants.EA_DocGenTable, formStyleDef( style_type_e.STYLE_EA_DOCGEN, EA_Constants.EA_DocGenTable, 0 ) );
131
         styleDefs.Add( EA_Constants.EA_DocGenTable, formStyleDef( style_type_e.STYLE_EA_DOCGEN, style_id_e.STYLE_ID_TABLE, EA_Constants.EA_DocGenTable, 0, style_handling_e.STYLE_USE_TAG_STYLE ) );
74
 
132
 
75
         // MS-Word formatting tags
133
         // MS-Word formatting tags
76
         styleDefs.Add( "b", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_Bold      ,0) );
134
         styleDefs.Add( "b", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_BOLD, EA_Constants.styleName_Bold      , 0, style_handling_e.STYLE_POST_FORMAT) );
77
         styleDefs.Add( "i", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_Italic    ,0) );
135
         styleDefs.Add( "i", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_ITALIC, EA_Constants.styleName_Italic    , 0, style_handling_e.STYLE_POST_FORMAT) );
78
         styleDefs.Add( "u", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_Underline ,0) );
136
         styleDefs.Add( "u", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_UNDERLINE, EA_Constants.styleName_Underline , 0, style_handling_e.STYLE_POST_FORMAT) );
79
 
137
 
80
         styleDefs.Add( "lb0", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_ListBullet0,1 ) );
138
         styleDefs.Add( "lb0", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_LIST_BULLET_0, EA_Constants.styleName_ListBullet0,1, style_handling_e.STYLE_POST_FORMAT ) );
81
         styleDefs.Add( "lb1", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_ListBullet1,2 ) );
139
         styleDefs.Add( "lb1", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_LIST_BULLET_1, EA_Constants.styleName_ListBullet1,2, style_handling_e.STYLE_POST_FORMAT ) );
82
         styleDefs.Add( "lb2", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_ListBullet2,3 ) );
140
         styleDefs.Add( "lb2", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_LIST_BULLET_2, EA_Constants.styleName_ListBullet2,3, style_handling_e.STYLE_POST_FORMAT ) );
83
         styleDefs.Add( "lb3", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_ListBullet3,4 ) );
141
         styleDefs.Add( "lb3", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_LIST_BULLET_3, EA_Constants.styleName_ListBullet3,4, style_handling_e.STYLE_POST_FORMAT ) );
84
         styleDefs.Add( "lb4", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_ListBullet4,5 ) );
142
         styleDefs.Add( "lb4", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_LIST_BULLET_4, EA_Constants.styleName_ListBullet4,5, style_handling_e.STYLE_POST_FORMAT ) );
85
         styleDefs.Add( "ln0", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_ListNumber0,1 ) );
143
         styleDefs.Add( "ln0", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_LIST_NUMBER_0, EA_Constants.styleName_ListNumber0,1, style_handling_e.STYLE_POST_FORMAT ) );
86
         styleDefs.Add( "ln1", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_ListNumber1,2 ) );
144
         styleDefs.Add( "ln1", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_LIST_NUMBER_1, EA_Constants.styleName_ListNumber1,2, style_handling_e.STYLE_POST_FORMAT ) );
87
         styleDefs.Add( "ln2", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_ListNumber2,3 ) );
145
         styleDefs.Add( "ln2", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_LIST_NUMBER_2, EA_Constants.styleName_ListNumber2,3, style_handling_e.STYLE_POST_FORMAT ) );
88
         styleDefs.Add( "ln3", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_ListNumber3,4 ) );
146
         styleDefs.Add( "ln3", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_LIST_NUMBER_3, EA_Constants.styleName_ListNumber3,4, style_handling_e.STYLE_POST_FORMAT ) );
89
         styleDefs.Add( "ln4", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_ListNumber4,5 ) );
147
         styleDefs.Add( "ln4", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_LIST_NUMBER_4, EA_Constants.styleName_ListNumber4,5, style_handling_e.STYLE_POST_FORMAT ) );
90
         styleDefs.Add( "li0", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_ListIndent0,1 ) );
148
         styleDefs.Add( "li0", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_LIST_INDENT_0, EA_Constants.styleName_ListIndent0,1, style_handling_e.STYLE_POST_FORMAT ) );
91
         styleDefs.Add( "li1", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_ListIndent1,2 ) );
149
         styleDefs.Add( "li1", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_LIST_INDENT_1, EA_Constants.styleName_ListIndent1,2, style_handling_e.STYLE_POST_FORMAT ) );
92
         styleDefs.Add( "li2", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_ListIndent2,3 ) );
150
         styleDefs.Add( "li2", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_LIST_INDENT_2, EA_Constants.styleName_ListIndent2,3, style_handling_e.STYLE_POST_FORMAT ) );
93
         styleDefs.Add( "li3", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_ListIndent3,4 ) );
151
         styleDefs.Add( "li3", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_LIST_INDENT_3, EA_Constants.styleName_ListIndent3,4, style_handling_e.STYLE_POST_FORMAT ) );
94
         styleDefs.Add( "li4", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_ListIndent4,5 ) );
152
         styleDefs.Add( "li4", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_LIST_INDENT_4, EA_Constants.styleName_ListIndent4,5, style_handling_e.STYLE_POST_FORMAT ) );
95
         styleDefs.Add( "la0", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_AlphaList0, 1 ) );
153
         styleDefs.Add( "la0", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_LIST_ALPHA_0, EA_Constants.styleName_AlphaList0, 1, style_handling_e.STYLE_POST_FORMAT ) );
96
         styleDefs.Add( "la1", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_AlphaList1, 2 ) );
154
         styleDefs.Add( "la1", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_LIST_ALPHA_1, EA_Constants.styleName_AlphaList1, 2, style_handling_e.STYLE_POST_FORMAT ) );
97
         styleDefs.Add( "la2", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_AlphaList2, 3 ) );
155
         styleDefs.Add( "la2", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_LIST_ALPHA_2, EA_Constants.styleName_AlphaList2, 3, style_handling_e.STYLE_POST_FORMAT ) );
98
         styleDefs.Add( "la3", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_AlphaList3, 4 ) );
156
         styleDefs.Add( "la3", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_LIST_ALPHA_3, EA_Constants.styleName_AlphaList3, 4, style_handling_e.STYLE_POST_FORMAT ) );
99
         styleDefs.Add( "la4", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_AlphaList4, 5 ) );
157
         styleDefs.Add( "la4", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_LIST_ALPHA_4, EA_Constants.styleName_AlphaList4, 5, style_handling_e.STYLE_POST_FORMAT ) );
100
 
158
 
101
         styleDefs.Add( "code", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_CodeText, 0 ) );
159
         styleDefs.Add( "code", formStyleDef( style_type_e.STYLE_MS_WORD,   style_id_e.STYLE_ID_CODETEXT, EA_Constants.styleName_CodeText, 0, style_handling_e.STYLE_USE_TAG_STYLE ) );
102
         styleDefs.Add( "normal", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_Normal  , 0 ) );
160
         styleDefs.Add( "normal", formStyleDef( style_type_e.STYLE_MS_WORD, style_id_e.STYLE_ID_NORMAL,   EA_Constants.styleName_Normal  , 0, style_handling_e.STYLE_USE_TAG_STYLE ) );
103
         styleDefs.Add( "note", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_Note  , 0 ) );
161
         styleDefs.Add( "note", formStyleDef( style_type_e.STYLE_MS_WORD,   style_id_e.STYLE_ID_NOTE,     EA_Constants.styleName_Note    , 0, style_handling_e.STYLE_USE_TAG_STYLE ) );
104
         styleDefs.Add( "warn", formStyleDef( style_type_e.STYLE_MS_WORD, EA_Constants.styleName_Warning , 0 ) );
162
         styleDefs.Add( "warn", formStyleDef( style_type_e.STYLE_MS_WORD,   style_id_e.STYLE_ID_WARNING,  EA_Constants.styleName_Warning , 0, style_handling_e.STYLE_USE_TAG_STYLE ) );
105
 
163
 
106
      }
164
      }
107
 
165
 
108
      /// <summary>
166
      /// <summary>
109
      /// Helper for initialise() function
167
      /// Helper for initialise() function
110
      /// </summary>
168
      /// </summary>
111
      /// <param name="styleType"></param>
169
      /// <param name="styleName"></param>
112
      /// <param name="styleName"></param>
170
      /// <param name="styleName"></param>
113
      /// <returns></returns>
171
      /// <returns></returns>
114
      private static token_type formStyleDef(style_type_e styleType, string styleName, int genvar1)
172
      private static token_type formStyleDef(style_type_e styleType, style_id_e styleId, string styleName, int levelvar, style_handling_e styleHandling)
115
      {
173
      {
116
         token_type tokenType = new token_type();
174
         token_type tokenType = new token_type();
-
 
175
         tokenType.styleType = styleType; // The kind of style (ms-word or ea_docgen)
117
         tokenType.styleType = styleType;
176
         tokenType.styleId   = styleId;   // The specific type of style
118
         tokenType.styleName = styleName;
177
         tokenType.styleName = styleName; // The name of the style
119
         tokenType.txt = null;
178
         tokenType.txt = null;            // This is the actual text to be formatted
-
 
179
         tokenType.level = levelvar;      // used to record level numbering - only really useful for bullet/list styles
120
         tokenType.gen1 = genvar1;
180
         tokenType.styleHandling = styleHandling;
121
         return tokenType;
181
         return tokenType;
122
      }
182
      }
123
 
183
 
124
 
184
 
-
 
185
      private static void initialiseToken(out token_type token)
-
 
186
      {
-
 
187
         token.styleName = EA_Constants.styleName_Body1;
-
 
188
         token.styleId   = style_id_e.STYLE_ID_BODY1;
-
 
189
         token.styleType = style_type_e.STYLE_MS_WORD;
-
 
190
         token.styleHandling = style_handling_e.STYLE_USE_CALLER_STYLE;
-
 
191
         token.txt = null;
-
 
192
         token.level = 0;
-
 
193
      }
125
 
194
 
126
      /// <summary>
195
      /// <summary>
127
      /// Parse the notes of an element and use the results to form document content.
196
      /// Parse the notes of an element and use the results to form document content.
128
      /// </summary>
197
      /// </summary>
129
      /// <param name="theElement"></param>
198
      /// <param name="theElement"></param>
130
      /// <param name="defaultStyle"></param>
199
      /// <param name="callerStyle"></param>
131
      /// <returns></returns>
200
      /// <returns></returns>
132
      public static bool parse(string s, int id, string defaultStyle, float indent_pts, bool continuation)
201
      public static bool parse(string s, int id, string callerStyle, float indent_pts, bool continuation)
133
      {
202
      {
134
         int pos;
203
         int pos;
135
         int pos_LeftBracket = 0;
204
         int pos_LeftBracket = 0;
136
         int pos_RightBracket = 0;
205
         int pos_RightBracket = 0;
137
         int pos_tagName;
206
         int pos_tagName;
Line 139... Line 208...
139
         int pos_ContentEnd;
208
         int pos_ContentEnd;
140
         bool lookingForTagEnd;
209
         bool lookingForTagEnd;
141
         bool foundError = false;
210
         bool foundError = false;
142
         Word.Range wr_body;
211
         Word.Range wr_body;
143
 
212
 
-
 
213
 
144
         // get relative (to 2.5cm) indentation user has commanded. At 2.5cm, the pts value is 70.866. We only indent, never outdent
214
         // Begin to construct a range that will eventually encompass ALL of the text we will serialize during the execution
-
 
215
         // of this function. This is needed later only if the caller has specified a requirement style that needs to have 
-
 
216
         // global strikethrough or italicising applied to (all of) the text
-
 
217
         object startLocation;
145
         // so end stop at 0.
218
         object endLocation;
-
 
219
         startLocation = createWordDoc.WordDocument.Content.End - 1;
-
 
220
 
-
 
221
         // Requirement element text must be indented according to the level number of the requirement tag. Caller
-
 
222
         // passes in absolute indentation value but for some items such as bullets/lists, we need a relative adjustment
-
 
223
         // since bullet/list styles have their own indentation settings and we only want to offset them rather than overwrite
-
 
224
         // them.
-
 
225
         // Get relative (to 2.5cm) indentation user has commanded. The 2.5cm mark is the standard point where body 1 text
-
 
226
         // begins. At 2.5cm, the pts value is 70.866. We only indent, never outdent so end stop at 0. 
146
         float relative_indent_adjustment = 0;
227
         float relative_indent_adjustment = 0;
147
         if (indent_pts > 0)
228
         if (indent_pts > 0)
148
         {
229
         {
149
            relative_indent_adjustment = indent_pts - (float)70.866;
230
            relative_indent_adjustment = indent_pts - (float)70.866;
150
            if (relative_indent_adjustment < 0)
231
            if (relative_indent_adjustment < 0)
151
               relative_indent_adjustment = 0;
232
               relative_indent_adjustment = 0;
152
         }
233
         }
153
 
234
 
-
 
235
         // A working variable and a list for completed tokens
154
         token_type token;
236
         token_type token;
155
         ArrayList tokens = new ArrayList();
237
         ArrayList tokens = new ArrayList();
156
 
238
 
157
         // default starting token - may be updated later
239
         // default starting token - may be updated later
158
         token.styleName = EA_Constants.styleName_Body1;
-
 
159
         token.styleType = style_type_e.STYLE_MS_WORD;
-
 
160
         token.txt = null;
240
         initialiseToken(out token);
161
         token.gen1 = 0;
-
 
-
 
241
 
162
 
242
 
163
         lookingForTagEnd = false;
243
         lookingForTagEnd = false;
164
         pos_ContentStart = 0;
244
         pos_ContentStart = 0;
165
 
245
 
-
 
246
         // PARSING LOOP -
-
 
247
         // Break up the input string into tokens that identify what kind of action is to be performed
-
 
248
         // with the token text. The default is as seen just above - apply Body1 MS-Word style. However,
-
 
249
         // if user has used formatting tags, the token style name, ID, and type will be updated accordingly.
-
 
250
         // This must be done iteratively until we have exhausted the input string.
-
 
251
 
166
         // look for a tag
252
         // look for a tag
167
         pos = s.IndexOf("<", 0);
253
         pos = s.IndexOf("<", 0);
168
         while ((pos >= 0) && (pos < s.Length))
254
         while ((pos >= 0) && (pos < s.Length))
169
         {
255
         {
170
            if (createWordDoc.abortCreationThread)
256
            if (createWordDoc.abortCreationThread)
Line 185... Line 271...
185
                  // skip past the / char
271
                  // skip past the / char
186
                  isEnding = true;
272
                  isEnding = true;
187
                  pos_tagName++;
273
                  pos_tagName++;
188
               }
274
               }
189
            }
275
            }
190
            
276
 
191
            // We found a possible tag, now figure out if this is one of the tags we recognise
277
            // We found a possible tag, now figure out if this is one of the tags we recognise
192
            bool found = false;
278
            bool found = false;
193
 
279
 
194
            // look for the closing bracket of the tag
280
            // look for the closing bracket of the tag
195
            pos = s.IndexOf(">", pos+1);
281
            pos = s.IndexOf(">", pos+1);
196
            if (pos >= 0)
282
            if (pos >= 0)
197
            {
283
            {
-
 
284
               // use hash table to identify the tag
198
               found = styleDefs.Contains(s.Substring(pos_tagName, pos - pos_tagName));
285
               found = styleDefs.Contains(s.Substring(pos_tagName, pos - pos_tagName));
199
            }
286
            }
200
            else
287
            else
201
            {
288
            {
202
               // Cannot find any '>' so we should just exit the loop
289
               // Cannot find any '>' so we should just exit the loop
Line 211... Line 298...
211
 
298
 
212
               // if this is an end tag, ie. </tagname>
299
               // if this is an end tag, ie. </tagname>
213
               if (isEnding)
300
               if (isEnding)
214
               {
301
               {
215
                  pos_ContentEnd = pos_LeftBracket - 1;  // not sure if we really need to compute pos_ContentEnd
302
                  pos_ContentEnd = pos_LeftBracket - 1;  // not sure if we really need to compute pos_ContentEnd
216
                
-
 
-
 
303
 
217
                  // check for out of sequence error
304
                  // check for out of sequence error
218
                  if (!lookingForTagEnd)
305
                  if (!lookingForTagEnd)
219
                  {
306
                  {
220
                     if (!foundError)
307
                     if (!foundError)
221
                     {
308
                     {
Line 224... Line 311...
224
                     }
311
                     }
225
                  }
312
                  }
226
                  else
313
                  else
227
                  {
314
                  {
228
                     // Check that the end tag matches the start tag
315
                     // Check that the end tag matches the start tag
-
 
316
                     // NOTE: If we were to allow lazy end-tagging (ie using '</>' only) we would have to do away with this
-
 
317
                     // check.
229
                     token_type tt = ((token_type)styleDefs[s.Substring(pos_tagName, pos_RightBracket-pos_tagName)]);
318
                     token_type tt = ((token_type)styleDefs[s.Substring(pos_tagName, pos_RightBracket-pos_tagName)]);
230
                     if (token.styleName == tt.styleName && 
319
                     if (token.styleType == tt.styleType &&
-
 
320
                        token.styleId == tt.styleId &&
231
                        token.styleType == tt.styleType)
321
                        token.styleName == tt.styleName)
232
                     {
322
                     {
233
                        // Update the token's text field and add the now complete token to our list
323
                        // Update the token's text field and add the now complete token to our list
234
                        // for processing a little later on.
324
                        // for processing a little later on.
235
                        token.txt = s.Substring(pos_ContentStart, pos_LeftBracket - pos_ContentStart);
325
                        token.txt = s.Substring(pos_ContentStart, pos_LeftBracket - pos_ContentStart);
236
                        tokens.Add(token);
326
                        tokens.Add(token);
237
 
327
 
238
                        // re-initialise token for next tag search
328
                        // re-initialise token for next tag search
239
                        token.styleName = EA_Constants.styleName_Body1;
-
 
240
                        token.styleType = style_type_e.STYLE_MS_WORD;
-
 
241
                        token.txt = null;
329
                        initialiseToken(out token);
242
 
330
 
243
                        lookingForTagEnd = false;
331
                        lookingForTagEnd = false;
244
 
332
 
245
                        pos_ContentStart = pos_RightBracket + 1;
333
                        pos_ContentStart = pos_RightBracket + 1;
246
                     }
334
                     }
Line 261... Line 349...
261
                  if ((pos_LeftBracket - pos_ContentStart) > 0)
349
                  if ((pos_LeftBracket - pos_ContentStart) > 0)
262
                  {
350
                  {
263
                     token.txt = s.Substring(pos_ContentStart, pos_LeftBracket - pos_ContentStart);
351
                     token.txt = s.Substring(pos_ContentStart, pos_LeftBracket - pos_ContentStart);
264
                     tokens.Add(token);
352
                     tokens.Add(token);
265
                  }
353
                  }
266
                
-
 
-
 
354
 
267
                  if (lookingForTagEnd)
355
                  if (lookingForTagEnd)
268
                  {
356
                  {
269
                     if (!foundError)
357
                     if (!foundError)
270
                     {
358
                     {
271
                        Main.WriteOutput(string.Format("ERROR, Found nested style tag ({0}), generated document text may be formatted incorrectly.", s.Substring(pos_LeftBracket, pos_RightBracket - pos_LeftBracket + 1)), id);
359
                        Main.WriteOutput(string.Format("ERROR, Found nested style tag ({0}), generated document text may be formatted incorrectly.", s.Substring(pos_LeftBracket, pos_RightBracket - pos_LeftBracket + 1)), id);
272
                        foundError = true;
360
                        foundError = true;
273
                     }
361
                     }
274
                  }
362
                  }
275
                  else
363
                  else
276
                  {
364
                  {
277
                     // update the token variable with this tags atributes from the hash table lookup
365
                     // update the token variable with this tags atributes from the hash table lookup. This overwrites
-
 
366
                     // the default values assigned when parsing began, or when we resumed parsing after dealing with
-
 
367
                     // the previous token found.
278
                     token_type tt = ((token_type)styleDefs[s.Substring(pos_tagName, pos_RightBracket-pos_tagName)]);
368
                     token_type lookupToken = ((token_type)styleDefs[s.Substring(pos_tagName, pos_RightBracket-pos_tagName)]);
279
                     token.styleName = tt.styleName;
369
                     token.styleId   = lookupToken.styleId;
280
                     token.styleType = tt.styleType;
370
                     token.styleType = lookupToken.styleType;
-
 
371
                     token.styleName = lookupToken.styleName;
281
                     token.gen1      = tt.gen1;
372
                     token.level     = lookupToken.level;
-
 
373
                     token.styleHandling = lookupToken.styleHandling;
282
                     token.txt = null; // we dont know what the text content will be yet. This is obtained when we encounter the end tag
374
                     token.txt = null; // we dont know what the text content will be yet. This is obtained when we encounter the end tag
283
 
375
 
284
                     pos_ContentStart = pos_RightBracket + 1;
376
                     pos_ContentStart = pos_RightBracket + 1;
285
 
377
 
286
                     lookingForTagEnd = true;
378
                     lookingForTagEnd = true;
Line 288... Line 380...
288
               }
380
               }
289
            }
381
            }
290
            else
382
            else
291
            {
383
            {
292
               // the tag was not recognised so for now we just treat it as if it were plain text and continue
384
               // the tag was not recognised so for now we just treat it as if it were plain text and continue
293
               //pos++;
-
 
294
            }
385
            }
295
 
386
 
296
            // look for next tag
387
            // look for next tag
297
            pos = s.IndexOf("<", pos);
388
            pos = s.IndexOf("<", pos);
298
 
389
 
299
         } // end of the loop
390
         } // end of the loop
300
 
391
 
301
 
392
 
302
         // POST-LOOP operations
-
 
303
 
-
 
304
         // take care of the last token, if there is one
393
         // take care of the last token, if there is one
305
         if (pos_ContentStart < s.Length)
394
         if (pos_ContentStart < s.Length)
306
         {
395
         {
307
            // Update the token's text field
396
            // Update the token's text field
308
            token.txt = s.Substring(pos_ContentStart, s.Length - pos_ContentStart);
397
            token.txt = s.Substring(pos_ContentStart, s.Length - pos_ContentStart);
Line 316... Line 405...
316
               Main.WriteOutput(string.Format("ERROR, Found incomplete style tag ({0}), generated document text may be formatted incorrectly.", s.Substring(pos_LeftBracket, pos_RightBracket - pos_LeftBracket + 1)), id);
405
               Main.WriteOutput(string.Format("ERROR, Found incomplete style tag ({0}), generated document text may be formatted incorrectly.", s.Substring(pos_LeftBracket, pos_RightBracket - pos_LeftBracket + 1)), id);
317
               foundError = true;
406
               foundError = true;
318
            }
407
            }
319
         }
408
         }
320
 
409
 
-
 
410
         // The way MS-Word works makes it necessary to do some formatting after we have serialised all of the text.
-
 
411
         // So, we need another list. This will contain elements that have the token AND the word range object that we
321
         
412
         // obtain when we serialise the text.
322
         ArrayList postFormats = new ArrayList();
413
         ArrayList postFormats = new ArrayList();
323
 
414
 
324
         // Now process all the tokens we have found
415
         // SERIALISATION LOOP - Now process all the tokens we have found
-
 
416
         int tt_i = 0;
325
         foreach (token_type tt in tokens)
417
         for (tt_i = 0; tt_i < tokens.Count; tt_i++)
326
         {
418
         {
-
 
419
            token_type tt = (token_type)tokens[tt_i];
-
 
420
 
327
            if (createWordDoc.abortCreationThread)
421
            if (createWordDoc.abortCreationThread)
328
               return false;
422
               return false;
329
 
423
 
330
            if (tt.txt != null && tt.txt.Length > 0)
424
            if (tt.txt != null && tt.txt.Length > 0)
331
            {
425
            {
332
 
426
 
333
               switch (tt.styleType)
427
               switch (tt.styleType)
334
               {
428
               {
335
                  case style_type_e.STYLE_EA_DOCGEN:
429
                  case style_type_e.STYLE_EA_DOCGEN:
336
                     switch (tt.styleName)
430
                     switch (tt.styleId)
337
                     {
431
                     {
338
                        case EA_Constants.EA_DocGenTable:
432
                        case style_id_e.STYLE_ID_TABLE:
339
                           TabularContent.processTableElement(tt.txt, 0, indent_pts);
433
                           TabularContent.processTableElement(tt.txt, 0, indent_pts);
340
                           continuation = false;
434
                           continuation = false;
341
 
435
 
342
                           // flag list numbering restart
436
                           // flag list numbering restart
343
                           postFormats.Add( new postFormat_type(null, tt) );
437
                           postFormats.Add( new postFormat_type(null, tt) );
Line 347... Line 441...
347
                           break;
441
                           break;
348
                     }
442
                     }
349
                     break;
443
                     break;
350
 
444
 
351
                  case style_type_e.STYLE_MS_WORD:
445
                  case style_type_e.STYLE_MS_WORD:
352
                     switch (tt.styleName)
446
                     switch (tt.styleHandling)
353
                     {
447
                     {
354
                        // List all formatting that has to be done after all of the text has been inserted into the 
-
 
355
                        // document ie. post-formatting
-
 
356
                        case EA_Constants.styleName_Bold:
-
 
357
                        case EA_Constants.styleName_Italic:
448
                        case style_handling_e.STYLE_POST_FORMAT:
358
                        case EA_Constants.styleName_Underline:
449
                           // Replace <br> with actual required characters, and use the caller supplied style when serialising
359
                        case EA_Constants.styleName_ListBullet0:
-
 
360
                        case EA_Constants.styleName_ListBullet1:
-
 
361
                        case EA_Constants.styleName_ListBullet2:
-
 
362
                        case EA_Constants.styleName_ListBullet3:
-
 
363
                        case EA_Constants.styleName_ListBullet4:
-
 
364
                        case EA_Constants.styleName_ListNumber0:
-
 
365
                        case EA_Constants.styleName_ListNumber1:
-
 
366
                        case EA_Constants.styleName_ListNumber2:
-
 
367
                        case EA_Constants.styleName_ListNumber3:
-
 
368
                        case EA_Constants.styleName_ListNumber4:
-
 
369
                        case EA_Constants.styleName_ListIndent0:
-
 
370
                        case EA_Constants.styleName_ListIndent1:
-
 
371
                        case EA_Constants.styleName_ListIndent2:
450
                           // the text
372
                        case EA_Constants.styleName_ListIndent3:
-
 
373
                        case EA_Constants.styleName_ListIndent4:
451
                           tt.txt = tt.txt.Replace("<br>","\r\n");
374
                        case EA_Constants.styleName_AlphaList0 :
-
 
375
                        case EA_Constants.styleName_AlphaList1 :
-
 
-
 
452
 
376
                        case EA_Constants.styleName_AlphaList2 :
453
                           // Serialise the text, initially applying callers style but since post-formatting will be
377
                        case EA_Constants.styleName_AlphaList3 :
454
                           // done later, the texts appearance will change from what this initially applied style
378
                        case EA_Constants.styleName_AlphaList4 :
455
                           // implies.
379
                           wr_body = TextualContent.appendAndSelectText( tt.txt, defaultStyle, continuation );
456
                           wr_body = TextualContent.appendAndSelectText( tt.txt, callerStyle, continuation );
380
                           continuation = true;
457
                           continuation = true;
-
 
458
 
381
                           if (wr_body.Characters.Last.Text.Equals("\r"))
459
                           while (wr_body.Characters.Last.Text.Equals("\r") || wr_body.Characters.Last.Text.Equals("\n"))
382
                              wr_body.End = wr_body.End - 1;  // don't format the \r char at the end - doing so causes wierd ms-word exceptions later on
460
                              wr_body.End = wr_body.End - 1;  // don't format the /n or \r char at the end - doing so causes wierd ms-word exceptions later on
383
                           postFormats.Add( new postFormat_type(wr_body, tt) );
461
                           postFormats.Add( new postFormat_type(wr_body, tt) );
384
                           break;
462
                           break;
385
 
463
 
386
                        case EA_Constants.styleName_CodeText:
464
                        case style_handling_e.STYLE_USE_TAG_STYLE:
-
 
465
                           // Replace <br> with actual required characters, and use the caller supplied style when serialising
387
                        case EA_Constants.styleName_Normal  :
466
                           // the text
388
                        case EA_Constants.styleName_Note    :
467
                           tt.txt = tt.txt.Replace("<br>","\r\n");
-
 
468
 
389
                        case EA_Constants.styleName_Warning :
469
                           // Serialise the text, applying the tag's style 
390
                           wr_body = TextualContent.appendAndSelectText( tt.txt, tt.styleName, continuation );
470
                           wr_body = TextualContent.appendAndSelectText( tt.txt, tt.styleName, continuation );
391
                           continuation = true;
471
                           continuation = true;
-
 
472
 
-
 
473
                           // Indent according to callers specified amount
392
                           if (indent_pts > 0)
474
                           if (indent_pts > 0)
393
                              wr_body.ParagraphFormat.LeftIndent = indent_pts;
475
                              wr_body.ParagraphFormat.LeftIndent = indent_pts;
394
 
476
 
395
                           // flag list numbering restart
477
                           // flag list numbering restart if this is printable text.
-
 
478
                           if (tt.txt.Trim().Length > 0)
396
                           postFormats.Add( new postFormat_type(null, tt) );
479
                              postFormats.Add( new postFormat_type(null, tt) );
397
                           break;
480
                           break;
398
 
481
 
399
 
482
 
400
                        // List all other formatting that can be done immediately.
483
                        case style_handling_e.STYLE_USE_CALLER_STYLE:
-
 
484
                           // Replace <br> with actual required characters, and use the caller supplied style when serialising
-
 
485
                           // the text
401
                        case EA_Constants.styleName_Body1:
486
                           tt.txt = tt.txt.Replace("<br>","\r\n");
-
 
487
 
-
 
488
                           // Serialise the text, applying callers style 
402
                           wr_body = TextualContent.appendAndSelectText( tt.txt, defaultStyle, continuation );
489
                           wr_body = TextualContent.appendAndSelectText( tt.txt, callerStyle, continuation );
403
                           continuation = true;
490
                           continuation = true;
-
 
491
 
-
 
492
                           // Indent according to callers specified amount
404
                           if (indent_pts > 0)
493
                           if (indent_pts > 0)
405
                              wr_body.ParagraphFormat.LeftIndent = indent_pts;
494
                              wr_body.ParagraphFormat.LeftIndent = indent_pts;
406
 
495
 
407
                           // flag list numbering restart if this is printable text.
496
                           // flag list numbering restart if this is printable text.
408
                           if (tt.txt.Trim().Length > 0)
497
                           if (tt.txt.Trim().Length > 0)
Line 416... Line 505...
416
 
505
 
417
                  default:
506
                  default:
418
                     break;
507
                     break;
419
               }
508
               }
420
            }
509
            }
421
         }
510
         } // end of serialisation loop
-
 
511
 
422
 
512
 
423
         // Now apply post formatting commands to text already serialised in previous loop
513
         // POST-FORMATTING LOOP - Now apply post formatting commands to text already serialised in previous loop
424
         int last_list_level = 0;
514
         int last_list_level = 0;
425
         foreach (postFormat_type pf in postFormats)
515
         foreach (postFormat_type pf in postFormats)
426
         {
516
         {
427
            object style;
517
            object style;
428
 
518
 
Line 434... Line 524...
434
            {
524
            {
435
               last_list_level = 0;
525
               last_list_level = 0;
436
            }
526
            }
437
            else
527
            else
438
            {
528
            {
439
               switch (pf.m_tk.styleName)
529
               switch (pf.m_tk.styleId)
440
               {
530
               {
441
                  case EA_Constants.styleName_Bold:
531
                  case style_id_e.STYLE_ID_BOLD:
442
                     pf.m_wr.Select();
532
                     pf.m_wr.Select();
443
                     createWordDoc.WordApp.Selection.Range.Bold = 1;
533
                     createWordDoc.WordApp.Selection.Range.Bold = 1;
444
                     last_list_level = 0;
534
                     last_list_level = 0;
445
                     break;
535
                     break;
446
 
536
 
447
                  case EA_Constants.styleName_Italic:
537
                  case style_id_e.STYLE_ID_ITALIC:
448
                     pf.m_wr.Select();
538
                     pf.m_wr.Select();
449
                     createWordDoc.WordApp.Selection.Range.Italic = 1;
539
                     createWordDoc.WordApp.Selection.Range.Italic = 1;
450
                     last_list_level = 0;
540
                     last_list_level = 0;
451
                     break;
541
                     break;
452
 
542
 
453
                  case EA_Constants.styleName_Underline:
543
                  case style_id_e.STYLE_ID_UNDERLINE:
454
                     pf.m_wr.Select();
544
                     pf.m_wr.Select();
455
                     createWordDoc.WordApp.Selection.Range.Underline = Word.WdUnderline.wdUnderlineSingle;
545
                     createWordDoc.WordApp.Selection.Range.Underline = Word.WdUnderline.wdUnderlineSingle;
456
                     last_list_level = 0;
546
                     last_list_level = 0;
457
                     break;
547
                     break;
458
 
548
 
459
                  case EA_Constants.styleName_ListBullet0:
549
                  default:
460
                  case EA_Constants.styleName_ListBullet1:
550
                     // Handle bullets/lists
461
                  case EA_Constants.styleName_ListBullet2:
-
 
462
                  case EA_Constants.styleName_ListBullet3:
-
 
463
                  case EA_Constants.styleName_ListBullet4:
-
 
464
                  case EA_Constants.styleName_ListIndent0:
551
                     if (pf.m_tk.styleId >= style_id_e.STYLE_ID_LIST_BULLET_0)
465
                  case EA_Constants.styleName_ListIndent1:
-
 
466
                  case EA_Constants.styleName_ListIndent2:
-
 
467
                  case EA_Constants.styleName_ListIndent3:
-
 
468
                  case EA_Constants.styleName_ListIndent4:
-
 
469
                  case EA_Constants.styleName_ListNumber0:
-
 
470
                  case EA_Constants.styleName_ListNumber1:
-
 
471
                  case EA_Constants.styleName_ListNumber2:
-
 
472
                  case EA_Constants.styleName_ListNumber3:
-
 
473
                  case EA_Constants.styleName_ListNumber4:
-
 
474
                  case EA_Constants.styleName_AlphaList0 :
-
 
475
                  case EA_Constants.styleName_AlphaList1 :
-
 
476
                  case EA_Constants.styleName_AlphaList2 :
-
 
477
                  case EA_Constants.styleName_AlphaList3 :
-
 
478
                  case EA_Constants.styleName_AlphaList4 :
552
                     {
479
                     style = pf.m_tk.styleName;
553
                        style = pf.m_tk.styleName;
480
                     pf.m_wr.Select();
554
                        pf.m_wr.Select();
481
                     createWordDoc.WordApp.Selection.Range.set_Style(ref style);
555
                        createWordDoc.WordApp.Selection.Range.set_Style(ref style);
482
 
556
 
-
 
557
                        // Figure out if we have to restart numbering
-
 
558
                        if (last_list_level < pf.m_tk.level)
-
 
559
                        {
483
                     //Main.WriteOutput(string.Format("last list level {0}, this list level {1}", last_list_level, pf.m_tk.gen1), -1);
560
                           // only need to restart numbering if this list displays numbering - bullets and simple
-
 
561
                           // indents do not, but alpha and numeric lists do. The style_id_e type has been organised to
-
 
562
                           // make this a simple test.
-
 
563
                           if (pf.m_tk.styleId >= style_id_e.STYLE_ID_LIST_NUMBER_0)
-
 
564
                           {
-
 
565
                              // To restart numbering, the only way to do it is to (re-)apply the list template to the 
-
 
566
                              // selection with a "continue previous list" setting of false, and an "apply to"
-
 
567
                              // setting of "whole list". 
-
 
568
                              object continuePreviousList = false;
-
 
569
                              object applyTo = Word.WdListApplyTo.wdListApplyToWholeList;
-
 
570
                              object defListBehavour = Word.WdDefaultListBehavior.wdWord10ListBehavior;
-
 
571
                              
-
 
572
                              Word.ListTemplate lt = createWordDoc.WordApp.Selection.Range.ListFormat.ListTemplate;
-
 
573
 
-
 
574
                              createWordDoc.WordApp.Selection.Range.ListFormat.ApplyListTemplate(
-
 
575
                                 lt, ref continuePreviousList, ref applyTo, ref defListBehavour);
-
 
576
                           }
-
 
577
                        }
484
 
578
 
485
                     // Figure out if we have to restart numbering
579
                        // shift content right by relative indent adjustment we calculated earlier
486
                     if (last_list_level < pf.m_tk.gen1)
-
 
487
                     {
-
 
488
                        Word.ListTemplate lt;
-
 
489
                        object continuePreviousList = false;
580
                        if (relative_indent_adjustment > 0)
490
                        object applyTo = Word.WdListApplyTo.wdListApplyToWholeList;
-
 
491
                        object defListBehavour = Word.WdDefaultListBehavior.wdWord10ListBehavior;
-
 
492
                    
-
 
493
                        if ((pf.m_tk.styleName.IndexOf("Alpha") >= 0) || (pf.m_tk.styleName.IndexOf("Number") >= 0))
-
 
494
                        {
581
                        {
495
                           lt = createWordDoc.WordApp.Selection.Range.ListFormat.ListTemplate;
-
 
496
                           
-
 
497
                           createWordDoc.WordApp.Selection.Range.ListFormat.ApplyListTemplate(
582
                           createWordDoc.WordApp.Selection.Range.ParagraphFormat.LeftIndent += relative_indent_adjustment;
498
                              lt, ref continuePreviousList, ref applyTo, ref defListBehavour);
-
 
499
                        }
583
                        }
500
                     }
-
 
501
 
584
 
502
                     // shift content right by relative indent adjustment we calculated earlier
-
 
503
                     if (relative_indent_adjustment > 0)
585
                        last_list_level = pf.m_tk.level;
504
                     {
-
 
505
                        createWordDoc.WordApp.Selection.Range.ParagraphFormat.LeftIndent += relative_indent_adjustment;
-
 
506
                     }
586
                     }
507
 
-
 
508
                     last_list_level = pf.m_tk.gen1;
-
 
509
                     break;
-
 
510
                  default:
-
 
511
                     break;
587
                     break;
512
               }
588
               }
513
            }
589
            }
-
 
590
         } // end of post-formatting loop
-
 
591
 
-
 
592
         // Special handling for Proposed and Rejected requirement sections - here the text must be italicies or
-
 
593
         // struck through (see definition of the styleName_ReqPropBody and styleName_ReqRejBody styles in StyleContent.cs).
-
 
594
         if (callerStyle.Equals(EA_Constants.styleName_ReqPropBody))
-
 
595
         {
-
 
596
            // Complete construction of a range that will encompass ALL of the text we will serialize during the execution
-
 
597
            // of this function
-
 
598
            endLocation = createWordDoc.WordDocument.Content.End;
-
 
599
            Word.Range wr_total = createWordDoc.WordDocument.Range(ref startLocation, ref endLocation);
-
 
600
            while (wr_total.Characters.Last.Text.Equals("\r") || wr_total.Characters.Last.Text.Equals("\n"))
-
 
601
               wr_total.End = wr_total.End - 1;  // don't format the \r\n char at the end - doing so causes wierd ms-word exceptions later on
-
 
602
 
-
 
603
            // italicise
-
 
604
            wr_total.Font.Italic = (int)MsoTriState.msoTrue;
514
         }
605
         }
-
 
606
         else if (callerStyle.Equals(EA_Constants.styleName_ReqRejBody))
-
 
607
         {
-
 
608
            // Complete construction of a range that will encompass ALL of the text we will serialize during the execution
-
 
609
            // of this function
-
 
610
            endLocation = createWordDoc.WordDocument.Content.End;
-
 
611
            Word.Range wr_total = createWordDoc.WordDocument.Range(ref startLocation, ref endLocation);
-
 
612
            while (wr_total.Characters.Last.Text.Equals("\r") || wr_total.Characters.Last.Text.Equals("\n"))
-
 
613
               wr_total.End = wr_total.End - 1;  // don't format the \r\n char at the end - doing so causes wierd ms-word exceptions later on
-
 
614
 
-
 
615
            // strikethrough - use msoCTrue since msoTrue simply toggles strikethough attribute, or so it seems
-
 
616
            wr_total.Font.StrikeThrough = (int)MsoTriState.msoCTrue;
-
 
617
         }
-
 
618
 
515
         return true;
619
         return true;
516
      }
620
      }
517
 
621
 
518
      
-
 
519
 
622
 
520
 
623
 
521
 
624
 
-
 
625
 
522
	}
626
   }
523
}
627
}