Logo Search packages:      
Sourcecode: djvulibre version File versions

GP< DjVmDoc > DjVuDocument::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}. You may also want to look at {write}() and {expand}() if you are interested in how to save the document.

{ Plugin Warning}. This function will read contents of the whole document. Thus, if you call it from the main thread (the thread, which transfers data from Netscape), the plugin will block.

Definition at line 1656 of file DjVuDocument.cpp.

References DjVmDoc::create(), get_djvu_file(), DjVuPort::get_portcaster(), id_to_url(), is_init_complete(), and DjVuPortcaster::notify_error().

Referenced by expand(), DjVuDocEditor::save_as(), and write().

{
   check();
   DEBUG_MSG("DjVuDocument::get_djvm_doc(): creating the DjVmDoc\n");
   DEBUG_MAKE_INDENT(3);

   if (!is_init_complete())
     G_THROW( ERR_MSG("DjVuDocument.init_not_done") );

   GP<DjVmDoc> doc=DjVmDoc::create();

   if (doc_type==BUNDLED || doc_type==INDIRECT)
   {
      DEBUG_MSG("Trivial: the document is either INDIRECT or BUNDLED: follow DjVmDir.\n");

      GPList<DjVmDir::File> files_list=djvm_dir->get_files_list();
      for(GPosition pos=files_list;pos;++pos)
      {
       GP<DjVmDir::File> f=new DjVmDir::File(*files_list[pos]);
       GP<DjVuFile> file=url_to_file(id_to_url(f->get_load_name()));
       GP<DataPool> data;
       if (file->is_modified()) data=file->get_djvu_data(false);
       else data=file->get_init_data_pool();
       doc->insert_file(f, data);
      }
   } else if (doc_type==SINGLE_PAGE)
   {
      DEBUG_MSG("Creating: djvm for a single page document.\n");
      GMap<GURL, void *> map_add;
      GP<DjVuFile> file=get_djvu_file(0);
      add_file_to_djvm(file, true, *doc, map_add,needs_compression_flag,can_compress_flag);
   } else
   {
      DEBUG_MSG("Converting: the document is in an old format.\n");

      GMap<GURL, void *> map_add;
      if(recover_errors == ABORT)
      {
        for(int page_num=0;page_num<ndir->get_pages_num();page_num++)
        {
          GP<DjVuFile> file=url_to_file(ndir->page_to_url(page_num));
          add_file_to_djvm(file, true, *doc, map_add,needs_compression_flag,can_compress_flag);
        }
      }else
      {
        for(int page_num=0;page_num<ndir->get_pages_num();page_num++)
        {
          G_TRY
          {
            GP<DjVuFile> file=url_to_file(ndir->page_to_url(page_num));
            add_file_to_djvm(file, true, *doc, map_add,needs_compression_flag,can_compress_flag);
          }
          G_CATCH(ex)
          {
            G_TRY { 
              get_portcaster()->notify_error(this, ex.get_cause());
              GUTF8String emsg = ERR_MSG("DjVuDocument.skip_page") "\t" + (page_num+1);
              get_portcaster()->notify_error(this, emsg);
            }
            G_CATCH_ALL
            {
              G_RETHROW;
            }
            G_ENDCATCH;
          }
          G_ENDCATCH;
        }
      }
   }
   return doc;
}


Generated by  Doxygen 1.6.0   Back to index