Blame SOURCES/0109-LOK-Implement-an-own-trivial-InteractionHandler.patch

135360
From fd6adbabe3debe2e41f3f39816a1e92e9c1850e1 Mon Sep 17 00:00:00 2001
135360
From: Jan Holesovsky <kendy@collabora.com>
135360
Date: Fri, 11 Sep 2015 18:46:53 +0200
135360
Subject: [PATCH 109/398] LOK: Implement an own trivial InteractionHandler.
135360
135360
So far it just selects 'Approve' for any interaction that is done through
135360
that, later we want to route the information via callbacks to the caller.
135360
135360
Change-Id: I7ae3e2dcc04877b8b0197b0396299126e1217a2a
135360
(cherry picked from commit f1f179ba0ff3d293e81c7b95554f8e6b140340d7)
135360
---
135360
 desktop/Library_sofficeapp.mk                |  2 +
135360
 desktop/source/lib/init.cxx                  | 19 ++++++-
135360
 desktop/source/lib/lokinteractionhandler.cxx | 83 ++++++++++++++++++++++++++++
135360
 desktop/source/lib/lokinteractionhandler.hxx | 70 +++++++++++++++++++++++
135360
 4 files changed, 173 insertions(+), 1 deletion(-)
135360
 create mode 100644 desktop/source/lib/lokinteractionhandler.cxx
135360
 create mode 100644 desktop/source/lib/lokinteractionhandler.hxx
135360
135360
diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
135360
index 467fecc8ffc2..ccad5a7ea5ca 100644
135360
--- a/desktop/Library_sofficeapp.mk
135360
+++ b/desktop/Library_sofficeapp.mk
135360
@@ -123,6 +123,7 @@ endif
135360
 ifneq ($(filter $(OS),ANDROID IOS),)
135360
 $(eval $(call gb_Library_add_exception_objects,sofficeapp,\
135360
 	desktop/source/lib/init \
135360
+	desktop/source/lib/lokinteractionhandler \
135360
 	$(if $(filter $(OS),ANDROID), \
135360
 		desktop/source/lib/lokandroid) \
135360
 ))
135360
@@ -130,6 +131,7 @@ else
135360
 ifeq ($(GUIBASE),unx)
135360
 $(eval $(call gb_Library_add_exception_objects,sofficeapp,\
135360
 	desktop/source/lib/init \
135360
+	desktop/source/lib/lokinteractionhandler \
135360
 ))
135360
 endif
135360
 endif
135360
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
135360
index be1a01867cf5..fb8ec3ea361a 100644
135360
--- a/desktop/source/lib/init.cxx
135360
+++ b/desktop/source/lib/init.cxx
135360
@@ -71,6 +71,8 @@
135360
 #include "../app/officeipcthread.hxx"
135360
 #include "../../inc/lib/init.hxx"
135360
 
135360
+#include "lokinteractionhandler.hxx"
135360
+
135360
 using namespace css;
135360
 using namespace vcl;
135360
 using namespace desktop;
135360
@@ -385,11 +387,26 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis,
135360
 
135360
     try
135360
     {
135360
-        uno::Sequence<css::beans::PropertyValue> aFilterOptions(1);
135360
+        uno::Sequence<css::beans::PropertyValue> aFilterOptions(2);
135360
         aFilterOptions[0] = css::beans::PropertyValue( OUString("FilterOptions"),
135360
                                                        0,
135360
                                                        uno::makeAny(OUString::createFromAscii(pOptions)),
135360
                                                        beans::PropertyState_DIRECT_VALUE);
135360
+
135360
+        uno::Reference<task::XInteractionHandler2> xInteraction(new LOKInteractionHandler(::comphelper::getProcessComponentContext()));
135360
+        aFilterOptions[1].Name = "InteractionHandler";
135360
+        aFilterOptions[1].Value <<= xInteraction;
135360
+
135360
+        /* TODO
135360
+        sal_Int16 nMacroExecMode = document::MacroExecMode::USE_CONFIG;
135360
+        aFilterOptions[2].Name = "MacroExecutionMode";
135360
+        aFilterOptions[2].Value <<= nMacroExecMode;
135360
+
135360
+        sal_Int16 nUpdateDoc = document::UpdateDocMode::ACCORDING_TO_CONFIG;
135360
+        aFilterOptions[3].Name = "UpdateDocMode";
135360
+        aFilterOptions[3].Value <<= nUpdateDoc;
135360
+        */
135360
+
135360
         uno::Reference<lang::XComponent> xComponent;
135360
         xComponent = xComponentLoader->loadComponentFromURL(
135360
                                             aURL, OUString("_blank"), 0,
135360
diff --git a/desktop/source/lib/lokinteractionhandler.cxx b/desktop/source/lib/lokinteractionhandler.cxx
135360
new file mode 100644
135360
index 000000000000..1d20b0219e28
135360
--- /dev/null
135360
+++ b/desktop/source/lib/lokinteractionhandler.cxx
135360
@@ -0,0 +1,83 @@
135360
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
135360
+/*
135360
+ * This file is part of the LibreOffice project.
135360
+ *
135360
+ * This Source Code Form is subject to the terms of the Mozilla Public
135360
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
135360
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
135360
+ *
135360
+ * This file incorporates work covered by the following license notice:
135360
+ *
135360
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
135360
+ *   contributor license agreements. See the NOTICE file distributed
135360
+ *   with this work for additional information regarding copyright
135360
+ *   ownership. The ASF licenses this file to you under the Apache
135360
+ *   License, Version 2.0 (the "License"); you may not use this file
135360
+ *   except in compliance with the License. You may obtain a copy of
135360
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
135360
+ */
135360
+
135360
+#include "lokinteractionhandler.hxx"
135360
+
135360
+#include <cppuhelper/supportsservice.hxx>
135360
+
135360
+#include <com/sun/star/task/XInteractionApprove.hpp>
135360
+
135360
+using namespace com::sun::star;
135360
+
135360
+LOKInteractionHandler::LOKInteractionHandler(uno::Reference<uno::XComponentContext> const & /*rxContext*/)
135360
+{
135360
+}
135360
+
135360
+LOKInteractionHandler::~LOKInteractionHandler()
135360
+{
135360
+}
135360
+
135360
+OUString SAL_CALL LOKInteractionHandler::getImplementationName() throw (uno::RuntimeException, std::exception)
135360
+{
135360
+    return OUString("com.sun.star.comp.uui.LOKInteractionHandler");
135360
+}
135360
+
135360
+sal_Bool SAL_CALL LOKInteractionHandler::supportsService(OUString const & rServiceName) throw (uno::RuntimeException, std::exception)
135360
+{
135360
+    return cppu::supportsService(this, rServiceName);
135360
+}
135360
+
135360
+uno::Sequence< OUString > SAL_CALL LOKInteractionHandler::getSupportedServiceNames() throw (uno::RuntimeException, std::exception)
135360
+{
135360
+    uno::Sequence< OUString > aNames(3);
135360
+    aNames[0] = "com.sun.star.task.InteractionHandler";
135360
+    // added to indicate support for configuration.backend.MergeRecoveryRequest
135360
+    aNames[1] = "com.sun.star.configuration.backend.InteractionHandler";
135360
+    aNames[2] = "com.sun.star.uui.InteractionHandler";
135360
+    // for backwards compatibility
135360
+    return aNames;
135360
+}
135360
+
135360
+void SAL_CALL LOKInteractionHandler::initialize(uno::Sequence<uno::Any> const & /*rArguments*/) throw (uno::Exception, std::exception)
135360
+{
135360
+}
135360
+
135360
+void SAL_CALL LOKInteractionHandler::handle(uno::Reference<task::XInteractionRequest> const & rRequest) throw (uno::RuntimeException, std::exception)
135360
+{
135360
+    // just do the same thing in both cases
135360
+    handleInteractionRequest(rRequest);
135360
+}
135360
+
135360
+sal_Bool SAL_CALL LOKInteractionHandler::handleInteractionRequest(const uno::Reference<task::XInteractionRequest >& rRequest) throw ( uno::RuntimeException, std::exception )
135360
+{
135360
+    uno::Sequence<uno::Reference<task::XInteractionContinuation>> const &rContinuations = rRequest->getContinuations();
135360
+
135360
+    // TODO: add LOK api that allows handling this for real, for the moment we
135360
+    // just set the interaction as 'Approved'
135360
+    for (sal_Int32 i = 0; i < rContinuations.getLength(); ++i)
135360
+    {
135360
+        uno::Reference<task::XInteractionApprove> xApprove(rContinuations[i], uno::UNO_QUERY);
135360
+        if (xApprove.is())
135360
+            xApprove->select();
135360
+    }
135360
+
135360
+    return sal_True;
135360
+}
135360
+
135360
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
135360
diff --git a/desktop/source/lib/lokinteractionhandler.hxx b/desktop/source/lib/lokinteractionhandler.hxx
135360
new file mode 100644
135360
index 000000000000..6d4aa8231daf
135360
--- /dev/null
135360
+++ b/desktop/source/lib/lokinteractionhandler.hxx
135360
@@ -0,0 +1,70 @@
135360
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
135360
+/*
135360
+ * This file is part of the LibreOffice project.
135360
+ *
135360
+ * This Source Code Form is subject to the terms of the Mozilla Public
135360
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
135360
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
135360
+ *
135360
+ * This file incorporates work covered by the following license notice:
135360
+ *
135360
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
135360
+ *   contributor license agreements. See the NOTICE file distributed
135360
+ *   with this work for additional information regarding copyright
135360
+ *   ownership. The ASF licenses this file to you under the Apache
135360
+ *   License, Version 2.0 (the "License"); you may not use this file
135360
+ *   except in compliance with the License. You may obtain a copy of
135360
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
135360
+ */
135360
+
135360
+#ifndef INCLUDED_DESKTOP_SOURCE_LIB_LOKINTERACTIONHANDLER_HXX
135360
+#define INCLUDED_DESKTOP_SOURCE_LIB_LOKINTERACTIONHANDLER_HXX
135360
+
135360
+#include <cppuhelper/implbase.hxx>
135360
+
135360
+#include <com/sun/star/lang/XInitialization.hpp>
135360
+#include <com/sun/star/lang/XServiceInfo.hpp>
135360
+#include <com/sun/star/task/InteractionHandler.hpp>
135360
+
135360
+/** InteractionHandler is an interface that provides the user with various dialogs / error messages.
135360
+
135360
+We need an own implementation for the LibreOfficeKit so that we can route the
135360
+information easily via callbacks.
135360
+
135360
+TODO: the callbacks are not implemented yet, we just approve any interaction
135360
+that we get.
135360
+*/
135360
+class LOKInteractionHandler: public cppu::WeakImplHelper
135360
+                                                         com::sun::star::lang::XInitialization,
135360
+                                                         com::sun::star::task::XInteractionHandler2>
135360
+{
135360
+    LOKInteractionHandler(const LOKInteractionHandler&) SAL_DELETED_FUNCTION;
135360
+    LOKInteractionHandler& operator=(const LOKInteractionHandler&) SAL_DELETED_FUNCTION;
135360
+
135360
+public:
135360
+    explicit LOKInteractionHandler(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const & rxContext);
135360
+
135360
+    virtual ~LOKInteractionHandler();
135360
+
135360
+    virtual OUString SAL_CALL getImplementationName()
135360
+        throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
135360
+
135360
+    virtual sal_Bool SAL_CALL supportsService(OUString const & rServiceName)
135360
+        throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
135360
+
135360
+    virtual com::sun::star::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
135360
+        throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
135360
+
135360
+    virtual void SAL_CALL initialize(com::sun::star::uno::Sequence<com::sun::star::uno::Any > const & rArguments)
135360
+        throw (com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
135360
+
135360
+    virtual void SAL_CALL handle(com::sun::star::uno::Reference<com::sun::star::task::XInteractionRequest> const & rRequest)
135360
+        throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
135360
+
135360
+    virtual sal_Bool SAL_CALL handleInteractionRequest(const ::com::sun::star::uno::Reference<::com::sun::star::task::XInteractionRequest>& _Request)
135360
+        throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
135360
+};
135360
+
135360
+#endif
135360
+
135360
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
135360
-- 
135360
2.12.0
135360