public void ExportFootnote_Missing() { 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! AddRunToMockedPara(m_para, "My text for footnotes", string.Empty); IStFootnote testFootnote = AddFootnote(m_book, m_para, m_para.Contents.Length, string.Empty); 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 (TextReader file = FileUtils.OpenFileForRead(m_fileName, Encoding.ASCII)) { string line = file.ReadLine(); // the line is the paragraph without the footnote marker. Assert.AreEqual(@"\pard\plain\s2\f1\fs20{My text for footnotes}", line); } }
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 (TextReader file = FileUtils.OpenFileForRead(m_fileName, Encoding.ASCII)) { string line = file.ReadLine(); Assert.AreEqual(@"This \{is\} a (test\}.", line); } }
public void ExportRtfBtFootnotes() { // Set up the vernacular text. AddTitleToMockedBook(m_book, "Genesis"); AddRunToMockedPara(m_para, "1", ScrStyleNames.ChapterNumber); AddRunToMockedPara(m_para, "1", ScrStyleNames.VerseNumber); AddRunToMockedPara(m_para, "yi kuch batchit he.", null); IScrFootnote footnote1 = AddFootnote( m_book, m_para, 2, "pehla pao wala note"); // Set up back translation. int wsBt = Cache.DefaultAnalWs; ICmTranslation transPara1 = AddBtToMockedParagraph(m_para, wsBt); AddRunToMockedTrans(transPara1, wsBt, "1", ScrStyleNames.ChapterNumber); AddRunToMockedTrans(transPara1, wsBt, "1", ScrStyleNames.VerseNumber); AddRunToMockedTrans(transPara1, wsBt, "This is some text.", null); AddBtFootnote(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(footnote1, wsBt); m_exporter.CloseOutputFile(); int markerStyleNumber = m_styleSheet.FindStyle(ScrStyleNames.FootnoteMarker).IndexInOwner + 1; int footnoteStyleNumber = m_styleSheet.FindStyle(ScrStyleNames.NormalFootnoteParagraph).IndexInOwner + 1; using (TextReader file = FileUtils.OpenFileForRead(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 + @"\f1\fs20{" + @"\*\cs" + markerStyleNumber + @" a" + @"}{ }{First footnote}", line2); } }
public void ExportFootnote_Unicode() { 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! AddRunToMockedPara(m_para, "My text for footnotes", string.Empty); IScrFootnote footnote = AddFootnote(m_book, m_para, 2); m_scr.FootnoteMarkerType = FootnoteMarkerTypes.SymbolicFootnoteMarker; m_scr.FootnoteMarkerSymbol = "¶"; m_scr.DisplaySymbolInFootnote = true; footnote.FootnoteMarker = stringFactory.MakeString(null, Cache.DefaultVernWs); IScrTxtPara footnotePara = Cache.ServiceLocator.GetInstance <IScrTxtParaFactory>().CreateWithStyle( footnote, ScrStyleNames.NormalFootnoteParagraph); string footnoteText = "C\u00f2\u00f3\u013a footnot\u0113"; footnotePara.Contents = stringFactory.MakeString(footnoteText, Cache.DefaultVernWs); m_exporter = new DummyExportRtf(m_fileName, Cache, m_styleSheet); m_exporter.CallExportFootnote(footnote); // Verify the contents of the temp file m_exporter.CloseOutputFile(); using (TextReader file = FileUtils.OpenFileForRead(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 + @"\f1\fs20{" + @"\*\cs" + markerStyleNumber + @" \uc0\u182 " + @"}{ }{Co\uc0\u768 o\uc0\u769 l\uc0\u769 footnote\uc0\u772 }", line2); } }
public void ExportFootnote_Unicode() { 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! AddRunToMockedPara(m_para, "My text for footnotes", string.Empty); IScrFootnote footnote = AddFootnote(m_book, m_para, 2); m_scr.FootnoteMarkerType = FootnoteMarkerTypes.SymbolicFootnoteMarker; m_scr.FootnoteMarkerSymbol = "\u00B6"; // U+00B6 PILCROW SIGN (¶) m_scr.DisplaySymbolInFootnote = true; footnote.FootnoteMarker = stringFactory.MakeString(null, Cache.DefaultVernWs); IScrTxtPara footnotePara = Cache.ServiceLocator.GetInstance<IScrTxtParaFactory>().CreateWithStyle( footnote, ScrStyleNames.NormalFootnoteParagraph); string footnoteText = "C\u00f2\u00f3\u013a footnot\u0113"; footnotePara.Contents = stringFactory.MakeString(footnoteText, Cache.DefaultVernWs); m_exporter = new DummyExportRtf(m_fileName, Cache, m_styleSheet); m_exporter.CallExportFootnote(footnote); // Verify the contents of the temp file m_exporter.CloseOutputFile(); using (TextReader file = FileUtils.OpenFileForRead(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 + @"\f1\fs20{" + @"\*\cs" + markerStyleNumber + @" \uc0\u182 " + @"}{ }{Co\uc0\u768 o\uc0\u769 l\uc0\u769 footnote\uc0\u772 }", line2); } }