Hello,
Questions :
1] How can I observe a table insert operation ?
2] When we cut/paste existing table frame what is the order of page items hierarchy creation ? like create text frame first then insert table in it.
Currently I have implemented a code to observe page items creation (of text frames, rectangle frames etc. ) using IID_IHIERARCHY_DOCUMENT and kNewPageItemCmdBoss. This is working fine.
But when I tried to copy/cut-paste existing table frame I get the kNewPageItemCmdBoss for text frame pageitem which contains table frame. but I did not get notification for table creation.
What I want to do is, When user paste table frame I need to access to newly created table and get its model UID (using GetNthModelUID), just after paste process (i.e. during processing of kNewPageItemCmdBoss)
I have tried following code but, it gives me table model count as 0,
Note : following code is added in IID_IHIERARCHY_DOCUMENT protocol observer code (please refer PstLstDocObserver.cpp code snippet of InDesign SDK)
////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////// //
if((theChange == kNewPageItemCmdBoss))
{
int32 SelectedFrames = itemList.Length();
if (SelectedFrames > 0)
{
UIDRef frameUIDRef, childUIDRef, parentUIDRef;
UID frameModelUID, childUID, parentUID;
for(int i=0; i<SelectedFrames; i++)
{
frameUIDRef = itemList.GetRef(i);
IDataBase *db = frameUIDRef.GetDataBase();
///////////////////////////////////////////////////////////////////////////////
InterfacePtr<IHierarchy> itemHierarchy(frameUIDRef, IID_IHIERARCHY);
if(itemHierarchy)
{
if((itemHierarchy->GetChildCount()) > 0 )
{
childUID = itemHierarchy->GetChildUID(0);
childUIDRef = UIDRef(db, childUID);
if(childUIDRef)
{
int32 tableCount = 0;
UIDRef tableModelUIDRef;
InterfacePtr<IMultiColumnTextFrame> mcFrame(childUIDRef, UseDefaultIID());
if (mcFrame)
{
InterfacePtr<ITextModel> textModel(mcFrame->QueryTextModel(), UseDefaultIID());
if(textModel)
{
InterfacePtr<ITableModelList> tableList(textModel, UseDefaultIID());
if(tableList)
{
//Here I get the tableCount as 0
tableCount = tableList->GetModelCount();
}
InterfacePtr<ITableModel> table(tableList->QueryNthModel(tableCount-1));
if(table)
{
tableModelUIDRef = ::GetUIDRef(table);
frameModelUID = tableModelUIDRef.GetUID();
}
}
}
}
}
}
}
}
}
}
}
////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////// //
Note : using CS6/CC SDK
Thanks,
-Harsh