You'd have to get the stories in the document, iterate through them, and get all the tables on each story. Each story has a list of story threads. Each table is a story thread (though not every story thread is a table). So go through all the threads in a story, check if it's a table, and if it add it to the list. Read the API docs for more info on story models, story threads, and tables. Here's sample code: /**
* @brief Retrieves all table models in the specified document.
*
* This function iterates through all user-accessible stories in the given document
* and collects the UID references of all table models found within those stories.
*
* @Param in_DocUIDRef The UID reference of the document to search for table models.
* @Param out_TableUIDs A vector to store the UID references of the found table models.
* @Return ErrorCode Returns kSuccess if all table models are successfully retrieved, otherwise kFailure.
*/
ErrorCode GetAllTableModelsOnDocument(const UIDRef& in_DocUIDRef, UIDRefVector& out_TableUIDs) const
{
ErrorCode status = kFailure;
do {
// Get the story list interface for the document
InterfacePtr<IStoryList> storyList(in_DocUIDRef, UseDefaultIID());
if (storyList == nil)
{
ASSERT(storyList);
break;
}
// Get the database associated with the document
IDataBase* db = in_DocUIDRef.GetDataBase();
if (db == nil)
{
ASSERT(db);
break;
}
// Get the number of user-accessible stories in the document
const int32 numStories = storyList->GetUserAccessibleStoryCount();
status = kSuccess;
// Iterate through each story and collect table models
for (int32 index = 0; index < numStories; ++index)
{
UIDRef curStory(storyList->GetNthUserAccessibleStoryUID(index));
// Retrieve all tables in the current story
if (GetAllTablesInStory(curStory, out_TableUIDs) != kSuccess)
{
ASSERT_FAIL("Could not get tables from story!");
status = kFailure;
break;
}
}
} while (kFalse);
return status;
}
/**
* @brief Retrieves all table models in the specified text story.
*
* This function iterates through the text story threads in the given text story
* and collects the UID references of all table models found within those threads.
*
* @Param in_TextStoryRef The UID reference of the text story to search for table models.
* @Param out_TableModelUIDs A vector to store the UID references of the found table models.
* @Return ErrorCode Returns kSuccess if all table models are successfully retrieved, otherwise kFailure.
*/
ErrorCode GetAllTablesInStory(const UIDRef& in_TextStoryRef, UIDRefVector& out_TableModelUIDs) const
{
ErrorCode status = kFailure;
do {
// Get the database associated with the text story
IDataBase* db = in_TextStoryRef.GetDataBase();
if (db == nil)
{
ASSERT(db);
break;
}
// Get the story thread hierarchy interface for the text story
InterfacePtr<ITextStoryThreadDictHier> storyThreadHier(in_TextStoryRef, UseDefaultIID());
if (storyThreadHier == nil)
{
ASSERT(storyThreadHier);
break;
}
UID nextUID = in_TextStoryRef.GetUID();
// Iterate through the story threads and collect table models
do {
if (nextUID != kInvalidUID)
{
// Get the table model interface for the current UID
InterfacePtr<ITableModel> tableModel(db, nextUID, UseDefaultIID());
// If it's a table model, add it to the output vector
if (tableModel != nil)
{
out_TableModelUIDs.push_back(UIDRef(db, nextUID));
}
}
nextUID = storyThreadHier->NextUID(nextUID);
} while (nextUID != kInvalidUID);
status = kSuccess;
} while (kFalse);
return status;
}
... View more