Logo Search packages:      
Sourcecode: djvulibre version File versions

GURL DjVuDocument::id_to_url ( const GUTF8String id  )  const

Translates the textual ID to the complete URL if possible.

Depending on the document format the translation is done in the following way: {itemize} For BUNDLED# and INDIRECT# documents the function scans the {DjVmDir} (the document directory) and matches the ID against: {enumerate} File ID from the {DjVmDir} File name from the {DjVmDir} File title from the {DjVmDir} {enumerate} Then for BUNDLED# document the URL is obtained by appending the name# of the found file to the document's URL.

For INDIRECT# documents the URL is obtained by appending the name# of the found file to the URL of the directory containing the document. For OLD_BUNDLED# documents the function compares the ID with internal name of every file inside the bundle and composes an artificial URL by appending the file name to the document's URL. For OLD_INDEXED# or SINGLE_PAGE# documents the function composes the URL by appending the ID to the URL of the directory containing the document. {itemize}

If information obtained by the initialization thread is not sufficient yet, the id_to_url()# may return an empty URL. Depending on the document type, the information is sufficient when {itemize} BUNDLED# and INDIRECT#: DOC_DIR_KNOWN# flag is set. OLD_BUNDLED# and OLD_INDEXED# and SINGLE_PAGE#: DOC_TYPE_KNOWN# flag is set. {itemize}

Definition at line 766 of file DjVuDocument.cpp.

References GURL::base().

Referenced by get_djvm_doc(), get_djvu_file(), id_to_page(), id_to_url(), DjVuDocEditor::set_file_name(), and DjVuDocEditor::simplify_anno().

{
   check();
   DEBUG_MSG("DjVuDocument::id_to_url(): translating ID='" << id << "' to URL\n");
   DEBUG_MAKE_INDENT(3);

   if (flags & DOC_TYPE_KNOWN)
      switch(doc_type)
      {
       case BUNDLED:
          if (flags & DOC_DIR_KNOWN)
          {
            GP<DjVmDir::File> file=djvm_dir->id_to_file(id);
            if (!file)
              {
                file=djvm_dir->name_to_file(id);
              if (!file)
                  file=djvm_dir->title_to_file(id);
              }
            if (file)
              return GURL::UTF8(file->get_load_name(),init_url);
          }
          break;
       case INDIRECT:
          if (flags & DOC_DIR_KNOWN)
          {
             GP<DjVmDir::File> file=djvm_dir->id_to_file(id);
             if (!file)
               {
                 file=djvm_dir->name_to_file(id);
               if (!file)
                   file=djvm_dir->title_to_file(id);
               }
             if (file)
               return GURL::UTF8(file->get_load_name(),init_url.base());
          }
          break;
       case OLD_BUNDLED:
          if (flags & DOC_DIR_KNOWN)
          {
             GP<DjVmDir0::FileRec> frec=djvm_dir0->get_file(id);
             if (frec)
                 return GURL::UTF8(id,init_url);
          }
          break;
       case OLD_INDEXED:
       case SINGLE_PAGE:
          return GURL::UTF8(id,init_url.base());
          break;
      }
   return GURL();
}


Generated by  Doxygen 1.6.0   Back to index