Bug 114080 - FILESAVE: "Save as Text" doesn't put end-of-line after each line shown on screen
Summary: FILESAVE: "Save as Text" doesn't put end-of-line after each line shown on screen
Status: RESOLVED INVALID
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.2.0.4 release
Hardware: x86-64 (AMD64) Windows (All)
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
: 114554 (view as bug list)
Depends on:
Blocks: Save-Text
  Show dependency treegraph
 
Reported: 2017-11-27 02:29 UTC by Jay Michael
Modified: 2017-12-27 03:40 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Result of Save as Text (211 bytes, text/plain)
2017-11-27 02:31 UTC, Jay Michael
Details
expected output -- never actually produced by LibreOffice (229 bytes, text/plain)
2017-12-01 03:14 UTC, Jay Michael
Details
macro to save current document as text, with hard line breaks (3.29 KB, text/plain)
2017-12-27 03:40 UTC, Jay Michael
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jay Michael 2017-11-27 02:29:35 UTC
Description:
I expect the output from Writer of Save as Text to be a text file with an end-of-line everywhere a line ended on the screen when I was in the editor.  What I get is a single, long, line for each "paragraph" in the original document.

Steps to Reproduce:
1. Open a New Text Document
2. Type a few paragraphs
3. File -> Save as... -> Select "Save as type" of "Text"

Actual Results:  
     This is a demonstration of text I want in a text file.
     I expect the text file to have an end-of-line marker at every point where I saw a line end on the screen when I was using LibreOffice Writer.


Expected Results:
     This is a 
demonstration of 
text I want in a 
text file.
     I expect the 
text file to have 
an end-of-line marker 
at every point where 
I saw a line end on 
the screen when I 
was using 
LibreOffice Writer.




Reproducible: Always


User Profile Reset: No



Additional Info:
"Actual Results", above, should contain only two lines:  "This is...text file.", and "I expect...Writer."

I set the left margin to 3 and the right margin to 3.5, and used Courier New, 12 point.

Version: 4.2.0.4
Build ID: 05dceb5d363845f2cf968344d7adab8dcfb2ba71


User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0; Touch)
Comment 1 Jay Michael 2017-11-27 02:31:42 UTC
Created attachment 138007 [details]
Result of Save as Text
Comment 2 Dieter 2017-11-28 19:56:09 UTC Comment hidden (obsolete)
Comment 3 Jay Michael 2017-11-29 04:24:27 UTC
     LibreOffice 5.4.3 behaves the same way as already described:  one line for each paragraph, rather than one line for each line that appeared on the screen in Writer.

     I uninstalled LibreOffice 4.2 and installed LibreOffice 5.4.3.  I opened a new Text Document, set the margins to 3 and 3.5 inches, changed the font to Courier New, 12 points, and pasted the sample text into the new document.  On screen, it looks as it did, and as I want:  lots of short lines.  When I Save as Text, I get what I got before:  one long line for each paragraph.

     There is an option "Save as Text - choose encoding".  It includes the options of specifying whether I want lines terminated with CR/LF, CR, or LF.  It makes no mention of manifesting soft returns.  It produces the same output as "Save as Text".
Comment 4 tommy27 2017-11-29 05:00:13 UTC
tested under Win8.1 x64 using LibO 5.3.6.1

I opened a blank new Writer document and I typed 4 lines like:

The cat is
on the table.
The dog is 
under the chair.

then I saved as .txt and opened the output which is exactly in 4 lines like the original text shown on screen.

I tried pasting your dummy text in Writer and then save it as .txt and again the output is like it appears on screen... I don't reproduce your issue since my results are different than those in your attached .txt file.
Comment 5 Jay Michael 2017-11-30 02:36:47 UTC
(In reply to tommy27 from comment #4)
     If, in your first test, you hit <ENTER> after each short line, then you're getting what I expect.  Hitting <ENTER> ends a "paragraph", and the "Save as Text" *does* put an end-of-line at the end of each paragraph.

     In your second test:

     Is the text you pasted what I posted as the result of Save as Text?  So it was two rather long lines?

     Did you change the left and right margins to force more dramatic line wrapping?

     How are you testing the resulting text file?  I open it in Notepad.  With very wide margins in LibreOffice, the lines of text are so short they don't come anywhere near the width of the Notepad window.  If your Notepad window is as wide as the default LibreOffice margins would make the usable part of a page, and you have word-wrap enabled in Notepad, it might reproduce what was displayed in LibreOffice.

     I tried pasting my sample text into LibreOffice without changing margins or font.  The first line fits.  The second line gets broken into two lines.  When I Save as Text, the output text file still contains only two lines -- just like the original.

     It doesn't seem likely that they changed it from 4.2 to 5.3, then took it out by 5.4.
Comment 6 Dieter 2017-11-30 20:03:42 UTC
Tried to reproduce it:
1. I opened a new document (set margins to 3 and 3,5)
2. I copy and pasted your text (Courier 12; each line a paragraph)
3. File => save as => Text - Choose encoding => confirm file format
4. Properties:  Western Europe (Windows-1252/WinLatin 1)
                Paragraph break: CR & LF
5. Opened in Windows editor => no problem

Is it pobably a problem of your editor? Do you get the same result with the windwows editor?

Version: 6.0.0.0.beta1 (x64)
Build ID: 97471ab4eb4db4c487195658631696bb3238656c
CPU threads: 4; OS: Windows 10.0; UI render: default; 
Locale: de-DE (de_DE); Calc: group threaded
Comment 7 Jay Michael 2017-12-01 02:12:49 UTC
(In reply to Dieter Praas from comment #6)
     I'm not sure what you mean by "the Windows editor".  I usually use Notepad.  I just tried again with Write (AKA, WordPad).  I checked the file with a hex editor.  The file produced by LibreOffice does *not* have an end-of-line mark at the end of every line that appeared on the screen when I was in LibreOffice Writer.  It just has an end-of-line mark at the end of each paragraph, which is also each place I hit <ENTER> when I was originally entering the text.

     I see that you're using Version 6 of LibreOffice, and running under Windows 10.  At least it makes some sense that you get different results.
Comment 8 Jay Michael 2017-12-01 03:14:27 UTC
Created attachment 138162 [details]
expected output -- never actually produced by LibreOffice
Comment 9 Jay Michael 2017-12-01 03:16:11 UTC
     I just put LibreOffice 6 Beta on a Windows 10 machine.  I tried Save as Text, and Save as Text -- choose encoding (Windows-1252, CR/LF).  I never get end-of-line marks, except for one at the end of each "paragraph".
Comment 10 Dieter 2017-12-01 06:56:54 UTC
(In reply to Jay Michael from comment #7)
>      I'm not sure what you mean by "the Windows editor".  I usually use
> Notepad.  I just tried again with Write (AKA, WordPad).

I found out, that Notepad is the same as Windows editor. I also tried WordPad and I had no problem. So I really have no idea, what I can do, to reproduce it. Sorry.
Comment 11 Buovjaga 2017-12-03 16:12:34 UTC
(In reply to Jay Michael from comment #0)
> Description:
> I expect the output from Writer of Save as Text to be a text file with an
> end-of-line everywhere a line ended on the screen when I was in the editor. 
> What I get is a single, long, line for each "paragraph" in the original
> document.

Why do you expect this? It does no make any sense to me. You have to format your text in Writer to behave like you want, with line or paragraph breaks.
Comment 12 Jay Michael 2017-12-04 02:39:40 UTC
(In reply to Buovjaga from comment #11)
> (In reply to Jay Michael from comment #0)
> Why do you expect this? It does no make any sense to me. You have to format
> your text in Writer to behave like you want, with line or paragraph breaks.

     I expect this mainly because it seems to me to be the obvious behavior:  I used a word processor so lines would be reflowed when I edited.  (As opposed to painfully reflowing by hand after an insertion or deletion, or just putting up with painfully inconsistent line lengths.)  I expect the output of a word processor to attempt to preserve the appearance of my document.  To me, this means having an end-of-line mark at the end of every line that was displayed on the screen.  I understand that this does not guarantee that the recipient will see what I saw while creating the document, but if I keep my usable space narrow enough, most of my recipients will see what I intend them to see.

     As justification for my expectation, I offer the observation that this was the behavior in other word processors.  (In particular, the last version of WordPerfect I used.)

     I *am* formatting my text to *look* like I want.  I am setting the margins to limit the width of the formatted text.  I am setting the font to what I expect my recipient will be using.  I used paragraph breaks, and expect that they will limit any reformatting that occurs.  All I'm asking is that the output include a mark wherever a line ended on the screen.

     Maybe the confusion comes from a disagreement over the purpose of Save as Text.  The current form is probably the most suitable for use in transferring a document to another word processor.  For me, the purpose is to produce a text file suitable for use as the content of an e-mail message, or to produce a text file for transfer to a device that does not have a word processor capable of interpreting an .ODT file.
Comment 13 Buovjaga 2017-12-04 12:51:23 UTC
(In reply to Jay Michael from comment #12)
>      Maybe the confusion comes from a disagreement over the purpose of Save
> as Text.  The current form is probably the most suitable for use in
> transferring a document to another word processor.  For me, the purpose is
> to produce a text file suitable for use as the content of an e-mail message,
> or to produce a text file for transfer to a device that does not have a word
> processor capable of interpreting an .ODT file.

Email clients have options to limit the line length: http://kb.mozillazine.org/Plain_text_e-mail_(Thunderbird)#Advanced
Text editors (even Notepad) support wrapping lines.

Changing the behaviour like you request would result in many complaints as it is unusual. Closing as WONTFIX.
Comment 14 Jay Michael 2017-12-05 05:07:57 UTC
(In reply to Buovjaga from comment #13)
> Changing the behaviour like you request would result in many complaints as
> it is unusual. Closing as WONTFIX.

     An option (defaulting to "No") to output an end-of-line for each soft-return would not result in any complaints.
Comment 15 V Stuart Foote 2017-12-05 06:26:44 UTC
This would make no sense. Our direct formatting and styles are applied to the paragraph as objects held on a page object; indentations, spacing, numbering, etc. are attributes of the paragraph.

What you are asking for is to maintain line spacing that would break paragraph object attributes--we won't do that and this is INVALID.

However, if you insist on manually formatting each line (rather than allowing the paragraph object to demark its text breaks within margins and indents) it is a simple practice to use <Shift>+<Enter> to break your lines with a <LF>.

Then each <LF> inserted will be filter exported to end each line in a Text formated file as HEX 0a, with Paragraph ends rendered as <CR><LF> 0a0d.

You should be able to work with the resulting text file as you prefer.

Setting Resolved => INVALID
Comment 16 Jay Michael 2017-12-06 05:14:50 UTC
(In reply to V Stuart Foote from comment #15)
> What you are asking for is to maintain line spacing that would break
> paragraph object attributes--we won't do that and this is INVALID.

     I don't think that's what I'm asking for.  What I'm asking for is for the output of "Save as Text" to look like you would make it look if you were printing on a text-only printer.

> However, if you insist on manually formatting each line (rather than
> allowing the paragraph object to demark its text breaks within margins and
> indents) it is a simple practice to use <Shift>+<Enter> to break your lines
> with a <LF>.
> 
> Then each <LF> inserted will be filter exported to end each line in a Text
> formated file as HEX 0a, with Paragraph ends rendered as <CR><LF> 0a0d.
> 
> You should be able to work with the resulting text file as you prefer.

     I don't insist on manually formatting each line.  I'm trying to get LibreOffice to figure out where to break lines of a paragraph, and then communicate that decision to the text file.

> 
> Setting Resolved => INVALID

     Is INVALID further from me getting what I want than WONTFIX was?
Comment 17 V Stuart Foote 2017-12-06 06:22:36 UTC
(In reply to Jay Michael from comment #16)

> > Setting Resolved => INVALID
> 
>      Is INVALID further from me getting what I want than WONTFIX was?

No. For this "enhancement" to be denied WONTFIX would require it to be a valid request. INVLAID is simply stating that the issue reported or requested development is out of scope or inappropriate for the project.

You comment "I expect...", "...text I want", "I expect this mainly because it seems to me to be the obvious behavior..."

And we are telling you what you get with LibreOffice's Save-As handling of .txt, as you confirm for yourself in comment 7.

Our internal layout handling (line width, indentation, kerning, justification) deals with text streams composed onto a document canvas. The line breaks are not stored with the stream--rather are recalculated dynamically as controlled by paragraph endings, or manual Line feeds and as influenced by other objects present on the document canvas. 

When filter exported to .txt, the paragraph endings (and any manual line feeds) will be included but no other formatting or layout. Typical text with just paragraph ends will not be wrapped in the .txt export result. That is normal and expected.

Your request would require development of a new, more complicated export filter that would need to interpret the text layout onto document canvas and then correctly insert linefeeds to maintain the same line breaks in the exported text.  It is abnormal and not otherwise expected and frankly too specialized to be anything more than a corner case.

These types of specialized tools are appropriately handled as extensions--not in the LibreOffice core.

"FILESAVE: "Save as Text" doesn't put end-of-line after each line shown on screen" => INVALID, because it is the correct behavior, nor should it.
Comment 18 Buovjaga 2017-12-25 19:33:03 UTC
*** Bug 114554 has been marked as a duplicate of this bug. ***
Comment 19 Jez 2017-12-26 17:18:14 UTC
I think this should be reopened.  I would like to see this option too.  My use-case for this is limiting my output text files to 80 characters, which is a common requirement for various internet submissions (like GameFAQS for example).  I used to adjust the document in MS Word so that it would fit only 80 characters per line, then on saving convert the soft line wraps to hard line wraps in the output TXT file.  This is very useful and I see no reason why it shouldn't at least be an aspiration to add this functionality in LibreOffice.
Comment 20 Jez 2017-12-26 17:19:11 UTC
MS Word called this "Text Only with Line Breaks" as its "save as" file type.
Comment 21 V Stuart Foote 2017-12-26 17:26:22 UTC
Nope as in comment 15 it remains invalid and completely inappropriate for how ODF documents are structured.

If one insists on forcing formatting this way--use the newline <Shift>+Enter while entering text--resulting Save-as .txt formatting will as assigned.
Comment 22 Buovjaga 2017-12-26 17:31:15 UTC
Closing again.

I hunted a solution for you guys and found several: https://forum.openoffice.org/en/forum/viewtopic.php?f=7&t=59304

A nice and quick one is changing the selection mode to Block (left-click the cursor icon in the status bar), select everything with mouse and paste to a new file.

In the OO.org topic there is also a macro posted on Thu Feb 23, 2017.

Finally, like the last post in the topic says:
File > Export as PDF. Now copy everything from the PDF and paste it into a new document.
Comment 23 Jay Michael 2017-12-27 03:29:40 UTC Comment hidden (obsolete)
Comment 24 Jay Michael 2017-12-27 03:38:17 UTC
     (I couldn't see how to delete a fumbled comment.)

     When I originally asked about this on ask.libreoffice.org,
https://ask.libreoffice.org/en/question/137329/feature-request-save-as-text-with-line-breaks/
librebel offered me the BASIC source for a macro that would save the current document as a text file, with a hard return at the end of each line as the line appeared on the screen in LibreOffice Write.

     I added a "Save as..." dialog.
Comment 25 Jay Michael 2017-12-27 03:40:39 UTC
Created attachment 138672 [details]
macro to save current document as text, with hard line breaks