1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_BROWSERLISTBOX_HXX
21 #define INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_BROWSERLISTBOX_HXX
23 #include "browserline.hxx"
24 #include "modulepcr.hxx"
25 #include "pcrcommon.hxx"
27 #include <com/sun/star/inspection/XPropertyControl.hpp>
28 #include <com/sun/star/inspection/XPropertyHandler.hpp>
29 #include <vcl/scrbar.hxx>
30 #include <vcl/lstbox.hxx>
31 #include <vcl/button.hxx>
32 #include <tools/link.hxx>
33 #include <rtl/ref.hxx>
36 #include <unordered_map>
38 #include <boost/shared_ptr.hpp>
45 class IPropertyLineListener
;
46 class IPropertyControlObserver
;
47 struct OLineDescriptor
;
48 class InspectorHelpWindow
;
49 class PropertyControlContext_Impl
;
52 // administrative structures for OBrowserListBox
54 typedef ::boost::shared_ptr
< OBrowserLine
> BrowserLinePointer
;
58 BrowserLinePointer pLine
;
59 ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyHandler
>
62 ListBoxLine( const OUString
& rName
, BrowserLinePointer _pLine
, const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyHandler
>& _rxHandler
)
65 xHandler( _rxHandler
)
69 typedef ::std::vector
< ListBoxLine
> ListBoxLines
;
72 /** non-UNO version of XPropertyControlContext
74 class SAL_NO_VTABLE IControlContext
77 virtual void SAL_CALL
focusGained( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& Control
) throw (::com::sun::star::uno::RuntimeException
) = 0;
78 virtual void SAL_CALL
valueChanged( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& Control
) throw (::com::sun::star::uno::RuntimeException
) = 0;
79 virtual void SAL_CALL
activateNextControl( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& CurrentControl
) throw (::com::sun::star::uno::RuntimeException
) = 0;
85 class OBrowserListBox
:public Control
86 ,public IButtonClickListener
87 ,public IControlContext
91 VclPtr
<Window
> m_aLinesPlayground
;
92 VclPtr
<ScrollBar
> m_aVScroll
;
93 VclPtr
<InspectorHelpWindow
> m_pHelpWindow
;
94 ListBoxLines m_aLines
;
95 IPropertyLineListener
* m_pLineListener
;
96 IPropertyControlObserver
* m_pControlObserver
;
98 long m_nCurrentPreferredHelpHeight
;
99 ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>
101 sal_uInt16 m_nTheNameSize
;
103 ::std::set
< sal_uInt16
> m_aOutOfDateLines
;
104 bool m_bIsActive
: 1;
106 ::rtl::Reference
< PropertyControlContext_Impl
>
107 m_pControlContextImpl
;
110 void PositionLine( sal_uInt16 _nIndex
);
111 void UpdatePosNSize();
112 void UpdatePlayGround();
113 void UpdateVScroll();
114 void ShowEntry(sal_uInt16 nPos
);
115 void MoveThumbTo(sal_Int32 nNewThumbPos
);
116 void Resize() SAL_OVERRIDE
;
119 OBrowserListBox( vcl::Window
* pParent
, WinBits nWinStyle
= WB_DIALOGCONTROL
);
121 virtual ~OBrowserListBox();
122 virtual void dispose() SAL_OVERRIDE
;
126 void ActivateListBox( bool _bActive
);
128 sal_uInt16
CalcVisibleLines();
130 void DisableUpdate();
131 bool Notify( NotifyEvent
& _rNEvt
) SAL_OVERRIDE
;
132 virtual bool PreNotify( NotifyEvent
& _rNEvt
) SAL_OVERRIDE
;
134 void SetListener( IPropertyLineListener
* _pListener
);
135 void SetObserver( IPropertyControlObserver
* _pObserver
);
137 void EnableHelpSection( bool _bEnable
);
138 bool HasHelpSection() const;
139 void SetHelpText( const OUString
& _rHelpText
);
140 void SetHelpLineLimites( sal_Int32 _nMinLines
, sal_Int32 _nMaxLines
);
144 sal_uInt16
InsertEntry( const OLineDescriptor
&, sal_uInt16 nPos
= EDITOR_LIST_APPEND
);
145 bool RemoveEntry( const OUString
& _rName
);
146 void ChangeEntry( const OLineDescriptor
&, sal_uInt16 nPos
);
148 void SetPropertyValue( const OUString
& rEntryName
, const ::com::sun::star::uno::Any
& rValue
, bool _bUnknownValue
);
149 sal_uInt16
GetPropertyPos( const OUString
& rEntryName
) const;
150 ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>
151 GetPropertyControl( const OUString
& rEntryName
);
152 void EnablePropertyControls( const OUString
& _rEntryName
, sal_Int16 _nControls
, bool _bEnable
);
153 void EnablePropertyLine( const OUString
& _rEntryName
, bool _bEnable
);
155 sal_Int32
GetMinimumWidth();
156 sal_Int32
GetMinimumHeight();
159 bool IsModified( ) const;
160 void CommitModified( );
164 virtual void SAL_CALL
focusGained( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& Control
) throw (::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
165 virtual void SAL_CALL
valueChanged( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& Control
) throw (::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
166 virtual void SAL_CALL
activateNextControl( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& CurrentControl
) throw (::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
168 // IButtonClickListener
169 void buttonClicked( OBrowserLine
* _pLine
, bool _bPrimary
) SAL_OVERRIDE
;
171 using Window::SetHelpText
;
173 DECL_LINK( ScrollHdl
, ScrollBar
* );
175 /** retrieves the index of a given control in our line list
177 The control to lookup. Must denote a control of one of the lines in ->m_aLines
179 sal_uInt16
impl_getControlPos( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& _rxControl
) const;
181 /** sets the given property value at the given control, after converting it as necessary
183 The line whose at which the value is to be set.
184 @param _rPropertyValue
185 the property value to set. If it's not compatible with the control value,
186 it will be converted, using <member>XPropertyHandler::convertToControlValue</member>
188 static void impl_setControlAsPropertyValue( const ListBoxLine
& _rLine
, const ::com::sun::star::uno::Any
& _rPropertyValue
);
190 /** retrieves the value for the given control, as a property value, after converting it as necessary
192 The line whose at which the value is to be set.
194 static ::com::sun::star::uno::Any
195 impl_getControlAsPropertyValue( const ListBoxLine
& _rLine
);
197 /** retrieves the ->BrowserLinePointer for a given entry name
199 the name whose line is to be looked up
201 contains, upon return, the found browser line, if any
203 <TRUE/> if and only if a non-<NULL/> line for the given entry name could be
206 bool impl_getBrowserLineForName( const OUString
& _rEntryName
, BrowserLinePointer
& _out_rpLine
) const;
208 /** returns the preferred height (in pixels) of the help section, or 0 if we
209 currently don't have a help section
211 long impl_getPrefererredHelpHeight();
214 using Window::Activate
;
221 #endif // INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_BROWSERLISTBOX_HXX
224 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */