Bug Summary

File:home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx
Warning:line 803, column 21
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name browserlistbox.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/extensions/inc -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx

/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx

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"
23#include "propcontrolobserver.hxx"
24#include "linedescriptor.hxx"
25#include "inspectorhelpwindow.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>
32#include <tools/diagnose_ex.h>
33#include <comphelper/asyncnotification.hxx>
34#include <cppuhelper/implbase.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
88 ::rtl::Reference< ::comphelper::AsyncEventNotifier > SharedNotifier::s_pNotifier;
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
115 /** implementation for of <type scope="css::inspection">XPropertyControlContext</type>
116 which forwards all events to a non-UNO version of this interface
117 */
118 typedef ::cppu::WeakImplHelper< XPropertyControlContext > PropertyControlContext_Impl_Base;
119 class PropertyControlContext_Impl :public PropertyControlContext_Impl_Base
120 ,public ::comphelper::IEventProcessor
121 {
122 public:
123 enum NotificationMode
124 {
125 eSynchronously,
126 eAsynchronously
127 };
128
129 private:
130 OBrowserListBox* m_pContext;
131 NotificationMode m_eMode;
132
133 public:
134 /** creates an instance
135 @param _rContextImpl
136 the instance to delegate events to
137 */
138 explicit PropertyControlContext_Impl( OBrowserListBox& _rContextImpl );
139
140 /** disposes the context.
141
142 When you call this method, all subsequent callbacks to the
143 <type scope="css::inspection">XPropertyControlContext</type> methods
144 will throw a <type scope="css::lang">DisposedException</type>.
145 */
146 void dispose();
147
148 /** sets the notification mode, so that notifications received from the controls are
149 forwarded to our OBrowserListBox either synchronously or asynchronously
150 @param _eMode
151 the new notification mode
152 */
153 void setNotificationMode( NotificationMode _eMode );
154
155 virtual void SAL_CALL acquire() throw() override;
156 virtual void SAL_CALL release() throw() 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:
171 /** processes the given event, i.e. notifies it to our OBrowserListBox
172 @param _rEvent
173 the event no notify
174 @precond
175 our mutex (well, the SolarMutex) is locked
176 */
177 void impl_processEvent_throw( const ::comphelper::AnyEvent& _rEvent );
178
179 /** checks whether the instance is already disposed
180 */
181 bool impl_isDisposed_nothrow() const { return m_pContext == nullptr; }
182
183 /** notifies the given event originating from the given control
184 @throws DisposedException
185 @param _rxControl
186 @param _eType
187 */
188 void impl_notify_throw( const Reference< XPropertyControl >& _rxControl, ControlEventType _eType );
189 };
190
191 PropertyControlContext_Impl::PropertyControlContext_Impl( OBrowserListBox& _rContextImpl )
192 : m_pContext( &_rContextImpl )
193 , m_eMode( eAsynchronously )
194 {
195 }
196
197 PropertyControlContext_Impl::~PropertyControlContext_Impl()
198 {
199 if ( !impl_isDisposed_nothrow() )
200 dispose();
201 }
202
203 void PropertyControlContext_Impl::dispose()
204 {
205 SolarMutexGuard aGuard;
206 if ( impl_isDisposed_nothrow() )
207 return;
208
209 SharedNotifier::getNotifier()->removeEventsForProcessor( this );
210 m_pContext = nullptr;
211 }
212
213 void PropertyControlContext_Impl::setNotificationMode( NotificationMode _eMode )
214 {
215 SolarMutexGuard aGuard;
216 m_eMode = _eMode;
217 }
218
219 void PropertyControlContext_Impl::impl_notify_throw( const Reference< XPropertyControl >& _rxControl, ControlEventType _eType )
220 {
221 ::comphelper::AnyEventRef pEvent;
222
223 {
224 SolarMutexGuard aGuard;
225 if ( impl_isDisposed_nothrow() )
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
254 void SAL_CALL PropertyControlContext_Impl::acquire() throw()
255 {
256 PropertyControlContext_Impl_Base::acquire();
257 }
258
259 void SAL_CALL PropertyControlContext_Impl::release() throw()
260 {
261 PropertyControlContext_Impl_Base::release();
262 }
263
264 void PropertyControlContext_Impl::processEvent( const ::comphelper::AnyEvent& _rEvent )
265 {
266 SolarMutexGuard aGuard;
267 if ( impl_isDisposed_nothrow() )
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")DbgUnhandledException( DbgGetCaughtException(), __func__, "/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "278" ": ", "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
299 OBrowserListBox::OBrowserListBox(weld::Builder& rBuilder, weld::Container* pContainer)
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
314 OBrowserListBox::~OBrowserListBox()
315 {
316 OSL_ENSURE( !IsModified(), "OBrowserListBox::~OBrowserListBox: still modified - should have been committed before!" )do { if (true && (!(!IsModified()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "316" ": "), "%s", "OBrowserListBox::~OBrowserListBox: still modified - should have been committed before!"
); } } while (false)
;
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
327 bool OBrowserListBox::IsModified() const
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
337 void OBrowserListBox::CommitModified( )
338 {
339 if ( !(IsModified() && m_xActiveControl.is()) )
340 return;
341
342 // for the time of this commit, notify all events synchronously
343 // #i63814#
344 m_pControlContextImpl->setNotificationMode( PropertyControlContext_Impl::eSynchronously );
345 try
346 {
347 m_xActiveControl->notifyModifiedValue();
348 }
349 catch( const Exception& )
350 {
351 DBG_UNHANDLED_EXCEPTION("extensions.propctrlr")DbgUnhandledException( DbgGetCaughtException(), __func__, "/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "351" ": ", "extensions.propctrlr" );
;
352 }
353 m_pControlContextImpl->setNotificationMode( PropertyControlContext_Impl::eAsynchronously );
354 }
355
356 void OBrowserListBox::SetListener( IPropertyLineListener* _pListener )
357 {
358 m_pLineListener = _pListener;
359 }
360
361 void OBrowserListBox::SetObserver( IPropertyControlObserver* _pObserver )
362 {
363 m_pControlObserver = _pObserver;
364 }
365
366 void OBrowserListBox::EnableHelpSection( bool _bEnable )
367 {
368 m_xHelpWindow->Show( _bEnable );
369 }
370
371 bool OBrowserListBox::HasHelpSection() const
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!" )do { if (true && (!(HasHelpSection()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "378" ": "), "%s", "OBrowserListBox::SetHelpText: help section not visible!"
); } } while (false)
;
379 m_xHelpWindow->SetText( _rHelpText );
380 }
381
382 void OBrowserListBox::UpdatePlayGround()
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!" )do { if (true && (!(xControl.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "398" ": "), "%s", "OBrowserListBox::SetPropertyValue: illegal control!"
); } } while (false)
;
399 if ( xControl.is() )
400 xControl->setValue( Any() );
401 }
402 else
403 impl_setControlAsPropertyValue( *line, _rValue );
404 }
405 }
406
407 sal_uInt16 OBrowserListBox::GetPropertyPos( const OUString& _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
419 return EDITOR_LIST_ENTRY_NOTFOUND(((sal_uInt16) 0xFFFF));
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(),
460 m_xSizeGroup.get(), m_pInitialControlParent);
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)(static_cast <bool> (false) ? void (0) : __assert_fail (
"false", "/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
, 468, __extension__ __PRETTY_FUNCTION__))
;
469 }
470 }
471
472 ListBoxLine aNewLine( rPropertyData.sName, pBrowserLine, rPropertyData.xPropertyHandler );
473 ListBoxLines::size_type nInsertPos = _nPos;
474 if ( _nPos >= m_aLines.size() )
1
Assuming the condition is false
2
Taking false branch
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);
3
Calling 'OBrowserListBox::ChangeEntry'
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!" )do { if (true && (!(_pLine))) { sal_detail_logFormat(
(SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "537" ": "), "%s", "OBrowserListBox::buttonClicked: invalid browser line!"
); } } while (false)
;
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",do { if (true && (!_rLine.xHandler.is())) { switch (sal_detail_log_report
(::SAL_DETAIL_LOG_LEVEL_WARN, "extensions.propctrlr")) { case
SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!") == 1
) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "557" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"), 0)
; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "557" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!") == 1
) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "557" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"), 0)
; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "557" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
556 "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '"do { if (true && (!_rLine.xHandler.is())) { switch (sal_detail_log_report
(::SAL_DETAIL_LOG_LEVEL_WARN, "extensions.propctrlr")) { case
SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!") == 1
) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "557" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"), 0)
; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "557" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!") == 1
) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "557" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"), 0)
; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "557" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
557 << _rLine.pLine->GetEntryName() << "')!" )do { if (true && (!_rLine.xHandler.is())) { switch (sal_detail_log_report
(::SAL_DETAIL_LOG_LEVEL_WARN, "extensions.propctrlr")) { case
SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!") == 1
) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "557" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"), 0)
; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "557" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!") == 1
) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "557" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"), 0)
; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "557" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
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")DbgUnhandledException( DbgGetCaughtException(), __func__, "/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "568" ": ", "extensions.propctrlr" );
;
569 }
570 }
571
572 Any OBrowserListBox::impl_getControlAsPropertyValue( const ListBoxLine& _rLine )
573 {
574 Reference< XPropertyControl > xControl( _rLine.pLine->getControl() );
575 Any aPropertyValue;
576 try
577 {
578 SAL_WARN_IF( !_rLine.xHandler.is(), "extensions.propctrlr",do { if (true && (!_rLine.xHandler.is())) { switch (sal_detail_log_report
(::SAL_DETAIL_LOG_LEVEL_WARN, "extensions.propctrlr")) { case
SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!") == 1
) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "580" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"), 0)
; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "580" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!") == 1
) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "580" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"), 0)
; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "580" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
579 "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '"do { if (true && (!_rLine.xHandler.is())) { switch (sal_detail_log_report
(::SAL_DETAIL_LOG_LEVEL_WARN, "extensions.propctrlr")) { case
SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!") == 1
) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "580" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"), 0)
; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "580" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!") == 1
) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "580" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"), 0)
; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "580" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
580 << _rLine.pLine->GetEntryName() << "')!" )do { if (true && (!_rLine.xHandler.is())) { switch (sal_detail_log_report
(::SAL_DETAIL_LOG_LEVEL_WARN, "extensions.propctrlr")) { case
SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!") == 1
) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "580" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"), 0)
; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "580" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!") == 1
) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "580" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"), 0)
; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '"
<< _rLine.pLine->GetEntryName() << "')!"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("extensions.propctrlr"
), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "580" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
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")DbgUnhandledException( DbgGetCaughtException(), __func__, "/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "588" ": ", "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!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "602" ": "), "%s", "OBrowserListBox::impl_getControlPos: invalid control - not part of any of our lines!"
); } } while (false)
;
603 return sal_uInt16(-1);
604 }
605
606
607 void OBrowserListBox::focusGained( const Reference< XPropertyControl >& _rxControl )
608 {
609 DBG_TESTSOLARMUTEX()do { DbgTestSolarMutex(); } while(false);
610
611 DBG_ASSERT( _rxControl.is(), "OBrowserListBox::focusGained: invalid event source!" )do { if (true && (!(_rxControl.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "611" ": "), "%s", "OBrowserListBox::focusGained: invalid event source!"
); } } while (false)
;
612 if ( !_rxControl.is() )
613 return;
614
615 if ( m_pControlObserver )
616 m_pControlObserver->focusGained( _rxControl );
617
618 m_xActiveControl = _rxControl;
619 ShowEntry( impl_getControlPos( m_xActiveControl ) );
620 }
621
622
623 void OBrowserListBox::valueChanged( const Reference< XPropertyControl >& _rxControl )
624 {
625 DBG_TESTSOLARMUTEX()do { DbgTestSolarMutex(); } while(false);
626
627 DBG_ASSERT( _rxControl.is(), "OBrowserListBox::valueChanged: invalid event source!" )do { if (true && (!(_rxControl.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "627" ": "), "%s", "OBrowserListBox::valueChanged: invalid event source!"
); } } while (false)
;
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 ) ];
637 m_pLineListener->Commit(
638 rLine.pLine->GetEntryName(),
639 impl_getControlAsPropertyValue( rLine )
640 );
641 }
642 }
643
644
645 void OBrowserListBox::activateNextControl( const Reference< XPropertyControl >& _rxCurrentControl )
646 {
647 DBG_TESTSOLARMUTEX()do { DbgTestSolarMutex(); } while(false);
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")DbgUnhandledException( DbgGetCaughtException(), __func__, "/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "682" ": ", "extensions.propctrlr" );
;
683 }
684 }
685 }
686
687 void OBrowserListBox::Clear()
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
697 clearContainer( m_aLines );
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!" )do { if (true && (!(rPropertyData.Control.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "715" ": "), "%s", "OBrowserListBox::ChangeEntry: invalid control!"
); } } while (false)
;
4
Taking false branch
5
Loop condition is false. Exiting loop
716 if ( !rPropertyData.Control.is() )
6
Calling 'BaseReference::is'
8
Returning from 'BaseReference::is'
9
Taking false branch
717 return;
718
719 if ( nPos == EDITOR_LIST_REPLACE_EXISTINGstd::numeric_limits<ListBoxLines::size_type>::max() )
10
Taking false branch
720 nPos = GetPropertyPos( rPropertyData.sName );
721
722 if ( nPos >= m_aLines.size() )
11
Assuming the condition is false
12
Taking false branch
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() )
13
Taking true branch
739 xControl->setControlContext( m_pControlContextImpl.get() );
740
741 // the initial property value
742 if ( rPropertyData.bUnknownValue )
14
Assuming field 'bUnknownValue' is true
15
Taking true branch
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 )
16
Assuming field 'HasPrimaryButton' is 0
17
Taking false branch
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 ),do { if (true && (!(( rPropertyData.IndentLevel == 0 )
|| ( rPropertyData.IndentLevel == 1 )))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "780" ": "), "%s", "OBrowserListBox::ChangeEntry: unsupported indent level!"
); } } while (false)
18
Assuming field 'IndentLevel' is equal to 0
19
Taking false branch
20
Loop condition is false. Exiting loop
780 "OBrowserListBox::ChangeEntry: unsupported indent level!" )do { if (true && (!(( rPropertyData.IndentLevel == 0 )
|| ( rPropertyData.IndentLevel == 1 )))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/extensions/source/propctrlr/browserlistbox.cxx"
":" "780" ": "), "%s", "OBrowserListBox::ChangeEntry: unsupported indent level!"
); } } while (false)
;
781 rLine.pLine->IndentTitle( rPropertyData.IndentLevel > 0 );
782
783 rLine.pLine->SetComponentHelpIds(
784 HelpIdUrl::getHelpId( rPropertyData.HelpURL )
785 );
786
787 if ( rPropertyData.bReadOnly )
21
Assuming field 'bReadOnly' is true
22
Taking true branch
788 {
789 rLine.pLine->SetReadOnly( true );
23
Value assigned to field 'm_pControlWindow'
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 ) )
24
Calling 'BaseReference::is'
26
Returning from 'BaseReference::is'
27
Assuming the condition is true
28
Taking true branch
797 {
798 weld::Widget* pWindow = rLine.pLine->getControlWindow();
29
'pWindow' initialized here
799 weld::Entry* pControlWindowAsEdit = dynamic_cast<weld::Entry*>(pWindow);
800 if (pControlWindowAsEdit)
30
Assuming 'pControlWindowAsEdit' is null
31
Taking false branch
801 pControlWindowAsEdit->set_editable(false);
802 else
803 pWindow->set_sensitive(false);
32
Called C++ object pointer is null
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;
811 UpdatePlayGround();
812 }
813 }
814} // namespace pcr
815
816
817/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/include/com/sun/star/uno/Reference.h

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#ifndef INCLUDED_COM_SUN_STAR_UNO_REFERENCE_H
20#define INCLUDED_COM_SUN_STAR_UNO_REFERENCE_H
21
22#include "sal/config.h"
23
24#include <cassert>
25#include <cstddef>
26
27#if defined LIBO_INTERNAL_ONLY1
28#include <type_traits>
29#endif
30
31#include "rtl/alloc.h"
32
33namespace com
34{
35namespace sun
36{
37namespace star
38{
39namespace uno
40{
41
42class RuntimeException;
43class XInterface;
44class Type;
45class Any;
46
47/** Enum defining UNO_REF_NO_ACQUIRE for setting reference without acquiring a given interface.
48 Deprecated, please use SAL_NO_ACQUIRE.
49 @deprecated
50*/
51enum UnoReference_NoAcquire
52{
53 /** This enum value can be used for creating a reference granting a given interface,
54 i.e. transferring ownership to it.
55 */
56 UNO_REF_NO_ACQUIRE
57};
58
59/** This base class serves as a base class for all template reference classes and
60 has been introduced due to compiler problems with templated operators ==, =!.
61*/
62class BaseReference
63{
64protected:
65 /** the interface pointer
66 */
67 XInterface * _pInterface;
68
69 /** Queries given interface for type rType.
70
71 @param pInterface interface pointer
72 @param rType interface type
73 @return interface of demanded type (may be null)
74 */
75 inline static XInterface * SAL_CALL iquery( XInterface * pInterface, const Type & rType );
76 /** Queries given interface for type rType.
77 Throws a RuntimeException if the demanded interface cannot be queried.
78
79 @param pInterface interface pointer
80 @param rType interface type
81 @return interface of demanded type
82 */
83 inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface, const Type & rType );
84
85public:
86 /** Gets interface pointer. This call does not acquire the interface.
87
88 @return UNacquired interface pointer
89 */
90 XInterface * SAL_CALL get() const
91 { return _pInterface; }
92
93 /** Checks if reference is null.
94
95 @return true if reference acquires an interface, i.e. true if it is not null
96 */
97 bool SAL_CALL is() const
98 { return (NULL__null != _pInterface); }
7
Returning the value 1, which participates in a condition later
25
Returning the value 1, which participates in a condition later
99
100#if defined LIBO_INTERNAL_ONLY1
101 /** Checks if reference is null.
102
103 @return true if reference acquires an interface, i.e. true if it is not null
104 */
105 explicit operator bool() const
106 { return is(); }
107#endif
108
109 /** Equality operator: compares two interfaces
110 Checks if both references are null or refer to the same object.
111
112 @param pInterface another interface
113 @return true if both references are null or refer to the same object, false otherwise
114 */
115 inline bool SAL_CALL operator == ( XInterface * pInterface ) const;
116 /** Inequality operator: compares two interfaces
117 Checks if both references are null or refer to the same object.
118
119 @param pInterface another interface
120 @return false if both references are null or refer to the same object, true otherwise
121 */
122 inline bool SAL_CALL operator != ( XInterface * pInterface ) const;
123
124 /** Equality operator: compares two interfaces
125 Checks if both references are null or refer to the same object.
126
127 @param rRef another reference
128 @return true if both references are null or refer to the same object, false otherwise
129 */
130 inline bool SAL_CALL operator == ( const BaseReference & rRef ) const;
131 /** Inequality operator: compares two interfaces
132 Checks if both references are null or refer to the same object.
133
134 @param rRef another reference
135 @return false if both references are null or refer to the same object, true otherwise
136 */
137 inline bool SAL_CALL operator != ( const BaseReference & rRef ) const;
138
139 /** Needed by some STL containers.
140
141 @param rRef another reference
142 @return true, if this reference is less than rRef
143 */
144 inline bool SAL_CALL operator < ( const BaseReference & rRef ) const;
145};
146
147/** Enum defining UNO_QUERY for implicit interface query.
148*/
149enum UnoReference_Query
150{
151 /** This enum value can be used for implicit interface query.
152 */
153 UNO_QUERY
154};
155/** Enum defining UNO_QUERY_THROW for implicit interface query.
156 If the demanded interface is unavailable, then a RuntimeException is thrown.
157*/
158enum UnoReference_QueryThrow
159{
160 /** This enum value can be used for implicit interface query.
161 */
162 UNO_QUERY_THROW
163};
164/** Enum defining UNO_SET_THROW for throwing if attempts are made to assign a null
165 interface
166
167 @since UDK 3.2.8
168*/
169enum UnoReference_SetThrow
170{
171 UNO_SET_THROW
172};
173
174/** Template reference class for interface type derived from BaseReference.
175 A special constructor given the UNO_QUERY identifier queries interfaces
176 for reference type.
177*/
178template< class interface_type >
179class SAL_DLLPUBLIC_RTTI__attribute__ ((type_visibility("default"))) Reference : public BaseReference
180{
181 /** Queries given interface for type interface_type.
182
183 @param pInterface interface pointer
184 @return interface of demanded type (may be null)
185 */
186 inline static XInterface * SAL_CALL iquery( XInterface * pInterface );
187 /** Queries given interface for type interface_type.
188 Throws a RuntimeException if the demanded interface cannot be queried.
189
190 @param pInterface interface pointer
191 @return interface of demanded type
192 */
193 inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface );
194 /** Returns the given interface if it is not <NULL/>, throws a RuntimeException otherwise.
195
196 @param pInterface interface pointer
197 @return pInterface
198 */
199 inline static interface_type * SAL_CALL iset_throw( interface_type * pInterface );
200
201 /** Cast from an "interface pointer" (e.g., BaseReference::_pInterface) to a
202 pointer to this interface_type.
203
204 To work around ambiguities in the case of multiple-inheritance interface
205 types (which inherit XInterface more than once), use reinterpret_cast
206 (resp. a sequence of two static_casts, to avoid warnings about
207 reinterpret_cast used between related classes) to switch from a pointer
208 to XInterface to a pointer to this derived interface_type. In
209 principle, this is not guaranteed to work. In practice, it seems to
210 work on all supported platforms.
211 */
212 static interface_type * castFromXInterface(XInterface * p) {
213 return static_cast< interface_type * >(static_cast< void * >(p));
214 }
215
216 /** Cast from a pointer to this interface_type to an "interface pointer"
217 (e.g., BaseReference::_pInterface).
218
219 To work around ambiguities in the case of multiple-inheritance interface
220 types (which inherit XInterface more than once), use reinterpret_cast
221 (resp. a sequence of two static_casts, to avoid warnings about
222 reinterpret_cast used between related classes) to switch from a pointer
223 to this derived interface_type to a pointer to XInterface. In
224 principle, this is not guaranteed to work. In practice, it seems to
225 work on all supported platforms.
226 */
227 static XInterface * castToXInterface(interface_type * p) {
228 return static_cast< XInterface * >(static_cast< void * >(p));
229 }
230
231public:
232 /// @cond INTERNAL
233 // these are here to force memory de/allocation to sal lib.
234 static void * SAL_CALL operator new ( ::size_t nSize )
235 { return ::rtl_allocateMemory( nSize ); }
236 static void SAL_CALL operator delete ( void * pMem )
237 { ::rtl_freeMemory( pMem ); }
238 static void * SAL_CALL operator new ( ::size_t, void * pMem )
239 { return pMem; }
240 static void SAL_CALL operator delete ( void *, void * )
241 {}
242 /// @endcond
243
244 /** Destructor: Releases interface if set.
245 */
246 inline ~Reference() COVERITY_NOEXCEPT_FALSE;
247
248 /** Default Constructor: Sets null reference.
249 */
250 inline Reference();
251
252 /** Copy constructor: Copies interface reference.
253
254 @param rRef another reference
255 */
256 inline Reference( const Reference< interface_type > & rRef );
257
258#if defined LIBO_INTERNAL_ONLY1
259 /** Move constructor
260
261 @param rRef another reference
262 */
263 inline Reference( Reference< interface_type > && rRef ) noexcept;
264
265 /** Up-casting conversion constructor: Copies interface reference.
266
267 Does not work for up-casts to ambiguous bases. For the special case of
268 up-casting to Reference< XInterface >, see the corresponding conversion
269 operator.
270
271 @param rRef another reference
272 */
273 template< class derived_type >
274 inline Reference(
275 const Reference< derived_type > & rRef,
276 std::enable_if_t<
277 std::is_base_of_v<interface_type, derived_type>
278 && !std::is_same_v<interface_type, XInterface>, void *> = nullptr);
279#endif
280
281 /** Constructor: Sets given interface pointer.
282
283 @param pInterface an interface pointer
284 */
285 inline Reference( interface_type * pInterface );
286
287 /** Constructor: Sets given interface pointer without acquiring it.
288
289 @param pInterface another reference
290 @param dummy SAL_NO_ACQUIRE to force obvious distinction to other constructors
291 */
292 inline Reference( interface_type * pInterface, __sal_NoAcquire dummy);
293 /** Constructor: Sets given interface pointer without acquiring it.
294 Deprecated, please use SAL_NO_ACQUIRE version.
295
296 @deprecated
297 @param pInterface another reference
298 @param dummy UNO_REF_NO_ACQUIRE to force obvious distinction to other constructors
299 */
300 inline SAL_DEPRECATED("use SAL_NO_ACQUIRE version")__attribute__((deprecated("use SAL_NO_ACQUIRE version"))) Reference( interface_type * pInterface, UnoReference_NoAcquire dummy );
301
302 /** Constructor: Queries given interface for reference interface type (interface_type).
303
304 @param rRef another reference
305 @param dummy UNO_QUERY to force obvious distinction to other constructors
306 */
307 inline Reference( const BaseReference & rRef, UnoReference_Query dummy );
308 /** Constructor: Queries given interface for reference interface type (interface_type).
309
310 @param pInterface an interface pointer
311 @param dummy UNO_QUERY to force obvious distinction to other constructors
312 */
313 inline Reference( XInterface * pInterface, UnoReference_Query dummy);
314 /** Constructor: Queries given any for reference interface type (interface_type).
315
316 @param rAny an any
317 @param dummy UNO_QUERY to force obvious distinction to other constructors
318 */
319 inline Reference( const Any & rAny, UnoReference_Query dummy);
320 /** Constructor: Queries given interface for reference interface type (interface_type).
321 Throws a RuntimeException if the demanded interface cannot be queried.
322
323 @param rRef another reference
324 @param dummy UNO_QUERY_THROW to force obvious distinction
325 to other constructors
326 */
327 inline Reference( const BaseReference & rRef, UnoReference_QueryThrow dummy );
328#ifdef LIBO_INTERNAL_ONLY1
329 /**
330 Prevent code from calling the QUERY_THROW constructor, when they meant to use the SET_THROW constructor.
331 */
332 Reference( const Reference< interface_type > & rRef, UnoReference_QueryThrow dummy ) = delete;
333#endif
334 /** Constructor: Queries given interface for reference interface type (interface_type).
335 Throws a RuntimeException if the demanded interface cannot be queried.
336
337 @param pInterface an interface pointer
338 @param dummy UNO_QUERY_THROW to force obvious distinction
339 to other constructors
340 */
341 inline Reference( XInterface * pInterface, UnoReference_QueryThrow dummy );
342 /** Constructor: Queries given any for reference interface type (interface_type).
343 Throws a RuntimeException if the demanded interface cannot be queried.
344
345 @param rAny an any
346 @param dummy UNO_QUERY_THROW to force obvious distinction
347 to other constructors
348 */
349 inline Reference( const Any & rAny, UnoReference_QueryThrow dummy );
350 /** Constructor: assigns from the given interface of the same type. Throws a RuntimeException
351 if the source interface is NULL.
352
353 @param rRef another interface reference of the same type
354 @param dummy UNO_SET_THROW to distinguish from default copy constructor
355
356 @since UDK 3.2.8
357 */
358 inline Reference( const Reference< interface_type > & rRef, UnoReference_SetThrow dummy );
359 /** Constructor: assigns from the given interface of the same type. Throws a RuntimeException
360 if the source interface is NULL.
361
362 @param pInterface an interface pointer
363 @param dummy UNO_SET_THROW to distinguish from default assignment constructor
364
365 @since UDK 3.2.8
366 */
367 inline Reference( interface_type * pInterface, UnoReference_SetThrow dummy );
368
369 /** Cast operator to Reference< XInterface >: Reference objects are binary compatible and
370 any interface must be derived from com.sun.star.uno.XInterface.
371 This a useful direct cast possibility.
372 */
373 SAL_CALL operator const Reference< XInterface > & () const
374 { return * reinterpret_cast< const Reference< XInterface > * >( this ); }
375
376 /** Dereference operator: Used to call interface methods.
377
378 @return UNacquired interface pointer
379 */
380 interface_type * SAL_CALL operator -> () const {
381 assert(_pInterface != NULL)(static_cast <bool> (_pInterface != __null) ? void (0) :
__assert_fail ("_pInterface != NULL", "/home/maarten/src/libreoffice/core/include/com/sun/star/uno/Reference.h"
, 381, __extension__ __PRETTY_FUNCTION__))
;
382 return castFromXInterface(_pInterface);
383 }
384
385 /** Indirection operator.
386
387 @since LibreOffice 6.3
388 @return UNacquired interface reference
389 */
390 interface_type & SAL_CALL operator * () const {
391 assert(_pInterface != NULL)(static_cast <bool> (_pInterface != __null) ? void (0) :
__assert_fail ("_pInterface != NULL", "/home/maarten/src/libreoffice/core/include/com/sun/star/uno/Reference.h"
, 391, __extension__ __PRETTY_FUNCTION__))
;
392 return *castFromXInterface(_pInterface);
393 }
394
395 /** Gets interface pointer. This call does not acquire the interface.
396
397 @return UNacquired interface pointer
398 */
399 interface_type * SAL_CALL get() const
400 { return castFromXInterface(_pInterface); }
401
402 /** Clears reference, i.e. releases interface. Reference is null after clear() call.
403 */
404 inline void SAL_CALL clear();
405
406 /** Sets the given interface. An interface already set will be released.
407
408 @param rRef another reference
409 @return true, if non-null interface was set
410 */
411 inline bool SAL_CALL set( const Reference< interface_type > & rRef );
412 /** Sets the given interface. An interface already set will be released.
413
414 @param pInterface another interface
415 @return true, if non-null interface was set
416 */
417 inline bool SAL_CALL set( interface_type * pInterface );
418
419 /** Sets interface pointer without acquiring it. An interface already set will be released.
420
421 @param pInterface an interface pointer
422 @param dummy SAL_NO_ACQUIRE to force obvious distinction to set methods
423 @return true, if non-null interface was set
424 */
425 inline bool SAL_CALL set( interface_type * pInterface, __sal_NoAcquire dummy);
426 /** Sets interface pointer without acquiring it. An interface already set will be released.
427 Deprecated, please use SAL_NO_ACQUIRE version.
428
429 @deprecated
430 @param pInterface an interface pointer
431 @param dummy UNO_REF_NO_ACQUIRE to force obvious distinction to set methods
432 @return true, if non-null interface was set
433 */
434 inline SAL_DEPRECATED("use SAL_NO_ACQUIRE version")__attribute__((deprecated("use SAL_NO_ACQUIRE version"))) bool SAL_CALL set( interface_type * pInterface, UnoReference_NoAcquire dummy);
435
436 /** Queries given interface for reference interface type (interface_type) and sets it.
437 An interface already set will be released.
438
439 @param pInterface an interface pointer
440 @param dummy UNO_QUERY to force obvious distinction to set methods
441 @return true, if non-null interface was set
442 */
443 inline bool SAL_CALL set( XInterface * pInterface, UnoReference_Query dummy );
444 /** Queries given interface for reference interface type (interface_type) and sets it.
445 An interface already set will be released.
446
447 @param rRef another reference
448 @param dummy UNO_QUERY to force obvious distinction to set methods
449 @return true, if non-null interface was set
450 */
451 inline bool SAL_CALL set( const BaseReference & rRef, UnoReference_Query dummy);
452
453 /** Queries given any for reference interface type (interface_type)
454 and sets it. An interface already set will be released.
455
456 @param rAny
457 an Any containing an interface
458 @param dummy
459 UNO_QUERY to force obvious distinction
460 to set methods
461 @return
462 true, if non-null interface was set
463 */
464 inline bool set( Any const & rAny, UnoReference_Query dummy );
465
466 /** Queries given interface for reference interface type (interface_type) and sets it.
467 An interface already set will be released.
468 Throws a RuntimeException if the demanded interface cannot be set.
469
470 @param pInterface an interface pointer
471 @param dummy UNO_QUERY_THROW to force obvious distinction
472 to set methods
473 */
474 inline void SAL_CALL set( XInterface * pInterface, UnoReference_QueryThrow dummy );
475 /** Queries given interface for reference interface type (interface_type) and sets it.
476 An interface already set will be released.
477 Throws a RuntimeException if the demanded interface cannot be set.
478
479 @param rRef another reference
480 @param dummy UNO_QUERY_THROW to force obvious distinction
481 to set methods
482 */
483 inline void SAL_CALL set( const BaseReference & rRef, UnoReference_QueryThrow dummy );
484#ifdef LIBO_INTERNAL_ONLY1
485 /**
486 Prevent code from calling the QUERY_THROW version, when they meant to use the SET_THROW version.
487 */
488 void set( const Reference< interface_type > & rRef, UnoReference_QueryThrow dummy ) = delete;
489#endif
490
491 /** Queries given any for reference interface type (interface_type) and
492 sets it. An interface already set will be released.
493 Throws a RuntimeException if the demanded interface cannot be set.
494
495 @param rAny
496 an Any containing an interface
497 @param dummy
498 UNO_QUERY_THROW to force obvious distinction to set methods
499 */
500 inline void set( Any const & rAny, UnoReference_QueryThrow dummy);
501 /** sets the given interface
502 An interface already set will be released.
503 Throws a RuntimeException if the source interface is @b NULL.
504
505 @param pInterface an interface pointer
506 @param dummy UNO_SET_THROW to force obvious distinction to other set methods
507
508 @since UDK 3.2.8
509 */
510 inline void SAL_CALL set( interface_type * pInterface, UnoReference_SetThrow dummy);
511 /** sets the given interface
512 An interface already set will be released.
513 Throws a RuntimeException if the source interface is @b NULL.
514
515 @param rRef an interface reference
516 @param dummy UNO_SET_THROW to force obvious distinction to other set methods
517
518 @since UDK 3.2.8
519 */
520 inline void SAL_CALL set( const Reference< interface_type > & rRef, UnoReference_SetThrow dummy);
521
522
523 /** Assignment operator: Acquires given interface pointer and sets reference.
524 An interface already set will be released.
525
526 @param pInterface an interface pointer
527 @return this reference
528 */
529 inline Reference< interface_type > & SAL_CALL operator = ( interface_type * pInterface );
530 /** Assignment operator: Acquires given interface reference and sets reference.
531 An interface already set will be released.
532
533 @param rRef an interface reference
534 @return this reference
535 */
536 inline Reference< interface_type > & SAL_CALL operator = ( const Reference< interface_type > & rRef );
537#if defined LIBO_INTERNAL_ONLY1
538 /** Assignment move operator: Acquires given interface reference and sets reference.
539 An interface already set will be released.
540
541 @param rRef an interface reference
542 @return this reference
543 */
544 inline Reference< interface_type > & SAL_CALL operator = ( Reference< interface_type > && rRef ) noexcept;
545#endif
546 /** Queries given interface reference for type interface_type.
547
548 @param rRef interface reference
549 @return interface reference of demanded type (may be null)
550 */
551 SAL_WARN_UNUSED_RESULT[[nodiscard]] inline static Reference< interface_type > SAL_CALL query( const BaseReference & rRef );
552 /** Queries given interface for type interface_type.
553
554 @param pInterface interface pointer
555 @return interface reference of demanded type (may be null)
556 */
557 SAL_WARN_UNUSED_RESULT[[nodiscard]] inline static Reference< interface_type > SAL_CALL query( XInterface * pInterface );
558};
559
560}
561}
562}
563}
564
565#endif
566
567/* vim:set shiftwidth=4 softtabstop=4 expandtab: */