Example #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Writes this response to the the specified annotation
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void WriteToCache(IScrScriptureNote ann, FwStyleSheet styleSheet)
        {
            ParagraphCollection parasResponse = new ParagraphCollection(Paragraphs, styleSheet);

            ParagraphCollection.ParaMatchType type;
            int matchIndex = FindMatchingResponse(parasResponse, ann.ResponsesOS, out type);

            switch (type)
            {
            case ParagraphCollection.ParaMatchType.Exact:
            case ParagraphCollection.ParaMatchType.Contains:
                break;                         // we can ignore the new response -- it's a subset of the old.

            case ParagraphCollection.ParaMatchType.IsContained:
                IStJournalText oldText = ann.ResponsesOS[matchIndex];
                oldText.ParagraphsOS.Clear();
                parasResponse.WriteToCache(oldText);
                break;

            case ParagraphCollection.ParaMatchType.None:
                IStJournalText newText = ann.Cache.ServiceLocator.GetInstance <IStJournalTextFactory>().Create();
                ann.ResponsesOS.Add(newText);
                parasResponse.WriteToCache(newText);
                break;
            }
        }
Example #2
0
        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);
        }
Example #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Find a text that matches the paragraph strings in rgtss, if any.
        /// </summary>
        /// <param name="paragraphs">The paragraphs for the response.</param>
        /// <param name="texts">The sequence of journal texts to search.</param>
        /// <param name="type">The type of match found (or not).</param>
        /// <returns>The index of the existing text found to be a match; or -1 if no match is
        /// found</returns>
        /// ------------------------------------------------------------------------------------
        private static int FindMatchingResponse(ParagraphCollection paragraphs,
                                                IFdoOwningSequence <IStJournalText> texts, out ParagraphCollection.ParaMatchType type)
        {
            for (int i = 0; i < texts.Count; ++i)
            {
                if (paragraphs.Equals(texts[i]))
                {
                    type = ParagraphCollection.ParaMatchType.Exact;
                    return(i);
                }
            }

            type = ParagraphCollection.ParaMatchType.None;
            return(-1);
        }