xref: /trunk/main/svl/inc/svl/itemprop.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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     sal_Bool hasPropertyByName( const ::rtl::OUString& rName ) const;
100 
101     void mergeProperties( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& rPropSeq );
102     PropertyEntryVector_t getPropertyEntries() const;
103     sal_uInt32 getSize() const;
104 
105 };
106 /* -----------------------------21.02.00 11:19--------------------------------
107 
108  ---------------------------------------------------------------------------*/
109 class SVL_DLLPUBLIC SfxItemPropertySet
110 {
111     SfxItemPropertyMap                                                              m_aMap;
112     mutable com::sun::star::uno::Reference<com::sun::star::beans::XPropertySetInfo> m_xInfo;
113 protected:
114     virtual sal_Bool            FillItem(SfxItemSet& rSet, sal_uInt16 nWhich, sal_Bool bGetProperty) const;
115 
116 public:
SfxItemPropertySet(const SfxItemPropertyMapEntry * pMap)117                             SfxItemPropertySet( const SfxItemPropertyMapEntry *pMap ) :
118                                 m_aMap(pMap) {}
119                             virtual ~SfxItemPropertySet();
120 
121     void getPropertyValue( const SfxItemPropertySimpleEntry& rEntry,
122                                           const SfxItemSet& rSet,
123                                           com::sun::star::uno::Any& rAny) const;
124     void getPropertyValue( const ::rtl::OUString &rName,
125                                             const SfxItemSet& rSet,
126                                             com::sun::star::uno::Any& rAny) const;
127     com::sun::star::uno::Any
128         getPropertyValue( const ::rtl::OUString &rName,
129                                             const SfxItemSet& rSet ) const;
130     void                    setPropertyValue( const SfxItemPropertySimpleEntry& rEntry,
131                                           const com::sun::star::uno::Any& aVal,
132                                           SfxItemSet& rSet ) const;
133     void                    setPropertyValue( const ::rtl::OUString& rPropertyName,
134                                             const com::sun::star::uno::Any& aVal,
135                                             SfxItemSet& rSet ) const;
136 
137     com::sun::star::beans::PropertyState
138         getPropertyState(const ::rtl::OUString& rName, const SfxItemSet& rSet)const;
139     com::sun::star::beans::PropertyState
140         getPropertyState(const SfxItemPropertySimpleEntry& rEntry, const SfxItemSet& rSet) const
141                                     throw();
142 
143     com::sun::star::uno::Reference<com::sun::star::beans::XPropertySetInfo>
144         getPropertySetInfo() const;
145     const SfxItemPropertyMap*
getPropertyMap() const146         getPropertyMap() const {return &m_aMap;}
147 
148 };
149 /* -----------------------------21.02.00 11:09--------------------------------
150 
151  ---------------------------------------------------------------------------*/
152 struct SfxItemPropertySetInfo_Impl;
153 class SVL_DLLPUBLIC SfxItemPropertySetInfo : public
154     cppu::WeakImplHelper1<com::sun::star::beans::XPropertySetInfo>
155 {
156     SfxItemPropertySetInfo_Impl* m_pImpl;
157 
158 public:
159     SfxItemPropertySetInfo(const SfxItemPropertyMap *pMap );
160     SfxItemPropertySetInfo(const SfxItemPropertyMapEntry *pEntries );
161     virtual ~SfxItemPropertySetInfo();
162 
163     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL
164         getProperties(  );
165 
166     virtual ::com::sun::star::beans::Property SAL_CALL
167         getPropertyByName( const ::rtl::OUString& aName );
168 
169     virtual sal_Bool SAL_CALL
170         hasPropertyByName( const ::rtl::OUString& Name );
171 
172     const SfxItemPropertyMap* getMap() const;
173 };
174 /* -----------------------------21.02.00 12:01--------------------------------
175 
176  ---------------------------------------------------------------------------*/
177 class SVL_DLLPUBLIC SfxExtItemPropertySetInfo: public cppu::WeakImplHelper1<com::sun::star::beans::XPropertySetInfo >
178 {
179     SfxItemPropertyMap aExtMap;
180 public:
181                             SfxExtItemPropertySetInfo(
182                                 const SfxItemPropertyMapEntry *pMap,
183                                 const com::sun::star::uno::Sequence<com::sun::star::beans::Property>& rPropSeq );
184                             virtual ~SfxExtItemPropertySetInfo();
185 
186     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL
187         getProperties(  );
188 
189     virtual ::com::sun::star::beans::Property SAL_CALL
190         getPropertyByName( const ::rtl::OUString& aName );
191 
192     virtual sal_Bool SAL_CALL
193         hasPropertyByName( const ::rtl::OUString& Name );
194 };
195 
196 #endif
197