private List<BTSegment> GetSegmentedBTInfo(IStTxtPara para) { List<BTSegment> rgBTSeg = new List<BTSegment>(); if (para == null || !para.IsValidObject) return rgBTSeg; // Backtranslation must exist if segmented BT exists ICmTranslation backtran = para.GetBT(); if (backtran == null) return rgBTSeg; // create list of WS used for back translations. List<int> rgWsBt = m_dictAnalLangs.Keys.ToList(); // Segment all BTs that aren't currently segmented if (rgWsBt.Count > 0) { foreach (ISegment segment in para.SegmentsOS) { BTSegment bts = new BTSegment(segment, para); foreach (int ws in rgWsBt) { ITsString tss = segment.FreeTranslation.get_String(ws); bts.SetTransForWs(ws, tss); string status = backtran.Status.get_String(ws).Text; if (!String.IsNullOrEmpty(status)) bts.SetBtStatusForWs(ws, status); } rgBTSeg.Add(bts); } } return rgBTSeg; }
private List<BTSegment> GetSegmentedBTInfo(IStTxtPara para) { List<BTSegment> rgBTSeg = new List<BTSegment>(); if (para == null || para.Hvo == 0) return rgBTSeg; // Backtranslation must exist if segmented BT exists ICmTranslation backtran = (para as StTxtPara).GetBT(); if (backtran == null) return rgBTSeg; // Check to see if there is at least one segmented BT bool hasSegmentedBT = false; foreach (int ws in m_dictAnalLangs.Keys) { if (backtran.Translation.GetAlternative(ws).Length > 0) { if (!(para as StTxtPara).HasNoSegmentBt(ws)) { hasSegmentedBT = true; break; } } } if (!hasSegmentedBT) return rgBTSeg; // create list of WS used for back translations. Segment all // BTs that aren't currently segmented List<int> rgWsBt = new List<int>(); foreach (int ws in m_dictAnalLangs.Keys) { if (backtran.Translation.GetAlternative(ws).Length > 0) { if ((para as StTxtPara).HasNoSegmentBt(ws)) new BtConverter(para).ConvertCmTransToInterlin(ws); rgWsBt.Add(ws); } } if (rgWsBt.Count > 0) { int kflidSegments = StTxtPara.SegmentsFlid(m_cache); int kflidFt = StTxtPara.SegmentFreeTranslationFlid(m_cache); ISilDataAccess sda = m_cache.MainCacheAccessor; int cseg = sda.get_VecSize(para.Hvo, kflidSegments); for (int iseg = 0; iseg < cseg; iseg++) { int hvoSeg = sda.get_VecItem(para.Hvo, kflidSegments, iseg); BTSegment bts = new BTSegment(m_cache, hvoSeg, para); int hvoFt = sda.get_ObjectProp(hvoSeg, kflidFt); foreach (int ws in rgWsBt) { ITsString tss = sda.get_MultiStringAlt(hvoFt, (int)CmAnnotation.CmAnnotationTags.kflidComment, ws); bts.SetTransForWs(ws, tss); string status = backtran.Status.GetAlternative(ws); if (!String.IsNullOrEmpty(status)) bts.SetBtStatusForWs(ws, status); } rgBTSeg.Add(bts); } } return rgBTSeg; }