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