Skip to content

feat: bind the html viewport config for java and python - #640

Merged
andiwand merged 2 commits into
mainfrom
feat/jni-viewport-config
Jul 31, 2026
Merged

feat: bind the html viewport config for java and python#640
andiwand merged 2 commits into
mainfrom
feat/jni-viewport-config

Conversation

@andiwand

Copy link
Copy Markdown
Member

🤖 Generated with Claude Code

HtmlConfig::viewport_mode, spreadsheet_viewport_mode and viewport_content had no bindings, so the mobile initial zoom was stuck on whatever automatic resolved to — unreachable from OpenDocument.droid, which is the consumer the option exists for.

Java

  • new HtmlViewportMode (AUTOMATIC, FIT_WIDTH, ACTUAL_SIZE, NONE), constant order matching the C++ enum
  • HtmlConfig.viewportMode / .spreadsheetViewportMode / .viewportContent, marshalled both ways in jni_style.cpp. The two optionals follow the existing convention: nullstd::nullopt, via the -1 enum ordinal for the mode and make_string_opt/get_string_opt for the raw content.

Python

  • pyodr.HtmlViewportMode plus the three def_readwrites; pybind11/stl.h is already included, so the optionals cross as None.

Tests

test/src/internal/html/common_test.cpp already covers the mode matrix, so the new tests only prove the config crosses the bindings: a round trip through HtmlService.config() and the <meta name="viewport"> an odt actually renders with, in both suites.

Verified locally: odr_jni_junit (7/7 in HtmlTest, none skipped) and pytest python/tests/test_html.py (8 passed).

`HtmlConfig::viewport_mode`, `spreadsheet_viewport_mode` and
`viewport_content` shipped without bindings, so the mobile initial zoom was
whatever `automatic` resolved to - not reachable from OpenDocument.droid,
which is the consumer the option exists for.

Java gets `HtmlViewportMode` (ordinals matching the C++ enum, `null` for the
absent optional, as everywhere else in the marshalling) plus the three
`HtmlConfig` fields; python gets the enum and three `def_readwrite`s.

The C++ suite already covers the mode matrix, so the new tests only prove the
config crosses the binding: a round trip through `HtmlService.config()`, and
the meta tag an odt renders with.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qis7KBzd1YHZqPa9ZEd6WV
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR exposes the existing C++ HTML viewport configuration (HtmlViewportMode and HtmlConfig’s viewport fields) through the Java (JNI) and Python bindings, enabling mobile clients (notably OpenDocument.droid) to control the generated <meta name="viewport"> behavior instead of being locked to the default automatic resolution.

Changes:

  • Added HtmlViewportMode enum bindings for both Python (pyodr.HtmlViewportMode) and Java (app.opendocument.core.HtmlViewportMode).
  • Bound HtmlConfig.viewportMode, HtmlConfig.spreadsheetViewportMode (nullable), and HtmlConfig.viewportContent across JNI and pybind11.
  • Added Java and Python tests to validate that viewport config round-trips through bindings and affects rendered HTML output.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
python/tests/test_html.py Adds Python-level regression tests for viewport defaults and emitted viewport meta tag.
python/src/bind_html.cpp Exposes HtmlViewportMode and HtmlConfig viewport fields via pybind11.
jni/tests/app/opendocument/core/HtmlTest.java Adds JNI tests for viewport defaults, round-trip config, and emitted viewport meta tag.
jni/src/jni_style.cpp Marshals viewport-related fields between odr::HtmlConfig and Java HtmlConfig.
jni/java/app/opendocument/core/HtmlViewportMode.java Introduces Java enum mirroring odr::HtmlViewportMode ordinal mapping.
jni/java/app/opendocument/core/HtmlConfig.java Adds Java-facing viewport configuration fields (mode, spreadsheet override, raw content).
jni/CMakeLists.txt Includes the new HtmlViewportMode.java in the Java build.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread jni/src/jni_style.cpp Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@andiwand
andiwand enabled auto-merge (squash) July 31, 2026 21:33
@andiwand
andiwand merged commit 242bf68 into main Jul 31, 2026
27 checks passed
@andiwand
andiwand deleted the feat/jni-viewport-config branch July 31, 2026 21:36
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.

2 participants