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 .
|
|
|
|
*/
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
|
|
#include <classes/taskcreator.hxx>
|
2006-09-08 07:32:29 +00:00
|
|
|
#include <loadenv/targethelper.hxx>
|
2001-03-29 12:17:17 +00:00
|
|
|
#include <services.h>
|
2014-01-09 17:32:35 +01:00
|
|
|
#include <taskcreatordefs.hxx>
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2012-12-14 12:58:00 +02:00
|
|
|
#include <com/sun/star/frame/Desktop.hpp>
|
2013-05-27 13:05:48 +02:00
|
|
|
#include <com/sun/star/frame/TaskCreator.hpp>
|
2006-09-08 07:32:29 +00:00
|
|
|
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
|
2007-04-16 15:36:23 +00:00
|
|
|
#include <com/sun/star/beans/NamedValue.hpp>
|
|
|
|
|
2005-11-11 11:04:35 +00:00
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
|
2013-07-26 19:12:11 +02:00
|
|
|
#include <officecfg/Office/TabBrowse.hxx>
|
|
|
|
|
2000-09-18 15:33:13 +00:00
|
|
|
namespace framework{
|
|
|
|
|
2014-02-25 18:54:02 +01:00
|
|
|
/*-****************************************************************************************************
|
2013-12-20 11:25:37 +01:00
|
|
|
@short initialize instance with necessary information
|
2017-06-05 09:17:37 +02:00
|
|
|
@descr We need a valid uno service manager to create or instantiate new services.
|
2013-02-28 18:11:24 -04:00
|
|
|
All other information to create frames or tasks come in on right interface methods.
|
2002-05-23 11:54:59 +00:00
|
|
|
|
2013-05-21 17:38:02 +02:00
|
|
|
@param xContext
|
2002-05-23 11:54:59 +00:00
|
|
|
points to the valid uno service manager
|
|
|
|
*//*-*****************************************************************************************************/
|
2013-05-21 17:38:02 +02:00
|
|
|
TaskCreator::TaskCreator( const css::uno::Reference< css::uno::XComponentContext >& xContext )
|
2014-03-20 11:51:31 +01:00
|
|
|
: m_xContext ( xContext )
|
2002-05-23 11:54:59 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-02-25 18:54:02 +01:00
|
|
|
/*-****************************************************************************************************
|
2002-05-23 11:54:59 +00:00
|
|
|
@short deinitialize instance
|
2012-07-30 08:41:34 +02:00
|
|
|
@descr We should release all used resource which are not needed any longer.
|
2002-05-23 11:54:59 +00:00
|
|
|
*//*-*****************************************************************************************************/
|
|
|
|
TaskCreator::~TaskCreator()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-02-25 18:54:02 +01:00
|
|
|
/*-****************************************************************************************************
|
2006-09-08 07:32:29 +00:00
|
|
|
TODO document me
|
2002-05-23 11:54:59 +00:00
|
|
|
*//*-*****************************************************************************************************/
|
2018-01-17 17:24:35 +01:00
|
|
|
css::uno::Reference< css::frame::XFrame > TaskCreator::createTask( const OUString& sName, const utl::MediaDescriptor& rDescriptor )
|
2002-05-23 11:54:59 +00:00
|
|
|
{
|
2006-09-08 07:32:29 +00:00
|
|
|
css::uno::Reference< css::lang::XSingleServiceFactory > xCreator;
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sCreator = IMPLEMENTATIONNAME_FWK_TASKCREATOR;
|
2005-11-11 11:04:35 +00:00
|
|
|
|
2006-09-08 07:32:29 +00:00
|
|
|
try
|
|
|
|
{
|
2007-01-23 06:31:12 +00:00
|
|
|
if (
|
2017-02-06 09:15:51 +02:00
|
|
|
( TargetHelper::matchSpecialTarget(sName, TargetHelper::ESpecialTarget::Blank ) ) ||
|
|
|
|
( TargetHelper::matchSpecialTarget(sName, TargetHelper::ESpecialTarget::Default) )
|
2007-01-23 06:31:12 +00:00
|
|
|
)
|
|
|
|
{
|
2013-07-26 19:12:11 +02:00
|
|
|
|
2014-03-20 11:51:31 +01:00
|
|
|
boost::optional<OUString> x(officecfg::Office::TabBrowse::TaskCreatorService::ImplementationName::get(m_xContext));
|
2013-07-26 19:12:11 +02:00
|
|
|
if (x) sCreator = x.get();
|
2007-01-23 06:31:12 +00:00
|
|
|
}
|
|
|
|
|
2015-11-02 10:04:55 +02:00
|
|
|
xCreator.set( m_xContext->getServiceManager()->createInstanceWithContext(sCreator, m_xContext), css::uno::UNO_QUERY_THROW);
|
2006-09-08 07:32:29 +00:00
|
|
|
}
|
|
|
|
catch(const css::uno::Exception&)
|
2007-01-23 06:31:12 +00:00
|
|
|
{}
|
|
|
|
|
2014-04-18 00:26:02 +03:00
|
|
|
// no catch here ... without an task creator service we can't open ANY document window within the office.
|
2017-11-13 00:20:20 +01:00
|
|
|
// That's IMHO not a good idea. Then we should accept the stacktrace showing us the real problem.
|
2007-01-23 06:31:12 +00:00
|
|
|
// BTW: The used fallback creator service (IMPLEMENTATIONNAME_FWK_TASKCREATOR) is implemented in the same
|
|
|
|
// library then these class here ... Why we should not be able to create it ?
|
|
|
|
if ( ! xCreator.is())
|
2014-03-20 11:51:31 +01:00
|
|
|
xCreator = css::frame::TaskCreator::create(m_xContext);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2018-01-17 17:24:35 +01:00
|
|
|
css::uno::Sequence< css::uno::Any > lArgs(6);
|
2014-04-06 19:36:08 +03:00
|
|
|
css::beans::NamedValue aArg;
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2014-12-18 13:19:13 +01:00
|
|
|
aArg.Name = ARGUMENT_PARENTFRAME;
|
2014-03-20 11:51:31 +01:00
|
|
|
aArg.Value <<= css::uno::Reference< css::frame::XFrame >( css::frame::Desktop::create( m_xContext ), css::uno::UNO_QUERY_THROW);
|
2007-04-16 15:36:23 +00:00
|
|
|
lArgs[0] <<= aArg;
|
|
|
|
|
2014-12-18 13:19:13 +01:00
|
|
|
aArg.Name = ARGUMENT_CREATETOPWINDOW;
|
2016-04-20 17:17:17 +02:00
|
|
|
aArg.Value <<= true;
|
2007-04-16 15:36:23 +00:00
|
|
|
lArgs[1] <<= aArg;
|
|
|
|
|
2014-12-18 13:19:13 +01:00
|
|
|
aArg.Name = ARGUMENT_MAKEVISIBLE;
|
2016-03-23 09:53:05 +02:00
|
|
|
aArg.Value <<= false;
|
2007-04-16 15:36:23 +00:00
|
|
|
lArgs[2] <<= aArg;
|
|
|
|
|
2014-12-18 13:19:13 +01:00
|
|
|
aArg.Name = ARGUMENT_SUPPORTPERSISTENTWINDOWSTATE;
|
2016-04-20 17:17:17 +02:00
|
|
|
aArg.Value <<= true;
|
2007-04-16 15:36:23 +00:00
|
|
|
lArgs[3] <<= aArg;
|
|
|
|
|
2014-12-18 13:19:13 +01:00
|
|
|
aArg.Name = ARGUMENT_FRAMENAME;
|
2007-04-16 15:36:23 +00:00
|
|
|
aArg.Value <<= sName;
|
|
|
|
lArgs[4] <<= aArg;
|
2006-09-08 07:32:29 +00:00
|
|
|
|
2018-01-17 17:24:35 +01:00
|
|
|
bool bHidden
|
2018-02-06 11:36:35 +01:00
|
|
|
= rDescriptor.getUnpackedValueOrDefault("HiddenForConversion", false);
|
|
|
|
aArg.Name = "HiddenForConversion";
|
2018-01-17 17:24:35 +01:00
|
|
|
aArg.Value <<= bHidden;
|
|
|
|
lArgs[5] <<= aArg;
|
|
|
|
|
2007-04-16 15:36:23 +00:00
|
|
|
css::uno::Reference< css::frame::XFrame > xTask(xCreator->createInstanceWithArguments(lArgs), css::uno::UNO_QUERY_THROW);
|
2006-09-08 07:32:29 +00:00
|
|
|
return xTask;
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
|
2002-05-23 11:54:59 +00:00
|
|
|
} // namespace framework
|
2010-10-12 15:53:47 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|