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_GENERALPAGE_HXX_
25cdf0e10cSrcweir #define _DBAUI_GENERALPAGE_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef _DBAUI_ADMINPAGES_HXX_
28cdf0e10cSrcweir #include "adminpages.hxx"
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #ifndef DBACCESS_SOURCE_UI_INC_OPENDOCCONTROLS_HXX
31cdf0e10cSrcweir #include "opendoccontrols.hxx"
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef _SV_FIXED_HXX
34cdf0e10cSrcweir #include <vcl/fixed.hxx>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #ifndef _SV_LSTBOX_HXX
37cdf0e10cSrcweir #include <vcl/lstbox.hxx>
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #ifndef _SV_EDIT_HXX
40cdf0e10cSrcweir #include <vcl/edit.hxx>
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #include <svtools/dialogcontrolling.hxx>
43cdf0e10cSrcweir #include <memory>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir //.........................................................................
46cdf0e10cSrcweir namespace dbaui
47cdf0e10cSrcweir {
48cdf0e10cSrcweir //.........................................................................
49cdf0e10cSrcweir 	class IDatabaseSettingsDialog;
50cdf0e10cSrcweir 	//=========================================================================
51cdf0e10cSrcweir 	//= OGeneralPage
52cdf0e10cSrcweir 	//=========================================================================
53cdf0e10cSrcweir 	class OGeneralPage : public OGenericAdministrationPage
54cdf0e10cSrcweir 	{
55cdf0e10cSrcweir         OGeneralPage(Window* pParent, const SfxItemSet& _rItems, sal_Bool _bDBWizardMode = sal_False);
56cdf0e10cSrcweir         ~OGeneralPage();
57cdf0e10cSrcweir 
58cdf0e10cSrcweir     public:
59cdf0e10cSrcweir         enum CreationMode
60cdf0e10cSrcweir         {
61cdf0e10cSrcweir             eCreateNew,
62cdf0e10cSrcweir             eConnectExternal,
63cdf0e10cSrcweir             eOpenExisting
64cdf0e10cSrcweir         };
65cdf0e10cSrcweir 
66cdf0e10cSrcweir         struct DocumentDescriptor
67cdf0e10cSrcweir         {
68cdf0e10cSrcweir             String  sURL;
69cdf0e10cSrcweir             String  sFilter;
70cdf0e10cSrcweir         };
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 	private:
73cdf0e10cSrcweir 		// dialog controls
74cdf0e10cSrcweir         FixedText           m_aFTHeaderText;
75cdf0e10cSrcweir         FixedText           m_aFTHelpText;
76cdf0e10cSrcweir         FixedText           m_aFT_DatasourceTypeHeader;
77cdf0e10cSrcweir         RadioButton         m_aRB_CreateDatabase;
78cdf0e10cSrcweir         RadioButton         m_aRB_OpenDocument;
79cdf0e10cSrcweir         RadioButton         m_aRB_GetExistingDatabase;
80cdf0e10cSrcweir         FixedText           m_aFT_DocListLabel;
81cdf0e10cSrcweir         ::std::auto_ptr< OpenDocumentListBox >
82cdf0e10cSrcweir                             m_pLB_DocumentList;
83cdf0e10cSrcweir         OpenDocumentButton  m_aPB_OpenDocument;
84cdf0e10cSrcweir 		FixedText			m_aTypePreLabel;
85cdf0e10cSrcweir 		FixedText			m_aDatasourceTypeLabel;
86cdf0e10cSrcweir         ::std::auto_ptr< ListBox >
87cdf0e10cSrcweir                             m_pDatasourceType;
88cdf0e10cSrcweir         FixedText           m_aFTDataSourceAppendix;
89cdf0e10cSrcweir         FixedText			m_aTypePostLabel;
90cdf0e10cSrcweir 		FixedText			m_aSpecialMessage;
91cdf0e10cSrcweir         sal_Bool            m_DBWizardMode;
92cdf0e10cSrcweir 		String				m_sMySQLEntry;
93cdf0e10cSrcweir         CreationMode        m_eOriginalCreationMode;
94cdf0e10cSrcweir         DocumentDescriptor  m_aBrowsedDocument;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir         ::svt::ControlDependencyManager
97cdf0e10cSrcweir                             m_aControlDependencies;
98cdf0e10cSrcweir         ::std::vector< ::rtl::OUString> m_aURLPrefixes;
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 		::dbaccess::ODsnTypeCollection*
102cdf0e10cSrcweir                             m_pCollection;	/// the DSN type collection instance
103cdf0e10cSrcweir 		::rtl::OUString     m_eCurrentSelection;	/// currently selected type
104cdf0e10cSrcweir 		::dbaccess::DATASOURCE_TYPE		m_eNotSupportedKnownType;	/// if a data source of an unsupported, but known type is encountered ....
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 		enum SPECIAL_MESSAGE
107cdf0e10cSrcweir 		{
108cdf0e10cSrcweir 			smNone,
109cdf0e10cSrcweir 			smUnsupportedType
110cdf0e10cSrcweir 		};
111cdf0e10cSrcweir 		SPECIAL_MESSAGE		m_eLastMessage;
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 		Link				m_aTypeSelectHandler;	/// to be called if a new type is selected
114cdf0e10cSrcweir         Link				m_aCreationModeHandler;	/// to be called if a new type is selected
115cdf0e10cSrcweir         Link				m_aDocumentSelectionHandler;    /// to be called when a document in the RecentDoc list is selected
116*07a3d7f1SPedro Giffuni         Link                m_aChooseDocumentHandler;       /// to be called when a recent document has been definitely chosen
117cdf0e10cSrcweir 		sal_Bool			m_bDisplayingInvalid : 1;	// the currently displayed data source is deleted
118cdf0e10cSrcweir 		sal_Bool			m_bUserGrabFocus : 1;
119cdf0e10cSrcweir         bool			    m_bInitTypeList : 1;
120cdf0e10cSrcweir 		bool                approveDataSourceType( const ::rtl::OUString& _sURLPrefix, String& _inout_rDisplayName );
121cdf0e10cSrcweir 		void				insertDatasourceTypeEntryData(const ::rtl::OUString& _sType, String sDisplayName);
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 	public:
124cdf0e10cSrcweir 		static SfxTabPage*	Create(Window* pParent, const SfxItemSet& _rAttrSet, sal_Bool _bDBWizardMode = sal_False);
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 		/// set a handler which gets called every time the user selects a new type
127cdf0e10cSrcweir 		void			SetTypeSelectHandler(const Link& _rHandler) { m_aTypeSelectHandler = _rHandler; }
128cdf0e10cSrcweir         void			SetCreationModeHandler(const Link& _rHandler) { m_aCreationModeHandler = _rHandler; }
129cdf0e10cSrcweir         void			SetDocumentSelectionHandler( const Link& _rHandler) { m_aDocumentSelectionHandler = _rHandler; }
130cdf0e10cSrcweir         void			SetChooseDocumentHandler( const Link& _rHandler) { m_aChooseDocumentHandler = _rHandler; }
131cdf0e10cSrcweir         CreationMode    GetDatabaseCreationMode() const;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir         DocumentDescriptor  GetSelectedDocument() const;
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 		/// get the currently selected datasource type
136cdf0e10cSrcweir 		::rtl::OUString 	GetSelectedType() const { return m_eCurrentSelection; }
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 	protected:
139cdf0e10cSrcweir 		// SfxTabPage overridables
140cdf0e10cSrcweir 		virtual	sal_Bool FillItemSet(SfxItemSet& _rCoreAttrs);
141cdf0e10cSrcweir 		virtual	void Reset(const SfxItemSet& _rCoreAttrs);
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 		virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 		virtual void GetFocus();
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 		// <method>OGenericAdministrationPage::fillControls</method>
148cdf0e10cSrcweir 		virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
149cdf0e10cSrcweir 		// <method>OGenericAdministrationPage::fillWindows</method>
150cdf0e10cSrcweir 		virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 	protected:
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 		void onTypeSelected(const ::rtl::OUString& _sURLPrefix);
155cdf0e10cSrcweir 		void initializeTypeList();
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 		void implSetCurrentType( const ::rtl::OUString& _eType );
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 		void switchMessage(const ::rtl::OUString& _sURLPrefix);
160cdf0e10cSrcweir 
161cdf0e10cSrcweir         /// sets the the title of the parent dialog
162cdf0e10cSrcweir 		void setParentTitle(const ::rtl::OUString& _sURLPrefix);
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 		DECL_LINK(OnDatasourceTypeSelected, ListBox*);
165cdf0e10cSrcweir         DECL_LINK(OnSetupModeSelected, RadioButton*);
166cdf0e10cSrcweir         DECL_LINK(OnDocumentSelected, ListBox*);
167cdf0e10cSrcweir         DECL_LINK(OnOpenDocument, PushButton*);
168cdf0e10cSrcweir 	};
169cdf0e10cSrcweir 
170cdf0e10cSrcweir //.........................................................................
171cdf0e10cSrcweir }	// namespace dbaui
172cdf0e10cSrcweir //.........................................................................
173cdf0e10cSrcweir #endif // _DBAUI_GENERALPAGE_HXX_
174