Impress: Implement getPartName.
[LibreOffice.git] / include / typelib / typedescription.hxx
blob05e7568373d6d3028a241f60ea6909cb71a79438
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_TYPELIB_TYPEDESCRIPTION_HXX
20 #define INCLUDED_TYPELIB_TYPEDESCRIPTION_HXX
22 #include <rtl/alloc.h>
23 #include <rtl/ustring.hxx>
24 #include <com/sun/star/uno/Type.h>
25 #include <typelib/typedescription.h>
28 namespace com
30 namespace sun
32 namespace star
34 namespace uno
37 /** C++ wrapper for typelib_TypeDescription.
38 Constructors by name, type, type description reference will get the full type description.
40 @see typelib_TypeDescription
42 class TypeDescription
44 /** C typelib type description
46 mutable typelib_TypeDescription * _pTypeDescr;
48 public:
49 /// @cond INTERNAL
50 // these are here to force memory de/allocation to sal lib.
51 inline static void * SAL_CALL operator new ( size_t nSize )
52 { return ::rtl_allocateMemory( nSize ); }
53 inline static void SAL_CALL operator delete ( void * pMem )
54 { ::rtl_freeMemory( pMem ); }
55 inline static void * SAL_CALL operator new ( size_t, void * pMem )
56 { return pMem; }
57 inline static void SAL_CALL operator delete ( void *, void * )
59 /// @endcond
61 /** Constructor:
63 @param pTypeDescr a type description
65 inline TypeDescription( typelib_TypeDescription * pTypeDescr = 0 );
66 /** Constructor:
68 @param pTypeDescrRef a type description reference
70 inline TypeDescription( typelib_TypeDescriptionReference * pTypeDescrRef );
71 /** Constructor:
73 @param rType a type
75 inline TypeDescription( const ::com::sun::star::uno::Type & rType );
76 /** Copy constructor:
78 @param rDescr another TypeDescription
80 inline TypeDescription( const TypeDescription & rDescr );
81 /** Constructor:
83 @param pTypeName a type name
85 inline TypeDescription( rtl_uString * pTypeName );
86 /** Constructor:
88 @param rTypeName a type name
90 inline TypeDescription( const ::rtl::OUString & rTypeName );
91 /** Destructor: releases type description
93 inline ~TypeDescription();
95 /** Assignment operator: acquires given type description and releases a set one.
97 @param pTypeDescr another type description
98 @return this TypeDescription
100 inline TypeDescription & SAL_CALL operator = ( typelib_TypeDescription * pTypeDescr );
101 /** Assignment operator: acquires given type description and releases a set one.
103 @param rTypeDescr another type description
104 @return this TypeDescription
106 inline TypeDescription & SAL_CALL operator =( const TypeDescription & rTypeDescr )
107 { return this->operator =( rTypeDescr.get() ); }
109 /** Tests whether two type descriptions are equal.
111 @param pTypeDescr another type description
112 @return true, if both type descriptions are equal, false otherwise
114 inline bool SAL_CALL equals( const typelib_TypeDescription * pTypeDescr ) const;
115 /** Tests whether two type descriptions are equal.
117 @param rTypeDescr another type description
118 @return true, if both type descriptions are equal, false otherwise
120 inline bool SAL_CALL equals( const TypeDescription & rTypeDescr ) const
121 { return equals( rTypeDescr._pTypeDescr ); }
123 /** Makes stored type description complete.
125 inline void SAL_CALL makeComplete() const;
127 /** Gets the UNacquired type description pointer.
129 @return stored pointer of type description
131 inline typelib_TypeDescription * SAL_CALL get() const
132 { return _pTypeDescr; }
133 /** Tests if a type description is set.
135 @return true, if a type description is set, false otherwise
137 inline bool SAL_CALL is() const
138 { return (_pTypeDescr != 0); }
141 inline TypeDescription::TypeDescription( typelib_TypeDescription * pTypeDescr )
142 : _pTypeDescr( pTypeDescr )
144 if (_pTypeDescr)
145 typelib_typedescription_acquire( _pTypeDescr );
148 inline TypeDescription::TypeDescription( typelib_TypeDescriptionReference * pTypeDescrRef )
149 : _pTypeDescr( 0 )
151 if (pTypeDescrRef)
152 typelib_typedescriptionreference_getDescription( &_pTypeDescr, pTypeDescrRef );
155 inline TypeDescription::TypeDescription( const ::com::sun::star::uno::Type & rType )
156 : _pTypeDescr( 0 )
158 if (rType.getTypeLibType())
159 typelib_typedescriptionreference_getDescription( &_pTypeDescr, rType.getTypeLibType() );
162 inline TypeDescription::TypeDescription( const TypeDescription & rTypeDescr )
163 : _pTypeDescr( rTypeDescr._pTypeDescr )
165 if (_pTypeDescr)
166 typelib_typedescription_acquire( _pTypeDescr );
169 inline TypeDescription::TypeDescription( rtl_uString * pTypeName )
170 : _pTypeDescr( 0 )
172 typelib_typedescription_getByName( &_pTypeDescr , pTypeName );
175 inline TypeDescription::TypeDescription( const ::rtl::OUString & rTypeName )
176 : _pTypeDescr( 0 )
178 typelib_typedescription_getByName( &_pTypeDescr , rTypeName.pData );
181 inline TypeDescription::~TypeDescription()
183 if (_pTypeDescr)
184 typelib_typedescription_release( _pTypeDescr );
187 inline TypeDescription & TypeDescription::operator = ( typelib_TypeDescription * pTypeDescr )
189 if (pTypeDescr)
190 typelib_typedescription_acquire( pTypeDescr );
191 if (_pTypeDescr)
192 typelib_typedescription_release( _pTypeDescr );
193 _pTypeDescr = pTypeDescr;
194 return *this;
197 inline bool TypeDescription::equals( const typelib_TypeDescription * pTypeDescr ) const
199 return (_pTypeDescr && pTypeDescr &&
200 typelib_typedescription_equals( _pTypeDescr, pTypeDescr ));
203 inline void TypeDescription::makeComplete() const
205 if (_pTypeDescr && !_pTypeDescr->bComplete)
206 ::typelib_typedescription_complete( &_pTypeDescr );
214 #endif
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */