Skip to main content
April 15, 2009
Answered

How to get a paragraph that contains selected string in FDK?

  • April 15, 2009
  • 1 reply
  • 660 views

Hello,

I am writing a program that extract a content of paragraph that contains a selection string. This program is running in menu item interaction. When user make a click on menu item. The processes as following:
1. Find a string on a document, e.g.:  F_ApiFind("ABC").
2. The API F_ApiFind("ABC") return structure F_TextRangeT.
3. The string "ABC" was highlighted on document.

Here is my question: 
How can I write a code to locate a paragraph ID object ( pgfId ) that contains string ( or object ) "ABC"?.
Since object "ABC" belongs to the current paragraph, how can I get paragraph ID ( pgfId) and then get the content of whole paragraph
without looping thru FP_FirstFlowInDoc, FP_FirstTextFrameInFlow, FP_FirstPgf, and FP_NextPgfInFlow.

Thank you very much for you help,

Thai Nguyen

    This topic has been closed for replies.
    Correct answer Russ Ward

    Hi Thai,

    The paragraph ID is returned as part of the F_TextRangeT structure, as the "objId" member. Let's say you have:

    F_TextRangeT tr;

    ...then:

    tr = F_ApiFind( ... );

    Upon a successful find action, "tr" will contain the pgfId of the paragraph. I'm assuming that you are looking for a string that is fully contained within a paragraph, in which case both of the following will contain the paragraph ID:

    tr.beg.objId

    tr.end objId

    If you want to retrieve all the paragraph text after the find action, you might do something like: (Warning, incomplete code!)

    F_TextItemsT ti;

    F_TextRangeT tr;

    F_ObjHandleT docId;

    ...

    tr = F_ApiFind( ... );

    tr.beg.offset = 0;

    tr.end.offset = FV_OBJ_END_OFFSET;

    ti = F_ApiGetTextForRange(docId, &tr, FTI_String);

    ...after which the paragraph text will be contained in the ti TextItems structure. Navigating this structure can be tricky and I'll forgo any discussion about that for now unless you need further help. There is good information in the Developer's Reference about using it.

    Russ

    1 reply

    Russ WardCorrect answer
    Legend
    April 15, 2009

    Hi Thai,

    The paragraph ID is returned as part of the F_TextRangeT structure, as the "objId" member. Let's say you have:

    F_TextRangeT tr;

    ...then:

    tr = F_ApiFind( ... );

    Upon a successful find action, "tr" will contain the pgfId of the paragraph. I'm assuming that you are looking for a string that is fully contained within a paragraph, in which case both of the following will contain the paragraph ID:

    tr.beg.objId

    tr.end objId

    If you want to retrieve all the paragraph text after the find action, you might do something like: (Warning, incomplete code!)

    F_TextItemsT ti;

    F_TextRangeT tr;

    F_ObjHandleT docId;

    ...

    tr = F_ApiFind( ... );

    tr.beg.offset = 0;

    tr.end.offset = FV_OBJ_END_OFFSET;

    ti = F_ApiGetTextForRange(docId, &tr, FTI_String);

    ...after which the paragraph text will be contained in the ti TextItems structure. Navigating this structure can be tricky and I'll forgo any discussion about that for now unless you need further help. There is good information in the Developer's Reference about using it.

    Russ

    April 15, 2009

    Hi Russ,

    You are the best. I got what I looked for.

    Thank you again.

    Thai Nguyen