LibreOffice
LibreOffice 4.1 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 cssu = com::sun::star::uno;
27 
28 namespace cppu
29 {
41  template<class T> inline T * mapOut(T * pT, cssu::Environment const & outerEnv)
42  {
43  cssu::Mapping curr2outer(cssu::Environment::getCurrent(), outerEnv);
44 
45  return reinterpret_cast<T *>(curr2outer.mapInterface(pT, getCppuType((cssu::Reference<T> *)NULL)));
46  }
47 
48 
56  template<class T> inline T * mapIn(T * pT, cssu::Environment const & outerEnv)
57  {
58  cssu::Mapping outer2curr(outerEnv, cssu::Environment::getCurrent());
59 
60  return reinterpret_cast<T *>(outer2curr.mapInterface(pT, getCppuType((cssu::Reference<T> *)NULL)));
61  }
62 
63 
71  // Problem: any gets assigned to something, acquire/releases may be called in wrong env.
72  inline void mapOutAny(cssu::Any const & any, cssu::Any * res, cssu::Environment const & outerEnv)
73  {
74  cssu::Mapping curr2outer(cssu::Environment::getCurrent(), outerEnv);
75 
78  res,
79  const_cast<void *>(any.getValue()),
80  any.getValueTypeRef(),
81  curr2outer.get());
82  }
83 
84 
92  inline void mapInAny(cssu::Any const & any, cssu::Any * res, cssu::Environment const & outerEnv)
93  {
94  cssu::Mapping outer2curr(outerEnv, cssu::Environment::getCurrent());
95 
98  res,
99  const_cast<void *>(any.getValue()),
100  any.getValueTypeRef(),
101  outer2curr.get());
102  }
103 }
104 
105 #endif
106 
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */