If you can assure that the current view of the spreadsheet document actually shows cells, the viewed range will change if the FormulaBar was visible and got hidden. This very dirty idea leads to:
Function isFormulaBarVisible() As Boolean REM Occasional false positives expected!
REM This is a VERY dirty, but not exactly quick as-if-solution.
REM It is definitely assured to be NOT reliable: If the current view doesn't
REM actually show any cells, this may not change if the FotrmulaBar gets hidden.
doc = ThisComponent
cCtrl = doc.CurrentController
before = cCtrl.ReferredCells.AbsoluteName
setVisibleFormulaBar(False)
after = cCtrl.ReferredCells.AbsoluteName
wasVisible = (after<>before)
If wasVisible Then setVisibleFormulaBar(True)
isFormulaBarVisible = wasVisible
End Function
where setVisibleFormulaBar()
is the Sub you already pointed to, just a bit adapted to the need (and to my personal naming preferences):
Sub setVisibleFormulaBar(Optional pShow As Boolean)
If IsMissing(pShow) Then pShow = True
Dim frame As Object
Dim dispatcher As Object
Dim args(0) As new com.sun.star.beans.PropertyValue
args(0).Name = "InputLineVisible"
args(0).Value = pShow
frame = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(frame, ".uno:InputLineVisible", "", 0, args())
End Sub