load document cache file content, @see saveChanges()
| 7750 | |
| 7751 | /// load document cache file content, @see saveChanges() |
| 7752 | bool ldomDocument::loadCacheFileContent(CacheLoadingCallback * formatCallback) |
| 7753 | { |
| 7754 | |
| 7755 | CRLog::trace("ldomDocument::loadCacheFileContent()"); |
| 7756 | { |
| 7757 | SerialBuf propsbuf(0, true); |
| 7758 | if ( !_cacheFile->read( CBT_PROP_DATA, propsbuf ) ) { |
| 7759 | CRLog::error("Error while reading props data"); |
| 7760 | return false; |
| 7761 | } |
| 7762 | getProps()->deserialize( propsbuf ); |
| 7763 | if ( propsbuf.error() ) { |
| 7764 | CRLog::error("Cannot decode property table for document"); |
| 7765 | return false; |
| 7766 | } |
| 7767 | |
| 7768 | if ( formatCallback ) { |
| 7769 | int fmt = getProps()->getIntDef(DOC_PROP_FILE_FORMAT_ID, |
| 7770 | doc_format_fb2); |
| 7771 | if (fmt < doc_format_fb2 || fmt > doc_format_max) |
| 7772 | fmt = doc_format_fb2; |
| 7773 | // notify about format detection, to allow setting format-specific CSS |
| 7774 | formatCallback->OnCacheFileFormatDetected((doc_format_t)fmt); |
| 7775 | } |
| 7776 | |
| 7777 | SerialBuf idbuf(0, true); |
| 7778 | if ( !_cacheFile->read( CBT_MAPS_DATA, idbuf ) ) { |
| 7779 | CRLog::error("Error while reading Id data"); |
| 7780 | return false; |
| 7781 | } |
| 7782 | deserializeMaps( idbuf ); |
| 7783 | if ( idbuf.error() ) { |
| 7784 | CRLog::error("Cannot decode ID table for document"); |
| 7785 | return false; |
| 7786 | } |
| 7787 | |
| 7788 | CRLog::trace("ldomDocument::loadCacheFileContent() - page data"); |
| 7789 | SerialBuf pagebuf(0, true); |
| 7790 | if ( !_cacheFile->read( CBT_PAGE_DATA, pagebuf ) ) { |
| 7791 | CRLog::error("Error while reading pages data"); |
| 7792 | return false; |
| 7793 | } |
| 7794 | pagebuf.swap( _pagesData ); |
| 7795 | _pagesData.setPos( 0 ); |
| 7796 | LVRendPageList pages; |
| 7797 | pages.deserialize(_pagesData); |
| 7798 | if ( _pagesData.error() ) { |
| 7799 | CRLog::error("Page data deserialization is failed"); |
| 7800 | return false; |
| 7801 | } |
| 7802 | CRLog::info("%d pages read from cache file", pages.length()); |
| 7803 | //_pagesData.setPos( 0 ); |
| 7804 | |
| 7805 | DocFileHeader h; |
| 7806 | memset(&h, 0, sizeof(h)); |
| 7807 | SerialBuf hdrbuf(0,true); |
| 7808 | if ( !_cacheFile->read( CBT_REND_PARAMS, hdrbuf ) ) { |
| 7809 | CRLog::error("Error while reading header data"); |
nothing calls this directly
no test coverage detected