Created attachment 112506 [details]
Simple repro showcasing the splitting of two paragraphs that ought to be kept together.
First, my understanding of how things work in LibreOffice... please correct me if I'm wrong. :)
With the 'Do not split paragraph' option set, LibreOffice moves a paragraph immediately to a new page once it figures out that this paragraph won't fit on the current page. If the previous paragraph has the 'Keep with next paragraph' option set, LibreOffice will try to keep those two paragraphs together, i.e. if they both fit on the current page, they remain there, otherwise if they both fit on a new, empty page, they will be moved to the next page. However if both paragraphs combined will span more than one page, LibreOffice will separate them, prioritizing the 2nd paragraph's 'Do not split' over the 1st paragraph's 'Keep with next' setting. Once the 2nd paragraph would span more than one page by itself however, the 'Keep with next' setting should have a higher priority again as nothing is really gained from moving only the 2nd paragraph to the next page (as it won't completely fit there anyway).
Furthermore it might be arguable if, should paragraph 2 fit exactly on one page by itself but would span more than one page if kept together with paragraph 1, the 'Keep with next' option should always have a higher priority as the 1st paragraph might e.g. serve as some kind of header to the bulk of content in the 2nd paragraph and as such should always visually remain with that content.
As far as I know LibreOffice behaves the way as Microsoft Word does, and I know I could always disable the 2nd paragraph's 'Do not split' option manually in this case but I am hitting this 'issue' when importing a huge auto-generated .rtf file with dozens to hundreds of these cases... so I thought I'd raise the issue here at least to see if I am alone in this or not. :)
Steps to reproduce:
Load the attached .odt file.
'Paragraph 1' (which has the 'Keep with next' option set) ends up all alone on page 1.
'Paragraph 2' (which has the 'Do not split' option set) ends up on page 2.
'Paragraph 2' should also end up on page 1, immediately following 'Paragraph 1' (due to the 1st paragraph's
'Keep with next' option being set and Paragraph 2 not fitting on page 2 in its entirety in the first place).
You are correct, this is the same behaviour as MS Word 2003. And that basically also answers the question as to whether this is correct behaviour. We need to mimic MSOffice for document compatibility, so this is not a bug.