Suppose you have a document and have a picture in it. Under the picture there's a hint/title/description "Picure 2.3. A snow falling in the UK."
As I found out, this text can be obtained trough FrameAnchor
from your suggestion.
var imgHintList = doc.GetTextForRange(doc.TextSelection, Constants.FTI_FrameAnchor);
var imgHint = imgHintList[imgIndex].obj.TextLoc;
This works good. The part that I'm working on now is how to limit the search with only this Hint. Th algorythm is:
1. Search a word in a hint.
2. Replace it with another.
3. Start the search again, but starting from the end of our replacement.
4. Repeat while we have any finds.
For now, I can search and replace all info, but I can't stop when the search reaches the end of the Hint. Here's what I have:
findParam = AllocatePropVals (1);
findParam[0].propIdent.num = Constants.FS_FindText;
findParam[0].propVal.valType = Constants.FT_String; //.... some code
var imgHintList = doc.GetTextForRange(doc.TextSelection, Constants.FTI_FrameAnchor);for(var imgIndex = 0; imgIndex < imgHintList.length; imgIndex++){ var imgHint = imgHintList[imgIndex].obj.TextLoc; findParam[0].propVal.sval = strings[i][1]; foundText = doc.Find (imgHint, findParam); testText = doc.GetTextForRange (foundText, Constants.FTI_String); while(testText.length > 0){// here, probably, should be an extra stop condition .... doc.DeleteText(foundText); doc.AddText(foundText.beg, strings[i][2]); //starting the search from the end of the replaced block imgHint.offset = foundText.end.offset; foundText = doc.Find (imgHint, findParam); testText = doc.GetTextForRange (foundText, Constants.FTI_String); }}
Any ideas?