28#include <com/sun/star/lang/DisposedException.hpp>
29#include <com/sun/star/lang/XComponent.hpp>
30#include <com/sun/star/inspection/PropertyControlType.hpp>
36#include <osl/mutex.hxx>
41 using ::com::sun::star::uno::Any;
42 using ::com::sun::star::uno::Exception;
43 using ::com::sun::star::inspection::XPropertyControlContext;
44 using ::com::sun::star::uno::Reference;
45 using ::com::sun::star::inspection::XPropertyControl;
46 using ::com::sun::star::lang::DisposedException;
47 using ::com::sun::star::lang::XComponent;
48 using ::com::sun::star::uno::UNO_QUERY;
50 namespace PropertyControlType = ::com::sun::star::inspection::PropertyControlType;
63 Reference< XPropertyControl > xControl;
64 ControlEventType
eType;
66 ControlEvent(
const Reference< XPropertyControl >& _rxControl, ControlEventType _eType )
67 :xControl( _rxControl )
77 static ::rtl::Reference< ::comphelper::AsyncEventNotifier > s_pNotifier;
80 SharedNotifier(
const SharedNotifier&) =
delete;
81 SharedNotifier& operator=(
const SharedNotifier&) =
delete;
82 static const ::rtl::Reference< ::comphelper::AsyncEventNotifier >&
91 ::osl::Mutex& SharedNotifier::getMutex()
93 static ::osl::Mutex s_aMutex;
98 const ::rtl::Reference< ::comphelper::AsyncEventNotifier >& SharedNotifier::getNotifier()
100 ::osl::MutexGuard aGuard(
getMutex() );
101 if ( !s_pNotifier.is() )
104 new ::comphelper::AsyncEventNotifier(
"browserlistbox"));
105 s_pNotifier->launch();
155 virtual void SAL_CALL
acquire() noexcept override;
156 virtual
void SAL_CALL
release() noexcept override;
162 virtual
void SAL_CALL
focusGained( const Reference< XPropertyControl >&
Control ) override;
163 virtual
void SAL_CALL
valueChanged( const Reference< XPropertyControl >&
Control ) override;
165 virtual
void SAL_CALL
activateNextControl( const Reference< XPropertyControl >& CurrentControl ) override;
188 void impl_notify_throw(
const Reference< XPropertyControl >& _rxControl, ControlEventType _eType );
192 : m_pContext( &_rContextImpl )
193 , m_eMode( eAsynchronously )
209 SharedNotifier::getNotifier()->removeEventsForProcessor(
this );
226 throw DisposedException( OUString(), *
this );
227 pEvent =
new ControlEvent( _rxControl, _eType );
236 SharedNotifier::getNotifier()->addEvent( pEvent,
this );
256 PropertyControlContext_Impl_Base::acquire();
261 PropertyControlContext_Impl_Base::release();
284 const ControlEvent& rControlEvent =
static_cast< const ControlEvent&
>( _rEvent );
285 switch ( rControlEvent.eType )
300 : m_xScrolledWindow(rBuilder.weld_scrolled_window(
"scrolledwindow"))
301 , m_xLinesPlayground(rBuilder.weld_container(
"playground"))
302 , m_xSizeGroup(rBuilder.create_size_group())
304 , m_pInitialControlParent(pContainer)
305 , m_pLineListener(nullptr)
306 , m_pControlObserver( nullptr )
316 OSL_ENSURE( !
IsModified(),
"OBrowserListBox::~OBrowserListBox: still modified - should have been committed before!" );
329 bool bModified =
false;
378 OSL_ENSURE(
HasHelpSection(),
"OBrowserListBox::SetHelpText: help section not visible!" );
391 [&_rEntryName](
const ListBoxLine& rLine) { return rLine.aName == _rEntryName; });
395 if ( _bUnknownValue )
397 Reference< XPropertyControl > xControl(
line->pLine->getControl() );
398 OSL_ENSURE( xControl.is(),
"OBrowserListBox::SetPropertyValue: illegal control!" );
400 xControl->setValue(
Any() );
412 if (
line.aName == _rEntryName )
425 [&_rEntryName](
const ListBoxLine& rLine) { return rLine.aName == _rEntryName; });
428 _out_rpLine =
line->pLine;
431 return bool(_out_rpLine);
438 pLine->EnablePropertyControls( _nControls, _bEnable );
445 pLine->EnablePropertyLine( _bEnable );
452 return pLine->getControl();
473 ListBoxLines::size_type nInsertPos =
_nPos;
506 int const nWinTop = nThumbPos;
507 int const nWinBottom = nWinTop + nWinHeight;
511 int const nSelectedItemTop = nCtrlPosY;
512 int const nSelectedItemBottom = nCtrlPosY +
m_nRowHeight;
513 bool const shouldScrollDown = nSelectedItemBottom >= nWinBottom;
514 bool const shouldScrollUp = nSelectedItemTop <= nWinTop;
515 bool const isNeedToScroll = shouldScrollDown || shouldScrollUp;
520 if (shouldScrollDown)
522 int nOffset = nSelectedItemBottom - nWinBottom;
523 nThumbPos += nOffset;
527 int nOffset = nWinTop - nSelectedItemTop;
528 nThumbPos -= nOffset;
537 DBG_ASSERT( _pLine,
"OBrowserListBox::buttonClicked: invalid browser line!" );
546 Reference< XPropertyControl > xControl( _rLine.
pLine->getControl() );
549 if ( _rPropertyValue.getValueType().equals( _rLine.
pLine->getControl()->getValueType() ) )
551 xControl->setValue( _rPropertyValue );
556 "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '"
557 << _rLine.
pLine->GetEntryName() <<
"')!" );
560 Any aControlValue = _rLine.
xHandler->convertToControlValue(
561 _rLine.
pLine->GetEntryName(), _rPropertyValue, xControl->getValueType() );
562 xControl->setValue( aControlValue );
574 Reference< XPropertyControl > xControl( _rLine.
pLine->getControl() );
579 "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '"
580 << _rLine.
pLine->GetEntryName() <<
"')!" );
582 aPropertyValue = _rLine.
xHandler->convertToPropertyValue( _rLine.
pLine->GetEntryName(), xControl->getValue() );
584 aPropertyValue = xControl->getValue();
590 return aPropertyValue;
598 if ( search.pLine->getControl().get() == _rxControl.get() )
602 OSL_FAIL(
"OBrowserListBox::impl_getControlPos: invalid control - not part of any of our lines!" );
603 return sal_uInt16(-1);
611 DBG_ASSERT( _rxControl.is(),
"OBrowserListBox::focusGained: invalid event source!" );
612 if ( !_rxControl.is() )
627 DBG_ASSERT( _rxControl.is(),
"OBrowserListBox::valueChanged: invalid event source!" );
628 if ( !_rxControl.is() )
638 rLine.
pLine->GetEntryName(),
653 while (
static_cast< size_t >( nLine ) <
m_aLines.size() )
655 if (
m_aLines[nLine].pLine->GrabFocus() )
661 if ( (
static_cast< size_t >( nLine ) >=
m_aLines.size() ) && ( !
m_aLines.empty() ) )
669 void lcl_implDisposeControl_nothrow(
const Reference< XPropertyControl >& _rxControl )
671 if ( !_rxControl.is() )
675 _rxControl->setControlContext(
nullptr );
676 Reference< XComponent > xControlComponent( _rxControl, UNO_QUERY );
677 if ( xControlComponent.is() )
678 xControlComponent->dispose();
680 catch(
const Exception& )
694 lcl_implDisposeControl_nothrow(
line.pLine->getControl() );
703 [&_rName](
const ListBoxLine& rLine) { return rLine.aName == _rName; });
715 OSL_PRECOND( rPropertyData.Control.is(),
"OBrowserListBox::ChangeEntry: invalid control!" );
716 if ( !rPropertyData.Control.is() )
729 Reference< XPropertyControl > xControl = rLine.
pLine->getControl();
732 lcl_implDisposeControl_nothrow( xControl );
735 rLine.
pLine->setControl( rPropertyData.Control );
736 xControl = rLine.
pLine->getControl();
743 xControl->setValue(
Any() );
747 rLine.
pLine->SetTitle(rPropertyData.DisplayName);
750 if ( rPropertyData.HasPrimaryButton )
752 if ( !rPropertyData.PrimaryButtonImageURL.isEmpty() )
753 rLine.
pLine->ShowBrowseButton( rPropertyData.PrimaryButtonImageURL,
true );
754 else if ( rPropertyData.PrimaryButtonImage.is() )
755 rLine.
pLine->ShowBrowseButton( rPropertyData.PrimaryButtonImage,
true );
757 rLine.
pLine->ShowBrowseButton(
true );
759 if ( rPropertyData.HasSecondaryButton )
761 if ( !rPropertyData.SecondaryButtonImageURL.isEmpty() )
762 rLine.
pLine->ShowBrowseButton( rPropertyData.SecondaryButtonImageURL,
false );
763 else if ( rPropertyData.SecondaryButtonImage.is() )
764 rLine.
pLine->ShowBrowseButton( rPropertyData.SecondaryButtonImage,
false );
766 rLine.
pLine->ShowBrowseButton(
false );
769 rLine.
pLine->HideBrowseButton(
false );
771 rLine.
pLine->SetClickListener(
this );
775 rLine.
pLine->HideBrowseButton(
true );
776 rLine.
pLine->HideBrowseButton(
false );
779 DBG_ASSERT( ( rPropertyData.IndentLevel == 0 ) || ( rPropertyData.IndentLevel == 1 ),
780 "OBrowserListBox::ChangeEntry: unsupported indent level!" );
781 rLine.
pLine->IndentTitle( rPropertyData.IndentLevel > 0 );
783 rLine.
pLine->SetComponentHelpIds(
789 rLine.
pLine->SetReadOnly(
true );
796 if ( xControl.is() && ( xControl->getControlType() == PropertyControlType::Unknown ) )
800 if (pControlWindowAsEdit)
807 sal_uInt16 nTextWidth =
m_xLinesPlayground->get_pixel_size(rPropertyData.DisplayName).Width();
#define EDITOR_LIST_REPLACE_EXISTING
static OUString getHelpId(std::u16string_view _rHelpURL)
non-UNO version of the XPropertyControlObserver
virtual void valueChanged(const css::uno::Reference< css::inspection::XPropertyControl > &Control)=0
virtual void focusGained(const css::uno::Reference< css::inspection::XPropertyControl > &Control)=0
virtual void Clicked(const OUString &_rName, bool _bPrimary)=0
virtual void Commit(const OUString &_rName, const css::uno::Any &_rVal)=0
const OUString & GetEntryName() const
std::unique_ptr< weld::Container > m_xLinesPlayground
void focusGained(const css::uno::Reference< css::inspection::XPropertyControl > &Control)
std::unique_ptr< weld::SizeGroup > m_xSizeGroup
void ChangeEntry(const OLineDescriptor &, ListBoxLines::size_type nPos)
static void impl_setControlAsPropertyValue(const ListBoxLine &_rLine, const css::uno::Any &_rPropertyValue)
sets the given property value at the given control, after converting it as necessary
IPropertyLineListener * m_pLineListener
void EnablePropertyControls(const OUString &_rEntryName, sal_Int16 _nControls, bool _bEnable)
void activateNextControl(const css::uno::Reference< css::inspection::XPropertyControl > &CurrentControl)
std::unique_ptr< InspectorHelpWindow > m_xHelpWindow
bool RemoveEntry(const OUString &_rName)
css::uno::Reference< css::inspection::XPropertyControl > GetPropertyControl(const OUString &rEntryName)
IPropertyControlObserver * m_pControlObserver
css::uno::Reference< css::inspection::XPropertyControl > m_xActiveControl
std::unique_ptr< weld::ScrolledWindow > m_xScrolledWindow
sal_uInt16 GetPropertyPos(std::u16string_view rEntryName) const
OBrowserListBox(weld::Builder &rBuilder, weld::Container *pContainer)
void SetPropertyValue(const OUString &rEntryName, const css::uno::Any &rValue, bool _bUnknownValue)
sal_uInt16 m_nTheNameSize
static css::uno::Any impl_getControlAsPropertyValue(const ListBoxLine &_rLine)
retrieves the value for the given control, as a property value, after converting it as necessary
void EnableHelpSection(bool _bEnable)
weld::Container * m_pInitialControlParent
sal_uInt16 impl_getControlPos(const css::uno::Reference< css::inspection::XPropertyControl > &_rxControl) const
retrieves the index of a given control in our line list
void valueChanged(const css::uno::Reference< css::inspection::XPropertyControl > &Control)
bool HasHelpSection() const
void EnablePropertyLine(const OUString &_rEntryName, bool _bEnable)
void SetObserver(IPropertyControlObserver *_pObserver)
void SetHelpText(const OUString &_rHelpText)
void buttonClicked(OBrowserLine *_pLine, bool _bPrimary) override
void InsertEntry(const OLineDescriptor &, sal_uInt16 nPos)
::rtl::Reference< PropertyControlContext_Impl > m_pControlContextImpl
void SetListener(IPropertyLineListener *_pListener)
void ShowEntry(sal_uInt16 nPos)
bool impl_getBrowserLineForName(const OUString &_rEntryName, BrowserLinePointer &_out_rpLine) const
retrieves the ->BrowserLinePointer for a given entry name
void setNotificationMode(NotificationMode _eMode)
sets the notification mode, so that notifications received from the controls are forwarded to our OBr...
virtual ~PropertyControlContext_Impl() override
virtual void SAL_CALL valueChanged(const Reference< XPropertyControl > &Control) override
virtual void SAL_CALL acquire() noexcept override
virtual void processEvent(const ::comphelper::AnyEvent &_rEvent) override
virtual void SAL_CALL activateNextControl(const Reference< XPropertyControl > &CurrentControl) override
virtual void SAL_CALL release() noexcept override
OBrowserListBox * m_pContext
void impl_notify_throw(const Reference< XPropertyControl > &_rxControl, ControlEventType _eType)
notifies the given event originating from the given control
virtual void SAL_CALL focusGained(const Reference< XPropertyControl > &Control) override
void impl_processEvent_throw(const ::comphelper::AnyEvent &_rEvent)
processes the given event, i.e.
bool impl_isDisposed_nothrow() const
checks whether the instance is already disposed
PropertyControlContext_Impl(OBrowserListBox &_rContextImpl)
creates an instance
void dispose()
disposes the context.
virtual void set_editable(bool bEditable)=0
#define DBG_ASSERT(sCon, aError)
#define DBG_TESTSOLARMUTEX()
#define DBG_UNHANDLED_EXCEPTION(...)
#define SAL_WARN_IF(condition, area, stream)
::osl::Mutex & getMutex()
a property handler for any virtual string properties
::cppu::WeakImplHelper< XPropertyControlContext > PropertyControlContext_Impl_Base
implementation for of <type scope="css::inspection">XPropertyControlContext</type> which forwards all...
void clearContainer(CONTAINER &_rContainer)
std::shared_ptr< OBrowserLine > BrowserLinePointer
#define EDITOR_LIST_ENTRY_NOTFOUND
css::uno::Reference< css::inspection::XPropertyHandler > xHandler
css::uno::Reference< css::inspection::XPropertyHandler > xPropertyHandler