Subversion Repositories DevTools

Rev

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

Rev 2104 Rev 2106
Line 4... Line 4...
4
using System.Text;
4
using System.Text;
5
using System.ComponentModel;
5
using System.ComponentModel;
6
using System.Windows.Forms;
6
using System.Windows.Forms;
7
using Word;
7
using Word;
8
using Microsoft.Office.Core;
8
using Microsoft.Office.Core;
9
 
-
 
-
 
9
using System.Threading;
10
 
10
 
11
namespace EA_DocGen
11
namespace EA_DocGen
12
{
12
{
13
 
13
 
14
 
14
 
Line 16... Line 16...
16
   /// Summary description for createWordDoc.
16
   /// Summary description for createWordDoc.
17
   /// </summary>
17
   /// </summary>
18
   public class createWordDoc : System.Windows.Forms.Form
18
   public class createWordDoc : System.Windows.Forms.Form
19
   {
19
   {
20
      // Enterprise Architect Model related data
20
      // Enterprise Architect Model related data
21
      private EA.Repository EA_Repository = null;
-
 
22
      private EA.Package EA_ParentPackage = null;
21
      private EA.Package EA_ParentPackage = null;
23
      private EA.Project EA_Project;
22
      private EA.Project EA_Project;
24
 
23
 
25
      private EA_Utilities EA_Utils = null;
-
 
26
 
-
 
27
      private TabularContent TableUtils = null;
24
      private Thread creationThread = null;           // Document generation thread
28
      private TextualContent TextUtils = null;
25
      public static bool abortCreationThread;         // Used to abort the document generation thread
29
      private StyleContent   StyleUtils = null;
26
      private bool mustClose = false;                 // Used to signal closure required for doc generation dialog
30
      private DocSectionTracking DocSectionTracker = null;
27
      private bool docGenCompletedNormally = false;   // Used to indicate if success message is made just prior to thread exit
31
 
28
 
32
      private bool oneShot_skipRootPackage = false;
29
      private bool oneShot_skipRootPackage = false;
33
      private bool oneShot_skipRootElementHeading = false;
30
      private bool oneShot_skipRootElementHeading = false;
34
 
31
 
35
      private int processingLink = 0;
32
      private int processingLink = 0;
Line 42... Line 39...
42
      private ArrayList classesNeedingUnitTests = null;
39
      private ArrayList classesNeedingUnitTests = null;
43
      private ArrayList classesWithUnitTests = null;
40
      private ArrayList classesWithUnitTests = null;
44
      private Word.Table utTraceabilityTable = null;
41
      private Word.Table utTraceabilityTable = null;
45
 
42
 
46
      // MS-Office Word related data
43
      // MS-Office Word related data
47
      private Word.Application WordApp = null;
44
      public static Word.Application WordApp = null;
48
      private Word.Document WordDocument = null;
45
      public static Word.Document WordDocument = null;
49
 
46
 
-
 
47
      // Form data
50
      private System.Windows.Forms.TextBox textBox_template;
48
      public System.Windows.Forms.TextBox textBox_template;
51
      private System.Windows.Forms.Button button_browse_template;
49
      private System.Windows.Forms.Button button_browse_template;
52
      private System.Windows.Forms.TextBox textBox_output_file;
50
      public System.Windows.Forms.TextBox textBox_output_file;
53
      private System.Windows.Forms.Button button_browse_output_file;
51
      private System.Windows.Forms.Button button_browse_output_file;
54
      private System.Windows.Forms.Button button_cancel;
52
      private System.Windows.Forms.Button button_cancel;
55
      private System.Windows.Forms.Button button_generate;
53
      private System.Windows.Forms.Button button_generate;
56
      private System.Windows.Forms.Button button_view_output;
54
      private System.Windows.Forms.Button button_view_output;
57
      private System.Windows.Forms.Label label1;
55
      private System.Windows.Forms.Label label1;
58
      private System.Windows.Forms.Label label2;
56
      private System.Windows.Forms.Label label2;
59
      private System.Windows.Forms.TextBox textBox_progress;
-
 
60
      private System.Windows.Forms.Label label3;
-
 
61
      private System.Windows.Forms.CheckBox checkBox_WordVisibility;
57
      private System.Windows.Forms.CheckBox checkBox_WordVisibility;
-
 
58
      private System.Windows.Forms.CheckBox checkBox_keep_on_top;
-
 
59
 
62
      /// <summary>
60
      /// <summary>
63
      /// Required designer variable.
61
      /// Required designer variable.
64
      /// </summary>
62
      /// </summary>
65
      private System.ComponentModel.Container components = null;
63
      private System.ComponentModel.Container components = null;
66
 
64
 
67
      public createWordDoc(EA.Repository theRepository, EA.Package theParentPackage, EA_Utilities theEA_Utils)
65
      public createWordDoc(EA.Package theParentPackage)
68
      {
66
      {
69
         //
67
         //
70
         // Required for Windows Form Designer support
68
         // Required for Windows Form Designer support
71
         //
69
         //
72
         InitializeComponent();
70
         InitializeComponent();
73
 
71
 
74
         EA_Repository    = theRepository;
-
 
75
         EA_ParentPackage = theParentPackage;
72
         EA_ParentPackage = theParentPackage;
76
         EA_Project       = EA_Repository.GetProjectInterface();
73
         EA_Project       = Main.EA_Repository.GetProjectInterface();
77
 
-
 
78
         EA_Utils         = theEA_Utils;
-
 
79
 
74
 
80
         DocSectionTracker = new DocSectionTracking();
75
         DocSectionTracking.initialise();
81
 
-
 
82
         TableUtils        = new TabularContent(WordApp, WordDocument, EA_Utils);
76
         TabularContent.initialise();
83
         TextUtils         = new TextualContent(WordApp, WordDocument, DocSectionTracker);
77
         TextualContent.initialise();
84
         StyleUtils        = new StyleContent(WordApp, WordDocument);
78
         StyleContent.initialise();
85
 
-
 
86
         
-
 
87
 
79
 
88
         WordApp = new Word.Application();
80
         WordApp = new Word.Application();
89
      }
81
      }
90
 
82
 
91
 
83
 
Line 121... Line 113...
121
         this.button_cancel = new System.Windows.Forms.Button();
113
         this.button_cancel = new System.Windows.Forms.Button();
122
         this.button_generate = new System.Windows.Forms.Button();
114
         this.button_generate = new System.Windows.Forms.Button();
123
         this.button_view_output = new System.Windows.Forms.Button();
115
         this.button_view_output = new System.Windows.Forms.Button();
124
         this.label1 = new System.Windows.Forms.Label();
116
         this.label1 = new System.Windows.Forms.Label();
125
         this.label2 = new System.Windows.Forms.Label();
117
         this.label2 = new System.Windows.Forms.Label();
126
         this.textBox_progress = new System.Windows.Forms.TextBox();
-
 
127
         this.label3 = new System.Windows.Forms.Label();
-
 
128
         this.checkBox_WordVisibility = new System.Windows.Forms.CheckBox();
118
         this.checkBox_WordVisibility = new System.Windows.Forms.CheckBox();
-
 
119
         this.checkBox_keep_on_top = new System.Windows.Forms.CheckBox();
129
         this.SuspendLayout();
120
         this.SuspendLayout();
130
         // 
121
         // 
131
         // textBox_template
122
         // textBox_template
132
         // 
123
         // 
133
         this.textBox_template.Location = new System.Drawing.Point(16, 40);
124
         this.textBox_template.Location = new System.Drawing.Point(8, 32);
134
         this.textBox_template.Name = "textBox_template";
125
         this.textBox_template.Name = "textBox_template";
135
         this.textBox_template.Size = new System.Drawing.Size(592, 22);
126
         this.textBox_template.Size = new System.Drawing.Size(696, 22);
136
         this.textBox_template.TabIndex = 0;
127
         this.textBox_template.TabIndex = 0;
137
         this.textBox_template.Text = "";
128
         this.textBox_template.Text = "";
138
         this.textBox_template.TextChanged += new System.EventHandler(this.textBox_template_TextChanged);
129
         this.textBox_template.TextChanged += new System.EventHandler(this.textBox_template_TextChanged);
139
         // 
130
         // 
140
         // button_browse_template
131
         // button_browse_template
141
         // 
132
         // 
142
         this.button_browse_template.Location = new System.Drawing.Point(616, 40);
133
         this.button_browse_template.Location = new System.Drawing.Point(712, 32);
143
         this.button_browse_template.Name = "button_browse_template";
134
         this.button_browse_template.Name = "button_browse_template";
144
         this.button_browse_template.Size = new System.Drawing.Size(80, 23);
135
         this.button_browse_template.Size = new System.Drawing.Size(64, 23);
145
         this.button_browse_template.TabIndex = 1;
136
         this.button_browse_template.TabIndex = 4;
146
         this.button_browse_template.Text = "Browse";
137
         this.button_browse_template.Text = "Browse";
147
         this.button_browse_template.Click += new System.EventHandler(this.button_browse_template_Click);
138
         this.button_browse_template.Click += new System.EventHandler(this.button_browse_template_Click);
148
         // 
139
         // 
149
         // textBox_output_file
140
         // textBox_output_file
150
         // 
141
         // 
151
         this.textBox_output_file.Location = new System.Drawing.Point(16, 112);
142
         this.textBox_output_file.Location = new System.Drawing.Point(8, 96);
152
         this.textBox_output_file.Name = "textBox_output_file";
143
         this.textBox_output_file.Name = "textBox_output_file";
153
         this.textBox_output_file.Size = new System.Drawing.Size(592, 22);
144
         this.textBox_output_file.Size = new System.Drawing.Size(696, 22);
154
         this.textBox_output_file.TabIndex = 2;
145
         this.textBox_output_file.TabIndex = 1;
155
         this.textBox_output_file.Text = "";
146
         this.textBox_output_file.Text = "";
156
         this.textBox_output_file.TextChanged += new System.EventHandler(this.textBox_output_file_TextChanged);
147
         this.textBox_output_file.TextChanged += new System.EventHandler(this.textBox_output_file_TextChanged);
157
         // 
148
         // 
158
         // button_browse_output_file
149
         // button_browse_output_file
159
         // 
150
         // 
160
         this.button_browse_output_file.Location = new System.Drawing.Point(616, 112);
151
         this.button_browse_output_file.Location = new System.Drawing.Point(712, 96);
161
         this.button_browse_output_file.Name = "button_browse_output_file";
152
         this.button_browse_output_file.Name = "button_browse_output_file";
162
         this.button_browse_output_file.Size = new System.Drawing.Size(80, 24);
153
         this.button_browse_output_file.Size = new System.Drawing.Size(64, 24);
163
         this.button_browse_output_file.TabIndex = 3;
154
         this.button_browse_output_file.TabIndex = 5;
164
         this.button_browse_output_file.Text = "Browse";
155
         this.button_browse_output_file.Text = "Browse";
165
         this.button_browse_output_file.Click += new System.EventHandler(this.button_browse_output_file_Click);
156
         this.button_browse_output_file.Click += new System.EventHandler(this.button_browse_output_file_Click);
166
         // 
157
         // 
167
         // button_cancel
158
         // button_cancel
168
         // 
159
         // 
-
 
160
         this.button_cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
169
         this.button_cancel.Location = new System.Drawing.Point(616, 384);
161
         this.button_cancel.Location = new System.Drawing.Point(648, 152);
170
         this.button_cancel.Name = "button_cancel";
162
         this.button_cancel.Name = "button_cancel";
171
         this.button_cancel.Size = new System.Drawing.Size(80, 23);
163
         this.button_cancel.Size = new System.Drawing.Size(128, 32);
172
         this.button_cancel.TabIndex = 4;
164
         this.button_cancel.TabIndex = 3;
173
         this.button_cancel.Text = "Close";
165
         this.button_cancel.Text = "Close / Abort";
174
         this.button_cancel.Click += new System.EventHandler(this.button_cancel_Click);
166
         this.button_cancel.Click += new System.EventHandler(this.button_cancel_Click);
175
         // 
167
         // 
176
         // button_generate
168
         // button_generate
177
         // 
169
         // 
178
         this.button_generate.Location = new System.Drawing.Point(496, 384);
170
         this.button_generate.Location = new System.Drawing.Point(496, 152);
179
         this.button_generate.Name = "button_generate";
171
         this.button_generate.Name = "button_generate";
180
         this.button_generate.Size = new System.Drawing.Size(96, 24);
172
         this.button_generate.Size = new System.Drawing.Size(128, 32);
181
         this.button_generate.TabIndex = 5;
173
         this.button_generate.TabIndex = 2;
182
         this.button_generate.Text = "Generate";
174
         this.button_generate.Text = "Generate";
183
         this.button_generate.Click += new System.EventHandler(this.button_generate_Click);
175
         this.button_generate.Click += new System.EventHandler(this.button_generate_Click);
184
         // 
176
         // 
185
         // button_view_output
177
         // button_view_output
186
         // 
178
         // 
187
         this.button_view_output.Enabled = false;
179
         this.button_view_output.Enabled = false;
188
         this.button_view_output.Location = new System.Drawing.Point(376, 384);
180
         this.button_view_output.Location = new System.Drawing.Point(336, 152);
189
         this.button_view_output.Name = "button_view_output";
181
         this.button_view_output.Name = "button_view_output";
190
         this.button_view_output.Size = new System.Drawing.Size(96, 23);
182
         this.button_view_output.Size = new System.Drawing.Size(128, 32);
191
         this.button_view_output.TabIndex = 6;
183
         this.button_view_output.TabIndex = 6;
192
         this.button_view_output.Text = "View Output";
184
         this.button_view_output.Text = "View Output";
193
         this.button_view_output.Click += new System.EventHandler(this.button_view_output_Click);
185
         this.button_view_output.Click += new System.EventHandler(this.button_view_output_Click);
194
         // 
186
         // 
195
         // label1
187
         // label1
196
         // 
188
         // 
197
         this.label1.Location = new System.Drawing.Point(16, 16);
189
         this.label1.Location = new System.Drawing.Point(8, 8);
198
         this.label1.Name = "label1";
190
         this.label1.Name = "label1";
199
         this.label1.Size = new System.Drawing.Size(224, 23);
191
         this.label1.Size = new System.Drawing.Size(224, 23);
200
         this.label1.TabIndex = 7;
192
         this.label1.TabIndex = 7;
201
         this.label1.Text = "Input Template or Document Name";
193
         this.label1.Text = "Input Template or Document Name";
202
         // 
194
         // 
203
         // label2
195
         // label2
204
         // 
196
         // 
205
         this.label2.Location = new System.Drawing.Point(16, 88);
197
         this.label2.Location = new System.Drawing.Point(8, 72);
206
         this.label2.Name = "label2";
198
         this.label2.Name = "label2";
207
         this.label2.Size = new System.Drawing.Size(280, 23);
199
         this.label2.Size = new System.Drawing.Size(280, 23);
208
         this.label2.TabIndex = 8;
200
         this.label2.TabIndex = 8;
209
         this.label2.Text = "Output Document Name";
201
         this.label2.Text = "Output Document Name";
210
         // 
202
         // 
211
         // textBox_progress
-
 
212
         // 
-
 
213
         this.textBox_progress.Location = new System.Drawing.Point(16, 184);
-
 
214
         this.textBox_progress.Multiline = true;
-
 
215
         this.textBox_progress.Name = "textBox_progress";
-
 
216
         this.textBox_progress.ReadOnly = true;
-
 
217
         this.textBox_progress.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
-
 
218
         this.textBox_progress.Size = new System.Drawing.Size(680, 168);
-
 
219
         this.textBox_progress.TabIndex = 9;
-
 
220
         this.textBox_progress.Text = "";
-
 
221
         // 
-
 
222
         // label3
-
 
223
         // 
-
 
224
         this.label3.Location = new System.Drawing.Point(16, 152);
-
 
225
         this.label3.Name = "label3";
-
 
226
         this.label3.TabIndex = 10;
-
 
227
         this.label3.Text = "Progress";
-
 
228
         // 
-
 
229
         // checkBox_WordVisibility
203
         // checkBox_WordVisibility
230
         // 
204
         // 
231
         this.checkBox_WordVisibility.Location = new System.Drawing.Point(16, 384);
205
         this.checkBox_WordVisibility.Location = new System.Drawing.Point(8, 168);
232
         this.checkBox_WordVisibility.Name = "checkBox_WordVisibility";
206
         this.checkBox_WordVisibility.Name = "checkBox_WordVisibility";
233
         this.checkBox_WordVisibility.Size = new System.Drawing.Size(256, 24);
207
         this.checkBox_WordVisibility.Size = new System.Drawing.Size(256, 24);
234
         this.checkBox_WordVisibility.TabIndex = 17;
208
         this.checkBox_WordVisibility.TabIndex = 7;
235
         this.checkBox_WordVisibility.Text = "Show MS-WORD During Construction";
209
         this.checkBox_WordVisibility.Text = "Show MS-WORD During Construction";
236
         // 
210
         // 
-
 
211
         // checkBox_keep_on_top
-
 
212
         // 
-
 
213
         this.checkBox_keep_on_top.Checked = true;
-
 
214
         this.checkBox_keep_on_top.CheckState = System.Windows.Forms.CheckState.Checked;
-
 
215
         this.checkBox_keep_on_top.Location = new System.Drawing.Point(8, 136);
-
 
216
         this.checkBox_keep_on_top.Name = "checkBox_keep_on_top";
-
 
217
         this.checkBox_keep_on_top.Size = new System.Drawing.Size(224, 24);
-
 
218
         this.checkBox_keep_on_top.TabIndex = 9;
-
 
219
         this.checkBox_keep_on_top.Text = "Keep dialog on top";
-
 
220
         this.checkBox_keep_on_top.CheckedChanged += new System.EventHandler(this.checkBox_keep_on_top_CheckedChanged);
-
 
221
         // 
237
         // createWordDoc
222
         // createWordDoc
238
         // 
223
         // 
-
 
224
         this.AcceptButton = this.button_generate;
239
         this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
225
         this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
-
 
226
         this.CancelButton = this.button_cancel;
240
         this.ClientSize = new System.Drawing.Size(712, 432);
227
         this.ClientSize = new System.Drawing.Size(784, 202);
-
 
228
         this.Controls.Add(this.checkBox_keep_on_top);
241
         this.Controls.Add(this.checkBox_WordVisibility);
229
         this.Controls.Add(this.checkBox_WordVisibility);
242
         this.Controls.Add(this.label3);
-
 
243
         this.Controls.Add(this.textBox_progress);
-
 
244
         this.Controls.Add(this.textBox_output_file);
230
         this.Controls.Add(this.textBox_output_file);
245
         this.Controls.Add(this.textBox_template);
231
         this.Controls.Add(this.textBox_template);
246
         this.Controls.Add(this.label2);
232
         this.Controls.Add(this.label2);
247
         this.Controls.Add(this.label1);
233
         this.Controls.Add(this.label1);
248
         this.Controls.Add(this.button_view_output);
234
         this.Controls.Add(this.button_view_output);
249
         this.Controls.Add(this.button_generate);
235
         this.Controls.Add(this.button_generate);
250
         this.Controls.Add(this.button_cancel);
236
         this.Controls.Add(this.button_cancel);
251
         this.Controls.Add(this.button_browse_output_file);
237
         this.Controls.Add(this.button_browse_output_file);
252
         this.Controls.Add(this.button_browse_template);
238
         this.Controls.Add(this.button_browse_template);
-
 
239
         this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
253
         this.Name = "createWordDoc";
240
         this.Name = "createWordDoc";
-
 
241
         this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
-
 
242
         this.Text = "Generate Document From Document Model";
254
         this.Text = "createWordDoc";
243
         this.TopMost = true;
255
         this.Closing += new System.ComponentModel.CancelEventHandler(this.createWordDoc_Closing);
244
         this.Closing += new System.ComponentModel.CancelEventHandler(this.createWordDoc_Closing);
256
         this.ResumeLayout(false);
245
         this.ResumeLayout(false);
257
 
246
 
258
      }
247
      }
259
      #endregion
248
      #endregion
Line 268... Line 257...
268
         }
257
         }
269
         button_view_output.Enabled = false;
258
         button_view_output.Enabled = false;
270
      }
259
      }
271
 
260
 
272
 
261
 
273
 
-
 
274
 
-
 
275
      private void button_generate_Click(object sender, System.EventArgs e)
262
      private void button_generate_Click(object sender, System.EventArgs e)
276
      {
263
      {
277
         if (this.textBox_template.Text.Length > 0)
264
         if (this.textBox_template.Text.Length > 0)
278
         {
265
         {
279
            if (this.textBox_output_file.Text.Length > 0)
266
            if (this.textBox_output_file.Text.Length > 0)
280
            {
267
            {
-
 
268
               creationThread = new Thread(new ThreadStart(createTheWordDoc));
281
               button_generate.Enabled = false;
269
               creationThread.ApartmentState = ApartmentState.STA;
-
 
270
               creationThread.Priority = ThreadPriority.Highest;
282
               createTheWordDoc();
271
               creationThread.Start();
283
            }
272
            }
284
            else
273
            else
285
            {
274
            {
286
               MessageBox.Show("Error - must specify an output file");
275
               MessageBox.Show("Error - must specify an output file");
287
            }
276
            }
Line 290... Line 279...
290
         {
279
         {
291
            MessageBox.Show("Error - must specify an input template file");
280
            MessageBox.Show("Error - must specify an input template file");
292
         }
281
         }
293
      }
282
      }
294
 
283
 
-
 
284
 
295
      private void button_cancel_Click(object sender, System.EventArgs e)
285
      private void button_cancel_Click(object sender, System.EventArgs e)
296
      {
286
      {
297
         this.Close();   
-
 
298
      }
287
      }
299
 
288
 
-
 
289
 
300
      private void button_browse_template_Click(object sender, System.EventArgs e)
290
      private void button_browse_template_Click(object sender, System.EventArgs e)
301
      {
291
      {
302
         OpenFileDialog dialog = new OpenFileDialog();
292
         OpenFileDialog dialog = new OpenFileDialog();
303
         dialog.Filter = "Word Files (*.doc;*.dot)|*.doc;*.dot|All files(*.*)|*.*";
293
         dialog.Filter = "Word Files (*.doc;*.dot)|*.doc;*.dot|All files(*.*)|*.*";
304
         dialog.FilterIndex = 1;
294
         dialog.FilterIndex = 1;
305
         dialog.ShowDialog();
295
         if (DialogResult.OK == dialog.ShowDialog())
-
 
296
         {
306
         this.textBox_template.Text = dialog.FileName;
297
            this.textBox_template.Text = dialog.FileName;
307
 
298
         }
308
      }
299
      }
309
 
300
 
-
 
301
 
310
      private void button_browse_output_file_Click(object sender, System.EventArgs e)
302
      private void button_browse_output_file_Click(object sender, System.EventArgs e)
311
      {
303
      {
312
         OpenFileDialog dialog = new OpenFileDialog();
304
         OpenFileDialog dialog = new OpenFileDialog();
313
         dialog.Filter = "Word Files (*.doc;*.dot)|*.doc;*.dot|All files(*.*)|*.*";
305
         dialog.Filter = "Word Files (*.doc;*.dot)|*.doc;*.dot|All files(*.*)|*.*";
314
         dialog.FilterIndex = 1;
306
         dialog.FilterIndex = 1;
315
         dialog.CheckFileExists = false;
307
         dialog.CheckFileExists = false;
316
         dialog.ShowDialog();
308
         if (DialogResult.OK == dialog.ShowDialog())
-
 
309
         {
317
         this.textBox_output_file.Text = dialog.FileName;
310
            this.textBox_output_file.Text = dialog.FileName;
-
 
311
         }
318
      }
312
      }
319
 
313
 
-
 
314
 
320
      private void textBox_template_TextChanged(object sender, System.EventArgs e)
315
      private void textBox_template_TextChanged(object sender, System.EventArgs e)
321
      {
316
      {
322
      
317
      
323
      }
318
      }
324
 
319
 
-
 
320
 
-
 
321
      private void checkBox_keep_on_top_CheckedChanged(object sender, System.EventArgs e)
-
 
322
      {
-
 
323
         this.TopMost = this.checkBox_keep_on_top.Checked; 
-
 
324
      }
-
 
325
 
-
 
326
 
325
      private void textBox_output_file_TextChanged(object sender, System.EventArgs e)
327
      private void textBox_output_file_TextChanged(object sender, System.EventArgs e)
326
      {
328
      {
327
      
329
      
328
      }
330
      }
329
      
331
      
-
 
332
 
330
      private void createWordDoc_Closing(object sender, System.ComponentModel.CancelEventArgs e)
333
      private void createWordDoc_Closing(object sender, System.ComponentModel.CancelEventArgs e)
331
      {
334
      {
-
 
335
         if (creationThread != null && creationThread.IsAlive && !mustClose && Main.threadCreateDocProcessRunning)
-
 
336
         {
-
 
337
            e.Cancel = true;
-
 
338
 
-
 
339
            DialogResult dlgRes = MessageBox.Show("Cancel Document Generation?", "Cancel", MessageBoxButtons.YesNo);
-
 
340
            if (dlgRes == DialogResult.Yes)
-
 
341
            {
-
 
342
               abortCreationThread = true;
-
 
343
               mustClose = true;
-
 
344
               Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Document Generation Aborting...Please Wait", -1);
-
 
345
            }
-
 
346
         }
332
         if (WordApp != null)
347
         else if (WordApp != null)
333
         {
348
         {
334
            // try-catch just in case user closed the application themselves whilst viewing the
349
            // try-catch just in case user closed the application themselves whilst viewing the
335
            // generated output document
350
            // generated output document
336
            try 
351
            try 
337
            {
352
            {
Line 346... Line 361...
346
               String s = createWordDoc_Closing_exception.Message;
361
               String s = createWordDoc_Closing_exception.Message;
347
            }
362
            }
348
         }
363
         }
349
      }
364
      }
350
 
365
 
-
 
366
 
351
      #endregion
367
      #endregion
352
 
368
 
353
 
369
 
354
      #region word document generation code
370
      #region word document generation code
355
 
371
 
Line 361... Line 377...
361
      /// </summary>
377
      /// </summary>
362
      /// <param name="prefix"></param>
378
      /// <param name="prefix"></param>
363
      /// <param name="EA_string"></param>
379
      /// <param name="EA_string"></param>
364
      private void displayProgress(string prefix, string EA_string)
380
      private void displayProgress(string prefix, string EA_string)
365
      {
381
      {
366
         textBox_progress.AppendText( prefix + EA_string + "\r\n" );
382
         //textBox_progress.AppendText( prefix + EA_string + "\r\n" );
367
 
383
 
368
         // Display to the output tab as well - as a longer term record of what happened
384
         // Display to the output tab as well - as a longer term record of what happened
369
         StringBuilder sb = new StringBuilder("");
385
         StringBuilder sb = new StringBuilder("");
370
 
386
 
371
         DocSectionTracker.appendHeadingNumber(ref sb);
387
         DocSectionTracking.appendHeadingNumber(ref sb);
372
 
388
 
373
         while (sb.Length < 30)
389
         while (sb.Length < 30)
374
            sb.Append(" ");
390
            sb.Append(" ");
375
 
391
 
376
         sb.Append(prefix);
392
         sb.Append(prefix);
377
         sb.Append(EA_string);
393
         sb.Append(EA_string);
378
 
394
 
379
         EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, sb.ToString(), 0);
395
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, sb.ToString(), 0);
380
      }
396
      }
381
 
397
 
382
 
398
 
383
      /// <summary>
399
      /// <summary>
384
      /// This method takes the specified EA diagram element and puts the diagram image
400
      /// This method takes the specified EA diagram element and puts the diagram image
Line 387... Line 403...
387
      /// </summary>
403
      /// </summary>
388
      /// <param name="theDiagram"></param>
404
      /// <param name="theDiagram"></param>
389
      private void appendAndSelectDiagramViaClipboard(EA.Diagram theDiagram)
405
      private void appendAndSelectDiagramViaClipboard(EA.Diagram theDiagram)
390
      {
406
      {
391
         // NOTE: diagrams only use one stereotype, not a list of them, so dont use StereotypeEx field
407
         // NOTE: diagrams only use one stereotype, not a list of them, so dont use StereotypeEx field
392
         if (  EA_Utils.options.opt_ConsiderAPIDiagramsOnly 
408
         if (  EA_DocGenOptions.opt_ConsiderAPIDiagramsOnly 
393
            && !theDiagram.Stereotype.Equals("API") )
409
            && !theDiagram.Stereotype.Equals("API") )
394
         {
410
         {
395
            displayProgress( "SKIPPED DIAGRAM: ", theDiagram.Name.ToString() );
411
            displayProgress( "SKIPPED DIAGRAM: ", theDiagram.Name.ToString() );
396
         }
412
         }
397
         // open the diagram in EA and copy it's image to the clipboard
413
         // open the diagram in EA and copy it's image to the clipboard
398
         else if (EA_Project.PutDiagramImageOnClipboard(theDiagram.DiagramGUID,0))
414
         else if (EA_Project.PutDiagramImageOnClipboard(theDiagram.DiagramGUID,0))
399
         {
415
         {
400
            object startLocation;
416
            object startLocation;
401
            object endLocation;
417
            object endLocation;
402
 
418
 
403
            TextUtils.appendDescription( theDiagram.Notes, EA_Utils );
419
            TextualContent.appendDescription( TextualContent.trimTrailingReturns(theDiagram.Notes) );
404
 
420
 
405
            // create a range at the end of the document
421
            // create a range at the end of the document
406
            startLocation = WordDocument.Content.End;
422
            startLocation = WordDocument.Content.End;
407
            WordDocument.Content.InsertParagraphAfter();
423
            WordDocument.Content.InsertParagraphAfter();
408
            endLocation = WordDocument.Content.End;
424
            endLocation = WordDocument.Content.End;
Line 410... Line 426...
410
            object direction = Word.WdCollapseDirection.wdCollapseEnd;
426
            object direction = Word.WdCollapseDirection.wdCollapseEnd;
411
            WordRange.Collapse(ref direction);  // collapse prevents existing content being replaced
427
            WordRange.Collapse(ref direction);  // collapse prevents existing content being replaced
412
 
428
 
413
            // Get ready for the diagram paste and the formatting we want to do on it with the
429
            // Get ready for the diagram paste and the formatting we want to do on it with the
414
            // selection object.
430
            // selection object.
415
            TextUtils.SelectInsertionPointAtEndOfDocument();
431
            TextualContent.SelectInsertionPointAtEndOfDocument();
416
 
432
 
417
            // Paste the diagram into the document
433
            // Paste the diagram into the document
418
            WordRange.Paste();           
434
            WordRange.Paste();           
419
 
435
 
420
            // Set style of the diagram to "Normal" so that it can occupy space all the way to the left margin
436
            // Set style of the diagram to "Normal" so that it can occupy space all the way to the left margin
Line 430... Line 446...
430
            WordApp.Selection.MoveDown( ref unit, ref count, ref missing);
446
            WordApp.Selection.MoveDown( ref unit, ref count, ref missing);
431
            WordApp.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
447
            WordApp.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
432
 
448
 
433
            // Add a caption
449
            // Add a caption
434
            WordDocument.Content.InsertParagraphAfter();
450
            WordDocument.Content.InsertParagraphAfter();
435
            TextUtils.SelectInsertionPointAtEndOfDocument();         
451
            TextualContent.SelectInsertionPointAtEndOfDocument();         
436
            object Label = "Figure";
452
            object Label = "Figure";
437
            object Title = Type.Missing;
453
            object Title = Type.Missing;
438
            object TitleAutoText = Type.Missing;
454
            object TitleAutoText = Type.Missing;
439
            object Position = Word.WdCaptionPosition.wdCaptionPositionAbove;
455
            object Position = Word.WdCaptionPosition.wdCaptionPositionAbove;
440
            object ExcludeLabel = 0;
456
            object ExcludeLabel = 0;
Line 448... Line 464...
448
            //string bookmarkName = theDiagram.Name;
464
            //string bookmarkName = theDiagram.Name;
449
            //bookmarkName = bookmarkName.Replace(' ', '_');
465
            //bookmarkName = bookmarkName.Replace(' ', '_');
450
            //WordDocument.Bookmarks.Add( bookmarkName, ref lastParaRange );
466
            //WordDocument.Bookmarks.Add( bookmarkName, ref lastParaRange );
451
 
467
 
452
            // Close the diagram in EA
468
            // Close the diagram in EA
453
            EA_Repository.CloseDiagram(theDiagram.DiagramID);
469
            Main.EA_Repository.CloseDiagram(theDiagram.DiagramID);
454
 
470
 
455
            displayProgress( "DIAGRAM: ", theDiagram.Name.ToString() );
471
            displayProgress( "DIAGRAM: ", theDiagram.Name.ToString() );
456
         }
472
         }
457
      }
473
      }
458
 
474
 
Line 489... Line 505...
489
               {
505
               {
490
                  oneShot_skipRootPackage = true;
506
                  oneShot_skipRootPackage = true;
491
               }
507
               }
492
               else if (s[0] == '{')
508
               else if (s[0] == '{')
493
               {
509
               {
494
                  EA.Package theFoundPackage = EA_Utils.EA_Finder.findPackageInRepositoryByGUID(s);
510
                  EA.Package theFoundPackage = Main.EA_Repository.GetPackageByGuid(s);
495
                  if (theFoundPackage != null)
511
                  if (theFoundPackage != null)
496
                  {
512
                  {
497
                     parse_package(theFoundPackage, recurse_level);
513
                     parse_package(theFoundPackage, recurse_level);
498
                  }
514
                  }
499
                  else
515
                  else
Line 527... Line 543...
527
         {
543
         {
528
            if (s.Length > 0 && s != "\n" && s != "\r" )
544
            if (s.Length > 0 && s != "\n" && s != "\r" )
529
            {
545
            {
530
               if (s[0] == '{')
546
               if (s[0] == '{')
531
               {
547
               {
532
                  EA.Diagram theFoundDiagram = EA_Utils.EA_Finder.findDiagramInRepositoryByGUID(s);
548
                  EA.Diagram theFoundDiagram = (EA.Diagram)Main.EA_Repository.GetDiagramByGuid(s);
533
                  if (theFoundDiagram != null)
549
                  if (theFoundDiagram != null)
534
                  {
550
                  {
535
                     appendAndSelectDiagramViaClipboard( theFoundDiagram );
551
                     appendAndSelectDiagramViaClipboard( theFoundDiagram );
536
                  }
552
                  }
537
                  else 
553
                  else 
Line 570... Line 586...
570
               {
586
               {
571
                  oneShot_skipRootElementHeading = true;
587
                  oneShot_skipRootElementHeading = true;
572
               }
588
               }
573
               else if ( s[0] == '{')
589
               else if ( s[0] == '{')
574
               {
590
               {
575
                  EA.Element theFoundElement = EA_Utils.EA_Finder.findElementInRepositoryByGUID(s);
591
                  EA.Element theFoundElement = Main.EA_Repository.GetElementByGuid(s);
576
                  if (theFoundElement != null)
592
                  if (theFoundElement != null)
577
                  {
593
                  {
578
                     parse_element( theFoundElement, recurse_level );
594
                     parse_element( theFoundElement, recurse_level );
579
                  }
595
                  }
580
                  else 
596
                  else 
Line 688... Line 704...
688
                  skipRoots = true;
704
                  skipRoots = true;
689
               }
705
               }
690
               else if (s[0] == '{')  // is it a GUID?
706
               else if (s[0] == '{')  // is it a GUID?
691
               {
707
               {
692
                  // find the package by its GUID
708
                  // find the package by its GUID
693
                  theFoundPackage = EA_Utils.EA_Finder.findPackageInRepositoryByGUID(s);
709
                  theFoundPackage = Main.EA_Repository.GetPackageByGuid(s);
694
               }
710
               }
695
               else if (s.StartsWith("package="))
711
               else if (s.StartsWith("package="))
696
               {
712
               {
697
                  // add the users named package to our list of names
713
                  // add the users named package to our list of names
698
                  names.Add( s.Substring(8, s.Length - 8) );
714
                  names.Add( s.Substring(8, s.Length - 8) );
Line 757... Line 773...
757
               if ( s[0] == '{')
773
               if ( s[0] == '{')
758
               {
774
               {
759
                  try
775
                  try
760
                  {
776
                  {
761
                     // try to find the GUID as a package
777
                     // try to find the GUID as a package
762
                     EA.Package theFoundPackage = EA_Utils.EA_Finder.findPackageInRepositoryByGUID(s);
778
                     EA.Package theFoundPackage = Main.EA_Repository.GetPackageByGuid(s);
763
                     if (theFoundPackage != null)
779
                     if (theFoundPackage != null)
764
                        TextUtils.appendUnitTestSuite(theFoundPackage, recurse_level, ref classesWithUnitTests, ref EA_Utils);
780
                        TextualContent.appendUnitTestSuite(theFoundPackage, recurse_level, ref classesWithUnitTests);
765
                     else 
781
                     else 
766
                     {
782
                     {
767
                        // try to find the GUID as an element
783
                        // try to find the GUID as an element
768
                        EA.Element theFoundElement = EA_Utils.EA_Finder.findElementInRepositoryByGUID(s);
784
                        EA.Element theFoundElement = Main.EA_Repository.GetElementByGuid(s);
769
                        if (theFoundElement != null)
785
                        if (theFoundElement != null)
770
                           TextUtils.appendUnitTestSuite(theFoundElement, recurse_level, ref classesWithUnitTests, ref EA_Utils);
786
                           TextualContent.appendUnitTestSuite(theFoundElement, recurse_level, ref classesWithUnitTests);
771
                        else 
787
                        else 
772
                           MessageBox.Show("WARNING - Could not find linked element : " + linkedName );
788
                           MessageBox.Show("WARNING - Could not find linked element : " + linkedName );
773
                     }
789
                     }
774
                  }
790
                  }
775
                  catch 
791
                  catch 
776
                  {
792
                  {
777
                     // try to find the GUID as an element
793
                     // try to find the GUID as an element
778
                     EA.Element theFoundElement = EA_Utils.EA_Finder.findElementInRepositoryByGUID(s);
794
                     EA.Element theFoundElement = Main.EA_Repository.GetElementByGuid(s);
779
                     if (theFoundElement != null)
795
                     if (theFoundElement != null)
780
                        TextUtils.appendUnitTestSuite(theFoundElement, recurse_level, ref classesWithUnitTests, ref EA_Utils);
796
                        TextualContent.appendUnitTestSuite(theFoundElement, recurse_level, ref classesWithUnitTests);
781
                     else 
797
                     else 
782
                        MessageBox.Show("WARNING - Could not find linked element : " + linkedName );
798
                        MessageBox.Show("WARNING - Could not find linked element : " + linkedName );
783
                  }
799
                  }
784
               }
800
               }
785
               else
801
               else
Line 795... Line 811...
795
      {
811
      {
796
         if (classesNeedingUnitTests.Count > 0)
812
         if (classesNeedingUnitTests.Count > 0)
797
         {
813
         {
798
            if (theElement.Notes.Length > 0)
814
            if (theElement.Notes.Length > 0)
799
            {
815
            {
800
               TextUtils.appendAndSelectText( theElement.Notes, EA_Constants.styleName_Body1);
816
               TextualContent.appendAndSelectText( theElement.Notes, EA_Constants.styleName_Body1);
801
            }
817
            }
802
            int tableNum = TableUtils.Table_Create("Design Element to Unit Test Suite Traceability", 2, 2);
818
            int tableNum = TabularContent.Table_Create("Design Element to Unit Test Suite Traceability", true, 2, 2);
803
            utTraceabilityTable = WordDocument.Tables[tableNum];
819
            utTraceabilityTable = WordDocument.Tables[tableNum];
804
 
820
 
805
            TableUtils.Table_SetTableColumnTitle(utTraceabilityTable, "Design Element (class)", 1);
821
            TabularContent.Table_SetTableColumnTitle(utTraceabilityTable, "Design Element (class)", 1);
806
            TableUtils.Table_SetTableColumnTitle(utTraceabilityTable, "Test Suite", 2);
822
            TabularContent.Table_SetTableColumnTitle(utTraceabilityTable, "Test Suite", 2);
807
         }
823
         }
808
      }
824
      }
809
 
825
 
810
 
826
 
811
      private void completeTestTraceability()
827
      private void completeTestTraceability()
Line 814... Line 830...
814
         {
830
         {
815
            int numClassesRemaining = classesNeedingUnitTests.Count;
831
            int numClassesRemaining = classesNeedingUnitTests.Count;
816
            int row = 2;
832
            int row = 2;
817
            foreach(int elementId in classesNeedingUnitTests)
833
            foreach(int elementId in classesNeedingUnitTests)
818
            {
834
            {
819
               EA.Element theElement = EA_Repository.GetElementByID( elementId );
835
               EA.Element theElement = Main.EA_Repository.GetElementByID( elementId );
820
               if (theElement != null)
836
               if (theElement != null)
821
               {
837
               {
822
                  utTraceabilityTable.Cell(row,1).Range.Text = theElement.Name;
838
                  utTraceabilityTable.Cell(row,1).Range.Text = theElement.Name;
823
 
839
 
824
                  if (classesWithUnitTests.Contains( elementId ))
840
                  if (classesWithUnitTests.Contains( elementId ))
825
                  {
841
                  {
826
                     utTraceabilityTable.Cell(row,2).Range.Text = TextUtils.testSuiteName(theElement);
842
                     utTraceabilityTable.Cell(row,2).Range.Text = TextualContent.testSuiteName(theElement);
827
                  }
843
                  }
828
                  else
844
                  else
829
                  {
845
                  {
830
                     utTraceabilityTable.Cell(row,2).Range.Text = "Missing tests!";
846
                     utTraceabilityTable.Cell(row,2).Range.Text = "Missing tests!";
831
                     utTraceabilityTable.Cell(row,2).Range.Font.Color = Word.WdColor.wdColorRed;
847
                     utTraceabilityTable.Cell(row,2).Range.Font.Color = Word.WdColor.wdColorRed;
Line 833... Line 849...
833
               }
849
               }
834
 
850
 
835
               numClassesRemaining--;
851
               numClassesRemaining--;
836
               if (numClassesRemaining > 0)
852
               if (numClassesRemaining > 0)
837
               {
853
               {
838
                  TableUtils.Table_InsertNewRowAfterThisRow(utTraceabilityTable, row);
854
                  TabularContent.Table_InsertNewRowAfterThisRow(utTraceabilityTable, row);
839
                  row++;
855
                  row++;
840
               }
856
               }
-
 
857
 
-
 
858
               if (abortCreationThread)
-
 
859
                  break;
841
            }
860
            }
842
         }
861
         }
843
      }
862
      }
844
 
863
 
845
      #endregion
864
      #endregion
Line 852... Line 871...
852
      /// <param name="thePackage"></param>
871
      /// <param name="thePackage"></param>
853
      private void createReferencesSection(EA.Package thePackage)
872
      private void createReferencesSection(EA.Package thePackage)
854
      {
873
      {
855
         foreach(EA.Element theElement in thePackage.Elements)
874
         foreach(EA.Element theElement in thePackage.Elements)
856
         {
875
         {
-
 
876
            if (abortCreationThread)
-
 
877
               return;
-
 
878
 
857
            // Here we want to apply the special ERG template styles for each reference
879
            // Here we want to apply the special ERG template styles for each reference
858
            // item.
880
            // item.
859
            TextUtils.appendAndSelectText( theElement.Name.ToString(), EA_Constants.styleName_RefListNum );
881
            TextualContent.appendAndSelectText( theElement.Name.ToString(), EA_Constants.styleName_RefListNum );
860
            TextUtils.appendAndSelectText( theElement.Notes.ToString(), EA_Constants.styleName_RefListText );
882
            TextualContent.appendAndSelectText( theElement.Notes.ToString(), EA_Constants.styleName_RefListText );
861
         }
883
         }
862
      }
884
      }
863
 
885
 
864
 
886
 
865
      private void createTerminologySection(EA.Package thePackage, int recurse_level)
887
      private void createTerminologySection(EA.Package thePackage, int recurse_level)
Line 867... Line 889...
867
         // Use local package elements as source of glossary, but if none are present, resort to using
889
         // Use local package elements as source of glossary, but if none are present, resort to using
868
         // the project glossary in the repository 
890
         // the project glossary in the repository 
869
         int numItems = thePackage.Elements.Count;
891
         int numItems = thePackage.Elements.Count;
870
         if (numItems == 0)
892
         if (numItems == 0)
871
         {
893
         {
872
            numItems = EA_Repository.Terms.Count;
894
            numItems = Main.EA_Repository.Terms.Count;
-
 
895
 
-
 
896
            // For some wierd reason, I have seen exceptions occur here when trying to get a sorted list of glossary
-
 
897
            // items, so I put a trap and retry loop in until such time as the exact cause can be determined.
-
 
898
            ArrayList glossary = null;
873
            // Create a table
899
            bool done = false;
874
            int tableNum = TableUtils.Table_Create("Terminology", numItems+1, 2);
900
            int retries = 3;
-
 
901
            do
-
 
902
            {
875
            Word.Table table = WordDocument.Tables[tableNum];
903
               if (abortCreationThread)
876
            object center = Word.WdParagraphAlignment.wdAlignParagraphCenter;
904
                  return;
877
 
905
 
-
 
906
               try
-
 
907
               {
878
            TableUtils.Table_SetTableColumnTitle(table, "Term", 1);
908
                  glossary = new ArrayList();
879
            TableUtils.Table_SetTableColumnTitle(table, "Definition", 2);
909
                  foreach(EA.Term theTerm in Main.EA_Repository.Terms)
-
 
910
                     glossary.Add(theTerm);
880
            table.Columns[1].SetWidth(100, Word.WdRulerStyle.wdAdjustSameWidth );
911
                  glossarySort sorter = new glossarySort();
-
 
912
                  glossary.Sort( sorter );
-
 
913
                  done = true;
-
 
914
               }
-
 
915
               catch (Exception e)
-
 
916
               {
-
 
917
                  Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Sorting Glossary, Exception" + e.Message, -1);
-
 
918
                  retries--;
881
            int row = 2;
919
               }
882
            // inject the glossary into the table
920
            } while (!done && retries > 0);
-
 
921
 
883
            foreach(EA.Term theTerm in EA_Repository.Terms)
922
            if (done && glossary.Count > 0)
884
            {
923
            {
-
 
924
               // Create a table
-
 
925
               int tableNum = TabularContent.Table_Create("Terminology", true, numItems+1, 2);
-
 
926
               Word.Table table = WordDocument.Tables[tableNum];
-
 
927
               object center = Word.WdParagraphAlignment.wdAlignParagraphCenter;
-
 
928
 
-
 
929
               TabularContent.Table_SetTableColumnTitle(table, "Term", 1);
-
 
930
               TabularContent.Table_SetTableColumnTitle(table, "Definition", 2);
-
 
931
               table.Columns[1].SetWidth(100, Word.WdRulerStyle.wdAdjustSameWidth );
-
 
932
               int row = 2;
-
 
933
               // inject the glossary into the table
-
 
934
               foreach(EA.Term theTerm in glossary)
-
 
935
               {
-
 
936
                  if (abortCreationThread)
-
 
937
                     return;
-
 
938
 
885
               table.Cell(row,1).Range.Text = theTerm.Term;
939
                  table.Cell(row,1).Range.Text = theTerm.Term;
886
               table.Cell(row,2).Range.Text = theTerm.Meaning;
940
                  table.Cell(row,2).Range.Text = theTerm.Meaning;
887
               row++;
941
                  row++;
-
 
942
               }
888
            }
943
            }
889
         }
944
         }
890
         else
945
         else
891
         {
946
         {
892
            // scan content of terminology package - allow user to specify tables, text, package links,
947
            // scan content of terminology package - allow user to specify tables, text, package links,
893
            // and diagram links.
948
            // and diagram links.
894
            ArrayList infoItems = new ArrayList();
949
            ArrayList infoItems = new ArrayList();
895
            foreach(EA.Element theElement in thePackage.Elements)
950
            foreach(EA.Element theElement in thePackage.Elements)
896
            {
951
            {
-
 
952
               if (abortCreationThread)
-
 
953
                  return;
-
 
954
 
897
               if (theElement.Name.StartsWith(EA_Constants.EA_DocGenTable))
955
               if (theElement.Name.StartsWith(EA_Constants.EA_DocGenTable))
898
               {
956
               {
899
                  TableUtils.processTableElement( theElement, recurse_level);
957
                  TabularContent.processTableElement( theElement, recurse_level);
900
               }
958
               }
901
               else if (theElement.Name.StartsWith(EA_Constants.EA_DocGenPackageLink))
959
               else if (theElement.Name.StartsWith(EA_Constants.EA_DocGenPackageLink))
902
               {
960
               {
903
                  processingLink++;
961
                  processingLink++;
904
                  processPackageLink( theElement, recurse_level );
962
                  processPackageLink( theElement, recurse_level );
905
                  processingLink--;
963
                  processingLink--;
906
               }
964
               }
907
               else if (theElement.Name.StartsWith(EA_Constants.EA_DocGenText))
965
               else if (theElement.Name.StartsWith(EA_Constants.EA_DocGenText))
908
               {
966
               {
909
                  TextUtils.appendAndSelectText( theElement.Notes.ToString(), EA_Constants.styleName_Body1 );
967
                  TextualContent.appendAndSelectText( TextualContent.trimTrailingReturns(theElement.Notes), EA_Constants.styleName_Body1 );
910
               }
968
               }
911
               else if (theElement.Name.StartsWith(EA_Constants.EA_DocGenDiagramLink))
969
               else if (theElement.Name.StartsWith(EA_Constants.EA_DocGenDiagramLink))
912
               {
970
               {
913
                  processingLink++;
971
                  processingLink++;
914
                  processDiagramLink( theElement );
972
                  processDiagramLink( theElement );
Line 928... Line 986...
928
            }
986
            }
929
 
987
 
930
            if (infoItems.Count > 0)
988
            if (infoItems.Count > 0)
931
            {
989
            {
932
               // Create a table
990
               // Create a table
933
               int tableNum = TableUtils.Table_Create("Terminology", infoItems.Count+1, 2);
991
               int tableNum = TabularContent.Table_Create("Terminology", true, infoItems.Count+1, 2);
934
               Word.Table table = WordDocument.Tables[tableNum];
992
               Word.Table table = WordDocument.Tables[tableNum];
935
               object center = Word.WdParagraphAlignment.wdAlignParagraphCenter;
993
               object center = Word.WdParagraphAlignment.wdAlignParagraphCenter;
936
 
994
 
937
               TableUtils.Table_SetTableColumnTitle(table, "Term", 1);
995
               TabularContent.Table_SetTableColumnTitle(table, "Term", 1);
938
               TableUtils.Table_SetTableColumnTitle(table, "Definition", 2);
996
               TabularContent.Table_SetTableColumnTitle(table, "Definition", 2);
939
               table.Columns[1].SetWidth(100, Word.WdRulerStyle.wdAdjustSameWidth );
997
               table.Columns[1].SetWidth(100, Word.WdRulerStyle.wdAdjustSameWidth );
940
               int row = 2;
998
               int row = 2;
941
 
999
 
-
 
1000
               elementSortByName sorter = new elementSortByName();
-
 
1001
               infoItems.Sort(sorter);
-
 
1002
 
942
               foreach(EA.Element theElement in infoItems)
1003
               foreach(EA.Element theElement in infoItems)
943
               {
1004
               {
-
 
1005
                  if (abortCreationThread)
-
 
1006
                     return;
-
 
1007
 
944
                  table.Cell(row,1).Range.Text = theElement.Name.ToString();
1008
                  table.Cell(row,1).Range.Text = theElement.Name.ToString();
945
                  table.Cell(row,2).Range.Text = theElement.Notes.ToString();
1009
                  table.Cell(row,2).Range.Text = theElement.Notes.ToString();
946
                  row++;
1010
                  row++;
947
               }
1011
               }
948
            }
1012
            }
Line 956... Line 1020...
956
         bool processLowerLevelContent = true;  // return value for this function
1020
         bool processLowerLevelContent = true;  // return value for this function
957
 
1021
 
958
         // The package name is a heading, and the package notes are paragraphs 
1022
         // The package name is a heading, and the package notes are paragraphs 
959
         // directly under that heading
1023
         // directly under that heading
960
 
1024
 
961
         TextUtils.appendAndSelectHeadingText( thePackage.Name.ToString(), recurse_level );
1025
         TextualContent.appendAndSelectHeadingText( thePackage.Name.ToString(), recurse_level );
962
         displayProgress( "PACKAGE: ", thePackage.Name.ToString() );
1026
         displayProgress( "PACKAGE: ", thePackage.Name.ToString() );
963
 
1027
 
964
         // Special handling for package called "Terminology" 
1028
         // Special handling for package called "Terminology" 
965
         if (thePackage.Name == "Terminology")
1029
         if (thePackage.Name == "Terminology")
966
         {
1030
         {
967
            TextUtils.appendAndSelectText( thePackage.Notes.ToString(), EA_Constants.styleName_Body1 );
1031
            TextualContent.appendAndSelectText( TextualContent.trimTrailingReturns(thePackage.Notes), EA_Constants.styleName_Body1 );
968
            createTerminologySection(thePackage, recurse_level);
1032
            createTerminologySection(thePackage, recurse_level);
969
            processLowerLevelContent = false;
1033
            processLowerLevelContent = false;
970
         }
1034
         }
971
 
1035
 
972
         else if (thePackage.Name == "References")
1036
         else if (thePackage.Name == "References")
973
         {
1037
         {
974
            TextUtils.appendAndSelectText( thePackage.Notes.ToString(), EA_Constants.styleName_Body1 );
1038
            TextualContent.appendAndSelectText( TextualContent.trimTrailingReturns(thePackage.Notes), EA_Constants.styleName_Body1 );
975
            createReferencesSection(thePackage);
1039
            createReferencesSection(thePackage);
976
            processLowerLevelContent = false;
1040
            processLowerLevelContent = false;
977
         }
1041
         }
978
         else
1042
         else
979
         {
1043
         {
980
            // use the package notes as body text and indicate to caller that package elements 
1044
            // use the package notes as body text and indicate to caller that package elements 
981
            // have not been consumed
1045
            // have not been consumed
982
            TextUtils.appendAndSelectText( thePackage.Notes.ToString(), EA_Constants.styleName_Body1 );      
1046
            TextualContent.appendAndSelectText( TextualContent.trimTrailingReturns(thePackage.Notes), EA_Constants.styleName_Body1 );      
983
         }
1047
         }
984
 
1048
 
985
         return processLowerLevelContent;
1049
         return processLowerLevelContent;
986
      }
1050
      }
987
 
1051
 
Line 989... Line 1053...
989
      private void generatePackageDiagrams( EA.Package thePackage )
1053
      private void generatePackageDiagrams( EA.Package thePackage )
990
      {
1054
      {
991
         // default handling of diagrams
1055
         // default handling of diagrams
992
         foreach(EA.Diagram theDiagram in thePackage.Diagrams)
1056
         foreach(EA.Diagram theDiagram in thePackage.Diagrams)
993
         {
1057
         {
-
 
1058
            if (abortCreationThread)
-
 
1059
               return;
-
 
1060
 
994
            if (theDiagram.ParentID == 0 || thePackage.PackageID == theDiagram.ParentID)
1061
            if (theDiagram.ParentID == 0 || thePackage.PackageID == theDiagram.ParentID)
995
            {
1062
            {
996
               appendAndSelectDiagramViaClipboard( theDiagram );
1063
               appendAndSelectDiagramViaClipboard( theDiagram );
997
            }
1064
            }
998
         }
1065
         }
Line 1002... Line 1069...
1002
      private void generateElementDiagrams( EA.Element theElement )
1069
      private void generateElementDiagrams( EA.Element theElement )
1003
      {
1070
      {
1004
         // default handling of diagrams
1071
         // default handling of diagrams
1005
         foreach(EA.Diagram theDiagram in theElement.Diagrams)
1072
         foreach(EA.Diagram theDiagram in theElement.Diagrams)
1006
         {
1073
         {
-
 
1074
            if (abortCreationThread)
-
 
1075
               return;
-
 
1076
 
1007
            if (theDiagram.ParentID == 0 || theElement.ElementID == theDiagram.ParentID)
1077
            if (theDiagram.ParentID == 0 || theElement.ElementID == theDiagram.ParentID)
1008
            {
1078
            {
1009
               appendAndSelectDiagramViaClipboard( theDiagram );
1079
               appendAndSelectDiagramViaClipboard( theDiagram );
1010
            }
1080
            }
1011
         }
1081
         }
Line 1027... Line 1097...
1027
         // filter out methods with certain characteristics?
1097
         // filter out methods with certain characteristics?
1028
         // eg. Users may only want to document public and protected methods.
1098
         // eg. Users may only want to document public and protected methods.
1029
         int numMethodsRemaining = 0;
1099
         int numMethodsRemaining = 0;
1030
         foreach(EA.Method theMethod in theMethods)
1100
         foreach(EA.Method theMethod in theMethods)
1031
         {
1101
         {
-
 
1102
            if (abortCreationThread)
-
 
1103
               return;
-
 
1104
 
1032
            if (EA_Utils.options.opt_SuppressPrivateMethods == false
1105
            if (EA_DocGenOptions.opt_SuppressPrivateMethods == false
1033
               || !theMethod.Visibility.StartsWith("Private"))
1106
               || !theMethod.Visibility.StartsWith("Private"))
1034
               numMethodsRemaining++;
1107
               numMethodsRemaining++;
1035
         }
1108
         }
1036
 
1109
 
1037
         Word.Range wr;
1110
         Word.Range wr;
Line 1041... Line 1114...
1041
         {
1114
         {
1042
            // Print the "<Class Name> Operations" headings
1115
            // Print the "<Class Name> Operations" headings
1043
            sb = new StringBuilder();
1116
            sb = new StringBuilder();
1044
            sb.Append( theElement.Name );
1117
            sb.Append( theElement.Name );
1045
            sb.Append( " Operations" );
1118
            sb.Append( " Operations" );
1046
            TextUtils.appendAndSelectHeadingText(sb.ToString(), recurse_level);
1119
            TextualContent.appendAndSelectHeadingText(sb.ToString(), recurse_level);
1047
 
1120
 
1048
            // Iterate through the class's methods
1121
            // Iterate through the class's methods
1049
            foreach(EA.Method theMethod in theMethods)
1122
            foreach(EA.Method theMethod in theMethods)
1050
            {
1123
            {
-
 
1124
               if (abortCreationThread)
-
 
1125
                  return;
-
 
1126
 
1051
               sb = new StringBuilder();
1127
               sb = new StringBuilder();
1052
 
1128
 
1053
               if (EA_Utils.options.opt_SuppressPrivateMethods == false
1129
               if (EA_DocGenOptions.opt_SuppressPrivateMethods == false
1054
                  || !theMethod.Visibility.StartsWith("Private"))
1130
                  || !theMethod.Visibility.StartsWith("Private"))
1055
               {
1131
               {
1056
                  // Print the Method name as a sub heading, and its description
1132
                  // Print the Method name as a sub heading, and its description
1057
                  TextUtils.appendAndSelectHeadingText(theMethod.Name , recurse_level + 1);
1133
                  TextualContent.appendAndSelectHeadingText(theMethod.Name , recurse_level + 1);
1058
                  TextUtils.appendDescription(theMethod.Notes, EA_Utils);
1134
                  TextualContent.appendDescription(TextualContent.trimTrailingReturns(theMethod.Notes));
1059
 
1135
 
1060
                  // Get a list of the method's parameters and sort them by the position field setup 
1136
                  // Get a list of the method's parameters and sort them by the position field setup 
1061
                  // in EA by the designer
1137
                  // in EA by the designer
1062
                  ArrayList theParams = new ArrayList();
1138
                  ArrayList theParams = new ArrayList();
1063
                  foreach(EA.Parameter theParam in theMethod.Parameters)
1139
                  foreach(EA.Parameter theParam in theMethod.Parameters)
1064
                     theParams.Add( theParam );
1140
                     theParams.Add( theParam );
1065
                  parameterSortByPos paramSorter = new parameterSortByPos();
1141
                  parameterSortByPos paramSorter = new parameterSortByPos();
1066
                  theParams.Sort( paramSorter );
1142
                  theParams.Sort( paramSorter );
1067
 
1143
 
1068
                  // Print the prototype heading
1144
                  // Print the prototype heading
1069
                  wr = TextUtils.appendAndSelectText("\nPrototype:", EA_Constants.styleName_Body1_Left_2_5cm_Italic);
1145
                  wr = TextualContent.appendAndSelectText("\nPrototype:", EA_Constants.styleName_Body1_Left_2_5cm_Italic);
1070
 
1146
 
1071
                  // begin to build the prototype string
1147
                  // begin to build the prototype string
1072
                  sb = new StringBuilder();
1148
                  sb = new StringBuilder();
1073
                  sb.Append( theMethod.ReturnType );
1149
                  sb.Append( theMethod.ReturnType );
1074
                  sb.Append( " " );
1150
                  sb.Append( " " );
Line 1078... Line 1154...
1078
                  if (theParams.Count > 0)
1154
                  if (theParams.Count > 0)
1079
                  {
1155
                  {
1080
                     int numParamsRemaining = theParams.Count;
1156
                     int numParamsRemaining = theParams.Count;
1081
 
1157
 
1082
                     // print what we have so far constructed for the prototype
1158
                     // print what we have so far constructed for the prototype
1083
                     wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_3_5cm);
1159
                     wr = TextualContent.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_3_5cm);
1084
 
1160
 
1085
                     // Now form a new string for the params
1161
                     // Now form a new string for the params
1086
                     sb = new StringBuilder();
1162
                     sb = new StringBuilder();
1087
                     foreach(EA.Parameter theParam in theParams)
1163
                     foreach(EA.Parameter theParam in theParams)
1088
                     {
1164
                     {
-
 
1165
                        if (abortCreationThread)
-
 
1166
                           return;
-
 
1167
 
1089
                        // each parameter is   "[in|out|inout] type name [= default-value]"
1168
                        // each parameter is   "[in|out|inout] type name [= default-value]"
1090
                        // where the default value is optional
1169
                        // where the default value is optional
1091
                        sb.Append( "[" );
1170
                        sb.Append( "[" );
1092
                        sb.Append( theParam.Kind );
1171
                        sb.Append( theParam.Kind );
1093
                        sb.Append( "] " );
1172
                        sb.Append( "] " );
Line 1107... Line 1186...
1107
                        numParamsRemaining--;
1186
                        numParamsRemaining--;
1108
                     }
1187
                     }
1109
 
1188
 
1110
                     // complete the prototype and print it.
1189
                     // complete the prototype and print it.
1111
                     sb.Append( ")" );
1190
                     sb.Append( ")" );
1112
                     wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_4_5cm);
1191
                     wr = TextualContent.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_4_5cm);
1113
                  }
1192
                  }
1114
                  else
1193
                  else
1115
                  {
1194
                  {
1116
                     // complete the prototype and print it.
1195
                     // complete the prototype and print it.
1117
                     sb.Append( ")" );
1196
                     sb.Append( ")" );
1118
                     wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_3_5cm);
1197
                     wr = TextualContent.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_3_5cm);
1119
                  }
1198
                  }
1120
 
1199
 
1121
 
1200
 
1122
                  // Prototype Attributes/Characteristics
1201
                  // Prototype Attributes/Characteristics
1123
                  sb = new StringBuilder();
1202
                  sb = new StringBuilder();
Line 1159... Line 1238...
1159
                     sb.Append( theMethod.Throws );
1238
                     sb.Append( theMethod.Throws );
1160
                  }
1239
                  }
1161
 
1240
 
1162
                  if (sb.Length > 0)
1241
                  if (sb.Length > 0)
1163
                  {
1242
                  {
1164
                     wr = TextUtils.appendAndSelectText("Characteristics:", EA_Constants.styleName_Body1_Left_2_5cm_Italic);
1243
                     wr = TextualContent.appendAndSelectText("Characteristics:", EA_Constants.styleName_Body1_Left_2_5cm_Italic);
1165
 
1244
 
1166
                     wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_3_5cm);
1245
                     wr = TextualContent.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_3_5cm);
1167
                  }
1246
                  }
1168
 
1247
 
1169
                  // Parameter Descriptions
1248
                  // Parameter Descriptions
1170
                  if (theParams.Count > 0)
1249
                  if (theParams.Count > 0)
1171
                  {
1250
                  {
1172
                     wr = TextUtils.appendAndSelectText("Parameters:", EA_Constants.styleName_Body1_Left_2_5cm_Italic);
1251
                     wr = TextualContent.appendAndSelectText("Parameters:", EA_Constants.styleName_Body1_Left_2_5cm_Italic);
1173
 
1252
 
1174
                     foreach(EA.Parameter theParam in theParams)
1253
                     foreach(EA.Parameter theParam in theParams)
1175
                     {
1254
                     {
1176
                        wr = TextUtils.appendAndSelectText( theParam.Name + "\t", EA_Constants.stylename_Parameter_Description);
1255
                        wr = TextualContent.appendAndSelectText( theParam.Name + "\t", EA_Constants.stylename_Parameter_Description);
1177
                        // do notes in seperate step since we want to call the appendDescription() method which 
1256
                        // do notes in seperate step since we want to call the appendDescription() method which 
1178
                        // automatically alerts us to missing descriptions in the generated document.
1257
                        // automatically alerts us to missing descriptions in the generated document.
1179
                        wr = TextUtils.appendDescription( theParam.Notes, EA_Constants.stylename_Parameter_Description, EA_Utils, true);
1258
                        wr = TextualContent.appendDescription( TextualContent.trimTrailingReturns(theParam.Notes), EA_Constants.stylename_Parameter_Description, true);
-
 
1259
 
-
 
1260
                        if (abortCreationThread)
-
 
1261
                           return;
1180
                     }
1262
                     }
1181
                  }
1263
                  }
1182
               }
1264
               }
1183
            }
1265
            }
1184
         }
1266
         }
Line 1207... Line 1289...
1207
         // eg. Users may only want to document public and protected attributes.
1289
         // eg. Users may only want to document public and protected attributes.
1208
 
1290
 
1209
         int numAttrsRemaining = 0;
1291
         int numAttrsRemaining = 0;
1210
         foreach(EA.Attribute theAttr in theAttrs)
1292
         foreach(EA.Attribute theAttr in theAttrs)
1211
         {
1293
         {
-
 
1294
            if (abortCreationThread)
-
 
1295
               return;
-
 
1296
 
1212
            if (EA_Utils.options.opt_SuppressPrivateAttributes == false
1297
            if (EA_DocGenOptions.opt_SuppressPrivateAttributes == false
1213
               || !theAttr.Visibility.StartsWith("Private"))
1298
               || !theAttr.Visibility.StartsWith("Private"))
1214
               numAttrsRemaining++;
1299
               numAttrsRemaining++;
1215
         }
1300
         }
1216
 
1301
 
1217
         if (numAttrsRemaining > 0)
1302
         if (numAttrsRemaining > 0)
1218
         {
1303
         {
1219
            StringBuilder sb = new StringBuilder();
1304
            StringBuilder sb = new StringBuilder();
1220
 
1305
 
1221
            sb.Append( theElement.Name );
1306
            sb.Append( theElement.Name );
1222
            sb.Append( " Attributes" );
1307
            sb.Append( " Attributes" );
1223
            TextUtils.appendAndSelectHeadingText(sb.ToString(), recurse_level);
1308
            TextualContent.appendAndSelectHeadingText(sb.ToString(), recurse_level);
1224
 
1309
 
1225
            // serialise the attributes to the document.
1310
            // serialise the attributes to the document.
1226
            foreach(EA.Attribute theAttr in theAttrs)
1311
            foreach(EA.Attribute theAttr in theAttrs)
1227
            {
1312
            {
-
 
1313
               if (abortCreationThread)
-
 
1314
                  return;
-
 
1315
 
1228
               if (EA_Utils.options.opt_SuppressPrivateAttributes == false
1316
               if (EA_DocGenOptions.opt_SuppressPrivateAttributes == false
1229
                  || !theAttr.Visibility.StartsWith("Private"))
1317
                  || !theAttr.Visibility.StartsWith("Private"))
1230
               {
1318
               {
1231
                  // Begin to build content string for the "Attribute" table column 
1319
                  // Begin to build content string for the "Attribute" table column 
1232
                  sb = new StringBuilder();
1320
                  sb = new StringBuilder();
1233
 
1321
 
1234
                  // <type> <name>
1322
                  // <type> <name>
1235
                  sb.Append("\n");
1323
                  sb.Append("\n");
1236
                  sb.Append(theAttr.Type);
1324
                  sb.Append(theAttr.Type);
1237
                  sb.Append(" ");
1325
                  sb.Append(" ");
1238
                  sb.Append(theAttr.Name);
1326
                  sb.Append(theAttr.Name);
1239
                  Word.Range wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1);
1327
                  Word.Range wr = TextualContent.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1);
1240
                  wr.Font.Bold = 1;
1328
                  wr.Font.Bold = 1;
1241
                  
1329
                  
1242
                  wr = TextUtils.appendDescription(theAttr.Notes, EA_Utils);
1330
                  wr = TextualContent.appendDescription(TextualContent.trimTrailingReturns(theAttr.Notes));
1243
                  wr.ParagraphFormat.LeftIndent = WordApp.CentimetersToPoints((float)3.5);
1331
                  wr.ParagraphFormat.LeftIndent = WordApp.CentimetersToPoints((float)3.5);
1244
 
1332
 
1245
                  // The approach here is to display as much of the attribute as we can but try to keep the output
1333
                  // The approach here is to display as much of the attribute as we can but try to keep the output
1246
                  // uncluttered by omitting items the user has not set via the EA GUI.
1334
                  // uncluttered by omitting items the user has not set via the EA GUI.
1247
 
1335
 
Line 1331... Line 1419...
1331
                  // Now look at the constraint and tagged value collections and add any found info to the
1419
                  // Now look at the constraint and tagged value collections and add any found info to the
1332
                  // right hand column
1420
                  // right hand column
1333
                  short i;
1421
                  short i;
1334
                  for(i=0; i<theAttr.Constraints.Count; i++)
1422
                  for(i=0; i<theAttr.Constraints.Count; i++)
1335
                  {
1423
                  {
-
 
1424
                     if (abortCreationThread)
-
 
1425
                        return;
-
 
1426
 
1336
                     EA.AttributeConstraint theCons = (EA.AttributeConstraint)theAttr.Constraints.GetAt(i);
1427
                     EA.AttributeConstraint theCons = (EA.AttributeConstraint)theAttr.Constraints.GetAt(i);
1337
                     sb.Append( theCons.Type );
1428
                     sb.Append( theCons.Type );
1338
                     sb.Append( ": {" );
1429
                     sb.Append( ": {" );
1339
                     sb.Append( theCons.Name );
1430
                     sb.Append( theCons.Name );
1340
                     sb.Append( "}\n" );
1431
                     sb.Append( "}\n" );
Line 1342... Line 1433...
1342
                     //sb.Append( "\n" );
1433
                     //sb.Append( "\n" );
1343
                  }
1434
                  }
1344
 
1435
 
1345
                  for(i=0; i<theAttr.TaggedValues.Count; i++)
1436
                  for(i=0; i<theAttr.TaggedValues.Count; i++)
1346
                  {
1437
                  {
-
 
1438
                     if (abortCreationThread)
-
 
1439
                        return;
-
 
1440
 
1347
                     EA.AttributeTag theTag = (EA.AttributeTag)theAttr.TaggedValues.GetAt(i);
1441
                     EA.AttributeTag theTag = (EA.AttributeTag)theAttr.TaggedValues.GetAt(i);
1348
                     sb.Append( "[" );
1442
                     sb.Append( "[" );
1349
                     sb.Append( theTag.Name );
1443
                     sb.Append( theTag.Name );
1350
                     sb.Append( "="  );
1444
                     sb.Append( "="  );
1351
                     sb.Append( theTag.Value );
1445
                     sb.Append( theTag.Value );
Line 1357... Line 1451...
1357
                  if (sb.Length > 0)
1451
                  if (sb.Length > 0)
1358
                  {
1452
                  {
1359
                     // remove the trailing "\n"
1453
                     // remove the trailing "\n"
1360
                     sb.Remove( sb.ToString().Length - 1, 1);
1454
                     sb.Remove( sb.ToString().Length - 1, 1);
1361
 
1455
 
1362
                     wr = TextUtils.appendAndSelectText("Characteristics:", EA_Constants.styleName_Body1_Left_3_5cm_Italic);
1456
                     wr = TextualContent.appendAndSelectText("Characteristics:", EA_Constants.styleName_Body1_Left_3_5cm_Italic);
1363
 
1457
 
1364
                     wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_4_5cm);
1458
                     wr = TextualContent.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_4_5cm);
1365
                  }
1459
                  }
1366
 
1460
 
1367
                  numAttrsRemaining--;
1461
                  numAttrsRemaining--;
1368
               }
1462
               }
1369
            }
1463
            }
Line 1375... Line 1469...
1375
      {
1469
      {
1376
         StringBuilder sb = new StringBuilder();
1470
         StringBuilder sb = new StringBuilder();
1377
 
1471
 
1378
         ////////////////////////////////////////////////////////////////////////////////////////////////
1472
         ////////////////////////////////////////////////////////////////////////////////////////////////
1379
         sb.Append( "Characteristics:" );
1473
         sb.Append( "Characteristics:" );
1380
         Word.Range wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_2_5cm_Italic);
1474
         Word.Range wr = TextualContent.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_2_5cm_Italic);
1381
         
1475
         
1382
         sb = new StringBuilder();
1476
         sb = new StringBuilder();
1383
         // VISIBILITY
1477
         // VISIBILITY
1384
         sb.Append( theElement.Visibility );
1478
         sb.Append( theElement.Visibility );
1385
         // ABSTRACT
1479
         // ABSTRACT
Line 1402... Line 1496...
1402
            sb.Append("\nClass is active (has its own thread of control)\n");
1496
            sb.Append("\nClass is active (has its own thread of control)\n");
1403
         // IS SPEC
1497
         // IS SPEC
1404
         if (theElement.IsSpec)
1498
         if (theElement.IsSpec)
1405
            sb.Append("\nClass is a specification\n");
1499
            sb.Append("\nClass is a specification\n");
1406
 
1500
 
1407
         wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_3_5cm);
1501
         wr = TextualContent.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_3_5cm);
1408
 
1502
 
1409
         ////////////////////////////////////////////////////////////////////////////////////////////////
1503
         ////////////////////////////////////////////////////////////////////////////////////////////////
1410
         sb = new StringBuilder();
1504
         sb = new StringBuilder();
1411
         foreach(EA.Element baseClass in theElement.BaseClasses)
1505
         foreach(EA.Element baseClass in theElement.BaseClasses)
1412
         {
1506
         {
1413
            sb.Append( baseClass.Name);
1507
            sb.Append( baseClass.Name);
1414
         }
1508
         }
1415
         if (sb.Length > 0)
1509
         if (sb.Length > 0)
1416
         {
1510
         {
1417
            wr = TextUtils.appendAndSelectText("Base Class(es):", EA_Constants.styleName_Body1_Left_2_5cm_Italic);
1511
            wr = TextualContent.appendAndSelectText("Base Class(es):", EA_Constants.styleName_Body1_Left_2_5cm_Italic);
1418
 
1512
 
1419
            wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_3_5cm);
1513
            wr = TextualContent.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_3_5cm);
1420
         }
1514
         }
1421
 
1515
 
1422
         ////////////////////////////////////////////////////////////////////////////////////////////////
1516
         ////////////////////////////////////////////////////////////////////////////////////////////////
1423
         sb = new StringBuilder();
1517
         sb = new StringBuilder();
1424
         foreach(EA.Element intf in theElement.Realizes)
1518
         foreach(EA.Element intf in theElement.Realizes)
1425
         {
1519
         {
1426
            sb.Append( intf.Name);
1520
            sb.Append( intf.Name);
1427
         }
1521
         }
1428
         if (sb.Length > 0)
1522
         if (sb.Length > 0)
1429
         {
1523
         {
1430
            wr = TextUtils.appendAndSelectText("Realises:", EA_Constants.styleName_Body1_Left_2_5cm_Italic);
1524
            wr = TextualContent.appendAndSelectText("Realises:", EA_Constants.styleName_Body1_Left_2_5cm_Italic);
1431
 
1525
 
1432
            wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_3_5cm);
1526
            wr = TextualContent.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_3_5cm);
1433
         }
1527
         }
1434
      }
1528
      }
1435
 
1529
 
1436
      
1530
      
1437
      private void generateClassRequirements( EA.Element theElement, int recurse_level )
1531
      private void generateClassRequirements( EA.Element theElement, int recurse_level )
1438
      {
1532
      {
1439
         StringBuilder sb = new StringBuilder();
1533
         StringBuilder sb = new StringBuilder();
1440
 
1534
 
1441
         sb.Append( "Requirements:" );
1535
         sb.Append( "Requirements:" );
1442
         Word.Range wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_2_5cm_Italic);
1536
         Word.Range wr = TextualContent.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_2_5cm_Italic);
1443
 
1537
 
1444
         foreach(EA.Requirement theReq in theElement.Requirements)
1538
         foreach(EA.Requirement theReq in theElement.Requirements)
1445
         {
1539
         {
-
 
1540
            if (abortCreationThread)
-
 
1541
               return;
-
 
1542
 
1446
            sb = new StringBuilder();
1543
            sb = new StringBuilder();
1447
            sb.Append( theReq.Name );
1544
            sb.Append( theReq.Name );
1448
            wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_3_5cm);
1545
            wr = TextualContent.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_3_5cm);
1449
            sb = new StringBuilder();
1546
            sb = new StringBuilder();
1450
            sb.Append( theReq.Notes );
1547
            sb.Append( theReq.Notes );
1451
            if (sb.Length > 0)
1548
            if (sb.Length > 0)
1452
            {
1549
            {
1453
               wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_4_5cm);
1550
               wr = TextualContent.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_4_5cm);
1454
            }
1551
            }
1455
         }
1552
         }
1456
      }
1553
      }
1457
 
1554
 
1458
      
1555
      
1459
      private void generateClassConstraints( EA.Element theElement, int recurse_level )
1556
      private void generateClassConstraints( EA.Element theElement, int recurse_level )
1460
      {
1557
      {
1461
         StringBuilder sb = new StringBuilder();
1558
         StringBuilder sb = new StringBuilder();
1462
 
1559
 
1463
         sb.Append( "Constraints:" );
1560
         sb.Append( "Constraints:" );
1464
         Word.Range wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_2_5cm_Italic);
1561
         Word.Range wr = TextualContent.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_2_5cm_Italic);
1465
         
1562
         
1466
         foreach(EA.Constraint theCons in theElement.Constraints)
1563
         foreach(EA.Constraint theCons in theElement.Constraints)
1467
         {
1564
         {
-
 
1565
            if (abortCreationThread)
-
 
1566
               return;
-
 
1567
 
1468
            sb = new StringBuilder();
1568
            sb = new StringBuilder();
1469
            sb.Append( theCons.Type );
1569
            sb.Append( theCons.Type );
1470
            sb.Append( ": {" );
1570
            sb.Append( ": {" );
1471
            sb.Append( theCons.Name );
1571
            sb.Append( theCons.Name );
1472
            sb.Append( "}" );
1572
            sb.Append( "}" );
1473
 
1573
 
1474
            wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_3_5cm);
1574
            wr = TextualContent.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_3_5cm);
1475
 
1575
 
1476
            if (theCons.Notes.Length > 0)
1576
            if (theCons.Notes.Length > 0)
1477
            {
1577
            {
1478
               sb = new StringBuilder();
1578
               sb = new StringBuilder();
1479
               sb.Append( theCons.Notes );
1579
               sb.Append( theCons.Notes );
1480
               wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_4_5cm);
1580
               wr = TextualContent.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_4_5cm);
1481
            }
1581
            }
1482
         }
1582
         }
1483
      }
1583
      }
1484
 
1584
 
1485
 
1585
 
Line 1489... Line 1589...
1489
 
1589
 
1490
         // track recursion level to control heading style formatting requirements
1590
         // track recursion level to control heading style formatting requirements
1491
         if (oneShot_skipRootElementHeading == false)
1591
         if (oneShot_skipRootElementHeading == false)
1492
            recurse_level++;
1592
            recurse_level++;
1493
 
1593
 
1494
         if (EA_Utils.options.elementTypeFoundInEA_DocGen( theElement.Type ))
1594
         if (EA_DocGenOptions.elementTypeFoundInEA_DocGen( theElement.Type ))
1495
         {
1595
         {
1496
            // pass the element to the requirement element serialisation function. It
1596
            // pass the element to the requirement element serialisation function. It
1497
            // will tell us if it did anything with it. If not, then carry out the default
1597
            // will tell us if it did anything with it. If not, then carry out the default
1498
            // element serialisation.
1598
            // element serialisation.
1499
            if (false == TextUtils.generateRequirementText(theElement, EA_Utils))
1599
            if (false == TextualContent.generateRequirementText(theElement))
1500
            {
1600
            {
1501
               bool isClass = theElement.Type.StartsWith("Class");
1601
               bool isClass = theElement.Type.StartsWith("Class");
1502
 
1602
 
1503
               if (   (   true == isClass
1603
               if (   (   true == isClass
1504
                       && true == EA_Utils.options.opt_SuppressPrivateClasses 
1604
                       && true == EA_DocGenOptions.opt_SuppressPrivateClasses 
1505
                       && true == theElement.Visibility.StartsWith("Private"))
1605
                       && true == theElement.Visibility.StartsWith("Private"))
1506
                   || (   true == EA_Utils.options.opt_ConsiderAPIElementsOnly 
1606
                   || (   true == EA_DocGenOptions.opt_ConsiderAPIElementsOnly 
1507
                       && 0 > theElement.StereotypeEx.IndexOf("API"))
1607
                       && 0 > theElement.StereotypeEx.IndexOf("API"))
1508
                  )
1608
                  )
1509
               {
1609
               {
1510
                  // do nothing
1610
                  // do nothing
1511
                  DocSectionTracker.trackDocSection(recurse_level);
1611
                  DocSectionTracking.trackDocSection(recurse_level);
1512
                  displayProgress( "SKIPPED: ", theElement.Name );
1612
                  displayProgress( "SKIPPED: ", theElement.Name );
1513
                  allowSubElementParsing = false;
1613
                  allowSubElementParsing = false;
1514
               }
1614
               }
1515
               else
1615
               else
1516
               {
1616
               {
1517
                  // disarm the one-shot element (heading) skipping feature if it was armed, and 
1617
                  // disarm the one-shot element (heading) skipping feature if it was armed, and 
1518
                  // by-pass the code to generate a new heading level for the element
1618
                  // by-pass the code to generate a new heading level for the element
1519
                  if (oneShot_skipRootElementHeading == false)
1619
                  if (oneShot_skipRootElementHeading == false)
1520
                  {
1620
                  {
1521
                     // Default element serialisation
1621
                     // Default element serialisation
1522
                     TextUtils.appendAndSelectHeadingText( theElement.Name, recurse_level );
1622
                     TextualContent.appendAndSelectHeadingText( theElement.Name, recurse_level );
1523
                  }
1623
                  }
1524
                  else
1624
                  else
1525
                  {
1625
                  {
1526
                     oneShot_skipRootElementHeading = false;
1626
                     oneShot_skipRootElementHeading = false;
1527
                  }
1627
                  }
1528
 
1628
 
1529
                  processedElements.Add(theElement.ElementID);
1629
                  processedElements.Add(theElement.ElementID);
1530
                  displayProgress( "ELEMENT: ", theElement.Name );
1630
                  displayProgress( "ELEMENT: ", theElement.Name );
1531
 
1631
 
1532
                  TextUtils.appendDescription( theElement.Notes, EA_Utils );
1632
                  TextualContent.appendDescription( TextualContent.trimTrailingReturns(theElement.Notes) );
1533
 
1633
 
1534
                  generateElementDiagrams(theElement);
1634
                  generateElementDiagrams(theElement);
1535
 
1635
 
1536
                  if (true == isClass)
1636
                  if (true == isClass)
1537
                  {
1637
                  {
Line 1540... Line 1640...
1540
                         && !theElement.Visibility.StartsWith("Private"))
1640
                         && !theElement.Visibility.StartsWith("Private"))
1541
                     {
1641
                     {
1542
                        classesNeedingUnitTests.Add( theElement.ElementID );
1642
                        classesNeedingUnitTests.Add( theElement.ElementID );
1543
                     }
1643
                     }
1544
 
1644
 
-
 
1645
                     if (!abortCreationThread)
1545
                     generateClassCharacteristics(theElement, recurse_level);
1646
                        generateClassCharacteristics(theElement, recurse_level);
1546
                  }
1647
                  }
1547
 
1648
 
1548
                  // Requirement collection
1649
                  // Requirement collection
1549
                  if (theElement.Requirements.Count > 0)
1650
                  if (!abortCreationThread && theElement.Requirements.Count > 0)
1550
                  {
1651
                  {
1551
                     generateClassRequirements(theElement, recurse_level);
1652
                     generateClassRequirements(theElement, recurse_level);
1552
                  }
1653
                  }
1553
 
1654
 
1554
                  // Constraint collection
1655
                  // Constraint collection
1555
                  if (theElement.Constraints.Count > 0)
1656
                  if (!abortCreationThread && theElement.Constraints.Count > 0)
1556
                  {
1657
                  {
1557
                     generateClassConstraints(theElement, recurse_level);
1658
                     generateClassConstraints(theElement, recurse_level);
1558
                  }
1659
                  }
1559
 
1660
 
1560
                  if (theElement.Issues.Count > 0)
1661
                  if (!abortCreationThread && theElement.Issues.Count > 0)
1561
                  {
1662
                  {
1562
                  }
1663
                  }
1563
 
1664
 
1564
                  // Attribute collection
1665
                  // Attribute collection
1565
                  if (theElement.Attributes.Count > 0)
1666
                  if (!abortCreationThread && theElement.Attributes.Count > 0)
1566
                  {
1667
                  {
1567
                     generateAttributeContent(theElement, recurse_level);
1668
                     generateAttributeContent(theElement, recurse_level);
1568
                  }
1669
                  }
1569
 
1670
 
1570
                  // Method collection
1671
                  // Method collection
1571
                  if (theElement.Methods.Count > 0)
1672
                  if (!abortCreationThread && theElement.Methods.Count > 0)
1572
                  {
1673
                  {
1573
                     generateMethodContent(theElement, recurse_level);
1674
                     generateMethodContent(theElement, recurse_level);
1574
                  }
1675
                  }
1575
               }
1676
               }
1576
            }
1677
            }
1577
            else
1678
            else
1578
            {
1679
            {
1579
               processedElements.Add(theElement.ElementID);
1680
               processedElements.Add(theElement.ElementID);
1580
               DocSectionTracker.trackDocSection(recurse_level);
1681
               DocSectionTracking.trackDocSection(recurse_level);
1581
               displayProgress( "ELEMENT: ", theElement.Name );
1682
               displayProgress( "ELEMENT: ", theElement.Name );
1582
            }
1683
            }
1583
         }
1684
         }
1584
         else
1685
         else
1585
         {
1686
         {
1586
            DocSectionTracker.trackDocSection(recurse_level);
1687
            DocSectionTracking.trackDocSection(recurse_level);
1587
            displayProgress( "FILTERED: ", theElement.Type );
1688
            displayProgress( "FILTERED: ", theElement.Type );
1588
         }
1689
         }
1589
         // TODO
1690
         // TODO
1590
         // We will probably have to put special code in here at some point for attributes
1691
         // We will probably have to put special code in here at some point for attributes
1591
         // of, and collections of things within elements. This will become apparent once
1692
         // of, and collections of things within elements. This will become apparent once
Line 1605... Line 1706...
1605
      /// </summary>
1706
      /// </summary>
1606
      private void removeExistingDocumentContent()
1707
      private void removeExistingDocumentContent()
1607
      {
1708
      {
1608
         //WordApp.Visible = true;  // enable this when debugging this horrible function
1709
         //WordApp.Visible = true;  // enable this when debugging this horrible function
1609
         Word.Selection aSelection;
1710
         Word.Selection aSelection;
1610
         object findStyle = StyleUtils.getStyle( EA_Constants.styleName_Heading1 );
1711
         object findStyle = StyleContent.getStyle( EA_Constants.styleName_Heading1 );
1611
    
1712
    
1612
         WordApp.Selection.WholeStory();
1713
         WordApp.Selection.WholeStory();
1613
         aSelection = WordApp.Selection;
1714
         aSelection = WordApp.Selection;
1614
 
1715
 
1615
         aSelection.Find.ClearFormatting();
1716
         aSelection.Find.ClearFormatting();
Line 1652... Line 1753...
1652
      /// </summary>
1753
      /// </summary>
1653
      /// <param name="theElement"></param>
1754
      /// <param name="theElement"></param>
1654
      /// <param name="recurse_level"></param>
1755
      /// <param name="recurse_level"></param>
1655
      private void parse_element(EA.Element theElement, int recurse_level)
1756
      private void parse_element(EA.Element theElement, int recurse_level)
1656
      {
1757
      {
-
 
1758
         if (abortCreationThread)
-
 
1759
            return;
-
 
1760
 
1657
         // First look for and handle special elements that control the doc-gen process
1761
         // First look for and handle special elements that control the doc-gen process
1658
 
1762
 
1659
         // The EA_DocGenPackageLink can contain a list of GUIDs in its notes section
1763
         // The EA_DocGenPackageLink can contain a list of GUIDs in its notes section
1660
         // that point to model structure outside of the localised structure forming the
1764
         // that point to model structure outside of the localised structure forming the
1661
         // document. This enables a document to grab content from other external models
1765
         // document. This enables a document to grab content from other external models
Line 1687... Line 1791...
1687
 
1791
 
1688
            // The EA_DocGenTable element can contain table content in its notes section
1792
            // The EA_DocGenTable element can contain table content in its notes section
1689
            // and must be dealt with in a special way.
1793
            // and must be dealt with in a special way.
1690
         else if (theElement.Name.StartsWith(EA_Constants.EA_DocGenTable))
1794
         else if (theElement.Name.StartsWith(EA_Constants.EA_DocGenTable))
1691
         {
1795
         {
1692
            TableUtils.processTableElement(theElement, recurse_level);
1796
            TabularContent.processTableElement(theElement, recurse_level);
1693
         }
1797
         }
1694
 
1798
 
1695
            // The EA_DocGenText element can contain text content in its notes section
1799
            // The EA_DocGenText element can contain text content in its notes section
1696
            // that must be appended to the doc in Body 1 style within the current
1800
            // that must be appended to the doc in Body 1 style within the current
1697
            // section.
1801
            // section.
1698
         else if (theElement.Name.StartsWith(EA_Constants.EA_DocGenText))
1802
         else if (theElement.Name.StartsWith(EA_Constants.EA_DocGenText))
1699
         {
1803
         {
1700
            TextUtils.appendAndSelectText( theElement.Notes.ToString(), EA_Constants.styleName_Body1 );
1804
            TextualContent.appendAndSelectText( TextualContent.trimTrailingReturns(theElement.Notes), EA_Constants.styleName_Body1 );
1701
         }
1805
         }
1702
 
1806
 
1703
         else if (theElement.Name.StartsWith(EA_Constants.EA_DocGenRelationshipMatrix))
1807
         else if (theElement.Name.StartsWith(EA_Constants.EA_DocGenRelationshipMatrix))
1704
         {
1808
         {
1705
            EA_RelationshipMatrix EA_RelMatrix = new EA_RelationshipMatrix(EA_Repository, TableUtils, TextUtils, EA_Utils, WordDocument, processedElements);
1809
            EA_RelationshipMatrix.initialise(processedElements);
1706
            if (EA_RelMatrix.processRelationshipMatrixOptions( theElement ))
1810
            if (EA_RelationshipMatrix.processRelationshipMatrixOptions( theElement ))
1707
            {
1811
            {
1708
               EA_RelMatrix.processRelationshipMatrixElement( theElement, recurse_level );
1812
               EA_RelationshipMatrix.processRelationshipMatrixElement( theElement, recurse_level );
1709
            }
1813
            }
1710
         }
1814
         }
1711
 
1815
 
1712
         else if (theElement.Name.StartsWith(EA_Constants.EA_DocGenTestLink))
1816
         else if (theElement.Name.StartsWith(EA_Constants.EA_DocGenTestLink))
1713
         {
1817
         {
Line 1736... Line 1840...
1736
            if (allowSubElementParsing)
1840
            if (allowSubElementParsing)
1737
            {
1841
            {
1738
               // Look at this elements sub-elements
1842
               // Look at this elements sub-elements
1739
               foreach(EA.Element subElement in theElement.Elements)
1843
               foreach(EA.Element subElement in theElement.Elements)
1740
               {
1844
               {
-
 
1845
                  if (abortCreationThread)
-
 
1846
                     return;
-
 
1847
 
1741
                  parse_element(subElement, recurse_level+1);
1848
                  parse_element(subElement, recurse_level+1);
1742
               }
1849
               }
1743
            }
1850
            }
1744
         }   
1851
         }   
1745
      }
1852
      }
Line 1752... Line 1859...
1752
      /// </summary>
1859
      /// </summary>
1753
      /// <param name="parentPackage"></param>
1860
      /// <param name="parentPackage"></param>
1754
      /// <param name="recurse_level"></param>
1861
      /// <param name="recurse_level"></param>
1755
      private void parse_package(EA.Package thePackage, int recurse_level)
1862
      private void parse_package(EA.Package thePackage, int recurse_level)
1756
      {
1863
      {
-
 
1864
         if (abortCreationThread)
-
 
1865
            return;
-
 
1866
 
1757
         // track recursion level to control heading style formatting requirements
1867
         // track recursion level to control heading style formatting requirements
1758
         // The one-shot skiproot feature of the EA_DocGenPackageLink element handling has an effect
1868
         // The one-shot skiproot feature of the EA_DocGenPackageLink element handling has an effect
1759
         // here, as you can see. 
1869
         // here, as you can see. 
1760
         bool rootPackageWasSkipped = !oneShot_skipRootPackage;
1870
         bool rootPackageWasSkipped = !oneShot_skipRootPackage;
1761
         if (oneShot_skipRootPackage == false)
1871
         if (oneShot_skipRootPackage == false)
Line 1767... Line 1877...
1767
         bool packageHasAPIStereotype = false;
1877
         bool packageHasAPIStereotype = false;
1768
         if (0 <= thePackage.StereotypeEx.IndexOf("API") )
1878
         if (0 <= thePackage.StereotypeEx.IndexOf("API") )
1769
            packageHasAPIStereotype = true;
1879
            packageHasAPIStereotype = true;
1770
 
1880
 
1771
         // only process the package if it the stereotype allows, or sensitivity to the stereotype is disabled
1881
         // only process the package if it the stereotype allows, or sensitivity to the stereotype is disabled
1772
         if (  !EA_Utils.options.opt_ConsiderAPIPackagesOnly
1882
         if (  !EA_DocGenOptions.opt_ConsiderAPIPackagesOnly
1773
            || (EA_Utils.options.opt_ConsiderAPIPackagesOnly && EA_Utils.options.opt_RestrictForLinkedPackagesOnly && processingLink == 0)
1883
            || (EA_DocGenOptions.opt_ConsiderAPIPackagesOnly && EA_DocGenOptions.opt_RestrictForLinkedPackagesOnly && processingLink == 0)
1774
            || (EA_Utils.options.opt_ConsiderAPIPackagesOnly && packageHasAPIStereotype) 
1884
            || (EA_DocGenOptions.opt_ConsiderAPIPackagesOnly && packageHasAPIStereotype) 
1775
            )
1885
            )
1776
         {
1886
         {
1777
            
1887
            
1778
            bool processLowerLevelContent = true;
1888
            bool processLowerLevelContent = true;
1779
 
1889
 
Line 1797... Line 1907...
1797
               // consume diagrams
1907
               // consume diagrams
1798
               generatePackageDiagrams( thePackage );
1908
               generatePackageDiagrams( thePackage );
1799
 
1909
 
1800
               foreach(EA.Element subElement in thePackage.Elements)
1910
               foreach(EA.Element subElement in thePackage.Elements)
1801
               {
1911
               {
-
 
1912
                  if (abortCreationThread)
-
 
1913
                     return;
-
 
1914
 
1802
                  if (subElement.ParentID == 0 || thePackage.PackageID == subElement.ParentID)
1915
                  if (subElement.ParentID == 0 || thePackage.PackageID == subElement.ParentID)
1803
                     parse_element(subElement, recurse_level);
1916
                     parse_element(subElement, recurse_level);
1804
               }
1917
               }
1805
 
1918
 
1806
               // Scan through the sub-packages within this package.
1919
               // Scan through the sub-packages within this package.
1807
               foreach(EA.Package subPackage in thePackage.Packages)
1920
               foreach(EA.Package subPackage in thePackage.Packages)
1808
               {
1921
               {
-
 
1922
                  if (abortCreationThread)
-
 
1923
                     return;
-
 
1924
 
1809
                  // recurse
1925
                  // recurse
1810
                  parse_package(subPackage, recurse_level);
1926
                  parse_package(subPackage, recurse_level);
1811
               }
1927
               }
1812
            }
1928
            }
1813
         }
1929
         }
Line 1827... Line 1943...
1827
      /// an input template, sets various characteristics of the document, schedules the
1943
      /// an input template, sets various characteristics of the document, schedules the
1828
      /// EA parsing function, before finally saving the document to the output file name.
1944
      /// EA parsing function, before finally saving the document to the output file name.
1829
      /// </summary>
1945
      /// </summary>
1830
      private void createTheWordDoc()
1946
      private void createTheWordDoc()
1831
      {
1947
      {
-
 
1948
         docGenCompletedNormally = false;
-
 
1949
         abortCreationThread = false;
-
 
1950
 
-
 
1951
         Main.threadCreateDocProcessRunning = true;
-
 
1952
 
1832
         // caputre initial security settings
1953
         // capture initial security settings
1833
         MsoAutomationSecurity  securityBefore = WordApp.AutomationSecurity;
1954
         MsoAutomationSecurity  securityBefore = WordApp.AutomationSecurity;
1834
 
1955
 
-
 
1956
         button_generate.Enabled = false;
-
 
1957
         button_browse_output_file.Enabled = false;
-
 
1958
         button_browse_template.Enabled = false;
-
 
1959
         textBox_output_file.Enabled = false;
-
 
1960
         textBox_template.Enabled = false;
-
 
1961
         checkBox_WordVisibility.Enabled = false;
-
 
1962
 
1835
         try 
1963
         try 
1836
         {
1964
         {
1837
            object template       = this.textBox_template.Text;
1965
            object template       = this.textBox_template.Text;
1838
            object newTemplate    = Type.Missing;
1966
            object newTemplate    = Type.Missing;
1839
            object outputFilename = this.textBox_output_file.Text;
1967
            object outputFilename = this.textBox_output_file.Text;
Line 1841... Line 1969...
1841
            object docType = Type.Missing;
1969
            object docType = Type.Missing;
1842
            object visible = Type.Missing;
1970
            object visible = Type.Missing;
1843
            object nothing = Type.Missing;
1971
            object nothing = Type.Missing;
1844
            object notTrue = false;
1972
            object notTrue = false;
1845
 
1973
 
1846
            EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "", 0);
1974
            Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "", 0);
1847
            EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, 
1975
            Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, 
1848
                                       String.Format( "Generating Document {0}", this.textBox_output_file.Text), 0 );
1976
                                       String.Format( "Generating Document {0}", this.textBox_output_file.Text), 0 );
1849
 
1977
 
1850
            // tell word not to show itself unless user has checked the option to say otherwise
1978
            // tell word not to show itself unless user has checked the option to say otherwise
1851
            WordApp.Visible = this.checkBox_WordVisibility.Checked;
1979
            WordApp.Visible = this.checkBox_WordVisibility.Checked;
1852
   
1980
   
1853
            // disable VB macros from running in the document
1981
            // disable VB macros from running in the document
1854
            WordApp.AutomationSecurity = MsoAutomationSecurity.msoAutomationSecurityForceDisable;
1982
            WordApp.AutomationSecurity = MsoAutomationSecurity.msoAutomationSecurityForceDisable;
1855
            WordApp.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;
1983
            WordApp.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;
1856
 
1984
 
1857
            // Create a document from the input template
1985
            // Create a document from the input template
-
 
1986
            Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Creating new document based on template", -1);
1858
            WordDocument = WordApp.Documents.Add(ref template, ref newTemplate, ref docType, ref visible);
1987
            WordDocument = WordApp.Documents.Add(ref template, ref newTemplate, ref docType, ref visible);
1859
   
-
 
1860
            TableUtils.AcceptWordAppAndDoc(WordApp, WordDocument);
-
 
1861
            TextUtils.AcceptWordAppAndDoc(WordApp, WordDocument);
-
 
1862
            StyleUtils.AcceptWordAppAndDoc(WordApp, WordDocument);
-
 
1863
 
1988
 
-
 
1989
   
1864
            // Remove all old content from the input document/template. Note that this assumes
1990
            // Remove all old content from the input document/template. Note that this assumes
1865
            // that content will begin at section 1 with the title "Introduction" and it will have
1991
            // that content will begin at section 1 with the title "Introduction" and it will have
1866
            // "Heading 1" style.
1992
            // "Heading 1" style.
-
 
1993
            if (!abortCreationThread)
-
 
1994
            {
-
 
1995
               Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Removing existing content (if any)", -1);
1867
            removeExistingDocumentContent();
1996
               removeExistingDocumentContent();
-
 
1997
            }
1868
 
1998
 
1869
            // turn off grammar and spell checking
1999
            // turn off grammar and spell checking
1870
            WordDocument.GrammarChecked = false;
2000
            WordDocument.GrammarChecked = false;
1871
            WordDocument.SpellingChecked = false;
2001
            WordDocument.SpellingChecked = false;
1872
        
2002
        
Line 1878... Line 2008...
1878
 
2008
 
1879
            processedElements = new ArrayList();
2009
            processedElements = new ArrayList();
1880
 
2010
 
1881
            // If the input template does not contain the styles needed for requirement documents, 
2011
            // If the input template does not contain the styles needed for requirement documents, 
1882
            // programmatically create them just in case.
2012
            // programmatically create them just in case.
-
 
2013
            if (!abortCreationThread)
-
 
2014
            {
-
 
2015
               Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Creating Requirement Styles", -1);
1883
            StyleUtils.createRequirementStyles();
2016
               StyleContent.createRequirementStyles();
-
 
2017
            }
-
 
2018
            if (!abortCreationThread)
-
 
2019
            {
-
 
2020
               Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Creating Additional Heading Styles", -1);
1884
            StyleUtils.createAdditionalHeadingLevelStyles();
2021
               StyleContent.createAdditionalHeadingLevelStyles();
-
 
2022
            }
-
 
2023
            if (!abortCreationThread)
-
 
2024
            {
-
 
2025
               Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Creating Element Detail Styles", -1);
1885
            StyleUtils.createElementDetailsStyles();
2026
               StyleContent.createElementDetailsStyles();
-
 
2027
            }
-
 
2028
            if (!abortCreationThread)
-
 
2029
            {
-
 
2030
               Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Correcting known problems in ERG template styles", -1);
1886
            StyleUtils.correctErrorsInTemplateStyles();
2031
               StyleContent.correctErrorsInTemplateStyles();
-
 
2032
            }
1887
 
2033
 
1888
            // Parse EA_DocGen Document Model. The parent package is the document model itself
2034
            // Parse EA_DocGen Document Model. The parent package is the document model itself
1889
            // and the packages within it are the top level packages only.
2035
            // and the packages within it are the top level packages only.
1890
            // Question: do we have to parse diagrams and elements at this top level? So far,
2036
            // Question: do we have to parse diagrams and elements at this top level? So far,
1891
            // this has been found to be unecessary, but you never know. For now, dont do it.
2037
            // this has been found to be unecessary, but you never know. For now, dont do it.
1892
            foreach(EA.Package thePackage in EA_ParentPackage.Packages)
2038
            if (!abortCreationThread)
1893
            {
2039
            {
1894
               parse_package(thePackage, 0);
2040
               Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Generating new content", -1);
1895
            }
-
 
1896
 
2041
 
-
 
2042
               foreach(EA.Package thePackage in EA_ParentPackage.Packages)
-
 
2043
               {
-
 
2044
                  parse_package(thePackage, 0);
-
 
2045
                  if (abortCreationThread)
-
 
2046
                     break;
-
 
2047
               }
-
 
2048
            }
1897
            // for design docs, a user may have used the test traceability element in their document model,
2049
            // for design docs, a user may have used the test traceability element in their document model,
1898
            // which means that now we are finished with parse 1 of the document, we can complete the traceability
2050
            // which means that now we are finished with parse 1 of the document, we can complete the traceability
1899
            // table (if any) that was begun when that special element was first encountered.
2051
            // table (if any) that was begun when that special element was first encountered.
1900
            completeTestTraceability();
2052
            if (!abortCreationThread)
1901
 
-
 
1902
            // Save the document to the output file before we try and update the fields. This is because
-
 
1903
            // I have seen Fields.Update() fail on a few occasions and it is very annoying
-
 
1904
            // to lose what has thus far been generated.
-
 
1905
            WordDocument.SaveAs( ref outputFilename, 
-
 
1906
               ref nothing, ref nothing, ref nothing, ref nothing, 
-
 
1907
               ref nothing, ref nothing, ref nothing, ref nothing,
-
 
1908
               ref nothing, ref nothing, ref nothing, ref nothing,
-
 
1909
               ref nothing, ref nothing, ref nothing);
-
 
1910
 
-
 
1911
            object noSave = Word.WdSaveOptions.wdDoNotSaveChanges;
-
 
1912
            object format = Word.WdOriginalFormat.wdWordDocument;
-
 
1913
            WordDocument.Close(ref noSave, ref format, ref nothing);
-
 
1914
 
-
 
1915
            // Re-load the document to update the fields. For some as yet unknown reason, doing this 
-
 
1916
            // sometimes fails, but by doing it in a re-loaded instance of the word document
-
 
1917
            // the failures seem to be reduced.
2053
            {
1918
            WordDocument = WordApp.Documents.Add(ref outputFilename, ref newTemplate, ref docType, ref visible);
-
 
1919
            WordDocument.Fields.Update();
2054
               completeTestTraceability();
1920
            WordDocument.SaveAs( ref outputFilename, 
-
 
1921
               ref nothing, ref nothing, ref nothing, ref nothing, 
-
 
1922
               ref nothing, ref nothing, ref nothing, ref nothing,
-
 
1923
               ref nothing, ref nothing, ref nothing, ref nothing,
-
 
1924
               ref nothing, ref nothing, ref nothing);
-
 
1925
 
2055
 
-
 
2056
               // Save the document to the output file before we try and update the fields. This is because
-
 
2057
               // I have seen Fields.Update() fail on a few occasions and it is very annoying
-
 
2058
               // to lose what has thus far been generated.
-
 
2059
               WordDocument.SaveAs( ref outputFilename, 
-
 
2060
                  ref nothing, ref nothing, ref nothing, ref nothing, 
-
 
2061
                  ref nothing, ref nothing, ref nothing, ref nothing,
-
 
2062
                  ref nothing, ref nothing, ref nothing, ref nothing,
-
 
2063
                  ref nothing, ref nothing, ref nothing);
-
 
2064
 
-
 
2065
               object noSave = Word.WdSaveOptions.wdDoNotSaveChanges;
-
 
2066
               object format = Word.WdOriginalFormat.wdWordDocument;
-
 
2067
               WordDocument.Close(ref noSave, ref format, ref nothing);
-
 
2068
 
-
 
2069
               if (!abortCreationThread)
-
 
2070
               {
-
 
2071
                  Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Updating Fields and Saving Document", -1);
-
 
2072
                  // Re-load the document to update the fields. For some as yet unknown reason, doing this 
-
 
2073
                  // sometimes fails, but by doing it in a re-loaded instance of the word document
-
 
2074
                  // the failures seem to be reduced.
-
 
2075
                  WordDocument = WordApp.Documents.Add(ref outputFilename, ref newTemplate, ref docType, ref visible);
-
 
2076
                  WordDocument.Fields.Update();
-
 
2077
                  WordDocument.SaveAs( ref outputFilename, 
-
 
2078
                     ref nothing, ref nothing, ref nothing, ref nothing, 
-
 
2079
                     ref nothing, ref nothing, ref nothing, ref nothing,
-
 
2080
                     ref nothing, ref nothing, ref nothing, ref nothing,
-
 
2081
                     ref nothing, ref nothing, ref nothing);
-
 
2082
 
1926
            // Tell user the process completed ok
2083
                  // Tell user the process completed ok
-
 
2084
                  Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Document Generation Complete", -1);
1927
            textBox_progress.AppendText( "---Completed---" );
2085
                  docGenCompletedNormally = true;
-
 
2086
                  button_view_output.Enabled = true;
-
 
2087
               }
-
 
2088
            }
-
 
2089
            else
-
 
2090
            {
-
 
2091
               Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Document Generation Aborted", -1);
1928
            MessageBox.Show("Document Generation Complete");
2092
               MessageBox.Show("Document Generation Aborted");
-
 
2093
            }
1929
 
2094
 
1930
            button_view_output.Enabled = true;
-
 
1931
         }
2095
         }
1932
         catch (Exception createTheWordDoc_exception)
2096
         catch (Exception createTheWordDoc_exception)
1933
         {
2097
         {
-
 
2098
            Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Document Generation Failed : " + createTheWordDoc_exception.Message, -1);
1934
            MessageBox.Show("Document Generation Failed\n\n" + createTheWordDoc_exception.Message);
2099
            MessageBox.Show("Document Generation Failed\n\n" + createTheWordDoc_exception.Message);
1935
         }
2100
         }
1936
 
2101
 
1937
         // restore security settings
2102
         // restore security settings
1938
         WordApp.AutomationSecurity = securityBefore;
2103
         WordApp.AutomationSecurity = securityBefore;
-
 
2104
 
-
 
2105
         // issue the generation complete message box as close to the end of the thread as possible so that
-
 
2106
         // there is less of a chance that a user pressing the close button will see a "cancel generation"
-
 
2107
         // warning box.
-
 
2108
         if (docGenCompletedNormally)
-
 
2109
            MessageBox.Show("Document Generation Complete");
-
 
2110
 
-
 
2111
         // we can mark the thread as not running since from now on we do not want to do anything with the 
-
 
2112
         // WordApp or WordDocument objects and their destruction wont cause any ill effects.
-
 
2113
         Main.threadCreateDocProcessRunning = false;
-
 
2114
 
-
 
2115
         if (mustClose)
-
 
2116
            this.Close();
1939
      }
2117
      }
1940
 
2118
 
1941
 
2119
 
1942
 
2120
 
1943
 
2121
 
1944
      #endregion
2122
      #endregion
-
 
2123
 
-
 
2124
 
-
 
2125
 
-
 
2126
 
1945
   }
2127
   }
1946
}
2128
}