LibreOffice Module svl (master) 1
itemprop.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#ifndef INCLUDED_SVL_ITEMPROP_HXX
20#define INCLUDED_SVL_ITEMPROP_HXX
21
22#include <com/sun/star/beans/XPropertySetInfo.hpp>
23#include <com/sun/star/beans/PropertyState.hpp>
26#include <svl/itemset.hxx>
27#include <svl/svldllapi.h>
29#include <o3tl/span.hxx>
30#include <string_view>
31#include <utility>
32
33// values from com/sun/star/beans/PropertyAttribute
34#define PROPERTY_NONE 0
35
38{
39 OUString aName;
40 css::uno::Type aType;
41 sal_uInt16 nWID;
43 sal_Int16 nFlags;
48
49 SfxItemPropertyMapEntry(OUString _aName, sal_uInt16 _nWID, css::uno::Type const & _rType,
50 sal_Int16 _nFlags, sal_uInt8 const _nMemberId, PropertyMoreFlags _nMoreFlags = PropertyMoreFlags::NONE)
51 : aName(std::move( _aName ))
52 , aType( _rType )
53 , nWID( _nWID )
54 , nFlags( _nFlags )
55 , nMemberId( _nMemberId )
56 , nMoreFlags( _nMoreFlags )
57 {
58 assert(_nFlags <= 0x1ff );
59 assert( (_nMemberId & 0x40) == 0 );
60 // Verify that if METRIC_ITEM is set, we are one of the types supported by
61 // SvxUnoConvertToMM.
62 assert(!(_nMoreFlags & PropertyMoreFlags::METRIC_ITEM) ||
63 ( (aType.getTypeClass() == css::uno::TypeClass_BYTE)
64 || (aType.getTypeClass() == css::uno::TypeClass_SHORT)
65 || (aType.getTypeClass() == css::uno::TypeClass_UNSIGNED_SHORT)
66 || (aType.getTypeClass() == css::uno::TypeClass_LONG)
67 || (aType.getTypeClass() == css::uno::TypeClass_UNSIGNED_LONG)
68 ) );
69 }
70};
71
73{
74 bool operator() ( const SfxItemPropertyMapEntry * lhs, const SfxItemPropertyMapEntry * rhs ) const
75 {
76 return lhs->aName < rhs->aName;
77 }
78};
80{
82 mutable css::uno::Sequence< css::beans::Property > m_aPropSeq;
83public:
87
88 const SfxItemPropertyMapEntry* getByName( std::u16string_view rName ) const;
89 css::uno::Sequence< css::beans::Property > const & getProperties() const;
91 css::beans::Property getPropertyByName( const OUString & rName ) const;
92 bool hasPropertyByName( std::u16string_view rName ) const;
93
95};
96
98{
100 mutable css::uno::Reference<css::beans::XPropertySetInfo> m_xInfo;
101
102public:
104 m_aMap(pMap) {}
106
109 const SfxItemSet& rSet,
110 css::uno::Any& rAny) const;
113 void getPropertyValue( const OUString &rName,
114 const SfxItemSet& rSet,
115 css::uno::Any& rAny) const;
118 css::uno::Any
119 getPropertyValue( const OUString &rName,
120 const SfxItemSet& rSet ) const;
124 const css::uno::Any& aVal,
125 SfxItemSet& rSet ) const;
129 void setPropertyValue( const OUString& rPropertyName,
130 const css::uno::Any& aVal,
131 SfxItemSet& rSet ) const;
132
134 css::beans::PropertyState
135 getPropertyState(const OUString& rName, const SfxItemSet& rSet)const;
136 css::beans::PropertyState
137 getPropertyState(const SfxItemPropertyMapEntry& rEntry, const SfxItemSet& rSet) const
138 noexcept;
139
140 css::uno::Reference<css::beans::XPropertySetInfo> const &
141 getPropertySetInfo() const;
142 const SfxItemPropertyMap& getPropertyMap() const {return m_aMap;}
143};
144
145// workaround for incremental linking bugs in MSVC2015
146class SAL_DLLPUBLIC_TEMPLATE SfxItemPropertySetInfo_Base : public cppu::WeakImplHelper< css::beans::XPropertySetInfo > {};
147
149{
151
152public:
155 virtual ~SfxItemPropertySetInfo() override;
156
157 virtual css::uno::Sequence< css::beans::Property > SAL_CALL
158 getProperties( ) override;
159
160 virtual css::beans::Property SAL_CALL
161 getPropertyByName( const OUString& aName ) override;
162
163 virtual sal_Bool SAL_CALL
164 hasPropertyByName( const OUString& Name ) override;
165
166};
167
169{
170 bool operator() ( const SfxItemPropertyMapEntry & lhs, const SfxItemPropertyMapEntry & rhs ) const
171 {
172 return lhs.aName < rhs.aName;
173 }
174};
175
176// workaround for incremental linking bugs in MSVC2015
177class SAL_DLLPUBLIC_TEMPLATE SfxExtItemPropertySetInfo_Base : public cppu::WeakImplHelper< css::beans::XPropertySetInfo > {};
178
180{
181public:
184 const css::uno::Sequence<css::beans::Property>& rPropSeq );
185 virtual ~SfxExtItemPropertySetInfo() override;
186
187 virtual css::uno::Sequence< css::beans::Property > SAL_CALL
188 getProperties( ) override;
189
190 virtual css::beans::Property SAL_CALL
191 getPropertyByName( const OUString& aName ) override;
192
193 virtual sal_Bool SAL_CALL
194 hasPropertyByName( const OUString& Name ) override;
195
196private:
197 const SfxItemPropertyMapEntry* getByName( std::u16string_view rName ) const;
199 mutable css::uno::Sequence< css::beans::Property > m_aPropSeq;
200};
201
202#endif
203
204/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Sequence< css::beans::Property > m_aPropSeq
Definition: itemprop.hxx:199
o3tl::sorted_vector< SfxItemPropertyMapEntry, SfxItemPropertyMapCompare2 > maMap
Definition: itemprop.hxx:198
css::uno::Sequence< css::beans::Property > m_aPropSeq
Definition: itemprop.hxx:82
SfxItemPropertyMap(const SfxItemPropertyMap &rSource)
const o3tl::sorted_vector< const SfxItemPropertyMapEntry *, SfxItemPropertyMapCompare > & getPropertyEntries() const
Definition: itemprop.hxx:94
o3tl::sorted_vector< const SfxItemPropertyMapEntry *, SfxItemPropertyMapCompare > m_aMap
Definition: itemprop.hxx:81
SfxItemPropertyMap m_aOwnMap
Definition: itemprop.hxx:150
SfxItemPropertySet(o3tl::span< const SfxItemPropertyMapEntry > pMap)
Definition: itemprop.hxx:103
css::uno::Reference< css::beans::XPropertySetInfo > m_xInfo
Definition: itemprop.hxx:100
void setPropertyValue(const SfxItemPropertyMapEntry &rEntry, const css::uno::Any &aVal, SfxItemSet &rSet) const
SfxItemPropertyMap m_aMap
Definition: itemprop.hxx:99
const SfxItemPropertyMap & getPropertyMap() const
Definition: itemprop.hxx:142
void getPropertyValue(const OUString &rName, const SfxItemSet &rSet, css::uno::Any &rAny) const
void getPropertyValue(const SfxItemPropertyMapEntry &rEntry, const SfxItemSet &rSet, css::uno::Any &rAny) const
void setPropertyValue(const OUString &rPropertyName, const css::uno::Any &aVal, SfxItemSet &rSet) const
OUString aName
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
PropertyMoreFlags
bool operator()(const SfxItemPropertyMapEntry &lhs, const SfxItemPropertyMapEntry &rhs) const
Definition: itemprop.hxx:170
bool operator()(const SfxItemPropertyMapEntry *lhs, const SfxItemPropertyMapEntry *rhs) const
Definition: itemprop.hxx:74
map a property between beans::XPropertySet and SfxPoolItem
Definition: itemprop.hxx:38
SfxItemPropertyMapEntry(OUString _aName, sal_uInt16 _nWID, css::uno::Type const &_rType, sal_Int16 _nFlags, sal_uInt8 const _nMemberId, PropertyMoreFlags _nMoreFlags=PropertyMoreFlags::NONE)
Definition: itemprop.hxx:49
PropertyMoreFlags nMoreFlags
Definition: itemprop.hxx:47
sal_uInt8 nMemberId
"member ID" to tell QueryValue/PutValue which property it is (when multiple properties map to the sam...
Definition: itemprop.hxx:46
OUString aName
name of property
Definition: itemprop.hxx:39
sal_uInt16 nWID
WhichId of SfxPoolItem.
Definition: itemprop.hxx:41
css::uno::Type aType
UNO type of property.
Definition: itemprop.hxx:40
sal_Int16 nFlags
flag bitmap,
Definition: itemprop.hxx:43
#define SVL_DLLPUBLIC
Definition: svldllapi.h:28
OUString Name
unsigned char sal_uInt8
unsigned char sal_Bool