xref: /trunk/main/dbaccess/source/ui/inc/dbwizsetup.hxx (revision cdf0e10c)
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_DBWIZ2_HXX
29 #define DBAUI_DBWIZ2_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 _URLOBJ_HXX
44 #include <tools/urlobj.hxx>
45 #endif
46 #include <memory>
47 #ifndef SVTOOLS_INC_ROADMAPWIZARD_HXX
48 #include <svtools/roadmapwizard.hxx>
49 #endif
50 #ifndef _CONNECTIVITY_DBTOOLS_HXX_
51 #include <connectivity/dbtools.hxx>
52 #endif
53 #ifndef _DBAUI_MODULE_DBU_HXX_
54 #include "moduledbu.hxx"
55 #endif
56 
57 FORWARD_DECLARE_INTERFACE(beans,XPropertySet)
58 FORWARD_DECLARE_INTERFACE(sdbc,XConnection)
59 FORWARD_DECLARE_INTERFACE(lang,XMultiServiceFactory)
60 
61 //.........................................................................
62 namespace dbaui
63 {
64 //.........................................................................
65 
66 class OGenericAdministrationPage;
67 
68 //=========================================================================
69 //= ODbTypeWizDialogSetup
70 //=========================================================================
71 class OGeneralPage;
72 class ODbDataSourceAdministrationHelper;
73 /** tab dialog for administrating the office wide registered data sources
74 */
75 class OMySQLIntroPageSetup;
76 
77 class ODbTypeWizDialogSetup : public svt::RoadmapWizard , public IItemSetHelper, public IDatabaseSettingsDialog,public dbaui::OModuleClient
78 {
79 
80 private:
81 	OModuleClient m_aModuleClient;
82 	::std::auto_ptr<ODbDataSourceAdministrationHelper>	m_pImpl;
83 	SfxItemSet*				m_pOutSet;
84 	::rtl::OUString         m_sURL;
85     ::rtl::OUString         m_sOldURL;
86 	sal_Bool				m_bResetting : 1;	/// sal_True while we're resetting the pages
87 	sal_Bool				m_bApplied : 1;		/// sal_True if any changes have been applied while the dialog was executing
88 	sal_Bool				m_bUIEnabled : 1;	/// <TRUE/> if the UI is enabled, false otherwise. Cannot be switched back to <TRUE/>, once it is <FALSE/>
89     sal_Bool                m_bIsConnectable : 1;
90     String                  m_sRM_IntroText;
91     String                  m_sRM_dBaseText;
92     String                  m_sRM_TextText;
93     String                  m_sRM_MSAccessText;
94     String                  m_sRM_LDAPText;
95     String                  m_sRM_ADABASText;
96     String                  m_sRM_ADOText;
97     String                  m_sRM_JDBCText;
98     String                  m_sRM_MySQLNativePageTitle;
99     String                  m_sRM_OracleText;
100     String                  m_sRM_MySQLText;
101     String                  m_sRM_ODBCText;
102     String                  m_sRM_SpreadSheetText;
103     String                  m_sRM_AuthentificationText;
104     String                  m_sRM_FinalText;
105     INetURLObject           m_aDocURL;
106     String                  m_sWorkPath;
107     OGeneralPage*           m_pGeneralPage;
108 	OMySQLIntroPageSetup*	m_pMySQLIntroPage;
109     ::dbaccess::ODsnTypeCollection*
110                             m_pCollection;	/// the DSN type collection instance
111 
112 
113 
114 public:
115 	/** ctor. The itemset given should have been created by <method>createItemSet</method> and should be destroyed
116 		after the dialog has been destroyed
117 	*/
118 	ODbTypeWizDialogSetup(Window* pParent
119 		,SfxItemSet* _pItems
120 		,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
121 		,const ::com::sun::star::uno::Any& _aDataSourceName
122 		);
123 	virtual ~ODbTypeWizDialogSetup();
124 
125 	virtual const SfxItemSet* getOutputSet() const;
126 	virtual SfxItemSet* getWriteOutputSet();
127 
128 	// forwards to ODbDataSourceAdministrationHelper
129 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const;
130 	virtual ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >,sal_Bool> createConnection();
131 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver >	getDriver();
132 	virtual ::rtl::OUString getDatasourceType(const SfxItemSet& _rSet) const;
133 	virtual void clearPassword();
134 	virtual void setTitle(const ::rtl::OUString& _sTitle);
135     virtual void enableConfirmSettings( bool _bEnable );
136     virtual sal_Bool saveDatasource();
137     virtual String  getStateDisplayName( WizardState _nState ) const;
138 
139     /** returns <TRUE/> if the database should be opened, otherwise <FALSE/>.
140     */
141     sal_Bool IsDatabaseDocumentToBeOpened() const;
142 
143     /** returns <TRUE/> if the table wizard should be opened, otherwise <FALSE/>.
144     */
145     sal_Bool IsTableWizardToBeStarted() const;
146 
147 protected:
148 	/// to override to create new pages
149 	virtual TabPage*	createPage(WizardState _nState);
150 	virtual	sal_Bool	leaveState(WizardState _nState);
151     virtual void enterState(WizardState _nState);
152 	virtual ::svt::IWizardPageController* getPageController( TabPage* _pCurrentPage ) const;
153 	virtual sal_Bool onFinish();
154 
155 protected:
156 	inline sal_Bool	isUIEnabled() const { return m_bUIEnabled; }
157 	inline void		disabledUI() { m_bUIEnabled = sal_False; }
158 
159 	/// select a datasource with a given name, adjust the item set accordingly, and everything like that ..
160 	void implSelectDatasource(const ::rtl::OUString& _rRegisteredName);
161 	void resetPages(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDatasource);
162 
163 	enum ApplyResult
164 	{
165 		AR_LEAVE_MODIFIED,		// somthing was modified and has successfully been committed
166 		AR_LEAVE_UNCHANGED,		// no changes were made
167 		AR_KEEP					// don't leave the page (e.g. because an error occured)
168 	};
169 
170 private:
171     /** declares a path with or without authentication, as indicated by the database type
172 
173         @param _sURL
174             the data source type for which the path is declared. If this
175             data source type does not support authentication, the PAGE_DBSETUPWIZARD_AUTHENTIFICATION
176             state will be stripped from the sequence of states.
177         @param _nPathId
178             the ID of the path
179         @path
180             the first state in this path, following by an arbitrary number of others, as in
181             RoadmapWizard::declarePath.
182     */
183     void declareAuthDepPath( const ::rtl::OUString& _sURL, PathId _nPathId, const svt::RoadmapWizardTypes::WizardPath& _rPaths);
184 
185     void RegisterDataSourceByLocation(const ::rtl::OUString& sPath);
186     sal_Bool SaveDatabaseDocument();
187     void activateDatabasePath();
188     String createUniqueFileName(const INetURLObject& rURL);
189     void CreateDatabase();
190     void createUniqueFolderName(INetURLObject* pURL);
191 	::dbaccess::DATASOURCE_TYPE VerifyDataSourceType(const ::dbaccess::DATASOURCE_TYPE _DatabaseType) const;
192 
193     ::rtl::OUString getDefaultDatabaseType() const;
194 
195     void updateTypeDependentStates();
196     sal_Bool callSaveAsDialog();
197     sal_Bool IsConnectionUrlRequired();
198 	DECL_LINK(OnTypeSelected, OGeneralPage*);
199 	DECL_LINK(OnChangeCreationMode, OGeneralPage*);
200     DECL_LINK(OnRecentDocumentSelected, OGeneralPage*);
201     DECL_LINK(OnSingleDocumentChosen, OGeneralPage*);
202     DECL_LINK(ImplClickHdl, OMySQLIntroPageSetup*);
203     DECL_LINK(ImplModifiedHdl, OGenericAdministrationPage*);
204 };
205 
206 //.........................................................................
207 }	// namespace dbaui
208 //.........................................................................
209 
210 #endif // DBAUI_DBWIZ2_HXX
211 
212