示例#1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Append a new section to the given book, having the specified text as the section
		/// head. The new section will have an empty content text created also.
		/// </summary>
		/// <param name="testBase">in-memory test base to use for testing</param>
		/// <param name="book">The book to which the section is to be appended</param>
		/// <param name="sSectionHead">The text of the new section head. Can be a simple string
		/// or a format string. (See CreateText for the definition of the format string)</param>
		/// <param name="paraStyleName">paragraph style to apply to the section head</param>
		/// <returns>The newly created section</returns>
		/// ------------------------------------------------------------------------------------
		internal static IScrSection CreateSection(ScrInMemoryFdoTestBase testBase, IScrBook book,
			string sSectionHead, string paraStyleName)
		{
			// Create a section
			bool fIsIntro = (paraStyleName.Equals(ScrStyleNames.IntroSectionHead));
			IScrSection section = testBase.AddSectionToMockedBook(book, fIsIntro);

			// Create a heading paragraph with text
			string styleName = !string.IsNullOrEmpty(paraStyleName) ? paraStyleName :
				ScrStyleNames.SectionHead;
			IStTxtPara para = section.HeadingOA.AddNewTextPara(styleName);

			if (!string.IsNullOrEmpty(sSectionHead) && sSectionHead[0] == '\\')
			{
				// Text is formatted so add it as a formatted string.
				testBase.AddFormatTextToMockedPara(book, para, sSectionHead, testBase.Cache.DefaultVernWs);
			}
			else
				testBase.AddRunToMockedPara(para, sSectionHead, testBase.Cache.DefaultVernWs);

			return section;
		}