Esempio n. 1
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);
        }
        /// <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;
        }