void init() { _words.clear(); //ldomDocument * doc = docview.getDocument(); int pageIndex = -1; //docview.getCurPage(); LVRef<ldomXRange> range = docview_.getPageDocumentRange( pageIndex ); crtrace trace; if( !range.isNull() ) { LVArray<ldomWord> words; range->getRangeWords(words); for ( int i=0; i<words.length(); i++ ) { lString16 w = words[i].getText(); lString8 encoded = encoding_.encode_string( w ); if ( w.length() < DICT_MIN_WORD_LENGTH ) continue; /* trace << "string " << w << " encoded as " << encoded << "\n"; */ int index = -1; for ( int j=0; j<_words.length(); j++ ) if ( _words[j]->equals(w) ) { index = j; break; } if ( index>=0 ) _words[index]->add( words[i] ); // add range to existing word else _words.add( new WordWithRanges( w, encoded, words[i] ) ); // add new word } } }
bool hasUnsupportedEncryption() { for (int i=0; i<_list.length(); i++) { lString16 method = _list[i]->_method; if (method != L"http://ns.adobe.com/pdf/enc#RC") { CRLog::debug("unsupported encryption method: %s", LCSTR(method)); return true; } } return false; }
virtual LVStreamRef OpenStream( const lChar16 * fname, lvopen_mode_t mode ) { if ( mode!=LVOM_READ ) return LVStreamRef(); for ( int i=0; i<_list.length(); i++ ) { //CRLog::trace("OpenStream(%s) : %s", LCSTR(lString16(fname)), LCSTR(lString16(_list[i]->GetName())) ); if ( !lStr_cmp(_list[i]->GetName(), fname) ) return _list[i]->openStream(); } return LVStreamRef(); }
void match( const lString8& prefix, LVArray<WordWithRanges *> & result ) { crtrace dumpstr; dumpstr << "match with " << prefix; for( int i=0; i<_words.length(); i++ ) { if( _words[i]->matchEncoded( prefix ) ) { result.add( _words[i] ); //dumpstr << " " << i << " " << encoded_words_[i]; }; }; }
bool open() { LVStreamRef stream = _container->OpenStream(L"META-INF/encryption.xml", LVOM_READ); if (stream.isNull()) return false; EncCallback enccallback(this); LVXMLParser parser(stream, &enccallback, false, false); if (!parser.Parse()) return false; if (_list.length()) return true; return false; }
EncryptedItem * findEncryptedItem(const lChar16 * name) { lString16 n; if (name[0] != '/' && name[0] != '\\') n << L"/"; n << name; for (int i=0; i<_list.length(); i++) { lString16 s = _list[i]->_uri; if (s[0]!='/' && s[i]!='\\') s = lString16(L"/") + s; if (_list[i]->_uri == s) return _list[i]; } return NULL; }
void RecentBooksDlg::removeFile(LVPtrVector<CRFileHistRecord> & files, int num) { QDir Dir0( cr2qt(files[num-1]->getFilePath()) ); // Удаляемый файл ещё существует if((Dir0.exists( cr2qt(files.get(num-1)->getFileName()) )) && (files.length() > 1)){ // Нужно чтобы в истории было больше одной книжки, чтобы можно было загрузить удяляемую запись а потом удалить m_docview->loadDocument(cr2qt(files[num-1]->getFilePathName())); // remove cache file QString filename = cr2qt(files.get(num-1)->getFileName()); filename = cr2qt(m_docview->getDocView()->getDocProps()->getStringDef(DOC_PROP_FILE_NAME)); // Уточняем CRC удаляемого файла lUInt32 crc = m_docview->getDocView()->getDocProps()->getIntDef(DOC_PROP_FILE_CRC32, 0); char s[16]; sprintf(s, ".%08x", (unsigned)crc); filename = filename+ QString(s); // Возвращаем активным первоначально просматриваемый документ (он сейчас первым в списке истории стоит) m_docview->loadDocument(cr2qt(files[1]->getFilePathName())); // // для отладки // trim file extension, need for archive files QDir Dir(qApp->applicationDirPath() + QDir::toNativeSeparators(QString("/data/cache/"))); QStringList fileList = Dir.entryList(QStringList() << filename + "*.cr3", QDir::Files); if(fileList.count()) Dir.remove(fileList.at(0)); files.remove(1); } else { // Известно лишь название архива и если его название не совпадает с названием файла то кеш файл не будет удалён // remove cache file QString filename = cr2qt(files.get(num-1)->getFileName()); // trim file extension, need for archive files int pos = filename.lastIndexOf("."); if(pos != -1) filename.resize(pos); QDir Dir(qApp->applicationDirPath() + QDir::toNativeSeparators(QString("/data/cache/"))); QStringList fileList = Dir.entryList(QStringList() << filename + "*.cr3", QDir::Files); if(fileList.count()) Dir.remove(fileList.at(0)); files.remove(num-1); } }
/// returns object size (file size or directory entry count) virtual lverror_t GetSize( lvsize_t * pSize ) { *pSize = _list.length(); return LVERR_OK; }
virtual int GetObjectCount() const { return _list.length(); }
//virtual const LVContainerItemInfo * GetObjectInfo(const wchar_t * pname); virtual const LVContainerItemInfo * GetObjectInfo(int index) { if ( index>=0 && index<_list.length() ) return _list[index]; return NULL; }