MigraDoc.Rendering.ParagraphRenderer.GetNextTabStop C# (CSharp) Method

GetNextTabStop() private method

Gets the next tab stop following the current x position.
private GetNextTabStop ( ) : MigraDoc.DocumentObjectModel.TabStop
return MigraDoc.DocumentObjectModel.TabStop
    private TabStop GetNextTabStop()
    {
      ParagraphFormat format = this.paragraph.Format;
      TabStops tabStops = format.TabStops;
      XUnit lastPosition = 0;

      foreach (TabStop tabStop in tabStops)
      {
        if (tabStop.Position.Point > this.formattingArea.Width - this.RightIndent + Tolerance)
          break;

        if (tabStop.Position.Point + this.formattingArea.X > this.currentXPosition + Tolerance) // With Tolerance ...
          return tabStop;

        lastPosition = tabStop.Position.Point;
      }
      //Automatic tab stop: FirstLineIndent < 0 => automatic tab stop at LeftIndent.

      if (format.FirstLineIndent < 0 || (!format.IsNull("ListInfo") && format.ListInfo.NumberPosition < format.LeftIndent))
      {
        XUnit leftIndent = format.LeftIndent.Point;
        if (this.isFirstLine && this.currentXPosition < leftIndent + this.formattingArea.X)
          return new TabStop(leftIndent.Point);
      }
      XUnit defaultTabStop = "1.25cm";
      if (!this.paragraph.Document.IsNull("DefaultTabstop"))
        defaultTabStop = this.paragraph.Document.DefaultTabStop.Point;

      XUnit currTabPos = defaultTabStop;
      while (currTabPos + this.formattingArea.X <= this.formattingArea.Width - this.RightIndent)
      {
        if (currTabPos > lastPosition && currTabPos + this.formattingArea.X > this.currentXPosition + Tolerance)
          return new TabStop(currTabPos.Point);

        currTabPos += defaultTabStop;
      }
      return null;
    }
ParagraphRenderer