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