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 INCLUDED_TOOLKIT_CONTROLS_UNOCONTROLCONTAINER_HXX
21 : #define INCLUDED_TOOLKIT_CONTROLS_UNOCONTROLCONTAINER_HXX
22 :
23 :
24 : #include <com/sun/star/awt/XControlContainer.hpp>
25 : #include <com/sun/star/awt/XUnoControlContainer.hpp>
26 : #include <com/sun/star/container/XContainer.hpp>
27 : #include <com/sun/star/container/XIdentifierContainer.hpp>
28 :
29 : #include <toolkit/controls/unocontrol.hxx>
30 : #include <toolkit/controls/unocontrolbase.hxx>
31 : #include <toolkit/helper/macros.hxx>
32 : #include <toolkit/helper/servicenames.hxx>
33 :
34 : #include <cppuhelper/implbase4.hxx>
35 :
36 : class UnoControlHolderList;
37 :
38 :
39 : // class UnoControlContainer
40 :
41 : typedef ::cppu::AggImplInheritanceHelper4 < UnoControlBase
42 : , ::com::sun::star::awt::XUnoControlContainer
43 : , ::com::sun::star::awt::XControlContainer
44 : , ::com::sun::star::container::XContainer
45 : , ::com::sun::star::container::XIdentifierContainer
46 : > UnoControlContainer_Base;
47 :
48 : class UnoControlContainer : public UnoControlContainer_Base
49 : {
50 : private:
51 : UnoControlHolderList* mpControls;
52 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController > > maTabControllers;
53 : ContainerListenerMultiplexer maCListeners;
54 :
55 : protected:
56 : void ImplActivateTabControllers();
57 :
58 : public:
59 : UnoControlContainer();
60 : UnoControlContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xPeer );
61 : virtual ~UnoControlContainer();
62 :
63 :
64 : // ::com::sun::star::lang::XComponent
65 : void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
66 :
67 : // ::com::sun::star::lang::XEventListener
68 : void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
69 :
70 : // ::com::sun::star::container::XContainer
71 : void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
72 : void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
73 :
74 : // ::com::sun::star::container::XIdentifierContainer
75 : virtual ::sal_Int32 SAL_CALL insert( const ::com::sun::star::uno::Any& aElement ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
76 :
77 : // ::com::sun::star::container::XIdentifierReplace
78 : virtual void SAL_CALL removeByIdentifier( ::sal_Int32 Identifier ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
79 : virtual void SAL_CALL replaceByIdentifer( ::sal_Int32 Identifier, const ::com::sun::star::uno::Any& aElement ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
80 :
81 : // ::com::sun::star::container::XIdentifierAccess
82 : virtual ::com::sun::star::uno::Any SAL_CALL getByIdentifier( ::sal_Int32 Identifierr ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
83 : virtual ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL getIdentifiers( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
84 :
85 : // ::com::sun::star::container::XElementAccess
86 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
87 : virtual sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
88 :
89 : // ::com::sun::star::awt::XControlContainer
90 : void SAL_CALL setStatusText( const OUString& StatusText ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
91 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > > SAL_CALL getControls( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
92 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > SAL_CALL getControl( const OUString& aName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
93 : void SAL_CALL addControl( const OUString& Name, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& Control ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
94 : void SAL_CALL removeControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& Control ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
95 :
96 : // ::com::sun::star::awt::XUnoControlContainer
97 : void SAL_CALL setTabControllers( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController > >& TabControllers ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
98 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController > > SAL_CALL getTabControllers( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
99 : void SAL_CALL addTabController( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController >& TabController ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
100 : void SAL_CALL removeTabController( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController >& TabController ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
101 :
102 : // ::com::sun::star::awt::XControl
103 : void SAL_CALL createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& Toolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& Parent ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
104 :
105 : // ::com::sun::star::awt::XWindow
106 : void SAL_CALL setVisible( sal_Bool Visible ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
107 :
108 2 : DECLIMPL_SERVICEINFO_DERIVED( UnoControlContainer, UnoControlBase, szServiceName2_UnoControlContainer )
109 :
110 : protected:
111 : virtual void PrepareWindowDescriptor( ::com::sun::star::awt::WindowDescriptor& rDesc ) SAL_OVERRIDE;
112 : virtual void removingControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl );
113 : virtual void addingControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl );
114 :
115 : /** ensures that the given control has a peer, if necessary and possible
116 : @param _rxControl
117 : an ->XControl which has just been inserted into the container. Must not be <NULL/>.
118 : @precond
119 : our mutex is locked
120 : */
121 : virtual void impl_createControlPeerIfNecessary(
122 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl
123 : );
124 : private:
125 : /** adds the control to the container, does necessary notifications, and the like
126 : @param _rxControl
127 : the control to add. Must not be <NULL/>
128 : @param _pName
129 : Pointer to a name for the control. Might be <NULL/>, in this case an auotmatic name is generated
130 : @return
131 : the ID of the newly added control
132 : */
133 : sal_Int32 impl_addControl(
134 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl,
135 : const OUString* _pName = NULL
136 : );
137 :
138 : /** removes the given control from the container, including necessary notifications and the like
139 : @param _nId
140 : the ID of the control to remove
141 : @param _rxControl
142 : the control itself. Must be the one which is stored under the given ID. This parameter could also be
143 : obtained inside the method, but callers usually have obtained it, anyway.
144 : @param _pNameAccessor
145 : the name which the control was registered for. Might be <NULL/>, in this case
146 : container event broadcasts use the ID as accessor.
147 : */
148 : void impl_removeControl(
149 : sal_Int32 _nId,
150 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl,
151 : const OUString* _pNameAccessor
152 : );
153 :
154 : };
155 :
156 :
157 :
158 : #endif // INCLUDED_TOOLKIT_CONTROLS_UNOCONTROLCONTAINER_HXX
159 :
160 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|