nss: upgrade to release 3.73
[LibreOffice.git] / include / svl / itemprop.hxx
blobe985977f265ad6e686c64e091da73add2fb4df12
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_SVL_ITEMPROP_HXX
20 #define INCLUDED_SVL_ITEMPROP_HXX
22 #include <com/sun/star/beans/XPropertySetInfo.hpp>
23 #include <com/sun/star/beans/PropertyState.hpp>
24 #include <comphelper/propertysetinfo.hxx>
25 #include <cppuhelper/implbase.hxx>
26 #include <svl/itemset.hxx>
27 #include <svl/svldllapi.h>
28 #include <vector>
29 #include <memory>
30 #include <string_view>
32 // values from com/sun/star/beans/PropertyAttribute
33 #define PROPERTY_NONE 0
35 /// map a property between beans::XPropertySet and SfxPoolItem
36 struct SfxItemPropertyMapEntry
38 std::u16string_view aName; ///< name of property
39 css::uno::Type aType; ///< UNO type of property
40 sal_uInt16 nWID; ///< WhichId of SfxPoolItem
41 /// flag bitmap, @see css::beans::PropertyAttribute
42 sal_Int16 nFlags;
43 /// "member ID" to tell QueryValue/PutValue which property it is
44 /// (when multiple properties map to the same nWID)
45 sal_uInt8 nMemberId;
46 PropertyMoreFlags nMoreFlags;
48 SfxItemPropertyMapEntry(std::u16string_view _aName, sal_uInt16 _nWID, css::uno::Type const & _rType,
49 sal_Int16 _nFlags, sal_uInt8 const _nMemberId, PropertyMoreFlags _nMoreFlags = PropertyMoreFlags::NONE)
50 : aName( _aName )
51 , aType( _rType )
52 , nWID( _nWID )
53 , nFlags( _nFlags )
54 , nMemberId( _nMemberId )
55 , nMoreFlags( _nMoreFlags )
57 assert(_nFlags <= 0x1ff );
58 assert( (_nMemberId & 0x40) == 0 );
59 // Verify that if METRIC_ITEM is set, we are one of the types supported by
60 // SvxUnoConvertToMM.
61 assert(!(_nMoreFlags & PropertyMoreFlags::METRIC_ITEM) ||
62 ( (aType.getTypeClass() == css::uno::TypeClass_BYTE)
63 || (aType.getTypeClass() == css::uno::TypeClass_SHORT)
64 || (aType.getTypeClass() == css::uno::TypeClass_UNSIGNED_SHORT)
65 || (aType.getTypeClass() == css::uno::TypeClass_LONG)
66 || (aType.getTypeClass() == css::uno::TypeClass_UNSIGNED_LONG)
67 ) );
71 struct SfxItemPropertySimpleEntry
73 css::uno::Type aType;
74 sal_uInt16 nWID;
75 /// flag bitmap, @see css::beans::PropertyAttribute
76 sal_Int16 nFlags;
77 sal_uInt8 nMemberId;
78 PropertyMoreFlags nMoreFlags = PropertyMoreFlags::NONE;
80 SfxItemPropertySimpleEntry()
81 : nWID( 0 )
82 , nFlags( 0 )
83 , nMemberId( 0 )
87 SfxItemPropertySimpleEntry(sal_uInt16 _nWID, css::uno::Type const & _rType,
88 sal_Int16 _nFlags)
89 : aType( _rType )
90 , nWID( _nWID )
91 , nFlags( _nFlags )
92 , nMemberId( 0 )
94 assert(_nFlags <= 0x1ff );
97 SfxItemPropertySimpleEntry( const SfxItemPropertyMapEntry* pMapEntry )
98 : aType( pMapEntry->aType )
99 , nWID( pMapEntry->nWID )
100 , nFlags( pMapEntry->nFlags )
101 , nMemberId( pMapEntry->nMemberId )
102 , nMoreFlags( pMapEntry->nMoreFlags )
107 struct SfxItemPropertyNamedEntry : public SfxItemPropertySimpleEntry
109 OUString sName;
110 SfxItemPropertyNamedEntry( const OUString& rName, const SfxItemPropertySimpleEntry& rSimpleEntry)
111 : SfxItemPropertySimpleEntry( rSimpleEntry )
112 , sName( rName )
117 typedef std::vector< SfxItemPropertyNamedEntry > PropertyEntryVector_t;
118 class SfxItemPropertyMap_Impl;
119 class SVL_DLLPUBLIC SfxItemPropertyMap
121 std::unique_ptr<SfxItemPropertyMap_Impl> m_pImpl;
122 public:
123 SfxItemPropertyMap( const SfxItemPropertyMapEntry* pEntries );
124 SfxItemPropertyMap( const SfxItemPropertyMap& rSource );
125 ~SfxItemPropertyMap();
127 const SfxItemPropertySimpleEntry* getByName( const OUString &rName ) const;
128 css::uno::Sequence< css::beans::Property > const & getProperties() const;
129 /// @throws css::beans::UnknownPropertyException
130 css::beans::Property getPropertyByName( const OUString & rName ) const;
131 bool hasPropertyByName( const OUString& rName ) const;
133 void mergeProperties( const css::uno::Sequence< css::beans::Property >& rPropSeq );
134 PropertyEntryVector_t getPropertyEntries() const;
135 sal_uInt32 getSize() const;
139 class SVL_DLLPUBLIC SfxItemPropertySet final
141 SfxItemPropertyMap m_aMap;
142 mutable css::uno::Reference<css::beans::XPropertySetInfo> m_xInfo;
144 public:
145 SfxItemPropertySet( const SfxItemPropertyMapEntry *pMap ) :
146 m_aMap(pMap) {}
147 ~SfxItemPropertySet();
149 /// @throws css::uno::RuntimeException
150 void getPropertyValue( const SfxItemPropertySimpleEntry& rEntry,
151 const SfxItemSet& rSet,
152 css::uno::Any& rAny) const;
153 /// @throws css::uno::RuntimeException
154 /// @throws css::beans::UnknownPropertyException
155 void getPropertyValue( const OUString &rName,
156 const SfxItemSet& rSet,
157 css::uno::Any& rAny) const;
158 /// @throws css::uno::RuntimeException
159 /// @throws css::beans::UnknownPropertyException
160 css::uno::Any
161 getPropertyValue( const OUString &rName,
162 const SfxItemSet& rSet ) const;
163 /// @throws css::uno::RuntimeException
164 /// @throws css::lang::IllegalArgumentException
165 void setPropertyValue( const SfxItemPropertySimpleEntry& rEntry,
166 const css::uno::Any& aVal,
167 SfxItemSet& rSet ) const;
168 /// @throws css::uno::RuntimeException
169 /// @throws css::lang::IllegalArgumentException
170 /// @throws css::beans::UnknownPropertyException
171 void setPropertyValue( const OUString& rPropertyName,
172 const css::uno::Any& aVal,
173 SfxItemSet& rSet ) const;
175 /// @throws css::beans::UnknownPropertyException
176 css::beans::PropertyState
177 getPropertyState(const OUString& rName, const SfxItemSet& rSet)const;
178 css::beans::PropertyState
179 getPropertyState(const SfxItemPropertySimpleEntry& rEntry, const SfxItemSet& rSet) const
180 throw();
182 css::uno::Reference<css::beans::XPropertySetInfo> const &
183 getPropertySetInfo() const;
184 const SfxItemPropertyMap& getPropertyMap() const {return m_aMap;}
187 // workaround for incremental linking bugs in MSVC2015
188 class SAL_DLLPUBLIC_TEMPLATE SfxItemPropertySetInfo_Base : public cppu::WeakImplHelper< css::beans::XPropertySetInfo > {};
190 class SVL_DLLPUBLIC SfxItemPropertySetInfo final : public SfxItemPropertySetInfo_Base
192 SfxItemPropertyMap m_aOwnMap;
194 public:
195 SfxItemPropertySetInfo(const SfxItemPropertyMap &rMap );
196 SfxItemPropertySetInfo(const SfxItemPropertyMapEntry *pEntries );
197 virtual ~SfxItemPropertySetInfo() override;
199 virtual css::uno::Sequence< css::beans::Property > SAL_CALL
200 getProperties( ) override;
202 virtual css::beans::Property SAL_CALL
203 getPropertyByName( const OUString& aName ) override;
205 virtual sal_Bool SAL_CALL
206 hasPropertyByName( const OUString& Name ) override;
210 // workaround for incremental linking bugs in MSVC2015
211 class SAL_DLLPUBLIC_TEMPLATE SfxExtItemPropertySetInfo_Base : public cppu::WeakImplHelper< css::beans::XPropertySetInfo > {};
213 class SVL_DLLPUBLIC SfxExtItemPropertySetInfo final : public SfxExtItemPropertySetInfo_Base
215 SfxItemPropertyMap aExtMap;
216 public:
217 SfxExtItemPropertySetInfo(
218 const SfxItemPropertyMapEntry *pMap,
219 const css::uno::Sequence<css::beans::Property>& rPropSeq );
220 virtual ~SfxExtItemPropertySetInfo() override;
222 virtual css::uno::Sequence< css::beans::Property > SAL_CALL
223 getProperties( ) override;
225 virtual css::beans::Property SAL_CALL
226 getPropertyByName( const OUString& aName ) override;
228 virtual sal_Bool SAL_CALL
229 hasPropertyByName( const OUString& Name ) override;
232 #endif
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */