Bug 164655 - copy->paste HTML in Writer adds paragraph break
Summary: copy->paste HTML in Writer adds paragraph break
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.1.0.4 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: HTML-Paste
  Show dependency treegraph
 
Reported: 2025-01-10 09:52 UTC by Stephan Bergmann
Modified: 2025-05-30 04:56 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 Stephan Bergmann 2025-01-10 09:52:52 UTC
At least with recent master towards LO 25.8:  In a fresh Writer document, type `x`, "Edit - Select All", "Edit - Copy", "Edit - Paste Special - Paste Special... - HyperText Markup Language (HTML) - OK" reinserts the `x`, but also adds a paragraph break after it.

The reason appears to be that the HTML clipboard content generated by LO (as can be seen with something like

> diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
> index 6d4c5df1b84d..e10bd2be7a15 100644
> --- a/sw/source/uibase/dochdl/swdtflvr.cxx
> +++ b/sw/source/uibase/dochdl/swdtflvr.cxx
> @@ -821,12 +821,10 @@ bool SwTransferable::WriteObject( SvStream& rOStream,
>          xWrt->m_bWriteOnlyFirstTable = bool(TransferBufferType::Table & m_eBufferType);
>          xWrt->SetShowProgress(false);
>  
> -#if defined(DEBUGPASTE)
>          SvFileStream aPasteDebug(
> -            u"PASTEBUFFER.debug"_ustr, StreamMode::WRITE|StreamMode::TRUNC);
> +            u"file:///tmp/PASTEBUFFER.debug"_ustr, StreamMode::WRITE|StreamMode::TRUNC);
>          SwWriter aDbgWrt( aPasteDebug, *pDoc );
>          aDbgWrt.Write( xWrt );
> -#endif
>  
>          SwWriter aWrt( rOStream, *pDoc );
>          if( ! aWrt.Write( xWrt ).IsError() )

), namely

> <!DOCTYPE html>
> <html>
> <head>
> 	<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
> 	<title></title>
> 	<meta name="generator" content="LibreOffice 25.8.0.0.alpha0 (Linux)"/>
> 	<style type="text/css">
> 		@page { size: 8.5in 11in; margin: 0.79in }
> 		p { margin-bottom: 0.1in; line-height: 115%; background: transparent }
> 	</style>
> </head>
> <body lang="en-US" link="#000080" vlink="#800000" dir="ltr"><p style="line-height: 100%; margin-bottom: 0in">
> x</p>
> </body>
> </html>

ends with a `</p>`.

See the code comment in <https://git.libreoffice.org/core/+/325945a544f0b18fb763bfd955e196258cc70eb1%5E%21> "Fix rudimentary Emscripten Qt6 copy -> paste support" for how this affects at least an (experimental, for now) --enable-qt6 Emscripten build:  "And for another, <https://github.com/qt/qtbase/commit/f0be152896471aa392bb1b2b649b66feb31480cc> 'wasm: improve clipboard support' also has code to 'prefer html over text' in QWasmClipboard::writeToClipboardApi, so if we reported both 'text/plain' and 'text/html',  that code would pick 'text/html', but the HTML provided by LO apparently always contains a trailing '</p>', so would always add a newline when pasted."
Comment 1 raal 2025-01-13 16:39:39 UTC
Confirm with Version: 25.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: db6a6efdc49df054826e9019ebe955282de929a7
CPU threads: 4; OS: Linux 6.8; UI render: default; VCL: gtk3
Locale: he-IL (cs_CZ.UTF-8); UI: en-US
Calc: threaded

and Version 4.1.0.0.alpha0+ (Build ID: 847749e975a7111ea306909a29fddb5df13e9a7)