2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-12 17:21:24 +00:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2009-01-02 15:26:18 +00:00
|
|
|
|
2010-02-12 16:56:44 +01:00
|
|
|
#include <dispatch/startmoduledispatcher.hxx>
|
|
|
|
|
2009-01-02 15:26:18 +00:00
|
|
|
#include <pattern/frame.hxx>
|
2010-10-29 15:36:30 +02:00
|
|
|
#include <framework/framelistanalyzer.hxx>
|
2009-01-02 15:26:18 +00:00
|
|
|
#include <targets.h>
|
|
|
|
#include <services.h>
|
|
|
|
#include <general.h>
|
2017-10-23 22:41:08 +02:00
|
|
|
#include "isstartmoduledispatch.hxx"
|
2009-01-02 15:26:18 +00:00
|
|
|
|
2012-12-14 12:58:00 +02:00
|
|
|
#include <com/sun/star/frame/Desktop.hpp>
|
2009-01-02 15:26:18 +00:00
|
|
|
#include <com/sun/star/frame/XController.hpp>
|
2013-01-07 16:19:36 +02:00
|
|
|
#include <com/sun/star/frame/StartModule.hpp>
|
2009-01-02 15:26:18 +00:00
|
|
|
#include <com/sun/star/awt/XTopWindow.hpp>
|
2014-05-10 18:15:21 +02:00
|
|
|
#include <com/sun/star/beans/XFastPropertySet.hpp>
|
2009-01-02 15:26:18 +00:00
|
|
|
|
|
|
|
#include <toolkit/helper/vclunohelper.hxx>
|
|
|
|
#include <vcl/window.hxx>
|
|
|
|
#include <vcl/svapp.hxx>
|
2009-10-06 07:38:24 +02:00
|
|
|
#include <unotools/moduleoptions.hxx>
|
2012-12-14 12:58:00 +02:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2009-01-02 15:26:18 +00:00
|
|
|
|
|
|
|
namespace framework{
|
|
|
|
|
|
|
|
#ifdef fpf
|
|
|
|
#error "Who uses \"fpf\" as define. It will overwrite my namespace alias ..."
|
|
|
|
#endif
|
|
|
|
|
2015-11-20 10:12:32 +02:00
|
|
|
StartModuleDispatcher::StartModuleDispatcher(const css::uno::Reference< css::uno::XComponentContext >& rxContext)
|
2014-03-18 09:42:35 +01:00
|
|
|
: m_xContext (rxContext )
|
2009-01-02 15:26:18 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
StartModuleDispatcher::~StartModuleDispatcher()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL StartModuleDispatcher::dispatch(const css::util::URL& aURL ,
|
|
|
|
const css::uno::Sequence< css::beans::PropertyValue >& lArguments)
|
|
|
|
{
|
|
|
|
dispatchWithNotification(aURL, lArguments, css::uno::Reference< css::frame::XDispatchResultListener >());
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL StartModuleDispatcher::dispatchWithNotification(const css::util::URL& aURL ,
|
|
|
|
const css::uno::Sequence< css::beans::PropertyValue >& /*lArguments*/,
|
|
|
|
const css::uno::Reference< css::frame::XDispatchResultListener >& xListener )
|
2010-02-12 16:56:44 +01:00
|
|
|
{
|
|
|
|
::sal_Int16 nResult = css::frame::DispatchResultState::DONTKNOW;
|
2016-04-18 17:32:45 +02:00
|
|
|
if (isStartModuleDispatch(aURL))
|
2010-02-12 16:56:44 +01:00
|
|
|
{
|
|
|
|
nResult = css::frame::DispatchResultState::FAILURE;
|
|
|
|
if (implts_isBackingModePossible ())
|
|
|
|
{
|
|
|
|
if (implts_establishBackingMode ())
|
2009-01-02 15:26:18 +00:00
|
|
|
nResult = css::frame::DispatchResultState::SUCCESS;
|
2010-02-12 16:56:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-02 15:26:18 +00:00
|
|
|
implts_notifyResultListener(xListener, nResult, css::uno::Any());
|
|
|
|
}
|
|
|
|
|
|
|
|
css::uno::Sequence< ::sal_Int16 > SAL_CALL StartModuleDispatcher::getSupportedCommandGroups()
|
|
|
|
{
|
|
|
|
return css::uno::Sequence< ::sal_Int16 >();
|
|
|
|
}
|
|
|
|
|
|
|
|
css::uno::Sequence< css::frame::DispatchInformation > SAL_CALL StartModuleDispatcher::getConfigurableDispatchInformation(::sal_Int16 /*nCommandGroup*/)
|
|
|
|
{
|
|
|
|
return css::uno::Sequence< css::frame::DispatchInformation >();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL StartModuleDispatcher::addStatusListener(const css::uno::Reference< css::frame::XStatusListener >& /*xListener*/,
|
|
|
|
const css::util::URL& /*aURL*/ )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL StartModuleDispatcher::removeStatusListener(const css::uno::Reference< css::frame::XStatusListener >& /*xListener*/,
|
|
|
|
const css::util::URL& /*aURL*/ )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-04-04 15:53:21 +02:00
|
|
|
bool StartModuleDispatcher::implts_isBackingModePossible()
|
2010-02-12 16:56:44 +01:00
|
|
|
{
|
2015-04-07 10:59:56 +02:00
|
|
|
if ( ! SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::EModule::STARTMODULE))
|
2014-04-04 15:53:21 +02:00
|
|
|
return false;
|
2010-02-12 16:56:44 +01:00
|
|
|
|
|
|
|
css::uno::Reference< css::frame::XFramesSupplier > xDesktop(
|
2014-03-18 09:42:35 +01:00
|
|
|
css::frame::Desktop::create( m_xContext ), css::uno::UNO_QUERY);
|
2010-02-12 16:56:44 +01:00
|
|
|
|
|
|
|
FrameListAnalyzer aCheck(
|
|
|
|
xDesktop,
|
|
|
|
css::uno::Reference< css::frame::XFrame >(),
|
2017-02-16 08:16:45 +02:00
|
|
|
FrameAnalyzerFlags::Help | FrameAnalyzerFlags::BackingComponent);
|
2010-02-12 16:56:44 +01:00
|
|
|
|
2014-04-04 15:53:21 +02:00
|
|
|
bool bIsPossible = false;
|
2010-02-12 16:56:44 +01:00
|
|
|
|
2016-02-16 19:58:33 +02:00
|
|
|
if ( ! aCheck.m_xBackingComponent.is()
|
|
|
|
&& aCheck.m_lOtherVisibleFrames.empty() )
|
2010-02-12 16:56:44 +01:00
|
|
|
{
|
2014-04-04 15:53:21 +02:00
|
|
|
bIsPossible = true;
|
2010-02-12 16:56:44 +01:00
|
|
|
}
|
|
|
|
|
2009-01-02 15:26:18 +00:00
|
|
|
return bIsPossible;
|
2010-02-12 16:56:44 +01:00
|
|
|
}
|
2009-01-02 15:26:18 +00:00
|
|
|
|
2014-04-04 15:53:21 +02:00
|
|
|
bool StartModuleDispatcher::implts_establishBackingMode()
|
2009-01-02 15:26:18 +00:00
|
|
|
{
|
2014-03-18 09:42:35 +01:00
|
|
|
css::uno::Reference< css::frame::XDesktop2> xDesktop = css::frame::Desktop::create( m_xContext );
|
2013-01-07 16:19:36 +02:00
|
|
|
css::uno::Reference< css::frame::XFrame > xFrame = xDesktop->findFrame(SPECIALTARGET_BLANK, 0);
|
|
|
|
css::uno::Reference< css::awt::XWindow > xContainerWindow = xFrame->getContainerWindow();
|
2009-01-02 15:26:18 +00:00
|
|
|
|
2014-03-18 09:42:35 +01:00
|
|
|
css::uno::Reference< css::frame::XController > xStartModule = css::frame::StartModule::createWithParentWindow(m_xContext, xContainerWindow);
|
2009-01-02 15:26:18 +00:00
|
|
|
css::uno::Reference< css::awt::XWindow > xComponentWindow(xStartModule, css::uno::UNO_QUERY);
|
|
|
|
xFrame->setComponent(xComponentWindow, xStartModule);
|
|
|
|
xStartModule->attachFrame(xFrame);
|
2016-04-20 17:17:17 +02:00
|
|
|
xContainerWindow->setVisible(true);
|
2009-01-02 15:26:18 +00:00
|
|
|
|
2014-04-04 15:53:21 +02:00
|
|
|
return true;
|
2009-01-02 15:26:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void StartModuleDispatcher::implts_notifyResultListener(const css::uno::Reference< css::frame::XDispatchResultListener >& xListener,
|
|
|
|
::sal_Int16 nState ,
|
|
|
|
const css::uno::Any& aResult )
|
|
|
|
{
|
|
|
|
if ( ! xListener.is())
|
|
|
|
return;
|
|
|
|
|
|
|
|
css::frame::DispatchResultEvent aEvent(
|
|
|
|
css::uno::Reference< css::uno::XInterface >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY),
|
|
|
|
nState,
|
|
|
|
aResult);
|
|
|
|
|
|
|
|
xListener->dispatchFinished(aEvent);
|
2010-02-12 16:56:44 +01:00
|
|
|
}
|
2009-01-02 15:26:18 +00:00
|
|
|
|
|
|
|
} // namespace framework
|
2010-10-12 15:53:47 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|