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