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 _DBAUI_DBADMIN_HXX_ 29 #define _DBAUI_DBADMIN_HXX_ 30 31 #ifndef _SFXTABDLG_HXX 32 #include <sfx2/tabdlg.hxx> 33 #endif 34 #ifndef _DBAUI_DSNTYPES_HXX_ 35 #include "dsntypes.hxx" 36 #endif 37 #ifndef DBAUI_ITEMSETHELPER_HXX 38 #include "IItemSetHelper.hxx" 39 #endif 40 #ifndef _COMPHELPER_UNO3_HXX_ 41 #include <comphelper/uno3.hxx> 42 #endif 43 #include <memory> 44 45 FORWARD_DECLARE_INTERFACE(beans,XPropertySet) 46 FORWARD_DECLARE_INTERFACE(sdbc,XConnection) 47 FORWARD_DECLARE_INTERFACE(lang,XMultiServiceFactory) 48 49 //......................................................................... 50 namespace dbaui 51 { 52 //......................................................................... 53 54 //========================================================================= 55 //= ODbAdminDialog 56 //========================================================================= 57 class OGeneralPage; 58 class ODbDataSourceAdministrationHelper; 59 /** tab dialog for administrating the office wide registered data sources 60 */ 61 class ODbAdminDialog : public SfxTabDialog , public IItemSetHelper, public IDatabaseSettingsDialog 62 { 63 private: 64 typedef ::std::stack< sal_Int32 > PageStack; 65 PageStack m_aCurrentDetailPages; // ids of all currently enabled (type-dependent) detail pages 66 67 ::std::auto_ptr<ODbDataSourceAdministrationHelper> m_pImpl; 68 69 sal_Bool m_bApplied : 1; /// sal_True if any changes have been applied while the dialog was executing 70 sal_Bool m_bUIEnabled : 1; /// <TRUE/> if the UI is enabled, false otherwise. Cannot be switched back to <TRUE/>, once it is <FALSE/> 71 sal_uInt16 m_nMainPageID; 72 73 public: 74 /** ctor. The itemset given should have been created by <method>createItemSet</method> and should be destroyed 75 after the dialog has been destroyed 76 */ 77 ODbAdminDialog(Window* pParent, 78 SfxItemSet* _pItems, 79 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB 80 ); 81 virtual ~ODbAdminDialog(); 82 83 /** create and return an item set for use with the dialog. 84 @param _pTypeCollection pointer to an <type>ODatasourceMap</type>. May be NULL, in this case 85 the pool will not contain a typecollection default. 86 */ 87 static SfxItemSet* createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults, ::dbaccess::ODsnTypeCollection* _pTypeCollection); 88 /** destroy and item set / item pool / pool defaults previously created by <method>createItemSet</method> 89 */ 90 static void destroyItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults); 91 92 /** selects the DataSource 93 @param _rName 94 The name of the data source 95 */ 96 void selectDataSource(const ::com::sun::star::uno::Any& _aDataSourceName); 97 98 virtual const SfxItemSet* getOutputSet() const; 99 virtual SfxItemSet* getWriteOutputSet(); 100 101 // forwards to ODbDataSourceAdministrationHelper 102 virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const; 103 virtual ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >,sal_Bool> createConnection(); 104 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver(); 105 virtual ::rtl::OUString getDatasourceType(const SfxItemSet& _rSet) const; 106 virtual void clearPassword(); 107 virtual sal_Bool saveDatasource(); 108 virtual void setTitle(const ::rtl::OUString& _sTitle); 109 virtual void enableConfirmSettings( bool _bEnable ); 110 111 protected: 112 // adds a new detail page and remove all the old ones 113 void addDetailPage(sal_uInt16 _nPageId,sal_uInt16 _nTextId,CreateTabPage pCreateFunc); 114 115 virtual void PageCreated(sal_uInt16 _nId, SfxTabPage& _rPage); 116 virtual short Ok(); 117 118 protected: 119 inline sal_Bool isUIEnabled() const { return m_bUIEnabled; } 120 inline void disabledUI() { m_bUIEnabled = sal_False; } 121 122 private: 123 /// select a datasource with a given name, adjust the item set accordingly, and everything like that .. 124 void impl_selectDataSource(const ::com::sun::star::uno::Any& _aDataSourceName); 125 /// reset the tag pages according to m_sCurrentDatasource and <arg>_rxDatasource</arg> 126 void impl_resetPages(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDatasource); 127 128 enum ApplyResult 129 { 130 AR_LEAVE_MODIFIED, // somthing was modified and has successfully been committed 131 AR_LEAVE_UNCHANGED, // no changes were made 132 AR_KEEP // don't leave the page (e.g. because an error occured) 133 }; 134 /** apply all changes made 135 */ 136 ApplyResult implApplyChanges(); 137 }; 138 139 //......................................................................... 140 } // namespace dbaui 141 //......................................................................... 142 143 #endif // _DBAUI_DBADMIN_HXX_ 144 145