summaryrefslogtreecommitdiff
path: root/static/README.wasm.md
diff options
context:
space:
mode:
Diffstat (limited to 'static/README.wasm.md')
-rw-r--r--static/README.wasm.md20
1 files changed, 18 insertions, 2 deletions
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);