LibreOffice Module forms (master) 1
InterfaceContainer.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
21#include <strings.hrc>
22#include <frm_resource.hxx>
23#include <frm_strings.hxx>
25#include <componenttools.hxx>
26#include <services.hxx>
27
28#include <com/sun/star/beans/XPropertySet.hpp>
29#include <com/sun/star/io/WrongFormatException.hpp>
30#include <com/sun/star/io/XMarkableStream.hpp>
31#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
32#include <com/sun/star/lang/XMultiServiceFactory.hpp>
33#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
34#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
35#include <com/sun/star/lang/XComponent.hpp>
36#include <com/sun/star/uno/XComponentContext.hpp>
37#include <com/sun/star/util/XCloneable.hpp>
38#include <com/sun/star/form/XForm.hpp>
39
44#include <comphelper/types.hxx>
46#include <o3tl/safeint.hxx>
47#include <tools/debug.hxx>
49#include <sal/log.hxx>
50
51#include <algorithm>
52#include <memory>
53
54
55#include <com/sun/star/frame/XModel.hpp>
56#include <com/sun/star/document/XCodeNameQuery.hpp>
57#include <ooo/vba/XVBAToOOEventDescGen.hpp>
58
59namespace frm
60{
61
62
63using namespace ::com::sun::star::frame;
64using namespace ::com::sun::star::lang;
65using namespace ::com::sun::star::uno;
66using namespace ::com::sun::star::beans;
67using namespace ::com::sun::star::document;
68using namespace ::com::sun::star::container;
69using namespace ::com::sun::star::script;
70using namespace ::com::sun::star::io;
71using namespace ::com::sun::star::form;
72using namespace ::com::sun::star::util;
73
74namespace
75{
76
77 void lcl_throwIllegalArgumentException()
78 {
79 throw IllegalArgumentException();
80 }
81}
82
83static bool
84lcl_hasVbaEvents( const Sequence< ScriptEventDescriptor >& sEvents )
85{
86 for ( auto const& rDesc : sEvents )
87 {
88 if ( rDesc.ScriptType == "VBAInterop" )
89 return true;
90 }
91 return false;
92}
93
94static Sequence< ScriptEventDescriptor >
95lcl_stripVbaEvents( const Sequence< ScriptEventDescriptor >& sEvents )
96{
97 Sequence< ScriptEventDescriptor > sStripped( sEvents.getLength() );
98 ScriptEventDescriptor* pStripped = sStripped.getArray();
99
100 sal_Int32 nCopied = 0;
101 for ( auto const& rDesc : sEvents )
102 {
103 if ( rDesc.ScriptType != "VBAInterop" )
104 {
105 pStripped[ nCopied++ ] = rDesc;
106 }
107 }
108 sStripped.realloc( nCopied );
109 return sStripped;
110}
111
113{
114 // we are dealing with form controls
115 try
116 {
117 do
118 {
119 Reference< XModel > xDoc( getXModel( static_cast< XContainer *> ( this ) ) );
120 if ( !xDoc.is() )
121 break;
122
123 Reference< XMultiServiceFactory > xDocFac( xDoc, UNO_QUERY_THROW );
124 Reference< XCodeNameQuery > xNameQuery( xDocFac->createInstance("ooo.vba.VBACodeNameProvider"), UNO_QUERY );
125 if ( !xNameQuery.is() )
126 break;
127
128 ::osl::MutexGuard aGuard( m_rMutex );
129 bool hasVBABindings = lcl_hasVbaEvents( m_xEventAttacher->getScriptEvents( i_nIndex ) );
130 if ( hasVBABindings )
131 break;
132
133 Reference< XInterface > xElement( getByIndex( i_nIndex ) , UNO_QUERY_THROW );
134 Reference< XForm > xElementAsForm( xElement, UNO_QUERY );
135 if ( xElementAsForm.is() )
136 break;
137
138 // Try getting the code name from the container first (faster),
139 // then from the element if that fails (slower).
140 Reference<XInterface> xThis = static_cast<XContainer*>(this);
141 OUString sCodeName = xNameQuery->getCodeNameForContainer(xThis);
142 if (sCodeName.isEmpty())
143 sCodeName = xNameQuery->getCodeNameForObject(xElement);
144
145 Reference< XPropertySet > xProps( xElement, UNO_QUERY_THROW );
146 OUString sServiceName;
147 xProps->getPropertyValue("DefaultControl") >>= sServiceName;
148
149 Reference< ooo::vba::XVBAToOOEventDescGen > xDescSupplier( m_xContext->getServiceManager()->createInstanceWithContext("ooo.vba.VBAToOOEventDesc", m_xContext), UNO_QUERY_THROW );
150 Sequence< ScriptEventDescriptor > vbaEvents = xDescSupplier->getEventDescriptions( sServiceName , sCodeName );
151
152 // register the vba script events
153 m_xEventAttacher->registerScriptEvents( i_nIndex, vbaEvents );
154 }
155 while ( false );
156 }
157 catch ( const ServiceNotRegisteredException& )
158 {
159 // silence this, not all document types support the ooo.vba.VBACodeNameProvider service
160 }
161 catch( const Exception& )
162 {
163 DBG_UNHANDLED_EXCEPTION("forms.misc");
164 }
165
166}
167
169{
170}
171
172
174 const Reference<XComponentContext>& _rxContext,
175 ::osl::Mutex& _rMutex,
176 const Type& _rElementType)
178 ,m_rMutex(_rMutex)
179 ,m_aContainerListeners(_rMutex)
180 ,m_aElementType(_rElementType)
181 ,m_xContext(_rxContext)
182{
183 impl_createEventAttacher_nothrow();
184}
185
186
187OInterfaceContainer::OInterfaceContainer( ::osl::Mutex& _rMutex, const OInterfaceContainer& _cloneSource )
189 ,m_rMutex( _rMutex )
190 ,m_aContainerListeners( _rMutex )
191 ,m_aElementType( _cloneSource.m_aElementType )
192 ,m_xContext( _cloneSource.m_xContext )
193{
195}
196
198{
199 try
200 {
201 const Reference< XIndexAccess > xSourceHierarchy( const_cast< OInterfaceContainer* >( &_cloneSource ) );
202 const sal_Int32 nCount = xSourceHierarchy->getCount();
203 for ( sal_Int32 i=0; i<nCount; ++i )
204 {
205 Reference< XCloneable > xCloneable( xSourceHierarchy->getByIndex( i ), UNO_QUERY_THROW );
206 Reference< XInterface > xClone( xCloneable->createClone() );
207 insertByIndex( i, Any( xClone ) );
208 }
209 }
210 catch (const RuntimeException&)
211 {
212 throw;
213 }
214 catch (const Exception&)
215 {
216 throw WrappedTargetRuntimeException(
217 "Could not clone the given interface hierarchy.",
218 static_cast< XIndexContainer* >( const_cast< OInterfaceContainer* >( &_cloneSource ) ),
219 ::cppu::getCaughtException()
220 );
221 }
222}
223
225{
226 try
227 {
228 m_xEventAttacher.set( ::comphelper::createEventAttacherManager( m_xContext ), UNO_SET_THROW );
229 }
230 catch( const Exception& )
231 {
232 DBG_UNHANDLED_EXCEPTION("forms.misc");
233 }
234}
235
236
238{
239}
240
241
243{
244 // dispose all elements
245 for (sal_Int32 i = m_aItems.size(); i > 0; --i)
246 {
247 Reference<XPropertySet> xSet(m_aItems[i - 1], UNO_QUERY);
248 if (xSet.is())
249 xSet->removePropertyChangeListener(PROPERTY_NAME, this);
250
251 // revoke event knittings
252 if ( m_xEventAttacher.is() )
253 {
254 m_xEventAttacher->detach( i - 1, Reference<XInterface>(xSet, UNO_QUERY) );
255 m_xEventAttacher->removeEntry( i - 1 );
256 }
257
258 Reference<XComponent> xComponent(xSet, UNO_QUERY);
259 if (xComponent.is())
260 xComponent->dispose();
261 }
262 m_aMap.clear();
263 m_aItems.clear();
264
265 css::lang::EventObject aEvt(static_cast<XContainer*>(this));
267}
268
269// XPersistObject
270
271namespace
272{
273
274 void lcl_saveEvents( ::std::vector< Sequence< ScriptEventDescriptor > >& _rSave,
275 const Reference< XEventAttacherManager >& _rxManager, const sal_Int32 _nItemCount )
276 {
277 OSL_ENSURE( _rxManager.is(), "lcl_saveEvents: invalid event attacher manager!" );
278 if ( !_rxManager.is() )
279 return;
280
281 // reserve the space needed
282 _rSave.reserve( _nItemCount );
283
284 // copy the events
285 for (sal_Int32 i=0; i<_nItemCount; ++i)
286 _rSave.push_back(_rxManager->getScriptEvents( i ));
287 }
288
289
290 void lcl_restoreEvents( const ::std::vector< Sequence< ScriptEventDescriptor > >& _rSave,
291 const Reference< XEventAttacherManager >& _rxManager )
292 {
293 OSL_ENSURE( _rxManager.is(), "lcl_restoreEvents: invalid event attacher manager!" );
294 if ( !_rxManager.is() )
295 return;
296
297 sal_Int32 i=0;
298 for (auto const& elem : _rSave)
299 {
300 _rxManager->revokeScriptEvents( i );
301 _rxManager->registerScriptEvents(i, elem);
302 ++i;
303 }
304 }
305}
306
307
308void SAL_CALL OInterfaceContainer::writeEvents(const Reference<XObjectOutputStream>& _rxOutStream)
309{
310 // We're writing a document in SO 5.2 format (or even from earlier versions)
311 // -> convert the events from the new runtime format to the format of the 5.2 files
312 // but before, remember the current script events set for our children
313 ::std::vector< Sequence< ScriptEventDescriptor > > aSave;
314 if ( m_xEventAttacher.is() )
315 lcl_saveEvents( aSave, m_xEventAttacher, m_aItems.size() );
316
318
319 try
320 {
321 Reference<XMarkableStream> xMark(_rxOutStream, UNO_QUERY);
322 sal_Int32 nMark = xMark->createMark();
323
324 sal_Int32 nObjLen = 0;
325 _rxOutStream->writeLong(nObjLen);
326
327 Reference<XPersistObject> xScripts(m_xEventAttacher, UNO_QUERY);
328 if (xScripts.is())
329 xScripts->write(_rxOutStream);
330
331 // Determine length
332 nObjLen = xMark->offsetToMark(nMark) - 4;
333 xMark->jumpToMark(nMark);
334 _rxOutStream->writeLong(nObjLen);
335 xMark->jumpToFurthest();
336 xMark->deleteMark(nMark);
337 }
338 catch( const Exception& )
339 {
340 // restore the events
341 if ( m_xEventAttacher.is() )
342 lcl_restoreEvents( aSave, m_xEventAttacher );
343 throw;
344 }
345
346 // restore the events
347 if ( m_xEventAttacher.is() )
348 lcl_restoreEvents( aSave, m_xEventAttacher );
349}
350
351namespace {
352
353struct TransformEventTo52Format
354{
355 void operator()( ScriptEventDescriptor& _rDescriptor )
356 {
357 if ( _rDescriptor.ScriptType != "StarBasic" )
358 return;
359
360 // it's a starbasic macro
361 sal_Int32 nPrefixLength = _rDescriptor.ScriptCode.indexOf( ':' );
362 if ( 0 <= nPrefixLength )
363 { // the macro name does not already contain a :
364#ifdef DBG_UTIL
365 const OUString sPrefix = _rDescriptor.ScriptCode.copy( 0, nPrefixLength );
366 DBG_ASSERT( sPrefix == "document"
367 || sPrefix == "application",
368 "TransformEventTo52Format: invalid (unknown) prefix!" );
369#endif
370 // cut the prefix
371 _rDescriptor.ScriptCode = _rDescriptor.ScriptCode.copy( nPrefixLength + 1 );
372 }
373 }
374};
375
376}
377
379{
380 OSL_ENSURE( m_xEventAttacher.is(), "OInterfaceContainer::transformEvents: no event attacher manager!" );
381 if ( !m_xEventAttacher.is() )
382 return;
383
384 try
385 {
386 // loop through all our children
387 sal_Int32 nItems = m_aItems.size();
388 Sequence< ScriptEventDescriptor > aChildEvents;
389
390 for (sal_Int32 i=0; i<nItems; ++i)
391 {
392 // get the script events for this object
393 aChildEvents = m_xEventAttacher->getScriptEvents( i );
394
395 if ( aChildEvents.hasElements() )
396 {
397 // do the transformation
398 auto [begin, end] = asNonConstRange(aChildEvents);
399 ::std::for_each( begin, end, TransformEventTo52Format() );
400
401 // revoke the script events
402 m_xEventAttacher->revokeScriptEvents( i );
403 // and re-register them
404 m_xEventAttacher->registerScriptEvents( i, aChildEvents );
405 }
406 }
407 }
408 catch( const Exception& )
409 {
410 DBG_UNHANDLED_EXCEPTION("forms.misc");
411 }
412}
413
414
415void SAL_CALL OInterfaceContainer::readEvents(const Reference<XObjectInputStream>& _rxInStream)
416{
417 ::osl::MutexGuard aGuard( m_rMutex );
418
419 // Read scripting info
420 Reference<XMarkableStream> xMark(_rxInStream, UNO_QUERY);
421 sal_Int32 nObjLen = _rxInStream->readLong();
422 if (nObjLen)
423 {
424 sal_Int32 nMark = xMark->createMark();
425 Reference<XPersistObject> xObj(m_xEventAttacher, UNO_QUERY);
426 if (xObj.is())
427 xObj->read(_rxInStream);
428 xMark->jumpToMark(nMark);
429 _rxInStream->skipBytes(nObjLen);
430 xMark->deleteMark(nMark);
431 }
432
433 // Read Attachment
434 if ( m_xEventAttacher.is() )
435 {
436 sal_Int32 i=0;
437 for (auto const& item : m_aItems)
438 {
439 Reference< XInterface > xAsIFace( item, UNO_QUERY ); // important to normalize this...
440 Reference< XPropertySet > xAsSet( xAsIFace, UNO_QUERY );
441 m_xEventAttacher->attach( i++, xAsIFace, Any( xAsSet ) );
442 }
443 }
444}
445
446
447void SAL_CALL OInterfaceContainer::write( const Reference< XObjectOutputStream >& _rxOutStream )
448{
449 ::osl::MutexGuard aGuard( m_rMutex );
450 sal_Int32 nLen = m_aItems.size();
451
452 // Write length
453 _rxOutStream->writeLong(nLen);
454
455 if (!nLen)
456 return;
457
458 // 1. Version
459 _rxOutStream->writeShort(0x0001);
460
461 // 2. Objects
462 for (sal_Int32 i = 0; i < nLen; i++)
463 {
464 Reference<XPersistObject> xObj(m_aItems[i], UNO_QUERY);
465 if (xObj.is())
466 _rxOutStream->writeObject(xObj);
467 else
468 {
469 // Error
470 }
471 }
472
473 // 3. Scripts
474 writeEvents(_rxOutStream);
475}
476
477
478namespace
479{
480 Reference< XPersistObject > lcl_createPlaceHolder( const Reference< XComponentContext >& _rxORB )
481 {
482 Reference< XPersistObject > xObject( _rxORB->getServiceManager()->createInstanceWithContext(FRM_COMPONENT_HIDDENCONTROL, _rxORB), UNO_QUERY );
483 DBG_ASSERT( xObject.is(), "lcl_createPlaceHolder: could not create a substitute for the unknown object!" );
484 if ( xObject.is() )
485 {
486 // set some properties describing what we did
487 Reference< XPropertySet > xObjProps( xObject, UNO_QUERY );
488 if ( xObject.is() )
489 {
490 try
491 {
492 xObjProps->setPropertyValue( PROPERTY_NAME, Any( ResourceManager::loadString(RID_STR_CONTROL_SUBSTITUTED_NAME) ) );
493 xObjProps->setPropertyValue( PROPERTY_TAG, Any( ResourceManager::loadString(RID_STR_CONTROL_SUBSTITUTED_EPXPLAIN) ) );
494 }
495 catch(const Exception&)
496 {
497 }
498 }
499 }
500 return xObject;
501 }
502}
503
504
505void SAL_CALL OInterfaceContainer::read( const Reference< XObjectInputStream >& _rxInStream )
506{
507 ::osl::MutexGuard aGuard( m_rMutex );
508
509 // after ::read the object is expected to be in the state it was when ::write was called, so we have
510 // to empty ourself here
511 while (getCount())
512 removeByIndex(0);
513
514 // Only writes depending on the length
515 sal_Int32 nLen = _rxInStream->readLong();
516
517 if (nLen)
518 {
519 // 1. Version
520 _rxInStream->readShort();
521
522 // 2. Objects
523 for (sal_Int32 i = 0; i < nLen; i++)
524 {
525 Reference<XPersistObject> xObj;
526 try
527 {
528 xObj = _rxInStream->readObject();
529 }
530 catch(const WrongFormatException&)
531 {
532 // the object could not be read
533 // create an object (so the readEvents below will assign the events to the right controls)
534 xObj = lcl_createPlaceHolder( m_xContext );
535 if ( !xObj.is() )
536 // couldn't handle it
537 throw;
538 }
539 catch(const Exception&)
540 {
541 // Clear the map
542 while (!m_aItems.empty())
544
545 // Rethrow the exception
546 throw;
547 }
548
549 if ( xObj.is() )
550 {
551 Reference< XPropertySet > xElement( xObj, UNO_QUERY );
552 try
553 {
555 m_aItems.size(), // position
556 xElement, // element to insert
557 false, // no event attacher manager handling
558 nullptr, // not yet approved - let implInsert do it
559 true // fire the event
560 );
561 }
562 catch( const Exception& )
563 {
564 SAL_WARN("forms.misc", "OInterfaceContainerHelper3::read: reading succeeded, but not inserting!" );
565 // create a placeholder
566 xElement.set(lcl_createPlaceHolder( m_xContext ), css::uno::UNO_QUERY);
567 if ( !xElement.is() )
568 // couldn't handle it
569 throw;
570 // insert the placeholder
571 implInsert( m_aItems.size(), xElement, false, nullptr, true );
572 }
573 }
574 }
575
576 readEvents(_rxInStream);
577 }
578 else
579 {
580 try
581 {
582 m_xEventAttacher = ::comphelper::createEventAttacherManager( m_xContext );
583 OSL_ENSURE( m_xEventAttacher.is(), "OInterfaceContainer::read: could not create an event attacher manager!" );
584 }
585 catch( const Exception& )
586 {
587 DBG_UNHANDLED_EXCEPTION("forms.misc");
588 }
589 }
590}
591
592// XContainer
593
594void SAL_CALL OInterfaceContainer::addContainerListener(const Reference<XContainerListener>& _rxListener)
595{
597}
598
599
600void SAL_CALL OInterfaceContainer::removeContainerListener(const Reference<XContainerListener>& _rxListener)
601{
603}
604
605// XEventListener
606
607void SAL_CALL OInterfaceContainer::disposing(const css::lang::EventObject& _rSource)
608{
609 ::osl::MutexGuard aGuard( m_rMutex );
610
611 Reference< XInterface > xSource( _rSource.Source, UNO_QUERY );
612 // normalized source
613
614 OInterfaceArray::iterator j;
615 for ( j = m_aItems.begin(); j != m_aItems.end(); ++j )
616 {
617 DBG_ASSERT( j->get() == Reference< XInterface >( *j, UNO_QUERY ).get(),
618 "OInterfaceContainer::disposing: vector element not normalized!" );
619
620 if ( xSource.get() == j->get() )
621 // found the element
622 break;
623 }
624
625 if ( m_aItems.end() == j )
626 return;
627
628 m_aItems.erase(j);
629
630 // look up in, and erase from, m_aMap, too
631 OInterfaceMap::iterator i = m_aMap.begin();
632 while ( i != m_aMap.end() )
633 {
634 DBG_ASSERT( i->second.get() == Reference< XInterface >( i->second, UNO_QUERY ).get(),
635 "OInterfaceContainer::disposing: map element not normalized!" );
636
637 if ( i->second.get() == xSource.get() )
638 {
639 // found it
640 m_aMap.erase(i);
641 break;
642 }
643
644 ++i;
645
646 DBG_ASSERT( i != m_aMap.end(), "OInterfaceContainer::disposing: inconsistency: the element was in m_aItems, but not in m_aMap!" );
647 }
648}
649
650// XPropertyChangeListener
651
652void OInterfaceContainer::propertyChange(const PropertyChangeEvent& evt) {
653 if (evt.PropertyName != PROPERTY_NAME)
654 return;
655
656 ::osl::MutexGuard aGuard( m_rMutex );
657 auto range = m_aMap.equal_range(::comphelper::getString(evt.OldValue));
658 for (auto it = range.first; it != range.second; ++it)
659 if (it->second == evt.Source)
660 {
661 css::uno::Reference<css::uno::XInterface> xCorrectType(it->second);
662 m_aMap.erase(it);
663 m_aMap.insert(::std::pair<const OUString, css::uno::Reference<css::uno::XInterface> >(::comphelper::getString(evt.NewValue),xCorrectType));
664 break;
665 }
666}
667
668// XElementAccess
669
671{
672 return !m_aMap.empty();
673}
674
675
677{
678 return m_aElementType;
679}
680
681// XEnumerationAccess
682
683Reference<XEnumeration> SAL_CALL OInterfaceContainer::createEnumeration()
684{
685 ::osl::MutexGuard aGuard( m_rMutex );
686 return new ::comphelper::OEnumerationByIndex(static_cast<XIndexAccess*>(this));
687}
688
689// XNameAccess
690
691Any SAL_CALL OInterfaceContainer::getByName( const OUString& _rName )
692{
693 ::std::pair <OInterfaceMap::iterator,
694 OInterfaceMap::iterator> aPair = m_aMap.equal_range(_rName);
695
696 if (aPair.first == aPair.second)
697 throw NoSuchElementException();
698
699 return (*aPair.first).second->queryInterface( m_aElementType );
700}
701
702
703css::uno::Sequence<OUString> SAL_CALL OInterfaceContainer::getElementNames()
704{
706}
707
708
709sal_Bool SAL_CALL OInterfaceContainer::hasByName( const OUString& _rName )
710{
711 ::std::pair <OInterfaceMap::iterator,
712 OInterfaceMap::iterator> aPair = m_aMap.equal_range(_rName);
713 return aPair.first != aPair.second;
714}
715
716// XIndexAccess
717
719{
720 return m_aItems.size();
721}
722
723
725{
726 if (_nIndex < 0 || (o3tl::make_unsigned(_nIndex) >= m_aItems.size()))
727 throw IndexOutOfBoundsException();
728
729 return m_aItems[_nIndex]->queryInterface( m_aElementType );
730}
731
732
733void OInterfaceContainer::approveNewElement( const Reference< XPropertySet >& _rxObject, ElementDescription* _pElement )
734{
735 // it has to be non-NULL
736 if ( !_rxObject.is() )
737 throw IllegalArgumentException(ResourceManager::loadString(RID_STR_NEED_NON_NULL_OBJECT), static_cast<XContainer*>(this), 1);
738
739 // it has to support our element type interface
740 Any aCorrectType = _rxObject->queryInterface( m_aElementType );
741 if ( !aCorrectType.hasValue() )
742 lcl_throwIllegalArgumentException();
743
744 // it has to have a "Name" property
745 if ( !hasProperty( PROPERTY_NAME, _rxObject ) )
746 lcl_throwIllegalArgumentException();
747
748 // it has to be a child, and it must not have a parent already
749 Reference< XChild > xChild( _rxObject, UNO_QUERY );
750 if ( !xChild.is() || xChild->getParent().is() )
751 {
752 lcl_throwIllegalArgumentException();
753 }
754
755 // passed all tests. cache the information we have so far
756 DBG_ASSERT( _pElement, "OInterfaceContainer::approveNewElement: invalid event descriptor!" );
757 if ( _pElement )
758 {
759 _pElement->xPropertySet = _rxObject;
760 _pElement->xChild = xChild;
761 _pElement->aElementTypeInterface = aCorrectType;
762 _pElement->xInterface = Reference< XInterface >( _rxObject, UNO_QUERY ); // normalized XInterface
763 }
764}
765
766
767void OInterfaceContainer::implInsert(sal_Int32 _nIndex, const Reference< XPropertySet >& _rxElement,
768 bool _bEvents, ElementDescription* _pApprovalResult, bool _bFire )
769{
770 const bool bHandleEvents = _bEvents && m_xEventAttacher.is();
771
772 // SYNCHRONIZED ----->
773 ::osl::ClearableMutexGuard aGuard( m_rMutex );
774
775 std::unique_ptr< ElementDescription > aAutoDeleteMetaData;
776 ElementDescription* pElementMetaData = _pApprovalResult;
777 if ( !pElementMetaData )
778 { // not yet approved by the caller -> do ourself
779 pElementMetaData = createElementMetaData();
780 DBG_ASSERT( pElementMetaData, "OInterfaceContainer::implInsert: createElementMetaData returned nonsense!" );
781
782 // ensure that the meta data structure will be deleted later on
783 aAutoDeleteMetaData.reset( pElementMetaData );
784
785 // will throw an exception if necessary
786 approveNewElement( _rxElement, pElementMetaData );
787 }
788
789
790 // approveNewElement (no matter if called here or outside) has ensure that all relevant interfaces
791 // exist
792
793 // set the name, and add as change listener for the name
794 OUString sName;
795 _rxElement->getPropertyValue(PROPERTY_NAME) >>= sName;
796 _rxElement->addPropertyChangeListener(PROPERTY_NAME, this);
797
798 // insert the object into our internal structures
799 if (_nIndex > static_cast<sal_Int32>(m_aItems.size())) // Calculate the actual index
800 {
801 _nIndex = m_aItems.size();
802 m_aItems.push_back( pElementMetaData->xInterface );
803 }
804 else
805 m_aItems.insert( m_aItems.begin() + _nIndex, pElementMetaData->xInterface );
806
807 m_aMap.insert( ::std::pair< const OUString, css::uno::Reference<css::uno::XInterface> >( sName, pElementMetaData->xInterface ) );
808
809 // announce ourself as parent to the new element
810 pElementMetaData->xChild->setParent(static_cast<XContainer*>(this));
811
812 // handle the events
813 if ( bHandleEvents )
814 {
815 m_xEventAttacher->insertEntry(_nIndex);
816 m_xEventAttacher->attach( _nIndex, pElementMetaData->xInterface, Any( _rxElement ) );
817 }
818
819 // notify derived classes
820 implInserted( pElementMetaData );
821
822 aGuard.clear();
823 // <----- SYNCHRONIZED
824
825 // insert faked VBA events?
826 bool bHandleVbaEvents = false;
827 try
828 {
829 _rxElement->getPropertyValue("GenerateVbaEvents") >>= bHandleVbaEvents;
830 }
831 catch( const Exception& )
832 {
833 }
834 if ( bHandleVbaEvents )
835 {
836 Reference< XEventAttacherManager > xMgr ( pElementMetaData->xInterface, UNO_QUERY );
837 OInterfaceContainer* pIfcMgr = xMgr.is() ? dynamic_cast<OInterfaceContainer*>(xMgr.get()) : nullptr;
838 if (pIfcMgr)
839 {
840 sal_Int32 nLen = pIfcMgr->getCount();
841 for (sal_Int32 i = 0; i < nLen; ++i)
842 {
843 // add fake events to the control at index i
845 }
846 }
847 else
848 {
849 // add fake events to the control at index i
851 }
852 }
853
854 // fire the notification about the change
855 if ( _bFire )
856 {
857 // notify listeners
858 ContainerEvent aEvt;
859 aEvt.Source = static_cast<XContainer*>(this);
860 aEvt.Accessor <<= _nIndex;
861 aEvt.Element = pElementMetaData->aElementTypeInterface;
862
863 m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvt );
864 }
865}
866
867
869{
870 OInterfaceArray::iterator i = m_aItems.begin();
871 css::uno::Reference<css::uno::XInterface> xElement(*i);
872
873 OInterfaceMap::iterator j = std::find_if(m_aMap.begin(), m_aMap.end(),
874 [&xElement](const OInterfaceMap::value_type& rEntry) { return rEntry.second == xElement; });
875
876 m_aItems.erase(i);
877 m_aMap.erase(j);
878
879 Reference<XPropertySet> xSet(xElement, UNO_QUERY);
880 if (xSet.is())
881 xSet->removePropertyChangeListener(PROPERTY_NAME, this);
882
883 Reference<XChild> xChild(xElement, UNO_QUERY);
884 if (xChild.is())
885 xChild->setParent(css::uno::Reference<css::uno::XInterface> ());
886}
887
888
890{
891 // not interested in
892}
893
894
895void OInterfaceContainer::implRemoved( const css::uno::Reference<css::uno::XInterface>& /*_rxObject*/ )
896{
897 // not interested in
898}
899
900
901void OInterfaceContainer::impl_replacedElement( const ContainerEvent& _rEvent, ::osl::ClearableMutexGuard& _rInstanceLock )
902{
903 _rInstanceLock.clear();
904 m_aContainerListeners.notifyEach( &XContainerListener::elementReplaced, _rEvent );
905}
906
907// XIndexContainer
908
909void SAL_CALL OInterfaceContainer::insertByIndex( sal_Int32 _nIndex, const Any& _rElement )
910{
911 Reference< XPropertySet > xElement;
912 _rElement >>= xElement;
913 implInsert( _nIndex, xElement, true /* event handling */ , nullptr /* not yet approved */ , true /* notification */ );
914}
915
916
917void OInterfaceContainer::implReplaceByIndex( const sal_Int32 _nIndex, const Any& _rNewElement, ::osl::ClearableMutexGuard& _rClearBeforeNotify )
918{
919 OSL_PRECOND( ( _nIndex >= 0 ) && ( o3tl::make_unsigned(_nIndex) < m_aItems.size() ), "OInterfaceContainer::implReplaceByIndex: precondition not met (index)!" );
920
921 // approve the new object
922 std::unique_ptr< ElementDescription > aElementMetaData( createElementMetaData() );
923 DBG_ASSERT(aElementMetaData,
924 "OInterfaceContainer::implReplaceByIndex: createElementMetaData returned nonsense!");
925 {
926 Reference< XPropertySet > xElementProps;
927 _rNewElement >>= xElementProps;
928 approveNewElement( xElementProps, aElementMetaData.get() );
929 }
930
931 // get the old element
932 css::uno::Reference<css::uno::XInterface> xOldElement( m_aItems[ _nIndex ] );
933 DBG_ASSERT( xOldElement.get() == Reference< XInterface >( xOldElement, UNO_QUERY ).get(),
934 "OInterfaceContainer::implReplaceByIndex: elements should be held normalized!" );
935
936 // locate the old element in the map
937 OInterfaceMap::iterator j = std::find_if(m_aMap.begin(), m_aMap.end(),
938 [&xOldElement](const OInterfaceMap::value_type& rEntry) { return rEntry.second.get() == xOldElement.get(); });
939
940 // remove event knittings
941 if ( m_xEventAttacher.is() )
942 {
943 css::uno::Reference<css::uno::XInterface> xNormalized( xOldElement, UNO_QUERY );
944 m_xEventAttacher->detach( _nIndex, xNormalized );
945 m_xEventAttacher->removeEntry( _nIndex );
946 }
947
948 // don't listen for property changes anymore
949 Reference<XPropertySet> xSet( xOldElement, UNO_QUERY );
950 if (xSet.is())
951 xSet->removePropertyChangeListener(PROPERTY_NAME, this);
952
953 // give the old element a new (void) parent
954 Reference<XChild> xChild(xOldElement, UNO_QUERY);
955 if (xChild.is())
956 xChild->setParent(css::uno::Reference<css::uno::XInterface> ());
957
958 // remove the old one
959 m_aMap.erase(j);
960
961 // examine the new element
962 OUString sName;
963 DBG_ASSERT(aElementMetaData->xPropertySet.is(),
964 "OInterfaceContainer::implReplaceByIndex: what did approveNewElement do?");
965
966 aElementMetaData->xPropertySet->getPropertyValue(PROPERTY_NAME) >>= sName;
967 aElementMetaData->xPropertySet->addPropertyChangeListener(PROPERTY_NAME, this);
968
969 // insert the new one
970 m_aMap.insert(::std::pair<const OUString, css::uno::Reference<css::uno::XInterface>>(
971 sName, aElementMetaData->xInterface));
972 m_aItems[_nIndex] = aElementMetaData->xInterface;
973
974 aElementMetaData->xChild->setParent(static_cast<XContainer*>(this));
975
976 if ( m_xEventAttacher.is() )
977 {
978 m_xEventAttacher->insertEntry( _nIndex );
979 m_xEventAttacher->attach(_nIndex, aElementMetaData->xInterface,
980 Any(aElementMetaData->xPropertySet));
981 }
982
983 ContainerEvent aReplaceEvent;
984 aReplaceEvent.Source = static_cast< XContainer* >( this );
985 aReplaceEvent.Accessor <<= _nIndex;
986 aReplaceEvent.Element = aElementMetaData->xInterface->queryInterface(m_aElementType);
987 aReplaceEvent.ReplacedElement = xOldElement->queryInterface( m_aElementType );
988
989 impl_replacedElement( aReplaceEvent, _rClearBeforeNotify );
990}
991
992
993void OInterfaceContainer::implCheckIndex( const sal_Int32 _nIndex )
994{
995 if (_nIndex < 0 || o3tl::make_unsigned(_nIndex) >= m_aItems.size())
996 throw IndexOutOfBoundsException();
997}
998
999
1000void SAL_CALL OInterfaceContainer::replaceByIndex(sal_Int32 _nIndex, const Any& Element)
1001{
1002 ::osl::ClearableMutexGuard aGuard( m_rMutex );
1003 // check the index
1004 implCheckIndex( _nIndex );
1005 // do the replace
1006 implReplaceByIndex( _nIndex, Element, aGuard );
1007}
1008
1009
1010void OInterfaceContainer::implRemoveByIndex( const sal_Int32 _nIndex, ::osl::ClearableMutexGuard& _rClearBeforeNotify )
1011{
1012 OSL_PRECOND( ( _nIndex >= 0 ) && ( o3tl::make_unsigned(_nIndex) < m_aItems.size() ), "OInterfaceContainer::implRemoveByIndex: precondition not met (index)!" );
1013
1014 OInterfaceArray::iterator i = m_aItems.begin() + _nIndex;
1015 css::uno::Reference<css::uno::XInterface> xElement(*i);
1016
1017 OInterfaceMap::iterator j = std::find_if(m_aMap.begin(), m_aMap.end(),
1018 [&xElement](const OInterfaceMap::value_type& rEntry) { return rEntry.second == xElement; });
1019
1020 m_aItems.erase(i);
1021 m_aMap.erase(j);
1022
1023 // remove event knittings
1024 if ( m_xEventAttacher.is() )
1025 {
1026 css::uno::Reference<css::uno::XInterface> xNormalized( xElement, UNO_QUERY );
1027 m_xEventAttacher->detach( _nIndex, xNormalized );
1028 m_xEventAttacher->removeEntry( _nIndex );
1029 }
1030
1031 Reference<XPropertySet> xSet(xElement, UNO_QUERY);
1032 if (xSet.is())
1033 xSet->removePropertyChangeListener(PROPERTY_NAME, this);
1034
1035 Reference<XChild> xChild(xElement, UNO_QUERY);
1036 if (xChild.is())
1037 xChild->setParent(css::uno::Reference<css::uno::XInterface> ());
1038
1039 // notify derived classes
1040 implRemoved(xElement);
1041
1042 // notify listeners
1043 ContainerEvent aEvt;
1044 aEvt.Source = static_cast<XContainer*>(this);
1045 aEvt.Element = xElement->queryInterface( m_aElementType );
1046 aEvt.Accessor <<= _nIndex;
1047
1048 _rClearBeforeNotify.clear();
1049 m_aContainerListeners.notifyEach( &XContainerListener::elementRemoved, aEvt );
1050}
1051
1052
1053void SAL_CALL OInterfaceContainer::removeByIndex(sal_Int32 _nIndex)
1054{
1055 ::osl::ClearableMutexGuard aGuard( m_rMutex );
1056 // check the index
1057 implCheckIndex( _nIndex );
1058 // do the removal
1059 implRemoveByIndex( _nIndex, aGuard );
1060}
1061
1062
1064{
1065 return new ElementDescription;
1066}
1067
1068
1069void SAL_CALL OInterfaceContainer::insertByName(const OUString& _rName, const Any& _rElement)
1070{
1071 Reference< XPropertySet > xElementProps;
1072
1073 std::unique_ptr< ElementDescription > aElementMetaData( createElementMetaData() );
1074 DBG_ASSERT(aElementMetaData,
1075 "OInterfaceContainer::insertByName: createElementMetaData returned nonsense!");
1076
1077 // ensure the correct name of the element
1078 try
1079 {
1080 _rElement >>= xElementProps;
1081 approveNewElement( xElementProps, aElementMetaData.get() );
1082
1083 xElementProps->setPropertyValue( PROPERTY_NAME, Any( _rName ) );
1084 }
1085 catch( const IllegalArgumentException& )
1086 {
1087 throw; // allowed to leave
1088 }
1089 catch( const ElementExistException& )
1090 {
1091 throw; // allowed to leave
1092 }
1093 catch( const Exception& )
1094 {
1095 TOOLS_WARN_EXCEPTION("forms.misc", "OInterfaceContainer::insertByName" );
1096 }
1097 implInsert( m_aItems.size(), xElementProps, true, aElementMetaData.get(), true );
1098}
1099
1100
1101void SAL_CALL OInterfaceContainer::replaceByName(const OUString& Name, const Any& Element)
1102{
1103 ::osl::ClearableMutexGuard aGuard( m_rMutex );
1104 ::std::pair <OInterfaceMap::iterator,
1105 OInterfaceMap::iterator> aPair = m_aMap.equal_range(Name);
1106 if (aPair.first == aPair.second)
1107 throw NoSuchElementException();
1108
1109 if (Element.getValueType().getTypeClass() != TypeClass_INTERFACE)
1110 lcl_throwIllegalArgumentException();
1111
1112 Reference<XPropertySet> xSet;
1113 Element >>= xSet;
1114 if (xSet.is())
1115 {
1116 if (!hasProperty(PROPERTY_NAME, xSet))
1117 lcl_throwIllegalArgumentException();
1118
1119 xSet->setPropertyValue(PROPERTY_NAME, Any(Name));
1120 }
1121
1122 // determine the element pos
1123 sal_Int32 nPos = ::std::find(m_aItems.begin(), m_aItems.end(), (*aPair.first).second) - m_aItems.begin();
1124
1125 implReplaceByIndex( nPos, Element, aGuard );
1126}
1127
1128
1129void SAL_CALL OInterfaceContainer::removeByName(const OUString& Name)
1130{
1131 ::osl::MutexGuard aGuard( m_rMutex );
1132 ::std::pair <OInterfaceMap::iterator,
1133 OInterfaceMap::iterator> aPair = m_aMap.equal_range(Name);
1134 if (aPair.first == aPair.second)
1135 throw NoSuchElementException();
1136
1137 sal_Int32 nPos = ::std::find(m_aItems.begin(), m_aItems.end(), (*aPair.first).second) - m_aItems.begin();
1139}
1140
1141
1142// XEventAttacherManager
1143
1144void SAL_CALL OInterfaceContainer::registerScriptEvent( sal_Int32 nIndex, const ScriptEventDescriptor& aScriptEvent )
1145{
1146 ::osl::ClearableMutexGuard aGuard( m_rMutex );
1147 if ( m_xEventAttacher.is() )
1148 {
1149 m_xEventAttacher->registerScriptEvent( nIndex, aScriptEvent );
1150 aGuard.clear();
1151 impl_addVbEvents_nolck_nothrow( nIndex ); // add fake vba events
1152 }
1153}
1154
1155
1156void SAL_CALL OInterfaceContainer::registerScriptEvents( sal_Int32 nIndex, const Sequence< ScriptEventDescriptor >& aScriptEvents )
1157{
1158 ::osl::ClearableMutexGuard aGuard( m_rMutex );
1159 if ( m_xEventAttacher.is() )
1160 {
1161 m_xEventAttacher->registerScriptEvents( nIndex, aScriptEvents );
1162 aGuard.clear();
1163 impl_addVbEvents_nolck_nothrow( nIndex ); // add fake vba events
1164 }
1165}
1166
1167
1168void SAL_CALL OInterfaceContainer::revokeScriptEvent( sal_Int32 nIndex, const OUString& aListenerType, const OUString& aEventMethod, const OUString& aRemoveListenerParam )
1169{
1170 if ( m_xEventAttacher.is() )
1171 m_xEventAttacher->revokeScriptEvent( nIndex, aListenerType, aEventMethod, aRemoveListenerParam );
1172}
1173
1174
1175void SAL_CALL OInterfaceContainer::revokeScriptEvents( sal_Int32 nIndex )
1176{
1177 if ( m_xEventAttacher.is() )
1178 m_xEventAttacher->revokeScriptEvents( nIndex );
1179}
1180
1181
1182void SAL_CALL OInterfaceContainer::insertEntry( sal_Int32 nIndex )
1183{
1184 if ( m_xEventAttacher.is() )
1185 m_xEventAttacher->insertEntry( nIndex );
1186}
1187
1188
1189void SAL_CALL OInterfaceContainer::removeEntry( sal_Int32 nIndex )
1190{
1191 if ( m_xEventAttacher.is() )
1192 m_xEventAttacher->removeEntry( nIndex );
1193}
1194
1195
1196Sequence< ScriptEventDescriptor > SAL_CALL OInterfaceContainer::getScriptEvents( sal_Int32 nIndex )
1197{
1198 Sequence< ScriptEventDescriptor > aReturn;
1199 if ( m_xEventAttacher.is() )
1200 {
1201 aReturn = m_xEventAttacher->getScriptEvents( nIndex );
1202 if ( lcl_hasVbaEvents( aReturn ) )
1203 {
1204 aReturn = lcl_stripVbaEvents( aReturn );
1205 }
1206 }
1207 return aReturn;
1208}
1209
1210
1211void SAL_CALL OInterfaceContainer::attach( sal_Int32 nIndex, const Reference< XInterface >& xObject, const Any& aHelper )
1212{
1213 if ( m_xEventAttacher.is() )
1214 m_xEventAttacher->attach( nIndex, xObject, aHelper );
1215}
1216
1217
1218void SAL_CALL OInterfaceContainer::detach( sal_Int32 nIndex, const Reference< XInterface >& xObject )
1219{
1220 if ( m_xEventAttacher.is() )
1221 m_xEventAttacher->detach( nIndex, xObject );
1222}
1223
1224
1225void SAL_CALL OInterfaceContainer::addScriptListener( const Reference< XScriptListener >& xListener )
1226{
1227 if ( m_xEventAttacher.is() )
1228 m_xEventAttacher->addScriptListener( xListener );
1229}
1230
1231
1232void SAL_CALL OInterfaceContainer::removeScriptListener( const Reference< XScriptListener >& xListener )
1233{
1234 if ( m_xEventAttacher.is() )
1235 m_xEventAttacher->removeScriptListener( xListener );
1236}
1237
1238
1239//= OFormComponents
1240
1241
1243{
1244 Any aReturn = OFormComponents_BASE::queryInterface(_rType);
1245 if (!aReturn.hasValue())
1246 {
1247 aReturn = OInterfaceContainer::queryInterface(_rType);
1248
1249 if (!aReturn.hasValue())
1251 }
1252
1253 return aReturn;
1254}
1255
1256
1257Sequence<Type> SAL_CALL OFormComponents::getTypes()
1258{
1260}
1261
1262
1263OFormComponents::OFormComponents(const Reference<XComponentContext>& _rxFactory)
1264 : ::cppu::OComponentHelper( m_aMutex )
1265 ,OInterfaceContainer( _rxFactory, m_aMutex, cppu::UnoType<XFormComponent>::get() )
1267{
1268}
1269
1270
1272 : ::cppu::OComponentHelper( m_aMutex )
1273 ,OInterfaceContainer( m_aMutex, _cloneSource )
1275{
1276}
1277
1278
1280{
1281 if (! ::cppu::OComponentHelper::rBHelper.bDisposed)
1282 {
1283 acquire();
1284 dispose();
1285 }
1286}
1287
1288// OComponentHelper
1289
1291{
1294 m_xParent = nullptr;
1295}
1296
1297//XChild
1298
1299void OFormComponents::setParent(const css::uno::Reference<css::uno::XInterface>& Parent)
1300{
1301 ::osl::MutexGuard aGuard( m_aMutex );
1302 m_xParent = Parent;
1303}
1304
1305
1306css::uno::Reference<css::uno::XInterface> OFormComponents::getParent()
1307{
1308 return m_xParent;
1309}
1310
1311
1312} // namespace frm
1313
1314
1315/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XComponentContext > m_xContext
constexpr OUStringLiteral sServiceName
sal_Int32 addInterface(const css::uno::Reference< ListenerT > &rxIFace)
void disposeAndClear(const css::lang::EventObject &rEvt)
sal_Int32 removeInterface(const css::uno::Reference< ListenerT > &rxIFace)
void notifyEach(void(SAL_CALL ListenerT::*NotificationMethod)(const EventT &), const EventT &Event)
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
virtual void SAL_CALL acquire() SAL_NOEXCEPT SAL_OVERRIDE
virtual void SAL_CALL disposing()
virtual void SAL_CALL dispose() SAL_OVERRIDE
virtual css::uno::Any SAL_CALL queryAggregation(css::uno::Type const &rType) SAL_OVERRIDE
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
virtual ~OFormComponents() override
virtual void SAL_CALL setParent(const css::uno::Reference< css::uno::XInterface > &Parent) override
virtual void SAL_CALL disposing() override
css::uno::Reference< css::uno::XInterface > m_xParent
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent() override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
OFormComponents(const css::uno::Reference< css::uno::XComponentContext > &_rxFactory)
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &_rType) override
void implCheckIndex(const sal_Int32 _nIndex)
validates the given index
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
const css::uno::Type m_aElementType
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
virtual void SAL_CALL registerScriptEvent(sal_Int32 nIndex, const css::script::ScriptEventDescriptor &aScriptEvent) override
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 _nIndex) override
virtual void SAL_CALL removeByName(const OUString &Name) override
virtual void SAL_CALL detach(sal_Int32 nIndex, const css::uno::Reference< css::uno::XInterface > &xObject) override
virtual void SAL_CALL revokeScriptEvents(sal_Int32 nIndex) override
void impl_addVbEvents_nolck_nothrow(const sal_Int32 i_nIndex)
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
void implReplaceByIndex(const sal_Int32 _nIndex, const css::uno::Any &_rNewElement, ::osl::ClearableMutexGuard &_rClearBeforeNotify)
replace an element, specified by position
void SAL_CALL writeEvents(const css::uno::Reference< css::io::XObjectOutputStream > &_rxOutStream)
virtual void SAL_CALL insertByIndex(sal_Int32 _nIndex, const css::uno::Any &Element) override
virtual void SAL_CALL insertEntry(sal_Int32 nIndex) override
virtual void SAL_CALL revokeScriptEvent(sal_Int32 nIndex, const OUString &aListenerType, const OUString &aEventMethod, const OUString &aRemoveListenerParam) override
virtual ElementDescription * createElementMetaData()
virtual void SAL_CALL attach(sal_Int32 nIndex, const css::uno::Reference< css::uno::XInterface > &xObject, const css::uno::Any &aHelper) override
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
virtual void approveNewElement(const css::uno::Reference< css::beans::XPropertySet > &_rxObject, ElementDescription *_pElement)
to be overridden if elements which are to be inserted into the container shall be checked
OInterfaceContainer(const css::uno::Reference< css::uno::XComponentContext > &_rxFactory, ::osl::Mutex &_rMutex, const css::uno::Type &_rElementType)
virtual void SAL_CALL disposing()
virtual void SAL_CALL replaceByIndex(sal_Int32 _nIndex, const css::uno::Any &_rElement) override
virtual void SAL_CALL removeByIndex(sal_Int32 _nIndex) override
virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent &evt) override
virtual void SAL_CALL insertByName(const OUString &Name, const css::uno::Any &_rElement) override
virtual void SAL_CALL addContainerListener(const css::uno::Reference< css::container::XContainerListener > &_rxListener) override
virtual sal_Bool SAL_CALL hasElements() override
css::uno::Reference< css::uno::XComponentContext > m_xContext
virtual void SAL_CALL registerScriptEvents(sal_Int32 nIndex, const css::uno::Sequence< css::script::ScriptEventDescriptor > &aScriptEvents) override
void SAL_CALL readEvents(const css::uno::Reference< css::io::XObjectInputStream > &_rxInStream)
virtual void SAL_CALL replaceByName(const OUString &Name, const css::uno::Any &_rElement) override
virtual css::uno::Sequence< css::script::ScriptEventDescriptor > SAL_CALL getScriptEvents(sal_Int32 Index) override
virtual void SAL_CALL removeScriptListener(const css::uno::Reference< css::script::XScriptListener > &Listener) override
void implInsert(sal_Int32 _nIndex, const css::uno::Reference< css::beans::XPropertySet > &_rxObject, bool _bEvents, ElementDescription *_pApprovalResult, bool _bFire)
inserts an object into our internal structures
void implRemoveByIndex(const sal_Int32 _nIndex, ::osl::ClearableMutexGuard &_rClearBeforeNotify)
removes an element, specified by position
virtual void SAL_CALL write(const css::uno::Reference< css::io::XObjectOutputStream > &OutStream) override
::comphelper::OInterfaceContainerHelper3< css::container::XContainerListener > m_aContainerListeners
virtual void implRemoved(const css::uno::Reference< css::uno::XInterface > &_rxObject)
virtual void SAL_CALL addScriptListener(const css::uno::Reference< css::script::XScriptListener > &xListener) override
virtual void implInserted(const ElementDescription *_pElement)
virtual void SAL_CALL read(const css::uno::Reference< css::io::XObjectInputStream > &InStream) override
virtual void impl_replacedElement(const css::container::ContainerEvent &_rEvent, ::osl::ClearableMutexGuard &_rInstanceLock)
called after an object was replaced.
void clonedFrom(const OInterfaceContainer &_cloneSource)
virtual void SAL_CALL removeEntry(sal_Int32 nIndex) override
css::uno::Reference< css::script::XEventAttacherManager > m_xEventAttacher
virtual sal_Int32 SAL_CALL getCount() override
virtual css::uno::Type SAL_CALL getElementType() override
virtual void SAL_CALL removeContainerListener(const css::uno::Reference< css::container::XContainerListener > &_rxListener) override
int nCount
::osl::Mutex & m_rMutex
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
Any aHelper
OUString sName
constexpr OUStringLiteral PROPERTY_NAME
Definition: frm_strings.hxx:28
constexpr OUStringLiteral PROPERTY_TAG
Definition: frm_strings.hxx:27
OUString sPrefix
std::mutex m_aMutex
sal_Int32 nIndex
sal_uInt16 nPos
#define SAL_WARN(area, stream)
@ Exception
bool hasProperty(const OUString &_rName, const Reference< XPropertySet > &_rxSet)
css::uno::Sequence< typename M::key_type > mapKeysToSequence(M const &map)
Type
OUString loadString(TranslateId aResId)
loads the string with the specified resource id from the FormLayer mo file
ListBox is a bit confusing / different from other form components, so here are a few notes:
Definition: BaseListBox.hxx:25
static Sequence< ScriptEventDescriptor > lcl_stripVbaEvents(const Sequence< ScriptEventDescriptor > &sEvents)
static bool lcl_hasVbaEvents(const Sequence< ScriptEventDescriptor > &sEvents)
css::uno::Reference< css::frame::XModel > getXModel(const css::uno::Reference< css::uno::XInterface > &_rxComponent)
int i
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
enumrange< T >::Iterator begin(enumrange< T >)
end
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
constexpr OUStringLiteral FRM_COMPONENT_HIDDENCONTROL
Definition: services.hxx:84
css::uno::Reference< css::beans::XPropertySet > xPropertySet
css::uno::Reference< css::uno::XInterface > xInterface
css::uno::Reference< css::container::XChild > xChild
OUString Name
unsigned char sal_Bool