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 _EXTENSIONS_DBP_COMMONPAGESDBP_HXX_
25 #define _EXTENSIONS_DBP_COMMONPAGESDBP_HXX_
26 
27 #include "controlwizard.hxx"
28 #include <vcl/fixed.hxx>
29 #include <vcl/lstbox.hxx>
30 #include <com/sun/star/container/XNameAccess.hpp>
31 
32 //.........................................................................
33 namespace dbp
34 {
35 //.........................................................................
36 
37 	//=====================================================================
38 	//= OTableSelectionPage
39 	//=====================================================================
40 	class OTableSelectionPage : public OControlWizardPage
41 	{
42 	protected:
43 		FixedLine		m_aData;
44 		FixedText		m_aExplanation;
45 		FixedText		m_aDatasourceLabel;
46 		ListBox			m_aDatasource;
47 		PushButton		m_aSearchDatabase;
48 		FixedText		m_aTableLabel;
49 		ListBox			m_aTable;
50 
51 		::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
52 						m_xDSContext;
53 
54 	public:
55 		OTableSelectionPage(OControlWizard* _pParent);
56 
57 	protected:
58 		// TabPage overridables
59 		void ActivatePage();
60 
61 		// OWizardPage overridables
62 		virtual void		initializePage();
63 		virtual sal_Bool	commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
64 
65 	protected:
66 		DECL_LINK( OnListboxSelection, ListBox* );
67 		DECL_LINK( OnListboxDoubleClicked, ListBox* );
68 		DECL_LINK( OnSearchClicked, PushButton* );
69 
70 		void implCollectDatasource();
71 		void implFillTables(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >&
72 						_rxConn = ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >());
73 
74 		// OControlWizardPage overridables
75 		virtual bool    canAdvance() const;
76 	};
77 
78 	//=====================================================================
79 	//= OMaybeListSelectionPage
80 	//=====================================================================
81 	class OMaybeListSelectionPage : public OControlWizardPage
82 	{
83 	protected:
84 		RadioButton*	m_pYes;
85 		RadioButton*	m_pNo;
86 		ListBox*		m_pList;
87 
88 	public:
89 		OMaybeListSelectionPage( OControlWizard* _pParent, const ResId& _rId );
90 
91 	protected:
92 		DECL_LINK( OnRadioSelected, RadioButton* );
93 
94 		// TabPage overridables
95 		void ActivatePage();
96 
97 		// own helper
98 		void	announceControls(
99 			RadioButton& _rYesButton,
100 			RadioButton& _rNoButton,
101 			ListBox& _rSelection);
102 
103 		void implEnableWindows();
104 
105 		void implInitialize(const String& _rSelection);
106 		void implCommit(String& _rSelection);
107 	};
108 
109 	//=====================================================================
110 	//= ODBFieldPage
111 	//=====================================================================
112 	class ODBFieldPage : public OMaybeListSelectionPage
113 	{
114 	protected:
115 		FixedLine		m_aFrame;
116 		FixedText		m_aDescription;
117 		FixedText		m_aQuestion;
118 		RadioButton		m_aStoreYes;
119 		RadioButton		m_aStoreNo;
120 		ListBox			m_aStoreWhere;
121 
122 	public:
123 		ODBFieldPage( OControlWizard* _pParent );
124 
125 	protected:
setDescriptionText(const String & _rDesc)126 		void setDescriptionText(const String& _rDesc) { m_aDescription.SetText(_rDesc); }
127 
128 		// OWizardPage overridables
129 		virtual void initializePage();
130 		virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
131 
132 		// own overridables
133 		virtual String& getDBFieldSetting() = 0;
134 	};
135 
136 //.........................................................................
137 }	// namespace dbp
138 //.........................................................................
139 
140 
141 #endif // _EXTENSIONS_DBP_COMMONPAGESDBP_HXX_
142 
143