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 // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_cui.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "connpooloptions.hxx" 32*cdf0e10cSrcweir #include "connpooloptions.hrc" 33*cdf0e10cSrcweir #include <svtools/editbrowsebox.hxx> 34*cdf0e10cSrcweir #include <vcl/field.hxx> 35*cdf0e10cSrcweir #include "connpoolsettings.hxx" 36*cdf0e10cSrcweir #include <svl/eitem.hxx> 37*cdf0e10cSrcweir #include <cuires.hrc> 38*cdf0e10cSrcweir #include "helpid.hrc" 39*cdf0e10cSrcweir #include <dialmgr.hxx> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir //........................................................................ 42*cdf0e10cSrcweir namespace offapp 43*cdf0e10cSrcweir { 44*cdf0e10cSrcweir //........................................................................ 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir //==================================================================== 47*cdf0e10cSrcweir //= DriverListControl 48*cdf0e10cSrcweir //==================================================================== 49*cdf0e10cSrcweir typedef ::svt::EditBrowseBox DriverListControl_Base; 50*cdf0e10cSrcweir class DriverListControl : public DriverListControl_Base 51*cdf0e10cSrcweir { 52*cdf0e10cSrcweir using Window::Update; 53*cdf0e10cSrcweir protected: 54*cdf0e10cSrcweir DriverPoolingSettings m_aSavedSettings; 55*cdf0e10cSrcweir DriverPoolingSettings m_aSettings; 56*cdf0e10cSrcweir DriverPoolingSettings::const_iterator m_aSeekRow; 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir String m_sYes; 59*cdf0e10cSrcweir String m_sNo; 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir Link m_aRowChangeHandler; 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir public: 64*cdf0e10cSrcweir DriverListControl( Window* _pParent, const ResId& _rId); 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir virtual void Init(); 67*cdf0e10cSrcweir void Update(const DriverPoolingSettings& _rSettings); 68*cdf0e10cSrcweir virtual String GetCellText( long nRow, sal_uInt16 nColId ) const; 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir // the handler will be called with a DriverPoolingSettings::const_iterator as parameter, 71*cdf0e10cSrcweir // or NULL if no valid current row exists 72*cdf0e10cSrcweir void SetRowChangeHandler(const Link& _rHdl) { m_aRowChangeHandler = _rHdl; } 73*cdf0e10cSrcweir Link GetRowChangeHandler() const { return m_aRowChangeHandler; } 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir const DriverPooling* getCurrentRow() const; 76*cdf0e10cSrcweir DriverPooling* getCurrentRow(); 77*cdf0e10cSrcweir void updateCurrentRow(); 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir const DriverPoolingSettings& getSettings() const { return m_aSettings; } 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir void saveValue() { m_aSavedSettings = m_aSettings; } 82*cdf0e10cSrcweir sal_Bool isModified() const; 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir protected: 85*cdf0e10cSrcweir virtual void InitController( ::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol ); 86*cdf0e10cSrcweir virtual ::svt::CellController* GetController( long nRow, sal_uInt16 nCol ); 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir virtual void PaintCell( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColId ) const; 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir virtual sal_Bool SeekRow( long nRow ); 91*cdf0e10cSrcweir virtual sal_Bool SaveModified(); 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir virtual sal_Bool IsTabAllowed(sal_Bool _bForward) const; 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir virtual void StateChanged( StateChangedType nStateChange ); 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir virtual void CursorMoved(); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir protected: 100*cdf0e10cSrcweir virtual sal_uInt32 GetTotalCellWidth(long nRow, sal_uInt16 nColId); 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir private: 104*cdf0e10cSrcweir String implGetCellText(DriverPoolingSettings::const_iterator _rPos, sal_uInt16 _nColId) const; 105*cdf0e10cSrcweir }; 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir //-------------------------------------------------------------------- 108*cdf0e10cSrcweir DriverListControl::DriverListControl( Window* _pParent, const ResId& _rId) 109*cdf0e10cSrcweir // :DriverListControl_Base(_pParent, _rId, DBBF_NOROWPICTURE, BROWSER_AUTO_VSCROLL | BROWSER_AUTO_HSCROLL | BROWSER_COLUMNSELECTION | BROWSER_HLINESFULL | BROWSER_VLINESFULL | BROWSER_HIDESELECT | BROWSER_CURSOR_WO_FOCUS) 110*cdf0e10cSrcweir :DriverListControl_Base(_pParent, _rId, EBBF_NOROWPICTURE, BROWSER_AUTO_VSCROLL | BROWSER_AUTO_HSCROLL | BROWSER_HIDECURSOR | BROWSER_AUTOSIZE_LASTCOL) 111*cdf0e10cSrcweir ,m_aSeekRow(m_aSettings.end()) 112*cdf0e10cSrcweir ,m_sYes(ResId(STR_YES,*_rId.GetResMgr())) 113*cdf0e10cSrcweir ,m_sNo(ResId(STR_NO,*_rId.GetResMgr())) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir SetStyle((GetStyle() & ~WB_HSCROLL) | WB_AUTOHSCROLL); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir SetUniqueId(UID_OFA_CONNPOOL_DRIVERLIST_BACK); 118*cdf0e10cSrcweir GetDataWindow().SetHelpId(HID_OFA_CONNPOOL_DRIVERLIST); 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir //-------------------------------------------------------------------- 122*cdf0e10cSrcweir sal_Bool DriverListControl::IsTabAllowed(sal_Bool /*_bForward*/) const 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir // no travinling within the fields via RETURN and TAB 125*cdf0e10cSrcweir return sal_False; 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir //-------------------------------------------------------------------- 129*cdf0e10cSrcweir sal_Bool DriverListControl::isModified() const 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir if (m_aSettings.size() != m_aSavedSettings.size()) 132*cdf0e10cSrcweir return sal_True; 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir DriverPoolingSettings::const_iterator aCurrent = m_aSettings.begin(); 135*cdf0e10cSrcweir DriverPoolingSettings::const_iterator aCurrentEnd = m_aSettings.end(); 136*cdf0e10cSrcweir DriverPoolingSettings::const_iterator aSaved = m_aSavedSettings.begin(); 137*cdf0e10cSrcweir for (;aCurrent != aCurrentEnd; ++aCurrent, ++aSaved) 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir if (*aCurrent != *aSaved) 140*cdf0e10cSrcweir return sal_True; 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir return sal_False; 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir //-------------------------------------------------------------------- 147*cdf0e10cSrcweir void DriverListControl::Init() 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir DriverListControl_Base::Init(); 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir Size aColWidth = LogicToPixel(Size(160, 0), MAP_APPFONT); 152*cdf0e10cSrcweir InsertDataColumn(1, String(CUI_RES(STR_DRIVER_NAME)), aColWidth.Width()); 153*cdf0e10cSrcweir aColWidth = LogicToPixel(Size(30, 0), MAP_APPFONT); 154*cdf0e10cSrcweir InsertDataColumn(2, String(CUI_RES(STR_POOLED_FLAG)), aColWidth.Width()); 155*cdf0e10cSrcweir aColWidth = LogicToPixel(Size(60, 0), MAP_APPFONT); 156*cdf0e10cSrcweir InsertDataColumn(3, String(CUI_RES(STR_POOL_TIMEOUT)), aColWidth.Width()); 157*cdf0e10cSrcweir // Attention: the resource of the string is local to the resource of the enclosing dialog! 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir //-------------------------------------------------------------------- 161*cdf0e10cSrcweir void DriverListControl::CursorMoved() 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir DriverListControl_Base::CursorMoved(); 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir // call the row change handler 166*cdf0e10cSrcweir if ( m_aRowChangeHandler.IsSet() ) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir if ( GetCurRow() >= 0 ) 169*cdf0e10cSrcweir { // == -1 may happen in case the browse box has just been cleared 170*cdf0e10cSrcweir m_aRowChangeHandler.Call( getCurrentRow() ); 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir //-------------------------------------------------------------------- 176*cdf0e10cSrcweir const DriverPooling* DriverListControl::getCurrentRow() const 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir OSL_ENSURE( ( GetCurRow() < m_aSettings.size() ) && ( GetCurRow() >= 0 ), 179*cdf0e10cSrcweir "DriverListControl::getCurrentRow: invalid current row!"); 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir if ( ( GetCurRow() >= 0 ) && ( GetCurRow() < m_aSettings.size() ) ) 182*cdf0e10cSrcweir return &(*(m_aSettings.begin() + GetCurRow())); 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir return NULL; 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir //-------------------------------------------------------------------- 188*cdf0e10cSrcweir DriverPooling* DriverListControl::getCurrentRow() 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir OSL_ENSURE( ( GetCurRow() < m_aSettings.size() ) && ( GetCurRow() >= 0 ), 191*cdf0e10cSrcweir "DriverListControl::getCurrentRow: invalid current row!"); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir if ( ( GetCurRow() >= 0 ) && ( GetCurRow() < m_aSettings.size() ) ) 194*cdf0e10cSrcweir return &(*(m_aSettings.begin() + GetCurRow())); 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir return NULL; 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir //-------------------------------------------------------------------- 200*cdf0e10cSrcweir void DriverListControl::updateCurrentRow() 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir Window::Invalidate( GetRowRectPixel( GetCurRow() ), INVALIDATE_UPDATE ); 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir //-------------------------------------------------------------------- 206*cdf0e10cSrcweir void DriverListControl::Update(const DriverPoolingSettings& _rSettings) 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir m_aSettings = _rSettings; 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir SetUpdateMode(sal_False); 211*cdf0e10cSrcweir RowRemoved(0, GetRowCount()); 212*cdf0e10cSrcweir RowInserted(0, m_aSettings.size()); 213*cdf0e10cSrcweir SetUpdateMode(sal_True); 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir ActivateCell(1, 0); 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir //-------------------------------------------------------------------- 219*cdf0e10cSrcweir sal_uInt32 DriverListControl::GetTotalCellWidth(long nRow, sal_uInt16 nColId) 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir return GetDataWindow().GetTextWidth(GetCellText(nRow, nColId)); 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir //-------------------------------------------------------------------- 225*cdf0e10cSrcweir String DriverListControl::implGetCellText(DriverPoolingSettings::const_iterator _rPos, sal_uInt16 _nColId) const 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir OSL_ENSURE(_rPos < m_aSettings.end(), "DriverListControl::implGetCellText: invalid position!"); 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir String sReturn; 230*cdf0e10cSrcweir switch (_nColId) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir case 1: 233*cdf0e10cSrcweir sReturn = _rPos->sName; 234*cdf0e10cSrcweir break; 235*cdf0e10cSrcweir case 2: 236*cdf0e10cSrcweir sReturn = _rPos->bEnabled ? m_sYes : m_sNo; 237*cdf0e10cSrcweir break; 238*cdf0e10cSrcweir case 3: 239*cdf0e10cSrcweir if (_rPos->bEnabled) 240*cdf0e10cSrcweir sReturn = String::CreateFromInt32(_rPos->nTimeoutSeconds); 241*cdf0e10cSrcweir break; 242*cdf0e10cSrcweir default: 243*cdf0e10cSrcweir OSL_ENSURE(sal_False, "DriverListControl::implGetCellText: invalid column id!"); 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir return sReturn; 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir //-------------------------------------------------------------------- 249*cdf0e10cSrcweir void DriverListControl::StateChanged( StateChangedType nStateChange ) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir if (STATE_CHANGE_ENABLE == nStateChange) 252*cdf0e10cSrcweir Window::Invalidate(INVALIDATE_UPDATE); 253*cdf0e10cSrcweir DriverListControl_Base::StateChanged( nStateChange ); 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir //-------------------------------------------------------------------- 257*cdf0e10cSrcweir String DriverListControl::GetCellText( long nRow, sal_uInt16 nColId ) const 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir String sReturn; 260*cdf0e10cSrcweir if (nRow > m_aSettings.size()) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir OSL_ENSURE(sal_False, "DriverListControl::GetCellText: don't ask me for such rows!"); 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir else 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir sReturn = implGetCellText(m_aSettings.begin() + nRow, nColId); 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir return sReturn; 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir //-------------------------------------------------------------------- 272*cdf0e10cSrcweir void DriverListControl::InitController( ::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol ) 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir rController->GetWindow().SetText(GetCellText(nRow, nCol)); 275*cdf0e10cSrcweir } 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir //-------------------------------------------------------------------- 278*cdf0e10cSrcweir ::svt::CellController* DriverListControl::GetController( long /*nRow*/, sal_uInt16 /*nCol*/ ) 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir return NULL; 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir //-------------------------------------------------------------------- 284*cdf0e10cSrcweir sal_Bool DriverListControl::SaveModified() 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir return sal_True; 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir //-------------------------------------------------------------------- 290*cdf0e10cSrcweir sal_Bool DriverListControl::SeekRow( long _nRow ) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir DriverListControl_Base::SeekRow(_nRow); 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir if (_nRow < m_aSettings.size()) 295*cdf0e10cSrcweir m_aSeekRow = m_aSettings.begin() + _nRow; 296*cdf0e10cSrcweir else 297*cdf0e10cSrcweir m_aSeekRow = m_aSettings.end(); 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir return m_aSeekRow != m_aSettings.end(); 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir //-------------------------------------------------------------------- 303*cdf0e10cSrcweir void DriverListControl::PaintCell( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColId ) const 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir OSL_ENSURE(m_aSeekRow != m_aSettings.end(), "DriverListControl::PaintCell: invalid row!"); 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir if (m_aSeekRow != m_aSettings.end()) 308*cdf0e10cSrcweir { 309*cdf0e10cSrcweir rDev.SetClipRegion(rRect); 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir sal_uInt16 nStyle = TEXT_DRAW_CLIP; 312*cdf0e10cSrcweir if (!IsEnabled()) 313*cdf0e10cSrcweir nStyle |= TEXT_DRAW_DISABLE; 314*cdf0e10cSrcweir switch (nColId) 315*cdf0e10cSrcweir { 316*cdf0e10cSrcweir case 1: nStyle |= TEXT_DRAW_LEFT; break; 317*cdf0e10cSrcweir case 2: 318*cdf0e10cSrcweir case 3: nStyle |= TEXT_DRAW_CENTER; break; 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir rDev.DrawText(rRect, implGetCellText(m_aSeekRow, nColId), nStyle); 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir rDev.SetClipRegion(); 324*cdf0e10cSrcweir } 325*cdf0e10cSrcweir } 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir //==================================================================== 328*cdf0e10cSrcweir //= ConnectionPoolOptionsPage 329*cdf0e10cSrcweir //==================================================================== 330*cdf0e10cSrcweir //-------------------------------------------------------------------- 331*cdf0e10cSrcweir ConnectionPoolOptionsPage::ConnectionPoolOptionsPage(Window* _pParent, const SfxItemSet& _rAttrSet) 332*cdf0e10cSrcweir :SfxTabPage(_pParent, CUI_RES(RID_OFAPAGE_CONNPOOLOPTIONS ), _rAttrSet) 333*cdf0e10cSrcweir ,m_aFrame (this, CUI_RES(FL_POOLING)) 334*cdf0e10cSrcweir ,m_aEnablePooling (this, CUI_RES(CB_POOL_CONNS)) 335*cdf0e10cSrcweir ,m_aDriversLabel (this, CUI_RES(FT_DRIVERS)) 336*cdf0e10cSrcweir ,m_pDriverList(new DriverListControl(this, CUI_RES(CTRL_DRIVER_LIST))) 337*cdf0e10cSrcweir ,m_aDriverLabel (this, CUI_RES(FT_DRIVERLABEL)) 338*cdf0e10cSrcweir ,m_aDriver (this, CUI_RES(FT_DRIVER)) 339*cdf0e10cSrcweir ,m_aDriverPoolingEnabled(this, CUI_RES(CB_DRIVERPOOLING)) 340*cdf0e10cSrcweir ,m_aTimeoutLabel (this, CUI_RES(FT_TIMEOUT)) 341*cdf0e10cSrcweir ,m_aTimeout (this, CUI_RES(NF_TIMEOUT)) 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir m_pDriverList->Init(); 344*cdf0e10cSrcweir m_pDriverList->Show(); 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir FreeResource(); 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir m_aEnablePooling.SetClickHdl( LINK(this, ConnectionPoolOptionsPage, OnEnabledDisabled) ); 349*cdf0e10cSrcweir m_aDriverPoolingEnabled.SetClickHdl( LINK(this, ConnectionPoolOptionsPage, OnEnabledDisabled) ); 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir m_pDriverList->SetRowChangeHandler( LINK(this, ConnectionPoolOptionsPage, OnDriverRowChanged) ); 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir //-------------------------------------------------------------------- 355*cdf0e10cSrcweir SfxTabPage* ConnectionPoolOptionsPage::Create(Window* _pParent, const SfxItemSet& _rAttrSet) 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir return new ConnectionPoolOptionsPage(_pParent, _rAttrSet); 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir //-------------------------------------------------------------------- 361*cdf0e10cSrcweir ConnectionPoolOptionsPage::~ConnectionPoolOptionsPage() 362*cdf0e10cSrcweir { 363*cdf0e10cSrcweir delete m_pDriverList; 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir //-------------------------------------------------------------------- 367*cdf0e10cSrcweir void ConnectionPoolOptionsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool /*_bFromReset*/) 368*cdf0e10cSrcweir { 369*cdf0e10cSrcweir // the enabled flag 370*cdf0e10cSrcweir SFX_ITEMSET_GET( _rSet, pEnabled, SfxBoolItem, SID_SB_POOLING_ENABLED, sal_True ); 371*cdf0e10cSrcweir OSL_ENSURE(pEnabled, "ConnectionPoolOptionsPage::implInitControls: missing the Enabled item!"); 372*cdf0e10cSrcweir m_aEnablePooling.Check(pEnabled ? pEnabled->GetValue() : sal_True); 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir m_aEnablePooling.SaveValue(); 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir // the settings for the single drivers 377*cdf0e10cSrcweir SFX_ITEMSET_GET( _rSet, pDriverSettings, DriverPoolingSettingsItem, SID_SB_DRIVER_TIMEOUTS, sal_True ); 378*cdf0e10cSrcweir if (pDriverSettings) 379*cdf0e10cSrcweir m_pDriverList->Update(pDriverSettings->getSettings()); 380*cdf0e10cSrcweir else 381*cdf0e10cSrcweir { 382*cdf0e10cSrcweir OSL_ENSURE(sal_False, "ConnectionPoolOptionsPage::implInitControls: missing the DriverTimeouts item!"); 383*cdf0e10cSrcweir m_pDriverList->Update(DriverPoolingSettings()); 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir m_pDriverList->saveValue(); 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir // reflect the new settings 388*cdf0e10cSrcweir OnEnabledDisabled(&m_aEnablePooling); 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir //-------------------------------------------------------------------- 392*cdf0e10cSrcweir long ConnectionPoolOptionsPage::Notify( NotifyEvent& _rNEvt ) 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir if (EVENT_LOSEFOCUS == _rNEvt.GetType()) 395*cdf0e10cSrcweir if (m_aTimeout.IsWindowOrChild(_rNEvt.GetWindow())) 396*cdf0e10cSrcweir commitTimeoutField(); 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir return SfxTabPage::Notify(_rNEvt); 399*cdf0e10cSrcweir } 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir //-------------------------------------------------------------------- 402*cdf0e10cSrcweir sal_Bool ConnectionPoolOptionsPage::FillItemSet(SfxItemSet& _rSet) 403*cdf0e10cSrcweir { 404*cdf0e10cSrcweir commitTimeoutField(); 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir sal_Bool bModified = sal_False; 407*cdf0e10cSrcweir // the enabled flag 408*cdf0e10cSrcweir if (m_aEnablePooling.GetSavedValue() != m_aEnablePooling.IsChecked()) 409*cdf0e10cSrcweir { 410*cdf0e10cSrcweir _rSet.Put(SfxBoolItem(SID_SB_POOLING_ENABLED, m_aEnablePooling.IsChecked()), SID_SB_POOLING_ENABLED); 411*cdf0e10cSrcweir bModified = sal_True; 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir // the settings for the single drivers 415*cdf0e10cSrcweir if (m_pDriverList->isModified()) 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir _rSet.Put(DriverPoolingSettingsItem(SID_SB_DRIVER_TIMEOUTS, m_pDriverList->getSettings()), SID_SB_DRIVER_TIMEOUTS); 418*cdf0e10cSrcweir bModified = sal_True; 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir return bModified; 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir //-------------------------------------------------------------------- 425*cdf0e10cSrcweir void ConnectionPoolOptionsPage::ActivatePage( const SfxItemSet& _rSet) 426*cdf0e10cSrcweir { 427*cdf0e10cSrcweir SfxTabPage::ActivatePage(_rSet); 428*cdf0e10cSrcweir implInitControls(_rSet, sal_False); 429*cdf0e10cSrcweir } 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir //-------------------------------------------------------------------- 432*cdf0e10cSrcweir void ConnectionPoolOptionsPage::Reset(const SfxItemSet& _rSet) 433*cdf0e10cSrcweir { 434*cdf0e10cSrcweir implInitControls(_rSet, sal_True); 435*cdf0e10cSrcweir } 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir //-------------------------------------------------------------------- 438*cdf0e10cSrcweir IMPL_LINK( ConnectionPoolOptionsPage, OnDriverRowChanged, const void*, _pRowIterator ) 439*cdf0e10cSrcweir { 440*cdf0e10cSrcweir sal_Bool bValidRow = (NULL != _pRowIterator); 441*cdf0e10cSrcweir m_aDriverPoolingEnabled.Enable(bValidRow && m_aEnablePooling.IsChecked()); 442*cdf0e10cSrcweir m_aTimeoutLabel.Enable(bValidRow); 443*cdf0e10cSrcweir m_aTimeout.Enable(bValidRow); 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir if (!bValidRow) 446*cdf0e10cSrcweir { // positioned on an invalid row 447*cdf0e10cSrcweir m_aDriver.SetText(String()); 448*cdf0e10cSrcweir } 449*cdf0e10cSrcweir else 450*cdf0e10cSrcweir { 451*cdf0e10cSrcweir const DriverPooling *pDriverPos = static_cast<const DriverPooling*>(_pRowIterator); 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir m_aDriver.SetText(pDriverPos->sName); 454*cdf0e10cSrcweir m_aDriverPoolingEnabled.Check(pDriverPos->bEnabled); 455*cdf0e10cSrcweir m_aTimeout.SetText(String::CreateFromInt32(pDriverPos->nTimeoutSeconds)); 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir OnEnabledDisabled(&m_aDriverPoolingEnabled); 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir return 0L; 461*cdf0e10cSrcweir } 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir //-------------------------------------------------------------------- 464*cdf0e10cSrcweir void ConnectionPoolOptionsPage::commitTimeoutField() 465*cdf0e10cSrcweir { 466*cdf0e10cSrcweir if (DriverPooling* pCurrentDriver = m_pDriverList->getCurrentRow()) 467*cdf0e10cSrcweir { 468*cdf0e10cSrcweir pCurrentDriver->nTimeoutSeconds = static_cast<long>(m_aTimeout.GetValue()); 469*cdf0e10cSrcweir m_pDriverList->updateCurrentRow(); 470*cdf0e10cSrcweir } 471*cdf0e10cSrcweir } 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir //-------------------------------------------------------------------- 474*cdf0e10cSrcweir IMPL_LINK( ConnectionPoolOptionsPage, OnEnabledDisabled, const CheckBox*, _pCheckBox ) 475*cdf0e10cSrcweir { 476*cdf0e10cSrcweir sal_Bool bGloballyEnabled = m_aEnablePooling.IsChecked(); 477*cdf0e10cSrcweir sal_Bool bLocalDriverChanged = &m_aDriverPoolingEnabled == _pCheckBox; 478*cdf0e10cSrcweir 479*cdf0e10cSrcweir if (&m_aEnablePooling == _pCheckBox) 480*cdf0e10cSrcweir { 481*cdf0e10cSrcweir m_aDriversLabel.Enable(bGloballyEnabled); 482*cdf0e10cSrcweir m_pDriverList->Enable(bGloballyEnabled); 483*cdf0e10cSrcweir m_aDriverLabel.Enable(bGloballyEnabled); 484*cdf0e10cSrcweir m_aDriver.Enable(bGloballyEnabled); 485*cdf0e10cSrcweir m_aDriverPoolingEnabled.Enable(bGloballyEnabled); 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir else 488*cdf0e10cSrcweir OSL_ENSURE(bLocalDriverChanged, "ConnectionPoolOptionsPage::OnEnabledDisabled: where did this come from?"); 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir m_aTimeoutLabel.Enable(bGloballyEnabled && m_aDriverPoolingEnabled.IsChecked()); 491*cdf0e10cSrcweir m_aTimeout.Enable(bGloballyEnabled && m_aDriverPoolingEnabled.IsChecked()); 492*cdf0e10cSrcweir 493*cdf0e10cSrcweir if (bLocalDriverChanged) 494*cdf0e10cSrcweir { 495*cdf0e10cSrcweir // update the list 496*cdf0e10cSrcweir m_pDriverList->getCurrentRow()->bEnabled = m_aDriverPoolingEnabled.IsChecked(); 497*cdf0e10cSrcweir m_pDriverList->updateCurrentRow(); 498*cdf0e10cSrcweir } 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir return 0L; 501*cdf0e10cSrcweir } 502*cdf0e10cSrcweir 503*cdf0e10cSrcweir //........................................................................ 504*cdf0e10cSrcweir } // namespace offapp 505*cdf0e10cSrcweir //........................................................................ 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir 508