see viewtopic.php?f=7&t=59825
Code: Select all
sub test()
dim AddedParaAtStart as boolean
SelectWholeWriterDocument(thiscomponent,AddedParaAtStart)
msgbox AddedParaAtStart
end sub
Sub SelectWholeWriterDocument(Doc,byref AddedParaAtStart as boolean)
dim dispatcher as object,OVC
oText= doc.text
OVC =thiscomponent.currentcontroller.viewcursor ' oText.createTextCursorByRange(oText.getStart)
with oVC
.JumpToFirstPage(false)
.JumpToStartOfPage(false)
do until res = false
res =.goUp(1,false)
loop
if Not IsEmpty(.TextTable) then 'if table at start then need to insertparagraph
'see https://forum.openoffice.org/en/forum/viewtopic.php?f=7&t=59825
'Text.insertControlCharacter(oVC,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, false) DOESN'T DO THIS
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(Doc.CurrentController.Frame, ".uno:InsertPara", "", 0, Array())
AddedParaAtStart = true
end if
.gotoend(true)
end with
End Sub