private ICmBaseAnnotation MakeSegment(IStTxtPara para, int beginOffset, int length)
        {
            ICmBaseAnnotation seg = CmBaseAnnotation.CreateUnownedCba(Cache);

            seg.BeginObjectRA       = para;
            seg.BeginOffset         = beginOffset;
            seg.EndOffset           = beginOffset + length;
            seg.AnnotationTypeRAHvo = m_hvoSegDefn;
            ISilDataAccess sda = para.Cache.MainCacheAccessor;

            int[] segments;
            if (sda.get_IsPropInCache(para.Hvo, kflidSegments, (int)CellarModuleDefns.kcptReferenceSequence, 0))
            {
                int[] segmentsT = Cache.GetVectorProperty(para.Hvo, kflidSegments, true);
                segments = new int[segmentsT.Length];
                Array.Copy(segmentsT, segments, segmentsT.Length);
                segments[segments.Length - 1] = seg.Hvo;
            }
            else
            {
                segments = new int[] { seg.Hvo };
            }
            para.Cache.VwCacheDaAccessor.CacheVecProp(seg.Hvo, kflidSegments, segments, segments.Length);
            return(seg);
        }
Example #2
0
        protected void CreateTestData()
        {
            // Create required virtual properties
            XmlDocument doc = new XmlDocument();

            // Subset of Flex virtuals required for parsing paragraphs etc.
            doc.LoadXml(
                "<virtuals>"
                + "<virtual modelclass=\"StTxtPara\" virtualfield=\"Segments\">"
                + "<dynamicloaderinfo assemblyPath=\"ITextDll.dll\" class=\"SIL.FieldWorks.IText.ParagraphSegmentsVirtualHandler\"/>"
                + "</virtual>"
                + "<virtual modelclass=\"WfiWordform\" virtualfield=\"OccurrencesInTexts\" destinationClass=\"CmBaseAnnotation\">"
                + "<dynamicloaderinfo assemblyPath=\"ITextDll.dll\" class=\"SIL.FieldWorks.IText.OccurrencesInTextsVirtualHandler\"/>"
                + "</virtual>"
                + "<virtual modelclass=\"WfiWordform\" virtualfield=\"HumanApprovedAnalyses\" computeeverytime=\"true\">"
                + "<dynamicloaderinfo assemblyPath=\"FDO.dll\" class=\"SIL.FieldWorks.FDO.FDOSequencePropertyVirtualHandler\"/>"
                + "</virtual>"
                + "<virtual modelclass=\"WfiWordform\" virtualfield=\"HumanNoOpinionParses\" computeeverytime=\"true\" requiresRealParserGeneratedData=\"true\">"
                + "<dynamicloaderinfo assemblyPath=\"FDO.dll\" class=\"SIL.FieldWorks.FDO.FDOSequencePropertyVirtualHandler\"/>"
                + "</virtual>"
                + "<virtual modelclass=\"WfiWordform\" virtualfield=\"HumanDisapprovedParses\" computeeverytime=\"true\">"
                + "<dynamicloaderinfo assemblyPath=\"FDO.dll\" class=\"SIL.FieldWorks.FDO.FDOSequencePropertyVirtualHandler\"/>"
                + "</virtual>"
                + "<virtual modelclass=\"WfiWordform\" virtualfield=\"FullConcordanceCount\" depends=\"OccurrencesInTexts\" computeeverytime=\"true\">"
                + "<dynamicloaderinfo assemblyPath=\"FDO.dll\" class=\"SIL.FieldWorks.FDO.IntegerPropertyVirtualHandler\"/>"
                + "</virtual>"
                + "<virtual modelclass=\"WfiWordform\" virtualfield=\"UserCount\" bulkLoadMethod=\"LoadAllUserCounts\" computeeverytime=\"true\">"
                + "<dynamicloaderinfo assemblyPath=\"FDO.dll\" class=\"SIL.FieldWorks.FDO.IntegerPropertyVirtualHandler\"/>"
                + "</virtual>"
                + "<virtual modelclass=\"WfiWordform\" virtualfield=\"ParserCount\" bulkLoadMethod=\"LoadAllParserCounts\" computeeverytime=\"true\" requiresRealParserGeneratedData=\"true\">"
                + "<dynamicloaderinfo assemblyPath=\"FDO.dll\" class=\"SIL.FieldWorks.FDO.IntegerPropertyVirtualHandler\"/>"
                + "</virtual>"
                + "<virtual modelclass=\"WfiWordform\" virtualfield=\"ConflictCount\" computeeverytime=\"true\" requiresRealParserGeneratedData=\"true\">"
                + "<dynamicloaderinfo assemblyPath=\"FDO.dll\" class=\"SIL.FieldWorks.FDO.IntegerPropertyVirtualHandler\"/>"
                + "</virtual>"
                + "<virtual modelclass=\"WordformInventory\" virtualfield=\"ConcordanceWords\" destinationClass=\"WfiWordform\">"
                + "<dynamicloaderinfo assemblyPath=\"ITextDll.dll\" class=\"SIL.FieldWorks.IText.ConcordanceWordsVirtualHandler\"/>"
                + "</virtual>"
                + "</virtuals>");
            BaseVirtualHandler.InstallVirtuals(doc.DocumentElement, Cache);

            m_text = new Text();
            Cache.LangProject.TextsOC.Add(m_text);
            string para1 = "Axx simplexx testxx withxx axx lotxx ofxx wordsxx endingxx inxx xx";
            string para2 = "axx sentencexx axx havingxx axx lotxx ofxx axx";

            m_para1           = new StTxtPara();
            m_stText          = new StText();
            m_text.ContentsOA = m_stText;
            m_para1           = MakePara(para1);
            m_para2           = MakePara(para2);
            m_wfAxx           = WfiWordform.CreateFromDBObject(Cache,
                                                               WfiWordform.FindOrCreateWordform(Cache, "axx", Cache.DefaultVernWs, true));
            // Make one real annotation, which also serves to link the Axx to this.
            m_cbaAxx = CmBaseAnnotation.CreateUnownedCba(Cache);
            m_cbaAxx.InstanceOfRA     = m_wfAxx;
            m_cbaAxx.BeginObjectRA    = m_para1;
            m_cbaAxx.BeginOffset      = 0;
            m_cbaAxx.EndOffset        = 3;
            m_cbaAxx.Flid             = (int)StTxtPara.StTxtParaTags.kflidContents;
            m_cbaAxx.AnnotationTypeRA = CmAnnotationDefn.Twfic(Cache);

            // Make another real annotation, which should get updated during Apply.
            IWfiWordform wf2 = WfiWordform.CreateFromDBObject(Cache,
                                                              WfiWordform.FindOrCreateWordform(Cache, "lotxx", Cache.DefaultVernWs, true));

            m_cba2 = CmBaseAnnotation.CreateUnownedCba(Cache);
            m_cba2.InstanceOfRA     = wf2;
            m_cba2.BeginObjectRA    = m_para2;
            m_cba2.BeginOffset      = "axx sentencexx axx havingxx axx ".Length;
            m_cba2.EndOffset        = m_cba2.BeginOffset + "lotxx".Length;
            m_cba2.AnnotationTypeRA = CmAnnotationDefn.Twfic(Cache);
            m_cba2.Flid             = (int)StTxtPara.StTxtParaTags.kflidContents;

            ParagraphParser.ConcordTexts(Cache, new int[] { m_stText.Hvo }, new NullProgressState());
            m_axxOccurrences   = m_wfAxx.ConcordanceIds;
            m_para1Occurrences = OccurrencesInPara(m_para1.Hvo, m_axxOccurrences);
            m_para2Occurrences = OccurrencesInPara(m_para2.Hvo, m_axxOccurrences);

            // to improve test isolation, be sure to null things not always initialized.
            m_wfaAxe    = m_wfaCut = m_wfaCutIt = m_wfaNotRude = null;
            m_cAnalyses = 0;
        }