[Solved] Dropdown to toolbar Item
-
- Posts: 16
- Joined: Fri May 30, 2008 1:38 pm
[Solved] Dropdown to toolbar Item
Welcome beginner. Please answer all of the questions below which may provide information necessary to answer your question.
-----------------------------------------------------------------------------------------------------------
Which version of OpenOffice.org are you using? 2.3
What Operating System (version) are you using? windows XP
What is your question or comment?
I added a toolbar in my spread sheet using Add-On through NetBeans.
in my tool bar two buttons are there one is dropdown option, second one ordinary button.
i added controlType node property in Addon.xcu file then i got a dropdown arrow .
my problem is i am not getting dropdown window while i clicked dropdown option button.
how can i get it.
can any one please help me.
-----------------------------------------------------------------------------------------------------------
Which version of OpenOffice.org are you using? 2.3
What Operating System (version) are you using? windows XP
What is your question or comment?
I added a toolbar in my spread sheet using Add-On through NetBeans.
in my tool bar two buttons are there one is dropdown option, second one ordinary button.
i added controlType node property in Addon.xcu file then i got a dropdown arrow .
my problem is i am not getting dropdown window while i clicked dropdown option button.
how can i get it.
can any one please help me.
Last edited by rameshkancherla on Mon Jun 09, 2008 5:30 am, edited 1 time in total.
- DrewJensen
- Volunteer
- Posts: 1734
- Joined: Sat Oct 06, 2007 9:01 pm
- Location: Cumberland, MD - USA
Re: dropdown to toolbarItem
Hi,
Don't have a tip for you just yet, as I am just starting into looking at the netbeans plugin for this use also...I did move your topic to a better spot on the forum, hopefully someone can address the dropdown button issue.
Don't have a tip for you just yet, as I am just starting into looking at the netbeans plugin for this use also...I did move your topic to a better spot on the forum, hopefully someone can address the dropdown button issue.
Former member of The Document Foundation
Former member of Apache OpenOffice PMC
LibreOffice on Ubuntu 18.04
Former member of Apache OpenOffice PMC
LibreOffice on Ubuntu 18.04
Re: dropdown to toolbarItem
Search the "old forum". I used "drop down toolbar"(all words)
http://www.oooforum.org/forum/viewtopic.phtml?t=47503
http://www.oooforum.org/forum/viewtopic.phtml?t=47503
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
-
- Posts: 16
- Joined: Fri May 30, 2008 1:38 pm
Re: dropdown to toolbarItem
hi Villeroy
i created one java class using bellow code
(i took bellow code from this link http://www.oooforum.org/forum/viewtopic.phtml?t=47503) .
i am getting toolbar and button also but
i am not getting dropdown to that button.
can you please tell me what is the problem
i created one java class using bellow code
(i took bellow code from this link http://www.oooforum.org/forum/viewtopic.phtml?t=47503) .
i am getting toolbar and button also but
i am not getting dropdown to that button.
can you please tell me what is the problem
Code: Select all
import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.PropertyVetoException;
import com.sun.star.beans.UnknownPropertyException;
import com.sun.star.beans.XPropertySet;
import com.sun.star.lang.IllegalArgumentException;
import com.sun.star.lang.IndexOutOfBoundsException;
import com.sun.star.lang.WrappedTargetException;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XInitialization;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.lang.XSingleComponentFactory;
import com.sun.star.lang.XServiceInfo;
import com.sun.star.lib.uno.helper.Factory;
import com.sun.star.lib.uno.helper.ComponentBase;
import com.sun.star.ui.XUIElement;
import com.sun.star.ui.XUIElementSettings;
import com.sun.star.uno.XComponentContext;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.xml.sax.*;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.frame.XDesktop;
import com.sun.star.frame.XFrame;
import com.sun.star.frame.XLayoutManager;
import com.sun.star.frame.XToolbarController;
import com.sun.star.frame.XStatusListener;
import com.sun.star.frame.XUIControllerRegistration;
import com.sun.star.util.XUpdatable;
import com.sun.star.frame.FeatureStateEvent;
import com.sun.star.awt.XWindow;
import com.sun.star.awt.XWindowPeer;
import com.sun.star.awt.WindowDescriptor;
import com.sun.star.awt.WindowClass;
import com.sun.star.awt.Rectangle;
import com.sun.star.awt.WindowAttribute;
import com.sun.star.awt.VclWindowPeerAttribute;
import com.sun.star.awt.XComboBox;
import com.sun.star.awt.XTextComponent;
import com.sun.star.awt.XToolkit;
import com.sun.star.lang.EventObject;
import com.sun.star.awt.XKeyListener;
import com.sun.star.awt.KeyEvent;
import com.sun.star.comp.helper.Bootstrap;
import com.sun.star.comp.helper.BootstrapException;
import com.sun.star.container.ElementExistException;
import com.sun.star.container.XIndexAccess;
import com.sun.star.container.XIndexContainer;
import com.sun.star.container.XSet;
/**
* ToolBar controller component registration wrapper
* <p>
* This wrapper is used by the unopkg registration application, to register the
* component name with the OpenOffice component Database.
*/
public class ComboToolbar {
/**
* An com.sun.star.frame.XToolbarController implementation, for extending
* the default operation and view of a Openoffice Toolbar.
*/
public static class Toolbar_06 extends ComponentBase implements
XInitialization, XStatusListener, XUpdatable, XKeyListener,
XServiceInfo, XToolbarController {
// the supported service names, the first one being the service name of the component itself
/**
* The Services supported by this component
*/
public static final String[] msServiceNames = { "testtoolbar06" };
private XComponentContext mxContext;
private XMultiComponentFactory mxMCF;
private XMultiServiceFactory mxMSF;
private String msInternalName;
private XComponent mxDocument;
private XTextComponent fixedText;
private XComboBox cBox_xComboBox;
public Toolbar_06(XComponentContext xContext) {
System.out.println("constructor called");
try {
mxContext = xContext;
mxMCF = mxContext.getServiceManager();
mxMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(
XMultiServiceFactory.class, mxMCF);
System.out.println("constructor try o.k.");
} catch (Exception e) {
}
msInternalName = new String();
mxDocument = null;
System.out.println("constructor left");
}
/**
* Component Initialization.
*/
public void initialize(Object[] args) throws com.sun.star.uno.Exception {
System.out.println("initialize: args.len: " + args.length);
for (int k = 0; k < args.length; k++) {
PropertyValue arg = (PropertyValue) args[k];
System.out.println("initialize: arg " + k + ": " + arg.Name+ ": " + arg.Value);
}
}
/**
* Retunrns the internal name of this component
*
* @return String Name
*/
public String getName() {
synchronized (this) {
return msInternalName;
}
}
/**
* Sets the internal name of this component
*
* @param sName The name to be set.
*/
public void setName(String sName) {
}
public void execute(short nKeyModifier) {
System.out.println("execute: ");
}
/**
* Single Click Mouse event handler
*
*/
public void click() {
}
/**
* Double Click Mouse event handler
*
*/
public void doubleClick() {
}
/**
* Pop-up window creator. Not Implemented
*
*/
public XWindow createPopupWindow() {
return null;
}
/**
* Creates the command line combo box which will be embedded in the supplied com.sun.star.awt.XWindow.
*
* @param xWindow The XWindow instance which will contain the combo box
* @return XWindow
* @see XWindow
*/
public XWindow createItemWindow(XWindow xWindow) {
// xMSF is set by initialize(Object[])
try {
// get XWindowPeer
XWindowPeer xWinPeer = (XWindowPeer) UnoRuntime.queryInterface(
XWindowPeer.class, xWindow);
Object o = mxMSF.createInstance("com.sun.star.awt.Toolkit");
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 = "combobox";
// 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("Enter Command Here");
XWindow cBox_xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, cBox_xWinPeer);
// add some elements
cBox_xComboBox.addItems(new String[] { "test", "foo", "bar",
"test2", "foo2", "bar2" }, (short) 0);
// cBox_xComboBox.addItems(new String[] {""}, (short) 4);
cBox_xComboBox.setDropDownLineCount((short) 6);
cBox_xWindow.addKeyListener(this);
return cBox_xWindow;
} catch (com.sun.star.uno.Exception e) {
System.out.println("createItemWindow left not o.k.");
return null;
}
}
/**
* Status Changed Event Listener
* @param aState the com.sun.star.frame.FeatureStateEvent status
*/
public void statusChanged(FeatureStateEvent aState) {
System.out.println("statusChanged: ");
}
/**
* Disposing event handler
*/
public void disposing(EventObject aSource) {
}
/**
* Toolbarcontroller com.sun.star.util.XUpdatable implementation update controller.
*
*/
public void update() {
System.out.println("update: ");
}
/**
* KeyPress event handler. This method is used to intercept the
* Key press events
*
* @param event The com.sun.star.awt.KeyEvent that has occured
* @see KeyEvent
*/
public void keyPressed(KeyEvent event) {
}
/**
* @param event The com.sun.star.awt.KeyEvent that has occured
* @see KeyEvent
*/
public void keyReleased(KeyEvent event) {
}
/**
* Returns the Service names supported by this component
*
* @return String[] ServiceNames
*/
public String[] getSupportedServiceNames() {
return msServiceNames;
}
public boolean supportsService(String sService) {
return (sService.equals(msServiceNames[0]));
}
/**
* Provides the implementation name of the service implementation
*
* @return The Implementation Name
*/
public String getImplementationName() {
return this.getClass().getName();
}
}
// Retrieves the MultiServiceFactory of StarOffice
public XMultiServiceFactory getMultiServiceFactory ( XComponentContext xComponentContext )
throws java.lang.Exception {
// Retrieve its
// property DefaultContext and get the
// remote service manager
XMultiComponentFactory xRemoteServiceManager =
xComponentContext.getServiceManager();
// Instantiate the MultiServiceFactory service
Object oMSF =
xRemoteServiceManager.createInstanceWithContext(
"com.sun.star.lang.MultiServiceFactory",
xComponentContext);
return (XMultiServiceFactory) UnoRuntime.queryInterface ( XMultiServiceFactory.class, oMSF);
}
public static void main(String[] args) {
try {
// -------------------- create and register a factory for your class
XComponentContext xContext = Bootstrap.bootstrap();
XSingleComponentFactory xFactory = Factory.createComponentFactory(Toolbar_06.class,
Toolbar_06.msServiceNames);
Object xDum = xContext.getValueByName("/singletons/com.sun.star.lang.theServiceManager");
XSet _SM = (XSet) UnoRuntime.queryInterface(XSet.class, xDum);
_SM.insert(xFactory);
//-------------------- use the toolbar
final String resourceURL = "private:resource/toolbar/ms777_23";
final String sUnoUrl = ".uno:CommandLineToolbar";
final String sService = "testtoolbar06";
final String sToolbarUIName = "ms777_23";
//-------------------- create the service
//oo = createUnoService("com.sun.star.frame.ToolBarControllerFactory");
ComboToolbar tool05 = new ComboToolbar();
XMultiServiceFactory xMSF = tool05.getMultiServiceFactory ( xContext );
Object ooToolbar = xMSF.createInstance("com.sun.star.frame.ToolBarControllerFactory");
XUIControllerRegistration oo = (XUIControllerRegistration) UnoRuntime.queryInterface ( XUIControllerRegistration.class, ooToolbar);
if (oo.hasController( sUnoUrl, "")) oo.deregisterController( sUnoUrl, "");
else oo.registerController( sUnoUrl, "", sService);
//-------------------- get the layout manager
Object desktop = xContext.getServiceManager().createInstanceWithContext(
"com.sun.star.frame.Desktop", xContext);
XComponentLoader xCompLoader = (XComponentLoader) UnoRuntime.queryInterface(
XComponentLoader.class, desktop);
// Load a Writer document, which will be automaticly displayed
xCompLoader.loadComponentFromURL("private:factory/swriter",
"_blank", 0, new PropertyValue[0]);
XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktop);
XFrame xFrame = xDesktop.getCurrentFrame();
XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xFrame);
XLayoutManager oLM = (XLayoutManager) UnoRuntime.queryInterface(
XLayoutManager.class, xPropSet.getPropertyValue("LayoutManager"));
//-------------------- get my toolbar
if (oLM.getElement(resourceURL) != null) oLM.destroyElement(resourceURL);
oLM.createElement(resourceURL);
XUIElement toolbarUIElement = oLM.getElement(resourceURL);
//oUIElement has this interface too... Not really clear with the documentation...
XUIElementSettings toolbarUIElementSettings = (XUIElementSettings) UnoRuntime.queryInterface(
XUIElementSettings.class, toolbarUIElement);
XIndexAccess toolbarIndexAccess = toolbarUIElementSettings.getSettings(true);
XPropertySet toolbarUIElementSettingsPropertySet = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, toolbarIndexAccess );
toolbarUIElementSettingsPropertySet.setPropertyValue("UIName", sToolbarUIName );
PropertyValue [] aToolbarItem = new PropertyValue[2];
aToolbarItem[0] = new PropertyValue();
aToolbarItem[0].Name = "CommandURL";
aToolbarItem[0].Value = sUnoUrl;
aToolbarItem[1] = new PropertyValue();
aToolbarItem[1].Name = "Label";
aToolbarItem[1].Value = "Test";
XIndexContainer toolbarIndexContainer = (XIndexContainer)
UnoRuntime.queryInterface( XIndexContainer.class,toolbarIndexAccess );
toolbarIndexContainer.insertByIndex( 0, aToolbarItem );
toolbarUIElementSettings.setSettings(toolbarIndexAccess);
oLM.showElement(resourceURL);
} catch (BootstrapException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ElementExistException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IndexOutOfBoundsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (WrappedTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnknownPropertyException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (PropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
-
- Posts: 16
- Joined: Fri May 30, 2008 1:38 pm
Re: dropdown to toolbarItem
hi Villeroy
i got it combobox in my tool bar.
i need one more
is there any way for adding icons to dropdownbox or dropdownbutton
if do you know please give me an advice to me how to add .
Thanks
Ramesh k
i got it combobox in my tool bar.
i need one more
is there any way for adding icons to dropdownbox or dropdownbutton
if do you know please give me an advice to me how to add .
Thanks
Ramesh k
Re: Dropdown to toolbar Item
Hi,
could you please tell us if you solved your problems with the above code ? I yes, how ?
For inserting icons see e.g. http://www.oooforum.org/forum/viewtopic.phtml?t=50877 or http://www.oooforum.org/forum/viewtopic ... 911#195911
Good luck,
ms777
could you please tell us if you solved your problems with the above code ? I yes, how ?
For inserting icons see e.g. http://www.oooforum.org/forum/viewtopic.phtml?t=50877 or http://www.oooforum.org/forum/viewtopic ... 911#195911
Good luck,
ms777
-
- Posts: 16
- Joined: Fri May 30, 2008 1:38 pm
Re: Dropdown to toolbar Item
i got combobox.
problem is toolbar shows button only. i felt ,i didnt get combobox. first i taught problem is on code.
so posted query on forum.
at finally i moves toolbar to in newline i got combobox.
problem is toolbar shows button only. i felt ,i didnt get combobox. first i taught problem is on code.
so posted query on forum.
at finally i moves toolbar to in newline i got combobox.
Re: Dropdown to toolbar Item
Good. Could you please add [solved] to the title of your first post then ?
Thanks ms777
Thanks ms777
Re: [Solved] Dropdown to toolbar Item
Hi.
I'm having problems with the combobox item when the toolbar is hidden and then shown again. The problem is that when the toolbar is shown again, the combobox is not redrawn.
Has anyone had a problem like this?
Regards,
Germán
I'm having problems with the combobox item when the toolbar is hidden and then shown again. The problem is that when the toolbar is shown again, the combobox is not redrawn.
Has anyone had a problem like this?
Regards,
Germán
OpenOffice 2.4.1 Open Suse Linux