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 .
22 #include <comphelper/broadcasthelper.hxx>
23 #include <comphelper/propagg.hxx>
24 #include <comphelper/proparrhlp.hxx>
25 #include <comphelper/propertycontainer.hxx>
26 #include <cppuhelper/compbase2.hxx>
27 #include <com/sun/star/util/XCloneable.hpp>
28 #include <com/sun/star/script/XScriptEventsSupplier.hpp>
29 #include <comphelper/IdPropArrayHelper.hxx>
31 namespace com::sun::star::resource
{ class XStringResourceResolver
; }
33 namespace com::sun::star
{
35 class XComponentContext
;
44 //= OGeometryControlModel_Base
46 typedef ::cppu::WeakAggComponentImplHelper2
< css::util::XCloneable
47 , css::script::XScriptEventsSupplier
49 class OGeometryControlModel_Base
50 :public ::comphelper::OMutexAndBroadcastHelper
51 ,public ::comphelper::OPropertySetAggregationHelper
52 ,public ::comphelper::OPropertyContainer
56 css::uno::Reference
< css::uno::XAggregation
>
58 css::uno::Reference
< css::container::XNameContainer
>
67 sal_Int16 m_nTabIndex
;
70 css::uno::Reference
< css::resource::XStringResourceResolver
> m_xStrResolver
;
76 static css::uno::Any
ImplGetDefaultValueByHandle(sal_Int32 nHandle
);
77 css::uno::Any
ImplGetPropertyValueByHandle(sal_Int32 nHandle
) const;
78 void ImplSetPropertyValueByHandle(sal_Int32 nHandle
, const css::uno::Any
& aValue
);
82 @param _pAggregateInstance
83 the object to be aggregated. The refcount of the instance given MUST be 0!
85 OGeometryControlModel_Base(css::uno::XAggregation
* _pAggregateInstance
);
88 @param _rxAggregateInstance
89 is the object to be aggregated. Must be acquired exactly once (by the reference object given).<br/>
90 Will be reset to NULL upon leaving
92 OGeometryControlModel_Base(css::uno::Reference
< css::util::XCloneable
>& _rxAggregateInstance
);
94 /** releases the aggregation
95 <p>Can be used if in a derived class, an exception has to be thrown after this base class here already
96 did the aggregation</p>
98 void releaseAggregation();
101 virtual ~OGeometryControlModel_Base() override
;
104 css::uno::Any SAL_CALL
queryAggregation( const css::uno::Type
& _aType
) override
;
107 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) override
;
108 virtual void SAL_CALL
acquire( ) throw() override
;
109 virtual void SAL_CALL
release( ) throw() override
;
112 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes( ) override
;
114 // OPropertySetHelper overridables
115 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
116 css::uno::Any
& _rConvertedValue
, css::uno::Any
& _rOldValue
,
117 sal_Int32 _nHandle
, const css::uno::Any
& _rValue
) override
;
119 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
120 sal_Int32 _nHandle
, const css::uno::Any
& _rValue
) override
;
122 using comphelper::OPropertySetAggregationHelper::getFastPropertyValue
;
123 virtual void SAL_CALL
getFastPropertyValue(
124 css::uno::Any
& _rValue
, sal_Int32 _nHandle
) const override
;
126 // OPropertyStateHelper overridables
127 virtual css::beans::PropertyState
getPropertyStateByHandle(sal_Int32 nHandle
) override
;
128 virtual void setPropertyToDefaultByHandle(sal_Int32 nHandle
) override
;
129 virtual css::uno::Any
getPropertyDefaultByHandle(sal_Int32 nHandle
) const override
;
132 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo() override
;
134 // OPropertySetAggregationHelper overridables
135 using OPropertySetAggregationHelper::getInfoHelper
;
138 virtual css::uno::Reference
< css::util::XCloneable
> SAL_CALL
createClone( ) override
;
140 //XScriptEventsSupplier
141 virtual css::uno::Reference
< css::container::XNameContainer
>
142 SAL_CALL
getEvents( ) override
;
144 // XCloneable implementation - to be overwritten
145 virtual OGeometryControlModel_Base
* createClone_Impl(
146 css::uno::Reference
< css::util::XCloneable
>& _rxAggregateInstance
) = 0;
149 using comphelper::OPropertySetAggregationHelper::disposing
;
150 virtual void SAL_CALL
disposing() override
;
153 void registerProperties();
157 //= OTemplateInstanceDisambiguation
159 template <class CONTROLMODEL
>
160 class OTemplateInstanceDisambiguation
165 //= OGeometryControlModel
167 /* example for usage:
168 Reference< XAggregation > xIFace = new ::toolkit::OGeometryControlModel< UnoControlButtonModel > ();
170 template <class CONTROLMODEL
>
171 class OGeometryControlModel final
172 :public OGeometryControlModel_Base
173 ,public ::comphelper::OAggregationArrayUsageHelper
< OTemplateInstanceDisambiguation
< CONTROLMODEL
> >
176 OGeometryControlModel( const css::uno::Reference
< css::uno::XComponentContext
>& i_factory
);
179 OGeometryControlModel(css::uno::Reference
< css::util::XCloneable
>& _rxAggregateInstance
);
181 // OAggregationArrayUsageHelper overridables
182 virtual void fillProperties(
183 css::uno::Sequence
< css::beans::Property
>& _rProps
,
184 css::uno::Sequence
< css::beans::Property
>& _rAggregateProps
187 // OPropertySetAggregationHelper overridables
188 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() override
;
190 // OGeometryControlModel_Base
191 virtual OGeometryControlModel_Base
* createClone_Impl(
192 css::uno::Reference
< css::util::XCloneable
>& _rxAggregateInstance
) override
;
195 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId( ) override
;
199 //= OCommonGeometryControlModel
201 /** allows to extend an arbitrary com.sun.star.awt::UnoControlModel with geometry
204 class OCommonGeometryControlModel final
205 :public OGeometryControlModel_Base
206 ,public ::comphelper::OIdPropertyArrayUsageHelper
< OCommonGeometryControlModel
>
209 OUString m_sServiceSpecifier
; // the service specifier of our aggregate
210 sal_Int32 m_nPropertyMapId
; // our unique property info id, used to look up in s_aAggregateProperties
213 /** instantiate the model
216 the instance to aggregate. Must support the com.sun.star.awt::UnoControlModel
217 (this is not checked here)
219 OCommonGeometryControlModel(
220 css::uno::Reference
< css::util::XCloneable
>& _rxAgg
,
221 const OUString
& _rxServiceSpecifier
224 // OIdPropertyArrayUsageHelper overridables
225 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper(sal_Int32 nId
) const override
;
227 // OPropertySetAggregationHelper overridables
228 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() override
;
230 // OGeometryControlModel_Base
231 virtual OGeometryControlModel_Base
* createClone_Impl(
232 css::uno::Reference
< css::util::XCloneable
>& _rxAggregateInstance
) override
;
235 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId( ) override
;
238 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
239 sal_Int32 _nHandle
, const css::uno::Any
& _rValue
) override
;
242 #include <controls/geometrycontrolmodel_impl.hxx>
245 // } // namespace toolkit
248 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */