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 .
20 #ifndef _TOOLKIT_HELPERS_GEOMETRYCONTROLMODEL_HXX_
21 #define _TOOLKIT_HELPERS_GEOMETRYCONTROLMODEL_HXX_
23 #include <comphelper/broadcasthelper.hxx>
24 #include <comphelper/uno3.hxx>
25 #include <comphelper/propagg.hxx>
26 #include <comphelper/proparrhlp.hxx>
27 #include <comphelper/propertycontainer.hxx>
28 #include <cppuhelper/weakagg.hxx>
29 #include <cppuhelper/compbase2.hxx>
30 #include <com/sun/star/util/XCloneable.hpp>
31 #include <com/sun/star/script/XScriptEventsSupplier.hpp>
32 #include <com/sun/star/resource/XStringResourceResolver.hpp>
33 #include <cppuhelper/typeprovider.hxx>
34 #include <comphelper/IdPropArrayHelper.hxx>
35 #include <comphelper/stl_types.hxx>
37 namespace com
{ namespace sun
{ namespace star
{
39 class XMultiServiceFactory
;
46 //........................................................................
49 //........................................................................
51 //====================================================================
52 //= OGeometryControlModel_Base
53 //====================================================================
54 typedef ::cppu::WeakAggComponentImplHelper2
< ::com::sun::star::util::XCloneable
55 , ::com::sun::star::script::XScriptEventsSupplier
57 class OGeometryControlModel_Base
58 :public ::comphelper::OMutexAndBroadcastHelper
59 ,public ::comphelper::OPropertySetAggregationHelper
60 ,public ::comphelper::OPropertyContainer
64 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XAggregation
>
66 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameContainer
>
75 sal_Int16 m_nTabIndex
;
78 ::com::sun::star::uno::Reference
< ::com::sun::star::resource::XStringResourceResolver
> m_xStrResolver
;
81 sal_Bool m_bCloneable
;
84 virtual ::com::sun::star::uno::Any
ImplGetDefaultValueByHandle(sal_Int32 nHandle
) const;
85 virtual ::com::sun::star::uno::Any
ImplGetPropertyValueByHandle(sal_Int32 nHandle
) const;
86 virtual void ImplSetPropertyValueByHandle(sal_Int32 nHandle
, const :: com::sun::star::uno::Any
& aValue
);
90 @param _pAggregateInstance
91 the object to be aggregated. The refcount of the instance given MUST be 0!
93 OGeometryControlModel_Base(::com::sun::star::uno::XAggregation
* _pAggregateInstance
);
96 @param _rxAggregateInstance
97 is the object to be aggregated. Must be aquired excatly once (by the reference object given).<br/>
98 Will be reset to NULL upon leaving
100 OGeometryControlModel_Base(::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloneable
>& _rxAggregateInstance
);
102 /** releases the aggregation
103 <p>Can be used if in a derived class, an exception has to be thrown after this base class here already
104 did the aggregation</p>
106 void releaseAggregation();
109 ~OGeometryControlModel_Base();
112 ::com::sun::star::uno::Any SAL_CALL
queryAggregation( const ::com::sun::star::uno::Type
& _aType
) throw(::com::sun::star::uno::RuntimeException
);
115 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& aType
) throw(::com::sun::star::uno::RuntimeException
);
116 virtual void SAL_CALL
acquire( ) throw();
117 virtual void SAL_CALL
release( ) throw();
120 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes( ) throw (::com::sun::star::uno::RuntimeException
);
122 // OPropertySetHelper overridables
123 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
124 ::com::sun::star::uno::Any
& _rConvertedValue
, ::com::sun::star::uno::Any
& _rOldValue
,
125 sal_Int32 _nHandle
, const ::com::sun::star::uno::Any
& _rValue
)
126 throw (::com::sun::star::lang::IllegalArgumentException
);
128 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
129 sal_Int32 _nHandle
, const ::com::sun::star::uno::Any
& _rValue
)
130 throw (::com::sun::star::uno::Exception
);
132 using comphelper::OPropertySetAggregationHelper::getFastPropertyValue
;
133 virtual void SAL_CALL
getFastPropertyValue(
134 ::com::sun::star::uno::Any
& _rValue
, sal_Int32 _nHandle
) const;
136 // OPropertyStateHelper overridables
137 virtual ::com::sun::star::beans::PropertyState
getPropertyStateByHandle(sal_Int32 nHandle
);
138 virtual void setPropertyToDefaultByHandle(sal_Int32 nHandle
);
139 virtual ::com::sun::star::uno::Any
getPropertyDefaultByHandle(sal_Int32 nHandle
) const;
142 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException
);
144 // OPropertySetAggregationHelper overridables
145 using OPropertySetAggregationHelper::getInfoHelper
;
148 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloneable
> SAL_CALL
createClone( ) throw(::com::sun::star::uno::RuntimeException
);
150 //XScriptEventsSupplier
151 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameContainer
>
152 SAL_CALL
getEvents( ) throw(::com::sun::star::uno::RuntimeException
);
154 // XCloneable implementation - to be overwritten
155 virtual OGeometryControlModel_Base
* createClone_Impl(
156 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloneable
>& _rxAggregateInstance
) = 0;
159 using comphelper::OPropertySetAggregationHelper::disposing
;
160 virtual void SAL_CALL
disposing();
163 void registerProperties();
166 //====================================================================
167 //= OTemplateInstanceDisambiguation
168 //====================================================================
169 template <class CONTROLMODEL
>
170 class OTemplateInstanceDisambiguation
174 //====================================================================
175 //= OGeometryControlModel
176 //====================================================================
177 /* example for usage:
178 Reference< XAggregation > xIFace = new ::toolkit::OGeometryControlModel< UnoControlButtonModel > ();
180 template <class CONTROLMODEL
>
181 class OGeometryControlModel
182 :public OGeometryControlModel_Base
183 ,public ::comphelper::OAggregationArrayUsageHelper
< OTemplateInstanceDisambiguation
< CONTROLMODEL
> >
186 OGeometryControlModel( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& i_factory
);
189 OGeometryControlModel(::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloneable
>& _rxAggregateInstance
);
192 // OAggregationArrayUsageHelper overridables
193 virtual void fillProperties(
194 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
>& _rProps
,
195 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
>& _rAggregateProps
198 // OPropertySetAggregationHelper overridables
199 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper();
201 // OGeometryControlModel_Base
202 virtual OGeometryControlModel_Base
* createClone_Impl(
203 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloneable
>& _rxAggregateInstance
);
206 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId( ) throw (::com::sun::star::uno::RuntimeException
);
209 //====================================================================
210 //= OCommonGeometryControlModel
211 //====================================================================
212 /** allows to extend an arbitrary <type scope="com.sun.star.awt">UnoControlModel</type> with geometry
215 class OCommonGeometryControlModel
216 :public OGeometryControlModel_Base
217 ,public ::comphelper::OIdPropertyArrayUsageHelper
< OCommonGeometryControlModel
>
220 OUString m_sServiceSpecifier
; // the service specifier of our aggregate
221 sal_Int32 m_nPropertyMapId
; // our unique property info id, used to look up in s_aAggregateProperties
224 /** instantiate the model
227 the instance to aggregate. Must support the <type scope="com.sun.star.awt">UnoControlModel</type>
228 (this is not checked here)
230 OCommonGeometryControlModel(
231 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloneable
>& _rxAgg
,
232 const OUString
& _rxServiceSpecifier
235 // OIdPropertyArrayUsageHelper overridables
236 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper(sal_Int32 nId
) const;
238 // OPropertySetAggregationHelper overridables
239 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper();
241 // OGeometryControlModel_Base
242 virtual OGeometryControlModel_Base
* createClone_Impl(
243 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloneable
>& _rxAggregateInstance
);
246 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId( ) throw (::com::sun::star::uno::RuntimeException
);
249 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
250 sal_Int32 _nHandle
, const ::com::sun::star::uno::Any
& _rValue
)
251 throw (::com::sun::star::uno::Exception
);
254 #include "toolkit/controls/geometrycontrolmodel_impl.hxx"
256 //........................................................................
257 // } // namespace toolkit
258 //........................................................................
260 #endif // _TOOLKIT_HELPERS_GEOMETRYCONTROLMODEL_HXX_
262 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */