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_MySQLNativePageTitle
;
102 String m_sRM_OracleText
;
103 String m_sRM_MySQLText
;
104 String m_sRM_ODBCText
;
105 String m_sRM_SpreadSheetText
;
106 String m_sRM_AuthentificationText
;
107 String m_sRM_FinalText
;
108 INetURLObject m_aDocURL
;
110 OGeneralPage
* m_pGeneralPage
;
111 OMySQLIntroPageSetup
* m_pMySQLIntroPage
;
112 ::dbaccess::ODsnTypeCollection
*
113 m_pCollection
; /// the DSN type collection instance
118 /** ctor. The itemset given should have been created by <method>createItemSet</method> and should be destroyed
119 after the dialog has been destroyed
121 ODbTypeWizDialogSetup(Window
* pParent
123 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _rxORB
124 ,const ::com::sun::star::uno::Any
& _aDataSourceName
126 virtual ~ODbTypeWizDialogSetup();
128 virtual const SfxItemSet
* getOutputSet() const;
129 virtual SfxItemSet
* getWriteOutputSet();
131 // forwards to ODbDataSourceAdministrationHelper
132 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> getORB() const;
133 virtual ::std::pair
< ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>,sal_Bool
> createConnection();
134 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDriver
> getDriver();
135 virtual ::rtl::OUString
getDatasourceType(const SfxItemSet
& _rSet
) const;
136 virtual void clearPassword();
137 virtual void setTitle(const ::rtl::OUString
& _sTitle
);
138 virtual void enableConfirmSettings( bool _bEnable
);
139 virtual sal_Bool
saveDatasource();
140 virtual String
getStateDisplayName( WizardState _nState
) const;
142 /** returns <TRUE/> if the database should be opened, otherwise <FALSE/>.
144 sal_Bool
IsDatabaseDocumentToBeOpened() const;
146 /** returns <TRUE/> if the table wizard should be opened, otherwise <FALSE/>.
148 sal_Bool
IsTableWizardToBeStarted() const;
151 /// to override to create new pages
152 virtual TabPage
* createPage(WizardState _nState
);
153 virtual sal_Bool
leaveState(WizardState _nState
);
154 virtual void enterState(WizardState _nState
);
155 virtual ::svt::IWizardPage
* getWizardPage(TabPage
* _pCurrentPage
) const;
156 virtual sal_Bool
onFinish(sal_Int32 _nResult
);
159 inline sal_Bool
isUIEnabled() const { return m_bUIEnabled
; }
160 inline void disabledUI() { m_bUIEnabled
= sal_False
; }
162 /// select a datasource with a given name, adjust the item set accordingly, and everything like that ..
163 void implSelectDatasource(const ::rtl::OUString
& _rRegisteredName
);
164 void resetPages(const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxDatasource
);
168 AR_LEAVE_MODIFIED
, // somthing was modified and has successfully been committed
169 AR_LEAVE_UNCHANGED
, // no changes were made
170 AR_KEEP
// don't leave the page (e.g. because an error occured)
174 /** declares a path with or without authentication, as indicated by the database type
177 the data source type for which the path is declared. If this
178 data source type does not support authentication, the PAGE_DBSETUPWIZARD_AUTHENTIFICATION
179 state will be stripped from the sequence of states.
183 the first state in this path, following by an arbitrary number of others, as in
184 RoadmapWizard::declarePath.
186 void declareAuthDepPath( const ::rtl::OUString
& _sURL
, PathId _nPathId
, const svt::RoadmapWizardTypes::WizardPath
& _rPaths
);
188 void RegisterDataSourceByLocation(const ::rtl::OUString
& sPath
);
189 sal_Bool
SaveDatabaseDocument();
190 void activateDatabasePath();
191 String
createUniqueFileName(const INetURLObject
& rURL
);
192 void CreateDatabase();
193 void createUniqueFolderName(INetURLObject
* pURL
);
194 ::dbaccess::DATASOURCE_TYPE
VerifyDataSourceType(const ::dbaccess::DATASOURCE_TYPE _DatabaseType
) const;
196 ::rtl::OUString
getDefaultDatabaseType() const;
198 void updateTypeDependentStates();
199 sal_Bool
callSaveAsDialog();
200 sal_Bool
IsConnectionUrlRequired();
201 DECL_LINK(OnTypeSelected
, OGeneralPage
*);
202 DECL_LINK(OnChangeCreationMode
, OGeneralPage
*);
203 DECL_LINK(OnRecentDocumentSelected
, OGeneralPage
*);
204 DECL_LINK(OnSingleDocumentChosen
, OGeneralPage
*);
205 DECL_LINK(ImplClickHdl
, OMySQLIntroPageSetup
*);
206 DECL_LINK(ImplModifiedHdl
, OGenericAdministrationPage
*);
209 //.........................................................................
211 //.........................................................................
213 #endif // DBAUI_DBWIZ2_HXX