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