Пример #1
0
 /// -----------------------------------------------------------------------------------
 /// <summary>
 /// Close the footnote view
 /// </summary>
 /// -----------------------------------------------------------------------------------
 public override void TestTearDown()
 {
     m_footnoteView = null;
     m_footnoteForm.Close();
     m_footnoteForm = null;
     base.TestTearDown();
 }
Пример #2
0
        public void ReadOnlySpaceAfterFootnoteMarker()
        {
            // Prepare the test by creating a footnote view
            FwStyleSheet styleSheet = new FwStyleSheet();

            styleSheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);

            using (Form form = new Form())
                using (DummyFootnoteView footnoteView = new DummyFootnoteView(Cache))
                {
                    footnoteView.StyleSheet = styleSheet;
                    footnoteView.Dock       = DockStyle.Fill;
                    footnoteView.Name       = "footnoteView";
                    footnoteView.Visible    = true;
                    form.Controls.Add(footnoteView);
                    form.Show();

                    try
                    {
                        // Select the footnote marker and some characters of the footnote paragraph
                        footnoteView.RootBox.MakeSimpleSel(true, false, false, true);
                        SelectionHelper selHelper = SelectionHelper.GetSelectionInfo(null, footnoteView);
                        selHelper.IchAnchor = 0;
                        selHelper.IchEnd    = 5;
                        SelLevInfo[] selLevInfo = new SelLevInfo[3];
                        Assert.AreEqual(4, selHelper.GetNumberOfLevels(SelectionHelper.SelLimitType.End));
                        Array.Copy(selHelper.GetLevelInfo(SelectionHelper.SelLimitType.End), 1, selLevInfo, 0, 3);
                        selHelper.SetLevelInfo(SelectionHelper.SelLimitType.End, selLevInfo);
                        selHelper.SetTextPropId(SelectionHelper.SelLimitType.End,
                                                StTxtParaTags.kflidContents);
                        selHelper.SetSelection(true);

                        // Now the real test:
                        IVwSelection sel = footnoteView.RootBox.Selection;
                        ITsString    tss;
                        sel.GetSelectionString(out tss, string.Empty);
                        Assert.AreEqual("a ", tss.Text.Substring(0, 2));

                        // make sure the marker and the space are read-only and the paragraph not.
                        ITsTextProps[]     vttp;
                        IVwPropertyStore[] vvps;
                        int cttp;
                        SelectionHelper.GetSelectionProps(sel, out vttp, out vvps, out cttp);
                        Assert.IsTrue(cttp >= 3);
                        Assert.IsFalse(SelectionHelper.IsEditable(vttp[0], vvps[0]),
                                       "Footnote marker is not read-only");
                        Assert.IsFalse(SelectionHelper.IsEditable(vttp[1], vvps[1]),
                                       "Space after marker is not read-only");
                        Assert.IsTrue(SelectionHelper.IsEditable(vttp[2], vvps[2]),
                                      "Footnote text is read-only");
                        Assert.IsTrue(SelectionHelper.IsEditable(vttp[3], vvps[3]),
                                      "Footnote text is read-only");
                    }
                    finally
                    {
                        form.Close();
                    }
                }
        }
Пример #3
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Create a new footnote view
        /// </summary>
        /// -----------------------------------------------------------------------------------
        public override void TestSetup()
        {
            base.TestSetup();
            m_footnoteForm = new DummyFootnoteViewForm();
            m_footnoteForm.DeleteRegistryKey();
            m_footnoteForm.CreateFootnoteView(Cache);

            //Application.DoEvents();
            m_footnoteForm.Show();
            m_footnoteView = m_footnoteForm.FootnoteView;
            Application.DoEvents();
        }
Пример #4
0
        public void SpaceAfterFootnoteMarker()
        {
            // Prepare the test by creating a footnote view
            FwStyleSheet styleSheet = new FwStyleSheet();

            styleSheet.Init(m_fdoCache, m_scr.Hvo,
                            (int)Scripture.ScriptureTags.kflidStyles);

            using (DummyFootnoteView footnoteView = new DummyFootnoteView(m_fdoCache))
            {
                footnoteView.StyleSheet = styleSheet;
                footnoteView.Visible    = false;

                // We don't actually want to show it, but we need to force the view to create the root
                // box and lay it out so that various test stuff can happen properly.
                footnoteView.MakeRoot();
                footnoteView.CallLayout();

                // Select the footnote marker and some characters of the footnote paragraph
                footnoteView.RootBox.MakeSimpleSel(true, false, false, true);
                SelectionHelper selHelper = SelectionHelper.GetSelectionInfo(null, footnoteView);
                selHelper.IchAnchor = 0;
                selHelper.IchEnd    = 5;
                SelLevInfo[] selLevInfo = new SelLevInfo[3];
                Assert.AreEqual(4, selHelper.GetNumberOfLevels(SelectionHelper.SelLimitType.End));
                Array.Copy(selHelper.GetLevelInfo(SelectionHelper.SelLimitType.End), 1, selLevInfo, 0, 3);
                selHelper.SetLevelInfo(SelectionHelper.SelLimitType.End, selLevInfo);
                selHelper.SetTextPropId(SelectionHelper.SelLimitType.End,
                                        (int)StTxtPara.StTxtParaTags.kflidContents);
                selHelper.SetSelection(true);

                // Now the real test:
                IVwSelection sel = footnoteView.RootBox.Selection;
                ITsString    tss;
                sel.GetSelectionString(out tss, string.Empty);
                Assert.AreEqual("a ", tss.Text.Substring(0, 2));

                //				// make sure the marker and the space are read-only and the paragraph not.
                //				ITsTextProps[] vttp;
                //				IVwPropertyStore[] vvps;
                //				int cttp;
                //				SelectionHelper.GetSelectionProps(sel, out vttp, out vvps, out cttp);
                //				Assert.IsTrue(cttp >= 3);
                //				Assert.IsFalse(SelectionHelper.IsEditable(vttp[0], vvps[0]),
                //					"Footnote marker is not read-only");
                //				Assert.IsFalse(SelectionHelper.IsEditable(vttp[1], vvps[1]),
                //					"Space after marker is not read-only");
                //				Assert.IsTrue(SelectionHelper.IsEditable(vttp[2], vvps[2]),
                //					"Footnote text is read-only");
                //				Assert.IsTrue(SelectionHelper.IsEditable(vttp[3], vvps[3]),
                //					"Footnote text is read-only");
            }
        }
Пример #5
0
        public void SpaceAfterFootnoteMarker()
        {
            IScrBook     book     = m_scr.ScriptureBooksOS[0];
            IScrFootnote footnote = AddFootnote(book, (IStTxtPara)book.TitleOA.ParagraphsOS[0], 0, "This is a footnote");

            footnote.FootnoteMarker = Cache.TsStrFactory.MakeString("a", Cache.WritingSystemFactory.GetWsFromStr("en"));
            // Prepare the test by creating a footnote view
            FwStyleSheet styleSheet = new FwStyleSheet();

            styleSheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);

            using (DummyFootnoteView footnoteView = new DummyFootnoteView(Cache))
            {
                footnoteView.StyleSheet = styleSheet;
                footnoteView.Visible    = false;

                // We don't actually want to show it, but we need to force the view to create the root
                // box and lay it out so that various test stuff can happen properly.
                footnoteView.MakeRoot();
                footnoteView.CallLayout();

                // Select the footnote marker and some characters of the footnote paragraph
                footnoteView.RootBox.MakeSimpleSel(true, false, false, true);
                SelectionHelper selHelper = SelectionHelper.GetSelectionInfo(null, footnoteView);
                selHelper.IchAnchor = 0;
                selHelper.IchEnd    = 5;
                SelLevInfo[] selLevInfo = new SelLevInfo[3];
                Assert.AreEqual(4, selHelper.GetNumberOfLevels(SelectionHelper.SelLimitType.End));
                Array.Copy(selHelper.GetLevelInfo(SelectionHelper.SelLimitType.End), 1, selLevInfo, 0, 3);
                selHelper.SetLevelInfo(SelectionHelper.SelLimitType.End, selLevInfo);
                selHelper.SetTextPropId(SelectionHelper.SelLimitType.End,
                                        StTxtParaTags.kflidContents);
                selHelper.SetSelection(true);

                // Now the real test:
                IVwSelection sel = footnoteView.RootBox.Selection;
                ITsString    tss;
                sel.GetSelectionString(out tss, string.Empty);
                Assert.AreEqual("a ", tss.Text.Substring(0, 2));

                // make sure the marker and the space are read-only (maybe have to select each run
                // separately to make this test truly correct)
                ITsTextProps[]     vttp;
                IVwPropertyStore[] vvps;
                int cttp;
                SelectionHelper.GetSelectionProps(sel, out vttp, out vvps, out cttp);
                Assert.IsTrue(cttp >= 2);
                Assert.IsFalse(SelectionHelper.IsEditable(vttp[0], vvps[0]),
                               "Footnote marker is not read-only");
                Assert.IsFalse(SelectionHelper.IsEditable(vttp[1], vvps[1]),
                               "Space after marker is not read-only");
            }
        }
Пример #6
0
        public void Init()
        {
            m_footnoteForm = new DummyFootnoteViewForm();
            m_footnoteForm.DeleteRegistryKey();
            m_footnoteForm.CreateFootnoteView();

            //Application.DoEvents();
            m_footnoteForm.Show();
            m_footnoteView = m_footnoteForm.FootnoteView;
            m_cache        = m_footnoteForm.Cache;
            IScripture scr = m_cache.LangProject.TranslatedScriptureOA;

            Application.DoEvents();
        }
Пример #7
0
        public void FootnoteTranslationTest()
        {
            // get an existing footnote
            IScrBook    book     = m_scr.ScriptureBooksOS[1];      // book of James
            IStFootnote footnote = book.FootnotesOS[0];
            StTxtPara   para     = (StTxtPara)footnote.ParagraphsOS[0];

            // add a translation to the footnote
            ICmTranslation translation = para.GetOrCreateBT();

            translation.Translation.AnalysisDefaultWritingSystem.UnderlyingTsString =
                TsStringHelper.MakeTSS("abcde", m_fdoCache.DefaultAnalWs);

            FwStyleSheet styleSheet = new FwStyleSheet();

            styleSheet.Init(m_fdoCache, m_scr.Hvo,
                            (int)Scripture.ScriptureTags.kflidStyles);

            // Prepare the test by creating a footnote view
            using (DummyFootnoteView footnoteView = new DummyFootnoteView(m_fdoCache, true))
            {
                footnoteView.StyleSheet = styleSheet;
                footnoteView.Visible    = false;

                // We don't actually want to show it, but we need to force the view to create the root
                // box and lay it out so that various test stuff can happen properly.
                footnoteView.MakeRoot();
                footnoteView.CallLayout();

                // Select the footnote marker and some characters of the footnote paragraph
                footnoteView.RootBox.MakeSimpleSel(true, true, false, true);
                SelectionHelper selHelper = SelectionHelper.GetSelectionInfo(null, footnoteView);

                // Now the real test:
                IVwSelection sel = footnoteView.RootBox.Selection.GrowToWord();
                ITsString    tss;
                sel.GetSelectionString(out tss, string.Empty);
                Assert.AreEqual("abcde", tss.Text);
            }
        }
Пример #8
0
 public void CleanUp()
 {
     if (m_cache != null)
     {
         if (m_cache.CanUndo)
         {
             m_cache.Undo();
         }
         if (m_cache.DatabaseAccessor.IsTransactionOpen())
         {
             m_cache.DatabaseAccessor.RollbackTrans();
         }
     }
     else
     {
         Debug.WriteLine("Null cache in cleanup, something went wrong.");
     }
     m_cache        = null;
     m_footnoteView = null;
     m_footnoteForm.Close();
     m_footnoteForm = null;
 }
Пример #9
0
        public void FootnoteTranslationTest()
        {
            // get an existing footnote
            IScrBook     book     = m_scr.ScriptureBooksOS[1];     // book of Exodus
            IScrFootnote footnote = AddFootnote(book, (IStTxtPara)book.TitleOA.ParagraphsOS[0], 0, "This is a footnote");
            IStTxtPara   para     = (IStTxtPara)footnote.ParagraphsOS[0];

            // add a translation to the footnote
            ICmTranslation translation = para.GetOrCreateBT();
            int            analWs      = Cache.DefaultAnalWs;

            translation.Translation.set_String(analWs, TsStringHelper.MakeTSS("abcde", analWs));

            FwStyleSheet styleSheet = new FwStyleSheet();

            styleSheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);

            // Prepare the test by creating a footnote view
            using (DummyFootnoteView footnoteView = new DummyFootnoteView(Cache, true))
            {
                footnoteView.StyleSheet = styleSheet;
                footnoteView.Visible    = false;

                // We don't actually want to show it, but we need to force the view to create the root
                // box and lay it out so that various test stuff can happen properly.
                footnoteView.MakeRoot();
                footnoteView.CallLayout();

                // Select the footnote marker and some characters of the footnote paragraph
                footnoteView.RootBox.MakeSimpleSel(true, true, false, true);

                // Now the real test:
                IVwSelection sel = footnoteView.RootBox.Selection.GrowToWord();
                ITsString    tss;
                sel.GetSelectionString(out tss, string.Empty);
                Assert.AreEqual("abcde", tss.Text);
            }
        }
Пример #10
0
		public void ReadOnlySpaceAfterFootnoteMarker()
		{
			// Prepare the test by creating a footnote view
			FwStyleSheet styleSheet = new FwStyleSheet();
			styleSheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);

			using (Form form = new Form())
			using (DummyFootnoteView footnoteView = new DummyFootnoteView(Cache))
			{
				footnoteView.StyleSheet = styleSheet;
				footnoteView.Dock = DockStyle.Fill;
				footnoteView.Name = "footnoteView";
				footnoteView.Visible = true;
				form.Controls.Add(footnoteView);
				form.Show();

				try
				{
					// Select the footnote marker and some characters of the footnote paragraph
					footnoteView.RootBox.MakeSimpleSel(true, false, false, true);
					SelectionHelper selHelper = SelectionHelper.GetSelectionInfo(null, footnoteView);
					selHelper.IchAnchor = 0;
					selHelper.IchEnd = 5;
					SelLevInfo[] selLevInfo = new SelLevInfo[3];
					Assert.AreEqual(4, selHelper.GetNumberOfLevels(SelectionHelper.SelLimitType.End));
					Array.Copy(selHelper.GetLevelInfo(SelectionHelper.SelLimitType.End), 1, selLevInfo, 0, 3);
					selHelper.SetLevelInfo(SelectionHelper.SelLimitType.End, selLevInfo);
					selHelper.SetTextPropId(SelectionHelper.SelLimitType.End,
						StTxtParaTags.kflidContents);
					selHelper.SetSelection(true);

					// Now the real test:
					IVwSelection sel = footnoteView.RootBox.Selection;
					ITsString tss;
					sel.GetSelectionString(out tss, string.Empty);
					Assert.AreEqual("a ", tss.Text.Substring(0, 2));

					// make sure the marker and the space are read-only and the paragraph not.
					ITsTextProps[] vttp;
					IVwPropertyStore[] vvps;
					int cttp;
					SelectionHelper.GetSelectionProps(sel, out vttp, out vvps, out cttp);
					Assert.IsTrue(cttp >= 3);
					Assert.IsFalse(SelectionHelper.IsEditable(vttp[0], vvps[0]),
						"Footnote marker is not read-only");
					Assert.IsFalse(SelectionHelper.IsEditable(vttp[1], vvps[1]),
						"Space after marker is not read-only");
					Assert.IsTrue(SelectionHelper.IsEditable(vttp[2], vvps[2]),
						"Footnote text is read-only");
					Assert.IsTrue(SelectionHelper.IsEditable(vttp[3], vvps[3]),
						"Footnote text is read-only");
				}
				finally
				{
					form.Close();
				}
			}
		}
Пример #11
0
		public void FootnoteTranslationTest()
		{
			// get an existing footnote
			IScrBook book = m_scr.ScriptureBooksOS[1]; // book of Exodus
			IScrFootnote footnote = AddFootnote(book, (IStTxtPara)book.TitleOA.ParagraphsOS[0], 0, "This is a footnote");
			IStTxtPara para = (IStTxtPara)footnote.ParagraphsOS[0];

			// add a translation to the footnote
			ICmTranslation translation = para.GetOrCreateBT();
			int analWs = Cache.DefaultAnalWs;
			translation.Translation.set_String(analWs, TsStringHelper.MakeTSS("abcde", analWs));

			FwStyleSheet styleSheet = new FwStyleSheet();
			styleSheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);

			// Prepare the test by creating a footnote view
			using (DummyFootnoteView footnoteView = new DummyFootnoteView(Cache, true))
			{
				footnoteView.StyleSheet = styleSheet;
				footnoteView.Visible = false;

				// We don't actually want to show it, but we need to force the view to create the root
				// box and lay it out so that various test stuff can happen properly.
				footnoteView.MakeRoot();
				footnoteView.CallLayout();

				// Select the footnote marker and some characters of the footnote paragraph
				footnoteView.RootBox.MakeSimpleSel(true, true, false, true);

				// Now the real test:
				IVwSelection sel = footnoteView.RootBox.Selection.GrowToWord();
				ITsString tss;
				sel.GetSelectionString(out tss, string.Empty);
				Assert.AreEqual("abcde", tss.Text);
			}
		}
Пример #12
0
		public void SpaceAfterFootnoteMarker()
		{
			IScrBook book = m_scr.ScriptureBooksOS[0];
			IScrFootnote footnote = AddFootnote(book, (IStTxtPara)book.TitleOA.ParagraphsOS[0], 0, "This is a footnote");
			footnote.FootnoteMarker = Cache.TsStrFactory.MakeString("a", Cache.WritingSystemFactory.GetWsFromStr("en"));
			// Prepare the test by creating a footnote view
			FwStyleSheet styleSheet = new FwStyleSheet();
			styleSheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);

			using (DummyFootnoteView footnoteView = new DummyFootnoteView(Cache))
			{
				footnoteView.StyleSheet = styleSheet;
				footnoteView.Visible = false;

				// We don't actually want to show it, but we need to force the view to create the root
				// box and lay it out so that various test stuff can happen properly.
				footnoteView.MakeRoot();
				footnoteView.CallLayout();

				// Select the footnote marker and some characters of the footnote paragraph
				footnoteView.RootBox.MakeSimpleSel(true, false, false, true);
				SelectionHelper selHelper = SelectionHelper.GetSelectionInfo(null, footnoteView);
				selHelper.IchAnchor = 0;
				selHelper.IchEnd = 5;
				SelLevInfo[] selLevInfo = new SelLevInfo[3];
				Assert.AreEqual(4, selHelper.GetNumberOfLevels(SelectionHelper.SelLimitType.End));
				Array.Copy(selHelper.GetLevelInfo(SelectionHelper.SelLimitType.End), 1, selLevInfo, 0, 3);
				selHelper.SetLevelInfo(SelectionHelper.SelLimitType.End, selLevInfo);
				selHelper.SetTextPropId(SelectionHelper.SelLimitType.End,
					StTxtParaTags.kflidContents);
				selHelper.SetSelection(true);

				// Now the real test:
				IVwSelection sel = footnoteView.RootBox.Selection;
				ITsString tss;
				sel.GetSelectionString(out tss, string.Empty);
				Assert.AreEqual("a ", tss.Text.Substring(0, 2));

				// make sure the marker and the space are read-only (maybe have to select each run
				// separately to make this test truly correct)
				ITsTextProps[] vttp;
				IVwPropertyStore[] vvps;
				int cttp;
				SelectionHelper.GetSelectionProps(sel, out vttp, out vvps, out cttp);
				Assert.IsTrue(cttp >= 2);
				Assert.IsFalse(SelectionHelper.IsEditable(vttp[0], vvps[0]),
					"Footnote marker is not read-only");
				Assert.IsFalse(SelectionHelper.IsEditable(vttp[1], vvps[1]),
					"Space after marker is not read-only");
			}
		}
Пример #13
0
		public void FootnoteTranslationTest()
		{
			// get an existing footnote
			IScrBook book = m_scr.ScriptureBooksOS[1]; // book of James
			IStFootnote footnote = book.FootnotesOS[0];
			StTxtPara para = (StTxtPara)footnote.ParagraphsOS[0];

			// add a translation to the footnote
			ICmTranslation translation = para.GetOrCreateBT();
			translation.Translation.AnalysisDefaultWritingSystem.UnderlyingTsString =
				TsStringHelper.MakeTSS("abcde", m_fdoCache.DefaultAnalWs);

			FwStyleSheet styleSheet = new FwStyleSheet();
			styleSheet.Init(m_fdoCache, m_scr.Hvo,
				(int)Scripture.ScriptureTags.kflidStyles);

			// Prepare the test by creating a footnote view
			using (DummyFootnoteView footnoteView = new DummyFootnoteView(m_fdoCache, true))
			{
				footnoteView.StyleSheet = styleSheet;
				footnoteView.Visible = false;

				// We don't actually want to show it, but we need to force the view to create the root
				// box and lay it out so that various test stuff can happen properly.
				footnoteView.MakeRoot();
				footnoteView.CallLayout();

				// Select the footnote marker and some characters of the footnote paragraph
				footnoteView.RootBox.MakeSimpleSel(true, true, false, true);
				SelectionHelper selHelper = SelectionHelper.GetSelectionInfo(null, footnoteView);

				// Now the real test:
				IVwSelection sel = footnoteView.RootBox.Selection.GrowToWord();
				ITsString tss;
				sel.GetSelectionString(out tss, string.Empty);
				Assert.AreEqual("abcde", tss.Text);
			}
		}
Пример #14
0
		public void SpaceAfterFootnoteMarker()
		{
			// Prepare the test by creating a footnote view
			FwStyleSheet styleSheet = new FwStyleSheet();
			styleSheet.Init(m_fdoCache, m_scr.Hvo,
				(int)Scripture.ScriptureTags.kflidStyles);

			using (DummyFootnoteView footnoteView = new DummyFootnoteView(m_fdoCache))
			{
				footnoteView.StyleSheet = styleSheet;
				footnoteView.Visible = false;

				// We don't actually want to show it, but we need to force the view to create the root
				// box and lay it out so that various test stuff can happen properly.
				footnoteView.MakeRoot();
				footnoteView.CallLayout();

				// Select the footnote marker and some characters of the footnote paragraph
				footnoteView.RootBox.MakeSimpleSel(true, false, false, true);
				SelectionHelper selHelper = SelectionHelper.GetSelectionInfo(null, footnoteView);
				selHelper.IchAnchor = 0;
				selHelper.IchEnd = 5;
				SelLevInfo[] selLevInfo = new SelLevInfo[3];
				Assert.AreEqual(4, selHelper.GetNumberOfLevels(SelectionHelper.SelLimitType.End));
				Array.Copy(selHelper.GetLevelInfo(SelectionHelper.SelLimitType.End), 1, selLevInfo, 0, 3);
				selHelper.SetLevelInfo(SelectionHelper.SelLimitType.End, selLevInfo);
				selHelper.SetTextPropId(SelectionHelper.SelLimitType.End,
					(int)StTxtPara.StTxtParaTags.kflidContents);
				selHelper.SetSelection(true);

				// Now the real test:
				IVwSelection sel = footnoteView.RootBox.Selection;
				ITsString tss;
				sel.GetSelectionString(out tss, string.Empty);
				Assert.AreEqual("a ", tss.Text.Substring(0, 2));

				//				// make sure the marker and the space are read-only and the paragraph not.
				//				ITsTextProps[] vttp;
				//				IVwPropertyStore[] vvps;
				//				int cttp;
				//				SelectionHelper.GetSelectionProps(sel, out vttp, out vvps, out cttp);
				//				Assert.IsTrue(cttp >= 3);
				//				Assert.IsFalse(SelectionHelper.IsEditable(vttp[0], vvps[0]),
				//					"Footnote marker is not read-only");
				//				Assert.IsFalse(SelectionHelper.IsEditable(vttp[1], vvps[1]),
				//					"Space after marker is not read-only");
				//				Assert.IsTrue(SelectionHelper.IsEditable(vttp[2], vvps[2]),
				//					"Footnote text is read-only");
				//				Assert.IsTrue(SelectionHelper.IsEditable(vttp[3], vvps[3]),
				//					"Footnote text is read-only");
			}
		}