[dev] Toolbar button added using Addon not enabled

2006-07-10 Thread bharathy b
Hi i tried to add a Addon to Writer using ProtocolHandlerAddon.java given in 
the SDK . 
ProtocolHandleraddon.java found in 
OpenOffice.org2.0_SDK\examples\DevelopersGuide\Components\Addons\ProtocolHandlerAddon_java
 
The addon creates toolbar button in openoffice writer and should display a 
message box when it is clicked. I used UNOPKG to do it instead of pkgchk. The 
toolbar buttons appear. but they are not activated.  here are the steps i have 
followed ...please tell me if i have missed out anything or gone wrong 
anywhere. 

1) compile the ProtocolHandlerAddon.java and get the 
ProtocolHandlerAddon.class and 
ProtocolHandlerAddon$ProtocolHandlerAddonImpl.class 
2) write the ProtocolHandlerAddon.uno.manifest file which Contains 
Code: 
RegistrationClassName:ProtocolHandlerAddon \n 

3) Using this command i get ProtocolHandlerAddon.uno.jar file 
Code: 
jar cvf ProtocolHandlerAddon.uno.jar ProtocolHandlerAddon. class 
ProtocolHandlerAddon$ProtocolHandlerAddonImpl.class ProtocolHandlerAddon.m 
anifest 

4) put the manifest.xml in a folder called META-INF. the manifest.xml is as 
follows 
Code: 
  http://openoffice.org/2001/manifest";> 

5) now zip the following files into ProtocolHandlerAddon.uno.zip 
i) ProtocolHandlerAddon.uno.jar 
which inturn contains 
META-INF/MANIFEST.MF 
ProtocolHandlerAddon.class 
ProtocolHandlerAddon$ProtocolHandlerAddonImpl.class 
ProtocolHandlerAddon.uno.manifest 
ii)Addons.xcu 
iii) ProtocolHandler.xcu 
iv) META-INF/manifest.xml 
6) exit OpenOffice(including Quickstart) and add the package using 
unopkg add ProtocolHandlerAddon.uno.zip 

Here is the ProtocolHandleraddon.java I hav used 
import com.sun.star.uno.XComponentContext; 
import com.sun.star.lib.uno.helper.Factory; 
import com.sun.star.lang.XSingleComponentFactory; 
import com.sun.star.lib.uno.helper.WeakBase; 
import com.sun.star.uno.UnoRuntime; 
import com.sun.star.registry.XRegistryKey; 
import com.sun.star.lang.XInitialization; 
import com.sun.star.lang.XTypeProvider; 
import com.sun.star.lang.XServiceInfo; 
import com.sun.star.uno.Type; 
import com.sun.star.frame.XStatusListener; 
import com.sun.star.frame.XDispatchProvider; 
import com.sun.star.frame.XDispatch; 
import com.sun.star.frame.XModel; 
import com.sun.star.frame.XFrame; 
import com.sun.star.frame.DispatchDescriptor; 
import com.sun.star.awt.XToolkit; 
import com.sun.star.awt.XWindowPeer; 
import com.sun.star.awt.XMessageBox; 
import com.sun.star.awt.WindowAttribute; 
import com.sun.star.awt.WindowClass; 
import com.sun.star.awt.WindowDescriptor; 
import com.sun.star.awt.Rectangle; 

public class ProtocolHandlerAddon { 
public static class ProtocolHandlerAddonImpl extends WeakBase implements 
XDispatchProvider, 
XDispatch, 
XInitialization, 
XServiceInfo { 
static private final String[] m_serviceNames = { 
"com.sun.star.frame.ProtocolHandler" }; 
private XComponentContext m_xCmpCtx; 
private XToolkit m_xToolkit; 
private XFrame m_xFrame; 
private XStatusListener m_xStatusListener; 
public ProtocolHandlerAddonImpl( XComponentContext xComponentContext ) { 
m_xCmpCtx = xComponentContext; 
} 
public void initialize( Object[] object ) 
throws com.sun.star.uno.Exception { 

if ( object.length > 0 ) 
{ 
m_xFrame = ( XFrame ) UnoRuntime.queryInterface( 
XFrame.class, object[ 0 ] ); 
} 

m_xToolkit = (XToolkit) UnoRuntime.queryInterface( 
XToolkit.class, 
m_xCmpCtx.getServiceManager().createInstanceWithContext("com.sun.star.awt.Toolkit",
 m_xCmpCtx)); 
} 
public String[] getSupportedServiceNames() { 
return getServiceNames(); } 
public static String[] getServiceNames() { 
return m_serviceNames;} 
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 getImplementationName() { 
return ProtocolHandlerAddonImpl.class.getName(); 
} 
// XDispatchProvider 
public XDispatch queryDispatch( /*IN*/com.sun.star.util.URL aURL, 
/*IN*/String sTargetFrameName, 
/*IN*/int iSearchFlags ) { 
XDispatch xRet = null; 
if ( aURL.Protocol.compareTo("org.openoffice.Office.addon.example:") == 0 ) { 
if ( aURL.Path.compareTo( "Function1" ) == 0 ) 
xRet = this; 
if ( aURL.Path.compareTo( "Function2" ) == 0 ) 
xRet = this; 

} 
return xRet; 
} 
public XDispatch[] queryDispatches( /*IN*/DispatchDescriptor[] seqDescripts ) { 
int nCount = seqDescripts.length; 
XDispatch[] lDispatcher = new XDispatch[nCount]; 

for( int i=0; i 
http://openoffice.org/2001/registry"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";> 
 
 
 
org.openoffice.Office.addon.example:* 
 
 
 
 

Here is the Addon.xcu that adds a toolbar buttons 
 
http://openoffice.org/2001/registry"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema"; oor:name="Addons" 
oor:package="org.openoffice.Office"> 
 
 
 
 
 
org.openoffice.Office.addon.example:Function1 
  
 
 
 
 
Function 1 
 
 
_self 
 
 
com.sun.star.text.TextDocument

[dev] Toolbar button added using Addon not enabled

2006-07-11 Thread bharathy b

Hi i tried to add a Addon to Writer using ProtocolHandlerAddon.java given in
the SDK .
ProtocolHandleraddon.java found in
OpenOffice.org2.0_SDK\examples\DevelopersGuide\Components\Addons\ProtocolHandlerAddon_java
The addon creates toolbar button in openoffice writer and should display a
message box when it is clicked. I used UNOPKG to do it instead of pkgchk. The
toolbar buttons appear. but they are not activated. [image: Sad] here are
the steps i have followed ...please tell me if i have missed out anything or
gone wrong anywhere.

1) compile the ProtocolHandlerAddon.java and get the
ProtocolHandlerAddon.class and
ProtocolHandlerAddon$ProtocolHandlerAddonImpl.class
2) write the ProtocolHandlerAddon.uno.manifest file which Contains
Code:
RegistrationClassName:ProtocolHandlerAddon \n

3) Using this command i get ProtocolHandlerAddon.uno.jar file
Code:
jar cvf ProtocolHandlerAddon.uno.jar ProtocolHandlerAddon. class
ProtocolHandlerAddon$ProtocolHandlerAddonImpl.class
ProtocolHandlerAddon.manifest

4) put the manifest.xml in a folder called META-INF. the manifest.xml is as
follows
Code:
  http://openoffice.org/2001/manifest";>

5) now zip the following files into ProtocolHandlerAddon.uno.zip
i) ProtocolHandlerAddon.uno.jar
which inturn contains
META-INF/MANIFEST.MF
ProtocolHandlerAddon.class
ProtocolHandlerAddon$ProtocolHandlerAddonImpl.class
ProtocolHandlerAddon.uno.manifest
ii)Addons.xcu
iii) ProtocolHandler.xcu
iv) META-INF/manifest.xml
6) exit OpenOffice(including Quickstart) and add the package using
unopkg add ProtocolHandlerAddon.uno.zip

Here is the ProtocolHandlerAddon.java I hav used
import com.sun.star.uno.XComponentContext;
import com.sun.star.lib.uno.helper.Factory;
import com.sun.star.lang.XSingleComponentFactory;
import com.sun.star.lib.uno.helper.WeakBase;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.registry.XRegistryKey;
import com.sun.star.lang.XInitialization;
import com.sun.star.lang.XTypeProvider;
import com.sun.star.lang.XServiceInfo;
import com.sun.star.uno.Type;
import com.sun.star.frame.XStatusListener;
import com.sun.star.frame.XDispatchProvider;
import com.sun.star.frame.XDispatch;
import com.sun.star.frame.XModel;
import com.sun.star.frame.XFrame;
import com.sun.star.frame.DispatchDescriptor;
import com.sun.star.awt.XToolkit;
import com.sun.star.awt.XWindowPeer;
import com.sun.star.awt.XMessageBox;
import com.sun.star.awt.WindowAttribute;
import com.sun.star.awt.WindowClass;
import com.sun.star.awt.WindowDescriptor;
import com.sun.star.awt.Rectangle;

public class ProtocolHandlerAddon {
public static class ProtocolHandlerAddonImpl extends WeakBase implements
XDispatchProvider,
XDispatch,
XInitialization,
XServiceInfo {
static private final String[] m_serviceNames = { "
com.sun.star.frame.ProtocolHandler" };
private XComponentContext m_xCmpCtx;
private XToolkit m_xToolkit;
private XFrame m_xFrame;
private XStatusListener m_xStatusListener;
public ProtocolHandlerAddonImpl( XComponentContext xComponentContext ) {
m_xCmpCtx = xComponentContext;
}
public void initialize( Object[] object )
throws com.sun.star.uno.Exception {

if ( object.length > 0 )
{
m_xFrame = ( XFrame ) UnoRuntime.queryInterface(
XFrame.class, object[ 0 ] );
}

m_xToolkit = (XToolkit) UnoRuntime.queryInterface(
XToolkit.class, m_xCmpCtx.getServiceManager().createInstanceWithContext("
com.sun.star.awt.Toolkit", m_xCmpCtx));
}
public String[] getSupportedServiceNames() {
return getServiceNames(); }
public static String[] getServiceNames() {
return m_serviceNames;}
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 getImplementationName() {
return ProtocolHandlerAddonImpl.class.getName();
}
// XDispatchProvider
public XDispatch queryDispatch( /*IN*/com.sun.star.util.URL aURL,
/*IN*/String sTargetFrameName,
/*IN*/int iSearchFlags ) {
XDispatch xRet = null;
if ( aURL.Protocol.compareTo("org.openoffice.Office.addon.example:") == 0 )
{
if ( aURL.Path.compareTo( "Function1" ) == 0 )
xRet = this;
if ( aURL.Path.compareTo( "Function2" ) == 0 )
xRet = this;

}
return xRet;
}
public XDispatch[] queryDispatches( /*IN*/DispatchDescriptor[] seqDescripts
) {
int nCount = seqDescripts.length;
XDispatch[] lDispatcher = new XDispatch[nCount];

for( int i=0; i
http://openoffice.org/2001/registry";
xmlns:xs="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance";>



org.openoffice.Office.addon.example:*





Here is the Addons.xcu that adds a toolbar buttons

http://openoffice.org/2001/registry";
xmlns:xs="http://www.w3.org/2001/XMLSchema"; oor:name="Addons" oor:package="
org.openoffice.Office">





org.openoffice.Office.addon.example:Function1
 




Function 1


_self


com.sun.star.text.TextDocument




org.openoffice.Office.addon.example:Function2
 




Function 2


_self

com.sun.star.text.TextDocument






Why are the buttons in

Re: [dev] Toolbar button added using Addon not enabled

2006-07-11 Thread Tom Schindl
This question is better answered at dev@api.openoffice.org

Tom



signature.asc
Description: OpenPGP digital signature