tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / framework / source / classes / taskcreator.cxx
blobf84bcb711467f9f26631f11314b337a28e37a2ae
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <classes/taskcreator.hxx>
21 #include <services.h>
22 #include <taskcreatordefs.hxx>
24 #include <com/sun/star/frame/Desktop.hpp>
25 #include <com/sun/star/frame/TaskCreator.hpp>
26 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
27 #include <com/sun/star/beans/NamedValue.hpp>
28 #include <utility>
30 namespace framework{
32 /*-****************************************************************************************************
33 @short initialize instance with necessary information
34 @descr We need a valid uno service manager to create or instantiate new services.
35 All other information to create frames or tasks come in on right interface methods.
37 @param xContext
38 points to the valid uno service manager
39 *//*-*****************************************************************************************************/
40 TaskCreator::TaskCreator( css::uno::Reference< css::uno::XComponentContext > xContext )
41 : m_xContext (std::move( xContext ))
45 /*-****************************************************************************************************
46 @short deinitialize instance
47 @descr We should release all used resource which are not needed any longer.
48 *//*-*****************************************************************************************************/
49 TaskCreator::~TaskCreator()
53 /*-****************************************************************************************************
54 TODO document me
55 *//*-*****************************************************************************************************/
56 css::uno::Reference< css::frame::XFrame > TaskCreator::createTask( const OUString& sName, const utl::MediaDescriptor& rDescriptor )
58 css::uno::Reference< css::lang::XSingleServiceFactory > xCreator;
60 try
62 xCreator.set( m_xContext->getServiceManager()->createInstanceWithContext(IMPLEMENTATIONNAME_FWK_TASKCREATOR, m_xContext), css::uno::UNO_QUERY_THROW);
64 catch(const css::uno::Exception&)
67 // no catch here ... without a task creator service we can't open ANY document window within the office.
68 // That's IMHO not a good idea. Then we should accept the stacktrace showing us the real problem.
69 // BTW: The used fallback creator service (IMPLEMENTATIONNAME_FWK_TASKCREATOR) is implemented in the same
70 // library then these class here ... Why we should not be able to create it ?
71 if ( ! xCreator.is())
72 xCreator = css::frame::TaskCreator::create(m_xContext);
74 css::uno::Sequence< css::uno::Any > lArgs
76 css::uno::Any(css::beans::NamedValue(ARGUMENT_PARENTFRAME, css::uno::Any(css::uno::Reference< css::frame::XFrame >( css::frame::Desktop::create( m_xContext ), css::uno::UNO_QUERY_THROW)))) ,
77 css::uno::Any(css::beans::NamedValue(ARGUMENT_CREATETOPWINDOW, css::uno::Any(true))),
78 css::uno::Any(css::beans::NamedValue(ARGUMENT_MAKEVISIBLE, css::uno::Any(false))),
79 css::uno::Any(css::beans::NamedValue(ARGUMENT_SUPPORTPERSISTENTWINDOWSTATE, css::uno::Any(true))),
80 css::uno::Any(css::beans::NamedValue(ARGUMENT_FRAMENAME, css::uno::Any(sName))),
81 css::uno::Any(css::beans::NamedValue(ARGUMENT_HIDDENFORCONVERSION, css::uno::Any(rDescriptor.getUnpackedValueOrDefault(ARGUMENT_HIDDENFORCONVERSION, false))))
83 css::uno::Reference< css::frame::XFrame > xTask(xCreator->createInstanceWithArguments(lArgs), css::uno::UNO_QUERY_THROW);
84 return xTask;
87 } // namespace framework
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */