From e8293f9182361104f2f849b4f78f393e4b984712 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Sun, 6 Sep 2026 13:49:29 +0200 Subject: [PATCH] refactor(api)!: drop the inert config and charset surface Four HtmlConfig fields stored a value no view read: background_image_format and background_image_dpi, from when a background was rendered to a file; no_drm, from when the output carried a restriction; embed_outline, from when one was written. Gone with their java, python, objc and wasm mirrors. TextFile::charset() went with them - encoding() answers it as a TextEncoding, and reports unknown where charset() returned nullopt - and so did UnknownCharset, which nothing has thrown since a file that cannot be named is still text. The bindings keep their own charset() accessors: those read encoding() rather than the removed overload, and are the shape a binding wants until the enum itself is mirrored. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_016hxDa2rev11eLUEJZJ5nmz --- CHANGELOG.md | 8 ++++++++ apple/include/OdrCoreObjC/ODRHtml.h | 10 ---------- apple/src/ODRHtml.mm | 8 -------- jni/java/app/opendocument/core/HtmlConfig.java | 12 ------------ jni/src/jni_style.cpp | 8 -------- python/src/bind_html.cpp | 10 ---------- src/odr/exceptions.cpp | 2 -- src/odr/exceptions.hpp | 7 ------- src/odr/file.cpp | 8 -------- src/odr/file.hpp | 5 ----- src/odr/html.hpp | 11 ----------- wasm/js/index.d.ts | 8 -------- wasm/src/wasm_html.cpp | 5 ----- 13 files changed, 8 insertions(+), 94 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81a9ba139..d687487fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,14 @@ The release run heads these entries with the version and opens a fresh ## Unreleased +- **Breaking**: the inert `HtmlConfig` fields `background_image_format`, + `background_image_dpi`, `no_drm` and `embed_outline` are gone, with their + java, python, objc and wasm mirrors. Drop them; nothing replaces them. + +- **Breaking**: `TextFile::charset()` and the `UnknownCharset` exception are + gone. Use `TextFile::encoding()`, which returns `TextEncoding::unknown` where + `charset()` returned `nullopt`. The bindings' own `charset()` is unchanged. + - **Breaking**: `GlobalParams` is gone, with its java, python and objc mirrors, `OdrAndroid.init`, and the `ODR_WITH_LIBMAGIC` / `ODR_BUNDLE_ASSETS` cmake options. All of it was inert; delete the calls, nothing replaces them. diff --git a/apple/include/OdrCoreObjC/ODRHtml.h b/apple/include/OdrCoreObjC/ODRHtml.h index cf89c19da..e482b6d73 100644 --- a/apple/include/OdrCoreObjC/ODRHtml.h +++ b/apple/include/OdrCoreObjC/ODRHtml.h @@ -122,11 +122,6 @@ NS_SWIFT_NAME(HtmlConfig) @property(nonatomic) uint8_t htmlIndent; @property(nonatomic, copy) NSString *htmlIndentString; -/// @deprecated Inert. -@property(nonatomic, copy) NSString *backgroundImageFormat; -/// @deprecated Inert. -@property(nonatomic) double backgroundImageDpi; - /// Render only pages `[begin, end)`, 0-based. `nil` end means to the last page. @property(nonatomic) uint32_t pageRangeBegin; @property(nonatomic, strong, nullable) @@ -136,11 +131,6 @@ NS_SWIFT_NAME(HtmlConfig) @property(nonatomic, copy) NSArray *pdfDualLayerFallbackFonts; @property(nonatomic) double pdfDualLayerFallbackFontSizeAdjust; -/// @deprecated Inert. -@property(nonatomic) BOOL noDrm; -/// @deprecated Inert. -@property(nonatomic) BOOL embedOutline; - @property(nonatomic, copy, nullable) NSString *outputPath; @end diff --git a/apple/src/ODRHtml.mm b/apple/src/ODRHtml.mm index 25e52f745..4f3c70b98 100644 --- a/apple/src/ODRHtml.mm +++ b/apple/src/ODRHtml.mm @@ -124,8 +124,6 @@ - (instancetype)initWithNativeConfig:(const odr::HtmlConfig &)config { _formatHtml = config.format_html ? YES : NO; _htmlIndent = config.html_indent; _htmlIndentString = to_nsstring(config.html_indent_string); - _backgroundImageFormat = to_nsstring(config.background_image_format); - _backgroundImageDpi = config.background_image_dpi; _pageRangeBegin = config.page_range_begin; _pageRangeEnd = config.page_range_end.has_value() ? @(static_cast(*config.page_range_end)) @@ -134,8 +132,6 @@ - (instancetype)initWithNativeConfig:(const odr::HtmlConfig &)config { _pdfDualLayerFallbackFonts = to_nsarray(config.pdf_dual_layer_fallback_fonts); _pdfDualLayerFallbackFontSizeAdjust = config.pdf_dual_layer_fallback_font_size_adjust; - _noDrm = config.no_drm ? YES : NO; - _embedOutline = config.embed_outline ? YES : NO; _outputPath = config.output_path.has_value() ? to_nsstring(*config.output_path) : nil; return self; @@ -211,8 +207,6 @@ - (instancetype)initWithNativeConfig:(const odr::HtmlConfig &)config { config.format_html = _formatHtml == YES; config.html_indent = _htmlIndent; config.html_indent_string = to_string(_htmlIndentString); - config.background_image_format = to_string(_backgroundImageFormat); - config.background_image_dpi = _backgroundImageDpi; config.page_range_begin = _pageRangeBegin; if (_pageRangeEnd != nil) { config.page_range_end = @@ -224,8 +218,6 @@ - (instancetype)initWithNativeConfig:(const odr::HtmlConfig &)config { config.pdf_dual_layer_fallback_fonts = to_strings(_pdfDualLayerFallbackFonts); config.pdf_dual_layer_fallback_font_size_adjust = _pdfDualLayerFallbackFontSizeAdjust; - config.no_drm = _noDrm == YES; - config.embed_outline = _embedOutline == YES; if (_outputPath != nil) { config.output_path = to_string(_outputPath); } else { diff --git a/jni/java/app/opendocument/core/HtmlConfig.java b/jni/java/app/opendocument/core/HtmlConfig.java index 17e3d6a09..2c82a38c1 100644 --- a/jni/java/app/opendocument/core/HtmlConfig.java +++ b/jni/java/app/opendocument/core/HtmlConfig.java @@ -62,12 +62,6 @@ public final class HtmlConfig { public int htmlIndent = 1; public String htmlIndentString = "\t"; - /** @deprecated Inert. */ - @Deprecated public String backgroundImageFormat = "png"; - - /** @deprecated Inert. */ - @Deprecated public double backgroundImageDpi = 144.0; - public int pageRangeBegin = 0; /** {@code null} renders to the end of the document. */ public Integer pageRangeEnd; @@ -78,12 +72,6 @@ public final class HtmlConfig { }; public double pdfDualLayerFallbackFontSizeAdjust = 0.5; - /** @deprecated Inert. */ - @Deprecated public boolean noDrm = false; - - /** @deprecated Inert. */ - @Deprecated public boolean embedOutline = false; - /** {@code null} keeps output in the cache directory. */ public String outputPath; } diff --git a/jni/src/jni_style.cpp b/jni/src/jni_style.cpp index 62e7258f0..ac610906b 100644 --- a/jni/src/jni_style.cpp +++ b/jni/src/jni_style.cpp @@ -489,8 +489,6 @@ jobject html_config_to_java(JNIEnv *env, const odr::HtmlConfig &config) { set_boolean("formatHtml", config.format_html); set_int("htmlIndent", config.html_indent); set_string("htmlIndentString", config.html_indent_string); - set_string("backgroundImageFormat", config.background_image_format); - set_double("backgroundImageDpi", config.background_image_dpi); set_int("pageRangeBegin", static_cast(config.page_range_begin)); set_object("pageRangeEnd", "Ljava/lang/Integer;", box_integer(env, config.page_range_end)); @@ -514,8 +512,6 @@ jobject html_config_to_java(JNIEnv *env, const odr::HtmlConfig &config) { } set_double("pdfDualLayerFallbackFontSizeAdjust", config.pdf_dual_layer_fallback_font_size_adjust); - set_boolean("noDrm", config.no_drm); - set_boolean("embedOutline", config.embed_outline); set_object("outputPath", "Ljava/lang/String;", make_string_opt(env, config.output_path)); @@ -678,8 +674,6 @@ odr::HtmlConfig html_config_from_java(JNIEnv *env, jobject config) { result.format_html = get_boolean("formatHtml"); result.html_indent = static_cast(get_int("htmlIndent")); result.html_indent_string = get_string("htmlIndentString"); - result.background_image_format = get_string("backgroundImageFormat"); - result.background_image_dpi = get_double("backgroundImageDpi"); result.page_range_begin = static_cast(get_int("pageRangeBegin")); { @@ -716,8 +710,6 @@ odr::HtmlConfig html_config_from_java(JNIEnv *env, jobject config) { } result.pdf_dual_layer_fallback_font_size_adjust = get_double("pdfDualLayerFallbackFontSizeAdjust"); - result.no_drm = get_boolean("noDrm"); - result.embed_outline = get_boolean("embedOutline"); result.output_path = get_string_opt("outputPath"); env->DeleteLocalRef(cls); diff --git a/python/src/bind_html.cpp b/python/src/bind_html.cpp index c6da5f602..a1a5ae2e9 100644 --- a/python/src/bind_html.cpp +++ b/python/src/bind_html.cpp @@ -101,12 +101,6 @@ void odr_python::bind_html(py::module_ &m) { .def_readwrite("format_html", &odr::HtmlConfig::format_html) .def_readwrite("html_indent", &odr::HtmlConfig::html_indent) .def_readwrite("html_indent_string", &odr::HtmlConfig::html_indent_string) - .def_readwrite("background_image_format", - &odr::HtmlConfig::background_image_format, - "Deprecated and inert.") - .def_readwrite("background_image_dpi", - &odr::HtmlConfig::background_image_dpi, - "Deprecated and inert.") .def_readwrite("page_range_begin", &odr::HtmlConfig::page_range_begin) .def_readwrite("page_range_end", &odr::HtmlConfig::page_range_end) .def_readwrite("pdf_text_mode", &odr::HtmlConfig::pdf_text_mode) @@ -114,10 +108,6 @@ void odr_python::bind_html(py::module_ &m) { &odr::HtmlConfig::pdf_dual_layer_fallback_fonts) .def_readwrite("pdf_dual_layer_fallback_font_size_adjust", &odr::HtmlConfig::pdf_dual_layer_fallback_font_size_adjust) - .def_readwrite("no_drm", &odr::HtmlConfig::no_drm, - "Deprecated and inert.") - .def_readwrite("embed_outline", &odr::HtmlConfig::embed_outline, - "Deprecated and inert.") .def_readwrite("output_path", &odr::HtmlConfig::output_path) .def_readwrite("resource_locator", &odr::HtmlConfig::resource_locator); diff --git a/src/odr/exceptions.cpp b/src/odr/exceptions.cpp index 1756bbd74..f58648ed2 100644 --- a/src/odr/exceptions.cpp +++ b/src/odr/exceptions.cpp @@ -49,8 +49,6 @@ NoMarkdownFile::NoMarkdownFile() : Exception("not a markdown file") {} NoJsonFile::NoJsonFile() : Exception("not a json file") {} -UnknownCharset::UnknownCharset() : Exception("unknown charset") {} - NoImageFile::NoImageFile() : Exception("not an image file") {} NoArchiveFile::NoArchiveFile() : Exception("not an archive file") {} diff --git a/src/odr/exceptions.hpp b/src/odr/exceptions.hpp index 8b282bad7..e5c838e46 100644 --- a/src/odr/exceptions.hpp +++ b/src/odr/exceptions.hpp @@ -100,13 +100,6 @@ struct NoJsonFile final : Exception { NoJsonFile(); }; -/// @brief Unknown charset exception -/// @deprecated Nothing throws this any more: a file whose encoding cannot be -/// named is still text, and reports @ref TextEncoding::unknown. -struct [[deprecated("nothing throws this")]] UnknownCharset final : Exception { - UnknownCharset(); -}; - /// @brief No image file exception struct NoImageFile final : Exception { NoImageFile(); diff --git a/src/odr/file.cpp b/src/odr/file.cpp index 087a85ecd..d42ec4d8a 100644 --- a/src/odr/file.cpp +++ b/src/odr/file.cpp @@ -301,14 +301,6 @@ TextFile::TextFile(std::shared_ptr impl) TextEncoding TextFile::encoding() const { return m_impl->encoding(); } -std::optional TextFile::charset() const { - const TextEncoding encoding = this->encoding(); - if (encoding == TextEncoding::unknown) { - return {}; - } - return std::string(text_encoding_to_string(encoding)); -} - std::unique_ptr TextFile::stream() const { return m_impl->file()->stream(); } diff --git a/src/odr/file.hpp b/src/odr/file.hpp index 36bd8b092..a095c55dc 100644 --- a/src/odr/file.hpp +++ b/src/odr/file.hpp @@ -424,11 +424,6 @@ class TextFile final : public DecodedFile { /// @brief The encoding the file's bytes were detected as, or decoded with. [[nodiscard]] TextEncoding encoding() const; - /// @deprecated See @ref encoding. Returns the encoding's canonical name, and - /// `nullopt` for @ref TextEncoding::unknown. - [[deprecated("use encoding()")]] [[nodiscard]] std::optional - charset() const; - /// @brief The file's bytes as they are. [[nodiscard]] std::unique_ptr stream() const; /// @brief The file's text, decoded to UTF-8 where @ref encoding is diff --git a/src/odr/html.hpp b/src/odr/html.hpp index 591c522d8..d564d28de 100644 --- a/src/odr/html.hpp +++ b/src/odr/html.hpp @@ -175,11 +175,6 @@ struct HtmlConfig { std::uint8_t html_indent{1}; std::string html_indent_string{"\t"}; - /// @deprecated Inert: no view renders a background image to a file. - std::string background_image_format{"png"}; - /// @deprecated See @ref background_image_format. - double background_image_dpi{144.0}; - /// Renders only the pages with 0-based index in `[page_range_begin, /// page_range_end)`; page views and `#pN` anchors keep their document-global /// numbers. Honored by the pdf pipeline. @@ -196,12 +191,6 @@ struct HtmlConfig { /// fill the box. Safe to underestimate: the excess is clipped, not shrunk. double pdf_dual_layer_fallback_font_size_adjust{0.5}; - /// @deprecated Inert: no output carries a restriction to lift. - bool no_drm{false}; - - /// @deprecated Inert: an outline is never written. - bool embed_outline{false}; - std::optional output_path; HtmlResourceLocator resource_locator; diff --git a/wasm/js/index.d.ts b/wasm/js/index.d.ts index c69ab08e7..b73b7c01e 100644 --- a/wasm/js/index.d.ts +++ b/wasm/js/index.d.ts @@ -86,14 +86,6 @@ export interface HtmlConfig { editable?: boolean; textDocumentMargin?: boolean; formatHtml?: boolean; - /** @deprecated Inert. */ - embedOutline?: boolean; - /** @deprecated Inert. */ - noDrm?: boolean; - /** @deprecated Inert. */ - backgroundImageFormat?: string; - /** @deprecated Inert. */ - backgroundImageDpi?: number; pageRangeBegin?: number; pageRangeEnd?: number; colorScheme?: number; diff --git a/wasm/src/wasm_html.cpp b/wasm/src/wasm_html.cpp index 2f4eeae8d..203948087 100644 --- a/wasm/src/wasm_html.cpp +++ b/wasm/src/wasm_html.cpp @@ -159,11 +159,6 @@ HtmlConfig to_html_config(const emscripten::val &value) { read(value, "editable", config.editable); read(value, "textDocumentMargin", config.text_document_margin); read(value, "formatHtml", config.format_html); - read(value, "embedOutline", config.embed_outline); - read(value, "noDrm", config.no_drm); - - read(value, "backgroundImageFormat", config.background_image_format); - read(value, "backgroundImageDpi", config.background_image_dpi); read(value, "pageRangeBegin", config.page_range_begin); if (const emscripten::val end = value["pageRangeEnd"];