summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--desktop/Library_sofficeapp.mk2
-rw-r--r--desktop/source/lib/init.cxx19
-rw-r--r--desktop/source/lib/lokinteractionhandler.cxx83
-rw-r--r--desktop/source/lib/lokinteractionhandler.hxx70
4 files changed, 173 insertions, 1 deletions
diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index 103581f74ee0..eec7e420efe8 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -123,6 +123,7 @@ endif
ifneq ($(filter $(OS),ANDROID IOS MACOSX),)
$(eval $(call gb_Library_add_exception_objects,sofficeapp,\
desktop/source/lib/init \
+ desktop/source/lib/lokinteractionhandler \
$(if $(filter $(OS),ANDROID), \
desktop/source/lib/lokandroid) \
))
@@ -130,6 +131,7 @@ else
ifeq ($(GUIBASE),unx)
$(eval $(call gb_Library_add_exception_objects,sofficeapp,\
desktop/source/lib/init \
+ desktop/source/lib/lokinteractionhandler \
))
endif
endif
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index be1a01867cf5..fb8ec3ea361a 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -71,6 +71,8 @@
#include "../app/officeipcthread.hxx"
#include "../../inc/lib/init.hxx"
+#include "lokinteractionhandler.hxx"
+
using namespace css;
using namespace vcl;
using namespace desktop;
@@ -385,11 +387,26 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis,
try
{
- uno::Sequence<css::beans::PropertyValue> aFilterOptions(1);
+ uno::Sequence<css::beans::PropertyValue> aFilterOptions(2);
aFilterOptions[0] = css::beans::PropertyValue( OUString("FilterOptions"),
0,
uno::makeAny(OUString::createFromAscii(pOptions)),
beans::PropertyState_DIRECT_VALUE);
+
+ uno::Reference<task::XInteractionHandler2> xInteraction(new LOKInteractionHandler(::comphelper::getProcessComponentContext()));
+ aFilterOptions[1].Name = "InteractionHandler";
+ aFilterOptions[1].Value <<= xInteraction;
+
+ /* TODO
+ sal_Int16 nMacroExecMode = document::MacroExecMode::USE_CONFIG;
+ aFilterOptions[2].Name = "MacroExecutionMode";
+ aFilterOptions[2].Value <<= nMacroExecMode;
+
+ sal_Int16 nUpdateDoc = document::UpdateDocMode::ACCORDING_TO_CONFIG;
+ aFilterOptions[3].Name = "UpdateDocMode";
+ aFilterOptions[3].Value <<= nUpdateDoc;
+ */
+
uno::Reference<lang::XComponent> xComponent;
xComponent = xComponentLoader->loadComponentFromURL(
aURL, OUString("_blank"), 0,
diff --git a/desktop/source/lib/lokinteractionhandler.cxx b/desktop/source/lib/lokinteractionhandler.cxx
new file mode 100644
index 000000000000..1d20b0219e28
--- /dev/null
+++ b/desktop/source/lib/lokinteractionhandler.cxx
@@ -0,0 +1,83 @@
+/* -*- 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 .
+ */
+
+#include "lokinteractionhandler.hxx"
+
+#include <cppuhelper/supportsservice.hxx>
+
+#include <com/sun/star/task/XInteractionApprove.hpp>
+
+using namespace com::sun::star;
+
+LOKInteractionHandler::LOKInteractionHandler(uno::Reference<uno::XComponentContext> const & /*rxContext*/)
+{
+}
+
+LOKInteractionHandler::~LOKInteractionHandler()
+{
+}
+
+OUString SAL_CALL LOKInteractionHandler::getImplementationName() throw (uno::RuntimeException, std::exception)
+{
+ return OUString("com.sun.star.comp.uui.LOKInteractionHandler");
+}
+
+sal_Bool SAL_CALL LOKInteractionHandler::supportsService(OUString const & rServiceName) throw (uno::RuntimeException, std::exception)
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+uno::Sequence< OUString > SAL_CALL LOKInteractionHandler::getSupportedServiceNames() throw (uno::RuntimeException, std::exception)
+{
+ uno::Sequence< OUString > aNames(3);
+ aNames[0] = "com.sun.star.task.InteractionHandler";
+ // added to indicate support for configuration.backend.MergeRecoveryRequest
+ aNames[1] = "com.sun.star.configuration.backend.InteractionHandler";
+ aNames[2] = "com.sun.star.uui.InteractionHandler";
+ // for backwards compatibility
+ return aNames;
+}
+
+void SAL_CALL LOKInteractionHandler::initialize(uno::Sequence<uno::Any> const & /*rArguments*/) throw (uno::Exception, std::exception)
+{
+}
+
+void SAL_CALL LOKInteractionHandler::handle(uno::Reference<task::XInteractionRequest> const & rRequest) throw (uno::RuntimeException, std::exception)
+{
+ // just do the same thing in both cases
+ handleInteractionRequest(rRequest);
+}
+
+sal_Bool SAL_CALL LOKInteractionHandler::handleInteractionRequest(const uno::Reference<task::XInteractionRequest >& rRequest) throw ( uno::RuntimeException, std::exception )
+{
+ uno::Sequence<uno::Reference<task::XInteractionContinuation>> const &rContinuations = rRequest->getContinuations();
+
+ // TODO: add LOK api that allows handling this for real, for the moment we
+ // just set the interaction as 'Approved'
+ for (sal_Int32 i = 0; i < rContinuations.getLength(); ++i)
+ {
+ uno::Reference<task::XInteractionApprove> xApprove(rContinuations[i], uno::UNO_QUERY);
+ if (xApprove.is())
+ xApprove->select();
+ }
+
+ return sal_True;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/source/lib/lokinteractionhandler.hxx b/desktop/source/lib/lokinteractionhandler.hxx
new file mode 100644
index 000000000000..6d4aa8231daf
--- /dev/null
+++ b/desktop/source/lib/lokinteractionhandler.hxx
@@ -0,0 +1,70 @@
+/* -*- 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_DESKTOP_SOURCE_LIB_LOKINTERACTIONHANDLER_HXX
+#define INCLUDED_DESKTOP_SOURCE_LIB_LOKINTERACTIONHANDLER_HXX
+
+#include <cppuhelper/implbase.hxx>
+
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/task/InteractionHandler.hpp>
+
+/** InteractionHandler is an interface that provides the user with various dialogs / error messages.
+
+We need an own implementation for the LibreOfficeKit so that we can route the
+information easily via callbacks.
+
+TODO: the callbacks are not implemented yet, we just approve any interaction
+that we get.
+*/
+class LOKInteractionHandler: public cppu::WeakImplHelper<com::sun::star::lang::XServiceInfo,
+ com::sun::star::lang::XInitialization,
+ com::sun::star::task::XInteractionHandler2>
+{
+ LOKInteractionHandler(const LOKInteractionHandler&) SAL_DELETED_FUNCTION;
+ LOKInteractionHandler& operator=(const LOKInteractionHandler&) SAL_DELETED_FUNCTION;
+
+public:
+ explicit LOKInteractionHandler(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const & rxContext);
+
+ virtual ~LOKInteractionHandler();
+
+ virtual OUString SAL_CALL getImplementationName()
+ throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+ virtual sal_Bool SAL_CALL supportsService(OUString const & rServiceName)
+ throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+ virtual com::sun::star::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
+ throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+ virtual void SAL_CALL initialize(com::sun::star::uno::Sequence<com::sun::star::uno::Any > const & rArguments)
+ throw (com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
+
+ virtual void SAL_CALL handle(com::sun::star::uno::Reference<com::sun::star::task::XInteractionRequest> const & rRequest)
+ throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+ virtual sal_Bool SAL_CALL handleInteractionRequest(const ::com::sun::star::uno::Reference<::com::sun::star::task::XInteractionRequest>& _Request)
+ throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */