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_CONTROLWIZARD_HXX
29 #define _EXTENSIONS_DBP_CONTROLWIZARD_HXX
30 
31 #include <svtools/wizardmachine.hxx>
32 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
33 #include <com/sun/star/form/FormComponentType.hpp>
34 #include <com/sun/star/sdbc/XConnection.hpp>
35 #include <com/sun/star/task/XInteractionHandler.hpp>
36 #include <vcl/fixed.hxx>
37 #include <vcl/edit.hxx>
38 #ifndef _SV_BUTTON_HXX
39 #include <vcl/button.hxx>
40 #endif
41 #include <vcl/lstbox.hxx>
42 #include <vcl/combobox.hxx>
43 #include "dbptypes.hxx"
44 #ifndef _EXTENSIONS_DBP_DBPRESID_HRC_
45 #include "dbpresid.hrc"
46 #endif
47 #include "componentmodule.hxx"
48 #include "wizardcontext.hxx"
49 
50 class ResId;
51 //.........................................................................
52 namespace dbp
53 {
54 //.........................................................................
55 
56 	//=====================================================================
57 	//= OControlWizardSettings
58 	//=====================================================================
59 	struct OControlWizardSettings
60 	{
61 		String		sControlLabel;
62 	};
63 
64 	//=====================================================================
65 	//= OControlWizardPage
66 	//=====================================================================
67 	class OControlWizard;
68 	typedef ::svt::OWizardPage OControlWizardPage_Base;
69 	class OControlWizardPage : public OControlWizardPage_Base
70 	{
71 	protected:
72 		FixedLine*		m_pFormSettingsSeparator;
73 		FixedText*		m_pFormDatasourceLabel;
74 		FixedText*		m_pFormDatasource;
75 		FixedText*		m_pFormContentTypeLabel;
76 		FixedText*		m_pFormContentType;
77 		FixedText*		m_pFormTableLabel;
78 		FixedText*		m_pFormTable;
79 
80 	protected:
81 		OControlWizard*					getDialog();
82 		const OControlWizard*			getDialog() const;
83 		const OControlWizardContext&	getContext();
84 		sal_Bool						updateContext();
85 		void							setFormConnection(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn, sal_Bool _bAutoDispose = sal_True );
86 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
87 										getFormConnection() const;
88 
89 	public:
90 		OControlWizardPage( OControlWizard* _pParent, const ResId& _rResId );
91 		~OControlWizardPage();
92 
93 	protected:
94 		void fillListBox(
95 			ListBox& _rList,
96 			const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rItems,
97 			sal_Bool _bClear = sal_True);
98 		void fillListBox(
99 			ComboBox& _rList,
100 			const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rItems,
101 			sal_Bool _bClear = sal_True);
102 
103 	protected:
104 		void enableFormDatasourceDisplay();
105 		void adjustControlForNoDSDisplay(Control* _pControl, sal_Bool bConstLowerDistance = sal_False);
106 
107 	protected:
108 		// OWizardPage overridables
109 		virtual void		initializePage();
110 	};
111 
112 	struct OAccessRegulator;
113 	//=====================================================================
114 	//= OControlWizard
115 	//=====================================================================
116 	typedef ::svt::OWizardMachine OControlWizard_Base;
117 	class OControlWizard : public OControlWizard_Base
118 	{
119 	private:
120 		OControlWizardContext	m_aContext;
121 
122 	protected:
123 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
124 					m_xORB;
125 
126 	public:
127 		OControlWizard(
128 			Window* _pParent,
129 			const ResId& _rId,
130 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObjectModel,
131 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
132 		);
133 		~OControlWizard();
134 
135 		// make the some base class methods public
136 		sal_Bool	travelNext() { return OControlWizard_Base::travelNext(); }
137 
138 	public:
139 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
140 			getServiceFactory() const { return m_xORB; }
141 
142 		const OControlWizardContext&	getContext() const { return m_aContext; }
143 		sal_Bool						updateContext(const OAccessRegulator&);
144 		void							setFormConnection(const OAccessRegulator&, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn, sal_Bool _bAutoDispose = sal_True );
145 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
146 										getFormConnection(const OAccessRegulator&) const;
147 
148         /** returns the com.sun.star.task.InteractionHandler
149             @param  _pWindow    The window will be used when an error message has to be shown.
150         */
151         ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > getInteractionHandler(Window* _pWindow) const;
152 
153 	protected:
154 		// initialize the derivees settings (which have to be derived from OControlWizardSettings)
155 		// with some common data extracted from the control model
156 		void initControlSettings(OControlWizardSettings* _pSettings);
157 		// commit the control-relevant settings
158 		void commitControlSettings(OControlWizardSettings* _pSettings);
159 
160 		sal_Bool needDatasourceSelection();
161 
162         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
163 										getFormConnection() const;
164 
165 		virtual sal_Bool approveControl(sal_Int16 _nClassId) = 0;
166 
167 		// ModalDialog overridables
168 		virtual short	Execute();
169 
170 	private:
171 		sal_Bool initContext();
172 
173 		void implGetDSContext();
174 		void implDetermineForm();
175 		void implDeterminePage();
176 		void implDetermineShape();
177 
178 		// made private. Not to be used by derived (or external) classes
179 		virtual void ActivatePage();
180 	};
181 
182 //.........................................................................
183 }	// namespace dbp
184 //.........................................................................
185 
186 #endif // _EXTENSIONS_DBP_CONTROLWIZARD_HXX
187 
188