1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef DBA_CONTAINERMEDIATOR_HXX 28 #define DBA_CONTAINERMEDIATOR_HXX 29 30 #ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_HPP_ 31 #include <com/sun/star/container/XContainerListener.hpp> 32 #endif 33 #ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_ 34 #include <com/sun/star/container/XContainer.hpp> 35 #endif 36 #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ 37 #include <com/sun/star/container/XNameContainer.hpp> 38 #endif 39 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ 40 #include <com/sun/star/beans/XPropertySet.hpp> 41 #endif 42 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ 43 #include <com/sun/star/sdbc/XConnection.hpp> 44 #endif 45 46 #ifndef _COMPHELPER_BROADCASTHELPER_HXX_ 47 #include <comphelper/broadcasthelper.hxx> 48 #endif 49 #ifndef _COMPHELPER_BROADCASTHELPER_HXX_ 50 #include <comphelper/broadcasthelper.hxx> 51 #endif 52 #ifndef _CPPUHELPER_IMPLBASE1_HXX_ 53 #include <cppuhelper/implbase1.hxx> 54 #endif 55 #ifndef _RTL_REF_HXX_ 56 #include <rtl/ref.hxx> 57 #endif 58 59 #include <map> 60 61 //........................................................................ 62 namespace dbaccess 63 { 64 //........................................................................ 65 66 class OPropertyForward; 67 68 class OContainerMediator : public ::comphelper::OBaseMutex 69 ,public ::cppu::WeakImplHelper1< ::com::sun::star::container::XContainerListener > 70 { 71 public: 72 enum ContainerType 73 { 74 eColumns, 75 eTables 76 }; 77 78 private: 79 typedef ::rtl::Reference< OPropertyForward > TPropertyForward; 80 typedef ::std::map< ::rtl::OUString, TPropertyForward > PropertyForwardList; 81 PropertyForwardList m_aForwardList; 82 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xSettings; // can not be weak 83 ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer > m_xContainer; // can not be weak 84 ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XConnection > m_aConnection; 85 ContainerType m_eType; 86 87 protected: 88 virtual ~OContainerMediator(); 89 90 public: 91 OContainerMediator( 92 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer >& _xContainer, 93 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xSettings, 94 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, 95 ContainerType _eType 96 ); 97 98 virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException); 99 virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException); 100 virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException); 101 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); 102 103 void notifyElementCreated(const ::rtl::OUString& _sElementName 104 ,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xElement); 105 106 private: 107 /** cleans up the instance, by deregistering as listener at the containers, 108 and resetting them to <NULL/> 109 */ 110 void impl_cleanup_nothrow(); 111 112 /** initializes the properties of the given object from its counterpart in our settings container 113 */ 114 void impl_initSettings_nothrow( 115 const ::rtl::OUString& _rName, 116 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDestination 117 ); 118 }; 119 //........................................................................ 120 } // namespace dbaccess 121 //........................................................................ 122 123 #endif // DBA_CONTAINERMEDIATOR_HXX 124