UDK 3.2.7 C/C++ API Reference

uno/current_context.hxx

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /*
00003  * This file is part of the LibreOffice project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * This file incorporates work covered by the following license notice:
00010  *
00011  *   Licensed to the Apache Software Foundation (ASF) under one or more
00012  *   contributor license agreements. See the NOTICE file distributed
00013  *   with this work for additional information regarding copyright
00014  *   ownership. The ASF licenses this file to you under the Apache
00015  *   License, Version 2.0 (the "License"); you may not use this file
00016  *   except in compliance with the License. You may obtain a copy of
00017  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
00018  */
00019 #ifndef _UNO_CURRENT_CONTEXT_HXX_
00020 #define _UNO_CURRENT_CONTEXT_HXX_
00021 
00022 #include <uno/current_context.h>
00023 
00024 #include <com/sun/star/uno/XCurrentContext.hpp>
00025 
00026 
00027 namespace com
00028 {
00029 namespace sun
00030 {
00031 namespace star
00032 {
00033 namespace uno
00034 {
00035 
00043 inline Reference< XCurrentContext > SAL_CALL getCurrentContext()
00044     SAL_THROW(())
00045 {
00046     Reference< XCurrentContext > xRet;
00047     ::rtl::OUString aEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) );
00048     ::uno_getCurrentContext( (void **)&xRet, aEnvTypeName.pData, 0 );
00049     return xRet;
00050 }
00056 inline bool SAL_CALL setCurrentContext(
00057     Reference< XCurrentContext > const & xContext )
00058     SAL_THROW(())
00059 {
00060     ::rtl::OUString aEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) );
00061     return (::uno_setCurrentContext( xContext.get(), aEnvTypeName.pData, 0 ) != sal_False);
00062 }
00063 
00068 class ContextLayer
00069 {
00072     ::rtl::OUString m_aEnvTypeName;
00075     Reference< XCurrentContext > m_xPreviousContext;
00076 
00077 public:
00082     inline ContextLayer(
00083         Reference< XCurrentContext > const & xNewContext = Reference< XCurrentContext >() )
00084         SAL_THROW(());
00087     inline ~ContextLayer() SAL_THROW(());
00088 
00093     inline Reference< XCurrentContext > SAL_CALL getPreviousContext() const
00094         SAL_THROW(())
00095         { return m_xPreviousContext; }
00096 };
00097 //__________________________________________________________________________________________________
00098 inline ContextLayer::ContextLayer( Reference< XCurrentContext > const & xNewContext )
00099     SAL_THROW(())
00100     : m_aEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) )
00101 {
00102     ::uno_getCurrentContext( (void **)&m_xPreviousContext, m_aEnvTypeName.pData, 0 );
00103     ::uno_setCurrentContext( xNewContext.get(), m_aEnvTypeName.pData, 0 );
00104 }
00105 //__________________________________________________________________________________________________
00106 inline ContextLayer::~ContextLayer()
00107     SAL_THROW(())
00108 {
00109     ::uno_setCurrentContext( m_xPreviousContext.get(), m_aEnvTypeName.pData, 0 );
00110 }
00111 
00112 }
00113 }
00114 }
00115 }
00116 
00117 #endif
00118 
00119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines