From 11d654788908a30ea4f7481f8474c334df83ae32 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 23 Jul 2026 08:43:26 +0200 Subject: [PATCH] Handle missing default values in JS UNO structs Signed-off-by: Stephan Bergmann Change-Id: I63b589645a8c1efc95b6fb023931c45b1d08b65e Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/7624 Reviewed-by: Michael Stahl Tested-by: Jenkins CPCI (cherry picked from commit 0e55d63d948f177f3b3dabf459000b576e169815) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208737 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- jsuno/source/jsuno.cxx | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/jsuno/source/jsuno.cxx b/jsuno/source/jsuno.cxx index 080167190977..633140e3d28b 100644 --- a/jsuno/source/jsuno.cxx +++ b/jsuno/source/jsuno.cxx @@ -2131,15 +2131,29 @@ css::uno::Any fromJs(JSContext* ctx, css::uno::Type const& type, JSValueConst va } if (has == 0) { - JS_ThrowTypeError(ctx, "TODO: BAD UNO STRUCT VALUE"); - throw JsException(); + if (compDesc->ppTypeRefs[i]->eTypeClass == typelib_TypeClass_ANY) + { + mems.emplace_back(); + } + else + { + css::uno::TypeDescription memDesc(compDesc->ppTypeRefs[i]); + memDesc.makeComplete(); + std::vector buf(memDesc.get()->nSize, 0); + uno_constructData(buf.data(), memDesc.get()); + mems.emplace_back(buf.data(), css::uno::Type(compDesc->ppTypeRefs[i])); + uno_destructData(buf.data(), memDesc.get(), css::uno::cpp_release); + } } - ValueRef mem(ctx, JS_GetProperty(ctx, val, a)); - if (JS_IsException(mem)) + else { - throw JsException(); + ValueRef mem(ctx, JS_GetProperty(ctx, val, a)); + if (JS_IsException(mem)) + { + throw JsException(); + } + mems.push_back(fromJs(ctx, compDesc->ppTypeRefs[i], mem)); } - mems.push_back(fromJs(ctx, compDesc->ppTypeRefs[i], mem)); } compDesc = compDesc->pBaseTypeDescription; if (compDesc == nullptr)