コード例 #1
0
		public void UpdateVerseBridgesInParagraph_InvalidRtoLBridge()
		{
			// Set up a verse with invalid verse bridge
			IScrTxtPara para = AddParaToMockedSectionContent(m_exodus.SectionsOS[0], ScrStyleNames.NormalParagraph);
			AddVerse(para, 0, 1, "Verse one.");
			// NOTE: The verse number format is how TE represents verse numbers with bridges.
			// This method should not change anything but the verse bridge character.
			AddVerse(para, 0, "2" + '\u200F' + '\u200F' + "&" + '\u200F' + '\u200F' + '\u200F',
				"Verse with invalid bridge.");

			using (ScriptureProperties dlg = new ScriptureProperties(Cache, m_stylesheet, null, true, null))
			{
				ReflectionHelper.CallMethod(dlg, "UpdateVerseBridgesInParagraph", para,
				'\u200f' + "&" + '\u200f', '\u200f' + "@" + '\u200f');

				AssertEx.RunIsCorrect(para.Contents, 0, "1",
					ScrStyleNames.VerseNumber, Cache.DefaultVernWs);
				AssertEx.RunIsCorrect(para.Contents, 1, "Verse one.", null, Cache.DefaultVernWs);
				AssertEx.RunIsCorrect(para.Contents, 2, "2" + '\u200F' + '\u200F' + "@" + '\u200F' + '\u200F' + '\u200F',
					ScrStyleNames.VerseNumber, Cache.DefaultVernWs);
				AssertEx.RunIsCorrect(para.Contents, 3, "Verse with invalid bridge.", null, Cache.DefaultVernWs);
			}
		}
コード例 #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Test converting the digits to a specific digit set
		/// </summary>
		/// <param name="zeroChar">zero character in the desired language</param>
		/// <param name="nineChar">nine character in the desired language</param>
		/// <param name="dlg">scripture properties dialog</param>
		/// ------------------------------------------------------------------------------------
		private void ScriptDigitConversionTest(char zeroChar, char nineChar, ScriptureProperties dlg)
		{
			m_scr.ScriptDigitZero = zeroChar;
			m_scr.UseScriptDigits = (zeroChar != '0');

			ReflectionHelper.CallMethod(dlg, "ConvertChapterVerseNumbers", null);

			int[] expectedNumbers = new [] { 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
			int expectedIndex = 0;

			ITsString tss = ((IStTxtPara)(m_exodus.SectionsOS[0]).ContentOA.ParagraphsOS[0]).Contents;
			for (int i = 0; i < tss.RunCount; i++)
			{
				TsRunInfo tri;
				ITsTextProps ttp = tss.FetchRunInfo(i, out tri);
				IStStyle style = m_scr.FindStyle(ttp);
				if (style != null &&
					(style.Function == FunctionValues.Verse ||
					style.Function == FunctionValues.Chapter))
				{
					int expectedNumber = expectedNumbers[expectedIndex++];
					string runChars = tss.GetChars(tri.ichMin, tri.ichLim);
					// make sure the expected digits were found
					Assert.AreEqual(expectedNumber, ScrReference.ChapterToInt(runChars));

					// make sure that all of the digits are in the desired language
					foreach (char c in runChars)
					{
						if (Char.IsDigit(c))
							Assert.IsTrue(c >= zeroChar && c <= nineChar, "Found incorrect digit");
					}
				}
			}

			// Make sure we saw all the expected numbers in the data
			Assert.AreEqual(expectedNumbers.Length, expectedIndex);
		}
コード例 #3
0
		public void ConvertChapterVerseNumbersTest_EmptyChapterNumber()
		{
			// Add paragraph with empty chapter number run.
			IStTxtPara para = AddParaToMockedSectionContent(m_exodus.SectionsOS[0], ScrStyleNames.ChapterNumber);
			ITsPropsFactory propFact = TsPropsFactoryClass.Create();
			ITsTextProps ttpChapterNumber = propFact.MakeProps(ScrStyleNames.ChapterNumber,
				Cache.ServiceLocator.WritingSystemManager.GetWsFromStr("fr"), 0);
			ITsStrBldr bldr = para.Contents.GetBldr();
			bldr.SetProperties(0, 0, ttpChapterNumber);
			para.Contents = bldr.GetString();

			using (ScriptureProperties dlg = new ScriptureProperties(Cache, m_stylesheet, null, true, null))
			{
				char bengaliZero = '\u09e6';
				char bengaliNine = (char)((int)bengaliZero + 9);

				// test arabic->bengali when there is a paragraph with an empty chapter number run.
				// It should complete without crashing.
				ScriptDigitConversionTest(bengaliZero, bengaliNine, dlg);
				// test bengali->arabic
				ScriptDigitConversionTest('0', '9', dlg);
			}
		}
コード例 #4
0
		public void ConvertChapterVerseNumbersTest_Bengali()
		{
			using (ScriptureProperties dlg = new ScriptureProperties(Cache, m_stylesheet, null, true, null))
			{
				char bengaliZero = '\u09e6';
				char bengaliNine = (char)((int)bengaliZero + 9);

				// test arabic->bengali
				ScriptDigitConversionTest(bengaliZero, bengaliNine, dlg);
				// test bengali->arabic
				ScriptDigitConversionTest('0', '9', dlg);
			}
		}
コード例 #5
0
ファイル: TeMainWnd.cs プロジェクト: sillsdev/FieldWorks
		private DialogResult DisplayScripturePropertiesDlg(bool fOnFootnoteTab, bool showFootnoteTab)
		{
			// even when the IP is in the footnote pane we still want to pass the draft view
			// because that controls the footnote pane. Otherwise the scrolling doesn't work
			// too well (DraftView scrolls to random place if IP is in footnote pane).
			IRootSite rootSite = ActiveView;
			var footnoteView = rootSite as FootnoteView;
			if (footnoteView != null)
				rootSite = footnoteView.DraftView;

			using (ScriptureProperties dlg = new ScriptureProperties(m_cache,
				m_StyleSheet, rootSite, showFootnoteTab, m_app))
			{
				if (fOnFootnoteTab && showFootnoteTab)
					dlg.DialogTab = ScriptureProperties.kFootnotesTab;

				return dlg.ShowDialog(this);
			}
		}
コード例 #6
0
		public void UpdateVerseBridgesInParagraph_ValidRtoLBridge()
		{
			// Set up a verse with invalid verse bridge
			StTxtPara para = AddPara(m_exodus.SectionsOS[0]);
			AddVerse(para, 0, 5, "Verse five.");
			// Right-to-Left Bridge: 6-24
			// NOTE: The verse number format is how TE represents verse numbers with bridges.
			// This method should not change anything but the verse bridge character.
			AddVerse(para, 0, "6" + '\u200f' + '\u200f' + "@" + '\u200f' + '\u200f' + '\u200f' + "24",
				"Verse with valid R-to-L bridge.");

			ScriptureProperties dlg = new ScriptureProperties(Cache, m_stylesheet, null, true);
			ReflectionHelper.CallMethod(dlg, "UpdateVerseBridgesInParagraph", para,
				'\u200f' + "@" + '\u200f', '\u200f' + "&" + '\u200f');

			AssertEx.RunIsCorrect(para.Contents.UnderlyingTsString, 0, "5", ScrStyleNames.VerseNumber,
				Cache.DefaultVernWs);
			AssertEx.RunIsCorrect(para.Contents.UnderlyingTsString, 1, "Verse five.", ScrStyleNames.NormalParagraph,
				Cache.DefaultVernWs);
			AssertEx.RunIsCorrect(para.Contents.UnderlyingTsString, 2, "6" + '\u200f' + '\u200f' + "&" +
				'\u200f' + '\u200f' + '\u200f' + "24", ScrStyleNames.VerseNumber, Cache.DefaultVernWs);
			AssertEx.RunIsCorrect(para.Contents.UnderlyingTsString, 3, "Verse with valid R-to-L bridge.",
				ScrStyleNames.NormalParagraph, Cache.DefaultVernWs);
		}
コード例 #7
0
		public void ConvertChapterVerseNumbersTest_EmptyChapterNumber()
		{
			CheckDisposed();

			// Add paragraph with empty chapter number run.
			StTxtPara para = m_scrInMemoryCache.AddParaToMockedSectionContent(m_exodus.SectionsOS[0].Hvo,
				ScrStyleNames.ChapterNumber);
			ITsPropsFactory propFact = TsPropsFactoryClass.Create();
			ITsTextProps ttpChapterNumber = propFact.MakeProps(ScrStyleNames.ChapterNumber,
				(int)InMemoryFdoCache.s_wsHvos.Fr, 0);
			ITsStrBldr bldr = para.Contents.UnderlyingTsString.GetBldr();
			bldr.SetProperties(0, 0, ttpChapterNumber);
			para.Contents.UnderlyingTsString = bldr.GetString();

			ScriptureProperties dlg = new ScriptureProperties(Cache, m_stylesheet, null, true);

			char bengaliZero = '\u09e6';
			char bengaliNine = (char)((int)bengaliZero + 9);

			// test arabic->bengali when there is a paragraph with an empty chapter number run.
			// It should complete without crashing.
			ScriptDigitConversionTest(bengaliZero, bengaliNine, dlg);
			// test bengali->arabic
			ScriptDigitConversionTest('0', '9', dlg);
		}