/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { m_stylesheet = new FwStyleSheet(); m_stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles); m_exodus = AddBookToMockedScripture(2, "Exodus"); AddTitleToMockedBook(m_exodus, "Exodus"); IScrSection section = AddSectionToMockedBook(m_exodus); AddSectionHeadParaToSection(section, "Section Heading", ScrStyleNames.SectionHead); IScrTxtPara para = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph); AddRunToMockedPara(para, "1", ScrStyleNames.ChapterNumber); AddRunToMockedPara(para, "1", ScrStyleNames.VerseNumber); AddRunToMockedPara(para, "Verse one. ", null); AddRunToMockedPara(para, "2", ScrStyleNames.VerseNumber); AddRunToMockedPara(para, "Verse two.", null); AddRunToMockedPara(para, "3", ScrStyleNames.VerseNumber); AddRunToMockedPara(para, "Verse three.", null); AddRunToMockedPara(para, "4", ScrStyleNames.VerseNumber); AddRunToMockedPara(para, "Verse four. ", null); AddRunToMockedPara(para, "5", ScrStyleNames.VerseNumber); AddRunToMockedPara(para, "Verse five.", null); AddRunToMockedPara(para, "6", ScrStyleNames.VerseNumber); AddRunToMockedPara(para, "Verse six. ", null); AddRunToMockedPara(para, "7", ScrStyleNames.VerseNumber); AddRunToMockedPara(para, "Verse seven.", null); AddRunToMockedPara(para, "8", ScrStyleNames.VerseNumber); AddRunToMockedPara(para, "Verse seven.", null); AddRunToMockedPara(para, "9", ScrStyleNames.VerseNumber); AddRunToMockedPara(para, "Verse seven.", null); AddRunToMockedPara(para, "10", ScrStyleNames.VerseNumber); AddRunToMockedPara(para, "Verse seven.", null); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="T:DiffViewProxy"/> class. /// </summary> /// <param name="dlg">The instance of the DiffDialog displaying this view.</param> /// <param name="name">The (internal) name of the view.</param> /// <param name="book">The book to display.</param> /// <param name="fRev"><c>true</c> if this proxy is for the side representing the saved /// or imported version</param> /// ------------------------------------------------------------------------------------ internal DiffViewProxy(DiffDialog dlg, string name, IScrBook book, bool fRev) : base(name, false) { m_dlg = dlg; m_book = book; m_fIsRevision = fRev; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Insert a book /// </summary> /// <returns>The new book</returns> /// ------------------------------------------------------------------------------------ public IScrBook Do() { IScripture scr = m_cache.LangProject.TranslatedScriptureOA; int hvoTitle; IScrBook newBook = ScrBook.CreateNewScrBook(m_bookID, scr, out hvoTitle); m_bookHvo = newBook.Hvo; // Insert the new book title and set the book names newBook.InitTitlePara(); newBook.Name.CopyAlternatives(newBook.BookIdRA.BookName); newBook.Abbrev.CopyAlternatives(newBook.BookIdRA.BookAbbrev); // Now insert the first section for the new book. ITsTextProps textProps = StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber, m_cache.DefaultVernWs); ScrSection.CreateScrSection(newBook, 0, scr.ConvertToString(1), textProps, false); // Do synchronize stuff if (FwApp.App != null) { FwApp.App.Synchronize(new SyncInfo(SyncMsg.ksyncReloadScriptureControl, 0, 0), m_cache); } // Use Redo for rest of sync'ing and updating book filter Redo(false); return(newBook); }
public override void TestSetup() { base.TestSetup(); m_vc = new StVc(); m_vc.Cache = Cache; m_pattern = VwPatternClass.Create(); m_pattern.Pattern = TsStringUtils.MakeString("a", Cache.DefaultVernWs); m_pattern.MatchOldWritingSystem = false; m_pattern.MatchDiacritics = false; m_pattern.MatchWholeWord = false; m_pattern.MatchCase = false; m_pattern.UseRegularExpressions = false; IScrBook genesis = AddBookWithTwoSections(1, "Genesis"); m_section = genesis.SectionsOS[0]; // Add paragraphs (because we use an StVc in the test we add them all to the same section) m_para1 = AddParaToMockedSectionContent(m_section, ScrStyleNames.NormalParagraph); AddRunToMockedPara(m_para1, "This is some text so that we can test the find functionality.", null); m_para2 = AddParaToMockedSectionContent(m_section, ScrStyleNames.NormalParagraph); AddRunToMockedPara(m_para2, "Some more text so that we can test the find and replace functionality.", null); m_para3 = AddParaToMockedSectionContent( m_section, ScrStyleNames.NormalParagraph); AddRunToMockedPara(m_para3, "This purugruph doesn't contuin the first letter of the ulphubet.", null); }
public void PageElementsDontOverlap_TwoFootnotes() { IScripture scr = Cache.LangProject.TranslatedScriptureOA; IScrBook genesis = scr.ScriptureBooksOS[0]; // Add a footnote in the first book, first section, first paragraph IScrSection section = genesis.SectionsOS[0]; IStFootnote footnote = AddFootnote(genesis, (IStTxtPara)section.ContentOA.ParagraphsOS[0], 2); IStTxtPara para = AddParaToMockedText(footnote, ScrStyleNames.NormalFootnoteParagraph); AddRunToMockedPara(para, "Another footnote", para.Cache.DefaultVernWs); // Add a footnote in the first book, last section, 6th paragraph section = (IScrSection)genesis.SectionsOS[genesis.SectionsOS.Count - 1]; footnote = AddFootnote(genesis, (IStTxtPara)section.ContentOA.ParagraphsOS[5], 10); para = AddParaToMockedText(footnote, ScrStyleNames.NormalFootnoteParagraph); AddRunToMockedPara(para, "This is the footnote", para.Cache.DefaultVernWs); m_pub.CreatePages(); m_pub.PrepareToDrawPages(0, m_pub.AutoScrollMinSize.Height * 2); Page firstPage = m_pub.Pages[0]; int cFoonotesOnThisPage = (int)m_division.m_testPageFootnoteInfo[firstPage.Handle]; Assert.AreEqual(2, cFoonotesOnThisPage, "Should display two footnotes on first page"); // None of the page elements on the first page should intersect CheckThatPageElementsDontOverlap(firstPage); }
public void GoToNextSection() { FdoOwningSequence <IScrBook> books = m_scr.ScriptureBooksOS; // Start in the title of the second book. m_draftView.TeEditingHelper.SetInsertionPoint((int)ScrBook.ScrBookTags.kflidTitle, 1, 0); m_draftView.TeEditingHelper.GoToNextSection(); VerifySelection(4, 1, 0, (int)ScrSection.ScrSectionTags.kflidHeading, 0, 0); // Start in the last section of the first book. IScrBook book = books[0]; m_draftView.TeEditingHelper.SetInsertionPoint((int)ScrSection.ScrSectionTags.kflidContent, 0, book.SectionsOS.Count - 1); m_draftView.TeEditingHelper.GoToNextSection(); VerifySelection(4, 1, 0, (int)ScrSection.ScrSectionTags.kflidHeading, 0, 0); // Start in the last para of the contents of the last section of the last book. int iBook = books.Count - 1; book = books[iBook]; int iSection = book.SectionsOS.Count - 1; IScrSection lastSection = book.SectionsOS[iSection]; int iPara = lastSection.ContentOA.ParagraphsOS.Count - 1; m_draftView.TeEditingHelper.SetInsertionPoint(iBook, iSection, iPara, 2, true); // Nothing should move m_draftView.TeEditingHelper.GoToNextSection(); VerifySelection(4, iBook, iSection, (int)ScrSection.ScrSectionTags.kflidContent, 2, 2); // Check the para SelectionHelper selHelper = SelectionHelper.Create(m_draftView); Assert.AreEqual(iPara, selHelper.LevelInfo[0].ihvo); // Start with a multi-text range selection IScrBook startBook = books[0]; m_draftView.TeEditingHelper.SetInsertionPoint((int)ScrSection.ScrSectionTags.kflidHeading, 0, startBook.SectionsOS.Count - 2); IVwSelection vwsel1 = m_draftView.RootBox.Selection; m_draftView.TeEditingHelper.SetInsertionPoint((int)ScrSection.ScrSectionTags.kflidContent, 0, startBook.SectionsOS.Count - 3); IVwSelection vwsel2 = m_draftView.RootBox.Selection; m_draftView.RootBox.MakeRangeSelection(vwsel1, vwsel2, true); m_draftView.TeEditingHelper.GoToNextSection(); VerifySelection(4, 0, startBook.SectionsOS.Count - 1, (int)ScrSection.ScrSectionTags.kflidHeading, 0, 0); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the Scripture reference of the specified annotation as string. /// </summary> /// <param name="ann">The specified annotation.</param> /// ------------------------------------------------------------------------------------ private string GetRefAsString(IScrScriptureNote ann) { BCVRef startRef = new BCVRef(ann.BeginRef); IScrBook book = m_scr.FindBook(startRef.Book); string bookName; // Book for note may not be in the project. if (book != null) { bookName = book.BestUIName; } else { IScrBookRef bookRef = Cache.ServiceLocator.GetInstance <IScrRefSystemRepository>().Singleton.BooksOS[startRef.Book - 1]; ITsString tsName = bookRef.BookName.get_String(Cache.DefaultUserWs); if (tsName.Length == 0) { tsName = bookRef.BookName.BestAnalysisAlternative; } bookName = tsName.Text; } string titleText = ResourceHelper.GetResourceString("kstidScriptureTitle"); string introText = ResourceHelper.GetResourceString("kstidScriptureIntro"); return(BCVRef.MakeReferenceString(bookName, startRef, new BCVRef(ann.EndRef), m_scr.ChapterVerseSepr, m_scr.Bridge, titleText, introText)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Attaches the annotated objects to the specifed annotation. /// </summary> /// ------------------------------------------------------------------------------------ private static void AttachAnnotatedObjects(IScripture scr, int bookNum, IScrScriptureNote scrNote) { int iSection, iPara, ichStart, ichEnd; ScrReference scrRef = new ScrReference(scrNote.BeginRef, scr.Versification); if (TeEditingHelper.FindTextInVerse(scr, scrNote.CitedTextTss, scrRef, true, out iSection, out iPara, out ichStart, out ichEnd)) { IScrBook book = scr.FindBook(bookNum); Debug.Assert(book != null); scrNote.BeginOffset = ichStart; scrNote.EndOffset = ichEnd; if (iSection == -1) { scrNote.BeginObjectRA = scrNote.EndObjectRA = book.TitleOA.ParagraphsOS[iPara]; } else { scrNote.BeginObjectRA = scrNote.EndObjectRA = book.SectionsOS[iSection].ContentOA.ParagraphsOS[iPara]; } } }
public override void TestTearDown() { m_genesis = null; m_genesisRevision = null; base.TestTearDown(); }
private ITsString m_tssVerse; // text to include in a verse #region Setup /// ------------------------------------------------------------------------------------ /// <summary> /// Overridden to only create a book with no content, heading, title, etc. /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { m_genesis = AddBookToMockedScripture(1, "Genesis"); m_genesisRevision = AddArchiveBookToMockedScripture(1, "Genesis"); m_tssVerse = TsStringUtils.MakeTss("verse text", Cache.DefaultVernWs); }
public void InsertVerseNumber_Verse2NoVerse1() { // Remove the formatting on the verse number so it doesn't interfere with the test. m_draftView.SelectRangeOfChars(1, 11, 0, 1, 2); m_draftView.EditingHelper.RemoveCharFormatting(); // Set the IP in the middle of verse James 4:1 when there is no verse number 1 m_draftView.SetInsertionPoint(1, 11, 0, 8, true); // insert verse num 2 at the IP m_draftView.InsertVerseNumber(); IScrBook book = Cache.LangProject.TranslatedScriptureOA.ScriptureBooksOS[1]; IStTxtPara para = (IStTxtPara)book.SectionsOS[11].ContentOA.ParagraphsOS[0]; ITsString tss = para.Contents; AssertEx.RunIsCorrect(tss, 0, "4", "Chapter Number", Cache.DefaultVernWs); Assert.AreEqual("1Where ", para.Contents.get_RunText(1).Substring(0, 7)); Assert.AreEqual(StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs), para.Contents.get_Properties(1)); AssertEx.RunIsCorrect(tss, 2, "2", "Verse Number", Cache.DefaultVernWs); Assert.AreEqual("do all the fights", para.Contents.get_RunText(3).Substring(0, 17)); Assert.AreEqual(StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs), para.Contents.get_Properties(3)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { ITsStrFactory strfact = TsStrFactoryClass.Create(); //Jude IScrBook jude = AddBookToMockedScripture(65, "Jude"); AddTitleToMockedBook(jude, "Jude"); // Jude Scripture section IScrSection section = AddSectionToMockedBook(jude); AddSectionHeadParaToSection(section, "First section", "Section Head"); IStTxtPara judePara = AddParaToMockedSectionContent(section, "Paragraph"); AddRunToMockedPara(judePara, "1", ScrStyleNames.ChapterNumber); AddRunToMockedPara(judePara, "1", ScrStyleNames.VerseNumber); AddRunToMockedPara(judePara, "This is the first verse", null); // Insert footnote into para 1 of Jude ITsStrBldr bldr = judePara.Contents.GetBldr(); IScrFootnote foot = jude.InsertFootnoteAt(0, bldr, 10); IScrTxtPara footPara = Cache.ServiceLocator.GetInstance <IScrTxtParaFactory>().CreateWithStyle( foot, ScrStyleNames.NormalFootnoteParagraph); footPara.Contents = strfact.MakeString("This is text for the footnote.", Cache.DefaultVernWs); judePara.Contents = bldr.GetString(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="BookPropertiesDialog"/> class. /// </summary> /// <param name="book">the current book</param> /// <param name="stylesheet">The stylesheet.</param> /// <param name="helpTopicProvider">The help topic provider.</param> /// ------------------------------------------------------------------------------------ public BookPropertiesDialog(IScrBook book, IVwStylesheet stylesheet, IHelpTopicProvider helpTopicProvider) { m_currentBook = book; m_helpTopicProvider = helpTopicProvider; // TE-5663: make sure the book's name and abbreviation are updated if some were added IScrRefSystem scrRefSystem = book.Cache.ServiceLocator.GetInstance<IScrRefSystemRepository>().AllInstances().FirstOrDefault(); book.Name.MergeAlternatives(scrRefSystem.BooksOS[book.CanonicalNum - 1].BookName); book.Abbrev.MergeAlternatives(scrRefSystem.BooksOS[book.CanonicalNum - 1].BookAbbrev); // // Required for Windows Form Designer support // InitializeComponent(); // Put the book name in the dialog caption Text = string.Format(Text, book.Name.UserDefaultWritingSystem.Text); m_listBookInfo.Cache = book.Cache; m_listBookInfo.FieldsToDisplay.Add(new FwMultilingualPropView.ColumnInfo( ScrBookTags.kflidName, TeResourceHelper.GetResourceString("kstidBookNameColHeader"), 60)); m_listBookInfo.FieldsToDisplay.Add(new FwMultilingualPropView.ColumnInfo( ScrBookTags.kflidAbbrev, TeResourceHelper.GetResourceString("kstidBookAbbrevColHeader"), 40)); m_listBookInfo.RootObject = book.Hvo; foreach (IWritingSystem ws in book.Cache.ServiceLocator.WritingSystems.AllWritingSystems) m_listBookInfo.WritingSystemsToDisplay.Add(ws.Handle); // Initialize the ID textbox. m_txtScrBookIdText.Text = m_currentBook.IdText; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="BookPropertiesDialog"/> class. /// </summary> /// <param name="book">the current book</param> /// <param name="stylesheet">The stylesheet.</param> /// ------------------------------------------------------------------------------------ public BookPropertiesDialog(IScrBook book, IVwStylesheet stylesheet) { m_currentBook = book; // TE-5663: make sure the book's name and abbreviation are updated if some were added book.Name.CopyAlternatives( ((ScrBookRef)book.Cache.ScriptureReferenceSystem.BooksOS[book.CanonicalNum - 1]).BookName, true); book.Abbrev.CopyAlternatives( ((ScrBookRef)book.Cache.ScriptureReferenceSystem.BooksOS[book.CanonicalNum - 1]).BookAbbrev, true); // // Required for Windows Form Designer support // InitializeComponent(); // Put the book name in the dialog caption Text = string.Format(Text, book.Name.UserDefaultWritingSystem); m_listBookInfo.Cache = book.Cache; m_listBookInfo.FieldsToDisplay.Add(new FwMultilingualPropView.ColumnInfo( (int)ScrBook.ScrBookTags.kflidName, TeResourceHelper.GetResourceString("kstidBookNameColHeader"), 60)); m_listBookInfo.FieldsToDisplay.Add(new FwMultilingualPropView.ColumnInfo( (int)ScrBook.ScrBookTags.kflidAbbrev, TeResourceHelper.GetResourceString("kstidBookAbbrevColHeader"), 40)); m_listBookInfo.RootObject = book.Hvo; foreach (int ws in book.Cache.LangProject.CurrentAnalysisAndVernWss) m_listBookInfo.WritingSystemsToDisplay.Add(ws); // Initialize the ID textbox. m_txtScrBookIdText.Text = m_currentBook.IdText; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="BookPropertiesDialog"/> class. /// </summary> /// <param name="book">the current book</param> /// <param name="stylesheet">The stylesheet.</param> /// ------------------------------------------------------------------------------------ public BookPropertiesDialog(IScrBook book, IVwStylesheet stylesheet) { m_currentBook = book; // TE-5663: make sure the book's name and abbreviation are updated if some were added book.Name.CopyAlternatives( ((ScrBookRef)book.Cache.ScriptureReferenceSystem.BooksOS[book.CanonicalNum - 1]).BookName, true); book.Abbrev.CopyAlternatives( ((ScrBookRef)book.Cache.ScriptureReferenceSystem.BooksOS[book.CanonicalNum - 1]).BookAbbrev, true); // // Required for Windows Form Designer support // InitializeComponent(); // Put the book name in the dialog caption Text = string.Format(Text, book.Name.UserDefaultWritingSystem); m_listBookInfo.Cache = book.Cache; m_listBookInfo.FieldsToDisplay.Add(new FwMultilingualPropView.ColumnInfo( (int)ScrBook.ScrBookTags.kflidName, TeResourceHelper.GetResourceString("kstidBookNameColHeader"), 60)); m_listBookInfo.FieldsToDisplay.Add(new FwMultilingualPropView.ColumnInfo( (int)ScrBook.ScrBookTags.kflidAbbrev, TeResourceHelper.GetResourceString("kstidBookAbbrevColHeader"), 40)); m_listBookInfo.RootObject = book.Hvo; foreach (int ws in book.Cache.LangProject.CurrentAnalysisAndVernWss) { m_listBookInfo.WritingSystemsToDisplay.Add(ws); } // Initialize the ID textbox. m_txtScrBookIdText.Text = m_currentBook.IdText; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Updates the book section group label. /// </summary> /// ------------------------------------------------------------------------------------ private void UpdateBookSectionGroupLabel() { IScrBook book = m_scr.FindBook(m_nBookForSections); m_grpSectionRange.Text = string.Format(m_sRangeBookFmt, book.Name.BestAnalysisVernacularAlternative.Text); }
public void InsertBookTest_BeforeEverything() { // Insert Exodus IScrBookRef bookRef = Cache.ServiceLocator.GetInstance <IScrRefSystemRepository>().AllInstances().First().BooksOS[1]; bookRef.BookName.SetVernacularDefaultWritingSystem("FunSquigles5"); bookRef.BookName.SetUserWritingSystem("Exodus"); bookRef.BookAbbrev.SetVernacularDefaultWritingSystem("STH"); bookRef.BookAbbrev.SetUserWritingSystem("Exo"); ((TestTeEditingHelper)m_mainWnd.ActiveEditingHelper).m_DeferSelectionUntilEndOfUOW = true; IScrBook exodus = m_mainWnd.ActiveEditingHelper.InsertBook(2); // Verify a bunch of stuff after inserting a book. TeEditingHelperTestsWithMockedFdoCache.VerifyInsertedBook(exodus, "EXO"); Assert.AreEqual(exodus, m_scr.ScriptureBooksOS[0]); VerifyInsertedBookInDraftView(((DummyDraftView)m_mainWnd.TheDraftView).RequestedSelectionAtEndOfUow); // Verify that there is a filter in place for exodus Assert.AreEqual(1, m_mainWnd.BookFilter.BookCount); Assert.AreEqual(exodus.Hvo, m_mainWnd.BookFilter.GetBook(0).Hvo); Assert.AreEqual("Exodus", exodus.Name.UserDefaultWritingSystem.Text); Assert.AreEqual("Exo", exodus.Abbrev.UserDefaultWritingSystem.Text); Assert.AreEqual("FunSquigles5", exodus.Name.VernacularDefaultWritingSystem.Text); Assert.AreEqual("STH", exodus.Abbrev.VernacularDefaultWritingSystem.Text); }
public void ReRunChecksWithNoBooks() { // We have to add a paragraph that is owned to add a valid annotation, so create // a book, section, paragraph. IScrBook book = AddBookToMockedScripture(1, "Genesis"); IScrSection section = AddSectionToMockedBook(book); IStTxtPara para = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph); AddRunToMockedPara(para, "some text for an annotation", ScrStyleNames.Normal); using (var renderingCtl = new EditorialChecksRenderingsControl(Cache, m_bookFilter, null, null)) { // Add a checking error annotation. AddAnnotation(para, 1001001, NoteType.CheckingError); // Now delete the book so that there are not any in the project. Cache.DomainDataByFlid.DeleteObj(book.Hvo); Assert.AreEqual(0, m_scr.ScriptureBooksOS.Count, "There should not be books for this test."); // Now attempt to load the checking error annotations. renderingCtl.LoadCheckingErrors(); var checkingErrors = ReflectionHelper.GetField(renderingCtl, "m_list") as List <ICheckGridRowObject>; // We expect that no annotations would be added to the EditorialRenderingsControl // and that we won't crash trying to load checking error annotations. Assert.AreEqual(0, checkingErrors.Count, "Since there are no books, the error annotation should not be added to the rendering control"); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates a book with 2 sections with the following layout: /// bookName /// Heading 1 /// (1)1Verse one. /// Heading 2 /// (2)1Verse one.2Verse two. /// (3)1Verse one. /// /// Numbers in () are chapter numbers. /// </summary> /// <returns>the book for testing</returns> /// ------------------------------------------------------------------------------------ protected IScrBook CreateBook(int nBookNumber, string bookName) { IScrBook book = AddBookToMockedScripture(nBookNumber, bookName); AddTitleToMockedBook(book, bookName); IScrSection section1 = AddSectionToMockedBook(book); AddSectionHeadParaToSection(section1, "Heading 1", ScrStyleNames.SectionHead); IStTxtPara para11 = AddParaToMockedSectionContent(section1, ScrStyleNames.NormalParagraph); AddRunToMockedPara(para11, "1", ScrStyleNames.ChapterNumber); AddRunToMockedPara(para11, "1", ScrStyleNames.VerseNumber); AddRunToMockedPara(para11, "Verse one.", null); IScrSection section2 = AddSectionToMockedBook(book); AddSectionHeadParaToSection(section2, "Heading 2", ScrStyleNames.SectionHead); IStTxtPara para21 = AddParaToMockedSectionContent(section2, ScrStyleNames.NormalParagraph); AddRunToMockedPara(para21, "2", ScrStyleNames.ChapterNumber); AddRunToMockedPara(para21, "1", ScrStyleNames.VerseNumber); AddRunToMockedPara(para21, "Verse one.", null); AddRunToMockedPara(para21, "2", ScrStyleNames.VerseNumber); AddRunToMockedPara(para21, "Verse two.", null); IStTxtPara para22 = AddParaToMockedSectionContent(section2, ScrStyleNames.NormalParagraph); AddRunToMockedPara(para22, "3", ScrStyleNames.ChapterNumber); AddRunToMockedPara(para22, "1", ScrStyleNames.VerseNumber); AddRunToMockedPara(para22, "Verse one.", null); return(book); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Get a string that describes the Scripture passage based on the selection. /// </summary> /// <param name="tag">The flid of the selected element</param> /// <param name="hvoSel">The hvo of the selected element, either a ScrSection (usually) /// or ScrBook (if in a title)</param> /// <param name="fSimpleFormat">Gets a simple, standardized reference (uses SIL 3-letter /// codes and no verse bridges)</param> /// <returns> /// String that describes the Scripture passage or null if the selection /// can't be interpreted as a book and/or section reference. /// </returns> /// ------------------------------------------------------------------------------------ public override string GetPassageAsString(int tag, int hvoSel, bool fSimpleFormat) { CheckDisposed(); if (m_cache == null) { return(null); } string sEditRef = null; // Title/reference/etc of text being edited in the draft pane switch (tag) { case ScrBookTags.kflidFootnotes: IScrBook book = m_cache.ServiceLocator.GetInstance <IScrBookRepository>().GetObject(hvoSel); sEditRef = (fSimpleFormat ? (book.BookId + " 0:0") : book.BestUIName); break; default: return(base.GetPassageAsString(tag, hvoSel, fSimpleFormat)); } // Add the back translation writing system info to the output string, if needed if (IsBackTranslation) { IWritingSystem ws = m_cache.ServiceLocator.WritingSystemManager.Get(ViewConstructorWS); sEditRef = string.Format( TeResourceHelper.GetResourceString("kstidCaptionInBackTrans"), sEditRef, ws.DisplayLabel); } return(string.IsNullOrEmpty(sEditRef) ? null : sEditRef); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Set up the dummy exporter for data in the given book. /// </summary> /// ------------------------------------------------------------------------------------ public void SetContext(IScrBook book) { CheckDisposed(); m_currentBookCode = book.BookId; m_currentBookOrd = book.CanonicalNum; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the new book (to the saved version...create it if need be) for which the /// vernacular is about to be imported. /// </summary> /// <param name="nCanonicalBookNumber">The canonical book number.</param> /// <param name="description">Description to use for the newly created imported version /// if necessary.</param> /// <param name="title">The title of the newly created book.</param> /// <returns>The newly created book (which has been added to the imported version)</returns> /// ------------------------------------------------------------------------------------ public IScrBook AddNewBook(int nCanonicalBookNumber, string description, out IStText title) { if (m_importedVersion == null) { m_importedVersion = GetOrCreateVersion(description); } IScrBook existingBook = SetCurrentBook(nCanonicalBookNumber, true); if (existingBook != null) { if (m_lastBookAddedToImportedBooks == 0) { // We've been asked to create a book we have already imported (typically // reading multiple independent SF files). title = existingBook.TitleOA; return(existingBook); } // Replace any previous book with the one we're about to import. m_importedVersion.BooksOS.Remove(existingBook); } IScrBook newScrBook = m_cache.ServiceLocator.GetInstance <IScrBookFactory>().Create(m_importedVersion.BooksOS, nCanonicalBookNumber, out title); return(newScrBook); }
public void SectionHeadTypeMismatch() { // Set up the vernacular to match the BT we will import. IScrBook book = AddBookToMockedScripture(2, "Exodo"); IScrSection sectionMajor = AddSectionToMockedBook(book); AddParaToMockedText(sectionMajor.HeadingOA, "Section Head Major"); IStTxtPara paraCMajor1 = AddParaToMockedSectionContent(sectionMajor, ScrStyleNames.NormalParagraph); AddRunToMockedPara(paraCMajor1, "1", ScrStyleNames.ChapterNumber); m_importer.Settings.ImportBackTranslation = true; m_importer.CurrentImportDomain = ImportDomain.BackTrans; // ************** process a \id segment, test MakeBook() method ********************* m_importer.TextSegment.FirstReference = new BCVRef(2, 0, 0); m_importer.TextSegment.LastReference = new BCVRef(2, 0, 0); m_importer.ProcessSegment("", @"\id"); // no text provided in segment, just the refs Assert.AreEqual(2, m_importer.BookNumber); // verify that we didn't create a different book Assert.AreEqual(book.Hvo, m_importer.ScrBook.Hvo); // begin section (Scripture text) // ************** process a chapter ********************* m_importer.TextSegment.FirstReference = new BCVRef(2, 1, 0); m_importer.TextSegment.LastReference = new BCVRef(2, 1, 0); m_importer.ProcessSegment("", @"\c"); // ************** process a section head (for 1:1) ********************* m_importer.ProcessSegment("First Scripture Section", @"\bts"); // ************** finalize ************** m_importer.FinalizeImport(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="T:UndoImportOverriddenBookAction"/> /// class. /// </summary> /// <param name="manager">A class that manages undoable aspects of importing and holds /// the state info needed for importing and later undoing the import.</param> /// <param name="existingBook">The existing book.</param> /// <remarks>This is internal because we only want UndoImportManager to create these /// </remarks> /// ------------------------------------------------------------------------------------ internal UndoImportModifiedBookAction(UndoImportManager manager, IScrBook existingBook) : base() { m_manager = manager; m_canonicalBookNum = existingBook.CanonicalNum; m_manager.ScriptureObj.AddBookToSavedVersion(manager.BackupVersion, existingBook); }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) { return; } if (disposing) { // Dispose managed resources here. if (m_draftForm != null) { m_draftForm.Dispose(); } } // Dispose unmanaged resources here, whether disposing is true or false. m_draftForm = null; m_btDraftView = null; m_book = null; base.Dispose(disposing); }
public void GetUnfilteredIndexTest() { IScrBook book = m_scr.ScriptureBooksOS[1]; m_filter.FilteredBooks = new IScrBook[] { book }; Assert.AreEqual(1, m_filter.GetUnfilteredIndex(0)); }
/// <summary> /// /// </summary> public override void TestSetup() { base.TestSetup(); m_vc = new DummyTeNotesVc(Cache); m_gen = AddBookWithTwoSections(1, "Genesis"); }
/// ------------------------------------------------------------------------------------- /// <summary> /// For any footnote in the specified book whose first paragraph has a run marked with /// the Note Target Reference style, remove that run and set the property on the footnote /// to display the target reference in the footnote view. /// </summary> /// <param name="book">The ScrBook whose footnotes are to be searched</param> /// ------------------------------------------------------------------------------------- private void RemoveDirectUsesOfFootnoteTargetRef(IScrBook book) { foreach (IStFootnote footnote in book.FootnotesOS) { // Probably only need to worry about first para if (footnote.ParagraphsOS.Count == 0) { continue; } IStTxtPara para = (IStTxtPara)footnote.ParagraphsOS[0]; ITsString tss = para.Contents; ITsStrBldr bldr = null; for (int iRun = 0; iRun < tss.RunCount; iRun++) { ITsTextProps props = tss.get_Properties(iRun); string style = props.GetStrPropValue( (int)FwTextPropType.ktptNamedStyle); if (style == ScrStyleNames.FootnoteTargetRef) { if (bldr == null) { bldr = tss.GetBldr(); } bldr.Replace(tss.get_MinOfRun(iRun), tss.get_LimOfRun(iRun), string.Empty, null); } } if (bldr != null) { para.Contents = bldr.GetString(); } } }
public void GetBookHvoWithFootnotes() { IScripture scr = Cache.LangProject.TranslatedScriptureOA; IScrBook genesis = scr.ScriptureBooksOS[0]; // Add a footnote in the first book, first section, first paragraph IScrSection section = genesis.SectionsOS[0]; IStFootnote footnote = AddFootnote(genesis, (IStTxtPara)section.ContentOA.ParagraphsOS[0], 2, "A footnote"); m_ScrPubCtrl.CallRefreshDisplay(); m_ScrPubCtrl.CreatePages(); m_ScrPubCtrl.PrepareToDrawPages(0, m_ScrPubCtrl.AutoScrollMinSize.Height * 2); // Simulate setting the IP at the beginning of the footnote bool fFoundPageWithFootnotes = false; foreach (DummyPage page in m_ScrPubCtrl.Pages) { if (page.DependentObjectsRootStream != null) { fFoundPageWithFootnotes = true; ((IVwRootBox)page.DependentObjectsRootStream).MakeSimpleSel(true, true, false, true); m_ScrPubCtrl.FocusedStream = page.DependentObjectsRootStream; break; } } Assert.IsTrue(fFoundPageWithFootnotes, "Can't run this test without finding any footnotes"); SelectionHelper selHelper = SelectionHelper.Create(m_ScrPubCtrl); IScrBook book = m_ScrPubCtrl.GetBook(selHelper, SelectionHelper.SelLimitType.Anchor); Assert.AreEqual(genesis, book); }
/// <summary> /// /// </summary> public override void TestTearDown() { Options.ShowEmptyParagraphPromptsSetting = m_oldPromptSetting; m_book = null; m_vwenvMock = null; base.TestTearDown(); }
public void DeleteFootnoteWithoutORC() { IScrBook book = (IScrBook)m_scr.ScriptureBooksOS[0]; int originalFootnoteCount = book.FootnotesOS.Count; // Insert a new footnote into the collection and view IScrFootnote footnote = Cache.ServiceLocator.GetInstance <IScrFootnoteFactory>().Create(); book.FootnotesOS.Insert(0, footnote); IScrTxtPara para = Cache.ServiceLocator.GetInstance <IScrTxtParaFactory>().CreateWithStyle( footnote, ScrStyleNames.CrossRefFootnoteParagraph); para.Contents = TsStringHelper.MakeTSS("My footnote", Cache.DefaultVernWs); m_footnoteView.RefreshDisplay(); MakeFootnoteSelection(0, 0, 0); // verify that a footnote was added to the collection Assert.AreEqual(originalFootnoteCount + 1, book.FootnotesOS.Count); m_footnoteView.DeleteFootnote(); // verify that the footnote was deleted Assert.AreEqual(originalFootnoteCount, book.FootnotesOS.Count); Assert.IsFalse(footnote.IsValidObject); }
public void BeginAndEndUndoTask() { ShowForm(); // we need a selection m_basicView.RootBox.MakeSimpleSel(true, true, false, true); // this should begin an outer undo task, so we will have only one undoable task! using (UndoTaskHelper helper = new UndoTaskHelper(m_actionHandler, m_basicView, "kstidUndoStyleChanges")) { IScrBook book = Cache.ServiceLocator.GetInstance <IScrBookFactory>().Create(6); Cache.LanguageProject.TranslatedScriptureOA.ScriptureBooksOS.Add(book); book = Cache.ServiceLocator.GetInstance <IScrBookFactory>().Create(7); Cache.LanguageProject.TranslatedScriptureOA.ScriptureBooksOS.Add(book); helper.RollBack = false; } int nUndoTasks = 0; while (m_actionHandler.CanUndo()) { Assert.AreEqual(UndoResult.kuresSuccess, m_actionHandler.Undo()); nUndoTasks++; } Assert.AreEqual(1, nUndoTasks); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { m_book = CreateExodusData(); // TODO (TimS): if we ever need tests to have more data write another method and // use the current method for the current tests. CreatePartialExodusBT(Cache.DefaultAnalWs); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="BookPropertiesDialog"/> class. /// </summary> /// <param name="book">the current book</param> /// <param name="stylesheet">The stylesheet.</param> /// <param name="helpTopicProvider">The help topic provider.</param> /// ------------------------------------------------------------------------------------ public BookPropertiesDialog(IScrBook book, IVwStylesheet stylesheet, IHelpTopicProvider helpTopicProvider) { m_currentBook = book; m_helpTopicProvider = helpTopicProvider; // TE-5663: make sure the book's name and abbreviation are updated if some were added IScrRefSystem scrRefSystem = book.Cache.ServiceLocator.GetInstance <IScrRefSystemRepository>().AllInstances().FirstOrDefault(); book.Name.MergeAlternatives(scrRefSystem.BooksOS[book.CanonicalNum - 1].BookName); book.Abbrev.MergeAlternatives(scrRefSystem.BooksOS[book.CanonicalNum - 1].BookAbbrev); // // Required for Windows Form Designer support // InitializeComponent(); // Put the book name in the dialog caption Text = string.Format(Text, book.Name.UserDefaultWritingSystem.Text); m_listBookInfo.Cache = book.Cache; m_listBookInfo.FieldsToDisplay.Add(new FwMultilingualPropView.ColumnInfo( ScrBookTags.kflidName, TeResourceHelper.GetResourceString("kstidBookNameColHeader"), 60)); m_listBookInfo.FieldsToDisplay.Add(new FwMultilingualPropView.ColumnInfo( ScrBookTags.kflidAbbrev, TeResourceHelper.GetResourceString("kstidBookAbbrevColHeader"), 40)); m_listBookInfo.RootObject = book.Hvo; foreach (IWritingSystem ws in book.Cache.ServiceLocator.WritingSystems.AllWritingSystems) { m_listBookInfo.WritingSystemsToDisplay.Add(ws.Handle); } // Initialize the ID textbox. m_txtScrBookIdText.Text = m_currentBook.IdText; }
public void FixOrcsWithoutProps_OrcForMissingObject() { IScrBook exodus = CreateExodusData(); IScrTxtPara para = AddParaToMockedSectionContent(exodus.SectionsOS[2], ScrStyleNames.NormalParagraph); AddVerse(para, 2, 3, "ORC is here, you see, my friend."); // Update the paragraph contents to include the picture ITsStrBldr tsStrBldr = para.Contents.GetBldr(); ITsStrFactory factory = TsStrFactoryClass.Create(); TsStringUtils.InsertOrcIntoPara(Guid.NewGuid(), FwObjDataTypes.kodtOwnNameGuidHot, tsStrBldr, 11, 11, Cache.DefaultVernWs); para.Contents = tsStrBldr.GetString(); TeScrInitializer scrInit = new TestTeScrInitializer(Cache); List <string> report = (List <string>)ReflectionHelper.GetResult(scrInit, "FixOrcsWithoutProps"); VerifyNoOrphanedFootnotes(); VerifyResourceForFixedOrphans(); Assert.AreEqual(1, report.Count); Assert.AreEqual("EXO 2:3 - Deleted corrupted footnote marker or picture anchor", report[0]); Assert.AreEqual(0, exodus.FootnotesOS.Count); }
public override void Exit() { CheckDisposed(); m_genesis = null; base.Exit(); }
public override void TestTearDown() { m_booksToMerge.Dispose(); m_booksToMerge = null; m_genesisRevision = null; base.TestTearDown(); }
public override void TestTearDown() { m_phm = null; m_phmBkRef = null; m_stylesheet = null; base.TestTearDown(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Override to end the undoable UOW, Undo everything, and 'commit', /// which will essentially clear out the Redo stack. /// </summary> /// ------------------------------------------------------------------------------------ public override void TestTearDown() { m_philemon = null; m_section = null; m_para = null; base.TestTearDown(); }
/// <summary> /// Do the actual swap. Also issues a ksyncReloadScriptureControl, which seems to be /// needed any time we change the list of active books. /// </summary> /// <param name="bookOld"></param> /// <param name="bookNew"></param> private void Swap(IScrBook bookOld, IScrBook bookNew) { if (m_app != null) // app may be null in tests { foreach (FwMainWnd wnd in m_app.MainWindows) Swap(bookOld, bookNew, wnd); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Append a new section to the given book, having the specified text as the section /// head. The general section head paragraph style is used. /// </summary> /// <param name="testBase">in-memory test base class</param> /// <param name="book">The book to which the section is to be appended</param> /// <param name="sSectionHead">The text of the new section head</param> /// <returns>The newly created section</returns> /// ------------------------------------------------------------------------------------ internal static IScrSection CreateSection(ScrInMemoryFdoTestBase testBase, IScrBook book, string sSectionHead) { IScrSection section = CreateSection(testBase, book, sSectionHead, ScrStyleNames.SectionHead); // this should be a scripture section and not an intro section bool isIntro = false; section.VerseRefEnd = book.CanonicalNum * 1000000 + 1000 + ((isIntro) ? 0 : 1); return section; }
/// ----------------------------------------------------------------------------------- /// <summary> /// Close the footnote view /// </summary> /// ----------------------------------------------------------------------------------- public override void TestTearDown() { m_footnoteView = null; // m_footnoteForm made it, and disposes it. m_footnoteForm.Close(); // This should also dispose it. m_footnoteForm = null; m_Jude = null; base.TestTearDown(); // If it isn't last, we get some C++ error }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create an empty book of Genesis. This is done to get it into the right order /// in the cache. /// </summary> /// ------------------------------------------------------------------------------------ private void CreateEmptyGenesis() { m_genesis = AddBookToMockedScripture(1, "Genesis"); AddTitleToMockedBook(m_genesis, "Genesis"); // add the book to the filter if (m_draftView != null && m_draftView.BookFilter != null) m_draftView.BookFilter.Add(m_genesis); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the DiffFootnoteView class /// </summary> /// <param name="cache">The FDO cache.</param> /// <param name="book">Scripture book to be displayed as the root in this view</param> /// <param name="differences">the list of differences</param> /// <param name="fRev"><c>true</c> if we display the revision, <c>false</c> if we /// display the current version.</param> /// <param name="filterInstance">The filter instance.</param> /// ------------------------------------------------------------------------------------ public DiffFootnoteView(FdoCache cache, IScrBook book, DifferenceList differences, bool fRev, int filterInstance) : base(cache) { m_filterInstance = filterInstance; m_scrBook = book; m_Differences = differences; m_fRev = fRev; Editable = false; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Append a new section to the given book, having the specified text as the section /// head. The general section head paragraph style is used. /// </summary> /// <param name="scrInMemoryCache">in-memory cache to use for testing</param> /// <param name="book">The book to which the section is to be appended</param> /// <param name="sSectionHead">The text of the new section head</param> /// <returns>The newly created section</returns> /// ------------------------------------------------------------------------------------ internal static ScrSection CreateSection(ScrInMemoryFdoCache scrInMemoryCache, IScrBook book, string sSectionHead) { ScrSection section = CreateSection(scrInMemoryCache, book, sSectionHead, ScrStyleNames.SectionHead); // this should be a scripture section and not an intro section bool isIntro = false; section.VerseRefEnd = book.CanonicalNum * 1000000 + 1000 + ((isIntro) ? 0 : 1); section.AdjustReferences(); return section; }
public override void Exit() { CheckDisposed(); m_philemon = null; m_section = null; m_para = null; base.Exit(); }
public override void Exit() { CheckDisposed(); m_introSection = null; m_genesis = null; m_section = null; m_secondSection = null; base.Exit(); }
public override void Exit() { CheckDisposed(); m_booksToMerge.Dispose(); m_booksToMerge = null; m_genesis = null; m_genesisRevision = null; base.Exit(); }
public override void Exit() { CheckDisposed(); m_btDraftView = null; m_draftForm.Close(); m_draftForm = null; m_book = null; base.Exit(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { base.CreateTestData(); m_philemon = m_scrInMemoryCache.AddBookToMockedScripture(57, "Philemon"); m_scrInMemoryCache.AddTitleToMockedBook(m_philemon.Hvo, "Philemon"); m_section = m_scrInMemoryCache.AddSectionToMockedBook(m_philemon.Hvo); m_para = m_scrInMemoryCache.AddParaToMockedSectionContent(m_section.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(m_para, "this is text", null); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Override to start an undoable UOW. /// </summary> /// ------------------------------------------------------------------------------------ public override void TestSetup() { base.TestSetup(); m_editingHelper.m_fUsingMockedSelection = true; m_philemon = AddBookToMockedScripture(57, "Philemon"); AddTitleToMockedBook(m_philemon, "Philemon"); m_section = AddSectionToMockedBook(m_philemon); m_para = AddParaToMockedSectionContent(m_section, ScrStyleNames.NormalParagraph); AddRunToMockedPara(m_para, "this is text", null); }
/// <summary> /// /// </summary> public override void TestSetup() { base.TestSetup(); m_wsVern = Cache.DefaultVernWs; m_wsTrans = Cache.DefaultAnalWs; m_book = Cache.ServiceLocator.GetInstance<IScrBookFactory>().Create(1); m_section = Cache.ServiceLocator.GetInstance<IScrSectionFactory>().Create(); m_book.SectionsOS.Add(m_section); m_section.ContentOA = m_text = Cache.ServiceLocator.GetInstance<IStTextFactory>().Create(); ; m_para = m_text.AddNewTextPara(ScrStyleNames.NormalParagraph); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create test data /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { m_matthew = m_scrInMemoryCache.AddBookToMockedScripture(40, "Matthews"); m_philemon = m_scrInMemoryCache.AddBookToMockedScripture(57, "Philemon"); m_scrInMemoryCache.AddTitleToMockedBook(m_philemon.Hvo, "Philemon"); m_inMemoryCache.InitializeWritingSystemEncodings(); // Initialize Philemon with intro and scripture sections IScrSection section = m_scrInMemoryCache.AddIntroSectionToMockedBook(m_philemon.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(section.Hvo, "Intro1", ScrStyleNames.IntroSectionHead); StTxtPara para = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para, "some intro text", null); section.AdjustReferences(); section = m_scrInMemoryCache.AddIntroSectionToMockedBook(m_philemon.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(section.Hvo, "Intro2", ScrStyleNames.IntroSectionHead); para = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para, "some more intro text", null); section.AdjustReferences(); // intro ends // normal scripture section = m_scrInMemoryCache.AddSectionToMockedBook(m_philemon.Hvo); para = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddSectionHeadParaToSection(section.Hvo, "Scripture1", ScrStyleNames.SectionHead); m_scrInMemoryCache.AddRunToMockedPara(para, "1", ScrStyleNames.ChapterNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "1", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "some text", null); m_scrInMemoryCache.AddRunToMockedPara(para, "2", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "some text", null); m_scrInMemoryCache.AddRunToMockedPara(para, "3-5", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "some text", null); section.AdjustReferences(); section = m_scrInMemoryCache.AddSectionToMockedBook(m_philemon.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(section.Hvo, "Scripture2", ScrStyleNames.SectionHead); para = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para, "6", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "some text", null); m_scrInMemoryCache.AddRunToMockedPara(para, "7", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "some text", null); section.AdjustReferences(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the DiffView class /// </summary> /// <param name="cache">The cache.</param> /// <param name="book">Scripture book to be displayed as the root in this view</param> /// <param name="differences">List of differences</param> /// <param name="fRev"><c>true</c> if we display the revision, <c>false</c> if we /// display the current version.</param> /// <param name="filterInstance">The filter instance.</param> /// ------------------------------------------------------------------------------------ public DiffView(FdoCache cache, IScrBook book, DifferenceList differences, bool fRev, int filterInstance) : base(cache) { m_filterInstance = filterInstance; m_scrBook = book; m_Differences = differences; m_fRev = fRev; // This call is required by the Windows.Forms Form Designer. InitializeComponent(); BackColor = SystemColors.Window; Editable = false; HorizMargin = 10; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates and initializes a footnote. /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { m_vernWs = Cache.DefaultVernWs; // create footnote IFdoServiceLocator servloc = Cache.ServiceLocator; m_footnote = servloc.GetInstance<IScrFootnoteFactory>().Create(); m_book = AddBookToMockedScripture(1, "Genesis"); m_book.FootnotesOS.Add(m_footnote); m_footnote.FootnoteMarker = TsStringUtils.MakeTss("a", m_vernWs); m_scr.DisplaySymbolInFootnote = true; m_scr.DisplayFootnoteReference = false; // create one empty footnote para m_footnotePara = m_footnote.AddNewTextPara(ScrStyleNames.NormalFootnoteParagraph); m_footnotePara.Contents = TsStringUtils.MakeTss(string.Empty, m_vernWs); }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) return; if (disposing) { // Dispose managed resources here. } // Dispose unmanaged resources here, whether disposing is true or false. m_book = null; base.Dispose(disposing); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Setup the selection in footnote. /// </summary> /// <param name="footnote">The footnote.</param> /// <param name="book">The book.</param> /// <param name="iBook">The 0-based index of the book.</param> /// <param name="ichStart">The 0-based starting character index.</param> /// <param name="ichEnd">The 0-based ending character index.</param> /// ------------------------------------------------------------------------------------ public void SetupSelectionInFootnote(IStFootnote footnote, IScrBook book, int iBook, int ichStart, int ichEnd) { CheckDisposed(); DynamicMock fakeSelHelper = new DynamicMock(typeof(SelectionHelper)); fakeSelHelper.SetupResult("GetTextPropId", StTxtParaTags.kflidContents, typeof(SelectionHelper.SelLimitType)); fakeSelHelper.SetupResult("NumberOfLevels", 3); // Setup the anchor SelLevInfo[] topInfo = new SelLevInfo[3]; IStTxtPara para = footnote[0]; topInfo[0].tag = StTextTags.kflidParagraphs; topInfo[0].ihvo = 0; // only one para per footnote allowed topInfo[0].hvo = para.Hvo; topInfo[1].tag = ScrBookTags.kflidFootnotes; topInfo[1].ihvo = footnote.IndexInOwner; topInfo[1].hvo = footnote.Hvo; topInfo[2].tag = BookFilter.Tag; topInfo[2].ihvo = iBook; topInfo[2].hvo = book.Hvo; // Setup the end SelLevInfo[] bottomInfo = new SelLevInfo[3]; for(int i = 0; i < 3; i++) bottomInfo[i] = topInfo[i]; fakeSelHelper.SetupResult("LevelInfo", topInfo); fakeSelHelper.SetupResult("IchAnchor", ichStart); fakeSelHelper.SetupResult("IchEnd", ichEnd); fakeSelHelper.SetupResultForParams("GetLevelInfo", topInfo, SelectionHelper.SelLimitType.Top); fakeSelHelper.SetupResultForParams("GetLevelInfo", topInfo, SelectionHelper.SelLimitType.Anchor); fakeSelHelper.SetupResultForParams("GetLevelInfo", bottomInfo, SelectionHelper.SelLimitType.Bottom); fakeSelHelper.SetupResultForParams("GetLevelInfo", bottomInfo, SelectionHelper.SelLimitType.End); fakeSelHelper.SetupResultForParams("GetIch", ichStart, SelectionHelper.SelLimitType.Top); fakeSelHelper.SetupResultForParams("GetIch", ichEnd, SelectionHelper.SelLimitType.Bottom); m_currentSelection = (SelectionHelper)fakeSelHelper.MockInstance; }