fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / dlg / adminpages.hxx
blobe5b11252144cee99e3a1708648c0b6ab76e29786
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_DBACCESS_SOURCE_UI_DLG_ADMINPAGES_HXX
21 #define INCLUDED_DBACCESS_SOURCE_UI_DLG_ADMINPAGES_HXX
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>
30 class NumericField;
31 class Edit;
32 namespace dbaui
34 /// helper class to wrap the savevalue and disable call
35 class SAL_NO_VTABLE ISaveValueWrapper
37 public:
38 virtual ~ISaveValueWrapper() = 0;
39 virtual bool SaveValue() = 0;
40 virtual bool Disable() = 0;
43 template < class T > class OSaveValueWrapper : public ISaveValueWrapper
45 T* m_pSaveValue;
46 public:
47 OSaveValueWrapper(T* _pSaveValue) : m_pSaveValue(_pSaveValue)
48 { OSL_ENSURE(m_pSaveValue,"Illegal argument!"); }
50 virtual bool SaveValue() SAL_OVERRIDE { m_pSaveValue->SaveValue(); return true;} // bool return value only for stl
51 virtual bool Disable() SAL_OVERRIDE { m_pSaveValue->Disable(); return true;} // bool return value only for stl
54 template < class T > class ODisableWrapper : public ISaveValueWrapper
56 T* m_pSaveValue;
57 public:
58 ODisableWrapper(T* _pSaveValue) : m_pSaveValue(_pSaveValue)
59 { OSL_ENSURE(m_pSaveValue,"Illegal argument!"); }
61 virtual bool SaveValue() SAL_OVERRIDE { return true;} // bool return value only for stl
62 virtual bool Disable() SAL_OVERRIDE { m_pSaveValue->Disable(); return true;} // bool return value only for stl
65 struct TSaveValueWrapperFunctor : public ::std::unary_function< ISaveValueWrapper, bool>
67 bool operator() (ISaveValueWrapper* lhs)
69 return lhs->SaveValue();
72 struct TDisableWrapperFunctor : public ::std::unary_function< ISaveValueWrapper, bool>
74 bool operator() (ISaveValueWrapper* lhs)
76 return lhs->Disable();
80 struct TDeleteWrapperFunctor : public ::std::unary_function< ISaveValueWrapper, bool>
82 bool operator() (ISaveValueWrapper* lhs)
84 delete lhs;
85 return true;
89 // OGenericAdministrationPage
90 class IDatabaseSettingsDialog;
91 class IItemSetHelper;
92 class OGenericAdministrationPage :public SfxTabPage
93 ,public ::svt::IWizardPageController
95 private:
96 Link<OGenericAdministrationPage const *, void> m_aModifiedHandler; /// to be called if something on the page has been modified
97 bool m_abEnableRoadmap;
98 protected:
99 IDatabaseSettingsDialog* m_pAdminDialog;
100 IItemSetHelper* m_pItemSetHelper;
102 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
103 m_xORB;
104 public:
105 OGenericAdministrationPage(vcl::Window* _pParent, const OString& _rId, const OUString& _rUIXMLDescription, const SfxItemSet& _rAttrSet);
106 /// set a handler which gets called every time something on the page has been modified
107 void SetModifiedHandler(const Link<OGenericAdministrationPage const *, void>& _rHandler) { m_aModifiedHandler = _rHandler; }
109 /** Sets the ParentDialog
110 @param _pAdminDialog
111 the ParentDialog
112 @param _pItemSetHelper
113 the itemset helper
115 inline void SetAdminDialog(IDatabaseSettingsDialog* _pDialog,IItemSetHelper* _pItemSetHelper)
117 OSL_ENSURE(_pDialog && _pItemSetHelper,"Values are NULL!");
118 m_pAdminDialog = _pDialog;
119 m_pItemSetHelper = _pItemSetHelper;
122 /** Sets the ServiceFactory
123 @param _rxORB
124 The service factory.
126 void SetServiceFactory(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxORB)
128 m_xORB = rxORB;
131 /** opens a dialog filled with all data sources available for this type and
132 returns the selected on.
133 @param _eType
134 The type for which the data source dialog should be opened.
135 @param _sReturn
136 <OUT/> contains the selected name.
137 @return
138 <FALSE/> if an error occurred, otherwise <TRUE/>
140 bool getSelectedDataSource(OUString& _sReturn, OUString& _sCurr);
142 // svt::IWizardPageController
143 virtual void initializePage() SAL_OVERRIDE;
144 virtual bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) SAL_OVERRIDE;
145 virtual bool canAdvance() const SAL_OVERRIDE;
147 void SetRoadmapStateValue( bool _bDoEnable ) { m_abEnableRoadmap = _bDoEnable; }
148 bool GetRoadmapStateValue() const { return m_abEnableRoadmap; }
150 protected:
151 /// default implementation: call FillItemSet, call prepareLeave,
152 virtual sfxpg DeactivatePage(SfxItemSet* pSet) SAL_OVERRIDE;
153 using SfxTabPage::DeactivatePage;
154 /// default implementation: call implInitControls with the given item set and _bSaveValue = sal_False
155 virtual void Reset(const SfxItemSet* _rCoreAttrs) SAL_OVERRIDE;
156 /// default implementation: call implInitControls with the given item set and _bSaveValue = sal_True
157 virtual void ActivatePage(const SfxItemSet& _rSet) SAL_OVERRIDE;
159 // TabPage overridables
160 virtual void ActivatePage() SAL_OVERRIDE;
162 protected:
163 void callModifiedHdl() const { if (m_aModifiedHandler.IsSet()) m_aModifiedHandler.Call(this); }
165 /// called from within DeactivatePage. The page is allowed to be deactivated if this method returns sal_True
166 virtual bool prepareLeave() { return true; }
168 /** called from within Reset and ActivatePage, use to initialize the controls with the items from the given set
169 @param _bSaveValue if set to sal_True, the implementation should call SaveValue on all relevant controls
171 virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue);
173 /// analyze the invalid and the readonly flag which may be present in the set
174 static void getFlags(const SfxItemSet& _rSet, bool& _rValid, bool& _rReadonly);
176 /** will be called inside <method>implInitControls</method> to save the value if necessary
177 @param _rControlList
178 The list must be filled with the controls.
179 It is not allowed to clear the list before pusching data into it.
181 virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) = 0;
183 /** will be called inside <method>implInitControls</method> to disable if necessary
184 @param _rControlList
185 The list must be filled with the controls.
186 It is not allowed to clear the list before pusching data into it.
188 virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) = 0;
190 public:
191 /** fills the Boolean value into the item set when the value changed.
192 @param _rSet
193 The item set where to put the new value into.
194 @param _pCheckBox
195 The check box which is checked.
196 @param _nID
197 The id in the itemset to set with the new value.
198 @param _bChangedSomething
199 <TRUE/> if something changed otherwise <FALSE/>
200 @param _bRevertValue
201 set to <TRUE/> if the display value should be reverted before putting it into the set
203 static void fillBool( SfxItemSet& _rSet, CheckBox* _pCheckBox, sal_uInt16 _nID, bool& _bChangedSomething, bool _bRevertValue = false);
205 /** fills the int value into the item set when the value changed.
206 @param _rSet
207 The item set where to put the new value into.
208 @param _pEdit
209 The check box which is checked.
210 @param _nID
211 The id in the itemset to set with the new value.
212 @param _bChangedSomething
213 <TRUE/> if something changed otherwise <FALSE/>
215 static void fillInt32(SfxItemSet& _rSet,NumericField* _pEdit,sal_uInt16 _nID, bool& _bChangedSomething);
217 /** fills the String value into the item set when the value changed.
218 @param _rSet
219 The item set where to put the new value into.
220 @param _pEdit
221 The check box which is checked.
222 @param _nID
223 The id in the itemset to set with the new value.
224 @param _bChangedSomething
225 <TRUE/> if something changed otherwise <FALSE/>
227 static void fillString(SfxItemSet& _rSet,Edit* _pEdit,sal_uInt16 _nID, bool& _bChangedSomething);
229 protected:
230 /** This link be used for controls where the tabpage does not need to take any special action when the control
231 is modified. The implementation just calls callModifiedHdl.
233 DECL_LINK(OnControlModified, void*);
234 DECL_LINK(OnTestConnectionClickHdl, PushButton*);
236 /// may be used in SetXXXHdl calls to controls, is a link to <method>OnControlModified</method>
237 virtual Link<> getControlModifiedLink() { return LINK(this, OGenericAdministrationPage, OnControlModified); }
240 // ControlRelation
241 enum ControlRelation
243 RelatedControls, UnrelatedControls
246 // LayoutHelper
247 class LayoutHelper
249 public:
250 static void positionBelow(
251 const Control& _rReference,
252 Control& _rControl,
253 const ControlRelation _eRelation,
254 const long _nIndentAppFont
256 /** fits the button size to be large enough to contain the buttons text
258 static void fitSizeRightAligned( PushButton& io_button );
259 // why is CalcMinimumSize not a virtual method of vcl::Window?
262 } // namespace dbaui
264 #endif // INCLUDED_DBACCESS_SOURCE_UI_DLG_ADMINPAGES_HXX
266 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */