Bug 116403 - DOC(X): Adding borders to a document with TOC doesn't correct TOC tabbing
Summary: DOC(X): Adding borders to a document with TOC doesn't correct TOC tabbing
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
(earliest affected) release
Hardware: All All
: medium normal
Assignee: Mike Kaganski
Whiteboard: target:6.1.0
Keywords: bibisected, bisected, regression
Depends on:
Blocks: DOCX-TableofContents Borders DOC-TableofContents
  Show dependency treegraph
Reported: 2018-03-14 15:37 UTC by Aron Budea
Modified: 2018-03-19 17:06 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:

Sample ODT (9.80 KB, application/vnd.oasis.opendocument.text)
2018-03-14 15:37 UTC, Aron Budea
Sample DOC (saved from ODT) (10.00 KB, application/msword)
2018-03-14 15:38 UTC, Aron Budea
Sample DOCX (saved from ODT) (5.09 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2018-03-14 15:39 UTC, Aron Budea

Note You need to log in before you can comment on or make changes to this bug.
Description Aron Budea 2018-03-14 15:37:56 UTC
Created attachment 140633 [details]
Sample ODT

Open the attached samples (ODT for reference, DOC/DOCX as bugdocs), and add border to all sides using Format -> Page...; Borders tab, Set All Four Borders.
The issue will be more apparent if Spacing to Contents is increased to eg. 0.2 cm.

=> Page numbers in TOC fall outside the border (only with DOC/DOCX, not with ODT).
The TOC in DOCX is a bit buggy already, but that's not related.

Observed using LO & / Windows 7.
The number stays in the border in, with DOC, DOCX is buggy.
=> regression

The "regression" was introduced by the commit referenced below. However, I don't think it's directly responsible for the issue, the tab position for TOC should be adjusted when adding a border.

author		Miklos Vajna <vmiklos@suse.cz>	2013-01-08 11:57:13 +0100
committer	Miklos Vajna <vmiklos@suse.cz>	2013-01-08 14:17:27 +0100

n#793998 sw: add TabOverMargin compat mode
Comment 1 Aron Budea 2018-03-14 15:38:38 UTC
Created attachment 140634 [details]
Sample DOC (saved from ODT)
Comment 2 Aron Budea 2018-03-14 15:39:07 UTC
Created attachment 140635 [details]
Sample DOCX (saved from ODT)
Comment 3 Xisco Faulí 2018-03-14 18:40:36 UTC
Moving to NEW
Comment 4 Mike Kaganski 2018-03-16 08:50:26 UTC

The problem is not in DOC/DOCX, or in the compatibility mode mentioned in comment 0.

When an index is (re)generated, every right-aligned tab in its tokens generates a (manually-applied) tabstop position in relevant paragraph, which position is calculated at the right text margin based on the layout. Further layout changes don't update the tabstop, unless user updates the index (right-click->Update index). The first problem (the real bug) is, that calculation of the position does not take borders into account, regardless of compatibility mode.

Still, when the text area is/becomes narrower than the tabstop position (like when right margin increases, or when borders exist), *without* the compatibility mode, the problem is not apparent, since the out-of-textarea tabstop is overriden by the textarea margin, so the number position gets to the expected position dynamically (even no index update necessary). But with the mode active, this becomes immediately visible.

One can check the problem with a new text document: add a heading and a ToC with default settings; then decrease right page margin and see that page number doesn't follow the margin (until index update).

So, to fix this first problem, the patch mentioned above simply considers margins when calculating tabstop position, thus correctly setting it on index creation/update.

The other thing is if we should also update the position dynamically after changing margins/borders (or relayouting that could move the index to another page with different margins/borders). This would be an enhancement, and should be tracked separately; also, we should consider that user can manually change the tabstops (when disabled the index protection; after modifications, the protection could be restored). So, how would we go when the positions were manually tweaked? dynamic update would destroy the overriden values.
Comment 5 Commit Notification 2018-03-16 09:55:07 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":


tdf#116403: consider borders when updating right-aligned tab in index

It will be available in 6.1.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:

Affected users are encouraged to test the fix and report feedback.