/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// <returns><c>true</c> if we dealt with the display, otherwise <c>false</c></returns> /// ------------------------------------------------------------------------------------ public bool Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case (int)FootnoteFrags.kfrScripture: case (int)ScrFrags.kfrScripture: { // This fragment should only be used on full refresh - clear the user prompt // flags so they will be shown again. m_RealVc.ClearUserPromptUpdates(); // We add this lazy - we will expand some of it immediately, but the non- // visible parts will remain lazy! vwenv.NoteDependency(new int[] { m_cache.LangProject.TranslatedScriptureOAHvo }, new int[] { (int)Scripture.ScriptureTags.kflidScriptureBooks }, 1); vwenv.AddLazyVecItems(m_bookTag, m_RealVc, frag == (int)ScrFrags.kfrScripture ? (int)ScrFrags.kfrBook : (int)FootnoteFrags.kfrBook); break; } case (int)ScrFrags.kfrBook: { vwenv.OpenDiv(); vwenv.AddObjProp((int)ScrBook.ScrBookTags.kflidTitle, m_RealVc, (int)StTextFrags.kfrText); vwenv.NoteDependency(new int[] { hvo }, new int[] { (int)ScrBook.ScrBookTags.kflidSections }, 1); vwenv.AddLazyVecItems((int)ScrBook.ScrBookTags.kflidSections, m_RealVc, (int)ScrFrags.kfrSection); vwenv.CloseDiv(); break; } case (int)FootnoteFrags.kfrBook: { vwenv.OpenDiv(); vwenv.AddObjVecItems((int)ScrBook.ScrBookTags.kflidFootnotes, m_RealVc, (int)StTextFrags.kfrFootnote); vwenv.CloseDiv(); break; } case (int)ScrFrags.kfrSection: { vwenv.OpenDiv(); vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidHeading, m_RealVc, (int)StTextFrags.kfrText); vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidContent, m_RealVc, (int)StTextFrags.kfrText); vwenv.CloseDiv(); break; } case (int)StTextFrags.kfrPara: case (int)StTextFrags.kfrFootnotePara: { // Open a table to display the vern para in column 1, and the BT para in column 2. VwLength vlTable; vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; VwLength vlColumn; vlColumn.nVal = 5000; vlColumn.unit = VwUnit.kunPercent100; int nColumns = 2; vwenv.OpenTable(nColumns, // One or two columns. vlTable, // Table uses 100% of available width. 0, // Border thickness. VwAlignment.kvaLeft, // Default alignment. VwFramePosition.kvfpVoid, // No border. VwRule.kvrlNone, 0, //No space between cells. 0, //No padding inside cells. true); // Specify column widths. The first argument is the number of columns, // not a column index. vwenv.MakeColumns(nColumns, vlColumn); vwenv.OpenTableBody(); vwenv.OpenTableRow(); if (m_RealVc.RightToLeft) { AddBtParagraph(vwenv, hvo, frag, false); AddVernParagraph(vwenv, hvo, frag, true); } else { AddVernParagraph(vwenv, hvo, frag, false); AddBtParagraph(vwenv, hvo, frag, true); } // Close table vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); break; } case (int)StTextFrags.kfrFootnoteReference: { ITsStrFactory tsStrFactory = TsStrFactoryClass.Create(); ScrFootnote footnote = new ScrFootnote(m_cache, hvo); ITsString tssRef = tsStrFactory.MakeString(footnote.GetReference(m_RealVc.DefaultWs), m_RealVc.DefaultWs); vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.AddString(tssRef); break; } default: return(false); } return(true); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the overrides to highlight a footnote diff. /// </summary> /// <param name="hvo">The hvo of the footnote paragraph.</param> /// ------------------------------------------------------------------------------------ private void AddOverridesToHighlightFootnoteDiff(int hvo) { Difference diff = FindSubDiffForFootnote(hvo); if (diff == null) { return; } StTxtPara para = new StTxtPara(Cache, hvo); // Get the footnote which contains the paragraph. int ownerHvo = para.OwnerHVO; Debug.Assert(m_cache.GetClassOfObject(ownerHvo) == StFootnote.kClassId); if (m_cache.GetClassOfObject(ownerHvo) != StFootnote.kClassId) { return; //don't override the props for this para; continue on gracefully } ScrFootnote footnote = new ScrFootnote(Cache, ownerHvo); // Only add offset to first paragraph in footnote (should only be one para) int offset = 0; if (footnote.ParagraphsOS[0].Hvo == hvo) { int refLength = footnote.GetReference(m_wsDefault).Length; int markerLength = footnote.FootnoteMarker.Length; //add one for the space in between (added in StVc) offset = refLength + markerLength + 1; } const uint knNinch = 0x80000000; // Now add appropriate properties. // Need to add override properties for each run in the // range to be highlighted. int ichOverrideMin = diff.GetIchMin(m_fRev); ITsString tss = para.Contents.UnderlyingTsString; TsRunInfo runInfo; int ichOverrideLim; int prevLim = 0; do { tss.FetchRunInfoAt(ichOverrideMin, out runInfo); ichOverrideLim = Math.Min(diff.GetIchLim(m_fRev), runInfo.ichLim); // Prevent infinite loop in case of bad data in difference if (ichOverrideLim == prevLim) { break; } prevLim = ichOverrideLim; DispPropOverride prop = new DispPropOverride(); prop.chrp.clrBack = DiffViewVc.kHighlightColor; prop.chrp.clrFore = knNinch; prop.chrp.clrUnder = knNinch; prop.chrp.dympOffset = -1; prop.chrp.ssv = -1; prop.chrp.unt = -1; prop.chrp.ttvBold = -1; prop.chrp.ttvItalic = -1; prop.chrp.dympHeight = -1; prop.chrp.szFaceName = null; prop.chrp.szFontVar = null; prop.ichMin = ichOverrideMin + offset; prop.ichLim = ichOverrideLim + offset; m_DispPropOverrides.Add(prop); ichOverrideMin = ichOverrideLim; }while (ichOverrideLim < diff.GetIchLim(m_fRev)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// Scripture Footnotes are displayed by displaying each footnote's reference and text. /// The text is displayed using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case (int)FootnoteFrags.kfrScripture: { vwenv.NoteDependency(new int[] { m_cache.LangProject.TranslatedScriptureOAHvo }, new int[] { (int)Scripture.ScriptureTags.kflidScriptureBooks }, 1); vwenv.AddLazyVecItems(BooksTag, this, (int)FootnoteFrags.kfrBook); break; } case (int)FootnoteFrags.kfrRootInPageSeq: { int tag = DummyVirtualHandler.InstallDummyHandler(m_cache.VwCacheDaAccessor, "Scripture", "FootnotesOnPage", (int)CellarModuleDefns.kcptReferenceSequence).Tag; // Get the list of footnotes to display int[] hvos = m_cache.GetVectorProperty(hvo, tag, true); if (hvos.Length > 0) { int ownerHvo = m_cache.GetOwnerOfObject(hvos[0]); // The ownerHvo should be the HVO of the book vwenv.NoteDependency(new int[] { ownerHvo }, new int[] { (int)ScrBook.ScrBookTags.kflidFootnotes }, 1); } vwenv.AddObjVec(tag, this, (int)FootnoteFrags.kfrAllFootnotesWithinPagePara); break; } case (int)FootnoteFrags.kfrFootnoteWithinPagePara: { // Note a dependency on the footnote options so that the footnote will // be refreshed when these are changed. int[] depHvos = { hvo }; int[] depTags = { StFootnote.ktagFootnoteOptions }; vwenv.NoteDependency(depHvos, depTags, 1); // Insert the marker and reference vwenv.AddObj(hvo, this, (int)StTextFrags.kfrFootnoteMarker); vwenv.AddObj(hvo, this, (int)StTextFrags.kfrFootnoteReference); // Insert (we hope only one) paragraph contents. vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this, (int)FootnoteFrags.kfrFootnoteParaWithinPagePara); break; } case (int)FootnoteFrags.kfrFootnoteParaWithinPagePara: { if (!InsertParaContentsUserPrompt(vwenv, hvo)) { // Display the text paragraph contents, or its user prompt. vwenv.AddStringProp((int)StTxtPara.StTxtParaTags.kflidContents, null); } break; } case (int)FootnoteFrags.kfrBook: { vwenv.OpenDiv(); vwenv.AddObjVecItems((int)ScrBook.ScrBookTags.kflidFootnotes, this, (int)StTextFrags.kfrFootnote); vwenv.CloseDiv(); break; } case (int)StTextFrags.kfrFootnoteMarker: { ScrFootnote footnote = new ScrFootnote(Cache, hvo); if (footnote.DisplayFootnoteMarker) { DisplayFootnoteMarker(vwenv, footnote); } break; } case (int)StTextFrags.kfrFootnoteReference: { ITsStrFactory tsStrFactory = TsStrFactoryClass.Create(); ITsPropsFactory tpf = TsPropsFactoryClass.Create(); ITsTextProps ttp = tpf.MakeProps(ScrStyleNames.FootnoteTargetRef, m_wsDefault, 0); ScrFootnote footnote = new ScrFootnote(m_cache, hvo); string footnoteRef = footnote.GetReference(m_wsDefault); ITsString tssRef = tsStrFactory.MakeStringWithPropsRgch(footnoteRef, footnoteRef.Length, ttp); vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.AddString(tssRef); break; } default: base.Display(vwenv, hvo, frag); break; } }