Bug 44282 - [FORMATING] [TOC] space missing between text and outline numbering
Summary: [FORMATING] [TOC] space missing between text and outline numbering
Status: ASSIGNED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
3.5.0 Beta2
Hardware: All All
: high enhancement
Assignee: RAHUL KUMAR
QA Contact:
URL:
Whiteboard: target:5.2.0 target:5.3.0 target:5.4....
Keywords: difficultyBeginner, easyHack, skillCpp
: 81981 103149 (view as bug list)
Depends on:
Blocks: TableofContents-Indexes Chapter-Numbering
  Show dependency treegraph
 
Reported: 2011-12-29 11:31 UTC by Gustavo Pacheco
Modified: 2017-10-28 02:35 UTC (History)
13 users (show)

See Also:
Crash report or crash signature:


Attachments
Example document demonstrating the bug (9.38 KB, application/vnd.oasis.opendocument.text)
2012-02-23 03:16 UTC, Ville Ranki
Details
Example with space (11.28 KB, application/vnd.oasis.opendocument.text)
2012-05-19 03:08 UTC, Alexandr
Details
The same example, but with tab 0,5 cm instead of space (11.24 KB, application/vnd.oasis.opendocument.text)
2012-05-19 03:21 UTC, sasha.libreoffice
Details
Updated TOC of toc-bug.odt (14.02 KB, image/png)
2016-03-18 21:59 UTC, Gabor Kelemen
Details
Updated TOC of toc.odt (14.48 KB, image/png)
2016-03-18 21:59 UTC, Gabor Kelemen
Details
Updated TOC of toc-tab.odt (14.91 KB, image/png)
2016-03-18 21:59 UTC, Gabor Kelemen
Details
List of possible separators between the numbering and text (39.36 KB, image/png)
2016-03-18 22:00 UTC, Gabor Kelemen
Details
Screenshot of the example documents TOCs with the new fix (106.72 KB, image/png)
2016-08-16 21:53 UTC, Gabor Kelemen
Details
Test file showing additional space after chapter no. in ToC (321.06 KB, application/vnd.oasis.opendocument.text)
2017-04-24 14:15 UTC, Thomas Lendo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gustavo Pacheco 2011-12-29 11:31:44 UTC
Create a new document with some paragraphs with 'Heading 1' style;

Insert outline numbering for 'Heading 1' paragraphs (Tools > Outline Numbering... ; Number field to '1, 2, 3, ...'), click OK;

Insert a TOC (Insert > Indexes and Tables > Indexes and Tables), click OK;

In the new TOC, there isn't space between text and number.

The workaround that I use is insert a space between <e#> and <e> in the structure of all entry levels of TOC.  But I think Writer can do it automatically.

Thanks!
Gustavo Pacheco.
Comment 1 sasha.libreoffice 2012-02-16 02:03:55 UTC
Please, attach small document that demonstrates this problem
Comment 2 Ville Ranki 2012-02-23 03:16:28 UTC
Created attachment 57513 [details]
Example document demonstrating the bug
Comment 3 Ville Ranki 2012-02-23 03:19:38 UTC
The bug has been annoying OO.o (and maybe even Staroffice) users for years. There is a workaround (adding a space in Index/Table settings) but by default there should be a space.

A lot of users have asked about this:

https://www.google.com/search?q=openoffice+toc+space+between
Comment 4 Alexandr 2012-05-18 10:59:26 UTC
The same in the 3.5.3.2 on Ubuntu 12.04 
Really annoying.
Comment 5 sasha.libreoffice 2012-05-19 02:56:13 UTC
Thanks for attachment, workaround, and additional information.
It is enhancement request because Writer works correctly, at least formally. But productivity may be increased.
Another question: what to add, space or tab? If space, then how much? If tab then on which distance? 0.5 cm looks reasonable for me.
Comment 6 Alexandr 2012-05-19 03:07:46 UTC
I have inserted one space - and it looks very well. 

But there is a small problem with this workaround: I have two chapters in the beginning without numbers (anтotation and introduction) if I insert a space it also affects them - they start not from the beginning of the line, but after the space. Of course it is much more better, than it was before without space but does not look perfectly.
Comment 7 Alexandr 2012-05-19 03:08:26 UTC
Created attachment 61834 [details]
Example with space
Comment 8 sasha.libreoffice 2012-05-19 03:21:22 UTC
Created attachment 61835 [details]
The same example, but with tab 0,5 cm instead of space
Comment 9 Alexandr 2012-05-19 03:31:58 UTC
Looks much more better with tab! 

But shouldn't be lines without numbers left aligned as the numbered lines? I think this variant will be correct. But your with tab is also very good.
Comment 10 Owen Genat (retired) 2014-08-01 05:02:09 UTC
*** Bug 81981 has been marked as a duplicate of this bug. ***
Comment 11 ababaaa 2015-02-04 19:31:51 UTC
Hello ,I am a rookie and want to solve this as my first easy bug hack.
Can any body give me idea how should I procede.
Thanks in Advance.
Comment 12 Cor Nouws 2015-02-05 15:54:39 UTC
Hi Lovekesh,

(In reply to Lovekesh Garg from comment #11)
> Hello ,I am a rookie and want to solve this as my first easy bug hack.
> Can any body give me idea how should I procede.

Nice. Look here http://wiki.documentfoundation.org/Development
and don't forget to use e.g. opengrock.

Cheers,
Cor
Comment 13 Andras Timar 2015-06-25 09:02:46 UTC
(In reply to ababaaa from comment #11)
> Hello ,I am a rookie and want to solve this as my first easy bug hack.
> Can any body give me idea how should I procede.
> Thanks in Advance.

See OUString SwTextNode::GetExpandText() in sw/source/core/txtnode/ndtxt.cxx and TextAndReading SwTOXPara::GetText_Impl() in sw/source/core/tox/txmsrt.cxx.
Comment 14 Robinson Tryon (qubit) 2015-12-14 06:58:00 UTC Comment hidden (obsolete)
Comment 15 Robinson Tryon (qubit) 2016-02-18 14:52:05 UTC Comment hidden (obsolete)
Comment 16 Mohamed Thabet 2016-03-13 09:54:20 UTC
Hello, I want to fix this bug
Comment 17 Mohamed Thabet 2016-03-13 09:59:50 UTC
I'm new to libreoffice, I'm planning to solve it as my first easyhack
Comment 18 Commit Notification 2016-03-18 11:04:49 UTC
Mohamed Thabet committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=9ebe054ddb2d938b24ca4688be9bcbc62745f67f

tdf#44282 fix missing space for numbered lists in TOC

It will be available in 5.2.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 19 Gabor Kelemen 2016-03-18 21:57:12 UTC
Thanks for taking the time to fix this.

I built LO from master, opened the three attached example files, then updated the TOC. Results are:

toc-bug.odt: 
TOC contains numbers and text without any spacing: "1Foo". Paragraphs contain a tab between the number and text: "1\tFoo".
After updating the TOC there is a space between the number and text: "1 Foo". 

toc.odt: 
TOC contains a space between the numbers and text: "1 Eins".
Paragraphs contain a tab between the number and text: "1\tEins".
After updating the TOC there are two spaces between the number and text: "1  Eins"

toc-tab.odt: 
TOC contains a tab between the numbers and text: "1\tEins".
Paragraphs contain a tab between the number and text: "1\tEins".
After updating the TOC there is a space and a tab between the number and text: "1 \tEins"

If we take a step backwards, Writer should take it into consideration
- what is already imported in the TOC, 
- what is set as a separator for the given level of numbering in the Bullets and Numbering window, Position tab, "Numbering followed by" dropdown, which has three possible values: Tab stop, Space, Nothing.

I think just blindly inserting a space is not the right thing.
Comment 20 Gabor Kelemen 2016-03-18 21:59:08 UTC
Created attachment 123705 [details]
Updated TOC of toc-bug.odt
Comment 21 Gabor Kelemen 2016-03-18 21:59:30 UTC
Created attachment 123706 [details]
Updated TOC of toc.odt
Comment 22 Gabor Kelemen 2016-03-18 21:59:53 UTC
Created attachment 123707 [details]
Updated TOC of toc-tab.odt
Comment 23 Gabor Kelemen 2016-03-18 22:00:30 UTC
Created attachment 123708 [details]
List of possible separators between the numbering and text
Comment 24 Mohamed Thabet 2016-03-18 22:21:06 UTC
Thank you for the detailed feedback, I will take the two points you mentioned into consideration and will try to work on it again.
Comment 25 Commit Notification 2016-03-21 19:37:10 UTC
jan iversen committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=0149e87df9f09f325f8a04f495d561b8deb1e625

Revert "tdf#44282 fix missing space for numbered lists in TOC"

It will be available in 5.2.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 26 Mohamed Thabet 2016-03-25 09:04:12 UTC
Regarding the first point,

I think if there is already a tab token added to the table of contents like the work around, and the number token has a separator after it, the normal behavior would be having two consecutive separators, is that right?

I made some progress, I can now insert the correct separator according to the list, and the option: "format: number without separator" now works for the number token.

there is still a problem when the list separator is a tab, where not defining a the correct tab stop position would expand the tab into dots, but I'm still looking into it.
Comment 27 Gabor Kelemen 2016-03-25 10:03:14 UTC
(In reply to Mohamed Thabet from comment #26)
> Regarding the first point,
> 
> I think if there is already a tab token added to the table of contents like
> the work around, and the number token has a separator after it, the normal
> behavior would be having two consecutive separators, is that right?
> 

No, because in the next "open document - refresh index" cycle there will be two tabs in the index, so you would add one more to make it three.

For inspiration, Word replaces the separator in the index with the one set in the header text.
If you have a tab separator in the index, then you change the separator to space in the text and update the index, there will be one space in the index too. So the index always follows the text.
Comment 28 Mohamed Thabet 2016-03-25 11:31:17 UTC
That word like behaviour is exactly what I'm aiming for.

I just need to clarify that the table of contents doesn't accumulate separators, in each table update it works like the first time, so doing the open document and update cycle won't add a third separator, what I mean by having two separators is having:
- the separator followed by the number
- the separator from the workaround.

so - exculding the use of a differnt separator - the "Updated TOC of toc-tab.odt" attachment works like expected, there is a number separator then there is the user added tab, updating the table of contents won't add any more separators.
Comment 29 jani 2016-04-25 05:55:30 UTC
A polite ping, still working on this patch?
Comment 30 Mohamed Thabet 2016-04-25 07:06:22 UTC
Currently I'm not working on it, I couldn't replicate the behavior of numbered lists in the table of contents when the separator was a tab.
Comment 31 Raj Sarkar 2016-07-15 15:35:30 UTC
I'm new here and want to solve this bug. I've understood the bug and have even replicated it. I took a look at one of the patches in the comments(which seems to not account for all the cases). 

Comment 19 explains what actually needs to be done and I quote a part of it here - 

"If we take a step backwards, Writer should take it into consideration
- what is already imported in the TOC, 
- what is set as a separator for the given level of numbering in the Bullets and Numbering window, Position tab, "Numbering followed by" dropdown, which has three possible values: Tab stop, Space, Nothing."

Can I know where should I look for the code related to the two points mentioned in the above comment?
Comment 32 jani 2016-07-18 05:57:20 UTC
(In reply to Raj Sarkar from comment #31)
> I'm new here and want to solve this bug. I've understood the bug and have
> even replicated it. I took a look at one of the patches in the
> comments(which seems to not account for all the cases). 
> 
> Comment 19 explains what actually needs to be done and I quote a part of it
> here - 
> 
> "If we take a step backwards, Writer should take it into consideration
> - what is already imported in the TOC, 
> - what is set as a separator for the given level of numbering in the Bullets
> and Numbering window, Position tab, "Numbering followed by" dropdown, which
> has three possible values: Tab stop, Space, Nothing."
> 
> Can I know where should I look for the code related to the two points
> mentioned in the above comment?

Welcome, in general have a look at:
https://wiki.documentfoundation.org/Development/GetInvolved

Code pointers are found in comment #18,
That patch was good, but had some side effects, so the easiest way is to take the patch, test it, and correct it.

The problem the patch introduced was around outlining at higher levels than 2.
Comment 33 Commit Notification 2016-08-16 06:27:25 UTC
Abhilash Singh committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=ce95e39f8e952159844e9dc04a1df402bb103634

tdf#44282 fix missing space for numbered lists in TOC

It will be available in 5.3.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 34 Gabor Kelemen 2016-08-16 21:52:11 UTC
(In reply to Commit Notification from comment #33)
> Abhilash Singh committed a patch related to this issue.
> It has been pushed to "master":
> 
> http://cgit.freedesktop.org/libreoffice/core/commit/
> ?id=ce95e39f8e952159844e9dc04a1df402bb103634
> 
> tdf#44282 fix missing space for numbered lists in TOC
> 
> It will be available in 5.3.0.
> 
> The patch should be included in the daily builds available at
> http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
> information about daily builds can be found at:
> http://wiki.documentfoundation.org/Testing_Daily_Builds
> 
> Affected users are encouraged to test the fix and report feedback.

Thanks for trying to fix this problem.

I have built the 5.3 master branch, and the situation is the same as with the earlier patch: a space separator is always added.

So after updating the TOC there is one space separatop in toc-bug.odt, two spaces in toc.odt and a space and tab in toc-tab.odt.
Comment 35 Gabor Kelemen 2016-08-16 21:53:21 UTC
Created attachment 126860 [details]
Screenshot of the example documents TOCs with the new fix
Comment 36 Cor Nouws 2016-10-12 11:25:19 UTC
*** Bug 103149 has been marked as a duplicate of this bug. ***
Comment 37 Cor Nouws 2016-10-12 11:27:11 UTC
@abhilash,

Can you please look at comment #34 and 35?
Thanks for your efforts on this issue - great to see progress!
Ciao - Cor
Comment 38 abhilash300singh 2016-10-12 20:45:59 UTC
Thanks for pointing out. 

I agree. The previous patch added a space irrespective of the fact whether or not numbering was done( For example - in attached file toc.odt, the previous patch also added a space to Heading-1 "Null" which wasn't even numbered and hence didn't require spacing. Comment 6 mentions the same problem).

My patch merely made sure that spacing is applied only when numbering is available( leaving the Heading 1 "Null" in toc.odt and taking care of all other Headings). 

So, what in addition needs to be done is - if the user has specified something between <E#> and <E> ( a space or some other character ) we don't need the default spacing to be applied. And in all other cases we need the default spacing to be applied. Is that so? Please confirm, and I will commit a patch soon accordingly.

Thanks.
Comment 39 Cor Nouws 2016-10-14 11:54:19 UTC
(In reply to abhilash300singh from comment #38)

> So, what in addition needs to be done is - if the user has specified
> something between <E#> and <E> ( a space or some other character ) we don't
> need the default spacing to be applied. And in all other cases we need the
> default spacing to be applied. Is that so? 

Indeed, perfect.

> Please confirm, and I will commit a patch soon accordingly.

Thanks a lot!
Comment 40 zyklon87 2016-10-17 20:06:37 UTC
Please don't forget to insert back the space, when a different separator gets deleted again. :)
Comment 41 abhilash300singh 2016-10-20 20:43:13 UTC
(In reply to zyklon87 from comment #40)
> Please don't forget to insert back the space, when a different separator
> gets deleted again. :)

I tested this. The case statements seem to take care of this themselves.
Comment 42 Commit Notification 2016-10-25 07:22:31 UTC
Abhilash committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=250252d02bac88877845a4bc27e3f1837f1312ba

tdf#44282 fix missing space for numbered lists in TOC

It will be available in 5.3.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 43 jani 2016-10-28 06:10:18 UTC
Seems solved.
Comment 44 Commit Notification 2017-02-15 11:35:39 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=dc8ebf205c3231ffc4d6737b53cee396c2ac0bfd

tdf#104315: Revert "tdf#44282 fix missing space...

It will be available in 5.4.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 45 Xisco Faulí 2017-02-15 11:39:38 UTC
Moving back to NEW as the commit has been reverted due to the fact that it introduced some regressions in TOC
Comment 46 Heiko Tietze 2017-02-15 12:35:01 UTC
Adding a space or any other character is not the right way of formatting. If the default of the style "Contents 1" (and below) is 0 for all indentation this property should be changed to something like 0.5/-0.5 for before text/first line.
Comment 47 Commit Notification 2017-02-15 13:27:03 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "libreoffice-5-3":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=05116fb49efa563610f6486d0c3f6216624dcd13&h=libreoffice-5-3

tdf#104315: Revert "tdf#44282 fix missing space...

It will be available in 5.3.1.

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

Affected users are encouraged to test the fix and report feedback.
Comment 48 RAHUL KUMAR 2017-03-15 16:10:08 UTC
I am starting to work on this bug.
Comment 49 Thomas Lendo 2017-04-24 14:15:21 UTC
Created attachment 132787 [details]
Test file showing additional space after chapter no. in ToC

In 5.3.1 an additional space after the chapter number in a Table of Content was introduced. You can test it with the attached document. Illustration and table indexes are not affected. 5.3.0 wasn't affected. 5.3.2 is also affected.

Actual result:
2.1 Heading level 2 ................. 2 -1

Expected result:
2.1 Heading level 2 ................. 2-1
Comment 50 Xisco Faulí 2017-05-25 02:49:06 UTC Comment hidden (obsolete)
Comment 51 Xisco Faulí 2017-06-25 02:31:27 UTC Comment hidden (obsolete)
Comment 52 Xisco Faulí 2017-07-26 02:36:31 UTC Comment hidden (obsolete)
Comment 53 Xisco Faulí 2017-09-27 02:32:16 UTC Comment hidden (obsolete)
Comment 54 Xisco Faulí 2017-10-28 02:35:18 UTC
A polite ping, still working on this bug?