• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to filter tables from body pages only?

Participant ,
May 12, 2016 May 12, 2016

Copy link to clipboard

Copied

I have the following code to handle tables:

for (F_ObjHandleT tableId = F_ApiGetId(FV_SessionId, docId, FP_FirstTblInDoc); tableId; tableId = F_ApiGetId(docId, tableId, FP_NextTblInDoc))

{

  for (F_ObjHandleT rowId = F_ApiGetId(docId, tableId, FP_FirstRowInTbl); rowId; rowId = F_ApiGetId(docId, rowId, FP_NextRowInTbl))

  {

    for (F_ObjHandleT cellId = F_ApiGetId(docId, rowId, FP_FirstCellInRow); cellId; cellId = F_ApiGetId(docId, cellId, FP_NextCellInRow))

    {

       ...

    }

  }

}

How can I get only tables that exist in body pages. I want to filter these only..

Please help.

TOPICS
Scripting

Views

397

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , May 13, 2016 May 13, 2016

The function it works. Thanks.

Votes

Translate

Translate
Participant ,
May 12, 2016 May 12, 2016

Copy link to clipboard

Copied

I have the following function from FDK examples for checking if the page type of a table is Body Page but is not working:

IntT GetPageType (F_ObjHandleT docId, F_ObjHandleT objectId)

  {

    F_ObjHandleT oldParentId;

    F_ObjHandleT parentId = objectId;

    IntT parentType = FO_TextFrame;

    while (parentType != FO_BodyPage &&

           parentType != FO_MasterPage &&

           parentType != FO_RefPage &&

           parentType != FO_HiddenPage)

    {

      oldParentId = parentId;

      parentId = F_ApiGetId(docId, parentId, FP_FrameParent);

      if (!parentId)

      {

        parentId = F_ApiGetId(docId, oldParentId, FP_PageFramePage);

        if (!parentId)

        {

          break;

        }

      }

    parentType = F_ApiGetObjectType(docId, parentId);

  }

  return parentType;

}

So I use it like this:

if (FO_BodyPage != GetPageType(docId, tableId))

  {

  continue;

  }

However this method returns the default initialized value FO_TextFrame.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
May 12, 2016 May 12, 2016

Copy link to clipboard

Copied

Hi Ch,

The problem is that this function requires an object that is already a frame object. A table object has no FP_FrameParent property, so it is not equipped to handle a table object alone. You have to get the parent frame of the table object first, then send it to the function. Or, you could just build it into the function. Here is an example using the existing function:

F_TextLocT tl;

F_PropValT prop;

F_ObjHandleT frameId;

. . .

tl = F_ApiGetTextLoc(docId, tableId, FP_TextLoc);

prop = F_ApiGetTextPropVal(docId, &tl, FP_InTextFrame);

frameId = (F_ObjHandleT)prop.propVal.u.ival;

if (FO_BodyPage != GetPageType(docId, frameId))

{

  continue;

}

. . .

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 12, 2016 May 12, 2016

Copy link to clipboard

Copied

I have written the following function.

Could you please review it?

IntT GetPageType (F_ObjHandleT docId, F_ObjHandleT objectId)

  {

       F_ObjHandleT frameId = 0;

       while (objectId)

       {

            frameId = objectId;

            IntT objType = F_ApiGetObjectType(docId, objectId);

            switch (objType)

            {

                 case FO_SubCol:

                      objectId = F_ApiGetId(docId, objectId, FP_ParentTextFrame);

                      break;

                 case FO_Tbl:

                 {

                      F_ObjHandleT rowId = F_ApiGetId(docId, objectId, FP_FirstRowInTbl);

                      F_ObjHandleT cellId = F_ApiGetId(docId, rowId, FP_FirstCellInRow);

                      objectId = cellId;

                 }

                 break;

                 /* handle FO_Cell case */

                 /* handle FO_Pgf case */

                 /* handle FO_AFrame case */

                 case FO_Cell:

                 case FO_Pgf:

                 case FO_AFrame:

                      objectId = F_ApiGetId(docId, objectId, FP_InTextFrame);

                      break;

                 /* handle graphic object cases */

                 case FO_TextLine:

                 case FO_TextFrame:

                 case FO_UnanchoredFrame:

                 case FO_Arc:

                 case FO_Ellipse:

                 case FO_Group:

                 case FO_Inset:

                 case FO_Line:

                 case FO_Math:

                 case FO_Polygon:

                 case FO_Polyline:

                 case FO_Rectangle:

                 case FO_RoundRect:

                      objectId = F_ApiGetId(docId, objectId, FP_FrameParent);

                      break;

                 /* prevents loop if unknown object type is found. */

                 default:

                      objectId = 0;

                      break;

                 }

            }

       if (frameId)

       {

            /* use FP_PageFramePage to get the page identifier of the object. */

            F_ObjHandleT pageId = F_ApiGetId(docId, frameId, FP_PageFramePage);

            return F_ApiGetObjectType(docId, pageId);

       }

     return -1;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 13, 2016 May 13, 2016

Copy link to clipboard

Copied

LATEST

The function it works. Thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines