/// ------------------------------------------------------------------------------------ /// <summary> /// Write out the picture as a <figure> element. /// </summary> /// ------------------------------------------------------------------------------------ private void ExportPicture(ICmPicture pict) { ITsString tssCaption = pict.Caption.BestVernacularAlternative; string sCaption; if (tssCaption.Length > 0 && !tssCaption.Equals(pict.Caption.NotFoundTss)) sCaption = tssCaption.Text.Normalize(); else sCaption = String.Empty; m_writer.WriteStartElement("figure"); m_fInFigure = true; try { string sPath = pict.PictureFileRA.AbsoluteInternalPath.Normalize(); string sFile = Path.GetFileName(sPath); WriteFigureAttributes(sCaption, sFile); m_writer.WriteComment(String.Format("path=\"{0}\"", sPath)); m_writer.WriteStartElement("caption"); List<BTSegment> rgbts = new List<BTSegment>(); BTSegment bts = new BTSegment(tssCaption, 0, sCaption.Normalize(NormalizationForm.FormD).Length, pict); foreach (int ws in m_dictAnalLangs.Keys) { ITsString tss = pict.Caption.get_String(ws); if (tss.Length > 0 && tss != pict.Caption.NotFoundTss) bts.SetTransForWs(ws, tss.get_NormalizedForm(FwNormalizationMode.knmNFC)); } rgbts.Add(bts); if (sCaption.Length > 0) // Don't export caption with "NotFoundTss" text ExportParagraphData(tssCaption, rgbts); m_writer.WriteEndElement(); //</caption> m_writer.WriteEndElement(); //</figure> } finally { m_fInFigure = false; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Write out the picture as a <figure> element. /// </summary> /// <param name="pict"></param> /// ------------------------------------------------------------------------------------ private void ExportPicture(ICmPicture pict) { ITsString tssCaption = pict.Caption.BestVernacularAlternative; string sCaption; if (tssCaption.Length > 0 && !tssCaption.Equals(pict.Caption.NotFoundTss)) sCaption = tssCaption.Text.Normalize(); else sCaption = String.Empty; m_writer.WriteStartElement("figure"); string sPath = pict.PictureFileRA.AbsoluteInternalPath.Normalize(); string sFile = Path.GetFileName(sPath); WriteFigureAttributes(sCaption, sFile); m_writer.WriteComment(String.Format("path=\"{0}\"", sPath)); m_writer.WriteStartElement("caption"); OpenTrGroupIfNeeded(); List<BTSegment> rgbts = null; BackTranslationInfo trans = null; if (Options.UseInterlinearBackTranslation) { rgbts = new List<BTSegment>(); BTSegment bts = new BTSegment(0, sCaption.Normalize(NormalizationForm.FormD).Length, pict); foreach (int ws in m_dictAnalLangs.Keys) { ITsString tss = pict.Caption.GetAlternative(ws).UnderlyingTsString; if (tss.Length > 0 && tss != pict.Caption.NotFoundTss) bts.SetTransForWs(ws, tss.get_NormalizedForm(FwNormalizationMode.knmNFC)); } rgbts.Add(bts); } else { trans = new BackTranslationInfo(pict); } if (tssCaption.Length > 0) ExportParagraphData(0, tssCaption, trans, rgbts); CloseTrGroupIfNeeded(); m_writer.WriteEndElement(); //</caption> m_writer.WriteEndElement(); //</figure> }
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; }