Page 1 of 1

Control apostrophe

Posted: Wed Mar 22, 2017 11:07 pm
by jbergx53
CALC would be greatly improved if the EXCEL feature of the Control Apostrophe were added. This feature replicates the content of the cell above it.

Re: Control apostrophe

Posted: Wed Mar 22, 2017 11:20 pm
by RusselB

Re: Control apostrophe

Posted: Wed Mar 22, 2017 11:21 pm
by Zizi64
CALC would be greatly improved if the EXCEL feature of the Control Apostrophe were added. This feature replicates the content of the cell above it.
A simple reference is not appropriate for you?

Code: Select all

A2: "Hello world!"
A1: =A2
Or you can write a simple macro code for copying the content of the selected cell into the cell above...

Re: Control apostrophe

Posted: Wed Mar 22, 2017 11:51 pm
by acknak
LibreOffice provides this shortcut. It is very handy.

You may be able to get it with a recorded macro in AOO—don't know for sure, but maybe worth playing with.

Re: Control apostrophe

Posted: Thu Mar 23, 2017 1:04 am
by jbergx53
Thank you both, Zizi64 and acknak!

Re: Control apostrophe

Posted: Thu Mar 23, 2017 7:32 am
by Zizi64
LibreOffice provides this shortcut. It is very handy.
Oooops!
I never heard about it. The Hungarian keyboard layout is basicly different therefore the ' (aphostrophe) sign is available at Shift-1.
The Ctrl-1 or Shift-Ctrl-1 in not work for me... And not work with the ' key ( near the K-L-; ) when I switch to English keyboard layout...
And I can not find such function in my Shortcut key list of LO 4.4.7...

Where can I find this function from the menu?
 Edit: Ahhh, it works - with English keyboard layout - in my LO 5.3.0 Portable version...
And the name of the function is: 'Fill single edit'. I can assign this function to a really available shortcut key now in my Hungarian LO 4.4.7 too. 

Re: Control apostrophe

Posted: Thu Mar 23, 2017 6:56 pm
by jbergx53
I have tried setting up a macro in CALC to replicate the cell above it, but have not been able to do this with a CTRL-' as is standard in EXCEL. I hope that the systems programmers that have given us the great capabilities of Open Office will see fit to make this a basic part of CALC.

Re: Control apostrophe

Posted: Thu Mar 23, 2017 7:52 pm
by Zizi64
When you have wrote (or recorded) a macro subroutine, and stored it into a Module of the MyMacros/Standard directory, then you can assogn the subroutine to a Menu item, or to a Hotkey (shortcut key) or to a Toolbar icon. Use the Customize function from the
Tools - Customize...

Here is a very simple, recorded macro:

Code: Select all

sub Copy_Down
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(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "By"
args1(0).Value = 1
args1(1).Name = "Sel"
args1(1).Value = false

dispatcher.executeDispatch(document, ".uno:GoUp", "", 0, args1())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())

rem ----------------------------------------------------------------------
dim args3(1) as new com.sun.star.beans.PropertyValue
args3(0).Name = "By"
args3(0).Value = 1
args3(1).Name = "Sel"
args3(1).Value = false

dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args3())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())


end sub
What is your Locale, and what keyboard layout are you using (where is the aphostrophe key on your keyboard)?

Re: Control apostrophe

Posted: Thu Mar 23, 2017 10:12 pm
by Zizi64
Here is an example file. The macro code is in the document. You need copy the macro code into the MyMacros/Standard directory if you want use it in all of your documents.
The button will launch the macro in this document.
You must customize your AOO: assign the macro from the MyMacros to the ' (apostrophe) key of the English keyboard layout.

The macro checks the type of the cell content of the above cell, and will copy the content based of the type value.
http://www.openoffice.org/api/docs/comm ... tType.html
CopyDown.ods
(12.88 KiB) Downloaded 425 times

Code: Select all

sub CopyDown

	oSheet = thiscomponent.getcurrentcontroller.activesheet
	oCellActual = ThisComponent.getCurrentSelection()
	oCellAddress = oCellActual.getCellAddress()
	iRow = oCellAddress.Row()
	iCol = oCellAddress.Column()
	oCellAbove = oSheet.getCellByPosition(iCol,iRow-1)

	Select Case oCellAbove.Type
		Case 0
			oCellActual.ClearContents(1 OR 2 OR 4 OR 8 OR 16 OR 32 OR 64 OR 128 OR 256 OR 512)
		Case 1
			oCellActual.Value = oCellAbove.Value
		Case 2
			oCellActual.String = oCellAbove.String
		Case 3
			oCellActual.Formula = oCellAbove.Formula
	End select
end sub