LibreOffice Module comphelper (master) 1
propertycontainerhelper.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_PROPERTYCONTAINERHELPER_HXX
21#define INCLUDED_COMPHELPER_PROPERTYCONTAINERHELPER_HXX
22
23#include <com/sun/star/uno/Type.hxx>
24#include <com/sun/star/beans/Property.hpp>
25#include <cstddef>
26#include <limits>
27#include <vector>
29
30
31namespace comphelper
32{
33
34
35// infos about one single property
37{
38 // the possibilities where a property holding object may be located
39 enum class LocationType
40 {
41 DerivedClassRealType, // within the derived class, it's a "real" (non-Any) type
42 DerivedClassAnyType, // within the derived class, it's a com.sun.star.uno::Any
43 HoldMyself // within m_aHoldProperties
44 };
45 // the location of an object holding a property value :
47 {
48 void* pDerivedClassMember; // a pointer to a member of an object of a derived class
49 std::size_t nOwnClassVectorIndex; // an index within m_aHoldProperties
50 };
51
52 css::beans::Property aProperty;
53 LocationType eLocated; // where is the object containing the value located ?
54 LocationAccess aLocation; // access to the property value
55
57 :aProperty( OUString(), -1, css::uno::Type(), 0 )
58 ,eLocated( LocationType::HoldMyself )
59 {
60 aLocation.nOwnClassVectorIndex = std::numeric_limits<std::size_t>::max();
61 }
62};
63
64
65//= OPropertyContainerHelper
66
75{
76 typedef ::std::vector< css::uno::Any > PropertyContainer;
78 // the properties which are hold by this class' instance, not the derived one's
79
80private:
81 typedef ::std::vector< PropertyDescription > Properties;
82 typedef Properties::iterator PropertiesIterator;
83 typedef Properties::const_iterator ConstPropertiesIterator;
85
86protected:
89
100 void registerProperty(const OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes,
101 void* _pPointerToMember, const css::uno::Type& _rMemberType);
102
103
114 void registerMayBeVoidProperty(const OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes,
115 css::uno::Any* _pPointerToMember, const css::uno::Type& _rExpectedType);
116
127 void registerPropertyNoMember(const OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes,
128 const css::uno::Type& _rType, css::uno::Any const & _pInitialValue);
129
134 void revokeProperty( sal_Int32 _nHandle );
135
136
138 bool isRegisteredProperty( sal_Int32 _nHandle ) const;
139
141 bool isRegisteredProperty( const OUString& _rName ) const;
142
143
144 // helper for implementing OPropertySetHelper overridables
145 bool convertFastPropertyValue(
146 css::uno::Any & rConvertedValue,
147 css::uno::Any & rOldValue,
148 sal_Int32 nHandle,
149 const css::uno::Any& rValue
150 );
151
152 void setFastPropertyValue(
153 sal_Int32 nHandle,
154 const css::uno::Any& rValue
155 );
156
157 void getFastPropertyValue(
158 css::uno::Any& rValue,
159 sal_Int32 nHandle
160 ) const;
161
162// helper
170 void describeProperties(css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps) const;
171
176 const css::beans::Property&
177 getProperty( const OUString& _rName ) const;
178
179private:
181 COMPHELPER_DLLPRIVATE void implPushBackProperty(const PropertyDescription& _rProp);
182
184 COMPHELPER_DLLPRIVATE PropertiesIterator searchHandle(sal_Int32 _nHandle);
185
186private:
189};
190
191
192} // namespace comphelper
193
194
195#endif // INCLUDED_COMPHELPER_PROPERTYCONTAINERHELPER_HXX
196
197/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
helper class for managing property values, and implementing most of the X*Property* interfaces
Properties::const_iterator ConstPropertiesIterator
::std::vector< css::uno::Any > PropertyContainer
OPropertyContainerHelper(const OPropertyContainerHelper &)=delete
::std::vector< PropertyDescription > Properties
OPropertyContainerHelper & operator=(const OPropertyContainerHelper &)=delete
#define COMPHELPER_DLLPRIVATE
#define COMPHELPER_DLLPUBLIC
Type
SVX_DLLPUBLIC OUString getProperty(css::uno::Reference< css::beans::XPropertyContainer > const &rxPropertyContainer, OUString const &rName)