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_LISTCOMBOWIZARD_HXX_
25 #define _EXTENSIONS_DBP_LISTCOMBOWIZARD_HXX_
26 
27 #include "controlwizard.hxx"
28 #include "commonpagesdbp.hxx"
29 
30 //.........................................................................
31 namespace dbp
32 {
33 //.........................................................................
34 
35 #define LCW_STATE_DATASOURCE_SELECTION	0
36 #define LCW_STATE_TABLESELECTION		1
37 #define LCW_STATE_FIELDSELECTION		2
38 #define LCW_STATE_FIELDLINK				3
39 #define LCW_STATE_COMBODBFIELD			4
40 
41 	//=====================================================================
42 	//= OListComboSettings
43 	//=====================================================================
44 	struct OListComboSettings : public OControlWizardSettings
45 	{
46 		String			sListContentTable;
47 		String			sListContentField;
48 		String			sLinkedFormField;
49 		String			sLinkedListField;
50 	};
51 
52 	//=====================================================================
53 	//= OListComboWizard
54 	//=====================================================================
55 	class OListComboWizard : public OControlWizard
56 	{
57 	protected:
58 		OListComboSettings		m_aSettings;
59 		sal_Bool				m_bListBox : 1;
60 		sal_Bool				m_bHadDataSelection : 1;
61 
62 	public:
63 		OListComboWizard(
64 			Window* _pParent,
65 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObjectModel,
66 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
67 		);
68 
getSettings()69 		OListComboSettings& getSettings() { return m_aSettings; }
70 
isListBox() const71 		sal_Bool isListBox() const { return m_bListBox; }
72 
73 	protected:
74 		// OWizardMachine overridables
75 		virtual ::svt::OWizardPage*	createPage( WizardState _nState );
76 		virtual WizardState	        determineNextState( WizardState _nCurrentState ) const;
77 		virtual	void			    enterState( WizardState _nState );
78 		virtual	sal_Bool		    leaveState( WizardState _nState );
79 		virtual sal_Bool            onFinish();
80 
81 		virtual sal_Bool approveControl(sal_Int16 _nClassId);
82 
getFinalState() const83 		WizardState getFinalState() const { return isListBox() ? LCW_STATE_FIELDLINK : LCW_STATE_COMBODBFIELD; }
84 
85 	private:
86 		void implApplySettings();
87 	};
88 
89 	//=====================================================================
90 	//= OLCPage
91 	//=====================================================================
92 	class OLCPage : public OControlWizardPage
93 	{
94 	public:
OLCPage(OListComboWizard * _pParent,const ResId & _rId)95 		OLCPage( OListComboWizard* _pParent, const ResId& _rId ) : OControlWizardPage(_pParent, _rId) { }
96 
97 	protected:
getSettings()98 		OListComboSettings& getSettings() { return static_cast<OListComboWizard*>(getDialog())->getSettings(); }
isListBox()99 		sal_Bool isListBox() { return static_cast<OListComboWizard*>(getDialog())->isListBox(); }
100 
101 	protected:
102 		::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
103 			getTables(sal_Bool _bNeedIt);
104 		::com::sun::star::uno::Sequence< ::rtl::OUString >
105 			getTableFields(sal_Bool _bNeedIt);
106 	};
107 
108 	//=====================================================================
109 	//= OContentTableSelection
110 	//=====================================================================
111 	class OContentTableSelection : public OLCPage
112 	{
113 	protected:
114 		FixedLine		m_aFrame;
115 		FixedText		m_aSelectTableLabel;
116 		ListBox			m_aSelectTable;
117 
118 	public:
119 		OContentTableSelection( OListComboWizard* _pParent );
120 
121 	protected:
122 		// TabPage overridables
123 		virtual void ActivatePage();
124 
125 		// OWizardPage overridables
126 		virtual void		initializePage();
127 		virtual sal_Bool	commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
128 		virtual bool        canAdvance() const;
129 
130 	protected:
131 		DECL_LINK( OnTableDoubleClicked, ListBox* );
132 		DECL_LINK( OnTableSelected, ListBox* );
133 	};
134 
135 	//=====================================================================
136 	//= OContentFieldSelection
137 	//=====================================================================
138 	class OContentFieldSelection : public OLCPage
139 	{
140 	protected:
141 		FixedLine		m_aFrame;
142 		FixedText		m_aTableFields;
143 		ListBox			m_aSelectTableField;
144 		FixedText		m_aDisplayedFieldLabel;
145 		Edit			m_aDisplayedField;
146 		FixedText		m_aInfo;
147 
148 
149 	public:
150 		OContentFieldSelection( OListComboWizard* _pParent );
151 
152 	protected:
153 		DECL_LINK( OnFieldSelected, ListBox* );
154 		DECL_LINK( OnTableDoubleClicked, ListBox* );
155 
156 		// TabPage overridables
157 		virtual void ActivatePage();
158 
159 		// OWizardPage overridables
160 		virtual void		initializePage();
161 		virtual sal_Bool	commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
162 		virtual bool        canAdvance() const;
163 	};
164 
165 	//=====================================================================
166 	//= OLinkFieldsPage
167 	//=====================================================================
168 	class OLinkFieldsPage : public OLCPage
169 	{
170 	protected:
171 		FixedText		m_aDescription;
172 		FixedLine		m_aFrame;
173 		FixedText		m_aValueListFieldLabel;
174 		ComboBox		m_aValueListField;
175 		FixedText		m_aTableFieldLabel;
176 		ComboBox		m_aTableField;
177 
178 
179 	public:
180 		OLinkFieldsPage( OListComboWizard* _pParent );
181 
182 	protected:
183 		// TabPage overridables
184 		virtual void ActivatePage();
185 
186 		// OWizardPage overridables
187 		virtual void		initializePage();
188 		virtual sal_Bool	commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
189 		virtual bool        canAdvance() const;
190 
191 	private:
192 		void implCheckFinish();
193 
194 		DECL_LINK(OnSelectionModified, void*);
195 	};
196 
197 	//=====================================================================
198 	//= OComboDBFieldPage
199 	//=====================================================================
200 	class OComboDBFieldPage : public ODBFieldPage
201 	{
202 	public:
203 		OComboDBFieldPage( OControlWizard* _pParent );
204 
205 	protected:
getSettings()206 		OListComboSettings& getSettings() { return static_cast<OListComboWizard*>(getDialog())->getSettings(); }
207 
208 		// TabPage overridables
209 		virtual void ActivatePage();
210 
211 		// OWizardPage overridables
212 		virtual bool    canAdvance() const;
213 
214 		// ODBFieldPage overridables
215 		virtual String& getDBFieldSetting();
216 	};
217 
218 //.........................................................................
219 }	// namespace dbp
220 //.........................................................................
221 
222 #endif // _EXTENSIONS_DBP_LISTCOMBOWIZARD_HXX_
223 
224