Subversion Repositories DevTools

Rev

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

Rev 2092 Rev 2094
Line 1... Line 1...
1
using System;
1
using System;
2
using System.Drawing;
2
using System.Drawing;
3
using System.Collections;
3
using System.Collections;
-
 
4
using System.Text;
4
using System.ComponentModel;
5
using System.ComponentModel;
5
using System.Windows.Forms;
6
using System.Windows.Forms;
6
using Word;
7
using Word;
7
using Microsoft.Office.Core;
8
using Microsoft.Office.Core;
8
 
9
 
Line 18... Line 19...
18
   {
19
   {
19
      // Enterprise Architect Model related data
20
      // Enterprise Architect Model related data
20
      private EA.Repository EA_Repository = null;
21
      private EA.Repository EA_Repository = null;
21
      private EA.Package EA_ParentPackage = null;
22
      private EA.Package EA_ParentPackage = null;
22
      private EA.Project EA_Project;
23
      private EA.Project EA_Project;
23
      
24
 
24
      private EA_Utilities EA_Utils = null;
25
      private EA_Utilities EA_Utils = null;
25
 
26
 
-
 
27
      private TabularContent TableUtils = null;
-
 
28
      private TextualContent TextUtils = null;
-
 
29
      private StyleContent   StyleUtils = null;
-
 
30
 
26
      private bool oneShot_skipRootPackage = false;
31
      private bool oneShot_skipRootPackage = false;
-
 
32
      private bool oneShot_skipRootElementHeading = false;
-
 
33
 
-
 
34
      // This data is designed to support unit test traceability. As such, it is only of real use
-
 
35
      // when making s/w design documents. It allows all non-private classes to be collected into
-
 
36
      // a list in order to generate a design-to-unit-test traceability table.
-
 
37
      private bool recordingNonPrivateClasses = false;
-
 
38
      private ArrayList nonPrivateClasses = null;
-
 
39
      private ArrayList classesWithUnitTests = null;
-
 
40
      private Word.Table utTraceabilityTable = null;
27
 
41
 
28
      // MS-Office Word related data
42
      // MS-Office Word related data
29
      private Word.Application WordApp = null;
43
      private Word.Application WordApp = null;
30
      private Word.Document WordDocument = null;
44
      private Word.Document WordDocument = null;
31
      private Word.Range WordRange;
-
 
32
      private object startLocation;
-
 
33
      private object endLocation;
-
 
34
      
45
 
35
      private int[] DocSection = null;
46
      private int[] DocSection = null;
36
      private int   iDocSection = 0;
47
      private int   iDocSection = 0;
37
 
48
 
38
      // Some style names used in EA_DocGen - most are expected to exist in the input template/doc
-
 
39
      // but the Requirement formatting styles are programmatcally generated if they are found to not
-
 
40
      // exist. The reason for this is that as of writing this add-in, they do not exist in the ERG
-
 
41
      // standard template.
-
 
42
      private const string styleName_ReqAppBody  = "Requirements Approved Body";
-
 
43
      private const string styleName_ReqAppHdr   = "Requirements Approved Heading";
-
 
44
      private const string styleName_ReqPropBody = "Requirements Proposed Body";
-
 
45
      private const string styleName_ReqPropHdr  = "Requirements Proposed Heading";
-
 
46
      private const string styleName_ReqRejBody  = "Requirements Rejected Body";
-
 
47
      private const string styleName_ReqRejHdr   = "Requirements Rejected Heading";
-
 
48
      private const string styleName_ReqName     = "Requirements Name";
-
 
49
      private const string styleName_Body1       = "Body 1";
-
 
50
      private const string styleName_Heading1    = "Heading 1";
-
 
51
      private const string styleName_Heading2    = "Heading 2";
-
 
52
      private const string styleName_Heading3    = "Heading 3";
-
 
53
      private const string styleName_Heading4    = "Heading 4";
-
 
54
      private const string styleName_Heading5    = "Heading 5";
-
 
55
      private const string styleName_Heading6    = "Heading 6";
-
 
56
      private const string styleName_Heading7    = "Heading 7";
-
 
57
      private const string styleName_Heading8    = "Heading 8";
-
 
58
      private const string styleName_Heading9    = "Heading 9";
-
 
59
      private const string styleName_NumPara1    = "NumPara 1";
-
 
60
      private const string styleName_NumPara2    = "NumPara 2";
-
 
61
      private const string styleName_NumPara3    = "NumPara 3";
-
 
62
      private const string styleName_NumPara4    = "NumPara 4";
-
 
63
      private const string styleName_NumPara5    = "NumPara 5";
-
 
64
      private const string styleName_NumPara6    = "NumPara 6";
-
 
65
      private const string styleName_NumPara7    = "NumPara 7";
-
 
66
      private const string styleName_NumPara8    = "NumPara 8";
-
 
67
      private const string styleName_NumPara9    = "NumPara 9";
-
 
68
      private const string styleName_TableText   = "Table Text";
-
 
69
      private const string styleName_RefListNum  = "Reference List Number";
-
 
70
      private const string styleName_RefListText = "Reference List Text";
-
 
71
      private const string styleName_Normal      = "Normal";
-
 
72
 
-
 
73
 
-
 
74
      private System.Windows.Forms.TextBox textBox_template;
49
      private System.Windows.Forms.TextBox textBox_template;
75
      private System.Windows.Forms.Button button_browse_template;
50
      private System.Windows.Forms.Button button_browse_template;
76
      private System.Windows.Forms.TextBox textBox_output_file;
51
      private System.Windows.Forms.TextBox textBox_output_file;
77
      private System.Windows.Forms.Button button_browse_output_file;
52
      private System.Windows.Forms.Button button_browse_output_file;
78
      private System.Windows.Forms.Button button_cancel;
53
      private System.Windows.Forms.Button button_cancel;
Line 99... Line 74...
99
         EA_ParentPackage = theParentPackage;
74
         EA_ParentPackage = theParentPackage;
100
         EA_Project       = EA_Repository.GetProjectInterface();
75
         EA_Project       = EA_Repository.GetProjectInterface();
101
 
76
 
102
         EA_Utils         = theEA_Utils;
77
         EA_Utils         = theEA_Utils;
103
 
78
 
-
 
79
         TableUtils       = new TabularContent(WordApp, WordDocument);
-
 
80
         TextUtils        = new TextualContent(WordApp, WordDocument);
-
 
81
         StyleUtils       = new StyleContent(WordApp, WordDocument);
-
 
82
 
-
 
83
 
104
         DocSection = new int[12];
84
         DocSection = new int[12];
105
         for (int i=0; i<DocSection.Length; i++)
85
         for (int i=0; i<DocSection.Length; i++)
106
         {
86
         {
107
            DocSection[i] = 0;
87
            DocSection[i] = 0;
108
         }
88
         }
109
 
89
 
110
         WordApp = new Word.Application();
90
         WordApp = new Word.Application();
111
      }
91
      }
112
 
92
 
-
 
93
 
113
      /// <summary>
94
      /// <summary>
114
      /// Clean up any resources being used.
95
      /// Clean up any resources being used.
115
      /// </summary>
96
      /// </summary>
116
      protected override void Dispose( bool disposing )
97
      protected override void Dispose( bool disposing )
117
      {
98
      {
Line 284... Line 265...
284
      {
265
      {
285
         if (WordApp != null)
266
         if (WordApp != null)
286
         {
267
         {
287
            WordApp.Visible = true;
268
            WordApp.Visible = true;
288
         }
269
         }
-
 
270
         button_view_output.Enabled = false;
289
      }
271
      }
290
 
272
 
291
 
273
 
292
 
274
 
293
 
275
 
Line 295... Line 277...
295
      {
277
      {
296
         if (this.textBox_template.Text.Length > 0)
278
         if (this.textBox_template.Text.Length > 0)
297
         {
279
         {
298
            if (this.textBox_output_file.Text.Length > 0)
280
            if (this.textBox_output_file.Text.Length > 0)
299
            {
281
            {
-
 
282
               button_generate.Enabled = false;
300
               createTheWordDoc();
283
               createTheWordDoc();
301
            }
284
            }
302
            else
285
            else
303
            {
286
            {
304
               MessageBox.Show("Error - must specify an output file");
287
               MessageBox.Show("Error - must specify an output file");
Line 384... Line 367...
384
      {
367
      {
385
         public ArrayList Elements = null;
368
         public ArrayList Elements = null;
386
 
369
 
387
         private ArrayList validElementTypes = null;
370
         private ArrayList validElementTypes = null;
388
 
371
 
-
 
372
         private EA_Utilities EA_Utils = null;
-
 
373
 
389
         public ElementAccumulator(ArrayList elementTypeList): base()
374
         public ElementAccumulator(ArrayList elementTypeList, EA_Utilities theEA_Utils): base()
390
         {
375
         {
391
            validElementTypes = elementTypeList;
376
            validElementTypes = elementTypeList;
-
 
377
            EA_Utils = theEA_Utils;
392
            Elements = new ArrayList();
378
            Elements = new ArrayList();
393
         }
379
         }
394
 
380
 
395
         public override void processElement( EA.Element theElement )
381
         public override void processElement( EA.Element theElement )
396
         {
382
         {
397
            if (validElementTypes.Contains( theElement.Type ))
383
            if (validElementTypes.Contains( theElement.Type ))
398
            {
384
            {
399
               if ( (theElement.Type == "Requirement") && (theElement.Status == "Rejected") )
385
               //if ( (theElement.Type == "Requirement") && (theElement.Status == "Rejected") )
400
                  return;
386
               //   return;
401
 
387
 
-
 
388
               if (   0 == theElement.Type.CompareTo("Class")
-
 
389
                  && true == EA_Utils.options.opt_SuppressPrivateClasses
-
 
390
                  && true == theElement.Visibility.StartsWith("Private") )
-
 
391
               {
-
 
392
                  // do nothing
-
 
393
               }
-
 
394
               else
402
               Elements.Add( theElement );
395
                  Elements.Add( theElement );
403
            }
396
            }
404
         }
397
         }
405
      }
398
      }
406
 
399
 
407
 
400
 
Line 422... Line 415...
422
      private void displayProgress(string prefix, string EA_string)
415
      private void displayProgress(string prefix, string EA_string)
423
      {
416
      {
424
         textBox_progress.AppendText( prefix + EA_string + "\r\n" );
417
         textBox_progress.AppendText( prefix + EA_string + "\r\n" );
425
 
418
 
426
         // Display to the output tab as well - as a longer term record of what happened
419
         // Display to the output tab as well - as a longer term record of what happened
427
         string s = "";
420
         StringBuilder sb = new StringBuilder("");
428
         for (int i = 1; i<=iDocSection; i++)
421
         for (int i = 1; i<=iDocSection; i++)
429
         {
422
         {
430
            if (i!=1)
423
            if (i!=1)
431
               s = s + ".";
424
               sb.Append(".");
432
            s = s + DocSection[i].ToString();
425
            sb.Append(DocSection[i].ToString());
433
         }
426
         }
434
         while (s.Length < 30)
427
         while (sb.Length < 30)
435
            s += " ";
428
            sb.Append(" ");
436
 
429
 
-
 
430
         sb.Append(prefix);
-
 
431
         sb.Append(EA_string);
-
 
432
 
437
         EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, s + prefix + EA_string, 0);
433
         EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, sb.ToString(), 0);
438
      }
434
      }
439
 
435
 
440
 
436
 
441
      /// <summary>
437
      /// <summary>
442
      /// This method takes the specified EA diagram element and puts the diagram image
438
      /// This method takes the specified EA diagram element and puts the diagram image
Line 447... Line 443...
447
      private void appendAndSelectDiagramViaClipboard(EA.Diagram theDiagram)
443
      private void appendAndSelectDiagramViaClipboard(EA.Diagram theDiagram)
448
      {
444
      {
449
         // open the diagram in EA and copy it's image to the clipboard
445
         // open the diagram in EA and copy it's image to the clipboard
450
         if (EA_Project.PutDiagramImageOnClipboard(theDiagram.DiagramGUID,0))
446
         if (EA_Project.PutDiagramImageOnClipboard(theDiagram.DiagramGUID,0))
451
         {
447
         {
-
 
448
            object startLocation;
-
 
449
            object endLocation;
-
 
450
 
452
            // create a range at the end of the document
451
            // create a range at the end of the document
453
            startLocation = WordDocument.Content.End;
452
            startLocation = WordDocument.Content.End;
454
            WordDocument.Content.InsertParagraphAfter();
453
            WordDocument.Content.InsertParagraphAfter();
455
            endLocation = WordDocument.Content.End;
454
            endLocation = WordDocument.Content.End;
456
            WordRange = WordDocument.Range(ref startLocation, ref endLocation);
455
            Word.Range WordRange = WordDocument.Range(ref startLocation, ref endLocation);
457
            object direction = Word.WdCollapseDirection.wdCollapseEnd;
456
            object direction = Word.WdCollapseDirection.wdCollapseEnd;
458
            WordRange.Collapse(ref direction);  // collapse prevents existing content being replaced
457
            WordRange.Collapse(ref direction);  // collapse prevents existing content being replaced
459
 
458
 
460
            // Get ready for the diagram paste and the formatting we want to do on it with the
459
            // Get ready for the diagram paste and the formatting we want to do on it with the
461
            // selection object.
460
            // selection object.
462
            SelectInsertionPointAtEndOfDocument();
461
            TextUtils.SelectInsertionPointAtEndOfDocument();
463
 
462
 
464
            // Paste the diagram into the document
463
            // Paste the diagram into the document
465
            WordRange.Paste();           
464
            WordRange.Paste();           
466
 
465
 
467
            // Set style of the diagram to "Normal" so that it can occupy space all the way to the left margin
466
            // Set style of the diagram to "Normal" so that it can occupy space all the way to the left margin
468
            object l_style = styleName_Normal;
467
            object l_style = EA_Constants.styleName_Normal;
469
            endLocation = WordDocument.Content.End;
468
            endLocation = WordDocument.Content.End;
470
            WordRange = WordDocument.Range(ref startLocation, ref endLocation);
469
            WordRange = WordDocument.Range(ref startLocation, ref endLocation);
471
            WordRange.set_Style(ref l_style);
470
            WordRange.set_Style(ref l_style);
472
            
471
            
473
            // Center the diagram on the page
472
            // Center the diagram on the page
Line 477... Line 476...
477
            WordApp.Selection.MoveDown( ref unit, ref count, ref missing);
476
            WordApp.Selection.MoveDown( ref unit, ref count, ref missing);
478
            WordApp.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
477
            WordApp.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
479
 
478
 
480
            // Add a caption
479
            // Add a caption
481
            WordDocument.Content.InsertParagraphAfter();
480
            WordDocument.Content.InsertParagraphAfter();
482
            SelectInsertionPointAtEndOfDocument();         
481
            TextUtils.SelectInsertionPointAtEndOfDocument();         
483
            object Label = "Figure";
482
            object Label = "Figure";
484
            object Title = Type.Missing;
483
            object Title = Type.Missing;
485
            object TitleAutoText = Type.Missing;
484
            object TitleAutoText = Type.Missing;
486
            object Position = Word.WdCaptionPosition.wdCaptionPositionAbove;
485
            object Position = Word.WdCaptionPosition.wdCaptionPositionAbove;
487
            object ExcludeLabel = 0;
486
            object ExcludeLabel = 0;
Line 499... Line 498...
499
            // Close the diagram in EA
498
            // Close the diagram in EA
500
            EA_Repository.CloseDiagram(theDiagram.DiagramID);
499
            EA_Repository.CloseDiagram(theDiagram.DiagramID);
501
         }
500
         }
502
      }
501
      }
503
 
502
 
504
 
-
 
505
      /// <summary>
-
 
506
      /// Appends a specified text string to the word document, selects the new text, and applies
-
 
507
      /// the specified style formatting to it.
-
 
508
      /// </summary>
-
 
509
      /// <param name="wordText"></param>
-
 
510
      /// <param name="styleText"></param>
-
 
511
      /// <param name="continuation"></param>
-
 
512
      private void appendAndSelectText(string wordText, string styleText) 
-
 
513
      { 
-
 
514
         appendAndSelectText(wordText, styleText, false );
-
 
515
      }
-
 
516
 
-
 
517
      private void appendAndSelectText(string wordText, string styleText, bool continuation )
-
 
518
      {
-
 
519
         if (wordText.Length > 0)
-
 
520
         {
-
 
521
            object style = styleText;
-
 
522
            int i;
-
 
523
            startLocation = 0;
-
 
524
            endLocation = i = WordDocument.Content.End;
-
 
525
 
-
 
526
            WordRange = WordDocument.Range(ref startLocation, ref endLocation);
-
 
527
 
-
 
528
            if (!continuation)
-
 
529
               WordRange.InsertAfter( "\n" );
-
 
530
            
-
 
531
            WordRange.InsertAfter( wordText );
-
 
532
 
-
 
533
            // Make a range out of the pasted text
-
 
534
            startLocation = i;
-
 
535
            endLocation = WordDocument.Content.End;
-
 
536
            WordRange = WordDocument.Range(ref startLocation, ref endLocation);
-
 
537
 
-
 
538
            // and set the pasted text style
-
 
539
            WordRange.set_Style(ref style);
-
 
540
         }
-
 
541
      }
-
 
542
   
-
 
543
 
-
 
544
      /// <summary>
-
 
545
      /// Appends a specified text string to the word document, selects the new text, and applies
-
 
546
      /// a heading level style to it. 
-
 
547
      /// </summary>
-
 
548
      /// <param name="wordText"></param>
-
 
549
      /// <param name="level"></param>
-
 
550
      private void appendAndSelectHeadingText(string wordText, int level)
-
 
551
      {
-
 
552
         // Convert level to heading style
-
 
553
         string styleText;
-
 
554
         switch(level)
-
 
555
         {
-
 
556
            case 1: styleText = styleName_Heading1; break;
-
 
557
            case 2: styleText = styleName_Heading2; break;
-
 
558
            case 3: styleText = styleName_Heading3; break;
-
 
559
            case 4: styleText = styleName_Heading4; break;
-
 
560
            case 5: styleText = styleName_Heading5; break;
-
 
561
            case 6: styleText = styleName_Heading6; break;
-
 
562
            case 7: styleText = styleName_Heading7; break;
-
 
563
            case 8: styleText = styleName_Heading8; break;
-
 
564
            case 9: styleText = styleName_Heading9; break;
-
 
565
            default: styleText = styleName_Heading9; break;
-
 
566
         }
-
 
567
         // append the text as a heading
-
 
568
         appendAndSelectText(wordText, styleText);
-
 
569
      }
-
 
570
 
503
 
571
 
-
 
572
      /// <summary>
-
 
573
      /// Appends a specified text string to the word document, selects the new text, and applies
504
      #region special element processing functions (link elements, table and text elements, etc)
574
      /// a num para heading level style to it. 
-
 
575
      /// </summary>
-
 
576
      /// <param name="wordText"></param>
-
 
577
      /// <param name="level"></param>
-
 
578
      private void appendAndSelectNumParaText(string wordText, int level)
-
 
579
      {
-
 
580
         // Convert level to heading style
-
 
581
         string styleText;
-
 
582
         switch(level)
-
 
583
         {
-
 
584
            case 1: styleText = styleName_NumPara1; break;
-
 
585
            case 2: styleText = styleName_NumPara2; break;
-
 
586
            case 3: styleText = styleName_NumPara3; break;
-
 
587
            case 4: styleText = styleName_NumPara4; break;
-
 
588
            case 5: styleText = styleName_NumPara5; break;
-
 
589
            case 6: styleText = styleName_NumPara6; break;
-
 
590
            case 7: styleText = styleName_NumPara7; break;
-
 
591
            case 8: styleText = styleName_NumPara8; break;
-
 
592
            case 9: styleText = styleName_NumPara9; break;
-
 
593
            default: styleText = styleName_NumPara9; break;
-
 
594
         }
-
 
595
         // append the text as a heading
-
 
596
         appendAndSelectText(wordText, styleText);
-
 
597
      }
-
 
598
 
-
 
599
 
-
 
600
      private void SelectInsertionPointAtEndOfDocument()
-
 
601
      {
-
 
602
         object unit; 
-
 
603
         object extend;
-
 
604
 
-
 
605
         unit = Word.WdUnits.wdStory; 
-
 
606
         extend = Word.WdMovementType.wdMove;
-
 
607
         WordApp.Selection.EndKey(ref unit, ref extend);
-
 
608
      }
-
 
609
 
-
 
610
 
-
 
611
      /// <summary>
505
      /// <summary>
612
      /// This is an attempt to create a table similar in style to those made by the ERG doc template macros.
506
      /// This is an attempt to create a table similar in style to those made by the ERG doc template macros.
613
      /// It is not exaclty that same though, and further work could be done to align it more precisely.
507
      /// It is not exaclty that same though, and further work could be done to align it more precisely.
614
      /// </summary>
508
      /// </summary>
615
      /// <param name="tableTitle"></param>
509
      /// <param name="tableTitle"></param>
616
      /// <param name="numRows"></param>
510
      /// <param name="numRows"></param>
617
      /// <param name="numCols"></param>
511
      /// <param name="numCols"></param>
618
      /// <returns></returns>
512
      /// <returns></returns>
619
      private int createTable(string tableTitle, int numRows, int numCols)
-
 
620
      {
-
 
621
         WordDocument.Content.InsertParagraphAfter();
-
 
622
         SelectInsertionPointAtEndOfDocument();
-
 
623
         
-
 
624
         object Label = "Table";
-
 
625
         object Title = Type.Missing;
-
 
626
         object TitleAutoText = Type.Missing;
-
 
627
         object Position = Word.WdCaptionPosition.wdCaptionPositionAbove;
-
 
628
         object ExcludeLabel = 0;
-
 
629
         WordApp.Selection.InsertCaption( ref Label, ref Title, ref TitleAutoText, ref Position, ref ExcludeLabel);
-
 
630
         WordApp.Selection.TypeText( ": " + tableTitle);
-
 
631
         WordApp.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
-
 
632
        
-
 
633
         startLocation = WordDocument.Content.End;
-
 
634
         WordDocument.Content.InsertParagraphAfter();
-
 
635
         endLocation = WordDocument.Content.End;
-
 
636
         WordRange = WordDocument.Range(ref startLocation, ref endLocation);
-
 
637
 
-
 
638
         object defaultTableBehaviour = Type.Missing;
-
 
639
         object autofitBehaviour = Type.Missing;
-
 
640
         Word.Table Table = WordDocument.Tables.Add( WordRange, numRows, numCols, ref defaultTableBehaviour, ref autofitBehaviour );
-
 
641
 
-
 
642
         Table.Rows[1].Shading.BackgroundPatternColor = Word.WdColor.wdColorGray10;
-
 
643
         Table.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
-
 
644
         Table.Borders.InsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
-
 
645
 
-
 
646
         Table.Select();
-
 
647
         object tableTextStyle = styleName_TableText;
-
 
648
         Table.Range.set_Style( ref tableTextStyle );
-
 
649
 
-
 
650
         return WordDocument.Tables.Count;
-
 
651
      }
-
 
652
 
-
 
653
     
-
 
654
 
513
 
655
      /// <summary>
514
      /// <summary>
656
      /// This function process a package link element, parsing each linked package by the
515
      /// This function process a package link element, parsing each linked package by the
657
      /// parse_package() recursive function.
516
      /// parse_package() recursive function.
658
      /// </summary>
517
      /// </summary>
659
      /// <param name="theElement"></param>
518
      /// <param name="theElement"></param>
Line 750... Line 609...
750
         
609
         
751
         foreach(string s in EA_DocGenEleLnk)
610
         foreach(string s in EA_DocGenEleLnk)
752
         {
611
         {
753
            if (s.Length > 0 && s != "\n" && s != "\r")
612
            if (s.Length > 0 && s != "\n" && s != "\r")
754
            {
613
            {
-
 
614
               if (s == "skiproot")
-
 
615
               {
-
 
616
                  oneShot_skipRootElementHeading = true;
-
 
617
               }
755
               if ( s[0] == '{')
618
               else if ( s[0] == '{')
756
               {
619
               {
757
                  EA.Element theFoundElement = EA_Utils.EA_Finder.findElementInRepositoryByGUID(s);
620
                  EA.Element theFoundElement = EA_Utils.EA_Finder.findElementInRepositoryByGUID(s);
758
                  if (theFoundElement != null)
621
                  if (theFoundElement != null)
759
                  {
622
                  {
760
                     parse_element( theFoundElement, recurse_level );
623
                     parse_element( theFoundElement, recurse_level );
Line 849... Line 712...
849
               MessageBox.Show( "Table Element Serialisation Failed - Insufficient Rows" );
712
               MessageBox.Show( "Table Element Serialisation Failed - Insufficient Rows" );
850
            }
713
            }
851
            else
714
            else
852
            {
715
            {
853
               // create the table in the word doc
716
               // create the table in the word doc
854
               int tableNum = createTable( tableTitle, rowCount, columnCount );
717
               int tableNum = TableUtils.Table_Create( tableTitle, rowCount, columnCount );
855
               Word.Table table = WordDocument.Tables[tableNum];
718
               Word.Table table = WordDocument.Tables[tableNum];
856
               object center = Word.WdParagraphAlignment.wdAlignParagraphCenter;
719
               object center = Word.WdParagraphAlignment.wdAlignParagraphCenter;
857
 
720
 
858
               // scan the element notes again to extract the cell content and add it to the
721
               // scan the element notes again to extract the cell content and add it to the
859
               // table we just created.
722
               // table we just created.
Line 907... Line 770...
907
            MessageBox.Show( "Table Element Serialisation Failed - Table Parameters Incomplete" );
770
            MessageBox.Show( "Table Element Serialisation Failed - Table Parameters Incomplete" );
908
         }
771
         }
909
      }
772
      }
910
 
773
 
911
 
774
 
-
 
775
 
-
 
776
      /// <summary>
-
 
777
      /// This function processes a test link element
-
 
778
      /// </summary>
-
 
779
      /// <param name="theElement"></param>
-
 
780
      /// <param name="recurse_level"></param>
-
 
781
      private void processTestLink(EA.Element theElement, int recurse_level )
-
 
782
      {
-
 
783
         string [] EA_DocGenEleLnk = null;
-
 
784
         string delimStr = "\r\n";
-
 
785
         char [] delim = delimStr.ToCharArray();
-
 
786
         EA_DocGenEleLnk = theElement.Notes.ToString().Split(delim,100);
-
 
787
         string linkedName = "";
-
 
788
         
-
 
789
         foreach(string s in EA_DocGenEleLnk)
-
 
790
         {
-
 
791
            if (s.Length > 0 && s != "\n" && s != "\r")
-
 
792
            {
-
 
793
               if ( s[0] == '{')
-
 
794
               {
-
 
795
                  try
-
 
796
                  {
-
 
797
                     // try to find the GUID as a package
-
 
798
                     EA.Package theFoundPackage = EA_Utils.EA_Finder.findPackageInRepositoryByGUID(s);
-
 
799
                     if (theFoundPackage != null)
-
 
800
                        TextUtils.appendUnitTestSuite(theFoundPackage, recurse_level, ref classesWithUnitTests);
-
 
801
                     else 
-
 
802
                     {
-
 
803
                        // try to find the GUID as an element
-
 
804
                        EA.Element theFoundElement = EA_Utils.EA_Finder.findElementInRepositoryByGUID(s);
-
 
805
                        if (theFoundElement != null)
-
 
806
                           TextUtils.appendUnitTestSuite(theFoundElement, recurse_level, ref classesWithUnitTests);
-
 
807
                        else 
-
 
808
                           MessageBox.Show("WARNING - Could not find linked element : " + linkedName );
-
 
809
                     }
-
 
810
                  }
-
 
811
                  catch 
-
 
812
                  {
-
 
813
                     // try to find the GUID as an element
-
 
814
                     EA.Element theFoundElement = EA_Utils.EA_Finder.findElementInRepositoryByGUID(s);
-
 
815
                     if (theFoundElement != null)
-
 
816
                        TextUtils.appendUnitTestSuite(theFoundElement, recurse_level, ref classesWithUnitTests);
-
 
817
                     else 
-
 
818
                        MessageBox.Show("WARNING - Could not find linked element : " + linkedName );
-
 
819
                  }
-
 
820
               }
-
 
821
               else
-
 
822
               {
-
 
823
                  linkedName = s;
-
 
824
               }            
-
 
825
            }
-
 
826
         }         
-
 
827
      }
-
 
828
 
-
 
829
 
-
 
830
 
912
      /// <summary>
831
      /// <summary>
913
      /// This function process a text element. It is a simple wrapper for the 
832
      /// This function process a text element. It is a simple wrapper for the 
914
      /// appendAndSelectText()function.
833
      /// appendAndSelectText()function.
915
      /// </summary>
834
      /// </summary>
916
      /// <param name="theElement"></param>
835
      /// <param name="theElement"></param>
917
      /// <param name="recurse_level"></param>
836
      /// <param name="recurse_level"></param>
918
      private void processTextElement(EA.Element theElement, int recurse_level )
837
      private void processTextElement(EA.Element theElement, int recurse_level )
919
      {
838
      {
920
         appendAndSelectText( theElement.Notes.ToString(), styleName_Body1 );
839
         TextUtils.appendAndSelectText( theElement.Notes.ToString(), EA_Constants.styleName_Body1 );
921
      }
840
      }
922
 
841
 
923
 
842
 
-
 
843
      /// <summary>
-
 
844
      /// This function will insert a relationship matrix table into the document, built from content
-
 
845
      /// specified in options that are provided in the notes section of the special element that
-
 
846
      /// has led to this function being called.
-
 
847
      /// </summary>
-
 
848
      /// <param name="theElement"></param>
-
 
849
      /// <param name="recurse_level"></param>
-
 
850
      private void processRelationshipMatrixElement( EA.Element theElement, int recurse_level )
-
 
851
      {
-
 
852
         int tableNum = 0;
-
 
853
         Word.Table table = null;
-
 
854
 
-
 
855
         // process the options for the relationship matrix
-
 
856
         EA_RelationshipMatrix EA_RelMatrix = new EA_RelationshipMatrix(EA_Utils);
-
 
857
         if (!EA_RelMatrix.processRelationshipMatrixOptions( theElement ))
-
 
858
         {
-
 
859
            return;  // must have been an error
-
 
860
         }
-
 
861
 
-
 
862
         // Scan the fromPackage to find all the "from elements".
-
 
863
         ElementAccumulator fromLister = new ElementAccumulator(EA_RelMatrix.fromElementTypes, EA_Utils);
-
 
864
         EA_Utils.findAndProcessPackageElements( EA_RelMatrix.fromPackage, fromLister, EA_RelMatrix.fromPackageRecursion );
-
 
865
 
-
 
866
         // Sort the "from elements"
-
 
867
         elementSortByName sorter = new elementSortByName();
-
 
868
         fromLister.Elements.Sort( sorter );
-
 
869
 
-
 
870
         // dictionary to support from-to table construction.
-
 
871
         ArrayList fromToDictionary = new ArrayList();
-
 
872
 
-
 
873
         // dictionary to support to-from table construction.
-
 
874
         ArrayList toFromDictionary = new ArrayList();
-
 
875
         
-
 
876
         bool needFromToTable = false;
-
 
877
         if (EA_RelMatrix.fromToTableTitle != null && EA_RelMatrix.fromToTableTitle.Length > 0)
-
 
878
            needFromToTable = true;
-
 
879
 
-
 
880
         bool needToFromTable = false;
-
 
881
         if (EA_RelMatrix.toFromTableTitle != null && EA_RelMatrix.toFromTableTitle.Length > 0)
-
 
882
            needToFromTable = true;
-
 
883
 
-
 
884
         // NOTE: this code has to execute even if no from-to table is needed, in order to support the
-
 
885
         // generation of a to-from table, assuming the user has requested one.
-
 
886
         int numberOfFromToRows = 0;
-
 
887
         
-
 
888
         foreach(EA.Element fromElement in fromLister.Elements)
-
 
889
         {
-
 
890
            // look at the elements connection collection to find references to the
-
 
891
            // destination elements
-
 
892
            bool foundToElement = false;
-
 
893
 
-
 
894
            EA.Collection conCollection = fromElement.Connectors;
-
 
895
            
-
 
896
            foreach (EA.Connector thisCon in conCollection)
-
 
897
            {
-
 
898
               EA.Element destE = EA_Repository.GetElementByID( thisCon.SupplierID );
-
 
899
               if (destE == null)
-
 
900
                  continue;
-
 
901
 
-
 
902
               // ignore self-referential connections
-
 
903
               if (fromElement.ElementID == thisCon.SupplierID)
-
 
904
                  continue;
-
 
905
 
-
 
906
               // if the destination element is of a type that the user has requested to include...
-
 
907
               if (!EA_RelMatrix.toElementTypes.Contains( destE.Type ))
-
 
908
                  continue;
-
 
909
 
-
 
910
               // Capture the from-to relationship in a dictionary where the key is the
-
 
911
               // "from element", and the value is the "to element".
-
 
912
               DictionaryEntry newFromToEntry = new DictionaryEntry(fromElement, destE);
-
 
913
               fromToDictionary.Add( newFromToEntry );
-
 
914
               foundToElement = true;
-
 
915
 
-
 
916
               // Capture the from-to relationship in a dictionary where the key is the
-
 
917
               // ID of the destination element, and the value is the from element name.
-
 
918
               // This dictionary will enable rapid construction of the to-from table if
-
 
919
               // the user has requested it, from the exact same relationship info used
-
 
920
               // to construct the from-to table.
-
 
921
               if (needToFromTable)
-
 
922
               {
-
 
923
                  DictionaryEntry newToFromEntry = new DictionaryEntry(destE.ElementID, fromElement.Name);
-
 
924
                  toFromDictionary.Add( newToFromEntry );
-
 
925
               }
-
 
926
            }
-
 
927
 
-
 
928
            // If we found a from-to relationship that table needs a new row.
-
 
929
            if (foundToElement)
-
 
930
            {
-
 
931
               numberOfFromToRows++;
-
 
932
            }
-
 
933
               // If we did not find a from-to relationship that table still needs a new row 
-
 
934
               // if the user wants all "from elements", even if some have no "to elements".
-
 
935
            else if (EA_RelMatrix.fromPackageTrimming == false)
-
 
936
            {
-
 
937
               DictionaryEntry newFromToEntry = new DictionaryEntry(fromElement, null);
-
 
938
               fromToDictionary.Add( newFromToEntry );
-
 
939
               numberOfFromToRows++;
-
 
940
            }
-
 
941
         }
-
 
942
 
-
 
943
         
-
 
944
         if (needFromToTable)
-
 
945
         {
-
 
946
            // Now we can actually serialise the table
-
 
947
 
-
 
948
            if (EA_RelMatrix.fromIntroText != null && EA_RelMatrix.fromIntroText.Length > 0)
-
 
949
            {
-
 
950
               TextUtils.appendAndSelectText( EA_RelMatrix.fromIntroText, EA_Constants.styleName_Body1 );
-
 
951
            }
-
 
952
 
-
 
953
            // create the from-to table in the word doc
-
 
954
            tableNum = TableUtils.Table_Create( EA_RelMatrix.fromToTableTitle, numberOfFromToRows + 1, 2 );
-
 
955
            table = WordDocument.Tables[tableNum];
-
 
956
            
-
 
957
            TableUtils.Table_SetTableColumnTitle(table, EA_RelMatrix.fromColumnTitle, 1);
-
 
958
            TableUtils.Table_SetTableColumnTitle(table, EA_RelMatrix.toColumnTitle, 2);
-
 
959
 
-
 
960
            int row = 1;
-
 
961
            int lastFromElementId = -1;
-
 
962
            bool firstFromToCon = true;
-
 
963
            foreach (DictionaryEntry de in fromToDictionary)
-
 
964
            {
-
 
965
               if ( ((EA.Element)de.Key).ElementID != lastFromElementId )
-
 
966
               {
-
 
967
                  lastFromElementId = ((EA.Element)de.Key).ElementID;
-
 
968
                  row++;
-
 
969
                  table.Cell(row,1).Range.Text = ((EA.Element)de.Key).Name;
-
 
970
                  firstFromToCon = true;
-
 
971
               }
-
 
972
 
-
 
973
               if (((EA.Element)de.Value) != null)
-
 
974
               {
-
 
975
                  if (firstFromToCon)
-
 
976
                  {
-
 
977
                     firstFromToCon = false;
-
 
978
                     table.Cell(row,2).Range.Text = ((EA.Element)de.Value).Name;
-
 
979
                  }
-
 
980
                  else
-
 
981
                  {
-
 
982
                     table.Cell(row,2).Range.Text += ((EA.Element)de.Value).Name;
-
 
983
                  }
-
 
984
               }
-
 
985
               else
-
 
986
               {
-
 
987
                  table.Cell(row,2).Range.Text = "Un-allocated relationship!";
-
 
988
                  table.Cell(row,2).Range.Font.Color = Word.WdColor.wdColorRed;
-
 
989
               }
-
 
990
            }
-
 
991
         }
-
 
992
 
-
 
993
         // Does user want a to-from table ?
-
 
994
         if (needToFromTable)
-
 
995
         {
-
 
996
            // re-use the fromToDictionary to prepare the to-from table content 
-
 
997
            fromToDictionary.Clear();
-
 
998
 
-
 
999
            // find all elements for the left hand column of the to-from table.
-
 
1000
            ElementAccumulator toLister = new ElementAccumulator(EA_RelMatrix.toElementTypes, EA_Utils);
-
 
1001
            EA_Utils.findAndProcessPackageElements( EA_RelMatrix.toPackage, toLister, EA_RelMatrix.toPackageRecursion );
-
 
1002
 
-
 
1003
            // Sort the "to" elements
-
 
1004
            toLister.Elements.Sort( sorter );
-
 
1005
 
-
 
1006
 
-
 
1007
            // To make the to-from table, we use the dictionary that was built when making the from-to
-
 
1008
            // table. The dictionary will allow rapid determination of what "from" items belong to each
-
 
1009
            // "to" item, without us having to go back to EA and enquire on the database.
-
 
1010
            // We build a new fromToDictionary from the toFromDictionary, in advance of actually making 
-
 
1011
            // the table so that we can figure out how many rows the table needs to have.
-
 
1012
            numberOfFromToRows = 0;
-
 
1013
            
-
 
1014
            foreach(EA.Element toElement in toLister.Elements)
-
 
1015
            {
-
 
1016
               bool foundToElement = false;
-
 
1017
 
-
 
1018
               // right-column cell content
-
 
1019
               foreach (DictionaryEntry de in toFromDictionary)
-
 
1020
               {
-
 
1021
                  if ((int)de.Key == toElement.ElementID)
-
 
1022
                  {
-
 
1023
                     DictionaryEntry newFromToEntry = new DictionaryEntry(toElement, (string)de.Value);
-
 
1024
                     fromToDictionary.Add( newFromToEntry );
-
 
1025
                     foundToElement = true;
-
 
1026
                  }
-
 
1027
               }
-
 
1028
 
-
 
1029
               // If we found a from-to relationship that table needs a new row.
-
 
1030
               if (foundToElement)
-
 
1031
               {
-
 
1032
                  numberOfFromToRows++;
-
 
1033
               }
-
 
1034
                  // if user wants all "from elements", even if some have no "to elements", then add a dictionary
-
 
1035
                  // entry and bump row count.
-
 
1036
               else if (EA_RelMatrix.toPackageTrimming == false)
-
 
1037
               {
-
 
1038
                  DictionaryEntry newFromToEntry = new DictionaryEntry(toElement, "");
-
 
1039
                  fromToDictionary.Add( newFromToEntry );
-
 
1040
                  numberOfFromToRows++;
-
 
1041
               }
-
 
1042
            }
-
 
1043
 
-
 
1044
            // Now begin to add the to-from table to the word document
-
 
1045
            if (EA_RelMatrix.toIntroText != null && EA_RelMatrix.toIntroText.Length > 0)
-
 
1046
            {
-
 
1047
               TextUtils.appendAndSelectText( EA_RelMatrix.toIntroText, EA_Constants.styleName_Body1 );
-
 
1048
            }
-
 
1049
 
-
 
1050
            // create the table in the word doc
-
 
1051
            tableNum = TableUtils.Table_Create( EA_RelMatrix.toFromTableTitle, numberOfFromToRows + 1, 2 );
-
 
1052
            table = WordDocument.Tables[tableNum];
-
 
1053
            
-
 
1054
            TableUtils.Table_SetTableColumnTitle(table, EA_RelMatrix.toColumnTitle, 1);
-
 
1055
            TableUtils.Table_SetTableColumnTitle(table, EA_RelMatrix.fromColumnTitle, 2);
924
 
1056
 
-
 
1057
            int lastFromElementId = -1;
-
 
1058
            bool firstToFromCon = true;
-
 
1059
            int row = 1;
-
 
1060
            foreach (DictionaryEntry de in fromToDictionary)
-
 
1061
            {
-
 
1062
               if ( ((EA.Element)de.Key).ElementID != lastFromElementId )
-
 
1063
               {
-
 
1064
                  lastFromElementId = ((EA.Element)de.Key).ElementID;
-
 
1065
                  row++;
-
 
1066
                  table.Cell(row,1).Range.Text = ((EA.Element)de.Key).Name;
-
 
1067
                  firstToFromCon = true;
-
 
1068
               }
-
 
1069
               
-
 
1070
               if (((string)de.Value).Length > 0)
-
 
1071
               {
-
 
1072
                  if (firstToFromCon)
-
 
1073
                  {
-
 
1074
                     firstToFromCon = false;
-
 
1075
                     table.Cell(row,2).Range.Text = (string)de.Value;
-
 
1076
                  }
-
 
1077
                  else
-
 
1078
                  {
-
 
1079
                     table.Cell(row,2).Range.Text += (string)de.Value;
-
 
1080
                  }
-
 
1081
               }
-
 
1082
               else
-
 
1083
               {
-
 
1084
                  table.Cell(row,2).Range.Text = "Un-allocated relationship!";
-
 
1085
                  table.Cell(row,2).Range.Font.Color = Word.WdColor.wdColorRed;
-
 
1086
               }
-
 
1087
            }
-
 
1088
         }
-
 
1089
      }
-
 
1090
 
-
 
1091
 
-
 
1092
      private void processTestTraceability( EA.Element theElement, int recurse_level )
-
 
1093
      {
-
 
1094
         if (nonPrivateClasses.Count > 0)
-
 
1095
         {
-
 
1096
            if (theElement.Notes.Length > 0)
-
 
1097
            {
-
 
1098
               TextUtils.appendAndSelectText( theElement.Notes, EA_Constants.styleName_Body1);
-
 
1099
            }
-
 
1100
            int tableNum = TableUtils.Table_Create("Design Element to Unit Test Suite Traceability", 2, 2);
-
 
1101
            utTraceabilityTable = WordDocument.Tables[tableNum];
-
 
1102
 
-
 
1103
            TableUtils.Table_SetTableColumnTitle(utTraceabilityTable, "Design Element (class)", 1);
-
 
1104
            TableUtils.Table_SetTableColumnTitle(utTraceabilityTable, "Test Suite", 2);
-
 
1105
         }
-
 
1106
      }
-
 
1107
 
-
 
1108
 
-
 
1109
      private void completeTestTraceability()
-
 
1110
      {
-
 
1111
         if (utTraceabilityTable != null)
-
 
1112
         {
-
 
1113
            int numClassesRemaining = nonPrivateClasses.Count;
-
 
1114
            int row = 2;
-
 
1115
            foreach(int elementId in nonPrivateClasses)
-
 
1116
            {
-
 
1117
               EA.Element theElement = EA_Repository.GetElementByID( elementId );
-
 
1118
               if (theElement != null)
-
 
1119
               {
-
 
1120
                  utTraceabilityTable.Cell(row,1).Range.Text = theElement.Name;
-
 
1121
 
-
 
1122
                  if (classesWithUnitTests.Contains( elementId ))
-
 
1123
                  {
-
 
1124
                     utTraceabilityTable.Cell(row,2).Range.Text = TextUtils.testSuiteName(theElement);
-
 
1125
                  }
-
 
1126
                  else
-
 
1127
                  {
-
 
1128
                     utTraceabilityTable.Cell(row,2).Range.Text = "Missing tests!";
-
 
1129
                     utTraceabilityTable.Cell(row,2).Range.Font.Color = Word.WdColor.wdColorRed;
-
 
1130
                  }
-
 
1131
               }
-
 
1132
 
-
 
1133
               numClassesRemaining--;
-
 
1134
               if (numClassesRemaining > 0)
-
 
1135
               {
-
 
1136
                  TableUtils.Table_InsertNewRowAfterThisRow(utTraceabilityTable, row);
-
 
1137
                  row++;
-
 
1138
               }
-
 
1139
            }
-
 
1140
         }
-
 
1141
      }
925
 
1142
 
-
 
1143
      #endregion
-
 
1144
 
-
 
1145
      #region special section processing functions (references, terminology, etc)
926
      /// <summary>
1146
      /// <summary>
927
      /// This function processes elements as if they represented document references for
1147
      /// This function processes elements as if they represented document references for
928
      /// the References section of a document.
1148
      /// the References section of a document.
929
      /// </summary>
1149
      /// </summary>
930
      /// <param name="thePackage"></param>
1150
      /// <param name="thePackage"></param>
Line 932... Line 1152...
932
      {
1152
      {
933
         foreach(EA.Element theElement in thePackage.Elements)
1153
         foreach(EA.Element theElement in thePackage.Elements)
934
         {
1154
         {
935
            // Here we want to apply the special ERG template styles for each reference
1155
            // Here we want to apply the special ERG template styles for each reference
936
            // item.
1156
            // item.
937
            appendAndSelectText( theElement.Name.ToString(), styleName_RefListNum );
1157
            TextUtils.appendAndSelectText( theElement.Name.ToString(), EA_Constants.styleName_RefListNum );
938
            appendAndSelectText( theElement.Notes.ToString(), styleName_RefListText );
1158
            TextUtils.appendAndSelectText( theElement.Notes.ToString(), EA_Constants.styleName_RefListText );
939
         }
1159
         }
940
      }
1160
      }
941
 
1161
 
942
 
1162
 
943
      private void createTerminologySection(EA.Package thePackage)
1163
      private void createTerminologySection(EA.Package thePackage)
Line 951... Line 1171...
951
         }
1171
         }
952
 
1172
 
953
         if (numItems > 0)
1173
         if (numItems > 0)
954
         {
1174
         {
955
            // Create a table
1175
            // Create a table
956
            int tableNum = createTable("Terminology", numItems+1, 2);
1176
            int tableNum = TableUtils.Table_Create("Terminology", numItems+1, 2);
957
            Word.Table table = WordDocument.Tables[tableNum];
1177
            Word.Table table = WordDocument.Tables[tableNum];
958
            object center = Word.WdParagraphAlignment.wdAlignParagraphCenter;
1178
            object center = Word.WdParagraphAlignment.wdAlignParagraphCenter;
-
 
1179
 
959
            table.Cell(1,1).Range.Text = "Term";
1180
            TableUtils.Table_SetTableColumnTitle(table, "Term", 1);
960
            table.Cell(1,1).Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
-
 
961
            table.Cell(1,1).Range.Font.Bold = 1;
-
 
962
            table.Cell(1,2).Range.Text = "Definition";
1181
            TableUtils.Table_SetTableColumnTitle(table, "Definition", 2);
963
            table.Cell(1,2).Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
-
 
964
            table.Cell(1,2).Range.Font.Bold = 1;
-
 
965
            table.Columns[1].SetWidth(100, Word.WdRulerStyle.wdAdjustSameWidth );
1182
            table.Columns[1].SetWidth(100, Word.WdRulerStyle.wdAdjustSameWidth );
966
            int row = 2;
1183
            int row = 2;
967
 
1184
 
968
            if (thePackage.Elements.Count > 0)
1185
            if (thePackage.Elements.Count > 0)
969
            {
1186
            {
Line 992... Line 1209...
992
               }
1209
               }
993
            }
1210
            }
994
         }
1211
         }
995
      }
1212
      }
996
 
1213
 
-
 
1214
      #endregion
997
 
1215
 
998
      private bool generatePackageHeadingAndDescription( EA.Package thePackage, int recurse_level )
1216
      private bool generatePackageHeadingAndDescription( EA.Package thePackage, int recurse_level )
999
      {
1217
      {
1000
         // disarm the one-shot package skipping feature if it was armed, and exit the function.
1218
         // disarm the one-shot package skipping feature if it was armed, and exit the function.
1001
         if (oneShot_skipRootPackage == true)
1219
         if (oneShot_skipRootPackage == true)
Line 1006... Line 1224...
1006
 
1224
 
1007
         // The package name is a heading, and the package notes are paragraphs 
1225
         // The package name is a heading, and the package notes are paragraphs 
1008
         // directly under that heading
1226
         // directly under that heading
1009
         displayProgress( "PACKAGE: ", thePackage.Name.ToString() );
1227
         displayProgress( "PACKAGE: ", thePackage.Name.ToString() );
1010
 
1228
 
1011
         appendAndSelectHeadingText( thePackage.Name.ToString(), recurse_level );
1229
         TextUtils.appendAndSelectHeadingText( thePackage.Name.ToString(), recurse_level );
1012
 
1230
 
1013
         // Special handling for package called "Terminology" 
1231
         // Special handling for package called "Terminology" 
1014
         if (thePackage.Name == "Terminology")
1232
         if (thePackage.Name == "Terminology")
1015
         {
1233
         {
1016
            appendAndSelectText( thePackage.Notes.ToString(), styleName_Body1 );
1234
            TextUtils.appendAndSelectText( thePackage.Notes.ToString(), EA_Constants.styleName_Body1 );
1017
            createTerminologySection(thePackage);
1235
            createTerminologySection(thePackage);
1018
            return true;
1236
            return true;
1019
         }
1237
         }
1020
 
1238
 
1021
         if (thePackage.Name == "References")
1239
         if (thePackage.Name == "References")
1022
         {
1240
         {
1023
            appendAndSelectText( thePackage.Notes.ToString(), styleName_Body1 );
1241
            TextUtils.appendAndSelectText( thePackage.Notes.ToString(), EA_Constants.styleName_Body1 );
1024
            createReferencesSection(thePackage);
1242
            createReferencesSection(thePackage);
1025
            return true;
1243
            return true;
1026
         }
1244
         }
1027
         
1245
         
1028
         // use the package notes as body text and indicate to caller that package elements 
1246
         // use the package notes as body text and indicate to caller that package elements 
1029
         // have not been consumed
1247
         // have not been consumed
1030
         appendAndSelectText( thePackage.Notes.ToString(), styleName_Body1 );      
1248
         TextUtils.appendAndSelectText( thePackage.Notes.ToString(), EA_Constants.styleName_Body1 );      
1031
         return false;
1249
         return false;
1032
      }
1250
      }
1033
 
1251
 
1034
  
1252
  
1035
      private void generatePackageDiagrams( EA.Package thePackage )
1253
      private void generatePackageDiagrams( EA.Package thePackage )
Line 1042... Line 1260...
1042
            appendAndSelectDiagramViaClipboard( theDiagram );
1260
            appendAndSelectDiagramViaClipboard( theDiagram );
1043
         }
1261
         }
1044
      }
1262
      }
1045
 
1263
 
1046
 
1264
 
1047
      private void generateElementContent( EA.Element theElement, int recurse_level )
1265
      private void generateMethodContent( EA.Element theElement, int recurse_level )
-
 
1266
      {
-
 
1267
         recurse_level++;
-
 
1268
         if (recurse_level > 8)  // 8 instead of 9 because this function generates two heading levels 
-
 
1269
         {
-
 
1270
            throw new System.StackOverflowException("Max Recursion Depth (9) Exceeded" );
-
 
1271
         }
-
 
1272
 
-
 
1273
         // Get all the methods into an array list and sort them by their position in the class's
-
 
1274
         // method list (ie. sort order is determined by the Pos value in each method).
-
 
1275
         ArrayList theMethods = new ArrayList();
-
 
1276
         foreach(EA.Method theMethod in theElement.Methods)
-
 
1277
            theMethods.Add( theMethod );
-
 
1278
         methodSortByPos sorter = new methodSortByPos();
-
 
1279
         theMethods.Sort( sorter );
-
 
1280
 
-
 
1281
         // filter out methods with certain characteristics?
-
 
1282
         // eg. Users may only want to document public and protected methods.
-
 
1283
         int numMethodsRemaining = 0;
-
 
1284
         foreach(EA.Method theMethod in theMethods)
-
 
1285
         {
-
 
1286
            if (EA_Utils.options.opt_SuppressPrivateMethods == false
-
 
1287
               || !theMethod.Visibility.StartsWith("Private"))
-
 
1288
               numMethodsRemaining++;
-
 
1289
         }
-
 
1290
 
-
 
1291
         Word.Range wr;
-
 
1292
         StringBuilder sb;
-
 
1293
 
-
 
1294
         if (numMethodsRemaining > 0)
-
 
1295
         {
-
 
1296
            // Print the "<Class Name> Operations" headings
-
 
1297
            sb = new StringBuilder();
-
 
1298
            sb.Append( theElement.Name );
-
 
1299
            sb.Append( " Operations" );
-
 
1300
            TextUtils.appendAndSelectHeadingText(sb.ToString(), recurse_level);
-
 
1301
 
-
 
1302
            // Iterate through the class's methods
-
 
1303
            foreach(EA.Method theMethod in theMethods)
-
 
1304
            {
-
 
1305
               sb = new StringBuilder();
-
 
1306
 
-
 
1307
               if (EA_Utils.options.opt_SuppressPrivateMethods == false
-
 
1308
                  || !theMethod.Visibility.StartsWith("Private"))
-
 
1309
               {
-
 
1310
                  // Print the Method name as a sub heading, and its description
-
 
1311
                  TextUtils.appendAndSelectHeadingText(theMethod.Name , recurse_level + 1);
-
 
1312
                  TextUtils.appendDescription(theMethod.Notes, EA_Utils);
-
 
1313
 
-
 
1314
                  // Get a list of the method's parameters and sort them by the position field setup 
-
 
1315
                  // in EA by the designer
-
 
1316
                  ArrayList theParams = new ArrayList();
-
 
1317
                  foreach(EA.Parameter theParam in theMethod.Parameters)
-
 
1318
                     theParams.Add( theParam );
-
 
1319
                  parameterSortByPos paramSorter = new parameterSortByPos();
-
 
1320
                  theParams.Sort( paramSorter );
-
 
1321
 
-
 
1322
                  // Print the prototype heading
-
 
1323
                  wr = TextUtils.appendAndSelectText("\nPrototype:", EA_Constants.styleName_Body1);
-
 
1324
                  wr.ParagraphFormat.LeftIndent = WordApp.CentimetersToPoints((float)2.5);
-
 
1325
                  wr.Font.Italic = 1;
-
 
1326
 
-
 
1327
                  // begin to build the prototype string
-
 
1328
                  sb = new StringBuilder();
-
 
1329
                  sb.Append( theMethod.ReturnType );
-
 
1330
                  sb.Append( " " );
-
 
1331
                  sb.Append( theMethod.Name );
-
 
1332
                  sb.Append( "(" );
-
 
1333
 
-
 
1334
                  if (theParams.Count > 0)
-
 
1335
                  {
-
 
1336
                     int numParamsRemaining = theParams.Count;
-
 
1337
 
-
 
1338
                     // print what we have so far constructed for the prototype
-
 
1339
                     wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1);
-
 
1340
                     wr.ParagraphFormat.LeftIndent = WordApp.CentimetersToPoints((float)3.5);
-
 
1341
 
-
 
1342
                     // Now form a new string for the params
-
 
1343
                     sb = new StringBuilder();
-
 
1344
                     foreach(EA.Parameter theParam in theParams)
-
 
1345
                     {
-
 
1346
                        // each parameter is   "[in|out|inout] type name [= default-value]"
-
 
1347
                        // where the default value is optional
-
 
1348
                        sb.Append( "[" );
-
 
1349
                        sb.Append( theParam.Kind );
-
 
1350
                        sb.Append( "] " );
-
 
1351
                        sb.Append( theParam.Type );
-
 
1352
                        sb.Append( " " );
-
 
1353
                        sb.Append( theParam.Name );
-
 
1354
                        if (theParam.Default.Length > 0)
-
 
1355
                        {
-
 
1356
                           sb.Append( " = " );
-
 
1357
                           sb.Append( theParam.Default );
-
 
1358
                        }
-
 
1359
 
-
 
1360
                        // if there are more parameters after this one, add a comma and newline
-
 
1361
                        if (numParamsRemaining > 1)
-
 
1362
                           sb.Append( ",\n" );
-
 
1363
 
-
 
1364
                        numParamsRemaining--;
-
 
1365
                     }
-
 
1366
 
-
 
1367
                     // complete the prototype and print it.
-
 
1368
                     sb.Append( ")" );
-
 
1369
                     wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1);
-
 
1370
                     wr.ParagraphFormat.LeftIndent = WordApp.CentimetersToPoints((float)4.5);
-
 
1371
                  }
-
 
1372
                  else
-
 
1373
                  {
-
 
1374
                     // complete the prototype and print it.
-
 
1375
                     sb.Append( ")" );
-
 
1376
                     wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1);
-
 
1377
                     wr.ParagraphFormat.LeftIndent = WordApp.CentimetersToPoints((float)3.5);
-
 
1378
                  }
-
 
1379
 
-
 
1380
 
-
 
1381
                  // Prototype Attributes/Characteristics
-
 
1382
                  sb = new StringBuilder();
-
 
1383
                  sb.Append( theMethod.Visibility );
-
 
1384
 
-
 
1385
                  if (theMethod.IsStatic)
-
 
1386
                     sb.Append("\nStatic");
-
 
1387
 
-
 
1388
                  if (theMethod.Abstract)
-
 
1389
                     sb.Append("\nAbstract");
-
 
1390
 
-
 
1391
                  if (theMethod.IsPure)
-
 
1392
                     sb.Append("\nPure (c++)");
-
 
1393
 
-
 
1394
                  if (theMethod.IsSynchronized)
-
 
1395
                     sb.Append("\nSynchronised");
-
 
1396
 
-
 
1397
                  if (theMethod.Concurrency != null && theMethod.Concurrency.Length > 0 && !theMethod.Concurrency.StartsWith("Sequential") )
-
 
1398
                  {
-
 
1399
                     sb.Append("\n");
-
 
1400
                     sb.Append(theMethod.Concurrency);
-
 
1401
                  }
-
 
1402
 
-
 
1403
                  if (theMethod.IsConst)
-
 
1404
                     sb.Append("\nConst");
-
 
1405
 
-
 
1406
                  if (theMethod.IsQuery)
-
 
1407
                     sb.Append("\nIs Querry (does not alter class variables)");
-
 
1408
 
-
 
1409
                  if (theMethod.IsLeaf)
-
 
1410
                     sb.Append("\nIs Leaf (cannot be overriden)");
-
 
1411
 
-
 
1412
                  if (theMethod.ReturnIsArray)
-
 
1413
                     sb.Append( "\nReturn value is an array" );
-
 
1414
 
-
 
1415
                  if (theMethod.Throws != null && theMethod.Throws.Length > 0)
-
 
1416
                  {
-
 
1417
                     sb.Append("\n");
-
 
1418
                     sb.Append( theMethod.Throws );
-
 
1419
                  }
-
 
1420
 
-
 
1421
                  if (sb.Length > 0)
-
 
1422
                  {
-
 
1423
                     wr = TextUtils.appendAndSelectText("Characteristics:", EA_Constants.styleName_Body1);
-
 
1424
                     wr.ParagraphFormat.LeftIndent = WordApp.CentimetersToPoints((float)2.5);
-
 
1425
                     wr.Font.Italic = 1;
-
 
1426
 
-
 
1427
                     wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1);
-
 
1428
                     wr.ParagraphFormat.LeftIndent = WordApp.CentimetersToPoints((float)3.5);
-
 
1429
                  }
-
 
1430
 
-
 
1431
                  // Parameter Descriptions
-
 
1432
                  if (theParams.Count > 0)
-
 
1433
                  {
-
 
1434
                     wr = TextUtils.appendAndSelectText("Parameters:", EA_Constants.styleName_Body1);
-
 
1435
                     wr.ParagraphFormat.LeftIndent = WordApp.CentimetersToPoints((float)2.5);
-
 
1436
                     wr.Font.Italic = 1;
-
 
1437
 
-
 
1438
                     foreach(EA.Parameter theParam in theParams)
-
 
1439
                     {
-
 
1440
                        wr = TextUtils.appendAndSelectText( theParam.Name, EA_Constants.styleName_Body1);
-
 
1441
                        wr.ParagraphFormat.LeftIndent = WordApp.CentimetersToPoints((float)3.5);
-
 
1442
 
-
 
1443
                        wr = TextUtils.appendDescription(theParam.Notes, EA_Utils);
-
 
1444
                        wr.ParagraphFormat.LeftIndent = WordApp.CentimetersToPoints((float)4.5);
-
 
1445
                     }
-
 
1446
                  }
-
 
1447
               }
-
 
1448
            }
-
 
1449
         }
-
 
1450
      }
-
 
1451
 
-
 
1452
 
-
 
1453
      /// <summary>
-
 
1454
      /// This method serialises a class's attributes to the document. 
-
 
1455
      /// </summary>
-
 
1456
      /// <param name="theElement"></param>
-
 
1457
      /// <param name="recurse_level"></param>
-
 
1458
      private void generateAttributeContent( EA.Element theElement, int recurse_level )
1048
      {
1459
      {
1049
         recurse_level++;
1460
         recurse_level++;
1050
         if (recurse_level > 9)
1461
         if (recurse_level > 9)
1051
         {
1462
         {
1052
            throw new System.StackOverflowException("Max Recursion Depth (9) Exceeded" );
1463
            throw new System.StackOverflowException("Max Recursion Depth (9) Exceeded" );
1053
         }
1464
         }
-
 
1465
      
-
 
1466
         // Get all the attributes into an array list and sort them by their position in the class's
-
 
1467
         // attribute list (ie. sort order is determined by the Pos value in each attribute).
-
 
1468
         ArrayList theAttrs = new ArrayList();
-
 
1469
         foreach(EA.Attribute theAttr in theElement.Attributes)
-
 
1470
            theAttrs.Add( theAttr );
-
 
1471
         attributeSortByPos sorter = new attributeSortByPos();
1054
         trackDocSection(recurse_level);
1472
         theAttrs.Sort( sorter );
-
 
1473
 
1055
         
1474
         // TODO
-
 
1475
         // filter out attributes with certain characteristics?
1056
         if (EA_Utils.options.elementTypeFoundInEA_DocGen( theElement.Type ))
1476
         // eg. Users may only want to document public and protected attributes.
-
 
1477
 
-
 
1478
         int numAttrsRemaining = 0;
-
 
1479
         foreach(EA.Attribute theAttr in theAttrs)
1057
         {
1480
         {
-
 
1481
            if (EA_Utils.options.opt_SuppressPrivateAttributes == false
-
 
1482
               || !theAttr.Visibility.StartsWith("Private"))
-
 
1483
               numAttrsRemaining++;
-
 
1484
         }
-
 
1485
 
-
 
1486
         if (numAttrsRemaining > 0)
-
 
1487
         {
1058
            displayProgress( "ELEMENT: ", theElement.Name.ToString() );
1488
            StringBuilder sb = new StringBuilder();
1059
 
1489
 
-
 
1490
            sb.Append( theElement.Name );
-
 
1491
            sb.Append( " Attributes" );
-
 
1492
            TextUtils.appendAndSelectHeadingText(sb.ToString(), recurse_level);
-
 
1493
 
1060
            if ( theElement.Type.StartsWith("Requirement")
1494
            // serialise the attributes to the document.
1061
               && EA_Utils.options.opt_DisplayRequirementsWithStatus == true )
1495
            foreach(EA.Attribute theAttr in theAttrs)
1062
            {
1496
            {
-
 
1497
               if (EA_Utils.options.opt_SuppressPrivateAttributes == false
-
 
1498
                  || !theAttr.Visibility.StartsWith("Private"))
-
 
1499
               {
-
 
1500
                  // Begin to build content string for the "Attribute" table column 
-
 
1501
                  sb = new StringBuilder();
-
 
1502
 
-
 
1503
                  // <type> <name>
-
 
1504
                  sb.Append("\n");
-
 
1505
                  sb.Append(theAttr.Type);
-
 
1506
                  sb.Append(" ");
-
 
1507
                  sb.Append(theAttr.Name);
-
 
1508
                  Word.Range wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1);
-
 
1509
                  wr.Font.Bold = 1;
-
 
1510
                  
-
 
1511
                  wr = TextUtils.appendDescription(theAttr.Notes, EA_Utils);
-
 
1512
                  wr.ParagraphFormat.LeftIndent = WordApp.CentimetersToPoints((float)3.5);
-
 
1513
 
-
 
1514
                  // The approach here is to display as much of the attribute as we can but try to keep the output
-
 
1515
                  // uncluttered by omitting items the user has not set via the EA GUI.
-
 
1516
 
-
 
1517
                  // Begin to build content string for the "Other Information" table cell
-
 
1518
                  sb = new StringBuilder();
-
 
1519
 
-
 
1520
                  sb.Append(theAttr.Visibility);
-
 
1521
                  sb.Append("\n");
-
 
1522
 
-
 
1523
                  if (theAttr.IsConst)
-
 
1524
                     sb.Append("Constant\n");
-
 
1525
 
-
 
1526
                  if (theAttr.IsStatic)
-
 
1527
                     sb.Append("Static\n");
-
 
1528
 
-
 
1529
                  if (theAttr.IsDerived)
-
 
1530
                     sb.Append("Derived\n");
-
 
1531
 
-
 
1532
                  if (theAttr.IsOrdered)
-
 
1533
                  {
-
 
1534
                     sb.Append("Is Ordered\n");
-
 
1535
                  }
-
 
1536
 
-
 
1537
                  if (theAttr.IsCollection)
-
 
1538
                  {
-
 
1539
                     sb.Append("Is A Collection\n");
-
 
1540
                  }
-
 
1541
 
-
 
1542
                  if (theAttr.Length.Length > 0 && System.Convert.ToInt32(theAttr.Length) > 0)
-
 
1543
                  {
-
 
1544
                     sb.Append("Length = ");
-
 
1545
                     sb.Append(theAttr.Length);
-
 
1546
                     sb.Append("\n");
-
 
1547
                  }
-
 
1548
 
-
 
1549
                  if (!theAttr.Containment.StartsWith("Not Specified"))
-
 
1550
                  {
-
 
1551
                     sb.Append("Containment =");
-
 
1552
                     sb.Append(theAttr.Containment);
-
 
1553
                     sb.Append("\n");
-
 
1554
                  }
-
 
1555
 
-
 
1556
                  if (theAttr.Container.Length > 0)
-
 
1557
                  {
-
 
1558
                     sb.Append("Container Type = ");
-
 
1559
                     sb.Append(theAttr.Container);
-
 
1560
                     sb.Append("\n");
-
 
1561
                  }
-
 
1562
 
-
 
1563
                  if (theAttr.Style.Length > 0)
-
 
1564
                  {
-
 
1565
                     sb.Append("Style = ");
-
 
1566
                     sb.Append(theAttr.Style);
-
 
1567
                     sb.Append("\n");
-
 
1568
                  }
-
 
1569
 
-
 
1570
                  if (  System.Convert.ToInt32(theAttr.LowerBound) > 1
-
 
1571
                     || System.Convert.ToInt32(theAttr.UpperBound) > 1)
-
 
1572
                  {
-
 
1573
                     sb.Append("Multiplicity [");
-
 
1574
                     sb.Append(theAttr.LowerBound);
-
 
1575
                     sb.Append("..");
-
 
1576
                     sb.Append(theAttr.UpperBound);
-
 
1577
                     sb.Append("]\n");
-
 
1578
                  }
-
 
1579
 
-
 
1580
                  if (theAttr.Scale.Length > 0 && System.Convert.ToInt32(theAttr.Scale) > 0)
-
 
1581
                  {
-
 
1582
                     sb.Append("Scale = ");
-
 
1583
                     sb.Append(theAttr.Scale);
-
 
1584
                     sb.Append( "\n" );
-
 
1585
                  }
-
 
1586
                  if (theAttr.Precision.Length > 0 && System.Convert.ToInt32(theAttr.Precision) > 0)
-
 
1587
                  {
-
 
1588
                     sb.Append("Precision = ");
-
 
1589
                     sb.Append(theAttr.Precision);
-
 
1590
                     sb.Append( "\n" );
-
 
1591
                  }
-
 
1592
 
-
 
1593
                  if (theAttr.Default.Length > 0)
-
 
1594
                  {
-
 
1595
                     sb.Append("Default Value = ");
-
 
1596
                     sb.Append(theAttr.Default);
-
 
1597
                     sb.Append( "\n" );
-
 
1598
                  }
-
 
1599
 
-
 
1600
                  // Now look at the constraint and tagged value collections and add any found info to the
-
 
1601
                  // right hand column
-
 
1602
                  short i;
-
 
1603
                  for(i=0; i<theAttr.Constraints.Count; i++)
-
 
1604
                  {
-
 
1605
                     EA.AttributeConstraint theCons = (EA.AttributeConstraint)theAttr.Constraints.GetAt(i);
-
 
1606
                     sb.Append( theCons.Type );
-
 
1607
                     sb.Append( ": {" );
-
 
1608
                     sb.Append( theCons.Name );
-
 
1609
                     sb.Append( "}\n" );
-
 
1610
                     //sb.Append( theCons.Notes  );
-
 
1611
                     //sb.Append( "\n" );
-
 
1612
                  }
-
 
1613
 
-
 
1614
                  for(i=0; i<theAttr.TaggedValues.Count; i++)
-
 
1615
                  {
-
 
1616
                     EA.AttributeTag theTag = (EA.AttributeTag)theAttr.TaggedValues.GetAt(i);
-
 
1617
                     sb.Append( "[" );
-
 
1618
                     sb.Append( theTag.Name );
-
 
1619
                     sb.Append( "="  );
-
 
1620
                     sb.Append( theTag.Value );
-
 
1621
                     sb.Append( "]\n" );
1063
               generateRequirementText( theElement );
1622
                     //sb.Append( theTag.Notes );
-
 
1623
                     //sb.Append( "\n" );
-
 
1624
                  }
-
 
1625
 
-
 
1626
                  if (sb.Length > 0)
-
 
1627
                  {
-
 
1628
                     // remove the trailing "\n"
-
 
1629
                     sb.Remove( sb.ToString().Length - 1, 1);
-
 
1630
 
-
 
1631
                     wr = TextUtils.appendAndSelectText("Characteristics:", EA_Constants.styleName_Body1);
-
 
1632
                     wr.ParagraphFormat.LeftIndent = WordApp.CentimetersToPoints((float)3.5);
-
 
1633
                     wr.Font.Italic = 1;
-
 
1634
 
-
 
1635
                     wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1);
-
 
1636
                     wr.ParagraphFormat.LeftIndent = WordApp.CentimetersToPoints((float)4.5);
-
 
1637
                  }
-
 
1638
 
-
 
1639
                  numAttrsRemaining--;
-
 
1640
               }
1064
            }
1641
            }
-
 
1642
         }
-
 
1643
      }
-
 
1644
 
-
 
1645
 
-
 
1646
      private void generateClassCharacteristics( EA.Element theElement, int recurse_level )
-
 
1647
      {
-
 
1648
         StringBuilder sb = new StringBuilder();
-
 
1649
 
-
 
1650
         sb.Append( "Characteristics:" );
-
 
1651
         Word.Range wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1);
-
 
1652
         wr.Font.Italic = 1;
-
 
1653
         
-
 
1654
         sb = new StringBuilder();
-
 
1655
         sb.Append( theElement.Visibility );
-
 
1656
 
-
 
1657
         if (System.Convert.ToInt32(theElement.Abstract) == 1)
-
 
1658
            sb.Append( "\nAbstract" );
-
 
1659
 
-
 
1660
         wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1);
-
 
1661
         wr.ParagraphFormat.LeftIndent = WordApp.CentimetersToPoints((float)3.5);
-
 
1662
         
-
 
1663
         sb = new StringBuilder();
-
 
1664
         foreach(EA.Element baseClass in theElement.BaseClasses)
-
 
1665
         {
-
 
1666
            sb.Append( baseClass.Name);
-
 
1667
         }
-
 
1668
         if (sb.Length > 0)
-
 
1669
         {
-
 
1670
            wr = TextUtils.appendAndSelectText("Base Class(es):", EA_Constants.styleName_Body1);
-
 
1671
            wr.Font.Italic = 1;
-
 
1672
 
-
 
1673
            wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1);
-
 
1674
            wr.ParagraphFormat.LeftIndent = WordApp.CentimetersToPoints((float)3.5);
-
 
1675
         }
-
 
1676
 
-
 
1677
         sb = new StringBuilder();
-
 
1678
         foreach(EA.Element intf in theElement.Realizes)
-
 
1679
         {
-
 
1680
            sb.Append( intf.Name);
-
 
1681
         }
-
 
1682
         if (sb.Length > 0)
-
 
1683
         {
-
 
1684
            wr = TextUtils.appendAndSelectText("Realises:", EA_Constants.styleName_Body1);
-
 
1685
            wr.Font.Italic = 1;
-
 
1686
 
-
 
1687
            wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1);
-
 
1688
            wr.ParagraphFormat.LeftIndent = WordApp.CentimetersToPoints((float)3.5);
-
 
1689
         }
-
 
1690
      }
-
 
1691
 
-
 
1692
      
-
 
1693
      private void generateClassRequirements( EA.Element theElement, int recurse_level )
-
 
1694
      {
-
 
1695
         StringBuilder sb = new StringBuilder();
-
 
1696
 
-
 
1697
         sb.Append( "Requirements:" );
-
 
1698
         Word.Range wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1);
-
 
1699
         wr.Font.Italic = 1;
-
 
1700
 
-
 
1701
         foreach(EA.Requirement theReq in theElement.Requirements)
1065
            else
1702
         {
-
 
1703
            sb = new StringBuilder();
-
 
1704
            sb.Append( theReq.Name );
-
 
1705
            wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1);
-
 
1706
            wr.ParagraphFormat.LeftIndent = WordApp.CentimetersToPoints((float)3.5);
-
 
1707
            sb = new StringBuilder();
-
 
1708
            sb.Append( theReq.Notes );
-
 
1709
            if (sb.Length > 0)
1066
            {
1710
            {
-
 
1711
               wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1);
-
 
1712
               wr.ParagraphFormat.LeftIndent = WordApp.CentimetersToPoints((float)4.5);
-
 
1713
            }
-
 
1714
         }
-
 
1715
      }
-
 
1716
 
-
 
1717
      
-
 
1718
      private void generateClassConstraints( EA.Element theElement, int recurse_level )
-
 
1719
      {
-
 
1720
         StringBuilder sb = new StringBuilder();
-
 
1721
 
-
 
1722
         sb.Append( "Constraints:" );
-
 
1723
         Word.Range wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1);
-
 
1724
         wr.Font.Italic = 1;
-
 
1725
         
-
 
1726
         foreach(EA.Constraint theCons in theElement.Constraints)
-
 
1727
         {
-
 
1728
            sb = new StringBuilder();
-
 
1729
            sb.Append( theCons.Type );
-
 
1730
            sb.Append( ": {" );
-
 
1731
            sb.Append( theCons.Name );
-
 
1732
            sb.Append( "}" );
-
 
1733
 
-
 
1734
            wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1);
-
 
1735
            wr.ParagraphFormat.LeftIndent = WordApp.CentimetersToPoints((float)3.5);
-
 
1736
 
-
 
1737
            if (theCons.Notes.Length > 0)
-
 
1738
            {
-
 
1739
               sb = new StringBuilder();
-
 
1740
               sb.Append( theCons.Notes );
-
 
1741
               wr = TextUtils.appendAndSelectText(sb.ToString(), EA_Constants.styleName_Body1);
-
 
1742
               wr.ParagraphFormat.LeftIndent = WordApp.CentimetersToPoints((float)4.5);
-
 
1743
            }
-
 
1744
         }
-
 
1745
      }
-
 
1746
 
-
 
1747
 
-
 
1748
      private void generateElementContent( EA.Element theElement, int recurse_level )
-
 
1749
      {
-
 
1750
         // track recursion level to control heading style formatting requirements
-
 
1751
         if (oneShot_skipRootElementHeading == false)
-
 
1752
            recurse_level++;
-
 
1753
         if (recurse_level > 9)
-
 
1754
         {
-
 
1755
            throw new System.StackOverflowException("Max Recursion Depth (9) Exceeded" );
-
 
1756
         }
-
 
1757
 
-
 
1758
         if (EA_Utils.options.elementTypeFoundInEA_DocGen( theElement.Type ))
-
 
1759
         {
-
 
1760
            // pass the element to the requirement element serialisation function. It
-
 
1761
            // will tell us if it did anything with it. If not, then carry out the default
-
 
1762
            // element serialisation.
-
 
1763
            if (false == TextUtils.generateRequirementText(theElement, EA_Utils))
-
 
1764
            {
1067
               if (theElement.Type.StartsWith("Requirement")
1765
               bool isClass = theElement.Type.StartsWith("Class");
-
 
1766
 
-
 
1767
               if (  true == isClass
1068
                  && EA_Utils.options.opt_DisplayRequirementElementsAsSections == false )
1768
                  && true == EA_Utils.options.opt_SuppressPrivateClasses
-
 
1769
                  && true == theElement.Visibility.StartsWith("Private") )
1069
               {
1770
               {
1070
                  string s;
1771
                  // do nothing
1071
                  s = EA_Utils.options.opt_RequirementElementDisplayFormat;
-
 
1072
                  s = s.Replace(@"%s",@"{0}");
-
 
1073
                  appendAndSelectText( String.Format( s, theElement.Name ), styleName_Body1);
-
 
1074
                  WordRange.Font.Bold = 1;
-
 
1075
               }
1772
               }
1076
               else if ( EA_Utils.options.opt_ElementHeadingTransitionLevel > 0
-
 
1077
                  && EA_Utils.options.opt_ElementHeadingTransitionLevel <= recurse_level )
-
 
1078
                  appendAndSelectNumParaText( theElement.Name.ToString(), recurse_level );
-
 
1079
               else
1773
               else
-
 
1774
               {
-
 
1775
                  trackDocSection(recurse_level);
-
 
1776
                  displayProgress( "ELEMENT: ", theElement.Name );
-
 
1777
 
-
 
1778
                  // disarm the one-shot element (heading) skipping feature if it was armed, and 
-
 
1779
                  // by-pass the code to generate a new heading level for the element
-
 
1780
                  if (oneShot_skipRootElementHeading == false)
-
 
1781
                  {
-
 
1782
                     // Default element serialisation
-
 
1783
                     if (  EA_Utils.options.opt_ElementHeadingTransitionLevel > 0
-
 
1784
                        && EA_Utils.options.opt_ElementHeadingTransitionLevel <= recurse_level )
-
 
1785
                        TextUtils.appendAndSelectNumParaText( theElement.Name, recurse_level );
-
 
1786
                     else
1080
                  appendAndSelectHeadingText( theElement.Name.ToString(), recurse_level );
1787
                        TextUtils.appendAndSelectHeadingText( theElement.Name, recurse_level );
-
 
1788
                  }
-
 
1789
                  else
-
 
1790
                  {
-
 
1791
                     oneShot_skipRootElementHeading = false;
-
 
1792
                  }
1081
 
1793
 
1082
               appendAndSelectText( theElement.Notes.ToString(), styleName_Body1 );
1794
                  TextUtils.appendDescription( theElement.Notes, EA_Utils );
-
 
1795
 
-
 
1796
                  if (true == isClass)
-
 
1797
                  {
-
 
1798
                     // If accumulation of non-private classes is enabled, then do so.
-
 
1799
                     if (recordingNonPrivateClasses)
-
 
1800
                     {
-
 
1801
                        if (!theElement.Visibility.StartsWith("Private"))
-
 
1802
                        {
-
 
1803
                           nonPrivateClasses.Add( theElement.ElementID );
-
 
1804
                        }
-
 
1805
                     }
-
 
1806
 
-
 
1807
                     generateClassCharacteristics(theElement, recurse_level);
-
 
1808
                  }
-
 
1809
 
-
 
1810
                  // Requirement collection
-
 
1811
                  if (theElement.Requirements.Count > 0)
-
 
1812
                  {
-
 
1813
                     generateClassRequirements(theElement, recurse_level);
-
 
1814
                  }
-
 
1815
 
-
 
1816
                  // Constraint collection
-
 
1817
                  if (theElement.Constraints.Count > 0)
-
 
1818
                  {
-
 
1819
                     generateClassConstraints(theElement, recurse_level);
-
 
1820
                  }
-
 
1821
 
-
 
1822
                  if (theElement.Issues.Count > 0)
-
 
1823
                  {
-
 
1824
                  }
-
 
1825
 
-
 
1826
                  // Attribute collection
-
 
1827
                  if (theElement.Attributes.Count > 0)
-
 
1828
                  {
-
 
1829
                     generateAttributeContent(theElement, recurse_level);
-
 
1830
                  }
-
 
1831
 
-
 
1832
                  // Method collection
-
 
1833
                  if (theElement.Methods.Count > 0)
-
 
1834
                  {
-
 
1835
                     generateMethodContent(theElement, recurse_level);
-
 
1836
                  }
-
 
1837
               }
-
 
1838
            }
-
 
1839
            else
-
 
1840
            {
-
 
1841
               trackDocSection(recurse_level);
-
 
1842
               displayProgress( "ELEMENT: ", theElement.Name );
1083
            }
1843
            }
1084
         }
1844
         }
1085
         else
1845
         else
1086
         {
1846
         {
1087
            displayProgress( "FILTERED: ", theElement.Type );
1847
            displayProgress( "FILTERED: ", theElement.Type );
1088
 
-
 
1089
         }
1848
         }
1090
         // TODO
1849
         // TODO
1091
         // We will probably have to put special code in here at some point for attributes
1850
         // We will probably have to put special code in here at some point for attributes
1092
         // of, and collections of things within elements. This will become apparent once
1851
         // of, and collections of things within elements. This will become apparent once
1093
         // someone tries to produce a design document where such things need to be included
1852
         // someone tries to produce a design document where such things need to be included
1094
         // in the generated document. Lots of work needed here eventually.
1853
         // in the generated document. Lots of work needed here eventually.
1095
         
1854
         
-
 
1855
         // disarm element heading skip control
-
 
1856
         oneShot_skipRootElementHeading = false;
1096
      }
1857
      }
1097
 
1858
 
1098
 
1859
 
1099
      /// <summary>
-
 
1100
      /// This function was the only way I could figure out how to obtain a style object for
-
 
1101
      /// the style name given. Everything else I tried, didn't work, even code from Visual Basic
-
 
1102
      /// examples failed to work or even compile (once converted) in C#.
-
 
1103
      /// </summary>
-
 
1104
      /// <param name="styleText"></param>
-
 
1105
      /// <returns></returns>
-
 
1106
      private Word.Style getStyle(string styleText)
-
 
1107
      {
-
 
1108
         foreach(Word.Style aStyle in WordDocument.Styles)
-
 
1109
         {
-
 
1110
            //MessageBox.Show( aStyle.NameLocal );
-
 
1111
            if (aStyle.NameLocal.StartsWith(styleText))
-
 
1112
            {
-
 
1113
               return aStyle;
-
 
1114
            }
-
 
1115
         }
-
 
1116
         return null;
-
 
1117
      }
-
 
1118
 
-
 
1119
 
-
 
1120
      /// <summary>
1860
      /// <summary>
1121
      /// This function searches for the old content in the document in order to remove it
1861
      /// This function searches for the old content in the document in order to remove it
1122
      /// prior to adding in the new content from the latest EA model data.
1862
      /// prior to adding in the new content from the latest EA model data.
1123
      /// </summary>
1863
      /// </summary>
1124
      private void removeExistingDocumentContent()
1864
      private void removeExistingDocumentContent()
1125
      {
1865
      {
1126
         //WordApp.Visible = true;  // enable this when debugging this horrible function
1866
         //WordApp.Visible = true;  // enable this when debugging this horrible function
1127
         Word.Selection aSelection;
1867
         Word.Selection aSelection;
1128
         object findStyle = getStyle( styleName_Heading1 );
1868
         object findStyle = StyleUtils.getStyle( EA_Constants.styleName_Heading1 );
1129
    
1869
    
1130
         WordApp.Selection.WholeStory();
1870
         WordApp.Selection.WholeStory();
1131
         aSelection = WordApp.Selection;
1871
         aSelection = WordApp.Selection;
1132
 
1872
 
1133
         aSelection.Find.ClearFormatting();
1873
         aSelection.Find.ClearFormatting();
Line 1155... Line 1895...
1155
            // old content.
1895
            // old content.
1156
            Word.Range range = aSelection.Range;
1896
            Word.Range range = aSelection.Range;
1157
            range.End = WordDocument.Content.End;
1897
            range.End = WordDocument.Content.End;
1158
            range.Cut();
1898
            range.Cut();
1159
            // try and ensure that no heading style is left in place following the removal
1899
            // try and ensure that no heading style is left in place following the removal
1160
            object style = styleName_Body1;
1900
            object style = EA_Constants.styleName_Body1;
1161
            range.set_Style(ref style);
1901
            range.set_Style(ref style);
1162
         }
1902
         }
1163
      }
1903
      }
1164
 
1904
 
1165
 
1905
 
Line 1176... Line 1916...
1176
 
1916
 
1177
         // The EA_DocGenPackageLink can contain a list of GUIDs in its notes section
1917
         // The EA_DocGenPackageLink can contain a list of GUIDs in its notes section
1178
         // that point to model structure outside of the localised structure forming the
1918
         // that point to model structure outside of the localised structure forming the
1179
         // document. This enables a document to grab content from other external models
1919
         // document. This enables a document to grab content from other external models
1180
         // as long as they are loaded into the repository.
1920
         // as long as they are loaded into the repository.
1181
         if (theElement.Name.StartsWith("EA_DocGenPackageLink"))
1921
         if (theElement.Name.StartsWith(EA_Constants.EA_DocGenPackageLink))
1182
         {
1922
         {
1183
            processPackageLink( theElement, recurse_level );
1923
            processPackageLink( theElement, recurse_level );
1184
         }
1924
         }
1185
 
1925
 
1186
            // The EA_DocGenDiagramLink can contain a list of GUIDs in its notes section
1926
            // The EA_DocGenDiagramLink can contain a list of GUIDs in its notes section
1187
            // that point to diagram elements anywhere in the repository.
1927
            // that point to diagram elements anywhere in the repository.
1188
         else if (theElement.Name.StartsWith("EA_DocGenDiagramLink"))
1928
         else if (theElement.Name.StartsWith(EA_Constants.EA_DocGenDiagramLink))
1189
         {
1929
         {
1190
            processDiagramLink( theElement );
1930
            processDiagramLink( theElement );
1191
         }
1931
         }
1192
 
1932
 
1193
            // The EA_DocGenDiagramLink can contain a list of GUIDs in its notes section
1933
            // The EA_DocGenDiagramLink can contain a list of GUIDs in its notes section
1194
            // that point to diagram elements anywhere in the repository.
1934
            // that point to diagram elements anywhere in the repository.
1195
         else if (theElement.Name.StartsWith("EA_DocGenElementLink"))
1935
         else if (theElement.Name.StartsWith(EA_Constants.EA_DocGenElementLink))
1196
         {
1936
         {
1197
            processElementLink( theElement, recurse_level );
1937
            processElementLink( theElement, recurse_level );
1198
         }
1938
         }
1199
 
1939
 
1200
            // The EA_DocGenTable element can contain table content in its notes section
1940
            // The EA_DocGenTable element can contain table content in its notes section
1201
            // and must be dealt with in a special way.
1941
            // and must be dealt with in a special way.
1202
         else if (theElement.Name.StartsWith("EA_DocGenTable"))
1942
         else if (theElement.Name.StartsWith(EA_Constants.EA_DocGenTable))
1203
         {
1943
         {
1204
            processTableElement( theElement, recurse_level );
1944
            processTableElement( theElement, recurse_level );
1205
         }
1945
         }
1206
 
1946
 
1207
            // The EA_DocGenText element can contain text content in its notes section
1947
            // The EA_DocGenText element can contain text content in its notes section
1208
            // that must be appended to the doc in Body 1 style within the current
1948
            // that must be appended to the doc in Body 1 style within the current
1209
            // section.
1949
            // section.
1210
         else if (theElement.Name.StartsWith("EA_DocGenText"))
1950
         else if (theElement.Name.StartsWith(EA_Constants.EA_DocGenText))
1211
         {
1951
         {
1212
            processTextElement( theElement, recurse_level );
1952
            processTextElement( theElement, recurse_level );
1213
         }
1953
         }
1214
 
1954
 
1215
         else if (theElement.Name.StartsWith("EA_DocGenRelationshipMatrix"))
1955
         else if (theElement.Name.StartsWith(EA_Constants.EA_DocGenRelationshipMatrix))
1216
         {
1956
         {
1217
            processRelationshipMatrixElement( theElement, recurse_level );
1957
            processRelationshipMatrixElement( theElement, recurse_level );
1218
         }
1958
         }
1219
 
1959
 
-
 
1960
         else if (theElement.Name.StartsWith(EA_Constants.EA_DocGenTestLink))
-
 
1961
         {
-
 
1962
            processTestLink( theElement, recurse_level );
1220
         else
1963
         }
-
 
1964
 
-
 
1965
         else if (theElement.Name.StartsWith(EA_Constants.EA_DocGenTestTraceability))
-
 
1966
         {
-
 
1967
            processTestTraceability( theElement, recurse_level );
-
 
1968
         }
-
 
1969
 
-
 
1970
 
-
 
1971
            // we are aware of the other ERG EA add-in, EA_ReqPro! That other add-in creates 
-
 
1972
            // ReqProDB stereotyped elements. Never consume them in the document generation process.
-
 
1973
         else if ( theElement.Stereotype != EA_Constants.stereotype_ReqProDB )    
1221
         {
1974
         {
1222
            generateElementContent( theElement, recurse_level );
1975
            generateElementContent( theElement, recurse_level );
1223
         }      
1976
         }      
1224
      }
1977
      }
1225
 
1978
 
Line 1246... Line 1999...
1246
         if (recurse_level > 9)
1999
         if (recurse_level > 9)
1247
         {
2000
         {
1248
            throw new System.StackOverflowException("Max Recursion Depth (9) Exceeded" );
2001
            throw new System.StackOverflowException("Max Recursion Depth (9) Exceeded" );
1249
         }
2002
         }
1250
 
2003
 
-
 
2004
         // If we have reached a "Detailed Design" section, we should begin to capture in a list, all public 
-
 
2005
         // classes so that we know later on what classes need to be considered in the unit testing section
-
 
2006
         // of the document, assuming that this is a s/w design document being generated ofcoarse. 
-
 
2007
         bool nameStartedWithDetailedDesign = false;
-
 
2008
         if (recordingNonPrivateClasses == false && thePackage.Name.StartsWith("Detailed Design"))
-
 
2009
         {
-
 
2010
            recordingNonPrivateClasses = true;
-
 
2011
            nameStartedWithDetailedDesign = true;
-
 
2012
         }
-
 
2013
 
1251
         // generate package heading and description. This may, depending on the package name,
2014
         // generate package heading and description. This may, depending on the package name,
1252
         // consume the elements in the package. If it does not, then consume them (and any diagrams)
2015
         // consume the elements in the package. If it does not, then consume them (and any diagrams)
1253
         // locally here.
2016
         // locally here.
1254
         if (false == generatePackageHeadingAndDescription( thePackage, recurse_level ))
2017
         if (false == generatePackageHeadingAndDescription( thePackage, recurse_level ))
1255
         {
2018
         {
Line 1277... Line 2040...
1277
         foreach(EA.Package lowerLevelPackage in thePackage.Packages)
2040
         foreach(EA.Package lowerLevelPackage in thePackage.Packages)
1278
         {
2041
         {
1279
            // recurse
2042
            // recurse
1280
            parse_package(lowerLevelPackage, recurse_level);
2043
            parse_package(lowerLevelPackage, recurse_level);
1281
         }
2044
         }
1282
         
-
 
1283
 
2045
 
-
 
2046
         // If appropriate, turn off non-private class accumulation.
1284
         if (rootPackageWasSkipped == false)
2047
         if (nameStartedWithDetailedDesign)
1285
            recurse_level--;
2048
            recordingNonPrivateClasses = false;
1286
      }
2049
      }
1287
 
2050
 
1288
 
2051
 
1289
      /// <summary>
2052
      /// <summary>
1290
      /// This is the overall generate document method. It creates a word document from 
2053
      /// This is the overall generate document method. It creates a word document from 
Line 1319... Line 2082...
1319
            WordApp.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;
2082
            WordApp.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;
1320
 
2083
 
1321
            // Create a document from the input template
2084
            // Create a document from the input template
1322
            WordDocument = WordApp.Documents.Add(ref template, ref newTemplate, ref docType, ref visible);
2085
            WordDocument = WordApp.Documents.Add(ref template, ref newTemplate, ref docType, ref visible);
1323
   
2086
   
-
 
2087
            TableUtils.AcceptWordAppAndDoc(WordApp, WordDocument);
-
 
2088
            TextUtils.AcceptWordAppAndDoc(WordApp, WordDocument);
-
 
2089
            StyleUtils.AcceptWordAppAndDoc(WordApp, WordDocument);
-
 
2090
 
1324
            // Remove all old content from the input document/template. Note that this assumes
2091
            // Remove all old content from the input document/template. Note that this assumes
1325
            // that content will begin at section 1 with the title "Introduction" and it will have
2092
            // that content will begin at section 1 with the title "Introduction" and it will have
1326
            // "Heading 1" style.
2093
            // "Heading 1" style.
1327
            removeExistingDocumentContent();
2094
            removeExistingDocumentContent();
1328
 
2095
 
1329
            // turn off grammar and spell checking
2096
            // turn off grammar and spell checking
1330
            WordDocument.GrammarChecked = false;
2097
            WordDocument.GrammarChecked = false;
1331
            WordDocument.SpellingChecked = false;
2098
            WordDocument.SpellingChecked = false;
1332
        
2099
        
-
 
2100
            // arm the public class list accumulator.
-
 
2101
            recordingNonPrivateClasses = false;
-
 
2102
            nonPrivateClasses = new ArrayList();
-
 
2103
            classesWithUnitTests = new ArrayList();
-
 
2104
 
1333
            // If the input template does not contain the styles needed for requirement documents, 
2105
            // If the input template does not contain the styles needed for requirement documents, 
1334
            // programmatically create them just in case.
2106
            // programmatically create them just in case.
1335
            createRequirementStylesIfNecessary();
2107
            StyleUtils.createRequirementStylesIfNecessary();
1336
 
2108
 
1337
            // Parse EA_DocGen Document Model. The parent package is the document model itself
2109
            // Parse EA_DocGen Document Model. The parent package is the document model itself
1338
            // and the packages within it are the top level packages only.
2110
            // and the packages within it are the top level packages only.
1339
            // Question: do we have to parse diagrams and elements at this top level? So far,
2111
            // Question: do we have to parse diagrams and elements at this top level? So far,
1340
            // this has been found to be unecessary, but you never know. For now, dont do it.
2112
            // this has been found to be unecessary, but you never know. For now, dont do it.
1341
            foreach(EA.Package thePackage in EA_ParentPackage.Packages)
2113
            foreach(EA.Package thePackage in EA_ParentPackage.Packages)
1342
            {
2114
            {
1343
               parse_package(thePackage, 0);
2115
               parse_package(thePackage, 0);
1344
            }
2116
            }
1345
 
2117
 
-
 
2118
            // for design docs, a user may have used the test traceability element in their document model,
-
 
2119
            // which means that now we are finished with parse 1 of the document, we can complete the traceability
-
 
2120
            // table (if any) that was begun when that special element was first encountered.
-
 
2121
            completeTestTraceability();
-
 
2122
 
-
 
2123
            // Save the document to the output file before we try and update the fields. This is because
-
 
2124
            // I have seen Fields.Update() fail on a few occasions and it is very annoying
-
 
2125
            // to lose what has thus far been generated.
-
 
2126
            WordDocument.SaveAs( ref outputFilename, 
-
 
2127
               ref nothing, ref nothing, ref nothing, ref nothing, 
-
 
2128
               ref nothing, ref nothing, ref nothing, ref nothing,
-
 
2129
               ref nothing, ref nothing, ref nothing, ref nothing,
-
 
2130
               ref nothing, ref nothing, ref nothing);
1346
 
2131
 
1347
            // Select the entire document, and Update all fields, including Table of Contents
2132
            object noSave = Word.WdSaveOptions.wdDoNotSaveChanges;
1348
            // and then collapse the selection in case user wants to view the document, because
2133
            object format = Word.WdOriginalFormat.wdWordDocument;
1349
            // they wont want to see the inverse video of the selection.
2134
            WordDocument.Close(ref noSave, ref format, ref nothing);
-
 
2135
 
1350
            WordApp.Selection.WholeStory();
2136
            // Re-load the document to update the fields. For some as yet unknown reason, doing this 
1351
            WordApp.Selection.Fields.Update();
2137
            // sometimes fails, but by doing it in a re-loaded instance of the word document
1352
            object direction = Word.WdCollapseDirection.wdCollapseEnd;
2138
            // the failures seem to be reduced.
1353
            WordApp.Selection.Collapse(ref direction);
2139
            WordDocument = WordApp.Documents.Add(ref outputFilename, ref newTemplate, ref docType, ref visible);
1354
 
-
 
1355
            // Save the document to the output file
2140
            WordDocument.Fields.Update();
1356
            WordDocument.SaveAs( ref outputFilename, 
2141
            WordDocument.SaveAs( ref outputFilename, 
1357
               ref nothing, ref nothing, ref nothing, ref nothing, 
2142
               ref nothing, ref nothing, ref nothing, ref nothing, 
1358
               ref nothing, ref nothing, ref nothing, ref nothing,
2143
               ref nothing, ref nothing, ref nothing, ref nothing,
1359
               ref nothing, ref nothing, ref nothing, ref nothing,
2144
               ref nothing, ref nothing, ref nothing, ref nothing,
1360
               ref nothing, ref nothing, ref nothing);
2145
               ref nothing, ref nothing, ref nothing);
1361
 
2146
 
1362
            // Tell user the process completed ok
2147
            // Tell user the process completed ok
1363
            textBox_progress.AppendText( "---Completed---" );
2148
            textBox_progress.AppendText( "---Completed---" );
1364
            MessageBox.Show("Document Generation Complete");
2149
            MessageBox.Show("Document Generation Complete");
1365
            
-
 
1366
 
-
 
1367
         }
2150
         }
1368
         catch (Exception createTheWordDoc_exception)
2151
         catch (Exception createTheWordDoc_exception)
1369
         {
2152
         {
1370
            MessageBox.Show("Document Generation Failed\n\n" + createTheWordDoc_exception.Message);
2153
            MessageBox.Show("Document Generation Failed\n\n" + createTheWordDoc_exception.Message);
1371
         }
2154
         }
1372
 
2155
 
1373
         // restore security settings
2156
         // restore security settings
1374
         WordApp.AutomationSecurity = securityBefore;
2157
         WordApp.AutomationSecurity = securityBefore;
1375
      }
2158
      }
1376
 
2159
 
1377
      /// <summary>
-
 
1378
      /// Creates a wdStyleTypeParagraph based style
-
 
1379
      /// </summary>
-
 
1380
      /// <param name="newStyleName"></param>
-
 
1381
      /// <param name="followingStyleName"></param>
-
 
1382
      /// <param name="baseStyle"></param>
-
 
1383
      /// <returns></returns>
-
 
1384
      private Word.Style createParagrapghStyle(string newStyleName, 
-
 
1385
                                               string followingStyleName, 
-
 
1386
                                               Word.Style baseStyle)
-
 
1387
      {
-
 
1388
         Word.Style s = getStyle(newStyleName);
-
 
1389
         if (s == null)
-
 
1390
         {
-
 
1391
            object o_styleType = Word.WdStyleType.wdStyleTypeParagraph;
-
 
1392
            s = WordDocument.Styles.Add(newStyleName, ref o_styleType);
-
 
1393
 
-
 
1394
            object o_baseStyle = baseStyle.NameLocal;
-
 
1395
            object o_followingStyle = followingStyleName;
-
 
1396
            s.set_BaseStyle(ref o_baseStyle);
-
 
1397
            s.set_NextParagraphStyle(ref o_followingStyle);
-
 
1398
 
-
 
1399
            s.Font = baseStyle.Font;
-
 
1400
            s.ParagraphFormat = baseStyle.ParagraphFormat;
-
 
1401
            s.LanguageID = Word.WdLanguageID.wdEnglishAUS;
-
 
1402
            s.NoProofing = 0;
-
 
1403
            s.Frame.Delete();
-
 
1404
            s.NoSpaceBetweenParagraphsOfSameStyle = false;
-
 
1405
            
-
 
1406
         }
-
 
1407
         return s;
-
 
1408
      }
-
 
1409
 
-
 
1410
      /// <summary>
-
 
1411
      /// Creates a wdStyleTypeCharacter based style
-
 
1412
      /// </summary>
-
 
1413
      /// <param name="newStyleName"></param>
-
 
1414
      /// <param name="baseStyle"></param>
-
 
1415
      /// <returns></returns>
-
 
1416
      private Word.Style createCharacterStyle(string newStyleName, Word.Style baseStyle)
-
 
1417
      {
-
 
1418
         Word.Style s = getStyle(newStyleName);
-
 
1419
         if (s == null)
-
 
1420
         {
-
 
1421
            object o_styleType = Word.WdStyleType.wdStyleTypeCharacter;
-
 
1422
            s = WordDocument.Styles.Add(newStyleName, ref o_styleType);
-
 
1423
            object o_baseStyle = baseStyle.NameLocal;
-
 
1424
            s.set_BaseStyle(ref o_baseStyle);
-
 
1425
            s.Font = baseStyle.Font;
-
 
1426
            s.LanguageID = Word.WdLanguageID.wdEnglishAUS;
-
 
1427
            s.NoProofing = 0;
-
 
1428
         }
-
 
1429
         return s;
-
 
1430
      }
-
 
1431
 
-
 
1432
 
-
 
1433
      /// <summary>
-
 
1434
      /// Creates the styles needed for generating requirement documentation, if they do not
-
 
1435
      /// already exist.
-
 
1436
      /// </summary>
-
 
1437
      private void createRequirementStylesIfNecessary()
-
 
1438
      {
-
 
1439
         Word.Style s_Body1 = getStyle(styleName_Body1);
-
 
1440
         if (s_Body1 != null)
-
 
1441
         {
-
 
1442
            // APPROVED ///////////////////////////////////////////////////////////////////////////////////////////////
-
 
1443
            Word.Style s_ReqAppBody = createParagrapghStyle(styleName_ReqAppBody, styleName_ReqAppBody, s_Body1);
-
 
1444
            if (s_ReqAppBody != null)
-
 
1445
            {
-
 
1446
               // No changes needed - this is just a copy of Body 1
-
 
1447
            }
-
 
1448
         
-
 
1449
            Word.Style s_ReqAppHdr = null;
-
 
1450
            if (s_ReqAppBody != null)
-
 
1451
            {
-
 
1452
               s_ReqAppHdr = createParagrapghStyle(styleName_ReqAppHdr, styleName_ReqAppBody, s_Body1);
-
 
1453
               if (s_ReqAppHdr != null)
-
 
1454
               {
-
 
1455
                  // Indent:Hanging: 2.5cm, Space After: 3pt, Keep with next, Tabs: 16.5cm, Right
-
 
1456
                  s_ReqAppHdr.ParagraphFormat.FirstLineIndent = WordApp.CentimetersToPoints((float)-2.5);
-
 
1457
                  s_ReqAppHdr.ParagraphFormat.SpaceAfter = 3;
-
 
1458
                  s_ReqAppHdr.ParagraphFormat.KeepWithNext = (int)MsoTriState.msoTrue;
-
 
1459
                  s_ReqAppHdr.ParagraphFormat.TabStops.ClearAll();
-
 
1460
                  object alignment = Word.WdTabAlignment.wdAlignTabRight;
-
 
1461
                  object leader = Word.WdTabLeader.wdTabLeaderSpaces;
-
 
1462
                  s_ReqAppHdr.ParagraphFormat.TabStops.Add( WordApp.CentimetersToPoints((float)16.5), ref alignment, ref leader );
-
 
1463
               }
-
 
1464
            }
-
 
1465
 
-
 
1466
            // PROPOSED ///////////////////////////////////////////////////////////////////////////////////////////////
-
 
1467
            Word.Style s_ReqPropBody = null;
-
 
1468
            if (s_ReqAppBody != null)
-
 
1469
            {
-
 
1470
               s_ReqPropBody = createParagrapghStyle(styleName_ReqPropBody, styleName_ReqPropBody, s_ReqAppBody );
-
 
1471
               if (s_ReqPropBody != null)
-
 
1472
               {
-
 
1473
                  // Font: Italic
-
 
1474
                  s_ReqPropBody.Font.Italic = (int)MsoTriState.msoTrue;
-
 
1475
               }
-
 
1476
            }
-
 
1477
 
-
 
1478
            if (s_ReqAppHdr != null && s_ReqPropBody != null)
-
 
1479
            {
-
 
1480
               Word.Style s_ReqPropHdr = createParagrapghStyle(styleName_ReqPropHdr, styleName_ReqPropBody, s_ReqAppHdr );
-
 
1481
               if (s_ReqPropHdr != null)
-
 
1482
               {
-
 
1483
                  // Font: Italic
-
 
1484
                  s_ReqPropHdr.Font.Italic = (int)MsoTriState.msoTrue;
-
 
1485
               }
-
 
1486
            }
-
 
1487
 
-
 
1488
            // REJECTED ///////////////////////////////////////////////////////////////////////////////////////////////
-
 
1489
            Word.Style s_ReqRejBody = null;
-
 
1490
            if (s_ReqAppBody != null)
-
 
1491
            {
-
 
1492
               s_ReqRejBody = createParagrapghStyle(styleName_ReqRejBody, styleName_ReqRejBody, s_ReqAppBody );
-
 
1493
               if (s_ReqRejBody != null)
-
 
1494
               {
-
 
1495
                  // Font: Italic
-
 
1496
                  s_ReqRejBody.Font.StrikeThrough = (int)MsoTriState.msoTrue;
-
 
1497
               }
-
 
1498
            }
-
 
1499
 
-
 
1500
            if (s_ReqAppHdr != null && s_ReqRejBody != null)
-
 
1501
            {
-
 
1502
               Word.Style s_ReqRejHdr = createParagrapghStyle(styleName_ReqRejHdr, styleName_ReqRejBody, s_ReqAppHdr );
-
 
1503
               if (s_ReqRejHdr != null)
-
 
1504
               {
-
 
1505
                  // Font: Italic
-
 
1506
                  s_ReqRejHdr.Font.StrikeThrough = (int)MsoTriState.msoTrue;
-
 
1507
               }
-
 
1508
            }
-
 
1509
 
-
 
1510
            // REQUIREMENT NAME ///////////////////////////////////////////////////////////////////////////////////////////////
-
 
1511
            Word.Style s_DefParaFont = getStyle("Default Paragraph Font");
-
 
1512
            if (s_DefParaFont != null)
-
 
1513
            {
-
 
1514
               Word.Style s_ReqName = createCharacterStyle(styleName_ReqName, s_DefParaFont );
-
 
1515
               if (s_ReqName != null)
-
 
1516
               {
-
 
1517
                  s_ReqName.Font.Bold = (int)MsoTriState.msoTrue;
-
 
1518
               }
-
 
1519
            }
-
 
1520
         }
-
 
1521
      }
-
 
1522
 
-
 
1523
      /// <summary>
-
 
1524
      /// Generates the text for requirements.  This uses custom styles to format the text 
-
 
1525
      /// rather than formatting it in code.
-
 
1526
      /// </summary>
-
 
1527
      private void generateRequirementText( EA.Element theElement )
-
 
1528
      {
-
 
1529
         string reqID = "";
-
 
1530
         string reqShortDesc = "";
-
 
1531
         string reqNotes = "";
-
 
1532
         string reqStatusText = "";
-
 
1533
         string reqHeadingStyle ="";
-
 
1534
         string reqParaStyle = "";
-
 
1535
         object reqNameStyle = styleName_ReqName;
-
 
1536
         Word.Range shortDescRange;
-
 
1537
 
-
 
1538
         // Set the style depending on the status
-
 
1539
         switch ( theElement.Status )
-
 
1540
         {
-
 
1541
            case "Proposed":
-
 
1542
               reqStatusText = "(Proposed)";
-
 
1543
               reqHeadingStyle = styleName_ReqPropHdr;
-
 
1544
               reqParaStyle    = styleName_ReqPropBody;
-
 
1545
               break;
-
 
1546
 
-
 
1547
            case "Rejected":
-
 
1548
               reqHeadingStyle = styleName_ReqRejHdr;
-
 
1549
               reqParaStyle    = styleName_ReqRejBody;
-
 
1550
               break;
-
 
1551
 
-
 
1552
            case "Approved":
-
 
1553
               reqStatusText = "(Phase " + theElement.Phase + ")";
-
 
1554
               reqHeadingStyle = styleName_ReqAppHdr;
-
 
1555
               reqParaStyle    = styleName_ReqAppBody;
-
 
1556
               break;
-
 
1557
 
-
 
1558
            default:
-
 
1559
               reqStatusText = "(" + theElement.Status + ")(Phase " + theElement.Phase + ")";
-
 
1560
               reqHeadingStyle = styleName_ReqAppHdr;
-
 
1561
               reqParaStyle    = styleName_ReqAppBody;
-
 
1562
               break;
-
 
1563
         }
-
 
1564
 
-
 
1565
         // Pull out the ID from the name
-
 
1566
         int pos = theElement.Name.IndexOf( " ", 0, theElement.Name.Length );
-
 
1567
         reqID = theElement.Name.Substring( 0, pos );
-
 
1568
 
-
 
1569
         // Pull out the short description from the rest of the name
-
 
1570
         reqShortDesc = theElement.Name.Substring( pos, theElement.Name.Length-pos );
-
 
1571
         reqShortDesc = reqShortDesc.Trim();
-
 
1572
 
-
 
1573
         // Pull out the notes
-
 
1574
         reqNotes = theElement.Notes.ToString();
-
 
1575
 
-
 
1576
         // Add the text
-
 
1577
         appendAndSelectText( reqID + '\t', reqHeadingStyle );
-
 
1578
         appendAndSelectText( reqShortDesc, reqHeadingStyle, true );
-
 
1579
         shortDescRange = WordRange;
-
 
1580
         appendAndSelectText( '\t' + reqStatusText, reqHeadingStyle, true );
-
 
1581
 
-
 
1582
         //reapply the name char style to the short desc.
-
 
1583
         shortDescRange.Start = shortDescRange.Start-1;
-
 
1584
         shortDescRange.End = WordRange.Start-1;
-
 
1585
         shortDescRange.set_Style( ref reqNameStyle );
-
 
1586
 
-
 
1587
         appendAndSelectText( reqNotes, reqParaStyle );
-
 
1588
 
-
 
1589
      }
-
 
1590
 
-
 
1591
 
2160
 
1592
      /// <summary>
2161
      /// <summary>
1593
      /// Class to sort EA elements alphabetically, in a case insensitive way.
2162
      /// Class to sort EA elements alphabetically, in a case insensitive way.
1594
      /// This is used by the processRelationshipMatrixElement method.
2163
      /// This is used by the processRelationshipMatrixElement method.
1595
      /// </summary>
2164
      /// </summary>
Line 1602... Line 2171...
1602
            else
2171
            else
1603
               return 0;
2172
               return 0;
1604
         }
2173
         }
1605
      }
2174
      }
1606
 
2175
 
1607
      /// <summary>
2176
 
1608
      /// This function will insert a relationship matrix table into the document, built from content
-
 
1609
      /// specified in options that are provided in the notes section of the special element that
-
 
1610
      /// has led to this function being called.
2177
      public class attributeSortByPos : IComparer
1611
      /// </summary>
-
 
1612
      /// <param name="theElement"></param>
-
 
1613
      /// <param name="recurse_level"></param>
-
 
1614
      private void processRelationshipMatrixElement( EA.Element theElement, int recurse_level )
-
 
1615
      {
2178
      {
1616
         int tableNum = 0;
-
 
1617
         Word.Table table = null;
-
 
1618
 
-
 
1619
         // process the options for the relationship matrix
2179
         int IComparer.Compare( object x, object y)
1620
         EA_RelationshipMatrix EA_RelMatrix = new EA_RelationshipMatrix(EA_Utils);
-
 
1621
         if (!EA_RelMatrix.processRelationshipMatrixOptions( theElement ))
-
 
1622
         {
2180
         {
1623
            return;  // must have been an error
2181
            if (x!=null & y!= null)
-
 
2182
               return ((EA.Attribute)x).Pos - ((EA.Attribute)y).Pos;
-
 
2183
            else
-
 
2184
               return 0;
1624
         }
2185
         }
-
 
2186
      }
1625
 
2187
 
1626
         // Scan the fromPackage to find out how many elements are present and so how many
-
 
1627
         // rows the matrix table will need
-
 
1628
         ElementAccumulator fromLister = new ElementAccumulator(EA_RelMatrix.fromElementTypes);
-
 
1629
         EA_Utils.findAndProcessPackageElements( EA_RelMatrix.fromPackage, fromLister, EA_RelMatrix.fromPackageRecursion );
-
 
1630
 
-
 
1631
         // Sort the "from" elements
-
 
1632
         elementSortByName sorter = new elementSortByName();
-
 
1633
         fromLister.Elements.Sort( sorter );
-
 
1634
         
-
 
1635
         // dictionary to support to-from table construction.
-
 
1636
         ArrayList fromToDictionary = new ArrayList();
-
 
1637
 
-
 
1638
         
-
 
1639
         bool needFromToTable = false;
-
 
1640
         if (EA_RelMatrix.fromToTableTitle != null && EA_RelMatrix.fromToTableTitle.Length > 0)
-
 
1641
            needFromToTable = true;
-
 
1642
 
-
 
1643
         bool needToFromTable = false;
-
 
1644
         if (EA_RelMatrix.toFromTableTitle != null && EA_RelMatrix.toFromTableTitle.Length > 0)
-
 
1645
            needToFromTable = true;
-
 
1646
 
-
 
1647
         if (needFromToTable)
-
 
1648
         {
-
 
1649
            if (EA_RelMatrix.fromIntroText != null && EA_RelMatrix.fromIntroText.Length > 0)
-
 
1650
            {
-
 
1651
               appendAndSelectText( EA_RelMatrix.fromIntroText, styleName_Body1 );
-
 
1652
            }
-
 
1653
 
-
 
1654
            // create the from-to table in the word doc
-
 
1655
            tableNum = createTable( EA_RelMatrix.fromToTableTitle, fromLister.Elements.Count + 1, 2 );
-
 
1656
            table = WordDocument.Tables[tableNum];
-
 
1657
            
-
 
1658
            table.Cell(1,1).Range.Text = EA_RelMatrix.fromColumnTitle;
-
 
1659
            table.Cell(1,1).Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
-
 
1660
            table.Cell(1,1).Range.Font.Bold = 1;
-
 
1661
            table.Cell(1,2).Range.Text = EA_RelMatrix.toColumnTitle;
-
 
1662
            table.Cell(1,2).Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
-
 
1663
            table.Cell(1,2).Range.Font.Bold = 1;
-
 
1664
         }
-
 
1665
 
2188
 
1666
         // Add from-to content to the from-to table. 
2189
      public class methodSortByPos : IComparer
1667
         // NOTE: this code has to execute even if no from-to table is needed, in order to support the
-
 
1668
         // generation of a to-from table, assuming the user has requested one.
-
 
1669
         int row = 2;
2190
      {
1670
         foreach(EA.Element fromElement in fromLister.Elements)
2191
         int IComparer.Compare( object x, object y)
1671
         {
2192
         {
1672
            // Output the left hand column text to the from-to table, if one has been requested
-
 
1673
            if (needFromToTable)
-
 
1674
               table.Cell(row,1).Range.Text = fromElement.Name;
-
 
1675
 
-
 
1676
            // look at the elements connection collection to find references to the
-
 
1677
            // destination elements
-
 
1678
            EA.Collection conCollection = fromElement.Connectors;
-
 
1679
            bool firstCon = true;
-
 
1680
            foreach (EA.Connector thisCon in conCollection)
-
 
1681
            {
-
 
1682
               EA.Element destE = EA_Repository.GetElementByID( thisCon.SupplierID );
-
 
1683
               if (destE == null)
2193
            if (x!=null & y!= null)
1684
                  continue;
-
 
1685
 
-
 
1686
               // ignore self-referential connections
-
 
1687
               if (fromElement.ElementID == thisCon.SupplierID)
2194
               return ((EA.Method)x).Pos - ((EA.Method)y).Pos;
1688
                  continue;
-
 
1689
 
-
 
1690
               // if the destination element is of a type that the user has requested to include...
-
 
1691
               if (!EA_RelMatrix.toElementTypes.Contains( destE.Type ))
-
 
1692
                  continue;
-
 
1693
 
-
 
1694
               // Output the right hand column text to the from-to table, if one has been requested
-
 
1695
               if (needFromToTable)
-
 
1696
               {
2195
            else
1697
                  if (firstCon)
-
 
1698
                  {
-
 
1699
                     firstCon = false;
-
 
1700
                     table.Cell(row,2).Range.Text = destE.Name;
-
 
1701
                  }
-
 
1702
                  else
-
 
1703
                  {
-
 
1704
                     table.Cell(row,2).Range.Text += destE.Name;
-
 
1705
                  }
2196
               return 0;
1706
               }
-
 
1707
 
-
 
1708
               // Capture the from-to relationship in a dictionary where the key is the
-
 
1709
               // ID of the destination element, and the value is the from element name.
-
 
1710
               // This dictionary will enable rapid construction of the to-from table if
-
 
1711
               // the user has requested it, from the exact same relationship info used
-
 
1712
               // to construct the from-to table.
-
 
1713
               if (needToFromTable)
-
 
1714
               {
-
 
1715
                  DictionaryEntry newEntry = new DictionaryEntry(destE.ElementID, fromElement.Name);
-
 
1716
                  fromToDictionary.Add( newEntry );
-
 
1717
               }
-
 
1718
            }
-
 
1719
            row++;
-
 
1720
         }
2197
         }
-
 
2198
      }
-
 
2199
  
1721
 
2200
 
1722
         // Does user want a to-from table ?
2201
      public class parameterSortByPos : IComparer
-
 
2202
      {
1723
         if (needToFromTable)
2203
         int IComparer.Compare( object x, object y)
1724
         {
2204
         {
1725
            ElementAccumulator toLister = new ElementAccumulator(EA_RelMatrix.toElementTypes);
-
 
1726
            EA_Utils.findAndProcessPackageElements( EA_RelMatrix.toPackage, toLister, EA_RelMatrix.toPackageRecursion );
-
 
1727
 
-
 
1728
            // Sort the "to" elements
-
 
1729
            toLister.Elements.Sort( sorter );
-
 
1730
 
-
 
1731
            if (EA_RelMatrix.toIntroText != null && EA_RelMatrix.toIntroText.Length > 0)
-
 
1732
            {
-
 
1733
               appendAndSelectText( EA_RelMatrix.toIntroText, styleName_Body1 );
-
 
1734
            }
-
 
1735
 
-
 
1736
            // create the table in the word doc
-
 
1737
            tableNum = createTable( EA_RelMatrix.toFromTableTitle, toLister.Elements.Count + 1, 2 );
-
 
1738
            table = WordDocument.Tables[tableNum];
-
 
1739
            
-
 
1740
            table.Cell(1,1).Range.Text = EA_RelMatrix.toColumnTitle;
-
 
1741
            table.Cell(1,1).Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
-
 
1742
            table.Cell(1,1).Range.Font.Bold = 1;
-
 
1743
            table.Cell(1,2).Range.Text = EA_RelMatrix.fromColumnTitle;
-
 
1744
            table.Cell(1,2).Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
-
 
1745
            table.Cell(1,2).Range.Font.Bold = 1;
-
 
1746
 
-
 
1747
            // To make the to-from table, we use the dictionary that was built when making the from-to
-
 
1748
            // table. The dictionary will allow rapid determination of what "from" items belong to each
-
 
1749
            // "to" item, without us having to go back to EA and enquire on the database.
-
 
1750
            row = 2;
-
 
1751
            foreach(EA.Element toElement in toLister.Elements)
-
 
1752
            {
-
 
1753
               // left-column cell content
-
 
1754
               table.Cell(row,1).Range.Text = toElement.Name;
-
 
1755
 
-
 
1756
               // right-column cell content
-
 
1757
               bool firstCon = true;
-
 
1758
               foreach (DictionaryEntry de in fromToDictionary)
-
 
1759
               {
-
 
1760
                  if ((int)de.Key == toElement.ElementID)
-
 
1761
                  {
-
 
1762
                     if (firstCon)
2205
            if (x!=null & y!= null)
1763
                     {
-
 
1764
                        firstCon = false;
-
 
1765
                        table.Cell(row,2).Range.Text = (string)de.Value;
-
 
1766
                     }
-
 
1767
                     else
-
 
1768
                     {
-
 
1769
                        table.Cell(row,2).Range.Text += (string)de.Value;
2206
               return ((EA.Parameter)x).Position - ((EA.Parameter)y).Position;
1770
                     }
-
 
1771
                  }
-
 
1772
               }
2207
            else
1773
               row++;
2208
               return 0;
1774
            }
-
 
1775
         }
2209
         }
1776
      }
2210
      }
1777
 
2211
 
1778
   
-
 
1779
 
2212
 
1780
      #endregion
2213
      #endregion
1781
   }
2214
   }
1782
}
2215
}