xref: /aoo4110/main/svl/inc/svl/itemprop.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SFX_ITEMPROP_HXX
24 #define _SFX_ITEMPROP_HXX
25 
26 #include "svl/svldllapi.h"
27 #include <tools/solar.h>
28 #include <tools/string.hxx>
29 #include <svl/itemset.hxx>
30 #include <cppuhelper/implbase1.hxx>
31 #include <com/sun/star/beans/XPropertySetInfo.hpp>
32 #include <com/sun/star/beans/PropertyState.hpp>
33 #include <com/sun/star/lang/IllegalArgumentException.hpp>
34 #include <vector>
35 /* -----------------------------21.02.00 11:03--------------------------------
36 	UNO III - Implementation
37  ---------------------------------------------------------------------------*/
38 #define MAP_CHAR_LEN(cchar) cchar, sizeof(cchar) - 1
39 
40 struct SfxItemPropertyMapEntry
41 {
42     const char*                         pName;
43     sal_uInt16                              nNameLen;
44     sal_uInt16                              nWID;
45     const com::sun::star::uno::Type*    pType;
46     long                                nFlags;
47     sal_uInt8                                nMemberId;
48 
49 };
50 
51 struct SfxItemPropertySimpleEntry
52 {
53     sal_uInt16                              nWID;
54     const com::sun::star::uno::Type*    pType;
55     long                                nFlags;
56     sal_uInt8                                nMemberId;
57 
SfxItemPropertySimpleEntrySfxItemPropertySimpleEntry58     SfxItemPropertySimpleEntry() :
59         nWID( 0 ),
60         pType( 0 ),
61         nFlags( 0 ),
62         nMemberId( 0 ){}
63 
SfxItemPropertySimpleEntrySfxItemPropertySimpleEntry64     SfxItemPropertySimpleEntry(sal_uInt16 _nWID, const com::sun::star::uno::Type* _pType,
65                                long _nFlags, sal_uInt8 _nMemberId) :
66         nWID(      _nWID ),
67         pType(     _pType ),
68         nFlags(    _nFlags ),
69         nMemberId( _nMemberId ){}
70 
SfxItemPropertySimpleEntrySfxItemPropertySimpleEntry71     SfxItemPropertySimpleEntry( const SfxItemPropertyMapEntry* pMapEntry ) :
72         nWID(      pMapEntry->nWID ),
73         pType(     pMapEntry->pType ),
74         nFlags(    pMapEntry->nFlags ),
75         nMemberId( pMapEntry->nMemberId ){}
76 
77 };
78 struct SfxItemPropertyNamedEntry : public SfxItemPropertySimpleEntry
79 {
80     ::rtl::OUString sName;
SfxItemPropertyNamedEntrySfxItemPropertyNamedEntry81     SfxItemPropertyNamedEntry( const String& rName, const SfxItemPropertySimpleEntry& rSimpleEntry) :
82         SfxItemPropertySimpleEntry( rSimpleEntry ),
83         sName( rName ){}
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* pSource );
94     ~SfxItemPropertyMap();
95 
96     const SfxItemPropertySimpleEntry*  getByName( const ::rtl::OUString &rName ) const;
97     com::sun::star::uno::Sequence< com::sun::star::beans::Property > getProperties() const;
98     com::sun::star::beans::Property getPropertyByName( const ::rtl::OUString rName ) const
99         throw( ::com::sun::star::beans::UnknownPropertyException );
100     sal_Bool hasPropertyByName( const ::rtl::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 /* -----------------------------21.02.00 11:19--------------------------------
108 
109  ---------------------------------------------------------------------------*/
110 class SVL_DLLPUBLIC SfxItemPropertySet
111 {
112     SfxItemPropertyMap                                                              m_aMap;
113     mutable com::sun::star::uno::Reference<com::sun::star::beans::XPropertySetInfo> m_xInfo;
114 protected:
115 	virtual sal_Bool			FillItem(SfxItemSet& rSet, sal_uInt16 nWhich, sal_Bool bGetProperty) const;
116 
117 public:
SfxItemPropertySet(const SfxItemPropertyMapEntry * pMap)118                             SfxItemPropertySet( const SfxItemPropertyMapEntry *pMap ) :
119                                 m_aMap(pMap) {}
120                             virtual ~SfxItemPropertySet();
121 
122     void getPropertyValue( const SfxItemPropertySimpleEntry& rEntry,
123                                           const SfxItemSet& rSet,
124                                           com::sun::star::uno::Any& rAny) const
125                                           throw(::com::sun::star::uno::RuntimeException);
126 	void getPropertyValue( const ::rtl::OUString &rName,
127 											const SfxItemSet& rSet,
128 											com::sun::star::uno::Any& rAny) const
129 											throw(::com::sun::star::uno::RuntimeException,
130 													::com::sun::star::beans::UnknownPropertyException);
131 	com::sun::star::uno::Any
132 		getPropertyValue( const ::rtl::OUString &rName,
133 											const SfxItemSet& rSet ) const
134 											throw(::com::sun::star::uno::RuntimeException,
135 													::com::sun::star::beans::UnknownPropertyException);
136     void                    setPropertyValue( const SfxItemPropertySimpleEntry& rEntry,
137                                           const com::sun::star::uno::Any& aVal,
138                                           SfxItemSet& rSet ) const
139                                           throw(::com::sun::star::uno::RuntimeException,
140                                                   com::sun::star::lang::IllegalArgumentException);
141 	void					setPropertyValue( const ::rtl::OUString& rPropertyName,
142 											const com::sun::star::uno::Any& aVal,
143 											SfxItemSet& rSet ) const
144 											throw(::com::sun::star::uno::RuntimeException,
145 													com::sun::star::lang::IllegalArgumentException,
146 													::com::sun::star::beans::UnknownPropertyException);
147 
148 	com::sun::star::beans::PropertyState
149         getPropertyState(const ::rtl::OUString& rName, const SfxItemSet& rSet)const
150                                     throw(com::sun::star::beans::UnknownPropertyException);
151     com::sun::star::beans::PropertyState
152         getPropertyState(const SfxItemPropertySimpleEntry& rEntry, const SfxItemSet& rSet) const
153                                     throw();
154 
155 	com::sun::star::uno::Reference<com::sun::star::beans::XPropertySetInfo>
156 		getPropertySetInfo() const;
157 	const SfxItemPropertyMap*
getPropertyMap() const158         getPropertyMap() const {return &m_aMap;}
159 
160 };
161 /* -----------------------------21.02.00 11:09--------------------------------
162 
163  ---------------------------------------------------------------------------*/
164 struct SfxItemPropertySetInfo_Impl;
165 class SVL_DLLPUBLIC SfxItemPropertySetInfo : public
166 	cppu::WeakImplHelper1<com::sun::star::beans::XPropertySetInfo>
167 {
168     SfxItemPropertySetInfo_Impl* m_pImpl;
169 
170 public:
171     SfxItemPropertySetInfo(const SfxItemPropertyMap *pMap );
172     SfxItemPropertySetInfo(const SfxItemPropertyMapEntry *pEntries );
173     virtual ~SfxItemPropertySetInfo();
174 
175     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL
176 		getProperties(  )
177 			throw(::com::sun::star::uno::RuntimeException);
178 
179 	virtual ::com::sun::star::beans::Property SAL_CALL
180 		getPropertyByName( const ::rtl::OUString& aName )
181 			throw(::com::sun::star::beans::UnknownPropertyException,
182 					::com::sun::star::uno::RuntimeException);
183 
184 	virtual sal_Bool SAL_CALL
185 		hasPropertyByName( const ::rtl::OUString& Name )
186 			throw(::com::sun::star::uno::RuntimeException);
187 
188     const SfxItemPropertyMap* getMap() const;
189 };
190 /* -----------------------------21.02.00 12:01--------------------------------
191 
192  ---------------------------------------------------------------------------*/
193 class SVL_DLLPUBLIC SfxExtItemPropertySetInfo: public cppu::WeakImplHelper1<com::sun::star::beans::XPropertySetInfo >
194 {
195     SfxItemPropertyMap aExtMap;
196 public:
197 							SfxExtItemPropertySetInfo(
198                                 const SfxItemPropertyMapEntry *pMap,
199 								const com::sun::star::uno::Sequence<com::sun::star::beans::Property>& rPropSeq );
200                             virtual ~SfxExtItemPropertySetInfo();
201 
202     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL
203 		getProperties(  )
204 			throw(::com::sun::star::uno::RuntimeException);
205 
206 	virtual ::com::sun::star::beans::Property SAL_CALL
207 		getPropertyByName( const ::rtl::OUString& aName )
208 			throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
209 
210 	virtual sal_Bool SAL_CALL
211 		hasPropertyByName( const ::rtl::OUString& Name )
212 			throw(::com::sun::star::uno::RuntimeException);
213 };
214 
215 #endif
216