Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6183453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:22:05+00:00 2026-05-24T01:22:05+00:00

is there any example on the web on how to build openoffice complex toolbar

  • 0

is there any example on the web on how to build openoffice complex toolbar in Java?
I found examples in C++ but no in Java
: http://wiki.services.openoffice.org/wiki/Framework/Article/Generic_UNO_Interfaces_for_complex_toolbar_controls

i need an article or tutorial on how to build and OO addon that uses a complex tool bar in java

i found this article http://java.dzone.com/news/lets-extend-openofficeorg-java#comment-53245 which implements a java PopupMenuController. i tried to do same process but using a XToolbarController instead of PopupMenuController. however i could’nt get my controller addon to work.
below are my controller.xcu and controller class.
can you tell what i am doing wrong?
thanks.

my Controller.xcu :

<?xml version="1.0" encoding="UTF-8"?>
<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" oor:name="Controller" oor:package="org.openoffice.Office.UI">
  <node oor:name="Registered">
    <node oor:name="ToolBar">
      <node oor:name="c10" oor:op="replace">
         <prop oor:name="Command">
            <value>.uno:CommandLineToolbar</value>
      </prop>
      <prop oor:name="Module">
             <value></value>
      </prop>
      <prop oor:name="Controller">
              <value>com.example.toolbar.Toolbar</value>
      </prop>
      </node>
    </node>
  </node>
</oor:component-data>

my toolbar controller class :

public final class Toolbar extends ComponentBase
   implements com.sun.star.util.XUpdatable,
              com.sun.star.frame.XToolbarController,
              com.sun.star.frame.XStatusListener,
              com.sun.star.lang.XServiceInfo,
              com.sun.star.lang.XInitialization,
              com.sun.star.frame.XSubToolbarController
{
    private final XComponentContext m_xContext;
    private static final String m_implementationName = Toolbar.class.getName();
    private static final String[] m_serviceNames = {
        &quot;com.sun.star.frame.ToolbarController&quot; };
 private String msInternalName = &quot;i do not now&quot;;
    private XComponent mxDocument;
    private XTextComponent fixedText;
    private XComboBox cBox_xComboBox;
private XMultiComponentFactory mxMCF;
    public XMultiServiceFactory mxMSF;
    public Toolbar( XComponentContext context )
    {
        m_xContext = context;

    };

    public static XSingleComponentFactory __getComponentFactory( String sImplementationName ) {
        XSingleComponentFactory xFactory = null;

        if ( sImplementationName.equals( m_implementationName ) )
            xFactory = Factory.createComponentFactory(Toolbar.class, m_serviceNames);
        return xFactory;
    }

    public static boolean __writeRegistryServiceInfo( XRegistryKey xRegistryKey ) {
        return Factory.writeRegistryServiceInfo(m_implementationName,
                                                m_serviceNames,
                                                xRegistryKey);
    }

    // com.sun.star.util.XUpdatable:
    public void update()
    {
        // TODO: Insert your implementation for &quot;update&quot; here.
    }

    // com.sun.star.frame.XToolbarController:
    public void execute(short KeyModifier)
    {
        // TODO: Insert your implementation for &quot;execute&quot; here.
    }

    public void click()
    {
        // TODO: Insert your implementation for &quot;click&quot; here.
    }

    public void doubleClick()
    {
        // TODO: Insert your implementation for &quot;doubleClick&quot; here.
    }

    public com.sun.star.awt.XWindow createPopupWindow()
    {
        // TODO: Exchange the default return implementation for &quot;createPopupWindow&quot; !!!
        // NOTE: Default initialized polymorphic structs can cause problems
        // because of missing default initialization of primitive types of
        // some C++ compilers or different Any initialization in Java and C++
        // polymorphic structs.
        return null;
    }

    public com.sun.star.awt.XWindow createItemWindow(com.sun.star.awt.XWindow Parent)
    {
         System.out.println(&quot;ToolbarCombobox createItemWindow start&quot;);
       Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());

// xMSF is set by initialize(Object[])
      try {
// get XWindowPeer
        XWindowPeer xWinPeer = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, Parent);
        Object o = mxMSF.createInstance(&quot;com.sun.star.awt.Toolkit&quot;);
        XToolkit xToolkit = (XToolkit) UnoRuntime.queryInterface(XToolkit.class, o);
// create WindowDescriptor
        WindowDescriptor wd = new WindowDescriptor();
        wd.Type = WindowClass.SIMPLE;
        wd.Parent = xWinPeer;
        wd.Bounds = new Rectangle(0, 0, 230, 23);
        wd.ParentIndex = (short) -1;
        wd.WindowAttributes = WindowAttribute.SHOW |VclWindowPeerAttribute .DROPDOWN;
        wd.WindowServiceName = &quot;combobox&quot;;
// create ComboBox
        XWindowPeer cBox_xWinPeer = xToolkit.createWindow(wd);
        cBox_xComboBox = (XComboBox) UnoRuntime.queryInterface(XComboBox.class, cBox_xWinPeer);
// Get Interface for manipulating the text in the combobox
        fixedText = (XTextComponent)UnoRuntime.queryInterface(XTextComponent.class,cBox_xComboBox);
        fixedText.setText(&quot;Enter Command Here&quot;);
        XWindow cBox_xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, cBox_xWinPeer);
 // add some elements
        cBox_xComboBox.addItems(new String[] { &quot;test&quot;, &quot;foo&quot;, &quot;bar&quot;, &quot;test2&quot;, &quot;foo2&quot;, &quot;bar2&quot; }, (short) 0);
// cBox_xComboBox.addItems(new String[] {&quot;&quot;}, (short) 4);
        cBox_xComboBox.setDropDownLineCount((short) 6);
        //cBox_xWindow.addKeyListener(this);

        System.out.println(&quot;ToolbarCombobox createItemWindow end&quot;);

        return cBox_xWindow;

      } catch (com.sun.star.uno.Exception e) {
        System.out.println(&quot;ToolbarCombobox createItemWindow end not o.k.&quot;);
        return null; }
    }

    // com.sun.star.lang.XEventListener:
    public void disposing(com.sun.star.lang.EventObject Source)
    {
        // TODO: Insert your implementation for &quot;disposing&quot; here.
    }

    // com.sun.star.frame.XStatusListener:
    public void statusChanged(com.sun.star.frame.FeatureStateEvent State)
    {
        // TODO: Insert your implementation for &quot;statusChanged&quot; 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 &lt; 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[] aArguments) throws com.sun.star.uno.Exception
    {
        if ( aArguments.length &gt; 0 )
        {
            mxMCF = m_xContext.getServiceManager();

            mxMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, mxMCF);
        }

    }

    // com.sun.star.frame.XSubToolbarController:
    public boolean opensSubToolbar()
    {
        // TODO: Exchange the default return implementation for &quot;opensSubToolbar&quot; !!!
        // NOTE: Default initialized polymorphic structs can cause problems
        // because of missing default initialization of primitive types of
        // some C++ compilers or different Any initialization in Java and C++
        // polymorphic structs.
        return false;
    }

    public String getSubToolbarName()
    {
        // TODO: Exchange the default return implementation for &quot;getSubToolbarName&quot; !!!
        // NOTE: Default initialized polymorphic structs can cause problems
        // because of missing default initialization of primitive types of
        // some C++ compilers or different Any initialization in Java and C++
        // polymorphic structs.
        return new String();
    }

    public void functionSelected(String aCommand)
    {
        // TODO: Insert your implementation for &quot;functionSelected&quot; here.
    }

    public void updateImage()
    {
        // TODO: Insert your implementation for &quot;updateImage&quot; here.
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:22:06+00:00Added an answer on May 24, 2026 at 1:22 am

    the solution is to use an Addons.xcu file as bellow. the Addons.xcu should have a property “URL” to reference the “Command” property in Controller.xcu.

    <?xml version='1.0' encoding='UTF-8'?>
    <oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="Addons" oor:package="org.openoffice.Office">
    <node oor:name="AddonUI">
        <node oor:name="OfficeToolBar">
            <node oor:name="com.example.toolbar.ToolbarAddOn" oor:op="replace">
                <node oor:name="a1_0" oor:op="replace">
                    <prop oor:name="URL">
                        <value>.uno:CommandLineToolbar</value>
                    </prop>
                    <prop oor:name="Title">
                        <value>Text</value>
                    </prop>
                    <prop oor:name="Context" oor:type="xs:string">
                        <value></value>
                    </prop>
                </node>
            </node>
        </node>
    </node>
    </oor:component-data>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Are there any good examples out there of how the following web service would
Is there any Java library that supports hierarchical column? For example (the first three
Is there any good example to give the difference between a struct and a
Are there any tools available that will calculate code metrics (for example number of
Is there any efficiency difference in an explicit vs implicit inner join? For example:
Are there any automatic methods for trimming a path string in .NET? For example:
Are there any advantages compiling for .NET Framework 3.5 instead of 2.0? For example
Is there any way to use a constant as a hash key? For example:
Is there any way of batch renaming files in sub directories? For example: Rename
Is there any way to use Relative path when configuring subversion externals. For example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.