Kaydet (Commit) f387ec16 authored tarafından Jan Holesovsky's avatar Jan Holesovsky

LOK: Implement an own trivial InteractionHandler.

So far it just selects 'Approve' for any interaction that is done through
that, later we want to route the information via callbacks to the caller.

Change-Id: I7ae3e2dcc04877b8b0197b0396299126e1217a2a
üst 341f5ce7
......@@ -123,6 +123,7 @@ endif
ifneq ($(filter $(OS),ANDROID IOS),)
$(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
......
......@@ -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,
......
/* -*- 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: */
/* -*- 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: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment