Bug 127141 - Default clipboard formats for paste from Microsoft One Note
Summary: Default clipboard formats for paste from Microsoft One Note
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.2.4.2 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Paste Clipboard
  Show dependency treegraph
 
Reported: 2019-08-24 19:50 UTC by Bro Bob
Modified: 2019-09-27 12:55 UTC (History)
4 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 Bro Bob 2019-08-24 19:50:57 UTC
Description:
Cutting text from One Note cannot be pasted into Libre Office Writer (likely other Libre Office products as well).  Work-around is to cut from One Note paste into Microsoft Notepad, then cut from Notepad and paste into writer! That actually works! Yay! But, it's a lot of unnecessary steps.

Steps to Reproduce:
1.Description above says it all!
2.
3.

Actual Results:
Paste works if filtered through Notepad first

Expected Results:
Paste works only if work-around is employed


Reproducible: Always


User Profile Reset: No



Additional Info:
It should be possible to directly cut or copy from One-Note into Libre Office Writer.
Comment 1 V Stuart Foote 2019-08-24 21:00:22 UTC
We have no idea what format "One Note" will copy to its clipboard. And LibreOffice will only be able to parse clipboard formats it knows about (either a 'default' Paste--i.e. with <Ctrl>+V, or one of the Paste Special actions).

So, load up some form of clipboard viewer, I prefer NirSoft's InsideClipboard [1] for this on Windows, and identify what exactly "One Note" is pushing to the clipboard.

=-ref-=
[1] https://www.nirsoft.net/utils/inside_clipboard.html
Comment 2 V Stuart Foote 2019-08-25 00:05:37 UTC
With One Note (Office 2016)

Using NirSoft's InsideClipboard a text string "My junk name" is copied to clipboard as 

1	CF_TEXT	Memory	15	4
8	CF_DIB	Memory	11,880	6
13	CF_UNICODETEXT	Memory	30	3
14	CF_ENHMETAFILE	Enhanced metafile	0	5
49409	HTML Format	Memory	650	2
50060	OneNote 2010 Internal	Memory	56	1	

=-=-=
On WIndows 10 Ent 64-bit en-US (1903) with
Version: 6.4.0.0.alpha0+ (x64)
Build ID: 3e64065612acec2eb29aa21e2b515953422256d7
CPU threads: 8; OS: Windows 10.0; UI render: GL; VCL: win; 
TinderBox: Win-x86_64@62-TDF, Branch:master, Time: 2019-08-15_22:57:26
Locale: en-US (en_US); UI-Language: en-US
Calc: threaded

Looks like for our paste action we use the CF_DIB -- Device Independent Bitmap

And in LibreOffice Paste Special actions, we list the source as 'Unknown Source', and offer these formats for use:

Stripped HypeTextMarkup Language (Simple HTML)
HTML format without comments
Unformatted text
Graphics Device Interface metafile (GDI)
Bitmap Image (BMP)


Bottom line--multiple ClipBoard formats available including handling of text strings for insertion to Writer. Nothing else necessary.

=> NAB
Comment 3 V Stuart Foote 2019-08-26 20:20:31 UTC
OP responded via PMs, Mon 2019-08-26 2:55 PM

Nice job and follow-through on this bug report using “InsideClipboard” to determine what actually gets captured to the clipboard when doing copies and cuts in Microsoft One Note.  I appreciate your spending the time to research this.   I’m not sure though, that we can dismiss this as  a fault in copying “pure text”.  It doesn’t explain why copied text can’t be pasted directly into Libre Writer from the clipboard.  The copied text has to be filtered through Microsoft’s Notepad first, then copied and pasted into Libre Writer.  MS Notepad strips all formatting off of what comes off the clipboard.   Once that has happened, the text can be successfully copied and pasted into Libre products.  This would raise the question, why can’t Libre Writer strip the formatting from the clipboard items, 
enabling direct pastes like Notepad?

@Bro Bob,

Simple response is that there has to be _some_ default handling for any content placed onto the os clipboard, One Note places a CF_DIB onto the clipboard and that is what gets picked up as default paste format, and is then rendered as bitmap to document canvas.

There is no direct linkage between LibreOffice and One Note, just the clipboard content signaling--we don't check what app is populating the os system clipboard, just what is available.  And depending on the LibreOffice module in use, we take a default clip format appropriate to the module. 

And as to Notepad placement onto the Windows clipboard, you actually get multiple clip formats there as well: CF_TEXT, CF_OEMTEXT, CF_UNICODETEXT and CF_LOCALE. So mostly text but the difference between TEXT/OEMTEXT and Unicode Text can be pretty significant for some locales/scripts.

LibreOffice does "strip the formatting" -- that is what the Paste Special -> 'Unformatted text' provides; it is just not the default. 

If we somehow tweaked LibreOffice clipboard handling to recognize MS One Note as source, "stripped of formatting" would not necessarily be the best default for MS One Note which generates rich context materials XHTML, Text, Bitmap and even vector graphics depending on use. Some folks will want the rich content.
Comment 4 Noel Grandin 2019-08-27 06:52:54 UTC
I don't know exactly how our default paste algorithm works, but I would expect it to start with the highest priority format and work down, which means I would expect it to paste the HTML format into writer.
Comment 5 Noel Grandin 2019-09-27 08:13:54 UTC
This commit might provide a clue to fixing this, it seems like we don't obey the system clipboard priority settings, and maintain our own sorted tables, so tweaking those tables might fix this.

https://cgit.freedesktop.org/libreoffice/core/commit/?id=e9e6d4b058e13165f3dde1ca7822eec97dfe8aa7
Comment 6 V Stuart Foote 2019-09-27 12:55:42 UTC
(In reply to Noel Grandin from comment #5)
> This commit might provide a clue to fixing this, it seems like we don't obey
> the system clipboard priority settings, and maintain our own sorted tables,
> so tweaking those tables might fix this.
> 
> https://cgit.freedesktop.org/libreoffice/core/commit/
> ?id=e9e6d4b058e13165f3dde1ca7822eec97dfe8aa7

Equally

https://gerrit.libreoffice.org/plugins/gitiles/core/+/29d4ecf32392bc94ab0ba9e73fd79eba65c23fdb%5E%21

But gyrations there seem cautionary!