コード例 #1
0
        /// <summary>
        /// Dispatch an URL to given frame.
        /// Caller can register himself for following result events for dispatched
        /// URL too. Notifications are guaranteed (instead of dispatch())
        /// Returning of the dispatch object isn't necessary.
        /// Nobody must hold it alive longer the dispatch needs.
        /// </summary>
        /// <param name="xFrame">frame wich should be the target of this dispatch</param>
        /// <param name="aUrl">full parsed and converted office URL for dispatch</param>
        /// <param name="lProperties">optional arguments for dispatch</param>
        /// <param name="xListener">
        /// optional listener which is registered automatically for status events
        /// (Note: Deregistration is not supported. Dispatcher does it automatically.)
        /// </param>
        public static void ExecuteWithNotification(XFrame xFrame, URL aUrl, PropertyValue[] lProperties, XDispatchResultListener xListener)
        {
            try
            {
                // Query the frame for right interface which provides access to all available dispatch objects.
                XDispatchProvider xProvider = (XDispatchProvider)xFrame;

                // Ask him for right dispatch object for given URL.
                // Force THIS frame as target for following dispatch.
                // Attention: The interface XNotifyingDispatch is an optional one!
                XDispatch          xDispatcher          = xProvider.queryDispatch(aUrl, "", 0);
                XNotifyingDispatch xNotifyingDispatcher = (XNotifyingDispatch)xDispatcher;

                // Dispatch the URL.
                if (xNotifyingDispatcher != null)
                {
                    xNotifyingDispatcher.dispatchWithNotification(aUrl, lProperties, xListener);
                }
            }
            catch (RuntimeException exUno)
            {
                // Any UNO method of this scope can throw this exception.
                // But there is nothing we can do then.
                System.Diagnostics.Debug.WriteLine(exUno);
            }
        }
コード例 #2
0
        /// <summary>
        /// Dispatch an URL to given frame.
        /// Caller can register himself for following status events for dispatched
        /// URL too. But nobody guarantee that such notifications will occur.
        /// (see dispatchWithNotification() if you interest on that)
        /// The returned dispatch object should be hold alive by caller
        /// till he doesn't need it any longer. Otherwise the dispatcher can(!)
        /// die by decreasing his refcount.
        /// (Note: Deregistration is part of this listener himself!)
        /// </summary>
        /// <param name="xFrame">frame wich should be the target of this dispatch</param>
        /// <param name="aUrl">full parsed and converted office URL for dispatch</param>
        /// <param name="lProperties">optional arguments for dispatch</param>
        /// <param name="xListener">optional listener which is registered automaticly for status events</param>
        /// <returns>
        /// It's the used dispatch object and can be used for deregistration of an optional listener.
        /// Otherwise caller can ignore it.
        /// </returns>
        public static XDispatch Execute(XFrame xFrame, URL aUrl, PropertyValue[] lProperties, XStatusListener xListener)
        {
            XDispatch xDispatcher;

            try
            {
                // Query the frame for right interface which provides access to all available dispatch objects.
                XDispatchProvider xProvider = (XDispatchProvider)xFrame;

                // Ask him for right dispatch object for given URL.
                // Force given frame as target for following dispatch by using "".
                // It means the same like "_self".
                xDispatcher = xProvider.queryDispatch(aUrl, "", 0);

                // Dispatch the URL into the frame.
                if (xDispatcher != null)
                {
                    if (xListener != null)
                    {
                        xDispatcher.addStatusListener(xListener, aUrl);
                    }

                    xDispatcher.dispatch(aUrl, lProperties);
                }
            }
            catch (RuntimeException exUno)
            {
                // Any UNO method of this scope can throw this exception.
                // But there will be nothing to do then - because
                // we haven't changed anything inside the remote objects
                // except method "addStatusListener().
                // But in this case the source of this exception has to
                // rollback all his operations. There is no chance to
                // make anything right then.
                // Reset the return value to a default - that's it.
                System.Diagnostics.Debug.WriteLine(exUno);
                xDispatcher = null;
            }

            return(xDispatcher);
        }