Brings ~55 mod-exclusive files to the upstream-based mod/master-resync branch: Activities (migrated to new ActivityManager pattern): - Clock/Time: SetTimeActivity, SetTimezoneOffsetActivity, NtpSyncActivity - Dictionary: DictionaryDefinitionActivity, DictionarySuggestionsActivity, DictionaryWordSelectActivity, LookedUpWordsActivity - Bookmark: EpubReaderBookmarkSelectionActivity - Book management: BookManageMenuActivity, EndOfBookMenuActivity - OPDS: OpdsServerListActivity, OpdsSettingsActivity - Utility: DirectoryPickerActivity, NumericStepperActivity Utilities (unchanged): - BookManager, BookSettings, BookmarkStore, BootNtpSync - Dictionary, LookupHistory, TimeSync, OpdsServerStore Libraries: PlaceholderCover, TableData, ChapterXPathIndexer Scripts: inject_mod_version, generate_book_icon, preview_placeholder_cover Docs: KOReader sync XPath mapping Migration changes: - ActivityWithSubactivity -> Activity base class - Callback constructors -> finish()/setResult() pattern - enterNewActivity() -> startActivityForResult() - Activity::RenderLock&& -> RenderLock&& These files won't compile yet - they reference mod settings and I18n strings that will be added in subsequent phases. Made-with: Cursor
2.9 KiB
2.9 KiB
EPUB Table Rendering Implementation
Task
Replace the [Table omitted] placeholder in the EPUB reader with full column-aligned table rendering, including grid lines, proportional column widths, and proper serialization.
Changes Made
New file
lib/Epub/Epub/TableData.h-- Lightweight structs (TableCell,TableRow,TableData) for buffering table content during SAX parsing.
Modified files
-
lib/Epub/Epub/ParsedText.h/.cpp- Added
getNaturalWidth()public method to measure the single-line content width of a ParsedText. Used by column width calculation.
- Added
-
lib/Epub/Epub/Page.h/.cpp- Added
TAG_PageTableRow = 2toPageElementTagenum. - Added
getTag()pure virtual method toPageElementbase class for tag-based serialization. - Added
PageTableCellDatastruct (cell lines, column width, x-offset). - Added
PageTableRowclass with render (grid lines + cell text), serialize, and deserialize support. - Updated
Page::serialize()to useel->getTag()instead of hardcoded tag. - Updated
Page::deserialize()to handleTAG_PageTableRow.
- Added
-
lib/Epub/Epub/parsers/ChapterHtmlSlimParser.h- Added
#include "../TableData.h". - Added table state fields:
bool inTable,std::unique_ptr<TableData> tableData. - Added
processTable()andaddTableRowToPage()method declarations.
- Added
-
lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp- Added table-related tag arrays (
TABLE_TRANSPARENT_TAGS,TABLE_SKIP_TAGS). - Replaced
[Table omitted]placeholder with full table buffering logic instartElement. - Modified
startNewTextBlockto be a no-op when inside a table (cell content stays in one ParsedText). - Added table close handling in
endElementfor</td>,</th>, and</table>. - Disabled the 750-word early split when inside a table.
- Implemented
processTable(): column width calculation (natural + proportional distribution), per-cell layout vialayoutAndExtractLines,PageTableRowcreation. - Implemented
addTableRowToPage(): page-break handling for table rows.
- Added table-related tag arrays (
Design Decisions
- Tables are buffered entirely during parsing, then processed on
</table>close (two-pass: measure then layout). - Column widths are proportional to natural content width, with equal distribution of extra space when content fits.
- Grid lines (1px) drawn around every cell; 2px horizontal cell padding.
- Nested tables are skipped (v1 limitation).
<caption>,<colgroup>,<col>are skipped;<thead>,<tbody>,<tfoot>are transparent.<th>cells get bold text. Cell text is left-aligned with no paragraph indent.- Serialization is backward-compatible: old firmware encountering the new tag will re-parse the section.
Follow-up Items
- Nested table support (currently skipped)
colspan/rowspansupport<caption>rendering as centered text above the table- CSS border detection (currently always draws grid lines)
- Consider CSS-based cell alignment