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 #pragma once 21 22 #include <AppElementType.hxx> 23 24 #include <com/sun/star/beans/XPropertyChangeListener.hpp> 25 #include <com/sun/star/lang/XComponent.hpp> 26 27 #include <comphelper/sharedmutex.hxx> 28 #include <cppuhelper/implbase.hxx> 29 30 #include <memory> 31 32 namespace dbaui 33 { 34 35 struct SubComponentManager_Data; 36 class OApplicationController; 37 38 // SubComponentManager 39 typedef ::cppu::WeakImplHelper< css::beans::XPropertyChangeListener 40 > SubComponentManager_Base; 41 class SubComponentManager : public SubComponentManager_Base 42 { 43 public: 44 SubComponentManager( OApplicationController& _rController, const ::comphelper::SharedMutex& _rMutex ); 45 virtual ~SubComponentManager() override; 46 47 void disposing(); 48 49 // XPropertyChangeListener 50 virtual void SAL_CALL propertyChange( const css::beans::PropertyChangeEvent& evt ) override; 51 52 // XEventListener 53 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; 54 55 // XDatabaseDocumentUI helpers 56 css::uno::Sequence< css::uno::Reference< css::lang::XComponent> > 57 getSubComponents() const; 58 bool closeSubComponents(); 59 60 // container access 61 void onSubComponentOpened( 62 const OUString& _rName, 63 const sal_Int32 _nComponentType, 64 const ElementOpenMode _eOpenMode, 65 const css::uno::Reference< css::lang::XComponent >& 66 _rxComponent 67 ); 68 bool empty() const; 69 70 /** activates (i.e. brings to top) the frame in which the given component is loaded, if any 71 72 @return 73 <TRUE/> if any only of such a frame was found, i.e. the component had already been loaded 74 previously 75 */ 76 bool activateSubFrame( 77 const OUString& _rName, 78 const sal_Int32 _nComponentType, 79 const ElementOpenMode _eOpenMode, 80 css::uno::Reference< css::lang::XComponent >& o_rComponent 81 ) const; 82 83 /** closes all frames of the given component 84 85 If a view for the component (given by name and type) has been loaded into one or more 86 frames (with potentially different OpenModes), then those frames are gracefully closed. 87 88 @return 89 <TRUE/> if and only if closing those frames was successful, or frames for the given sub component 90 exist. 91 */ 92 bool closeSubFrames( 93 std::u16string_view _rName, 94 const sal_Int32 _nComponentType 95 ); 96 97 /** searches for the given sub component 98 99 @param i_rComponent 100 the sub component to look up 101 @param o_rName 102 contains, upon successful return, the name of the sub component 103 @param o_nComponentType 104 contains, upon successful return, the type of the sub component 105 @return 106 <TRUE/> if and only if the component was found 107 */ 108 bool lookupSubComponent( 109 const css::uno::Reference< css::lang::XComponent >& i_rComponent, 110 OUString& o_rName, 111 sal_Int32& o_rComponentType 112 ); 113 114 private: 115 std::unique_ptr< SubComponentManager_Data > m_pData; 116 }; 117 118 } // namespace dbaui 119 120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 121