LibreOffice
LibreOffice 5.0 SDK C/C++ API Reference
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
uno
current_context.hxx
Go to the documentation of this file.
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
#ifndef INCLUDED_UNO_CURRENT_CONTEXT_HXX
20
#define INCLUDED_UNO_CURRENT_CONTEXT_HXX
21
22
#include <
uno/current_context.h
>
23
#include <
uno/lbnames.h
>
24
25
#include <com/sun/star/uno/XCurrentContext.hpp>
26
27
28
namespace
com
29
{
30
namespace
sun
31
{
32
namespace
star
33
{
34
namespace
uno
35
{
36
44
inline
Reference< XCurrentContext >
SAL_CALL
getCurrentContext
()
45
{
46
Reference< XCurrentContext >
xRet;
47
::rtl::OUString
aEnvTypeName( CPPU_CURRENT_LANGUAGE_BINDING_NAME );
48
::uno_getCurrentContext
( reinterpret_cast<void **>(&xRet), aEnvTypeName.pData, 0 );
49
return
xRet;
50
}
56
inline
bool
SAL_CALL
setCurrentContext
(
57
Reference< XCurrentContext >
const
& xContext )
58
{
59
::rtl::OUString
aEnvTypeName( CPPU_CURRENT_LANGUAGE_BINDING_NAME );
60
return
(::
uno_setCurrentContext
( xContext.
get
(), aEnvTypeName.pData, 0 ) !=
sal_False
);
61
}
62
67
class
ContextLayer
68
{
71
::rtl::OUString
m_aEnvTypeName;
74
Reference< XCurrentContext >
m_xPreviousContext;
75
76
public
:
81
inline
ContextLayer
(
82
Reference< XCurrentContext >
const
& xNewContext =
Reference< XCurrentContext >
() );
85
inline
~ContextLayer
();
86
91
inline
Reference< XCurrentContext >
SAL_CALL
getPreviousContext
()
const
92
{
return
m_xPreviousContext; }
93
};
94
95
inline
ContextLayer::ContextLayer
(
Reference< XCurrentContext >
const
& xNewContext )
96
: m_aEnvTypeName( CPPU_CURRENT_LANGUAGE_BINDING_NAME )
97
{
98
::uno_getCurrentContext
( reinterpret_cast<void **>(&m_xPreviousContext), m_aEnvTypeName.pData, 0 );
99
::uno_setCurrentContext
( xNewContext.
get
(), m_aEnvTypeName.pData, 0 );
100
}
101
102
inline
ContextLayer::~ContextLayer
()
103
{
104
::uno_setCurrentContext
( m_xPreviousContext.
get
(), m_aEnvTypeName.pData, 0 );
105
}
106
107
}
108
}
109
}
110
}
111
112
#endif
113
114
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Generated by
1.8.4