In measured document of Word-inspired project we have to use IDocument interface. How do I add a new paragraph to document and set its text alignment without having to know the alignment of previous paragraph? ChangeParagraphTextAlignment method behaves differently based on the current paragraph alignment. If current is Center, and we "change" to Center the result is Left. If current is Left and we "change" to Left the result is Justify. The method really really wants to change the alignment.
So in my code I do InsertParagraph(), not knowing how the previous paragraph was aligned. How to center-align this new paragraph?
I suppose I can use ClearAllFormatting, but now here's the followup question. How to reuse all other paragraph properties from previous paragraph, like indentation and spacing, and just set text alignment to Center?
I could make two calls, "change" to Justify, and then to Center. Whatever was the starting state we should reach Center, but this looks like a hack to me. In case we want to set the alignment to Left we would have to make three calls to make sure we actually reach Left state (for instance "change" to Right, then Justify, then Left).I feel this should not be so complicated.