Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #ifndef _DBAUI_ADMINPAGES_HXX_
21 : : #define _DBAUI_ADMINPAGES_HXX_
22 : :
23 : : #include <sfx2/tabdlg.hxx>
24 : : #include "dsntypes.hxx"
25 : : #include "commontypes.hxx"
26 : : #include <svtools/wizardmachine.hxx>
27 : : #include <vcl/field.hxx>
28 : : #include <vcl/fixed.hxx>
29 : :
30 : :
31 : : class NumericField;
32 : : class Edit;
33 : : //.........................................................................
34 : : namespace dbaui
35 : : {
36 : : //.........................................................................
37 : : /// helper class to wrap the savevalue and disable call
38 : 0 : class SAL_NO_VTABLE ISaveValueWrapper
39 : : {
40 : : public:
41 : : virtual ~ISaveValueWrapper() = 0;
42 : : virtual bool SaveValue() = 0;
43 : : virtual bool Disable() = 0;
44 : : };
45 : :
46 [ # # ][ # # ]: 0 : template < class T > class OSaveValueWrapper : public ISaveValueWrapper
[ # # ][ # # ]
47 : : {
48 : : T* m_pSaveValue;
49 : : public:
50 : 0 : OSaveValueWrapper(T* _pSaveValue) : m_pSaveValue(_pSaveValue)
51 : 0 : { OSL_ENSURE(m_pSaveValue,"Illegal argument!"); }
52 : :
53 : 0 : virtual bool SaveValue() { m_pSaveValue->SaveValue(); return true;} // bool return value only for stl
54 : 0 : virtual bool Disable() { m_pSaveValue->Disable(); return true;} // bool return value only for stl
55 : : };
56 : :
57 [ # # ][ # # ]: 0 : template < class T > class ODisableWrapper : public ISaveValueWrapper
[ # # ]
58 : : {
59 : : T* m_pSaveValue;
60 : : public:
61 : 0 : ODisableWrapper(T* _pSaveValue) : m_pSaveValue(_pSaveValue)
62 : 0 : { OSL_ENSURE(m_pSaveValue,"Illegal argument!"); }
63 : :
64 : 0 : virtual bool SaveValue() { return true;} // bool return value only for stl
65 : 0 : virtual bool Disable() { m_pSaveValue->Disable(); return true;} // bool return value only for stl
66 : : };
67 : :
68 : : struct TSaveValueWrapperFunctor : public ::std::unary_function< ISaveValueWrapper, bool>
69 : : {
70 : 0 : bool operator() (ISaveValueWrapper* lhs)
71 : : {
72 : 0 : return lhs->SaveValue();
73 : : }
74 : : };
75 : : struct TDisableWrapperFunctor : public ::std::unary_function< ISaveValueWrapper, bool>
76 : : {
77 : 0 : bool operator() (ISaveValueWrapper* lhs)
78 : : {
79 : 0 : return lhs->Disable();
80 : : }
81 : : };
82 : :
83 : : struct TDeleteWrapperFunctor : public ::std::unary_function< ISaveValueWrapper, bool>
84 : : {
85 : 0 : bool operator() (ISaveValueWrapper* lhs)
86 : : {
87 [ # # ]: 0 : delete lhs;
88 : 0 : return true;
89 : : }
90 : : };
91 : :
92 : : //=========================================================================
93 : : //= OGenericAdministrationPage
94 : : //=========================================================================
95 : : class IDatabaseSettingsDialog;
96 : : class IItemSetHelper;
97 : : class OGenericAdministrationPage :public SfxTabPage
98 : : ,public ::svt::IWizardPageController
99 : : {
100 : : private:
101 : : Link m_aModifiedHandler; /// to be called if something on the page has been modified
102 : : sal_Bool m_abEnableRoadmap;
103 : : protected:
104 : : IDatabaseSettingsDialog* m_pAdminDialog;
105 : : IItemSetHelper* m_pItemSetHelper;
106 : : FixedText* m_pFT_HeaderText;
107 : :
108 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
109 : : m_xORB;
110 : : public:
111 : : OGenericAdministrationPage(Window* _pParent, const ResId& _rId, const SfxItemSet& _rAttrSet);
112 : : ~OGenericAdministrationPage();
113 : :
114 : : /// set a handler which gets called every time something on the page has been modified
115 : 0 : void SetModifiedHandler(const Link& _rHandler) { m_aModifiedHandler = _rHandler; }
116 : :
117 : : /** Sets the ParentDialog
118 : : @param _pAdminDialog
119 : : the ParentDialog
120 : : @param _pItemSetHelper
121 : : the itemset helper
122 : : */
123 : 0 : inline void SetAdminDialog(IDatabaseSettingsDialog* _pDialog,IItemSetHelper* _pItemSetHelper)
124 : : {
125 : : OSL_ENSURE(_pDialog && _pItemSetHelper,"Values are NULL!");
126 : 0 : m_pAdminDialog = _pDialog;
127 : 0 : m_pItemSetHelper = _pItemSetHelper;
128 : 0 : }
129 : :
130 : : /** Sets the ServiceFactory
131 : : @param _rxORB
132 : : The service factory.
133 : : */
134 : 0 : virtual void SetServiceFactory(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB)
135 : : {
136 : 0 : m_xORB = _rxORB;
137 : 0 : }
138 : :
139 : : /** opens a dialog filled with all data sources available for this type and
140 : : returns the selected on.
141 : : @param _eType
142 : : The type for which the data source dialog should be opened.
143 : : @param _sReturn
144 : : <OUT/> contains the selected name.
145 : : @return
146 : : <FALSE/> if an error occurred, otherwise <TRUE/>
147 : : */
148 : : sal_Bool getSelectedDataSource(::rtl::OUString& _sReturn,::rtl::OUString& _sCurr);
149 : :
150 : : // svt::IWizardPageController
151 : : virtual void initializePage();
152 : : virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
153 : : virtual bool canAdvance() const;
154 : :
155 : 0 : void SetRoadmapStateValue( sal_Bool _bDoEnable ) { m_abEnableRoadmap = _bDoEnable; }
156 : 0 : bool GetRoadmapStateValue() const { return m_abEnableRoadmap; }
157 : :
158 : : protected:
159 : : /// default implementation: call FillItemSet, call prepareLeave,
160 : : virtual int DeactivatePage(SfxItemSet* pSet);
161 : : using SfxTabPage::DeactivatePage;
162 : : /// default implementation: call implInitControls with the given item set and _bSaveValue = sal_False
163 : : virtual void Reset(const SfxItemSet& _rCoreAttrs);
164 : : /// default implementation: call implInitControls with the given item set and _bSaveValue = sal_True
165 : : virtual void ActivatePage(const SfxItemSet& _rSet);
166 : :
167 : : // TabPage overridables
168 : : virtual void ActivatePage();
169 : :
170 : : protected:
171 [ # # ]: 0 : void callModifiedHdl() const { if (m_aModifiedHandler.IsSet()) m_aModifiedHandler.Call((void*)this); }
172 : :
173 : : /// called from within DeactivatePage. The page is allowed to be deactivated if this method returns sal_True
174 : 0 : virtual sal_Bool prepareLeave() { return sal_True; }
175 : :
176 : : /** called from within Reset and ActivatePage, use to initialize the controls with the items from the given set
177 : : @param _bSaveValue if set to sal_True, the implementation should call SaveValue on all relevant controls
178 : : */
179 : : virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
180 : :
181 : : /// analyze the invalid and the readonly flag which may be present in the set
182 : : void getFlags(const SfxItemSet& _rSet, sal_Bool& _rValid, sal_Bool& _rReadonly);
183 : :
184 : : /** will be called inside <method>implInitControls</method> to save the value if necessary
185 : : @param _rControlList
186 : : The list must be filled with the controls.
187 : : It is not allowed to clear the list before pusching data into it.
188 : : */
189 : : virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) = 0;
190 : :
191 : : /** will be called inside <method>implInitControls</method> to disable if necessary
192 : : @param _rControlList
193 : : The list must be filled with the controls.
194 : : It is not allowed to clear the list before pusching data into it.
195 : : */
196 : : virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) = 0;
197 : :
198 : : public:
199 : : /** fills the Boolean value into the item set when the value changed.
200 : : @param _rSet
201 : : The item set where to put the new value into.
202 : : @param _pCheckBox
203 : : The check box which is checked.
204 : : @param _nID
205 : : The id in the itemset to set whith the new value.
206 : : @param _bChangedSomething
207 : : <TRUE/> if something changed otherwise <FALSE/>
208 : : @param _bRevertValue
209 : : set to <TRUE/> if the display value should be reverted before putting it into the set
210 : : */
211 : : static void fillBool( SfxItemSet& _rSet, CheckBox* _pCheckBox, sal_uInt16 _nID, sal_Bool& _bChangedSomething, bool _bRevertValue = false);
212 : :
213 : : /** fills the int value into the item set when the value changed.
214 : : @param _rSet
215 : : The item set where to put the new value into.
216 : : @param _pEdit
217 : : The check box which is checked.
218 : : @param _nID
219 : : The id in the itemset to set whith the new value.
220 : : @param _bChangedSomething
221 : : <TRUE/> if something changed otherwise <FALSE/>
222 : : */
223 : : static void fillInt32(SfxItemSet& _rSet,NumericField* _pEdit,sal_uInt16 _nID,sal_Bool& _bChangedSomething);
224 : :
225 : : /** fills the String value into the item set when the value changed.
226 : : @param _rSet
227 : : The item set where to put the new value into.
228 : : @param _pEdit
229 : : The check box which is checked.
230 : : @param _nID
231 : : The id in the itemset to set whith the new value.
232 : : @param _bChangedSomething
233 : : <TRUE/> if something changed otherwise <FALSE/>
234 : : */
235 : : static void fillString(SfxItemSet& _rSet,Edit* _pEdit,sal_uInt16 _nID,sal_Bool& _bChangedSomething);
236 : :
237 : : protected:
238 : : // used to set the right Pane header of a wizard to bold
239 : : void SetControlFontWeight(Window* _pWindow, FontWeight _eWeight = WEIGHT_BOLD);
240 : : void SetHeaderText( sal_uInt16 _nFTResId, sal_uInt16 _StringResId);
241 : :
242 : : /** This link be used for controls where the tabpage does not need to take any special action when the control
243 : : is modified. The implementation just calls callModifiedHdl.
244 : : */
245 : : DECL_LINK(OnControlModified, void*);
246 : : DECL_LINK(OnTestConnectionClickHdl,PushButton*);
247 : :
248 : : /// may be used in SetXXXHdl calls to controls, is a link to <method>OnControlModified</method>
249 : 0 : virtual Link getControlModifiedLink() { return LINK(this, OGenericAdministrationPage, OnControlModified); }
250 : : };
251 : :
252 : : //=========================================================================
253 : : //= ControlRelation
254 : : //=========================================================================
255 : : enum ControlRelation
256 : : {
257 : : RelatedControls, UnrelatedControls
258 : : };
259 : :
260 : : //=========================================================================
261 : : //= LayoutHelper
262 : : //=========================================================================
263 : : class LayoutHelper
264 : : {
265 : : public:
266 : : static void positionBelow(
267 : : const Control& _rReference,
268 : : Control& _rControl,
269 : : const ControlRelation _eRelation,
270 : : const long _nIndentAppFont
271 : : );
272 : : /** fits the button size to be large enough to contain the buttons text
273 : : */
274 : : static void fitSizeRightAligned( PushButton& io_button );
275 : : // why is CalcMinimumSize not a virtual method of ::Window?
276 : : };
277 : :
278 : : //.........................................................................
279 : : } // namespace dbaui
280 : : //.........................................................................
281 : :
282 : : #endif // _DBAUI_ADMINPAGES_HXX_
283 : :
284 : :
285 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|