Created attachment 183063 [details] text-grid-test.odt Steps to Reproduce: 1. New Writer, make sure the option named "Use square page mode for text grid" in "Tools - Options - LibreOffice Writer - General" is unchecked. 2. Format > Page Style > Text Grid, check the "Grid (lines and characters)" option and "Snap to Characters" option. 3. In the "Grid Layout" section, input 22 for "lines per page" and 28 for characters per line". 4. Click OK, then fill the full page with Chinese characters (e.g. copy paste the character "某" to fill the whole page). Current Result: There are 21 lines per page. Expected Result: There should be 22 lines per page, as set in the Page Style settings. Version: 7.4.3.0.0+ / LibreOffice Community Build ID: ee37514eb64b2c431c2f51e7f70d933913217cd6 CPU threads: 8; OS: Linux 5.19; UI render: default; VCL: gtk3 Locale: zh-CN (zh_CN.UTF-8); UI: en-US Calc: threaded Also in 7.3.8.0+
I confirm it with Version: 7.4.2.2 (x64) / LibreOffice Community Build ID: 1726efbecd001a1fe871cba3e00e71283688f34d CPU threads: 4; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win Locale: de-DE (de_DE); UI: en-GB Calc: CL Steps 1. Make sure, that "Asian" is set in Tools -> options -> Language Settings -> Languages 2. Open attachment 183063 [details] 3. Count lines per page (are 21; should be 22) 4. Change lines per page in grid tap of page style dialog and recount Actual result There is always one line missing on a page. If you choose one line per page, LO freezes Expected result Number of lines per page, should be the same as set in the Page Style settings.
Seems like an off-by-one error. Since there is a crash when lines on the page is set to 1, need a backtrace to locate the code pointer.
I could not reproduce the crash, although there seems to be a hang. Adding Mark Hung to cc as he had worked on bug 141957.
Also reproducible in the "oldest" version of the "releases" bibisect repo, thus this is inherited from OOo.
I did some debugging. In function SwTextGridPage::UpdatePageSize(const SfxItemSet& rSet), currently when calculating the page height (net of the header, footer, top space, bottom space etc) (strictly speaking it is the height of the text area, should not be named "page size"), it used the following code: sal_Int32 nValue1 = rSize.GetSize().Height() - nDistanceUL - rBox.GetDistance(SvxBoxItemLine::TOP) - rBox.GetDistance(SvxBoxItemLine::BOTTOM); When I change this to: sal_Int32 nValue1 = rSize.GetSize().Height() - nDistanceUL - rBox.GetDistance(SvxBoxItemLine::TOP) - rBox.GetDistance(SvxBoxItemLine::BOTTOM) - 425; (i.e. deducting the calculated text area height by 425 twips), then if I set the page grid to 22 lines then there would be 22 lines perfectly shown on the page. As a result, I guess the problem may be that when calculating the text area height it did not take into account the spaces between the lines, as when you enlarge the page you will see that there are spaces between each lines. The exact additional spaces to be deducted should be the height of each space multiplied by the lines to be displayed on the page.
https://opengrok.libreoffice.org/xref/core/sw/source/ui/misc/pggrid.cxx?r=384167ab#294
Created attachment 183369 [details] screenshot showing spaces btw lines.pdf
I think I get it. The tine space above each line is the "ruby" which should only be there when in squared page mode. The code seems to be trying to set the ruby height to zero in line https://opengrok.libreoffice.org/xref/core/sw/source/ui/misc/pggrid.cxx?r=384167ab#388 but there seems to be a conversion loss, thus each line finally contains a tiny ruby height, which makes the page not able to hold the number of lines set on the UI.
Kevin Suo committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/875c27dc7975de9b007a215fe1d6f171b4ef090e tdf#151544: Page grid: ruby height should be zero when not in square page mode It will be available in 7.5.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.
This is now fixed on master.
Kevin Suo committed a patch related to this issue. It has been pushed to "libreoffice-7-4": https://git.libreoffice.org/core/commit/e6b070d3da4a3be84fa84d0b8c447d58be6d8923 tdf#151544: Page grid: ruby height should be zero when not in square page mode It will be available in 7.4.4. 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.
VERIFIED with Version: 7.5.0.0.alpha0+ (X86_64) / LibreOffice Community Build ID: 55cd20e6228a06836285c14ca6726adb1bb4ffcb CPU threads: 4; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win Locale: en-US (de_DE); UI: en-GB Calc: CL threaded Kevin, thanks for fixing it! Additional information: If you open attachment 183063 [details] it still has only 21 lines (expected 22). But if you change number of lines in page style dialog, you always get the correct result. So I would think, it is fixed.
> If you open attachment 183063 [details] it still has only 21 lines (expected 22). But if you change number of lines in page style dialog. That would be because the old line-space settings were already written to the document. This will also be good as this way it would not break old document.