LibreOffice LibreOffice 6.0 SDK C/C++ API Reference

Map.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
20 #ifndef INCLUDED_CPPU_MAP_HXX
21 #define INCLUDED_CPPU_MAP_HXX
22
23 #include "uno/mapping.hxx"
24
25
26 namespace cppu
27 {
39 template<class T> inline T * mapOut(T * pT, css::uno::Environment const & outerEnv)
40 {
41 css::uno::Mapping curr2outer(css::uno::Environment::getCurrent(), outerEnv);
42
43 return reinterpret_cast<T *>(curr2outer.mapInterface(pT, cppu::UnoType<T>::get()));
44 }
45
46
54 template<class T> inline T * mapIn(T * pT, css::uno::Environment const & outerEnv)
55 {
56 css::uno::Mapping outer2curr(outerEnv, css::uno::Environment::getCurrent());
57
58 return reinterpret_cast<T *>(outer2curr.mapInterface(pT, cppu::UnoType<T>::get()));
59 }
60
61
69 // Problem: any gets assigned to something, acquire/releases may be called in wrong env.
70 inline void mapOutAny(css::uno::Any const & any, css::uno::Any * res, css::uno::Environment const & outerEnv)
71 {
72 css::uno::Mapping curr2outer(css::uno::Environment::getCurrent(), outerEnv);
73
74 uno_any_destruct(res, css::uno::cpp_release);
75 uno_type_any_constructAndConvert(
76 res,
77 const_cast<void *>(any.getValue()),
78 any.getValueTypeRef(),
79 curr2outer.get());
80 }
81
82
90 inline void mapInAny(css::uno::Any const & any, css::uno::Any * res, css::uno::Environment const & outerEnv)
91 {
92 css::uno::Mapping outer2curr(outerEnv, css::uno::Environment::getCurrent());
93
94 uno_any_destruct(res, css::uno::cpp_release);
95 uno_type_any_constructAndConvert(
96 res,
97 const_cast<void *>(any.getValue()),
98 any.getValueTypeRef(),
99 outer2curr.get());
100 }
101 }
102
103 #endif
104
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
cppu::mapOutAny
void mapOutAny(css::uno::Any const &any, css::uno::Any *res, css::uno::Environment const &outerEnv)
Maps an any from the current to an outer Environment, fills passed any.
Definition: Map.hxx:70
com::sun::star::uno::cpp_release
void cpp_release(void *pCppI)
Function to release a C++ interface.
Definition: genfunc.hxx:46
uno_any_destruct
CPPU_DLLPUBLIC void uno_any_destruct(uno_Any *pValue, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Destructs an any.
mapping.hxx
cppu::UnoType
Get the css::uno::Type instance representing a certain UNO type.
Definition: unotype.hxx:47
uno_type_any_constructAndConvert
CPPU_DLLPUBLIC void uno_type_any_constructAndConvert(uno_Any *pDest, void *pSource, struct _typelib_TypeDescriptionReference *pType, struct _uno_Mapping *mapping) SAL_THROW_EXTERN_C()
Constructs an any with a given value and converts/ maps interfaces.
cppu
Definition: Enterable.hxx:26
cppu::mapOut
T * mapOut(T *pT, css::uno::Environment const &outerEnv)
Helpers for mapping objects relative to the current environment.
Definition: Map.hxx:39
cppu::mapIn
T * mapIn(T *pT, css::uno::Environment const &outerEnv)
Maps an object from an outer Environment to the current, returns mapped object.
Definition: Map.hxx:54
cppu::mapInAny
void mapInAny(css::uno::Any const &any, css::uno::Any *res, css::uno::Environment const &outerEnv)
Maps an any from an outer Environment to the current, fills passed any.
Definition: Map.hxx:90