summaryrefslogtreecommitdiffstats
path: root/framework/source/inc/dispatch
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--framework/source/inc/dispatch/dispatchdisabler.hxx101
-rw-r--r--framework/source/inc/dispatch/loaddispatcher.hxx123
-rw-r--r--framework/source/inc/dispatch/windowcommanddispatch.hxx111
3 files changed, 335 insertions, 0 deletions
diff --git a/framework/source/inc/dispatch/dispatchdisabler.hxx b/framework/source/inc/dispatch/dispatchdisabler.hxx
new file mode 100644
index 000000000..ed64a656e
--- /dev/null
+++ b/framework/source/inc/dispatch/dispatchdisabler.hxx
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#ifndef INCLUDED_FRAMEWORK_INC_SERVICES_DISPATCH_DISABLER_HXX
+#define INCLUDED_FRAMEWORK_INC_SERVICES_DISPATCH_DISABLER_HXX
+
+#include <set>
+
+#include <cppuhelper/implbase.hxx>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/frame/XInterceptorInfo.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
+
+#include <macros/xserviceinfo.hxx>
+
+namespace framework {
+
+/**
+ * Implementation of a service to make it easy to disable a whole
+ * suite of UNO commands in a batch - and have that act in-process.
+ *
+ * Often external re-use of LibreOffice wants a very cut-down set
+ * of functionality included, and disabling elements remotely one
+ * by one performs poorly.
+ */
+class DispatchDisabler : public ::cppu::WeakImplHelper<
+ css::lang::XInitialization,
+ css::container::XNameContainer,
+ css::frame::XDispatchProviderInterceptor,
+ css::frame::XInterceptorInfo,
+ css::lang::XServiceInfo >
+{
+ std::set<OUString> maDisabledURLs;
+ css::uno::Reference< css::frame::XDispatchProvider > mxSlave;
+ css::uno::Reference< css::frame::XDispatchProvider > mxMaster;
+public:
+ DispatchDisabler(const css::uno::Reference< css::uno::XComponentContext >& rxContext);
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::css::uno::Sequence< ::css::uno::Any >& aArguments ) override;
+
+ // XDispatchProvider
+ virtual ::css::uno::Reference< ::css::frame::XDispatch > SAL_CALL
+ queryDispatch( const ::css::util::URL& URL,
+ const OUString& TargetFrameName,
+ ::sal_Int32 SearchFlags ) override;
+ virtual ::css::uno::Sequence< ::css::uno::Reference< ::css::frame::XDispatch > > SAL_CALL
+ queryDispatches( const ::css::uno::Sequence< ::css::frame::DispatchDescriptor >& Requests ) override;
+
+ // XDispatchProviderInterceptor
+ virtual ::css::uno::Reference< ::css::frame::XDispatchProvider > SAL_CALL
+ getSlaveDispatchProvider() override;
+ virtual void SAL_CALL
+ setSlaveDispatchProvider( const ::css::uno::Reference< ::css::frame::XDispatchProvider >& NewDispatchProvider ) override;
+ virtual ::css::uno::Reference< ::css::frame::XDispatchProvider > SAL_CALL
+ getMasterDispatchProvider() override;
+ virtual void SAL_CALL
+ setMasterDispatchProvider( const ::css::uno::Reference< ::css::frame::XDispatchProvider >& NewSupplier ) override;
+
+ // XInterceptorInfo
+ virtual ::css::uno::Sequence< OUString > SAL_CALL
+ getInterceptedURLs() override;
+
+ // XElementAccess
+ virtual ::css::uno::Type SAL_CALL getElementType() override;
+ virtual ::sal_Bool SAL_CALL hasElements() override;
+
+ // XNameAccess
+ virtual ::css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
+ virtual ::css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
+ virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
+
+ // XNameReplace
+ virtual void SAL_CALL replaceByName( const OUString& aName, const ::css::uno::Any& aElement ) override;
+
+ // XNameContainer
+ virtual void SAL_CALL insertByName( const OUString& aName, const ::css::uno::Any& aElement ) override;
+ virtual void SAL_CALL removeByName( const OUString& Name ) override;
+
+ DECLARE_XSERVICEINFO_NOFACTORY
+ /* Helper for registry */
+ /// @throws css::uno::Exception
+ static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager );
+ static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager );
+};
+
+} // namespace framework
+
+#endif // INCLUDED_FRAMEWORK_INC_SERVICES_DISPATCH_DISABLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/inc/dispatch/loaddispatcher.hxx b/framework/source/inc/dispatch/loaddispatcher.hxx
new file mode 100644
index 000000000..e473dd532
--- /dev/null
+++ b/framework/source/inc/dispatch/loaddispatcher.hxx
@@ -0,0 +1,123 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_FRAMEWORK_SOURCE_INC_DISPATCH_LOADDISPATCHER_HXX
+#define INCLUDED_FRAMEWORK_SOURCE_INC_DISPATCH_LOADDISPATCHER_HXX
+
+#include <loadenv/loadenv.hxx>
+
+#include <com/sun/star/frame/XNotifyingDispatch.hpp>
+#include <com/sun/star/frame/XSynchronousDispatch.hpp>
+
+#include <cppuhelper/implbase.hxx>
+#include <cppuhelper/weakref.hxx>
+
+namespace framework{
+
+/** @short implements a dispatch object which can be used to load
+ non-visible components (by using the mechanism of ContentHandler)
+ or visible-components (by using the mechanism of FrameLoader).
+ */
+class LoadDispatcher : public ::cppu::WeakImplHelper< css::frame::XNotifyingDispatch, // => XDispatch => XInterface
+ css::frame::XSynchronousDispatch >
+{
+
+ // member
+
+ private:
+ osl::Mutex m_mutex;
+
+ /** @short TODO document me */
+ css::uno::WeakReference< css::frame::XFrame > m_xOwnerFrame;
+
+ /** @short TODO document me */
+ OUString m_sTarget;
+
+ /** @short TODO document me */
+ sal_Int32 m_nSearchFlags;
+
+ /** @short TODO document me */
+ LoadEnv m_aLoader;
+
+ // native interface
+
+ public:
+
+ /** @short creates a new instance and initialize it with all necessary parameters.
+
+ @descr Every instance of such LoadDispatcher can be used for the specified context only.
+ That means: it can be used to load any further requested content into the here(!)
+ specified target frame.
+
+ @param xContext
+ will be used to create own needed services on demand.
+
+ @param xOwnerFrame
+ used as startpoint to locate the right target frame.
+
+ @param sTargetName
+ the name or the target frame for loading or a special qualifier
+ which define such target.
+
+ @param nSearchFlags
+ used in case sTargetFrame isn't a special one.
+ */
+ LoadDispatcher(const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::frame::XFrame >& xOwnerFrame ,
+ const OUString& sTargetName ,
+ sal_Int32 nSearchFlags);
+
+ /** @short used to free internal resources.
+ */
+ virtual ~LoadDispatcher() override;
+
+ // uno interface
+
+ public:
+
+ // XNotifyingDispatch
+ virtual void SAL_CALL dispatchWithNotification(const css::util::URL& aURL ,
+ const css::uno::Sequence< css::beans::PropertyValue >& lArguments,
+ const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) override;
+
+ // XDispatch
+ virtual void SAL_CALL dispatch(const css::util::URL& aURL ,
+ const css::uno::Sequence< css::beans::PropertyValue >& lArguments) override;
+
+ virtual void SAL_CALL addStatusListener(const css::uno::Reference< css::frame::XStatusListener >& xListener,
+ const css::util::URL& aURL ) override;
+
+ virtual void SAL_CALL removeStatusListener(const css::uno::Reference< css::frame::XStatusListener >& xListener,
+ const css::util::URL& aURL ) override;
+
+ // XSynchronousDispatch
+ virtual css::uno::Any SAL_CALL dispatchWithReturnValue( const css::util::URL& aURL ,
+ const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) override;
+
+ private:
+ css::uno::Any impl_dispatch( const css::util::URL& rURL,
+ const css::uno::Sequence< css::beans::PropertyValue >& lArguments,
+ const css::uno::Reference< css::frame::XDispatchResultListener >& xListener );
+}; // class LoadDispatcher
+
+} // namespace framework
+
+#endif // INCLUDED_FRAMEWORK_SOURCE_INC_DISPATCH_LOADDISPATCHER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/inc/dispatch/windowcommanddispatch.hxx b/framework/source/inc/dispatch/windowcommanddispatch.hxx
new file mode 100644
index 000000000..db5602fd2
--- /dev/null
+++ b/framework/source/inc/dispatch/windowcommanddispatch.hxx
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_FRAMEWORK_SOURCE_INC_DISPATCH_WINDOWCOMMANDDISPATCH_HXX
+#define INCLUDED_FRAMEWORK_SOURCE_INC_DISPATCH_WINDOWCOMMANDDISPATCH_HXX
+
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+
+#include <cppuhelper/weakref.hxx>
+#include <tools/link.hxx>
+
+namespace com::sun::star::uno {
+ class XComponentContext;
+}
+class VclWindowEvent;
+
+namespace framework{
+
+/** @short internal helper to bind e.g. MAC-Menu events to our internal dispatch API.
+
+ @descr On e.g. MAC platform system menus are merged together with some fix entries as
+ e.g. "Pereferences" or "About". These menu entries trigger hard coded commands.
+ Here we map these commands to the right URLs and dispatch them.
+
+ This helper knows a frame and its container window (where VCL provide the hard coded
+ commands). We hold those objects weak so there is no need to react for complex UNO dispose/ing()
+ scenarios. On the other side VCL does not hold us alive (because it doesn't know our UNO reference).
+ So we register at the VCL level as an event listener and
+ */
+class WindowCommandDispatch final
+{
+ private:
+ osl::Mutex m_mutex;
+
+ /// can be used to create own needed services on demand.
+ css::uno::Reference< css::uno::XComponentContext > m_xContext;
+
+ /// knows the frame, where we dispatch our commands as weak reference
+ css::uno::WeakReference< css::frame::XFrame > m_xFrame;
+
+ /// knows the VCL window (where the hard coded commands occurred) as weak XWindow reference
+ css::uno::WeakReference< css::awt::XWindow > m_xWindow;
+
+ // native interface
+
+ public:
+
+ /** @short creates a new instance and initialize it with all necessary parameters.
+
+ @descr Every instance of such MACDispatch can be used for the specified context only.
+ Means: 1 MACDispatch object is bound to 1 Frame/Window pair in which context
+ the detected commands will be executed.
+
+ @param xContext
+ will be used to create own needed services on demand.
+
+ @param xFrame
+ used as for new detected commands.
+ */
+ WindowCommandDispatch(const css::uno::Reference< css::uno::XComponentContext >& xContext ,
+ const css::uno::Reference< css::frame::XFrame >& xFrame);
+
+ /** @short used to free internal resources.
+ */
+ ~WindowCommandDispatch();
+
+ // implementation
+
+ private:
+
+ /** @short establish all listener connections we need.
+
+ @descr Those listener connections will be created one times only (see ctor).
+ Afterwards we listen for incoming events till our referred frame/window pair
+ will be closed.
+ */
+ void impl_startListening();
+
+ /** @short drop all listener connections we need.
+
+ */
+ void impl_stopListening();
+
+ /** @short callback from VCL to notify new commands
+ */
+ DECL_LINK( impl_notifyCommand, VclWindowEvent&, void );
+
+}; // class WindowCommandDispatch
+
+} // namespace framework
+
+#endif // INCLUDED_FRAMEWORK_SOURCE_INC_DISPATCH_WINDOWCOMMANDDISPATCH_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */