Fix selection printing
Needs ReviewPublic

Authored by hoffmannrobert on Jan 10 2020, 1:40 PM.

Details

Reviewers
dhaumann
Summary

Printing selected text only worked correctly if the lines from which text was
selected fit into single printed lines. Text selected from lines using multiple
printed lines was printed incompletely and/or additional text which wasn't
selected was printed.

This patch fixes printing text from long lines.

BUG: 415570

Test Plan
  1. Select text from one or more lines which do not fit into single printed lines.
  2. Print (Ctrl+P)
  3. Options: Print range: Selection; Print (preferably to a PDF file)
  4. Compare printed and selected text.
  5. Repeat steps 1 to 4: select and print different parts of the text. For example, first select all, then exclude text from selection from the end, then from the beginning, then from both end and beginning and reduce the selection gradually.

Diff Detail

Repository
R39 KTextEditor
Branch
fix_selection_printing
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 21786
Build 21804: arc lint + arc unit
hoffmannrobert created this revision.Jan 10 2020, 1:40 PM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptJan 10 2020, 1:40 PM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
hoffmannrobert requested review of this revision.Jan 10 2020, 1:40 PM

That looks already better: If a line is wrapped and on the same page, then only the selected text is printed. It seems there are still corner cases.

  1. Create a document with just one long line that wraps over two printed pages. I this case, I am not able to print only the selected text properly.
  2. Say you have a line that wraps over e.g. 5 visual lines. And you just want to print the visually wrapped line 4 and 5. Right now, the visual lines 1-3 are just empty, but still take place. Maybe it makes sense to omit fully empty lines completely?

Can you reproduce this? I know this is tricky, so I'd be fine with committing the code as is. Or are you willing to put more efforts into 1. and/or 2. ? :-)

In any case, this is already very much appreciated.

Yes, I am working on it. Now, I have a solution for 1, but 2 is more difficult to fix. Probably next week.

Cool! Thanks for taking care of this.

  • Fix 1: long lines wrapping over pages

Here is the fix for 1.

I've tried number 2, but I didn't get anywhere. I think this would need huge efforts: To remove the empty space before (and after) the selection you would have to change the layout, which is tied to the document, so basically you would have to change the document. And after that, all the regions which mask the parts (not) to be printed would have to be calculated in different ways. Please correct me if I'm wrong.

I don't think the space saving is worth the effort, and I couldn't justify it to my sponsor.

In case my last comment was mistakable, I fixed this:

  1. Create a document with just one long line that wraps over two printed pages. I this case, I am not able to print only the selected text properly.

but I couldn't fix this:

  1. Say you have a line that wraps over e.g. 5 visual lines. And you just want to print the visually wrapped line 4 and 5. Right now, the visual lines 1-3 are just empty, but still take place. Maybe it makes sense to omit fully empty lines completely?