Hi…
The text range of an element includes the open element tag (but not the
end, I think), so when you add text at the tr.beg location, it’s
probably being added just *before* the footnote element. To move the
insertion point into the element do a .. tr.beg.offset++ .. before using
tr.beg. However, that will just get the new text into the footnote ..
you’ll have duplicated text, since you need to delete the old text (with
F_ApiDeleteText) before inserting the new. When you use F_ApiDeleteText,
be sure your tr doesn’t include the begin or end element tags. Also,
keep in mind that your tis is just the “FTI_String” items .. it’s
possible that your tr could include other objects like markers, so
you’ll need to use care when deleting text.
I think a better approach might be to just delete the leading spaces
from the text rather than deleting and replacing the whole string
(although, this could probably be argued one way or the other). Just
count the number of spaces at the beginning of the element (while
checking for other objects), then set the tr.beg.offset and the
tr.end.offset so it wraps just the leading spaces, and delete.
Good luck.
….scott
kutips2003 wrote:
>
> Hi!
>
> I have a program that loops through all the footnote elements in my
> document and tries to strip the leading spaces. (Example: ” This
> sentence” should change to “This sentence”) After stripping away the
> leading spaces the text in the footnote-element should be updated but
> im not quite sure how to do it….Here’s the code I’ve got so far:
>
> Function for getting the text (this function always get the ID of a
> Footnote element):
>
> StringT GetElementText(F_ObjHandleT docId, F_ObjHandleT elemId)
> {
> F_TextItemsT tis;
> StringT tstr, cp;
> IntT i;
>
> tstr = (StringT)F_Calloc(1, sizeof(UCharT), NO_DSE);
> tstr[0] = ‘’;
>
> tis = F_ApiGetText(docId, elemId, FTI_String);
>
> if (tis.len == 0) return NULL;
>
> for (i = 0; i cp = F_StrCopyString(tis.val[i].u.sdata);
> tstr = (StringT)F_Realloc(tstr, F_StrLen(tstr)+F_StrLen(cp)
> +2, NO_DSE);
> F_StrCat(tstr, cp);
> F_Free(cp);
> }
> F_ApiDeallocateTextItems(&tis);
>
> return tstr;
> }
>
> Here is the code where I try to modify and set the text (elemId is
> the foonote ID in this context):
>
> elemText = F_StrCopyString(GetElementText(docId, elemId));
> F_StrStripLeadingSpaces(elemText);
>
> tr = F_ApiGetTextRange(docId, elemId,
> FP_TextRange);
> F_ApiAddText(docId, &tr.beg, elemText);
>
> When i run it The text is inserted in the main flow and its not
> replacing the text in the footnote as it should. I know that I’m
> doing something wrong, but I dont know what to do…
>
> I’m not very familiar working with text and characters so I really
> would appreciate any help!!:-)
>
> In advance thanks!
>
>
Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/frame_dev/
Your email settings:
Individual Email | Traditional
To change settings online go to:
http://groups.yahoo.com/group/frame_dev/join
(Yahoo! ID required)
To change settings via email:
mailto:frame_dev-digest@yahoogroups.com
mailto:frame_dev-fullfeatured@yahoogroups.com
To unsubscribe from this group, send an email to:
frame_dev-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
























