private bool ButtonAllreadyExists(string commandUrl) { XIndexContainer mOoToolbarSettings = Settings; if (mOoToolbarSettings == null) { return(false); } int iCount = mOoToolbarSettings.getCount(); for (int i = 0; i < iCount; i++) { Array ooToolbarButton = mOoToolbarSettings.getByIndex(i).Value as Array ?? new Array[0]; int jCount = ooToolbarButton.GetUpperBound(0); for (int j = 0; j < jCount; j++) { var pv = ((PropertyValue)ooToolbarButton.GetValue(j)); if (pv.Name.Equals("CommandURL")) { if (pv.Value.Value.Equals(commandUrl)) { return(true); } } } } return(false); }
/// <summary> /// Sets the button propery. /// </summary> /// <param name="commandUrl">The command URL.</param> /// <param name="propertyName">Name of the property.</param> /// <param name="value">The value.</param> public void SetButtonPropery(String commandUrl, string propertyName, object value) { XIndexContainer mOoToolbarSettings = Settings; if (mOoToolbarSettings == null) { return; } bool bButtonFound = false; bool save = false; int iCount = mOoToolbarSettings.getCount(); for (int i = 0; i < iCount; i++) { Array ooToolbarButton = mOoToolbarSettings.getByIndex(i).Value as Array ?? new Array[0]; int jCount = ooToolbarButton.GetUpperBound(0); for (int j = 0; j < jCount; j++) { var pv = ((PropertyValue)ooToolbarButton.GetValue(j)); if (pv.Name.Equals("CommandURL")) { if (pv.Value.Value.Equals(commandUrl)) { bButtonFound = true; } } else if (pv.Name.Equals(propertyName) && bButtonFound && (bool)pv.Value.Value) { pv.Value = Any.Get(value); bButtonFound = false; save = true; } else if (j + 1 >= jCount) { ooToolbarButton.SetValue(new PropertyValue { Name = propertyName, Value = Any.Get(value) }, jCount); bButtonFound = false; save = true; } } if (save) { mOoToolbarSettings.replaceByIndex(i, Any.GetAsOne(ooToolbarButton)); } } if (save) { Settings = mOoToolbarSettings; } }
/// <summary> /// Event Listener to get called. /// </summary> /// <param name="aEvent">A event.</param> /// <returns></returns> public ContextMenuInterceptorAction notifyContextMenuExecute(ContextMenuExecuteEvent aEvent) { XIndexContainer xContextMenu = aEvent.ActionTriggerContainer; XMultiServiceFactory xMenuElementFactory = (XMultiServiceFactory)xContextMenu; if (AddMenuEnties(aEvent, xMenuElementFactory, xContextMenu)) { return(ContextMenuInterceptorAction.CONTINUE_MODIFIED); } return(ContextMenuInterceptorAction.IGNORED); }
/// <summary> /// Creates a menue entry. /// </summary> /// <param name="xMenuElementFactory">The x menu element factory.</param> /// <param name="text">The text.</param> /// <param name="commandUrl">The command URL.</param> /// <param name="helpUrl">The help URL.</param> /// <param name="subContainer">The sub container.</param> /// <returns></returns> protected XPropertySet CreateMenueEntry(XMultiServiceFactory xMenuElementFactory, string text, string commandUrl, string helpUrl, XIndexContainer subContainer) { var entry = CreateMenueEntry(xMenuElementFactory, text, commandUrl, helpUrl); if (entry != null) { entry.setPropertyValue("SubContainer", Any.Get(subContainer)); } return(entry); }
/// <summary> /// Adds the menu enties. /// </summary> /// <param name="aEvent">A event.</param> /// <param name="xMenuElementFactory">The x menu element factory.</param> /// <param name="xContextMenu">The x context menu.</param> /// <returns></returns> protected abstract bool AddMenuEnties(ContextMenuExecuteEvent aEvent, XMultiServiceFactory xMenuElementFactory, XIndexContainer xContextMenu);
public Object addRoadmap(XItemListener _xItemListener, String sName = "") { XPropertySet xDialogModelPropertySet = null; try { // create a unique name by means of an own implementation... if (String.IsNullOrWhiteSpace(sName)) sName = createUniqueName(MXDlgModelNameContainer, "ROADMAP"); else sName = createUniqueName(MXDlgModelNameContainer, sName); xDialogModelPropertySet = (XPropertySet)MXContext; // Similar to the office assistants the roadmap is adjusted to the height of the dialog // where a certain space is left at the bottom for the buttons... int nDialogHeight = (int)(xDialogModelPropertySet.getPropertyValue("Height").Value); // instantiate the roadmapmodel... Object oRoadmapModel = MXMcf.createInstanceWithContext(OO.Services.AWT_CONTROL_ROADMAP_MODEL, MXContext); // define the properties of the roadmapmodel XMultiPropertySet xRMMPSet = (XMultiPropertySet)oRoadmapModel; xRMMPSet.setPropertyValues( new String[] { "Complete", "Height", "Name", "PositionX", "PositionY", "Text", "Width" }, Any.Get(new Object[] { false, (nDialogHeight - 26), sName, 0, 0, "Steps", 85 })); m_xRMPSet = (XPropertySet)oRoadmapModel; // add the roadmapmodel to the dialog container.. MXDlgModelNameContainer.insertByName(sName, Any.Get(oRoadmapModel)); // the roadmapmodel is a SingleServiceFactory to instantiate the roadmapitems... m_xSSFRoadmap = (XSingleServiceFactory)oRoadmapModel; m_xRMIndexCont = (XIndexContainer)oRoadmapModel; //util.Debug.GetAllProperties(oRoadmapModel); //util.Debug.GetAllServicesOfObject(oRoadmapModel); // add the itemlistener to the control... XControl xRMControl = GetControlByName(sName); XItemEventBroadcaster xRMBroadcaster = (XItemEventBroadcaster)xRMControl; xRMBroadcaster.addItemListener(_xItemListener); return oRoadmapModel; } catch (System.Exception) { //jexception.printStackTrace(System.out); } return null; }
/// <summary> /// Creates a menue entry. /// </summary> /// <param name="xMenuElementFactory">The x menu element factory.</param> /// <param name="text">The text.</param> /// <param name="commandUrl">The command URL.</param> /// <param name="helpUrl">The help URL.</param> /// <param name="subContainer">The sub container.</param> /// <returns></returns> protected XPropertySet CreateMenueEntry(XMultiServiceFactory xMenuElementFactory, string text, string commandUrl, string helpUrl, XIndexContainer subContainer) { var entry = CreateMenueEntry(xMenuElementFactory, text, commandUrl, helpUrl); if (entry != null) { entry.setPropertyValue("SubContainer", Any.Get(subContainer)); } return entry; }
protected override bool AddMenuEnties(ContextMenuExecuteEvent aEvent, XMultiServiceFactory xMenuElementFactory, XIndexContainer xContextMenu) { debugEvent(aEvent); xContextMenu.insertByIndex(0, Any.Get(CreateLineSeperator(xMenuElementFactory))); xContextMenu.insertByIndex(0, Any.Get(CreateMenueEntry(xMenuElementFactory, "testZeug", ".uno:open", ""))); return(true); }
protected override bool AddMenuEnties(ContextMenuExecuteEvent aEvent, XMultiServiceFactory xMenuElementFactory, XIndexContainer xContextMenu) { debugEvent(aEvent); xContextMenu.insertByIndex(0, Any.Get(CreateLineSeperator(xMenuElementFactory))); xContextMenu.insertByIndex(0, Any.Get(CreateMenueEntry(xMenuElementFactory, "testZeug", ".uno:open", ""))); return true; }