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