本文整理汇总了C#中IStTxtPara.GetBT方法的典型用法代码示例。如果您正苦于以下问题:C# IStTxtPara.GetBT方法的具体用法?C# IStTxtPara.GetBT怎么用?C# IStTxtPara.GetBT使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IStTxtPara
的用法示例。
在下文中一共展示了IStTxtPara.GetBT方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyBtFootnote
/// ------------------------------------------------------------------------------------
/// <summary>
/// Make sure the marker for a footnote exists in the back translation and refers to the
/// footnote properly.
/// </summary>
/// <param name="footnote">given footnote whose marker we want to verify in the BT</param>
/// <param name="para">vernacular paragraph which owns the back translation</param>
/// <param name="ws">writing system of the back transltion</param>
/// <param name="ich">Character position where ORC should be in the specified back
/// translation</param>
/// ------------------------------------------------------------------------------------
public static void VerifyBtFootnote(IStFootnote footnote, IStTxtPara para, int ws, int ich)
{
ICmTranslation trans = para.GetBT();
ITsString btTss = trans.Translation.get_String(ws);
int iRun = btTss.get_RunAt(ich);
Guid newFootnoteGuid = TsStringUtils.GetGuidFromRun(btTss, iRun, FwObjDataTypes.kodtNameGuidHot);
Assert.AreEqual(footnote.Guid, newFootnoteGuid);
}
示例2: CompareFootnoteTrans
/// ------------------------------------------------------------------------------------
/// <summary>
/// Compares the translations of the footnote.
/// </summary>
/// <param name="expectedTrans">The expected translation</param>
/// <param name="currentPara">The current footnote paragraph.</param>
/// ------------------------------------------------------------------------------------
private void CompareFootnoteTrans(ICmTranslation expectedTrans, IStTxtPara currentPara)
{
ICmTranslation actualTrans = currentPara.GetBT();
if (expectedTrans == null)
{
Assert.IsNull(actualTrans, "Found an unexpected translation for footnote paragraph " +
currentPara.IndexInOwner + " having text: " + currentPara.Contents.Text);
return;
}
Assert.IsNotNull(actualTrans, "Translation missing for paragraph " +
currentPara.IndexInOwner + " having text: " + currentPara.Contents.Text);
foreach (int ws in actualTrans.Translation.AvailableWritingSystemIds)
{
ITsString tssExpected = expectedTrans.Translation.get_String(ws);
ITsString tssActual = actualTrans.Translation.get_String(ws);
if (tssExpected == null || tssExpected.Length == 0)
{
Assert.IsTrue(tssActual == null || tssActual.Length == 0,
"Found an unexpected translation for WS " + ws);
continue;
}
AssertEx.AreTsStringsEqual(tssExpected, tssActual);
}
}
示例3: GetSegmentedBTInfo
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;
}
示例4: VerifyRemovedFootnoteMarker
/// ------------------------------------------------------------------------------------
/// <summary>
/// Verifies that the footnote marker was deleted from the specified back translation
/// </summary>
/// <param name="para">Paragraph that contains the footnote marker</param>
/// <param name="guidFootnote">GUID of the deleted footnote</param>
/// <param name="ws">The HVO of the back trans writing system to check</param>
/// ------------------------------------------------------------------------------------
private void VerifyRemovedFootnoteMarker(IStTxtPara para, Guid guidFootnote, int ws)
{
ICmTranslation trans = para.GetBT();
if (trans == null)
return; // no back translation exists to check
int actualWs;
ITsString tssBt;
if (trans.Translation.TryWs(ws, out actualWs, out tssBt))
VerifyRemovedFootnoteMarker(guidFootnote, tssBt);
}
示例5: SetContentsForMoveDest
/// ------------------------------------------------------------------------------------
/// <summary>
/// This implements one half of a move. The text newValue is being moved from position
/// ichSource in paragraph source to ichInsert in the current paragraph. Run an analysis
/// adjuster to move analysis information that should survive.
/// </summary>
/// <param name="newValue">The new string to insert into the paragraph.</param>
/// <param name="ichInsert">The character index to insert newValue.</param>
/// <param name="cchInsert">The count of characters insert.</param>
/// <param name="source">The source containing the string to move.</param>
/// <param name="ichSource">The character offset in the source from which we will copy.</param>
/// <param name="fDstIsNew"><c>true</c> if the destination paragraph (i.e. this paragraph)
/// is brand new; <c>false</c> otherwise.</param>
/// ------------------------------------------------------------------------------------
private void SetContentsForMoveDest(ITsString newValue, int ichInsert, int cchInsert,
IStTxtPara source, int ichSource, bool fDstIsNew)
{
ITsString originalValue = m_Contents;
SetContentsInternal(newValue, new TsStringDiffInfo(ichInsert, cchInsert, 0), false);
AnalysisAdjuster.HandleMoveDest(this, originalValue, ichInsert, cchInsert, source, ichSource, fDstIsNew);
// We need to update the CmTranslation of the destination paragraph (this) to match
// what happened to the segments. (FWR-2224)
// We use the available writing systems of the source paragraph since that is where the
// segments in the destination paragraph originated.
ICmTranslation trans = source.GetBT();
if (trans != null) // Should only be null for non-Scripture paragraphs
{
int[] availableWss = trans.Translation.AvailableWritingSystemIds;
BackTranslationAndFreeTranslationUpdateHelper.Do(this, () =>
ScriptureServices.UpdateMainTransFromSegmented(this, availableWss));
}
}
示例6: GetTextRepresentationOfTrans
/// ------------------------------------------------------------------------------------
/// <summary>
/// Gets the text representation of the back translations for a footnote paragraph.
/// </summary>
/// <param name="footnotePara">The footnote paragraph.</param>
/// <returns>
/// text representation of all of the back translations for the footnote paragraph
/// </returns>
/// ------------------------------------------------------------------------------------
private string GetTextRepresentationOfTrans(IStTxtPara footnotePara)
{
ICmTranslation trans = footnotePara.GetBT();
if (trans == null)
return string.Empty;
StringBuilder transRepresentation = new StringBuilder();
foreach (var ws in trans.AvailableWritingSystems)
{
ITsString tss = trans.Translation.get_String(ws.Handle);
if (tss != null && tss.Length > 0)
{
transRepresentation.Append("<TRANS WS='");
transRepresentation.Append(ws.Id);
transRepresentation.Append("'>");
transRepresentation.Append(GetTextRepresentationOfTsString(tss));
transRepresentation.Append("</TRANS>");
}
}
return transRepresentation.ToString();
}
示例7: VerifyParagraphsAreDifferentObjects
/// ------------------------------------------------------------------------------------
/// <summary>
/// Helper method verifies that the copy was sufficiently "deep":
/// copied paragraphs are different objects, and that owner and owned objects
/// are different.
/// </summary>
/// <param name="srcPara">The para rev.</param>
/// <param name="newPara">The new para.</param>
/// ------------------------------------------------------------------------------------
private static void VerifyParagraphsAreDifferentObjects(IStTxtPara srcPara, IStTxtPara newPara)
{
Assert.AreNotEqual(srcPara, newPara);
// owned by different StTexts
Assert.AreNotEqual(srcPara.Owner, newPara.Owner);
// owning different back translations
Assert.AreNotEqual(srcPara.GetBT(), newPara.GetBT());
}
示例8: VerifyCopiedPara
/// ------------------------------------------------------------------------------------
/// <summary>
/// Helper method:
/// Verify the given copied paragraph, including footnotes and back translation,
/// plus any other fields deemed necessary.
/// </summary>
/// ------------------------------------------------------------------------------------
private void VerifyCopiedPara(IStTxtPara newPara)
{
// Verify the para StyleRules
Assert.AreEqual("Line 1", newPara.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));
// Verify the para Contents
Assert.AreEqual("11This" + StringUtils.kChObject + " is" + StringUtils.kChObject + " the previous version of the text.",
newPara.Contents.Text);
ITsString tssNewParaContents = newPara.Contents;
Assert.AreEqual(7, tssNewParaContents.RunCount);
AssertEx.RunIsCorrect(tssNewParaContents, 0, "1", "CharacterStyle1", Cache.DefaultVernWs, true);
AssertEx.RunIsCorrect(tssNewParaContents, 1, "1", "CharacterStyle2", Cache.DefaultVernWs, true);
AssertEx.RunIsCorrect(tssNewParaContents, 2, "This", null, Cache.DefaultVernWs, true);
// Run #3 is ORC for footnote, checked below...
AssertEx.RunIsCorrect(tssNewParaContents, 4, " is", null, Cache.DefaultVernWs, true);
// Run #5 is ORC for footnote, checked below...
AssertEx.RunIsCorrect(tssNewParaContents, 6, " the previous version of the text.", null, Cache.DefaultVernWs, true);
// note: At this point, having done the Copyxx() but not CreateOwnedObjects(),
// the ORCs still refer to footnote objects owned by m_archivedText...
IScrFootnote footnote1 = (IScrFootnote)m_archivedFootnotesOS[0];
VerifyFootnote(footnote1, newPara, 6);
Assert.AreEqual("Footnote1", footnote1[0].Contents.Text);
IScrFootnote footnote2 = (IScrFootnote)m_archivedFootnotesOS[1];
VerifyFootnote(footnote2, newPara, 10);
Assert.AreEqual("Footnote2", footnote2[0].Contents.Text);
// ...thus the footnotes are not yet in m_currentFootnotesOS.
Assert.AreEqual(0, m_currentFootnotesOS.Count);
// Verify the para translations
Assert.AreEqual(1, newPara.TranslationsOC.Count); //only 1 translation, the BT
ICmTranslation paraTrans = newPara.GetBT();
// verify each alternate translation
int[] wsBt = new int[] { m_wsEn, m_wsDe };
foreach (int ws in wsBt)
{
ITsString tssBtParaContents = paraTrans.Translation.get_String(ws);
Assert.AreEqual("BT" + StringUtils.kChObject + " of" + StringUtils.kChObject +
" test paragraph" + ws.ToString(), tssBtParaContents.Text);
Assert.AreEqual(5, tssBtParaContents.RunCount);
// could check every run too, but we'll skip that
Assert.AreEqual(BackTranslationStatus.Finished.ToString(),
paraTrans.Status.get_String(ws).Text);
}
// Verify the footnote translations, their ORCs, and their status
foreach (int ws in wsBt)
{
FdoTestHelper.VerifyBtFootnote(footnote1, newPara, ws, 2);
ICmTranslation footnoteTrans = footnote1[0].GetBT();
Assert.AreEqual("BT of footnote1 " + ws.ToString(),
footnoteTrans.Translation.get_String(ws).Text);
Assert.AreEqual(BackTranslationStatus.Checked.ToString(),
footnoteTrans.Status.get_String(ws).Text);
FdoTestHelper.VerifyBtFootnote(footnote2, newPara, ws, 6);
footnoteTrans = footnote2[0].GetBT();
Assert.AreEqual("BT of footnote2 " + ws.ToString(),
footnoteTrans.Translation.get_String(ws).Text);
Assert.AreEqual(BackTranslationStatus.Finished.ToString(),
footnoteTrans.Status.get_String(ws).Text);
}
}
示例9: ExportParagraph
/// ------------------------------------------------------------------------------------
/// <summary>
/// Export a paragraph of a title, section heading, or section contents.
/// </summary>
/// <param name="para">the given paragraph</param>
/// <param name="owningBook">The book that owns the paragraph</param>
/// ------------------------------------------------------------------------------------
protected void ExportParagraph(IStTxtPara para, IScrBook owningBook)
{
ExportMode exportMode = ExportMode.VernacularOnly;
ITsString paraText;
List<IScrFootnote> footnotes = null;
if (m_exportScripture)
paraText = para.Contents;
else
{ // get the tss of the requested back translation
if (!m_exportBackTrans)
return;
footnotes = owningBook.FootnotesOS.Where(f => f.ParaContainingOrcRA == para).ToList();
ICmTranslation trans = para.GetBT();
paraText = (trans != null ?
trans.Translation.get_String(m_nonInterleavedBtWs) : null);
if (paraText == null)
{
// No useful translation. However, we still want to export the marker for
// the paragraph, so create a dummy string so we have something to export.
ITsStrFactory fact = TsStrFactoryClass.Create();
paraText = fact.MakeString(string.Empty, m_nonInterleavedBtWs);
}
exportMode = ExportMode.BackTransOnly;
}
bool isEmptyPara = (paraText.Length == 0);
// Pre-process this paragraph. If it begins with a chapter number, we need to export
// the chapter marker before the paragraph marker.
RefElement runTypeFound;
ProcessParaStart(paraText, 0, out runTypeFound);
// Get the paragraph style name.
// TODO: if para.StyleRules is null, get the default paragraph style
string styleName = null;
if (para.StyleRules != null)
{
styleName = para.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle);
}
else
{
Debug.Fail("StyleRules should never be null.");
}
// If this is a section head style and it is for chapter 1 and there is no
// text, then we skip it.
IStStyle style = m_scr.FindStyle(styleName);
if (style != null && style.Structure == StructureValues.Heading)
{
// Only skip the first section in intro or Scripture if it is the very first one.
IScrSection section = para.OwnerOfClass<IScrSection>();
if (section.IsIntro && !m_fFoundFirstIntroSection)
{
m_fFoundFirstIntroSection = true;
if (isEmptyPara)
return;
}
else if (!section.IsIntro && !m_fFoundFirstScrSection)
{
m_fFoundFirstScrSection = true;
if (isEmptyPara)
return;
}
}
// Determine the marker for the paragraph.
string paraMarker = GetMarkerForStyle(styleName);
// Get the back translation if it exists and the options are enabled to export it
// interleaved with scripture.
ICmTranslation backTranslation = null;
if (m_markupSystem == MarkupType.Toolbox && m_exportScripture && m_exportBackTrans)
{
backTranslation = para.GetBT(); //may return null if no BT exists
exportMode = ExportMode.InterleavedVernAndBt;
}
// Export the fields of the paragraph,
// also the interleaved back translation if appropriate
ExportParagraphDetails(paraMarker, paraText, backTranslation, para.Hvo, exportMode, footnotes);
}