SIL.FieldWorks.IText.InterlinDocForAnalysis.GetNextSegment C# (CSharp) Method

GetNextSegment() private method

Get the next segment with either a non-null annotation that is configured or a non-punctuation analysis. Also skip segments that are Scripture labels (like Chapter/Verse/Footnote numbers. It tries the next one after the SelectedOccurrence.Segment then tries the next paragraph, etc.. Use this version if the calling code already has the actual para/seg objects.
private GetNextSegment ( IStTxtPara currentPara, ISegment seg, bool upward, SIL.FieldWorks.FDO.DomainServices.AnalysisOccurrence &realAnalysis ) : ISegment
currentPara IStTxtPara
seg ISegment
upward bool true if moving up and left, false otherwise
realAnalysis SIL.FieldWorks.FDO.DomainServices.AnalysisOccurrence the first or last real analysis found in the next segment
return ISegment
		private ISegment GetNextSegment(IStTxtPara currentPara, ISegment seg, bool upward,
				out AnalysisOccurrence realAnalysis)
		{
			ISegment nextSeg = null;
			realAnalysis = null;
			var currentText = currentPara.Owner as IStText;
			Debug.Assert(currentText != null, "Paragraph not owned by a text.");
			var lines = LineChoices.m_specs as IEnumerable<InterlinLineSpec>;
			var delta = upward ? -1 : 1;
			var nextSegIndex = delta + seg.IndexInOwner;
			do
			{
				if (0 <= nextSegIndex && nextSegIndex < currentPara.SegmentsOS.Count)
				{
					nextSeg = currentPara.SegmentsOS[nextSegIndex];
					nextSegIndex += delta; // increment for next loop in case it doesn't check out
				}
				else
				{   // try the first (last) segment in the next (previous) paragraph
					int nextParaIndex = delta + currentPara.IndexInOwner;
					nextSeg = null;
					IStTxtPara nextPara = null;
					if (0 <= nextParaIndex && nextParaIndex < currentText.ParagraphsOS.Count)
					{   // try to find this paragraph's first (last) segment
						currentPara = (IStTxtPara)currentText.ParagraphsOS[nextParaIndex];
						nextSegIndex = upward ? currentPara.SegmentsOS.Count - 1 : 0;
					}
					else
					{	// no more paragraphs in this text
						break;
					}
				}
				realAnalysis = FindRealAnalysisInSegment(nextSeg, !upward);
			} while (nextSeg == null || (realAnalysis == null && !HasVisibleTranslationOrNote(nextSeg, lines)));
			return nextSeg;
		}

Same methods

InterlinDocForAnalysis::GetNextSegment ( int paraIndex, int segIndex, bool upward, SIL.FieldWorks.FDO.DomainServices.AnalysisOccurrence &realAnalysis ) : ISegment
InterlinDocForAnalysis