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