How do I ensure that the LO GUI is minimised on startup

Using LO v4.4.4.3 with OSX 10.10.4 & Windows 7 & Ubuntu 15.04

I’m developing a LO database application and want to keep LO in the background well away from my users.
who will be **poets and writers ** - who will be not especially IT/database literate.

My aim is that when a user clicks on the application’s .obd file (s)he will will see the start up LO screen
and then the next thing they will see is my announcing application’s splash screen shortly followed by the controlling
switchboard. I.E. they will NOT see the LO GUI which would expose the application’s tables, queries, forms & reports and simply confuse and distract them.

I’m guessing that I can’t bypass the GUI completely (am I correct?) so I’d like my startup macro - which already established the database connection and fires the application - to minimise the GUI and banish it to the task bar.

The application is self contained; it has it’s own exit which automatically shuts down the db connection and terminates LO and it has it’s own error report log which the user will be able email back to me.

So, my question is:

“What lines of Basic code to I need to
have the GUI automatically minimised on startup?”

Examine the soffice startup options. I show the headline ones below on my system ("–invisible" + “–minimized” are two obvious ones) but there are a lot more:

:~$ /opt/libreoffice4.4/program/soffice.bin --help
LibreOffice 4.4.4.3 2c39ebcf046445232b798108aa8a7e7d89552ea8

Usage: soffice [options] [documents...]

Options:
--minimized    keep startup bitmap minimized.
--invisible    no startup screen, no default document and no UI.
--norestore    suppress restart/restore after fatal errors.
--quickstart   starts the quickstart service
--nologo       don't show startup screen.
--nolockcheck  don't check for remote instances using the installation
--nodefault    don't start with an empty document
--headless     like invisible but no userinteraction at all.
--help/-h/-?   show this message and exit.
--version      display the version information.
--writer       create new text document.
--calc         create new spreadsheet document.
--draw         create new drawing.
--impress      create new presentation.
--base         create new database.
--math         create new formula.
--global       create new global document.
--web          create new HTML document.
-o             open documents regardless whether they are templates or not.
-n             always open documents as new files (use as template).

If this helps then please tick the answer (:heavy_check_mark:).

Thanks for this very prompt help.

that’s a nice option. I have been using the method .SetVisible(False) on startup on the .CurrentController.Frame.ContainerWindow but there still is a second on startup where the gui appears. I’ll try --invisible out.

Alex, unfortunately the startup option:

–invisible

does NOT turn off the UI on the MAC.

I\ve also tried other combinations of --minimized & --nologo none of which affect the UI.

Doug could you please explain in a bit more detail how and where to put your solution - thanks

An alternate way to make the main database window go away on startup is to create a macro that activates on the Open Document event. The result will that the database window is open for less than a second at startup and then disappears in favor of your switchboard. The principle behind this is easy to implement, but there is bulk added to the solution to avoid some common problems and make it work automatically at startup.

First, you will need to create a new Library in My Macros. Go to ToolsMacrosOrganize MacrosMy Macros and click the button Organizer and then in the new dialog, click the tab Libraries. Click New and choose a name. Then in the Macro window click New to add a Module to the library. This must be the module you use. This is necessary to allow the macro to be invoked from a document-level macro.

Second, create a subroutine in the module. Here is the annotated subroutine. The key part is the SetVisible(False):

REM  '*****  BASIC  *****'

Sub HideDBWinOpenSwitchboard

  REM 'catch any error to give alternate instructions to user'

  On Local Error Goto ErrHandOpenDB
  
  REM 'if applied to the `Open Document` event `ThisComponent` is equivalent to `ThisDatabaseDocument`'
  REM 'the difference being `ThisComponent` works'

  tc = ThisComponent

  REM 'this loop is to work around a delay in defining `ThisComponent` by LO'

  i = 1
  Do Until InStr(tc.dbg_properties, "CurrentController" ) > 0 Or i  >= 70
    Wait 5
    tc = ThisComponent
    i = i + 1
  Loop

  REM 'work around more LO limitations when atteming to run on `Open Document` event'

  tc.connectController(tc.CurrentController)

  tc.Title = "Title that is displayed at the top of the window and can be used in form titles"

  REM 'here is the object hierarchy to get to the database window'

  cntrllr = tc.CurrentController

  REM 'belt and suspenders, this might not be necessary'

  If cntrllr.isConnected = False Then 
    cntrllr.Connect
  End If
  
  REM 'more of the object hierarchy'

  frm = cntrllr.Frame
  appWindow = frm.ContainerWindow
  
  REM 'make main application window disappear'

  appWindow.setVisible(False)
  appWindow.IsMaximized = False

  REM 'FYI this is the window inside the application window, if can be resized independently'
  REM 'but have not seen any use for this yet'

  REM comWin = frm.ComponentWindow
  
  REM 'open switchboard form'

  FrmContainer = tc.FormDocuments.getByName("switchboard")
  FrmContainer.open

  rootFrm = FrmContainer.Component.getDrawPage.getForms
  rootDoc = rootFrm.parent
  ctrllr = rootDoc.CurrentController
  frm = ctrllr.Frame

  REM 'apply title of database set forth above plus title of form'

  frm.Title = tc.Title & ": switchboard"
  
  REM 'maximize the switchboard window'

  frmWindow = frm.ContainerWindow
  frmWindow.IsMaximized = True

  REM 'FYI again here is the window inside the form window'
  REM frmComp = frm.ComponentWindow

  REM 'adjust zoom of switchboard'

  ctrllr.ViewSettings.ZoomValue = 90
  
  Exit Sub
  ErrHandOpenDB:
  
  MsgBox "The intro did not go as planned.  Browse to `Forms` and open the `Switchboard`."

End Sub

Third, Assign the macro to the Open Document event in your document. My Macros. Go to ToolsMacrosOrganize Macros: navigate to your macro and then Assign button. Assign the Macro to the Open Document event in your odb document (be aware of the list option at the bottom).

Fourth, if you have other users, you will need to distribute this Macro library to them. It is easy to do this by going to the My Macros view in the Macros window and then clicking the button Organizer..., go to the Libraries tab and click Export preferentially as a Extension.

Fifth, for any other computer using this document, install the Extension.

As you can see, this is a little more involved than many other macro operations. Also note a significant bug when working with Reports.

(if this answers your question, please accept the answer by clicking the check (image description) to the left)

Doug
thanks for this which has the virtue of

a) working (not that I expected it wouldn’t)

and vices of b) clobbering my call DBopen - no matter where I put it with inside the macro at the beginning, as the very last statement, outside called before or after - it just wouldn’t work!? and c) the very last point you make that there’s a significant bug when working with report all of which mean that, unfortunately I can’t use it. I’ve reinstalled LO v4.4.4 to re-experiment with the options

If you look at the bug report, you’ll see there is a sort-of-clumsy workaround for the Reports bug. Provide some more detail on DBopen problem. I would guess the problem is here : tc.connectController(tc.CurrentController). You could try deleting it, although odds are you will run into other problems …

Also, it is assuming ThisComponent is the same as ThisDatabaseDocument based on the event that is called. The latter does not work for me on the Open Document event. However, if calling on a different event, you might use the latter as a troubleshooting step.

Try this method, make a dukoment into sets a button and give the name of the form you want to open.

The button execute events to this macro inserted.

    Sub kaldformkanp(oEvent AS OBJECT)
DIM kanp AS Object

kanp = oEvent.source.model
navnpaaknap=kanp.Name
openForm(navnpaaknap)
END Sub

Function openForm(FormName as String) 
   oContext = CreateUnoService("com.sun.star.sdb.DatabaseContext") 
   oFont = oContext.getRegisteredObject("You database") ´remember to register database
   dbForms = oFont.DatabaseDocument.FormDocuments 
   oAConnection = oFont.getConnection("","") 

   Dim pProp(1) As New com.sun.star.beans.PropertyValue 
   pProp(0).Name = "ActiveConnection" 
   pProp(0).Value = oAConnection 
   pProp(1).Name = "OpenMode" 
   pProp(1).Value = "open" 

   oForm = dbForms.loadComponentFromURL(FormName, "_blank", 0, pProp()) 
End Function`