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

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