config_host.mk.in | 2 +- solenv/gbuild/platform/unxgcc.mk | 2 +- static/README.wasm.md | 20 ++++++++++++++++++-- static/emscripten/soffice_args.js | 4 +--- 4 files changed, 21 insertions(+), 7 deletions(-)
New commits: commit dd332f72ce68d2a6109e390b8e45e84143d10960 Author: Stephan Bergmann <stephan.bergm...@allotropia.de> AuthorDate: Thu Jul 25 16:59:33 2024 +0200 Commit: Stephan Bergmann <stephan.bergm...@allotropia.de> CommitDate: Thu Jul 25 18:37:58 2024 +0200 Enable start center in Emscripten build ...and let it open with that instead of with a hard-coded example.odt. (But keep that example.odt in CustomTarget,static_emscripten_fs_image and adapt the example code in static/README.wasm.md to explicitly load it now.) Change-Id: Ie43e3795e44542acba5a8e755f65acc56fa753f8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171019 Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de> Tested-by: Jenkins diff --git a/config_host.mk.in b/config_host.mk.in index 4a5b6c12e843..70e8552fdced 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -252,7 +252,7 @@ export ENABLE_WASM_STRIP_LANGUAGETOOL=@ENABLE_WASM_STRIP@ export ENABLE_WASM_STRIP_LOCALES=@ENABLE_WASM_STRIP@ export ENABLE_WASM_STRIP_PINGUSER=@ENABLE_WASM_STRIP@ export ENABLE_WASM_STRIP_PREMULTIPLY=@ENABLE_WASM_STRIP@ -export ENABLE_WASM_STRIP_RECENT=@ENABLE_WASM_STRIP@ +export ENABLE_WASM_STRIP_RECENT= export ENABLE_WASM_STRIP_RECOVERYUI=@ENABLE_WASM_STRIP@ export ENABLE_WASM_STRIP_SPLASH=@ENABLE_WASM_STRIP@ export ENABLE_WASM_STRIP_SWEXPORTS=@ENABLE_WASM_STRIP@ diff --git a/solenv/gbuild/platform/unxgcc.mk b/solenv/gbuild/platform/unxgcc.mk index 68ea5c571c32..591eceeb9839 100644 --- a/solenv/gbuild/platform/unxgcc.mk +++ b/solenv/gbuild/platform/unxgcc.mk @@ -185,7 +185,7 @@ $(if $(filter TRUE,$(ENABLE_QT5)), \ sed -e 's/@APPNAME@/$(subst $(gb_Executable_EXT),,$(notdir $(1)))/' $(QT5_PLATFORMS_SRCDIR)/wasm_shell.html > $(dir $(1))qt_$(notdir $(1)) && \ cp $(QT5_PLATFORMS_SRCDIR)/qtlogo.svg $(QT5_PLATFORMS_SRCDIR)/qtloader.js $(dir $(1)) && \ ,$(if $(filter TRUE,$(ENABLE_QT6)), \ - sed -e 's/@APPNAME@/$(basename $(notdir $(1)))/g' -e 's/@APPEXPORTNAME@/$(basename $(notdir $(1)))_entry/g' -e 's/@PRELOAD@//g' -e 's|const instance = await qtLoad$(OPEN_PAREN){|const instance = await qtLoad$(OPEN_PAREN){ "arguments": ["--norestore"$(COMMA) "--nologo"$(COMMA) "--writer"$(COMMA) "/android/default-document/example.odt"]$(COMMA)|' -e 's/}$(CLOSE_PAREN);$$/}$(CLOSE_PAREN); window.Module = instance;/' $(QT6_PLATFORMS_SRCDIR)/wasm_shell.html > $(dir $(1))qt_$(basename $(notdir $(1))).html && \ + sed -e 's/@APPNAME@/$(basename $(notdir $(1)))/g' -e 's/@APPEXPORTNAME@/$(basename $(notdir $(1)))_entry/g' -e 's/@PRELOAD@//g' -e 's|const instance = await qtLoad$(OPEN_PAREN){|const instance = await qtLoad$(OPEN_PAREN){ "arguments": ["--norestore"$(COMMA) "--nologo"]$(COMMA)|' -e 's/}$(CLOSE_PAREN);$$/}$(CLOSE_PAREN); window.Module = instance;/' $(QT6_PLATFORMS_SRCDIR)/wasm_shell.html > $(dir $(1))qt_$(basename $(notdir $(1))).html && \ cp $(QT6_PLATFORMS_SRCDIR)/qtlogo.svg $(QT6_PLATFORMS_SRCDIR)/qtloader.js $(dir $(1)) && \ )) \ cp $(gb_CustomTarget_workdir)/static/emscripten_fs_image/soffice.data $(dir $(1))/soffice.data && \ diff --git a/static/README.wasm.md b/static/README.wasm.md index a28a23efac67..4cf0688d0796 100644 --- a/static/README.wasm.md +++ b/static/README.wasm.md @@ -182,7 +182,15 @@ Some usage examples through javascript of the current implementation: // inserts a string at the start of the Writer document. Module.uno_init.then(function() { const css = Module.uno.com.sun.star; - const xModel = Module.getCurrentModelFromViewSh(); + let xModel = Module.getCurrentModelFromViewSh(); + if (xModel === null || !css.text.XTextDocument.query(xModel)) { + const desktop = css.frame.Desktop.create(Module.getUnoComponentContext()); + const args = new Module.uno_Sequence_com$sun$star$beans$PropertyValue( + 0, Module.uno_Sequence.FromSize); + xModel = css.frame.XComponentLoader.query(desktop).loadComponentFromURL( + 'file:///android/default-document/example.odt', '_default', 0, args); + args.delete(); + } const xTextDocument = css.text.XTextDocument.query(xModel); const xText = xTextDocument.getText(); const xTextCursor = xText.createTextCursor(); @@ -194,7 +202,15 @@ Module.uno_init.then(function() { // changes each paragraph of the Writer document to a random color. Module.uno_init.then(function() { const css = Module.uno.com.sun.star; - const xModel = Module.getCurrentModelFromViewSh(); + let xModel = Module.getCurrentModelFromViewSh(); + if (xModel === null || !css.text.XTextDocument.query(xModel)) { + const desktop = css.frame.Desktop.create(Module.getUnoComponentContext()); + const args = new Module.uno_Sequence_com$sun$star$beans$PropertyValue( + 0, Module.uno_Sequence.FromSize); + xModel = css.frame.XComponentLoader.query(desktop).loadComponentFromURL( + 'file:///android/default-document/example.odt', '_default', 0, args); + args.delete(); + } const xTextDocument = css.text.XTextDocument.query(xModel); const xText = xTextDocument.getText(); const xEnumAccess = css.container.XEnumerationAccess.query(xText); diff --git a/static/emscripten/soffice_args.js b/static/emscripten/soffice_args.js index 6881741bdf0b..7656c7edee7e 100644 --- a/static/emscripten/soffice_args.js +++ b/static/emscripten/soffice_args.js @@ -2,7 +2,5 @@ Module['arguments'] = [ '--norestore', - '--nologo', - '--writer', - '/android/default-document/example.odt' + '--nologo' ];