Subversion Repositories DevTools

Rev

Rev 2128 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2128 Rev 2136
Line 1... Line 1...
1
using System;
1
using System;
2
using System.Collections;
2
using System.Collections;
3
using System.Text;
3
using System.Text;
-
 
4
using System.Web;
4
using Word;
5
using System.IO;
-
 
6
using Microsoft.Office.Interop.Word;
5
 
7
 
6
namespace EA_DocGen
8
namespace EA_DocGen
7
{
9
{
8
	/// <summary>
10
	/// <summary>
9
	/// Summary description for TextualContent.
11
	/// Summary description for TextualContent.
Line 16... Line 18...
16
      {
18
      {
17
         string s_trim_newlines = "\r\n";
19
         string s_trim_newlines = "\r\n";
18
         trim_newlines = s_trim_newlines.ToCharArray();
20
         trim_newlines = s_trim_newlines.ToCharArray();
19
      }
21
      }
20
 
22
 
21
      public static Word.Range appendDescription(string wordText)
23
       public static Range appendDescription(string wordText)
22
      {
24
      {
23
         return appendDescription(wordText, false);
25
         return appendDescription(wordText, false);
24
      }
26
      }
25
 
27
 
26
      public static Word.Range appendDescription(string wordText, bool continuation)
28
       public static Range appendDescription(string wordText, bool continuation)
27
      {
29
      {
28
         return appendDescription(wordText, EA_Constants.styleName_Body1, continuation);
30
         return appendDescription(wordText, EA_Constants.styleName_Body1, continuation);
29
      }
31
      }
30
 
32
 
31
      public static Word.Range appendDescription(string wordText, string styleName, bool continuation)
33
       public static Range appendDescription(string wordText, string styleName, bool continuation)
32
      {
34
      {
33
         Word.Range wr = null;
35
          Range wr = null;
34
 
36
 
35
         if (wordText != null && wordText.Length > 0)
37
         if (wordText != null && wordText.Length > 0)
36
         {
38
         {
37
            wr = appendAndSelectText(wordText, styleName, continuation);
39
            wr = appendAndSelectText(wordText, styleName, continuation);
38
         }
40
         }
Line 41... Line 43...
41
            wr = appendAndSelectText("Description missing!", styleName, continuation);
43
            wr = appendAndSelectText("Description missing!", styleName, continuation);
42
 
44
 
43
            if (wr.Characters.Last.Text.Equals("\r"))
45
            if (wr.Characters.Last.Text.Equals("\r"))
44
               wr.End = wr.End - 1;  // dont italicise the \r char at the end
46
               wr.End = wr.End - 1;  // dont italicise the \r char at the end
45
            wr.Font.Italic = 1;
47
            wr.Font.Italic = 1;
46
            wr.Font.Color = Word.WdColor.wdColorRed;
48
            wr.Font.Color = WdColor.wdColorRed;
47
         }
49
         }
48
         return wr;
50
         return wr;
49
      }
51
      }
50
 
52
 
51
 
53
 
Line 55... Line 57...
55
      /// the specified style formatting to it.
57
      /// the specified style formatting to it.
56
      /// </summary>
58
      /// </summary>
57
      /// <param name="wordText"></param>
59
      /// <param name="wordText"></param>
58
      /// <param name="styleText"></param>
60
      /// <param name="styleText"></param>
59
      /// <param name="continuation"></param>
61
      /// <param name="continuation"></param>
60
      public static Word.Range appendAndSelectText(string wordText, string styleText)
62
       public static Range appendAndSelectText(string wordText, string styleText)
61
      {
63
      {
62
         return appendAndSelectText(wordText, styleText, false );
64
         return appendAndSelectText(wordText, styleText, false );
63
      }
65
      }
64
 
66
 
65
 
67
 
66
      public static Word.Range appendAndSelectText(string wordText, string styleText, bool continuation )
68
       public static Range appendAndSelectText(string wordText, string styleText, bool continuation)
67
      {
69
      {
68
         if (wordText != null && wordText.Length > 0)
70
         if (wordText != null && wordText.Length > 0)
69
         {
71
         {
70
            Word.Range WordRange = null;
72
            Range WordRange = null;
71
            object startLocation;
73
            object startLocation;
72
            object endLocation;
74
            object endLocation;
73
 
75
 
74
            object style = styleText;
76
            object style = styleText;
75
            int i;
77
            int i;
Line 235... Line 237...
235
                  appendAndSelectText(theTest.AcceptanceCriteria, EA_Constants.styleName_Body1);
237
                  appendAndSelectText(theTest.AcceptanceCriteria, EA_Constants.styleName_Body1);
236
               }
238
               }
237
            }
239
            }
238
            else
240
            else
239
            {
241
            {
240
               Word.Range wr = appendAndSelectText("Test Cases missing!", EA_Constants.styleName_Body1);
242
               Range wr = appendAndSelectText("Test Cases missing!", EA_Constants.styleName_Body1);
241
               if (wr.Characters.Last.Text.Equals("\r"))
243
               if (wr.Characters.Last.Text.Equals("\r"))
242
                  wr.End = wr.End - 1;  // dont italicise the \r char at the end
244
                  wr.End = wr.End - 1;  // dont italicise the \r char at the end
243
               wr.Font.Italic = 1;
245
               wr.Font.Italic = 1;
244
               wr.Font.Color = Word.WdColor.wdColorRed;
246
               wr.Font.Color = WdColor.wdColorRed;
245
            }
247
            }
246
         }
248
         }
247
      }
249
      }
248
 
250
 
249
 
251
 
Line 276... Line 278...
276
      public static void SelectInsertionPointAtEndOfDocument()
278
      public static void SelectInsertionPointAtEndOfDocument()
277
      {
279
      {
278
         object unit;
280
         object unit;
279
         object extend;
281
         object extend;
280
 
282
 
281
         unit = Word.WdUnits.wdStory;
283
         unit = WdUnits.wdStory;
282
         extend = Word.WdMovementType.wdMove;
284
         extend = WdMovementType.wdMove;
283
         createWordDoc.WordApp.Selection.EndKey(ref unit, ref extend);
285
         createWordDoc.WordApp.Selection.EndKey(ref unit, ref extend);
284
      }
286
      }
285
 
287
 
286
 
288
 
287
      /// <summary>
289
      /// <summary>
Line 383... Line 385...
383
                  reqShortDesc = theElement.Notes;
385
                  reqShortDesc = theElement.Notes;
384
               }
386
               }
385
            }
387
            }
386
 
388
 
387
            // Add the ID to the document
389
            // Add the ID to the document
388
            Word.Range wr_id = appendAndSelectText( reqID + '\t', reqHeadingStyle );
390
            Range wr_id = appendAndSelectText( reqID + '\t', reqHeadingStyle );
389
 
391
 
390
            // Add the short description to the document
392
            // Add the short description to the document
391
            Word.Range wr_desc = appendAndSelectText( reqShortDesc, reqHeadingStyle, true );
393
            Range wr_desc = appendAndSelectText( reqShortDesc, reqHeadingStyle, true );
392
            if (wr_desc != null)
394
            if (wr_desc != null)
393
            {
395
            {
394
               // Bold the short description, but only if the element notes have not been used
396
               // Bold the short description, but only if the element notes have not been used
395
               // as the short description. Element notes may contain a lot of text and having
397
               // as the short description. Element notes may contain a lot of text and having
396
               // it all bolded can make the document look a little too busy, and the reader
398
               // it all bolded can make the document look a little too busy, and the reader
Line 451... Line 453...
451
                  sb.Append(" section ");
453
                  sb.Append(" section ");
452
                  sb.Append(srcSect);
454
                  sb.Append(srcSect);
453
               }
455
               }
454
               sb.Append("]");
456
               sb.Append("]");
455
 
457
 
456
               Word.Range wrs_body = appendAndSelectText(sb.ToString(), reqParaStyle);
458
               Range wrs_body = appendAndSelectText(sb.ToString(), reqParaStyle);
457
               if (wrs_body.Characters.Last.Text.Equals("\r"))
459
               if (wrs_body.Characters.Last.Text.Equals("\r"))
458
                  wrs_body.End = wrs_body.End - 1;  // dont italicise the \r char at the end - doing so causes wierd ms-word exceptions later on
460
                  wrs_body.End = wrs_body.End - 1;  // dont italicise the \r char at the end - doing so causes wierd ms-word exceptions later on
459
               wrs_body.Font.Italic = 1;
461
               wrs_body.Font.Italic = 1;
460
               if (numDots > 0)
462
               if (numDots > 0)
461
               {
463
               {
Line 468... Line 470...
468
         }
470
         }
469
 
471
 
470
         return false;
472
         return false;
471
      }
473
      }
472
 
474
 
-
 
475
      public static string HtmlDecode(string sHtml)
-
 
476
      {
-
 
477
          StringWriter writer = new StringWriter();
-
 
478
          HttpUtility.HtmlDecode(sHtml, writer);
-
 
479
          return writer.ToString();
-
 
480
      }
-
 
481
 
473
   }
482
   }
474
}
483
}