示例#1
0
		public void KeyboardHandling_otherKeysNonEditable()
		{
			CheckDisposed();
			CompleteInitialize(true, m_philemonRev);

			using (DummyDiffView view = new DummyDiffView(Cache, m_philemonRev,
				m_bookMerger.Differences, true))
			{
				view.StyleSheet = m_styleSheet;
				view.MakeRoot();
				view.PerformLayout();
				view.RootBox.Activate(VwSelectionState.vssEnabled);
				view.RootBox.MakeSimpleSel(true, true, true, true);
				view.SetInsertionPoint(0, 1, 0, 0, true);
				StTxtPara para = (StTxtPara)m_philemonRev.SectionsOS[1].ContentOA.ParagraphsOS[0];
				int charCount = para.Contents.Length;
				// press a letter
				view.ExposeOnKeyPress(new KeyPressEventArgs('f'));
				SelectionHelper helper = SelectionHelper.Create(view);
				Assert.AreEqual(0, helper.IchAnchor, "IP should not move");
				Assert.AreEqual(charCount, para.Contents.Length);
				// press the enter key
				view.ExposeOnKeyDown(new KeyEventArgs(Keys.Enter));
				helper = SelectionHelper.Create(view);
				Assert.AreEqual(0, helper.IchAnchor, "IP should not move");
				Assert.AreEqual(charCount, para.Contents.Length);
			}
		}
示例#2
0
		public void Edit_ControlSpacePreservesVerseNumber()
		{
			CheckDisposed();
			CompleteInitialize(true, m_philemonRev);

			FdoOwningSequence<IStPara> paras = m_philemonCurr.SectionsOS[2].ContentOA.ParagraphsOS;
			StTxtPara para = (StTxtPara)paras[paras.Count - 1];
			int ichAnchor = para.Contents.Length;
			int iRun = para.Contents.UnderlyingTsString.RunCount - 1;
			m_scrInMemoryCache.AddRunToMockedPara(para, " More text in last verse.", "Emphasis");
			m_scrInMemoryCache.AddRunToMockedPara(para, "24", ScrStyleNames.VerseNumber);
			m_scrInMemoryCache.AddRunToMockedPara(para, "The really very last verse.", "Strong");
			int ichEnd = para.Contents.Length;

			using (DummyDiffView view = new DummyDiffView(Cache, m_philemonCurr,
				m_bookMerger.Differences, false))
			{
				// select all three added runs
				view.EditingHelper.InTestMode = true;
				view.Editable = true;
				view.StyleSheet = m_styleSheet;
				view.MakeRoot();
				view.PerformLayout();
				view.RootBox.Activate(VwSelectionState.vssEnabled);
				view.SetInsertionPoint(0, 2, paras.Count - 1, ichAnchor, true);
				SelectionHelper helper = SelectionHelper.Create(view);
				helper.IchEnd = ichEnd;
				helper.MakeBest(true);

				// press Ctrl+Space to clear character styles (except verse number)
				view.ExposeOnKeyDown(new KeyEventArgs(Keys.Control | Keys.Space));

				// verify that the character styles have been cleared (but not the verse number style)
				ITsString tss = para.Contents.UnderlyingTsString;
				AssertEx.RunIsCorrect(tss, iRun, "the existentialists are all wrong. " +
					"The last verse. " + "More text in last verse.",
					null, Cache.DefaultVernWs);
				AssertEx.RunIsCorrect(tss, iRun + 1, "24", ScrStyleNames.VerseNumber,
					Cache.DefaultVernWs);
				AssertEx.RunIsCorrect(tss, iRun + 2, "The really very last verse.",
					null, Cache.DefaultVernWs);
			}
		}
示例#3
0
		public void KeyboardHandling_arrowsNonEditable()
		{
			CheckDisposed();
			CompleteInitialize(true, m_philemonRev);

			using (DummyDiffView view = new DummyDiffView(Cache, m_philemonCurr,
				m_bookMerger.Differences, false))
			{
				view.StyleSheet = m_styleSheet;
				view.MakeRoot();
				view.PerformLayout();
				view.RootBox.Activate(VwSelectionState.vssEnabled);
				// if we try to set the insertion point to section 0 it doesn't work.
				// Couldn't figure out why.
				view.SetInsertionPoint(0, 1, 0, 0, true);
				// press the down arrow key
				view.ExposeOnKeyDown(new KeyEventArgs(Keys.Down));
				SelectionHelper helper = SelectionHelper.Create(view);
				Assert.IsTrue(helper.IchAnchor > 15, "IP should move down");
				// press the up arrow key
				view.ExposeOnKeyDown(new KeyEventArgs(Keys.Up));
				helper = SelectionHelper.Create(view);
				Assert.AreEqual(0, helper.IchAnchor, "IP should move back to the previous location");
				// press the right arrow key
				view.ExposeOnKeyDown(new KeyEventArgs(Keys.Right));
				helper = SelectionHelper.Create(view);
				Assert.AreEqual(1, helper.IchAnchor, "IP should move to the right");
				// press the left arrow key
				view.ExposeOnKeyDown(new KeyEventArgs(Keys.Left));
				helper = SelectionHelper.Create(view);
				Assert.AreEqual(0, helper.IchAnchor, "IP should move back to the previous location");
			}
		}
示例#4
0
		public void Edit_EnterAtEndOfSectionHeadDoesntInsertBodyParaIntoSectionHead()
		{
			CheckDisposed();
			CompleteInitialize(true, m_philemonRev);

			IStStyle sectionHeadStyle = m_scr.FindStyle(ScrStyleNames.SectionHead);
			sectionHeadStyle.NextRA = m_scr.FindStyle(ScrStyleNames.NormalParagraph);
			FdoOwningSequence<IStPara> headingParas = m_philemonCurr.SectionsOS[1].HeadingOA.ParagraphsOS;
			int sectionHeadParaCount = headingParas.Count;
			int sectionContentParaCount = m_philemonCurr.SectionsOS[1].ContentOA.ParagraphsOS.Count;

			using (DummyDiffView view = new DummyDiffView(Cache, m_philemonCurr,
				m_bookMerger.Differences, false))
			{
				view.EditingHelper.InTestMode = true;
				view.Editable = true;
				view.StyleSheet = m_styleSheet;
				view.MakeRoot();
				view.PerformLayout();
				view.RootBox.Activate(VwSelectionState.vssEnabled);
				view.SetInsertionPoint(0, 1, 0, 0, true);
				view.ExposeOnKeyDown(new KeyEventArgs(Keys.Left));
				SelectionHelper helper = SelectionHelper.Create(view);
				Assert.AreEqual(((StTxtPara)headingParas[0]).Contents.Length,
					helper.IchAnchor, "IP should be at the end of the last section head paragraph");
				view.ExposeOnKeyDown(new KeyEventArgs(Keys.Enter));
				view.ExposeOnKeyPress(new KeyPressEventArgs('\r'));

				Assert.AreEqual(sectionHeadParaCount,
					m_philemonCurr.SectionsOS[1].HeadingOA.ParagraphsOS.Count,
					"the number of heading paragraphs should stay the same");
				Assert.AreEqual(sectionContentParaCount + 1,
					m_philemonCurr.SectionsOS[1].ContentOA.ParagraphsOS.Count,
					"the number of content paragraphs should increase by one");
				Assert.AreEqual(0,
					((StTxtPara)m_philemonCurr.SectionsOS[1].ContentOA.ParagraphsOS[0]).Contents.Length,
					"the inserted paragraph should be empty");
			}
		}
示例#5
0
		public void Edit_EnterAtEndOfNonUltimateSectionHeadPara()
		{
			CheckDisposed();
			CompleteInitialize(true, m_philemonRev);

			IStStyle sectionHeadStyle = m_scr.FindStyle(ScrStyleNames.SectionHead);
			sectionHeadStyle.NextRA = m_scr.FindStyle(ScrStyleNames.NormalParagraph);
			int origNumberOfSections = m_philemonCurr.SectionsOS.Count;
			IStText heading = m_philemonCurr.SectionsOS[1].HeadingOA;
			FdoOwningSequence<IStPara> headingParas = heading.ParagraphsOS;
			int origNumberOfSectionHeadParas = headingParas.Count;
			int sectionContentParaCount = m_philemonCurr.SectionsOS[1].ContentOA.ParagraphsOS.Count;
			StTxtPara headPara2 = m_scrInMemoryCache.AddParaToMockedText(heading.Hvo,
				ScrStyleNames.SectionHead);
			m_scrInMemoryCache.AddRunToMockedPara(headPara2, "Head After Break", Cache.DefaultVernWs);

			using (DummyDiffView view = new DummyDiffView(Cache, m_philemonCurr,
				m_bookMerger.Differences, false))
			{
				view.EditingHelper.InTestMode = true;
				view.Editable = true;
				view.StyleSheet = m_styleSheet;
				view.MakeRoot();
				view.PerformLayout();
				view.RootBox.Activate(VwSelectionState.vssEnabled);
				view.SetInsertionPoint(0, 1, 0, 0, true);
				view.ExposeOnKeyDown(new KeyEventArgs(Keys.Up)); // Move to start of last section head para
				view.ExposeOnKeyDown(new KeyEventArgs(Keys.Left)); // Move to end of preceding section head para
				SelectionHelper helper = SelectionHelper.Create(view);
				Assert.AreEqual(((StTxtPara)headingParas[origNumberOfSectionHeadParas - 1]).Contents.Length,
					helper.IchAnchor, "IP should be at the end of the penultimate section head paragraph");
				view.ExposeOnKeyDown(new KeyEventArgs(Keys.Enter));
				view.ExposeOnKeyPress(new KeyPressEventArgs('\r'));

				Assert.AreEqual(origNumberOfSections + 1, m_philemonCurr.SectionsOS.Count,
					"New section should have been added.");
				IScrSection section2 = m_philemonCurr.SectionsOS[1];
				IScrSection section3 = m_philemonCurr.SectionsOS[2];
				Assert.AreEqual(origNumberOfSectionHeadParas,
					section2.HeadingOA.ParagraphsOS.Count,
					"The number of heading paragraphs in second section should go back to what it was before we added an extra one");
				Assert.AreEqual(1,
					section2.ContentOA.ParagraphsOS.Count,
					"There should only be 1 content paragraph in the second section.");
				Assert.AreEqual(0,
					((StTxtPara)section2.ContentOA.ParagraphsOS[0]).Contents.Length,
					"Content paragraph in the second section should be empty.");
				Assert.AreEqual(sectionContentParaCount,
					section3.ContentOA.ParagraphsOS.Count,
					"All content paragraphs from original section should now be in the new section.");
				Assert.AreEqual(1, section3.HeadingOA.ParagraphsOS.Count,
					"New section should have 1 heading paragraph.");
				Assert.AreEqual("Head After Break",
					((StTxtPara)section3.HeadingOA.ParagraphsOS[0]).Contents.Text,
					"New section heading paragraph should be the last paragraph of the original section heading.");
			}
		}
示例#6
0
		public void Edit_DeletingFootnoteMarkers()
		{
			CheckDisposed();
			CompleteInitialize(true, m_philemonRev);

			StTxtPara para = (StTxtPara)m_philemonCurr.SectionsOS[1].ContentOA.ParagraphsOS[0];
			int hvoFootnote = m_scrInMemoryCache.AddFootnote(m_philemonCurr, para, 0).Hvo;
			int footnoteCount = m_philemonCurr.FootnotesOS.Count;

			using (DummyDiffView view = new DummyDiffView(Cache, m_philemonCurr,
				m_bookMerger.Differences, false))
			{
				view.EditingHelper.InTestMode = true;
				view.Editable = true;
				view.StyleSheet = m_styleSheet;
				view.MakeRoot();
				view.PerformLayout();
				view.RootBox.Activate(VwSelectionState.vssEnabled);
				// Copy the footnote at the start of the first Scripture section and paste it at the para start.
				view.SetInsertionPoint(0, 1, 0, 0, true);
				view.ExposeOnKeyDown(new KeyEventArgs(Keys.Shift | Keys.Right));
				view.ExposeOnKeyDown(new KeyEventArgs(Keys.Delete));

				SelectionHelper helper = SelectionHelper.Create(view);
				Assert.AreEqual(0, helper.IchAnchor, "IP should be at the start of the paragraph");
				Assert.IsFalse(helper.IsRange, "Should have a simple IP");
				Assert.AreEqual(footnoteCount - 1, m_philemonCurr.FootnotesOS.Count);
				Assert.IsFalse(Cache.MainCacheAccessor.get_IsPropInCache(hvoFootnote,
					(int)CmObjectFields.kflidCmObject_Class, (int)CellarModuleDefns.kcptInteger, 0));
				AssertEx.RunIsCorrect(para.Contents.UnderlyingTsString, 0, "1",
					ScrStyleNames.VerseNumber, Cache.DefaultVernWs);
			}
		}
示例#7
0
		public void Edit_TypingNextToVerseNumber()
		{
			CheckDisposed();
			CompleteInitialize(true, m_philemonRev);

			StTxtPara para = (StTxtPara)m_philemonCurr.SectionsOS[1].ContentOA.ParagraphsOS[0];

			using (DummyDiffView view = new DummyDiffView(Cache, m_philemonCurr,
				m_bookMerger.Differences, false))
			{
				view.EditingHelper.InTestMode = true;
				view.Editable = true;
				view.StyleSheet = m_styleSheet;
				view.MakeRoot();
				view.PerformLayout();
				view.RootBox.Activate(VwSelectionState.vssEnabled);
				view.SetInsertionPoint(0, 1, 0, 0, true);
				view.ExposeOnKeyPress(new KeyPressEventArgs('a'));
				view.ExposeOnKeyDown(new KeyEventArgs(Keys.Right));
				view.ExposeOnKeyPress(new KeyPressEventArgs('b'));

				ITsString tss = para.Contents.UnderlyingTsString;
				AssertEx.RunIsCorrect(tss, 0, "a", null, Cache.DefaultVernWs);
				AssertEx.RunIsCorrect(tss, 1, "1", ScrStyleNames.VerseNumber, Cache.DefaultVernWs);
				AssertEx.RunIsCorrect(tss, 2, "band the earth was without form and void and darkness covered the face of the deep", null, Cache.DefaultVernWs);
			}
		}
示例#8
0
		public void Edit_PastingFootnoteMarkers()
		{
			CheckDisposed();
			CompleteInitialize(true, m_philemonRev);

			StTxtPara para = (StTxtPara)m_philemonCurr.SectionsOS[1].ContentOA.ParagraphsOS[0];
			IStFootnote footnote = m_scrInMemoryCache.AddFootnote(m_philemonCurr, para, 0);
			int footnoteCount = m_philemonCurr.FootnotesOS.Count;
			int hvoOrigFootnote = footnote.Hvo;

			using (DummyDiffView view = new DummyDiffView(Cache, m_philemonCurr,
				m_bookMerger.Differences, false))
			{
				view.EditingHelper.InTestMode = true;
				view.Editable = true;
				view.StyleSheet = m_styleSheet;
				view.MakeRoot();
				view.PerformLayout();
				view.RootBox.Activate(VwSelectionState.vssEnabled);
				// Copy the footnote at the start of the first Scripture section and paste it at the para start.
				view.SetInsertionPoint(0, 1, 0, 0, true);
				view.ExposeOnKeyDown(new KeyEventArgs(Keys.Shift | Keys.Right));
				view.EditingHelper.CopySelection();
				view.ExposeOnKeyDown(new KeyEventArgs(Keys.Left));
				view.EditingHelper.PasteClipboard(false);

				SelectionHelper helper = SelectionHelper.Create(view);
				Assert.AreEqual(1, helper.IchAnchor, "IP should be after the footnote marker (and the little space)");
				Assert.AreEqual(footnoteCount + 1, m_philemonCurr.FootnotesOS.Count);
				Guid guid = StringUtils.GetGuidFromRun(para.Contents.UnderlyingTsString, 0);
				footnote = m_philemonCurr.FootnotesOS[0];
				Assert.AreEqual(footnote.Guid, guid);
				Assert.AreNotEqual(hvoOrigFootnote, footnote.Hvo);
			}
		}
示例#9
0
		public void Edit_DeletingFootnoteMarkers()
		{
			CompleteInitialize(true, m_philemonRev);

			IScrTxtPara para = (IScrTxtPara)m_philemonCurr.SectionsOS[1].ContentOA.ParagraphsOS[0];
			IStFootnote footnote;
			using (UndoableUnitOfWorkHelper undoHelper = new UndoableUnitOfWorkHelper(m_actionHandler, "initialization"))
			{
				footnote = AddFootnote(m_philemonCurr, para, 0);
				undoHelper.RollBack = false;
			}
			int footnoteCount = m_philemonCurr.FootnotesOS.Count;

			using (DummyDiffView view = new DummyDiffView(Cache, m_philemonCurr,
				m_bookMerger.Differences, false))
			{
				view.Editable = true;
				view.StyleSheet = m_styleSheet;
				view.MakeRoot();
				view.PerformLayout();
				view.RootBox.Activate(VwSelectionState.vssEnabled);
				// Copy the footnote at the start of the first Scripture section and paste it at the para start.
				view.SetInsertionPoint(0, 1, 0, 0, true);
				view.ExposeOnKeyDown(new KeyEventArgs(Keys.Shift | Keys.Right));
				using (UndoableUnitOfWorkHelper undoHelper = new UndoableUnitOfWorkHelper(m_actionHandler, ":("))
				{
					view.ExposeOnKeyDown(new KeyEventArgs(Keys.Delete));
					undoHelper.RollBack = false;
				}
				SelectionHelper helper = SelectionHelper.Create(view);
				Assert.AreEqual(0, helper.IchAnchor, "IP should be at the start of the paragraph");
				Assert.IsFalse(helper.IsRange, "Should have a simple IP");
				Assert.AreEqual(footnoteCount - 1, m_philemonCurr.FootnotesOS.Count);
				Assert.IsFalse(footnote.IsValidObject);
				AssertEx.RunIsCorrect(para.Contents, 0, "1",
					ScrStyleNames.VerseNumber, Cache.DefaultVernWs);
			}
		}
示例#10
0
		public void Edit_PastingFootnoteMarkers()
		{
			CompleteInitialize(true, m_philemonRev);

			var para = (IScrTxtPara)m_philemonCurr.SectionsOS[1].ContentOA.ParagraphsOS[0];
			IStFootnote footnote;
			using (var undoHelper = new UndoableUnitOfWorkHelper(m_actionHandler, "initialization"))
			{
				footnote = AddFootnote(m_philemonCurr, para, 0);
				undoHelper.RollBack = false;
			}
			var hvoOrigFootnote = footnote.Hvo;

			using (var view = new DummyDiffView(Cache, m_philemonCurr,
				m_bookMerger.Differences, false))
			{
				view.Editable = true;
				view.StyleSheet = m_styleSheet;
				view.MakeRoot();
				view.PerformLayout();
				view.RootBox.Activate(VwSelectionState.vssEnabled);
				// Copy the footnote at the start of the first Scripture section and paste it at the para start.
				view.SetInsertionPoint(0, 1, 0, 0, true);
				view.ExposeOnKeyDown(new KeyEventArgs(Keys.Shift | Keys.Right));
				view.EditingHelper.CopySelection();
				view.ExposeOnKeyDown(new KeyEventArgs(Keys.Left));
				using (var undoHelper = new UndoableUnitOfWorkHelper(m_actionHandler, "initialization"))
				{
					view.EditingHelper.PasteClipboard();
					undoHelper.RollBack = false;
				}

				var helper = SelectionHelper.Create(view);
				Assert.AreEqual(1, helper.IchAnchor, "IP should be after the footnote marker (and the little space)");
				Assert.AreEqual(2, m_philemonCurr.FootnotesOS.Count, "Should create a new footnote when pasting footnote marker");
				var guid = TsStringUtils.GetGuidFromRun(para.Contents, 0);
				footnote = m_philemonCurr.FootnotesOS[0];
				Assert.AreEqual(footnote.Guid, guid);
				Assert.AreNotEqual(hvoOrigFootnote, footnote.Hvo);
			}
		}