xref: /trunk/main/basic/source/inc/propacc.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _SFX_PROPBAG_HXX
28 #define _SFX_PROPBAG_HXX
29 
30 #include <svl/svarray.hxx>
31 #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HXX_
32 #include <com/sun/star/beans/PropertyValue.hpp>
33 #endif
34 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HXX_
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #endif
37 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HXX_
38 #include <com/sun/star/beans/XPropertySetInfo.hpp>
39 #endif
40 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYACCESS_HXX_
41 #include <com/sun/star/beans/XPropertyAccess.hpp>
42 #endif
43 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYCONTAINER_HXX_
44 #include <com/sun/star/beans/XPropertyContainer.hpp>
45 #endif
46 #include <cppuhelper/implbase1.hxx>
47 #include <cppuhelper/implbase2.hxx>
48 
49 #define NS_BEANS    ::com::sun::star::beans
50 #define NS_LANG     ::com::sun::star::lang
51 #define NS_UNO      ::com::sun::star::uno
52 
53 typedef NS_BEANS::PropertyValue* SbPropertyValuePtr;
54 SV_DECL_PTRARR( SbPropertyValueArr_Impl, SbPropertyValuePtr, 4, 4 )
55 
56 typedef ::cppu::WeakImplHelper2< NS_BEANS::XPropertySet,
57                                  NS_BEANS::XPropertyAccess > SbPropertyValuesHelper;
58 
59 
60 //==========================================================================
61 
62 class SbPropertyValues:     public SbPropertyValuesHelper
63 {
64     SbPropertyValueArr_Impl _aPropVals;
65     NS_UNO::Reference< ::com::sun::star::beans::XPropertySetInfo > _xInfo;
66 
67 private:
68     sal_Int32                   GetIndex_Impl( const ::rtl::OUString &rPropName ) const;
69 
70 public:
71                             SbPropertyValues();
72     virtual                 ~SbPropertyValues();
73 
74     // XPropertySet
75     virtual NS_UNO::Reference< NS_BEANS::XPropertySetInfo > SAL_CALL
76         getPropertySetInfo(void) throw( NS_UNO::RuntimeException );
77     virtual void SAL_CALL   setPropertyValue(
78                                 const ::rtl::OUString& aPropertyName,
79                                 const NS_UNO::Any& aValue)
80                                 throw (::com::sun::star::beans::UnknownPropertyException,
81                                 ::com::sun::star::beans::PropertyVetoException,
82                                 ::com::sun::star::lang::IllegalArgumentException,
83                                 ::com::sun::star::lang::WrappedTargetException,
84                                 ::com::sun::star::uno::RuntimeException);
85     virtual NS_UNO::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName )
86         throw(  NS_BEANS::UnknownPropertyException,
87                 NS_LANG::WrappedTargetException,
88                 NS_UNO::RuntimeException);
89     virtual void SAL_CALL   addPropertyChangeListener(
90                                 const ::rtl::OUString& aPropertyName,
91                                 const NS_UNO::Reference< NS_BEANS::XPropertyChangeListener >& )
92                                 throw ();
93     virtual void SAL_CALL   removePropertyChangeListener(
94                                 const ::rtl::OUString& aPropertyName,
95                                 const NS_UNO::Reference< NS_BEANS::XPropertyChangeListener >& )
96                                 throw ();
97     virtual void SAL_CALL   addVetoableChangeListener(
98                                 const ::rtl::OUString& aPropertyName,
99                                 const NS_UNO::Reference< NS_BEANS::XVetoableChangeListener >& )
100                                 throw ();
101     virtual void SAL_CALL   removeVetoableChangeListener(
102                                 const ::rtl::OUString& aPropertyName,
103                                 const NS_UNO::Reference< NS_BEANS::XVetoableChangeListener >& )
104                                 throw ();
105 
106     // XPropertyAccess
107     virtual NS_UNO::Sequence< NS_BEANS::PropertyValue > SAL_CALL getPropertyValues(void) throw (::com::sun::star::uno::RuntimeException);
108     virtual void SAL_CALL setPropertyValues(const NS_UNO::Sequence< NS_BEANS::PropertyValue >& PropertyValues_) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
109 };
110 
111 //==========================================================================
112 
113 typedef ::cppu::WeakImplHelper1< NS_BEANS::XPropertySetInfo > SbPropertySetInfoHelper;
114 
115 // AB 20.3.2000 Help Class for XPropertySetInfo implementation
116 class PropertySetInfoImpl
117 {
118     friend class SbPropertySetInfo;
119     friend class SbPropertyContainer;
120 
121     NS_UNO::Sequence< NS_BEANS::Property > _aProps;
122 
123     sal_Int32 GetIndex_Impl( const ::rtl::OUString &rPropName ) const;
124 
125 public:
126     PropertySetInfoImpl();
127     PropertySetInfoImpl( NS_UNO::Sequence< NS_BEANS::Property >& rProps );
128 
129     // XPropertySetInfo
130     NS_UNO::Sequence< NS_BEANS::Property > SAL_CALL getProperties(void) throw ();
131     NS_BEANS::Property SAL_CALL getPropertyByName(const ::rtl::OUString& Name)
132         throw( NS_UNO::RuntimeException );
133     sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& Name)
134         throw ( NS_UNO::RuntimeException );
135 };
136 
137 class SbPropertySetInfo:    public SbPropertySetInfoHelper
138 {
139     PropertySetInfoImpl aImpl;
140 
141 public:
142                             SbPropertySetInfo();
143                             SbPropertySetInfo( const SbPropertyValueArr_Impl &rPropVals );
144     virtual                 ~SbPropertySetInfo();
145 
146     // XPropertySetInfo
147     virtual NS_UNO::Sequence< NS_BEANS::Property > SAL_CALL getProperties(void)
148         throw( NS_UNO::RuntimeException );
149     virtual NS_BEANS::Property SAL_CALL getPropertyByName(const ::rtl::OUString& Name)
150         throw( NS_UNO::RuntimeException );
151     virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& Name)
152         throw( NS_UNO::RuntimeException );
153 };
154 
155 //==========================================================================
156 
157 typedef ::cppu::WeakImplHelper2< NS_BEANS::XPropertySetInfo, NS_BEANS::XPropertyContainer > SbPropertyContainerHelper;
158 
159 class SbPropertyContainer: public SbPropertyContainerHelper
160 {
161     PropertySetInfoImpl aImpl;
162 
163 public:
164                             SbPropertyContainer();
165     virtual                 ~SbPropertyContainer();
166 
167     // XPropertyContainer
168     virtual void SAL_CALL addProperty(  const ::rtl::OUString& Name,
169                                         sal_Int16 Attributes,
170                                         const NS_UNO::Any& DefaultValue)
171         throw(  NS_BEANS::PropertyExistException, NS_BEANS::IllegalTypeException,
172                 NS_LANG::IllegalArgumentException, NS_UNO::RuntimeException );
173     virtual void SAL_CALL removeProperty(const ::rtl::OUString& Name)
174         throw( NS_BEANS::UnknownPropertyException, NS_UNO::RuntimeException );
175 
176     // XPropertySetInfo
177     virtual NS_UNO::Sequence< NS_BEANS::Property > SAL_CALL getProperties(void) throw();
178     virtual NS_BEANS::Property SAL_CALL getPropertyByName(const ::rtl::OUString& Name)
179         throw( NS_UNO::RuntimeException );
180     virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& Name)
181         throw( NS_UNO::RuntimeException );
182 
183     // XPropertyAccess
184     virtual NS_UNO::Sequence< NS_BEANS::PropertyValue > SAL_CALL getPropertyValues(void);
185     virtual void SAL_CALL setPropertyValues(const NS_UNO::Sequence< NS_BEANS::PropertyValue >& PropertyValues_);
186 };
187 
188 //=========================================================================
189 
190 class StarBASIC;
191 class SbxArray;
192 
193 void RTL_Impl_CreatePropertySet( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite );
194 
195 
196 #undef NS_BEANS
197 #undef NS_LANG
198 #undef NS_UNO
199 
200 
201 
202 #endif
203 
204