Logo Search packages:      
Sourcecode: djvulibre version File versions

int DjVuDocument::url_to_page ( const GURL url  )  const

Translates the page URL back to page number. Returns #-1# if the page is not in the document or the document's structure has not been learnt yet.

Depending on the document format, the function starts working properly as soon as: {itemize} OLD_INDEXED# and OLD_BUNDLED# and SINGLE_PAGE#: DOC_NDIR_KNOWN# is set INDIRECT# and BUNDLED#: DOC_DIR_KNOWN# is set. {itemize}

Definition at line 718 of file DjVuDocument.cpp.

References GURL::base(), and GURL::fname().

Referenced by id_to_page().

{
   check();
   DEBUG_MSG("DjVuDocument::url_to_page(): url='" << url << "'\n");
   DEBUG_MAKE_INDENT(3);

   int page_num=-1;
   if (flags & DOC_TYPE_KNOWN)
      switch(doc_type)
      {
       case SINGLE_PAGE:
       case OLD_BUNDLED:
       case OLD_INDEXED:
       {
          if (flags & DOC_NDIR_KNOWN) page_num=ndir->url_to_page(url);
          break;
       }
       case BUNDLED:
       {
          if (flags & DOC_DIR_KNOWN)
          {
             GP<DjVmDir::File> file;
             if (url.base()==init_url)
                 file=djvm_dir->id_to_file(url.fname());
             if (file)
                 page_num=file->get_page_num();
          }
          break;
       }
       case INDIRECT:
       {
          if (flags & DOC_DIR_KNOWN)
          {
             GP<DjVmDir::File> file;
             if (url.base()==init_url.base())
                 file=djvm_dir->id_to_file(url.fname());
             if (file)
                 page_num=file->get_page_num();
          }
          break;
       }
       default:
          G_THROW( ERR_MSG("DjVuDocument.unk_type") );
      }
   return page_num;
}


Generated by  Doxygen 1.6.0   Back to index