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
);
153 void SetListener( IPropertyLineListener
* _pListener
);
154 void SetObserver( IPropertyControlObserver
* _pObserver
);
156 void EnableHelpSection( bool _bEnable
);
157 bool HasHelpSection() const;
158 void SetHelpText( const ::rtl::OUString
& _rHelpText
);
159 void SetHelpLineLimites( sal_Int32 _nMinLines
, sal_Int32 _nMaxLines
);
163 sal_uInt16
InsertEntry( const OLineDescriptor
&, sal_uInt16 nPos
= EDITOR_LIST_APPEND
);
164 sal_Bool
RemoveEntry( const ::rtl::OUString
& _rName
);
165 void ChangeEntry( const OLineDescriptor
&, sal_uInt16 nPos
);
167 void SetPropertyValue( const ::rtl::OUString
& rEntryName
, const ::com::sun::star::uno::Any
& rValue
, bool _bUnknownValue
);
168 ::com::sun::star::uno::Any
GetPropertyValue( const ::rtl::OUString
& rEntryName
) const;
169 sal_uInt16
GetPropertyPos( const ::rtl::OUString
& rEntryName
) const;
170 ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>
171 GetPropertyControl( const ::rtl::OUString
& rEntryName
);
172 void EnablePropertyControls( const ::rtl::OUString
& _rEntryName
, sal_Int16 _nControls
, bool _bEnable
);
173 void EnablePropertyLine( const ::rtl::OUString
& _rEntryName
, bool _bEnable
);
174 sal_Bool
IsPropertyInputEnabled( const ::rtl::OUString
& _rEntryName
) const;
176 sal_Int32
GetMinimumWidth();
177 sal_Int32
GetMinimumHeight();
180 sal_Bool
IsModified( ) const;
181 void CommitModified( );
185 virtual void SAL_CALL
focusGained( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& Control
) throw (::com::sun::star::uno::RuntimeException
);
186 virtual void SAL_CALL
valueChanged( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& Control
) throw (::com::sun::star::uno::RuntimeException
);
187 virtual void SAL_CALL
activateNextControl( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& CurrentControl
) throw (::com::sun::star::uno::RuntimeException
);
189 // IButtonClickListener
190 void buttonClicked( OBrowserLine
* _pLine
, sal_Bool _bPrimary
);
192 using Window::SetHelpText
;
194 DECL_LINK( ScrollHdl
, ScrollBar
* );
196 /** retrieves the index of a given control in our line list
198 The control to lookup. Must denote a control of one of the lines in ->m_aLines
200 sal_uInt16
impl_getControlPos( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& _rxControl
) const;
202 /** retrieves (a reference to) the ->ListBoxLine for a given control
204 The control to lookup. Must denote a control of one of the lines in ->m_aLines
206 inline const ListBoxLine
&
207 impl_getControlLine( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& _rxControl
) const
209 return m_aOrderedLines
[ impl_getControlPos( _rxControl
) ]->second
;
212 /** sets the given property value at the given control, after converting it as necessary
214 The line whose at which the value is to be set.
215 @param _rPropertyValue
216 the property value to set. If it's not compatible with the control value,
217 it will be converted, using <member>XPropertyHandler::convertToControlValue</member>
219 void impl_setControlAsPropertyValue( const ListBoxLine
& _rLine
, const ::com::sun::star::uno::Any
& _rPropertyValue
);
221 /** retrieves the value for the given control, as a property value, after converting it as necessary
223 The line whose at which the value is to be set.
225 ::com::sun::star::uno::Any
226 impl_getControlAsPropertyValue( const ListBoxLine
& _rLine
) const;
228 /** retrieves the ->BrowserLinePointer for a given entry name
230 the name whose line is to be looked up
232 contains, upon return, the found browser line, if any
234 <TRUE/> if and only if a non-<NULL/> line for the given entry name could be
237 bool impl_getBrowserLineForName( const ::rtl::OUString
& _rEntryName
, BrowserLinePointer
& _out_rpLine
) const;
239 /** returns the preferred height (in pixels) of the help section, or 0 if we
240 currently don't have a help section
242 long impl_getPrefererredHelpHeight();
245 using Window::Activate
;
248 //............................................................................
250 //............................................................................
252 #endif // _EXTENSIONS_PROPCTRLR_BROWSERLISTBOX_HXX_