Copy link to clipboard
Copied
I'm looking to convert libreoffice java example to cfm but j don't undestand how reference to "XComponentLoader.class" before create it
this row are ok
<cfset OOB = createObject("java","com.sun.star.comp.helper.Bootstrap")/>
<cfset xContext = OOB.bootstrap()>
<cfset xMCF = xContext.getServiceManager()>
<cfset desktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext)>
<cfset UnoRuntime = createObject("java","com.sun.star.uno.UnoRuntime")/>
this is then row to convert
XComponentLoader xCompLoader = UnoRuntime.queryInterface(XComponentLoader.class, xDesktop);
I try:
1)
<cfset xComponentLoader = UnoRuntime.queryInterface(XComponentLoader.class, desktop)>
2)
<cfset myloader = createObject("java","com.sun.star.frame.XComponentLoader")/>
<cfset xComponentLoader = UnoRuntime.queryInterface(myloader.class, desktop)>
3)
<cfobject type="Java" class="com.sun.star.frame.XComponentLoader.class" name="myloader" action="create">
<cfset xComponentLoader = UnoRuntime.queryInterface(myloader, desktop)>
but no one work
any ideas or j've to pass to cfx ?
1 Correct answer
possibly
<cfset cls = CreateObject("java", "java.lang.Class")>
<cfset xCompLoaderClass = cls.forName("com.sun.star.frame.XComponentLoader")>
or
<cfset XCompLoader = CreateObject("java", "com.sun.star.frame.XComponentLoader")>
<cfset xCompLoaderClass = XCompLoader.getClass()>
then
<cfset xCompLoader = UnoRuntime.queryInterface(xCompLoaderClass, desktop)>
Copy link to clipboard
Copied
This is just a shot in the dark, I'm not testing this code sample. It looks like your variable names in your code examples don't match up with the ones in the Java code, though.
Java code:
XComponentLoader xCompLoader = UnoRuntime.queryInterface(XComponentLoader.class, xDesktop);
CFML code:
<cfset xCompLoader = createObject("java","com.sun.star.frame.XComponentLoader")>
<cfset xCompLoader = UnoRuntime.queryInterface(XComponentLoader.class, desktop)>
You might be able to string these together using method chaining:
<cfset xCompLoader = createObject("java","com.sun.star.frame.XComponentLoader").UnoRuntime.queryInterface(XComponentLoader.class, desktop)>
Dave Watts, Eidolon LLC
Copy link to clipboard
Copied
it still don't work, with
<cfset xCompLoader = createObject("java","com.sun.star.frame.XComponentLoader")>
<cfset xCompLoader = UnoRuntime.queryInterface(XComponentLoader.class, desktop)>
return the error
Element CLASS is undefined in XCOMPONENTLOADER.
and with
<cfset xCompLoader = createObject("java","com.sun.star.frame.XComponentLoader").UnoRuntime.queryInterface(XComponentLoader.class, desktop)>
return the error
Element UNORUNTIME is undefined in a Java object of type class coldfusion.runtime.StructBean.
Copy link to clipboard
Copied
possibly
<cfset cls = CreateObject("java", "java.lang.Class")>
<cfset xCompLoaderClass = cls.forName("com.sun.star.frame.XComponentLoader")>
or
<cfset XCompLoader = CreateObject("java", "com.sun.star.frame.XComponentLoader")>
<cfset xCompLoaderClass = XCompLoader.getClass()>
then
<cfset xCompLoader = UnoRuntime.queryInterface(xCompLoaderClass, desktop)>

