Created attachment 184058 [details] Text file with 65535 non-blank lines Description: In LibreOffice Writer document statistics, the line number can not exceed 65535 and it resets to zero after that. This shows the usage of 16 bit unsigned integer for the line count. Steps to Reproduce: 1. Create a file containing 65535 non-blank lines. For example: for i in {1..65535}; do echo .; done > lines.txt Alternatively, you can download and use the attachment (lines.txt) from this issue. 2. Open the file 3. Go to File > Properties > Statistics and click Update. See 65535 in the lines. 4. Add a new non-blank line. 3. Count the statistics again, just like step 3. Actual Results: The line count is shown as 0. Expected Results: The line count should be 65536. Using a 32 bit unsigend integer can increase the limit to 2^32-1=4,294,967,295 (~4.3 billion) which is much better, and is a good practical limit. Reproducible: Always User Profile Reset: No Additional Info: Reproducible with the latst LO 7.5 dev master: Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community Build ID: 95a3d7733c5b48c99b2b74b06c7eeee718fdcd03 CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3 Locale: en-US (en_US.UTF-8); UI: en-US Calc: threaded
Confirm with Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community Build ID: 95a3d7733c5b48c99b2b74b06c7eeee718fdcd03 CPU threads: 4; OS: Linux 5.19; UI render: default; VCL: gtk3 Locale: ro-RO (ro_RO.UTF-8); UI: en-US Calc: threaded It's reseting to zero after the 65535 line.
(In reply to Hossein from comment #0) > The line count should be 65536. Using a 32 bit unsigend integer can increase > the limit to 2^32-1=4,294,967,295 (~4.3 billion) which is much better, and > is a good practical limit. Please don't use unsigned integers, unless you really have to. 2^31 is not much worse. If you are unhappy with that limitation, use sal_Int64, which is *native* on most contemporary platforms.
Bogdan B committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/2f5bffafe4f653aa4ce86f7a27305587680cba58 tdf#152431 Fix line count resets to zero after 65535 It will be available in 7.6.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.
Hossein, is there more to be done? Or I could mark this as Resolved?
(In reply to BogdanB from comment #4) > Hossein, is there more to be done? Or I could mark this as Resolved? Your patch has fixed the problem, and I set it to RESOLVED/FIXED. On the other hand, I think further tests are needed with huge number of lines. Then, possible problems can be reported in separate issues. If you want to further examine other candidates for changes, you can take a look into places that static_cast<sal_Int32>() is used.