nss: upgrade to release 3.73
[LibreOffice.git] / toolkit / inc / controls / controlmodelcontainerbase.hxx
blobc2d715dc3b6175c85c970362d861f6facffc9f21
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <com/sun/star/container/XNameContainer.hpp>
23 #include <com/sun/star/container/XContainer.hpp>
24 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
25 #include <com/sun/star/awt/XTabControllerModel.hpp>
26 #include <com/sun/star/util/XChangesNotifier.hpp>
27 #include <com/sun/star/util/XChangesListener.hpp>
28 #include <com/sun/star/util/XModifyListener.hpp>
29 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
30 #include <cppuhelper/implbase8.hxx>
31 #include <cppuhelper/implbase3.hxx>
32 #include <cppuhelper/weak.hxx>
33 #include <toolkit/helper/listenermultiplexer.hxx>
34 #include <toolkit/controls/unocontrolmodel.hxx>
35 #include <controls/unocontrolcontainer.hxx>
36 #include <cppuhelper/propshlp.hxx>
37 #include <cppuhelper/basemutex.hxx>
38 #include <com/sun/star/awt/tab/XTabPageModel.hpp>
39 #include <com/sun/star/lang/XInitialization.hpp>
40 #include <vector>
42 namespace com::sun::star::resource { class XStringResourceResolver; }
43 namespace com::sun::star::uno { class XComponentContext; }
46 typedef UnoControlModel ControlModel_Base;
47 typedef ::cppu::AggImplInheritanceHelper8 < ControlModel_Base
48 , css::lang::XMultiServiceFactory
49 , css::container::XContainer
50 , css::container::XNameContainer
51 , css::awt::XTabControllerModel
52 , css::util::XChangesNotifier
53 , css::beans::XPropertyChangeListener
54 , css::awt::tab::XTabPageModel
55 , css::lang::XInitialization
56 > ControlModelContainer_IBase;
58 class ControlModelContainerBase : public ControlModelContainer_IBase
60 public:
61 enum ChildOperation { Insert = 0, Remove };
62 // would like to make this typedef private, too, but the Forte 7 compiler does have
63 // problems with this...
64 typedef ::std::pair< css::uno::Reference< css::awt::XControlModel >, OUString >
65 UnoControlModelHolder;
66 private:
67 typedef ::std::vector< UnoControlModelHolder > UnoControlModelHolderVector;
69 public:
70 // for grouping control models (XTabControllerModel::getGroupXXX)
71 typedef ::std::vector< css::uno::Reference< css::awt::XControlModel > >
72 ModelGroup;
73 typedef ::std::vector< ModelGroup > AllGroups;
75 friend struct CloneControlModel;
76 friend struct CompareControlModel;
78 protected:
79 ContainerListenerMultiplexer maContainerListeners;
80 ::comphelper::OInterfaceContainerHelper2 maChangeListeners;
81 UnoControlModelHolderVector maModels;
83 AllGroups maGroups;
84 bool mbGroupsUpToDate;
86 OUString m_sImageURL;
87 OUString m_sTooltip;
88 sal_Int16 m_nTabPageId;
90 void Clone_Impl(ControlModelContainerBase& _rClone) const;
91 protected:
92 css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override;
93 ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
95 UnoControlModelHolderVector::iterator ImplFindElement( const OUString& rName );
97 /// @throws css::lang::IllegalArgumentException
98 /// @throws css::container::ElementExistException
99 /// @throws css::lang::WrappedTargetException
100 /// @throws css::uno::RuntimeException
101 void updateUserFormChildren( const css::uno::Reference< css::container::XNameContainer >& xAllChildren, const OUString& aName, ChildOperation Operation, const css::uno::Reference< css::awt::XControlModel >& xTarget );
102 public:
103 ControlModelContainerBase( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
104 ControlModelContainerBase( const ControlModelContainerBase& rModel );
105 virtual ~ControlModelContainerBase() override;
107 rtl::Reference<UnoControlModel> Clone() const override;
109 // css::container::XContainer
110 void SAL_CALL addContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override;
111 void SAL_CALL removeContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override;
113 // css::container::XElementAccess
114 css::uno::Type SAL_CALL getElementType( ) override;
115 sal_Bool SAL_CALL hasElements( ) override;
117 // css::container::XNameContainer, XNameReplace, XNameAccess
118 void SAL_CALL replaceByName( const OUString& aName, const css::uno::Any& aElement ) override;
119 css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
120 css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override;
121 sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
122 void SAL_CALL insertByName( const OUString& aName, const css::uno::Any& aElement ) override;
123 void SAL_CALL removeByName( const OUString& Name ) override;
125 // css::beans::XMultiPropertySet
126 css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
128 // css::lang::XMultiServiceFactory
129 css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const OUString& aServiceSpecifier ) override;
130 css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( const OUString& ServiceSpecifier, const css::uno::Sequence< css::uno::Any >& Arguments ) override;
131 css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames( ) override;
133 // XComponent
134 void SAL_CALL dispose( ) override;
136 // XTabControllerModel
137 virtual sal_Bool SAL_CALL getGroupControl( ) override;
138 virtual void SAL_CALL setGroupControl( sal_Bool GroupControl ) override;
139 virtual void SAL_CALL setControlModels( const css::uno::Sequence< css::uno::Reference< css::awt::XControlModel > >& Controls ) override;
140 virtual css::uno::Sequence< css::uno::Reference< css::awt::XControlModel > > SAL_CALL getControlModels( ) override;
141 virtual void SAL_CALL setGroup( const css::uno::Sequence< css::uno::Reference< css::awt::XControlModel > >& Group, const OUString& GroupName ) override;
142 virtual sal_Int32 SAL_CALL getGroupCount( ) override;
143 virtual void SAL_CALL getGroup( sal_Int32 nGroup, css::uno::Sequence< css::uno::Reference< css::awt::XControlModel > >& Group, OUString& Name ) override;
144 virtual void SAL_CALL getGroupByName( const OUString& Name, css::uno::Sequence< css::uno::Reference< css::awt::XControlModel > >& Group ) override;
146 // XChangesNotifier
147 virtual void SAL_CALL addChangesListener( const css::uno::Reference< css::util::XChangesListener >& aListener ) override;
148 virtual void SAL_CALL removeChangesListener( const css::uno::Reference< css::util::XChangesListener >& aListener ) override;
150 // XPropertyChangeListener
151 virtual void SAL_CALL propertyChange( const css::beans::PropertyChangeEvent& evt ) override;
153 // XEventListener
154 using cppu::OPropertySetHelper::disposing;
155 virtual void SAL_CALL disposing( const css::lang::EventObject& evt ) override;
157 // XServiceInfo
158 DECLIMPL_SERVICEINFO_DERIVED(ControlModelContainerBase, ControlModel_Base, "toolkit.ControlModelContainerBase" )
160 // XInitialization
161 virtual void SAL_CALL initialize (const css::uno::Sequence<css::uno::Any>& rArguments) override;
163 // css::awt::tab::XTabPageModel
164 virtual ::sal_Int16 SAL_CALL getTabPageID() override;
165 virtual sal_Bool SAL_CALL getEnabled() override;
166 virtual void SAL_CALL setEnabled( sal_Bool _enabled ) override;
167 virtual OUString SAL_CALL getTitle() override;
168 virtual void SAL_CALL setTitle( const OUString& _title ) override;
169 virtual OUString SAL_CALL getImageURL() override;
170 virtual void SAL_CALL setImageURL( const OUString& _imageurl ) override;
171 virtual OUString SAL_CALL getToolTip() override;
172 virtual void SAL_CALL setToolTip( const OUString& _tooltip ) override;
174 protected:
175 void startControlListening( const css::uno::Reference< css::awt::XControlModel >& _rxChildModel );
176 void stopControlListening( const css::uno::Reference< css::awt::XControlModel >& _rxChildModel );
178 void implNotifyTabModelChange( const OUString& _rAccessor );
180 void implUpdateGroupStructure();
183 class ResourceListener final : public css::util::XModifyListener,
184 public ::cppu::OWeakObject,
185 public ::cppu::BaseMutex
187 public:
188 ResourceListener( const css::uno::Reference< css::util::XModifyListener >& xListener );
189 virtual ~ResourceListener() override;
191 void startListening( const css::uno::Reference< css::resource::XStringResourceResolver >& rResource );
192 void stopListening();
194 // XInterface
195 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
196 virtual void SAL_CALL acquire() throw () override;
197 virtual void SAL_CALL release() throw () override;
199 // XModifyListener
200 virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
202 // XEventListener
203 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
205 private:
206 css::uno::Reference< css::resource::XStringResourceResolver > m_xResource;
207 css::uno::Reference< css::util::XModifyListener > m_xListener;
208 bool m_bListening;
211 typedef ::cppu::AggImplInheritanceHelper3 < UnoControlContainer
212 , css::container::XContainerListener
213 , css::util::XChangesListener
214 , css::util::XModifyListener
215 > ControlContainer_IBase;
217 class ControlContainerBase : public ControlContainer_IBase
219 protected:
220 css::uno::Reference< css::uno::XComponentContext > m_xContext;
221 bool mbSizeModified;
222 bool mbPosModified;
223 css::uno::Reference< css::awt::XTabController > mxTabController;
224 css::uno::Reference< css::util::XModifyListener > mxListener;
226 void ImplInsertControl( css::uno::Reference< css::awt::XControlModel > const & rxModel, const OUString& rName );
227 void ImplRemoveControl( css::uno::Reference< css::awt::XControlModel > const & rxModel );
228 virtual void ImplSetPosSize( css::uno::Reference< css::awt::XControl >& rxCtrl );
229 void ImplUpdateResourceResolver();
230 void ImplStartListingForResourceEvents();
232 #ifdef _MSC_VER
233 // just implemented to let the various FooImplInheritanceHelper compile
234 ControlContainerBase();
235 #endif
237 public:
238 ControlContainerBase( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
239 virtual ~ControlContainerBase() override;
241 DECLIMPL_SERVICEINFO_DERIVED( ControlContainerBase, UnoControlBase, "toolkit.ControlContainerBase" )
243 void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
244 void SAL_CALL dispose() override;
246 void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override;
248 // css::container::XContainerListener
249 void SAL_CALL elementInserted( const css::container::ContainerEvent& Event ) override;
250 void SAL_CALL elementRemoved( const css::container::ContainerEvent& Event ) override;
251 void SAL_CALL elementReplaced( const css::container::ContainerEvent& Event ) override;
253 // XChangesListener
254 virtual void SAL_CALL changesOccurred( const css::util::ChangesEvent& Event ) override;
256 // css::awt::XControl
257 sal_Bool SAL_CALL setModel( const css::uno::Reference< css::awt::XControlModel >& Model ) override;
258 void SAL_CALL setDesignMode( sal_Bool bOn ) override;
259 // XModifyListener
260 // Using a dummy/no-op implementation here, not sure if every container control needs
261 // to implement this, certainly Dialog does, lets see about others
262 virtual void SAL_CALL modified( const css::lang::EventObject& ) override {}
263 protected:
264 virtual void ImplModelPropertiesChanged( const css::uno::Sequence< css::beans::PropertyChangeEvent >& rEvents ) override;
265 virtual void removingControl( const css::uno::Reference< css::awt::XControl >& _rxControl ) override;
266 virtual void addingControl( const css::uno::Reference< css::awt::XControl >& _rxControl ) override;
269 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */