1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_comphelper.hxx"
31 /** === begin UNO includes === **/
32 #include "com/sun/star/frame/XDispatchProvider.hpp"
33 #include "com/sun/star/frame/XSynchronousDispatch.hpp"
34 #include "com/sun/star/lang/XComponent.hpp"
35 #include "com/sun/star/lang/XMultiServiceFactory.hpp"
36 #include "com/sun/star/util/XURLTransformer.hpp"
37 /** === end UNO includes === **/
39 #include "comphelper/synchronousdispatch.hxx"
40 #include "comphelper/processfactory.hxx"
42 #define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
44 //.........................................................................
47 //.........................................................................
49 using namespace ::com::sun::star
;
51 //====================================================================
52 //= SynchronousDispatch
53 //====================================================================
55 uno::Reference
< lang::XComponent
> SynchronousDispatch::dispatch(
56 const uno::Reference
< uno::XInterface
> &xStartPoint
,
57 const rtl::OUString
&sURL
,
58 const rtl::OUString
&sTarget
,
59 const sal_Int32 nFlags
,
60 const uno::Sequence
< beans::PropertyValue
> &lArguments
)
64 uno::Reference
< util::XURLTransformer
> xTrans( ::comphelper::getProcessServiceFactory()->createInstance(
65 UNISTRING("com.sun.star.util.URLTransformer" )),
68 xTrans
->parseStrict( aURL
);
70 uno::Reference
< frame::XDispatch
> xDispatcher
;
71 uno::Reference
< frame::XDispatchProvider
> xProvider( xStartPoint
, uno::UNO_QUERY
);
74 xDispatcher
= xProvider
->queryDispatch( aURL
, sTarget
, nFlags
);
76 uno::Reference
< lang::XComponent
> aComponent
;
78 if ( xDispatcher
.is() )
83 uno::Reference
< frame::XSynchronousDispatch
> xSyncDisp( xDispatcher
, uno::UNO_QUERY_THROW
);
85 aRet
= xSyncDisp
->dispatchWithReturnValue( aURL
, lArguments
);
89 catch ( uno::Exception
& )
91 rtl::OUString aMsg
= UNISTRING( "SynchronousDispatch::dispatch() Error while dispatching! ");
92 OSL_ENSURE( sal_False
, OUStringToOString(aMsg
, RTL_TEXTENCODING_ASCII_US
).getStr());
99 //.........................................................................
100 } // namespace comphelper
101 //.........................................................................