本文整理汇总了C#中ITsString.FetchRunInfo方法的典型用法代码示例。如果您正苦于以下问题:C# ITsString.FetchRunInfo方法的具体用法?C# ITsString.FetchRunInfo怎么用?C# ITsString.FetchRunInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITsString
的用法示例。
在下文中一共展示了ITsString.FetchRunInfo方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetGuidFromRun
/// ------------------------------------------------------------------------------------
/// <summary>
/// Get a Guid from the given run in a structured text string.
/// </summary>
/// <param name="tss">given structured text string</param>
/// <param name="iRun">given run</param>
/// <param name="odt">object data type, 0 if no ORC guid located</param>
/// <param name="tri">run information</param>
/// <param name="ttp">text properties of the run (if incoming value is null and the
/// run is an object, this will be set to the run props)</param>
/// <param name="desiredOrcTypes">The desired ORC types, or null to return any type of
/// ORC</param>
/// <returns>
/// The GUID associated with the specified run of the tss, if any; otherwise Guid.Empty
/// </returns>
/// ------------------------------------------------------------------------------------
private static Guid GetGuidFromRun(ITsString tss, int iRun, FwObjDataTypes[] desiredOrcTypes, out FwObjDataTypes odt, out TsRunInfo tri, ref ITsTextProps ttp)
{
tss.FetchRunInfo(iRun, out tri);
if (tri.ichLim - tri.ichMin == 1 && tss.get_RunText(iRun)[0] == StringUtils.kChObject)
{
// determine if single-character run contains an ORC
ttp = ttp ?? tss.get_Properties(iRun);
return GetGuidFromProps(ttp, desiredOrcTypes, out odt);
}
odt = 0;
return Guid.Empty;
}
示例2: TextProps
/// ------------------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the <see cref="T:TextProps"/> class.
/// </summary>
/// ------------------------------------------------------------------------------------
public TextProps(int irun, ITsString tss, FdoCache cache)
{
TsRunInfo runinfo;
ITsTextProps ttp = tss.FetchRunInfo(irun, out runinfo);
IchMin = runinfo.ichMin;
IchLim = runinfo.ichLim;
SetProps(ttp, cache);
}
示例3: GetNextRef
/// ------------------------------------------------------------------------------------
/// <summary>
/// Loop through the runs of the given string until a verse or chapter number is
/// found. Update the start and end reference with the found number.
/// </summary>
/// <param name="iStart">Index of run to start search</param>
/// <param name="iLim">Index of run to end search.
/// One exception: if the run at iLim-1 is a chapter, we will go one run further (at the
/// iLim) to check for an adjacent verse number.</param>
/// <param name="tss">The string</param>
/// <param name="fIgnoreErrors"><c>true</c> to ignore runs with errors, <c>false</c>
/// to throw an exception if we encounter a invalid chapter or verse number.</param>
/// <param name="refStart">Start reference</param>
/// <param name="refEnd">End reference</param>
/// <param name="iNext">Index of run after last one processed (i.e. iCurr+1)</param>
/// <exception cref="T:System.ArgumentException">Invalid chapter number</exception>
/// ------------------------------------------------------------------------------------
public static RefRunType GetNextRef(int iStart, int iLim, ITsString tss,
bool fIgnoreErrors, ref ScrReference refStart, ref ScrReference refEnd, out int iNext)
{
Debug.Assert(iStart >= 0 && iStart < iLim);
Debug.Assert(iLim <= tss.RunCount);
// look at all of the text runs in this paragraph starting at
int iRun = iStart;
try
{
for (; iRun < iLim; iRun++)
{
TsRunInfo runInfo;
string style = tss.FetchRunInfo(iRun, out runInfo).Style();
if (style == ScrStyleNames.VerseNumber)
{
// for verse number runs, get the verse range and save it
int startVerse, endVerse;
ScrReference.VerseToInt(tss.get_RunText(iRun), out startVerse, out endVerse);
if (startVerse <= 0)
{
if (fIgnoreErrors)
continue;
throw new InvalidVerseException(tss.get_RunText(iRun), runInfo);
}
if (startVerse <= refStart.LastVerse)
{
refStart.Verse = startVerse;
refEnd.Verse = Math.Min(refEnd.LastVerse, endVerse);
}
iNext = iRun + 1;
return RefRunType.Verse;
}
if (style == ScrStyleNames.ChapterNumber)
{
int chapter = -1;
try
{
// for chapter number runs, get the chapter number and save it
chapter = ScrReference.ChapterToInt(tss.get_RunText(iRun));
}
catch (ArgumentException)
{
if (fIgnoreErrors)
continue;
throw new InvalidChapterException(tss.get_RunText(iRun), runInfo);
}
Debug.Assert(chapter > 0); // should have thrown exception in ScrReference.ChapterToInt
// if chapter is valid for this book...
if (chapter <= refStart.LastChapter)
{
refStart.Chapter = refEnd.Chapter = chapter;
refStart.Verse = refEnd.Verse = 1; // implicit default
}
iNext = iRun + 1; // increment just beyond the chapter
// Because we've found a chapter, check the very next run (if we can)
// to see if it is a verse.
if (iNext < tss.RunCount && iNext < iLim + 1) // it's ok to check at iLim in this special case
{
int dummy;
ScrReference startTemp = new ScrReference(refStart);
ScrReference endTemp = new ScrReference(refEnd);
RefRunType nextItemType = GetNextRef(iNext, iNext + 1, tss, fIgnoreErrors,
ref startTemp, ref endTemp, out dummy);
// if it is a verse, update refStart/refEnd
if (nextItemType == RefRunType.Verse)
{
refStart = startTemp;
refEnd = endTemp;
iNext++;
return RefRunType.ChapterAndVerse;
}
}
// Otherwise, since a verse didn't immediatly follow, verse 1 is implicit
// so use it as the refStart/RefEnd
return RefRunType.Chapter;
}
}
iNext = iLim;
//.........这里部分代码省略.........
示例4: WriteTsStringAsXml
/// <summary>
/// Write the ITsString out.
/// </summary>
/// <param name="tssPara"></param>
/// <param name="cchIndent"></param>
/// <remarks>TODO: this maybe should go into a generic method somewhere?
/// Except that part of it is specific to XHTML output...</remarks>
private void WriteTsStringAsXml(ITsString tssPara, int cchIndent)
{
// First, build the indentation.
StringBuilder bldr = new StringBuilder();
while (cchIndent > 0)
{
bldr.Append(" ");
--cchIndent;
}
string sIndent = bldr.ToString();
bldr.Append(" ");
string sIndent2 = bldr.ToString();
m_writer.WriteLine("{0}<Str>", sIndent);
int crun = tssPara.RunCount;
string sField = null;
for (int irun = 0; irun < crun; ++irun)
{
TsRunInfo tri;
ITsTextProps ttpRun = tssPara.FetchRunInfo(irun, out tri);
int ctip = ttpRun.IntPropCount;
int ctsp = ttpRun.StrPropCount;
string sFieldRun = ttpRun.GetStrPropValue((int)FwTextPropType.ktptFieldName);
if (sFieldRun != sField)
{
if (!String.IsNullOrEmpty(sField))
m_writer.WriteLine("{0}</Field>", sIndent2);
if (!String.IsNullOrEmpty(sFieldRun))
m_writer.WriteLine("{0}<Field name=\"{1}\">", sIndent2, sFieldRun);
sField = sFieldRun;
sFieldRun = null;
}
bool fMarkItem;
int tpt;
string sVal;
bool fSkipText = false;
int nVar;
int nVal = ttpRun.GetIntPropValues((int)FwTextPropType.ktptMarkItem, out nVar);
if (nVal == (int)FwTextToggleVal.kttvForceOn && nVar == (int)FwTextPropVar.ktpvEnum)
{
m_writer.Write("{0}<Item><Run", sIndent2);
fMarkItem = true;
}
else
{
m_writer.Write("{0}<Run", sIndent2);
fMarkItem = false;
}
for (int itip = 0; itip < ctip; ++itip)
{
nVal = ttpRun.GetIntProp(itip, out tpt, out nVar);
if (tpt == (int)FwTextPropType.ktptWs || tpt == (int)FwTextPropType.ktptBaseWs)
{
if (nVal != 0)
{
ILgWritingSystem lgws = LgWritingSystem.CreateFromDBObject(m_cache, nVal);
m_writer.Write(" {0}=\"{1}\"",
tpt == (int)FwTextPropType.ktptWs ? "ws" : "wsBase", lgws.RFC4646bis);
}
}
else if (tpt != (int)FwTextPropType.ktptMarkItem)
{
WriteIntTextProp(m_writer, m_cache.LanguageWritingSystemFactoryAccessor, tpt, nVar, nVal);
}
}
string sRun = tssPara.get_RunText(irun);
Guid guidFootnote = Guid.Empty;
for (int itsp = 0; itsp < ctsp; ++itsp)
{
sVal = ttpRun.GetStrProp(itsp, out tpt);
Debug.Assert(tpt != (int)FwTextPropType.ktptBulNumFontInfo);
Debug.Assert(tpt != (int)FwTextPropType.ktptWsStyle);
WriteStrTextProp(m_writer, tpt, sVal);
if (sRun != null && sRun.Length == 1 && sRun[0] == StringUtils.kchObject)
{
Debug.Assert(tpt == (int)FwTextPropType.ktptObjData);
fSkipText = true;
if ((int)sVal[0] == (int)FwObjDataTypes.kodtOwnNameGuidHot)
guidFootnote = MiscUtils.GetGuidFromObjData(sVal.Substring(1));
}
}
m_writer.Write(">");
if (!fSkipText)
{
int cch = tri.ichLim - tri.ichMin;
if (cch > 0)
{
sRun = sRun.Normalize();
m_writer.Write(XmlUtils.MakeSafeXml(sRun));
}
}
if (fMarkItem)
m_writer.WriteLine("</Run></Item>");
//.........这里部分代码省略.........
示例5: VerifyRemovedFootnoteMarker
/// ------------------------------------------------------------------------------------
/// <summary>
/// Verifies that the footnote marker was deleted from the given TsString
/// </summary>
/// <param name="guidFootnote">The GUID footnote.</param>
/// <param name="tssContents">The TsString.</param>
/// ------------------------------------------------------------------------------------
private void VerifyRemovedFootnoteMarker(Guid guidFootnote, ITsString tssContents)
{
for (int i = 0; i < tssContents.RunCount; i++)
{
ITsTextProps tprops;
TsRunInfo runInfo;
tprops = tssContents.FetchRunInfo(i, out runInfo);
string strGuid =
tprops.GetStrPropValue((int)FwTextPropType.ktptObjData);
if (strGuid != null)
{
Guid guid = MiscUtils.GetGuidFromObjData(strGuid.Substring(1));
Assert.IsFalse(guid == guidFootnote, "Footnote marker not deleted");
}
}
}
示例6: WriteBtSegment
/// ------------------------------------------------------------------------------------
/// <summary>
/// Writes the ITsString of the back translation segment.
/// </summary>
/// <param name="tssSeg">ITsString containing the contents of the back translation.</param>
/// ------------------------------------------------------------------------------------
private void WriteBtSegment(ITsString tssSeg)
{
int crun = tssSeg.RunCount;
List<int> rgws;
List<OxesInfo> rgInfo = CollectRunInfo(tssSeg, out rgws);
for (int iRun = 0; iRun < crun; ++iRun)
{
TsRunInfo tri;
ITsTextProps ttp = tssSeg.FetchRunInfo(iRun, out tri);
string data = tssSeg.get_RunText(iRun);
string dataNFC = String.Empty;
if (!string.IsNullOrEmpty(data))
dataNFC = data.Normalize();
if (IsObjectReference(dataNFC))
ExportRefToEmbeddedObject(ttp);
else
WriteRunDataWithEmbeddedStyleInfo(rgInfo, rgws, iRun, m_cache.DefaultVernWs, dataNFC, true);
}
}
示例7: WriteVernSegment
/// ------------------------------------------------------------------------------------
/// <summary>
/// Writes the ITsString of the vernacular segment.
/// </summary>
/// <param name="tssSeg">ITsString containing the contents of the vernacular.</param>
/// <param name="isLabel">if set to <c>true</c> this segment is a label; <c>false</c>
/// otherwise.</param>
/// <returns></returns>
/// ------------------------------------------------------------------------------------
private void WriteVernSegment(ITsString tssSeg, bool isLabel)
{
int crun = tssSeg.RunCount;
List<int> rgws;
List<OxesInfo> rgInfo = CollectRunInfo(tssSeg, out rgws);
for (int iRun = 0; iRun < crun; ++iRun)
{
TsRunInfo tri;
ITsTextProps ttp = tssSeg.FetchRunInfo(iRun, out tri);
string data = tssSeg.get_RunText(iRun);
string dataNFC = string.IsNullOrEmpty(data) ? string.Empty : data.Normalize();
OxesInfo xinfo = rgInfo[iRun];
switch (xinfo.StyleName)
{
case ScrStyleNames.ChapterNumber:
CloseLabelTrIfNeeded();
ProcessChapterNumber(dataNFC, null, null, null);
break;
case ScrStyleNames.VerseNumber:
case ScrStyleNames.VerseNumberInNote:
case ScrStyleNames.VerseNumberAlternate:
CloseLabelTrIfNeeded();
ProcessVerseNumber(dataNFC, null, null, null,
xinfo.StyleName == ScrStyleNames.VerseNumberAlternate);
break;
default:
if (isLabel && dataNFC != StringUtils.kChHardLB.ToString()) // a hard line break should be its own segment
{
// dealing with whitespace after a label. Return for export with next run.
OpenLabelTrIfNeeded();
WriteRunDataWithEmbeddedStyleInfo(rgInfo, rgws, iRun, m_cache.DefaultVernWs, dataNFC);
}
else
{
// Exporting Scripture (non-label) text
Debug.Assert(!m_fInLabelTr);
OpenTrGroupIfNeeded(); // open the <trGroup> for the paragraph if it isn't already started
OpenTranslationElementIfNeeded(); // open the <tr> for the paragraph if it isn't already started
if (IsObjectReference(dataNFC))
ExportEmbeddedObject(ttp);
else
WriteRunDataWithEmbeddedStyleInfo(rgInfo, rgws, iRun, m_cache.DefaultVernWs, dataNFC);
}
break;
}
}
CloseLabelTrIfNeeded();
}
示例8: ReplaceString
/// ------------------------------------------------------------------------------------
/// <summary>
/// Replaces the string.
/// </summary>
/// <param name="tsbBuilder">The string builder for the text to be replaced.</param>
/// <param name="tssInput">The input string to be replaced.</param>
/// <param name="ichMinInput">The start in the input string.</param>
/// <param name="ichLimInput">The lim in the input string.</param>
/// <param name="tssReplace">The replacement text. This should come from VwPattern.ReplacementText,
/// NOT VwPattern.ReplaceWith. The former includes any ORCs that need to be saved from the input, as well as
/// properly handling $1, $2 etc. in regular expressions.</param>
/// <param name="delta">length difference between tssInput and tsbBuilder from previous
/// replacements.</param>
/// <param name="fEmptySearch"><c>true</c> if search text is empty (irun.e. we're searching
/// for a style or Writing System)</param>
/// <param name="fUseWs">if set to <c>true</c> use the writing system used in the
/// replace string of the Find/Replace dialog.</param>
/// <returns>Change in length of the string.</returns>
/// ------------------------------------------------------------------------------------
public static int ReplaceString(ITsStrBldr tsbBuilder, ITsString tssInput,
int ichMinInput, int ichLimInput, ITsString tssReplace, int delta, bool fEmptySearch,
bool fUseWs)
{
int initialLength = tsbBuilder.Length;
int replaceRunCount = tssReplace.RunCount;
// Determine whether to replace the sStyleName. We do this if any of the runs of
// the replacement string have the sStyleName set (to something other than
// Default Paragraph Characters).
bool fUseStyle = false;
bool fUseTags = false;
// ENHANCE (EberhardB): If we're not doing a RegEx search we could store these flags
// since they don't change.
TsRunInfo runInfo;
for (int irunReplace = 0; irunReplace < replaceRunCount; irunReplace++)
{
ITsTextProps textProps = tssReplace.FetchRunInfo(irunReplace, out runInfo);
string sStyleName =
textProps.GetStrPropValue((int)FwTextPropType.ktptNamedStyle);
if (sStyleName != null && sStyleName.Length > 0)
fUseStyle = true;
//string tags = textProps.GetStrPropValue((int)FwTextPropType.ktptTags);
//if (tags.Length > 0)
// fUseTags = true;
}
int iRunInput = tssInput.get_RunAt(ichMinInput);
ITsTextProps selProps = tssInput.get_Properties(iRunInput);
ITsPropsBldr propsBldr = selProps.GetBldr();
// Remove all tags that are anywhere in the Find-what string. But also include any
// other tags that are present in the first run of the found string. So the resulting
// replacement string will have any tags in the first char of the selection plus
// any specified replacement tags.
// Vector<StrUni> vstuTagsToRemove;
// GetTagsToRemove(m_qtssFindWhat, &fUseTags, vstuTagsToRemove);
// Vector<StrUni> vstuTagsToInclude;
// GetTagsToInclude(qtssSel, vstuTagsToRemove, vstuTagsToInclude);
// Make a string builder to accumulate the real replacement string.
// Copy the runs of the replacement string, adjusting the properties.
// Make a string builder to accumulate the real replacement string.
ITsStrBldr stringBldr = TsStrBldrClass.Create();
// Copy the runs of the replacement string, adjusting the properties.
for (int irun = 0; irun < replaceRunCount; irun++)
{
ITsTextProps ttpReplaceRun = tssReplace.FetchRunInfo(irun, out runInfo);
if (StringUtils.GetGuidFromRun(tssReplace, irun) != Guid.Empty)
{
// If the run was a footnote or picture ORC, then just use the run
// properties as they are.
}
else if (fUseWs || fUseStyle || fUseTags)
{
// Copy only writing system/old writing system, char sStyleName and/or
// tag info into the builder.
if (fUseWs)
{
int ttv, ws;
ws = ttpReplaceRun.GetIntPropValues((int)FwTextPropType.ktptWs, out ttv);
propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, ttv, ws);
}
if (fUseStyle)
{
string sStyleName = ttpReplaceRun.GetStrPropValue(
(int)FwTextPropType.ktptNamedStyle);
if (sStyleName == FwStyleSheet.kstrDefaultCharStyle)
propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
null);
else
propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
sStyleName);
}
//if (fUseTags)
//{
//.........这里部分代码省略.........
示例9: GetGuidFromRun
/// ------------------------------------------------------------------------------------
/// <summary>
/// Get a Guid from the given run in a structured text string.
/// </summary>
/// <param name="tss">given structured text string</param>
/// <param name="iRun">given run</param>
/// <param name="odt">object data type, 0 if no ORC guid located</param>
/// <param name="tri">run information</param>
/// <param name="ttp">text properties of the run (if incoming value is null and the
/// run is an object, this will be set to the run props)</param>
/// <param name="desiredOrcTypes">The desired ORC types, or null to return any type of
/// ORC</param>
/// <returns>
/// The GUID associated with the specified run of the tss, if any; otherwise Guid.Empty
/// </returns>
/// ------------------------------------------------------------------------------------
private static Guid GetGuidFromRun(ITsString tss, int iRun,
Set<FwObjDataTypes> desiredOrcTypes, out FwObjDataTypes odt, out TsRunInfo tri,
ref ITsTextProps ttp)
{
odt = 0;
tss.FetchRunInfo(iRun, out tri);
if (tri.ichLim - tri.ichMin == 1 &&
tss.get_RunText(iRun)[0] == kchObject)
{
// determine if single-character run contains an ORC
ttp = ttp ?? tss.get_Properties(iRun);
string sObjData = ttp.GetStrPropValue(
(int)FwTextPropType.ktptObjData);
if (sObjData != null)
{
odt = (FwObjDataTypes)Convert.ToByte(sObjData[0]);
// See if it's one of the types of objects we want.
if (desiredOrcTypes == null || desiredOrcTypes.Contains(odt))
{
// Get GUID for ORC
return MiscUtils.GetGuidFromObjData(sObjData.Substring(1));
}
}
}
return Guid.Empty;
}
示例10: WriteParagraphWithSegmentedBT
/// ------------------------------------------------------------------------------------
/// <summary>
/// Write the paragraph using a segmented back translation.
/// </summary>
/// <param name="tssPara"></param>
/// <param name="rgBTSeg"></param>
/// ------------------------------------------------------------------------------------
private void WriteParagraphWithSegmentedBT(ITsString tssPara, List<BTSegment> rgBTSeg)
{
int cseg = rgBTSeg.Count;
if (tssPara.Length > 0)
{
int crun = tssPara.RunCount;
List<int> rgws;
List<OxesInfo> rgInfo = CollectRunInfo(tssPara, out rgws);
int iseg = 0;
BTSegment bts = rgBTSeg[0];
for (int irun = 0; irun < crun; ++irun)
{
TsRunInfo tri;
ITsTextProps ttp = tssPara.FetchRunInfo(irun, out tri);
if (tri.ichMin >= bts.EndOffset)
{
++iseg;
if (iseg < cseg)
bts = rgBTSeg[iseg];
}
string data = tssPara.get_RunText(irun);
//#if DEBUG
// string sTRDebug = String.Format("Run[{0}] min={1,4}, lim={2,4}; data='{3}'", irun, tri.ichMin, tri.ichLim, data);
// Debug.WriteLine(sTRDebug);
//#endif
string dataNFC = String.Empty;
if (!String.IsNullOrEmpty(data))
dataNFC = data.Normalize();
OxesInfo xinfo = rgInfo[irun];
int ws = rgws[irun];
switch (xinfo.StyleName)
{
case ScrStyleNames.ChapterNumber:
//#if DEBUG
// WriteSegmentedBackTransDebugInfo(bts, iseg);
// Debug.Assert(bts.BeginOffset == tri.ichMin);
//#endif
ProcessChapterNumber(dataNFC, null, null, null);
break;
case ScrStyleNames.VerseNumber:
case ScrStyleNames.VerseNumberInNote:
case ScrStyleNames.VerseNumberAlternate:
//#if DEBUG
// WriteSegmentedBackTransDebugInfo(bts, iseg);
// Debug.Assert(bts.EndOffset == tri.ichLim);
//#endif
ProcessVerseNumber(dataNFC, null, null, null,
xinfo.StyleName == ScrStyleNames.VerseNumberAlternate);
break;
default:
if (IsObjectReference(dataNFC))
{
//#if DEBUG
// WriteSegmentedBackTransDebugInfo(bts, iseg);
// Debug.Assert(bts.EndOffset == tri.ichLim);
//#endif
Guid guidFootnote = GetFootnoteGuidIfAny(ttp);
m_sBTsWithFootnote = null;
if (m_fInTrGroup)
CloseTranslationElementIfNeededAndWriteBackTrans(bts, tri, guidFootnote);
ExportEmbeddedObject(ttp);
}
else
{
// Write all the segments that are fully contained in this run,
// or that end in this run.
while (iseg < cseg && bts.EndOffset <= tri.ichLim)
{
WritePartialRunWithBTSegment(tssPara, irun, ref tri, rgws,
rgInfo, iseg, bts);
++iseg;
if (iseg < cseg)
bts = rgBTSeg[iseg];
}
// Write any partial segment that starts (or continues) in this
// run, but finishes in a later run.
if (iseg < cseg && bts.BeginOffset < tri.ichLim)
{
WritePartialRunWithBTSegment(tssPara, irun, ref tri, rgws,
rgInfo, iseg, bts);
}
}
break;
}
}
}
else
{
for (int iseg = 0; iseg < cseg; ++iseg)
{
OpenTrGroupIfNeeded();
WriteSegmentedBackTrans(rgBTSeg[iseg], iseg);
}
//.........这里部分代码省略.........