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 <vector>
27 
28 
29 namespace comphelper
30 {
31 
32 
33 // infos about one single property
35 {
36  // the possibilities where a property holding object may be located
37  enum class LocationType
38  {
39  DerivedClassRealType, // within the derived class, it's a "real" (non-Any) type
40  DerivedClassAnyType, // within the derived class, it's a com.sun.star.uno::Any
41  HoldMyself // within m_aHoldProperties
42  };
43  // the location of an object holding a property value :
45  {
46  void* pDerivedClassMember; // a pointer to a member of an object of a derived class
47  sal_Int32 nOwnClassVectorIndex; // an index within m_aHoldProperties
48  };
49 
50  css::beans::Property aProperty;
51  LocationType eLocated; // where is the object containing the value located ?
52  LocationAccess aLocation; // access to the property value
53 
55  :aProperty( OUString(), -1, css::uno::Type(), 0 )
56  ,eLocated( LocationType::HoldMyself )
57  {
58  aLocation.nOwnClassVectorIndex = -1;
59  }
60 };
61 
62 
63 //= OPropertyContainerHelper
64 
73 {
74  typedef ::std::vector< css::uno::Any > PropertyContainer;
75  PropertyContainer m_aHoldProperties;
76  // the properties which are hold by this class' instance, not the derived one's
77 
78 private:
79  typedef ::std::vector< PropertyDescription > Properties;
80  typedef Properties::iterator PropertiesIterator;
81  typedef Properties::const_iterator ConstPropertiesIterator;
82  Properties m_aProperties;
83 
84 protected:
87 
98  void registerProperty(const OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes,
99  void* _pPointerToMember, const css::uno::Type& _rMemberType);
100 
101 
112  void registerMayBeVoidProperty(const OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes,
113  css::uno::Any* _pPointerToMember, const css::uno::Type& _rExpectedType);
114 
125  void registerPropertyNoMember(const OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes,
126  const css::uno::Type& _rType, css::uno::Any const & _pInitialValue);
127 
132  void revokeProperty( sal_Int32 _nHandle );
133 
134 
136  bool isRegisteredProperty( sal_Int32 _nHandle ) const;
137 
139  bool isRegisteredProperty( const OUString& _rName ) const;
140 
141 
142  // helper for implementing OPropertySetHelper overridables
143  bool convertFastPropertyValue(
144  css::uno::Any & rConvertedValue,
145  css::uno::Any & rOldValue,
146  sal_Int32 nHandle,
147  const css::uno::Any& rValue
148  );
149 
150  void setFastPropertyValue(
151  sal_Int32 nHandle,
152  const css::uno::Any& rValue
153  );
154 
155  void getFastPropertyValue(
156  css::uno::Any& rValue,
157  sal_Int32 nHandle
158  ) const;
159 
160 // helper
168  void describeProperties(css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps) const;
169 
174  const css::beans::Property&
175  getProperty( const OUString& _rName ) const;
176 
177 private:
179  COMPHELPER_DLLPRIVATE void implPushBackProperty(const PropertyDescription& _rProp);
180 
182  COMPHELPER_DLLPRIVATE PropertiesIterator searchHandle(sal_Int32 _nHandle);
183 
184 private:
186  OPropertyContainerHelper& operator=( const OPropertyContainerHelper& ) = delete;
187 };
188 
189 
190 } // namespace comphelper
191 
192 
193 #endif // INCLUDED_COMPHELPER_PROPERTYCONTAINERHELPER_HXX
194 
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Type
OUString getProperty(uno::Reference< beans::XPropertyContainer > const &rxPropertyContainer, OUString const &rName)
::std::vector< PropertyDescription > Properties
helper class for managing property values, and implementing most of the X*Property* interfaces ...
#define COMPHELPER_DLLPRIVATE
Properties::const_iterator ConstPropertiesIterator
::std::vector< css::uno::Any > PropertyContainer
#define COMPHELPER_DLLPUBLIC