Line data Source code
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>
24 : #include <com/sun/star/lang/IllegalArgumentException.hpp>
25 : #include <cppuhelper/implbase1.hxx>
26 : #include <svl/itemset.hxx>
27 : #include <svl/svldllapi.h>
28 : #include <vector>
29 :
30 : /// map a property between beans::XPropertySet and SfxPoolItem
31 192983 : struct SfxItemPropertyMapEntry
32 : {
33 : OUString aName; ///< name of property
34 : sal_uInt16 nWID; ///< WhichId of SfxPoolItem
35 : com::sun::star::uno::Type aType; ///< UNO type of property
36 : /// flag bitmap, @see com::sun::star::beans::PropertyAttribute
37 : long nFlags;
38 : /// "member ID" to tell QueryValue/PutValue which property it is
39 : /// (when multiple properties map to the same nWID)
40 : sal_uInt8 nMemberId;
41 :
42 : };
43 :
44 35081017 : struct SfxItemPropertySimpleEntry
45 : {
46 : sal_uInt16 nWID;
47 : com::sun::star::uno::Type aType;
48 : long nFlags;
49 : sal_uInt8 nMemberId;
50 :
51 7863390 : SfxItemPropertySimpleEntry()
52 : : nWID( 0 )
53 : , nFlags( 0 )
54 7863390 : , nMemberId( 0 )
55 : {
56 7863390 : }
57 :
58 6260419 : SfxItemPropertySimpleEntry(sal_uInt16 _nWID, com::sun::star::uno::Type const & _rType,
59 : long _nFlags, sal_uInt8 _nMemberId)
60 : : nWID( _nWID )
61 : , aType( _rType )
62 : , nFlags( _nFlags )
63 6260419 : , nMemberId( _nMemberId )
64 : {
65 6260419 : }
66 :
67 1603378 : SfxItemPropertySimpleEntry( const SfxItemPropertyMapEntry* pMapEntry )
68 : : nWID( pMapEntry->nWID )
69 : , aType( pMapEntry->aType )
70 : , nFlags( pMapEntry->nFlags )
71 1603378 : , nMemberId( pMapEntry->nMemberId )
72 : {
73 1603378 : }
74 :
75 : };
76 8453226 : struct SfxItemPropertyNamedEntry : public SfxItemPropertySimpleEntry
77 : {
78 : OUString sName;
79 2817742 : SfxItemPropertyNamedEntry( const OUString& rName, const SfxItemPropertySimpleEntry& rSimpleEntry)
80 : : SfxItemPropertySimpleEntry( rSimpleEntry )
81 2817742 : , sName( rName )
82 : {
83 2817742 : }
84 :
85 : };
86 : typedef std::vector< SfxItemPropertyNamedEntry > PropertyEntryVector_t;
87 : class SfxItemPropertyMap_Impl;
88 : class SVL_DLLPUBLIC SfxItemPropertyMap
89 : {
90 : SfxItemPropertyMap_Impl* m_pImpl;
91 : public:
92 : SfxItemPropertyMap( const SfxItemPropertyMapEntry* pEntries );
93 : SfxItemPropertyMap( const SfxItemPropertyMap& rSource );
94 : ~SfxItemPropertyMap();
95 :
96 : const SfxItemPropertySimpleEntry* getByName( const OUString &rName ) const;
97 : com::sun::star::uno::Sequence< com::sun::star::beans::Property > getProperties() const;
98 : com::sun::star::beans::Property getPropertyByName( const OUString & rName ) const
99 : throw( ::com::sun::star::beans::UnknownPropertyException );
100 : bool hasPropertyByName( const OUString& rName ) const;
101 :
102 : void mergeProperties( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& rPropSeq );
103 : PropertyEntryVector_t getPropertyEntries() const;
104 : sal_uInt32 getSize() const;
105 :
106 : };
107 :
108 : class SVL_DLLPUBLIC SfxItemPropertySet
109 : {
110 : SfxItemPropertyMap m_aMap;
111 : mutable com::sun::star::uno::Reference<com::sun::star::beans::XPropertySetInfo> m_xInfo;
112 :
113 : public:
114 8297 : SfxItemPropertySet( const SfxItemPropertyMapEntry *pMap ) :
115 8297 : m_aMap(pMap) {}
116 : virtual ~SfxItemPropertySet();
117 :
118 : void getPropertyValue( const SfxItemPropertySimpleEntry& rEntry,
119 : const SfxItemSet& rSet,
120 : com::sun::star::uno::Any& rAny) const
121 : throw(::com::sun::star::uno::RuntimeException);
122 : void getPropertyValue( const OUString &rName,
123 : const SfxItemSet& rSet,
124 : com::sun::star::uno::Any& rAny) const
125 : throw(::com::sun::star::uno::RuntimeException,
126 : ::com::sun::star::beans::UnknownPropertyException);
127 : com::sun::star::uno::Any
128 : getPropertyValue( const OUString &rName,
129 : const SfxItemSet& rSet ) const
130 : throw(::com::sun::star::uno::RuntimeException,
131 : ::com::sun::star::beans::UnknownPropertyException);
132 : void setPropertyValue( const SfxItemPropertySimpleEntry& rEntry,
133 : const com::sun::star::uno::Any& aVal,
134 : SfxItemSet& rSet ) const
135 : throw(::com::sun::star::uno::RuntimeException,
136 : com::sun::star::lang::IllegalArgumentException);
137 : void setPropertyValue( const OUString& rPropertyName,
138 : const com::sun::star::uno::Any& aVal,
139 : SfxItemSet& rSet ) const
140 : throw(::com::sun::star::uno::RuntimeException,
141 : com::sun::star::lang::IllegalArgumentException,
142 : ::com::sun::star::beans::UnknownPropertyException);
143 :
144 : com::sun::star::beans::PropertyState
145 : getPropertyState(const OUString& rName, const SfxItemSet& rSet)const
146 : throw(com::sun::star::beans::UnknownPropertyException);
147 : com::sun::star::beans::PropertyState
148 : getPropertyState(const SfxItemPropertySimpleEntry& rEntry, const SfxItemSet& rSet) const
149 : throw();
150 :
151 : com::sun::star::uno::Reference<com::sun::star::beans::XPropertySetInfo>
152 : getPropertySetInfo() const;
153 1419351 : const SfxItemPropertyMap& getPropertyMap() const {return m_aMap;}
154 : };
155 :
156 : struct SfxItemPropertySetInfo_Impl;
157 : class SVL_DLLPUBLIC SfxItemPropertySetInfo : public
158 : cppu::WeakImplHelper1<com::sun::star::beans::XPropertySetInfo>
159 : {
160 : SfxItemPropertySetInfo_Impl* m_pImpl;
161 :
162 : public:
163 : SfxItemPropertySetInfo(const SfxItemPropertyMap &rMap );
164 : SfxItemPropertySetInfo(const SfxItemPropertyMapEntry *pEntries );
165 : virtual ~SfxItemPropertySetInfo();
166 :
167 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL
168 : getProperties( )
169 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
170 :
171 : virtual ::com::sun::star::beans::Property SAL_CALL
172 : getPropertyByName( const OUString& aName )
173 : throw(::com::sun::star::beans::UnknownPropertyException,
174 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
175 :
176 : virtual sal_Bool SAL_CALL
177 : hasPropertyByName( const OUString& Name )
178 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
179 :
180 : };
181 :
182 : class SVL_DLLPUBLIC SfxExtItemPropertySetInfo: public cppu::WeakImplHelper1<com::sun::star::beans::XPropertySetInfo >
183 : {
184 : SfxItemPropertyMap aExtMap;
185 : public:
186 : SfxExtItemPropertySetInfo(
187 : const SfxItemPropertyMapEntry *pMap,
188 : const com::sun::star::uno::Sequence<com::sun::star::beans::Property>& rPropSeq );
189 : virtual ~SfxExtItemPropertySetInfo();
190 :
191 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL
192 : getProperties( )
193 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
194 :
195 : virtual ::com::sun::star::beans::Property SAL_CALL
196 : getPropertyByName( const OUString& aName )
197 : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
198 :
199 : virtual sal_Bool SAL_CALL
200 : hasPropertyByName( const OUString& Name )
201 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
202 : };
203 :
204 : #endif
205 :
206 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|