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/button.hxx>
31 #include <tools/link.hxx>
32 #include <rtl/ref.hxx>
37 #include <unordered_map>
40 #define EDITOR_LIST_REPLACE_EXISTING \
41 std::numeric_limits<ListBoxLines::size_type>::max()
47 class IPropertyLineListener
;
48 class IPropertyControlObserver
;
49 struct OLineDescriptor
;
50 class InspectorHelpWindow
;
51 class PropertyControlContext_Impl
;
54 // administrative structures for OBrowserListBox
56 typedef std::shared_ptr
< OBrowserLine
> BrowserLinePointer
;
60 BrowserLinePointer pLine
;
61 css::uno::Reference
< css::inspection::XPropertyHandler
>
64 ListBoxLine( const OUString
& rName
, const BrowserLinePointer
& _pLine
, const css::uno::Reference
< css::inspection::XPropertyHandler
>& _rxHandler
)
67 xHandler( _rxHandler
)
71 typedef std::vector
< ListBoxLine
> ListBoxLines
;
74 class OBrowserListBox final
: public Control
75 ,public IButtonClickListener
77 VclPtr
<Window
> m_aLinesPlayground
;
78 VclPtr
<ScrollBar
> m_aVScroll
;
79 VclPtr
<InspectorHelpWindow
> m_pHelpWindow
;
80 ListBoxLines m_aLines
;
81 IPropertyLineListener
* m_pLineListener
;
82 IPropertyControlObserver
* m_pControlObserver
;
84 long m_nCurrentPreferredHelpHeight
;
85 css::uno::Reference
< css::inspection::XPropertyControl
>
87 sal_uInt16 m_nTheNameSize
;
89 std::set
<ListBoxLines::size_type
> m_aOutOfDateLines
;
92 ::rtl::Reference
< PropertyControlContext_Impl
>
93 m_pControlContextImpl
;
95 void PositionLine( ListBoxLines::size_type _nIndex
);
96 void UpdatePosNSize();
97 void UpdatePlayGround();
99 void ShowEntry(sal_uInt16 nPos
);
100 void MoveThumbTo(sal_Int32 nNewThumbPos
);
101 void Resize() override
;
104 explicit OBrowserListBox( vcl::Window
* pParent
);
106 virtual ~OBrowserListBox() override
;
107 virtual void dispose() override
;
109 void ActivateListBox( bool _bActive
);
111 sal_uInt16
CalcVisibleLines();
113 void DisableUpdate();
114 bool EventNotify( NotifyEvent
& _rNEvt
) override
;
115 virtual bool PreNotify( NotifyEvent
& _rNEvt
) override
;
117 void SetListener( IPropertyLineListener
* _pListener
);
118 void SetObserver( IPropertyControlObserver
* _pObserver
);
120 void EnableHelpSection( bool _bEnable
);
121 bool HasHelpSection() const;
122 void SetHelpText( const OUString
& _rHelpText
);
123 void SetHelpLineLimites( sal_Int32 _nMinLines
, sal_Int32 _nMaxLines
);
127 void InsertEntry( const OLineDescriptor
&, sal_uInt16 nPos
);
128 bool RemoveEntry( const OUString
& _rName
);
129 void ChangeEntry( const OLineDescriptor
&, ListBoxLines::size_type nPos
);
131 void SetPropertyValue( const OUString
& rEntryName
, const css::uno::Any
& rValue
, bool _bUnknownValue
);
132 sal_uInt16
GetPropertyPos( const OUString
& rEntryName
) const;
133 css::uno::Reference
< css::inspection::XPropertyControl
>
134 GetPropertyControl( const OUString
& rEntryName
);
135 void EnablePropertyControls( const OUString
& _rEntryName
, sal_Int16 _nControls
, bool _bEnable
);
136 void EnablePropertyLine( const OUString
& _rEntryName
, bool _bEnable
);
138 sal_Int32
GetMinimumWidth();
139 sal_Int32
GetMinimumHeight();
142 bool IsModified( ) const;
143 void CommitModified( );
145 /// @throws css::uno::RuntimeException
146 void focusGained( const css::uno::Reference
< css::inspection::XPropertyControl
>& Control
);
147 /// @throws css::uno::RuntimeException
148 void valueChanged( const css::uno::Reference
< css::inspection::XPropertyControl
>& Control
);
149 /// @throws css::uno::RuntimeException
150 void activateNextControl( const css::uno::Reference
< css::inspection::XPropertyControl
>& CurrentControl
);
153 // IButtonClickListener
154 void buttonClicked( OBrowserLine
* _pLine
, bool _bPrimary
) override
;
156 using Window::SetHelpText
;
158 DECL_LINK( ScrollHdl
, ScrollBar
*, void );
160 /** retrieves the index of a given control in our line list
162 The control to lookup. Must denote a control of one of the lines in ->m_aLines
164 sal_uInt16
impl_getControlPos( const css::uno::Reference
< css::inspection::XPropertyControl
>& _rxControl
) const;
166 /** sets the given property value at the given control, after converting it as necessary
168 The line whose at which the value is to be set.
169 @param _rPropertyValue
170 the property value to set. If it's not compatible with the control value,
171 it will be converted, using <member>XPropertyHandler::convertToControlValue</member>
173 static void impl_setControlAsPropertyValue( const ListBoxLine
& _rLine
, const css::uno::Any
& _rPropertyValue
);
175 /** retrieves the value for the given control, as a property value, after converting it as necessary
177 The line whose at which the value is to be set.
180 impl_getControlAsPropertyValue( const ListBoxLine
& _rLine
);
182 /** retrieves the ->BrowserLinePointer for a given entry name
184 the name whose line is to be looked up
186 contains, upon return, the found browser line, if any
188 <TRUE/> if and only if a non-<NULL/> line for the given entry name could be
191 bool impl_getBrowserLineForName( const OUString
& _rEntryName
, BrowserLinePointer
& _out_rpLine
) const;
193 /** returns the preferred height (in pixels) of the help section, or 0 if we
194 currently don't have a help section
196 long impl_getPrefererredHelpHeight();
198 using Window::Activate
;
205 #endif // INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_BROWSERLISTBOX_HXX
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */