Review comments
This commit is contained in:
@@ -55,9 +55,13 @@ class ChapterXPathIndexer {
|
|||||||
* Parse DocFragment index from KOReader-style path segment:
|
* Parse DocFragment index from KOReader-style path segment:
|
||||||
* /body/DocFragment[N]/body/...
|
* /body/DocFragment[N]/body/...
|
||||||
*
|
*
|
||||||
|
* KOReader uses 1-based DocFragment indices; N is converted to the 0-based
|
||||||
|
* spine index stored in outSpineIndex (i.e. outSpineIndex = N - 1).
|
||||||
|
*
|
||||||
* @param xpath KOReader XPath
|
* @param xpath KOReader XPath
|
||||||
* @param outSpineIndex Parsed DocFragment index (0-based)
|
* @param outSpineIndex 0-based spine index derived from DocFragment[N]
|
||||||
* @return true when DocFragment[N] exists and N is valid integer >= 0
|
* @return true when DocFragment[N] exists and N is a valid integer >= 1
|
||||||
|
* (converted to 0-based outSpineIndex); false otherwise
|
||||||
*/
|
*/
|
||||||
static bool tryExtractSpineIndexFromXPath(const std::string& xpath, int& outSpineIndex);
|
static bool tryExtractSpineIndexFromXPath(const std::string& xpath, int& outSpineIndex);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <Logging.h>
|
#include <Logging.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "ChapterXPathIndexer.h"
|
#include "ChapterXPathIndexer.h"
|
||||||
@@ -71,7 +72,12 @@ CrossPointPosition ProgressMapper::toCrossPoint(const std::shared_ptr<Epub>& epu
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t targetBytes = static_cast<size_t>(bookSize * koPos.percentage);
|
if (!std::isfinite(koPos.percentage)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
const float sanitizedPercentage = std::clamp(koPos.percentage, 0.0f, 1.0f);
|
||||||
|
const size_t targetBytes = static_cast<size_t>(bookSize * sanitizedPercentage);
|
||||||
|
|
||||||
bool spineFound = false;
|
bool spineFound = false;
|
||||||
for (int i = 0; i < spineCount; i++) {
|
for (int i = 0; i < spineCount; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user