Ask Your Question
0

Accessing a singleton

asked 2017-08-30 09:35:00 +0100

Zev Spitz gravatar image

updated 2017-08-30 10:06:58 +0100

The type com.sun.star.frame.Desktop is deprecated, and it is recommended to use the com.sun.star.frame.theDesktop singleton instead.

How can I acces this (and other) singletons?

In Java, this thread says the following works:

com.sun.star.frame.theDesktop.get(componentContext)

However, the com.sun.star.frame namespace isn't available under the Automation bridge; there is only the single entry point of the service manager:

var objServiceManager = new ActiveXObject('com.sun.star.ServiceManager');
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2017-08-30 17:29:47 +0100

librebel gravatar image

hello Zev Spitz,

you need to get the Default Context from the ServiceManager, then call getName() with the singleton path as argument.

i do not know enough Java, but in Basic it would look like this, so you get the idea:

theDesktop = GetDefaultContext().getByName( "/singletons/com.sun.star.frame.theDesktop" )

Hope it helps, lib

edit flag offensive delete link more

Comments

I am not asking about Java, but rather using the Automation bridge. How do I get the script context via the Automation bridge?

Zev Spitz gravatar imageZev Spitz ( 2017-09-03 14:33:56 +0100 )edit
-1

answered 2017-09-03 14:37:10 +0100

Zev Spitz gravatar image

The Automation bridge exposes the script context at the DefaultContext property on the service manager. Once we have the script context, we can use the getByName method, passing in the singleton path:

var serviceManager = new ActiveXObject('com.sun.star.ServiceManager');
var desktop = serviceManager.defaultContext.getByName('/singletons/com.sun.star.frame.theDesktop');

(I was led to the solution by this post where the author is trying to automate OpenOffice using Delphi.)

Question on StackOverflow

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

2 followers

Stats

Asked: 2017-08-30 09:35:00 +0100

Seen: 94 times

Last updated: Sep 03 '17