| Line 2... |
Line 2... |
| 2 |
using System.Drawing;
|
2 |
using System.Drawing;
|
| 3 |
using System.Collections;
|
3 |
using System.Collections;
|
| 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 Microsoft.Office.Interop.Word;
|
| 8 |
using Microsoft.Office.Core;
|
8 |
using Microsoft.Office.Core;
|
| 9 |
using System.Threading;
|
9 |
using System.Threading;
|
| 10 |
|
10 |
|
| 11 |
namespace EA_DocGen
|
11 |
namespace EA_DocGen
|
| 12 |
{
|
12 |
{
|
| Line 36... |
Line 36... |
| 36 |
// This data is designed to support unit test traceability. As such, it is only of real use
|
36 |
// This data is designed to support unit test traceability. As such, it is only of real use
|
| 37 |
// when making s/w design documents. It allows all non-private classes to be collected into
|
37 |
// when making s/w design documents. It allows all non-private classes to be collected into
|
| 38 |
// a list in order to generate a design-to-unit-test traceability table.
|
38 |
// a list in order to generate a design-to-unit-test traceability table.
|
| 39 |
private ArrayList classesNeedingUnitTests = null;
|
39 |
private ArrayList classesNeedingUnitTests = null;
|
| 40 |
private ArrayList classesWithUnitTests = null;
|
40 |
private ArrayList classesWithUnitTests = null;
|
| 41 |
private Word.Table utTraceabilityTable = null;
|
41 |
private Table utTraceabilityTable = null;
|
| 42 |
|
42 |
|
| 43 |
// MS-Office Word related data
|
43 |
// MS-Office Word related data
|
| 44 |
public static Word.Application WordApp = null;
|
44 |
public static Microsoft.Office.Interop.Word.Application WordApp = null;
|
| 45 |
public static Word.Document WordDocument = null;
|
45 |
public static Document WordDocument = null;
|
| 46 |
|
46 |
|
| 47 |
// Form data
|
47 |
// Form data
|
| 48 |
public System.Windows.Forms.TextBox textBox_template;
|
48 |
public System.Windows.Forms.TextBox textBox_template;
|
| 49 |
private System.Windows.Forms.Button button_browse_template;
|
49 |
private System.Windows.Forms.Button button_browse_template;
|
| 50 |
public System.Windows.Forms.TextBox textBox_output_file;
|
50 |
public System.Windows.Forms.TextBox textBox_output_file;
|
| Line 76... |
Line 76... |
| 76 |
TabularContent.initialise();
|
76 |
TabularContent.initialise();
|
| 77 |
TextualContent.initialise();
|
77 |
TextualContent.initialise();
|
| 78 |
StyleContent.initialise();
|
78 |
StyleContent.initialise();
|
| 79 |
TextParser.initialise();
|
79 |
TextParser.initialise();
|
| 80 |
|
80 |
|
| 81 |
WordApp = new Word.Application();
|
81 |
WordApp = new Microsoft.Office.Interop.Word.Application();
|
| 82 |
}
|
82 |
}
|
| 83 |
|
83 |
|
| 84 |
|
84 |
|
| 85 |
/// <summary>
|
85 |
/// <summary>
|
| 86 |
/// Clean up any resources being used.
|
86 |
/// Clean up any resources being used.
|
| Line 264... |
Line 264... |
| 264 |
|
264 |
|
| 265 |
private void button_generate_Click(object sender, System.EventArgs e)
|
265 |
private void button_generate_Click(object sender, System.EventArgs e)
|
| 266 |
{
|
266 |
{
|
| 267 |
if (this.textBox_template.Text.Length > 0)
|
267 |
if (this.textBox_template.Text.Length > 0)
|
| 268 |
{
|
268 |
{
|
| 269 |
if (this.textBox_output_file.Text.Length > 0)
|
269 |
if (this.textBox_output_file.Text.Length > 0)
|
| 270 |
{
|
270 |
{
|
| - |
|
271 |
button_generate.Enabled = false;
|
| - |
|
272 |
button_browse_output_file.Enabled = false;
|
| - |
|
273 |
button_browse_template.Enabled = false;
|
| - |
|
274 |
textBox_output_file.Enabled = false;
|
| - |
|
275 |
textBox_template.Enabled = false;
|
| - |
|
276 |
checkBox_WordVisibility.Enabled = false;
|
| - |
|
277 |
|
| 271 |
creationThread = new Thread(new ThreadStart(createTheWordDoc));
|
278 |
creationThread = new Thread(new ThreadStart(createTheWordDoc));
|
| 272 |
creationThread.ApartmentState = ApartmentState.STA;
|
279 |
creationThread.SetApartmentState(ApartmentState.STA);
|
| 273 |
creationThread.Priority = ThreadPriority.Highest;
|
280 |
creationThread.Priority = ThreadPriority.Highest;
|
| 274 |
creationThread.Start();
|
281 |
creationThread.Start();
|
| 275 |
}
|
282 |
}
|
| 276 |
else
|
283 |
else
|
| 277 |
{
|
284 |
{
|
| 278 |
MessageBox.Show("Error - must specify an output file");
|
285 |
MessageBox.Show("Error - must specify an output file");
|
| 279 |
}
|
286 |
}
|
| 280 |
}
|
287 |
}
|
| 281 |
else
|
288 |
else
|
| 282 |
{
|
289 |
{
|
| 283 |
MessageBox.Show("Error - must specify an input template file");
|
290 |
MessageBox.Show("Error - must specify an input template file");
|
| 284 |
}
|
291 |
}
|
| Line 354... |
Line 361... |
| 354 |
try
|
361 |
try
|
| 355 |
{
|
362 |
{
|
| 356 |
object nothing = Type.Missing;
|
363 |
object nothing = Type.Missing;
|
| 357 |
object notTrue = false;
|
364 |
object notTrue = false;
|
| 358 |
|
365 |
|
| 359 |
WordApp.Application.Quit( ref notTrue, ref nothing, ref nothing);
|
366 |
((Microsoft.Office.Interop.Word._Application)WordApp.Application).Quit(ref notTrue, ref nothing, ref nothing);
|
| 360 |
}
|
367 |
}
|
| 361 |
catch (Exception createWordDoc_Closing_exception)
|
368 |
catch (Exception createWordDoc_Closing_exception)
|
| 362 |
{
|
369 |
{
|
| 363 |
// dummy statement
|
370 |
// dummy statement
|
| 364 |
String s = createWordDoc_Closing_exception.Message;
|
371 |
String s = createWordDoc_Closing_exception.Message;
|
| Line 432... |
Line 439... |
| 432 |
|
439 |
|
| 433 |
// create a range at the end of the document
|
440 |
// create a range at the end of the document
|
| 434 |
startLocation = WordDocument.Content.End;
|
441 |
startLocation = WordDocument.Content.End;
|
| 435 |
WordDocument.Content.InsertParagraphAfter();
|
442 |
WordDocument.Content.InsertParagraphAfter();
|
| 436 |
endLocation = WordDocument.Content.End;
|
443 |
endLocation = WordDocument.Content.End;
|
| 437 |
Word.Range WordRange = WordDocument.Range(ref startLocation, ref endLocation);
|
444 |
Range WordRange = WordDocument.Range(ref startLocation, ref endLocation);
|
| 438 |
object direction = Word.WdCollapseDirection.wdCollapseEnd;
|
445 |
object direction = WdCollapseDirection.wdCollapseEnd;
|
| 439 |
WordRange.Collapse(ref direction); // collapse prevents existing content being replaced
|
446 |
WordRange.Collapse(ref direction); // collapse prevents existing content being replaced
|
| 440 |
|
447 |
|
| 441 |
// Get ready for the diagram paste and the formatting we want to do on it with the
|
448 |
// Get ready for the diagram paste and the formatting we want to do on it with the
|
| 442 |
// selection object.
|
449 |
// selection object.
|
| 443 |
TextualContent.SelectInsertionPointAtEndOfDocument();
|
450 |
TextualContent.SelectInsertionPointAtEndOfDocument();
|
| Line 450... |
Line 457... |
| 450 |
endLocation = WordDocument.Content.End;
|
457 |
endLocation = WordDocument.Content.End;
|
| 451 |
WordRange = WordDocument.Range(ref startLocation, ref endLocation);
|
458 |
WordRange = WordDocument.Range(ref startLocation, ref endLocation);
|
| 452 |
WordRange.set_Style(ref l_style);
|
459 |
WordRange.set_Style(ref l_style);
|
| 453 |
|
460 |
|
| 454 |
// Center the diagram on the page
|
461 |
// Center the diagram on the page
|
| 455 |
object unit = Word.WdUnits.wdLine;
|
462 |
object unit = WdUnits.wdLine;
|
| 456 |
object missing = Type.Missing;
|
463 |
object missing = Type.Missing;
|
| 457 |
object count = 1;
|
464 |
object count = 1;
|
| 458 |
WordApp.Selection.MoveDown( ref unit, ref count, ref missing);
|
465 |
WordApp.Selection.MoveDown( ref unit, ref count, ref missing);
|
| 459 |
WordApp.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
|
466 |
WordApp.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
|
| 460 |
|
467 |
|
| 461 |
// Add a caption
|
468 |
// Add a caption
|
| 462 |
WordDocument.Content.InsertParagraphAfter();
|
469 |
WordDocument.Content.InsertParagraphAfter();
|
| 463 |
TextualContent.SelectInsertionPointAtEndOfDocument();
|
470 |
TextualContent.SelectInsertionPointAtEndOfDocument();
|
| 464 |
object Label = "Figure";
|
471 |
object Label = "Figure";
|
| 465 |
object Title = Type.Missing;
|
472 |
object Title = Type.Missing;
|
| 466 |
object TitleAutoText = Type.Missing;
|
473 |
object TitleAutoText = Type.Missing;
|
| 467 |
object Position = Word.WdCaptionPosition.wdCaptionPositionAbove;
|
474 |
object Position = WdCaptionPosition.wdCaptionPositionAbove;
|
| 468 |
object ExcludeLabel = 0;
|
475 |
object ExcludeLabel = 0;
|
| 469 |
WordApp.Selection.InsertCaption( ref Label, ref Title, ref TitleAutoText, ref Position, ref ExcludeLabel);
|
476 |
WordApp.Selection.InsertCaption( ref Label, ref Title, ref TitleAutoText, ref Position, ref ExcludeLabel);
|
| 470 |
WordApp.Selection.TypeText( ": " + theDiagram.Name);
|
477 |
WordApp.Selection.TypeText( ": " + theDiagram.Name);
|
| 471 |
WordApp.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
|
478 |
WordApp.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
|
| 472 |
|
479 |
|
| 473 |
// experimental code to create a bookmark for the figure caption
|
480 |
// experimental code to create a bookmark for the figure caption
|
| 474 |
//WordDocument.Paragraphs[ WordDocument.Paragraphs.Count ].Range.Select();
|
481 |
//WordDocument.Paragraphs[ WordDocument.Paragraphs.Count ].Range.Select();
|
| 475 |
//object lastParaRange = WordDocument.Paragraphs[ WordDocument.Paragraphs.Count ].Range;
|
482 |
//object lastParaRange = WordDocument.Paragraphs[ WordDocument.Paragraphs.Count ].Range;
|
| 476 |
//string bookmarkName = theDiagram.Name;
|
483 |
//string bookmarkName = theDiagram.Name;
|
| Line 860... |
Line 867... |
| 860 |
utTraceabilityTable.Cell(row,2).Range.Text = TextualContent.testSuiteName(theElement);
|
867 |
utTraceabilityTable.Cell(row,2).Range.Text = TextualContent.testSuiteName(theElement);
|
| 861 |
}
|
868 |
}
|
| 862 |
else
|
869 |
else
|
| 863 |
{
|
870 |
{
|
| 864 |
utTraceabilityTable.Cell(row,2).Range.Text = "Missing tests!";
|
871 |
utTraceabilityTable.Cell(row,2).Range.Text = "Missing tests!";
|
| 865 |
utTraceabilityTable.Cell(row,2).Range.Font.Color = Word.WdColor.wdColorRed;
|
872 |
utTraceabilityTable.Cell(row,2).Range.Font.Color = WdColor.wdColorRed;
|
| 866 |
}
|
873 |
}
|
| 867 |
}
|
874 |
}
|
| 868 |
|
875 |
|
| 869 |
numClassesRemaining--;
|
876 |
numClassesRemaining--;
|
| 870 |
if (numClassesRemaining > 0)
|
877 |
if (numClassesRemaining > 0)
|
| Line 939... |
Line 946... |
| 939 |
|
946 |
|
| 940 |
if (done && glossary.Count > 0)
|
947 |
if (done && glossary.Count > 0)
|
| 941 |
{
|
948 |
{
|
| 942 |
// Create a table
|
949 |
// Create a table
|
| 943 |
int tableNum = TabularContent.Table_Create("Terminology", true, numItems+1, 2);
|
950 |
int tableNum = TabularContent.Table_Create("Terminology", true, numItems+1, 2);
|
| 944 |
Word.Table table = WordDocument.Tables[tableNum];
|
951 |
Table table = WordDocument.Tables[tableNum];
|
| 945 |
object center = Word.WdParagraphAlignment.wdAlignParagraphCenter;
|
952 |
object center = WdParagraphAlignment.wdAlignParagraphCenter;
|
| 946 |
|
953 |
|
| 947 |
TabularContent.Table_SetTableColumnTitle(table, "Term", 1);
|
954 |
TabularContent.Table_SetTableColumnTitle(table, "Term", 1);
|
| 948 |
TabularContent.Table_SetTableColumnTitle(table, "Definition", 2);
|
955 |
TabularContent.Table_SetTableColumnTitle(table, "Definition", 2);
|
| 949 |
table.Columns[1].SetWidth(100, Word.WdRulerStyle.wdAdjustSameWidth );
|
956 |
table.Columns[1].SetWidth(100, WdRulerStyle.wdAdjustSameWidth );
|
| 950 |
int row = 2;
|
957 |
int row = 2;
|
| 951 |
// inject the glossary into the table
|
958 |
// inject the glossary into the table
|
| 952 |
foreach(EA.Term theTerm in glossary)
|
959 |
foreach(EA.Term theTerm in glossary)
|
| 953 |
{
|
960 |
{
|
| 954 |
if (abortCreationThread)
|
961 |
if (abortCreationThread)
|
| Line 1005... |
Line 1012... |
| 1005 |
|
1012 |
|
| 1006 |
if (infoItems.Count > 0)
|
1013 |
if (infoItems.Count > 0)
|
| 1007 |
{
|
1014 |
{
|
| 1008 |
// Create a table
|
1015 |
// Create a table
|
| 1009 |
int tableNum = TabularContent.Table_Create("Terminology", true, infoItems.Count+1, 2);
|
1016 |
int tableNum = TabularContent.Table_Create("Terminology", true, infoItems.Count+1, 2);
|
| 1010 |
Word.Table table = WordDocument.Tables[tableNum];
|
1017 |
Table table = WordDocument.Tables[tableNum];
|
| 1011 |
object center = Word.WdParagraphAlignment.wdAlignParagraphCenter;
|
1018 |
object center = WdParagraphAlignment.wdAlignParagraphCenter;
|
| 1012 |
|
1019 |
|
| 1013 |
TabularContent.Table_SetTableColumnTitle(table, "Term", 1);
|
1020 |
TabularContent.Table_SetTableColumnTitle(table, "Term", 1);
|
| 1014 |
TabularContent.Table_SetTableColumnTitle(table, "Definition", 2);
|
1021 |
TabularContent.Table_SetTableColumnTitle(table, "Definition", 2);
|
| 1015 |
table.Columns[1].SetWidth(100, Word.WdRulerStyle.wdAdjustSameWidth );
|
1022 |
table.Columns[1].SetWidth(100, WdRulerStyle.wdAdjustSameWidth );
|
| 1016 |
int row = 2;
|
1023 |
int row = 2;
|
| 1017 |
|
1024 |
|
| 1018 |
elementSortByName sorter = new elementSortByName();
|
1025 |
elementSortByName sorter = new elementSortByName();
|
| 1019 |
infoItems.Sort(sorter);
|
1026 |
infoItems.Sort(sorter);
|
| 1020 |
|
1027 |
|
| Line 1130... |
Line 1137... |
| 1130 |
if (EA_DocGenOptions.optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_PRIVATE_METHODS) == false
|
1137 |
if (EA_DocGenOptions.optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_PRIVATE_METHODS) == false
|
| 1131 |
|| !theMethod.Visibility.StartsWith("Private"))
|
1138 |
|| !theMethod.Visibility.StartsWith("Private"))
|
| 1132 |
numMethodsRemaining++;
|
1139 |
numMethodsRemaining++;
|
| 1133 |
}
|
1140 |
}
|
| 1134 |
|
1141 |
|
| 1135 |
Word.Range wr;
|
1142 |
Range wr;
|
| 1136 |
StringBuilder sb;
|
1143 |
StringBuilder sb;
|
| 1137 |
|
1144 |
|
| 1138 |
if (numMethodsRemaining > 0)
|
1145 |
if (numMethodsRemaining > 0)
|
| 1139 |
{
|
1146 |
{
|
| 1140 |
// Print the "<Class Name> Operations" headings
|
1147 |
// Print the "<Class Name> Operations" headings
|
| Line 1154... |
Line 1161... |
| 1154 |
if (EA_DocGenOptions.optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_PRIVATE_METHODS) == false
|
1161 |
if (EA_DocGenOptions.optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_PRIVATE_METHODS) == false
|
| 1155 |
|| !theMethod.Visibility.StartsWith("Private"))
|
1162 |
|| !theMethod.Visibility.StartsWith("Private"))
|
| 1156 |
{
|
1163 |
{
|
| 1157 |
// Print the Method name as a sub heading, and its description
|
1164 |
// Print the Method name as a sub heading, and its description
|
| 1158 |
TextualContent.appendAndSelectHeadingText(theMethod.Name , recurse_level + 1);
|
1165 |
TextualContent.appendAndSelectHeadingText(theMethod.Name , recurse_level + 1);
|
| - |
|
1166 |
|
| - |
|
1167 |
if (theMethod.Notes != null && theMethod.Notes.Length > 0)
|
| - |
|
1168 |
{
|
| 1159 |
TextualContent.appendDescription(TextualContent.trimTrailingReturns(theMethod.Notes));
|
1169 |
TextParser.parse( TextualContent.trimTrailingReturns(theMethod.Notes), theMethod.MethodID, EA_Constants.styleName_Body1, 0, false);
|
| - |
|
1170 |
}
|
| 1160 |
|
1171 |
|
| 1161 |
// Get a list of the method's parameters and sort them by the position field setup
|
1172 |
// Get a list of the method's parameters and sort them by the position field setup
|
| 1162 |
// in EA by the designer
|
1173 |
// in EA by the designer
|
| 1163 |
ArrayList theParams = new ArrayList();
|
1174 |
ArrayList theParams = new ArrayList();
|
| 1164 |
foreach(EA.Parameter theParam in theMethod.Parameters)
|
1175 |
foreach(EA.Parameter theParam in theMethod.Parameters)
|
| Line 1190... |
Line 1201... |
| 1190 |
if (abortCreationThread)
|
1201 |
if (abortCreationThread)
|
| 1191 |
return;
|
1202 |
return;
|
| 1192 |
|
1203 |
|
| 1193 |
// each parameter is "[in|out|inout] type name [= default-value]"
|
1204 |
// each parameter is "[in|out|inout] type name [= default-value]"
|
| 1194 |
// where the default value is optional
|
1205 |
// where the default value is optional
|
| - |
|
1206 |
if (!(EA_DocGenOptions.optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_PARAMETER_KIND)))
|
| - |
|
1207 |
{
|
| 1195 |
sb.Append( "[" );
|
1208 |
sb.Append("[");
|
| 1196 |
sb.Append( theParam.Kind );
|
1209 |
sb.Append(theParam.Kind);
|
| 1197 |
sb.Append( "] " );
|
1210 |
sb.Append("] ");
|
| - |
|
1211 |
}
|
| 1198 |
sb.Append( theParam.Type );
|
1212 |
sb.Append( theParam.Type );
|
| 1199 |
sb.Append( " " );
|
1213 |
sb.Append( " " );
|
| 1200 |
sb.Append( theParam.Name );
|
1214 |
sb.Append( theParam.Name );
|
| 1201 |
if (theParam.Default.Length > 0)
|
1215 |
if (theParam.Default.Length > 0)
|
| 1202 |
{
|
1216 |
{
|
| Line 1350... |
Line 1364... |
| 1350 |
// <type> <name>
|
1364 |
// <type> <name>
|
| 1351 |
sb.Append("\n");
|
1365 |
sb.Append("\n");
|
| 1352 |
sb.Append(theAttr.Type);
|
1366 |
sb.Append(theAttr.Type);
|
| 1353 |
sb.Append(" ");
|
1367 |
sb.Append(" ");
|
| 1354 |
sb.Append(theAttr.Name);
|
1368 |
sb.Append(theAttr.Name);
|
| 1355 |
Word.Range wr = TextualContent.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1);
|
1369 |
Range wr = TextualContent.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1);
|
| 1356 |
if (wr.Characters.Last.Text.Equals("\r"))
|
1370 |
if (wr.Characters.Last.Text.Equals("\r"))
|
| 1357 |
wr.End = wr.End - 1; // Dont boldise the \r paragraph marker
|
1371 |
wr.End = wr.End - 1; // Dont boldise the \r paragraph marker
|
| 1358 |
wr.Font.Bold = 1;
|
1372 |
wr.Font.Bold = 1;
|
| 1359 |
|
1373 |
|
| 1360 |
wr = TextualContent.appendDescription(TextualContent.trimTrailingReturns(theAttr.Notes));
|
1374 |
wr = TextualContent.appendDescription(TextualContent.trimTrailingReturns(theAttr.Notes));
|
| Line 1504... |
Line 1518... |
| 1504 |
|
1518 |
|
| 1505 |
|
1519 |
|
| 1506 |
private void generateClassCharacteristics( EA.Element theElement, int recurse_level )
|
1520 |
private void generateClassCharacteristics( EA.Element theElement, int recurse_level )
|
| 1507 |
{
|
1521 |
{
|
| 1508 |
StringBuilder sb = null;
|
1522 |
StringBuilder sb = null;
|
| 1509 |
Word.Range wr = null;
|
1523 |
Range wr = null;
|
| 1510 |
|
1524 |
|
| 1511 |
// CHARACTERISTICS
|
1525 |
// CHARACTERISTICS
|
| 1512 |
if (EA_DocGenOptions.optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_CLASS_CHARACTERISTICS) == false)
|
1526 |
if (EA_DocGenOptions.optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_CLASS_CHARACTERISTICS) == false)
|
| 1513 |
{
|
1527 |
{
|
| 1514 |
sb = new StringBuilder();
|
1528 |
sb = new StringBuilder();
|
| Line 1583... |
Line 1597... |
| 1583 |
if (EA_DocGenOptions.optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_CLASS_REQUIREMENTS) == false)
|
1597 |
if (EA_DocGenOptions.optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_CLASS_REQUIREMENTS) == false)
|
| 1584 |
{
|
1598 |
{
|
| 1585 |
StringBuilder sb = new StringBuilder();
|
1599 |
StringBuilder sb = new StringBuilder();
|
| 1586 |
|
1600 |
|
| 1587 |
sb.Append( "Requirements:" );
|
1601 |
sb.Append( "Requirements:" );
|
| 1588 |
Word.Range wr = TextualContent.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_2_5cm_Italic);
|
1602 |
Range wr = TextualContent.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_2_5cm_Italic);
|
| 1589 |
|
1603 |
|
| 1590 |
foreach(EA.Requirement theReq in theElement.Requirements)
|
1604 |
foreach(EA.Requirement theReq in theElement.Requirements)
|
| 1591 |
{
|
1605 |
{
|
| 1592 |
if (abortCreationThread)
|
1606 |
if (abortCreationThread)
|
| 1593 |
return;
|
1607 |
return;
|
| Line 1612... |
Line 1626... |
| 1612 |
if (EA_DocGenOptions.optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_CLASS_CONSTRAINTS) == false)
|
1626 |
if (EA_DocGenOptions.optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_CLASS_CONSTRAINTS) == false)
|
| 1613 |
{
|
1627 |
{
|
| 1614 |
StringBuilder sb = new StringBuilder();
|
1628 |
StringBuilder sb = new StringBuilder();
|
| 1615 |
|
1629 |
|
| 1616 |
sb.Append( "Constraints:" );
|
1630 |
sb.Append( "Constraints:" );
|
| 1617 |
Word.Range wr = TextualContent.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_2_5cm_Italic);
|
1631 |
Range wr = TextualContent.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1_Left_2_5cm_Italic);
|
| 1618 |
|
1632 |
|
| 1619 |
foreach(EA.Constraint theCons in theElement.Constraints)
|
1633 |
foreach(EA.Constraint theCons in theElement.Constraints)
|
| 1620 |
{
|
1634 |
{
|
| 1621 |
if (abortCreationThread)
|
1635 |
if (abortCreationThread)
|
| 1622 |
return;
|
1636 |
return;
|
| Line 1767... |
Line 1781... |
| 1767 |
/// prior to adding in the new content from the latest EA model data.
|
1781 |
/// prior to adding in the new content from the latest EA model data.
|
| 1768 |
/// </summary>
|
1782 |
/// </summary>
|
| 1769 |
private void removeExistingDocumentContent()
|
1783 |
private void removeExistingDocumentContent()
|
| 1770 |
{
|
1784 |
{
|
| 1771 |
//WordApp.Visible = true; // enable this when debugging this horrible function
|
1785 |
//WordApp.Visible = true; // enable this when debugging this horrible function
|
| 1772 |
Word.Selection aSelection;
|
1786 |
Selection aSelection;
|
| 1773 |
object findStyle = StyleContent.getStyle( EA_Constants.styleName_Heading1 );
|
1787 |
object findStyle = StyleContent.getStyle( EA_Constants.styleName_Heading1 );
|
| 1774 |
|
1788 |
|
| 1775 |
WordApp.Selection.WholeStory();
|
1789 |
WordApp.Selection.WholeStory();
|
| 1776 |
aSelection = WordApp.Selection;
|
1790 |
aSelection = WordApp.Selection;
|
| 1777 |
|
1791 |
|
| Line 1796... |
Line 1810... |
| 1796 |
{
|
1810 |
{
|
| 1797 |
// found Introduction with Heading 1 style so we are now at the point in the
|
1811 |
// found Introduction with Heading 1 style so we are now at the point in the
|
| 1798 |
// document where everything here on must be deleted in readiness for the newly
|
1812 |
// document where everything here on must be deleted in readiness for the newly
|
| 1799 |
// generated content. Extend the range to the end of the document and cut out the
|
1813 |
// generated content. Extend the range to the end of the document and cut out the
|
| 1800 |
// old content.
|
1814 |
// old content.
|
| 1801 |
Word.Range range = aSelection.Range;
|
1815 |
Range range = aSelection.Range;
|
| 1802 |
range.End = WordDocument.Content.End;
|
1816 |
range.End = WordDocument.Content.End;
|
| 1803 |
range.Cut();
|
1817 |
range.Cut();
|
| 1804 |
// try and ensure that no heading style is left in place following the removal
|
1818 |
// try and ensure that no heading style is left in place following the removal
|
| 1805 |
object style = EA_Constants.styleName_Body1;
|
1819 |
object style = EA_Constants.styleName_Body1;
|
| 1806 |
range.set_Style(ref style);
|
1820 |
range.set_Style(ref style);
|
| Line 2020... |
Line 2034... |
| 2020 |
Main.threadCreateDocProcessRunning = true;
|
2034 |
Main.threadCreateDocProcessRunning = true;
|
| 2021 |
|
2035 |
|
| 2022 |
// capture initial security settings
|
2036 |
// capture initial security settings
|
| 2023 |
MsoAutomationSecurity securityBefore = WordApp.AutomationSecurity;
|
2037 |
MsoAutomationSecurity securityBefore = WordApp.AutomationSecurity;
|
| 2024 |
|
2038 |
|
| 2025 |
button_generate.Enabled = false;
|
- |
|
| 2026 |
button_browse_output_file.Enabled = false;
|
- |
|
| 2027 |
button_browse_template.Enabled = false;
|
- |
|
| 2028 |
textBox_output_file.Enabled = false;
|
- |
|
| 2029 |
textBox_template.Enabled = false;
|
- |
|
| 2030 |
checkBox_WordVisibility.Enabled = false;
|
- |
|
| 2031 |
|
2039 |
|
| 2032 |
try
|
2040 |
try
|
| 2033 |
{
|
2041 |
{
|
| 2034 |
object template = this.textBox_template.Text;
|
2042 |
object template = this.textBox_template.Text;
|
| 2035 |
object newTemplate = Type.Missing;
|
2043 |
object newTemplate = Type.Missing;
|
| Line 2047... |
Line 2055... |
| 2047 |
// control word visibility based on checkbox user can modify
|
2055 |
// control word visibility based on checkbox user can modify
|
| 2048 |
WordApp.Visible = this.checkBox_WordVisibility.Checked;
|
2056 |
WordApp.Visible = this.checkBox_WordVisibility.Checked;
|
| 2049 |
|
2057 |
|
| 2050 |
// disable VB macros from running in the document
|
2058 |
// disable VB macros from running in the document
|
| 2051 |
WordApp.AutomationSecurity = MsoAutomationSecurity.msoAutomationSecurityForceDisable;
|
2059 |
WordApp.AutomationSecurity = MsoAutomationSecurity.msoAutomationSecurityForceDisable;
|
| 2052 |
WordApp.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;
|
2060 |
WordApp.DisplayAlerts = WdAlertLevel.wdAlertsNone;
|
| 2053 |
|
2061 |
|
| 2054 |
// Create a document from the input template
|
2062 |
// Create a document from the input template
|
| 2055 |
Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Creating new document based on template", -1);
|
2063 |
Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Creating new document based on template", -1);
|
| 2056 |
WordDocument = WordApp.Documents.Add(ref template, ref newTemplate, ref docType, ref visible);
|
2064 |
WordDocument = WordApp.Documents.Add(ref template, ref newTemplate, ref docType, ref visible);
|
| 2057 |
|
2065 |
|
| Line 2134... |
Line 2142... |
| 2134 |
ref nothing, ref nothing, ref nothing, ref nothing,
|
2142 |
ref nothing, ref nothing, ref nothing, ref nothing,
|
| 2135 |
ref nothing, ref nothing, ref nothing, ref nothing,
|
2143 |
ref nothing, ref nothing, ref nothing, ref nothing,
|
| 2136 |
ref nothing, ref nothing, ref nothing, ref nothing,
|
2144 |
ref nothing, ref nothing, ref nothing, ref nothing,
|
| 2137 |
ref nothing, ref nothing, ref nothing);
|
2145 |
ref nothing, ref nothing, ref nothing);
|
| 2138 |
|
2146 |
|
| 2139 |
object noSave = Word.WdSaveOptions.wdDoNotSaveChanges;
|
2147 |
object noSave = WdSaveOptions.wdDoNotSaveChanges;
|
| 2140 |
object format = Word.WdOriginalFormat.wdWordDocument;
|
2148 |
object format = WdOriginalFormat.wdWordDocument;
|
| 2141 |
WordDocument.Close(ref noSave, ref format, ref nothing);
|
2149 |
((_Document)WordDocument).Close(ref noSave, ref format, ref nothing);
|
| 2142 |
|
2150 |
|
| 2143 |
if (!abortCreationThread)
|
2151 |
if (!abortCreationThread)
|
| 2144 |
{
|
2152 |
{
|
| 2145 |
Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Updating Fields and Saving Document", -1);
|
2153 |
Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Updating Fields and Saving Document", -1);
|
| 2146 |
// Re-load the document to update the fields. For some as yet unknown reason, doing this
|
2154 |
// Re-load the document to update the fields. For some as yet unknown reason, doing this
|
| Line 2155... |
Line 2163... |
| 2155 |
ref nothing, ref nothing, ref nothing);
|
2163 |
ref nothing, ref nothing, ref nothing);
|
| 2156 |
|
2164 |
|
| 2157 |
// Tell user the process completed ok
|
2165 |
// Tell user the process completed ok
|
| 2158 |
Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Document Generation Complete", -1);
|
2166 |
Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Document Generation Complete", -1);
|
| 2159 |
docGenCompletedNormally = true;
|
2167 |
docGenCompletedNormally = true;
|
| 2160 |
button_view_output.Enabled = true;
|
2168 |
ThreadComplete(EThreadCompleteStatus.tcsComplete);
|
| 2161 |
}
|
2169 |
}
|
| 2162 |
}
|
2170 |
}
|
| 2163 |
else
|
2171 |
else
|
| 2164 |
{
|
2172 |
{
|
| 2165 |
Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Document Generation Aborted", -1);
|
2173 |
Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Document Generation Aborted", -1);
|
| Line 2184... |
Line 2192... |
| 2184 |
// we can mark the thread as not running since from now on we do not want to do anything with the
|
2192 |
// we can mark the thread as not running since from now on we do not want to do anything with the
|
| 2185 |
// WordApp or WordDocument objects and their destruction wont cause any ill effects.
|
2193 |
// WordApp or WordDocument objects and their destruction wont cause any ill effects.
|
| 2186 |
Main.threadCreateDocProcessRunning = false;
|
2194 |
Main.threadCreateDocProcessRunning = false;
|
| 2187 |
|
2195 |
|
| 2188 |
if (mustClose)
|
2196 |
if (mustClose)
|
| - |
|
2197 |
ThreadComplete(EThreadCompleteStatus.tcsClose);
|
| - |
|
2198 |
}
|
| - |
|
2199 |
|
| - |
|
2200 |
public enum EThreadCompleteStatus
|
| - |
|
2201 |
{
|
| - |
|
2202 |
tcsComplete,
|
| 2189 |
this.Close();
|
2203 |
tcsClose
|
| 2190 |
}
|
2204 |
}
|
| 2191 |
|
2205 |
|
| - |
|
2206 |
public delegate void ThreadCompleteDelegate(EThreadCompleteStatus Status);
|
| 2192 |
|
2207 |
|
| - |
|
2208 |
private void ThreadComplete(EThreadCompleteStatus Status)
|
| - |
|
2209 |
{
|
| - |
|
2210 |
// Ensure form access is thread safe
|
| - |
|
2211 |
|
| - |
|
2212 |
if (this.InvokeRequired)
|
| - |
|
2213 |
{
|
| - |
|
2214 |
this.Invoke(new ThreadCompleteDelegate(ThreadComplete), new object[] { Status });
|
| - |
|
2215 |
}
|
| - |
|
2216 |
else
|
| - |
|
2217 |
{
|
| - |
|
2218 |
if (Status == EThreadCompleteStatus.tcsComplete)
|
| - |
|
2219 |
{
|
| - |
|
2220 |
button_view_output.Enabled = true;
|
| - |
|
2221 |
}
|
| - |
|
2222 |
else if (Status == EThreadCompleteStatus.tcsClose)
|
| - |
|
2223 |
{
|
| - |
|
2224 |
this.Close();
|
| - |
|
2225 |
}
|
| - |
|
2226 |
}
|
| - |
|
2227 |
}
|
| 2193 |
|
2228 |
|
| 2194 |
|
2229 |
|
| 2195 |
#endregion
|
2230 |
#endregion
|
| 2196 |
|
2231 |
|
| 2197 |
|
2232 |
|