LibreOffice Module comphelper (master)  1
propertysetinfo.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_PROPERTYSETINFO_HXX
21 #define INCLUDED_COMPHELPER_PROPERTYSETINFO_HXX
22 
23 #include <sal/config.h>
24 
25 #include <com/sun/star/beans/XPropertySetInfo.hpp>
26 #include <cppuhelper/implbase.hxx>
28 #include <o3tl/typed_flags_set.hxx>
29 #include <map>
30 #include <vector>
31 
33  NONE = 0x00,
34  METRIC_ITEM = 0x01,
35 };
36 namespace o3tl {
37  template<> struct typed_flags<PropertyMoreFlags> : is_typed_flags<PropertyMoreFlags, 0x1> {};
38 }
39 
40 namespace comphelper
41 {
42 
44 {
45  OUString maName;
46  css::uno::Type maType;
47  sal_Int32 mnHandle;
49  sal_Int16 mnAttributes;
52 
53  PropertyMapEntry(OUString _aName, sal_Int32 _nHandle, css::uno::Type const & _rType,
54  sal_Int16 _nAttributes, sal_uInt8 _nMemberId, PropertyMoreFlags _nMoreFlags = PropertyMoreFlags::NONE)
55  : maName( _aName )
56  , maType( _rType )
57  , mnHandle( _nHandle )
58  , mnAttributes( _nAttributes )
59  , mnMemberId( _nMemberId )
60  , mnMoreFlags( _nMoreFlags )
61  {
62  assert(mnAttributes <= 0x1ff );
63  assert( (_nMemberId & 0x40) == 0 );
64  // Verify that if METRIC_ITEM is set, we are one of the types supported by
65  // SvxUnoConvertToMM.
66  assert(!(_nMoreFlags & PropertyMoreFlags::METRIC_ITEM) ||
67  ( (maType.getTypeClass() == css::uno::TypeClass_BYTE)
68  || (maType.getTypeClass() == css::uno::TypeClass_SHORT)
69  || (maType.getTypeClass() == css::uno::TypeClass_UNSIGNED_SHORT)
70  || (maType.getTypeClass() == css::uno::TypeClass_LONG)
71  || (maType.getTypeClass() == css::uno::TypeClass_UNSIGNED_LONG)
72  ) );
73  }
74  PropertyMapEntry() = default;
75 };
76 
77 typedef std::map<OUString, PropertyMapEntry const *> PropertyMap;
78 
79 // don't export to avoid duplicate WeakImplHelper definitions with MSVC
80 class SAL_DLLPUBLIC_TEMPLATE PropertySetInfo_BASE
81  : public ::cppu::WeakImplHelper< css::beans::XPropertySetInfo >
82 {};
83 
88  : public PropertySetInfo_BASE
89 {
90 public:
91  PropertySetInfo() noexcept;
92  PropertySetInfo( PropertyMapEntry const * pMap ) noexcept;
93  PropertySetInfo(css::uno::Sequence<css::beans::Property> const &) noexcept;
94  virtual ~PropertySetInfo() noexcept override;
95 
99  const PropertyMap& getPropertyMap() const noexcept { return maPropertyMap; }
100 
104  void add( PropertyMapEntry const * pMap ) noexcept;
105 
107  void remove( const OUString& aName ) noexcept;
108 
109  virtual css::uno::Sequence< css::beans::Property > SAL_CALL getProperties() override;
110  virtual css::beans::Property SAL_CALL getPropertyByName( const OUString& aName ) override;
111  virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) override;
112 
113 private:
114  void addImpl(PropertyMapEntry const * pMap) noexcept;
115 
116  PropertyMap maPropertyMap;
117  std::vector< css::beans::Property > maProperties;
118 };
119 
120 }
121 
122 #endif // _UTL_PROPERTSETINFO_HXX_
123 
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PropertyMapEntry(OUString _aName, sal_Int32 _nHandle, css::uno::Type const &_rType, sal_Int16 _nAttributes, sal_uInt8 _nMemberId, PropertyMoreFlags _nMoreFlags=PropertyMoreFlags::NONE)
sal_Int16 mnAttributes
flag bitmap,
std::vector< css::beans::Property > maProperties
std::map< OUString, PropertyMapEntry const * > PropertyMap
this class implements a XPropertySetInfo that is initialized with arrays of PropertyMapEntry.
unsigned char sal_Bool
const PropertyMap & getPropertyMap() const noexcept
returns a stl map with all PropertyMapEntry pointer.
unsigned char sal_uInt8
OUString aName
#define COMPHELPER_DLLPUBLIC
PropertyMoreFlags