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 <map>
26 
27 #include <com/sun/star/beans/XPropertySetInfo.hpp>
28 #include <cppuhelper/implbase.hxx>
30 #include <o3tl/typed_flags_set.hxx>
31 #include <memory>
32 
34  NONE = 0x00,
35  METRIC_ITEM = 0x01,
36 };
37 namespace o3tl {
38  template<> struct typed_flags<PropertyMoreFlags> : is_typed_flags<PropertyMoreFlags, 0x1> {};
39 }
40 
41 namespace comphelper
42 {
43 
45 {
46  OUString maName;
47  sal_Int32 mnHandle;
48  css::uno::Type maType;
50  sal_Int16 mnAttributes;
53 
54  PropertyMapEntry(OUString _aName, sal_Int32 _nHandle, css::uno::Type const & _rType,
55  sal_Int16 _nAttributes, sal_uInt8 _nMemberId, PropertyMoreFlags _nMoreFlags = PropertyMoreFlags::NONE)
56  : maName( _aName )
57  , mnHandle( _nHandle )
58  , maType( _rType )
59  , mnAttributes( _nAttributes )
60  , mnMemberId( _nMemberId )
61  , mnMoreFlags( _nMoreFlags )
62  {
63  assert(mnAttributes <= 0x1ff );
64  assert( (_nMemberId & 0x40) == 0 );
65  // Verify that if METRIC_ITEM is set, we are one of the types supported by
66  // SvxUnoConvertToMM.
67  assert(!(_nMoreFlags & PropertyMoreFlags::METRIC_ITEM) ||
68  ( (maType.getTypeClass() == css::uno::TypeClass_BYTE)
69  || (maType.getTypeClass() == css::uno::TypeClass_SHORT)
70  || (maType.getTypeClass() == css::uno::TypeClass_UNSIGNED_SHORT)
71  || (maType.getTypeClass() == css::uno::TypeClass_LONG)
72  || (maType.getTypeClass() == css::uno::TypeClass_UNSIGNED_LONG)
73  ) );
74  }
75  PropertyMapEntry() = default;
76 };
77 
78 typedef std::map<OUString, PropertyMapEntry const *> PropertyMap;
79 
80 class PropertyMapImpl;
81 
82 // don't export to avoid duplicate WeakImplHelper definitions with MSVC
83 class SAL_DLLPUBLIC_TEMPLATE PropertySetInfo_BASE
84  : public ::cppu::WeakImplHelper< css::beans::XPropertySetInfo >
85 {};
86 
91  : public PropertySetInfo_BASE
92 {
93 private:
94  std::unique_ptr<PropertyMapImpl> mpImpl;
95 public:
96  PropertySetInfo() throw();
97  PropertySetInfo( PropertyMapEntry const * pMap ) throw();
98  PropertySetInfo(css::uno::Sequence<css::beans::Property> const &) throw();
99  virtual ~PropertySetInfo() throw() override;
100 
104  const PropertyMap& getPropertyMap() const throw();
105 
109  void add( PropertyMapEntry const * pMap ) throw();
110 
112  void remove( const OUString& aName ) throw();
113 
114  virtual css::uno::Sequence< css::beans::Property > SAL_CALL getProperties() override;
115  virtual css::beans::Property SAL_CALL getPropertyByName( const OUString& aName ) override;
116  virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) override;
117 };
118 
119 }
120 
121 #endif // _UTL_PROPERTSETINFO_HXX_
122 
123 /* 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,
OUStringBuffer & remove(OUStringBuffer &rIn, sal_Unicode c)
Removes all occurrences of a character from within the source string.
Definition: string.hxx:60
std::map< OUString, PropertyMapEntry const * > PropertyMap
this class implements a XPropertySetInfo that is initialized with arrays of PropertyMapEntry.
unsigned char sal_Bool
std::unique_ptr< PropertyMapImpl > mpImpl
unsigned char sal_uInt8
#define COMPHELPER_DLLPUBLIC
PropertyMoreFlags