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: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium enhancement
Assignee: Kira Tubo
URL:
Whiteboard: target:25.2.0
Keywords: difficultyMedium, easyHack, skillCpp
Depends on:
Blocks: Paragraph-Indent
  Show dependency treegraph
 
Reported: 2023-07-19 07:41 UTC by Mike Kaganski
Modified: 2024-10-01 00:55 UTC (History)
5 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.
Comment 3 Commit Notification 2024-09-29 00:40:26 UTC
Kira Tubo committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/4cc532c0393914a743c11e806bd25dfa3d28fb5c

tdf#156374: Create hanging indent on paragraph without one

It will be available in 25.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 4 BogdanB 2024-09-29 16:41:19 UTC
Working well in
Version: 25.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 9e5321f46d175e827924a8040f6325cdcd7d751f
CPU threads: 16; OS: Linux 6.8; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded

Not working in (for comparison reason)
Version: 24.8.2.1 (X86_64) / LibreOffice Community
Build ID: 0f794b6e29741098670a3b95d60478a65d05ef13
CPU threads: 16; OS: Linux 6.8; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded
Comment 5 BogdanB 2024-10-01 00:55:11 UTC
Verified in comment 4