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 :
20 : #ifndef _TOOLKIT_AWT_UNOCONTROLMODEL_HXX_
21 : #define _TOOLKIT_AWT_UNOCONTROLMODEL_HXX_
22 :
23 : #include <com/sun/star/awt/XControlModel.hpp>
24 : #include <com/sun/star/lang/XComponent.hpp>
25 : #include <com/sun/star/lang/XServiceInfo.hpp>
26 : #include <com/sun/star/beans/XPropertyState.hpp>
27 : #include <com/sun/star/io/XPersistObject.hpp>
28 : #include <com/sun/star/lang/XTypeProvider.hpp>
29 : #include <com/sun/star/lang/XUnoTunnel.hpp>
30 : #include <com/sun/star/util/XCloneable.hpp>
31 : #include <cppuhelper/weakagg.hxx>
32 : #include <osl/mutex.hxx>
33 :
34 : #include <toolkit/helper/mutexandbroadcasthelper.hxx>
35 : #include <toolkit/helper/listenermultiplexer.hxx>
36 :
37 : #include <cppuhelper/propshlp.hxx>
38 : #include <cppuhelper/interfacecontainer.hxx>
39 : #include <cppuhelper/implbase7.hxx>
40 : #include <comphelper/componentcontext.hxx>
41 : #include <comphelper/uno3.hxx>
42 :
43 : #include <list>
44 : #include <map>
45 :
46 : typedef std::map<sal_uInt16, ::com::sun::star::uno::Any> ImplPropertyTable;
47 :
48 : // ----------------------------------------------------
49 : // class UnoControlModel
50 : // ----------------------------------------------------
51 :
52 : typedef ::cppu::WeakAggImplHelper7 < ::com::sun::star::awt::XControlModel
53 : , ::com::sun::star::beans::XPropertyState
54 : , ::com::sun::star::io::XPersistObject
55 : , ::com::sun::star::lang::XComponent
56 : , ::com::sun::star::lang::XServiceInfo
57 : , ::com::sun::star::lang::XUnoTunnel
58 : , ::com::sun::star::util::XCloneable
59 : > UnoControlModel_Base;
60 :
61 7 : class TOOLKIT_DLLPUBLIC UnoControlModel :public UnoControlModel_Base
62 : ,public MutexAndBroadcastHelper
63 : ,public ::cppu::OPropertySetHelper
64 : {
65 : private:
66 : ImplPropertyTable maData;
67 : EventListenerMultiplexer maDisposeListeners;
68 :
69 : protected:
70 : const ::comphelper::ComponentContext maContext;
71 :
72 : protected:
73 : void ImplRegisterProperty( sal_uInt16 nPropType );
74 : void ImplRegisterProperties( const std::list< sal_uInt16 > &rIds );
75 : void ImplRegisterProperty( sal_uInt16 nPropId, const ::com::sun::star::uno::Any& rDefault );
76 : ::com::sun::star::uno::Sequence<sal_Int32> ImplGetPropertyIds() const;
77 : virtual ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const;
78 : sal_Bool ImplHasProperty( sal_uInt16 nPropId ) const;
79 :
80 : /** called before setting multiple properties, allows to care for property dependencies
81 :
82 : <p>When multiple property values are set (e.g. XPropertySet::setPropertyValues), it may happen that some
83 : of them are dependent. For this, derivees which know such dependencies can affect the order in which
84 : the properties are internally really set.</p>
85 : */
86 : virtual void ImplNormalizePropertySequence(
87 : const sal_Int32 _nCount, /// the number of entries in the arrays
88 : sal_Int32* _pHandles, /// the handles of the properties to set
89 : ::com::sun::star::uno::Any* _pValues, /// the values of the properties to set
90 : sal_Int32* _pValidHandles /// pointer to the valid handles, allowed to be adjusted
91 : ) const SAL_THROW(());
92 :
93 : /// ensures that two property values in a sequence have a certain order
94 : void ImplEnsureHandleOrder(
95 : const sal_Int32 _nCount, /// number of entries in the array
96 : sal_Int32* _pHandles, /// pointer to the handles
97 : ::com::sun::star::uno::Any* _pValues, /// pointer to the values
98 : sal_Int32 _nFirstHandle, /// first handle, which should precede _nSecondHandle in the sequence
99 : sal_Int32 _nSecondHandle /// second handle, which should supersede _nFirstHandle in the sequence
100 : ) const;
101 :
102 : protected:
103 : UnoControlModel() //do not use! needed by MSVC at compile time to satisfy WeakAggImplHelper7
104 : : UnoControlModel_Base()
105 : , MutexAndBroadcastHelper()
106 : , OPropertySetHelper( BrdcstHelper )
107 : , maDisposeListeners( *this )
108 : , maContext( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
109 : {
110 : assert(false);
111 : }
112 :
113 : public:
114 : UnoControlModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory );
115 : UnoControlModel( const UnoControlModel& rModel );
116 :
117 : virtual UnoControlModel* Clone() const = 0;
118 :
119 : // ::com::sun::star::uno::XInterface
120 203 : ::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); }
121 : void SAL_CALL acquire() throw();
122 : void SAL_CALL release() throw();
123 :
124 : // ::com::sun::star::uno::XAggregation
125 : ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
126 :
127 : // ::com::sun::star::lang::XUnoTunnel
128 : static const ::com::sun::star::uno::Sequence< sal_Int8 >& GetUnoTunnelId() throw();
129 : sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier ) throw(::com::sun::star::uno::RuntimeException);
130 :
131 : // ::com::sun::star::util::XCloneable
132 : ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone() throw(::com::sun::star::uno::RuntimeException);
133 :
134 : // ::com::sun::star::lang::XTypeProvider
135 : DECLARE_XTYPEPROVIDER()
136 :
137 : // ::com::sun::star::lang::XComponent
138 : void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException);
139 : void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
140 : void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException);
141 :
142 : // ::com::sun::star::beans::XPropertyState
143 : ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
144 : ::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);
145 : void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
146 : ::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);
147 :
148 : // ::com::sun::star::io::XPersistObject
149 : ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException);
150 : 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);
151 : 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);
152 :
153 : // ::com::sun::star::lang::XServiceInfo
154 : ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
155 : sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
156 : ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
157 :
158 : // ::cppu::OPropertySetHelper
159 : ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() = 0;
160 : 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);
161 : void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception);
162 : using cppu::OPropertySetHelper::getFastPropertyValue;
163 : void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
164 :
165 : // setValue-Methoden ueberladen, um die Einzelproperties des FontDescriptors abzufangen
166 : // ::com::sun::star::beans::XPropertySet
167 : 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);
168 : // ::com::sun::star::beans::XFastPropertySet
169 : 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);
170 : // ::com::sun::star::beans::XMultiPropertySet
171 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
172 : 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);
173 : };
174 :
175 : #define UNO_CONTROL_MODEL_REGISTER_PROPERTIES(a) \
176 : do { \
177 : std::list< sal_uInt16 > aIds; \
178 : a::ImplGetPropertyIds( aIds ); \
179 : ImplRegisterProperties( aIds ); \
180 : } while (0)
181 :
182 : #endif // _TOOLKIT_AWT_UNOCONTROLMODEL_HXX_
183 :
184 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|