/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Finds or creates an annotation.
		/// </summary>
		/// <param name="info">The information about a annotation being imported.</param>
		/// <param name="annotatedObjGuid">The annotated obj GUID.</param>
		/// <returns>
		/// The annotation (whether created or found)
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public static IScrScriptureNote FindOrCreateAnnotation(ScrAnnotationInfo info,
			Guid annotatedObjGuid)
		{
			IScrScriptureNote ann;

			// If an identical note is not found...
			if (!s_existingAnnotations.TryGetValue(info.Key, out ann))
			{
				ICmObject annotatedObj = null;
				if (annotatedObjGuid != Guid.Empty)
					s_scr.Cache.ServiceLocator.GetInstance<ICmObjectRepository>().TryGetObject(annotatedObjGuid, out annotatedObj);
				ann = s_annotationList.InsertImportedNote(info.startReference, info.endReference,
					annotatedObj, annotatedObj,	info.guidAnnotationType, null);

				ann.BeginOffset = ann.EndOffset = info.ichOffset;

				if (ann.CitedText != null)
					ann.EndOffset += ann.CitedText.Length;
			}

			return ann;
		}
Example #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets a paragraph builder for a simple, single-paragraph Scripture annotation
		/// discussion field. The base implementation just returns null, but this is virtual to
		/// allow subclasses to return something useful if they don't handle complex annotations.
		/// </summary>
		/// <param name="info">The information about a annotation being imported.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		protected virtual StTxtParaBldr GetAnnotDiscussionParaBldr(ScrAnnotationInfo info)
		{
			return null;
		}
Example #3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets a paragraph builder for a simple, single-paragraph Scripture annotation
		/// discussion field. This is virtual to allow subclasses to return NULL if they can't
		/// deal with this much simplicity.
		/// </summary>
		/// <param name="info">The information about a annotation being imported.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		protected override StTxtParaBldr GetAnnotDiscussionParaBldr(ScrAnnotationInfo info)
		{
			if (info.bldrsDiscussion == null || info.bldrsDiscussion.Count == 0)
				return null;
			Debug.Assert(info.bldrsDiscussion.Count == 1);
			return info.bldrsDiscussion[0];
		}
Example #4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Finds or creates an annotation.
		/// </summary>
		/// <param name="info">The information about a annotation being imported.</param>
		/// <param name="annotatedObj">The annotated object (a book or paragraph).</param>
		/// <returns>
		/// The annotation (whether created or found)
		/// </returns>
		/// ------------------------------------------------------------------------------------
		protected IScrScriptureNote FindOrCreateAnnotation(ScrAnnotationInfo info,
			ICmObject annotatedObj)
		{
			IScrScriptureNote ann;
			// If an identical note is not found...
			if (!m_existingAnnotations.TryGetValue(info.Key, out ann))
			{
				// insert this note.
				ann = m_undoManager.InsertNote(info.startReference, info.endReference,
					annotatedObj, GetAnnotDiscussionParaBldr(info), info.guidAnnotationType);

				ann.BeginOffset = ann.EndOffset = info.ichOffset;
				if (ann.CitedText != null)
					ann.EndOffset += ann.CitedText.Length;
			}

			return ann;
		}
Example #5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Prepares the paragraphs for the annotation text fields (e.g. Quote, Recommendation,
		/// etc.) and creates the annotation (or finds an existing one having all the same
		/// information).
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private IScrScriptureNote FindOrCreateAnnotation(FwStyleSheet styleSheet)
		{
			FdoCache cache = styleSheet.Cache;

			ParagraphCollection parasQuote = new ParagraphCollection(Quote, styleSheet, cache.DefaultVernWs);
			ParagraphCollection parasDiscussion = new ParagraphCollection(Discussion, styleSheet);
			ParagraphCollection parasRecommendation = new ParagraphCollection(Suggestion, styleSheet);
			ParagraphCollection parasResolution = new ParagraphCollection(Resolution, styleSheet);

			if (m_guidType == Guid.Empty)
				m_guidType = CmAnnotationDefnTags.kguidAnnConsultantNote;
			ScrAnnotationInfo info = new ScrAnnotationInfo(m_guidType, parasDiscussion,
				 parasQuote, parasRecommendation, parasResolution, BeginOffset,
				 BeginScrBCVRef, EndScrBCVRef, m_createdDate);

			IScrScriptureNote scrNote =
				ScrNoteImportManager.FindOrCreateAnnotation(info, m_guidBegObj);

			parasQuote.WriteToCache(scrNote.QuoteOA);
			parasDiscussion.WriteToCache(scrNote.DiscussionOA);
			parasRecommendation.WriteToCache(scrNote.RecommendationOA);
			parasResolution.WriteToCache(scrNote.ResolutionOA);

			return scrNote;
		}