public ResizingContainer(int width, int height, string sName) { #region inner Container // create a control model at the multi service factory of the dialog model... innerScrlContrModel = OO.GetMultiServiceFactory(MXContext).createInstance(AWT_UNO_CONTROL_CONTAINER_Model) as XControlModel; innerScrlContr = OO.GetMultiServiceFactory(MXContext).createInstance(AWT_UNO_CONTROL_CONTAINER) as XControl; if (innerScrlContr != null && innerScrlContrModel != null) { innerScrlContr.setModel(innerScrlContrModel); } XMultiPropertySet xinnerScrlContMPSet = innerScrlContrModel as XMultiPropertySet; if (xinnerScrlContMPSet != null) { xinnerScrlContMPSet.setPropertyValues( new String[] { "Name", "State" }, Any.Get(new Object[] { sName, ((short)0) })); } innerWidth = width; innerHeight = height; // Set the size of the surrounding container if (innerScrlContr is XWindow) { ((XWindow)innerScrlContr).setPosSize(0, 0, innerWidth, innerHeight, PosSize.POSSIZE); } #endregion }
/// <summary> /// Executes a dispatch. /// The dispatch call is executed in a time limited way <see cref="TimeLimitExecutor"/> (200 ms). /// </summary> /// <param name="commandUrl">The command URL to dispatch. Describes the /// feature which should be supported by internally used dispatch object. /// <see cref="https://wiki.openoffice.org/wiki/Framework/Article/OpenOffice.org_2.x_Commands#Draw.2FImpress_commands"/></param> /// <param name="docViewContrl">The document view controller. Points to /// the provider, which should be asked for valid dispatch objects.</param> /// <param name="_frame">Specifies the frame which should be the target /// for this request.</param> /// <param name="_sFlag">Optional search parameter for finding the frame /// if no special TargetFrameName was used.</param> /// <param name="args">Optional arguments for this request They depend on /// the real implementation of the dispatch object.</param> /// <remarks>This function is time limited to 200 ms.</remarks> internal static bool CallDispatch(string commandUrl, XDispatchProvider docViewContrl, String _frame = "", int _sFlag = 0, PropertyValue[] args = null) { bool successs = false; if (!String.IsNullOrWhiteSpace(commandUrl)) { bool abort = TimeLimitExecutor.WaitForExecuteWithTimeLimit( 200, new Action(() => { var disp = GetDispatcher(OO.GetMultiServiceFactory()); if (disp != null) { // A possible result of the executed internal dispatch. // The information behind this any depends on the dispatch! var result = disp.executeDispatch(docViewContrl, commandUrl, _frame, _sFlag, args); if (result.hasValue() && result.Value is unoidl.com.sun.star.frame.DispatchResultEvent) { var val = result.Value as unoidl.com.sun.star.frame.DispatchResultEvent; if (val != null && val.State == (short)DispatchResultState.SUCCESS) { successs = true; } } } }), "Dispatch Call"); successs &= abort; } return(successs); }
internal static Object CreateObjectFromService(Object _msf, String[] services) { try { // get MSF XMultiServiceFactory msf = _msf as XMultiServiceFactory; if (msf == null) { msf = OO.GetMultiServiceFactory(); } if (msf != null && services != null && services.Length > 0) { string[] serv = msf.getAvailableServiceNames(); System.Diagnostics.Debug.WriteLine("Available Service Names: " + String.Join("\n\t", serv)); //object component = msf.createInstance(services[0]); // object component = msf.createInstance("com.sun.star.document.ExportGraphicObjectResolver"); object component = msf.createInstance("com.sun.star.document.ImportEmbeddedObjectResolver"); //Debug.GetAllServicesOfObject(component); Debug.GetAllInterfacesOfObject(component); var n = ((XNameAccess)component).getElementNames(); return(component); } } catch (Exception ex) { } return(null); }
/// <summary> /// Provides an easy way to dispatch an URL using one call instead of multiple ones. /// Normally a complete dispatch is splitted into different parts: /// - converting and parsing the URL /// - searching for a valid dispatch object available on a dispatch provider /// - dispatching of the URL and it's parameters /// </summary> /// <param name="_msf">The MSF.</param> /// <returns>The dispatch helper or <c>null</c></returns> internal static XDispatchHelper GetDispatcher(XMultiServiceFactory _msf = null) { if (_msf == null) { _msf = OO.GetMultiServiceFactory(); } if (_msf != null) { //Create the Dispatcher return(_msf.createInstance("com.sun.star.frame.DispatchHelper") as XDispatchHelper); } return(null); }
protected virtual XFixedText CreateFixedLabel(String text, int _nPosX, int _nPosY, int _nWidth, int _nHeight, int _nStep, XMouseListener _xMouseListener, String sName = "") { XFixedText xFixedText = null; try { // create a controlmodel at the multiservicefactory of the dialog model... Object oFTModel = OO.GetMultiServiceFactory().createInstance(OO.Services.AWT_CONTROL_TEXT_FIXED_MODEL); Object xFTControl = OO.GetMultiServiceFactory().createInstance(OO.Services.AWT_CONTROL_TEXT_FIXED); XMultiPropertySet xFTModelMPSet = (XMultiPropertySet)oFTModel; // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xFTModelMPSet.setPropertyValues( new String[] { "Height", "Name", "PositionX", "PositionY", "Step", "Width", "Label" }, Any.Get(new Object[] { _nHeight, sName, _nPosX, _nPosY, _nStep, _nWidth, text })); if (oFTModel != null && xFTControl != null && xFTControl is XControl) { ((XControl)xFTControl).setModel(oFTModel as XControlModel); } xFixedText = xFTControl as XFixedText; if (_xMouseListener != null && xFTControl is XWindow) { XWindow xWindow = (XWindow)xFTControl; xWindow.addMouseListener(_xMouseListener); } } catch (unoidl.com.sun.star.uno.Exception ex) { System.Diagnostics.Debug.WriteLine("uno.Exception:"); System.Diagnostics.Debug.WriteLine(ex); } catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine("System.Exception:"); System.Diagnostics.Debug.WriteLine(ex); } return(xFixedText); }
/// <summary> /// Gets the dispatch helper as anonymous object. /// </summary> /// <returns>The XDispatchHelper as Object.</returns> public static Object GetDispatchHelper_anonymous() { return(GetDispatcher(OO.GetMultiServiceFactory())); }