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>
|
2007-04-16 15:36:23 +00:00
|
|
|
#include "services/taskcreatorsrv.hxx"
|
2002-05-23 11:54:59 +00:00
|
|
|
#include <threadhelp/readguard.hxx>
|
2006-09-08 07:32:29 +00:00
|
|
|
#include <loadenv/targethelper.hxx>
|
2001-03-29 12:17:17 +00:00
|
|
|
#include <services.h>
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2012-12-14 12:58:00 +02:00
|
|
|
#include <com/sun/star/frame/Desktop.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>
|
|
|
|
|
2006-09-08 07:32:29 +00:00
|
|
|
#include <comphelper/configurationhelper.hxx>
|
2005-11-11 11:04:35 +00:00
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
|
2000-09-18 15:33:13 +00:00
|
|
|
namespace framework{
|
|
|
|
|
2002-05-23 11:54:59 +00:00
|
|
|
/*-****************************************************************************************************//**
|
|
|
|
@short initialize instance with neccessary informations
|
|
|
|
@descr We need a valid uno service manager to create or instanciate 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
|
|
|
|
|
|
|
@param xSMGR
|
|
|
|
points to the valid uno service manager
|
|
|
|
*//*-*****************************************************************************************************/
|
|
|
|
TaskCreator::TaskCreator( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR )
|
|
|
|
: ThreadHelpBase( )
|
|
|
|
, m_xSMGR ( xSMGR )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-****************************************************************************************************//**
|
|
|
|
@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()
|
|
|
|
{
|
2006-09-08 07:32:29 +00:00
|
|
|
m_xSMGR.clear();
|
2002-05-23 11:54:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-****************************************************************************************************//**
|
2006-09-08 07:32:29 +00:00
|
|
|
TODO document me
|
2002-05-23 11:54:59 +00:00
|
|
|
*//*-*****************************************************************************************************/
|
|
|
|
css::uno::Reference< css::frame::XFrame > TaskCreator::createTask( const ::rtl::OUString& sName ,
|
|
|
|
sal_Bool bVisible )
|
|
|
|
{
|
|
|
|
/* SAFE { */
|
|
|
|
ReadGuard aReadLock( m_aLock );
|
|
|
|
css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR;
|
|
|
|
aReadLock.unlock();
|
|
|
|
/* } SAFE */
|
2005-11-11 11:04:35 +00:00
|
|
|
|
2006-09-08 07:32:29 +00:00
|
|
|
css::uno::Reference< css::lang::XSingleServiceFactory > xCreator;
|
|
|
|
::rtl::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 (
|
|
|
|
( TargetHelper::matchSpecialTarget(sName, TargetHelper::E_BLANK ) ) ||
|
|
|
|
( TargetHelper::matchSpecialTarget(sName, TargetHelper::E_DEFAULT) )
|
|
|
|
)
|
|
|
|
{
|
2012-10-16 14:05:41 +02:00
|
|
|
::comphelper::ConfigurationHelper::readDirectKey(
|
|
|
|
comphelper::getComponentContext(xSMGR),
|
2012-06-25 12:50:46 +01:00
|
|
|
"org.openoffice.Office.TabBrowse",
|
|
|
|
"TaskCreatorService",
|
|
|
|
"ImplementationName",
|
|
|
|
::comphelper::ConfigurationHelper::E_READONLY) >>= sCreator;
|
2007-01-23 06:31:12 +00:00
|
|
|
}
|
|
|
|
|
2006-09-08 07:32:29 +00:00
|
|
|
xCreator = css::uno::Reference< css::lang::XSingleServiceFactory >(
|
|
|
|
xSMGR->createInstance(sCreator), css::uno::UNO_QUERY_THROW);
|
|
|
|
}
|
|
|
|
catch(const css::uno::Exception&)
|
2007-01-23 06:31:12 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
// no catch here ... without an task creator service we cant open ANY document window within the office.
|
|
|
|
// Thats IMHO not a good idea. Then we should accept the stacktrace showing us the real problem.
|
|
|
|
// 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())
|
2006-09-08 07:32:29 +00:00
|
|
|
xCreator = css::uno::Reference< css::lang::XSingleServiceFactory >(
|
|
|
|
xSMGR->createInstance(IMPLEMENTATIONNAME_FWK_TASKCREATOR), css::uno::UNO_QUERY_THROW);
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2007-04-16 15:36:23 +00:00
|
|
|
css::uno::Sequence< css::uno::Any > lArgs(5);
|
|
|
|
css::beans::NamedValue aArg ;
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2012-04-01 21:25:49 +01:00
|
|
|
aArg.Name = rtl::OUString(ARGUMENT_PARENTFRAME);
|
2012-12-14 12:58:00 +02:00
|
|
|
aArg.Value <<= css::uno::Reference< css::frame::XFrame >( css::frame::Desktop::create( comphelper::getComponentContext(xSMGR) ), css::uno::UNO_QUERY_THROW);
|
2007-04-16 15:36:23 +00:00
|
|
|
lArgs[0] <<= aArg;
|
|
|
|
|
2012-04-01 21:25:49 +01:00
|
|
|
aArg.Name = rtl::OUString(ARGUMENT_CREATETOPWINDOW);
|
2007-04-16 15:36:23 +00:00
|
|
|
aArg.Value <<= sal_True;
|
|
|
|
lArgs[1] <<= aArg;
|
|
|
|
|
2012-04-01 21:25:49 +01:00
|
|
|
aArg.Name = rtl::OUString(ARGUMENT_MAKEVISIBLE);
|
2007-04-16 15:36:23 +00:00
|
|
|
aArg.Value <<= bVisible;
|
|
|
|
lArgs[2] <<= aArg;
|
|
|
|
|
2012-04-01 21:25:49 +01:00
|
|
|
aArg.Name = rtl::OUString(ARGUMENT_SUPPORTPERSISTENTWINDOWSTATE);
|
2007-04-16 15:36:23 +00:00
|
|
|
aArg.Value <<= sal_True;
|
|
|
|
lArgs[3] <<= aArg;
|
|
|
|
|
2012-04-01 21:25:49 +01:00
|
|
|
aArg.Name = rtl::OUString(ARGUMENT_FRAMENAME);
|
2007-04-16 15:36:23 +00:00
|
|
|
aArg.Value <<= sName;
|
|
|
|
lArgs[4] <<= aArg;
|
2006-09-08 07:32:29 +00:00
|
|
|
|
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: */
|