This may be important: in your ttest_4.odt, you merge cells in first column. This means your table has a single row in first column and two rows in second column. This could have an impact on widow/orphan handling (though I suspect it is not effective in tables) and make a split-decision much more difficult.
A sort of conclusion.
I’ve implemented table of contents the way it should look (from my point of view). Attached the file with LibreOffice TOC and this same TOC, generated from Asciidoctor.
test-asciidoctor-open-document.odt (460.0 KB)
The greatest thing, I couldn’t reach in MS Word, this approach prevents page break between parent and first child on any level.
If somebody is interested, here is the implementation https://github.com/CourseOrchestra/asciidoctor-open-document/blob/main/lib/slim/outline.fodt.slim. At least, it shows the hierarchy of used elements. The same idea can be implemented with LibreOffice macro.
To tables. In my opinion, LibreOffice implementation of breaking table across pages is somewhere between satisfactory and unsatisfactory. Here are rules, I would follow within the current flawed implementation:
Uncheck the option that allows rows to break between pages and columns (by default, it is checked). LibreOffice will still break cells between pages if they are spanned vertically. But this is often an expected behavior. Moreover, this option, if checked, leads to errors in breaking text across pages in vertically spanned cells.
If you need rows to break between pages, then turn this option off for the last row. Widows look worse than orphans. Despite this option is set in table properties, it is applied only to selected rows.
I’ve updated connected issues. Thank you for your help.