Пример #1
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");
            }
        }
Пример #2
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");
            }
        }
Пример #3
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);
            }
        }
Пример #4
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);
            }
        }
Пример #5
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);
			}
		}
Пример #6
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");
			}
		}
Пример #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 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");
			}
		}