Bug 151612 - Text styles should support a "prevent line breaking" feature
Summary: Text styles should support a "prevent line breaking" feature
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.5.0.0 alpha0+
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Writer-Styles-Character ODF-spec Word-Line-Break
  Show dependency treegraph
 
Reported: 2022-10-17 20:38 UTC by Eyal Rozenberg
Modified: 2024-08-17 01:04 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
invisible frame with non-breaking text (18.52 KB, application/vnd.oasis.opendocument.text)
2024-08-16 09:21 UTC, László Németh
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eyal Rozenberg 2022-10-17 20:38:51 UTC
Sometimes you want a short stretch of text, which has some meaning as a whole (e.g. a legal case number or a multi-word title) to not be broken across lines. This is either difficult or impossible to do by Unicode control characters (non-breaking spaces are not sufficient, since you may have dashes or other non-word characters). Also, you might want to say "whenever I mark a stretch of text in some way, it should not break across lines". 

The conclusion is that this feature should be part of Character Styles. And - at the moment, it's missing. There is, in fact, no flow control settings for character styles.
Comment 1 Eyal Rozenberg 2022-10-17 20:45:14 UTC
Adding ODF-spec in case this is lacking in ODF.
Comment 2 Dieter 2022-10-31 13:18:58 UTC
As far as I understand you like to prevent certain words from hyphenation. LO still provides this option, see https://help.libreoffice.org/7.4/en-GB/text/swriter/guide/hyphen_prevent.html?&DbPAR=SHARED&System=WIN


Does this solve your problem?
=> NEEDINFO
Comment 3 Eyal Rozenberg 2022-10-31 14:56:22 UTC
This doesn't have much to do with hyphenation. I'm talking about _any_ breaks, and particularly breaks _between_ words, not the question of whether you can break within a single word or only at edges-of-words.
Comment 4 Dieter 2022-11-01 08:43:43 UTC
(In reply to Eyal Rozenberg from comment #3)
> This doesn't have much to do with hyphenation. I'm talking about _any_
> breaks, and particularly breaks _between_ words, not the question of whether
> you can break within a single word or only at edges-of-words.

You avoid line breaking between words with Strg+Shift+Space. So I really don't nderstand why a new feature is needed here.

cc: Design-Team
Comment 5 Eyal Rozenberg 2022-11-01 13:24:52 UTC
(In reply to Dieter from comment #4)
> You avoid line breaking between words with Strg+Shift+Space. So I really
> don't nderstand why a new feature is needed here.

I'm guessing you mean Ctrl+Shift+Space?

Anyway, that would be a workaround, but

1. I don't want to use formatting characters.
2. I don't want to manually handle this issue in dozens or hundreds of places where my character style is used; this is something which I should be able to enforce using the style.
Comment 6 Heiko Tietze 2022-11-07 14:03:37 UTC
(In reply to Eyal Rozenberg from comment #0)
> ...a short stretch of text

You mean Character > Position > Spacing: Character Spacing?
Comment 7 Eyal Rozenberg 2022-11-07 19:58:25 UTC
(In reply to Heiko Tietze from comment #6)
> (In reply to Eyal Rozenberg from comment #0)
> > ...a short stretch of text
> 
> You mean Character > Position > Spacing: Character Spacing?

No, I meant a short piece of text, a few words at most.
Comment 8 Heiko Tietze 2022-11-09 12:49:15 UTC
Using the CS as means to suppress paragraph break requires it to be standardized. I think it's easier to realize and more familiar to enter non-breaking spacing. Ultimately the use case is a bit far-fetched, IMO.
Comment 9 Eyal Rozenberg 2022-11-10 22:08:39 UTC
(In reply to Heiko Tietze from comment #8)
> Using the CS as means to suppress paragraph break requires it to be
> standardized.

You mean, in the ODF spec? I did mark that as a dependent. Also adding Regina to the CC list.

> I think it's easier to realize and more familiar to enter
> non-breaking spacing. 

That's a bit like saying it's more familiar to manually boldface/italicize text rather define a character style for emphasis... if you have dozens of occurrences of the CS in your document, you don't want to start typing up NBSPs. Or delete them if you've changed your mind. And you you may not want them when you export the text.

Also - many users don't even know about Ctrl+Shift+Space and NBSPs. Actually, maybe even _most_ users.


> Ultimately the use case is a bit far-fetched, IMO.

Why would you say that? Character styles for:

* Titles of books/papers
* References to legal case names (which contain hyphens, spaces etc.)

are common when writing academic documents or legal briefs. And it is not far-fetched for the user to want those not to break across lines.
Comment 10 Heiko Tietze 2022-11-14 10:06:15 UTC
(In reply to Eyal Rozenberg from comment #9)
> > Ultimately the use case is a bit far-fetched, IMO.
> 
> Why would you say that? Character styles for...

I don't buy the heavy need for such a feature. You rarely have hyphens or spaces that must not break and can easily define those as special non-breakable character offered by Unicode.
Comment 11 Eyal Rozenberg 2022-11-14 11:49:42 UTC
(In reply to Heiko Tietze from comment #10)
> I don't buy the heavy need for such a feature. 

We're talking about a feature which won't have UI on the main window, nor a toolbar button. It will only have a check-box in one of the stlye panes, e.g. in "Position", under "Spacing". So, it doesn't have to be feature with "heavy" use. In some kinds of documents, it is quite useful. And - it's a capability that's worthwhile to have in the spec.

> You rarely have hyphens or spaces that must not break

When you write legal documents, or catalogues, or engineering specs, you often want certain kinds of terms - which are likely to have a character style - to not break across lines. This is not rare.

> and can easily define those as special non-breakable character offered by Unicode.

You are suggesting using a hack instead of proper styling. If something is not local to a single place in the document, but to all occurrences of text with a certain character style, the way to handle features of that text is via the character style.

Think also of styles offered to people who are less formatting-and-styling concious: You want to offer them good defaults in the styles, minimizing the amount of design-work and consideration they need to apply.
Comment 12 Dieter 2023-11-21 08:41:32 UTC
Heiko is this a topic for a meeting of the design-team?
Eyal, could you perhaps add a sample document? And if you have that Feature, how should it work? Should font size be reduced to fit a word within a libe of spacing or ...?
Comment 13 Heiko Tietze 2023-11-22 09:45:53 UTC
(In reply to Dieter from comment #12)
> Heiko is this a topic for a meeting of the design-team?
Don't think so. It requires ODF-spec and all other document formats since this is not an option in any text processor (except simple text editors where you can switch off line wrapping - for the whole paragraph then).

We have means to prevent line breaking yet the request asks to make this easier. And I doubt this ease to be highly relevant. Eventually you end up in lines that overflow the canvas, hard to imagine this is wanted.

=> WF
Comment 14 Eyal Rozenberg 2023-11-24 21:01:12 UTC
(In reply to Dieter from comment #12)
> Eyal, could you perhaps add a sample document? 

What would you like a sample document to contain?

> And if you have that Feature, how should it work Should font size be reduced to fit a word within a line of spacing or ...?

It should work as though the whole stretch of text were a single word: Either it fits on the earlier line, or it gets placed entirely on the next line. And if it's too long - again, like the case of an overly-long word; or any other reasonable fallback.
Comment 15 Eyal Rozenberg 2023-11-24 22:59:00 UTC
(In reply to Heiko Tietze from comment #13)
> Don't think so. It requires ODF-spec

Probably, yeah.

> and all other document formats since
> this is not an option in any text processor (except simple text editors
> where you can switch off line wrapping - for the whole paragraph then).

I'm pretty sure you can do this with TeX. As for other formats - we already warn about other document formats not capturing all of ODF's capabilities; this would just be another one. (This issue might be mitigated by an export filter toggle for replace spaces with NBSP's in such text.)

Anyway, the argument about other formats and apps is essentially an argument against technical leadership in general: Don't do things which are word processors don't support. IMNSHO, that is _at most_ an argument regarding effort investment priority, not feature validity. The use case is clearly demonstrable.


> We have means to prevent line breaking yet the request asks to make this
> easier.

Not _easier_, but part of _styling_, as opposed to hack-based.

> Eventually you end up in lines that overflow the canvas

With typical uses of this feature (legal case titles, book titles, person names etc.) - you don't. Also, when we end up having decent paragraph-level algorithm (see bug 38159) - there will be even less chance of that happening.
Comment 16 László Németh 2024-08-15 17:57:45 UTC
@Eyal and all: thanks for your report and feedback! The issue was solved in Bug 106733. More information:

https://wiki.documentfoundation.org/ReleaseNotes/24.8#Exclude_words_from_hyphenation

*** This bug has been marked as a duplicate of bug 106733 ***
Comment 17 Eyal Rozenberg 2024-08-15 21:25:15 UTC
(In reply to László Németh from comment #16)
> @Eyal and all: thanks for your report and feedback! The issue was solved in
> Bug 106733.

So, I understand that marking allows excluding from hyphenation, but - does it also exclude from line-breaking altogether?

If it doesn't, then it doesn't resolve this bug; and if it does - don't we want to be able to exclude from hyphenation _only_, but allow line breaking?
Comment 18 László Németh 2024-08-16 08:49:48 UTC
(In reply to Eyal Rozenberg from comment #17)
> (In reply to László Németh from comment #16)
> > @Eyal and all: thanks for your report and feedback! The issue was solved in
> > Bug 106733.
> 
> So, I understand that marking allows excluding from hyphenation, but - does
> it also exclude from line-breaking altogether?

Sorry, it doesn't. I have reopened the issue.
Comment 19 László Németh 2024-08-16 09:18:57 UTC
The proposed workaround is to use non-breaking spaces and non-breaking hyphens.

The other proposed one without replacing spaces and hyphens: put the text in an  invisible frame, anchored as character:

1. Select the text
2. Insert->Frame->Frame...
3. In the Frame dialog, set
a) Anchor As Character
b) Width AutoSize (as Height)
c) Width 0 (will be replaced with a minimum value)
d) Height 0 (will be replaced with a minimum value)
e) Position->Vertical->to Character
f) Wrap pane -> Spacing 0
g) Border pane -> No border, Padding 0
4. Press OK to insert the frame with the originally selected text, and to fix the lost position (regression of the new versions of LibreOffice):
5. Ctrl-C
6. Undo
7. Ctrl-V

See the attached document.
Comment 20 László Németh 2024-08-16 09:21:19 UTC
(In reply to László Németh from comment #19)
> The proposed workaround is to use non-breaking spaces and non-breaking
> hyphens.

Ctrl+Shift+Space and Ctrl+Shift+-, see Insert->Formatting Mark
Comment 21 László Németh 2024-08-16 09:21:48 UTC
Created attachment 195845 [details]
invisible frame with non-breaking text
Comment 22 Eyal Rozenberg 2024-08-16 13:10:06 UTC
(In reply to László Németh from comment #19)
> The proposed workaround is to use non-breaking spaces and non-breaking
> hyphens.

Dieter suggested this in comment #4, I replied in comment #5.

> The other proposed one without replacing spaces and hyphens: put the text in
> an  invisible frame, anchored as character

1. Why should a user need to jump through these hoops just make sure their, say, legal case titles, don't get line-broken?
2. Say what you mean, not how you want to see it.
2. The user would need to do that a zillion times; and then, if they want to change the style of something, they would need to remove the frame etc.
Comment 23 László Németh 2024-08-17 01:03:48 UTC
(In reply to Eyal Rozenberg from comment #22)
> (In reply to László Németh from comment #19)
> > The proposed workaround is to use non-breaking spaces and non-breaking
> > hyphens.
> 
> Dieter suggested this in comment #4, I replied in comment #5.

I repeated it only because I wanted to list all the possible workarounds (I remembered a field-based solution, too, but I haven't found it.)

> 
> > The other proposed one without replacing spaces and hyphens: put the text in
> > an  invisible frame, anchored as character
> 
> 1. Why should a user need to jump through these hoops just make sure their,
> say, legal case titles, don't get line-broken?
> 2. Say what you mean, not how you want to see it.
> 2. The user would need to do that a zillion times; and then, if they want to
> change the style of something, they would need to remove the frame etc.

While macros/macro extensions could solve these now, I've found that this is a compatibility feature, see Adobe InDesign's No Break character formatting, which is a strong argument for implementation. (Note: also the implementation of Adobe InDesign's GREP style could help to achieve the same with styles.) Thanks for your suggestion!