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 28 #ifndef _BIB_DATMAN_HXX 29 #define _BIB_DATMAN_HXX 30 31 #include <com/sun/star/awt/XControlModel.hpp> 32 #include <com/sun/star/form/XForm.hpp> 33 #include <com/sun/star/sdbc/XResultSet.hpp> 34 #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> 35 #include <com/sun/star/form/runtime/XFormController.hpp> 36 #include <cppuhelper/compbase2.hxx> 37 #include <cppuhelper/interfacecontainer.h> 38 #include <com/sun/star/form/XLoadable.hpp> 39 #include <comphelper/broadcasthelper.hxx> 40 // #100312# -------------------- 41 #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp> 42 #include <com/sun/star/frame/XDispatchProviderInterception.hpp> 43 #include <cppuhelper/implbase1.hxx> 44 45 class Window; 46 47 //----------------------------------------------------------------------------- 48 namespace bib 49 { 50 class BibView; 51 // #100312# ----------- 52 class BibBeamer; 53 } 54 55 class BibToolBar; 56 struct BibDBDescriptor; 57 58 // #100312# --------------------- 59 class BibInterceptorHelper 60 :public cppu::WeakImplHelper1< ::com::sun::star::frame::XDispatchProviderInterceptor > 61 { 62 private: 63 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > xMasterDispatchProvider; 64 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > xSlaveDispatchProvider; 65 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xFormDispatch; 66 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception > xInterception; 67 68 protected: 69 ~BibInterceptorHelper( ); 70 71 public: 72 BibInterceptorHelper( ::bib::BibBeamer* pBibBeamer, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch); 73 74 void ReleaseInterceptor(); 75 76 // XDispatchProvider 77 virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw (::com::sun::star::uno::RuntimeException); 78 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw (::com::sun::star::uno::RuntimeException); 79 // XDispatchProviderInterceptor 80 virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getSlaveDispatchProvider( ) throw (::com::sun::star::uno::RuntimeException); 81 virtual void SAL_CALL setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSlaveDispatchProvider ) throw (::com::sun::star::uno::RuntimeException); 82 virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getMasterDispatchProvider( ) throw (::com::sun::star::uno::RuntimeException); 83 virtual void SAL_CALL setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewMasterDispatchProvider ) throw (::com::sun::star::uno::RuntimeException); 84 }; 85 86 typedef cppu::WeakComponentImplHelper2 < ::com::sun::star::beans::XPropertyChangeListener 87 , ::com::sun::star::form::XLoadable 88 > BibDataManager_Base; 89 class BibDataManager 90 :public ::comphelper::OMutexAndBroadcastHelper 91 ,public BibDataManager_Base 92 { 93 private: 94 ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > m_xForm; 95 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > m_xGridModel; 96 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xSourceProps; 97 ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > m_xParser; 98 ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xFormCtrl; 99 // #100312# ------------------- 100 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xFormDispatch; 101 BibInterceptorHelper* m_pInterceptorHelper; 102 103 ::rtl::OUString aActiveDataTable; 104 ::rtl::OUString aDataSourceURL; 105 ::rtl::OUString aQuoteChar; 106 ::com::sun::star::uno::Any aUID; 107 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > xBibCursor; 108 109 ::cppu::OInterfaceContainerHelper m_aLoadListeners; 110 111 ::bib::BibView* pBibView; 112 BibToolBar* pToolbar; 113 114 rtl::OUString sIdentifierMapping; 115 protected: 116 117 void InsertFields(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > & xGrid); 118 void SetMeAsUidListener(); 119 void RemoveMeAsUidListener(); 120 121 void UpdateAddressbookCursor(::rtl::OUString aSourceName); 122 123 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > 124 updateGridModel(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > & xDbForm); 125 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > 126 createGridModel( const ::rtl::OUString& rName ); 127 128 // XLoadable 129 virtual void SAL_CALL load( ) throw (::com::sun::star::uno::RuntimeException); 130 virtual void SAL_CALL unload( ) throw (::com::sun::star::uno::RuntimeException); 131 virtual void SAL_CALL reload( ) throw (::com::sun::star::uno::RuntimeException); 132 virtual sal_Bool SAL_CALL isLoaded( ) throw (::com::sun::star::uno::RuntimeException); 133 virtual void SAL_CALL addLoadListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); 134 virtual void SAL_CALL removeLoadListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); 135 136 virtual void SAL_CALL disposing(); 137 138 public: 139 140 BibDataManager(); 141 ~BibDataManager(); 142 143 virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) 144 throw( ::com::sun::star::uno::RuntimeException ); 145 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) 146 throw( ::com::sun::star::uno::RuntimeException ); 147 148 149 150 ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > createDatabaseForm( BibDBDescriptor& aDesc); 151 152 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > updateGridModel(); 153 154 ::com::sun::star::uno::Sequence< ::rtl::OUString> getDataSources(); 155 156 ::rtl::OUString getActiveDataSource() {return aDataSourceURL;} 157 void setActiveDataSource(const ::rtl::OUString& rURL); 158 159 ::rtl::OUString getActiveDataTable(); 160 void setActiveDataTable(const ::rtl::OUString& rTable); 161 162 void setFilter(const ::rtl::OUString& rQuery); 163 ::rtl::OUString getFilter(); 164 165 ::com::sun::star::uno::Sequence< ::rtl::OUString> getQueryFields(); 166 ::rtl::OUString getQueryField(); 167 void startQueryWith(const ::rtl::OUString& rQuery); 168 169 const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >& getParser() { return m_xParser; } 170 const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& getForm() { return m_xForm; } 171 172 173 ::rtl::OUString getControlName(sal_Int32 nFormatKey ); 174 175 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > loadControlModel(const ::rtl::OUString& rName, 176 sal_Bool bForceListBox = sal_False); 177 178 void CreateMappingDialog(Window* pParent); 179 ::rtl::OUString CreateDBChangeDialog(Window* pParent); 180 181 void DispatchDBChangeDialog(); 182 sal_Bool HasActiveConnection() const; 183 184 void SetView( ::bib::BibView* pView ) { pBibView = pView; } 185 186 void SetToolbar(BibToolBar* pSet); 187 188 const rtl::OUString& GetIdentifierMapping(); 189 void ResetIdentifierMapping() {sIdentifierMapping = rtl::OUString();} 190 191 ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > GetFormController(); 192 // #100312# ---------- 193 void RegisterInterceptor( ::bib::BibBeamer* pBibBeamer); 194 195 sal_Bool HasActiveConnection(); 196 }; 197 198 199 #endif 200