|
UDK 3.2.7 C/C++ API Reference
|
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 00020 #ifndef INCLUDED_cppu_Map_hxx 00021 #define INCLUDED_cppu_Map_hxx 00022 00023 #include <uno/mapping.hxx> 00024 00025 00026 namespace cssu = com::sun::star::uno; 00027 00028 namespace cppu 00029 { 00041 template<class T> inline T * mapOut(T * pT, cssu::Environment const & outerEnv) 00042 { 00043 cssu::Mapping curr2outer(cssu::Environment::getCurrent(), outerEnv); 00044 00045 return reinterpret_cast<T *>(curr2outer.mapInterface(pT, getCppuType((cssu::Reference<T> *)NULL))); 00046 } 00047 00048 00056 template<class T> inline T * mapIn(T * pT, cssu::Environment const & outerEnv) 00057 { 00058 cssu::Mapping outer2curr(outerEnv, cssu::Environment::getCurrent()); 00059 00060 return reinterpret_cast<T *>(outer2curr.mapInterface(pT, getCppuType((cssu::Reference<T> *)NULL))); 00061 } 00062 00063 00071 // Problem: any gets assigned to something, acquire/releases may be called in wrong env. 00072 inline void mapOutAny(cssu::Any const & any, cssu::Any * res, cssu::Environment const & outerEnv) 00073 { 00074 cssu::Mapping curr2outer(cssu::Environment::getCurrent(), outerEnv); 00075 00076 uno_any_destruct(res, (uno_ReleaseFunc)cssu::cpp_release); 00077 uno_type_any_constructAndConvert( 00078 res, 00079 const_cast<void *>(any.getValue()), 00080 any.getValueTypeRef(), 00081 curr2outer.get()); 00082 } 00083 00084 00092 inline void mapInAny(cssu::Any const & any, cssu::Any * res, cssu::Environment const & outerEnv) 00093 { 00094 cssu::Mapping outer2curr(outerEnv, cssu::Environment::getCurrent()); 00095 00096 uno_any_destruct(res, (uno_ReleaseFunc)cssu::cpp_release); 00097 uno_type_any_constructAndConvert( 00098 res, 00099 const_cast<void *>(any.getValue()), 00100 any.getValueTypeRef(), 00101 outer2curr.get()); 00102 } 00103 } 00104 00105 #endif 00106 00107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
1.7.3