bump product version to 5.0.4.1
[LibreOffice.git] / extensions / source / propctrlr / browserlistbox.hxx
blob193ec8164a014bb8d5fa55b402360d43480d1d6a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
35 #include <set>
36 #include <unordered_map>
37 #include <vector>
38 #include <boost/shared_ptr.hpp>
41 namespace pcr
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;
55 struct ListBoxLine
57 OUString aName;
58 BrowserLinePointer pLine;
59 ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >
60 xHandler;
62 ListBoxLine( const OUString& rName, BrowserLinePointer _pLine, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >& _rxHandler )
63 : aName( rName ),
64 pLine( _pLine ),
65 xHandler( _rxHandler )
69 typedef ::std::vector< ListBoxLine > ListBoxLines;
72 /** non-UNO version of XPropertyControlContext
74 class SAL_NO_VTABLE IControlContext
76 public:
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;
81 protected:
82 ~IControlContext() {}
85 class OBrowserListBox :public Control
86 ,public IButtonClickListener
87 ,public IControlContext
88 ,public PcrClient
90 protected:
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;
97 long m_nYOffset;
98 long m_nCurrentPreferredHelpHeight;
99 ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
100 m_xActiveControl;
101 sal_uInt16 m_nTheNameSize;
102 long m_nRowHeight;
103 ::std::set< sal_uInt16 > m_aOutOfDateLines;
104 bool m_bIsActive : 1;
105 bool m_bUpdate : 1;
106 ::rtl::Reference< PropertyControlContext_Impl >
107 m_pControlContextImpl;
109 protected:
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;
118 public:
119 OBrowserListBox( vcl::Window* pParent, WinBits nWinStyle = WB_DIALOGCONTROL );
121 virtual ~OBrowserListBox();
122 virtual void dispose() SAL_OVERRIDE;
124 void UpdateAll();
126 void ActivateListBox( bool _bActive );
128 sal_uInt16 CalcVisibleLines();
129 void EnableUpdate();
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 );
142 void Clear();
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( );
162 protected:
163 // IControlContext
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;
172 private:
173 DECL_LINK( ScrollHdl, ScrollBar* );
175 /** retrieves the index of a given control in our line list
176 @param _rxControl
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
182 @param _rLine
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
191 @param _rLine
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
198 @param _rEntryName
199 the name whose line is to be looked up
200 @param _out_rpLine
201 contains, upon return, the found browser line, if any
202 @return
203 <TRUE/> if and only if a non-<NULL/> line for the given entry name could be
204 found.
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();
213 private:
214 using Window::Activate;
218 } // namespace pcr
221 #endif // INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_BROWSERLISTBOX_HXX
224 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */