LibreOffice Module extensions (master) 1
browserlistbox.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include "browserlistbox.hxx"
21#include "pcrcommon.hxx"
22#include "proplinelistener.hxx"
24#include "linedescriptor.hxx"
26
27#include <sal/log.hxx>
28#include <com/sun/star/lang/DisposedException.hpp>
29#include <com/sun/star/lang/XComponent.hpp>
30#include <com/sun/star/inspection/PropertyControlType.hpp>
31#include <tools/debug.hxx>
35#include <vcl/svapp.hxx>
36#include <osl/mutex.hxx>
37
38
39namespace pcr
40{
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;
49
50 namespace PropertyControlType = ::com::sun::star::inspection::PropertyControlType;
51
52 namespace {
53
54 enum ControlEventType
55 {
56 FOCUS_GAINED,
57 VALUE_CHANGED,
58 ACTIVATE_NEXT
59 };
60
61 struct ControlEvent : public ::comphelper::AnyEvent
62 {
63 Reference< XPropertyControl > xControl;
64 ControlEventType eType;
65
66 ControlEvent( const Reference< XPropertyControl >& _rxControl, ControlEventType _eType )
67 :xControl( _rxControl )
68 ,eType( _eType )
69 {
70 }
71 };
72
73 class SharedNotifier
74 {
75 private:
76 static ::osl::Mutex& getMutex();
77 static ::rtl::Reference< ::comphelper::AsyncEventNotifier > s_pNotifier;
78
79 public:
80 SharedNotifier(const SharedNotifier&) = delete;
81 SharedNotifier& operator=(const SharedNotifier&) = delete;
82 static const ::rtl::Reference< ::comphelper::AsyncEventNotifier >&
83 getNotifier();
84 };
85
86 }
87
89
90
91 ::osl::Mutex& SharedNotifier::getMutex()
92 {
93 static ::osl::Mutex s_aMutex;
94 return s_aMutex;
95 }
96
97
98 const ::rtl::Reference< ::comphelper::AsyncEventNotifier >& SharedNotifier::getNotifier()
99 {
100 ::osl::MutexGuard aGuard( getMutex() );
101 if ( !s_pNotifier.is() )
102 {
103 s_pNotifier.set(
104 new ::comphelper::AsyncEventNotifier("browserlistbox"));
105 s_pNotifier->launch();
106 //TODO: a protocol is missing how to join with the launched
107 // thread before exit(3), to ensure the thread is no longer
108 // relying on any infrastructure while that infrastructure is
109 // being shut down in atexit handlers
110 }
111 return s_pNotifier;
112 }
113
114
118 typedef ::cppu::WeakImplHelper< XPropertyControlContext > PropertyControlContext_Impl_Base;
121 {
122 public:
124 {
127 };
128
129 private:
132
133 public:
138 explicit PropertyControlContext_Impl( OBrowserListBox& _rContextImpl );
139
146 void dispose();
147
154
155 virtual void SAL_CALL acquire() noexcept override;
156 virtual void SAL_CALL release() noexcept override;
157
158 protected:
159 virtual ~PropertyControlContext_Impl() override;
160
161 // XPropertyControlObserver
162 virtual void SAL_CALL focusGained( const Reference< XPropertyControl >& Control ) override;
163 virtual void SAL_CALL valueChanged( const Reference< XPropertyControl >& Control ) override;
164 // XPropertyControlContext
165 virtual void SAL_CALL activateNextControl( const Reference< XPropertyControl >& CurrentControl ) override;
166
167 // IEventProcessor
168 virtual void processEvent( const ::comphelper::AnyEvent& _rEvent ) override;
169
170 private:
177 void impl_processEvent_throw( const ::comphelper::AnyEvent& _rEvent );
178
181 bool impl_isDisposed_nothrow() const { return m_pContext == nullptr; }
182
188 void impl_notify_throw( const Reference< XPropertyControl >& _rxControl, ControlEventType _eType );
189 };
190
192 : m_pContext( &_rContextImpl )
193 , m_eMode( eAsynchronously )
194 {
195 }
196
198 {
200 dispose();
201 }
202
204 {
205 SolarMutexGuard aGuard;
207 return;
208
209 SharedNotifier::getNotifier()->removeEventsForProcessor( this );
210 m_pContext = nullptr;
211 }
212
214 {
215 SolarMutexGuard aGuard;
216 m_eMode = _eMode;
217 }
218
219 void PropertyControlContext_Impl::impl_notify_throw( const Reference< XPropertyControl >& _rxControl, ControlEventType _eType )
220 {
222
223 {
224 SolarMutexGuard aGuard;
226 throw DisposedException( OUString(), *this );
227 pEvent = new ControlEvent( _rxControl, _eType );
228
229 if ( m_eMode == eSynchronously )
230 {
231 impl_processEvent_throw( *pEvent );
232 return;
233 }
234 }
235
236 SharedNotifier::getNotifier()->addEvent( pEvent, this );
237 }
238
239 void SAL_CALL PropertyControlContext_Impl::focusGained( const Reference< XPropertyControl >& Control )
240 {
241 impl_notify_throw( Control, FOCUS_GAINED );
242 }
243
244 void SAL_CALL PropertyControlContext_Impl::valueChanged( const Reference< XPropertyControl >& Control )
245 {
246 impl_notify_throw( Control, VALUE_CHANGED );
247 }
248
249 void SAL_CALL PropertyControlContext_Impl::activateNextControl( const Reference< XPropertyControl >& CurrentControl )
250 {
251 impl_notify_throw( CurrentControl, ACTIVATE_NEXT );
252 }
253
255 {
256 PropertyControlContext_Impl_Base::acquire();
257 }
258
260 {
261 PropertyControlContext_Impl_Base::release();
262 }
263
264 void PropertyControlContext_Impl::processEvent( const ::comphelper::AnyEvent& _rEvent )
265 {
266 SolarMutexGuard aGuard;
268 return;
269
270 try
271 {
272 impl_processEvent_throw( _rEvent );
273 }
274 catch( const Exception& )
275 {
276 // can't handle otherwise, since our caller (the notification thread) does not allow
277 // for exceptions (it could itself abort only)
278 DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
279 }
280 }
281
282 void PropertyControlContext_Impl::impl_processEvent_throw( const ::comphelper::AnyEvent& _rEvent )
283 {
284 const ControlEvent& rControlEvent = static_cast< const ControlEvent& >( _rEvent );
285 switch ( rControlEvent.eType )
286 {
287 case FOCUS_GAINED:
288 m_pContext->focusGained( rControlEvent.xControl );
289 break;
290 case VALUE_CHANGED:
291 m_pContext->valueChanged( rControlEvent.xControl );
292 break;
293 case ACTIVATE_NEXT:
294 m_pContext->activateNextControl( rControlEvent.xControl );
295 break;
296 }
297 }
298
300 : m_xScrolledWindow(rBuilder.weld_scrolled_window("scrolledwindow"))
301 , m_xLinesPlayground(rBuilder.weld_container("playground"))
302 , m_xSizeGroup(rBuilder.create_size_group())
303 , m_xHelpWindow(new InspectorHelpWindow(rBuilder))
304 , m_pInitialControlParent(pContainer)
305 , m_pLineListener(nullptr)
306 , m_pControlObserver( nullptr )
307 , m_nTheNameSize(0)
308 , m_nRowHeight(0)
309 , m_pControlContextImpl( new PropertyControlContext_Impl( *this ) )
310 {
311 m_xScrolledWindow->set_size_request(-1, m_xScrolledWindow->get_text_height() * 20);
312 }
313
315 {
316 OSL_ENSURE( !IsModified(), "OBrowserListBox::~OBrowserListBox: still modified - should have been committed before!" );
317
318 // doing the commit here, while we, as well as our owner, as well as some other components,
319 // are already "half dead" (means within their dtor) is potentially dangerous.
320 // By definition, CommitModified has to be called (if necessary) before destruction
321 m_pControlContextImpl->dispose();
322 m_pControlContextImpl.clear();
323
324 Clear();
325 }
326
328 {
329 bool bModified = false;
330
331 if (m_xScrolledWindow->get_visible() && m_xActiveControl.is())
332 bModified = m_xActiveControl->isModified();
333
334 return bModified;
335 }
336
338 {
339 if ( !(IsModified() && m_xActiveControl.is()) )
340 return;
341
342 // for the time of this commit, notify all events synchronously
343 // #i63814#
345 try
346 {
347 m_xActiveControl->notifyModifiedValue();
348 }
349 catch( const Exception& )
350 {
351 DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
352 }
354 }
355
357 {
358 m_pLineListener = _pListener;
359 }
360
362 {
363 m_pControlObserver = _pObserver;
364 }
365
367 {
368 m_xHelpWindow->Show( _bEnable );
369 }
370
372 {
373 return m_xHelpWindow->IsVisible();
374 }
375
376 void OBrowserListBox::SetHelpText( const OUString& _rHelpText )
377 {
378 OSL_ENSURE( HasHelpSection(), "OBrowserListBox::SetHelpText: help section not visible!" );
379 m_xHelpWindow->SetText( _rHelpText );
380 }
381
383 {
384 for (auto& line : m_aLines)
385 line.pLine->SetTitleWidth(m_nTheNameSize);
386 }
387
388 void OBrowserListBox::SetPropertyValue(const OUString& _rEntryName, const Any& _rValue, bool _bUnknownValue )
389 {
390 ListBoxLines::iterator line = std::find_if(m_aLines.begin(), m_aLines.end(),
391 [&_rEntryName](const ListBoxLine& rLine) { return rLine.aName == _rEntryName; });
392
393 if ( line != m_aLines.end() )
394 {
395 if ( _bUnknownValue )
396 {
397 Reference< XPropertyControl > xControl( line->pLine->getControl() );
398 OSL_ENSURE( xControl.is(), "OBrowserListBox::SetPropertyValue: illegal control!" );
399 if ( xControl.is() )
400 xControl->setValue( Any() );
401 }
402 else
404 }
405 }
406
407 sal_uInt16 OBrowserListBox::GetPropertyPos( std::u16string_view _rEntryName ) const
408 {
409 sal_uInt16 nPos = 0;
410 for (auto const& line : m_aLines)
411 {
412 if ( line.aName == _rEntryName )
413 {
414 return nPos;
415 }
416 ++nPos;
417 }
418
420 }
421
422 bool OBrowserListBox::impl_getBrowserLineForName( const OUString& _rEntryName, BrowserLinePointer& _out_rpLine ) const
423 {
424 ListBoxLines::const_iterator line = std::find_if(m_aLines.begin(), m_aLines.end(),
425 [&_rEntryName](const ListBoxLine& rLine) { return rLine.aName == _rEntryName; });
426
427 if ( line != m_aLines.end() )
428 _out_rpLine = line->pLine;
429 else
430 _out_rpLine.reset();
431 return bool(_out_rpLine);
432 }
433
434 void OBrowserListBox::EnablePropertyControls( const OUString& _rEntryName, sal_Int16 _nControls, bool _bEnable )
435 {
436 BrowserLinePointer pLine;
437 if ( impl_getBrowserLineForName( _rEntryName, pLine ) )
438 pLine->EnablePropertyControls( _nControls, _bEnable );
439 }
440
441 void OBrowserListBox::EnablePropertyLine( const OUString& _rEntryName, bool _bEnable )
442 {
443 BrowserLinePointer pLine;
444 if ( impl_getBrowserLineForName( _rEntryName, pLine ) )
445 pLine->EnablePropertyLine( _bEnable );
446 }
447
448 Reference< XPropertyControl > OBrowserListBox::GetPropertyControl( const OUString& _rEntryName )
449 {
450 BrowserLinePointer pLine;
451 if ( impl_getBrowserLineForName( _rEntryName, pLine ) )
452 return pLine->getControl();
453 return nullptr;
454 }
455
456 void OBrowserListBox::InsertEntry(const OLineDescriptor& rPropertyData, sal_uInt16 _nPos)
457 {
458 // create a new line
459 BrowserLinePointer pBrowserLine = std::make_shared<OBrowserLine>(rPropertyData.sName, m_xLinesPlayground.get(),
461
462 // check that the name is unique
463 for (auto const& line : m_aLines)
464 {
465 if (line.aName == rPropertyData.sName)
466 {
467 // already have another line for this name!
468 assert(false);
469 }
470 }
471
472 ListBoxLine aNewLine( rPropertyData.sName, pBrowserLine, rPropertyData.xPropertyHandler );
473 ListBoxLines::size_type nInsertPos = _nPos;
474 if ( _nPos >= m_aLines.size() )
475 {
476 nInsertPos = m_aLines.size();
477 m_aLines.push_back( aNewLine );
478 }
479 else
480 m_aLines.insert( m_aLines.begin() + _nPos, aNewLine );
481
482 pBrowserLine->SetTitleWidth(m_nTheNameSize);
483
484 // initialize the entry
485 ChangeEntry(rPropertyData, nInsertPos);
486
487 m_nRowHeight = std::max(m_nRowHeight, pBrowserLine->GetRowHeight() + 6); // 6 is spacing of the "playground" in browserpage.ui
488 m_xScrolledWindow->vadjustment_set_step_increment(m_nRowHeight);
489 }
490
491 void OBrowserListBox::ShowEntry(sal_uInt16 nPos)
492 {
493 if (nPos == 0)
494 {
495 // special case the simple entry 0 situation
496 m_xScrolledWindow->vadjustment_set_value(0);
497 return;
498 }
499
500 if (nPos >= m_aLines.size())
501 return;
502
503 unsigned const nWinHeight = m_xScrolledWindow->vadjustment_get_page_size();
504
505 auto nThumbPos = m_xScrolledWindow->vadjustment_get_value();
506 int const nWinTop = nThumbPos;
507 int const nWinBottom = nWinTop + nWinHeight;
508
509 auto nCtrlPosY = nPos * m_nRowHeight;
510
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;
516
517 if (!isNeedToScroll)
518 return;
519
520 if (shouldScrollDown)
521 {
522 int nOffset = nSelectedItemBottom - nWinBottom;
523 nThumbPos += nOffset;
524 }
525 else
526 {
527 int nOffset = nWinTop - nSelectedItemTop;
528 nThumbPos -= nOffset;
529 if(nThumbPos < 0)
530 nThumbPos = 0;
531 }
532 m_xScrolledWindow->vadjustment_set_value(nThumbPos);
533 }
534
535 void OBrowserListBox::buttonClicked( OBrowserLine* _pLine, bool _bPrimary )
536 {
537 DBG_ASSERT( _pLine, "OBrowserListBox::buttonClicked: invalid browser line!" );
538 if ( _pLine && m_pLineListener )
539 {
540 m_pLineListener->Clicked( _pLine->GetEntryName(), _bPrimary );
541 }
542 }
543
544 void OBrowserListBox::impl_setControlAsPropertyValue( const ListBoxLine& _rLine, const Any& _rPropertyValue )
545 {
546 Reference< XPropertyControl > xControl( _rLine.pLine->getControl() );
547 try
548 {
549 if ( _rPropertyValue.getValueType().equals( _rLine.pLine->getControl()->getValueType() ) )
550 {
551 xControl->setValue( _rPropertyValue );
552 }
553 else
554 {
555 SAL_WARN_IF( !_rLine.xHandler.is(), "extensions.propctrlr",
556 "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '"
557 << _rLine.pLine->GetEntryName() << "')!" );
558 if ( _rLine.xHandler.is() )
559 {
560 Any aControlValue = _rLine.xHandler->convertToControlValue(
561 _rLine.pLine->GetEntryName(), _rPropertyValue, xControl->getValueType() );
562 xControl->setValue( aControlValue );
563 }
564 }
565 }
566 catch( const Exception& )
567 {
568 DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
569 }
570 }
571
573 {
574 Reference< XPropertyControl > xControl( _rLine.pLine->getControl() );
575 Any aPropertyValue;
576 try
577 {
578 SAL_WARN_IF( !_rLine.xHandler.is(), "extensions.propctrlr",
579 "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '"
580 << _rLine.pLine->GetEntryName() << "')!" );
581 if ( _rLine.xHandler.is() )
582 aPropertyValue = _rLine.xHandler->convertToPropertyValue( _rLine.pLine->GetEntryName(), xControl->getValue() );
583 else
584 aPropertyValue = xControl->getValue();
585 }
586 catch( const Exception& )
587 {
588 DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
589 }
590 return aPropertyValue;
591 }
592
593 sal_uInt16 OBrowserListBox::impl_getControlPos( const Reference< XPropertyControl >& _rxControl ) const
594 {
595 sal_uInt16 nPos = 0;
596 for (auto const& search : m_aLines)
597 {
598 if ( search.pLine->getControl().get() == _rxControl.get() )
599 return nPos;
600 ++nPos;
601 }
602 OSL_FAIL( "OBrowserListBox::impl_getControlPos: invalid control - not part of any of our lines!" );
603 return sal_uInt16(-1);
604 }
605
606
607 void OBrowserListBox::focusGained( const Reference< XPropertyControl >& _rxControl )
608 {
610
611 DBG_ASSERT( _rxControl.is(), "OBrowserListBox::focusGained: invalid event source!" );
612 if ( !_rxControl.is() )
613 return;
614
615 if ( m_pControlObserver )
616 m_pControlObserver->focusGained( _rxControl );
617
618 m_xActiveControl = _rxControl;
620 }
621
622
623 void OBrowserListBox::valueChanged( const Reference< XPropertyControl >& _rxControl )
624 {
626
627 DBG_ASSERT( _rxControl.is(), "OBrowserListBox::valueChanged: invalid event source!" );
628 if ( !_rxControl.is() )
629 return;
630
631 if ( m_pControlObserver )
632 m_pControlObserver->valueChanged( _rxControl );
633
634 if ( m_pLineListener )
635 {
636 const ListBoxLine& rLine = m_aLines[ impl_getControlPos( _rxControl ) ];
638 rLine.pLine->GetEntryName(),
640 );
641 }
642 }
643
644
645 void OBrowserListBox::activateNextControl( const Reference< XPropertyControl >& _rxCurrentControl )
646 {
648
649 sal_uInt16 nLine = impl_getControlPos( _rxCurrentControl );
650
651 // cycle forwards, 'til we've the next control which can grab the focus
652 ++nLine;
653 while ( static_cast< size_t >( nLine ) < m_aLines.size() )
654 {
655 if ( m_aLines[nLine].pLine->GrabFocus() )
656 break;
657 ++nLine;
658 }
659
660 // wrap around?
661 if ( ( static_cast< size_t >( nLine ) >= m_aLines.size() ) && ( !m_aLines.empty() ) )
662 m_aLines[0].pLine->GrabFocus();
663 }
664
665
666 namespace
667 {
668
669 void lcl_implDisposeControl_nothrow( const Reference< XPropertyControl >& _rxControl )
670 {
671 if ( !_rxControl.is() )
672 return;
673 try
674 {
675 _rxControl->setControlContext( nullptr );
676 Reference< XComponent > xControlComponent( _rxControl, UNO_QUERY );
677 if ( xControlComponent.is() )
678 xControlComponent->dispose();
679 }
680 catch( const Exception& )
681 {
682 DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
683 }
684 }
685 }
686
688 {
689 for (auto const& line : m_aLines)
690 {
691 // hide the line
692 line.pLine->Hide();
693 // reset the listener
694 lcl_implDisposeControl_nothrow( line.pLine->getControl() );
695 }
696
698 }
699
700 bool OBrowserListBox::RemoveEntry( const OUString& _rName )
701 {
702 ListBoxLines::iterator it = std::find_if(m_aLines.begin(), m_aLines.end(),
703 [&_rName](const ListBoxLine& rLine) { return rLine.aName == _rName; });
704
705 if ( it == m_aLines.end() )
706 return false;
707
708 m_aLines.erase( it );
709
710 return true;
711 }
712
713 void OBrowserListBox::ChangeEntry( const OLineDescriptor& rPropertyData, ListBoxLines::size_type nPos )
714 {
715 OSL_PRECOND( rPropertyData.Control.is(), "OBrowserListBox::ChangeEntry: invalid control!" );
716 if ( !rPropertyData.Control.is() )
717 return;
718
720 nPos = GetPropertyPos( rPropertyData.sName );
721
722 if ( nPos >= m_aLines.size() )
723 return;
724
725 // the current line and control
726 ListBoxLine& rLine = m_aLines[nPos];
727
728 // the old control and some data about it
729 Reference< XPropertyControl > xControl = rLine.pLine->getControl();
730
731 // clean up the old control
732 lcl_implDisposeControl_nothrow( xControl );
733
734 // set the new control at the line
735 rLine.pLine->setControl( rPropertyData.Control );
736 xControl = rLine.pLine->getControl();
737
738 if ( xControl.is() )
739 xControl->setControlContext( m_pControlContextImpl );
740
741 // the initial property value
742 if ( rPropertyData.bUnknownValue )
743 xControl->setValue( Any() );
744 else
745 impl_setControlAsPropertyValue( rLine, rPropertyData.aValue );
746
747 rLine.pLine->SetTitle(rPropertyData.DisplayName);
748 rLine.xHandler = rPropertyData.xPropertyHandler;
749
750 if ( rPropertyData.HasPrimaryButton )
751 {
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 );
756 else
757 rLine.pLine->ShowBrowseButton( true );
758
759 if ( rPropertyData.HasSecondaryButton )
760 {
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 );
765 else
766 rLine.pLine->ShowBrowseButton( false );
767 }
768 else
769 rLine.pLine->HideBrowseButton( false );
770
771 rLine.pLine->SetClickListener( this );
772 }
773 else
774 {
775 rLine.pLine->HideBrowseButton( true );
776 rLine.pLine->HideBrowseButton( false );
777 }
778
779 DBG_ASSERT( ( rPropertyData.IndentLevel == 0 ) || ( rPropertyData.IndentLevel == 1 ),
780 "OBrowserListBox::ChangeEntry: unsupported indent level!" );
781 rLine.pLine->IndentTitle( rPropertyData.IndentLevel > 0 );
782
783 rLine.pLine->SetComponentHelpIds(
784 HelpIdUrl::getHelpId( rPropertyData.HelpURL )
785 );
786
787 if ( rPropertyData.bReadOnly )
788 {
789 rLine.pLine->SetReadOnly( true );
790
791 // user controls (i.e. the ones not provided by the usual
792 // XPropertyControlFactory) have no chance to know that they should be read-only,
793 // since XPropertyHandler::describePropertyLine does not transport this
794 // information.
795 // So, we manually switch this to read-only.
796 if ( xControl.is() && ( xControl->getControlType() == PropertyControlType::Unknown ) )
797 {
798 weld::Widget* pWindow = rLine.pLine->getControlWindow();
799 weld::Entry* pControlWindowAsEdit = dynamic_cast<weld::Entry*>(pWindow);
800 if (pControlWindowAsEdit)
801 pControlWindowAsEdit->set_editable(false);
802 else
803 pWindow->set_sensitive(false);
804 }
805 }
806
807 sal_uInt16 nTextWidth = m_xLinesPlayground->get_pixel_size(rPropertyData.DisplayName).Width();
808 if (m_nTheNameSize< nTextWidth)
809 {
810 m_nTheNameSize = nTextWidth;
812 }
813 }
814} // namespace pcr
815
816
817/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define EDITOR_LIST_REPLACE_EXISTING
static OUString getHelpId(std::u16string_view _rHelpURL)
Definition: pcrcommon.cxx:37
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
Definition: browserline.hxx:85
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)
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
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
virtual void set_sensitive(bool sensitive)=0
#define DBG_ASSERT(sCon, aError)
#define DBG_TESTSOLARMUTEX()
#define DBG_UNHANDLED_EXCEPTION(...)
DocumentType eType
sal_uInt16 nPos
#define SAL_WARN_IF(condition, area, stream)
@ Exception
::osl::Mutex & getMutex()
line
a property handler for any virtual string properties
Definition: browserline.cxx:39
::cppu::WeakImplHelper< XPropertyControlContext > PropertyControlContext_Impl_Base
implementation for of <type scope="css::inspection">XPropertyControlContext</type> which forwards all...
void clearContainer(CONTAINER &_rContainer)
Definition: pcrcommon.hxx:54
std::shared_ptr< OBrowserLine > BrowserLinePointer
#define EDITOR_LIST_ENTRY_NOTFOUND
Definition: pcrcommon.hxx:23
css::uno::Reference< css::inspection::XPropertyHandler > xHandler
BrowserLinePointer pLine
css::uno::Reference< css::inspection::XPropertyHandler > xPropertyHandler
sal_Int32 _nPos