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_DBWIZ_HXX 29 #define DBAUI_DBWIZ_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 #ifndef _SVTOOLS_WIZARDMACHINE_HXX_ 44 #include <svtools/wizardmachine.hxx> 45 #endif 46 #ifndef _DBAUI_MODULE_DBU_HXX_ 47 #include "moduledbu.hxx" 48 #endif 49 #include <memory> 50 51 FORWARD_DECLARE_INTERFACE(beans,XPropertySet) 52 FORWARD_DECLARE_INTERFACE(sdbc,XConnection) 53 FORWARD_DECLARE_INTERFACE(lang,XMultiServiceFactory) 54 55 namespace dbaccess 56 { 57 class ODsnTypeCollection; 58 } 59 //......................................................................... 60 namespace dbaui 61 { 62 //......................................................................... 63 64 //========================================================================= 65 //= ODbTypeWizDialog 66 //========================================================================= 67 class OGeneralPage; 68 class ODbDataSourceAdministrationHelper; 69 /** tab dialog for administrating the office wide registered data sources 70 */ 71 class ODbTypeWizDialog : public svt::OWizardMachine , public IItemSetHelper, public IDatabaseSettingsDialog,public dbaui::OModuleClient 72 { 73 private: 74 OModuleClient m_aModuleClient; 75 ::std::auto_ptr<ODbDataSourceAdministrationHelper> m_pImpl; 76 SfxItemSet* m_pOutSet; 77 ::dbaccess::ODsnTypeCollection* 78 m_pCollection; /// the DSN type collection instance 79 ::rtl::OUString m_eType; 80 81 sal_Bool m_bResetting : 1; /// sal_True while we're resetting the pages 82 sal_Bool m_bApplied : 1; /// sal_True if any changes have been applied while the dialog was executing 83 sal_Bool m_bUIEnabled : 1; /// <TRUE/> if the UI is enabled, false otherwise. Cannot be switched back to <TRUE/>, once it is <FALSE/> 84 85 public: 86 /** ctor. The itemset given should have been created by <method>createItemSet</method> and should be destroyed 87 after the dialog has been destroyed 88 */ 89 ODbTypeWizDialog(Window* pParent 90 ,SfxItemSet* _pItems 91 ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB 92 ,const ::com::sun::star::uno::Any& _aDataSourceName 93 ); 94 virtual ~ODbTypeWizDialog(); 95 96 virtual const SfxItemSet* getOutputSet() const; 97 virtual SfxItemSet* getWriteOutputSet(); 98 99 // forwards to ODbDataSourceAdministrationHelper 100 virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const; 101 virtual ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >,sal_Bool> createConnection(); 102 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver(); 103 virtual ::rtl::OUString getDatasourceType(const SfxItemSet& _rSet) const; 104 virtual void clearPassword(); 105 virtual sal_Bool saveDatasource(); 106 virtual void setTitle(const ::rtl::OUString& _sTitle); 107 virtual void enableConfirmSettings( bool _bEnable ); 108 109 protected: 110 /// to override to create new pages 111 virtual TabPage* createPage(WizardState _nState); 112 virtual WizardState determineNextState(WizardState _nCurrentState) const; 113 virtual sal_Bool leaveState(WizardState _nState); 114 virtual ::svt::IWizardPageController* 115 getPageController( TabPage* _pCurrentPage ) const; 116 virtual sal_Bool onFinish(); 117 118 protected: 119 inline sal_Bool isUIEnabled() const { return m_bUIEnabled; } 120 inline void disabledUI() { m_bUIEnabled = sal_False; } 121 122 /// select a datasource with a given name, adjust the item set accordingly, and everything like that .. 123 void implSelectDatasource(const ::rtl::OUString& _rRegisteredName); 124 void resetPages(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDatasource); 125 126 enum ApplyResult 127 { 128 AR_LEAVE_MODIFIED, // somthing was modified and has successfully been committed 129 AR_LEAVE_UNCHANGED, // no changes were made 130 AR_KEEP // don't leave the page (e.g. because an error occured) 131 }; 132 /** apply all changes made 133 */ 134 ApplyResult implApplyChanges(); 135 136 private: 137 DECL_LINK(OnTypeSelected, OGeneralPage*); 138 }; 139 140 //......................................................................... 141 } // namespace dbaui 142 //......................................................................... 143 144 #endif // DBAUI_DBWIZ_HXX 145 146