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