1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef _SFX_ITEMPROP_HXX
20 #define _SFX_ITEMPROP_HXX
22 #include "svl/svldllapi.h"
23 #include <tools/solar.h>
24 #include <tools/string.hxx>
25 #include <svl/itemset.hxx>
26 #include <cppuhelper/implbase1.hxx>
27 #include <com/sun/star/beans/XPropertySetInfo.hpp>
28 #include <com/sun/star/beans/PropertyState.hpp>
29 #include <com/sun/star/lang/IllegalArgumentException.hpp>
32 // UNO III - Implementation
33 #define MAP_CHAR_LEN(cchar) cchar, sizeof(cchar) - 1
35 struct SfxItemPropertyMapEntry
40 const com::sun::star::uno::Type
* pType
;
46 struct SfxItemPropertySimpleEntry
49 const com::sun::star::uno::Type
* pType
;
53 SfxItemPropertySimpleEntry() :
59 SfxItemPropertySimpleEntry(sal_uInt16 _nWID
, const com::sun::star::uno::Type
* _pType
,
60 long _nFlags
, sal_uInt8 _nMemberId
) :
64 nMemberId( _nMemberId
){}
66 SfxItemPropertySimpleEntry( const SfxItemPropertyMapEntry
* pMapEntry
) :
67 nWID( pMapEntry
->nWID
),
68 pType( pMapEntry
->pType
),
69 nFlags( pMapEntry
->nFlags
),
70 nMemberId( pMapEntry
->nMemberId
){}
73 struct SfxItemPropertyNamedEntry
: public SfxItemPropertySimpleEntry
76 SfxItemPropertyNamedEntry( const String
& rName
, const SfxItemPropertySimpleEntry
& rSimpleEntry
) :
77 SfxItemPropertySimpleEntry( rSimpleEntry
),
81 typedef std::vector
< SfxItemPropertyNamedEntry
> PropertyEntryVector_t
;
82 class SfxItemPropertyMap_Impl
;
83 class SVL_DLLPUBLIC SfxItemPropertyMap
85 SfxItemPropertyMap_Impl
* m_pImpl
;
87 SfxItemPropertyMap( const SfxItemPropertyMapEntry
* pEntries
);
88 SfxItemPropertyMap( const SfxItemPropertyMap
& rSource
);
89 ~SfxItemPropertyMap();
91 const SfxItemPropertySimpleEntry
* getByName( const OUString
&rName
) const;
92 com::sun::star::uno::Sequence
< com::sun::star::beans::Property
> getProperties() const;
93 com::sun::star::beans::Property
getPropertyByName( const OUString rName
) const
94 throw( ::com::sun::star::beans::UnknownPropertyException
);
95 sal_Bool
hasPropertyByName( const OUString
& rName
) const;
97 void mergeProperties( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
>& rPropSeq
);
98 PropertyEntryVector_t
getPropertyEntries() const;
99 sal_uInt32
getSize() const;
103 class SVL_DLLPUBLIC SfxItemPropertySet
105 SfxItemPropertyMap m_aMap
;
106 mutable com::sun::star::uno::Reference
<com::sun::star::beans::XPropertySetInfo
> m_xInfo
;
108 virtual sal_Bool
FillItem(SfxItemSet
& rSet
, sal_uInt16 nWhich
, sal_Bool bGetProperty
) const;
111 SfxItemPropertySet( const SfxItemPropertyMapEntry
*pMap
) :
113 virtual ~SfxItemPropertySet();
115 void getPropertyValue( const SfxItemPropertySimpleEntry
& rEntry
,
116 const SfxItemSet
& rSet
,
117 com::sun::star::uno::Any
& rAny
) const
118 throw(::com::sun::star::uno::RuntimeException
);
119 void getPropertyValue( const OUString
&rName
,
120 const SfxItemSet
& rSet
,
121 com::sun::star::uno::Any
& rAny
) const
122 throw(::com::sun::star::uno::RuntimeException
,
123 ::com::sun::star::beans::UnknownPropertyException
);
124 com::sun::star::uno::Any
125 getPropertyValue( const OUString
&rName
,
126 const SfxItemSet
& rSet
) const
127 throw(::com::sun::star::uno::RuntimeException
,
128 ::com::sun::star::beans::UnknownPropertyException
);
129 void setPropertyValue( const SfxItemPropertySimpleEntry
& rEntry
,
130 const com::sun::star::uno::Any
& aVal
,
131 SfxItemSet
& rSet
) const
132 throw(::com::sun::star::uno::RuntimeException
,
133 com::sun::star::lang::IllegalArgumentException
);
134 void setPropertyValue( const OUString
& rPropertyName
,
135 const com::sun::star::uno::Any
& aVal
,
136 SfxItemSet
& rSet
) const
137 throw(::com::sun::star::uno::RuntimeException
,
138 com::sun::star::lang::IllegalArgumentException
,
139 ::com::sun::star::beans::UnknownPropertyException
);
141 com::sun::star::beans::PropertyState
142 getPropertyState(const OUString
& rName
, const SfxItemSet
& rSet
)const
143 throw(com::sun::star::beans::UnknownPropertyException
);
144 com::sun::star::beans::PropertyState
145 getPropertyState(const SfxItemPropertySimpleEntry
& rEntry
, const SfxItemSet
& rSet
) const
148 com::sun::star::uno::Reference
<com::sun::star::beans::XPropertySetInfo
>
149 getPropertySetInfo() const;
150 const SfxItemPropertyMap
& getPropertyMap() const {return m_aMap
;}
153 struct SfxItemPropertySetInfo_Impl
;
154 class SVL_DLLPUBLIC SfxItemPropertySetInfo
: public
155 cppu::WeakImplHelper1
<com::sun::star::beans::XPropertySetInfo
>
157 SfxItemPropertySetInfo_Impl
* m_pImpl
;
160 SfxItemPropertySetInfo(const SfxItemPropertyMap
&rMap
);
161 SfxItemPropertySetInfo(const SfxItemPropertyMapEntry
*pEntries
);
162 virtual ~SfxItemPropertySetInfo();
164 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
> SAL_CALL
166 throw(::com::sun::star::uno::RuntimeException
);
168 virtual ::com::sun::star::beans::Property SAL_CALL
169 getPropertyByName( const OUString
& aName
)
170 throw(::com::sun::star::beans::UnknownPropertyException
,
171 ::com::sun::star::uno::RuntimeException
);
173 virtual sal_Bool SAL_CALL
174 hasPropertyByName( const OUString
& Name
)
175 throw(::com::sun::star::uno::RuntimeException
);
179 class SVL_DLLPUBLIC SfxExtItemPropertySetInfo
: public cppu::WeakImplHelper1
<com::sun::star::beans::XPropertySetInfo
>
181 SfxItemPropertyMap aExtMap
;
183 SfxExtItemPropertySetInfo(
184 const SfxItemPropertyMapEntry
*pMap
,
185 const com::sun::star::uno::Sequence
<com::sun::star::beans::Property
>& rPropSeq
);
186 virtual ~SfxExtItemPropertySetInfo();
188 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
> SAL_CALL
190 throw(::com::sun::star::uno::RuntimeException
);
192 virtual ::com::sun::star::beans::Property SAL_CALL
193 getPropertyByName( const OUString
& aName
)
194 throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
);
196 virtual sal_Bool SAL_CALL
197 hasPropertyByName( const OUString
& Name
)
198 throw(::com::sun::star::uno::RuntimeException
);
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */