1*2e2212a7SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2e2212a7SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2e2212a7SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2e2212a7SAndrew Rist * distributed with this work for additional information 6*2e2212a7SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2e2212a7SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2e2212a7SAndrew Rist * "License"); you may not use this file except in compliance 9*2e2212a7SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*2e2212a7SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*2e2212a7SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2e2212a7SAndrew Rist * software distributed under the License is distributed on an 15*2e2212a7SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2e2212a7SAndrew Rist * KIND, either express or implied. See the License for the 17*2e2212a7SAndrew Rist * specific language governing permissions and limitations 18*2e2212a7SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*2e2212a7SAndrew Rist *************************************************************/ 21*2e2212a7SAndrew Rist 22*2e2212a7SAndrew Rist 23cdf0e10cSrcweir #ifndef DBA_CONTAINERMEDIATOR_HXX 24cdf0e10cSrcweir #define DBA_CONTAINERMEDIATOR_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_HPP_ 27cdf0e10cSrcweir #include <com/sun/star/container/XContainerListener.hpp> 28cdf0e10cSrcweir #endif 29cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_ 30cdf0e10cSrcweir #include <com/sun/star/container/XContainer.hpp> 31cdf0e10cSrcweir #endif 32cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ 33cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp> 34cdf0e10cSrcweir #endif 35cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ 36cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 37cdf0e10cSrcweir #endif 38cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ 39cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp> 40cdf0e10cSrcweir #endif 41cdf0e10cSrcweir 42cdf0e10cSrcweir #ifndef _COMPHELPER_BROADCASTHELPER_HXX_ 43cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx> 44cdf0e10cSrcweir #endif 45cdf0e10cSrcweir #ifndef _COMPHELPER_BROADCASTHELPER_HXX_ 46cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx> 47cdf0e10cSrcweir #endif 48cdf0e10cSrcweir #ifndef _CPPUHELPER_IMPLBASE1_HXX_ 49cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 50cdf0e10cSrcweir #endif 51cdf0e10cSrcweir #ifndef _RTL_REF_HXX_ 52cdf0e10cSrcweir #include <rtl/ref.hxx> 53cdf0e10cSrcweir #endif 54cdf0e10cSrcweir 55cdf0e10cSrcweir #include <map> 56cdf0e10cSrcweir 57cdf0e10cSrcweir //........................................................................ 58cdf0e10cSrcweir namespace dbaccess 59cdf0e10cSrcweir { 60cdf0e10cSrcweir //........................................................................ 61cdf0e10cSrcweir 62cdf0e10cSrcweir class OPropertyForward; 63cdf0e10cSrcweir 64cdf0e10cSrcweir class OContainerMediator : public ::comphelper::OBaseMutex 65cdf0e10cSrcweir ,public ::cppu::WeakImplHelper1< ::com::sun::star::container::XContainerListener > 66cdf0e10cSrcweir { 67cdf0e10cSrcweir public: 68cdf0e10cSrcweir enum ContainerType 69cdf0e10cSrcweir { 70cdf0e10cSrcweir eColumns, 71cdf0e10cSrcweir eTables 72cdf0e10cSrcweir }; 73cdf0e10cSrcweir 74cdf0e10cSrcweir private: 75cdf0e10cSrcweir typedef ::rtl::Reference< OPropertyForward > TPropertyForward; 76cdf0e10cSrcweir typedef ::std::map< ::rtl::OUString, TPropertyForward > PropertyForwardList; 77cdf0e10cSrcweir PropertyForwardList m_aForwardList; 78cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xSettings; // can not be weak 79cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer > m_xContainer; // can not be weak 80cdf0e10cSrcweir ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XConnection > m_aConnection; 81cdf0e10cSrcweir ContainerType m_eType; 82cdf0e10cSrcweir 83cdf0e10cSrcweir protected: 84cdf0e10cSrcweir virtual ~OContainerMediator(); 85cdf0e10cSrcweir 86cdf0e10cSrcweir public: 87cdf0e10cSrcweir OContainerMediator( 88cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer >& _xContainer, 89cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xSettings, 90cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, 91cdf0e10cSrcweir ContainerType _eType 92cdf0e10cSrcweir ); 93cdf0e10cSrcweir 94cdf0e10cSrcweir virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException); 95cdf0e10cSrcweir virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException); 96cdf0e10cSrcweir virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException); 97cdf0e10cSrcweir virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); 98cdf0e10cSrcweir 99cdf0e10cSrcweir void notifyElementCreated(const ::rtl::OUString& _sElementName 100cdf0e10cSrcweir ,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xElement); 101cdf0e10cSrcweir 102cdf0e10cSrcweir private: 103cdf0e10cSrcweir /** cleans up the instance, by deregistering as listener at the containers, 104cdf0e10cSrcweir and resetting them to <NULL/> 105cdf0e10cSrcweir */ 106cdf0e10cSrcweir void impl_cleanup_nothrow(); 107cdf0e10cSrcweir 108cdf0e10cSrcweir /** initializes the properties of the given object from its counterpart in our settings container 109cdf0e10cSrcweir */ 110cdf0e10cSrcweir void impl_initSettings_nothrow( 111cdf0e10cSrcweir const ::rtl::OUString& _rName, 112cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDestination 113cdf0e10cSrcweir ); 114cdf0e10cSrcweir }; 115cdf0e10cSrcweir //........................................................................ 116cdf0e10cSrcweir } // namespace dbaccess 117cdf0e10cSrcweir //........................................................................ 118cdf0e10cSrcweir 119cdf0e10cSrcweir #endif // DBA_CONTAINERMEDIATOR_HXX 120