You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openoffice.apache.org by bu...@apache.org on 2014/09/28 12:04:38 UTC
[Issue 125691] New: [netbeans-integration] add-on constructor is
called as many times as there are menu items
https://issues.apache.org/ooo/show_bug.cgi?id=125691
Issue ID: 125691
Issue Type: DEFECT
Summary: [netbeans-integration] add-on constructor is called as
many times as there are menu items
Product: App Dev
Version: 4.1.1
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: sdk
Assignee: issues@openoffice.apache.org
Reporter: john.dorazio@cappellaniauniroma3.org
If I make a sample add-on project in Netbeans using the OpenOffice plugin, and
I make two menu items, and I put a 'System.out.println("Hello World!");' in the
constructor, then compile and "Install and run in OpenOffice", I see "Hello
World!" printed twice to the console.
If I make a project with three menu items, I see "Hello World!" printed three
times to the console. And then as soon as I click on the menu to open it, I see
"Hello World!" printed three more times to the console.
It seems that the dispatch provider is calling the constructor for each menu
item / toolbar item?
See the code below generated by the add-on wizard, the only line I have added
is in the constructor 'System.out.println("Hello World!");'.
package com.example;
import com.sun.star.lang.XSingleComponentFactory;
import com.sun.star.lib.uno.helper.Factory;
import com.sun.star.lib.uno.helper.WeakBase;
import com.sun.star.registry.XRegistryKey;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
public final class AddOnTest2 extends WeakBase
implements com.sun.star.frame.XDispatchProvider,
com.sun.star.frame.XDispatch,
com.sun.star.lang.XServiceInfo,
com.sun.star.lang.XInitialization
{
private final XComponentContext m_xContext;
private com.sun.star.frame.XFrame m_xFrame;
private static final String m_implementationName =
AddOnTest2.class.getName();
private static final String[] m_serviceNames = {
"com.sun.star.frame.ProtocolHandler" };
public AddOnTest2( XComponentContext context )
{
m_xContext = context;
System.out.println("Hello World!");
};
public static XSingleComponentFactory __getComponentFactory( String
sImplementationName ) {
XSingleComponentFactory xFactory = null;
if ( sImplementationName.equals( m_implementationName ) )
xFactory = Factory.createComponentFactory(AddOnTest2.class,
m_serviceNames);
return xFactory;
}
public static boolean __writeRegistryServiceInfo( XRegistryKey xRegistryKey
) {
return Factory.writeRegistryServiceInfo(m_implementationName,
m_serviceNames,
xRegistryKey);
}
// com.sun.star.frame.XDispatchProvider:
public com.sun.star.frame.XDispatch queryDispatch( com.sun.star.util.URL
aURL,
String sTargetFrameName,
int iSearchFlags )
{
if ( aURL.Protocol.compareTo("com.example.addontest2:") == 0 )
{
if ( aURL.Path.compareTo("Command0") == 0 )
return this;
if ( aURL.Path.compareTo("Command1") == 0 )
return this;
}
return null;
}
// com.sun.star.frame.XDispatchProvider:
public com.sun.star.frame.XDispatch[] queryDispatches(
com.sun.star.frame.DispatchDescriptor[] seqDescriptors )
{
int nCount = seqDescriptors.length;
com.sun.star.frame.XDispatch[] seqDispatcher =
new com.sun.star.frame.XDispatch[seqDescriptors.length];
for( int i=0; i < nCount; ++i )
{
seqDispatcher[i] = queryDispatch(seqDescriptors[i].FeatureURL,
seqDescriptors[i].FrameName,
seqDescriptors[i].SearchFlags );
}
return seqDispatcher;
}
// com.sun.star.frame.XDispatch:
public void dispatch( com.sun.star.util.URL aURL,
com.sun.star.beans.PropertyValue[] aArguments )
{
if ( aURL.Protocol.compareTo("com.example.addontest2:") == 0 )
{
if ( aURL.Path.compareTo("Command0") == 0 )
{
// add your own code here
return;
}
if ( aURL.Path.compareTo("Command1") == 0 )
{
// add your own code here
return;
}
}
}
public void addStatusListener( com.sun.star.frame.XStatusListener xControl,
com.sun.star.util.URL aURL )
{
// add your own code here
}
public void removeStatusListener( com.sun.star.frame.XStatusListener
xControl,
com.sun.star.util.URL aURL )
{
// add your own code here
}
// com.sun.star.lang.XServiceInfo:
public String getImplementationName() {
return m_implementationName;
}
public boolean supportsService( String sService ) {
int len = m_serviceNames.length;
for( int i=0; i < len; i++) {
if (sService.equals(m_serviceNames[i]))
return true;
}
return false;
}
public String[] getSupportedServiceNames() {
return m_serviceNames;
}
// com.sun.star.lang.XInitialization:
public void initialize( Object[] object )
throws com.sun.star.uno.Exception
{
if ( object.length > 0 )
{
m_xFrame = (com.sun.star.frame.XFrame)UnoRuntime.queryInterface(
com.sun.star.frame.XFrame.class, object[0]);
}
}
}
--
You are receiving this mail because:
You are the assignee for the issue.
You are watching all issue changes.
[Issue 125691] [netbeans-integration] add-on constructor is called
as many times as there are menu items
Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=125691
Carl Marcum <cm...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |CONFIRMED
CC| |cmarcum@apache.org
Ever confirmed|0 |1
--- Comment #1 from Carl Marcum <cm...@apache.org> ---
I can confirm the described behavior.
I started a new AddOn project AddOnTest2 and created menu items Command0, 1,
and 2
I assigned:
0 to writer and spreadsheet context
1 to writer
2 to spreadsheet
I added this to the AddOnTest2 constructor:
System.out.println("Contructor Context " + context.toString());
and this to each of the commands in the dispatch method
System.out.println("CommandX");
I deployed to AOO and opened a new writer there was no output yet.
When I clicked the the Menu I received:
Contructor Context com.sun.star.bridges.jni_uno.JNI_proxy@5b74bd37
[oid=7f2bf924e6d0;gcc3[0];f644c4deeb694c8d96e296f02b7a8e88,
type=com.sun.star.uno.XComponentContext]
Contructor Context com.sun.star.bridges.jni_uno.JNI_proxy@5b74bd37
[oid=7f2bf924e6d0;gcc3[0];f644c4deeb694c8d96e296f02b7a8e88,
type=com.sun.star.uno.XComponentContext]
then when selecting the commands 0 and 1 I received the expected:
Command0
Command1
I closed Writer and opened Calc and received no further output.
When I clicked the the Menu I received:
Contructor Context com.sun.star.bridges.jni_uno.JNI_proxy@5b74bd37
[oid=7f2bf924e6d0;gcc3[0];f644c4deeb694c8d96e296f02b7a8e88,
type=com.sun.star.uno.XComponentContext]
Contructor Context com.sun.star.bridges.jni_uno.JNI_proxy@5b74bd37
[oid=7f2bf924e6d0;gcc3[0];f644c4deeb694c8d96e296f02b7a8e88,
type=com.sun.star.uno.XComponentContext]
then when selecting the commands 0 and 2 I received the expected:
Command0
Command2
I'm not sure Netbeans is causing this issue. I will ask on the dev mailing list
on how the extension constructor is called by AOO and if this is expected
behavior.
Carl
--
You are receiving this mail because:
You are the assignee for the issue.
You are watching all issue changes.
[Issue 125691] [netbeans-integration] add-on constructor is called
as many times as there are menu items
Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=125691
John R. D'Orazio <jo...@cappellaniauniroma3.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |john.dorazio@cappellaniauni
| |roma3.org
Latest|--- |4.1.1
Confirmation on| |
--
You are receiving this mail because:
You are the assignee for the issue.
You are watching all issue changes.