.uno:InsertDoc - how to use?

Hi there,

I am testing CODE

I would like to insert a document into the active editor programatically using the .uno:InsertDoc command.

I have created the following function:

function sendInsertDoc(name) {
  post({'MessageId': 'Send_UNO_Command',
    'Values': {
      'Command': '.uno:InsertDoc',
      'Args': {
        Name: {
          type: 'string',
          value: `${name}.docx`
        Filter: {
          type: 'string',
          value: ``

And when I call it, sendInsertDoc('123'), I see:

kit-03405-00023 2023-06-18 16:06:51.956260 +0000 [ kitbroker_12e ] DBG #17: child_ws: recv [child-617a uno .uno:InsertDoc {"Name":{"type":"string","value":"123.docx"},"Filter":{"type":"string","value":""}} | kit/Kit.cpp:2453

… in the docker-compose logs.

However there is no mention of an incoming request for the file to the WOPI host … which I find puzzling.

How to I supply the file to the WOPI client? … there is no error messages, nothing at all other than the message from Kit.cpp.

The example sendInsertBookMarkUNOCommand() from here: online/browser/html/framed.doc.html at master · CollaboraOnline/online · GitHub works as expected.

Any ideas please?

1 Like

This will need implementing and handling in coolwsd’s DocumentBroker to be able to fetch the file, insert it into the jail and hand a re-written UNO command to the Kit process. This shouldn’t be unfeasibly difficult - happy to provide some code-pointers if you like. I would imagine the command essentially passes a path through to the kit that is to a file that doesn’t exist in the jail - if it makes it through at all; we white-list supported UNO commands in the core in desktop/source/lib/ - and I suspect this is not one (yet). Hope that helps.

1 Like

Thanks for your response.

Yes I studied the code on GitHub and came to similar ('tho less in depth) conclusion myself.

My current (hacky) plan is to initiate another off screen instance of the editor and use the browser clipboard to amalgamate the docs. My preference would be using uno commands because I am not sure whether the clipboard api will be complaining about clipboard access at every request or not …

If you are able to provide any further hints that would be great, I would love to contribute to this project.


1 Like

Hey - we’d love to have you contribute. So @ash would be the best person to help you here I think;
bool DocumentBroker::download(const std::shared_ptr& session, const std::string& jailId)
has the code for a synchronous download that would need re-factoring out I guess. I think we’d need to catch the UNO command passing by in bool ClientSession::filterMessage(const std::string& message) const and re-write it to handle the newly downloaded file. Hopefully that helps a bit ?
Then again @ash is doing some even-more-async work around this code AFAIR that will need merging soon.

1 Like