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.
The function it works. Thanks.
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.
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;
}
. . .
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;
}
Copy link to clipboard
Copied
The function it works. Thanks.