Logo Search packages:      
Sourcecode: djvulibre version File versions

void DjVuDocEditor::create_shared_anno_file ( void(*)(float progress, void *)  progress_cb = 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.

Definition at line 1428 of file DjVuDocEditor.cpp.

References IFFByteStream::close_chunk(), DataPool::create(), ByteStream::create(), ByteStream::flush(), DjVuDocument::get_djvu_file(), DjVmDir::get_pages_num(), DjVmDir::get_shared_anno_file(), DjVmDir::insert_file(), IFFByteStream::put_chunk(), and ByteStream::seek().

{
   if (djvm_dir->get_shared_anno_file())
      G_THROW( ERR_MSG("DjVuDocEditor.share_fail") );

      // Prepare file with ANTa chunk inside
   const GP<ByteStream> gstr(ByteStream::create());
   const GP<IFFByteStream> giff(IFFByteStream::create(gstr));
   IFFByteStream &iff=*giff;
   iff.put_chunk("FORM:DJVI");
   iff.put_chunk("ANTa");
   iff.close_chunk();
   iff.close_chunk();
   ByteStream &str=*gstr;
   str.flush();
   str.seek(0);
   const GP<DataPool> file_pool(DataPool::create(gstr));

      // Get a unique ID for the new file
   const GUTF8String id(find_unique_id("shared_anno.iff"));

      // Add it into the directory
   GP<DjVmDir::File> frec(DjVmDir::File::create(id, id, id,
     DjVmDir::File::SHARED_ANNO));
   djvm_dir->insert_file(frec, 1);

      // Add it to our "cache"
   {
      GP<File> f=new File;
      f->pool=file_pool;
      GCriticalSectionLock lock(&files_lock);
      files_map[id]=f;
   }

      // Now include this shared file into every top-level page file
   int pages_num=djvm_dir->get_pages_num();
   for(int page_num=0;page_num<pages_num;page_num++)
   {
      GP<DjVuFile> djvu_file=get_djvu_file(page_num);
      djvu_file->insert_file(id, 1);

      if (progress_cb)
         progress_cb((float) page_num/pages_num, cl_data);
   }
}


Generated by  Doxygen 1.6.0   Back to index