Пример #1
0
        public void CreateFromGuid()
        {
            CheckDisposed();

            ICmAnnotationDefn cad = CmAnnotationDefn.TextSegment(Cache);

            Assert.AreEqual("Text Segment", cad.Name.UserDefaultWritingSystem);
        }
 public override void Initialize()
 {
     CheckDisposed();
     base.Initialize();
     InstallVirtuals(@"Language Explorer\Configuration\Words\AreaConfiguration.xml",
                     new string[] { "SIL.FieldWorks.IText.ParagraphSegmentsVirtualHandler", "SIL.FieldWorks.IText.OccurrencesInTextsVirtualHandler" });
     m_wsVern  = Cache.DefaultVernWs;
     m_wsTrans = Cache.DefaultAnalWs;
     m_book    = new ScrBook();
     Cache.LangProject.TranslatedScriptureOA.ScriptureBooksOS.Append(m_book);
     m_section = new ScrSection();
     m_book.SectionsOS.Append(m_section);
     m_para = new StTxtPara();
     m_text = new StText();
     m_section.ContentOA = m_text;
     m_text.ParagraphsOS.Append(m_para);
     m_hvoSegDefn  = CmAnnotationDefn.TextSegment(Cache).Hvo;
     m_hvoFtDefn   = Cache.GetIdFromGuid(new Guid(LangProject.kguidAnnFreeTranslation));
     kflidFT       = StTxtPara.SegmentFreeTranslationFlid(Cache);
     kflidSegments = StTxtPara.SegmentsFlid(Cache);
 }
Пример #3
0
        /// <summary>
        /// Return the hvo for theCmBaseAnnotation that
        /// matches the given boundaries in an StTxtPara object.
        /// If no exact match is found, return the nearest segment (preferably the following word).
        /// </summary>
        /// <param name="hvoStTxtPara"></param>
        /// <param name="ichMin"></param>
        /// <param name="ichLim"></param>
        /// <param name="fOnlyTWFIC">true, if restricted to TWFIC</param>
        /// <param name="fExactMatch"> true if we return an exact match, false otherwise.</param>
        /// <returns>hvo is 0 if not found.</returns>
        static internal int FindAnnotationHvoForStTxtPara(FdoCache cache, int hvoStTxtPara, int ichMin, int ichLim, bool fOnlyTWFIC, out bool fExactMatch)
        {
            int twficType   = CmAnnotationDefn.Twfic(cache).Hvo;
            int textSegType = CmAnnotationDefn.TextSegment(cache).Hvo;

            fExactMatch = false;
            int clsid = cache.GetClassOfObject(hvoStTxtPara);

            if (clsid != StTxtPara.kClassId)
            {
                Debug.Assert(clsid != StTxtPara.kClassId, "hvoStTxtPara should be of class StTxtPara.");
                return(0);
            }
            int            kflidParaSegment = InterlinVc.ParaSegmentTag(cache);
            ISilDataAccess sda = cache.MainCacheAccessor;

            // first find the closest segment.
            int[]             segments      = cache.GetVectorProperty(hvoStTxtPara, kflidParaSegment, true);
            ICmBaseAnnotation cbaClosestSeg = FindClosestAnnotation(cache, segments, textSegType, ichMin, ichLim, out fExactMatch);

            if (cbaClosestSeg == null)
            {
                return(0);
            }
            // if it was an exact match for a segment, return it.
            if (cbaClosestSeg != null && fExactMatch && !fOnlyTWFIC)
            {
                return(cbaClosestSeg.Hvo);
            }
            // otherwise, see if we can find a closer wordform
            int[]             segmentForms = cache.GetVectorProperty(cbaClosestSeg.Hvo, InterlinVc.SegmentFormsTag(cache), true);
            ICmBaseAnnotation cbaClosestWf = FindClosestAnnotation(cache, segmentForms, twficType, ichMin, ichLim, out fExactMatch);

            if (cbaClosestWf == null)
            {
                return(fOnlyTWFIC ? 0 : cbaClosestSeg.Hvo);
            }
            return(cbaClosestWf.Hvo);
        }