LibreOffice detecting opened Help window

Hi,

I’m quite new in LibreOffice basic scripting and running on redHAT Linux 9.3, have to detect&report any opened Help window (for security purposes).

There are some examples that are supposed to detect the opened Help window, but I failed to run them properly:

1. Sub CheckHelpWindow()
    Dim oDesktop As Object
    Dim oHelpWindow As Object

    ' Get the current desktop - *fails for .getScriptContext()*
    oDesktop = ThisComponent.getScriptProvider().getScriptContext().getDesktop()
   
    ' Check if the help window is active
    oHelpWindow = oDesktop.getCurrentFrame().getContainerWindow()
    
    If oHelpWindow.isVisible() Then
        MsgBox "Help window is active."
    Else
        MsgBox "Help window is not active."
    End If
End Sub

2. Sub CheckHelpActive()
	dim oActiveHelp as object

        ' Fails to getActiveSheet() - not found.
	oActiveHelp = ThisComponent.getCurrentController().getActiveSheet()

	rem msgBox(oActiveHelp)
 	If Application.IsHelpActive Then
		MsgBox "Help is active."
	Else
		MsgBox "Help is not active."
	End If
End Sub

Where am I wrong, and is there a proper way to perform the requested operation ?

Thanks
Zeev

Welcome!
Sorry if I didn’t understand the problem correctly.

Are you really asking about the Help window? The window that should be opened by pressing the F1 key or by clicking the Help button from any dialog windows? In other words, are you talking about the browser tab that displays Office Help?

Hi JohnSUN,

Thanks for so prompt response.

The main task is preventing from an end-user to open any Help window - actually detect&close.
Because using the Help window, it’s possible to access local files.
Due to the project implemented security protocols, any user’s access to files is forbidden.`Preformatted text.

Accessing local files using a browser is not an easy task… Can you please remind me which is the default browser in redHAT Linux 9.3? FireFox? How about removing it from the system? And all other browsers too.

Isn’t it possible to access the same local files using the Calс, Writer or Impress window?

We are using only the LibreOffice->Calc and its all other possibilities I’ve already disabled via Tools->Customize.
Just LibreOffice->Help->Print->Save to PDF->Save as …
You have an access …
That’s the reason for the necessity to detect&close the Help window.

@Zeev What version of LibreOffice do you use? 6.x or older? Because the Help from version 7.x is opened in web browser like Firefox, Opera etc.

@ KamilLanda
On redHAT7.8 -LibreOffice 5.3.6.1
On redHAT9.3 - LibreOffice 7.1.8.1 - definitely isn’t opened in a browser

The opened Help windows look just the same

I doubt that. It’s possible through spreadsheet formula expressions to read values from files (at least from those of a type that can be imported to Calc as cell values) by using external references or the DDE() function, or create hyperlinks that open files in the browser. Which is the reason why when opening a spreadsheet containing such you get an InfoBar to confirm access of external resources, unless the spreadsheet resides in a trusted location.

1 Like

@ erAck
I’ve added the basic macro to the LibreOffice itself (not to a document).
The macro is activated because I’ve added the action to Tools->Customize->Events (Document Open …)
The problem is that in the 1st routine - ThisComponent.getScriptProvider().getScriptContext() isn’t found, and in the 2nd - ThisComponent.getCurrentController().getActiveSheet() isn’t found as well.

And what to upgrade to 24.2? I don’t remember exactly in what version was Help made to html for web browsers, but maybe in 7.2?
But 24.2 is really better and faster version than 7.1.
ThisComponent.getCurrentController().getActiveSheet() is functional for ODS files, ThisComponent.getScriptProvider().getScriptContext() isn’t functional, but I tested on Win10.

@ KamilLanda
Thanks a lot.
I’ll try.

It was 6.0. But the old help viewer may still be enabled at compile time, and I know that some distros opted to that. Indeed, it is not tested that much since then, and regressions may go unnoticed…

And you don’t trust the access-rights in the file-system of linux?
.
If you really wish to isolate a program consider to look at QubesOS.

Hi Wanderer,

It’s a dedicated system running RHEL9.3 which runs UI in the kiosk-mode and an end-user is limited to the UI provided operations only.
LibreOffice is used to view the UI created Excel spreadsheets.
The open/save files option is disabled and the Help window is the only way to get to the filesystem, which I’m trying to disable as well…

If you rely on only disabled UI and filepicker dialogs you might get surprised by the inventive ways users may come up with to circumvent your measures if they really want to. Anyway, good luck.

1 Like

There is just the UI - no filepickers / terminals /…

Let’s imagine someone is (not so) randomly pressing keys and the combination Ctrl+Alt+Backspace is pressed…

Doubtless there are a lot of other nasty tricks.

I’ve disabled the Ctrl+Alt+Backspace sequence in the KDE configuration :slight_smile:

@Zeev Please write here some report about functionality of your restrictions after few months :-). I’m curious if it will be functional, or if your users will discover some hacks, or maybe they will be more good-hearted than it seems now :-). Or maybe other interestingnesses will occur?

You still seem to not understand. Create a new Calc spreadsheet document and in a cell enter

='/etc/passwd'#sheet1.a1

or

=HYPERLINK("file:///etc/passwd";"Ctrl+Click me")