1*46dbaceeSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*46dbaceeSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*46dbaceeSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*46dbaceeSAndrew Rist * distributed with this work for additional information 6*46dbaceeSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*46dbaceeSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*46dbaceeSAndrew Rist * "License"); you may not use this file except in compliance 9*46dbaceeSAndrew Rist * with the License. You may obtain a copy of the License at 10*46dbaceeSAndrew Rist * 11*46dbaceeSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*46dbaceeSAndrew Rist * 13*46dbaceeSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*46dbaceeSAndrew Rist * software distributed under the License is distributed on an 15*46dbaceeSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*46dbaceeSAndrew Rist * KIND, either express or implied. See the License for the 17*46dbaceeSAndrew Rist * specific language governing permissions and limitations 18*46dbaceeSAndrew Rist * under the License. 19*46dbaceeSAndrew Rist * 20*46dbaceeSAndrew Rist *************************************************************/ 21*46dbaceeSAndrew Rist 22*46dbaceeSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _EXTENSIONS_PROPCTRLR_BROWSERLISTBOX_HXX_ 25cdf0e10cSrcweir #define _EXTENSIONS_PROPCTRLR_BROWSERLISTBOX_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "browserline.hxx" 28cdf0e10cSrcweir #ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_ 29cdf0e10cSrcweir #include "modulepcr.hxx" 30cdf0e10cSrcweir #endif 31cdf0e10cSrcweir #include "pcrcommon.hxx" 32cdf0e10cSrcweir 33cdf0e10cSrcweir /** === begin UNO includes === **/ 34cdf0e10cSrcweir #include <com/sun/star/inspection/XPropertyControl.hpp> 35cdf0e10cSrcweir #include <com/sun/star/inspection/XPropertyHandler.hpp> 36cdf0e10cSrcweir /** === end UNO includes === **/ 37cdf0e10cSrcweir #include <vcl/scrbar.hxx> 38cdf0e10cSrcweir #include <vcl/lstbox.hxx> 39cdf0e10cSrcweir #ifndef _SV_BUTTON_HXX 40cdf0e10cSrcweir #include <vcl/button.hxx> 41cdf0e10cSrcweir #endif 42cdf0e10cSrcweir #include <tools/link.hxx> 43cdf0e10cSrcweir #include <rtl/ref.hxx> 44cdf0e10cSrcweir 45cdf0e10cSrcweir #include <set> 46cdf0e10cSrcweir #include <vector> 47cdf0e10cSrcweir #include <hash_map> 48cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 49cdf0e10cSrcweir 50cdf0e10cSrcweir //............................................................................ 51cdf0e10cSrcweir namespace pcr 52cdf0e10cSrcweir { 53cdf0e10cSrcweir //............................................................................ 54cdf0e10cSrcweir 55cdf0e10cSrcweir class IPropertyLineListener; 56cdf0e10cSrcweir class IPropertyControlObserver; 57cdf0e10cSrcweir struct OLineDescriptor; 58cdf0e10cSrcweir class InspectorHelpWindow; 59cdf0e10cSrcweir class PropertyControlContext_Impl; 60cdf0e10cSrcweir 61cdf0e10cSrcweir //======================================================================== 62cdf0e10cSrcweir //= administrative structures for OBrowserListBox 63cdf0e10cSrcweir //======================================================================== 64cdf0e10cSrcweir typedef ::boost::shared_ptr< OBrowserLine > BrowserLinePointer; 65cdf0e10cSrcweir struct ListBoxLine 66cdf0e10cSrcweir { 67cdf0e10cSrcweir BrowserLinePointer pLine; 68cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler > 69cdf0e10cSrcweir xHandler; 70cdf0e10cSrcweir ListBoxLinepcr::ListBoxLine71cdf0e10cSrcweir ListBoxLine() { } ListBoxLinepcr::ListBoxLine72cdf0e10cSrcweir ListBoxLine( BrowserLinePointer _pLine, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >& _rxHandler ) 73cdf0e10cSrcweir :pLine( _pLine ) 74cdf0e10cSrcweir ,xHandler( _rxHandler ) 75cdf0e10cSrcweir { 76cdf0e10cSrcweir } 77cdf0e10cSrcweir }; 78cdf0e10cSrcweir typedef ::std::hash_map< ::rtl::OUString, ListBoxLine, ::rtl::OUStringHash > ListBoxLines; 79cdf0e10cSrcweir typedef ::std::vector< ListBoxLines::iterator > OrderedListBoxLines; 80cdf0e10cSrcweir 81cdf0e10cSrcweir //======================================================================== 82cdf0e10cSrcweir //= IControlContext 83cdf0e10cSrcweir //======================================================================== 84cdf0e10cSrcweir /** non-UNO version of XPropertyControlContext 85cdf0e10cSrcweir */ 86cdf0e10cSrcweir class SAL_NO_VTABLE IControlContext 87cdf0e10cSrcweir { 88cdf0e10cSrcweir public: 89cdf0e10cSrcweir virtual void SAL_CALL focusGained( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& Control ) throw (::com::sun::star::uno::RuntimeException) = 0; 90cdf0e10cSrcweir virtual void SAL_CALL valueChanged( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& Control ) throw (::com::sun::star::uno::RuntimeException) = 0; 91cdf0e10cSrcweir virtual void SAL_CALL activateNextControl( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& CurrentControl ) throw (::com::sun::star::uno::RuntimeException) = 0; 92cdf0e10cSrcweir }; 93cdf0e10cSrcweir 94cdf0e10cSrcweir //======================================================================== 95cdf0e10cSrcweir //= OBrowserListBox 96cdf0e10cSrcweir //======================================================================== 97cdf0e10cSrcweir class OBrowserListBox :public Control 98cdf0e10cSrcweir ,public IButtonClickListener 99cdf0e10cSrcweir ,public IControlContext 100cdf0e10cSrcweir ,public PcrClient 101cdf0e10cSrcweir { 102cdf0e10cSrcweir protected: 103cdf0e10cSrcweir Window m_aLinesPlayground; 104cdf0e10cSrcweir ScrollBar m_aVScroll; 105cdf0e10cSrcweir ::std::auto_ptr< InspectorHelpWindow > 106cdf0e10cSrcweir m_pHelpWindow; 107cdf0e10cSrcweir ListBoxLines m_aLines; 108cdf0e10cSrcweir OrderedListBoxLines m_aOrderedLines; 109cdf0e10cSrcweir IPropertyLineListener* m_pLineListener; 110cdf0e10cSrcweir IPropertyControlObserver* m_pControlObserver; 111cdf0e10cSrcweir long m_nYOffset; 112cdf0e10cSrcweir long m_nCurrentPreferredHelpHeight; 113cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl > 114cdf0e10cSrcweir m_xActiveControl; 115cdf0e10cSrcweir sal_uInt16 m_nTheNameSize; 116cdf0e10cSrcweir sal_uInt16 m_nRowHeight; 117cdf0e10cSrcweir ::std::set< sal_uInt16 > m_aOutOfDateLines; 118cdf0e10cSrcweir sal_Bool m_bIsActive : 1; 119cdf0e10cSrcweir sal_Bool m_bUpdate : 1; 120cdf0e10cSrcweir ::rtl::Reference< PropertyControlContext_Impl > 121cdf0e10cSrcweir m_pControlContextImpl; 122cdf0e10cSrcweir 123cdf0e10cSrcweir protected: 124cdf0e10cSrcweir void PositionLine( sal_uInt16 _nIndex ); 125cdf0e10cSrcweir void UpdatePosNSize(); 126cdf0e10cSrcweir void UpdatePlayGround(); 127cdf0e10cSrcweir void UpdateVScroll(); 128cdf0e10cSrcweir void ShowEntry(sal_uInt16 nPos); 129cdf0e10cSrcweir void MoveThumbTo(sal_Int32 nNewThumbPos); 130cdf0e10cSrcweir void Resize(); 131cdf0e10cSrcweir 132cdf0e10cSrcweir public: 133cdf0e10cSrcweir OBrowserListBox( Window* pParent, WinBits nWinStyle = WB_DIALOGCONTROL ); 134cdf0e10cSrcweir 135cdf0e10cSrcweir ~OBrowserListBox(); 136cdf0e10cSrcweir 137cdf0e10cSrcweir void UpdateAll(); 138cdf0e10cSrcweir 139cdf0e10cSrcweir void ActivateListBox( sal_Bool _bActive ); 140cdf0e10cSrcweir 141cdf0e10cSrcweir sal_uInt16 CalcVisibleLines(); 142cdf0e10cSrcweir void EnableUpdate(); 143cdf0e10cSrcweir void DisableUpdate(); 144cdf0e10cSrcweir long Notify( NotifyEvent& _rNEvt ); 145cdf0e10cSrcweir long PreNotify( NotifyEvent& _rNEvt ); 146cdf0e10cSrcweir 147cdf0e10cSrcweir void SetListener( IPropertyLineListener* _pListener ); 148cdf0e10cSrcweir void SetObserver( IPropertyControlObserver* _pObserver ); 149cdf0e10cSrcweir 150cdf0e10cSrcweir void EnableHelpSection( bool _bEnable ); 151cdf0e10cSrcweir bool HasHelpSection() const; 152cdf0e10cSrcweir void SetHelpText( const ::rtl::OUString& _rHelpText ); 153cdf0e10cSrcweir void SetHelpLineLimites( sal_Int32 _nMinLines, sal_Int32 _nMaxLines ); 154cdf0e10cSrcweir 155cdf0e10cSrcweir void Clear(); 156cdf0e10cSrcweir 157cdf0e10cSrcweir sal_uInt16 InsertEntry( const OLineDescriptor&, sal_uInt16 nPos = EDITOR_LIST_APPEND ); 158cdf0e10cSrcweir sal_Bool RemoveEntry( const ::rtl::OUString& _rName ); 159cdf0e10cSrcweir void ChangeEntry( const OLineDescriptor&, sal_uInt16 nPos ); 160cdf0e10cSrcweir 161cdf0e10cSrcweir void SetPropertyValue( const ::rtl::OUString& rEntryName, const ::com::sun::star::uno::Any& rValue, bool _bUnknownValue ); 162cdf0e10cSrcweir sal_uInt16 GetPropertyPos( const ::rtl::OUString& rEntryName ) const; 163cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl > 164cdf0e10cSrcweir GetPropertyControl( const ::rtl::OUString& rEntryName ); 165cdf0e10cSrcweir void EnablePropertyControls( const ::rtl::OUString& _rEntryName, sal_Int16 _nControls, bool _bEnable ); 166cdf0e10cSrcweir void EnablePropertyLine( const ::rtl::OUString& _rEntryName, bool _bEnable ); 167cdf0e10cSrcweir 168cdf0e10cSrcweir sal_Int32 GetMinimumWidth(); 169cdf0e10cSrcweir sal_Int32 GetMinimumHeight(); 170cdf0e10cSrcweir 171cdf0e10cSrcweir 172cdf0e10cSrcweir sal_Bool IsModified( ) const; 173cdf0e10cSrcweir void CommitModified( ); 174cdf0e10cSrcweir 175cdf0e10cSrcweir protected: 176cdf0e10cSrcweir // IControlContext 177cdf0e10cSrcweir virtual void SAL_CALL focusGained( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& Control ) throw (::com::sun::star::uno::RuntimeException); 178cdf0e10cSrcweir virtual void SAL_CALL valueChanged( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& Control ) throw (::com::sun::star::uno::RuntimeException); 179cdf0e10cSrcweir virtual void SAL_CALL activateNextControl( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& CurrentControl ) throw (::com::sun::star::uno::RuntimeException); 180cdf0e10cSrcweir 181cdf0e10cSrcweir // IButtonClickListener 182cdf0e10cSrcweir void buttonClicked( OBrowserLine* _pLine, sal_Bool _bPrimary ); 183cdf0e10cSrcweir 184cdf0e10cSrcweir using Window::SetHelpText; 185cdf0e10cSrcweir private: 186cdf0e10cSrcweir DECL_LINK( ScrollHdl, ScrollBar* ); 187cdf0e10cSrcweir 188cdf0e10cSrcweir /** retrieves the index of a given control in our line list 189cdf0e10cSrcweir @param _rxControl 190cdf0e10cSrcweir The control to lookup. Must denote a control of one of the lines in ->m_aLines 191cdf0e10cSrcweir */ 192cdf0e10cSrcweir sal_uInt16 impl_getControlPos( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _rxControl ) const; 193cdf0e10cSrcweir 194cdf0e10cSrcweir /** retrieves (a reference to) the ->ListBoxLine for a given control 195cdf0e10cSrcweir @param _rxControl 196cdf0e10cSrcweir The control to lookup. Must denote a control of one of the lines in ->m_aLines 197cdf0e10cSrcweir */ 198cdf0e10cSrcweir inline const ListBoxLine& impl_getControlLine(const::com::sun::star::uno::Reference<::com::sun::star::inspection::XPropertyControl> & _rxControl) const199cdf0e10cSrcweir impl_getControlLine( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _rxControl ) const 200cdf0e10cSrcweir { 201cdf0e10cSrcweir return m_aOrderedLines[ impl_getControlPos( _rxControl ) ]->second; 202cdf0e10cSrcweir } 203cdf0e10cSrcweir 204cdf0e10cSrcweir /** sets the given property value at the given control, after converting it as necessary 205cdf0e10cSrcweir @param _rLine 206cdf0e10cSrcweir The line whose at which the value is to be set. 207cdf0e10cSrcweir @param _rPropertyValue 208cdf0e10cSrcweir the property value to set. If it's not compatible with the control value, 209cdf0e10cSrcweir it will be converted, using <member>XPropertyHandler::convertToControlValue</member> 210cdf0e10cSrcweir */ 211cdf0e10cSrcweir void impl_setControlAsPropertyValue( const ListBoxLine& _rLine, const ::com::sun::star::uno::Any& _rPropertyValue ); 212cdf0e10cSrcweir 213cdf0e10cSrcweir /** retrieves the value for the given control, as a property value, after converting it as necessary 214cdf0e10cSrcweir @param _rLine 215cdf0e10cSrcweir The line whose at which the value is to be set. 216cdf0e10cSrcweir */ 217cdf0e10cSrcweir ::com::sun::star::uno::Any 218cdf0e10cSrcweir impl_getControlAsPropertyValue( const ListBoxLine& _rLine ) const; 219cdf0e10cSrcweir 220cdf0e10cSrcweir /** retrieves the ->BrowserLinePointer for a given entry name 221cdf0e10cSrcweir @param _rEntryName 222cdf0e10cSrcweir the name whose line is to be looked up 223cdf0e10cSrcweir @param _out_rpLine 224cdf0e10cSrcweir contains, upon return, the found browser line, if any 225cdf0e10cSrcweir @return 226cdf0e10cSrcweir <TRUE/> if and only if a non-<NULL/> line for the given entry name could be 227cdf0e10cSrcweir found. 228cdf0e10cSrcweir */ 229cdf0e10cSrcweir bool impl_getBrowserLineForName( const ::rtl::OUString& _rEntryName, BrowserLinePointer& _out_rpLine ) const; 230cdf0e10cSrcweir 231cdf0e10cSrcweir /** returns the preferred height (in pixels) of the help section, or 0 if we 232cdf0e10cSrcweir currently don't have a help section 233cdf0e10cSrcweir */ 234cdf0e10cSrcweir long impl_getPrefererredHelpHeight(); 235cdf0e10cSrcweir 236cdf0e10cSrcweir private: 237cdf0e10cSrcweir using Window::Activate; 238cdf0e10cSrcweir }; 239cdf0e10cSrcweir 240cdf0e10cSrcweir //............................................................................ 241cdf0e10cSrcweir } // namespace pcr 242cdf0e10cSrcweir //............................................................................ 243cdf0e10cSrcweir 244cdf0e10cSrcweir #endif // _EXTENSIONS_PROPCTRLR_BROWSERLISTBOX_HXX_ 245cdf0e10cSrcweir 246cdf0e10cSrcweir 247