When the anchor point of an image/shape is displayed as a character, it appears as content under a certain heading. I want the user to know which heading the image/shape is under when they click on it. Also, when a user selects an area, if the selected content includes images/shapes, it should be possible to identify which heading they are under. Thank you.
One possible way to archive this is to get the anchor of the image, and then check if the anchor paragraph is a heading. If not, then go to the previous paragraph, and check again, till you either reach the start of the document (gotoPreviousParagraph() returns false) or you find a paragraph which is a heading.
Note that if your image is anchored in its own XText (like a table cell), then likely you’ll need to travel with the user cursor, otherwise you won’t be able to find the heading outside the table cell when the image is inside a table cell.