1*2a97ec55SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2a97ec55SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2a97ec55SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2a97ec55SAndrew Rist  * distributed with this work for additional information
6*2a97ec55SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2a97ec55SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2a97ec55SAndrew Rist  * "License"); you may not use this file except in compliance
9*2a97ec55SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2a97ec55SAndrew Rist  *
11*2a97ec55SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2a97ec55SAndrew Rist  *
13*2a97ec55SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2a97ec55SAndrew Rist  * software distributed under the License is distributed on an
15*2a97ec55SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2a97ec55SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2a97ec55SAndrew Rist  * specific language governing permissions and limitations
18*2a97ec55SAndrew Rist  * under the License.
19*2a97ec55SAndrew Rist  *
20*2a97ec55SAndrew Rist  *************************************************************/
21*2a97ec55SAndrew Rist 
22*2a97ec55SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_extensions.hxx"
26cdf0e10cSrcweir #include "groupboxwiz.hxx"
27cdf0e10cSrcweir #include "commonpagesdbp.hxx"
28cdf0e10cSrcweir #include <tools/debug.hxx>
29cdf0e10cSrcweir #include <vcl/svapp.hxx>
30cdf0e10cSrcweir #include <vcl/msgbox.hxx>
31cdf0e10cSrcweir #include "optiongrouplayouter.hxx"
32cdf0e10cSrcweir #include "dbpilots.hrc"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir 
35cdf0e10cSrcweir //#define GBW_STATE_DATASELECTION		0
36cdf0e10cSrcweir #define GBW_STATE_OPTIONLIST		0
37cdf0e10cSrcweir #define GBW_STATE_DEFAULTOPTION		1
38cdf0e10cSrcweir #define GBW_STATE_OPTIONVALUES		2
39cdf0e10cSrcweir #define GBW_STATE_DBFIELD			3
40cdf0e10cSrcweir #define GBW_STATE_FINALIZE			4
41cdf0e10cSrcweir 
42cdf0e10cSrcweir //.........................................................................
43cdf0e10cSrcweir namespace dbp
44cdf0e10cSrcweir {
45cdf0e10cSrcweir //.........................................................................
46cdf0e10cSrcweir 
47cdf0e10cSrcweir 	using namespace ::com::sun::star::uno;
48cdf0e10cSrcweir 	using namespace ::com::sun::star::lang;
49cdf0e10cSrcweir 	using namespace ::com::sun::star::beans;
50cdf0e10cSrcweir 	using namespace ::com::sun::star::form;
51cdf0e10cSrcweir 	using namespace ::svt;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir 	//=====================================================================
54cdf0e10cSrcweir 	//= OGroupBoxWizard
55cdf0e10cSrcweir 	//=====================================================================
56cdf0e10cSrcweir 	//---------------------------------------------------------------------
57cdf0e10cSrcweir 	OGroupBoxWizard::OGroupBoxWizard( Window* _pParent,
58cdf0e10cSrcweir 			const Reference< XPropertySet >& _rxObjectModel, const Reference< XMultiServiceFactory >& _rxORB )
59cdf0e10cSrcweir 		:OControlWizard(_pParent, ModuleRes(RID_DLG_GROUPBOXWIZARD), _rxObjectModel, _rxORB)
60cdf0e10cSrcweir 		,m_bVisitedDefault(sal_False)
61cdf0e10cSrcweir 		,m_bVisitedDB(sal_False)
62cdf0e10cSrcweir 	{
63cdf0e10cSrcweir 		initControlSettings(&m_aSettings);
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 		m_pPrevPage->SetHelpId(HID_GROUPWIZARD_PREVIOUS);
66cdf0e10cSrcweir 		m_pNextPage->SetHelpId(HID_GROUPWIZARD_NEXT);
67cdf0e10cSrcweir 		m_pCancel->SetHelpId(HID_GROUPWIZARD_CANCEL);
68cdf0e10cSrcweir 		m_pFinish->SetHelpId(HID_GROUPWIZARD_FINISH);
69cdf0e10cSrcweir 	}
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 	//---------------------------------------------------------------------
72cdf0e10cSrcweir 	sal_Bool OGroupBoxWizard::approveControl(sal_Int16 _nClassId)
73cdf0e10cSrcweir 	{
74cdf0e10cSrcweir 		return FormComponentType::GROUPBOX == _nClassId;
75cdf0e10cSrcweir 	}
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 	//---------------------------------------------------------------------
78cdf0e10cSrcweir 	OWizardPage* OGroupBoxWizard::createPage(::svt::WizardTypes::WizardState _nState)
79cdf0e10cSrcweir 	{
80cdf0e10cSrcweir 		switch (_nState)
81cdf0e10cSrcweir 		{
82cdf0e10cSrcweir //			case GBW_STATE_DATASELECTION:
83cdf0e10cSrcweir //				return new OTableSelectionPage(this);
84cdf0e10cSrcweir //
85cdf0e10cSrcweir 			case GBW_STATE_OPTIONLIST:
86cdf0e10cSrcweir 				return new ORadioSelectionPage(this);
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 			case GBW_STATE_DEFAULTOPTION:
89cdf0e10cSrcweir 				return new ODefaultFieldSelectionPage(this);
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 			case GBW_STATE_OPTIONVALUES:
92cdf0e10cSrcweir 				return new OOptionValuesPage(this);
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 			case GBW_STATE_DBFIELD:
95cdf0e10cSrcweir 				return new OOptionDBFieldPage(this);
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 			case GBW_STATE_FINALIZE:
98cdf0e10cSrcweir 				return new OFinalizeGBWPage(this);
99cdf0e10cSrcweir 		}
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 		return NULL;
102cdf0e10cSrcweir 	}
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	//---------------------------------------------------------------------
105cdf0e10cSrcweir 	WizardTypes::WizardState OGroupBoxWizard::determineNextState( ::svt::WizardTypes::WizardState _nCurrentState ) const
106cdf0e10cSrcweir 	{
107cdf0e10cSrcweir 		switch (_nCurrentState)
108cdf0e10cSrcweir 		{
109cdf0e10cSrcweir //			case GBW_STATE_DATASELECTION:
110cdf0e10cSrcweir //				return GBW_STATE_OPTIONLIST;
111cdf0e10cSrcweir //
112cdf0e10cSrcweir 			case GBW_STATE_OPTIONLIST:
113cdf0e10cSrcweir 				return GBW_STATE_DEFAULTOPTION;
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 			case GBW_STATE_DEFAULTOPTION:
116cdf0e10cSrcweir 				return GBW_STATE_OPTIONVALUES;
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 			case GBW_STATE_OPTIONVALUES:
119cdf0e10cSrcweir 				if (getContext().aFieldNames.getLength())
120cdf0e10cSrcweir 					return GBW_STATE_DBFIELD;
121cdf0e10cSrcweir 				else
122cdf0e10cSrcweir 					return GBW_STATE_FINALIZE;
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 			case GBW_STATE_DBFIELD:
125cdf0e10cSrcweir 				return GBW_STATE_FINALIZE;
126cdf0e10cSrcweir 		}
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 		return WZS_INVALID_STATE;
129cdf0e10cSrcweir 	}
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 	//---------------------------------------------------------------------
132cdf0e10cSrcweir 	void OGroupBoxWizard::enterState(::svt::WizardTypes::WizardState _nState)
133cdf0e10cSrcweir 	{
134cdf0e10cSrcweir 		// some stuff to do before calling the base class (modifying our settings)
135cdf0e10cSrcweir 		switch (_nState)
136cdf0e10cSrcweir 		{
137cdf0e10cSrcweir 			case GBW_STATE_DEFAULTOPTION:
138cdf0e10cSrcweir 				if (!m_bVisitedDefault)
139cdf0e10cSrcweir 				{	// assume that the first of the radio buttons should be selected
140cdf0e10cSrcweir 					DBG_ASSERT(m_aSettings.aLabels.size(), "OGroupBoxWizard::enterState: should never have reached this state!");
141cdf0e10cSrcweir 					m_aSettings.sDefaultField = m_aSettings.aLabels[0];
142cdf0e10cSrcweir 				}
143cdf0e10cSrcweir 				m_bVisitedDefault = sal_True;
144cdf0e10cSrcweir 				break;
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 			case GBW_STATE_DBFIELD:
147cdf0e10cSrcweir 				if (!m_bVisitedDB)
148cdf0e10cSrcweir 				{	// try to generate a default for the DB field
149cdf0e10cSrcweir 					// (simply use the first field in the DB names collection)
150cdf0e10cSrcweir 					if (getContext().aFieldNames.getLength())
151cdf0e10cSrcweir 						m_aSettings.sDBField = getContext().aFieldNames[0];
152cdf0e10cSrcweir 				}
153cdf0e10cSrcweir 				m_bVisitedDB = sal_True;
154cdf0e10cSrcweir 				break;
155cdf0e10cSrcweir 		}
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 		// setting the def button .... to be done before the base class is called, too, 'cause the base class
158cdf0e10cSrcweir 		// calls the pages, which are allowed to override our def button behaviour
159cdf0e10cSrcweir 		defaultButton(GBW_STATE_FINALIZE == _nState ? WZB_FINISH : WZB_NEXT);
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 		// allow "finish" on the last page only
162cdf0e10cSrcweir 		enableButtons(WZB_FINISH, GBW_STATE_FINALIZE == _nState);
163cdf0e10cSrcweir 		// allow previous on all pages but the first one
164cdf0e10cSrcweir 		enableButtons(WZB_PREVIOUS, GBW_STATE_OPTIONLIST != _nState);
165cdf0e10cSrcweir 		// allow next on all pages but the last one
166cdf0e10cSrcweir 		enableButtons(WZB_NEXT, GBW_STATE_FINALIZE != _nState);
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 		OControlWizard::enterState(_nState);
169cdf0e10cSrcweir 	}
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 	//---------------------------------------------------------------------
172cdf0e10cSrcweir 	void OGroupBoxWizard::createRadios()
173cdf0e10cSrcweir 	{
174cdf0e10cSrcweir 		try
175cdf0e10cSrcweir 		{
176cdf0e10cSrcweir 			OOptionGroupLayouter aLayouter(getServiceFactory());
177cdf0e10cSrcweir 			aLayouter.doLayout(getContext(), getSettings());
178cdf0e10cSrcweir 		}
179cdf0e10cSrcweir 		catch(Exception&)
180cdf0e10cSrcweir 		{
181cdf0e10cSrcweir 			DBG_ERROR("OGroupBoxWizard::createRadios: caught an exception while creating the radio shapes!");
182cdf0e10cSrcweir 		}
183cdf0e10cSrcweir 	}
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 	//---------------------------------------------------------------------
186cdf0e10cSrcweir 	sal_Bool OGroupBoxWizard::onFinish()
187cdf0e10cSrcweir 	{
188cdf0e10cSrcweir 		// commit the basic control setttings
189cdf0e10cSrcweir 		commitControlSettings(&m_aSettings);
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 		// create the radio buttons
192cdf0e10cSrcweir 		createRadios();
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 		return OControlWizard::onFinish();
195cdf0e10cSrcweir 	}
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 	//=====================================================================
198cdf0e10cSrcweir 	//= ORadioSelectionPage
199cdf0e10cSrcweir 	//=====================================================================
200cdf0e10cSrcweir 	//---------------------------------------------------------------------
201cdf0e10cSrcweir 	ORadioSelectionPage::ORadioSelectionPage( OControlWizard* _pParent )
202cdf0e10cSrcweir 		:OGBWPage(_pParent, ModuleRes(RID_PAGE_GROUPRADIOSELECTION))
203cdf0e10cSrcweir 		,m_aFrame				(this, ModuleRes(FL_DATA))
204cdf0e10cSrcweir 		,m_aRadioNameLabel		(this, ModuleRes(FT_RADIOLABELS))
205cdf0e10cSrcweir 		,m_aRadioName			(this, ModuleRes(ET_RADIOLABELS))
206cdf0e10cSrcweir 		,m_aMoveRight			(this, ModuleRes(PB_MOVETORIGHT))
207cdf0e10cSrcweir 		,m_aMoveLeft			(this, ModuleRes(PB_MOVETOLEFT))
208cdf0e10cSrcweir 		,m_aExistingRadiosLabel	(this, ModuleRes(FT_RADIOBUTTONS))
209cdf0e10cSrcweir 		,m_aExistingRadios		(this, ModuleRes(LB_RADIOBUTTONS))
210cdf0e10cSrcweir 	{
211cdf0e10cSrcweir 		FreeResource();
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 		if (getContext().aFieldNames.getLength())
214cdf0e10cSrcweir 		{
215cdf0e10cSrcweir 			enableFormDatasourceDisplay();
216cdf0e10cSrcweir 		}
217cdf0e10cSrcweir 		else
218cdf0e10cSrcweir 		{
219cdf0e10cSrcweir 			adjustControlForNoDSDisplay(&m_aFrame);
220cdf0e10cSrcweir 			adjustControlForNoDSDisplay(&m_aRadioNameLabel);
221cdf0e10cSrcweir 			adjustControlForNoDSDisplay(&m_aRadioName);
222cdf0e10cSrcweir 			adjustControlForNoDSDisplay(&m_aMoveRight);
223cdf0e10cSrcweir 			adjustControlForNoDSDisplay(&m_aMoveLeft);
224cdf0e10cSrcweir 			adjustControlForNoDSDisplay(&m_aExistingRadiosLabel);
225cdf0e10cSrcweir 			adjustControlForNoDSDisplay(&m_aExistingRadios, sal_True);
226cdf0e10cSrcweir 		}
227cdf0e10cSrcweir 
228cdf0e10cSrcweir 		m_aMoveLeft.SetClickHdl(LINK(this, ORadioSelectionPage, OnMoveEntry));
229cdf0e10cSrcweir 		m_aMoveRight.SetClickHdl(LINK(this, ORadioSelectionPage, OnMoveEntry));
230cdf0e10cSrcweir 		m_aRadioName.SetModifyHdl(LINK(this, ORadioSelectionPage, OnNameModified));
231cdf0e10cSrcweir 		m_aExistingRadios.SetSelectHdl(LINK(this, ORadioSelectionPage, OnEntrySelected));
232cdf0e10cSrcweir 
233cdf0e10cSrcweir 		implCheckMoveButtons();
234cdf0e10cSrcweir 		m_aExistingRadios.EnableMultiSelection(sal_True);
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 		getDialog()->defaultButton(&m_aMoveRight);
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 		m_aExistingRadios.SetAccessibleRelationMemberOf(&m_aExistingRadios);
239cdf0e10cSrcweir 		m_aExistingRadios.SetAccessibleRelationLabeledBy(&m_aExistingRadiosLabel);
240cdf0e10cSrcweir 	}
241cdf0e10cSrcweir 
242cdf0e10cSrcweir 	//---------------------------------------------------------------------
243cdf0e10cSrcweir 	void ORadioSelectionPage::ActivatePage()
244cdf0e10cSrcweir 	{
245cdf0e10cSrcweir 		OGBWPage::ActivatePage();
246cdf0e10cSrcweir 		m_aRadioName.GrabFocus();
247cdf0e10cSrcweir 	}
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 	//---------------------------------------------------------------------
250cdf0e10cSrcweir 	void ORadioSelectionPage::initializePage()
251cdf0e10cSrcweir 	{
252cdf0e10cSrcweir 		OGBWPage::initializePage();
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 		m_aRadioName.SetText(String());
255cdf0e10cSrcweir 
256cdf0e10cSrcweir 		// no need to initialize the list of radios here
257cdf0e10cSrcweir 		// (we're the only one affecting this special setting, so it will be in the same state as last time this
258cdf0e10cSrcweir 		// page was commited)
259cdf0e10cSrcweir 
260cdf0e10cSrcweir 		implCheckMoveButtons();
261cdf0e10cSrcweir 	}
262cdf0e10cSrcweir 
263cdf0e10cSrcweir 	//---------------------------------------------------------------------
264cdf0e10cSrcweir 	sal_Bool ORadioSelectionPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
265cdf0e10cSrcweir 	{
266cdf0e10cSrcweir 		if (!OGBWPage::commitPage(_eReason))
267cdf0e10cSrcweir 			return sal_False;
268cdf0e10cSrcweir 
269cdf0e10cSrcweir 		// copy the names of the radio buttons to be inserted
270cdf0e10cSrcweir 		// and initialize the values
271cdf0e10cSrcweir 		OOptionGroupSettings& rSettings = getSettings();
272cdf0e10cSrcweir 		rSettings.aLabels.clear();
273cdf0e10cSrcweir 		rSettings.aValues.clear();
274cdf0e10cSrcweir 		rSettings.aLabels.reserve(m_aExistingRadios.GetEntryCount());
275cdf0e10cSrcweir 		rSettings.aValues.reserve(m_aExistingRadios.GetEntryCount());
276cdf0e10cSrcweir 		for (::svt::WizardTypes::WizardState i=0; i<m_aExistingRadios.GetEntryCount(); ++i)
277cdf0e10cSrcweir 		{
278cdf0e10cSrcweir 			rSettings.aLabels.push_back(m_aExistingRadios.GetEntry(i));
279cdf0e10cSrcweir 			rSettings.aValues.push_back(String::CreateFromInt32((sal_Int32)(i + 1)));
280cdf0e10cSrcweir 		}
281cdf0e10cSrcweir 
282cdf0e10cSrcweir 		return sal_True;
283cdf0e10cSrcweir 	}
284cdf0e10cSrcweir 
285cdf0e10cSrcweir 	//---------------------------------------------------------------------
286cdf0e10cSrcweir 	IMPL_LINK( ORadioSelectionPage, OnMoveEntry, PushButton*, _pButton )
287cdf0e10cSrcweir 	{
288cdf0e10cSrcweir 		sal_Bool bMoveLeft = (&m_aMoveLeft == _pButton);
289cdf0e10cSrcweir 		if (bMoveLeft)
290cdf0e10cSrcweir 		{
291cdf0e10cSrcweir 			while (m_aExistingRadios.GetSelectEntryCount())
292cdf0e10cSrcweir 				m_aExistingRadios.RemoveEntry(m_aExistingRadios.GetSelectEntryPos(0));
293cdf0e10cSrcweir 		}
294cdf0e10cSrcweir 		else
295cdf0e10cSrcweir 		{
296cdf0e10cSrcweir 			m_aExistingRadios.InsertEntry(m_aRadioName.GetText());
297cdf0e10cSrcweir 			m_aRadioName.SetText(String());
298cdf0e10cSrcweir 		}
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 		implCheckMoveButtons();
301cdf0e10cSrcweir 
302cdf0e10cSrcweir 		//adjust the focus
303cdf0e10cSrcweir 		if (bMoveLeft)
304cdf0e10cSrcweir 			m_aExistingRadios.GrabFocus();
305cdf0e10cSrcweir 		else
306cdf0e10cSrcweir 			m_aRadioName.GrabFocus();
307cdf0e10cSrcweir 		return 0L;
308cdf0e10cSrcweir 	}
309cdf0e10cSrcweir 
310cdf0e10cSrcweir 	//---------------------------------------------------------------------
311cdf0e10cSrcweir 	IMPL_LINK( ORadioSelectionPage, OnEntrySelected, ListBox*, /*_pList*/ )
312cdf0e10cSrcweir 	{
313cdf0e10cSrcweir 		implCheckMoveButtons();
314cdf0e10cSrcweir 		return 0L;
315cdf0e10cSrcweir 	}
316cdf0e10cSrcweir 
317cdf0e10cSrcweir 	//---------------------------------------------------------------------
318cdf0e10cSrcweir 	IMPL_LINK( ORadioSelectionPage, OnNameModified, Edit*, /*_pList*/ )
319cdf0e10cSrcweir 	{
320cdf0e10cSrcweir 		implCheckMoveButtons();
321cdf0e10cSrcweir 		return 0L;
322cdf0e10cSrcweir 	}
323cdf0e10cSrcweir 
324cdf0e10cSrcweir 	//---------------------------------------------------------------------
325cdf0e10cSrcweir 	bool ORadioSelectionPage::canAdvance() const
326cdf0e10cSrcweir 	{
327cdf0e10cSrcweir 		return 0 != m_aExistingRadios.GetEntryCount();
328cdf0e10cSrcweir 	}
329cdf0e10cSrcweir 
330cdf0e10cSrcweir 	//---------------------------------------------------------------------
331cdf0e10cSrcweir 	void ORadioSelectionPage::implCheckMoveButtons()
332cdf0e10cSrcweir 	{
333cdf0e10cSrcweir 		sal_Bool bHaveSome = (0 != m_aExistingRadios.GetEntryCount());
334cdf0e10cSrcweir 		sal_Bool bSelectedSome = (0 != m_aExistingRadios.GetSelectEntryCount());
335cdf0e10cSrcweir 		sal_Bool bUnfinishedInput = (0 != m_aRadioName.GetText().Len());
336cdf0e10cSrcweir 
337cdf0e10cSrcweir 		m_aMoveLeft.Enable(bSelectedSome);
338cdf0e10cSrcweir 		m_aMoveRight.Enable(bUnfinishedInput);
339cdf0e10cSrcweir 
340cdf0e10cSrcweir 		getDialog()->enableButtons(WZB_NEXT, bHaveSome);
341cdf0e10cSrcweir 
342cdf0e10cSrcweir 		if (bUnfinishedInput)
343cdf0e10cSrcweir 		{
344cdf0e10cSrcweir 			if (0 == (m_aMoveRight.GetStyle() & WB_DEFBUTTON))
345cdf0e10cSrcweir 				getDialog()->defaultButton(&m_aMoveRight);
346cdf0e10cSrcweir 		}
347cdf0e10cSrcweir 		else
348cdf0e10cSrcweir 		{
349cdf0e10cSrcweir 			if (WB_DEFBUTTON == (m_aMoveRight.GetStyle() & WB_DEFBUTTON))
350cdf0e10cSrcweir 				getDialog()->defaultButton(WZB_NEXT);
351cdf0e10cSrcweir 		}
352cdf0e10cSrcweir 	}
353cdf0e10cSrcweir 
354cdf0e10cSrcweir 	//=====================================================================
355cdf0e10cSrcweir 	//= ODefaultFieldSelectionPage
356cdf0e10cSrcweir 	//=====================================================================
357cdf0e10cSrcweir 	//---------------------------------------------------------------------
358cdf0e10cSrcweir 	ODefaultFieldSelectionPage::ODefaultFieldSelectionPage( OControlWizard* _pParent )
359cdf0e10cSrcweir 		:OMaybeListSelectionPage(_pParent, ModuleRes(RID_PAGE_DEFAULTFIELDSELECTION))
360cdf0e10cSrcweir 		,m_aFrame					(this, ModuleRes(FL_DEFAULTSELECTION))
361cdf0e10cSrcweir 		,m_aDefaultSelectionLabel	(this, ModuleRes(FT_DEFAULTSELECTION))
362cdf0e10cSrcweir 		,m_aDefSelYes				(this, ModuleRes(RB_DEFSELECTION_YES))
363cdf0e10cSrcweir 		,m_aDefSelNo				(this, ModuleRes(RB_DEFSELECTION_NO))
364cdf0e10cSrcweir 		,m_aDefSelection			(this, ModuleRes(LB_DEFSELECTIONFIELD))
365cdf0e10cSrcweir 	{
366cdf0e10cSrcweir 		FreeResource();
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 		announceControls(m_aDefSelYes, m_aDefSelNo, m_aDefSelection);
369cdf0e10cSrcweir 		m_aDefSelection.SetDropDownLineCount(10);
370cdf0e10cSrcweir 		m_aDefSelection.SetAccessibleRelationLabeledBy( &m_aDefSelYes );
371cdf0e10cSrcweir 		m_aDefSelection.SetAccessibleRelationMemberOf(&m_aDefaultSelectionLabel);
372cdf0e10cSrcweir 	}
373cdf0e10cSrcweir 
374cdf0e10cSrcweir 	//---------------------------------------------------------------------
375cdf0e10cSrcweir 	void ODefaultFieldSelectionPage::initializePage()
376cdf0e10cSrcweir 	{
377cdf0e10cSrcweir 		OMaybeListSelectionPage::initializePage();
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 		const OOptionGroupSettings& rSettings = getSettings();
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 		// fill the listbox
382cdf0e10cSrcweir 		m_aDefSelection.Clear();
383cdf0e10cSrcweir 		for	(	ConstStringArrayIterator aLoop = rSettings.aLabels.begin();
384cdf0e10cSrcweir 				aLoop != rSettings.aLabels.end();
385cdf0e10cSrcweir 				++aLoop
386cdf0e10cSrcweir 			)
387cdf0e10cSrcweir 			m_aDefSelection.InsertEntry(*aLoop);
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 
390cdf0e10cSrcweir 		implInitialize(rSettings.sDefaultField);
391cdf0e10cSrcweir 	}
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 	//---------------------------------------------------------------------
394cdf0e10cSrcweir 	sal_Bool ODefaultFieldSelectionPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
395cdf0e10cSrcweir 	{
396cdf0e10cSrcweir 		if (!OMaybeListSelectionPage::commitPage(_eReason))
397cdf0e10cSrcweir 			return sal_False;
398cdf0e10cSrcweir 
399cdf0e10cSrcweir 		OOptionGroupSettings& rSettings = getSettings();
400cdf0e10cSrcweir 		implCommit(rSettings.sDefaultField);
401cdf0e10cSrcweir 
402cdf0e10cSrcweir 		return sal_True;
403cdf0e10cSrcweir 	}
404cdf0e10cSrcweir 
405cdf0e10cSrcweir 	//=====================================================================
406cdf0e10cSrcweir 	//= OOptionValuesPage
407cdf0e10cSrcweir 	//=====================================================================
408cdf0e10cSrcweir 	//---------------------------------------------------------------------
409cdf0e10cSrcweir 	OOptionValuesPage::OOptionValuesPage( OControlWizard* _pParent )
410cdf0e10cSrcweir 		:OGBWPage(_pParent, ModuleRes(RID_PAGE_OPTIONVALUES))
411cdf0e10cSrcweir 		,m_aFrame				(this, ModuleRes(FL_OPTIONVALUES))
412cdf0e10cSrcweir 		,m_aDescription			(this, ModuleRes(FT_OPTIONVALUES_EXPL))
413cdf0e10cSrcweir 		,m_aValueLabel			(this, ModuleRes(FT_OPTIONVALUES))
414cdf0e10cSrcweir 		,m_aValue				(this, ModuleRes(ET_OPTIONVALUE))
415cdf0e10cSrcweir 		,m_aOptionsLabel		(this, ModuleRes(FT_RADIOBUTTONS))
416cdf0e10cSrcweir 		,m_aOptions				(this, ModuleRes(LB_RADIOBUTTONS))
417cdf0e10cSrcweir 		,m_nLastSelection((::svt::WizardTypes::WizardState)-1)
418cdf0e10cSrcweir 	{
419cdf0e10cSrcweir 		FreeResource();
420cdf0e10cSrcweir 
421cdf0e10cSrcweir 		m_aOptions.SetSelectHdl(LINK(this, OOptionValuesPage, OnOptionSelected));
422cdf0e10cSrcweir 
423cdf0e10cSrcweir 		m_aOptions.SetAccessibleRelationMemberOf(&m_aOptions);
424cdf0e10cSrcweir 		m_aOptions.SetAccessibleRelationLabeledBy(&m_aOptionsLabel);
425cdf0e10cSrcweir 	}
426cdf0e10cSrcweir 
427cdf0e10cSrcweir 	//---------------------------------------------------------------------
428cdf0e10cSrcweir 	IMPL_LINK( OOptionValuesPage, OnOptionSelected, ListBox*, /*NOTINTERESTEDIN*/ )
429cdf0e10cSrcweir 	{
430cdf0e10cSrcweir 		implTraveledOptions();
431cdf0e10cSrcweir 		return 0L;
432cdf0e10cSrcweir 	}
433cdf0e10cSrcweir 
434cdf0e10cSrcweir 	//---------------------------------------------------------------------
435cdf0e10cSrcweir 	void OOptionValuesPage::ActivatePage()
436cdf0e10cSrcweir 	{
437cdf0e10cSrcweir 		OGBWPage::ActivatePage();
438cdf0e10cSrcweir 		m_aValue.GrabFocus();
439cdf0e10cSrcweir 	}
440cdf0e10cSrcweir 
441cdf0e10cSrcweir 	//---------------------------------------------------------------------
442cdf0e10cSrcweir 	void OOptionValuesPage::implTraveledOptions()
443cdf0e10cSrcweir 	{
444cdf0e10cSrcweir 		if ((::svt::WizardTypes::WizardState)-1 != m_nLastSelection)
445cdf0e10cSrcweir 		{
446cdf0e10cSrcweir 			// save the value for the last option
447cdf0e10cSrcweir 			DBG_ASSERT((size_t)m_nLastSelection < m_aUncommittedValues.size(), "OOptionValuesPage::implTraveledOptions: invalid previous selection index!");
448cdf0e10cSrcweir 			m_aUncommittedValues[m_nLastSelection] = m_aValue.GetText();
449cdf0e10cSrcweir 		}
450cdf0e10cSrcweir 
451cdf0e10cSrcweir 		m_nLastSelection = m_aOptions.GetSelectEntryPos();
452cdf0e10cSrcweir 		DBG_ASSERT((size_t)m_nLastSelection < m_aUncommittedValues.size(), "OOptionValuesPage::implTraveledOptions: invalid new selection index!");
453cdf0e10cSrcweir 		m_aValue.SetText(m_aUncommittedValues[m_nLastSelection]);
454cdf0e10cSrcweir 	}
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 	//---------------------------------------------------------------------
457cdf0e10cSrcweir 	void OOptionValuesPage::initializePage()
458cdf0e10cSrcweir 	{
459cdf0e10cSrcweir 		OGBWPage::initializePage();
460cdf0e10cSrcweir 
461cdf0e10cSrcweir 		const OOptionGroupSettings& rSettings = getSettings();
462cdf0e10cSrcweir 		DBG_ASSERT(rSettings.aLabels.size(), "OOptionValuesPage::initializePage: no options!!");
463cdf0e10cSrcweir 		DBG_ASSERT(rSettings.aLabels.size() == rSettings.aValues.size(), "OOptionValuesPage::initializePage: inconsistent data!");
464cdf0e10cSrcweir 
465cdf0e10cSrcweir 		// fill the list with all available options
466cdf0e10cSrcweir 		m_aOptions.Clear();
467cdf0e10cSrcweir 		m_nLastSelection = -1;
468cdf0e10cSrcweir 		for	(	ConstStringArrayIterator aLoop = rSettings.aLabels.begin();
469cdf0e10cSrcweir 				aLoop != rSettings.aLabels.end();
470cdf0e10cSrcweir 				++aLoop
471cdf0e10cSrcweir 			)
472cdf0e10cSrcweir 			m_aOptions.InsertEntry(*aLoop);
473cdf0e10cSrcweir 
474cdf0e10cSrcweir 		// remember the values ... can't set them directly in the settings without the explicit commit call
475cdf0e10cSrcweir 		// so we need have a copy of the values
476cdf0e10cSrcweir 		m_aUncommittedValues = rSettings.aValues;
477cdf0e10cSrcweir 
478cdf0e10cSrcweir 		// select the first entry
479cdf0e10cSrcweir 		m_aOptions.SelectEntryPos(0);
480cdf0e10cSrcweir 		implTraveledOptions();
481cdf0e10cSrcweir 	}
482cdf0e10cSrcweir 
483cdf0e10cSrcweir 	//---------------------------------------------------------------------
484cdf0e10cSrcweir 	sal_Bool OOptionValuesPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
485cdf0e10cSrcweir 	{
486cdf0e10cSrcweir 		if (!OGBWPage::commitPage(_eReason))
487cdf0e10cSrcweir 			return sal_False;
488cdf0e10cSrcweir 
489cdf0e10cSrcweir 		OOptionGroupSettings& rSettings = getSettings();
490cdf0e10cSrcweir 
491cdf0e10cSrcweir 		// commit the current value
492cdf0e10cSrcweir 		implTraveledOptions();
493cdf0e10cSrcweir 		// copy the uncommitted values
494cdf0e10cSrcweir 		rSettings.aValues = m_aUncommittedValues;
495cdf0e10cSrcweir 
496cdf0e10cSrcweir 		return sal_True;
497cdf0e10cSrcweir 	}
498cdf0e10cSrcweir 
499cdf0e10cSrcweir 	//=====================================================================
500cdf0e10cSrcweir 	//= OOptionDBFieldPage
501cdf0e10cSrcweir 	//=====================================================================
502cdf0e10cSrcweir 	//---------------------------------------------------------------------
503cdf0e10cSrcweir 	OOptionDBFieldPage::OOptionDBFieldPage( OControlWizard* _pParent )
504cdf0e10cSrcweir 		:ODBFieldPage(_pParent)
505cdf0e10cSrcweir 	{
506cdf0e10cSrcweir 		setDescriptionText(String(ModuleRes(RID_STR_GROUPWIZ_DBFIELD)));
507cdf0e10cSrcweir 	}
508cdf0e10cSrcweir 
509cdf0e10cSrcweir 	//---------------------------------------------------------------------
510cdf0e10cSrcweir 	String& OOptionDBFieldPage::getDBFieldSetting()
511cdf0e10cSrcweir 	{
512cdf0e10cSrcweir 		return getSettings().sDBField;
513cdf0e10cSrcweir 	}
514cdf0e10cSrcweir 
515cdf0e10cSrcweir 	//=====================================================================
516cdf0e10cSrcweir 	//= OFinalizeGBWPage
517cdf0e10cSrcweir 	//=====================================================================
518cdf0e10cSrcweir 	//---------------------------------------------------------------------
519cdf0e10cSrcweir 	OFinalizeGBWPage::OFinalizeGBWPage( OControlWizard* _pParent )
520cdf0e10cSrcweir 		:OGBWPage(_pParent, ModuleRes(RID_PAGE_OPTIONS_FINAL))
521cdf0e10cSrcweir 		,m_aFrame			(this, ModuleRes(FL_NAMEIT))
522cdf0e10cSrcweir 		,m_aNameLabel		(this, ModuleRes(FT_NAMEIT))
523cdf0e10cSrcweir 		,m_aName			(this, ModuleRes(ET_NAMEIT))
524cdf0e10cSrcweir 		,m_aThatsAll		(this, ModuleRes(FT_THATSALL))
525cdf0e10cSrcweir 	{
526cdf0e10cSrcweir 		FreeResource();
527cdf0e10cSrcweir 	}
528cdf0e10cSrcweir 
529cdf0e10cSrcweir 	//---------------------------------------------------------------------
530cdf0e10cSrcweir 	void OFinalizeGBWPage::ActivatePage()
531cdf0e10cSrcweir 	{
532cdf0e10cSrcweir 		OGBWPage::ActivatePage();
533cdf0e10cSrcweir 		m_aName.GrabFocus();
534cdf0e10cSrcweir 	}
535cdf0e10cSrcweir 
536cdf0e10cSrcweir 	//---------------------------------------------------------------------
537cdf0e10cSrcweir 	bool OFinalizeGBWPage::canAdvance() const
538cdf0e10cSrcweir 	{
539cdf0e10cSrcweir 		return false;
540cdf0e10cSrcweir 	}
541cdf0e10cSrcweir 
542cdf0e10cSrcweir 	//---------------------------------------------------------------------
543cdf0e10cSrcweir 	void OFinalizeGBWPage::initializePage()
544cdf0e10cSrcweir 	{
545cdf0e10cSrcweir 		OGBWPage::initializePage();
546cdf0e10cSrcweir 
547cdf0e10cSrcweir 		const OOptionGroupSettings& rSettings = getSettings();
548cdf0e10cSrcweir 		m_aName.SetText(rSettings.sControlLabel);
549cdf0e10cSrcweir 	}
550cdf0e10cSrcweir 
551cdf0e10cSrcweir 	//---------------------------------------------------------------------
552cdf0e10cSrcweir 	sal_Bool OFinalizeGBWPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
553cdf0e10cSrcweir 	{
554cdf0e10cSrcweir 		if (!OGBWPage::commitPage(_eReason))
555cdf0e10cSrcweir 			return sal_False;
556cdf0e10cSrcweir 
557cdf0e10cSrcweir 		getSettings().sControlLabel = m_aName.GetText();
558cdf0e10cSrcweir 
559cdf0e10cSrcweir 		return sal_True;
560cdf0e10cSrcweir 	}
561cdf0e10cSrcweir 
562cdf0e10cSrcweir //.........................................................................
563cdf0e10cSrcweir }	// namespace dbp
564cdf0e10cSrcweir //.........................................................................
565cdf0e10cSrcweir 
566