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

ProbeAfterDecimalAlignedTab() private method

Probes the paragraph elements after a right aligned tab stop and returns the vertical text position to start at.
private ProbeAfterDecimalAlignedTab ( PdfSharp.Drawing.XUnit tabStopPosition, bool &notFitting ) : PdfSharp.Drawing.XUnit
tabStopPosition PdfSharp.Drawing.XUnit Position of the tab to probe.
notFitting bool Out parameter determining whether the tab causes a line break.
return PdfSharp.Drawing.XUnit
    XUnit ProbeAfterDecimalAlignedTab(XUnit tabStopPosition, out bool notFitting)
    {
      notFitting = false;
      ParagraphIterator savedLeaf = this.currentLeaf;

      //Extra for auto tab after list symbol
      if (IsTab(this.currentLeaf.Current))
        this.currentLeaf = this.currentLeaf.GetNextLeaf();
      if (this.currentLeaf == null)
      {
        this.currentLeaf = savedLeaf;
        return this.currentXPosition + tabStopPosition;
      }
      VerticalLineInfo newVerticalInfo = CalcCurrentVerticalInfo();
      Rectangle fittingRect = this.formattingArea.GetFittingRect(this.currentYPosition, newVerticalInfo.height);
      if (fittingRect == null)
      {
        notFitting = true;
        this.currentLeaf = savedLeaf;
        return this.currentXPosition;
      }

      if (IsPlainText(this.currentLeaf.Current))
      {
        Text text = (Text)this.currentLeaf.Current;
        string word = text.Content;
        int lastIndex = text.Content.LastIndexOfAny(new char[] { ',', '.' });
        if (lastIndex > 0)
          word = word.Substring(0, lastIndex);

        XUnit wordLength = MeasureString(word);
        notFitting = this.currentXPosition + wordLength >= formattingArea.X + formattingArea.Width + Tolerance;
        if (!notFitting)
          return this.formattingArea.X + tabStopPosition - wordLength;

        else
          return this.currentXPosition;
      }
      this.currentLeaf = savedLeaf;
      return ProbeAfterRightAlignedTab(tabStopPosition, out notFitting);
    }
ParagraphRenderer