Bug 103641 - postMessage API: File menu commands
Summary: postMessage API: File menu commands
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice Online
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:5.3.0 target:5.3.0.4
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-02 09:09 UTC by Aleksander Machniak
Modified: 2017-03-02 11:44 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aleksander Machniak 2016-11-02 09:09:23 UTC
I'd like to implement a toolbar on the host page that will "proxy" some of the editor toolbar functionality. I'd like to hide completely "File" menu and "Save" button.

So, one thing is a way to tell the editor to not display some of the UI (File menu and Save button).

The other thing is postMessage API extension with:

1. "Action_Save" command - just emit click on "Save" button
2. "Action_Print" command - just emit click on Print menu item
3. "Action_Export" command - just emit click on "Download as" with pre-selected output format.
4. "Export_Formats"/"Export_Formats_Resp" commands - to get supported export formats. This should return an array of:
   "label" - file type description
   "format" - file mimetype (used for input for "Action_Export").


BTW, is there a simple way to remove the logo element at all? I see that even with branding.css it's not so simple as it requires some style to move the menus/toolbars to the left.

I'm using loolwsd 1.9.5.
Comment 1 Pranav Kant 2016-11-10 13:03:27 UTC
(In reply to Aleksander Machniak from comment #0)
> 1. "Action_Save" command - just emit click on "Save" button
> 2. "Action_Print" command - just emit click on Print menu item
> 3. "Action_Export" command - just emit click on "Download as" with
> pre-selected output format.
> 4. "Export_Formats"/"Export_Formats_Resp" commands - to get supported export
> formats. This should return an array of:
>    "label" - file type description

Should it (label) be a localized string ? Loleaflet has localisation string for descriptions like 'Download as X', X = PDF, ODT etc.


>    "format" - file mimetype (used for input for "Action_Export").
Comment 2 Aleksander Machniak 2016-11-10 13:13:42 UTC
Yes, it should be localized. However, my button label already is "Export as" or "Download as", so the format label should not contain "Download as " prefix.
Comment 3 Commit Notification 2016-11-10 16:36:01 UTC
Pranav Kant committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/online/commit/?id=9c5928a87b91a58f37b8960453e9553c6020e1e8

tdf#103641: Convert 'wopi:' message to JSON formatted message
Comment 4 Commit Notification 2016-11-10 16:36:55 UTC
Pranav Kant committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/online/commit/?id=2168617d603a81eab62465a9b18d6f64b35e66da

tdf#103641: Implement ability to hide save, print, export options
Comment 5 Commit Notification 2016-11-10 16:37:29 UTC
Pranav Kant committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/online/commit/?id=5219baaab0691fa6d727d966d0376b75061331f6

tdf#103641: WOPI: Implement Action_Save, Action_Print, Action_Export
Comment 6 Commit Notification 2016-11-10 16:38:00 UTC
Pranav Kant committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/online/commit/?id=e850ac836f566316d827a42e22e6bbe35f2c11e7

tdf#103641: Another Post message API - Get_Export_Formats
Comment 7 Pranav Kant 2016-11-10 17:40:26 UTC
(In reply to Aleksander Machniak from comment #0)
> I'd like to implement a toolbar on the host page that will "proxy" some of
> the editor toolbar functionality. I'd like to hide completely "File" menu
> and "Save" button.
> 
> So, one thing is a way to tell the editor to not display some of the UI
> (File menu and Save button).

HideSaveOption
HidePrintOption
HideExportOption

Set these to true and all of them would be hidden. You can also chose to hide them individually. File menu item will only dissappear if there are no items in it (obviously), which will happen if you turn all of above to true.

> 
> The other thing is postMessage API extension with:
> 
> 1. "Action_Save" command - just emit click on "Save" button
> 2. "Action_Print" command - just emit click on Print menu item
> 3. "Action_Export" command - just emit click on "Download as" with
> pre-selected output format.
> 4. "Export_Formats"/"Export_Formats_Resp" commands - to get supported export
> formats. This should return an array of:
>    "label" - file type description
>    "format" - file mimetype (used for input for "Action_Export").

Have a look at loleaflet/reference.html where I have updated the documentation regarding these.
Comment 8 Aleksander Machniak 2016-11-14 10:54:13 UTC
An obvious mistake fixed in https://gerrit.libreoffice.org/#/c/30842/ Please, review.
Comment 9 Aleksander Machniak 2016-11-14 11:26:54 UTC
And I have another problem that I don't know how to fix/workaround. When posting Get_Export_Formats message (properly after receiving App_LoadingStatus) I don't get the response. In console I see 

TypeError: this._map._docLayer is undefined

Maybe some race condition?
Comment 10 Pranav Kant 2016-11-14 11:30:50 UTC
(In reply to Aleksander Machniak from comment #9)
> And I have another problem that I don't know how to fix/workaround. When
> posting Get_Export_Formats message (properly after receiving
> App_LoadingStatus) I don't get the response. In console I see 
> 
> TypeError: this._map._docLayer is undefined
> 
> Maybe some race condition?

Ah, okay. I know whats up there, will push a fix soon.

Thanks.
Comment 11 Aleksander Machniak 2016-11-15 08:12:08 UTC
Another issue here. The Save button is properly hidden on .odt documents, but not when using .odp.

Also, normally there's w2ui-break element on the right of the Save button. If we hide the button we should remove also that element, which is redundant.
Comment 12 Pranav Kant 2016-11-15 11:20:12 UTC
(In reply to Aleksander Machniak from comment #9)
> And I have another problem that I don't know how to fix/workaround. When
> posting Get_Export_Formats message (properly after receiving
> App_LoadingStatus) I don't get the response. In console I see 
> 
> TypeError: this._map._docLayer is undefined
> 
> Maybe some race condition?

Another problem here is that view information (number of users editing the document; their color, names etc.) is available only after document load finishes and currently App_LoadingStatus is emitted before that (when frame becomes ready) which means you can't send 'Get_Views' command (as opposed to what WOPI expects I guess) until document is loaded.

There are two possible solutions

1. We can delay the App_LoadingStatus to emit after document is loaded, but then you won't be seeing any loleaflet's spinner till document is fully loaded and all tiles are visible. We only have a rotating spinner as of now, but we will have a progress bar there in future showing % of document load which can be quite useful information to show to the user (especially for large documents). 

2. We can keep App_LoadingStatus before document load (in its current form) but add a new post message API - 'Document_Loaded' that tells outer frame that it can now use 'Get_View'
Comment 13 Pranav Kant 2016-11-15 11:35:06 UTC
(In reply to Aleksander Machniak from comment #9)
> And I have another problem that I don't know how to fix/workaround. When
> posting Get_Export_Formats message (properly after receiving
> App_LoadingStatus) I don't get the response. In console I see 
> 
> TypeError: this._map._docLayer is undefined

This is also a similar problem like mentioned in Comment 12. All these layers and what export formats are available, we can't know till document is actually loaded.
Comment 14 Aleksander Machniak 2016-11-15 11:40:25 UTC
(In reply to Pranav Kant from comment #12)
> Another problem here is that view information (number of users editing the
> document; their color, names etc.) is available only after document load
> finishes and currently App_LoadingStatus is emitted before that (when frame
> becomes ready) which means you can't send 'Get_Views' command (as opposed to
> what WOPI expects I guess) until document is loaded.

I don't really use Get_Views since I observed that View_Added is also
sent for the current user.

> There are two possible solutions
> 
> 1. We can delay the App_LoadingStatus to emit after document is loaded, but
> then you won't be seeing any loleaflet's spinner till document is fully
> loaded and all tiles are visible. We only have a rotating spinner as of now,
> but we will have a progress bar there in future showing % of document load
> which can be quite useful information to show to the user (especially for
> large documents). 

Loading spinner is not a big problem, I have a loading spinner on host
page too (in the page corner, so less significant, but still).
Displaying percentage would be useful though for bigger documents.

> 2. We can keep App_LoadingStatus before document load (in its current form)
> but add a new post message API - 'Document_Loaded' that tells outer frame
> that it can now use 'Get_View'

I think I could accept this solution if there's no other option.
Comment 15 Commit Notification 2016-11-15 13:48:42 UTC
Pranav Kant committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/online/commit/?id=d8a202bf1cc2a4cc343833348f08dcfdadbdd409

tdf#103641: Split App_LoadedStatus - Frame_Ready, Document_Loaded
Comment 16 Commit Notification 2016-11-15 13:48:48 UTC
Pranav Kant committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/online/commit/?id=26adebfcb06521bb7023f22ada041298c3c4aa3d

tdf#103641: Fix save button visible for presentation
Comment 17 Commit Notification 2017-03-02 11:44:59 UTC
Pranav Kant committed a patch related to this issue.
It has been pushed to "libreoffice-5-3":

http://cgit.freedesktop.org/libreoffice/online/commit/?id=37266761c5d202ef173e49477b2a0e899e981127&h=libreoffice-5-3

tdf#103641: Hide redundant break after save too