/// <summary> /// /// </summary> /// <param name="url"></param> public static Object GetGraphicFromUrl(string url) { try { var msf = OO.GetMultiComponentFactory(); if (msf != null) { var graphicProvider = msf.createInstanceWithContext(OO.Services.GRAPHIC_GRAPHICPROVIDER, OO.GetContext()); if (graphicProvider != null && graphicProvider is XGraphicProvider) { PropertyValue val = new PropertyValue(); val.Name = "URL"; val.Value = Any.Get(CreateBitmapUrl(url)); PropertyValue val2 = new PropertyValue(); val2.Name = "MimeType"; val2.Value = Any.Get(@"image/png"); var graphic = ((XGraphicProvider)graphicProvider).queryGraphic(new PropertyValue[] { val }); return(graphic); } } } catch (Exception ex) { Logger.Instance.Log(LogPriority.DEBUG, "oOUtils", "Cannot get Graphic provider: " + ex); } return(null); }
/// <summary> /// News the doc component. /// </summary> /// <param name="docType">Type of the doc.</param> /// <param name="xMsFactory"> </param> /// <param name="xContext"> </param> /// <returns></returns> public static XComponent OpenNewDocumentComponent(String docType, XComponentContext xContext = null, XMultiComponentFactory xMsFactory = null) { try { if (xContext == null) { xContext = OO.GetContext(); } if (xMsFactory == null) { xMsFactory = OO.GetMultiComponentFactory(xContext); } var desktop = xMsFactory.createInstanceWithContext(OO.Services.FRAME_DESKTOP, xContext); var mxCompLoader = desktop as XComponentLoader; String loadUrl = OO.DocTypes.DOC_TYPE_BASE + docType; var loadProps = new unoidl.com.sun.star.beans.PropertyValue[0]; if (mxCompLoader != null) { return(mxCompLoader.loadComponentFromURL(loadUrl, "_blank", 0, loadProps)); } } catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine("Desktop to XComponentLoader cast Exeption: " + ex); } return(null); }
/// <summary> /// Connect to a running office that is accepting connections. /// </summary> /// <param name="args">The args.</param> /// <returns>The ServiceManager to instantiate office components.</returns> public XMultiComponentFactory Connect(String[] args) { if (MXContext == null) { return(null); } try { return((XMultiComponentFactory)MXContext.getServiceManager()); } catch (unoidl.com.sun.star.lang.DisposedException) { return(OO.GetMultiComponentFactory()); } }
/// <summary> /// Initializes a new instance of the <see cref="ToolBar"/> class. /// </summary> /// <param name="xMsf">the XMultiComponentFactory.</param> /// <param name="name">The UIName Parameter of the ToolBar.</param> /// <param name="documentModluleIdentifier">The document modlule identifier for the ToolBar. /// E.g. "com.sun.star.text.TextDocument" to add the ToolBar to all text documents</param> public ToolBar(string name, string documentModluleIdentifier, XMultiComponentFactory xMsf = null) { if (name.Trim().Length < 1) { throw new NullReferenceException("Name for ToolBar creation is empty"); } XMcf = xMsf ?? OO.GetMultiComponentFactory(); Name = name; RecourceUrl = GetToolBarUrl(name); // Retrieve the module configuration manager supplier to get // the configuration setting from the module _xModCfgMgrSupplier = (XModuleUIConfigurationManagerSupplier) XMcf.createInstanceWithContext(OO.Services.UI_MOD_UI_CONF_MGR_SUPPLIER, OO.GetContext()); // Retrieve the module configuration manager XCfgMgr = _xModCfgMgrSupplier.getUIConfigurationManager(documentModluleIdentifier); if (XCfgMgr.hasSettings(RecourceUrl) == false) { // Creates a copy of the user interface configuration manager Settings = XCfgMgr.createSettings(); // Defines the name of the toolbar var xToolbarProperties = (XPropertySet)Settings; xToolbarProperties.setPropertyValue("UIName", Any.Get(name)); // Makes the toolbar to the UI manager available try { XCfgMgr.insertSettings(RecourceUrl, Settings); } catch (ElementExistException) { Settings = XCfgMgr.getSettings(RecourceUrl, true) as XIndexContainer; } } else { Settings = XCfgMgr.getSettings(RecourceUrl, true) as XIndexContainer; } }
public AbstactUnoDialogBase(XComponentContext xContext) : this(xContext, OO.GetMultiComponentFactory(xContext)) { }
public void CreateScrollableContainer(int _nPosX, int _nPosY, int _nWidth, int _nHeight, String sName) { try { // create a unique id by means of an own implementation... if (String.IsNullOrWhiteSpace(sName)) { sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, "SCROLL_CONTAINER"); } else { sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, sName); } //XMultiServiceFactory _xMSF = OO.GetMultiServiceFactory(MXContext); XMultiComponentFactory _xMcf = OO.GetMultiComponentFactory(MXContext, true); #region Outer Container // create a UnoControlContainerModel. A thing which differs from other dialog-controls in many aspects // Position and size of the model have no effect, so we apply setPosSize() on it's view later. // Unlike a dialog-model the container-model can not have any control-models. // As an instance of a dialog-model it can have the property "Step"(among other things), // provided by service awt.UnoControlDialogElement, without actually supporting this service! // create a control model at the multi service factory of the dialog model... outerScrlContrModel = _xMcf.createInstanceWithContext(AWT_UNO_CONTROL_CONTAINER_Model, MXContext) as XControlModel; OuterScrlContr = _xMcf.createInstanceWithContext(AWT_UNO_CONTROL_CONTAINER, MXContext) as XControl; if (OuterScrlContr != null && outerScrlContrModel != null) { OuterScrlContr.setModel(outerScrlContrModel); } XMultiPropertySet xoScrlContMPSet = outerScrlContrModel as XMultiPropertySet; if (xoScrlContMPSet != null) { // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xoScrlContMPSet.setPropertyValues( new String[] { "Height", "Name", "PositionX", "PositionY", "State", "Width" }, Any.Get(new Object[] { 0, sName, 0, 0, ((short)0), 0, 0 })); } //add to the dialog XControlContainer xCntrCont = parentCnt as XControlContainer; if (xCntrCont != null) { xCntrCont.addControl(sName, OuterScrlContr as XControl); } #endregion #region Scroll bars //insert scroll bars HorizontalScrlBar = insertHorizontalScrollBar(this, _nPosX, _nPosY + _nHeight, _nWidth); VerticalScrlBar = insertVerticalScrollBar(this, _nPosX + _nWidth, _nPosY, _nHeight); #endregion #region Set Size of outer Container //make the outer container pos and size via the pos and size of the scroll bars if (HorizontalScrlBar is XWindow) { Rectangle hSBPos = ((XWindow)HorizontalScrlBar).getPosSize(); _width = hSBPos.Width; _posX = hSBPos.X; } if (VerticalScrlBar is XWindow) { Rectangle vSBPos = ((XWindow)VerticalScrlBar).getPosSize(); _height = vSBPos.Height; _posY = vSBPos.Y; } // Set the size of the surrounding container if (OuterScrlContr is XWindow) { ((XWindow)OuterScrlContr).setPosSize(PosX, PosY, Width, Height, PosSize.POSSIZE); ((XWindow)OuterScrlContr).addMouseListener(this); } #endregion #region inner Container // create a control model at the multi service factory of the dialog model... innerScrlContrModel = _xMcf.createInstanceWithContext(AWT_UNO_CONTROL_CONTAINER_Model, MXContext) as XControlModel; InnerScrlContr = _xMcf.createInstanceWithContext(AWT_UNO_CONTROL_CONTAINER, MXContext) 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 + "_S", ((short)0) })); } //// FIXME: only for fixing //util.Debug.GetAllServicesOfObject(parentCnt); //Object oDialogModel = OO.GetMultiComponentFactory().createInstanceWithContext(OO.Services.AWT_CONTROL_DIALOG_MODEL, MXContext); //// The named container is used to insert the created controls into... //MXDlgModelNameContainer = (XNameContainer)oDialogModel; //System.Diagnostics.Debug.WriteLine("_________"); //util.Debug.GetAllServicesOfObject(MXDlgModelNameContainer); //// END //add inner container to the outer scroll container XControlContainer outerCntrCont = OuterScrlContr as XControlContainer; if (outerCntrCont != null) { outerCntrCont.addControl(sName + "_S", InnerScrlContr as XControl); InnerWidth = Width; InnerHeight = Height; // Set the size of the surrounding container if (InnerScrlContr is XWindow) { ((XWindow)InnerScrlContr).setPosSize(0, 0, InnerWidth, InnerHeight, PosSize.POSSIZE); ((XWindow)InnerScrlContr).addMouseListener(this); } } #endregion } catch (System.Exception) { } }
public static XControlContainer createDialog(XComponentContext xContext, int posX, int posY, int width, int height, string title ) { return(createDialog(OO.GetMultiComponentFactory(xContext), xContext, posX, posX, width, height, title)); }