| 71 | } |
| 72 | |
| 73 | Document* load_document(Context* context, const char* filename) |
| 74 | { |
| 75 | /* TODO add a option to configure what to do with the sequence */ |
| 76 | std::unique_ptr<FileOp> fop(FileOp::createLoadDocumentOperation(context, filename, FILE_LOAD_SEQUENCE_NONE)); |
| 77 | if (!fop) |
| 78 | return nullptr; |
| 79 | |
| 80 | // Operate in this same thread |
| 81 | fop->operate(); |
| 82 | fop->done(); |
| 83 | fop->postLoad(); |
| 84 | |
| 85 | if (fop->hasError()) { |
| 86 | Console console(context); |
| 87 | console.printf(fop->error().c_str()); |
| 88 | } |
| 89 | |
| 90 | auto document = fop->releaseDocument(); |
| 91 | |
| 92 | if (document && context) |
| 93 | document->setContext(context); |
| 94 | |
| 95 | return document; |
| 96 | } |
| 97 | |
| 98 | int save_document(Context* context, doc::Document* document) |
| 99 | { |