示例#1
0
        public void ExportFootnote_Missing()
        {
            CheckDisposed();

            int markerStyleNumber =
                m_styleSheet.FindStyle(ScrStyleNames.FootnoteMarker).IndexInOwner + 1;
            int footnoteStyleNumber =
                m_styleSheet.FindStyle(ScrStyleNames.NormalFootnoteParagraph).IndexInOwner + 1;

            ITsStrFactory stringFactory = TsStrFactoryClass.Create();

            // Create a book with a section that has a paragraph with some text and a footnote!
            m_scrInMemoryCache.AddRunToMockedPara(m_para, "My text for footnotes", string.Empty);

            StFootnote testFootnote = m_scrInMemoryCache.AddFootnote(m_book, m_para, m_para.Contents.UnderlyingTsString.Length);

            // Set the GUID to an object that does not exist (Guid.Empty).
            testFootnote.Guid = new Guid("400BF7E7-B61A-4112-AFFD-188B505F177D");

            m_exporter = new DummyExportRtf(m_fileName, Cache, m_styleSheet);
            m_exporter.CallExportParagraph(m_para);

            // Verify the contents of the temp file
            m_exporter.CloseOutputFile();
            using (StreamReader file = new StreamReader(m_fileName, Encoding.ASCII))
            {
                string line = file.ReadLine();

                // the line is the paragraph without the footnote marker.
                Assert.AreEqual(@"\pard\plain\s2\f2\fs20{My text for footnotes}", line);
            }
        }
示例#2
0
        public void ExportTextWithBraces()
        {
            m_exporter = new DummyExportRtf(m_fileName, Cache, m_styleSheet);
            m_exporter.CallExportRun("This {is} a (test}.");

            // Verify the contents of the temp file
            m_exporter.CloseOutputFile();
            using (StreamReader file = new StreamReader(m_fileName, Encoding.ASCII))
            {
                string line = file.ReadLine();
                Assert.AreEqual(@"This \{is\} a (test\}.", line);
            }
        }
示例#3
0
        public override void Exit()
        {
            CheckDisposed();

            m_styleSheet = null;
            m_exporter   = null;

            m_book    = null;
            m_section = null;
            m_para    = null;

            base.Exit();
        }
示例#4
0
        public void ExportFootnote_Unicode()
        {
            CheckDisposed();

            int markerStyleNumber =
                m_styleSheet.FindStyle(ScrStyleNames.FootnoteMarker).IndexInOwner + 1;
            int footnoteStyleNumber =
                m_styleSheet.FindStyle(ScrStyleNames.NormalFootnoteParagraph).IndexInOwner + 1;

            ITsStrFactory stringFactory = TsStrFactoryClass.Create();

            // Create a book with a section that has a paragraph with some text and a footnote!
            m_scrInMemoryCache.AddRunToMockedPara(m_para, "My text for footnotes", string.Empty);
            StFootnote footnote = m_scrInMemoryCache.AddFootnote(m_book, m_para, 2);

            m_scr.FootnoteMarkerType      = FootnoteMarkerTypes.SymbolicFootnoteMarker;
            m_scr.FootnoteMarkerSymbol    = "¶";
            m_scr.DisplaySymbolInFootnote = true;
            footnote.FootnoteMarker.UnderlyingTsString = stringFactory.MakeString(null, Cache.DefaultVernWs);
            StTxtPara footnotePara = new StTxtPara();

            footnote.ParagraphsOS.Append(footnotePara);
            footnotePara.StyleRules = StyleUtils.ParaStyleTextProps(ScrStyleNames.NormalFootnoteParagraph);
            string footnoteText = "C\u00f2\u00f3\u013a footnot\u0113";

            footnotePara.Contents.UnderlyingTsString = stringFactory.MakeString(footnoteText, Cache.DefaultVernWs);

            m_exporter = new DummyExportRtf(m_fileName, Cache, m_styleSheet);
            m_exporter.CallExportFootnote(new ScrFootnote(Cache, footnote.Hvo));

            // Verify the contents of the temp file
            m_exporter.CloseOutputFile();
            using (StreamReader file = new StreamReader(m_fileName, Encoding.ASCII))
            {
                string line1 = file.ReadLine();
                string line2 = file.ReadLine();

                // the first line is the marker emitted into the text stream.
                // Footnote markers now have the footnote marker style applied
                Assert.AreEqual(@"\*\cs" + markerStyleNumber + @" \uc0\u182 }", line1);
                Assert.AreEqual(@"{\footnote \pard\plain \s" + footnoteStyleNumber +
                                @"\f2\fs20{" + @"\*\cs" + markerStyleNumber + @" \uc0\u182 " +
                                @"}{ }{C\uc0\u242 \uc0\u243 \uc0\u314  footnot\uc0\u275 }",
                                line2);
            }
        }
示例#5
0
        public void ExportRtfBtFootnotes()
        {
            // Set up the vernacular text.
            m_scrInMemoryCache.AddTitleToMockedBook(m_book.Hvo, "Genesis");
            m_scrInMemoryCache.AddRunToMockedPara(m_para, "1", ScrStyleNames.ChapterNumber);
            m_scrInMemoryCache.AddRunToMockedPara(m_para, "1", ScrStyleNames.VerseNumber);
            m_scrInMemoryCache.AddRunToMockedPara(m_para, "yi kuch batchit he.", null);
            StFootnote footnote1 = m_scrInMemoryCache.AddFootnote(
                m_book, m_para, 2, "pehla pao wala note");

            // Set up back translation.
            int            wsBt       = m_scrInMemoryCache.Cache.DefaultAnalWs;
            ICmTranslation transPara1 = m_scrInMemoryCache.AddBtToMockedParagraph(m_para, wsBt);

            m_scrInMemoryCache.AddRunToMockedTrans(transPara1, wsBt, "1", ScrStyleNames.ChapterNumber);
            m_scrInMemoryCache.AddRunToMockedTrans(transPara1, wsBt, "1", ScrStyleNames.VerseNumber);
            m_scrInMemoryCache.AddRunToMockedTrans(transPara1, wsBt, "This is some text.", null);
            m_scrInMemoryCache.AddFootnoteORCtoTrans(transPara1, 4, wsBt, footnote1, "First footnote");

            m_scr.DisplaySymbolInFootnote = true;

            // Export the back translation of the footnote.
            m_exporter = new DummyExportRtf(m_fileName, Cache, m_styleSheet, wsBt);
            m_exporter.CallExportFootnote(new ScrFootnote(Cache, footnote1.Hvo), wsBt);
            m_exporter.CloseOutputFile();

            int markerStyleNumber =
                m_styleSheet.FindStyle(ScrStyleNames.FootnoteMarker).IndexInOwner + 1;
            int footnoteStyleNumber =
                m_styleSheet.FindStyle(ScrStyleNames.NormalFootnoteParagraph).IndexInOwner + 1;

            using (StreamReader file = new StreamReader(m_fileName, Encoding.ASCII))
            {
                string line1 = file.ReadLine();
                string line2 = file.ReadLine();

                // the first line is the marker emitted into the text stream.
                // Footnote markers now have the footnote marker style applied
                Assert.AreEqual(@"\*\cs" + markerStyleNumber + @" a}", line1);
                Assert.AreEqual(@"{\footnote \pard\plain \s" + footnoteStyleNumber +
                                @"\f2\fs20{" + @"\*\cs" + markerStyleNumber + @" a" + @"}{ }{First footnote}", line2);
            }
        }
示例#6
0
		public void ExportRtfBtFootnotes()
		{
			// Set up the vernacular text.
			m_scrInMemoryCache.AddTitleToMockedBook(m_book.Hvo, "Genesis");
			m_scrInMemoryCache.AddRunToMockedPara(m_para, "1", ScrStyleNames.ChapterNumber);
			m_scrInMemoryCache.AddRunToMockedPara(m_para, "1", ScrStyleNames.VerseNumber);
			m_scrInMemoryCache.AddRunToMockedPara(m_para, "yi kuch batchit he.", null);
			StFootnote footnote1 = m_scrInMemoryCache.AddFootnote(
				m_book, m_para, 2, "pehla pao wala note");

			// Set up back translation.
			int wsBt = m_scrInMemoryCache.Cache.DefaultAnalWs;
			ICmTranslation transPara1 = m_scrInMemoryCache.AddBtToMockedParagraph(m_para, wsBt);
			m_scrInMemoryCache.AddRunToMockedTrans(transPara1, wsBt, "1", ScrStyleNames.ChapterNumber);
			m_scrInMemoryCache.AddRunToMockedTrans(transPara1, wsBt, "1", ScrStyleNames.VerseNumber);
			m_scrInMemoryCache.AddRunToMockedTrans(transPara1, wsBt, "This is some text.", null);
			m_scrInMemoryCache.AddFootnoteORCtoTrans(transPara1, 4, wsBt, footnote1, "First footnote");

			m_scr.DisplaySymbolInFootnote = true;

			// Export the back translation of the footnote.
			m_exporter = new DummyExportRtf(m_fileName, Cache, m_styleSheet, wsBt);
			m_exporter.CallExportFootnote(new ScrFootnote(Cache, footnote1.Hvo), wsBt);
			m_exporter.CloseOutputFile();

			int markerStyleNumber =
				m_styleSheet.FindStyle(ScrStyleNames.FootnoteMarker).IndexInOwner + 1;
			int footnoteStyleNumber =
				m_styleSheet.FindStyle(ScrStyleNames.NormalFootnoteParagraph).IndexInOwner + 1;
			using (StreamReader file = new StreamReader(m_fileName, Encoding.ASCII))
			{
				string line1 = file.ReadLine();
				string line2 = file.ReadLine();

				// the first line is the marker emitted into the text stream.
				// Footnote markers now have the footnote marker style applied
				Assert.AreEqual(@"\*\cs" + markerStyleNumber + @" a}", line1);
				Assert.AreEqual(@"{\footnote \pard\plain \s" + footnoteStyleNumber +
					@"\f2\fs20{" + @"\*\cs" + markerStyleNumber + @" a" + @"}{ }{First footnote}", line2);
			}
		}
示例#7
0
		public void ExportTextWithBraces()
		{
			m_exporter = new DummyExportRtf(m_fileName, Cache, m_styleSheet);
			m_exporter.CallExportRun("This {is} a (test}.");

			// Verify the contents of the temp file
			m_exporter.CloseOutputFile();
			using (StreamReader file = new StreamReader(m_fileName, Encoding.ASCII))
			{
				string line = file.ReadLine();
				Assert.AreEqual(@"This \{is\} a (test\}.", line);
			}
		}
示例#8
0
		public void ExportFootnote_Missing()
		{
			CheckDisposed();

			int markerStyleNumber =
				m_styleSheet.FindStyle(ScrStyleNames.FootnoteMarker).IndexInOwner + 1;
			int footnoteStyleNumber =
				m_styleSheet.FindStyle(ScrStyleNames.NormalFootnoteParagraph).IndexInOwner + 1;

			ITsStrFactory stringFactory = TsStrFactoryClass.Create();

			// Create a book with a section that has a paragraph with some text and a footnote!
			m_scrInMemoryCache.AddRunToMockedPara(m_para, "My text for footnotes", string.Empty);

			StFootnote testFootnote = m_scrInMemoryCache.AddFootnote(m_book, m_para, m_para.Contents.UnderlyingTsString.Length);
			// Set the GUID to an object that does not exist (Guid.Empty).
			testFootnote.Guid = new Guid("400BF7E7-B61A-4112-AFFD-188B505F177D");

			m_exporter = new DummyExportRtf(m_fileName, Cache, m_styleSheet);
			m_exporter.CallExportParagraph(m_para);

			// Verify the contents of the temp file
			m_exporter.CloseOutputFile();
			using (StreamReader file = new StreamReader(m_fileName, Encoding.ASCII))
			{
				string line = file.ReadLine();

				// the line is the paragraph without the footnote marker.
				Assert.AreEqual(@"\pard\plain\s2\f2\fs20{My text for footnotes}", line);
			}
		}
示例#9
0
		public void ExportFootnote_Unicode()
		{
			CheckDisposed();

			int markerStyleNumber =
				m_styleSheet.FindStyle(ScrStyleNames.FootnoteMarker).IndexInOwner + 1;
			int footnoteStyleNumber =
				m_styleSheet.FindStyle(ScrStyleNames.NormalFootnoteParagraph).IndexInOwner + 1;

			ITsStrFactory stringFactory = TsStrFactoryClass.Create();

			// Create a book with a section that has a paragraph with some text and a footnote!
			m_scrInMemoryCache.AddRunToMockedPara(m_para, "My text for footnotes", string.Empty);
			StFootnote footnote = m_scrInMemoryCache.AddFootnote(m_book, m_para, 2);
			m_scr.FootnoteMarkerType = FootnoteMarkerTypes.SymbolicFootnoteMarker;
			m_scr.FootnoteMarkerSymbol = "¶";
			m_scr.DisplaySymbolInFootnote = true;
			footnote.FootnoteMarker.UnderlyingTsString = stringFactory.MakeString(null, Cache.DefaultVernWs);
			StTxtPara footnotePara = new StTxtPara();
			footnote.ParagraphsOS.Append(footnotePara);
			footnotePara.StyleRules = StyleUtils.ParaStyleTextProps(ScrStyleNames.NormalFootnoteParagraph);
			string footnoteText = "C\u00f2\u00f3\u013a footnot\u0113";
			footnotePara.Contents.UnderlyingTsString = stringFactory.MakeString(footnoteText, Cache.DefaultVernWs);

			m_exporter = new DummyExportRtf(m_fileName, Cache, m_styleSheet);
			m_exporter.CallExportFootnote(new ScrFootnote(Cache, footnote.Hvo));

			// Verify the contents of the temp file
			m_exporter.CloseOutputFile();
			using (StreamReader file = new StreamReader(m_fileName, Encoding.ASCII))
			{
				string line1 = file.ReadLine();
				string line2 = file.ReadLine();

				// the first line is the marker emitted into the text stream.
				// Footnote markers now have the footnote marker style applied
				Assert.AreEqual(@"\*\cs" + markerStyleNumber + @" \uc0\u182 }", line1);
				Assert.AreEqual(@"{\footnote \pard\plain \s" + footnoteStyleNumber +
					@"\f2\fs20{" + @"\*\cs" + markerStyleNumber + @" \uc0\u182 " +
					@"}{ }{C\uc0\u242 \uc0\u243 \uc0\u314  footnot\uc0\u275 }",
					line2);
			}
		}
示例#10
0
		public override void Exit()
		{
			CheckDisposed();

			m_styleSheet = null;
			m_exporter = null;

			m_book = null;
			m_section = null;
			m_para = null;

			base.Exit();
		}