Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _TOOLKIT_AWT_UNOCONTROLMODEL_HXX_
30 : : #define _TOOLKIT_AWT_UNOCONTROLMODEL_HXX_
31 : :
32 : : #include <com/sun/star/awt/XControlModel.hpp>
33 : : #include <com/sun/star/lang/XComponent.hpp>
34 : : #include <com/sun/star/lang/XServiceInfo.hpp>
35 : : #include <com/sun/star/beans/XPropertyState.hpp>
36 : : #include <com/sun/star/io/XPersistObject.hpp>
37 : : #include <com/sun/star/lang/XTypeProvider.hpp>
38 : : #include <com/sun/star/lang/XUnoTunnel.hpp>
39 : : #include <com/sun/star/util/XCloneable.hpp>
40 : : #include <cppuhelper/weakagg.hxx>
41 : : #include <osl/mutex.hxx>
42 : :
43 : : #include <toolkit/helper/mutexandbroadcasthelper.hxx>
44 : : #include <toolkit/helper/listenermultiplexer.hxx>
45 : :
46 : : #include <cppuhelper/propshlp.hxx>
47 : : #include <cppuhelper/interfacecontainer.hxx>
48 : : #include <cppuhelper/implbase7.hxx>
49 : : #include <comphelper/componentcontext.hxx>
50 : : #include <comphelper/uno3.hxx>
51 : :
52 : : #include <list>
53 : : #include <map>
54 : :
55 : : typedef std::map<sal_uInt16, ::com::sun::star::uno::Any> ImplPropertyTable;
56 : :
57 : : // ----------------------------------------------------
58 : : // class UnoControlModel
59 : : // ----------------------------------------------------
60 : :
61 : : typedef ::cppu::WeakAggImplHelper7 < ::com::sun::star::awt::XControlModel
62 : : , ::com::sun::star::beans::XPropertyState
63 : : , ::com::sun::star::io::XPersistObject
64 : : , ::com::sun::star::lang::XComponent
65 : : , ::com::sun::star::lang::XServiceInfo
66 : : , ::com::sun::star::lang::XUnoTunnel
67 : : , ::com::sun::star::util::XCloneable
68 : : > UnoControlModel_Base;
69 : :
70 [ + - ][ + - ]: 1369 : class TOOLKIT_DLLPUBLIC UnoControlModel :public UnoControlModel_Base
[ + - ][ + - ]
[ - + ]
71 : : ,public MutexAndBroadcastHelper
72 : : ,public ::cppu::OPropertySetHelper
73 : : {
74 : : private:
75 : : ImplPropertyTable maData;
76 : : EventListenerMultiplexer maDisposeListeners;
77 : :
78 : : protected:
79 : : const ::comphelper::ComponentContext maContext;
80 : :
81 : : protected:
82 : : void ImplRegisterProperty( sal_uInt16 nPropType );
83 : : void ImplRegisterProperties( const std::list< sal_uInt16 > &rIds );
84 : : void ImplRegisterProperty( sal_uInt16 nPropId, const ::com::sun::star::uno::Any& rDefault );
85 : : ::com::sun::star::uno::Sequence<sal_Int32> ImplGetPropertyIds() const;
86 : : virtual ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const;
87 : : sal_Bool ImplHasProperty( sal_uInt16 nPropId ) const;
88 : :
89 : : /** called before setting multiple properties, allows to care for property dependencies
90 : :
91 : : <p>When multiple property values are set (e.g. XPropertySet::setPropertyValues), it may happen that some
92 : : of them are dependent. For this, derivees which know such dependencies can affect the order in which
93 : : the properties are internally really set.</p>
94 : : */
95 : : virtual void ImplNormalizePropertySequence(
96 : : const sal_Int32 _nCount, /// the number of entries in the arrays
97 : : sal_Int32* _pHandles, /// the handles of the properties to set
98 : : ::com::sun::star::uno::Any* _pValues, /// the values of the properties to set
99 : : sal_Int32* _pValidHandles /// pointer to the valid handles, allowed to be adjusted
100 : : ) const SAL_THROW(());
101 : :
102 : : /// ensures that two property values in a sequence have a certain order
103 : : void ImplEnsureHandleOrder(
104 : : const sal_Int32 _nCount, /// number of entries in the array
105 : : sal_Int32* _pHandles, /// pointer to the handles
106 : : ::com::sun::star::uno::Any* _pValues, /// pointer to the values
107 : : sal_Int32 _nFirstHandle, /// first handle, which should precede _nSecondHandle in the sequence
108 : : sal_Int32 _nSecondHandle /// second handle, which should supersede _nFirstHandle in the sequence
109 : : ) const;
110 : :
111 : : protected:
112 : : UnoControlModel() //do not use! needed by MSVC at compile time to satisfy WeakAggImplHelper7
113 : : : UnoControlModel_Base()
114 : : , MutexAndBroadcastHelper()
115 : : , OPropertySetHelper( BrdcstHelper )
116 : : , maDisposeListeners( *this )
117 : : , maContext( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
118 : : {
119 : : assert(false);
120 : : }
121 : :
122 : : public:
123 : : UnoControlModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory );
124 : : UnoControlModel( const UnoControlModel& rModel );
125 : :
126 : : virtual UnoControlModel* Clone() const = 0;
127 : :
128 : : // ::com::sun::star::uno::XInterface
129 : 63838 : ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { return OWeakAggObject::queryInterface(rType); }
130 : : void SAL_CALL acquire() throw();
131 : : void SAL_CALL release() throw();
132 : :
133 : : // ::com::sun::star::uno::XAggregation
134 : : ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
135 : :
136 : : // ::com::sun::star::lang::XUnoTunnel
137 : : static const ::com::sun::star::uno::Sequence< sal_Int8 >& GetUnoTunnelId() throw();
138 : : sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier ) throw(::com::sun::star::uno::RuntimeException);
139 : :
140 : : // ::com::sun::star::util::XCloneable
141 : : ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone() throw(::com::sun::star::uno::RuntimeException);
142 : :
143 : : // ::com::sun::star::lang::XTypeProvider
144 : : DECLARE_XTYPEPROVIDER()
145 : :
146 : : // ::com::sun::star::lang::XComponent
147 : : void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException);
148 : : void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
149 : : void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException);
150 : :
151 : : // ::com::sun::star::beans::XPropertyState
152 : : ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
153 : : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
154 : : void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
155 : : ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
156 : :
157 : : // ::com::sun::star::io::XPersistObject
158 : : ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException);
159 : : void SAL_CALL write( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream >& OutStream ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
160 : : void SAL_CALL read( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream >& InStream ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
161 : :
162 : : // ::com::sun::star::lang::XServiceInfo
163 : : ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
164 : : sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
165 : : ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
166 : :
167 : : // ::cppu::OPropertySetHelper
168 : : ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() = 0;
169 : : sal_Bool SAL_CALL convertFastPropertyValue( ::com::sun::star::uno::Any & rConvertedValue, ::com::sun::star::uno::Any & rOldValue, sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::lang::IllegalArgumentException);
170 : : void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception);
171 : : using cppu::OPropertySetHelper::getFastPropertyValue;
172 : : void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
173 : :
174 : : // setValue-Methoden ueberladen, um die Einzelproperties des FontDescriptors abzufangen
175 : : // ::com::sun::star::beans::XPropertySet
176 : : void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) 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);
177 : : // ::com::sun::star::beans::XFastPropertySet
178 : : void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const ::com::sun::star::uno::Any& aValue ) 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);
179 : : // ::com::sun::star::beans::XMultiPropertySet
180 : : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
181 : : void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
182 : : };
183 : :
184 : : #define UNO_CONTROL_MODEL_REGISTER_PROPERTIES(a) \
185 : : do { \
186 : : std::list< sal_uInt16 > aIds; \
187 : : a::ImplGetPropertyIds( aIds ); \
188 : : ImplRegisterProperties( aIds ); \
189 : : } while (0)
190 : :
191 : : #endif // _TOOLKIT_AWT_UNOCONTROLMODEL_HXX_
192 : :
193 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|