00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #ifndef _DJVUDOCEDITOR_H
00058 #define _DJVUDOCEDITOR_H
00059 #ifdef HAVE_CONFIG_H
00060 #include "config.h"
00061 #endif
00062 #if NEED_GNUG_PRAGMAS
00063 # pragma interface
00064 #endif
00065
00066
00067 #include "DjVuDocument.h"
00068 #include "DjVmDoc.h"
00069
00070 #ifdef HAVE_NAMESPACES
00071 namespace DJVU {
00072 # ifdef NOT_DEFINED // Just to fool emacs c++ mode
00073 }
00074 #endif
00075 #endif
00076
00089
00104 class DjVuDocEditor : public DjVuDocument
00105 {
00106 public:
00107 static int thumbnails_per_file;
00108
00109 protected:
00111 DjVuDocEditor(void);
00112
00118 void init(void);
00119
00125 void init(const GURL &url);
00126
00127 public:
00129 static GP<DjVuDocEditor> create_wait(const GURL &url);
00130
00132 static GP<DjVuDocEditor> create_wait(void);
00133
00134
00136 virtual ~DjVuDocEditor(void);
00137
00143 int get_orig_doc_type(void) const;
00144
00161 bool can_be_saved(void) const;
00162
00168 int get_save_doc_type(void) const;
00169
00173 void save(void);
00174
00176 virtual void save_as(const GURL &where, bool bundled);
00177
00188 virtual void write(const GP<ByteStream> &str, bool force_djvm=false);
00191 virtual void write(const GP<ByteStream> &str,
00192 const GMap<GUTF8String,void *> &reserved);
00193
00195 void save_pages_as(
00196 const GP<ByteStream> &str, const GList<int> & page_list);
00197
00200 GUTF8String page_to_id(int page_num) const;
00201
00202 GUTF8String insert_file(const GURL &url, const GUTF8String &parent_id,
00203 int chunk_num=1, DjVuPort *source=0);
00219 void insert_page(const GURL &fname, int page_num=-1);
00233 void insert_page(GP<DataPool> & file_pool,
00234 const GURL &fname, int page_num=-1);
00258 void insert_group(const GList<GURL> & furl_list, int page_num=-1,
00259 void (* refresh_cb)(void *)=0, void * cl_data=0);
00263 void remove_page(int page_num, bool remove_unref=true);
00267 void remove_pages(const GList<int> & page_list, bool remove_unref=true);
00275 void remove_file(const GUTF8String &id, bool remove_unref=true);
00279 void move_page(int page_num, int new_page_num);
00287 void move_pages(const GList<int> & page_list, int shift);
00288
00292 void set_file_name(const GUTF8String &id, const GUTF8String &name);
00296 void set_page_name(int page_num, const GUTF8String &name);
00300 void set_file_title(const GUTF8String &id, const GUTF8String &title);
00304 void set_page_title(int page_num, const GUTF8String &title);
00305
00318 int get_thumbnails_num(void) const;
00319
00327 int get_thumbnails_size(void) const;
00328
00330 void remove_thumbnails(void);
00331
00341 int generate_thumbnails(int thumb_size, int page_num);
00342
00357 void generate_thumbnails(int thumb_size,
00358 bool (* cb)(int page_num, void *)=0,
00359 void * cl_data=0);
00361
00366 void simplify_anno(void (* progress_cb)(float progress, void *)=0,
00367 void * cl_data=0);
00368
00375 void create_shared_anno_file(void (* progress_cb)(float progress, void *)=0,
00376 void * cl_data=0);
00377
00379 void set_djvm_nav(GP<DjVmNav> nav);
00380
00386 GP<DjVuFile> get_shared_anno_file(void);
00387
00388 GURL get_doc_url(void) const;
00389
00392 virtual bool inherits(const GUTF8String &class_name) const;
00393 virtual GP<DataPool> request_data(const DjVuPort * source, const GURL & url);
00394 protected:
00395 virtual GP<DjVuFile> url_to_file(const GURL & url, bool dont_create) const;
00396 virtual GP<DataPool> get_thumbnail(int page_num, bool dont_decode);
00397 friend class CThumbNails;
00398 public:
00399 class File;
00400 private:
00401 bool initialized;
00402 GURL doc_url;
00403 GP<DataPool> doc_pool;
00404 GURL tmp_doc_url;
00405 int orig_doc_type;
00406 int orig_doc_pages;
00407
00408 GPMap<GUTF8String, File> files_map;
00409 GCriticalSection files_lock;
00410
00411 GPMap<GUTF8String,DataPool> thumb_map;
00412 GCriticalSection thumb_lock;
00413
00414 void (* refresh_cb)(void *);
00415 void * refresh_cl_data;
00416
00417 void check(void);
00418 GUTF8String find_unique_id(GUTF8String id);
00419 GP<DataPool> strip_incl_chunks(const GP<DataPool> & pool);
00420 void clean_files_map(void);
00421 bool insert_file_type(const GURL &file_url,
00422 DjVmDir::File::FILE_TYPE page_type,
00423 int & file_pos,
00424 GMap<GUTF8String, GUTF8String> & name2id);
00425 bool insert_file( const GP<DataPool> &pool,
00426 const GURL &file_url, bool is_page,
00427 int & file_pos,
00428 GMap<GUTF8String,GUTF8String> & name2id,
00429 DjVuPort *source=0 );
00430 bool insert_file(
00431 const GURL &file_url, bool is_page,
00432 int & file_pos,
00433 GMap<GUTF8String,GUTF8String> & name2id,
00434 DjVuPort *source=0 );
00435 void remove_file(const GUTF8String &id, bool remove_unref,
00436 GMap<GUTF8String, void *> & ref_map);
00437 void generate_ref_map(const GP<DjVuFile> & file,
00438 GMap<GUTF8String, void *> & ref_map,
00439 GMap<GURL, void *> & visit_map);
00440 void move_file(const GUTF8String &id, int & file_pos,
00441 GMap<GUTF8String, void *> & map);
00442 void unfile_thumbnails(void);
00443 void file_thumbnails(void);
00444 void save_file(const GUTF8String &id, const GURL &codebase,
00445 const bool only_modified, GMap<GUTF8String, GUTF8String> & map);
00446 void save_file(const GUTF8String &id, const GURL &codebase,
00447 GMap<GUTF8String, GUTF8String> & map);
00448 };
00449
00451
00452
00453 #ifdef HAVE_NAMESPACES
00454 }
00455 # ifndef NOT_USING_DJVU_NAMESPACE
00456 using namespace DJVU;
00457 # endif
00458 #endif
00459 #endif
00460