1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: browserlistbox.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _EXTENSIONS_PROPCTRLR_BROWSERLISTBOX_HXX_
32 #define _EXTENSIONS_PROPCTRLR_BROWSERLISTBOX_HXX_
34 #include "browserline.hxx"
35 #ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
36 #include "modulepcr.hxx"
38 #include "pcrcommon.hxx"
40 /** === begin UNO includes === **/
41 #include <com/sun/star/inspection/XPropertyControl.hpp>
42 #include <com/sun/star/inspection/XPropertyHandler.hpp>
43 /** === end UNO includes === **/
44 #include <vcl/scrbar.hxx>
45 #include <vcl/lstbox.hxx>
46 #ifndef _SV_BUTTON_HXX
47 #include <vcl/button.hxx>
49 #include <tools/link.hxx>
50 #include <rtl/ref.hxx>
55 #include <boost/shared_ptr.hpp>
57 //............................................................................
60 //............................................................................
62 class IPropertyLineListener
;
63 class IPropertyControlObserver
;
64 struct OLineDescriptor
;
65 class InspectorHelpWindow
;
66 class PropertyControlContext_Impl
;
68 //========================================================================
69 //= administrative structures for OBrowserListBox
70 //========================================================================
71 typedef ::boost::shared_ptr
< OBrowserLine
> BrowserLinePointer
;
74 BrowserLinePointer pLine
;
75 ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyHandler
>
79 ListBoxLine( BrowserLinePointer _pLine
, const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyHandler
>& _rxHandler
)
81 ,xHandler( _rxHandler
)
85 typedef ::std::hash_map
< ::rtl::OUString
, ListBoxLine
, ::rtl::OUStringHash
> ListBoxLines
;
86 typedef ::std::vector
< ListBoxLines::iterator
> OrderedListBoxLines
;
88 //========================================================================
90 //========================================================================
91 /** non-UNO version of XPropertyControlContext
93 class SAL_NO_VTABLE IControlContext
96 virtual void SAL_CALL
focusGained( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& Control
) throw (::com::sun::star::uno::RuntimeException
) = 0;
97 virtual void SAL_CALL
valueChanged( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& Control
) throw (::com::sun::star::uno::RuntimeException
) = 0;
98 virtual void SAL_CALL
activateNextControl( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& CurrentControl
) throw (::com::sun::star::uno::RuntimeException
) = 0;
101 //========================================================================
103 //========================================================================
104 class OBrowserListBox
:public Control
105 ,public IButtonClickListener
106 ,public IControlContext
110 Window m_aLinesPlayground
;
111 ScrollBar m_aVScroll
;
112 ::std::auto_ptr
< InspectorHelpWindow
>
114 ListBoxLines m_aLines
;
115 OrderedListBoxLines m_aOrderedLines
;
116 IPropertyLineListener
* m_pLineListener
;
117 IPropertyControlObserver
* m_pControlObserver
;
119 long m_nCurrentPreferredHelpHeight
;
120 ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>
122 sal_uInt16 m_nTheNameSize
;
123 sal_uInt16 m_nRowHeight
;
124 ::std::set
< sal_uInt16
> m_aOutOfDateLines
;
125 sal_Bool m_bIsActive
: 1;
126 sal_Bool m_bUpdate
: 1;
127 ::rtl::Reference
< PropertyControlContext_Impl
>
128 m_pControlContextImpl
;
131 void PositionLine( sal_uInt16 _nIndex
);
132 void UpdatePosNSize();
133 void UpdatePlayGround();
134 void UpdateVScroll();
135 void ShowEntry(sal_uInt16 nPos
);
136 void MoveThumbTo(sal_Int32 nNewThumbPos
);
140 OBrowserListBox( Window
* pParent
, WinBits nWinStyle
= WB_DIALOGCONTROL
);
146 void ActivateListBox( sal_Bool _bActive
);
148 sal_uInt16
CalcVisibleLines();
150 void DisableUpdate();
151 long Notify( NotifyEvent
& _rNEvt
);
152 long PreNotify( NotifyEvent
& _rNEvt
);
154 void SetListener( IPropertyLineListener
* _pListener
);
155 void SetObserver( IPropertyControlObserver
* _pObserver
);
157 void EnableHelpSection( bool _bEnable
);
158 bool HasHelpSection() const;
159 void SetHelpText( const ::rtl::OUString
& _rHelpText
);
160 void SetHelpLineLimites( sal_Int32 _nMinLines
, sal_Int32 _nMaxLines
);
164 sal_uInt16
InsertEntry( const OLineDescriptor
&, sal_uInt16 nPos
= EDITOR_LIST_APPEND
);
165 sal_Bool
RemoveEntry( const ::rtl::OUString
& _rName
);
166 void ChangeEntry( const OLineDescriptor
&, sal_uInt16 nPos
);
168 void SetPropertyValue( const ::rtl::OUString
& rEntryName
, const ::com::sun::star::uno::Any
& rValue
, bool _bUnknownValue
);
169 ::com::sun::star::uno::Any
GetPropertyValue( const ::rtl::OUString
& rEntryName
) const;
170 sal_uInt16
GetPropertyPos( const ::rtl::OUString
& rEntryName
) const;
171 ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>
172 GetPropertyControl( const ::rtl::OUString
& rEntryName
);
173 void EnablePropertyControls( const ::rtl::OUString
& _rEntryName
, sal_Int16 _nControls
, bool _bEnable
);
174 void EnablePropertyLine( const ::rtl::OUString
& _rEntryName
, bool _bEnable
);
175 sal_Bool
IsPropertyInputEnabled( const ::rtl::OUString
& _rEntryName
) const;
177 sal_Int32
GetMinimumWidth();
178 sal_Int32
GetMinimumHeight();
181 sal_Bool
IsModified( ) const;
182 void CommitModified( );
186 virtual void SAL_CALL
focusGained( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& Control
) throw (::com::sun::star::uno::RuntimeException
);
187 virtual void SAL_CALL
valueChanged( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& Control
) throw (::com::sun::star::uno::RuntimeException
);
188 virtual void SAL_CALL
activateNextControl( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& CurrentControl
) throw (::com::sun::star::uno::RuntimeException
);
190 // IButtonClickListener
191 void buttonClicked( OBrowserLine
* _pLine
, sal_Bool _bPrimary
);
193 using Window::SetHelpText
;
195 DECL_LINK( ScrollHdl
, ScrollBar
* );
197 /** retrieves the index of a given control in our line list
199 The control to lookup. Must denote a control of one of the lines in ->m_aLines
201 sal_uInt16
impl_getControlPos( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& _rxControl
) const;
203 /** retrieves (a reference to) the ->ListBoxLine for a given control
205 The control to lookup. Must denote a control of one of the lines in ->m_aLines
207 inline const ListBoxLine
&
208 impl_getControlLine( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& _rxControl
) const
210 return m_aOrderedLines
[ impl_getControlPos( _rxControl
) ]->second
;
213 /** sets the given property value at the given control, after converting it as necessary
215 The line whose at which the value is to be set.
216 @param _rPropertyValue
217 the property value to set. If it's not compatible with the control value,
218 it will be converted, using <member>XPropertyHandler::convertToControlValue</member>
220 void impl_setControlAsPropertyValue( const ListBoxLine
& _rLine
, const ::com::sun::star::uno::Any
& _rPropertyValue
);
222 /** retrieves the value for the given control, as a property value, after converting it as necessary
224 The line whose at which the value is to be set.
226 ::com::sun::star::uno::Any
227 impl_getControlAsPropertyValue( const ListBoxLine
& _rLine
) const;
229 /** retrieves the ->BrowserLinePointer for a given entry name
231 the name whose line is to be looked up
233 contains, upon return, the found browser line, if any
235 <TRUE/> if and only if a non-<NULL/> line for the given entry name could be
238 bool impl_getBrowserLineForName( const ::rtl::OUString
& _rEntryName
, BrowserLinePointer
& _out_rpLine
) const;
240 /** returns the preferred height (in pixels) of the help section, or 0 if we
241 currently don't have a help section
243 long impl_getPrefererredHelpHeight();
246 using Window::Activate
;
249 //............................................................................
251 //............................................................................
253 #endif // _EXTENSIONS_PROPCTRLR_BROWSERLISTBOX_HXX_