1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dbwizsetup.hxx,v $
10 * $Revision: 1.14.68.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef DBAUI_DBWIZ2_HXX
32 #define DBAUI_DBWIZ2_HXX
34 #ifndef _SFXTABDLG_HXX
35 #include <sfx2/tabdlg.hxx>
37 #ifndef _DBAUI_DSNTYPES_HXX_
38 #include "dsntypes.hxx"
40 #ifndef DBAUI_ITEMSETHELPER_HXX
41 #include "IItemSetHelper.hxx"
43 #ifndef _COMPHELPER_UNO3_HXX_
44 #include <comphelper/uno3.hxx>
47 #include <tools/urlobj.hxx>
50 #ifndef SVTOOLS_INC_ROADMAPWIZARD_HXX
51 #include <svtools/roadmapwizard.hxx>
53 #ifndef _CONNECTIVITY_DBTOOLS_HXX_
54 #include <connectivity/dbtools.hxx>
56 #ifndef _DBAUI_MODULE_DBU_HXX_
57 #include "moduledbu.hxx"
60 FORWARD_DECLARE_INTERFACE(beans
,XPropertySet
)
61 FORWARD_DECLARE_INTERFACE(sdbc
,XConnection
)
62 FORWARD_DECLARE_INTERFACE(lang
,XMultiServiceFactory
)
64 //.........................................................................
67 //.........................................................................
69 class OGenericAdministrationPage
;
71 //=========================================================================
72 //= ODbTypeWizDialogSetup
73 //=========================================================================
75 class ODbDataSourceAdministrationHelper
;
76 /** tab dialog for administrating the office wide registered data sources
78 class OMySQLIntroPageSetup
;
80 class ODbTypeWizDialogSetup
: public svt::RoadmapWizard
, public IItemSetHelper
, public IDatabaseSettingsDialog
,public dbaui::OModuleClient
84 OModuleClient m_aModuleClient
;
85 ::std::auto_ptr
<ODbDataSourceAdministrationHelper
> m_pImpl
;
86 SfxItemSet
* m_pOutSet
;
87 ::rtl::OUString m_sURL
;
88 ::rtl::OUString m_sOldURL
;
89 sal_Bool m_bResetting
: 1; /// sal_True while we're resetting the pages
90 sal_Bool m_bApplied
: 1; /// sal_True if any changes have been applied while the dialog was executing
91 sal_Bool m_bUIEnabled
: 1; /// <TRUE/> if the UI is enabled, false otherwise. Cannot be switched back to <TRUE/>, once it is <FALSE/>
92 sal_Bool m_bIsConnectable
: 1;
93 String m_sRM_IntroText
;
94 String m_sRM_dBaseText
;
95 String m_sRM_TextText
;
96 String m_sRM_MSAccessText
;
97 String m_sRM_LDAPText
;
98 String m_sRM_ADABASText
;
100 String m_sRM_JDBCText
;
101 String m_sRM_OracleText
;
102 String m_sRM_MySQLText
;
103 String m_sRM_ODBCText
;
104 String m_sRM_SpreadSheetText
;
105 String m_sRM_AuthentificationText
;
106 String m_sRM_FinalText
;
107 INetURLObject m_aDocURL
;
109 OGeneralPage
* m_pGeneralPage
;
110 OMySQLIntroPageSetup
* m_pMySQLIntroPage
;
111 ::dbaccess::ODsnTypeCollection
*
112 m_pCollection
; /// the DSN type collection instance
117 /** ctor. The itemset given should have been created by <method>createItemSet</method> and should be destroyed
118 after the dialog has been destroyed
120 ODbTypeWizDialogSetup(Window
* pParent
122 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _rxORB
123 ,const ::com::sun::star::uno::Any
& _aDataSourceName
125 virtual ~ODbTypeWizDialogSetup();
127 virtual const SfxItemSet
* getOutputSet() const;
128 virtual SfxItemSet
* getWriteOutputSet();
130 // forwards to ODbDataSourceAdministrationHelper
131 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> getORB() const;
132 virtual ::std::pair
< ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>,sal_Bool
> createConnection();
133 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDriver
> getDriver();
134 virtual ::rtl::OUString
getDatasourceType(const SfxItemSet
& _rSet
) const;
135 virtual void clearPassword();
136 virtual void setTitle(const ::rtl::OUString
& _sTitle
);
137 virtual void enableConfirmSettings( bool _bEnable
);
138 virtual sal_Bool
saveDatasource();
139 virtual String
getStateDisplayName( WizardState _nState
) const;
141 /** returns <TRUE/> if the database should be opened, otherwise <FALSE/>.
143 sal_Bool
IsDatabaseDocumentToBeOpened() const;
145 /** returns <TRUE/> if the table wizard should be opened, otherwise <FALSE/>.
147 sal_Bool
IsTableWizardToBeStarted() const;
150 /// to override to create new pages
151 virtual TabPage
* createPage(WizardState _nState
);
152 virtual sal_Bool
leaveState(WizardState _nState
);
153 virtual void enterState(WizardState _nState
);
154 virtual ::svt::IWizardPage
* getWizardPage(TabPage
* _pCurrentPage
) const;
155 virtual sal_Bool
onFinish(sal_Int32 _nResult
);
158 inline sal_Bool
isUIEnabled() const { return m_bUIEnabled
; }
159 inline void disabledUI() { m_bUIEnabled
= sal_False
; }
161 /// select a datasource with a given name, adjust the item set accordingly, and everything like that ..
162 void implSelectDatasource(const ::rtl::OUString
& _rRegisteredName
);
163 void resetPages(const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxDatasource
);
167 AR_LEAVE_MODIFIED
, // somthing was modified and has successfully been committed
168 AR_LEAVE_UNCHANGED
, // no changes were made
169 AR_KEEP
// don't leave the page (e.g. because an error occured)
173 /** declares a path with or without authentication, as indicated by the database type
176 the data source type for which the path is declared. If this
177 data source type does not support authentication, the PAGE_DBSETUPWIZARD_AUTHENTIFICATION
178 state will be stripped from the sequence of states.
182 the first state in this path, following by an arbitrary number of others, as in
183 RoadmapWizard::declarePath.
185 void declareAuthDepPath( const ::rtl::OUString
& _sURL
, PathId _nPathId
, const svt::RoadmapWizardTypes::WizardPath
& _rPaths
);
187 void RegisterDataSourceByLocation(const ::rtl::OUString
& sPath
);
188 sal_Bool
SaveDatabaseDocument();
189 void activateDatabasePath();
190 String
createUniqueFileName(const INetURLObject
& rURL
);
191 void CreateDatabase();
192 void createUniqueFolderName(INetURLObject
* pURL
);
193 ::dbaccess::DATASOURCE_TYPE
VerifyDataSourceType(const ::dbaccess::DATASOURCE_TYPE _DatabaseType
) const;
195 ::rtl::OUString
getDefaultDatabaseType() const;
197 void updateTypeDependentStates();
198 sal_Bool
callSaveAsDialog();
199 sal_Bool
IsConnectionUrlRequired();
200 DECL_LINK(OnTypeSelected
, OGeneralPage
*);
201 DECL_LINK(OnChangeCreationMode
, OGeneralPage
*);
202 DECL_LINK(OnRecentDocumentSelected
, OGeneralPage
*);
203 DECL_LINK(OnSingleDocumentChosen
, OGeneralPage
*);
204 DECL_LINK(ImplClickHdl
, OMySQLIntroPageSetup
*);
205 DECL_LINK(ImplModifiedHdl
, OGenericAdministrationPage
*);
208 //.........................................................................
210 //.........................................................................
212 #endif // DBAUI_DBWIZ2_HXX