/* num should be greater than or equal to 1 */ int RawDocOutput (query_data * qd, u_long num, FILE * Output) { static last_pos = 0; static u_char *c_buffer = 0; static int buf_len = -1; static u_char *uc_buffer = 0; u_long pos, len; int ULen; FetchDocStart (qd, num, &pos, &len); if ((int) len > buf_len) { if (c_buffer) { Xfree (c_buffer); Xfree (uc_buffer); } if (!(c_buffer = Xmalloc (len))) return -1; if (!(uc_buffer = Xmalloc ((int) (qd->td->cth.ratio * 1.01 * len) + 100))) return -1; buf_len = len; } if (last_pos != pos) Fseek (qd->td->TextFile, pos, 0); Fread (c_buffer, 1, len, qd->td->TextFile); last_pos = pos + len; DecodeText (qd->cd, c_buffer, len, uc_buffer, &ULen); fwrite (uc_buffer, ULen, sizeof (u_char), Output); return 0; }
void FacadeDocumentProviderImpl::DecodeWorkshareId(const std::wstring& workshareId, std::wstring& artifactId, std::wstring& versionLabel, std::wstring& repositoryId) { std::wstring id = RemoveServiceIdFromWorkshareId(this->ServiceId, workshareId); const wchar_t delimiter = L';'; std::wstring::size_type startIndex = 0; std::wstring::size_type currentIndex = id.find(delimiter); artifactId = DecodeText(id.substr(startIndex, currentIndex)); startIndex = currentIndex + 1; currentIndex = id.find(delimiter, startIndex); if(id.npos != currentIndex) versionLabel = DecodeText(id.substr(startIndex, currentIndex - startIndex)); startIndex = currentIndex + 1; if(0 < (id.length() - startIndex)) repositoryId = DecodeText(id.substr(startIndex, id.length() - startIndex)); }
void PageInfo::Update(GP<DjVuImage> pImage) { if (pImage == NULL) return; if (!bDecoded) { nInitialRotate = GetTotalRotate(pImage, 0); szPage = CSize(pImage->get_width(), pImage->get_height()); if (nInitialRotate % 2 != 0) swap(szPage.cx, szPage.cy); nDPI = pImage->get_dpi(); if (szPage.cx <= 0 || szPage.cy <= 0) { szPage.cx = 100; szPage.cy = 100; nDPI = 100; } bHasText = !!(pImage->get_djvu_file()->text != NULL); bDecoded = true; } try { if (bHasText && !bTextDecoded) DecodeText(pImage->get_text()); } catch (GException&) { } try { if (!bAnnoDecoded) DecodeAnno(pImage->get_anno()); } catch (GException&) { } }
int mg_get_raw_doc(void *qd, u_long docnum, unsigned char **p_ucbuf, int *p_ucbuf_len, int *p_retlen) { query_data *real_qd ; static last_pos = 0 ; static u_char *c_buffer = NULL ; u_long pos, len ; int newucbuf_len ; int temp_retlen, temp_ucbuf_len ; if (p_retlen == NULL) p_retlen = &temp_retlen ; if (p_ucbuf_len == NULL) { p_ucbuf_len = &temp_ucbuf_len ; *p_ucbuf_len = 0 ; } real_qd = (query_data *)qd ; FetchDocStart(real_qd, docnum, &pos, &len) ; newucbuf_len = (int)(real_qd->td->cth.ratio * 1.01 * len)+101 ; if (c_buffer != NULL) Xfree(c_buffer) ; if (!(c_buffer = Xmalloc(len))) return -1 ; if (newucbuf_len > *p_ucbuf_len) { if (*p_ucbuf != NULL) Xfree(*p_ucbuf) ; if (!(*p_ucbuf = Xmalloc(newucbuf_len))) return -1 ; *p_ucbuf_len = newucbuf_len ; } if (last_pos != pos) Fseek(real_qd->td->TextFile, pos, 0) ; Fread(c_buffer, 1, len, real_qd->td->TextFile) ; last_pos = pos+len ; DecodeText(real_qd->cd, c_buffer, len, *p_ucbuf, p_retlen) ; (*p_ucbuf)[*p_retlen]='\0' ; return 0 ; }