class DjVuDocEditor: public DjVuDocument

DjVuDocEditor is an extension of DjVuDocument class with additional capabilities for editing the document contents.

Inheritance:


Public Methods

[more] DjVuDocEditor(void)
Default constructor
[more]void init(void)
Initialization function.
[more]void init(const char * fname)
Initialization function.
[more]virtual ~DjVuDocEditor(void)
Destructor
[more]int get_orig_doc_type(void) const
Returns type of open document.
[more]bool can_be_saved(void) const
Returns TRUE if the document can be "saved" (sometimes the only possibility is to do a "save as").
[more]int get_save_doc_type(void) const
Returns type of the document, which can be created by save() function.
[more]void save(void)
Saves the document.
[more]virtual void save_as(const char * where, bool bundled)
Saves the document.
[more]void save_pages_as(ByteStream & str, const GList<int> & page_list)
Saves the specified pages in DjVu BUNDLED multipage document.
[more]GString page_to_id(int page_num) const
Translates page number page_num to ID.
[more]void insert_page(const char * fname, int page_num=-1)
Inserts the referenced file into this DjVu document.
[more]void insert_page(GP<DataPool> & file_pool, const char * fname, int page_num=-1)
Inserts a new page with data inside the data_pool as page number page_num.
[more]void insert_group(const GList<GString> & fname_list, int page_num=-1, void (* refresh_cb)(void *)=0, void * cl_data=0)
Inserts a group of pages into this DjVu document.
[more]void remove_page(int page_num, bool remove_unref=true)
Removes the specified page from the document.
[more]void remove_pages(const GList<int> & page_list, bool remove_unref=true)
Removes the specified pages from the document.
[more]void remove_file(const char * id, bool remove_unref=true)
Removes a DjVu file with the specified
[more]void move_page(int page_num, int new_page_num)
Makes page number page_num to be new_page_num.
[more]void move_pages(const GList<int> & page_list, int shift)
Shifts all pags from the page_list according to the shift.
[more]void set_file_name(const char * id, const char * name)
Changes the name of the file with ID Refer to DjVmDir for the explanation of IDs, names and titles.
[more]void set_page_name(int page_num, const char * name)
Changes the name of the page page_num to name.
[more]void set_file_title(const char * id, const char * title)
Changes the title of the file with ID Refer to DjVmDir for the explanation of IDs, names and titles.
[more]void set_page_title(int page_num, const char * title)
Changes the title of the page page_num to title.
[more]void simplify_anno(void (* progress_cb)(float progress, void *)=0, void * cl_data=0)
Use this function to simplify annotations in the document.
[more]void create_shared_anno_file(void (* progress_cb)(float progress, void *)=0, void * cl_data=0)
Will create a file that will be included into every page and marked with the SHARED_ANNO flag.
[more]GP<DjVuFile> get_shared_anno_file(void)
Returns a pointer to the file with SHARED_ANNO flag on.
[more]virtual bool inherits(const char * class_name) const
Returns TRUE if class_name is "DjVuDocEditor", "DjVuDocument" or "DjVuPort"

Public

[more] Thumbnails

[more]int get_thumbnails_num(void) const
Returns the number of thumbnails stored inside this document.
[more]int get_thumbnails_size(void) const
Returns the size of the first encountered thumbnail image.
[more]void remove_thumbnails(void)
Removes all thumbnails from the document
[more]int generate_thumbnails(int thumb_size, int page_num)
Generates thumbnails for the specified page, if and only if it does not have a thumbnail yet.
[more]void generate_thumbnails(int thumb_size, bool (* cb)(int page_num, void *)=0, void * cl_data=0)
Generates thumbnails for those pages, which do not have them yet.


Inherited from DjVuDocument:

Public Classes

oenum DOC_FLAGS
oenum DOC_TYPE

Public Methods

ovoid start_init(const GURL & url, GP<DjVuPort> port=0, DjVuFileCache * cache=0)
ostatic GP<DjVuDocument> create( const GURL &url, GP<DjVuPort> xport=0, DjVuFileCache * const xcache=0)
ostatic GP<DjVuDocument> create( GP<DataPool> pool, GP<DjVuPort> xport=0, DjVuFileCache * const xcache=0)
ostatic GP<DjVuDocument> create( ByteStream &bs, GP<DjVuPort> xport=0, DjVuFileCache * const xcache=0)
ovoid stop_init(void)
obool is_init_complete(void) const
obool is_init_ok(void) const
ovoid set_needs_compression(void)
obool needs_compression(void) const
obool needs_rename(void) const
obool can_compress(void) const
obool is_init_failed(void) const
oint get_doc_type(void) const
olong get_doc_flags(void) const
obool is_bundled(void) const
oGURL get_init_url(void) const
oGP<DataPool> get_init_data_pool(void) const
obool wait_for_complete_init(void)
oint wait_get_pages_num(void)
oDjVuFileCache* get_cache(void) const
oGP<DjVmDir> get_djvm_dir(void) const
oGP<DjVmDir0> get_djvm_dir0(void) const
oGP<DjVuNavDir> get_nav_dir(void) const

Public

Accessing pages

[more]int get_pages_num(void) const
Returns the number of pages in the document.
[more]GURL page_to_url(int page_num) const
Translates the page number to the full URL of the page.
[more]int url_to_page(const GURL & url) const
Translates the page URL back to page number.
[more]GURL id_to_url(const char * id) const
Translates the textual ID to the complete URL if possible.
[more]GP<DjVuImage> get_page(int page_num, bool sync=true, DjVuPort * port=0)
Returns GP pointer to DjVuImage corresponding to page page_num.
[more]GP<DjVuImage> get_page(const char * id, bool sync=true, DjVuPort * port=0)
Returns GP pointer to DjVuImage corresponding to the specified ID.
[more]GP<DjVuFile> get_djvu_file(int page_num, bool dont_create=false)
Returns DjVuFile corresponding to the specified page.
[more]GP<DjVuFile> get_djvu_file(const char * id, bool dont_create=false)
Returns DjVuFile corresponding to the specified ID.
[more]virtual GP<DataPool> get_thumbnail(int page_num, bool dont_decode)
Returns a DataPool containing one chunk TH44 with the encoded thumbnail for the specified page.

Saving document to disk

[more]GP<DjVmDoc> get_djvm_doc(void)
Returns pointer to the DjVmDoc class, which can save the document contents on the hard disk in one of the two new formats: bundled and indirect.
[more]void write(ByteStream & str, bool force_djvm=false)
Saves the document in the new bundled format.
[more]void expand(const char * dir_name, const char * idx_name)
Saves the document in the new indirect format when every page and component are stored in separate files.
[more]virtual void save_as(const char where[], const bool bundled=0)
This function can be used instead of write() and expand().


Inherited from DjVuPort:

Public Methods

ostatic DjVuPortcaster* get_portcaster(void)
oDjVuPort& operator=(const DjVuPort & port)

Public

Notifications.

[more]virtual GURL id_to_url(const DjVuPort * source, const char * id)
This request is issued to request translation of the ID, used in an DjVu INCL chunk to a URL, which may be used to request data associated with included file.
[more]virtual GPBase id_to_file(const DjVuPort * source, const char * id)
This request is used to get a file corresponding to the given ID.
[more]virtual GP<DataPool> request_data(const DjVuPort * source, const GURL & url)
This request is issued when decoder needs additional data for decoding.
[more]virtual bool notify_error(const DjVuPort * source, const char * msg)
This notification is sent when an error occurs and the error message should be shown to the user.
[more]virtual bool notify_status(const DjVuPort * source, const char * msg)
This notification is sent to update the decoding status.
[more]virtual void notify_redisplay(const class DjVuImage * source)
This notification is sent by DjVuImage when it should be redrawn.
[more]virtual void notify_relayout(const class DjVuImage * source)
This notification is sent by \ref{DjVuImage} when its geometry has been changed as a result of decoding.
[more]virtual void notify_chunk_done(const DjVuPort * source, const char * name)
This notification is sent when a new chunk has been decoded.
[more]virtual void notify_file_flags_changed(const class DjVuFile * source, long set_mask, long clr_mask)
This notification is sent after the DjVuFile flags have been changed.
[more]virtual void notify_doc_flags_changed(const class DjVuDocument * source, long set_mask, long clr_mask)
This notification is sent after the DjVuDocument flags have been changed.
[more]virtual void notify_decode_progress(const DjVuPort * source, float done)
This notification is sent from time to time while decoding is in progress.
[more]enum ErrorRecoveryAction
This is the standard types for defining what to do in case of errors.


Inherited from GPEnabled:

Public Methods

oint get_count(void) const

Protected Fields

ovolatile int count


Documentation

DjVuDocEditor is an extension of DjVuDocument class with additional capabilities for editing the document contents.

It can be used to:

  1. Create (compose) new multipage DjVu documents using single page DjVu documents. The class does not do compression.
  2. Insert and remove different pages of multipage DjVu documents.
  3. Change attributes (names, IDs and titles) of files composing the DjVu document.
  4. Generate thumbnail images and integrate them into the document.
o DjVuDocEditor(void)
Default constructor

ovoid init(void)
Initialization function. Initializes an empty document.

Note: You must call either of the two available init() function before you start doing anything else with the DjVuDocEditor.

ovoid init(const char * fname)
Initialization function. Opens document with name fname.

Note: You must call either of the two available init() function before you start doing anything else with the DjVuDocEditor.

ovirtual ~DjVuDocEditor(void)
Destructor

oint get_orig_doc_type(void) const
Returns type of open document. DjVuDocEditor silently converts any open DjVu document to BUNDLED format (see DjVuDocument. Thus, get_doc_type() will always be returning BUNDLED. Use this function to learn the original format of the document being edited.

obool can_be_saved(void) const
Returns TRUE if the document can be "saved" (sometimes the only possibility is to do a "save as"). The reason why we have this function is that DjVuDocEditor can save documents in new formats only (BUNDLED and INDIRECT). At the same time it recognizes all DjVu formats (OLD_BUNDLED, OLD_INDEXED, BUNDLED, and INDIRECT).

OLD_BUNDLED and BUNDLED documents occupy only one file, so in this case "saving" involves the automatic conversion to BUNDLED format and storing data into the same file.

OLD_INDEXED documents, on the other hand, occupy more than one file. They could be converted to INDIRECT format if these two formats had the same set of files. Unfortunately, these formats are too different, and the best thing to do is to use "save as" capability.

oint get_save_doc_type(void) const
Returns type of the document, which can be created by save() function. Can be INDIRECT, BUNDLED, SINGLE_PAGE, or UNKNOWN_TYPE. The latter indicates, that save() will fail, and that save_as() should be used instead

ovoid save(void)
Saves the document. May generate exception if the document can not be saved, and save_as() should be used. See can_be_saved() for details.

ovirtual void save_as(const char * where, bool bundled)
Saves the document.

ovoid save_pages_as(ByteStream & str, const GList<int> & page_list)
Saves the specified pages in DjVu BUNDLED multipage document.

oGString page_to_id(int page_num) const
Translates page number page_num to ID. If page_num is invalid, an exception is thrown.

ovoid insert_page(const char * fname, int page_num=-1)
Inserts the referenced file into this DjVu document.

Parameters:
fname - Name of the top-level file containing the image of the page to be inserted. This file must be a DjVu file and may include one or more other DjVu files. If it include other DjVu files, the function will try to insert them into the document too. Should this attempt fail, the corresponding INCL chunk will be removed from the referencing file and an exception will be thrown. When inserting a file, the function may modify its name to be unique in the DjVu document.
page_num - Position where the new page should be inserted at. Negative value means "append"

ovoid insert_page(GP<DataPool> & file_pool, const char * fname, int page_num=-1)
Inserts a new page with data inside the data_pool as page number page_num.
Parameters:
data_pool - DataPool with data for this page.
file_name - Name, which will be assigned to this page. If you try to save the document in INDIRECT format, a file with this name will be created to hold the page's data. If there is already a file in the document with the same name, the function will derive a new unique name from file_name, which will be assigned to the page.
page_num - Describes where the page should be inserted. Negative number means "append".

ovoid insert_group(const GList<GString> & fname_list, int page_num=-1, void (* refresh_cb)(void *)=0, void * cl_data=0)
Inserts a group of pages into this DjVu document.

Like insert_page() it will insert every page into the document. The main advantage of calling this function once for the whole group instead of calling insert_page() for every page is the processing of included files:

The group of files may include one or more files, which are thus shared by them. If you call insert_page() for every page, this shared file will be inserted into the document more than once though under different names. This is how insert_page() works: whenever it inserts something, it checks for duplicate names with only one purpose: invent a new name if a given one is already in use.

On the other hand, if you call shared included files only once. This is because it can analyze the group of files before inserting them and figure out what files are shared and thus should be inserted only once.

Parameters:
fname_list - List of top-level files for the pages to be inserted
page_num - Position where the new pages should be inserted at. Negative value means "append"

ovoid remove_page(int page_num, bool remove_unref=true)
Removes the specified page from the document. If remove_unref is TRUE, the function will also remove from the document any file, which became unreferenced due to the page's removal

ovoid remove_pages(const GList<int> & page_list, bool remove_unref=true)
Removes the specified pages from the document. If remove_unref is TRUE, the function will also remove from the document any file, which became unreferenced due to the pages' removal

ovoid remove_file(const char * id, bool remove_unref=true)
Removes a DjVu file with the specified

If some other files include this file, the corresponding INCL chunks will be removed to avoid dead links.

If remove_unref is TRUE, the function will also remove every file, which will become unreferenced after the removal of this file.

ovoid move_page(int page_num, int new_page_num)
Makes page number page_num to be new_page_num. If new_page_num is negative or too big, the function will move page page_num to the end of the document.

ovoid move_pages(const GList<int> & page_list, int shift)
Shifts all pags from the page_list according to the shift. The shift can be positive (shift toward the end of the document) or negative (shift toward the beginning of the document).

It is OK to make shift too big in value. Pages will just be moved to the end (or to the beginning, depending on the shift sign) of the document.

ovoid set_file_name(const char * id, const char * name)
Changes the name of the file with ID Refer to DjVmDir for the explanation of IDs, names and titles.

ovoid set_page_name(int page_num, const char * name)
Changes the name of the page page_num to name. Refer to DjVmDir for the explanation of IDs, names and titles.

ovoid set_file_title(const char * id, const char * title)
Changes the title of the file with ID Refer to DjVmDir for the explanation of IDs, names and titles.

ovoid set_page_title(int page_num, const char * title)
Changes the title of the page page_num to title. Refer to DjVmDir for the explanation of IDs, names and titles.

o Thumbnails

oint get_thumbnails_num(void) const
Returns the number of thumbnails stored inside this document.

It may be ZERO, which means, that there are no thumbnails at all.

It may be equal to the number of pages, which is what should normally be.

Finally, it may be greater than ZERO and less than the number of pages, in which case thumbnails should be regenerated before the document can be saved.

oint get_thumbnails_size(void) const
Returns the size of the first encountered thumbnail image. Since thumbnails can currently be generated by generate_thumbnails() only, all thumbnail images should be of the same size. Thus, the number returned is actually the size of all document thumbnails.

The function will return -1 if there are no thumbnails.

ovoid remove_thumbnails(void)
Removes all thumbnails from the document

oint generate_thumbnails(int thumb_size, int page_num)
Generates thumbnails for the specified page, if and only if it does not have a thumbnail yet. If you want to regenerate thumbnails for all pages, call remove_thumbnails() prior to calling this function.

Parameters:
thumb_size - The size of the thumbnails in pixels. DjVu viewer is able to rescale the thumbnail images if necessary, so this parameter affects thumbnails quality only. 128 is a good number.
page_num - The page number to genate the thumbnail for.

ovoid generate_thumbnails(int thumb_size, bool (* cb)(int page_num, void *)=0, void * cl_data=0)
Generates thumbnails for those pages, which do not have them yet. If you want to regenerate thumbnails for all pages, call remove_thumbnails() prior to calling this function.

Parameters:
thumb_size - The size of the thumbnails in pixels. DjVu viewer is able to rescale the thumbnail images if necessary, so this parameter affects thumbnails quality only. 128 is a good number.
cb - The callback, which will be called after thumbnail image for the next page has been generated. Regardless of if the document already has thumbnail images for some of its pages, the callback will be called pages_num times, where pages_num is the total number of pages in the document. The callback should return FALSE if thumbnails generating should proceed. TRUE will stop it.

ovoid simplify_anno(void (* progress_cb)(float progress, void *)=0, void * cl_data=0)
Use this function to simplify annotations in the document. The "simplified" format is when annotations are only allowed either in top-level page files or in a special file with SHARED_ANNO flag on. This file is supposed to be included into every page.

ovoid create_shared_anno_file(void (* progress_cb)(float progress, void *)=0, void * cl_data=0)
Will create a file that will be included into every page and marked with the SHARED_ANNO flag. This file can be used to store global annotations (annotations applicable to every page).

Note: There may be only one SHARED_ANNO file in any DjVu multipage document.

oGP<DjVuFile> get_shared_anno_file(void)
Returns a pointer to the file with SHARED_ANNO flag on. This file should be used for storing document-wide annotations.

Note: There may be only one SHARED_ANNO file in any DjVu multipage document.

ovirtual bool inherits(const char * class_name) const
Returns TRUE if class_name is "DjVuDocEditor", "DjVuDocument" or "DjVuPort"


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java


DjVu is a trademark of LizardTech, Inc.
All other products mentioned are registered trademarks or trademarks of their respective companies.