Ask Your Question
1

Clean exit macro from DB and LibO ?

asked 2017-02-18 10:07:15 +0100

kirsch gravatar image

updated 2017-02-18 10:08:05 +0100

Hello, is There a usable macro on hand, to trigger from a button in a Base Form, a clean exit from DB and LibO(V5) ? I'll take it ! Bob

edit retag flag offensive close merge delete

Comments

This button exists… its the X button in the up|right corner of the window

karolus gravatar imagekarolus ( 2017-02-18 14:02:17 +0100 )edit

2 Answers

Sort by » oldest newest most voted
2

answered 2017-02-19 02:02:49 +0100

Ratslinger gravatar image

updated 2017-02-21 21:28:22 +0100

Understand that Ctrl & Q closes ALL open instances of LO and not just your .odb - including any writer, calc, math, draw, or impress windows which are open. With that, here is the function:

sub loQuit
    document   = ThisComponent.CurrentController.Frame
    dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
    dim args1(0) as new com.sun.star.beans.PropertyValue
    dispatcher.executeDispatch(document, ".uno:Quit", "", 0, args1())
end sub

Edit: This may work to just close the .odb and related open form:

sub CloseDoc
    document = ThisComponent.getParent().getCurrentController().getFrame()
    document.close(1)
end sub

Edit 2/21/2017:

Further testing was done using the above routines. All tests were done on Linux systems.

Sub "loQuit" works without a problem in LO v5.3.0.3 but using v5.2.3.3 there is an abnormal exit when the routine is called from a push button or custom toolbar item. It does work in v5.2.3.3 when run directly from Basic IDE.

Sub "CloseDoc" executes from a push button in v5.3.0.3 and v5.2.3.3 but does not completely shut down LO. Ironically, under both versions, if the document.close(1) statement is actually executed within MRI, there is a complete shutdown without any side effects. There is no explanation for this at this point and it is not the first time I saw this type of thing happen. The other occurrence has eluded me for over a year.

edit flag offensive delete link more

Comments

The above "LoQuit code

  • gives" an UNEXPETED ERROR on activating the macro from a QUIT LIBREOFFICE button in the Form!
  • and leaves a .lck file in the DB directory.

So I deactivate the button and label it with "quit with CRTL/Q" ;-)

kirsch gravatar imagekirsch ( 2017-02-21 17:30:54 +0100 )edit

@kirsch Will edit my answer with further findings/explanation.

Ratslinger gravatar imageRatslinger ( 2017-02-21 21:10:05 +0100 )edit
0

answered 2017-02-19 00:34:25 +0100

kirsch gravatar image

updated 2017-02-19 00:37:47 +0100

Hi Karolus, about your comment

That upper right corner "X" button does not the job properly in my case:

I start the database by opening a Form from start, the usual DB development window is not on screen (hidden). When I click the X button in the Form, the form-window closes leaving a LibreOffice process running! And it gives trouble later on when I try to start a other DB. Closing that Form trough its menu File->Close does the un-clean exit and leaves a unneeded and unwanted LibreOffice running process.

The only clean Exit from that is using in the Form the menu choice File->Quit LibreOffice (Of course it needs the menu bar in the Form) or I can use CTRL/Q to quit LibO.

But in my application, I'd like to have a nice button in the form to do that CTRL/Q action.

Thanks anyway for your comment Karolus, it makes me explain my problem more pecisely. Bob.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-02-18 10:07:15 +0100

Seen: 215 times

Last updated: Feb 21 '17