Ejemplo n.º 1
0
		/// ------------------------------------------------------------------------------------
		/// <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;
			}
		}
Ejemplo n.º 2
0
		/// ------------------------------------------------------------------------------------
		/// <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));
		}
Ejemplo n.º 3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Get the Chapter Verse Reference representation for a footnote (ie. sectionCV-CV Footnote(footnoteCV))
		/// Or Title representation (ie. Title Footnote(OwnOrd))
		/// </summary>
		/// <param name="footnote"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public string ContainingRefAsString(ScrFootnote footnote)
		{
			footnote.IgnoreDisplaySettings = true; // so we can access GetReference.
			string parentContext = "";
			string footnoteRef = "";
			int hvoContainingObj;
			if (footnote.TryGetContainingSectionHvo(out hvoContainingObj))
			{
				ScrSection section = new ScrSection(Cache, hvoContainingObj);
				parentContext = ChapterVerseBridgeAsString(section);
				footnoteRef = footnote.GetReference(m_cache.DefaultUserWs).Trim();
			}
			else if (footnote.TryGetContainingTitle(out hvoContainingObj))
			{
				parentContext = ResourceHelper.GetResourceString("kstidScriptureTitle");
				footnoteRef = footnote.OwnOrd.ToString();
			}
			return String.Format("{0} {1}({2})", parentContext,
				ResourceHelper.GetResourceString("kstidScriptureFootnote"), footnoteRef);
		}