1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _DBAUI_GENERALPAGE_HXX_
29*cdf0e10cSrcweir #define _DBAUI_GENERALPAGE_HXX_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #ifndef _DBAUI_ADMINPAGES_HXX_
32*cdf0e10cSrcweir #include "adminpages.hxx"
33*cdf0e10cSrcweir #endif
34*cdf0e10cSrcweir #ifndef DBACCESS_SOURCE_UI_INC_OPENDOCCONTROLS_HXX
35*cdf0e10cSrcweir #include "opendoccontrols.hxx"
36*cdf0e10cSrcweir #endif
37*cdf0e10cSrcweir #ifndef _SV_FIXED_HXX
38*cdf0e10cSrcweir #include <vcl/fixed.hxx>
39*cdf0e10cSrcweir #endif
40*cdf0e10cSrcweir #ifndef _SV_LSTBOX_HXX
41*cdf0e10cSrcweir #include <vcl/lstbox.hxx>
42*cdf0e10cSrcweir #endif
43*cdf0e10cSrcweir #ifndef _SV_EDIT_HXX
44*cdf0e10cSrcweir #include <vcl/edit.hxx>
45*cdf0e10cSrcweir #endif
46*cdf0e10cSrcweir #include <svtools/dialogcontrolling.hxx>
47*cdf0e10cSrcweir #include <memory>
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir //.........................................................................
50*cdf0e10cSrcweir namespace dbaui
51*cdf0e10cSrcweir {
52*cdf0e10cSrcweir //.........................................................................
53*cdf0e10cSrcweir 	class IDatabaseSettingsDialog;
54*cdf0e10cSrcweir 	//=========================================================================
55*cdf0e10cSrcweir 	//= OGeneralPage
56*cdf0e10cSrcweir 	//=========================================================================
57*cdf0e10cSrcweir 	class OGeneralPage : public OGenericAdministrationPage
58*cdf0e10cSrcweir 	{
59*cdf0e10cSrcweir         OGeneralPage(Window* pParent, const SfxItemSet& _rItems, sal_Bool _bDBWizardMode = sal_False);
60*cdf0e10cSrcweir         ~OGeneralPage();
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir     public:
63*cdf0e10cSrcweir         enum CreationMode
64*cdf0e10cSrcweir         {
65*cdf0e10cSrcweir             eCreateNew,
66*cdf0e10cSrcweir             eConnectExternal,
67*cdf0e10cSrcweir             eOpenExisting
68*cdf0e10cSrcweir         };
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir         struct DocumentDescriptor
71*cdf0e10cSrcweir         {
72*cdf0e10cSrcweir             String  sURL;
73*cdf0e10cSrcweir             String  sFilter;
74*cdf0e10cSrcweir         };
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 	private:
77*cdf0e10cSrcweir 		// dialog controls
78*cdf0e10cSrcweir         FixedText           m_aFTHeaderText;
79*cdf0e10cSrcweir         FixedText           m_aFTHelpText;
80*cdf0e10cSrcweir         FixedText           m_aFT_DatasourceTypeHeader;
81*cdf0e10cSrcweir         RadioButton         m_aRB_CreateDatabase;
82*cdf0e10cSrcweir         RadioButton         m_aRB_OpenDocument;
83*cdf0e10cSrcweir         RadioButton         m_aRB_GetExistingDatabase;
84*cdf0e10cSrcweir         FixedText           m_aFT_DocListLabel;
85*cdf0e10cSrcweir         ::std::auto_ptr< OpenDocumentListBox >
86*cdf0e10cSrcweir                             m_pLB_DocumentList;
87*cdf0e10cSrcweir         OpenDocumentButton  m_aPB_OpenDocument;
88*cdf0e10cSrcweir 		FixedText			m_aTypePreLabel;
89*cdf0e10cSrcweir 		FixedText			m_aDatasourceTypeLabel;
90*cdf0e10cSrcweir         ::std::auto_ptr< ListBox >
91*cdf0e10cSrcweir                             m_pDatasourceType;
92*cdf0e10cSrcweir         FixedText           m_aFTDataSourceAppendix;
93*cdf0e10cSrcweir         FixedText			m_aTypePostLabel;
94*cdf0e10cSrcweir 		FixedText			m_aSpecialMessage;
95*cdf0e10cSrcweir         sal_Bool            m_DBWizardMode;
96*cdf0e10cSrcweir 		String				m_sMySQLEntry;
97*cdf0e10cSrcweir         CreationMode        m_eOriginalCreationMode;
98*cdf0e10cSrcweir         DocumentDescriptor  m_aBrowsedDocument;
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir         ::svt::ControlDependencyManager
101*cdf0e10cSrcweir                             m_aControlDependencies;
102*cdf0e10cSrcweir         ::std::vector< ::rtl::OUString> m_aURLPrefixes;
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 		::dbaccess::ODsnTypeCollection*
106*cdf0e10cSrcweir                             m_pCollection;	/// the DSN type collection instance
107*cdf0e10cSrcweir 		::rtl::OUString     m_eCurrentSelection;	/// currently selected type
108*cdf0e10cSrcweir 		::dbaccess::DATASOURCE_TYPE		m_eNotSupportedKnownType;	/// if a data source of an unsupported, but known type is encountered ....
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir 		enum SPECIAL_MESSAGE
111*cdf0e10cSrcweir 		{
112*cdf0e10cSrcweir 			smNone,
113*cdf0e10cSrcweir 			smUnsupportedType
114*cdf0e10cSrcweir 		};
115*cdf0e10cSrcweir 		SPECIAL_MESSAGE		m_eLastMessage;
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 		Link				m_aTypeSelectHandler;	/// to be called if a new type is selected
118*cdf0e10cSrcweir         Link				m_aCreationModeHandler;	/// to be called if a new type is selected
119*cdf0e10cSrcweir         Link				m_aDocumentSelectionHandler;    /// to be called when a document in the RecentDoc list is selected
120*cdf0e10cSrcweir         Link                m_aChooseDocumentHandler;       /// to be called when a recent document has been definately chosen
121*cdf0e10cSrcweir 		sal_Bool			m_bDisplayingInvalid : 1;	// the currently displayed data source is deleted
122*cdf0e10cSrcweir 		sal_Bool			m_bUserGrabFocus : 1;
123*cdf0e10cSrcweir         bool			    m_bInitTypeList : 1;
124*cdf0e10cSrcweir 		bool                approveDataSourceType( const ::rtl::OUString& _sURLPrefix, String& _inout_rDisplayName );
125*cdf0e10cSrcweir 		void				insertDatasourceTypeEntryData(const ::rtl::OUString& _sType, String sDisplayName);
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 	public:
128*cdf0e10cSrcweir 		static SfxTabPage*	Create(Window* pParent, const SfxItemSet& _rAttrSet, sal_Bool _bDBWizardMode = sal_False);
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 		/// set a handler which gets called every time the user selects a new type
131*cdf0e10cSrcweir 		void			SetTypeSelectHandler(const Link& _rHandler) { m_aTypeSelectHandler = _rHandler; }
132*cdf0e10cSrcweir         void			SetCreationModeHandler(const Link& _rHandler) { m_aCreationModeHandler = _rHandler; }
133*cdf0e10cSrcweir         void			SetDocumentSelectionHandler( const Link& _rHandler) { m_aDocumentSelectionHandler = _rHandler; }
134*cdf0e10cSrcweir         void			SetChooseDocumentHandler( const Link& _rHandler) { m_aChooseDocumentHandler = _rHandler; }
135*cdf0e10cSrcweir         CreationMode    GetDatabaseCreationMode() const;
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir         DocumentDescriptor  GetSelectedDocument() const;
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 		/// get the currently selected datasource type
140*cdf0e10cSrcweir 		::rtl::OUString 	GetSelectedType() const { return m_eCurrentSelection; }
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir 	protected:
143*cdf0e10cSrcweir 		// SfxTabPage overridables
144*cdf0e10cSrcweir 		virtual	sal_Bool FillItemSet(SfxItemSet& _rCoreAttrs);
145*cdf0e10cSrcweir 		virtual	void Reset(const SfxItemSet& _rCoreAttrs);
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 		virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 		virtual void GetFocus();
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir 		// <method>OGenericAdministrationPage::fillControls</method>
152*cdf0e10cSrcweir 		virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
153*cdf0e10cSrcweir 		// <method>OGenericAdministrationPage::fillWindows</method>
154*cdf0e10cSrcweir 		virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir 	protected:
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 		void onTypeSelected(const ::rtl::OUString& _sURLPrefix);
159*cdf0e10cSrcweir 		void initializeTypeList();
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir 		void implSetCurrentType( const ::rtl::OUString& _eType );
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir 		void switchMessage(const ::rtl::OUString& _sURLPrefix);
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir         /// sets the the title of the parent dialog
166*cdf0e10cSrcweir 		void setParentTitle(const ::rtl::OUString& _sURLPrefix);
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir 		DECL_LINK(OnDatasourceTypeSelected, ListBox*);
169*cdf0e10cSrcweir         DECL_LINK(OnSetupModeSelected, RadioButton*);
170*cdf0e10cSrcweir         DECL_LINK(OnDocumentSelected, ListBox*);
171*cdf0e10cSrcweir         DECL_LINK(OnOpenDocument, PushButton*);
172*cdf0e10cSrcweir 	};
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir //.........................................................................
175*cdf0e10cSrcweir }	// namespace dbaui
176*cdf0e10cSrcweir //.........................................................................
177*cdf0e10cSrcweir #endif // _DBAUI_GENERALPAGE_HXX_
178