Skip to content

Pick the pages before rendering them, like OpenDocument.droid - #124

Merged
andiwand merged 1 commit into
mainfrom
core-page-selection
Jul 26, 2026
Merged

Pick the pages before rendering them, like OpenDocument.droid#124
andiwand merged 1 commit into
mainfrom
core-page-selection

Conversation

@andiwand

@andiwand andiwand commented Jul 26, 2026

Copy link
Copy Markdown
Member

🤖 Generated with Claude Code

Why

CoreWrapper decided which odrcore views become pages per document type: keep the combined document view for presentations and drawings, drop it for spreadsheets, keep everything for anything else.

OpenDocument.droid asks a different question — does the service have a combined view at all? — and that rule also holds for the formats iOS never enumerated. A PDF translated by core has a combined view plus one view per page, so the old rule would have shown a tab per page right next to the tab that already contains all of them. PDFs still go to WKWebView, so nothing about them changes here; the point is that the rule no longer needs another if when they stop doing so.

What changed

  • CoreWrapperSelectViews replaces shouldSkipPageNamed:ofDocumentType: — spreadsheets drop the combined view, everything else keeps only the combined view when there is one, and services without one (plain text, images) keep whatever they offer. Same rule as core_wrapper.cpp on Android.
  • The selection now happens before rendering. bring_offline() wrote every view to disk and the discarded ones were thrown away afterwards, so a 50 slide deck wrote 51 HTML files to display one. bring_offline(path, views) renders only what will be shown.

Tests

Four new cases in OpenDocumentReaderTests: a text document is one page, a spreadsheet is one page per sheet, a presentation is only the combined page, and — the one that fails on main — the slides of a presentation are no longer written to the output directory.

The two fixtures are minimal ODF packages generated by OpenDocumentReaderTests/fixtures/make-fixtures.py (~1 KB each), rather than samples from OpenDocument.test that are megabytes of third party material.

Verified locally: xcodebuild test on the iPhone 17 simulator, all 24 tests pass, plus scripts/format.sh.

Which odrcore views become pages was decided per document type: keep the
combined "document" view for presentations and drawings, drop it for
spreadsheets, keep everything for anything else. OpenDocument.droid asks
a different question - is there a combined view at all? - and that one
also holds for the formats iOS did not enumerate. A PDF translated by
core has a combined view plus one view per page, so the old rule would
have offered a tab per page next to the tab that already has them all.
PDFs still go to WKWebView, so this is not visible yet; the point is
that the rule no longer has to be extended when they stop doing so.

The selection also moved in front of the rendering. `bring_offline()`
wrote out every view and the discarded ones were dropped afterwards, so
a fifty slide deck wrote fifty one HTML files to show one of them.
`bring_offline(path, views)` renders only what is going to be shown.

The two fixtures are minimal ODF packages built by the script next to
them, a few hundred bytes each, rather than samples from
OpenDocument.test that are megabytes of third party material.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011MhKU2kWm1cPW4GBq9gon5
@andiwand
andiwand merged commit fb8a86e into main Jul 26, 2026
4 checks passed
@andiwand
andiwand deleted the core-page-selection branch July 26, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant