Logo Search packages:      
Sourcecode: djvulibre version File versions

void DjVuDocEditor::remove_file ( const GUTF8String id,
bool  remove_unref = true 
)

Removes a DjVu file with the specified id#.

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.

Definition at line 1039 of file DjVuDocEditor.cpp.

References GMapTemplate< KTYPE, VTYPE, VTYPE >::del(), DjVuDocument::get_djvu_file(), DjVmDir::get_pages_num(), and DjVmDir::id_to_file().

Referenced by remove_page(), and simplify_anno().

{
   DEBUG_MSG("DjVuDocEditor::remove_file(): id='" << id << "'\n");
   DEBUG_MAKE_INDENT(3);

   if (!djvm_dir->id_to_file(id))
      G_THROW( ERR_MSG("DjVuDocEditor.no_file") "\t"+id);

      // First generate a map of references (containing the list of parents
      // including this particular file. This will speed things up
      // significatly.
   GMap<GUTF8String, void *> ref_map;        // GMap<GUTF8String, GMap<GUTF8String, void *> *> in fact
   GMap<GURL, void *> visit_map;        // To avoid loops

   int pages_num=djvm_dir->get_pages_num();
   for(int page_num=0;page_num<pages_num;page_num++)
      generate_ref_map(get_djvu_file(page_num), ref_map, visit_map);

      // Now call the function, which will do the removal recursively
   remove_file(id, remove_unref, ref_map);

      // And clear the ref_map
   GPosition pos;
   while((pos=ref_map))
   {
      GMap<GUTF8String, void *> * parents=(GMap<GUTF8String, void *> *) ref_map[pos];
      delete parents;
      ref_map.del(pos);
   }
}


Generated by  Doxygen 1.6.0   Back to index