1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _EXTENSIONS_DBP_COMMONPAGESDBP_HXX_
29 #define _EXTENSIONS_DBP_COMMONPAGESDBP_HXX_
30 
31 #include "controlwizard.hxx"
32 #include <vcl/fixed.hxx>
33 #include <vcl/lstbox.hxx>
34 #include <com/sun/star/container/XNameAccess.hpp>
35 
36 //.........................................................................
37 namespace dbp
38 {
39 //.........................................................................
40 
41 	//=====================================================================
42 	//= OTableSelectionPage
43 	//=====================================================================
44 	class OTableSelectionPage : public OControlWizardPage
45 	{
46 	protected:
47 		FixedLine		m_aData;
48 		FixedText		m_aExplanation;
49 		FixedText		m_aDatasourceLabel;
50 		ListBox			m_aDatasource;
51 		PushButton		m_aSearchDatabase;
52 		FixedText		m_aTableLabel;
53 		ListBox			m_aTable;
54 
55 		::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
56 						m_xDSContext;
57 
58 	public:
59 		OTableSelectionPage(OControlWizard* _pParent);
60 
61 	protected:
62 		// TabPage overridables
63 		void ActivatePage();
64 
65 		// OWizardPage overridables
66 		virtual void		initializePage();
67 		virtual sal_Bool	commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
68 
69 	protected:
70 		DECL_LINK( OnListboxSelection, ListBox* );
71 		DECL_LINK( OnListboxDoubleClicked, ListBox* );
72 		DECL_LINK( OnSearchClicked, PushButton* );
73 
74 		void implCollectDatasource();
75 		void implFillTables(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >&
76 						_rxConn = ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >());
77 
78 		// OControlWizardPage overridables
79 		virtual bool    canAdvance() const;
80 	};
81 
82 	//=====================================================================
83 	//= OMaybeListSelectionPage
84 	//=====================================================================
85 	class OMaybeListSelectionPage : public OControlWizardPage
86 	{
87 	protected:
88 		RadioButton*	m_pYes;
89 		RadioButton*	m_pNo;
90 		ListBox*		m_pList;
91 
92 	public:
93 		OMaybeListSelectionPage( OControlWizard* _pParent, const ResId& _rId );
94 
95 	protected:
96 		DECL_LINK( OnRadioSelected, RadioButton* );
97 
98 		// TabPage overridables
99 		void ActivatePage();
100 
101 		// own helper
102 		void	announceControls(
103 			RadioButton& _rYesButton,
104 			RadioButton& _rNoButton,
105 			ListBox& _rSelection);
106 
107 		void implEnableWindows();
108 
109 		void implInitialize(const String& _rSelection);
110 		void implCommit(String& _rSelection);
111 	};
112 
113 	//=====================================================================
114 	//= ODBFieldPage
115 	//=====================================================================
116 	class ODBFieldPage : public OMaybeListSelectionPage
117 	{
118 	protected:
119 		FixedLine		m_aFrame;
120 		FixedText		m_aDescription;
121 		FixedText		m_aQuestion;
122 		RadioButton		m_aStoreYes;
123 		RadioButton		m_aStoreNo;
124 		ListBox			m_aStoreWhere;
125 
126 	public:
127 		ODBFieldPage( OControlWizard* _pParent );
128 
129 	protected:
130 		void setDescriptionText(const String& _rDesc) { m_aDescription.SetText(_rDesc); }
131 
132 		// OWizardPage overridables
133 		virtual void initializePage();
134 		virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
135 
136 		// own overridables
137 		virtual String& getDBFieldSetting() = 0;
138 	};
139 
140 //.........................................................................
141 }	// namespace dbp
142 //.........................................................................
143 
144 
145 #endif // _EXTENSIONS_DBP_COMMONPAGESDBP_HXX_
146 
147