Use IID_PPV_ARGS and CComPtr to simplify
[LibreOffice.git] / toolkit / inc / controls / unocontrolcontainer.hxx
blobf05fa959e1f744e7117bcdbc5227ec131e34ddb7
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
23 #include <com/sun/star/awt/XControlContainer.hpp>
24 #include <com/sun/star/awt/XUnoControlContainer.hpp>
25 #include <com/sun/star/container/XContainer.hpp>
26 #include <com/sun/star/container/XIdentifierContainer.hpp>
28 #include <toolkit/controls/unocontrolbase.hxx>
30 #include <cppuhelper/implbase4.hxx>
31 #include <memory>
33 class UnoControlHolderList;
37 typedef ::cppu::AggImplInheritanceHelper4 < UnoControlBase
38 , css::awt::XUnoControlContainer
39 , css::awt::XControlContainer
40 , css::container::XContainer
41 , css::container::XIdentifierContainer
42 > UnoControlContainer_Base;
44 class UnoControlContainer : public UnoControlContainer_Base
46 private:
47 std::unique_ptr<UnoControlHolderList> mpControls;
48 css::uno::Sequence< css::uno::Reference< css::awt::XTabController > > maTabControllers;
49 ContainerListenerMultiplexer maCListeners;
51 protected:
52 void ImplActivateTabControllers();
54 public:
55 UnoControlContainer();
56 UnoControlContainer( const css::uno::Reference< css::awt::XVclWindowPeer >& xPeer );
57 virtual ~UnoControlContainer() override;
60 // css::lang::XComponent
61 void SAL_CALL dispose() override;
63 // css::lang::XEventListener
64 void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
66 // css::container::XContainer
67 void SAL_CALL addContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override;
68 void SAL_CALL removeContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override;
70 // css::container::XIdentifierContainer
71 virtual ::sal_Int32 SAL_CALL insert( const css::uno::Any& aElement ) override;
73 // css::container::XIdentifierReplace
74 virtual void SAL_CALL removeByIdentifier( ::sal_Int32 Identifier ) override;
75 virtual void SAL_CALL replaceByIdentifer( ::sal_Int32 Identifier, const css::uno::Any& aElement ) override;
77 // css::container::XIdentifierAccess
78 virtual css::uno::Any SAL_CALL getByIdentifier( ::sal_Int32 Identifier ) override;
79 virtual css::uno::Sequence< ::sal_Int32 > SAL_CALL getIdentifiers( ) override;
81 // css::container::XElementAccess
82 virtual css::uno::Type SAL_CALL getElementType( ) override;
83 virtual sal_Bool SAL_CALL hasElements( ) override;
85 // css::awt::XControlContainer
86 void SAL_CALL setStatusText( const OUString& StatusText ) override;
87 css::uno::Sequence< css::uno::Reference< css::awt::XControl > > SAL_CALL getControls( ) override;
88 css::uno::Reference< css::awt::XControl > SAL_CALL getControl( const OUString& aName ) override;
89 void SAL_CALL addControl( const OUString& Name, const css::uno::Reference< css::awt::XControl >& Control ) override;
90 void SAL_CALL removeControl( const css::uno::Reference< css::awt::XControl >& Control ) override;
92 // css::awt::XUnoControlContainer
93 void SAL_CALL setTabControllers( const css::uno::Sequence< css::uno::Reference< css::awt::XTabController > >& TabControllers ) override;
94 css::uno::Sequence< css::uno::Reference< css::awt::XTabController > > SAL_CALL getTabControllers( ) override;
95 void SAL_CALL addTabController( const css::uno::Reference< css::awt::XTabController >& TabController ) override;
96 void SAL_CALL removeTabController( const css::uno::Reference< css::awt::XTabController >& TabController ) override;
98 // css::awt::XControl
99 void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override;
101 // css::awt::XWindow
102 void SAL_CALL setVisible( sal_Bool Visible ) override;
104 OUString SAL_CALL getImplementationName() override;
106 css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
108 protected:
109 virtual void PrepareWindowDescriptor( css::awt::WindowDescriptor& rDesc ) override;
110 virtual void removingControl( const css::uno::Reference< css::awt::XControl >& _rxControl );
111 virtual void addingControl( const css::uno::Reference< css::awt::XControl >& _rxControl );
113 /** ensures that the given control has a peer, if necessary and possible
114 @param _rxControl
115 an ->XControl which has just been inserted into the container. Must not be <NULL/>.
116 @precond
117 our mutex is locked
119 virtual void impl_createControlPeerIfNecessary(
120 const css::uno::Reference< css::awt::XControl >& _rxControl
122 private:
123 /** adds the control to the container, does necessary notifications, and the like
124 @param _rxControl
125 the control to add. Must not be <NULL/>
126 @param _pName
127 Pointer to a name for the control. Might be <NULL/>, in this case an automatic name is generated
128 @return
129 the ID of the newly added control
131 sal_Int32 impl_addControl(
132 const css::uno::Reference< css::awt::XControl >& _rxControl,
133 const OUString* _pName = nullptr
136 /** removes the given control from the container, including necessary notifications and the like
137 @param _nId
138 the ID of the control to remove
139 @param _rxControl
140 the control itself. Must be the one which is stored under the given ID. This parameter could also be
141 obtained inside the method, but callers usually have obtained it, anyway.
143 void impl_removeControl(
144 sal_Int32 _nId,
145 const css::uno::Reference< css::awt::XControl >& _rxControl
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */