/// ------------------------------------------------------------------------------------ /// <summary> /// Calculates the diff type of the label text. /// </summary> /// <param name="baseDiff">the base difference</param> /// <param name="fIsCurr">true if the label is for the Current pane; false if for the /// Revision</param> /// <returns>the text of the label</returns> /// ------------------------------------------------------------------------------------ private string CalcLblText(Difference baseDiff, bool fIsCurr) { // True if the Current pane is the newer text; False if Revision is newer // set a local for now; when we import into a revision, this will need to be a parameter ScrDraft draft = new ScrDraft(m_cache, m_bookMerger.BookRev.OwnerHVO); bool fCurrIsNewer = (draft.Type == ScrDraftType.SavedVersion); DifferenceType diffType = CombineDifferenceTypes(baseDiff); int paraHvo = (fIsCurr) ? baseDiff.HvoCurr : baseDiff.HvoRev; int ichMin = (fIsCurr) ? baseDiff.IchMinCurr : baseDiff.IchMinRev; string labelText = string.Empty; if ((diffType & DifferenceType.ParagraphStyleDifference) != 0) { // paragraph style difference StTxtPara para = new StTxtPara(m_cache, paraHvo); ITsTextProps props = para.StyleRules; if (props != null) { labelText = AppendLabel(labelText, props.GetStrPropValue((int)FwTextPropType.ktptNamedStyle)); } else labelText = AppendLabel(labelText, TeDiffViewResources.kstidMissingParaStyle); } else if ((diffType & DifferenceType.CharStyleDifference) != 0) { string styleName = (fIsCurr) ? baseDiff.StyleNameCurr : baseDiff.StyleNameRev; if (styleName == null) styleName = FdoResources.DefaultParaCharsStyleName; labelText = AppendLabel(labelText, styleName); } else if ((diffType & DifferenceType.WritingSystemDifference) != 0) { string wsName = (fIsCurr) ? baseDiff.WsNameCurr : baseDiff.WsNameRev; labelText = AppendLabel(labelText, wsName); } else if ((diffType & DifferenceType.MultipleCharStyleDifferences) != 0) { labelText = AppendLabel(labelText, TeDiffViewResources.kstidMultipleStyleDiffs); } else if ((diffType & DifferenceType.MultipleWritingSystemDifferences) != 0) { labelText = AppendLabel(labelText, TeDiffViewResources.kstidMultipleWritingSystemDiffs); } // The remaining labels are for "added/deleted/changed" types of differences; // for these differences, we put a label ONLY on the pane with the 'newer' text. // If we are in the 'older' pane, quit now. if (fCurrIsNewer != fIsCurr) return labelText; if ((diffType & DifferenceType.TextDifference) != 0) { // normal text difference; append to the style label, if any labelText = AppendLabel(labelText, TeDiffViewResources.kstidTextChanged); } if ((diffType & DifferenceType.FootnoteDifference) != 0) { string sFootnoteDiffLabel = string.Empty; Debug.Assert(baseDiff.HasORCSubDiffs, "Found a footnote subdifference whose owning diff does not have subdiffs for ORCs"); sFootnoteDiffLabel = GetFootnoteDifferenceText(baseDiff, fIsCurr); // add info from my ORC subdiffs. // footnote differences; append to the style label labelText = AppendLabel(labelText, sFootnoteDiffLabel); } if ((diffType & DifferenceType.FootnoteMissingInCurrent) != 0) { // Footnote missing in current difference labelText = AppendLabel(labelText, fIsCurr ? TeDiffViewResources.kstidFootnoteDeleted : TeDiffViewResources.kstidFootnoteAdded); } if ((diffType & DifferenceType.FootnoteAddedToCurrent) != 0) { // Footnote missing in revision difference labelText = AppendLabel(labelText, fIsCurr ? TeDiffViewResources.kstidFootnoteAdded : TeDiffViewResources.kstidFootnoteDeleted); } if ((diffType & DifferenceType.PictureAddedToCurrent) != 0) { // Picture missing in current difference labelText = AppendLabel(labelText, fIsCurr ? TeDiffViewResources.kstidPictureAdded : TeDiffViewResources.kstidPictureMissing); } if ((diffType & DifferenceType.PictureMissingInCurrent) != 0) { // Picture missing in current difference labelText = AppendLabel(labelText, fIsCurr ? TeDiffViewResources.kstidPictureMissing : TeDiffViewResources.kstidPictureAdded); } if ((diffType & DifferenceType.VerseMissingInCurrent) != 0) { // Verse missing in current difference labelText = fIsCurr ? TeDiffViewResources.kstidVerseDeleted : TeDiffViewResources.kstidVerseAdded; } else if ((diffType & DifferenceType.VerseAddedToCurrent) != 0) { // Verse missing in revision difference labelText = fIsCurr ? TeDiffViewResources.kstidVerseAdded : TeDiffViewResources.kstidVerseDeleted; } if ((diffType & DifferenceType.ParagraphMissingInCurrent) != 0) { // Paragraph missing in current difference labelText = fIsCurr ? TeDiffViewResources.kstidParagraphDeleted : TeDiffViewResources.kstidParagraphAdded; } else if ((diffType & DifferenceType.ParagraphAddedToCurrent) != 0) { // Paragraph missing in revision difference labelText = fIsCurr ? TeDiffViewResources.kstidParagraphAdded : TeDiffViewResources.kstidParagraphDeleted; } if ((diffType & DifferenceType.StanzaBreakMissingInCurrent) != 0) { // Stanza break missing in current difference labelText = fIsCurr ? TeDiffViewResources.kstidStanzaBreakDeleted : TeDiffViewResources.kstidStanzaBreakAdded; } else if ((diffType & DifferenceType.StanzaBreakAddedToCurrent) != 0) { // Stanza break missing in revision difference labelText = fIsCurr ? TeDiffViewResources.kstidStanzaBreakAdded : TeDiffViewResources.kstidStanzaBreakDeleted; } if ((diffType & DifferenceType.SectionAddedToCurrent) != 0) { if (baseDiff.HvosSectionsCurr.Length > 1) labelText = fIsCurr ? TeDiffViewResources.kstidSectionsAdded : TeDiffViewResources.kstidSectionsDeleted; else labelText = fIsCurr ? TeDiffViewResources.kstidSectionAdded : TeDiffViewResources.kstidSectionDeleted; } else if ((diffType & DifferenceType.SectionMissingInCurrent) != 0) { if (baseDiff.HvosSectionsRev.Length > 1) labelText = fIsCurr ? TeDiffViewResources.kstidSectionsDeleted : TeDiffViewResources.kstidSectionsAdded; else labelText = fIsCurr ? TeDiffViewResources.kstidSectionDeleted : TeDiffViewResources.kstidSectionAdded; } if ((diffType & DifferenceType.SectionHeadAddedToCurrent) != 0) { // Section split in Current difference labelText = fIsCurr ? TeDiffViewResources.kstidSectionHeadAdded : TeDiffViewResources.kstidSectionHeadDeleted; } else if ((diffType & DifferenceType.SectionHeadMissingInCurrent) != 0) { // Section merged in Current difference labelText = fIsCurr ? TeDiffViewResources.kstidSectionHeadDeleted : TeDiffViewResources.kstidSectionHeadAdded; } if ((diffType & DifferenceType.SectionAddedToCurrent) != 0 && baseDiff.HasParaSubDiffs) { Debug.Assert(((Difference)baseDiff.SubDiffsForParas[0]).DiffType == DifferenceType.VerseMoved); //sMovedDiffLabel = string.Format(TeDiffViewResources.fmt, // CalcLblText((Difference)diff.subDiffs[0], fIsCurr)); "Verse 10 moved" string sMovedDiffLabel = baseDiff.SubDiffsForParas.Count == 1 ? TeDiffViewResources.kstidVerseMoved : TeDiffViewResources.kstidVersesMoved; labelText = AppendLabel(labelText, sMovedDiffLabel); } if ((diffType & DifferenceType.ParagraphSplitInCurrent) != 0 || (diffType & DifferenceType.ParagraphMergedInCurrent) != 0 || (diffType & DifferenceType.ParagraphStructureChange) != 0) { if ((diffType & DifferenceType.ParagraphAddedToCurrent) != 0 && (diffType & DifferenceType.ParagraphMissingInCurrent) != 0) { labelText = AppendLabel(labelText, CreateParaStructLabel(baseDiff, fIsCurr, fCurrIsNewer)); } else labelText = CreateParaStructLabel(baseDiff, fIsCurr, fCurrIsNewer); } // if we didn't find a difference we know about then just put some text in saying // that we don't know about the current difference. if (labelText == string.Empty) labelText = "Unknown DiffType"; return labelText; }
/// ----------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="DiffDialog"/> class. /// </summary> /// <param name="bookMerger"></param> /// <param name="cache"></param> /// <param name="stylesheet"></param> /// <param name="zoomFactorDraft">The zoom percentage to be used for the "draft" (i.e., /// main Scripture) view</param> /// <param name="zoomFactorFootnote">The zoom percentage to be used for the "footnote" /// view</param> /// <param name="fDoCollapseUndo">true if we want to collapse to a single Undo item on close.</param> /// ----------------------------------------------------------------------------------- public DiffDialog(BookMerger bookMerger, FdoCache cache, IVwStylesheet stylesheet, float zoomFactorDraft, float zoomFactorFootnote, bool fDoCollapseUndo) { Debug.Assert(cache != null); m_viewHelper = new ActiveViewHelper(this); m_fDoCollapseUndo = fDoCollapseUndo; // Required for Windows Form Designer support InitializeComponent(); // just as fallback in case the Designer replaced FwContainer with Container // in InitializeComponent()... if (!(components is FwContainer)) components = new FwContainer(components); // the last column of the table layout manager in the last row should have the // width of the scroll bar TableLayoutPanel tablePanel = tableLayoutPanel.GetControlFromPosition(0, 3) as TableLayoutPanel; tablePanel.ColumnStyles[3].Width = SystemInformation.VerticalScrollBarWidth - SystemInformation.FixedFrameBorderSize.Width; tablePanel = tableLayoutPanel.GetControlFromPosition(1, 3) as TableLayoutPanel; tablePanel.ColumnStyles[3].Width = SystemInformation.VerticalScrollBarWidth - SystemInformation.FixedFrameBorderSize.Width; m_msgMediator = new Mediator(); m_msgMediator.AddColleague(this); components.Add(m_msgMediator); m_bookMerger = bookMerger; m_differences = bookMerger.Differences; m_cache = cache; m_scr = m_cache.LangProject.TranslatedScriptureOA; m_stylesheet = stylesheet; m_zoomFactorDraft = zoomFactorDraft; m_zoomFactorFootnote = zoomFactorFootnote; // Don't start out in edit mode m_editMode = false; // If the diff is a comparison of the current against a normal saved version, then // change the label text. ScrDraft draft = new ScrDraft(m_cache, m_bookMerger.BookRev.OwnerHVO); if (draft.Type == ScrDraftType.SavedVersion) { lblSavedVersion.Text = string.Format(TeDiffViewResources.kstidSavedVersion, draft.Description); } else lblSavedVersion.Text = string.Format(lblSavedVersion.Text, draft.Description); CreateUndoMark(); }
public void AdjustAnnotationReferences_ParaInArchive() { IScrBook genesis = m_scrInMemoryCache.AddBookToMockedScripture(1, "Genesis"); StText titleText = m_scrInMemoryCache.AddTitleToMockedBook(genesis.Hvo, "Genesis"); IStPara titlePara = titleText.ParagraphsOS[0]; // Introduction section IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(genesis.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(section.Hvo, "Introduction head", ScrStyleNames.IntroSectionHead); StTxtPara para = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.IntroParagraph); m_scrInMemoryCache.AddRunToMockedPara(para, "An intro to Genesis", null); section.AdjustReferences(true); IScrDraft version = new ScrDraft(); m_scr.ArchivedDraftsOC.Add(version); int hvoSavedVersion = m_scr.AddBookToSavedVersion(version, genesis.Hvo); IScrBook genesisSaved = new ScrBook(m_scrInMemoryCache.Cache, hvoSavedVersion); IStPara paraSaved = genesisSaved.SectionsOS[0].ContentOA.ParagraphsOS[0]; ScrBookAnnotations annotations = (ScrBookAnnotations)m_scr.BookAnnotationsOS[0]; BCVRef ref1 = new BCVRef(1, 1, 0); IScrScriptureNote note = annotations.InsertNote(ref1, ref1, paraSaved, paraSaved, LangProject.kguidAnnConsultantNote); Assert.IsNotNull(note); m_scr.AdjustAnnotationReferences(); Assert.AreEqual(para.Hvo, note.BeginObjectRA.Hvo); }
public void ImportExistingBook() { CheckDisposed(); FdoOwningCollection<IScrDraft> archivedDrafts = m_cache.LangProject.TranslatedScriptureOA.ArchivedDraftsOC; int nDrafts = archivedDrafts.Count; // modify the existing copy of Philemon IScrBook philemon = m_cache.LangProject.TranslatedScriptureOA.FindBook("PHM"); Assert.IsNotNull(philemon, "Philemon is missing!"); int cSections = philemon.SectionsOS.Count; FdoOwningSequence<IStPara> titleParas = philemon.TitleOA.ParagraphsOS; Assert.AreEqual(1, titleParas.Count, "Title should consist of 1 para before import"); // add guid to title, to make it unique ITsStrBldr titleBldr = ((StTxtPara)titleParas[0]).Contents.UnderlyingTsString.GetBldr(); titleBldr.Replace(0, 0, System.Guid.NewGuid().ToString(), null); ITsString tssGuidTitle = titleBldr.GetString(); ((IStTxtPara)titleParas[0]).Contents.UnderlyingTsString = tssGuidTitle; // set up a ScrImportSetFW for our test m_settings.ImportTranslation = true; m_settings.ImportBookIntros = true; m_settings.ImportAnnotations = false; MakeSFImportTestSettings((m_settings as ScrImportSet)); // do the import BCVRef screfPhm = new BCVRef(57, 1, 1); (m_settings as ScrImportSet).StartRef = screfPhm; (m_settings as ScrImportSet).EndRef = screfPhm; TeSfmImporter.Import(m_settings, m_cache, m_styleSheet, null); // verify the new imported book philemon = m_cache.LangProject.TranslatedScriptureOA.FindBook("PHM"); Assert.IsNotNull(philemon, "Philemon was not imported"); titleParas = philemon.TitleOA.ParagraphsOS; Assert.AreEqual(1, titleParas.Count, "Title should consist of 1 para after import"); Assert.IsTrue( ((IStTxtPara)titleParas[0]).Contents.Text.StartsWith("Paul's Letter to")); Assert.AreEqual(6, philemon.SectionsOS.Count, "The English version of Philemon has 6 sections"); // Verify that the modified (i.e., original) copy was moved to the revision position // in the DB. Assert.AreEqual(nDrafts + 1, archivedDrafts.Count); IScrDraft draft = new ScrDraft(m_cache, archivedDrafts.HvoArray[archivedDrafts.Count - 1]); Assert.AreEqual(1, draft.BooksOS.Count); IScrBook bookRev = draft.BooksOS[0]; Assert.AreEqual("PHM", bookRev.BookId); titleParas = bookRev.TitleOA.ParagraphsOS; Assert.AreEqual(1, titleParas.Count, "Title in revision should consist of 1 paras"); AssertEx.AreTsStringsEqual(tssGuidTitle, ((IStTxtPara)titleParas[0]).Contents.UnderlyingTsString); Assert.AreEqual(cSections, bookRev.SectionsOS.Count); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <param name="bookMerger"></param> /// <param name="cache"></param> /// <param name="stylesheet"></param> /// <param name="draft"></param> /// ------------------------------------------------------------------------------------ public DummyDiffDialog(BookMerger bookMerger, FdoCache cache, IVwStylesheet stylesheet, ScrDraft draft) : base(bookMerger, cache, stylesheet, 1.0f, 1.0f) { }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <param name="bookMerger"></param> /// <param name="cache"></param> /// <param name="stylesheet"></param> /// <param name="draft"></param> /// ------------------------------------------------------------------------------------ public MockedCacheDiffDialog(BookMerger bookMerger, FdoCache cache, IVwStylesheet stylesheet, ScrDraft draft) : base(bookMerger, cache, stylesheet, draft) { }