Surely there isn’t a command for this compound task that you simply can assign to a keyboard shortcut. You first have to create a routine for the purpose. Doing this you need to explicitly specify where the rows shall be inserted.
I made a demo inserting as many rows as currently are selected above the selected range and filling the new rows with the content of as many rows from above the inserted ones.
Considering the specifics it might be preferable to insert below and to take the contents from the rows selected in advance.
Simply adapt the routine as needed.
Please note: If you want to use the Sub, you should copy it from the example document to a module of your ‘Standard’ library of BASIC macros.
(Edit:) To ease the comparison I add the code of the Sub contained in the above mentioned demo. You will see that the Sub is clearly “row-oriented” and uses the current selection only to define the range of rows for insertion and for the source (complete rows again) for the subsequent filling.
REM Thanks to the teachers, in specific to Andrew Pitonyak
REM This Sub was tested under LibO V 5.3.3.
REM It was assigned to Ctrl+Alt+P for the tests.
Dim theDoc As Object, theFrame As Object, theSel As Object
Dim theSheet As Object, theDispH As Object, interimSel As Object
Dim sR As Long, eR As Long
theDoc = ThisComponent
theFrame = theDoc.CurrentController.Frame
If NOT theDoc.SupportsService("com.sun.star.sheet.SpreadsheetDocument") Then
theSel = theDoc.CurrentSelection
If NOT theSel.SupportsService("com.sun.star.sheet.SheetCellRange") Then
theSheet = theDoc.Sheets(theSel.RangeAddress.Sheet)
sR = theSel.RangeAddress.StartRow
eR = theSel.RangeAddress.EndRow
If (sR*2 - eR - 1) < 0 Then
theDispH = CreateUnoService("com.sun.star.frame.DispatchHelper")
theDispH.ExecuteDispatch(theFrame, ".uno:InsertRowsBefore", "", 0, Array())
interimSel= theSheet.GetCellRangeByPosition(0, sR*2 - eR - 1, 1023, sR - 1) '(left, top, right, bottom)
theDispH.ExecuteDispatch(theFrame, ".uno:Copy", "", 0, Array())
interimSel = theSheet.GetCellRangeByPosition(0, sR, 1023, eR)
theDispH.ExecuteDispatch(theFrame, ".uno:Paste", "", 0, Array())