status_t PDocument::Archive(BMessage* archive, bool deep) const { TRACE(); BLooper::Archive(archive, deep); Indexer *indexer = new Indexer((PDocument *)this); int32 i = 0; BMessage *commandManage = new BMessage(); BMessage *tmpNode = NULL; BMessage *allNodesMessage = new BMessage(); BMessage *allConnectionsMessage = new BMessage(); BMessage *selectedMessage = new BMessage(); archive->AddMessage("PDocument::documentSetting",documentSetting); //save all Nodes for (i=0; i<allNodes->CountItems();i++) { tmpNode=(BMessage *)allNodes->ItemAt(i); allNodesMessage->AddMessage("node",indexer->IndexNode(tmpNode)); } archive->AddMessage("PDocument::allNodes",allNodesMessage); //save all Connections for (i=0; i<allConnections->CountItems();i++) { tmpNode=(BMessage *)allConnections->ItemAt(i); allConnectionsMessage->AddMessage("node",indexer->IndexConnection(tmpNode)); } archive->AddMessage("PDocument::allConnections",allConnectionsMessage); //save the selected List for (i=0; i<selected->CountItems();i++) { selectedMessage->AddPointer("node",selected->ItemAt(i)); } archive->AddMessage("PDocument::selected",selectedMessage); //save all Command related Stuff like Undo/Makor // commandManager->Archive(commandManage); for (i=0;i<(commandManager->GetUndoList())->CountItems();i++) { commandManage->AddMessage("undo",indexer->IndexMacroCommand((BMessage *)(commandManager->GetUndoList())->ItemAt(i))); } for (i=0;i<(commandManager->GetMacroList())->CountItems();i++) { commandManage->AddMessage("macro",(BMessage *)(commandManager->GetMacroList())->ItemAt(i)); } commandManage->AddInt32("undoStatus",commandManager->GetUndoIndex()); archive->AddMessage("PDocument::commandManager", commandManage); delete indexer; delete commandManage; //delete tmpNode; delete allNodesMessage; delete allConnectionsMessage; delete selectedMessage; return B_OK; }
void PDocument::PushToStream(BPositionIO *pushTo) { Indexer *indexer = new Indexer((PDocument *)this); BMessage *tmpNode = NULL; BMessage *commandManage = new BMessage(); BMessage *selectedMessage = new BMessage(); int i = 0; //**security check if the passed BPositionIO ok is documentSetting->Flatten(pushTo); for (i=0; i<allNodes->CountItems();i++) { tmpNode=(BMessage *)allNodes->ItemAt(i); BMessage *indexed = indexer->IndexNode(tmpNode); indexed->Flatten(pushTo); } for (i=0; i<allConnections->CountItems();i++) { tmpNode=(BMessage *)allConnections->ItemAt(i); BMessage *indexed = indexer->IndexConnection(tmpNode); indexed->Flatten(pushTo); } for (i=0; i<selected->CountItems();i++) { selectedMessage->AddPointer("node",selected->ItemAt(i)); } selectedMessage->Flatten(pushTo); for (i=0;i<(commandManager->GetMacroList())->CountItems();i++) { BMessage *macro =(BMessage *)(commandManager->GetMacroList()->ItemAt(i)); macro->Flatten(pushTo); } for (i=0;i<(commandManager->GetUndoList())->CountItems();i++) { BMessage *indexed = indexer->IndexMacroCommand((BMessage *)(commandManager->GetUndoList()->ItemAt(i))); indexed->Flatten(pushTo); } //**add the UndoIndex commandManage->AddInt32("undoStatus",commandManager->GetUndoIndex()); //add the commandManage commandManage->Flatten(pushTo); delete indexer; delete commandManage; delete selectedMessage; }