internal static XTransferableSupplier FindTransferableSupplier(XModel2 xModel2) { XTransferableSupplier result = null; try { if (xModel2 != null) { XEnumeration xEnumeration = xModel2.getControllers(); while (xEnumeration.hasMoreElements()) { XController xController = (XController)xEnumeration.nextElement().Value; if (xController is XTransferableSupplier) { result = xController as XTransferableSupplier; } } } } catch (Exception ex) { throw; } return(result); }
/// <summary> /// Try to close the document without any saving of modifications. /// We can try it only! Controller and/or model of this document /// can disagree with that. But mostly they doesn't do so. /// </summary> /// <param name="xDocument">document which should be clcosed</param> public static void CloseDocument(XComponent xDocument) { try { // Check supported functionality of the document (model or controller). XModel xModel = (XModel)xDocument; if (xModel != null) { // It's a full featured office document. // Reset the modify state of it and close it. // Note: Model can disagree by throwing a veto exception. XModifiable xModify = (XModifiable)xModel; xModify.setModified(false); xDocument.dispose(); } else { // It's a document which supports a controller .. or may by a pure // window only. If it's at least a controller - we can try to // suspend him. But - he can disagree with that! XController xController = (XController)xDocument; if (xController != null) { if (xController.suspend(true)) { // Note: Don't dispose the controller - destroy the frame // to make it right! XFrame xFrame = xController.getFrame(); xFrame.dispose(); } } } } catch (PropertyVetoException exVeto) { // Can be thrown by "setModified()" call on model. // He disagree with our request. // But there is nothing to do then. Following "dispose()" call wasn't // never called (because we catch it before). Closing failed -that's it. System.Diagnostics.Debug.WriteLine(exVeto); } catch (DisposedException exDisposed) { // If an UNO object was already disposed before - he throw this special // runtime exception. Of course every UNO call must be look for that - // but it's a question of error handling. // For demonstration this exception is handled here. System.Diagnostics.Debug.WriteLine(exDisposed); } catch (RuntimeException exRuntime) { // Every uno call can throw that. // Do nothing - closing failed - that's it. System.Diagnostics.Debug.WriteLine(exRuntime); } }
internal static void Copy(XController controller, Object selection) { XTransferableSupplier xTransferableSupplier = controller as XTransferableSupplier; Debug.GetAllInterfacesOfObject(controller); Copy(controller, selection, xTransferableSupplier); }
public static XLayer getActiveLayer(XController xController) { XLayer bActiveLayer = null; if (xController != null) { try { XPropertySet xPropSet = (XPropertySet)xController; bActiveLayer = xPropSet.getPropertyValue("ActiveLayer").Value as XLayer; } catch (unoidl.com.sun.star.uno.Exception e) { System.Diagnostics.Debug.WriteLine("Error while getting active layer:\n" + e); } } return bActiveLayer; }
public static XLayer getActiveLayer(XController xController) { XLayer bActiveLayer = null; if (xController != null) { try { XPropertySet xPropSet = (XPropertySet)xController; bActiveLayer = xPropSet.getPropertyValue("ActiveLayer").Value as XLayer; } catch (unoidl.com.sun.star.uno.Exception e) { System.Diagnostics.Debug.WriteLine("Error while getting active layer:\n" + e); } } return(bActiveLayer); }
private static void Copy(XController controller, Object selection, XTransferableSupplier xTransferableSupplier) { if (xTransferableSupplier != null) { // get selection supplier XSelectionSupplier xSelectionSupplier = controller as XSelectionSupplier; if (xSelectionSupplier != null) { // select the objects to select try { xSelectionSupplier.select(Any.Get(selection)); } catch (Exception ex) { throw new ArgumentException("Object can't be set as selection", "selection", ex); } XTransferable transfarable = xTransferableSupplier.getTransferable(); } } }
public ControllerAdapter() { outController = new XBoxController(); }
/// <summary> /// Try to get the page number of the current active page /// </summary> /// <param name="contr"></param> /// <param name="pid"></param> /// <returns></returns> private int getCurrentActivePageId(XController contr) { int pid = -1; lock (_controlerLock) { TimeLimitExecutor.WaitForExecuteWithTimeLimit(500, () => { try { if (contr != null && contr is XDrawView) { // get the current page var page = ((XDrawView)contr).getCurrentPage(); // get the number pid = util.OoUtils.GetIntProperty(page, "Number"); } } catch (DisposedException) { Logger.Instance.Log(LogPriority.IMPORTANT, this, "[ERROR] Controller seems to be already disposed"); this.Dispose(); } catch (System.Exception ex) { Logger.Instance.Log(LogPriority.IMPORTANT, this, "[ERROR] cant use the controller of document window: " + ex); } } , "useControllerOfModel" ); } return pid; }