+// 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);
+ return aRes;
+}
+
+bool Model_Session::save(const char* theFileName, std::list<std::string>& theResults)
+{
+ return ROOT_DOC->save(theFileName, theResults);
+}
+
+void Model_Session::closeAll()
+{
+ ROOT_DOC->close(true);
+ Model_Application::getApplication()->deleteAllDocuments();
+}
+
+void Model_Session::startOperation()
+{
+ ROOT_DOC->startOperation();
+ 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();
+ setCheckTransactions(true);
+}
+
+void Model_Session::abortOperation()
+{
+ setCheckTransactions(false);
+ ROOT_DOC->abortOperation();
+ 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()
+{
+ return ROOT_DOC->isModified();
+}
+
+bool Model_Session::canUndo()
+{
+ return ROOT_DOC->canUndo();
+}
+
+void Model_Session::undo()
+{
+ setCheckTransactions(false);
+ ROOT_DOC->undo();
+ setCheckTransactions(true);
+}
+
+bool Model_Session::canRedo()
+{
+ return ROOT_DOC->canRedo();
+}
+
+void Model_Session::redo()
+{
+ setCheckTransactions(false);
+ ROOT_DOC->redo();
+ setCheckTransactions(true);
+}
+