lo_DocState *state;
LO_Element* lo_GetFirstCellInColumnOrRow(MWContext *pContext, LO_Element *pElement, int32 x, int32 y, XP_Bool bGetColumn, LO_Element **ppLastCellInTable){	LO_Element *pFirstCell = NULL;	LO_Element *pLastCellInTable = NULL;	LO_Element *tptr = NULL;    int32 closest = 0;    lo_DocState *state;    if( pElement->type == LO_TABLE )    {        /* Start at first element after the table */        tptr = pElement->lo_any.next;    } else {            if( pElement->type == LO_CELL )        {            /* Element is a cell */            tptr = pElement;        } else {            /* Get parent cell of supplied element */            tptr = (LO_Element*)lo_GetParentCell(pContext, pElement);        }        if( !tptr )            return NULL;            /* Search back until we are at first cell in table */        while ( (tptr->lo_any.prev)->type != LO_TABLE )        {            tptr = tptr->lo_any.prev;        }    }        /* Scan all cells to find first and last */    do {        if( tptr->type == LO_CELL )        {            if( bGetColumn && tptr->lo_any.x <= x &&                tptr->lo_any.x > closest  )            {                /* We found a cell candidate */                closest = tptr->lo_any.x;                pFirstCell = tptr;            } else if( !bGetColumn && tptr->lo_any.y <= y &&                       tptr->lo_any.y > closest )            {                closest = tptr->lo_any.y;                pFirstCell = tptr;            }            pLastCellInTable = tptr;        }        tptr = tptr->lo_any.next;       /* Table ends at linefeed (top level) or null element (nested table) */    } while (tptr && tptr->type != LO_LINEFEED );     /* Return last cell element encountered */    if( ppLastCellInTable )        *ppLastCellInTable = pLastCellInTable;    return pFirstCell;    }