[Issue] Copying cells to clipboard adds newline at the end

Discuss the spreadsheet application
Post Reply
trevor-es
Posts: 17
Joined: Wed Jan 23, 2008 12:31 am

[Issue] Copying cells to clipboard adds newline at the end

Post by trevor-es »

Single or multiple cells copied to the clipboard (with ctrl-c) and pasted into another application such as Notepad contain a new line at the end. So every time I c&p cells elsewhere I manually remove the added line. Is there a reason for the behavior and a way to change it?

There was a discussion of the same behavior in writer a couple years ago:
http://user.services.openoffice.org/en/ ... 53&start=0
And a resolved bug issue report:
http://qa.openoffice.org/issues/show_bug.cgi?id=90511
Last edited by Hagar Delest on Wed Mar 14, 2012 9:22 am, edited 1 time in total.
Reason: tagged the thread as Issue (link to a bug report).
OpenOffice 3.1.0 Build 9399 on Windows 2000
User avatar
MrProgrammer
Moderator
Posts: 4905
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Copying cells to clipboard always adds a newline at the

Post by MrProgrammer »

For the benefit of others reading this topic, issue 90511 deals only with Writer and would not apply to Calc.

I'm not thrilled by this behavior myself but have sort of learned to live with it. For single cells, I sometimes circumvent this by editing the cell, selecting all, and cancelling (on Mac: F2, ⌘A, ⌘C, ⎋; probably F2, Ctrl+A, Ctrl+C, Esc on other platforms). But this is less than convenient and doesn't work on read-only spreadsheets because F2 is disabled. As you know, it depends on the receiving application whether the extra Newline is a problem or not. In some cases it does no harm.

I believe the reason it works this way is for consistency with what happens when multiple cells are copied and then pasted into a pure text file (not Writer or RTF or HTML, etc. but to TXT format). The text from cells in a row is separated by Tab characters, and then each row is ended by Newline. For a single cell, no Tabs are needed but the "row" still ends with Newline.

To "fix" this we would either need an exception to adding NewLInes to the clipboard in certain cases (copying a single cell, perhaps other situations?) during the Copy operation. (We can't alter the Paste behavior since it may occur in a different application.) So we would almost need a "Copy Special" function! Now there could be a lot of benefit to this idea (such as copy text without formatting or copy formatting only or copy formula to clipboard instead of value) but this would be a relatively major change to Calc.

I've considered writing an Applescript which would remove the last Newline on the clipboard, if present, but haven't done so yet. Presumably there are ways to do something similar on Windows also. (I presume you use Windows since you mention Notepad. It would be helpful to add this information and your OOo release to your forum signature.) I'm not a developer and can't do anything to "fix" this, only suggest why it works as it does and suggest ways around it.

If this answered your question please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
trevor-es
Posts: 17
Joined: Wed Jan 23, 2008 12:31 am

Re: Copying cells to clipboard always adds a newline at the

Post by trevor-es »

Thanks for the tips. I changed my sig. I imagine some users are annoyed by the newline but haven't raised it here. On the Windows platform a resident hot-key program like Autohotkey might allow me to shorten the contents in the clipboard with a key press (of ctrl-c) within only Calc. If possible it won't be the easiest one. May be some one registered on the developers site would submit a 'bug' issue report or feature request for Calc similar to Writer in second link above.
OpenOffice 3.1.0 Build 9399 on Windows 2000
cbj4074
Posts: 2
Joined: Wed Feb 29, 2012 2:11 am

Re: Copying cells to clipboard always adds a newline at the

Post by cbj4074 »

As a preface, I really appreciate the various projects for which this board provides community support. If I sound harsh in my discourse, it's because I want to help improve these products.

I often copy/paste information from Calc into HTML form inputs (input elements with the "text" type attribute). This extra newline that is appended to the contents of the copied cell is a major annoyance in this particular case. The input field within the HTML appears to be blank, because the text string is inserted with a newline at the end, which actually pushes the cursor down to a new line, even within an HTML input field (which is limited to a single line of input when data is entered directly). I have to hit backspace even to see the actual content that I had intended to paste, and in Chrome (and perhaps other browsers), I've seen instances in which no amount of backspacing brings the pasted text back into view. I have to Ctrl+A (select all) and hit backspace, then use Notepad or similar as an interim step for removing the newline. Hardly ideal.

I'm sure that this suggestion is not novel, but if a developer happens to be reading, perhaps the solution is not to include the superfluous newline when the user copies a single cell only.

Quite frankly, I'm surprised that more people have not bothered to complain about this. Perhaps it is the board registration requirement that deters them.

I do have somewhat of a workaround, but it, too, is less than ideal. It seems that the inability to press F2 to shift a cell into edit mode for read-only documents has been rectified. So, I'm able to hit F2, Ctrl+A, and copy just the text (the newline is not appended automatically).

As a final point of note, I find the inability to position the caret/cursor inside the editing field (at the top of the spreadsheet) within a read-only document extremely annoying. There is no reason for this behavior. If the intention here is to inform the user that the document is in read-only mode, this is the wrong way to go about doing so. This behavior keeps me from copying portions of a cell to the clipboard, which seems absurd. Am I missing something?
LibreOffice 3.4.4
OOO340m1 (Build:402)
Windows 7 x64
User avatar
kingfisher
Volunteer
Posts: 2123
Joined: Tue Nov 20, 2007 10:53 am

Re: Copying cells to clipboard always adds a newline at the

Post by kingfisher »

I was unaware of that issue. Copying from the input line should also be free of a space. I write html documents in a text editor so there is no problem anyway.

If you think it is important enough, file an issue. If you don't think it's important enough to file a report, no developer will think it important enough to fix. There is a tutorial on the forum tutorials board about filing an issue.

More annoying to me is spaces being added when I copy from pdf or html to a spreadsheet. Fortunately, I can edit items on the clipboard.
Apache OpenOffice 4.1.9 on Linux
cbj4074
Posts: 2
Joined: Wed Feb 29, 2012 2:11 am

Re: Copying cells to clipboard always adds a newline at the

Post by cbj4074 »

Thank you for the reply, kingfisher.

Done: https://issues.apache.org/ooo/show_bug.cgi?id=119060
LibreOffice 3.4.4
OOO340m1 (Build:402)
Windows 7 x64
Post Reply