1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _DBAUI_GENERALPAGE_HXX_
25 #define _DBAUI_GENERALPAGE_HXX_
26 
27 #ifndef _DBAUI_ADMINPAGES_HXX_
28 #include "adminpages.hxx"
29 #endif
30 #ifndef DBACCESS_SOURCE_UI_INC_OPENDOCCONTROLS_HXX
31 #include "opendoccontrols.hxx"
32 #endif
33 #ifndef _SV_FIXED_HXX
34 #include <vcl/fixed.hxx>
35 #endif
36 #ifndef _SV_LSTBOX_HXX
37 #include <vcl/lstbox.hxx>
38 #endif
39 #ifndef _SV_EDIT_HXX
40 #include <vcl/edit.hxx>
41 #endif
42 #include <svtools/dialogcontrolling.hxx>
43 #include <memory>
44 
45 //.........................................................................
46 namespace dbaui
47 {
48 //.........................................................................
49 	class IDatabaseSettingsDialog;
50 	//=========================================================================
51 	//= OGeneralPage
52 	//=========================================================================
53 	class OGeneralPage : public OGenericAdministrationPage
54 	{
55         OGeneralPage(Window* pParent, const SfxItemSet& _rItems, sal_Bool _bDBWizardMode = sal_False);
56         ~OGeneralPage();
57 
58     public:
59         enum CreationMode
60         {
61             eCreateNew,
62             eConnectExternal,
63             eOpenExisting
64         };
65 
66         struct DocumentDescriptor
67         {
68             String  sURL;
69             String  sFilter;
70         };
71 
72 	private:
73 		// dialog controls
74         FixedText           m_aFTHeaderText;
75         FixedText           m_aFTHelpText;
76         FixedText           m_aFT_DatasourceTypeHeader;
77         RadioButton         m_aRB_CreateDatabase;
78         RadioButton         m_aRB_OpenDocument;
79         RadioButton         m_aRB_GetExistingDatabase;
80         FixedText           m_aFT_DocListLabel;
81         ::std::auto_ptr< OpenDocumentListBox >
82                             m_pLB_DocumentList;
83         OpenDocumentButton  m_aPB_OpenDocument;
84 		FixedText			m_aTypePreLabel;
85 		FixedText			m_aDatasourceTypeLabel;
86         ::std::auto_ptr< ListBox >
87                             m_pDatasourceType;
88         FixedText           m_aFTDataSourceAppendix;
89         FixedText			m_aTypePostLabel;
90 		FixedText			m_aSpecialMessage;
91         sal_Bool            m_DBWizardMode;
92 		String				m_sMySQLEntry;
93         CreationMode        m_eOriginalCreationMode;
94         DocumentDescriptor  m_aBrowsedDocument;
95 
96         ::svt::ControlDependencyManager
97                             m_aControlDependencies;
98         ::std::vector< ::rtl::OUString> m_aURLPrefixes;
99 
100 
101 		::dbaccess::ODsnTypeCollection*
102                             m_pCollection;	/// the DSN type collection instance
103 		::rtl::OUString     m_eCurrentSelection;	/// currently selected type
104 		::dbaccess::DATASOURCE_TYPE		m_eNotSupportedKnownType;	/// if a data source of an unsupported, but known type is encountered ....
105 
106 		enum SPECIAL_MESSAGE
107 		{
108 			smNone,
109 			smUnsupportedType
110 		};
111 		SPECIAL_MESSAGE		m_eLastMessage;
112 
113 		Link				m_aTypeSelectHandler;	/// to be called if a new type is selected
114         Link				m_aCreationModeHandler;	/// to be called if a new type is selected
115         Link				m_aDocumentSelectionHandler;    /// to be called when a document in the RecentDoc list is selected
116         Link                m_aChooseDocumentHandler;       /// to be called when a recent document has been definately chosen
117 		sal_Bool			m_bDisplayingInvalid : 1;	// the currently displayed data source is deleted
118 		sal_Bool			m_bUserGrabFocus : 1;
119         bool			    m_bInitTypeList : 1;
120 		bool                approveDataSourceType( const ::rtl::OUString& _sURLPrefix, String& _inout_rDisplayName );
121 		void				insertDatasourceTypeEntryData(const ::rtl::OUString& _sType, String sDisplayName);
122 
123 	public:
124 		static SfxTabPage*	Create(Window* pParent, const SfxItemSet& _rAttrSet, sal_Bool _bDBWizardMode = sal_False);
125 
126 		/// set a handler which gets called every time the user selects a new type
SetTypeSelectHandler(const Link & _rHandler)127 		void			SetTypeSelectHandler(const Link& _rHandler) { m_aTypeSelectHandler = _rHandler; }
SetCreationModeHandler(const Link & _rHandler)128         void			SetCreationModeHandler(const Link& _rHandler) { m_aCreationModeHandler = _rHandler; }
SetDocumentSelectionHandler(const Link & _rHandler)129         void			SetDocumentSelectionHandler( const Link& _rHandler) { m_aDocumentSelectionHandler = _rHandler; }
SetChooseDocumentHandler(const Link & _rHandler)130         void			SetChooseDocumentHandler( const Link& _rHandler) { m_aChooseDocumentHandler = _rHandler; }
131         CreationMode    GetDatabaseCreationMode() const;
132 
133         DocumentDescriptor  GetSelectedDocument() const;
134 
135 		/// get the currently selected datasource type
GetSelectedType() const136 		::rtl::OUString 	GetSelectedType() const { return m_eCurrentSelection; }
137 
138 	protected:
139 		// SfxTabPage overridables
140 		virtual	sal_Bool FillItemSet(SfxItemSet& _rCoreAttrs);
141 		virtual	void Reset(const SfxItemSet& _rCoreAttrs);
142 
143 		virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
144 
145 		virtual void GetFocus();
146 
147 		// <method>OGenericAdministrationPage::fillControls</method>
148 		virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
149 		// <method>OGenericAdministrationPage::fillWindows</method>
150 		virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
151 
152 	protected:
153 
154 		void onTypeSelected(const ::rtl::OUString& _sURLPrefix);
155 		void initializeTypeList();
156 
157 		void implSetCurrentType( const ::rtl::OUString& _eType );
158 
159 		void switchMessage(const ::rtl::OUString& _sURLPrefix);
160 
161         /// sets the the title of the parent dialog
162 		void setParentTitle(const ::rtl::OUString& _sURLPrefix);
163 
164 		DECL_LINK(OnDatasourceTypeSelected, ListBox*);
165         DECL_LINK(OnSetupModeSelected, RadioButton*);
166         DECL_LINK(OnDocumentSelected, ListBox*);
167         DECL_LINK(OnOpenDocument, PushButton*);
168 	};
169 
170 //.........................................................................
171 }	// namespace dbaui
172 //.........................................................................
173 #endif // _DBAUI_GENERALPAGE_HXX_
174