Bug 156374 - Make Hanging Indent command create a hanging indent, when used on a paragraph without one
Summary: Make Hanging Indent command create a hanging indent, when used on a paragraph...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: difficultyMedium, easyHack, skillCpp
Depends on:
Blocks: Paragraph-Indent
  Show dependency treegraph
 
Reported: 2023-07-19 07:41 UTC by Mike Kaganski
Modified: 2024-04-09 03:12 UTC (History)
4 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 Mike Kaganski 2023-07-19 07:41:37 UTC
There is a Hanging Indent function in Writer [1] (.uno:HangingIndent), implemented in commit c1351a7b1363dac4349f37ac8876fdf950e62b97, that allows to toggle the first line indent into hanging indent and back, when a paragraph already has an indent for its first line, positive or negative.

But this function does nothing, if the paragraph has no indent at all. Compare with a function in MS Word, where Ctrl+T creates a hanging indent in a paragraph without one. (In Word, it would increase the indent each time; but let us not focus on the following behavior - only on the first use on a clean unindented paragraph.)

Steps:
0. Assign "Hanging Indent" function in Writer to a key, say, Ctrl+T.
1. In a new Writer document, create a paragraph with all indents set to 0.
2. Press Ctrl+T

=> nothing happens (this is suggested to be changed in this issue)

3. Set the paragraph's first line indent to 10 mm
4. Press Ctrl+T

=> The indentation is converted to hanging indentation (OK)

The proposal is to add some pre-defined indentation in this case; it might be e.g. equal to the default tab stop. So in step 2, the expected result would be creation of a hanging indent of, say, 1.25 cm, or whatever default tab stop is, or whatever value would be decided (there are some style guides out there, which might be taken into account with regards of this size).

[1] https://help.libreoffice.org/7.6/en-US/text/swriter/guide/indenting.html
Comment 1 Heiko Tietze 2023-07-24 10:53:06 UTC
(In reply to Mike Kaganski from comment #0)
> The proposal is to add some pre-defined indentation in this case; it might
> be e.g. equal to the default tab stop.

Sounds very much reasonable to me. It also does not improve usability when Increase Indent and Hanging Indent have very similar icons but the functionality is quite different (talking about the properties tab in the sidebar).

I wonder if this could be an easyhack.
Comment 2 Mike Kaganski 2024-04-08 06:29:40 UTC
(In reply to Heiko Tietze from comment #1)
> I wonder if this could be an easyhack.

Indeed.
The functionality is implemented for SID_HANGING_INDENT in several places (for different modules - sw, sd; for different contexts). The code pointers:

1. Look into the commit mentioned in comment 0, and see the methods implementing the functionality.
1.a. Alternatively: grep for 'SID_HANGING_INDENT' in .sdi files (there the slots for different UNO commands are defined); write down the 'ExecMethod' in each of the found places; and then, find these methods in the respective module's CXX files, where SID_HANGING_INDENT is handled.
2. In these methods, make sure that there is a reasonable processing for the case when current indent is 0.

I suppose, that the default hanging indent likely should be the same length as "Increase Indent" function does, as indicated by Heiko.