Creating Card Suit Symbol Shortcuts in OpenOffice For Bridge

Creating a macro - Writing a Script - Using the API

Creating Card Suit Symbol Shortcuts in OpenOffice For Bridge

Postby jinglenose » Wed May 28, 2014 5:39 pm

I'm going to explain how to create suit symbol macros in openoffice and assign them to a short cut key combination. In this case I'm going to assign them to alt-c, alt-d, alt-h and alt-s for clubs, diamonds, hearts and spades. You just need to press alt and c to get a club symbol for instance.

Go to the menu item...

Tools >> Macros >> Organise Macros >> Openoffice.orb basic and the following window should turn up...


Click edit and a text editor should appear that contain the macro code. All you need to do is move to the end and past in this code...

-------------------------------start of code-------------------------------------

sub Club

dim document as object
dim dispatcher as object

document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Text"
args1(0).Value = "♣"

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

end sub

sub Diamond

dim document as object
dim dispatcher as object

document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

dim args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Text"
args1(0).Value = "♦"

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

end sub

sub Heart

dim document as object
dim dispatcher as object

document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Text"
args1(0).Value = "♥"

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

end sub

sub Spade

dim document as object
dim dispatcher as object

document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Text"
args1(0).Value = "♠"

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

end sub

-------------------------------end of code--------------------------------------

Close the text editor and it should save the changes.

Now we need to assign these to a short cut. Choose the menu item...

Tools >> Customise

Then choose the keyboard tab. Scroll down the key combinations list box until you see the alt-c option etc.
You then choose openoffice.org macros >> user >> standard >> module and choose the appropriate function. Lets start with the "Club" function. Select alt-c in the shortcuts list and the click modify. This will then associate alt-c with the clubs function. Do this for each suit shortcut you want and then click OK.

Good luck!
OpenOffice 4.1 on Windows 7
jinglenose
 
Posts: 3
Joined: Wed May 28, 2014 4:00 pm

Re: Creating Card Suit Symbol Shortcuts in OpenOffice For Br

Postby John_Ha » Wed May 28, 2014 5:53 pm

My bridge playing colleague did this by AutoCorrect, where he told AOO to AutoCorrect, say, [c] to a black ♣ (and removing the square brackets), where you have already created the ♣ (Insert > Special character ...) and you copy and paste it into the Replace field. Similarly for diamonds, hearts and clubs. If you want the number to be red/black, then AutoCorrect [6h] to a red 6♥ etc.
Attachments
Clipboard01.png
Last edited by John_Ha on Thu May 26, 2016 11:29 am, edited 1 time in total.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
 
Posts: 7796
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Creating Card Suit Symbol Shortcuts in OpenOffice For Br

Postby acknak » Wed May 28, 2014 6:31 pm

You could also define autotexts for the suits (or cards). For example, (once you've configured it) type csh and press F3 to get the suit symbol.
AOO4/LO5 • Linux • Fedora 23
User avatar
acknak
Moderator
 
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Creating Card Suit Symbol Shortcuts in OpenOffice For Br

Postby kurtrabbit » Sun Feb 03, 2019 11:59 pm

I believe I did this correctly but it doesn't work.
OpenOffice 4.0.0 on Windows 7
kurtrabbit
 
Posts: 8
Joined: Wed Jan 28, 2015 4:58 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 3 guests