1*37adc4f0SAndrew Rist /**************************************************************
2*37adc4f0SAndrew Rist *
3*37adc4f0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*37adc4f0SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*37adc4f0SAndrew Rist * distributed with this work for additional information
6*37adc4f0SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*37adc4f0SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*37adc4f0SAndrew Rist * "License"); you may not use this file except in compliance
9*37adc4f0SAndrew Rist * with the License. You may obtain a copy of the License at
10*37adc4f0SAndrew Rist *
11*37adc4f0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*37adc4f0SAndrew Rist *
13*37adc4f0SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*37adc4f0SAndrew Rist * software distributed under the License is distributed on an
15*37adc4f0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*37adc4f0SAndrew Rist * KIND, either express or implied. See the License for the
17*37adc4f0SAndrew Rist * specific language governing permissions and limitations
18*37adc4f0SAndrew Rist * under the License.
19*37adc4f0SAndrew Rist *
20*37adc4f0SAndrew Rist *************************************************************/
21*37adc4f0SAndrew Rist
22*37adc4f0SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #include "sal/config.h"
25cdf0e10cSrcweir
26cdf0e10cSrcweir #include "com/sun/star/uno/Reference.hxx"
27cdf0e10cSrcweir #include "com/sun/star/uno/RuntimeException.hpp"
28cdf0e10cSrcweir #include "com/sun/star/uno/XInterface.hpp"
29cdf0e10cSrcweir #include "rtl/ustring.h"
30cdf0e10cSrcweir #include "rtl/ustring.hxx"
31cdf0e10cSrcweir #include "uno/current_context.h"
32cdf0e10cSrcweir #include "uno/dispatcher.hxx"
33cdf0e10cSrcweir #include "uno/lbnames.h"
34cdf0e10cSrcweir
35cdf0e10cSrcweir #include "currentcontext.hxx"
36cdf0e10cSrcweir
37cdf0e10cSrcweir namespace binaryurp {
38cdf0e10cSrcweir
39cdf0e10cSrcweir namespace {
40cdf0e10cSrcweir
41cdf0e10cSrcweir namespace css = com::sun::star;
42cdf0e10cSrcweir
43cdf0e10cSrcweir }
44cdf0e10cSrcweir
45cdf0e10cSrcweir namespace current_context {
46cdf0e10cSrcweir
get()47cdf0e10cSrcweir css::uno::UnoInterfaceReference get() {
48cdf0e10cSrcweir css::uno::UnoInterfaceReference cc;
49cdf0e10cSrcweir if (!uno_getCurrentContext(
50cdf0e10cSrcweir reinterpret_cast< void ** >(&cc.m_pUnoI),
51cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO)).pData, 0))
52cdf0e10cSrcweir {
53cdf0e10cSrcweir throw css::uno::RuntimeException(
54cdf0e10cSrcweir rtl::OUString(
55cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("uno_getCurrentContext failed")),
56cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface >());
57cdf0e10cSrcweir }
58cdf0e10cSrcweir return cc;
59cdf0e10cSrcweir }
60cdf0e10cSrcweir
set(css::uno::UnoInterfaceReference const & value)61cdf0e10cSrcweir void set(css::uno::UnoInterfaceReference const & value) {
62cdf0e10cSrcweir css::uno::UnoInterfaceReference cc(value);
63cdf0e10cSrcweir if (!uno_setCurrentContext(
64cdf0e10cSrcweir cc.m_pUnoI,
65cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO)).pData, 0))
66cdf0e10cSrcweir {
67cdf0e10cSrcweir throw css::uno::RuntimeException(
68cdf0e10cSrcweir rtl::OUString(
69cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("uno_setCurrentContext failed")),
70cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface >());
71cdf0e10cSrcweir }
72cdf0e10cSrcweir }
73cdf0e10cSrcweir
74cdf0e10cSrcweir }
75cdf0e10cSrcweir
76cdf0e10cSrcweir }
77