示例#1
0
        public void FindOrCreateAnnotation_GuidNotFound()
        {
            StTxtParaBldr     bldr    = new StTxtParaBldr(Cache);
            ScrAnnotationInfo annInfo = new ScrAnnotationInfo(CmAnnotationDefnTags.kguidAnnConsultantNote,
                                                              bldr, 0, 01001001, 01001002);
            IScrScriptureNote newNote = ScrNoteImportManager.FindOrCreateAnnotation(annInfo, Guid.NewGuid());

            Assert.IsNotNull(newNote);
            Assert.IsNull(newNote.BeginObjectRA);
            Assert.IsNull(newNote.EndObjectRA);
            Assert.AreEqual(01001001, newNote.BeginRef);
            Assert.AreEqual(01001002, newNote.EndRef);
        }
示例#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;
		}
示例#3
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 ScrScriptureNote FindOrCreateAnnotation(ScrAnnotationInfo info,
			ICmObject annotatedObj)
		{
			ScrScriptureNote ann;
			// If an identical note is not found...
			if (!m_existingAnnotations.TryGetValue(info.Key, out ann))
			{
				// insert this note.
				ann = (ScrScriptureNote)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;
		}
示例#4
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];
		}
		public void FindOrCreateAnnotation_GuidNotFound()
		{
			StTxtParaBldr bldr = new StTxtParaBldr(Cache);
			ScrAnnotationInfo annInfo = new ScrAnnotationInfo(CmAnnotationDefnTags.kguidAnnConsultantNote,
				bldr, 0, 01001001, 01001002);
			IScrScriptureNote newNote = ScrNoteImportManager.FindOrCreateAnnotation(annInfo, Guid.NewGuid());
			Assert.IsNotNull(newNote);
			Assert.IsNull(newNote.BeginObjectRA);
			Assert.IsNull(newNote.EndObjectRA);
			Assert.AreEqual(01001001, newNote.BeginRef);
			Assert.AreEqual(01001002, newNote.EndRef);
		}
示例#6
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 = LangProject.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;
		}
示例#7
0
		/// ------------------------------------------------------------------------------------
		/// <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 ScrScriptureNote FindOrCreateAnnotation(ScrAnnotationInfo info,
			Guid annotatedObjGuid)
		{
			ScrScriptureNote ann;

			// If an identical note is not found...
			if (!s_existingAnnotations.TryGetValue(info.Key, out ann))
			{
				using (new SuppressSubTasks(s_scr.Cache))
				{
					int hvo = s_scr.Cache.GetIdFromGuid(annotatedObjGuid);
					ICmObject annotatedObj = hvo <= 0 ? null :
						CmObject.CreateFromDBObject(s_scr.Cache, hvo);
					ann = (ScrScriptureNote)s_annotationList.InsertImportedNote(
						info.startReference, info.endReference, annotatedObj, annotatedObj,
						info.guidAnnotationType, null);
				}

				if (s_scr.Cache.ActionHandlerAccessor != null)
					s_scr.Cache.ActionHandlerAccessor.AddAction(new UndoImportObjectAction(ann));

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

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

			return ann;
		}