How can I determine the number of tabs (versus indentation) that precede text for a paragraph?

I have attached a word document and would like to determine the number of tabs that precede the text for a paragraph.
I can already determine the level of indentation (one indentation seems to be 36.0, two seems to be 72.0).

The attached document contains examples of both (I used tabs to ‘indent’ the text and I used indentation to indent it). I wrote code to print left indent and right indent of paragraph format. Any thoughts on how I can determine;

  1. number of tabs (e.g. ‘This is tabbed once’ would indicate one tab, ‘This is tabbed twice’ would indicate 2 tabs, others are indicate 0 tabs). Is it something in Runs or Run?

iterate over every paragraph in Document…

if (aParagraph != null)
{
    ParagraphFormat paragraphFormat = aParagraph.getParagraphFormat();
    if (paragraphFormat != null)
    {
        double leftIndent = paragraphFormat.getLeftIndent();
        double rightIndent = paragraphFormat.getRightIndent();

        System.out.println("paragraph left indent is " + leftIndent);
        System.out.println("paragraph right indent is " + rightIndent);
    }
}

produces(the paragraph text is printed subsequently by caller);


Paragraph text This is not indented or tabbed
paragraph left indent is 0.0
paragraph right indent is 0.0
EndParagraph

Paragraph text This is indented once
paragraph left indent is 36.0
paragraph right indent is 0.0
EndParagraph

Paragraph text This is indented twice
paragraph left indent is 72.0
paragraph right indent is 0.0
EndParagraph

Paragraph text
paragraph left indent is 0.0
paragraph right indent is 0.0
EndParagraph

Paragraph text This is not indented or tabbed
paragraph left indent is 0.0
paragraph right indent is 0.0
EndParagraph

Paragraph text This is tabbed once
paragraph left indent is 0.0
paragraph right indent is 0.0
EndParagraph

Paragraph text This is tabbed twice.
paragraph left indent is 0.0
paragraph right indent is 0.0
EndParagraph

By the way this produces 0 for me as well;

TabStops tabStops = paragraphFormat.getTabStops();
System.out.println("number of tab stops is " + tabStops.getCount());

Hi
Thanks for your inquiry. I think you can try to determine count of tabs at the beginning of the paragraph. You can get text of paragraph using the following code:

string text = paragraph.ToTxt();

This will return the following string.
"\t\tThis is tabbed twice.\r\n"
You should just calculate number of “\t” characters at the beginning of string.
Best regards.