Adding preference shortcut to toolbar

Discuss the spreadsheet application
Post Reply
orionp3
Posts: 2
Joined: Sun Feb 16, 2020 7:27 am

Adding preference shortcut to toolbar

Post by orionp3 »

I would like to add a short-cut ("grid lines" - off/on and colour preference) to the standard toolbar rather than have to dig through the preferences menu which covers all components of Open Office.
Is there any way of doing this ?
Thanks.
open office 73 on mac macOS 10.14.6 (Mojave)
User avatar
Zizi64
Volunteer
Posts: 11363
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: adding preference shortcut to toolbar

Post by Zizi64 »

https://extensions.openoffice.org/en/project/gridlines

Or you can write your own macro code based on the API descriptions and the code of the extension, because it is quite old extension. Maybe it will not work with the newer versions of the AOO/LO:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="GridLinesMod" script:language="StarBasic">REM  *****  BASIC  *****

Dim GridLinesListener As Object
Global SheetsWithHideGridLines
&apos;-----------------------------------------------------------------
Sub RunGridLinesListener
	GridLinesListener = createUnoListener ("SHEET_","com.sun.star.beans.XPropertyChangeListener")
	ThisComponent.CurrentController.addPropertyChangeListener("ActiveSheet",GridLinesListener)
	GetSheetsWithHideGridLines
End Sub
&apos;-----------------------------------------------------------------
Sub SHEET_propertyChange(oEvent)
	Dim ActiveSheet$
	Dim i%	
	
	ActiveSheet = ThisComponent.CurrentController.ActiveSheet.AbsoluteName
		For i = 0 To uBound(SheetsWithHideGridLines)
			If ActiveSheet = SheetsWithHideGridLines(i) Then
				ThisComponent.CurrentController.showGrid = False
				i = uBound(SheetsWithHideGridLines) + 1
			Else
				ThisComponent.CurrentController.showGrid = True
			End If
		Next
End Sub
&apos;----------------------------------------------------------------
Sub GetSheetsWithHideGridLines
	Dim ActiveSheet$
	Dim i%
	Dim u%	
	
	ActiveSheet = ThisComponent.CurrentController.ActiveSheet.AbsoluteName
	If IsEmpty(SheetsWithHideGridLines) Then
		SheetsWithHideGridLines = Array(ActiveSheet)
		ThisComponent.CurrentController.showGrid = False
	Else
	u = UBound(SheetsWithHideGridLines)
			For i = 0 to u
				If SheetsWithHideGridLines(i) = ActiveSheet Then
					SheetsWithHideGridLines(i) = ""
					ThisComponent.CurrentController.showGrid = True
					Exit Sub
				End If
			Next
			Redim Preserve SheetsWithHideGridLines (u + 1)
			SheetsWithHideGridLines(u + 1) = ActiveSheet
			ThisComponent.CurrentController.showGrid = False
	End If
End Sub

</script:module>
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
orionp3
Posts: 2
Joined: Sun Feb 16, 2020 7:27 am

Re: Adding preference shortcut to toolbar

Post by orionp3 »

Hello again, and many thanks for your guidance. Unfortunately, I should have made clear at the time that I'm not particularly computer literate at least not to the extent of writing code and integrating that code with an application. So, my apologies by omitting that info. For what it's worth I am happy to copy and past to the Mac terminal.
Thanks again and any further guidance from this point on would of course be most appreciated.
open office 73 on mac macOS 10.14.6 (Mojave)
Post Reply