public override void Initialize() { CheckDisposed(); base.Initialize(); //m_inMemoryCache.InitializeAnnotationDefs(); 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_text = new Text(); Cache.LangProject.TextsOC.Add(m_text); m_para = new StTxtPara(); StText text = new StText(); m_text.ContentsOA = text; text.ParagraphsOS.Append(m_para); m_trans = new CmTranslation(); m_para.TranslationsOC.Add(m_trans); kflidFT = StTxtPara.SegmentFreeTranslationFlid(Cache); kflidSegments = StTxtPara.SegmentsFlid(Cache); m_btPoss = Cache.LangProject.TranslationTagsOA.LookupPossibilityByGuid( LangProject.kguidTranBackTranslation); m_trans.TypeRA = m_btPoss; m_fWasUseScriptDigits = Cache.LangProject.TranslatedScriptureOA.UseScriptDigits; Cache.LangProject.TranslatedScriptureOA.UseScriptDigits = false; // do we need to set status? }
/// <summary> /// Make one for converting the specified paragraph. /// </summary> /// <param name="para"></param> public BtConverter(IStTxtPara para) { m_para = para; m_cache = para.Cache; kflidFT = StTxtPara.SegmentFreeTranslationFlid(m_cache); kflidSegments = StTxtPara.SegmentsFlid(m_cache); m_cpe = m_cache.LanguageWritingSystemFactoryAccessor.UnicodeCharProps; m_scr = para.Cache.LangProject.TranslatedScriptureOA; }
/// <summary> /// Ensure that the segments property of the paragraph is consistent with its contents and consists of real /// database objects. /// </summary> internal static FdoCache EnsureMainParaSegments(IStTxtPara para, int wsBt) { ParagraphParser pp = new ParagraphParser(para); List <int> EosOffsets; List <int> segs = pp.CollectSegmentAnnotationsOfPara(out EosOffsets); // Make sure the segments list is up to date. FdoCache cache = para.Cache; cache.VwCacheDaAccessor.CacheVecProp(para.Hvo, StTxtPara.SegmentsFlid(cache), segs.ToArray(), segs.Count); // This further makes sure all are real. StTxtPara.LoadSegmentFreeTranslations(new int[] { para.Hvo }, cache, wsBt); return(cache); }
/// <summary> /// Get the segments of the paragraph. This is public static to allow others to use /// the same code. This will actually parse the text of the paragraph, create any /// segments that do not yet exist, and create any needed free translation annotations /// to go with them. It also sets the kflidSegments (virtual) property of the paragraph, /// and the kflidFT (virtual) property of the segments. /// </summary> /// <returns>array of ICmBaseAnnotation objects for the segments</returns> public static ICmBaseAnnotation[] GetMainParaSegments(IStTxtPara para, int wsBt, out int[] paraSegs) { FdoCache cache = EnsureMainParaSegments(para, wsBt); int kflidSegments = StTxtPara.SegmentsFlid(cache); paraSegs = cache.GetVectorProperty(para.Hvo, kflidSegments, true); ICmBaseAnnotation[] segments = new ICmBaseAnnotation[paraSegs.Length]; for (int i = 0; i < paraSegs.Length; i++) { // This prevents trying to really load it from the database, which is typically not // useful and actully causes failures of some tests when using a memory cache that considers all // objects to be non-dummies. cache.VwCacheDaAccessor.CacheIntProp(paraSegs[i], (int)CmObjectFields.kflidCmObject_Class, (int)CmBaseAnnotation.kclsidCmBaseAnnotation); segments[i] = new CmBaseAnnotation(cache, paraSegs[i]); } return(segments); }
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); }
/// <summary> /// Insert the back translation segments. TeStVc overrides to make sure they are loaded properly. /// </summary> protected virtual void InsertBtSegments(StVc vc, IVwEnv vwenv, int hvo) { vwenv.AddObjVecItems(StTxtPara.SegmentsFlid(Cache), vc, (int)StTextFrags.kfrSegmentFreeTranslations); }