Пример #1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Constructor to use when using an in-memory cache
		/// </summary>
		/// <param name="settings">Import settings</param>
		/// <param name="cache">FDO Cache</param>
		/// <param name="styleSheet">A stylesheet</param>
		/// <param name="inMemoryCache"> in-memory cache (use null to test against real DB)</param>
		/// ------------------------------------------------------------------------------------
		public DummyTeImporter(ScrImportSet settings, FdoCache cache, FwStyleSheet styleSheet,
			ScrInMemoryFdoCache inMemoryCache) :
			base(settings, cache, styleSheet, new DummyUndoImportManager(inMemoryCache),
				new TeImportNoUi())
		{
			m_inMemoryCache = inMemoryCache;
		}
Пример #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Append a new section to the given book, having the specified text as the section
		/// head. The general section head paragraph style is used.
		/// </summary>
		/// <param name="scrInMemoryCache">in-memory cache 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</param>
		/// <returns>The newly created section</returns>
		/// ------------------------------------------------------------------------------------
		internal static ScrSection CreateSection(ScrInMemoryFdoCache scrInMemoryCache, IScrBook book,
			string sSectionHead)
		{
			ScrSection section = CreateSection(scrInMemoryCache, book, sSectionHead, ScrStyleNames.SectionHead);
			// this should be a scripture section and not an intro section
			bool isIntro = false;
			section.VerseRefEnd = book.CanonicalNum * 1000000 + 1000 + ((isIntro) ? 0 : 1);
			section.AdjustReferences();
			return section;
		}
Пример #3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a title paragrpaph for the given book.
		/// </summary>
		/// <param name="scrInMemoryCache">in-memory cache to use for testing</param>
		/// <param name="book">The book</param>param>
		/// <param name="sTitle">The text of the title. Can be a simple string or a format
		/// string. (See InMemoryFdoCache.CreateFormatText for the definition of the
		/// format string)</param>
		/// ------------------------------------------------------------------------------------
		internal static void SetTitle(ScrInMemoryFdoCache scrInMemoryCache, IScrBook book, string sTitle)
		{
			book.TitleOA = new StText();

			if (sTitle[0] != '\\')
			{
				scrInMemoryCache.AddTitleToMockedBook(book.Hvo, sTitle);
			}
			else
			{
				// Create a more complex title from the given format string
				// insert a new para in the title
				StTxtPara para = new StTxtPara();
				book.TitleOA.ParagraphsOS.Append(para);
				// set the para's fields
				scrInMemoryCache.AddFormatTextToMockedPara(book, para, sTitle, scrInMemoryCache.Cache.DefaultVernWs);
				para.StyleRules = StyleUtils.ParaStyleTextProps(ScrStyleNames.MainBookTitle);
			}
		}
		public void Init()
		{
			CheckDisposed();

			Debug.Assert(m_inMemoryCache == null, "m_inMemoryCache is not null.");
			//if (m_inMemoryCache != null)
			//	m_inMemoryCache.Dispose();
			m_inMemoryCache = ScrInMemoryFdoCache.Create();
			m_inMemoryCache.InitializeLangProject();
			m_inMemoryCache.InitializeScripture();

			m_scripture = m_inMemoryCache.Cache.LangProject.TranslatedScriptureOA;
			m_inMemoryCache.InitializeActionHandler();

			m_styleSheet = new DynamicMock(typeof(FwStyleSheet));
			m_styleSheet.Strict = true;

			BTInsertVerseAndFootnoteTests.InitializeVwSelection(m_selHelper);

			Debug.Assert(m_btView == null, "m_btView is not null.");
			//if (m_btView != null)
			//	m_btView.Dispose();
			m_btView = new DummyDraftView(m_inMemoryCache.Cache, true, 0);
			m_btView.RootBox = SetupRootBox();
			m_btView.Graphics = SetupGraphics();
			m_btView.MakeRoot();
			m_btView.StyleSheet = (FwStyleSheet)m_styleSheet.MockInstance;
			m_btView.ActivateView();
			m_btView.TeEditingHelper.InTestMode = true;
			m_rootBox.Strict = true;
		}
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		protected override void Dispose(bool disposing)
		{
			Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if (disposing)
			{
				// Dispose managed resources here.
				if (m_btView != null)
					m_btView.Dispose();
				if (m_inMemoryCache != null)
					m_inMemoryCache.Dispose();
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_btView = null; // mimick back translation view using DummyDraftView
			m_scripture = null; //m_scripture = null; // Why not set it to null?
			m_inMemoryCache = null;
			m_styleSheet = null; // m_styleSheet = null; // Why not set it to null?
			m_rootBox = null;
			m_vwGraphics = null;
			m_selHelper = null;
			m_sel = null;
			m_PropInfoArgs = null;
			m_PropInfoTypes = null;
			m_TextSelInfoArgs = null;
			m_TextSelInfoTypes = null;
			m_LocationArgs = null;
			m_LocationTypes = null;
			m_AllSelEndInfoArgs = null;
			m_AllSelEndInfoTypes = null;

			base.Dispose(disposing);
		}
Пример #6
0
		public void Teardown()
		{
			m_ctrlOwner.Close();
			m_ctrlOwner.Dispose();
			m_inMemoryCache.Dispose();
			m_inMemoryCache = null;
		}
Пример #7
0
		public void Init()
		{
			m_inMemoryCache = ScrInMemoryFdoCache.Create(this);
			m_inMemoryCache.InitializeLangProject();
			m_inMemoryCache.InitializeScripture();
			m_inMemoryCache.AddBookToMockedScripture(1, "Genesis");
			m_inMemoryCache.AddBookToMockedScripture(2, "Exodus");
			m_inMemoryCache.AddBookToMockedScripture(5, "Deuteronomy");
			m_James = m_inMemoryCache.AddBookToMockedScripture(59, "James");
			m_inMemoryCache.AddBookToMockedScripture(66, "Revelation");
			m_fdoCache = m_inMemoryCache.Cache;

			m_scr = (Scripture)m_fdoCache.LangProject.TranslatedScriptureOA;

			m_ctrlOwner = new Form();

			ILgWritingSystemFactory wsf = m_fdoCache.LanguageWritingSystemFactoryAccessor;
			m_scp = new DummyScrPassageControl(null, m_scr, false);
			m_dbScp = new DummyScrPassageControl(null, m_scr, true);

			m_ctrlOwner.Controls.Add(m_scp);
			m_ctrlOwner.Controls.Add(m_dbScp);
			m_ctrlOwner.CreateControl();

			if (m_scp.DropDownWindow != null)
				m_scp.DropDownWindow.Close();

			if (m_dbScp.DropDownWindow != null)
				m_dbScp.DropDownWindow.Close();

			// Forcing the reference to this should reset the ScrReference object for us
			// which, we hope will cause some strange errors to occur when running in
			// console mode. The tests seem to always work in gui mode but not console mode.
			m_scp.ScReference = new ScrReference(01001001, m_scr.Versification);
			m_dbScp.ScReference = new ScrReference(01001001, m_scr.Versification);
		}
Пример #8
0
		public void SetUp()
		{
			CheckDisposed();

			if (m_emptyTsString != null)
				Marshal.ReleaseComObject(m_emptyTsString);
			// Create an empty TsString
			ITsStrBldr bldr = TsStrBldrClass.Create();
			bldr.Replace(0, 0, string.Empty, null);
			m_emptyTsString = bldr.GetString();

			// Set up the FDO mock and populate it with some values
			m_inMemoryCache = ScrInMemoryFdoCache.Create();
			m_inMemoryCache.InitializeLangProject();
			m_inMemoryCache.InitializeScripture();
			m_book = m_inMemoryCache.AddBookToMockedScripture(57, "Philemon");

			// Set up IVwEnv object
			m_vwenvMock = new DynamicMock(typeof(IVwEnv));
			m_vwenvMock.SetupResult("DataAccess", m_inMemoryCache.CacheAccessor);

			// save settings
			m_oldPromptSetting = Options.ShowEmptyParagraphPromptsSetting;
		}
Пример #9
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Add an annotation to a language project that applies to a single verse reference and
		/// a single paragraph.
		/// </summary>
		/// <param name="scrInMemoryCache">in-memory cache to use for testing</param>
		/// <param name="noteText">text to include in annotation</param>
		/// <param name="reference">The reference.</param>
		/// <param name="para">StTxtPara to annotate</param>
		/// <returns>a new annotation</returns>
		/// ------------------------------------------------------------------------------------
		internal static IScrScriptureNote AddAnnotation(ScrInMemoryFdoCache scrInMemoryCache, string noteText,
			ScrReference reference, ICmObject para)
		{
			return AddAnnotation(scrInMemoryCache, noteText, reference, reference, para, para);
		}
Пример #10
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Get the first translator note annotation definition.
		/// </summary>
		/// <returns>type of annotation</returns>
		/// ------------------------------------------------------------------------------------
		private static ICmAnnotationDefn StandardNoteType(ScrInMemoryFdoCache scrInMemoryCache)
		{
			ICmPossibility possibility =
				scrInMemoryCache.Cache.LangProject.AnnotationDefsOA.PossibilitiesOS[0];

			return possibility.SubPossibilitiesOS[0] as ICmAnnotationDefn;
		}
Пример #11
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a back translation from a format string, and attach it to the
		/// given paragraph.
		/// </summary>
		/// <param name="scrInMemoryCache">in-memory cache to use for testing</param>
		/// <param name="book">book to use</param>
		/// <param name="para">the paragraph that will own this back translation</param>
		/// <param name="format">(See CreateText for the definition of the format string)</param>
		/// <param name="ws">writing system of the back translation</param>
		/// ------------------------------------------------------------------------------------
		internal static void AddBackTranslation(ScrInMemoryFdoCache scrInMemoryCache, IScrBook book,
			StTxtPara para, string format, int ws)
		{
			ICmTranslation cmTrans = para.GetOrCreateBT();
			// Set the translation string for the given WS
			cmTrans.Translation.GetAlternative(ws).UnderlyingTsString =
				ScrInMemoryFdoCache.CreateFormatText(book, null, format, ws);
		}
Пример #12
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a paragraph from a format string, and append it to the given section's
		/// content.
		/// </summary>
		/// <param name="scrInMemoryCache">in-memory cache to use for testing</param>
		/// <param name="book">book to use</param>
		/// <param name="section">section to append to</param>
		/// <param name="format">(See CreateText for the definition of the format string)</param>
		/// <param name="ws">writing system to use</param>
		/// <param name="paraStyle">paragraph style name</param>
		/// <returns>the new paragraph</returns>
		/// ------------------------------------------------------------------------------------
		internal static StTxtPara AppendParagraph(ScrInMemoryFdoCache scrInMemoryCache, IScrBook book,
			IScrSection section, string format, int ws, string paraStyle)
		{
			// insert a new para in the section content
			StTxtPara para = new StTxtPara();
			section.ContentOA.ParagraphsOS.Append(para);

			// set the para's fields
			scrInMemoryCache.AddFormatTextToMockedPara(book as ScrBook, para, format, ws);
			para.StyleRules = StyleUtils.ParaStyleTextProps(paraStyle);

			section.AdjustReferences();
			return para;
		}
Пример #13
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="scrInMemoryCache">in-memory cache 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 ScrSection CreateSection(ScrInMemoryFdoCache scrInMemoryCache, IScrBook book,
			string sSectionHead, string paraStyleName)
		{
			// Create a section
			ScrSection section = new ScrSection();
			book.SectionsOS.Append(section);

			// Create a section head for this section
			section.HeadingOA = new StText();

			if (sSectionHead.Length == 0 || sSectionHead[0] != '\\')
			{
				// create a simple section head with no character style
				StTxtParaBldr paraBldr = new StTxtParaBldr(scrInMemoryCache.Cache);
				paraBldr.ParaProps = StyleUtils.ParaStyleTextProps(paraStyleName);
				paraBldr.AppendRun(sSectionHead,
					StyleUtils.CharStyleTextProps(null, scrInMemoryCache.Cache.DefaultVernWs));
				paraBldr.CreateParagraph(section.HeadingOAHvo);
			}
			else
			{
				// Create a more complex section head from the given format string
				// insert a new para in the title
				StTxtPara para = new StTxtPara();
				section.HeadingOA.ParagraphsOS.Append(para);
				// set the para's fields
				scrInMemoryCache.AddFormatTextToMockedPara(book, para, sSectionHead, scrInMemoryCache.Cache.DefaultVernWs);
				para.StyleRules = StyleUtils.ParaStyleTextProps(paraStyleName);
			}

			section.ContentOA = new StText();
			section.AdjustReferences();
			return section;
		}
Пример #14
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:DummyUndoImportManager"/> class.
		/// </summary>
		/// <param name="inMemoryCache"></param>
		/// ------------------------------------------------------------------------------------
		public DummyUndoImportManager(ScrInMemoryFdoCache inMemoryCache) :
			base(inMemoryCache.Cache, null)
		{
			m_inMemoryCache = inMemoryCache;
		}
		public void CleanUp()
		{
			CheckDisposed();

			m_btView.Dispose();
			m_btView = null;
			m_inMemoryCache.Dispose();
			m_inMemoryCache = null;
			m_scripture = null;
			m_styleSheet = null;
			m_rootBox = null;
			m_vwGraphics = null;
		}
Пример #16
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		/// ------------------------------------------------------------------------------------
		protected override void Dispose(bool disposing)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if (disposing)

			{
				// Dispose managed resources here.
				if (m_inMemoryCache != null)
					m_inMemoryCache.Dispose();
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			if (m_emptyTsString != null)

			{
				Marshal.ReleaseComObject(m_emptyTsString);
				m_emptyTsString = null;
			}
			m_vwenvMock = null;
			m_inMemoryCache = null;
			m_book = null;

			base.Dispose(disposing);
		}
Пример #17
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Add an annotation to a language project.
		/// </summary>
		/// <param name="scrInMemoryCache">in-memory cache to use for testing</param>
		/// <param name="noteText">text to include in discussion</param>
		/// <param name="startRef"></param>
		/// <param name="endRef"></param>
		/// <param name="topPara">Begin StTxtPara to annotate</param>
		/// <param name="bottomPara">End StTxtPara to annotate</param>
		/// <returns>a new annotation</returns>
		/// ------------------------------------------------------------------------------------
		internal static IScrScriptureNote AddAnnotation(ScrInMemoryFdoCache scrInMemoryCache, string noteText,
			ScrReference startRef, ScrReference endRef, ICmObject topPara, ICmObject bottomPara)
		{
			ILangProject lp = scrInMemoryCache.Cache.LangProject;
			ScrBookAnnotations annotations = (ScrBookAnnotations)lp.TranslatedScriptureOA.BookAnnotationsOS[startRef.Book - 1];
			IScrScriptureNote note = annotations.InsertNote(startRef, endRef, topPara, bottomPara,
				StandardNoteType(scrInMemoryCache).Guid);

			StTxtPara discussionPara = (StTxtPara)note.DiscussionOA.ParagraphsOS[0];
			scrInMemoryCache.AddRunToMockedPara(discussionPara, noteText, scrInMemoryCache.Cache.DefaultAnalWs);

			note.DateCreated = new DateTime(s_Ticks++);

			return note;
		}
Пример #18
0
		public void TearDown()
		{
			CheckDisposed();

			Options.ShowEmptyParagraphPromptsSetting = m_oldPromptSetting;
			if (m_emptyTsString != null)
				Marshal.ReleaseComObject(m_emptyTsString);
			m_inMemoryCache.Dispose();
			m_inMemoryCache = null;
			m_book = null;
			m_vwenvMock = null;
		}
Пример #19
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates the in memory fdo cache.
		/// </summary>
		/// <param name="provider">The provider.</param>
		/// ------------------------------------------------------------------------------------
		protected override InMemoryFdoCache CreateInMemoryFdoCache(IWsFactoryProvider provider)
		{
			m_scrInMemoryCache = (ScrInMemoryFdoCache)ScrInMemoryFdoCache.Create(provider);
			return m_scrInMemoryCache;
		}