πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.framemaker.sgml
3 messages
3 total messages Started by Stanislav_Kurik Wed, 16 Jul 2008 08:06
F_ApiGetTextForRange()
#852
Author: Stanislav_Kurik
Date: Wed, 16 Jul 2008 08:06
9 lines
1288 bytes
Hello to all,

I encounter some weird behaviour of this function when called in structured document. It suffices to create new document based on "Report, plain" structured template and delete all text except the first line, "ReportTitle".

Then if I call F_ApiGetTextForRange() with text range having offset 0 and length 11 ( = the length of text "ReportTitle"), I get FTI_String containing only "ReportTit". If I adjust the text range to have length 13 (I just tried it), it gives me correctly "ReportTitle". It works perfectly in unstructured documents, however it seems to have some problems in structured environment.

Is there any way how to make it work for structured documents as well?

Thank you.
Re: F_ApiGetTextForRange()
#853
Author: Russ Ward
Date: Wed, 16 Jul 2008 12:30
29 lines
2568 bytes
Hi Stanislav,

This is indeed a quirk with structured documents. What happens is that the element boundaries (tags or brackets) are included in the text range, even if they are hidden. In your case, when you delete everything except the title element, there are two element boundaries to the left and right of the title paragraph (show the boundaries to see them). So, the actual offset of the paragraph text is 2-13, not 0-11 as in an unstructured document.

I do not know any way to prevent this behavior. In my work with structured documents, I have avoided this problem by working strictly with element ranges, only converting to text ranges when necessary. For example, if I want to select the contents of your title element, I might do something like the following:

er.beg.parentId = er.end.parentId = F_ApiGetId(docId, elemId, FP_ParentElement);

er.beg.childId = elemId;

er.end.childId = F_ApiGetId(docId, elemId, FP_NextSiblingElement);

if(!er.end.childId) er.end.childId = 0;

er.beg.offset = er.end.offset = 0;

...where "er" is an F_ElementRangeT structure. Then, if I need to convert it to an F_TextRangeT, I can do something like:

F_ApiSetElementRange(docId, elemId, FP_ElementSelection, &er);
tr = F_ApiGetTextRange(FV_SessionId, docId, FP_TextSelection);

...or, you can do it without actually selecting the text with something like:

tr.beg = F_ApiElementLocToTextLoc(docId, &er.beg);
tr.end = F_ApiElementLocToTextLoc(docId, &er.end);

Maybe this isn't the best solution for you, and maybe there is an easier way. In any case, I have found it best to always use element ranges to navigate and set text ranges while working in a structured doc. If there truly is no way to avoid the inclusion of element boundaries in text range offsets, it seems a very difficult proposition indeed to guess where the boundaries will be. Working with element ranges first, you can avoid that guesswork.

Russ
Re: F_ApiGetTextForRange()
#854
Author: Michael_Mueller-Hillebrand
Date: Thu, 17 Jul 2008 17:00
5 lines
1229 bytes
In addition to Russ' comments: If your EDD formatting rules define a prefix or a suffix, the string length of those also has to be considered.

If you need a text selection in a structured document it would be best to look at the TextList (that's the name in FrameScript programming) of the first paragraph of an element. Only strings that start after the PrefixEnd and end before the SuffixBegin can be selected.

- Michael MοΏ½ller-Hillebrand
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads