+// t oredirect all calls to the root document
+#define ROOT_DOC std::dynamic_pointer_cast<Model_Document>(moduleDocument())
+
+bool Model_Session::load(const char* theFileName)
+{
+ bool aRes = ROOT_DOC->load(theFileName, ROOT_DOC);
+ return aRes;
+}
+
+bool Model_Session::save(const char* theFileName, std::list<std::string>& theResults)
+{
+ return ROOT_DOC->save(theFileName, theResults);
+}
+
+void Model_Session::closeAll()
+{
+ Model_Application::getApplication()->deleteAllDocuments();
+}
+
+void Model_Session::startOperation(const std::string& theId, const bool theAttachedToNested)
+{
+ myOperationAttachedToNext = theAttachedToNested;
+ ROOT_DOC->startOperation();
+ ROOT_DOC->operationId(theId);
+ static std::shared_ptr<Events_Message> aStartedMsg
+ (new Events_Message(Events_Loop::eventByName("StartOperation")));
+ Events_Loop::loop()->send(aStartedMsg);
+ // remove all useless documents that has been closed: on start of operation undo/redo is cleared
+ std::list<std::shared_ptr<ModelAPI_Document> > aUsedDocs = allOpenedDocuments();
+ Model_Application::getApplication()->removeUselessDocuments(aUsedDocs);
+}
+
+void Model_Session::finishOperation()
+{
+ setCheckTransactions(false);
+ ROOT_DOC->finishOperation();
+ if (myOperationAttachedToNext) { // twice, with nested
+ ROOT_DOC->finishOperation();
+ myOperationAttachedToNext = false;
+ }
+ setCheckTransactions(true);
+}
+
+void Model_Session::abortOperation()
+{
+ setCheckTransactions(false);
+ ROOT_DOC->abortOperation();
+ if (myOperationAttachedToNext) { // twice, with nested
+ ROOT_DOC->abortOperation();
+ myOperationAttachedToNext = false;
+ }
+ setCheckTransactions(true);
+ // here the update mechanism may work after abort, so, supress the warnings about
+ // modifications outside of the transactions
+ bool aWasCheck = myCheckTransactions;
+ myCheckTransactions = false;
+ static std::shared_ptr<Events_Message> anAbortMsg
+ (new Events_Message(Events_Loop::eventByName("AbortOperation")));
+ Events_Loop::loop()->send(anAbortMsg);
+ myCheckTransactions = true;
+ myCheckTransactions = aWasCheck;
+}
+
+bool Model_Session::isOperation()
+{
+ return ROOT_DOC->isOperation();
+}
+
+bool Model_Session::isModified()