LibreOffice Module comphelper (master)  1
types.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_COMPHELPER_TYPES_HXX
21 #define INCLUDED_COMPHELPER_TYPES_HXX
22 
23 #include <com/sun/star/uno/Reference.hxx>
24 #include <com/sun/star/lang/XComponent.hpp>
25 #include <com/sun/star/lang/XUnoTunnel.hpp>
27 
28 namespace com { namespace sun { namespace star { namespace awt {
29  struct FontDescriptor;
30 } } } }
31 
32 namespace com { namespace sun { namespace star { namespace uno { class Any; } } } }
33 namespace com { namespace sun { namespace star { namespace uno { class XInterface; } } } }
34 
35 
36 namespace comphelper
37 {
39  COMPHELPER_DLLPUBLIC bool isAssignableFrom(const css::uno::Type& _rAssignable, const css::uno::Type& _rFrom);
40 
43  template <class TYPE>
44  void disposeComponent(css::uno::Reference<TYPE>& _rxComp)
45  {
46  css::uno::Reference<css::lang::XComponent> xComp(_rxComp, css::uno::UNO_QUERY);
47  if (xComp.is())
48  {
49  xComp->dispose();
50  _rxComp = nullptr;
51  }
52  }
53 
54 
59  COMPHELPER_DLLPUBLIC css::awt::FontDescriptor getDefaultFont();
60 
63  COMPHELPER_DLLPUBLIC css::uno::Type getSequenceElementType(const css::uno::Type& _rSequenceType);
64 
65 
66 //= replacement of the former UsrAny.getXXX methods
67 
68  // may be used if you need the return value just as temporary, else it's may be too inefficient...
69 
70  // no, we don't use templates here. This would lead to a lot of implicit uses of the conversion methods,
71  // which would be difficult to trace...
72 
73  COMPHELPER_DLLPUBLIC sal_Int64 getINT64(const css::uno::Any& _rAny);
74  COMPHELPER_DLLPUBLIC sal_Int32 getINT32(const css::uno::Any& _rAny);
75  COMPHELPER_DLLPUBLIC sal_Int16 getINT16(const css::uno::Any& _rAny);
76  COMPHELPER_DLLPUBLIC double getDouble(const css::uno::Any& _rAny);
77  COMPHELPER_DLLPUBLIC float getFloat(const css::uno::Any& _rAny);
78  COMPHELPER_DLLPUBLIC OUString getString(const css::uno::Any& _rAny);
79  COMPHELPER_DLLPUBLIC bool getBOOL(const css::uno::Any& _rAny);
80 
82  COMPHELPER_DLLPUBLIC sal_Int32 getEnumAsINT32(const css::uno::Any& _rAny);
83 
84 } // namespace comphelper
85 
86 
87 #endif // INCLUDED_COMPHELPER_TYPES_HXX
88 
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Type getSequenceElementType(const Type &_rSequenceType)
Definition: types.cxx:136
float getFloat(const Any &_rAny)
Definition: types.cxx:75
sal_Int64 getINT64(const Any &_rAny)
Definition: types.cxx:39
bool getBOOL(const Any &_rAny)
Definition: types.cxx:93
bool isAssignableFrom(const Type &_rAssignable, const Type &_rFrom)
Definition: types.cxx:123
sal_Int16 getINT16(const Any &_rAny)
Definition: types.cxx:57
sal_Int32 getEnumAsINT32(const Any &_rAny)
Definition: types.cxx:104
sal_Int32 getINT32(const Any &_rAny)
Definition: types.cxx:48
double getDouble(const Any &_rAny)
Definition: types.cxx:66
FontDescriptor getDefaultFont()
get a css::awt::FontDescriptor that is fully initialized with the XXX_DONTKNOW enum values (which isn...
Definition: types.cxx:113
void disposeComponent(css::uno::Reference< TYPE > &_rxComp)
ask the given object for an XComponent interface and dispose on it
Definition: types.hxx:44
#define COMPHELPER_DLLPUBLIC
OUString getString(const Any &_rAny)
Definition: types.cxx:84