(I'll keep this answer here because it is more general than using a builtin command as suggested in my other answer — with a macro you can use any combination of paste options, not just a couple of predefined operations.)
You can define a macro and bind it to a key combination. The simplest way is probably to use the macro recorder:
Ensure that macro recording is turned on: Choose Tools → Options, choose the LibreOffice → General page, then check the “Enable macro recording” option.
Prepare to record the macro: Copy a cell to clipboard (options offered for the Paste Special… command depend on clipboard contents, so you need to have something coming from LibreOffice Calc in the clipboard if you want to record a macro for pasting data copied from Calc).
Select an empty cell to which you will paste the copied data.
Start macro recording: Choose Tools → Macros → Record Macro. The ”Record Macro” toolbar with a Stop Recording button will appear.
Select Edit → Paste Special…, then choose the combination of options you want to record in the macro and press OK.
Click the Stop Recording button; a dialog for saving the macro will appear. Enter the new macro name (e.g., PasteAsTextOrNumber
), select My Macros/Standard/Module1
in the left tree, then press the Save button. (If you enter a macro name which already exists in the module, you will need to confirm that you want to overwrite the old macro; there is no way to append new action to an existing macro using just the macro recorder.)
Now you can assign the macro to a shortcut key. Select Tools → Customize, then switch to the “Keyboard” tab, select the desired shortcut key combination in the top list, then find the macro in bottom lists:
- Category: LibreOffice Macros → user → Standard → Module1
- Function: your macro name (e.g.,
PasteAsTextOrNumber
)
Press Modify to assign the macro to the key combination.
You can also create a toolbar button for the macro using the “Toolbars” tab.
The macro code generated for me when only “Text” and “Numbers” options were checked is:
sub PasteAsTextOrNumber
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(5) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Flags"
args1(0).Value = "SV"
args1(1).Name = "FormulaCommand"
args1(1).Value = 0
args1(2).Name = "SkipEmptyCells"
args1(2).Value = false
args1(3).Name = "Transpose"
args1(3).Value = false
args1(4).Name = "AsLink"
args1(4).Value = false
args1(5).Name = "MoveMode"
args1(5).Value = 4
dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0, args1())
end sub