Of course(?), I don't "understand" TextCursors either.
But I was able to rewrite Villeroy's respective function to make it insert a paragraph above any newly inserted table for a DrawPage:
- Code: Select all Expand viewCollapse view
Function getNewWriterTable(pDoc, pCols, pRows)
Dim theText, theTable, theTC, cPB
cPB = com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK 'Integer constant (complicated way to write 0)
theText = pDoc.GetText
theTC = theText.CreateTextCursorByRange(theText)
theTC.GotoEnd(False)
theText.InsertControlCharacter(theTC, cPB, False)
theTable = pDoc.CreateInstance("com.sun.star.text.TextTable")
theTable.Initialize(pRows, pCols)
theText.InsertTextContent(theTC, theTable, False)
getNewWriterTable = theTable
End Function
The reworked code is included in the new attachment. There is also demonstrated that this solution will not get the texts from grouped shapes though such a group on page3 looks exactly the same as the two ungrouped shapes on page1. (In page 2 the detection of the text entered as a kind of a label for the ball would fail if it was grouped with it as should be expected.)
I meanwhile also found time to see about a way to recursively resolve groups and multiselections from 'Draw' documents . I only did it out of principal interest, but If somebody has employment for this and gives notice of it, I will post the respective code in the 'Snippets' branch.
I did not yet find a way to access the selection of pages (slides) from the Page Panel (labelled "Pages"; only visible if enabled in 'View'). The selection may consist of a single page, but multiple selection is also supported. See also my question here:
https://ask.libreoffice.org/en/question/146304/.
On Windows 10: LibreOffice 6.2 and older versions, PortableOpenOffice 4.1.5 and older, StarOffice 5.2
---
Lupp from München