1*2a97ec55SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2a97ec55SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2a97ec55SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2a97ec55SAndrew Rist * distributed with this work for additional information 6*2a97ec55SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2a97ec55SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2a97ec55SAndrew Rist * "License"); you may not use this file except in compliance 9*2a97ec55SAndrew Rist * with the License. You may obtain a copy of the License at 10*2a97ec55SAndrew Rist * 11*2a97ec55SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2a97ec55SAndrew Rist * 13*2a97ec55SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2a97ec55SAndrew Rist * software distributed under the License is distributed on an 15*2a97ec55SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2a97ec55SAndrew Rist * KIND, either express or implied. See the License for the 17*2a97ec55SAndrew Rist * specific language governing permissions and limitations 18*2a97ec55SAndrew Rist * under the License. 19*2a97ec55SAndrew Rist * 20*2a97ec55SAndrew Rist *************************************************************/ 21*2a97ec55SAndrew Rist 22*2a97ec55SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_extensions.hxx" 26cdf0e10cSrcweir #include "propertyeditor.hxx" 27cdf0e10cSrcweir #include "browserpage.hxx" 28cdf0e10cSrcweir #include "linedescriptor.hxx" 29cdf0e10cSrcweir 30cdf0e10cSrcweir /** === begin UNO includes === **/ 31cdf0e10cSrcweir /** === end UNO includes === **/ 32cdf0e10cSrcweir #include <tools/debug.hxx> 33cdf0e10cSrcweir 34cdf0e10cSrcweir //............................................................................ 35cdf0e10cSrcweir namespace pcr 36cdf0e10cSrcweir { 37cdf0e10cSrcweir //............................................................................ 38cdf0e10cSrcweir 39cdf0e10cSrcweir #define LAYOUT_BORDER_LEFT 3 40cdf0e10cSrcweir #define LAYOUT_BORDER_TOP 3 41cdf0e10cSrcweir #define LAYOUT_BORDER_RIGHT 3 42cdf0e10cSrcweir #define LAYOUT_BORDER_BOTTOM 3 43cdf0e10cSrcweir 44cdf0e10cSrcweir /** === begin UNO using === **/ 45cdf0e10cSrcweir using ::com::sun::star::uno::Any; 46cdf0e10cSrcweir using ::com::sun::star::inspection::XPropertyControl; 47cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 48cdf0e10cSrcweir /** === end UNO using === **/ 49cdf0e10cSrcweir 50cdf0e10cSrcweir //================================================================== 51cdf0e10cSrcweir // class OPropertyEditor 52cdf0e10cSrcweir //================================================================== DBG_NAME(OPropertyEditor)53cdf0e10cSrcweir DBG_NAME(OPropertyEditor) 54cdf0e10cSrcweir //------------------------------------------------------------------ 55cdf0e10cSrcweir OPropertyEditor::OPropertyEditor( Window* pParent, WinBits nWinStyle) 56cdf0e10cSrcweir :Control(pParent, nWinStyle) 57cdf0e10cSrcweir ,m_aTabControl( this ) 58cdf0e10cSrcweir ,m_nNextId(1) 59cdf0e10cSrcweir ,m_bHasHelpSection( false ) 60cdf0e10cSrcweir ,m_nMinHelpLines( 0 ) 61cdf0e10cSrcweir ,m_nMaxHelpLines( 0 ) 62cdf0e10cSrcweir { 63cdf0e10cSrcweir DBG_CTOR(OPropertyEditor,NULL); 64cdf0e10cSrcweir 65cdf0e10cSrcweir m_aTabControl.Show(); 66cdf0e10cSrcweir m_aTabControl.SetDeactivatePageHdl(LINK(this, OPropertyEditor, OnPageDeactivate)); 67cdf0e10cSrcweir m_aTabControl.SetActivatePageHdl(LINK(this, OPropertyEditor, OnPageActivate)); 68cdf0e10cSrcweir m_aTabControl.SetBackground(GetBackground()); 69cdf0e10cSrcweir m_aTabControl.SetPaintTransparent(sal_True); 70cdf0e10cSrcweir } 71cdf0e10cSrcweir 72cdf0e10cSrcweir //------------------------------------------------------------------ ~OPropertyEditor()73cdf0e10cSrcweir OPropertyEditor::~OPropertyEditor() 74cdf0e10cSrcweir { 75cdf0e10cSrcweir Hide(); 76cdf0e10cSrcweir ClearAll(); 77cdf0e10cSrcweir DBG_DTOR(OPropertyEditor,NULL); 78cdf0e10cSrcweir } 79cdf0e10cSrcweir 80cdf0e10cSrcweir //------------------------------------------------------------------ ClearAll()81cdf0e10cSrcweir void OPropertyEditor::ClearAll() 82cdf0e10cSrcweir { 83cdf0e10cSrcweir m_nNextId=1; 84cdf0e10cSrcweir sal_uInt16 nCount = m_aTabControl.GetPageCount(); 85cdf0e10cSrcweir for(long i = nCount-1; i >= 0; --i) 86cdf0e10cSrcweir { 87cdf0e10cSrcweir sal_uInt16 nID = m_aTabControl.GetPageId((sal_uInt16)i); 88cdf0e10cSrcweir OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(nID)); 89cdf0e10cSrcweir if (pPage) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir pPage->EnableInput(sal_False); 92cdf0e10cSrcweir m_aTabControl.RemovePage(nID); 93cdf0e10cSrcweir delete pPage; 94cdf0e10cSrcweir } 95cdf0e10cSrcweir } 96cdf0e10cSrcweir m_aTabControl.Clear(); 97cdf0e10cSrcweir 98cdf0e10cSrcweir { 99cdf0e10cSrcweir MapStringToPageId aEmpty; 100cdf0e10cSrcweir m_aPropertyPageIds.swap( aEmpty ); 101cdf0e10cSrcweir } 102cdf0e10cSrcweir 103cdf0e10cSrcweir while ( !m_aHiddenPages.empty() ) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir delete m_aHiddenPages.begin()->second.pPage; 106cdf0e10cSrcweir m_aHiddenPages.erase( m_aHiddenPages.begin() ); 107cdf0e10cSrcweir } 108cdf0e10cSrcweir } 109cdf0e10cSrcweir 110cdf0e10cSrcweir //------------------------------------------------------------------ getMinimumHeight()111cdf0e10cSrcweir sal_Int32 OPropertyEditor::getMinimumHeight() 112cdf0e10cSrcweir { 113cdf0e10cSrcweir sal_Int32 nMinHeight( LAYOUT_BORDER_TOP + LAYOUT_BORDER_BOTTOM ); 114cdf0e10cSrcweir 115cdf0e10cSrcweir if ( m_aTabControl.GetPageCount() > 0 ) 116cdf0e10cSrcweir { 117cdf0e10cSrcweir sal_uInt16 nFirstID = m_aTabControl.GetPageId( 0 ); 118cdf0e10cSrcweir 119cdf0e10cSrcweir // reserve space for the tabs themself 120cdf0e10cSrcweir Rectangle aTabArea( m_aTabControl.GetTabBounds( nFirstID ) ); 121cdf0e10cSrcweir nMinHeight += aTabArea.GetHeight(); 122cdf0e10cSrcweir 123cdf0e10cSrcweir // ask the page how much it requires 124cdf0e10cSrcweir OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( nFirstID ) ); 125cdf0e10cSrcweir if ( pPage ) 126cdf0e10cSrcweir nMinHeight += pPage->getMinimumHeight(); 127cdf0e10cSrcweir } 128cdf0e10cSrcweir else 129cdf0e10cSrcweir nMinHeight += 250; // arbitrary ... 130cdf0e10cSrcweir 131cdf0e10cSrcweir return nMinHeight; 132cdf0e10cSrcweir } 133cdf0e10cSrcweir 134cdf0e10cSrcweir //------------------------------------------------------------------ getMinimumWidth()135cdf0e10cSrcweir sal_Int32 OPropertyEditor::getMinimumWidth() 136cdf0e10cSrcweir { 137cdf0e10cSrcweir sal_uInt16 nCount = m_aTabControl.GetPageCount(); 138cdf0e10cSrcweir sal_Int32 nPageMinWidth = 0; 139cdf0e10cSrcweir for(long i = nCount-1; i >= 0; --i) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir sal_uInt16 nID = m_aTabControl.GetPageId((sal_uInt16)i); 142cdf0e10cSrcweir OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(nID)); 143cdf0e10cSrcweir if (pPage) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir sal_Int32 nCurPageMinWidth = pPage->getMinimumWidth(); 146cdf0e10cSrcweir if( nCurPageMinWidth > nPageMinWidth ) 147cdf0e10cSrcweir nPageMinWidth = nCurPageMinWidth; 148cdf0e10cSrcweir } 149cdf0e10cSrcweir } 150cdf0e10cSrcweir return nPageMinWidth+6; 151cdf0e10cSrcweir } 152cdf0e10cSrcweir 153cdf0e10cSrcweir //------------------------------------------------------------------ CommitModified()154cdf0e10cSrcweir void OPropertyEditor::CommitModified() 155cdf0e10cSrcweir { 156cdf0e10cSrcweir // commit all of my pages, if necessary 157cdf0e10cSrcweir 158cdf0e10cSrcweir sal_uInt16 nCount = m_aTabControl.GetPageCount(); 159cdf0e10cSrcweir for ( sal_uInt16 i=0; i<nCount; ++i ) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir sal_uInt16 nID = m_aTabControl.GetPageId( i ); 162cdf0e10cSrcweir OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( nID ) ); 163cdf0e10cSrcweir 164cdf0e10cSrcweir if ( pPage && pPage->getListBox().IsModified() ) 165cdf0e10cSrcweir pPage->getListBox().CommitModified(); 166cdf0e10cSrcweir } 167cdf0e10cSrcweir } 168cdf0e10cSrcweir 169cdf0e10cSrcweir //------------------------------------------------------------------ GetFocus()170cdf0e10cSrcweir void OPropertyEditor::GetFocus() 171cdf0e10cSrcweir { 172cdf0e10cSrcweir m_aTabControl.GrabFocus(); 173cdf0e10cSrcweir } 174cdf0e10cSrcweir 175cdf0e10cSrcweir //------------------------------------------------------------------ getPage(const::rtl::OUString & _rPropertyName)176cdf0e10cSrcweir OBrowserPage* OPropertyEditor::getPage( const ::rtl::OUString& _rPropertyName ) 177cdf0e10cSrcweir { 178cdf0e10cSrcweir OBrowserPage* pPage = NULL; 179cdf0e10cSrcweir MapStringToPageId::const_iterator aPropertyPageIdPos = m_aPropertyPageIds.find( _rPropertyName ); 180cdf0e10cSrcweir if ( aPropertyPageIdPos != m_aPropertyPageIds.end() ) 181cdf0e10cSrcweir pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( aPropertyPageIdPos->second ) ); 182cdf0e10cSrcweir return pPage; 183cdf0e10cSrcweir } 184cdf0e10cSrcweir 185cdf0e10cSrcweir //------------------------------------------------------------------ getPage(const::rtl::OUString & _rPropertyName) const186cdf0e10cSrcweir const OBrowserPage* OPropertyEditor::getPage( const ::rtl::OUString& _rPropertyName ) const 187cdf0e10cSrcweir { 188cdf0e10cSrcweir return const_cast< OPropertyEditor* >( this )->getPage( _rPropertyName ); 189cdf0e10cSrcweir } 190cdf0e10cSrcweir 191cdf0e10cSrcweir //------------------------------------------------------------------ getPage(sal_uInt16 & _rPageId)192cdf0e10cSrcweir OBrowserPage* OPropertyEditor::getPage( sal_uInt16& _rPageId ) 193cdf0e10cSrcweir { 194cdf0e10cSrcweir return static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( _rPageId ) ); 195cdf0e10cSrcweir } 196cdf0e10cSrcweir 197cdf0e10cSrcweir //------------------------------------------------------------------ getPage(sal_uInt16 & _rPageId) const198cdf0e10cSrcweir const OBrowserPage* OPropertyEditor::getPage( sal_uInt16& _rPageId ) const 199cdf0e10cSrcweir { 200cdf0e10cSrcweir return const_cast< OPropertyEditor* >( this )->getPage( _rPageId ); 201cdf0e10cSrcweir } 202cdf0e10cSrcweir 203cdf0e10cSrcweir //------------------------------------------------------------------ Resize()204cdf0e10cSrcweir void OPropertyEditor::Resize() 205cdf0e10cSrcweir { 206cdf0e10cSrcweir Rectangle aPlayground( 207cdf0e10cSrcweir Point( LAYOUT_BORDER_LEFT, LAYOUT_BORDER_TOP ), 208cdf0e10cSrcweir Size( 209cdf0e10cSrcweir GetOutputSizePixel().Width() - LAYOUT_BORDER_LEFT - LAYOUT_BORDER_RIGHT, 210cdf0e10cSrcweir GetOutputSizePixel().Height() - LAYOUT_BORDER_TOP - LAYOUT_BORDER_BOTTOM 211cdf0e10cSrcweir ) 212cdf0e10cSrcweir ); 213cdf0e10cSrcweir 214cdf0e10cSrcweir Rectangle aTabArea( aPlayground ); 215cdf0e10cSrcweir m_aTabControl.SetPosSizePixel( aTabArea.TopLeft(), aTabArea.GetSize() ); 216cdf0e10cSrcweir } 217cdf0e10cSrcweir 218cdf0e10cSrcweir //------------------------------------------------------------------ AppendPage(const String & _rText,const rtl::OString & _rHelpId)219cdf0e10cSrcweir sal_uInt16 OPropertyEditor::AppendPage( const String & _rText, const rtl::OString& _rHelpId ) 220cdf0e10cSrcweir { 221cdf0e10cSrcweir // obtain a new id 222cdf0e10cSrcweir sal_uInt16 nId = m_nNextId++; 223cdf0e10cSrcweir // insert the id 224cdf0e10cSrcweir m_aTabControl.InsertPage(nId, _rText); 225cdf0e10cSrcweir 226cdf0e10cSrcweir // create a new page 227cdf0e10cSrcweir OBrowserPage* pPage = new OBrowserPage(&m_aTabControl); 228cdf0e10cSrcweir pPage->SetText( _rText ); 229cdf0e10cSrcweir // some knittings 230cdf0e10cSrcweir pPage->SetSizePixel(m_aTabControl.GetTabPageSizePixel()); 231cdf0e10cSrcweir pPage->getListBox().SetListener(m_pListener); 232cdf0e10cSrcweir pPage->getListBox().SetObserver(m_pObserver); 233cdf0e10cSrcweir pPage->getListBox().EnableHelpSection( m_bHasHelpSection ); 234cdf0e10cSrcweir pPage->getListBox().SetHelpLineLimites( m_nMinHelpLines, m_nMaxHelpLines ); 235cdf0e10cSrcweir pPage->SetHelpId( _rHelpId ); 236cdf0e10cSrcweir 237cdf0e10cSrcweir // immediately activate the page 238cdf0e10cSrcweir m_aTabControl.SetTabPage(nId, pPage); 239cdf0e10cSrcweir m_aTabControl.SetCurPageId(nId); 240cdf0e10cSrcweir 241cdf0e10cSrcweir return nId; 242cdf0e10cSrcweir } 243cdf0e10cSrcweir 244cdf0e10cSrcweir //------------------------------------------------------------------ SetHelpId(const rtl::OString & rHelpId)245cdf0e10cSrcweir void OPropertyEditor::SetHelpId( const rtl::OString& rHelpId ) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir Control::SetHelpId(""); 248cdf0e10cSrcweir m_aTabControl.SetHelpId(rHelpId); 249cdf0e10cSrcweir } 250cdf0e10cSrcweir 251cdf0e10cSrcweir //------------------------------------------------------------------ RemovePage(sal_uInt16 nID)252cdf0e10cSrcweir void OPropertyEditor::RemovePage(sal_uInt16 nID) 253cdf0e10cSrcweir { 254cdf0e10cSrcweir OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(nID)); 255cdf0e10cSrcweir 256cdf0e10cSrcweir if (pPage) 257cdf0e10cSrcweir pPage->EnableInput(sal_False); 258cdf0e10cSrcweir m_aTabControl.RemovePage(nID); 259cdf0e10cSrcweir if (pPage) 260cdf0e10cSrcweir delete pPage; 261cdf0e10cSrcweir } 262cdf0e10cSrcweir 263cdf0e10cSrcweir //------------------------------------------------------------------ SetPage(sal_uInt16 nId)264cdf0e10cSrcweir void OPropertyEditor::SetPage(sal_uInt16 nId) 265cdf0e10cSrcweir { 266cdf0e10cSrcweir m_aTabControl.SetCurPageId(nId); 267cdf0e10cSrcweir } 268cdf0e10cSrcweir 269cdf0e10cSrcweir //------------------------------------------------------------------ GetCurPage()270cdf0e10cSrcweir sal_uInt16 OPropertyEditor::GetCurPage() 271cdf0e10cSrcweir { 272cdf0e10cSrcweir if(m_aTabControl.GetPageCount()>0) 273cdf0e10cSrcweir return m_aTabControl.GetCurPageId(); 274cdf0e10cSrcweir else 275cdf0e10cSrcweir return 0; 276cdf0e10cSrcweir } 277cdf0e10cSrcweir 278cdf0e10cSrcweir //------------------------------------------------------------------ Update(const::std::mem_fun_t<void,OBrowserListBox> & _aUpdateFunction)279cdf0e10cSrcweir void OPropertyEditor::Update(const ::std::mem_fun_t<void,OBrowserListBox>& _aUpdateFunction) 280cdf0e10cSrcweir { 281cdf0e10cSrcweir // forward this to all our pages 282cdf0e10cSrcweir sal_uInt16 nCount = m_aTabControl.GetPageCount(); 283cdf0e10cSrcweir for (sal_uInt16 i=0;i<nCount;++i) 284cdf0e10cSrcweir { 285cdf0e10cSrcweir sal_uInt16 nID = m_aTabControl.GetPageId(i); 286cdf0e10cSrcweir OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(nID)); 287cdf0e10cSrcweir if (pPage) 288cdf0e10cSrcweir _aUpdateFunction(&pPage->getListBox()); 289cdf0e10cSrcweir } 290cdf0e10cSrcweir } 291cdf0e10cSrcweir //------------------------------------------------------------------ EnableUpdate()292cdf0e10cSrcweir void OPropertyEditor::EnableUpdate() 293cdf0e10cSrcweir { 294cdf0e10cSrcweir Update(::std::mem_fun(&OBrowserListBox::EnableUpdate)); 295cdf0e10cSrcweir } 296cdf0e10cSrcweir //------------------------------------------------------------------ DisableUpdate()297cdf0e10cSrcweir void OPropertyEditor::DisableUpdate() 298cdf0e10cSrcweir { 299cdf0e10cSrcweir Update(::std::mem_fun(&OBrowserListBox::DisableUpdate)); 300cdf0e10cSrcweir } 301cdf0e10cSrcweir 302cdf0e10cSrcweir //------------------------------------------------------------------ forEachPage(PageOperation _pOperation,const void * _pArgument)303cdf0e10cSrcweir void OPropertyEditor::forEachPage( PageOperation _pOperation, const void* _pArgument ) 304cdf0e10cSrcweir { 305cdf0e10cSrcweir sal_uInt16 nCount = m_aTabControl.GetPageCount(); 306cdf0e10cSrcweir for ( sal_uInt16 i=0; i<nCount; ++i ) 307cdf0e10cSrcweir { 308cdf0e10cSrcweir sal_uInt16 nID = m_aTabControl.GetPageId(i); 309cdf0e10cSrcweir OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( nID ) ); 310cdf0e10cSrcweir if ( !pPage ) 311cdf0e10cSrcweir continue; 312cdf0e10cSrcweir (this->*_pOperation)( *pPage, _pArgument ); 313cdf0e10cSrcweir } 314cdf0e10cSrcweir } 315cdf0e10cSrcweir 316cdf0e10cSrcweir //------------------------------------------------------------------ setPageLineListener(OBrowserPage & _rPage,const void *)317cdf0e10cSrcweir void OPropertyEditor::setPageLineListener( OBrowserPage& _rPage, const void* ) 318cdf0e10cSrcweir { 319cdf0e10cSrcweir _rPage.getListBox().SetListener( m_pListener ); 320cdf0e10cSrcweir } 321cdf0e10cSrcweir 322cdf0e10cSrcweir //------------------------------------------------------------------ SetLineListener(IPropertyLineListener * _pListener)323cdf0e10cSrcweir void OPropertyEditor::SetLineListener(IPropertyLineListener* _pListener) 324cdf0e10cSrcweir { 325cdf0e10cSrcweir m_pListener = _pListener; 326cdf0e10cSrcweir forEachPage( &OPropertyEditor::setPageLineListener ); 327cdf0e10cSrcweir } 328cdf0e10cSrcweir 329cdf0e10cSrcweir //------------------------------------------------------------------ setPageControlObserver(OBrowserPage & _rPage,const void *)330cdf0e10cSrcweir void OPropertyEditor::setPageControlObserver( OBrowserPage& _rPage, const void* ) 331cdf0e10cSrcweir { 332cdf0e10cSrcweir _rPage.getListBox().SetObserver( m_pObserver ); 333cdf0e10cSrcweir } 334cdf0e10cSrcweir 335cdf0e10cSrcweir //------------------------------------------------------------------ SetControlObserver(IPropertyControlObserver * _pObserver)336cdf0e10cSrcweir void OPropertyEditor::SetControlObserver( IPropertyControlObserver* _pObserver ) 337cdf0e10cSrcweir { 338cdf0e10cSrcweir m_pObserver = _pObserver; 339cdf0e10cSrcweir forEachPage( &OPropertyEditor::setPageControlObserver ); 340cdf0e10cSrcweir } 341cdf0e10cSrcweir 342cdf0e10cSrcweir //------------------------------------------------------------------ EnableHelpSection(bool _bEnable)343cdf0e10cSrcweir void OPropertyEditor::EnableHelpSection( bool _bEnable ) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir m_bHasHelpSection = _bEnable; 346cdf0e10cSrcweir forEachPage( &OPropertyEditor::enableHelpSection ); 347cdf0e10cSrcweir } 348cdf0e10cSrcweir 349cdf0e10cSrcweir //------------------------------------------------------------------ HasHelpSection() const350cdf0e10cSrcweir bool OPropertyEditor::HasHelpSection() const 351cdf0e10cSrcweir { 352cdf0e10cSrcweir return m_bHasHelpSection; 353cdf0e10cSrcweir } 354cdf0e10cSrcweir 355cdf0e10cSrcweir //------------------------------------------------------------------ SetHelpText(const::rtl::OUString & _rHelpText)356cdf0e10cSrcweir void OPropertyEditor::SetHelpText( const ::rtl::OUString& _rHelpText ) 357cdf0e10cSrcweir { 358cdf0e10cSrcweir forEachPage( &OPropertyEditor::setHelpSectionText, &_rHelpText ); 359cdf0e10cSrcweir } 360cdf0e10cSrcweir 361cdf0e10cSrcweir //------------------------------------------------------------------ SetHelpLineLimites(sal_Int32 _nMinLines,sal_Int32 _nMaxLines)362cdf0e10cSrcweir void OPropertyEditor::SetHelpLineLimites( sal_Int32 _nMinLines, sal_Int32 _nMaxLines ) 363cdf0e10cSrcweir { 364cdf0e10cSrcweir m_nMinHelpLines = _nMinLines; 365cdf0e10cSrcweir m_nMaxHelpLines = _nMaxLines; 366cdf0e10cSrcweir forEachPage( &OPropertyEditor::setHelpLineLimits ); 367cdf0e10cSrcweir } 368cdf0e10cSrcweir 369cdf0e10cSrcweir //------------------------------------------------------------------ enableHelpSection(OBrowserPage & _rPage,const void *)370cdf0e10cSrcweir void OPropertyEditor::enableHelpSection( OBrowserPage& _rPage, const void* ) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir _rPage.getListBox().EnableHelpSection( m_bHasHelpSection ); 373cdf0e10cSrcweir } 374cdf0e10cSrcweir 375cdf0e10cSrcweir //------------------------------------------------------------------ setHelpSectionText(OBrowserPage & _rPage,const void * _pPointerToOUString)376cdf0e10cSrcweir void OPropertyEditor::setHelpSectionText( OBrowserPage& _rPage, const void* _pPointerToOUString ) 377cdf0e10cSrcweir { 378cdf0e10cSrcweir OSL_ENSURE( _pPointerToOUString, "OPropertyEditor::setHelpSectionText: invalid argument!" ); 379cdf0e10cSrcweir if ( !_pPointerToOUString ) 380cdf0e10cSrcweir return; 381cdf0e10cSrcweir 382cdf0e10cSrcweir const ::rtl::OUString& rText( *(const ::rtl::OUString*)_pPointerToOUString ); 383cdf0e10cSrcweir _rPage.getListBox().SetHelpText( rText ); 384cdf0e10cSrcweir } 385cdf0e10cSrcweir 386cdf0e10cSrcweir //------------------------------------------------------------------ setHelpLineLimits(OBrowserPage & _rPage,const void *)387cdf0e10cSrcweir void OPropertyEditor::setHelpLineLimits( OBrowserPage& _rPage, const void* ) 388cdf0e10cSrcweir { 389cdf0e10cSrcweir _rPage.getListBox().SetHelpLineLimites( m_nMinHelpLines, m_nMaxHelpLines ); 390cdf0e10cSrcweir } 391cdf0e10cSrcweir 392cdf0e10cSrcweir //------------------------------------------------------------------ InsertEntry(const OLineDescriptor & rData,sal_uInt16 _nPageId,sal_uInt16 nPos)393cdf0e10cSrcweir sal_uInt16 OPropertyEditor::InsertEntry( const OLineDescriptor& rData, sal_uInt16 _nPageId, sal_uInt16 nPos ) 394cdf0e10cSrcweir { 395cdf0e10cSrcweir // let the current page handle this 396cdf0e10cSrcweir OBrowserPage* pPage = getPage( _nPageId ); 397cdf0e10cSrcweir DBG_ASSERT( pPage, "OPropertyEditor::InsertEntry: don't have such a page!" ); 398cdf0e10cSrcweir if ( !pPage ) 399cdf0e10cSrcweir return LISTBOX_ENTRY_NOTFOUND; 400cdf0e10cSrcweir 401cdf0e10cSrcweir sal_uInt16 nEntry = pPage->getListBox().InsertEntry( rData, nPos ); 402cdf0e10cSrcweir 403cdf0e10cSrcweir OSL_ENSURE( m_aPropertyPageIds.find( rData.sName ) == m_aPropertyPageIds.end(), 404cdf0e10cSrcweir "OPropertyEditor::InsertEntry: property already present in the map!" ); 405cdf0e10cSrcweir m_aPropertyPageIds.insert( MapStringToPageId::value_type( rData.sName, _nPageId ) ); 406cdf0e10cSrcweir 407cdf0e10cSrcweir return nEntry; 408cdf0e10cSrcweir } 409cdf0e10cSrcweir 410cdf0e10cSrcweir //------------------------------------------------------------------ RemoveEntry(const::rtl::OUString & _rName)411cdf0e10cSrcweir void OPropertyEditor::RemoveEntry( const ::rtl::OUString& _rName ) 412cdf0e10cSrcweir { 413cdf0e10cSrcweir OBrowserPage* pPage = getPage( _rName ); 414cdf0e10cSrcweir if ( pPage ) 415cdf0e10cSrcweir { 416cdf0e10cSrcweir OSL_VERIFY( pPage->getListBox().RemoveEntry( _rName ) ); 417cdf0e10cSrcweir 418cdf0e10cSrcweir OSL_ENSURE( m_aPropertyPageIds.find( _rName ) != m_aPropertyPageIds.end(), 419cdf0e10cSrcweir "OPropertyEditor::RemoveEntry: property not present in the map!" ); 420cdf0e10cSrcweir m_aPropertyPageIds.erase( _rName ); 421cdf0e10cSrcweir } 422cdf0e10cSrcweir } 423cdf0e10cSrcweir 424cdf0e10cSrcweir //------------------------------------------------------------------ ChangeEntry(const OLineDescriptor & rData)425cdf0e10cSrcweir void OPropertyEditor::ChangeEntry( const OLineDescriptor& rData ) 426cdf0e10cSrcweir { 427cdf0e10cSrcweir OBrowserPage* pPage = getPage( rData.sName ); 428cdf0e10cSrcweir if ( pPage ) 429cdf0e10cSrcweir pPage->getListBox().ChangeEntry( rData, EDITOR_LIST_REPLACE_EXISTING ); 430cdf0e10cSrcweir } 431cdf0e10cSrcweir 432cdf0e10cSrcweir //------------------------------------------------------------------ SetPropertyValue(const::rtl::OUString & rEntryName,const Any & _rValue,bool _bUnknownValue)433cdf0e10cSrcweir void OPropertyEditor::SetPropertyValue( const ::rtl::OUString& rEntryName, const Any& _rValue, bool _bUnknownValue ) 434cdf0e10cSrcweir { 435cdf0e10cSrcweir OBrowserPage* pPage = getPage( rEntryName ); 436cdf0e10cSrcweir if ( pPage ) 437cdf0e10cSrcweir pPage->getListBox().SetPropertyValue( rEntryName, _rValue, _bUnknownValue ); 438cdf0e10cSrcweir } 439cdf0e10cSrcweir 440cdf0e10cSrcweir //------------------------------------------------------------------ GetPropertyPos(const::rtl::OUString & rEntryName) const441cdf0e10cSrcweir sal_uInt16 OPropertyEditor::GetPropertyPos( const ::rtl::OUString& rEntryName ) const 442cdf0e10cSrcweir { 443cdf0e10cSrcweir sal_uInt16 nVal=LISTBOX_ENTRY_NOTFOUND; 444cdf0e10cSrcweir const OBrowserPage* pPage = getPage( rEntryName ); 445cdf0e10cSrcweir if ( pPage ) 446cdf0e10cSrcweir nVal = pPage->getListBox().GetPropertyPos( rEntryName ); 447cdf0e10cSrcweir return nVal; 448cdf0e10cSrcweir } 449cdf0e10cSrcweir 450cdf0e10cSrcweir //------------------------------------------------------------------ ShowPropertyPage(sal_uInt16 _nPageId,bool _bShow)451cdf0e10cSrcweir void OPropertyEditor::ShowPropertyPage( sal_uInt16 _nPageId, bool _bShow ) 452cdf0e10cSrcweir { 453cdf0e10cSrcweir if ( !_bShow ) 454cdf0e10cSrcweir { 455cdf0e10cSrcweir sal_uInt16 nPagePos = m_aTabControl.GetPagePos( _nPageId ); 456cdf0e10cSrcweir if ( TAB_PAGE_NOTFOUND == nPagePos ) 457cdf0e10cSrcweir return; 458cdf0e10cSrcweir DBG_ASSERT( m_aHiddenPages.find( _nPageId ) == m_aHiddenPages.end(), "OPropertyEditor::ShowPropertyPage: page already hidden!" ); 459cdf0e10cSrcweir 460cdf0e10cSrcweir m_aHiddenPages[ _nPageId ] = HiddenPage( nPagePos, m_aTabControl.GetTabPage( _nPageId ) ); 461cdf0e10cSrcweir m_aTabControl.RemovePage( _nPageId ); 462cdf0e10cSrcweir } 463cdf0e10cSrcweir else 464cdf0e10cSrcweir { 465cdf0e10cSrcweir ::std::map< sal_uInt16, HiddenPage >::iterator aPagePos = m_aHiddenPages.find( _nPageId ); 466cdf0e10cSrcweir if ( aPagePos == m_aHiddenPages.end() ) 467cdf0e10cSrcweir return; 468cdf0e10cSrcweir 469cdf0e10cSrcweir aPagePos->second.pPage->SetSizePixel( m_aTabControl.GetTabPageSizePixel() ); 470cdf0e10cSrcweir m_aTabControl.InsertPage( aPagePos->first, aPagePos->second.pPage->GetText(), aPagePos->second.nPos ); 471cdf0e10cSrcweir m_aTabControl.SetTabPage( aPagePos->first, aPagePos->second.pPage ); 472cdf0e10cSrcweir 473cdf0e10cSrcweir m_aHiddenPages.erase( aPagePos ); 474cdf0e10cSrcweir } 475cdf0e10cSrcweir } 476cdf0e10cSrcweir 477cdf0e10cSrcweir //------------------------------------------------------------------ EnablePropertyControls(const::rtl::OUString & _rEntryName,sal_Int16 _nControls,bool _bEnable)478cdf0e10cSrcweir void OPropertyEditor::EnablePropertyControls( const ::rtl::OUString& _rEntryName, sal_Int16 _nControls, bool _bEnable ) 479cdf0e10cSrcweir { 480cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < m_aTabControl.GetPageCount(); ++i ) 481cdf0e10cSrcweir { 482cdf0e10cSrcweir OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( m_aTabControl.GetPageId( i ) ) ); 483cdf0e10cSrcweir if ( pPage ) 484cdf0e10cSrcweir pPage->getListBox().EnablePropertyControls( _rEntryName, _nControls, _bEnable ); 485cdf0e10cSrcweir } 486cdf0e10cSrcweir } 487cdf0e10cSrcweir 488cdf0e10cSrcweir //------------------------------------------------------------------ EnablePropertyLine(const::rtl::OUString & _rEntryName,bool _bEnable)489cdf0e10cSrcweir void OPropertyEditor::EnablePropertyLine( const ::rtl::OUString& _rEntryName, bool _bEnable ) 490cdf0e10cSrcweir { 491cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < m_aTabControl.GetPageCount(); ++i ) 492cdf0e10cSrcweir { 493cdf0e10cSrcweir OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( m_aTabControl.GetPageId( i ) ) ); 494cdf0e10cSrcweir if ( pPage ) 495cdf0e10cSrcweir pPage->getListBox().EnablePropertyLine( _rEntryName, _bEnable ); 496cdf0e10cSrcweir } 497cdf0e10cSrcweir } 498cdf0e10cSrcweir 499cdf0e10cSrcweir //------------------------------------------------------------------ GetPropertyControl(const::rtl::OUString & rEntryName)500cdf0e10cSrcweir Reference< XPropertyControl > OPropertyEditor::GetPropertyControl(const ::rtl::OUString& rEntryName) 501cdf0e10cSrcweir { 502cdf0e10cSrcweir Reference< XPropertyControl > xControl; 503cdf0e10cSrcweir // let the current page handle this 504cdf0e10cSrcweir OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(m_aTabControl.GetCurPageId())); 505cdf0e10cSrcweir if (pPage) 506cdf0e10cSrcweir xControl = pPage->getListBox().GetPropertyControl(rEntryName); 507cdf0e10cSrcweir return xControl; 508cdf0e10cSrcweir } 509cdf0e10cSrcweir 510cdf0e10cSrcweir //------------------------------------------------------------------ IMPL_LINK(OPropertyEditor,OnPageActivate,TabControl *,EMPTYARG)511cdf0e10cSrcweir IMPL_LINK(OPropertyEditor, OnPageActivate, TabControl*, EMPTYARG) 512cdf0e10cSrcweir { 513cdf0e10cSrcweir if (m_aPageActivationHandler.IsSet()) 514cdf0e10cSrcweir m_aPageActivationHandler.Call(NULL); 515cdf0e10cSrcweir return 0L; 516cdf0e10cSrcweir } 517cdf0e10cSrcweir 518cdf0e10cSrcweir //------------------------------------------------------------------ IMPL_LINK(OPropertyEditor,OnPageDeactivate,TabControl *,EMPTYARG)519cdf0e10cSrcweir IMPL_LINK(OPropertyEditor, OnPageDeactivate, TabControl*, EMPTYARG) 520cdf0e10cSrcweir { 521cdf0e10cSrcweir // commit the data on the current (to-be-decativated) tab page 522cdf0e10cSrcweir // (79404) 523cdf0e10cSrcweir sal_Int32 nCurrentId = m_aTabControl.GetCurPageId(); 524cdf0e10cSrcweir OBrowserPage* pCurrentPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage((sal_uInt16)nCurrentId)); 525cdf0e10cSrcweir if ( !pCurrentPage ) 526cdf0e10cSrcweir return 1L; 527cdf0e10cSrcweir 528cdf0e10cSrcweir if ( pCurrentPage->getListBox().IsModified() ) 529cdf0e10cSrcweir pCurrentPage->getListBox().CommitModified(); 530cdf0e10cSrcweir 531cdf0e10cSrcweir return 1L; 532cdf0e10cSrcweir } 533cdf0e10cSrcweir 534cdf0e10cSrcweir //............................................................................ 535cdf0e10cSrcweir } // namespace pcr 536cdf0e10cSrcweir //............................................................................ 537cdf0e10cSrcweir 538cdf0e10cSrcweir 539