Integrate PT 1455
This commit is contained in:
@@ -23,6 +23,15 @@ class Section {
|
||||
bool embeddedStyle, uint8_t imageRendering);
|
||||
uint32_t onPageComplete(std::unique_ptr<Page> page);
|
||||
|
||||
struct TocBoundary {
|
||||
int tocIndex = 0;
|
||||
uint16_t startPage = 0;
|
||||
};
|
||||
std::vector<TocBoundary> tocBoundaries;
|
||||
|
||||
void buildTocBoundaries(const std::vector<std::pair<std::string, uint16_t>>& anchors);
|
||||
void buildTocBoundariesFromFile(FsFile& f);
|
||||
|
||||
public:
|
||||
uint16_t pageCount = 0;
|
||||
int currentPage = 0;
|
||||
@@ -42,6 +51,19 @@ class Section {
|
||||
uint8_t imageRendering, const std::function<void(int)>& progressFn = nullptr);
|
||||
std::unique_ptr<Page> loadPageFromSectionFile();
|
||||
|
||||
// Given a page in this section, return the TOC index for that page.
|
||||
int getTocIndexForPage(int page) const;
|
||||
// Given a TOC index, return the start page in this section.
|
||||
// Returns nullopt if the TOC index doesn't map to a boundary in this spine (e.g. belongs to a different spine).
|
||||
std::optional<int> getPageForTocIndex(int tocIndex) const;
|
||||
|
||||
struct TocPageRange {
|
||||
int startPage; // inclusive
|
||||
int endPage; // exclusive
|
||||
};
|
||||
// Returns the page range [start, end) within this spine that belongs to the given TOC index.
|
||||
std::optional<TocPageRange> getPageRangeForTocIndex(int tocIndex) const;
|
||||
|
||||
// Look up the page number for an anchor id from the section cache file.
|
||||
std::optional<uint16_t> getPageForAnchor(const std::string& anchor) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user