1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _EXTENSIONS_PROPCTRLR_BROWSERLISTBOX_HXX_
30 #define _EXTENSIONS_PROPCTRLR_BROWSERLISTBOX_HXX_
32 #include "browserline.hxx"
33 #include "modulepcr.hxx"
34 #include "pcrcommon.hxx"
36 /** === begin UNO includes === **/
37 #include <com/sun/star/inspection/XPropertyControl.hpp>
38 #include <com/sun/star/inspection/XPropertyHandler.hpp>
39 /** === end UNO includes === **/
40 #include <vcl/scrbar.hxx>
41 #include <vcl/lstbox.hxx>
42 #include <vcl/button.hxx>
43 #include <tools/link.hxx>
44 #include <rtl/ref.hxx>
48 #include <boost/unordered_map.hpp>
49 #include <boost/shared_ptr.hpp>
51 //............................................................................
54 //............................................................................
56 class IPropertyLineListener
;
57 class IPropertyControlObserver
;
58 struct OLineDescriptor
;
59 class InspectorHelpWindow
;
60 class PropertyControlContext_Impl
;
62 //========================================================================
63 //= administrative structures for OBrowserListBox
64 //========================================================================
65 typedef ::boost::shared_ptr
< OBrowserLine
> BrowserLinePointer
;
68 ::rtl::OUString aName
;
69 BrowserLinePointer pLine
;
70 ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyHandler
>
73 ListBoxLine( const ::rtl::OUString
& rName
, BrowserLinePointer _pLine
, const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyHandler
>& _rxHandler
)
76 xHandler( _rxHandler
)
80 typedef ::std::vector
< ListBoxLine
> ListBoxLines
;
82 //========================================================================
84 //========================================================================
85 /** non-UNO version of XPropertyControlContext
87 class SAL_NO_VTABLE IControlContext
90 virtual void SAL_CALL
focusGained( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& Control
) throw (::com::sun::star::uno::RuntimeException
) = 0;
91 virtual void SAL_CALL
valueChanged( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& Control
) throw (::com::sun::star::uno::RuntimeException
) = 0;
92 virtual void SAL_CALL
activateNextControl( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& CurrentControl
) throw (::com::sun::star::uno::RuntimeException
) = 0;
98 //========================================================================
100 //========================================================================
101 class OBrowserListBox
:public Control
102 ,public IButtonClickListener
103 ,public IControlContext
107 Window m_aLinesPlayground
;
108 ScrollBar m_aVScroll
;
109 ::std::auto_ptr
< InspectorHelpWindow
>
111 ListBoxLines m_aLines
;
112 IPropertyLineListener
* m_pLineListener
;
113 IPropertyControlObserver
* m_pControlObserver
;
115 long m_nCurrentPreferredHelpHeight
;
116 ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>
118 sal_uInt16 m_nTheNameSize
;
119 sal_uInt16 m_nRowHeight
;
120 ::std::set
< sal_uInt16
> m_aOutOfDateLines
;
121 sal_Bool m_bIsActive
: 1;
122 sal_Bool m_bUpdate
: 1;
123 ::rtl::Reference
< PropertyControlContext_Impl
>
124 m_pControlContextImpl
;
127 void PositionLine( sal_uInt16 _nIndex
);
128 void UpdatePosNSize();
129 void UpdatePlayGround();
130 void UpdateVScroll();
131 void ShowEntry(sal_uInt16 nPos
);
132 void MoveThumbTo(sal_Int32 nNewThumbPos
);
136 OBrowserListBox( Window
* pParent
, WinBits nWinStyle
= WB_DIALOGCONTROL
);
142 void ActivateListBox( sal_Bool _bActive
);
144 sal_uInt16
CalcVisibleLines();
146 void DisableUpdate();
147 long Notify( NotifyEvent
& _rNEvt
);
148 long PreNotify( NotifyEvent
& _rNEvt
);
150 void SetListener( IPropertyLineListener
* _pListener
);
151 void SetObserver( IPropertyControlObserver
* _pObserver
);
153 void EnableHelpSection( bool _bEnable
);
154 bool HasHelpSection() const;
155 void SetHelpText( const ::rtl::OUString
& _rHelpText
);
156 void SetHelpLineLimites( sal_Int32 _nMinLines
, sal_Int32 _nMaxLines
);
160 sal_uInt16
InsertEntry( const OLineDescriptor
&, sal_uInt16 nPos
= EDITOR_LIST_APPEND
);
161 sal_Bool
RemoveEntry( const ::rtl::OUString
& _rName
);
162 void ChangeEntry( const OLineDescriptor
&, sal_uInt16 nPos
);
164 void SetPropertyValue( const ::rtl::OUString
& rEntryName
, const ::com::sun::star::uno::Any
& rValue
, bool _bUnknownValue
);
165 sal_uInt16
GetPropertyPos( const ::rtl::OUString
& rEntryName
) const;
166 ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>
167 GetPropertyControl( const ::rtl::OUString
& rEntryName
);
168 void EnablePropertyControls( const ::rtl::OUString
& _rEntryName
, sal_Int16 _nControls
, bool _bEnable
);
169 void EnablePropertyLine( const ::rtl::OUString
& _rEntryName
, bool _bEnable
);
171 sal_Int32
GetMinimumWidth();
172 sal_Int32
GetMinimumHeight();
175 sal_Bool
IsModified( ) const;
176 void CommitModified( );
180 virtual void SAL_CALL
focusGained( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& Control
) throw (::com::sun::star::uno::RuntimeException
);
181 virtual void SAL_CALL
valueChanged( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& Control
) throw (::com::sun::star::uno::RuntimeException
);
182 virtual void SAL_CALL
activateNextControl( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& CurrentControl
) throw (::com::sun::star::uno::RuntimeException
);
184 // IButtonClickListener
185 void buttonClicked( OBrowserLine
* _pLine
, sal_Bool _bPrimary
);
187 using Window::SetHelpText
;
189 DECL_LINK( ScrollHdl
, ScrollBar
* );
191 /** retrieves the index of a given control in our line list
193 The control to lookup. Must denote a control of one of the lines in ->m_aLines
195 sal_uInt16
impl_getControlPos( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& _rxControl
) const;
197 /** sets the given property value at the given control, after converting it as necessary
199 The line whose at which the value is to be set.
200 @param _rPropertyValue
201 the property value to set. If it's not compatible with the control value,
202 it will be converted, using <member>XPropertyHandler::convertToControlValue</member>
204 void impl_setControlAsPropertyValue( const ListBoxLine
& _rLine
, const ::com::sun::star::uno::Any
& _rPropertyValue
);
206 /** retrieves the value for the given control, as a property value, after converting it as necessary
208 The line whose at which the value is to be set.
210 ::com::sun::star::uno::Any
211 impl_getControlAsPropertyValue( const ListBoxLine
& _rLine
) const;
213 /** retrieves the ->BrowserLinePointer for a given entry name
215 the name whose line is to be looked up
217 contains, upon return, the found browser line, if any
219 <TRUE/> if and only if a non-<NULL/> line for the given entry name could be
222 bool impl_getBrowserLineForName( const ::rtl::OUString
& _rEntryName
, BrowserLinePointer
& _out_rpLine
) const;
224 /** returns the preferred height (in pixels) of the help section, or 0 if we
225 currently don't have a help section
227 long impl_getPrefererredHelpHeight();
230 using Window::Activate
;
233 //............................................................................
235 //............................................................................
237 #endif // _EXTENSIONS_PROPCTRLR_BROWSERLISTBOX_HXX_
240 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */