merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / ui / dlg / adminpages.hxx
blobf8ba43384b8b2671bdba9ffd174bc9333fab9dd9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: adminpages.hxx,v $
10 * $Revision: 1.35.68.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _DBAUI_ADMINPAGES_HXX_
32 #define _DBAUI_ADMINPAGES_HXX_
34 #ifndef _SFXTABDLG_HXX
35 #include <sfx2/tabdlg.hxx>
36 #endif
37 #ifndef _DBAUI_DSNTYPES_HXX_
38 #include "dsntypes.hxx"
39 #endif
40 #ifndef _DBAUI_COMMON_TYPES_HXX_
41 #include "commontypes.hxx"
42 #endif
43 #ifndef _SVTOOLS_WIZARDMACHINE_HXX_
44 #include <svtools/wizardmachine.hxx>
45 #endif
46 #ifndef _SV_FIELD_HXX
47 #include <vcl/field.hxx>
48 #endif
49 #ifndef _SV_FIXED_HXX
50 #include <vcl/fixed.hxx>
51 #endif
54 class NumericField;
55 class Edit;
56 //.........................................................................
57 namespace dbaui
59 //.........................................................................
60 /// helper class to wrap the savevalue and disable call
61 class SAL_NO_VTABLE ISaveValueWrapper
63 public:
64 virtual bool SaveValue() = 0;
65 virtual bool Disable() = 0;
68 template < class T > class OSaveValueWrapper : public ISaveValueWrapper
70 T* m_pSaveValue;
71 public:
72 OSaveValueWrapper(T* _pSaveValue) : m_pSaveValue(_pSaveValue)
73 { OSL_ENSURE(m_pSaveValue,"Illegal argument!"); }
75 virtual bool SaveValue() { m_pSaveValue->SaveValue(); return true;} // bool return value only for stl
76 virtual bool Disable() { m_pSaveValue->Disable(); return true;} // bool return value only for stl
79 template < class T > class ODisableWrapper : public ISaveValueWrapper
81 T* m_pSaveValue;
82 public:
83 ODisableWrapper(T* _pSaveValue) : m_pSaveValue(_pSaveValue)
84 { OSL_ENSURE(m_pSaveValue,"Illegal argument!"); }
86 virtual bool SaveValue() { return true;} // bool return value only for stl
87 virtual bool Disable() { m_pSaveValue->Disable(); return true;} // bool return value only for stl
90 struct TSaveValueWrapperFunctor : public ::std::unary_function< ISaveValueWrapper, bool>
92 bool operator() (ISaveValueWrapper* lhs)
94 return lhs->SaveValue();
97 struct TDisableWrapperFunctor : public ::std::unary_function< ISaveValueWrapper, bool>
99 bool operator() (ISaveValueWrapper* lhs)
101 return lhs->Disable();
105 struct TDeleteWrapperFunctor : public ::std::unary_function< ISaveValueWrapper, bool>
107 bool operator() (ISaveValueWrapper* lhs)
109 delete lhs;
110 return true;
114 //=========================================================================
115 //= OGenericAdministrationPage
116 //=========================================================================
117 class IDatabaseSettingsDialog;
118 class IItemSetHelper;
119 class OGenericAdministrationPage : public SfxTabPage, public svt::IWizardPage
121 private:
122 Link m_aModifiedHandler; /// to be called if something on the page has been modified
123 sal_Bool m_abEnableRoadmap;
124 protected:
125 IDatabaseSettingsDialog* m_pAdminDialog;
126 IItemSetHelper* m_pItemSetHelper;
127 FixedText* m_pFT_HeaderText;
129 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
130 m_xORB;
131 public:
132 OGenericAdministrationPage(Window* _pParent, const ResId& _rId, const SfxItemSet& _rAttrSet);
133 ~OGenericAdministrationPage();
135 /// set a handler which gets called every time something on the page has been modified
136 void SetModifiedHandler(const Link& _rHandler) { m_aModifiedHandler = _rHandler; }
138 /** Sets the ParentDialog
139 @param _pAdminDialog
140 the ParentDialog
141 @param _pItemSetHelper
142 the itemset helper
144 inline void SetAdminDialog(IDatabaseSettingsDialog* _pDialog,IItemSetHelper* _pItemSetHelper)
146 OSL_ENSURE(_pDialog && _pItemSetHelper,"Values are NULL!");
147 m_pAdminDialog = _pDialog;
148 m_pItemSetHelper = _pItemSetHelper;
151 /** Sets the ServiceFactory
152 @param _rxORB
153 The service factory.
155 virtual void SetServiceFactory(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB)
157 m_xORB = _rxORB;
160 /** opens a dialog filled with all data sources available for this type and
161 returns the selected on.
162 @param _eType
163 The type for which the data source dialog should be opened.
164 @param _sReturn
165 <OUT/> contains the selected name.
166 @return
167 <FALSE/> if an error occured, otherwise <TRUE/>
169 sal_Bool getSelectedDataSource(::rtl::OUString& _sReturn,::rtl::OUString& _sCurr);
171 // svt::IWizardPage
172 virtual void initializePage();
173 virtual sal_Bool commitPage( CommitPageReason _eReason );
175 void SetRoadmapStateValue( sal_Bool _bDoEnable ) { m_abEnableRoadmap = _bDoEnable; }
176 bool GetRoadmapStateValue() const { return m_abEnableRoadmap; }
178 protected:
179 /// default implementation: call FillItemSet, call prepareLeave,
180 virtual int DeactivatePage(SfxItemSet* pSet);
181 using SfxTabPage::DeactivatePage;
182 /// default implementation: call implInitControls with the given item set and _bSaveValue = sal_False
183 virtual void Reset(const SfxItemSet& _rCoreAttrs);
184 /// default implementation: call implInitControls with the given item set and _bSaveValue = sal_True
185 virtual void ActivatePage(const SfxItemSet& _rSet);
187 // TabPage overridables
188 virtual void ActivatePage();
190 protected:
191 void callModifiedHdl() const { if (m_aModifiedHandler.IsSet()) m_aModifiedHandler.Call((void*)this); }
193 /// called from within DeactivatePage. The page is allowed to be deactivated if this method returns sal_True
194 virtual sal_Bool prepareLeave() { return sal_True; }
196 /** called from within Reset and ActivatePage, use to initialize the controls with the items from the given set
197 @param _bSaveValue if set to sal_True, the implementation should call SaveValue on all relevant controls
199 virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
201 /// analyze the invalid and the readonly flag which may be present in the set
202 void getFlags(const SfxItemSet& _rSet, sal_Bool& _rValid, sal_Bool& _rReadonly);
204 /** will be called inside <method>implInitControls</method> to save the value if necessary
205 @param _rControlList
206 The list must be filled with the controls.
207 It is not allowed to clear the list before pusching data into it.
209 virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) = 0;
211 /** will be called inside <method>implInitControls</method> to disable if necessary
212 @param _rControlList
213 The list must be filled with the controls.
214 It is not allowed to clear the list before pusching data into it.
216 virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) = 0;
218 public:
219 /** fills the Boolean value into the item set when the value changed.
220 @param _rSet
221 The item set where to put the new value into.
222 @param _pCheckBox
223 The check box which is checked.
224 @param _nID
225 The id in the itemset to set whith the new value.
226 @param _bChangedSomething
227 <TRUE/> if something changed otherwise <FALSE/>
228 @param _bRevertValue
229 set to <TRUE/> if the display value should be reverted before putting it into the set
231 static void fillBool( SfxItemSet& _rSet, CheckBox* _pCheckBox, USHORT _nID, sal_Bool& _bChangedSomething, bool _bRevertValue = false);
233 /** fills the int value into the item set when the value changed.
234 @param _rSet
235 The item set where to put the new value into.
236 @param _pEdit
237 The check box which is checked.
238 @param _nID
239 The id in the itemset to set whith the new value.
240 @param _bChangedSomething
241 <TRUE/> if something changed otherwise <FALSE/>
243 static void fillInt32(SfxItemSet& _rSet,NumericField* _pEdit,USHORT _nID,sal_Bool& _bChangedSomething);
245 /** fills the String value into the item set when the value changed.
246 @param _rSet
247 The item set where to put the new value into.
248 @param _pEdit
249 The check box which is checked.
250 @param _nID
251 The id in the itemset to set whith the new value.
252 @param _bChangedSomething
253 <TRUE/> if something changed otherwise <FALSE/>
255 static void fillString(SfxItemSet& _rSet,Edit* _pEdit,USHORT _nID,sal_Bool& _bChangedSomething);
257 protected:
258 // used to set the right Pane header of a wizard to bold
259 void SetControlFontWeight(Window* _pWindow, FontWeight _eWeight = WEIGHT_BOLD);
260 void SetHeaderText( USHORT _nFTResId, USHORT _StringResId);
262 /** This link be used for controls where the tabpage does not need to take any special action when the control
263 is modified. The implementation just calls callModifiedHdl.
265 DECL_LINK(OnControlModified, Control*);
266 DECL_LINK(OnTestConnectionClickHdl,PushButton*);
268 /// may be used in SetXXXHdl calls to controls, is a link to <method>OnControlModified</method>
269 virtual Link getControlModifiedLink() { return LINK(this, OGenericAdministrationPage, OnControlModified); }
272 //=========================================================================
273 //= ControlRelation
274 //=========================================================================
275 enum ControlRelation
277 RelatedControls, UnrelatedControls
280 //=========================================================================
281 //= LayoutHelper
282 //=========================================================================
283 class LayoutHelper
285 public:
286 static void positionBelow(
287 const Control& _rReference,
288 Control& _rControl,
289 const ControlRelation _eRelation,
290 const long _nIndentAppFont
294 //.........................................................................
295 } // namespace dbaui
296 //.........................................................................
298 #endif // _DBAUI_ADMINPAGES_HXX_