AlterOffice
AlterOffice 3.4 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 #ifndef INCLUDED_UNO_CURRENT_CONTEXT_HXX
4 #define INCLUDED_UNO_CURRENT_CONTEXT_HXX
5 
6 #include "sal/config.h"
7 
8 #include <cstddef>
9 
10 #include "uno/current_context.h"
11 #include "uno/lbnames.h"
12 
13 #include "com/sun/star/uno/XCurrentContext.hpp"
14 
15 
16 namespace com
17 {
18 namespace sun
19 {
20 namespace star
21 {
22 namespace uno
23 {
24 
33 {
35  ::rtl::OUString aEnvTypeName( CPPU_CURRENT_LANGUAGE_BINDING_NAME );
36  ::uno_getCurrentContext( reinterpret_cast<void **>(&xRet), aEnvTypeName.pData, NULL );
37  return xRet;
38 }
44 inline bool SAL_CALL setCurrentContext(
45  Reference< XCurrentContext > const & xContext )
46 {
47  ::rtl::OUString aEnvTypeName( CPPU_CURRENT_LANGUAGE_BINDING_NAME );
48  return ::uno_setCurrentContext( xContext.get(), aEnvTypeName.pData, NULL );
49 }
50 
56 {
59  ::rtl::OUString m_aEnvTypeName;
62  Reference< XCurrentContext > m_xPreviousContext;
63 
64 public:
69  inline ContextLayer(
73  inline ~ContextLayer();
74 
80  { return m_xPreviousContext; }
81 };
82 
84  : m_aEnvTypeName( CPPU_CURRENT_LANGUAGE_BINDING_NAME )
85 {
86  ::uno_getCurrentContext( reinterpret_cast<void **>(&m_xPreviousContext), m_aEnvTypeName.pData, NULL );
87  ::uno_setCurrentContext( xNewContext.get(), m_aEnvTypeName.pData, NULL );
88 }
89 
91 {
92  ::uno_setCurrentContext( m_xPreviousContext.get(), m_aEnvTypeName.pData, NULL );
93 }
94 
95 }
96 }
97 }
98 }
99 
100 #endif
101 
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ContextLayer(Reference< XCurrentContext > const &xNewContext=Reference< XCurrentContext >())
Constructor: Saves the previous context and sets the new (given) one.
Definition: current_context.hxx:83
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:182
Reference< XCurrentContext > getCurrentContext()
Getting the current context.
Definition: current_context.hxx:32
bool setCurrentContext(Reference< XCurrentContext > const &xContext)
Setting the current context.
Definition: current_context.hxx:44
Objects of this class are used for applying a current context until they are destructed, i.e.
Definition: current_context.hxx:55
Reference< XCurrentContext > getPreviousContext() const
Gets the previously set context.
Definition: current_context.hxx:79
pData
Definition: ustring.hxx:334
interface_type * get() const
Gets interface pointer.
Definition: Reference.h:383
~ContextLayer()
Destructor: restores the previous context.
Definition: current_context.hxx:90
CPPU_DLLPUBLIC sal_Bool uno_setCurrentContext(void *pCurrentContext, rtl_uString *pEnvDcp, void *pEnvContext) SAL_THROW_EXTERN_C()
Sets the current task&#39;s context.
CPPU_DLLPUBLIC sal_Bool uno_getCurrentContext(void **ppCurrentContext, rtl_uString *pEnvDcp, void *pEnvContext) SAL_THROW_EXTERN_C()
Gets the current task&#39;s context.