kviewshell
DjVmDoc Class Reference
Read/Write DjVu multipage documents. More...
#include <DjVmDoc.h>
Public Member Functions | |
void | delete_file (const GUTF8String &id) |
GP< DataPool > | get_data (const GUTF8String &id) const |
void | insert_file (const GP< DjVmDir::File > &f, GP< DataPool > data, int pos=-1) |
void | insert_file (const GP< DataPool > &pool, DjVmDir::File::FILE_TYPE file_type, const GUTF8String &name, const GUTF8String &id, const GUTF8String &title=GUTF8String(), int pos=-1) |
void | insert_file (ByteStream &data, DjVmDir::File::FILE_TYPE file_type, const GUTF8String &name, const GUTF8String &id, const GUTF8String &title=GUTF8String(), int pos=-1) |
void | set_djvm_nav (GP< DjVmNav > n) |
void | expand (const GURL &codebase, const GUTF8String &idx_name) |
GUTF8String | save_file (const GURL &codebase, const DjVmDir::File &file, GMap< GUTF8String, GUTF8String > &incl, const GP< DataPool > &pool) const |
void | save_file (const GURL &codebase, const DjVmDir::File &file) const |
void | save_page (const GURL &codebase, const DjVmDir::File &file, GMap< GUTF8String, GUTF8String > &incl) const |
void | save_page (const GURL &codebase, const DjVmDir::File &file) const |
void | write (const GP< ByteStream > &str, const GMap< GUTF8String, void * > &reserved) |
void | write (const GP< ByteStream > &str) |
void | write_index (const GP< ByteStream > &str) |
DjVmDoc.h | |
GP< DjVmDir > | get_djvm_dir (void) |
void | read (const GURL &url) |
void | read (const GP< DataPool > &data_pool) |
void | read (ByteStream &str) |
Static Public Member Functions | |
static GP< DjVmDoc > | create (void) |
Protected Member Functions | |
DjVmDoc (void) | |
void | init (void) |
Detailed Description
Read/Write DjVu multipage documents.The "new" DjVu multipage documents can be of two types: {bundled} and {indirect}. In the first case all pages are packed into one file, which is very like an archive internally. In the second case every page is stored in a separate file. Plus there can be other components, included into one or more pages, which also go into separate files. In addition to pages and components, in the case of the {indirect} format there is one more top-level file with the document directory (see {DjVmDir}), which is basically an index file containing the list of all files composing the document.
This class can read documents of both formats and can save them under any format. It is therefore ideal for converting between {bundled} and {indirect} formats. It cannot be used however for reading obsolete formats. The best way to convert obsolete formats consists in reading them with class {DjVuDocument} class and saving them using {DjVuDocument::write} or {DjVuDocument::expand}.
This class can also be used to create and modify multipage documents at the low level without decoding every page or component (See {insert_file}() and {delete_file}()).
Definition at line 117 of file DjVmDoc.h.
Constructor & Destructor Documentation
DjVmDoc::DjVmDoc | ( | void | ) | [protected] |
Definition at line 146 of file DjVmDoc.cpp.
Member Function Documentation
void DjVmDoc::delete_file | ( | const GUTF8String & | id | ) |
Removes file with the specified id# from the document.
Every file inside a new DjVu multipage document has its unique ID (refer to {DjVmDir} for details), which is passed to this function.
Definition at line 222 of file DjVmDoc.cpp.
void DjVmDoc::expand | ( | const GURL & | codebase, | |
const GUTF8String & | idx_name | |||
) |
Writes the multipage DjVu document in the {indirect} format into the given directory.
Every page and included file will be stored as a separate file. Besides, one top-level file with the document directory (named idx_name#) will be created unless idx_name# is empty.
- Parameters:
-
dir_name Name of the directory where files should be created idx_name Name of the top-level file with the {DjVmDir} with the list of files composing the given document. If empty, the file will not be created.
Definition at line 630 of file DjVmDoc.cpp.
GP< DataPool > DjVmDoc::get_data | ( | const GUTF8String & | id | ) | const |
Returns contents of file with ID id# from the document.
Please refer to {DjVmDir} for the explanation of what IDs mean.
Definition at line 243 of file DjVmDoc.cpp.
void DjVmDoc::init | ( | void | ) | [protected] |
Definition at line 153 of file DjVmDoc.cpp.
void DjVmDoc::insert_file | ( | const GP< DjVmDir::File > & | f, | |
GP< DataPool > | data, | |||
int | pos = -1 | |||
) |
Inserts a file described by {DjVmDir::File} structure with data data# at position pos#.
If pos# is negative, the file will be appended to the document. Otherwise it will be inserted at position pos#.
Definition at line 168 of file DjVmDoc.cpp.
void DjVmDoc::insert_file | ( | const GP< DataPool > & | pool, | |
DjVmDir::File::FILE_TYPE | file_type, | |||
const GUTF8String & | name, | |||
const GUTF8String & | id, | |||
const GUTF8String & | title = GUTF8String() , |
|||
int | pos = -1 | |||
) |
Inserts a file into the document.
- Parameters:
-
pool Data pool containing file data. file_type Describes the type of the file to be inserted. See {DjVmDir::File} for details. name Name of the file in the document (e.g. an URL). id Identifier of the file (as used in INCL chunks). title Optional title of the file (shown in browsers). pos Position of the file in the document (default is append).
Definition at line 210 of file DjVmDoc.cpp.
void DjVmDoc::insert_file | ( | ByteStream & | data, | |
DjVmDir::File::FILE_TYPE | file_type, | |||
const GUTF8String & | name, | |||
const GUTF8String & | id, | |||
const GUTF8String & | title = GUTF8String() , |
|||
int | pos = -1 | |||
) |
Inserts a file into the document.
- Parameters:
-
data ByteStream containing the file data. file_type Describes the type of the file to be inserted. See {DjVmDir::File} for details. name Name of the file in the document (e.g. an URL). id Identifier of the file (as used in INCL chunks). title Optional title of the file (shown in browsers). pos Position of the file in the document (default is append).
Definition at line 190 of file DjVmDoc.cpp.
void DjVmDoc::read | ( | const GURL & | url | ) |
Reads the DjVu multipage document in either {bundled} or {indirect} format.
{ Note:} For {bundled} documents the file is not read into memory. We just open it and access data directly there. Thus you should not modify the file contents.
- Parameters:
-
name For {bundled} documents this is the name of the document. For {indirect} documents this is the name of the top-level file of the document (containing the {DjVmDir} with the list of all files). The rest of the files are expected to be in the same directory and will be read by this function as well.
Definition at line 489 of file DjVmDoc.cpp.
Reads contents of a {bundled} multipage DjVu document from the {DataPool}.
Definition at line 437 of file DjVmDoc.cpp.
void DjVmDoc::read | ( | ByteStream & | str | ) |
Reading routines.
Reads contents of a {bundled} multipage DjVu document from the stream.
Definition at line 473 of file DjVmDoc.cpp.
GUTF8String DjVmDoc::save_file | ( | const GURL & | codebase, | |
const DjVmDir::File & | file, | |||
GMap< GUTF8String, GUTF8String > & | incl, | |||
const GP< DataPool > & | pool | |||
) | const |
void DjVmDoc::save_file | ( | const GURL & | codebase, | |
const DjVmDir::File & | file | |||
) | const |
Writes an individual file specified, remapping INCL chunks as appropriate.
Included files will not be saved.
Definition at line 585 of file DjVmDoc.cpp.
void DjVmDoc::save_page | ( | const GURL & | codebase, | |
const DjVmDir::File & | file, | |||
GMap< GUTF8String, GUTF8String > & | incl | |||
) | const |
Writes an individual file if not mapped, and all included files.
INCL chunks will be remapped as appropriate. All pages saved are added to the incl# map.
Definition at line 577 of file DjVmDoc.cpp.
void DjVmDoc::save_page | ( | const GURL & | codebase, | |
const DjVmDir::File & | file | |||
) | const |
Writes an individual file, and all included files.
INCL chunks will be remapped as appropriate.
Definition at line 569 of file DjVmDoc.cpp.
void DjVmDoc::write | ( | const GP< ByteStream > & | str, | |
const GMap< GUTF8String, void * > & | reserved | |||
) |
Writes the multipage DjVu document in the {bundled} format into the stream, reserving any of the specified names.
Definition at line 283 of file DjVmDoc.cpp.
void DjVmDoc::write | ( | const GP< ByteStream > & | str | ) |
Writing routines.
Writes the multipage DjVu document in the {bundled} format into the stream.
Definition at line 269 of file DjVmDoc.cpp.
void DjVmDoc::write_index | ( | const GP< ByteStream > & | str | ) |
Stored index (top-level) file of the DjVu document in the {indirect} format into the specified stream.
Definition at line 533 of file DjVmDoc.cpp.
The documentation for this class was generated from the following files: