/src/libreoffice/comphelper/source/misc/synchronousdispatch.cxx
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | |
21 | | #include <com/sun/star/frame/XDispatchProvider.hpp> |
22 | | #include <com/sun/star/frame/XSynchronousDispatch.hpp> |
23 | | #include <com/sun/star/lang/XComponent.hpp> |
24 | | #include <com/sun/star/util/URLTransformer.hpp> |
25 | | |
26 | | #include <comphelper/synchronousdispatch.hxx> |
27 | | #include <comphelper/processfactory.hxx> |
28 | | #include <sal/log.hxx> |
29 | | |
30 | | namespace comphelper |
31 | | { |
32 | | |
33 | | |
34 | | using namespace ::com::sun::star; |
35 | | |
36 | | uno::Reference< lang::XComponent > SynchronousDispatch::dispatch( |
37 | | const uno::Reference< uno::XInterface > &xStartPoint, |
38 | | const OUString &sURL, |
39 | | const OUString &sTarget, |
40 | | const uno::Sequence< beans::PropertyValue > &lArguments ) |
41 | 0 | { |
42 | 0 | util::URL aURL; |
43 | 0 | aURL.Complete = sURL; |
44 | 0 | uno::Reference < util::XURLTransformer > xTrans = util::URLTransformer::create( ::comphelper::getProcessComponentContext() ); |
45 | 0 | xTrans->parseStrict( aURL ); |
46 | |
|
47 | 0 | uno::Reference < frame::XDispatch > xDispatcher; |
48 | 0 | uno::Reference < frame::XDispatchProvider > xProvider( xStartPoint, uno::UNO_QUERY ); |
49 | |
|
50 | 0 | if ( xProvider.is() ) |
51 | 0 | xDispatcher = xProvider->queryDispatch( aURL, sTarget, 0 ); |
52 | |
|
53 | 0 | uno::Reference < lang::XComponent > aComponent; |
54 | |
|
55 | 0 | if ( xDispatcher.is() ) |
56 | 0 | { |
57 | 0 | try |
58 | 0 | { |
59 | 0 | uno::Any aRet; |
60 | 0 | uno::Reference < frame::XSynchronousDispatch > xSyncDisp( xDispatcher, uno::UNO_QUERY_THROW ); |
61 | |
|
62 | 0 | aRet = xSyncDisp->dispatchWithReturnValue( aURL, lArguments ); |
63 | |
|
64 | 0 | aRet >>= aComponent; |
65 | 0 | } |
66 | 0 | catch ( uno::Exception& ) |
67 | 0 | { |
68 | | // can't use TOOLS_WARN_EXCEPTION, as comphelper is used by libtl! |
69 | 0 | SAL_WARN("comphelper", "SynchronousDispatch::dispatch(): error while dispatching '" |
70 | 0 | << sURL << "' for '" << sTarget << "'!"); |
71 | 0 | } |
72 | 0 | } |
73 | | |
74 | 0 | return aComponent; |
75 | 0 | } |
76 | | |
77 | | |
78 | | } // namespace comphelper |
79 | | |
80 | | |
81 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |