COOPY » Guide  version 0.6.5
/home/paulfitz/cvs/coopy_scm/coopy/src/libsocialcalc/SocialCalcTextBookFactory.cpp
Go to the documentation of this file.
00001 #include <coopy/SocialCalcTextBook.h>
00002 #include <coopy/SocialCalcTextBookFactory.h>
00003 
00004 using namespace coopy::store;
00005 using namespace coopy::store::socialcalc;
00006 
00007 TextBook *SocialCalcTextBookFactory::open(AttachConfig& config, 
00008                                           AttachReport& report) {
00009   if (config.shouldWrite) {
00010     if (config.prevBook!=NULL) {
00011       dbg_printf("writing socialcalc file %s\n", config.options.get("file").asString().c_str());
00012       bool ok = SocialCalcTextBook::write(config.prevBook,config.options);
00013       if (ok) {
00014         report.success = true;
00015         return config.prevBook;
00016       }
00017     }
00018     return NULL;
00019   }
00020   
00021   SocialCalcTextBook *book = new SocialCalcTextBook;
00022   if (book==NULL) return NULL;
00023   
00024   if (config.shouldRead) {
00025     if (!config.options.check("should_attach")) {
00026       dbg_printf("reading socialcalc file %s\n", config.options.get("file").asString().c_str());
00027       bool ok = book->open(config.options);
00028       if (!ok) {
00029         delete book;
00030         book = NULL;
00031       }
00032     }
00033   }
00034   
00035   if (book!=NULL) {
00036     report.success = true;
00037   }
00038   
00039   return book;
00040 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines