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