Estimated read time: 3 minutes
Calc now supports much better copy&paste when you transfer data between Google Sheets and Calc.
This work is primarily for Collabora Online, but the feature is fully available in desktop Calc as well.
Motivation¶
First, Collabora Online was using the
deprecated
document.execCommand()
API to paste text, which is problematic, as the "paste" button on the
toolbar can't behave the same way as pressing Ctrl-V on the keyboard.
Second, it turns out Google Sheets came up with some additional HTML attributes to represent spreadsheet data in HTML in a much better way, and Calc HTML import/export had no support for this, while this is all fixable.
Results so far¶
In short, Collabora Online now uses the Clipboard API to read from the system clipboard -- this has to be supported by the integration, and Calc's HTML filter now support the subset of the Google Sheets markup I figured out so far. This subset is also documented.
Note that the default behavior is that the new Clipboard API is available in Chrome/Safari, but not in Firefox.
For the longer version, here are some screenshots:
How is this implemented?¶
If you would like to know a bit more about how this works, continue reading... :-)
As usual, the high-level problem was addressed by a series of small changes:
- tdf#159483 sc HTML import: handle data-sheets-value attribute for the text case
- tdf#159483 sc HTML paste: handle data-sheets-value here, too
- tdf#159483 sc HTML import: handle data-sheets-value attribute for the bool case
- tdf#159483 sc HTML import: handle data-sheets-value attribute for the num case
- tdf#159483 sc HTML paste: handle data-sheets-formula attribute
- tdf#159483 sc HTML paste: handle data-sheets- attributes on a span
- tdf#159483 sc HTML export: handle data-sheets-value attribute for the text case
- tdf#159483 sc HTML copy: handle data-sheets-value attribute for the bool case
- tdf#159483 sc HTML copy: handle data-sheets-value attribute for the num case
- tdf#159483 sc HTML copy: handle data-sheets-formula attribute
The tracking issue on the Online side was cool#8023.
Want to start using this?¶
You can get a snapshot / demo of Collabora Office 24.04 and try it out yourself right now: try the unstable snapshot. Collabora intends to continue supporting and contributing to LibreOffice, the code is merged so we expect all of this work will be available in TDF's next release too (24.8).