A bit of philosophy:
Having selected any CellRange of a sheet, the copy command is used to copy “everything” connected to that range. This always includes the formula / formulae if any. In the same sense as a true subrange of the locked output range of an array-formula cannot be edited, it cannot be copied therefor.
To allow for the ‘Copy’ command you actually want - without the formulae - a command like ‘Copy Special…’ in analogy to ‘Paste Special…’ would be needed.
You may file a feature request (“enhancement”) to https://bugs.documentfoundation.org/. Feature requests are treated exactly like (as) bugs.
If you don’t shy back from resorting to custom code: It isn’t exactly difficult to get the needed commands this way.
Edit1 adding provisional code and attaching this demo.
REM ***** BASIC *****
REM 2018-04-06 Wolfgang Jäger
Global copiedDA As Object
Sub copyDA()
REM 2018-04-06 Wolfgang Jäger
doc0 = ThisComponent
theSel = doc0.CurrentSelection
If NOT theSel.SupportsService("com.sun.star.sheet.SheetCellRange") Then Exit Sub
copiedDA = theSel.GetDataArray
End Sub
Sub pasteDA()
REM 2018-04-06 Wolfgang Jäger
REM The target range is exclusively based on the cell having currently the focus
REM even if this cell isn't currently selected itself. The selection as shown
REM by highlighting is ignored. The dimensions of the target range are taken
REM from the previously taken DataArray.
REM Formats are ignored. Trying to do it otherwise would raise serious complications, imo:
REM first copy using the sheet method CopyRange, then ClearContents, then as shown here.
doc0 = ThisComponent
If NOT doc0.SupportsService("com.sun.star.sheet.SpreadsheetDocument") Then Exit Sub
fC = focusCell(doc0.CurrentController)
On Error Goto errorExit
m = Ubound(copiedDA(0)) : n = Ubound(copiedDA)
With fC.CellAddress
target = fC.Spreadsheet.GetCellRangeByPosition(.Column, .Row, .Column + m, .Row + n)
End With
target.SetDataArray(copiedDA)
errorExit:
End Sub
REM === The following helper function is the most obscure part of the solution. ===
Function focusCell(Optional pCtrl) As Object
REM Concept by "uros", "Villeroy"
REM Responsible for this variant: Wolfgang Jäger
REM 2017-09-28 V0
If IsMissing(pCtrl) Then pCtrl = ThisComponent.CurrentController
If NOT pCtrl.SupportsService("com.sun.star.sheet.SpreadsheetView") Then Exit Function
Dim theSheet As Object, fC As Object, sheetNum As Long, sInfo As String
Dim sInfoDelim As String, vD, vDSplit, sInfoSplit
vD = pCtrl.ViewData
vDSplit = Split(vD, ";")
theSheet = pCtrl.ActiveSheet
sheetNum = theSheet.RangeAddress.Sheet
sInfo = vDSplit(sheetNum + 3)
REM For CellAddress.Row >= 8192 the "+" is used as the subdelimiter in ViewData. WHY?
If InStr(sInfo, "+")>0 Then
sInfoDelim = "+"
Else
sInfoDelim = "/"
End If
sInfoSplit = Split(sInfo, sInfoDelim)
fC = theSheet.GetCellByPosition(sInfoSplit(0), sInfoSplit(1))
focusCell = fC
End Function
Edit2 (Obsolete line of code deleted; delete also the respective comment.)
When I tested the macros I noticed that the action by the Sub ‘pasteDA’ is not always cleanly made undone using the respective command. Cells that were blank previously retain the inserted content wrongly after Ctrl+Z.
I therefor posted the bug report tdf#116850.