Bug 161368 - Text wraps before page margins when page width exceeds 119 cm
Summary: Text wraps before page margins when page width exceeds 119 cm
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Mike Kaganski
URL:
Whiteboard: target:24.8.0
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-31 22:08 UTC by Alistair Saywell
Modified: 2024-09-02 12:33 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Page width 120 cm, wraps at 4 mm (9.96 KB, application/vnd.oasis.opendocument.text)
2024-05-31 22:08 UTC, Alistair Saywell
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alistair Saywell 2024-05-31 22:08:18 UTC
Created attachment 194492 [details]
Page width 120 cm, wraps at 4 mm

If the page width in Writer is set wider than 119 cm then the text starts wrapping before the the right hand page margin. An extreme example, at a page width of 120 cm, the line wraps at approximately 4 mm, see attached Writer document. The point at which the text starts wrapping varies with page width beyond 119 cm

Earliest tested on 6.4.7.2

Expectation: The text should continue to the right hand margin

Issue arose recently in https://ask.libreoffice.org/t/ultra-wide-document/106370 
Also, earlier in https://ask.libreoffice.org/t/libreoffice-writer-possible-bug-format-page/40120
Comment 1 Mike Kaganski 2024-06-01 13:11:51 UTC
Almost definitely an integer overflow. 65536 twip is 115.6 cm; add 2 x 2 cm margins, and you get 119.6 cm (and then, 120 cm - 119.6 cm gives the 4 mm).

A tentative code pointer: sal_uInt16 SwTextFormatInfo::Width() in sw/source/core/text/inftxt.hxx (and many other cases of use of sal_uInt16 e.g. in sw/source/core/text/itrform2.cxx).
Comment 2 Mike Kaganski 2024-06-02 05:50:57 UTC
i#34348 already changed *some* fields in SwTextFormatInfo from sal_uInt16, so putting that to See Also.
Comment 3 Commit Notification 2024-06-02 17:19:11 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/7e9c23894bd45e015accf26ae0a77035b7eed452

tdf#161368: use SwTwips for twip sizes, instead of sal_uInt16

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