work out the section index for a toc index
| 830 | |
| 831 | // work out the section index for a toc index |
| 832 | int Epub::getSpineIndexForTocIndex(const int tocIndex) const { |
| 833 | if (!bookMetadataCache || !bookMetadataCache->isLoaded()) { |
| 834 | LOG_ERR("EBP", "getSpineIndexForTocIndex called but cache not loaded"); |
| 835 | return 0; |
| 836 | } |
| 837 | |
| 838 | if (tocIndex < 0 || tocIndex >= bookMetadataCache->getTocCount()) { |
| 839 | LOG_ERR("EBP", "getSpineIndexForTocIndex: tocIndex %d out of range", tocIndex); |
| 840 | return 0; |
| 841 | } |
| 842 | |
| 843 | const int spineIndex = bookMetadataCache->getTocEntry(tocIndex).spineIndex; |
| 844 | if (spineIndex < 0) { |
| 845 | LOG_DBG("EBP", "Section not found for TOC index %d", tocIndex); |
| 846 | return 0; |
| 847 | } |
| 848 | |
| 849 | return spineIndex; |
| 850 | } |
| 851 | |
| 852 | int Epub::getTocIndexForSpineIndex(const int spineIndex) const { return getSpineItem(spineIndex).tocIndex; } |
| 853 |
nothing calls this directly
no test coverage detected