Tab stops not represented in headers/footers?

I'm finding that when processing headers and footers from Microsoft Word documents via Aspose.Words, the tab stops (usually at the left, center, and right) are not being represented in the Aspose document model. Is this a limitation or possibly a bug?

Thanks very much,

Steve

Please attach the document showing the problem, or let me know how I can reproduce and see the problem on my side.

Best regards,

Thanks for your quick response. Here are some steps to reproduce the problem:

Open the attached document in Microsoft Word and double-click the header area where it says "Hi there". You'll see in the Ruler that there is a center-aligned tabstop at 3 inches and a right-aligned tabstop at 6 inches.

In Microsoft DevStudio, open the DocumentExplorer sample project.
Start debugging.
In DocumentExplorer, open the document that I have attached here.
In the left pane, expand the Section node, then expand the HeaderFooter - HeaderPrimary node, so you see the Paragraph node within it.
Put a breakpoint in Item.cs in the Node getter (line 37)
In the left hand pane click the Paragraph node. The debugger should stop at that breakpoint, and the current mNode is a Paragraph (the paragraph within the header).
Add the following watch expression:
((Paragraph)mNode).ParagraphFormat.TabStops

You'll see that the TabStops Count value is zero.

Thanks,

Steve

Aha, I think I see the problem. Apparently Word (or Aspose.Words?) has a notion of default tabstops in headers at the center and the right edge. If the tabstops are left untouched by the user, they don't get exposed in the document model. But if the user changes or adds a tabstop, they all do get exposed in the document model. I found this by changing the center tabstop in the header so it's positioned at 2 inches, and seeing that the tabstops in the header are now included in the Aspose document model.

Is this indeed Microsoft Word behavior that I need to account for?

Thanks,

Steve

Please note, that the actual formatting of the paragraph (and tab stops are part of paragraph format) is formed from formatting defined in paragraph itself (Paragraph.ParagraphFormat) and also the style of the paragraph (Paragraph.ParagraphFormat.Style.ParagraphFormat). In your case the tabs in questions are defined on style level rather than paragraph level. You can get them by using Paragraph.ParagraphFormat.Style.ParagraphFormat.TabStops.

Hope that answers your question,

Thanks, Vladimir. That certainly helps.

I had assumed that formats defined in styles always "show through" in the Paragraph.ParagraphFormat instance as well. For example, that seems to be the case for Heading styles.

Are there other cases where I should check Paragraph.ParagraphFormat.Style.ParagraphFormat in addition to Paragraph.ParagraphFormat? And which one takes precedence?

Thanks,

Steve

The immediate formatting of the paragraph takes precedence over style formatting of course. Exactly as it is in MS Word.

Regards,

Thanks for the answer regarding precedence. The other question was, in what cases do I need to also examine Style.ParagraphFormat for a style-applied value (vs. just examining Paragraph.ParagraphFormat)?

Currently I understand I need to examine Paragraph.ParagraphFormat.Style.ParagraphFormat.TabsStops when Paragraph.ParagraphFormat.TabStops.Count == 0. Do I also need to check when LeftIndent == 0? When SpaceAfter == 0? etc.

Thanks,

Steve

I have checked our source and it seems that only TabStops and Shading are taken immediately from paragraph. All other paragraph formatting properties are expanded to take into account the style formatting.

Best regards,

Thanks, Vladimir, that’s just what I needed to know. Your responsiveness is excellent.