LibreOffice Module basic (master) 1
sbunoobj.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <sal/config.h>
21
22#include <o3tl/any.hxx>
23#include <o3tl/safeint.hxx>
24#include <utility>
25#include <vcl/svapp.hxx>
27#include <svl/hint.hxx>
28
35
36#include <rtl/math.hxx>
37#include <rtl/ustrbuf.hxx>
38
39#include <com/sun/star/script/ArrayWrapper.hpp>
40#include <com/sun/star/script/CannotConvertException.hpp>
41#include <com/sun/star/script/NativeObjectWrapper.hpp>
42
43#include <com/sun/star/uno/XComponentContext.hpp>
44#include <com/sun/star/uno/DeploymentException.hpp>
45#include <com/sun/star/lang/XTypeProvider.hpp>
46#include <com/sun/star/lang/XSingleServiceFactory.hpp>
47#include <com/sun/star/lang/XMultiServiceFactory.hpp>
48#include <com/sun/star/lang/XServiceInfo.hpp>
49#include <com/sun/star/beans/PropertyAttribute.hpp>
50#include <com/sun/star/beans/PropertyConcept.hpp>
51#include <com/sun/star/beans/MethodConcept.hpp>
52#include <com/sun/star/beans/XPropertySet.hpp>
53#include <com/sun/star/beans/theIntrospection.hpp>
54#include <com/sun/star/script/BasicErrorException.hpp>
55#include <com/sun/star/script/InvocationAdapterFactory.hpp>
56#include <com/sun/star/script/XAllListener.hpp>
57#include <com/sun/star/script/Converter.hpp>
58#include <com/sun/star/script/XDefaultProperty.hpp>
59#include <com/sun/star/script/XDirectInvocation.hpp>
60#include <com/sun/star/container/XNameAccess.hpp>
61#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
62#include <com/sun/star/reflection/XIdlArray.hpp>
63#include <com/sun/star/reflection/XIdlReflection.hpp>
64#include <com/sun/star/reflection/XServiceConstructorDescription.hpp>
65#include <com/sun/star/reflection/XSingletonTypeDescription.hpp>
66#include <com/sun/star/reflection/theCoreReflection.hpp>
67#include <com/sun/star/bridge/oleautomation/NamedArgument.hpp>
68#include <com/sun/star/bridge/oleautomation/Date.hpp>
69#include <com/sun/star/bridge/oleautomation/Decimal.hpp>
70#include <com/sun/star/bridge/oleautomation/Currency.hpp>
71#include <com/sun/star/bridge/oleautomation/XAutomationObject.hpp>
72#include <com/sun/star/script/XAutomationInvocation.hpp>
73
74#include <rtlproto.hxx>
75
76#include <basic/sbstar.hxx>
77#include <basic/sbuno.hxx>
78#include <basic/sberrors.hxx>
79#include <sbunoobj.hxx>
80#include <sbintern.hxx>
81#include <runtime.hxx>
82
83#include <algorithm>
84#include <math.h>
85#include <memory>
86#include <string_view>
87#include <unordered_map>
88#include <com/sun/star/reflection/XTypeDescriptionEnumerationAccess.hpp>
89#include <com/sun/star/reflection/XConstantsTypeDescription.hpp>
90
92using namespace com::sun::star::uno;
93using namespace com::sun::star::lang;
94using namespace com::sun::star::reflection;
95using namespace com::sun::star::beans;
96using namespace com::sun::star::script;
97using namespace com::sun::star::container;
98using namespace com::sun::star::bridge;
99using namespace cppu;
100
101
102// Identifiers for creating the strings for dbg_Properties
103constexpr OUStringLiteral ID_DBG_SUPPORTEDINTERFACES = u"Dbg_SupportedInterfaces";
104constexpr OUStringLiteral ID_DBG_PROPERTIES = u"Dbg_Properties";
105constexpr OUStringLiteral ID_DBG_METHODS = u"Dbg_Methods";
106
107char const aSeqLevelStr[] = "[]";
108
109// Gets the default property for a uno object. Note: There is some
110// redirection built in. The property name specifies the name
111// of the default property.
112
113bool SbUnoObject::getDefaultPropName( SbUnoObject const * pUnoObj, OUString& sDfltProp )
114{
115 bool bResult = false;
116 Reference< XDefaultProperty> xDefaultProp( pUnoObj->maTmpUnoObj, UNO_QUERY );
117 if ( xDefaultProp.is() )
118 {
119 sDfltProp = xDefaultProp->getDefaultPropertyName();
120 if ( !sDfltProp.isEmpty() )
121 bResult = true;
122 }
123 return bResult;
124}
125
127{
128 SbxVariable* pDefaultProp = nullptr;
129 if ( pRef->GetType() == SbxOBJECT )
130 {
131 SbxObject* pObj = dynamic_cast<SbxObject*>(pRef);
132 if (!pObj)
133 {
134 SbxBase* pObjVarObj = pRef->GetObject();
135 pObj = dynamic_cast<SbxObject*>( pObjVarObj );
136 }
137 if (SbUnoObject* pUnoObj = dynamic_cast<SbUnoObject*>(pObj))
138 {
139 pDefaultProp = pUnoObj->GetDfltProperty();
140 }
141 }
142 return pDefaultProp;
143}
144
146{
147 SbUnoObject* pUnoObj = dynamic_cast<SbUnoObject*>( pObj );
148 if ( pUnoObj )
149 {
150 OUString sDfltPropName;
151
152 if ( SbUnoObject::getDefaultPropName( pUnoObj, sDfltPropName ) )
153 {
154 pUnoObj->SetDfltProperty( sDfltPropName );
156 }
157}
158
159// save CoreReflection statically
161{
162 return css::reflection::theCoreReflection::get(
164}
165
166// save CoreReflection statically
168{
169 static Reference< XHierarchicalNameAccess > xCoreReflection_HierarchicalNameAccess;
170
171 if( !xCoreReflection_HierarchicalNameAccess.is() )
172 {
174 if( xCoreReflection.is() )
175 {
176 xCoreReflection_HierarchicalNameAccess =
178 }
179 }
180 return xCoreReflection_HierarchicalNameAccess;
181}
182
183// Hold TypeProvider statically
185{
187
188 // Do we have already CoreReflection; if not obtain it
189 if( !xAccess.is() )
190 {
193 if( xContext.is() )
194 {
195 xContext->getValueByName(
196 "/singletons/com.sun.star.reflection.theTypeDescriptionManager" )
197 >>= xAccess;
198 OSL_ENSURE( xAccess.is(), "### TypeDescriptionManager singleton not accessible!?" );
199 }
200 if( !xAccess.is() )
201 {
202 throw DeploymentException(
203 "/singletons/com.sun.star.reflection.theTypeDescriptionManager singleton not accessible" );
204 }
205 }
206 return xAccess;
207}
208
209// Hold TypeConverter statically
211{
213
214 // Do we have already CoreReflection; if not obtain it
215 if( !xTypeConverter.is() )
216 {
219 if( xContext.is() )
220 {
221 xTypeConverter = Converter::create(xContext);
222 }
223 if( !xTypeConverter.is() )
224 {
225 throw DeploymentException(
226 "com.sun.star.script.Converter service not accessible" );
227 }
228 }
229 return xTypeConverter;
230}
231
232
233// #111851 factory function to create an OLE object
234SbUnoObject* createOLEObject_Impl( const OUString& aType )
235{
236 static const Reference<XMultiServiceFactory> xOLEFactory = [] {
239 if( xContext.is() )
240 {
241 Reference<XMultiComponentFactory> xSMgr = xContext->getServiceManager();
242 xFactory.set(
243 xSMgr->createInstanceWithContext( "com.sun.star.bridge.OleObjectFactory", xContext ),
244 UNO_QUERY );
245 }
246 return xFactory;
247 }();
248
249 SbUnoObject* pUnoObj = nullptr;
250 if( xOLEFactory.is() )
251 {
252 // some type names available in VBA can not be directly used in COM
253 OUString aOLEType = aType;
254 if ( aOLEType == "SAXXMLReader30" )
255 {
256 aOLEType = "Msxml2.SAXXMLReader.3.0";
257 }
258 Reference< XInterface > xOLEObject = xOLEFactory->createInstance( aOLEType );
259 if( xOLEObject.is() )
260 {
261 pUnoObj = new SbUnoObject( aType, Any(xOLEObject) );
262 OUString sDfltPropName;
263
264 if ( SbUnoObject::getDefaultPropName( pUnoObj, sDfltPropName ) )
265 pUnoObj->SetDfltProperty( sDfltPropName );
266 }
267 }
268 return pUnoObj;
269}
270
271
272namespace
273{
274 void lcl_indent( OUStringBuffer& _inout_rBuffer, sal_Int32 _nLevel )
275 {
276 while ( _nLevel-- > 0 )
277 {
278 _inout_rBuffer.append( " " );
279 }
280 }
281}
282
283static void implAppendExceptionMsg( OUStringBuffer& _inout_rBuffer, const Exception& _e, std::u16string_view _rExceptionType, sal_Int32 _nLevel )
284{
285 _inout_rBuffer.append( "\n" );
286 lcl_indent( _inout_rBuffer, _nLevel );
287 _inout_rBuffer.append( "Type: " );
288
289 if ( _rExceptionType.empty() )
290 _inout_rBuffer.append( "Unknown" );
291 else
292 _inout_rBuffer.append( _rExceptionType );
293
294 _inout_rBuffer.append( "\n" );
295 lcl_indent( _inout_rBuffer, _nLevel );
296 _inout_rBuffer.append( "Message: " );
297 _inout_rBuffer.append( _e.Message );
298
299}
300
301// construct an error message for the exception
302static OUString implGetExceptionMsg( const Exception& e, std::u16string_view aExceptionType_ )
303{
304 OUStringBuffer aMessageBuf;
305 implAppendExceptionMsg( aMessageBuf, e, aExceptionType_, 0 );
306 return aMessageBuf.makeStringAndClear();
307}
308
309static OUString implGetExceptionMsg( const Any& _rCaughtException )
310{
311 auto e = o3tl::tryAccess<Exception>(_rCaughtException);
312 OSL_PRECOND( e, "implGetExceptionMsg: illegal argument!" );
313 if ( !e )
314 {
315 return OUString();
316 }
317 return implGetExceptionMsg( *e, _rCaughtException.getValueTypeName() );
318}
319
320static Any convertAny( const Any& rVal, const Type& aDestType )
321{
322 Any aConvertedVal;
324 try
325 {
326 aConvertedVal = xConverter->convertTo( rVal, aDestType );
327 }
328 catch( const IllegalArgumentException& )
329 {
331 implGetExceptionMsg( ::cppu::getCaughtException() ) );
332 return aConvertedVal;
333 }
334 catch( const CannotConvertException& e2 )
335 {
337 implGetExceptionMsg( e2, u"com.sun.star.lang.IllegalArgumentException" ) );
338 return aConvertedVal;
339 }
340 return aConvertedVal;
341}
342
343
344// #105565 Special Object to wrap a strongly typed Uno Any
345
346
347// TODO: source out later
349{
350 return getCoreReflection_Impl()->forName(rType.getTypeName());
351}
352
353// Exception type unknown
354template< class EXCEPTION >
355static OUString implGetExceptionMsg( const EXCEPTION& e )
356{
357 return implGetExceptionMsg( e, cppu::UnoType<decltype(e)>::get().getTypeName() );
358}
359
360static void implHandleBasicErrorException( BasicErrorException const & e )
361{
362 ErrCode nError = StarBASIC::GetSfxFromVBError( static_cast<sal_uInt16>(e.ErrorCode) );
363 StarBASIC::Error( nError, e.ErrorMessageArgument );
364}
365
366static void implHandleWrappedTargetException( const Any& _rWrappedTargetException )
367{
368 Any aExamine( _rWrappedTargetException );
369
370 // completely strip the first InvocationTargetException, its error message isn't of any
371 // interest to the user, it just says something like "invoking the UNO method went wrong.".
372 InvocationTargetException aInvocationError;
373 if ( aExamine >>= aInvocationError )
374 aExamine = aInvocationError.TargetException;
375
376 BasicErrorException aBasicError;
377
379 OUStringBuffer aMessageBuf;
380
381 // strip any other WrappedTargetException instances, but this time preserve the error messages.
382 WrappedTargetException aWrapped;
383 sal_Int32 nLevel = 0;
384 while ( aExamine >>= aWrapped )
385 {
386 // special handling for BasicErrorException errors
387 if ( aWrapped.TargetException >>= aBasicError )
388 {
389 nError = StarBASIC::GetSfxFromVBError( static_cast<sal_uInt16>(aBasicError.ErrorCode) );
390 aMessageBuf.append( aBasicError.ErrorMessageArgument );
391 aExamine.clear();
392 break;
393 }
394
395 // append this round's message
396 implAppendExceptionMsg( aMessageBuf, aWrapped, aExamine.getValueTypeName(), nLevel );
397 if ( aWrapped.TargetException.getValueTypeClass() == TypeClass_EXCEPTION )
398 // there is a next chain element
399 aMessageBuf.append( "\nTargetException:" );
400
401 // next round
402 aExamine = aWrapped.TargetException;
403 ++nLevel;
404 }
405
406 if ( auto e = o3tl::tryAccess<Exception>(aExamine) )
407 {
408 // the last element in the chain is still an exception, but no WrappedTargetException
409 implAppendExceptionMsg( aMessageBuf, *e, aExamine.getValueTypeName(), nLevel );
410 }
411
412 StarBASIC::Error( nError, aMessageBuf.makeStringAndClear() );
413}
414
415static void implHandleAnyException( const Any& _rCaughtException )
416{
417 BasicErrorException aBasicError;
418 WrappedTargetException aWrappedError;
419
420 if ( _rCaughtException >>= aBasicError )
421 {
422 implHandleBasicErrorException( aBasicError );
423 }
424 else if ( _rCaughtException >>= aWrappedError )
425 {
426 implHandleWrappedTargetException( _rCaughtException );
427 }
428 else
429 {
431 }
432}
433
434namespace {
435
436// NativeObjectWrapper handling
437struct ObjectItem
438{
439 SbxObjectRef m_xNativeObj;
440
441 explicit ObjectItem( SbxObject* pNativeObj )
442 : m_xNativeObj( pNativeObj )
443 {}
444};
445
446}
447
448typedef std::vector< ObjectItem > NativeObjectWrapperVector;
449
450namespace {
451
452NativeObjectWrapperVector gaNativeObjectWrapperVector;
453
454}
455
457{
458 gaNativeObjectWrapperVector.clear();
459}
460
461static sal_uInt32 lcl_registerNativeObjectWrapper( SbxObject* pNativeObj )
462{
463 sal_uInt32 nIndex = gaNativeObjectWrapperVector.size();
464 gaNativeObjectWrapperVector.emplace_back( pNativeObj );
465 return nIndex;
466}
467
468static SbxObject* lcl_getNativeObject( sal_uInt32 nIndex )
469{
470 SbxObjectRef xRetObj;
471 if( nIndex < gaNativeObjectWrapperVector.size() )
472 {
473 ObjectItem& rItem = gaNativeObjectWrapperVector[ nIndex ];
474 xRetObj = rItem.m_xNativeObj;
475 }
476 return xRetObj.get();
477}
478
479// convert from Uno to Sbx
480static SbxDataType unoToSbxType( TypeClass eType )
481{
482 SbxDataType eRetType = SbxVOID;
483
484 switch( eType )
485 {
486 case TypeClass_INTERFACE:
487 case TypeClass_TYPE:
488 case TypeClass_STRUCT:
489 case TypeClass_EXCEPTION: eRetType = SbxOBJECT; break;
490
491 case TypeClass_ENUM: eRetType = SbxLONG; break;
492 case TypeClass_SEQUENCE:
493 eRetType = SbxDataType( SbxOBJECT | SbxARRAY );
494 break;
495
496
497 case TypeClass_ANY: eRetType = SbxVARIANT; break;
498 case TypeClass_BOOLEAN: eRetType = SbxBOOL; break;
499 case TypeClass_CHAR: eRetType = SbxCHAR; break;
500 case TypeClass_STRING: eRetType = SbxSTRING; break;
501 case TypeClass_FLOAT: eRetType = SbxSINGLE; break;
502 case TypeClass_DOUBLE: eRetType = SbxDOUBLE; break;
503 case TypeClass_BYTE: eRetType = SbxINTEGER; break;
504 case TypeClass_SHORT: eRetType = SbxINTEGER; break;
505 case TypeClass_LONG: eRetType = SbxLONG; break;
506 case TypeClass_HYPER: eRetType = SbxSALINT64; break;
507 case TypeClass_UNSIGNED_SHORT: eRetType = SbxUSHORT; break;
508 case TypeClass_UNSIGNED_LONG: eRetType = SbxULONG; break;
509 case TypeClass_UNSIGNED_HYPER: eRetType = SbxSALUINT64;break;
510 default: break;
511 }
512 return eRetType;
513}
514
516{
517 SbxDataType eRetType = SbxVOID;
518 if( xIdlClass.is() )
519 {
520 TypeClass eType = xIdlClass->getTypeClass();
521 eRetType = unoToSbxType( eType );
522 }
523 return eRetType;
524}
525
526static void implSequenceToMultiDimArray( SbxDimArray*& pArray, Sequence< sal_Int32 >& indices, Sequence< sal_Int32 >& sizes, const Any& aValue, sal_Int32 dimension, bool bIsZeroIndex, Type const * pType )
527{
528 const Type& aType = aValue.getValueType();
529 TypeClass eTypeClass = aType.getTypeClass();
530
531 sal_Int32 dimCopy = dimension;
532
533 if ( eTypeClass == TypeClass_SEQUENCE )
534 {
535 Reference< XIdlClass > xIdlTargetClass = TypeToIdlClass( aType );
536 Reference< XIdlArray > xIdlArray = xIdlTargetClass->getArray();
537 typelib_TypeDescription * pTD = nullptr;
538 aType.getDescription( &pTD );
539 Type aElementType( reinterpret_cast<typelib_IndirectTypeDescription *>(pTD)->pType );
540 ::typelib_typedescription_release( pTD );
541
542 sal_Int32 nLen = xIdlArray->getLen( aValue );
543 for ( sal_Int32 index = 0; index < nLen; ++index )
544 {
545 auto pindices = indices.getArray();
546 Any aElementAny = xIdlArray->get( aValue, static_cast<sal_uInt32>(index) );
547 // This detects the dimension were currently processing
548 if ( dimCopy == dimension )
549 {
550 ++dimCopy;
551 if ( sizes.getLength() < dimCopy )
552 {
553 sizes.realloc( sizes.getLength() + 1 );
554 sizes.getArray()[ sizes.getLength() - 1 ] = nLen;
555 indices.realloc( indices.getLength() + 1 );
556 pindices = indices.getArray();
557 }
558 }
559
560 if ( bIsZeroIndex )
561 pindices[ dimCopy - 1 ] = index;
562 else
563 pindices[ dimCopy - 1] = index + 1;
564
565 implSequenceToMultiDimArray( pArray, indices, sizes, aElementAny, dimCopy, bIsZeroIndex, &aElementType );
566 }
567
568 }
569 else
570 {
571 if ( !indices.hasElements() )
572 {
573 // Should never ever get here ( indices.getLength()
574 // should equal number of dimensions in the array )
575 // And that should at least be 1 !
576 // #QUESTION is there a better error?
578 return;
579 }
580
581 SbxDataType eSbxElementType = unoToSbxType( pType ? pType->getTypeClass() : aValue.getValueTypeClass() );
582 if ( !pArray )
583 {
584 pArray = new SbxDimArray( eSbxElementType );
585 sal_Int32 nIndexLen = indices.getLength();
586
587 // Dimension the array
588 for ( sal_Int32 index = 0; index < nIndexLen; ++index )
589 {
590 if ( bIsZeroIndex )
591 pArray->unoAddDim(0, sizes[index] - 1);
592 else
593 pArray->unoAddDim(1, sizes[index]);
594
595 }
596 }
597
598 if ( pArray )
599 {
600 auto xVar = tools::make_ref<SbxVariable>( eSbxElementType );
601 unoToSbxValue( xVar.get(), aValue );
602
603 sal_Int32* pIndices = indices.getArray();
604 pArray->Put(xVar.get(), pIndices);
605
606 }
607 }
608}
609
610void unoToSbxValue( SbxVariable* pVar, const Any& aValue )
611{
612 const Type& aType = aValue.getValueType();
613 TypeClass eTypeClass = aType.getTypeClass();
614 switch( eTypeClass )
615 {
616 case TypeClass_TYPE:
617 {
618 // Map Type to IdlClass
619 Type aType_;
620 aValue >>= aType_;
621 Reference<XIdlClass> xClass = TypeToIdlClass( aType_ );
622 Any aClassAny;
623 aClassAny <<= xClass;
624
625 // instantiate SbUnoObject
626 SbUnoObject* pSbUnoObject = new SbUnoObject( OUString(), aClassAny );
627 SbxObjectRef xWrapper = static_cast<SbxObject*>(pSbUnoObject);
628
629 // If the object is invalid deliver null
630 if( !pSbUnoObject->getUnoAny().hasValue() )
631 {
632 pVar->PutObject( nullptr );
633 }
634 else
635 {
636 pVar->PutObject( xWrapper.get() );
637 }
638 }
639 break;
640 // Interfaces and Structs must be wrapped in a SbUnoObject
641 case TypeClass_INTERFACE:
642 case TypeClass_STRUCT:
643 case TypeClass_EXCEPTION:
644 {
645 if( eTypeClass == TypeClass_STRUCT )
646 {
647 ArrayWrapper aWrap;
648 NativeObjectWrapper aNativeObjectWrapper;
649 if ( aValue >>= aWrap )
650 {
651 SbxDimArray* pArray = nullptr;
652 Sequence< sal_Int32 > indices;
654 implSequenceToMultiDimArray( pArray, indices, sizes, aWrap.Array, /*dimension*/0, aWrap.IsZeroIndex, nullptr );
655 if ( pArray )
656 {
657 SbxDimArrayRef xArray = pArray;
658 SbxFlagBits nFlags = pVar->GetFlags();
660 pVar->PutObject( xArray.get() );
661 pVar->SetFlags( nFlags );
662 }
663 else
664 pVar->PutEmpty();
665 break;
666 }
667 else if ( aValue >>= aNativeObjectWrapper )
668 {
669 sal_uInt32 nIndex = 0;
670 if( aNativeObjectWrapper.ObjectId >>= nIndex )
671 {
673 pVar->PutObject( pObj );
674 }
675 else
676 pVar->PutEmpty();
677 break;
678 }
679 else
680 {
681 SbiInstance* pInst = GetSbData()->pInst;
682 if( pInst && pInst->IsCompatibility() )
683 {
684 oleautomation::Date aDate;
685 if( aValue >>= aDate )
686 {
687 pVar->PutDate( aDate.Value );
688 break;
689 }
690 else
691 {
692 oleautomation::Decimal aDecimal;
693 if( aValue >>= aDecimal )
694 {
695 pVar->PutDecimal( aDecimal );
696 break;
697 }
698 else
699 {
700 oleautomation::Currency aCurrency;
701 if( aValue >>= aCurrency )
702 {
703 pVar->PutCurrency( aCurrency.Value );
704 break;
705 }
706 }
707 }
708 }
709 }
710 }
711 // instantiate a SbUnoObject
712 SbUnoObject* pSbUnoObject = new SbUnoObject( OUString(), aValue );
713 //If this is called externally e.g. from the scripting
714 //framework then there is no 'active' runtime the default property will not be set up
715 //only a vba object will have XDefaultProp set anyway so... this
716 //test seems a bit of overkill
717 //if ( SbiRuntime::isVBAEnabled() )
718 {
719 OUString sDfltPropName;
720
721 if ( SbUnoObject::getDefaultPropName( pSbUnoObject, sDfltPropName ) )
722 {
723 pSbUnoObject->SetDfltProperty( sDfltPropName );
724 }
725 }
726 SbxObjectRef xWrapper = static_cast<SbxObject*>(pSbUnoObject);
727
728 // If the object is invalid deliver null
729 if( !pSbUnoObject->getUnoAny().hasValue() )
730 {
731 pVar->PutObject( nullptr );
732 }
733 else
734 {
735 pVar->PutObject( xWrapper.get() );
736 }
737 }
738 break;
739
740
741 case TypeClass_ENUM:
742 {
743 sal_Int32 nEnum = 0;
744 enum2int( nEnum, aValue );
745 pVar->PutLong( nEnum );
746 }
747 break;
748
749 case TypeClass_SEQUENCE:
750 {
751 Reference< XIdlClass > xIdlTargetClass = TypeToIdlClass( aType );
752 Reference< XIdlArray > xIdlArray = xIdlTargetClass->getArray();
753 sal_Int32 i, nLen = xIdlArray->getLen( aValue );
754
755 typelib_TypeDescription * pTD = nullptr;
756 aType.getDescription( &pTD );
757 assert( pTD && pTD->eTypeClass == typelib_TypeClass_SEQUENCE );
758 Type aElementType( reinterpret_cast<typelib_IndirectTypeDescription *>(pTD)->pType );
759 ::typelib_typedescription_release( pTD );
760
761 // build an Array in Basic
762 SbxDimArrayRef xArray;
763 SbxDataType eSbxElementType = unoToSbxType( aElementType.getTypeClass() );
764 xArray = new SbxDimArray( eSbxElementType );
765 if( nLen > 0 )
766 {
767 xArray->unoAddDim(0, nLen - 1);
768
769 // register the elements as variables
770 for( i = 0 ; i < nLen ; i++ )
771 {
772 // convert elements
773 Any aElementAny = xIdlArray->get( aValue, static_cast<sal_uInt32>(i) );
774 auto xVar = tools::make_ref<SbxVariable>( eSbxElementType );
775 unoToSbxValue( xVar.get(), aElementAny );
776
777 // put into the Array
778 xArray->Put(xVar.get(), &i);
779 }
780 }
781 else
782 {
783 xArray->unoAddDim(0, -1);
784 }
785
786 // return the Array
787 SbxFlagBits nFlags = pVar->GetFlags();
789 pVar->PutObject( xArray.get() );
790 pVar->SetFlags( nFlags );
791
792 }
793 break;
794
795
796 case TypeClass_BOOLEAN: pVar->PutBool( *o3tl::forceAccess<bool>(aValue) ); break;
797 case TypeClass_CHAR:
798 {
799 pVar->PutChar( *o3tl::forceAccess<sal_Unicode>(aValue) );
800 break;
801 }
802 case TypeClass_STRING: { OUString val; aValue >>= val; pVar->PutString( val ); } break;
803 case TypeClass_FLOAT: { float val = 0; aValue >>= val; pVar->PutSingle( val ); } break;
804 case TypeClass_DOUBLE: { double val = 0; aValue >>= val; pVar->PutDouble( val ); } break;
805 case TypeClass_BYTE: { sal_Int8 val = 0; aValue >>= val; pVar->PutInteger( val ); } break;
806 case TypeClass_SHORT: { sal_Int16 val = 0; aValue >>= val; pVar->PutInteger( val ); } break;
807 case TypeClass_LONG: { sal_Int32 val = 0; aValue >>= val; pVar->PutLong( val ); } break;
808 case TypeClass_HYPER: { sal_Int64 val = 0; aValue >>= val; pVar->PutInt64( val ); } break;
809 case TypeClass_UNSIGNED_SHORT: { sal_uInt16 val = 0; aValue >>= val; pVar->PutUShort( val ); } break;
810 case TypeClass_UNSIGNED_LONG: { sal_uInt32 val = 0; aValue >>= val; pVar->PutULong( val ); } break;
811 case TypeClass_UNSIGNED_HYPER: { sal_uInt64 val = 0; aValue >>= val; pVar->PutUInt64( val ); } break;
812 default: pVar->PutEmpty(); break;
813 }
814}
815
816// Deliver the reflection for Sbx types
818{
819 Type aRetType = cppu::UnoType<void>::get();
820 switch( eType )
821 {
822 case SbxNULL: aRetType = cppu::UnoType<XInterface>::get(); break;
823 case SbxINTEGER: aRetType = cppu::UnoType<sal_Int16>::get(); break;
824 case SbxLONG: aRetType = cppu::UnoType<sal_Int32>::get(); break;
825 case SbxSINGLE: aRetType = cppu::UnoType<float>::get(); break;
826 case SbxDOUBLE: aRetType = cppu::UnoType<double>::get(); break;
829 case SbxDATE: {
830 SbiInstance* pInst = GetSbData()->pInst;
831 if( pInst && pInst->IsCompatibility() )
832 aRetType = cppu::UnoType<double>::get();
833 else
835 }
836 break;
837 case SbxSTRING: aRetType = cppu::UnoType<OUString>::get(); break;
838 case SbxBOOL: aRetType = cppu::UnoType<sal_Bool>::get(); break;
839 case SbxVARIANT: aRetType = cppu::UnoType<Any>::get(); break;
840 case SbxCHAR: aRetType = cppu::UnoType<cppu::UnoCharType>::get(); break;
841 case SbxBYTE: aRetType = cppu::UnoType<sal_Int8>::get(); break;
843 case SbxULONG: aRetType = ::cppu::UnoType<sal_uInt32>::get(); break;
844 // map machine-dependent ones to long for consistency
845 case SbxINT: aRetType = ::cppu::UnoType<sal_Int32>::get(); break;
846 case SbxUINT: aRetType = ::cppu::UnoType<sal_uInt32>::get(); break;
847 default: break;
848 }
849 return aRetType;
850}
851
852// Converting of Sbx to Uno without a know target class for TypeClass_ANY
854{
855 Type aRetType = cppu::UnoType<void>::get();
856 if( !pVal )
857 return aRetType;
858
859 // convert SbxType to Uno
860 SbxDataType eBaseType = pVal->SbxValue::GetType();
861 if( eBaseType == SbxOBJECT )
862 {
863 SbxBaseRef xObj = pVal->GetObject();
864 if( !xObj.is() )
865 {
867 return aRetType;
868 }
869
870 if( auto pArray = dynamic_cast<SbxDimArray*>( xObj.get() ) )
871 {
872 sal_Int32 nDims = pArray->GetDims();
873 Type aElementType = getUnoTypeForSbxBaseType( static_cast<SbxDataType>(pArray->GetType() & 0xfff) );
874 TypeClass eElementTypeClass = aElementType.getTypeClass();
875
876 // Normal case: One dimensional array
877 sal_Int32 nLower, nUpper;
878 if (nDims == 1 && pArray->GetDim(1, nLower, nUpper))
879 {
880 if( eElementTypeClass == TypeClass_VOID || eElementTypeClass == TypeClass_ANY )
881 {
882 // If all elements of the arrays are from the same type, take
883 // this one - otherwise the whole will be considered as Any-Sequence
884 bool bNeedsInit = true;
885
886 for (sal_Int32 aIdx[1] = { nLower }; aIdx[0] <= nUpper; ++aIdx[0])
887 {
888 SbxVariableRef xVar = pArray->Get(aIdx);
889 Type aType = getUnoTypeForSbxValue( xVar.get() );
890 if( bNeedsInit )
891 {
892 if( aType.getTypeClass() == TypeClass_VOID )
893 {
894 // if only first element is void: different types -> []any
895 // if all elements are void: []void is not allowed -> []any
896 aElementType = cppu::UnoType<Any>::get();
897 break;
898 }
899 aElementType = aType;
900 bNeedsInit = false;
901 }
902 else if( aElementType != aType )
903 {
904 // different types -> AnySequence
905 aElementType = cppu::UnoType<Any>::get();
906 break;
907 }
908 }
909 }
910
911 OUString aSeqTypeName = aSeqLevelStr + aElementType.getTypeName();
912 aRetType = Type( TypeClass_SEQUENCE, aSeqTypeName );
913 }
914 // #i33795 Map also multi dimensional arrays to corresponding sequences
915 else if( nDims > 1 )
916 {
917 if( eElementTypeClass == TypeClass_VOID || eElementTypeClass == TypeClass_ANY )
918 {
919 // For this check the array's dim structure does not matter
920 sal_uInt32 nFlatArraySize = pArray->Count();
921
922 bool bNeedsInit = true;
923 for( sal_uInt32 i = 0 ; i < nFlatArraySize ; i++ )
924 {
925 SbxVariableRef xVar = pArray->SbxArray::Get(i);
926 Type aType = getUnoTypeForSbxValue( xVar.get() );
927 if( bNeedsInit )
928 {
929 if( aType.getTypeClass() == TypeClass_VOID )
930 {
931 // if only first element is void: different types -> []any
932 // if all elements are void: []void is not allowed -> []any
933 aElementType = cppu::UnoType<Any>::get();
934 break;
935 }
936 aElementType = aType;
937 bNeedsInit = false;
938 }
939 else if( aElementType != aType )
940 {
941 // different types -> AnySequence
942 aElementType = cppu::UnoType<Any>::get();
943 break;
944 }
945 }
946 }
947
948 OUStringBuffer aSeqTypeName;
949 for(sal_Int32 iDim = 0 ; iDim < nDims ; iDim++ )
950 {
951 aSeqTypeName.append(aSeqLevelStr);
952 }
953 aSeqTypeName.append(aElementType.getTypeName());
954 aRetType = Type( TypeClass_SEQUENCE, aSeqTypeName.makeStringAndClear() );
955 }
956 }
957 // No array, but ...
958 else if( auto obj = dynamic_cast<SbUnoObject*>( xObj.get() ) )
959 {
960 aRetType = obj->getUnoAny().getValueType();
961 }
962 // SbUnoAnyObject?
963 else if( auto any = dynamic_cast<SbUnoAnyObject*>( xObj.get() ) )
964 {
965 aRetType = any->getValue().getValueType();
966 }
967 // Otherwise it is a No-Uno-Basic-Object -> default==deliver void
968 }
969 // No object, convert basic type
970 else
971 {
972 if (eBaseType == SbxBYTE && pVal->GetByte() > 127)
973 {
974 // Basic Byte type is unsigned; cppu::UnoType<sal_uInt8> corresponds to UNO boolean,
975 // so values 128-255 are only representable starting with UNO short types
976 eBaseType = SbxUSHORT;
977 }
978 aRetType = getUnoTypeForSbxBaseType( eBaseType );
979 }
980 return aRetType;
981}
982
983// converting of Sbx to Uno without known target class for TypeClass_ANY
984static Any sbxToUnoValueImpl( const SbxValue* pVar, bool bBlockConversionToSmallestType = false )
985{
986 SbxDataType eBaseType = pVar->SbxValue::GetType();
987 if( eBaseType == SbxOBJECT )
988 {
989 SbxBaseRef xObj = pVar->GetObject();
990 if( xObj.is() )
991 {
992 if( auto obj = dynamic_cast<SbUnoAnyObject*>( xObj.get() ) )
993 return obj->getValue();
994 if( auto pClassModuleObj = dynamic_cast<SbClassModuleObject*>( xObj.get() ) )
995 {
996 Any aRetAny;
997 SbModule* pClassModule = pClassModuleObj->getClassModule();
998 if( pClassModule->createCOMWrapperForIface( aRetAny, pClassModuleObj ) )
999 return aRetAny;
1000 }
1001 if( dynamic_cast<const SbUnoObject*>( xObj.get() ) == nullptr )
1002 {
1003 // Create NativeObjectWrapper to identify object in case of callbacks
1004 SbxObject* pObj = dynamic_cast<SbxObject*>( pVar->GetObject() );
1005 if( pObj != nullptr )
1006 {
1007 NativeObjectWrapper aNativeObjectWrapper;
1008 sal_uInt32 nIndex = lcl_registerNativeObjectWrapper( pObj );
1009 aNativeObjectWrapper.ObjectId <<= nIndex;
1010 Any aRetAny;
1011 aRetAny <<= aNativeObjectWrapper;
1012 return aRetAny;
1013 }
1014 }
1015 }
1016 }
1017
1018 Type aType = getUnoTypeForSbxValue( pVar );
1019 TypeClass eType = aType.getTypeClass();
1020
1021 if( !bBlockConversionToSmallestType )
1022 {
1023 // #79615 Choose "smallest" representation for int values
1024 // because up cast is allowed, downcast not
1025 switch( eType )
1026 {
1027 case TypeClass_FLOAT:
1028 case TypeClass_DOUBLE:
1029 {
1030 double d = pVar->GetDouble();
1031 if( rtl::math::approxEqual(d, floor( d )) )
1032 {
1033 if( d >= -128 && d <= 127 )
1035 else if( d >= SbxMININT && d <= SbxMAXINT )
1037 else if( d >= -SbxMAXLNG && d <= SbxMAXLNG )
1039 }
1040 break;
1041 }
1042 case TypeClass_SHORT:
1043 {
1044 sal_Int16 n = pVar->GetInteger();
1045 if( n >= -128 && n <= 127 )
1047 break;
1048 }
1049 case TypeClass_LONG:
1050 {
1051 sal_Int32 n = pVar->GetLong();
1052 if( n >= -128 && n <= 127 )
1054 else if( n >= SbxMININT && n <= SbxMAXINT )
1056 break;
1057 }
1058 case TypeClass_UNSIGNED_LONG:
1059 {
1060 sal_uInt32 n = pVar->GetLong();
1061 if( n <= SbxMAXUINT )
1063 break;
1064 }
1065 // TODO: need to add hyper types ?
1066 default: break;
1067 }
1068 }
1069
1070 return sbxToUnoValue( pVar, aType );
1071}
1072
1073
1074// Helper function for StepREDIMP
1076 const Type& aElemType, sal_Int32 nMaxDimIndex, sal_Int32 nActualDim,
1077 sal_Int32* pActualIndices, sal_Int32* pLowerBounds, sal_Int32* pUpperBounds )
1078{
1079 sal_Int32 nSeqLevel = nMaxDimIndex - nActualDim + 1;
1080 OUStringBuffer aSeqTypeName;
1081 sal_Int32 i;
1082 for( i = 0 ; i < nSeqLevel ; i++ )
1083 {
1084 aSeqTypeName.append(aSeqLevelStr);
1085 }
1086 aSeqTypeName.append(aElemType.getTypeName());
1087 Type aSeqType( TypeClass_SEQUENCE, aSeqTypeName.makeStringAndClear() );
1088
1089 // Create Sequence instance
1090 Any aRetVal;
1091 Reference< XIdlClass > xIdlTargetClass = TypeToIdlClass( aSeqType );
1092 xIdlTargetClass->createObject( aRetVal );
1093
1094 // Alloc sequence according to array bounds
1095 sal_Int32 nUpper = pUpperBounds[nActualDim];
1096 sal_Int32 nLower = pLowerBounds[nActualDim];
1097 sal_Int32 nSeqSize = nUpper - nLower + 1;
1098 Reference< XIdlArray > xArray = xIdlTargetClass->getArray();
1099 xArray->realloc( aRetVal, nSeqSize );
1100
1101 sal_Int32& ri = pActualIndices[nActualDim];
1102
1103 for( ri = nLower,i = 0 ; ri <= nUpper ; ri++,i++ )
1104 {
1105 Any aElementVal;
1106
1107 if( nActualDim < nMaxDimIndex )
1108 {
1109 aElementVal = implRekMultiDimArrayToSequence( pArray, aElemType,
1110 nMaxDimIndex, nActualDim + 1, pActualIndices, pLowerBounds, pUpperBounds );
1111 }
1112 else
1113 {
1114 SbxVariable* pSource = pArray->Get(pActualIndices);
1115 aElementVal = sbxToUnoValue( pSource, aElemType );
1116 }
1117
1118 try
1119 {
1120 // transfer to the sequence
1121 xArray->set( aRetVal, i, aElementVal );
1122 }
1123 catch( const IllegalArgumentException& )
1124 {
1126 implGetExceptionMsg( ::cppu::getCaughtException() ) );
1127 }
1128 catch (const IndexOutOfBoundsException&)
1129 {
1131 }
1132 }
1133 return aRetVal;
1134}
1135
1136// Map old interface
1138{
1139 return sbxToUnoValueImpl( pVar );
1140}
1141
1142// function to find a global identifier in
1143// the UnoScope and to wrap it for Sbx
1144static bool implGetTypeByName( const OUString& rName, Type& rRetType )
1145{
1146 bool bSuccess = false;
1147
1149 if( xTypeAccess->hasByHierarchicalName( rName ) )
1150 {
1151 Any aRet = xTypeAccess->getByHierarchicalName( rName );
1153 aRet >>= xTypeDesc;
1154
1155 if( xTypeDesc.is() )
1156 {
1157 rRetType = Type( xTypeDesc->getTypeClass(), xTypeDesc->getName() );
1158 bSuccess = true;
1159 }
1160 }
1161 return bSuccess;
1162}
1163
1164
1165// converting of Sbx to Uno with known target class
1166Any sbxToUnoValue( const SbxValue* pVar, const Type& rType, Property const * pUnoProperty )
1167{
1168 Any aRetVal;
1169
1170 // #94560 No conversion of empty/void for MAYBE_VOID properties
1171 if( pUnoProperty && pUnoProperty->Attributes & PropertyAttribute::MAYBEVOID )
1172 {
1173 if( pVar->IsEmpty() )
1174 return aRetVal;
1175 }
1176
1177 SbxDataType eBaseType = pVar->SbxValue::GetType();
1178 if( eBaseType == SbxOBJECT )
1179 {
1180 SbxBaseRef xObj = pVar->GetObject();
1181 if ( auto obj = dynamic_cast<SbUnoAnyObject*>( xObj.get() ) )
1182 {
1183 return obj->getValue();
1184 }
1185 }
1186
1187 TypeClass eType = rType.getTypeClass();
1188 switch( eType )
1189 {
1190 case TypeClass_INTERFACE:
1191 case TypeClass_STRUCT:
1192 case TypeClass_EXCEPTION:
1193 {
1194 Reference< XIdlClass > xIdlTargetClass = TypeToIdlClass( rType );
1195
1196 // null reference?
1197 if( pVar->IsNull() && eType == TypeClass_INTERFACE )
1198 {
1200 OUString aClassName = xIdlTargetClass->getName();
1201 Type aClassType( xIdlTargetClass->getTypeClass(), aClassName );
1202 aRetVal.setValue( &xRef, aClassType );
1203 }
1204 else
1205 {
1206 // #112368 Special conversion for Decimal, Currency and Date
1207 if( eType == TypeClass_STRUCT )
1208 {
1209 SbiInstance* pInst = GetSbData()->pInst;
1210 if( pInst && pInst->IsCompatibility() )
1211 {
1213 {
1214 oleautomation::Decimal aDecimal;
1215 pVar->fillAutomationDecimal( aDecimal );
1216 aRetVal <<= aDecimal;
1217 break;
1218 }
1220 {
1221 // assumes per previous code that ole Currency is Int64
1222 aRetVal <<= pVar->GetInt64();
1223 break;
1224 }
1225 else if( rType == cppu::UnoType<oleautomation::Date>::get())
1226 {
1227 oleautomation::Date aDate;
1228 aDate.Value = pVar->GetDate();
1229 aRetVal <<= aDate;
1230 break;
1231 }
1232 }
1233 }
1234
1235 SbxBaseRef pObj = pVar->GetObject();
1236 if( auto obj = dynamic_cast<SbUnoObject*>( pObj.get() ) )
1237 {
1238 aRetVal = obj->getUnoAny();
1239 }
1240 else if( auto structRef = dynamic_cast<SbUnoStructRefObject*>( pObj.get() ) )
1241 {
1242 aRetVal = structRef->getUnoAny();
1243 }
1244 else
1245 {
1246 // null object -> null XInterface
1248 aRetVal <<= xInt;
1249 }
1250 }
1251 }
1252 break;
1253
1254 case TypeClass_TYPE:
1255 {
1256 if( eBaseType == SbxOBJECT )
1257 {
1258 // XIdlClass?
1259 Reference< XIdlClass > xIdlClass;
1260
1261 SbxBaseRef pObj = pVar->GetObject();
1262 if( auto obj = dynamic_cast<SbUnoObject*>( pObj.get() ) )
1263 {
1264 Any aUnoAny = obj->getUnoAny();
1265 aUnoAny >>= xIdlClass;
1266 }
1267
1268 if( xIdlClass.is() )
1269 {
1270 OUString aClassName = xIdlClass->getName();
1271 Type aType( xIdlClass->getTypeClass(), aClassName );
1272 aRetVal <<= aType;
1273 }
1274 }
1275 else if( eBaseType == SbxSTRING )
1276 {
1277 OUString aTypeName = pVar->GetOUString();
1278 Type aType;
1279 bool bSuccess = implGetTypeByName( aTypeName, aType );
1280 if( bSuccess )
1281 {
1282 aRetVal <<= aType;
1283 }
1284 }
1285 }
1286 break;
1287
1288
1289 case TypeClass_ENUM:
1290 {
1291 aRetVal = int2enum( pVar->GetLong(), rType );
1292 }
1293 break;
1294
1295 case TypeClass_SEQUENCE:
1296 {
1297 SbxBaseRef xObj = pVar->GetObject();
1298 if( auto pArray = dynamic_cast<SbxDimArray*>( xObj.get() ) )
1299 {
1300 sal_Int32 nDims = pArray->GetDims();
1301
1302 // Normal case: One dimensional array
1303 sal_Int32 nLower, nUpper;
1304 if (nDims == 1 && pArray->GetDim(1, nLower, nUpper))
1305 {
1306 sal_Int32 nSeqSize = nUpper - nLower + 1;
1307
1308 // create the instance of the required sequence
1309 Reference< XIdlClass > xIdlTargetClass = TypeToIdlClass( rType );
1310 xIdlTargetClass->createObject( aRetVal );
1311 Reference< XIdlArray > xArray = xIdlTargetClass->getArray();
1312 xArray->realloc( aRetVal, nSeqSize );
1313
1314 // Element-Type
1315 OUString aClassName = xIdlTargetClass->getName();
1316 typelib_TypeDescription * pSeqTD = nullptr;
1317 typelib_typedescription_getByName( &pSeqTD, aClassName.pData );
1318 assert( pSeqTD );
1319 Type aElemType( reinterpret_cast<typelib_IndirectTypeDescription *>(pSeqTD)->pType );
1320
1321 // convert all array member and register them
1322 sal_Int32 aIdx[1];
1323 aIdx[0] = nLower;
1324 for (sal_Int32 i = 0 ; i < nSeqSize; ++i, ++aIdx[0])
1325 {
1326 SbxVariableRef xVar = pArray->Get(aIdx);
1327
1328 // Convert the value of Sbx to Uno
1329 Any aAnyValue = sbxToUnoValue( xVar.get(), aElemType );
1330
1331 try
1332 {
1333 // insert in the sequence
1334 xArray->set( aRetVal, i, aAnyValue );
1335 }
1336 catch( const IllegalArgumentException& )
1337 {
1339 implGetExceptionMsg( ::cppu::getCaughtException() ) );
1340 }
1341 catch (const IndexOutOfBoundsException&)
1342 {
1344 }
1345 }
1346 }
1347 // #i33795 Map also multi dimensional arrays to corresponding sequences
1348 else if( nDims > 1 )
1349 {
1350 // Element-Type
1351 typelib_TypeDescription * pSeqTD = nullptr;
1352 Type aCurType( rType );
1353 sal_Int32 nSeqLevel = 0;
1354 Type aElemType;
1355 do
1356 {
1357 OUString aTypeName = aCurType.getTypeName();
1358 typelib_typedescription_getByName( &pSeqTD, aTypeName.pData );
1359 assert( pSeqTD );
1360 if( pSeqTD->eTypeClass == typelib_TypeClass_SEQUENCE )
1361 {
1362 aCurType = Type( reinterpret_cast<typelib_IndirectTypeDescription *>(pSeqTD)->pType );
1363 nSeqLevel++;
1364 }
1365 else
1366 {
1367 aElemType = aCurType;
1368 break;
1369 }
1370 }
1371 while( true );
1372
1373 if( nSeqLevel == nDims )
1374 {
1375 std::unique_ptr<sal_Int32[]> pLowerBounds(new sal_Int32[nDims]);
1376 std::unique_ptr<sal_Int32[]> pUpperBounds(new sal_Int32[nDims]);
1377 std::unique_ptr<sal_Int32[]> pActualIndices(new sal_Int32[nDims]);
1378 for(sal_Int32 i = 1 ; i <= nDims ; i++ )
1379 {
1380 sal_Int32 lBound, uBound;
1381 pArray->GetDim(i, lBound, uBound);
1382
1383 sal_Int32 j = i - 1;
1384 pActualIndices[j] = pLowerBounds[j] = lBound;
1385 pUpperBounds[j] = uBound;
1386 }
1387
1388 aRetVal = implRekMultiDimArrayToSequence( pArray, aElemType,
1389 nDims - 1, 0, pActualIndices.get(), pLowerBounds.get(), pUpperBounds.get() );
1390 }
1391 }
1392 }
1393 }
1394 break;
1395
1396
1397 // for Any use the class independent converting routine
1398 case TypeClass_ANY:
1399 {
1400 aRetVal = sbxToUnoValueImpl( pVar );
1401 }
1402 break;
1403
1404 case TypeClass_BOOLEAN:
1405 {
1406 aRetVal <<= pVar->GetBool();
1407 break;
1408 }
1409 case TypeClass_CHAR:
1410 {
1411 aRetVal <<= pVar->GetChar();
1412 break;
1413 }
1414 case TypeClass_STRING: aRetVal <<= pVar->GetOUString(); break;
1415 case TypeClass_FLOAT: aRetVal <<= pVar->GetSingle(); break;
1416 case TypeClass_DOUBLE: aRetVal <<= pVar->GetDouble(); break;
1417
1418 case TypeClass_BYTE:
1419 {
1420 sal_Int16 nVal = pVar->GetInteger();
1421 bool bOverflow = false;
1422 if( nVal < -128 )
1423 {
1424 bOverflow = true;
1425 nVal = -128;
1426 }
1427 else if( nVal > 255 ) // 128..255 map to -128..-1
1428 {
1429 bOverflow = true;
1430 nVal = 127;
1431 }
1432 if( bOverflow )
1434
1435 sal_Int8 nByteVal = static_cast<sal_Int8>(nVal);
1436 aRetVal <<= nByteVal;
1437 break;
1438 }
1439 case TypeClass_SHORT: aRetVal <<= pVar->GetInteger(); break;
1440 case TypeClass_LONG: aRetVal <<= pVar->GetLong(); break;
1441 case TypeClass_HYPER: aRetVal <<= pVar->GetInt64(); break;
1442 case TypeClass_UNSIGNED_SHORT: aRetVal <<= pVar->GetUShort(); break;
1443 case TypeClass_UNSIGNED_LONG: aRetVal <<= pVar->GetULong(); break;
1444 case TypeClass_UNSIGNED_HYPER: aRetVal <<= pVar->GetUInt64(); break;
1445 default: break;
1446 }
1447
1448 return aRetVal;
1449}
1450
1451static void processAutomationParams( SbxArray* pParams, Sequence< Any >& args, sal_uInt32 nParamCount )
1452{
1453 AutomationNamedArgsSbxArray* pArgNamesArray = dynamic_cast<AutomationNamedArgsSbxArray*>( pParams );
1454
1455 args.realloc( nParamCount );
1456 Any* pAnyArgs = args.getArray();
1457 bool bBlockConversionToSmallestType = GetSbData()->pInst->IsCompatibility();
1458 sal_uInt32 i = 0;
1459 if( pArgNamesArray )
1460 {
1461 Sequence< OUString >& rNameSeq = pArgNamesArray->getNames();
1462 OUString* pNames = rNameSeq.getArray();
1463 Any aValAny;
1464 for( i = 0 ; i < nParamCount ; i++ )
1465 {
1466 sal_uInt32 iSbx = i + 1;
1467
1468 aValAny = sbxToUnoValueImpl(pParams->Get(iSbx),
1469 bBlockConversionToSmallestType );
1470
1471 OUString aParamName = pNames[iSbx];
1472 if( !aParamName.isEmpty() )
1473 {
1474 oleautomation::NamedArgument aNamedArgument;
1475 aNamedArgument.Name = aParamName;
1476 aNamedArgument.Value = aValAny;
1477 pAnyArgs[i] <<= aNamedArgument;
1478 }
1479 else
1480 {
1481 pAnyArgs[i] = aValAny;
1482 }
1483 }
1484 }
1485 else
1486 {
1487 for( i = 0 ; i < nParamCount ; i++ )
1488 {
1489 pAnyArgs[i] = sbxToUnoValueImpl(pParams->Get(i + 1),
1490 bBlockConversionToSmallestType );
1491 }
1492 }
1493
1494}
1495
1496namespace {
1497
1498enum class INVOKETYPE
1499{
1500 GetProp = 0,
1501 Func
1502};
1503
1504}
1505
1506static Any invokeAutomationMethod( const OUString& Name, Sequence< Any > const & args, SbxArray* pParams, sal_uInt32 nParamCount, Reference< XInvocation > const & rxInvocation, INVOKETYPE invokeType )
1507{
1508 Sequence< sal_Int16 > OutParamIndex;
1509 Sequence< Any > OutParam;
1510
1511 Any aRetAny;
1512 switch( invokeType )
1513 {
1514 case INVOKETYPE::Func:
1515 aRetAny = rxInvocation->invoke( Name, args, OutParamIndex, OutParam );
1516 break;
1517 case INVOKETYPE::GetProp:
1518 {
1519 Reference< XAutomationInvocation > xAutoInv( rxInvocation, UNO_QUERY );
1520 aRetAny = xAutoInv->invokeGetProperty( Name, args, OutParamIndex, OutParam );
1521 break;
1522 }
1523 default:
1524 assert(false); break;
1525
1526 }
1527 const sal_Int16* pIndices = OutParamIndex.getConstArray();
1528 sal_uInt32 nLen = OutParamIndex.getLength();
1529 if( nLen )
1530 {
1531 const Any* pNewValues = OutParam.getConstArray();
1532 for( sal_uInt32 j = 0 ; j < nLen ; j++ )
1533 {
1534 sal_Int16 iTarget = pIndices[ j ];
1535 if( o3tl::make_unsigned(iTarget) >= nParamCount )
1536 break;
1537 unoToSbxValue(pParams->Get(j + 1), pNewValues[j]);
1538 }
1539 }
1540 return aRetAny;
1541}
1542
1543// Debugging help method to readout the implemented interfaces of an object
1544static OUString Impl_GetInterfaceInfo( const Reference< XInterface >& x, const Reference< XIdlClass >& xClass, sal_uInt16 nRekLevel )
1545{
1546 Type aIfaceType = cppu::UnoType<XInterface>::get();
1547 static Reference< XIdlClass > xIfaceClass = TypeToIdlClass( aIfaceType );
1548
1549 OUStringBuffer aRetStr;
1550 for( sal_uInt16 i = 0 ; i < nRekLevel ; i++ )
1551 aRetStr.append( " " );
1552 aRetStr.append( xClass->getName() );
1553 OUString aClassName = xClass->getName();
1554 Type aClassType( xClass->getTypeClass(), aClassName );
1555
1556 // checking if the interface is really supported
1557 if( !x->queryInterface( aClassType ).hasValue() )
1558 {
1559 aRetStr.append( " (ERROR: Not really supported!)\n" );
1560 }
1561 // Are there super interfaces?
1562 else
1563 {
1564 aRetStr.append( "\n" );
1565
1566 // get the super interfaces
1567 Sequence< Reference< XIdlClass > > aSuperClassSeq = xClass->getSuperclasses();
1568 const Reference< XIdlClass >* pClasses = aSuperClassSeq.getConstArray();
1569 sal_uInt32 nSuperIfaceCount = aSuperClassSeq.getLength();
1570 for( sal_uInt32 j = 0 ; j < nSuperIfaceCount ; j++ )
1571 {
1572 const Reference< XIdlClass >& rxIfaceClass = pClasses[j];
1573 if( !rxIfaceClass->equals( xIfaceClass ) )
1574 aRetStr.append( Impl_GetInterfaceInfo( x, rxIfaceClass, nRekLevel + 1 ) );
1575 }
1576 }
1577 return aRetStr.makeStringAndClear();
1578}
1579
1580static OUString getDbgObjectNameImpl(SbUnoObject& rUnoObj)
1581{
1582 OUString aName = rUnoObj.GetClassName();
1583 if( aName.isEmpty() )
1584 {
1585 Any aToInspectObj = rUnoObj.getUnoAny();
1586 Reference< XInterface > xObj(aToInspectObj, css::uno::UNO_QUERY);
1587 if( xObj.is() )
1588 {
1589 Reference< XServiceInfo > xServiceInfo( xObj, UNO_QUERY );
1590 if( xServiceInfo.is() )
1591 aName = xServiceInfo->getImplementationName();
1592 }
1593 }
1594 return aName;
1595}
1596
1597static OUString getDbgObjectName(SbUnoObject& rUnoObj)
1598{
1599 OUString aName = getDbgObjectNameImpl(rUnoObj);
1600 if( aName.isEmpty() )
1601 aName += "Unknown";
1602
1603 OUStringBuffer aRet;
1604 if( aName.getLength() > 20 )
1605 {
1606 aRet.append( "\n" );
1607 }
1608 aRet.append( "\"" + aName + "\":" );
1609 return aRet.makeStringAndClear();
1610}
1611
1613{
1614 if (pObj)
1615 {
1616 if (SbUnoObject* pUnoObj = dynamic_cast<SbUnoObject*>(pObj))
1617 {
1618 return getDbgObjectNameImpl(*pUnoObj);
1619 }
1620 else if (SbUnoStructRefObject* pUnoStructObj = dynamic_cast<SbUnoStructRefObject*>(pObj))
1621 {
1622 return pUnoStructObj->GetClassName();
1623 }
1624 }
1625 return OUString();
1626}
1627
1628namespace {
1629
1630bool matchesBasicTypeName(
1631 css::uno::Reference<css::reflection::XIdlClass> const & unoType, OUString const & basicTypeName)
1632{
1633 if (unoType->getName().endsWithIgnoreAsciiCase(basicTypeName)) {
1634 return true;
1635 }
1636 auto const sups = unoType->getSuperclasses();
1637 return std::any_of(
1638 sups.begin(), sups.end(),
1639 [&basicTypeName](auto const & t) { return matchesBasicTypeName(t, basicTypeName); });
1640}
1641
1642}
1643
1644bool checkUnoObjectType(SbUnoObject& rUnoObj, const OUString& rClass)
1645{
1646 Any aToInspectObj = rUnoObj.getUnoAny();
1647
1648 // Return true for XInvocation based objects as interface type names don't count then
1649 Reference< XInvocation > xInvocation( aToInspectObj, UNO_QUERY );
1650 if( xInvocation.is() )
1651 {
1652 return true;
1653 }
1654 bool bResult = false;
1655 Reference< XTypeProvider > xTypeProvider( aToInspectObj, UNO_QUERY );
1656 if( xTypeProvider.is() )
1657 {
1658 /* Although interfaces in the ooo.vba namespace obey the IDL rules and
1659 have a leading 'X', in Basic we want to be able to do something
1660 like 'Dim wb As Workbooks' or 'Dim lb As MSForms.Label'. Here we
1661 add a leading 'X' to the class name and a leading dot to the entire
1662 type name. This results e.g. in '.XWorkbooks' or '.MSForms.XLabel'
1663 which matches the interface names 'ooo.vba.excel.XWorkbooks' or
1664 'ooo.vba.msforms.XLabel'.
1665 */
1666 OUString aClassName;
1668 {
1669 aClassName = ".";
1670 sal_Int32 nClassNameDot = rClass.lastIndexOf( '.' );
1671 if( nClassNameDot >= 0 )
1672 {
1673 aClassName += OUString::Concat(rClass.subView( 0, nClassNameDot + 1 )) + "X" + rClass.subView( nClassNameDot + 1 );
1674 }
1675 else
1676 {
1677 aClassName += "X" + rClass;
1678 }
1679 }
1680 else // assume extended type declaration support for basic ( can't get here
1681 // otherwise.
1682 aClassName = rClass;
1683
1684 Sequence< Type > aTypeSeq = xTypeProvider->getTypes();
1685 const Type* pTypeArray = aTypeSeq.getConstArray();
1686 sal_uInt32 nIfaceCount = aTypeSeq.getLength();
1687 for( sal_uInt32 j = 0 ; j < nIfaceCount ; j++ )
1688 {
1689 const Type& rType = pTypeArray[j];
1690
1691 Reference<XIdlClass> xClass = TypeToIdlClass( rType );
1692 if( !xClass.is() )
1693 {
1694 OSL_FAIL("failed to get XIdlClass for type");
1695 break;
1696 }
1697 OUString aInterfaceName = xClass->getName();
1698 if ( aInterfaceName == "com.sun.star.bridge.oleautomation.XAutomationObject" )
1699 {
1700 // there is a hack in the extensions/source/ole/oleobj.cxx to return the typename of the automation object, lets check if it
1701 // matches
1702 Reference< XInvocation > xInv( aToInspectObj, UNO_QUERY );
1703 if ( xInv.is() )
1704 {
1705 OUString sTypeName;
1706 xInv->getValue( "$GetTypeName" ) >>= sTypeName;
1707 if ( sTypeName.isEmpty() || sTypeName == "IDispatch" )
1708 {
1709 // can't check type, leave it pass
1710 bResult = true;
1711 }
1712 else
1713 {
1714 bResult = sTypeName == rClass;
1715 }
1716 }
1717 break; // finished checking automation object
1718 }
1719
1720 if ( matchesBasicTypeName(xClass, aClassName) )
1721 {
1722 bResult = true;
1723 break;
1724 }
1725 }
1726 }
1727 return bResult;
1728}
1729
1730// Debugging help method to readout the implemented interfaces of an object
1732{
1733 Any aToInspectObj = rUnoObj.getUnoAny();
1734
1735 // allow only TypeClass interface
1736 OUStringBuffer aRet;
1737 auto x = o3tl::tryAccess<Reference<XInterface>>(aToInspectObj);
1738 if( !x )
1739 {
1740 aRet.append( ID_DBG_SUPPORTEDINTERFACES
1741 + " not available.\n(TypeClass is not TypeClass_INTERFACE)\n" );
1742 }
1743 else
1744 {
1745 Reference< XTypeProvider > xTypeProvider( *x, UNO_QUERY );
1746
1747 aRet.append( "Supported interfaces by object "
1748 + getDbgObjectName(rUnoObj)
1749 + "\n" );
1750 if( xTypeProvider.is() )
1751 {
1752 // get the interfaces of the implementation
1753 Sequence< Type > aTypeSeq = xTypeProvider->getTypes();
1754 const Type* pTypeArray = aTypeSeq.getConstArray();
1755 sal_uInt32 nIfaceCount = aTypeSeq.getLength();
1756 for( sal_uInt32 j = 0 ; j < nIfaceCount ; j++ )
1757 {
1758 const Type& rType = pTypeArray[j];
1759
1760 Reference<XIdlClass> xClass = TypeToIdlClass( rType );
1761 if( xClass.is() )
1762 {
1763 aRet.append( Impl_GetInterfaceInfo( *x, xClass, 1 ) );
1764 }
1765 else
1766 {
1767 typelib_TypeDescription * pTD = nullptr;
1768 rType.getDescription( &pTD );
1769
1770 aRet.append( OUString::Concat("*** ERROR: No IdlClass for type \"")
1771 + OUString::unacquired(&pTD->pTypeName)
1772 + "\"\n*** Please check type library\n" );
1773 }
1774 }
1775 }
1776 }
1777 return aRet.makeStringAndClear();
1778}
1779
1780
1781// Debugging help method SbxDataType -> String
1782static OUString Dbg_SbxDataType2String( SbxDataType eType )
1783{
1784 OUStringBuffer aRet;
1785 switch( +eType )
1786 {
1787 case SbxEMPTY: aRet.append("SbxEMPTY"); break;
1788 case SbxNULL: aRet.append("SbxNULL"); break;
1789 case SbxINTEGER: aRet.append("SbxINTEGER"); break;
1790 case SbxLONG: aRet.append("SbxLONG"); break;
1791 case SbxSINGLE: aRet.append("SbxSINGLE"); break;
1792 case SbxDOUBLE: aRet.append("SbxDOUBLE"); break;
1793 case SbxCURRENCY: aRet.append("SbxCURRENCY"); break;
1794 case SbxDECIMAL: aRet.append("SbxDECIMAL"); break;
1795 case SbxDATE: aRet.append("SbxDATE"); break;
1796 case SbxSTRING: aRet.append("SbxSTRING"); break;
1797 case SbxOBJECT: aRet.append("SbxOBJECT"); break;
1798 case SbxERROR: aRet.append("SbxERROR"); break;
1799 case SbxBOOL: aRet.append("SbxBOOL"); break;
1800 case SbxVARIANT: aRet.append("SbxVARIANT"); break;
1801 case SbxDATAOBJECT: aRet.append("SbxDATAOBJECT"); break;
1802 case SbxCHAR: aRet.append("SbxCHAR"); break;
1803 case SbxBYTE: aRet.append("SbxBYTE"); break;
1804 case SbxUSHORT: aRet.append("SbxUSHORT"); break;
1805 case SbxULONG: aRet.append("SbxULONG"); break;
1806 case SbxSALINT64: aRet.append("SbxINT64"); break;
1807 case SbxSALUINT64: aRet.append("SbxUINT64"); break;
1808 case SbxINT: aRet.append("SbxINT"); break;
1809 case SbxUINT: aRet.append("SbxUINT"); break;
1810 case SbxVOID: aRet.append("SbxVOID"); break;
1811 case SbxHRESULT: aRet.append("SbxHRESULT"); break;
1812 case SbxPOINTER: aRet.append("SbxPOINTER"); break;
1813 case SbxDIMARRAY: aRet.append("SbxDIMARRAY"); break;
1814 case SbxCARRAY: aRet.append("SbxCARRAY"); break;
1815 case SbxUSERDEF: aRet.append("SbxUSERDEF"); break;
1816 case SbxLPSTR: aRet.append("SbxLPSTR"); break;
1817 case SbxLPWSTR: aRet.append("SbxLPWSTR"); break;
1818 case SbxCoreSTRING: aRet.append("SbxCoreSTRING"); break;
1819 case SbxOBJECT | SbxARRAY: aRet.append("SbxARRAY"); break;
1820 default: aRet.append("Unknown Sbx-Type!");break;
1821 }
1822 return aRet.makeStringAndClear();
1823}
1824
1825// Debugging help method to display the properties of a SbUnoObjects
1826static OUString Impl_DumpProperties(SbUnoObject& rUnoObj)
1827{
1828 OUStringBuffer aRet("Properties of object " + getDbgObjectName(rUnoObj));
1829
1830 // analyse the Uno-Infos to recognise the arrays
1832 if( !xAccess.is() )
1833 {
1834 Reference< XInvocation > xInvok = rUnoObj.getInvocation();
1835 if( xInvok.is() )
1836 xAccess = xInvok->getIntrospection();
1837 }
1838 if( !xAccess.is() )
1839 {
1840 aRet.append( "\nUnknown, no introspection available\n" );
1841 return aRet.makeStringAndClear();
1842 }
1843
1844 Sequence<Property> props = xAccess->getProperties( PropertyConcept::ALL - PropertyConcept::DANGEROUS );
1845 sal_uInt32 nUnoPropCount = props.getLength();
1846 const Property* pUnoProps = props.getConstArray();
1847
1848 SbxArray* pProps = rUnoObj.GetProperties();
1849 sal_uInt32 nPropCount = pProps->Count();
1850 sal_uInt32 nPropsPerLine = 1 + nPropCount / 30;
1851 for( sal_uInt32 i = 0; i < nPropCount; i++ )
1852 {
1853 SbxVariable* pVar = pProps->Get(i);
1854 if( pVar )
1855 {
1856 OUStringBuffer aPropStr;
1857 if( (i % nPropsPerLine) == 0 )
1858 aPropStr.append( "\n" );
1859
1860 // output the type and name
1861 // Is it in Uno a sequence?
1862 SbxDataType eType = pVar->GetFullType();
1863
1864 bool bMaybeVoid = false;
1865 if( i < nUnoPropCount )
1866 {
1867 const Property& rProp = pUnoProps[ i ];
1868
1869 // For MAYBEVOID freshly convert the type from Uno,
1870 // so not just SbxEMPTY is returned.
1871 if( rProp.Attributes & PropertyAttribute::MAYBEVOID )
1872 {
1873 eType = unoToSbxType( rProp.Type.getTypeClass() );
1874 bMaybeVoid = true;
1875 }
1876 if( eType == SbxOBJECT )
1877 {
1878 Type aType = rProp.Type;
1879 if( aType.getTypeClass() == TypeClass_SEQUENCE )
1881 }
1882 }
1883 aPropStr.append( Dbg_SbxDataType2String( eType ) );
1884 if( bMaybeVoid )
1885 aPropStr.append( "/void" );
1886 aPropStr.append( " " + pVar->GetName() );
1887
1888 if( i == nPropCount - 1 )
1889 aPropStr.append( "\n" );
1890 else
1891 aPropStr.append( "; " );
1892
1893 aRet.append( aPropStr );
1894 }
1895 }
1896 return aRet.makeStringAndClear();
1897}
1898
1899// Debugging help method to display the methods of an SbUnoObjects
1900static OUString Impl_DumpMethods(SbUnoObject& rUnoObj)
1901{
1902 OUStringBuffer aRet("Methods of object " + getDbgObjectName(rUnoObj));
1903
1904 // XIntrospectionAccess, so that the types of the parameter could be outputted
1906 if( !xAccess.is() )
1907 {
1908 Reference< XInvocation > xInvok = rUnoObj.getInvocation();
1909 if( xInvok.is() )
1910 xAccess = xInvok->getIntrospection();
1911 }
1912 if( !xAccess.is() )
1913 {
1914 aRet.append( "\nUnknown, no introspection available\n" );
1915 return aRet.makeStringAndClear();
1916 }
1917 Sequence< Reference< XIdlMethod > > methods = xAccess->getMethods
1918 ( MethodConcept::ALL - MethodConcept::DANGEROUS );
1919 const Reference< XIdlMethod >* pUnoMethods = methods.getConstArray();
1920
1921 SbxArray* pMethods = rUnoObj.GetMethods();
1922 sal_uInt32 nMethodCount = pMethods->Count();
1923 if( !nMethodCount )
1924 {
1925 aRet.append( "\nNo methods found\n" );
1926 return aRet.makeStringAndClear();
1927 }
1928 sal_uInt32 nPropsPerLine = 1 + nMethodCount / 30;
1929 for( sal_uInt32 i = 0; i < nMethodCount; i++ )
1930 {
1931 SbxVariable* pVar = pMethods->Get(i);
1932 if( pVar )
1933 {
1934 if( (i % nPropsPerLine) == 0 )
1935 aRet.append( "\n" );
1936
1937 // address the method
1938 const Reference< XIdlMethod >& rxMethod = pUnoMethods[i];
1939
1940 // Is it in Uno a sequence?
1941 SbxDataType eType = pVar->GetFullType();
1942 if( eType == SbxOBJECT )
1943 {
1944 Reference< XIdlClass > xClass = rxMethod->getReturnType();
1945 if( xClass.is() && xClass->getTypeClass() == TypeClass_SEQUENCE )
1947 }
1948 // output the name and the type
1949 aRet.append( Dbg_SbxDataType2String( eType )
1950 + " " + pVar->GetName() + " ( " );
1951
1952 // the get-method mustn't have a parameter
1953 Sequence< Reference< XIdlClass > > aParamsSeq = rxMethod->getParameterTypes();
1954 sal_uInt32 nParamCount = aParamsSeq.getLength();
1955 const Reference< XIdlClass >* pParams = aParamsSeq.getConstArray();
1956
1957 if( nParamCount > 0 )
1958 {
1959 for( sal_uInt32 j = 0; j < nParamCount; j++ )
1960 {
1961 aRet.append ( Dbg_SbxDataType2String( unoToSbxType( pParams[ j ] ) ) );
1962 if( j < nParamCount - 1 )
1963 aRet.append( ", " );
1964 }
1965 }
1966 else
1967 aRet.append( "void" );
1968
1969 aRet.append( " ) " );
1970
1971 if( i == nMethodCount - 1 )
1972 aRet.append( "\n" );
1973 else
1974 aRet.append( "; " );
1975 }
1976 }
1977 return aRet.makeStringAndClear();
1978}
1979
1980
1981// Implementation SbUnoObject
1983{
1984 if( bNeedIntrospection )
1986
1987 const SbxHint* pHint = dynamic_cast<const SbxHint*>(&rHint);
1988 if( !pHint )
1989 return;
1990
1991 SbxVariable* pVar = pHint->GetVar();
1992 SbxArray* pParams = pVar->GetParameters();
1993 SbUnoProperty* pProp = dynamic_cast<SbUnoProperty*>( pVar );
1994 SbUnoMethod* pMeth = dynamic_cast<SbUnoMethod*>( pVar );
1995 if( pProp )
1996 {
1997 bool bInvocation = pProp->isInvocationBased();
1998 if( pHint->GetId() == SfxHintId::BasicDataWanted )
1999 {
2000 // Test-Properties
2001 sal_Int32 nId = pProp->nId;
2002 if( nId < 0 )
2003 {
2004 // Id == -1: Display implemented interfaces according the ClassProvider
2005 if( nId == -1 ) // Property ID_DBG_SUPPORTEDINTERFACES"
2006 {
2007 OUString aRetStr = Impl_GetSupportedInterfaces(*this);
2008 pVar->PutString( aRetStr );
2009 }
2010 // Id == -2: output properties
2011 else if( nId == -2 ) // Property ID_DBG_PROPERTIES
2012 {
2013 // now all properties must be created
2014 implCreateAll();
2015 OUString aRetStr = Impl_DumpProperties(*this);
2016 pVar->PutString( aRetStr );
2017 }
2018 // Id == -3: output the methods
2019 else if( nId == -3 ) // Property ID_DBG_METHODS
2020 {
2021 // now all properties must be created
2022 implCreateAll();
2023 OUString aRetStr = Impl_DumpMethods(*this);
2024 pVar->PutString( aRetStr );
2025 }
2026 return;
2027 }
2028
2029 if( !bInvocation && mxUnoAccess.is() )
2030 {
2031 try
2032 {
2033 if ( maStructInfo )
2034 {
2035 StructRefInfo aMember = maStructInfo->getStructMember( pProp->GetName() );
2036 if ( aMember.isEmpty() )
2037 {
2039 }
2040 else
2041 {
2042 if ( pProp->isUnoStruct() )
2043 {
2044 SbUnoStructRefObject* pSbUnoObject = new SbUnoStructRefObject( pProp->GetName(), std::move(aMember) );
2045 SbxObjectRef xWrapper = static_cast<SbxObject*>(pSbUnoObject);
2046 pVar->PutObject( xWrapper.get() );
2047 }
2048 else
2049 {
2050 Any aRetAny = aMember.getValue();
2051 // take over the value from Uno to Sbx
2052 unoToSbxValue( pVar, aRetAny );
2053 }
2054 return;
2055 }
2056 }
2057 // get the value
2058 Reference< XPropertySet > xPropSet( mxUnoAccess->queryAdapter( cppu::UnoType<XPropertySet>::get()), UNO_QUERY );
2059 Any aRetAny = xPropSet->getPropertyValue( pProp->GetName() );
2060 // The use of getPropertyValue (instead of using the index) is
2061 // suboptimal, but the refactoring to XInvocation is already pending
2062 // Otherwise it is possible to use FastPropertySet
2063
2064 // take over the value from Uno to Sbx
2065 unoToSbxValue( pVar, aRetAny );
2066 }
2067 catch( const Exception& )
2068 {
2069 implHandleAnyException( ::cppu::getCaughtException() );
2070 }
2071 }
2072 else if( bInvocation && mxInvocation.is() )
2073 {
2074 try
2075 {
2076 sal_uInt32 nParamCount = pParams ? (pParams->Count() - 1) : 0;
2077 bool bCanBeConsideredAMethod = mxInvocation->hasMethod( pProp->GetName() );
2078 Any aRetAny;
2079 if ( bCanBeConsideredAMethod && nParamCount )
2080 {
2081 // Automation properties have methods, so... we need to invoke this through
2082 // XInvocation
2084 processAutomationParams( pParams, args, nParamCount );
2085 aRetAny = invokeAutomationMethod( pProp->GetName(), args, pParams, nParamCount, mxInvocation, INVOKETYPE::GetProp );
2086 }
2087 else
2088 aRetAny = mxInvocation->getValue( pProp->GetName() );
2089 // take over the value from Uno to Sbx
2090 unoToSbxValue( pVar, aRetAny );
2091 if( pParams && bCanBeConsideredAMethod )
2092 pVar->SetParameters( nullptr );
2093
2094 }
2095 catch( const Exception& )
2096 {
2097 implHandleAnyException( ::cppu::getCaughtException() );
2098 }
2099 }
2100 }
2101 else if( pHint->GetId() == SfxHintId::BasicDataChanged )
2102 {
2103 if( !bInvocation && mxUnoAccess.is() )
2104 {
2105 if( pProp->aUnoProp.Attributes & PropertyAttribute::READONLY )
2106 {
2108 return;
2109 }
2110 if ( maStructInfo )
2111 {
2112 StructRefInfo aMember = maStructInfo->getStructMember( pProp->GetName() );
2113 if ( aMember.isEmpty() )
2114 {
2116 }
2117 else
2118 {
2119 Any aAnyValue = sbxToUnoValue( pVar, pProp->aUnoProp.Type, &pProp->aUnoProp );
2120 aMember.setValue( aAnyValue );
2121 }
2122 return;
2123 }
2124 // take over the value from Uno to Sbx
2125 Any aAnyValue = sbxToUnoValue( pVar, pProp->aUnoProp.Type, &pProp->aUnoProp );
2126 try
2127 {
2128 // set the value
2129 Reference< XPropertySet > xPropSet( mxUnoAccess->queryAdapter( cppu::UnoType<XPropertySet>::get()), UNO_QUERY );
2130 xPropSet->setPropertyValue( pProp->GetName(), aAnyValue );
2131 // The use of getPropertyValue (instead of using the index) is
2132 // suboptimal, but the refactoring to XInvocation is already pending
2133 // Otherwise it is possible to use FastPropertySet
2134 }
2135 catch( const Exception& )
2136 {
2137 implHandleAnyException( ::cppu::getCaughtException() );
2138 }
2139 }
2140 else if( bInvocation && mxInvocation.is() )
2141 {
2142 // take over the value from Uno to Sbx
2143 Any aAnyValue = sbxToUnoValueImpl( pVar );
2144 try
2145 {
2146 // set the value
2147 mxInvocation->setValue( pProp->GetName(), aAnyValue );
2148 }
2149 catch( const Exception& )
2150 {
2151 implHandleAnyException( ::cppu::getCaughtException() );
2152 }
2153 }
2154 }
2155 }
2156 else if( pMeth )
2157 {
2158 bool bInvocation = pMeth->isInvocationBased();
2159 if( pHint->GetId() == SfxHintId::BasicDataWanted )
2160 {
2161 // number of Parameter -1 because of Param0 == this
2162 sal_uInt32 nParamCount = pParams ? (pParams->Count() - 1) : 0;
2164 bool bOutParams = false;
2165
2166 if( !bInvocation && mxUnoAccess.is() )
2167 {
2168 // get info
2169 const Sequence<ParamInfo>& rInfoSeq = pMeth->getParamInfos();
2170 const ParamInfo* pParamInfos = rInfoSeq.getConstArray();
2171 sal_uInt32 nUnoParamCount = rInfoSeq.getLength();
2172 sal_uInt32 nAllocParamCount = nParamCount;
2173
2174 // ignore surplus parameter; alternative: throw an error
2175 if( nParamCount > nUnoParamCount )
2176 {
2177 nParamCount = nUnoParamCount;
2178 nAllocParamCount = nParamCount;
2179 }
2180 else if( nParamCount < nUnoParamCount )
2181 {
2182 SbiInstance* pInst = GetSbData()->pInst;
2183 if( pInst && pInst->IsCompatibility() )
2184 {
2185 // Check types
2186 bool bError = false;
2187 for( sal_uInt32 i = nParamCount ; i < nUnoParamCount ; i++ )
2188 {
2189 const ParamInfo& rInfo = pParamInfos[i];
2190 const Reference< XIdlClass >& rxClass = rInfo.aType;
2191 if( rxClass->getTypeClass() != TypeClass_ANY )
2192 {
2193 bError = true;
2195 }
2196 }
2197 if( !bError )
2198 nAllocParamCount = nUnoParamCount;
2199 }
2200 }
2201
2202 if( nAllocParamCount > 0 )
2203 {
2204 args.realloc( nAllocParamCount );
2205 Any* pAnyArgs = args.getArray();
2206 for( sal_uInt32 i = 0 ; i < nParamCount ; i++ )
2207 {
2208 const ParamInfo& rInfo = pParamInfos[i];
2209 const Reference< XIdlClass >& rxClass = rInfo.aType;
2210
2211 css::uno::Type aType( rxClass->getTypeClass(), rxClass->getName() );
2212
2213 // ATTENTION: Don't forget for Sbx-Parameter the offset!
2214 pAnyArgs[i] = sbxToUnoValue(pParams->Get(i + 1), aType);
2215
2216 // If it is not certain check whether the out-parameter are available.
2217 if( !bOutParams )
2218 {
2219 ParamMode aParamMode = rInfo.aMode;
2220 if( aParamMode != ParamMode_IN )
2221 bOutParams = true;
2222 }
2223 }
2224 }
2225 }
2226 else if( bInvocation && pParams && mxInvocation.is() )
2227 {
2228 processAutomationParams( pParams, args, nParamCount );
2229 }
2230
2231 // call the method
2232 GetSbData()->bBlockCompilerError = true; // #106433 Block compiler errors for API calls
2233 try
2234 {
2235 if( !bInvocation && mxUnoAccess.is() )
2236 {
2237 Any aRetAny = pMeth->m_xUnoMethod->invoke( getUnoAny(), args );
2238
2239 // take over the value from Uno to Sbx
2240 unoToSbxValue( pVar, aRetAny );
2241
2242 // Did we to copy back the Out-Parameter?
2243 if( bOutParams )
2244 {
2245 const Any* pAnyArgs = args.getConstArray();
2246
2247 // get info
2248 const Sequence<ParamInfo>& rInfoSeq = pMeth->getParamInfos();
2249 const ParamInfo* pParamInfos = rInfoSeq.getConstArray();
2250
2251 sal_uInt32 j;
2252 for( j = 0 ; j < nParamCount ; j++ )
2253 {
2254 const ParamInfo& rInfo = pParamInfos[j];
2255 ParamMode aParamMode = rInfo.aMode;
2256 if( aParamMode != ParamMode_IN )
2257 unoToSbxValue(pParams->Get(j + 1), pAnyArgs[j]);
2258 }
2259 }
2260 }
2261 else if( bInvocation && mxInvocation.is() )
2262 {
2263 Any aRetAny = invokeAutomationMethod( pMeth->GetName(), args, pParams, nParamCount, mxInvocation, INVOKETYPE::Func );
2264 unoToSbxValue( pVar, aRetAny );
2265 }
2266
2267 // remove parameter here, because this was not done anymore in unoToSbxValue()
2268 // for arrays
2269 if( pParams )
2270 pVar->SetParameters( nullptr );
2271 }
2272 catch( const Exception& )
2273 {
2274 implHandleAnyException( ::cppu::getCaughtException() );
2275 }
2276 GetSbData()->bBlockCompilerError = false; // #106433 Unblock compiler errors
2277 }
2278 }
2279 else
2280 SbxObject::Notify( rBC, rHint );
2281}
2282
2283
2284SbUnoObject::SbUnoObject( const OUString& aName_, const Any& aUnoObj_ )
2285 : SbxObject( aName_ )
2286 , bNeedIntrospection( true )
2287 , bNativeCOMObject( false )
2288{
2289 // beat out again the default properties of Sbx
2290 Remove( "Name", SbxClassType::DontCare );
2291 Remove( "Parent", SbxClassType::DontCare );
2292
2293 // check the type of the objects
2294 TypeClass eType = aUnoObj_.getValueType().getTypeClass();
2296 if( eType == TypeClass_INTERFACE )
2297 {
2298 // get the interface from the Any
2299 aUnoObj_ >>= x;
2300 if( !x.is() )
2301 return;
2302 }
2303
2304 // Did the object have an invocation itself?
2305 mxInvocation.set( x, UNO_QUERY );
2306
2307 if( mxInvocation.is() )
2308 {
2309
2310 // get the ExactName
2311 mxExactNameInvocation.set( mxInvocation, UNO_QUERY );
2312
2313 // The remainder refers only to the introspection
2314 Reference< XTypeProvider > xTypeProvider( x, UNO_QUERY );
2315 if( !xTypeProvider.is() )
2316 {
2317 bNeedIntrospection = false;
2318 return;
2319 }
2320
2321 // Ignore introspection based members for COM objects to avoid
2322 // hiding of equally named COM symbols, e.g. XInvocation::getValue
2323 Reference< oleautomation::XAutomationObject > xAutomationObject( aUnoObj_, UNO_QUERY );
2324 if( xAutomationObject.is() )
2325 bNativeCOMObject = true;
2326 }
2327
2328 maTmpUnoObj = aUnoObj_;
2329
2330
2331 //*** Define the name ***
2332 bool bFatalError = true;
2333
2334 // Is it an interface or a struct?
2335 bool bSetClassName = false;
2336 OUString aClassName_;
2337 if( eType == TypeClass_STRUCT || eType == TypeClass_EXCEPTION )
2338 {
2339 // Struct is Ok
2340 bFatalError = false;
2341
2342 // insert the real name of the class
2343 if( aName_.isEmpty() )
2344 {
2345 aClassName_ = aUnoObj_.getValueType().getTypeName();
2346 bSetClassName = true;
2347 }
2348 StructRefInfo aThisStruct( maTmpUnoObj, maTmpUnoObj.getValueType(), 0 );
2349 maStructInfo = std::make_shared<SbUnoStructRefObject>( GetName(), aThisStruct );
2350 }
2351 else if( eType == TypeClass_INTERFACE )
2352 {
2353 // Interface works always through the type in the Any
2354 bFatalError = false;
2355 }
2356 if( bSetClassName )
2357 SetClassName( aClassName_ );
2358
2359 // Neither interface nor Struct -> FatalError
2360 if( bFatalError )
2361 {
2363 return;
2364 }
2365
2366 // pass the introspection primal on demand
2367}
2368
2370{
2371}
2372
2373
2374// pass the introspection on Demand
2376{
2377 if( !bNeedIntrospection )
2378 return;
2379
2381
2382 if (!xContext.is())
2383 return;
2384
2385
2386 // get the introspection service
2388
2389 try
2390 {
2391 xIntrospection = theIntrospection::get(xContext);
2392 }
2393 catch ( const css::uno::DeploymentException& )
2394 {
2395 }
2396
2397 if (!xIntrospection.is())
2398 return;
2399
2400 bNeedIntrospection = false;
2401
2402 // pass the introspection
2403 try
2404 {
2406 }
2407 catch( const RuntimeException& e )
2408 {
2410 }
2411
2412 if( !mxUnoAccess.is() )
2413 {
2414 // #51475 mark to indicate an invalid object (no mxMaterialHolder)
2415 return;
2416 }
2417
2418 // get MaterialHolder from access
2419 mxMaterialHolder.set( mxUnoAccess, UNO_QUERY );
2420
2421 // get ExactName from access
2422 mxExactName.set( mxUnoAccess, UNO_QUERY );
2423}
2424
2425
2426// Start of a list of all SbUnoMethod-Instances
2427static SbUnoMethod* pFirst = nullptr;
2428
2430{
2431 SbUnoMethod* pMeth = pFirst;
2432 while( pMeth )
2433 {
2434 SbxObject* pObject = pMeth->GetParent();
2435 if ( pObject )
2436 {
2437 StarBASIC* pModBasic = dynamic_cast< StarBASIC* >( pObject->GetParent() );
2438 if ( pModBasic == pBasic )
2439 {
2440 // for now the solution is to remove the method from the list and to clear it,
2441 // but in case the element should be correctly transferred to another StarBASIC,
2442 // we should either set module parent to NULL without clearing it, or even
2443 // set the new StarBASIC as the parent of the module
2444 // pObject->SetParent( NULL );
2445
2446 if( pMeth == pFirst )
2447 pFirst = pMeth->pNext;
2448 else if( pMeth->pPrev )
2449 pMeth->pPrev->pNext = pMeth->pNext;
2450 if( pMeth->pNext )
2451 pMeth->pNext->pPrev = pMeth->pPrev;
2452
2453 pMeth->pPrev = nullptr;
2454 pMeth->pNext = nullptr;
2455
2456 pMeth->SbxValue::Clear();
2457 pObject->SbxValue::Clear();
2458
2459 // start from the beginning after object clearing, the cycle will end since the method is removed each time
2460 pMeth = pFirst;
2461 }
2462 else
2463 pMeth = pMeth->pNext;
2464 }
2465 else
2466 pMeth = pMeth->pNext;
2467 }
2468}
2469
2471{
2472 SbUnoMethod* pMeth = pFirst;
2473 while( pMeth )
2474 {
2475 pMeth->SbxValue::Clear();
2476 pMeth = pMeth->pNext;
2477 }
2478}
2479
2480
2482(
2483 const OUString& aName_,
2484 SbxDataType eSbxType,
2485 Reference< XIdlMethod > const & xUnoMethod_,
2486 bool bInvocation
2487)
2488 : SbxMethod( aName_, eSbxType )
2489 , mbInvocation( bInvocation )
2490{
2491 m_xUnoMethod = xUnoMethod_;
2492 pParamInfoSeq = nullptr;
2493
2494 // enregister the method in a list
2495 pNext = pFirst;
2496 pPrev = nullptr;
2497 pFirst = this;
2498 if( pNext )
2499 pNext->pPrev = this;
2500}
2501
2503{
2504 pParamInfoSeq.reset();
2505
2506 if( this == pFirst )
2507 pFirst = pNext;
2508 else if( pPrev )
2509 pPrev->pNext = pNext;
2510 if( pNext )
2511 pNext->pPrev = pPrev;
2512}
2513
2515{
2516 if( !pInfo.is() && m_xUnoMethod.is() )
2517 {
2518 SbiInstance* pInst = GetSbData()->pInst;
2519 if( pInst && pInst->IsCompatibility() )
2520 {
2521 pInfo = new SbxInfo();
2522
2523 const Sequence<ParamInfo>& rInfoSeq = getParamInfos();
2524 const ParamInfo* pParamInfos = rInfoSeq.getConstArray();
2525 sal_uInt32 nParamCount = rInfoSeq.getLength();
2526
2527 for( sal_uInt32 i = 0 ; i < nParamCount ; i++ )
2528 {
2529 const ParamInfo& rInfo = pParamInfos[i];
2530 OUString aParamName = rInfo.aName;
2531
2532 pInfo->AddParam( aParamName, SbxVARIANT, SbxFlagBits::Read );
2533 }
2534 }
2535 }
2536 return pInfo.get();
2537}
2538
2540{
2541 if (!pParamInfoSeq)
2542 {
2544 if (m_xUnoMethod.is())
2545 aTmp = m_xUnoMethod->getParameterInfos();
2546 pParamInfoSeq.reset( new Sequence<ParamInfo>(aTmp) );
2547 }
2548 return *pParamInfoSeq;
2549}
2550
2552(
2553 const OUString& aName_,
2554 SbxDataType eSbxType,
2555 SbxDataType eRealSbxType,
2556 Property aUnoProp_,
2557 sal_Int32 nId_,
2558 bool bInvocation,
2559 bool bUnoStruct
2560)
2561 : SbxProperty( aName_, eSbxType )
2562 , aUnoProp(std::move( aUnoProp_ ))
2563 , nId( nId_ )
2564 , mbInvocation( bInvocation )
2565 , mRealType( eRealSbxType )
2566 , mbUnoStruct( bUnoStruct )
2567{
2568 // as needed establish a dummy array so that SbiRuntime::CheckArray() works
2569 static SbxArrayRef xDummyArray = new SbxArray( SbxVARIANT );
2570 if( eSbxType & SbxARRAY )
2571 PutObject( xDummyArray.get() );
2572}
2573
2575{}
2576
2577
2578SbxVariable* SbUnoObject::Find( const OUString& rName, SbxClassType t )
2579{
2580 static Reference< XIdlMethod > xDummyMethod;
2581 static Property aDummyProp;
2582
2583 SbxVariable* pRes = SbxObject::Find( rName, t );
2584
2585 if( bNeedIntrospection )
2587
2588 // New 1999-03-04: Create properties on demand. Therefore search now via
2589 // IntrospectionAccess if a property or a method of the required name exist
2590 if( !pRes )
2591 {
2592 OUString aUName( rName );
2593 if( mxUnoAccess.is() && !bNativeCOMObject )
2594 {
2595 if( mxExactName.is() )
2596 {
2597 OUString aUExactName = mxExactName->getExactName( aUName );
2598 if( !aUExactName.isEmpty() )
2599 {
2600 aUName = aUExactName;
2601 }
2602 }
2603 if( mxUnoAccess->hasProperty( aUName, PropertyConcept::ALL - PropertyConcept::DANGEROUS ) )
2604 {
2605 const Property& rProp = mxUnoAccess->
2606 getProperty( aUName, PropertyConcept::ALL - PropertyConcept::DANGEROUS );
2607
2608 // If the property could be void the type had to be set to Variant
2609 SbxDataType eSbxType;
2610 if( rProp.Attributes & PropertyAttribute::MAYBEVOID )
2611 eSbxType = SbxVARIANT;
2612 else
2613 eSbxType = unoToSbxType( rProp.Type.getTypeClass() );
2614
2615 SbxDataType eRealSbxType = ( ( rProp.Attributes & PropertyAttribute::MAYBEVOID ) ? unoToSbxType( rProp.Type.getTypeClass() ) : eSbxType );
2616 // create the property and superimpose it
2617 auto pProp = tools::make_ref<SbUnoProperty>( rProp.Name, eSbxType, eRealSbxType, rProp, 0, false, ( rProp.Type.getTypeClass() == css::uno::TypeClass_STRUCT ) );
2618 QuickInsert( pProp.get() );
2619 pRes = pProp.get();
2620 }
2621 else if( mxUnoAccess->hasMethod( aUName,
2622 MethodConcept::ALL - MethodConcept::DANGEROUS ) )
2623 {
2624 // address the method
2625 const Reference< XIdlMethod >& rxMethod = mxUnoAccess->
2626 getMethod( aUName, MethodConcept::ALL - MethodConcept::DANGEROUS );
2627
2628 // create SbUnoMethod and superimpose it
2629 auto xMethRef = tools::make_ref<SbUnoMethod>( rxMethod->getName(),
2630 unoToSbxType( rxMethod->getReturnType() ), rxMethod, false );
2631 QuickInsert( xMethRef.get() );
2632 pRes = xMethRef.get();
2633 }
2634
2635 // If nothing was found check via XNameAccess
2636 if( !pRes )
2637 {
2638 try
2639 {
2640 Reference< XNameAccess > xNameAccess( mxUnoAccess->queryAdapter( cppu::UnoType<XPropertySet>::get()), UNO_QUERY );
2641
2642 if( xNameAccess.is() && xNameAccess->hasByName( rName ) )
2643 {
2644 Any aAny = xNameAccess->getByName( rName );
2645
2646 // ATTENTION: Because of XNameAccess, the variable generated here
2647 // may not be included as a fixed property in the object and therefore
2648 // won't be stored anywhere.
2649 // If this leads to problems, it has to be created
2650 // synthetically or a class SbUnoNameAccessProperty,
2651 // which checks the existence on access and which
2652 // is disposed if the name is not found anymore.
2653 pRes = new SbxVariable( SbxVARIANT );
2654 unoToSbxValue( pRes, aAny );
2655 }
2656 }
2657 catch( const NoSuchElementException& e )
2658 {
2660 }
2661 catch( const Exception& )
2662 {
2663 // Establish so that the exception error will not be overwritten
2664 if( !pRes )
2665 pRes = new SbxVariable( SbxVARIANT );
2666
2667 implHandleAnyException( ::cppu::getCaughtException() );
2668 }
2669 }
2670 }
2671 if( !pRes && mxInvocation.is() )
2672 {
2673 if( mxExactNameInvocation.is() )
2674 {
2675 OUString aUExactName = mxExactNameInvocation->getExactName( aUName );
2676 if( !aUExactName.isEmpty() )
2677 {
2678 aUName = aUExactName;
2679 }
2680 }
2681
2682 try
2683 {
2684 if( mxInvocation->hasProperty( aUName ) )
2685 {
2686 // create a property and superimpose it
2687 auto xVarRef = tools::make_ref<SbUnoProperty>( aUName, SbxVARIANT, SbxVARIANT, aDummyProp, 0, true, false );
2688 QuickInsert( xVarRef.get() );
2689 pRes = xVarRef.get();
2690 }
2691 else if( mxInvocation->hasMethod( aUName ) )
2692 {
2693 // create SbUnoMethode and superimpose it
2694 auto xMethRef = tools::make_ref<SbUnoMethod>( aUName, SbxVARIANT, xDummyMethod, true );
2695 QuickInsert( xMethRef.get() );
2696 pRes = xMethRef.get();
2697 }
2698 else
2699 {
2700 Reference< XDirectInvocation > xDirectInvoke( mxInvocation, UNO_QUERY );
2701 if ( xDirectInvoke.is() && xDirectInvoke->hasMember( aUName ) )
2702 {
2703 auto xMethRef = tools::make_ref<SbUnoMethod>( aUName, SbxVARIANT, xDummyMethod, true );
2704 QuickInsert( xMethRef.get() );
2705 pRes = xMethRef.get();
2706 }
2707
2708 }
2709 }
2710 catch( const RuntimeException& e )
2711 {
2712 // Establish so that the exception error will not be overwritten
2713 if( !pRes )
2714 pRes = new SbxVariable( SbxVARIANT );
2715
2717 }
2718 }
2719 }
2720
2721 // At the very end checking if the Dbg_-Properties are meant
2722
2723 if( !pRes )
2724 {
2725 if( rName.equalsIgnoreAsciiCase(ID_DBG_SUPPORTEDINTERFACES) ||
2726 rName.equalsIgnoreAsciiCase(ID_DBG_PROPERTIES) ||
2727 rName.equalsIgnoreAsciiCase(ID_DBG_METHODS) )
2728 {
2729 // Create
2731
2732 // Now they have to be found regular
2733 pRes = SbxObject::Find( rName, SbxClassType::DontCare );
2734 }
2735 }
2736 return pRes;
2737}
2738
2739
2740// help method to create the dbg_-Properties
2742{
2743 Property aProp;
2744
2745 // Id == -1: display the implemented interfaces corresponding the ClassProvider
2746 auto xVarRef = tools::make_ref<SbUnoProperty>( OUString(ID_DBG_SUPPORTEDINTERFACES), SbxSTRING, SbxSTRING, aProp, -1, false, false );
2747 QuickInsert( xVarRef.get() );
2748
2749 // Id == -2: output the properties
2750 xVarRef = tools::make_ref<SbUnoProperty>( OUString(ID_DBG_PROPERTIES), SbxSTRING, SbxSTRING, aProp, -2, false, false );
2751 QuickInsert( xVarRef.get() );
2752
2753 // Id == -3: output the Methods
2754 xVarRef = tools::make_ref<SbUnoProperty>( OUString(ID_DBG_METHODS), SbxSTRING, SbxSTRING, aProp, -3, false, false );
2755 QuickInsert( xVarRef.get() );
2756}
2757
2759{
2760 // throw away all existing methods and properties
2761 pMethods = tools::make_ref<SbxArray>();
2762 pProps = tools::make_ref<SbxArray>();
2763
2765
2766 // get introspection
2768 if( !xAccess.is() || bNativeCOMObject )
2769 {
2770 if( mxInvocation.is() )
2771 xAccess = mxInvocation->getIntrospection();
2772 else if( bNativeCOMObject )
2773 return;
2774 }
2775 if( !xAccess.is() )
2776 return;
2777
2778 // Establish properties
2779 Sequence<Property> props = xAccess->getProperties( PropertyConcept::ALL - PropertyConcept::DANGEROUS );
2780 sal_uInt32 nPropCount = props.getLength();
2781 const Property* pProps_ = props.getConstArray();
2782
2783 sal_uInt32 i;
2784 for( i = 0 ; i < nPropCount ; i++ )
2785 {
2786 const Property& rProp = pProps_[ i ];
2787
2788 // If the property could be void the type had to be set to Variant
2789 SbxDataType eSbxType;
2790 if( rProp.Attributes & PropertyAttribute::MAYBEVOID )
2791 eSbxType = SbxVARIANT;
2792 else
2793 eSbxType = unoToSbxType( rProp.Type.getTypeClass() );
2794
2795 SbxDataType eRealSbxType = ( ( rProp.Attributes & PropertyAttribute::MAYBEVOID ) ? unoToSbxType( rProp.Type.getTypeClass() ) : eSbxType );
2796 // Create property and superimpose it
2797 auto xVarRef = tools::make_ref<SbUnoProperty>( rProp.Name, eSbxType, eRealSbxType, rProp, i, false, ( rProp.Type.getTypeClass() == css::uno::TypeClass_STRUCT ) );
2798 QuickInsert( xVarRef.get() );
2799 }
2800
2801 // Create Dbg_-Properties
2803
2804 // Create methods
2805 Sequence< Reference< XIdlMethod > > aMethodSeq = xAccess->getMethods
2806 ( MethodConcept::ALL - MethodConcept::DANGEROUS );
2807 sal_uInt32 nMethCount = aMethodSeq.getLength();
2808 const Reference< XIdlMethod >* pMethods_ = aMethodSeq.getConstArray();
2809 for( i = 0 ; i < nMethCount ; i++ )
2810 {
2811 // address method
2812 const Reference< XIdlMethod >& rxMethod = pMethods_[i];
2813
2814 // Create SbUnoMethod and superimpose it
2815 auto xMethRef = tools::make_ref<SbUnoMethod>
2816 ( rxMethod->getName(), unoToSbxType( rxMethod->getReturnType() ), rxMethod, false );
2817 QuickInsert( xMethRef.get() );
2818 }
2819}
2820
2821
2822// output the value
2824{
2825 Any aRetAny;
2827 if ( maStructInfo )
2828 aRetAny = maTmpUnoObj;
2829 else if( mxMaterialHolder.is() )
2830 aRetAny = mxMaterialHolder->getMaterial();
2831 else if( mxInvocation.is() )
2832 aRetAny <<= mxInvocation;
2833 return aRetAny;
2834}
2835
2836// help method to create a Uno-Struct per CoreReflection
2837static SbUnoObjectRef Impl_CreateUnoStruct( const OUString& aClassName )
2838{
2839 // get CoreReflection
2841 if( !xCoreReflection.is() )
2842 return nullptr;
2843
2844 // search for the class
2846 const Reference< XHierarchicalNameAccess >& xHarryName =
2848 if( xHarryName.is() && xHarryName->hasByHierarchicalName( aClassName ) )
2849 xClass = xCoreReflection->forName( aClassName );
2850 if( !xClass.is() )
2851 return nullptr;
2852
2853 // Is it really a struct?
2854 TypeClass eType = xClass->getTypeClass();
2855 if ( ( eType != TypeClass_STRUCT ) && ( eType != TypeClass_EXCEPTION ) )
2856 return nullptr;
2857
2858 // create an instance
2859 Any aNewAny;
2860 xClass->createObject( aNewAny );
2861 // make a SbUnoObject out of it
2862 SbUnoObjectRef pUnoObj = new SbUnoObject( aClassName, aNewAny );
2863 return pUnoObj;
2864}
2865
2866
2867// Factory-Class to create Uno-Structs per DIM AS NEW
2868SbxBaseRef SbUnoFactory::Create( sal_uInt16, sal_uInt32 )
2869{
2870 // Via SbxId nothing works in Uno
2871 return nullptr;
2872}
2873
2874SbxObjectRef SbUnoFactory::CreateObject( const OUString& rClassName )
2875{
2876 return Impl_CreateUnoStruct( rClassName ).get();
2877}
2878
2879
2880// Provisional interface for the UNO-Connection
2881// Deliver a SbxObject, that wrap a Uno-Interface
2882SbxObjectRef GetSbUnoObject( const OUString& aName, const Any& aUnoObj_ )
2883{
2884 return new SbUnoObject( aName, aUnoObj_ );
2885}
2886
2887// Force creation of all properties for debugging
2889{
2890 if( !pObj )
2891 return;
2892
2893 SbUnoObject* pUnoObj = dynamic_cast<SbUnoObject*>( pObj );
2894 SbUnoStructRefObject* pUnoStructObj = dynamic_cast<SbUnoStructRefObject*>( pObj );
2895 if( pUnoObj )
2896 {
2897 pUnoObj->createAllProperties();
2898 }
2899 else if ( pUnoStructObj )
2900 {
2901 pUnoStructObj->createAllProperties();
2902 }
2903}
2904
2905
2907{
2908 // We need 1 parameter minimum
2909 if (rPar.Count() < 2)
2910 {
2912 return;
2913 }
2914
2915 // get the name of the class of the struct
2916 OUString aClassName = rPar.Get(1)->GetOUString();
2917
2918 // try to create Struct with the same name
2919 SbUnoObjectRef xUnoObj = Impl_CreateUnoStruct( aClassName );
2920 if( !xUnoObj.is() )
2921 {
2922 return;
2923 }
2924 // return the object
2925 SbxVariableRef refVar = rPar.Get(0);
2926 refVar->PutObject( xUnoObj.get() );
2927}
2928
2930{
2931 // We need 1 Parameter minimum
2932 if (rPar.Count() < 2)
2933 {
2935 return;
2936 }
2937
2938 // get the name of the class of the struct
2939 OUString aServiceName = rPar.Get(1)->GetOUString();
2940
2941 // search for the service and instantiate it
2943 Reference< XInterface > xInterface;
2944 try
2945 {
2946 xInterface = xFactory->createInstance( aServiceName );
2947 }
2948 catch( const Exception& )
2949 {
2950 implHandleAnyException( ::cppu::getCaughtException() );
2951 }
2952
2953 SbxVariableRef refVar = rPar.Get(0);
2954 if( xInterface.is() )
2955 {
2956 // Create a SbUnoObject out of it and return it
2957 SbUnoObjectRef xUnoObj = new SbUnoObject( aServiceName, Any(xInterface) );
2958 if( xUnoObj->getUnoAny().hasValue() )
2959 {
2960 // return the object
2961 refVar->PutObject( xUnoObj.get() );
2962 }
2963 else
2964 {
2965 refVar->PutObject( nullptr );
2966 }
2967 }
2968 else
2969 {
2970 refVar->PutObject( nullptr );
2971 }
2972}
2973
2975{
2976 // We need 2 parameter minimum
2977 if (rPar.Count() < 3)
2978 {
2980 return;
2981 }
2982
2983 // get the name of the class of the struct
2984 OUString aServiceName = rPar.Get(1)->GetOUString();
2985 Any aArgAsAny = sbxToUnoValue(rPar.Get(2),
2986 cppu::UnoType<Sequence<Any>>::get() );
2987 Sequence< Any > aArgs;
2988 aArgAsAny >>= aArgs;
2989
2990 // search for the service and instantiate it
2992 Reference< XInterface > xInterface;
2993 try
2994 {
2995 xInterface = xFactory->createInstanceWithArguments( aServiceName, aArgs );
2996 }
2997 catch( const Exception& )
2998 {
2999 implHandleAnyException( ::cppu::getCaughtException() );
3000 }
3001
3002 SbxVariableRef refVar = rPar.Get(0);
3003 if( xInterface.is() )
3004 {
3005 // Create a SbUnoObject out of it and return it
3006 SbUnoObjectRef xUnoObj = new SbUnoObject( aServiceName, Any(xInterface) );
3007 if( xUnoObj->getUnoAny().hasValue() )
3008 {
3009 // return the object
3010 refVar->PutObject( xUnoObj.get() );
3011 }
3012 else
3013 {
3014 refVar->PutObject( nullptr );
3015 }
3016 }
3017 else
3018 {
3019 refVar->PutObject( nullptr );
3020 }
3021}
3022
3024{
3025 SbxVariableRef refVar = rPar.Get(0);
3026
3027 // get the global service manager
3029
3030 // Create a SbUnoObject out of it and return it
3031 SbUnoObjectRef xUnoObj = new SbUnoObject( "ProcessServiceManager", Any(xFactory) );
3032 refVar->PutObject( xUnoObj.get() );
3033}
3034
3036{
3037 // We need 2 parameter minimum
3038 sal_uInt32 nParCount = rPar.Count();
3039 if( nParCount < 3 )
3040 {
3042 return;
3043 }
3044
3045 // variable for the return value
3046 SbxVariableRef refVar = rPar.Get(0);
3047 refVar->PutBool( false );
3048
3049 // get the Uno-Object
3050 SbxBaseRef pObj = rPar.Get(1)->GetObject();
3051 auto obj = dynamic_cast<SbUnoObject*>( pObj.get() );
3052 if( obj == nullptr )
3053 {
3054 return;
3055 }
3056 Any aAny = obj->getUnoAny();
3057 auto x = o3tl::tryAccess<Reference<XInterface>>(aAny);
3058 if( !x )
3059 {
3060 return;
3061 }
3062
3063 // get CoreReflection
3065 if( !xCoreReflection.is() )
3066 {
3067 return;
3068 }
3069 for( sal_uInt32 i = 2 ; i < nParCount ; i++ )
3070 {
3071 // get the name of the interface of the struct
3072 OUString aIfaceName = rPar.Get(i)->GetOUString();
3073
3074 // search for the class
3075 Reference< XIdlClass > xClass = xCoreReflection->forName( aIfaceName );
3076 if( !xClass.is() )
3077 {
3078 return;
3079 }
3080 // check if the interface will be supported
3081 OUString aClassName = xClass->getName();
3082 Type aClassType( xClass->getTypeClass(), aClassName );
3083 if( !(*x)->queryInterface( aClassType ).hasValue() )
3084 {
3085 return;
3086 }
3087 }
3088
3089 // Everything works; then return TRUE
3090 refVar->PutBool( true );
3091}
3092
3094{
3095 // We need 1 parameter minimum
3096 if (rPar.Count() < 2)
3097 {
3099 return;
3100 }
3101
3102 // variable for the return value
3103 SbxVariableRef refVar = rPar.Get(0);
3104 refVar->PutBool( false );
3105
3106 // get the Uno-Object
3107 SbxVariableRef xParam = rPar.Get(1);
3108 if( !xParam->IsObject() )
3109 {
3110 return;
3111 }
3112 SbxBaseRef pObj = xParam->GetObject();
3113 auto obj = dynamic_cast<SbUnoObject*>( pObj.get() );
3114 if( obj == nullptr )
3115 {
3116 return;
3117 }
3118 Any aAny = obj->getUnoAny();
3119 TypeClass eType = aAny.getValueType().getTypeClass();
3120 if( eType == TypeClass_STRUCT )
3121 {
3122 refVar->PutBool( true );
3123 }
3124}
3125
3126
3128{
3129 if (rPar.Count() < 3)
3130 {
3132 return;
3133 }
3134
3135 // variable for the return value
3136 SbxVariableRef refVar = rPar.Get(0);
3137 refVar->PutBool( false );
3138
3139 // get the Uno-Objects
3140 SbxVariableRef xParam1 = rPar.Get(1);
3141 if( !xParam1->IsObject() )
3142 {
3143 return;
3144 }
3145 SbxBaseRef pObj1 = xParam1->GetObject();
3146 auto obj1 = dynamic_cast<SbUnoObject*>( pObj1.get() );
3147 if( obj1 == nullptr )
3148 {
3149 return;
3150 }
3151 Any aAny1 = obj1->getUnoAny();
3152 TypeClass eType1 = aAny1.getValueType().getTypeClass();
3153 if( eType1 != TypeClass_INTERFACE )
3154 {
3155 return;
3156 }
3158 aAny1 >>= x1;
3159
3160 SbxVariableRef xParam2 = rPar.Get(2);
3161 if( !xParam2->IsObject() )
3162 {
3163 return;
3164 }
3165 SbxBaseRef pObj2 = xParam2->GetObject();
3166 auto obj2 = dynamic_cast<SbUnoObject*>( pObj2.get() );
3167 if( obj2 == nullptr )
3168 {
3169 return;
3170 }
3171 Any aAny2 = obj2->getUnoAny();
3172 TypeClass eType2 = aAny2.getValueType().getTypeClass();
3173 if( eType2 != TypeClass_INTERFACE )
3174 {
3175 return;
3176 }
3178 aAny2 >>= x2;
3179
3180 if( x1 == x2 )
3181 {
3182 refVar->PutBool( true );
3183 }
3184}
3185
3186
3187// helper wrapper function to interact with TypeProvider and
3188// XTypeDescriptionEnumerationAccess.
3189// if it fails for whatever reason
3190// returned Reference<> be null e.g. .is() will be false
3191
3193 const Sequence< TypeClass >& types,
3194 TypeDescriptionSearchDepth depth )
3195{
3198 if ( xTypeEnumAccess.is() )
3199 {
3200 try
3201 {
3202 xEnum = xTypeEnumAccess->createTypeDescriptionEnumeration(
3203 sSearchRoot, types, depth );
3204 }
3205 catch(const NoSuchTypeNameException& /*nstne*/ ) {}
3206 catch(const InvalidTypeNameException& /*nstne*/ ) {}
3207 }
3208 return xEnum;
3209}
3210
3213{
3215 return aHelper;
3216}
3217
3219{
3220 if ( isInited )
3221 return;
3222
3223 Reference< XTypeDescriptionEnumeration > xEnum = getTypeDescriptorEnumeration( "ooo.vba", {TypeClass_CONSTANTS}, TypeDescriptionSearchDepth_INFINITE );
3224
3225 if ( !xEnum.is())
3226 {
3227 return; //NULL;
3228 }
3229 while ( xEnum->hasMoreElements() )
3230 {
3231 Reference< XConstantsTypeDescription > xConstants( xEnum->nextElement(), UNO_QUERY );
3232 if ( xConstants.is() )
3233 {
3234 // store constant group name
3235 OUString sFullName = xConstants->getName();
3236 sal_Int32 indexLastDot = sFullName.lastIndexOf('.');
3237 OUString sLeafName( sFullName );
3238 if ( indexLastDot > -1 )
3239 {
3240 sLeafName = sFullName.copy( indexLastDot + 1);
3241 }
3242 aConstCache.push_back( sLeafName ); // assume constant group names are unique
3243 const Sequence< Reference< XConstantTypeDescription > > aConsts = xConstants->getConstants();
3244 for (const auto& ctd : aConsts)
3245 {
3246 // store constant member name
3247 sFullName = ctd->getName();
3248 indexLastDot = sFullName.lastIndexOf('.');
3249 sLeafName = sFullName;
3250 if ( indexLastDot > -1 )
3251 {
3252 sLeafName = sFullName.copy( indexLastDot + 1);
3253 }
3254 aConstHash[ sLeafName.toAsciiLowerCase() ] = ctd->getConstantValue();
3255 }
3256 }
3257 }
3258 isInited = true;
3259}
3260
3261bool
3262VBAConstantHelper::isVBAConstantType( std::u16string_view rName )
3263{
3264 init();
3265 bool bConstant = false;
3266
3267 for (auto const& elem : aConstCache)
3268 {
3269 if( o3tl::equalsIgnoreAsciiCase(rName, elem) )
3270 {
3271 bConstant = true;
3272 break;
3273 }
3274 }
3275 return bConstant;
3276}
3277
3280{
3281 SbxVariable* pConst = nullptr;
3282 init();
3283
3284 auto it = aConstHash.find( rName.toAsciiLowerCase() );
3285
3286 if ( it != aConstHash.end() )
3287 {
3288 pConst = new SbxVariable( SbxVARIANT );
3289 pConst->SetName( rName );
3290 unoToSbxValue( pConst, it->second );
3291 }
3292
3293 return pConst;
3294}
3295
3296// Function to search for a global identifier in the
3297// UnoScope and to wrap it for Sbx
3298SbUnoClass* findUnoClass( const OUString& rName )
3299{
3300 // #105550 Check if module exists
3301 SbUnoClass* pUnoClass = nullptr;
3302
3304 if( xTypeAccess->hasByHierarchicalName( rName ) )
3305 {
3306 Any aRet = xTypeAccess->getByHierarchicalName( rName );
3308 aRet >>= xTypeDesc;
3309
3310 if( xTypeDesc.is() )
3311 {
3312 TypeClass eTypeClass = xTypeDesc->getTypeClass();
3313 if( eTypeClass == TypeClass_MODULE || eTypeClass == TypeClass_CONSTANTS )
3314 {
3315 pUnoClass = new SbUnoClass( rName );
3316 }
3317 }
3318 }
3319 return pUnoClass;
3320}
3321
3323{
3325
3326 // If nothing were located the submodule isn't known yet
3327 if( !pRes )
3328 {
3329 // If it is already a class, ask for the field
3330 if( m_xClass.is() )
3331 {
3332 // Is it a field(?)
3333 Reference< XIdlField > xField = m_xClass->getField( rName );
3334 if( xField.is() )
3335 {
3336 try
3337 {
3338 Any aAny = xField->get( {} ); //TODO: does this make sense?
3339
3340 // Convert to Sbx
3341 pRes = new SbxVariable( SbxVARIANT );
3342 pRes->SetName( rName );
3343 unoToSbxValue( pRes, aAny );
3344 }
3345 catch( const Exception& )
3346 {
3347 implHandleAnyException( ::cppu::getCaughtException() );
3348 }
3349 }
3350 }
3351 else
3352 {
3353 // expand fully qualified name
3354 OUString aNewName = GetName()
3355 + "."
3356 + rName;
3357
3358 // get CoreReflection
3360 if( xCoreReflection.is() )
3361 {
3362 // Is it a constant?
3364 if( xHarryName.is() )
3365 {
3366 try
3367 {
3368 Any aValue = xHarryName->getByHierarchicalName( aNewName );
3369 TypeClass eType = aValue.getValueType().getTypeClass();
3370
3371 // Interface located? Then it is a class
3372 if( eType == TypeClass_INTERFACE )
3373 {
3374 Reference< XIdlClass > xClass( aValue, UNO_QUERY );
3375 if( xClass.is() )
3376 {
3377 pRes = new SbxVariable( SbxVARIANT );
3378 SbxObjectRef xWrapper = static_cast<SbxObject*>(new SbUnoClass( aNewName, xClass ));
3379 pRes->PutObject( xWrapper.get() );
3380 }
3381 }
3382 else
3383 {
3384 pRes = new SbxVariable( SbxVARIANT );
3385 unoToSbxValue( pRes, aValue );
3386 }
3387 }
3388 catch( const NoSuchElementException& )
3389 {
3390 }
3391 }
3392
3393 // Otherwise take it again as class
3394 if( !pRes )
3395 {
3396 SbUnoClass* pNewClass = findUnoClass( aNewName );
3397 if( pNewClass )
3398 {
3399 pRes = new SbxVariable( SbxVARIANT );
3400 SbxObjectRef xWrapper = static_cast<SbxObject*>(pNewClass);
3401 pRes->PutObject( xWrapper.get() );
3402 }
3403 }
3404
3405 // A UNO service?
3406 if( !pRes )
3407 {
3408 SbUnoService* pUnoService = findUnoService( aNewName );
3409 if( pUnoService )
3410 {
3411 pRes = new SbxVariable( SbxVARIANT );
3412 SbxObjectRef xWrapper = static_cast<SbxObject*>(pUnoService);
3413 pRes->PutObject( xWrapper.get() );
3414 }
3415 }
3416
3417 // A UNO singleton?
3418 if( !pRes )
3419 {
3420 SbUnoSingleton* pUnoSingleton = findUnoSingleton( aNewName );
3421 if( pUnoSingleton )
3422 {
3423 pRes = new SbxVariable( SbxVARIANT );
3424 SbxObjectRef xWrapper = static_cast<SbxObject*>(pUnoSingleton);
3425 pRes->PutObject( xWrapper.get() );
3426 }
3427 }
3428 }
3429 }
3430
3431 if( pRes )
3432 {
3433 pRes->SetName( rName );
3434
3435 // Insert variable, so that it could be found later
3436 QuickInsert( pRes );
3437
3438 // Take us out as listener at once,
3439 // the values are all constant
3440 if( pRes->IsBroadcaster() )
3441 EndListening( pRes->GetBroadcaster(), true );
3442 }
3443 }
3444 return pRes;
3445}
3446
3447
3448SbUnoService* findUnoService( const OUString& rName )
3449{
3450 SbUnoService* pSbUnoService = nullptr;
3451
3453 if( xTypeAccess->hasByHierarchicalName( rName ) )
3454 {
3455 Any aRet = xTypeAccess->getByHierarchicalName( rName );
3457 aRet >>= xTypeDesc;
3458
3459 if( xTypeDesc.is() )
3460 {
3461 TypeClass eTypeClass = xTypeDesc->getTypeClass();
3462 if( eTypeClass == TypeClass_SERVICE )
3463 {
3464 Reference< XServiceTypeDescription2 > xServiceTypeDesc( xTypeDesc, UNO_QUERY );
3465 if( xServiceTypeDesc.is() )
3466 pSbUnoService = new SbUnoService( rName, xServiceTypeDesc );
3467 }
3468 }
3469 }
3470 return pSbUnoService;
3471}
3472
3474{
3476
3477 if( !pRes )
3478 {
3479 // If it is already a class ask for a field
3480 if( m_bNeedsInit && m_xServiceTypeDesc.is() )
3481 {
3482 m_bNeedsInit = false;
3483
3485 const Reference< XServiceConstructorDescription >* pCtorSeq = aSCDSeq.getConstArray();
3486 int nCtorCount = aSCDSeq.getLength();
3487 for( int i = 0 ; i < nCtorCount ; ++i )
3488 {
3490
3491 OUString aName( xCtor->getName() );
3492 if( aName.isEmpty() )
3493 {
3494 if( xCtor->isDefaultConstructor() )
3495 {
3496 aName = "create";
3497 }
3498 }
3499
3500 if( !aName.isEmpty() )
3501 {
3502 // Create and insert SbUnoServiceCtor
3503 SbxVariableRef xSbCtorRef = new SbUnoServiceCtor( aName, xCtor );
3504 QuickInsert( xSbCtorRef.get() );
3505 }
3506 }
3507 pRes = SbxObject::Find( rName, SbxClassType::Method );
3508 }
3509 }
3510
3511 return pRes;
3512}
3513
3515{
3516 const SbxHint* pHint = dynamic_cast<const SbxHint*>(&rHint);
3517 if( !pHint )
3518 return;
3519
3520 SbxVariable* pVar = pHint->GetVar();
3521 SbxArray* pParams = pVar->GetParameters();
3522 SbUnoServiceCtor* pUnoCtor = dynamic_cast<SbUnoServiceCtor*>( pVar );
3523 if( pUnoCtor && pHint->GetId() == SfxHintId::BasicDataWanted )
3524 {
3525 // Parameter count -1 because of Param0 == this
3526 sal_uInt32 nParamCount = pParams ? (pParams->Count() - 1) : 0;
3528
3530 Sequence< Reference< XParameter > > aParameterSeq = xCtor->getParameters();
3531 const Reference< XParameter >* pParameterSeq = aParameterSeq.getConstArray();
3532 sal_uInt32 nUnoParamCount = aParameterSeq.getLength();
3533
3534 // Default: Ignore not needed parameters
3535 bool bParameterError = false;
3536
3537 // Is the last parameter a rest parameter?
3538 bool bRestParameterMode = false;
3539 if( nUnoParamCount > 0 )
3540 {
3541 Reference< XParameter > xLastParam = pParameterSeq[ nUnoParamCount - 1 ];
3542 if( xLastParam.is() )
3543 {
3544 if( xLastParam->isRestParameter() )
3545 bRestParameterMode = true;
3546 }
3547 }
3548
3549 // Too many parameters with context as first parameter?
3550 sal_uInt32 nSbxParameterOffset = 1;
3551 sal_uInt32 nParameterOffsetByContext = 0;
3552 Reference < XComponentContext > xFirstParamContext;
3553 if( nParamCount > nUnoParamCount )
3554 {
3555 // Check if first parameter is a context and use it
3556 // then in createInstanceWithArgumentsAndContext
3557 Any aArg0 = sbxToUnoValue(pParams->Get(nSbxParameterOffset));
3558 if( (aArg0 >>= xFirstParamContext) && xFirstParamContext.is() )
3559 nParameterOffsetByContext = 1;
3560 }
3561
3562 sal_uInt32 nEffectiveParamCount = nParamCount - nParameterOffsetByContext;
3563 sal_uInt32 nAllocParamCount = nEffectiveParamCount;
3564 if( nEffectiveParamCount > nUnoParamCount )
3565 {
3566 if( !bRestParameterMode )
3567 {
3568 nEffectiveParamCount = nUnoParamCount;
3569 nAllocParamCount = nUnoParamCount;
3570 }
3571 }
3572 // Not enough parameters?
3573 else if( nUnoParamCount > nEffectiveParamCount )
3574 {
3575 // RestParameterMode only helps if one (the last) parameter is missing
3576 int nDiff = nUnoParamCount - nEffectiveParamCount;
3577 if( !bRestParameterMode || nDiff > 1 )
3578 {
3579 bParameterError = true;
3581 }
3582 }
3583
3584 if( !bParameterError )
3585 {
3586 bool bOutParams = false;
3587 if( nAllocParamCount > 0 )
3588 {
3589 args.realloc( nAllocParamCount );
3590 Any* pAnyArgs = args.getArray();
3591 for( sal_uInt32 i = 0 ; i < nEffectiveParamCount ; i++ )
3592 {
3593 sal_uInt32 iSbx = i + nSbxParameterOffset + nParameterOffsetByContext;
3594
3595 // bRestParameterMode allows nEffectiveParamCount > nUnoParamCount
3597 if( i < nUnoParamCount )
3598 {
3599 xParam = pParameterSeq[i];
3600 if( !xParam.is() )
3601 continue;
3602
3603 Reference< XTypeDescription > xParamTypeDesc = xParam->getType();
3604 if( !xParamTypeDesc.is() )
3605 continue;
3606 css::uno::Type aType( xParamTypeDesc->getTypeClass(), xParamTypeDesc->getName() );
3607
3608 // sbx parameter needs offset 1
3609 pAnyArgs[i] = sbxToUnoValue(pParams->Get(iSbx), aType);
3610
3611 // Check for out parameter if not already done
3612 if( !bOutParams && xParam->isOut() )
3613 bOutParams = true;
3614 }
3615 else
3616 {
3617 pAnyArgs[i] = sbxToUnoValue(pParams->Get(iSbx));
3618 }
3619 }
3620 }
3621
3622 // "Call" ctor using createInstanceWithArgumentsAndContext
3624 xFirstParamContext.is()
3625 ? xFirstParamContext
3627 Reference< XMultiComponentFactory > xServiceMgr( xContext->getServiceManager() );
3628
3629 Any aRetAny;
3630 OUString aServiceName = GetName();
3632 try
3633 {
3634 xRet = xServiceMgr->createInstanceWithArgumentsAndContext( aServiceName, args, xContext );
3635 }
3636 catch( const Exception& )
3637 {
3638 implHandleAnyException( ::cppu::getCaughtException() );
3639 }
3640 aRetAny <<= xRet;
3641 unoToSbxValue( pVar, aRetAny );
3642
3643 // Copy back out parameters?
3644 if( bOutParams )
3645 {
3646 const Any* pAnyArgs = args.getConstArray();
3647
3648 for( sal_uInt32 j = 0 ; j < nUnoParamCount ; j++ )
3649 {
3650 Reference< XParameter > xParam = pParameterSeq[j];
3651 if( !xParam.is() )
3652 continue;
3653
3654 if( xParam->isOut() )
3655 unoToSbxValue(pParams->Get(j + 1), pAnyArgs[j]);
3656 }
3657 }
3658 }
3659 }
3660 else
3661 SbxObject::Notify( rBC, rHint );
3662}
3663
3664
3666 : SbxMethod( aName_, SbxOBJECT )
3667 , m_xServiceCtorDesc( xServiceCtorDesc )
3668{
3669}
3670
3672{
3673}
3674
3676{
3677 return nullptr;
3678}
3679
3680
3681SbUnoSingleton* findUnoSingleton( const OUString& rName )
3682{
3683 SbUnoSingleton* pSbUnoSingleton = nullptr;
3684
3686 if( xTypeAccess->hasByHierarchicalName( rName ) )
3687 {
3688 Any aRet = xTypeAccess->getByHierarchicalName( rName );
3690 aRet >>= xTypeDesc;
3691
3692 if( xTypeDesc.is() )
3693 {
3694 TypeClass eTypeClass = xTypeDesc->getTypeClass();
3695 if( eTypeClass == TypeClass_SINGLETON )
3696 {
3697 Reference< XSingletonTypeDescription > xSingletonTypeDesc( xTypeDesc, UNO_QUERY );
3698 if( xSingletonTypeDesc.is() )
3699 pSbUnoSingleton = new SbUnoSingleton( rName );
3700 }
3701 }
3702 }
3703 return pSbUnoSingleton;
3704}
3705
3706SbUnoSingleton::SbUnoSingleton( const OUString& aName_ )
3707 : SbxObject( aName_ )
3708{
3709 SbxVariableRef xGetMethodRef = new SbxMethod( "get", SbxOBJECT );
3710 QuickInsert( xGetMethodRef.get() );
3711}
3712
3714{
3715 const SbxHint* pHint = dynamic_cast<const SbxHint*>(&rHint);
3716 if( pHint )
3717 {
3718 SbxVariable* pVar = pHint->GetVar();
3719 SbxArray* pParams = pVar->GetParameters();
3720 sal_uInt32 nParamCount = pParams ? (pParams->Count() - 1) : 0;
3721 sal_uInt32 nAllowedParamCount = 1;
3722
3723 Reference < XComponentContext > xContextToUse;
3724 if( nParamCount > 0 )
3725 {
3726 // Check if first parameter is a context and use it then
3727 Reference < XComponentContext > xFirstParamContext;
3728 Any aArg1 = sbxToUnoValue(pParams->Get(1));
3729 if( (aArg1 >>= xFirstParamContext) && xFirstParamContext.is() )
3730 xContextToUse = xFirstParamContext;
3731 }
3732
3733 if( !xContextToUse.is() )
3734 {
3736 --nAllowedParamCount;
3737 }
3738
3739 if( nParamCount > nAllowedParamCount )
3740 {
3742 return;
3743 }
3744
3745 Any aRetAny;
3746 if( xContextToUse.is() )
3747 {
3748 OUString aSingletonName = "/singletons/"
3749 + GetName();
3751 xContextToUse->getValueByName( aSingletonName ) >>= xRet;
3752 aRetAny <<= xRet;
3753 }
3754 unoToSbxValue( pVar, aRetAny );
3755 }
3756 else
3757 {
3758 SbxObject::Notify( rBC, rHint );
3759 }
3760}
3761
3762namespace {
3763
3764// Implementation of an EventAttacher-drawn AllListener, which
3765// solely transmits several events to a general AllListener
3766class BasicAllListener_Impl : public WeakImplHelper< XAllListener >
3767{
3768 void firing_impl(const AllEventObject& Event, Any* pRet);
3769
3770public:
3771 SbxObjectRef xSbxObj;
3772 OUString aPrefixName;
3773
3774 explicit BasicAllListener_Impl( OUString aPrefixName );
3775
3776 // Methods of XAllListener
3777 virtual void SAL_CALL firing(const AllEventObject& Event) override;
3778 virtual Any SAL_CALL approveFiring(const AllEventObject& Event) override;
3779
3780 // Methods of XEventListener
3781 virtual void SAL_CALL disposing(const EventObject& Source) override;
3782};
3783
3784}
3785
3786BasicAllListener_Impl::BasicAllListener_Impl(OUString aPrefixName_)
3787 : aPrefixName(std::move( aPrefixName_ ))
3788{
3789}
3790
3791void BasicAllListener_Impl::firing_impl( const AllEventObject& Event, Any* pRet )
3792{
3793 SolarMutexGuard guard;
3794
3795 if( !xSbxObj.is() )
3796 return;
3797
3798 OUString aMethodName = aPrefixName + Event.MethodName;
3799
3800 SbxVariable * pP = xSbxObj.get();
3801 while( pP->GetParent() )
3802 {
3803 pP = pP->GetParent();
3804 StarBASIC * pLib = dynamic_cast<StarBASIC*>( pP );
3805 if( pLib )
3806 {
3807 // Create in a Basic Array
3808 SbxArrayRef xSbxArray = new SbxArray( SbxVARIANT );
3809 const Any * pArgs = Event.Arguments.getConstArray();
3810 sal_Int32 nCount = Event.Arguments.getLength();
3811 for( sal_Int32 i = 0; i < nCount; i++ )
3812 {
3813 // Convert elements
3815 unoToSbxValue( xVar.get(), pArgs[i] );
3816 xSbxArray->Put(xVar.get(), i + 1);
3817 }
3818
3819 pLib->Call( aMethodName, xSbxArray.get() );
3820
3821 // get the return value from the Param-Array, if requested
3822 if( pRet )
3823 {
3824 SbxVariable* pVar = xSbxArray->Get(0);
3825 if( pVar )
3826 {
3827 // #95792 Avoid a second call
3828 SbxFlagBits nFlags = pVar->GetFlags();
3830 *pRet = sbxToUnoValueImpl( pVar );
3831 pVar->SetFlags( nFlags );
3832 }
3833 }
3834 break;
3835 }
3836 }
3837}
3838
3839
3840// Methods of Listener
3841void BasicAllListener_Impl::firing( const AllEventObject& Event )
3842{
3843 firing_impl( Event, nullptr );
3844}
3845
3846Any BasicAllListener_Impl::approveFiring( const AllEventObject& Event )
3847{
3848 Any aRetAny;
3849 firing_impl( Event, &aRetAny );
3850 return aRetAny;
3851}
3852
3853
3854// Methods of XEventListener
3855void BasicAllListener_Impl ::disposing(const EventObject& )
3856{
3857 SolarMutexGuard guard;
3858
3859 xSbxObj.clear();
3860}
3861
3862
3863// class InvocationToAllListenerMapper
3864// helper class to map XInvocation to XAllListener (also in project eventattacher!)
3865
3866namespace {
3867
3868class InvocationToAllListenerMapper : public WeakImplHelper< XInvocation >
3869{
3870public:
3871 InvocationToAllListenerMapper( const Reference< XIdlClass >& ListenerType,
3872 const Reference< XAllListener >& AllListener, Any Helper );
3873
3874 // XInvocation
3875 virtual Reference< XIntrospectionAccess > SAL_CALL getIntrospection() override;
3876 virtual Any SAL_CALL invoke(const OUString& FunctionName, const Sequence< Any >& Params, Sequence< sal_Int16 >& OutParamIndex, Sequence< Any >& OutParam) override;
3877 virtual void SAL_CALL setValue(const OUString& PropertyName, const Any& Value) override;
3878 virtual Any SAL_CALL getValue(const OUString& PropertyName) override;
3879 virtual sal_Bool SAL_CALL hasMethod(const OUString& Name) override;
3880 virtual sal_Bool SAL_CALL hasProperty(const OUString& Name) override;
3881
3882private:
3885 Any m_Helper;
3886};
3887
3888}
3889
3890// Function to replace AllListenerAdapterService::createAllListerAdapter
3892(
3893 const Reference< XInvocationAdapterFactory2 >& xInvocationAdapterFactory,
3894 const Reference< XIdlClass >& xListenerType,
3895 const Reference< XAllListener >& xListener,
3896 const Any& Helper
3897)
3898{
3899 Reference< XInterface > xAdapter;
3900 if( xInvocationAdapterFactory.is() && xListenerType.is() && xListener.is() )
3901 {
3902 Reference< XInvocation > xInvocationToAllListenerMapper =
3903 new InvocationToAllListenerMapper(xListenerType, xListener, Helper);
3904 Type aListenerType( xListenerType->getTypeClass(), xListenerType->getName() );
3905 xAdapter = xInvocationAdapterFactory->createAdapter( xInvocationToAllListenerMapper, {aListenerType} );
3906 }
3907 return xAdapter;
3908}
3909
3910
3911// InvocationToAllListenerMapper
3912InvocationToAllListenerMapper::InvocationToAllListenerMapper
3913 ( const Reference< XIdlClass >& ListenerType, const Reference< XAllListener >& AllListener, Any Helper )
3914 : m_xAllListener( AllListener )
3915 , m_xListenerType( ListenerType )
3916 , m_Helper(std::move( Helper ))
3917{
3918}
3919
3920
3921Reference< XIntrospectionAccess > SAL_CALL InvocationToAllListenerMapper::getIntrospection()
3922{
3924}
3925
3926
3927Any SAL_CALL InvocationToAllListenerMapper::invoke(const OUString& FunctionName, const Sequence< Any >& Params,
3929{
3930 Any aRet;
3931
3932 // Check if to firing or approveFiring has to be called
3933 Reference< XIdlMethod > xMethod = m_xListenerType->getMethod( FunctionName );
3934 bool bApproveFiring = false;
3935 if( !xMethod.is() )
3936 return aRet;
3937 Reference< XIdlClass > xReturnType = xMethod->getReturnType();
3938 Sequence< Reference< XIdlClass > > aExceptionSeq = xMethod->getExceptionTypes();
3939 if( ( xReturnType.is() && xReturnType->getTypeClass() != TypeClass_VOID ) ||
3940 aExceptionSeq.hasElements() )
3941 {
3942 bApproveFiring = true;
3943 }
3944 else
3945 {
3946 Sequence< ParamInfo > aParamSeq = xMethod->getParameterInfos();
3947 sal_uInt32 nParamCount = aParamSeq.getLength();
3948 if( nParamCount > 1 )
3949 {
3950 const ParamInfo* pInfo = aParamSeq.getConstArray();
3951 for( sal_uInt32 i = 0 ; i < nParamCount ; i++ )
3952 {
3953 if( pInfo[ i ].aMode != ParamMode_IN )
3954 {
3955 bApproveFiring = true;
3956 break;
3957 }
3958 }
3959 }
3960 }
3961
3962 AllEventObject aAllEvent;
3963 aAllEvent.Source = getXWeak();
3964 aAllEvent.Helper = m_Helper;
3965 aAllEvent.ListenerType = Type(m_xListenerType->getTypeClass(), m_xListenerType->getName() );
3966 aAllEvent.MethodName = FunctionName;
3967 aAllEvent.Arguments = Params;
3968 if( bApproveFiring )
3969 aRet = m_xAllListener->approveFiring( aAllEvent );
3970 else
3971 m_xAllListener->firing( aAllEvent );
3972 return aRet;
3973}
3974
3975
3976void SAL_CALL InvocationToAllListenerMapper::setValue(const OUString&, const Any&)
3977{}
3978
3979
3980Any SAL_CALL InvocationToAllListenerMapper::getValue(const OUString&)
3981{
3982 return Any();
3983}
3984
3985
3986sal_Bool SAL_CALL InvocationToAllListenerMapper::hasMethod(const OUString& Name)
3987{
3988 Reference< XIdlMethod > xMethod = m_xListenerType->getMethod( Name );
3989 return xMethod.is();
3990}
3991
3992
3993sal_Bool SAL_CALL InvocationToAllListenerMapper::hasProperty(const OUString& Name)
3994{
3995 Reference< XIdlField > xField = m_xListenerType->getField( Name );
3996 return xField.is();
3997}
3998
3999
4000// create Uno-Service
4001// 1. Parameter == Prefix-Name of the macro
4002// 2. Parameter == fully qualified name of the listener
4003void SbRtl_CreateUnoListener(StarBASIC * pBasic, SbxArray & rPar, bool)
4004{
4005 // We need 2 parameters
4006 if (rPar.Count() != 3)
4007 {
4009 return;
4010 }
4011
4012 // get the name of the class of the struct
4013 OUString aPrefixName = rPar.Get(1)->GetOUString();
4014 OUString aListenerClassName = rPar.Get(2)->GetOUString();
4015
4016 // get the CoreReflection
4018 if( !xCoreReflection.is() )
4019 return;
4020
4021 // get the AllListenerAdapterService
4023
4024 // search the class
4025 Reference< XIdlClass > xClass = xCoreReflection->forName( aListenerClassName );
4026 if( !xClass.is() )
4027 return;
4028
4029 // From 1999-11-30: get the InvocationAdapterFactory
4030 Reference< XInvocationAdapterFactory2 > xInvocationAdapterFactory =
4031 InvocationAdapterFactory::create( xContext );
4032
4033 rtl::Reference<BasicAllListener_Impl> xAllLst = new BasicAllListener_Impl( aPrefixName );
4034 Any aTmp;
4035 Reference< XInterface > xLst = createAllListenerAdapter( xInvocationAdapterFactory, xClass, xAllLst, aTmp );
4036 if( !xLst.is() )
4037 return;
4038
4039 OUString aClassName = xClass->getName();
4040 Type aClassType( xClass->getTypeClass(), aClassName );
4041 aTmp = xLst->queryInterface( aClassType );
4042 if( !aTmp.hasValue() )
4043 return;
4044
4045 SbUnoObject* pUnoObj = new SbUnoObject( aListenerClassName, aTmp );
4046 xAllLst->xSbxObj = pUnoObj;
4047 xAllLst->xSbxObj->SetParent( pBasic );
4048
4049 // #100326 Register listener object to set Parent NULL in Dtor
4050 SbxArrayRef xBasicUnoListeners = pBasic->getUnoListeners();
4051 xBasicUnoListeners->Insert(pUnoObj, xBasicUnoListeners->Count());
4052
4053 // return the object
4054 SbxVariableRef refVar = rPar.Get(0);
4055 refVar->PutObject( xAllLst->xSbxObj.get() );
4056}
4057
4058
4059// Represents the DefaultContext property of the ProcessServiceManager
4060// in the Basic runtime system.
4062{
4063 SbxVariableRef refVar = rPar.Get(0);
4064
4066
4067 SbUnoObjectRef xUnoObj = new SbUnoObject( "DefaultContext", aContextAny );
4068 refVar->PutObject( xUnoObj.get() );
4069}
4070
4071
4072// Creates a Basic wrapper object for a strongly typed Uno value
4073// 1. parameter: Uno type as full qualified type name, e.g. "byte[]"
4075{
4076 // 2 parameters needed
4077 if (rPar.Count() != 3)
4078 {
4080 return;
4081 }
4082
4083 // get the name of the class of the struct
4084 OUString aTypeName = rPar.Get(1)->GetOUString();
4085 SbxVariable* pVal = rPar.Get(2);
4086
4087 if( aTypeName == "type" )
4088 {
4089 SbxDataType eBaseType = pVal->SbxValue::GetType();
4090 OUString aValTypeName;
4091 if( eBaseType == SbxSTRING )
4092 {
4093 aValTypeName = pVal->GetOUString();
4094 }
4095 else if( eBaseType == SbxOBJECT )
4096 {
4097 // XIdlClass?
4098 Reference< XIdlClass > xIdlClass;
4099
4100 SbxBaseRef pObj = pVal->GetObject();
4101 if( auto obj = dynamic_cast<SbUnoObject*>( pObj.get() ) )
4102 {
4103 Any aUnoAny = obj->getUnoAny();
4104 aUnoAny >>= xIdlClass;
4105 }
4106
4107 if( xIdlClass.is() )
4108 {
4109 aValTypeName = xIdlClass->getName();
4110 }
4111 }
4112 Type aType;
4113 bool bSuccess = implGetTypeByName( aValTypeName, aType );
4114 if( bSuccess )
4115 {
4116 Any aTypeAny( aType );
4117 SbxVariableRef refVar = rPar.Get(0);
4118 SbxObjectRef xUnoAnyObject = new SbUnoAnyObject( aTypeAny );
4119 refVar->PutObject( xUnoAnyObject.get() );
4120 }
4121 return;
4122 }
4123
4124 // Check the type
4126 Any aRet;
4127 try
4128 {
4129 aRet = xTypeAccess->getByHierarchicalName( aTypeName );
4130 }
4131 catch( const NoSuchElementException& e1 )
4132 {
4134 implGetExceptionMsg( e1, u"com.sun.star.container.NoSuchElementException" ) );
4135 return;
4136 }
4138 aRet >>= xTypeDesc;
4139 TypeClass eTypeClass = xTypeDesc->getTypeClass();
4140 Type aDestType( eTypeClass, aTypeName );
4141
4142
4143 // Preconvert value
4144 Any aVal = sbxToUnoValueImpl( pVal );
4145 Any aConvertedVal = convertAny( aVal, aDestType );
4146
4147 SbxVariableRef refVar = rPar.Get(0);
4148 SbxObjectRef xUnoAnyObject = new SbUnoAnyObject( aConvertedVal );
4149 refVar->PutObject( xUnoAnyObject.get() );
4150}
4151
4152namespace {
4153
4154class ModuleInvocationProxy : public WeakImplHelper< XInvocation, XComponent >
4155{
4156 std::mutex m_aMutex;
4157 OUString m_aPrefix;
4158 SbxObjectRef m_xScopeObj;
4159 bool m_bProxyIsClassModuleObject;
4160
4162
4163public:
4164 ModuleInvocationProxy( std::u16string_view aPrefix, SbxObjectRef const & xScopeObj );
4165
4166 // XInvocation
4167 virtual Reference< XIntrospectionAccess > SAL_CALL getIntrospection() override;
4168 virtual void SAL_CALL setValue( const OUString& rProperty, const Any& rValue ) override;
4169 virtual Any SAL_CALL getValue( const OUString& rProperty ) override;
4170 virtual sal_Bool SAL_CALL hasMethod( const OUString& rName ) override;
4171 virtual sal_Bool SAL_CALL hasProperty( const OUString& rProp ) override;
4172
4173 virtual Any SAL_CALL invoke( const OUString& rFunction,
4174 const Sequence< Any >& rParams,
4175 Sequence< sal_Int16 >& rOutParamIndex,
4176 Sequence< Any >& rOutParam ) override;
4177
4178 // XComponent
4179 virtual void SAL_CALL dispose() override;
4180 virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) override;
4181 virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& aListener ) override;
4182};
4183
4184}
4185
4186ModuleInvocationProxy::ModuleInvocationProxy( std::u16string_view aPrefix, SbxObjectRef const & xScopeObj )
4187 : m_aPrefix( OUString::Concat(aPrefix) + "_" )
4188 , m_xScopeObj( xScopeObj )
4189{
4190 m_bProxyIsClassModuleObject = xScopeObj.is() && dynamic_cast<const SbClassModuleObject*>( xScopeObj.get() ) != nullptr;
4191}
4192
4193Reference< XIntrospectionAccess > SAL_CALL ModuleInvocationProxy::getIntrospection()
4194{
4196}
4197
4198void SAL_CALL ModuleInvocationProxy::setValue(const OUString& rProperty, const Any& rValue)
4199{
4200 if( !m_bProxyIsClassModuleObject )
4201 throw UnknownPropertyException();
4202
4203 SolarMutexGuard guard;
4204
4205 OUString aPropertyFunctionName = "Property Set "
4206 + m_aPrefix
4207 + rProperty;
4208
4209 SbxVariable* p = m_xScopeObj->Find( aPropertyFunctionName, SbxClassType::Method );
4210 SbMethod* pMeth = dynamic_cast<SbMethod*>( p );
4211 if( pMeth == nullptr )
4212 {
4213 // TODO: Check vba behavior concerning missing function
4214 //StarBASIC::Error( ERRCODE_BASIC_NO_METHOD, aFunctionName );
4215 throw UnknownPropertyException(aPropertyFunctionName);
4216 }
4217
4218 // Setup parameter
4219 SbxArrayRef xArray = new SbxArray;
4221 unoToSbxValue( xVar.get(), rValue );
4222 xArray->Put(xVar.get(), 1);
4223
4224 // Call property method
4225 SbxVariableRef xValue = new SbxVariable;
4226 pMeth->SetParameters( xArray.get() );
4227 pMeth->Call( xValue.get() );
4228 pMeth->SetParameters( nullptr );
4229
4230 // TODO: OutParameter?
4231
4232
4233}
4234
4235Any SAL_CALL ModuleInvocationProxy::getValue(const OUString& rProperty)
4236{
4237 if( !m_bProxyIsClassModuleObject )
4238 {
4239 throw UnknownPropertyException();
4240 }
4241 SolarMutexGuard guard;
4242
4243 OUString aPropertyFunctionName = "Property Get "
4244 + m_aPrefix
4245 + rProperty;
4246
4247 SbxVariable* p = m_xScopeObj->Find( aPropertyFunctionName, SbxClassType::Method );
4248 SbMethod* pMeth = dynamic_cast<SbMethod*>( p );
4249 if( pMeth == nullptr )
4250 {
4251 // TODO: Check vba behavior concerning missing function
4252 //StarBASIC::Error( ERRCODE_BASIC_NO_METHOD, aFunctionName );
4253 throw UnknownPropertyException(aPropertyFunctionName);
4254 }
4255
4256 // Call method
4257 SbxVariableRef xValue = new SbxVariable;
4258 pMeth->Call( xValue.get() );
4259 Any aRet = sbxToUnoValue( xValue.get() );
4260 return aRet;
4261}
4262
4263sal_Bool SAL_CALL ModuleInvocationProxy::hasMethod( const OUString& )
4264{
4265 return false;
4266}
4267
4268sal_Bool SAL_CALL ModuleInvocationProxy::hasProperty( const OUString& )
4269{
4270 return false;
4271}
4272
4273Any SAL_CALL ModuleInvocationProxy::invoke( const OUString& rFunction,
4274 const Sequence< Any >& rParams,
4277{
4278 SolarMutexGuard guard;
4279
4280 Any aRet;
4281 SbxObjectRef xScopeObj = m_xScopeObj;
4282 if( !xScopeObj.is() )
4283 {
4284 return aRet;
4285 }
4286 OUString aFunctionName = m_aPrefix
4287 + rFunction;
4288
4289 bool bOldReschedule = false;
4290 SbiInstance* pInst = GetSbData()->pInst;
4291 if( pInst && pInst->IsCompatibility() )
4292 {
4293 bOldReschedule = pInst->IsReschedule();
4294 if ( bOldReschedule )
4295 pInst->EnableReschedule( false );
4296 }
4297
4298 SbxVariable* p = xScopeObj->Find( aFunctionName, SbxClassType::Method );
4299 SbMethod* pMeth = dynamic_cast<SbMethod*>( p );
4300 if( pMeth == nullptr )
4301 {
4302 // TODO: Check vba behavior concerning missing function
4303 //StarBASIC::Error( ERRCODE_BASIC_NO_METHOD, aFunctionName );
4304 return aRet;
4305 }
4306
4307 // Setup parameters
4308 SbxArrayRef xArray;
4309 sal_Int32 nParamCount = rParams.getLength();
4310 if( nParamCount )
4311 {
4312 xArray = new SbxArray;
4313 const Any *pArgs = rParams.getConstArray();
4314 for( sal_Int32 i = 0 ; i < nParamCount ; i++ )
4315 {
4317 unoToSbxValue( xVar.get(), pArgs[i] );
4318 xArray->Put(xVar.get(), sal::static_int_cast<sal_uInt16>(i + 1));
4319 }
4320 }
4321
4322 // Call method
4323 SbxVariableRef xValue = new SbxVariable;
4324 if( xArray.is() )
4325 pMeth->SetParameters( xArray.get() );
4326 pMeth->Call( xValue.get() );
4327 aRet = sbxToUnoValue( xValue.get() );
4328 pMeth->SetParameters( nullptr );
4329
4330 if (bOldReschedule)
4331 pInst->EnableReschedule( bOldReschedule );
4332
4333 // TODO: OutParameter?
4334
4335 return aRet;
4336}
4337
4338void SAL_CALL ModuleInvocationProxy::dispose()
4339{
4340 std::unique_lock aGuard( m_aMutex );
4341
4342 EventObject aEvent( static_cast<XComponent*>(this) );
4343 m_aListeners.disposeAndClear( aGuard, aEvent );
4344
4345 m_xScopeObj = nullptr;
4346}
4347
4348void SAL_CALL ModuleInvocationProxy::addEventListener( const Reference< XEventListener >& xListener )
4349{
4350 std::unique_lock aGuard( m_aMutex );
4351 m_aListeners.addInterface( aGuard, xListener );
4352}
4353
4354void SAL_CALL ModuleInvocationProxy::removeEventListener( const Reference< XEventListener >& xListener )
4355{
4356 std::unique_lock aGuard( m_aMutex );
4357 m_aListeners.removeInterface( aGuard, xListener );
4358}
4359
4360
4361Reference< XInterface > createComListener( const Any& aControlAny, const OUString& aVBAType,
4362 std::u16string_view aPrefix,
4363 const SbxObjectRef& xScopeObj )
4364{
4366
4369 Reference< XMultiComponentFactory > xServiceMgr( xContext->getServiceManager() );
4370
4371 Reference< XInvocation > xProxy = new ModuleInvocationProxy( aPrefix, xScopeObj );
4372
4373 Sequence<Any> args{ aControlAny, Any(aVBAType), Any(xProxy) };
4374
4375 try
4376 {
4377 xRet = xServiceMgr->createInstanceWithArgumentsAndContext(
4378 "com.sun.star.custom.UnoComListener",
4379 args, xContext );
4380 }
4381 catch( const Exception& )
4382 {
4383 implHandleAnyException( ::cppu::getCaughtException() );
4384 }
4385
4386 return xRet;
4387}
4388
4389typedef std::vector< WeakReference< XComponent > > ComponentRefVector;
4390
4391namespace {
4392
4393struct StarBasicDisposeItem
4394{
4395 StarBASIC* m_pBasic;
4396 SbxArrayRef m_pRegisteredVariables;
4397 ComponentRefVector m_vComImplementsObjects;
4398
4399 explicit StarBasicDisposeItem( StarBASIC* pBasic )
4400 : m_pBasic( pBasic )
4401 , m_pRegisteredVariables(new SbxArray())
4402 {
4403 }
4404};
4405
4406}
4407
4408typedef std::vector< StarBasicDisposeItem* > DisposeItemVector;
4409
4411
4412static DisposeItemVector::iterator lcl_findItemForBasic( StarBASIC const * pBasic )
4413{
4414 return std::find_if(GaDisposeItemVector.begin(), GaDisposeItemVector.end(),
4415 [&pBasic](StarBasicDisposeItem* pItem) { return pItem->m_pBasic == pBasic; });
4416}
4417
4418static StarBasicDisposeItem* lcl_getOrCreateItemForBasic( StarBASIC* pBasic )
4419{
4420 DisposeItemVector::iterator it = lcl_findItemForBasic( pBasic );
4421 StarBasicDisposeItem* pItem = (it != GaDisposeItemVector.end()) ? *it : nullptr;
4422 if( pItem == nullptr )
4423 {
4424 pItem = new StarBasicDisposeItem( pBasic );
4425 GaDisposeItemVector.push_back( pItem );
4426 }
4427 return pItem;
4428}
4429
4431 ( const Reference< XComponent >& xComponent, StarBASIC* pBasic )
4432{
4433 StarBasicDisposeItem* pItem = lcl_getOrCreateItemForBasic( pBasic );
4434 pItem->m_vComImplementsObjects.emplace_back(xComponent );
4435}
4436
4438{
4439 StarBasicDisposeItem* pItem = lcl_getOrCreateItemForBasic( pBasic );
4440 SbxArray* pArray = pItem->m_pRegisteredVariables.get();
4441 pArray->Put(pVar, pArray->Count());
4442}
4443
4445{
4446 DisposeItemVector::iterator it = lcl_findItemForBasic( pBasic );
4447 if( it == GaDisposeItemVector.end() )
4448 return;
4449
4450 StarBasicDisposeItem* pItem = *it;
4451
4452 SbxArray* pArray = pItem->m_pRegisteredVariables.get();
4453 sal_uInt32 nCount = pArray->Count();
4454 for( sal_uInt32 i = 0 ; i < nCount ; ++i )
4455 {
4456 SbxVariable* pVar = pArray->Get(i);
4457 pVar->ClearComListener();
4458 }
4459
4460 ComponentRefVector& rv = pItem->m_vComImplementsObjects;
4461 for (auto const& elem : rv)
4462 {
4463 Reference< XComponent > xComponent( elem.get(), UNO_QUERY );
4464 if (xComponent.is())
4465 xComponent->dispose();
4466 }
4467
4468 delete pItem;
4469 GaDisposeItemVector.erase( it );
4470}
4471
4472
4473// Handle module implements mechanism for OLE types
4474bool SbModule::createCOMWrapperForIface( Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject )
4475{
4476 // For now: Take first interface that allows to instantiate COM wrapper
4477 // TODO: Check if support for multiple interfaces is needed
4478
4481 Reference< XMultiComponentFactory > xServiceMgr( xContext->getServiceManager() );
4482 Reference< XSingleServiceFactory > xComImplementsFactory
4483 (
4484 xServiceMgr->createInstanceWithContext( "com.sun.star.custom.ComImplementsFactory", xContext ),
4485 UNO_QUERY
4486 );
4487 if( !xComImplementsFactory.is() )
4488 return false;
4489
4490 bool bSuccess = false;
4491
4492 SbxArray* pModIfaces = pClassData->mxIfaces.get();
4493 sal_uInt32 nCount = pModIfaces->Count();
4494 for( sal_uInt32 i = 0 ; i < nCount ; ++i )
4495 {
4496 SbxVariable* pVar = pModIfaces->Get(i);
4497 const OUString& aIfaceName = pVar->GetName();
4498
4499 if( !aIfaceName.isEmpty() )
4500 {
4501 OUString aPureIfaceName = aIfaceName;
4502 sal_Int32 indexLastDot = aIfaceName.lastIndexOf('.');
4503 if ( indexLastDot > -1 )
4504 {
4505 aPureIfaceName = aIfaceName.copy( indexLastDot + 1 );
4506 }
4507 Reference< XInvocation > xProxy = new ModuleInvocationProxy( aPureIfaceName, pProxyClassModuleObject );
4508
4509 Sequence<Any> args{ Any(aIfaceName), Any(xProxy) };
4510
4512 try
4513 {
4514 xRet = xComImplementsFactory->createInstanceWithArguments( args );
4515 bSuccess = true;
4516 }
4517 catch( const Exception& )
4518 {
4519 implHandleAnyException( ::cppu::getCaughtException() );
4520 }
4521
4522 if( bSuccess )
4523 {
4524 Reference< XComponent > xComponent( xProxy, UNO_QUERY );
4525 if( xComponent.is() )
4526 {
4527 StarBASIC* pParentBasic = nullptr;
4528 SbxObject* pCurObject = this;
4529 do
4530 {
4531 SbxObject* pObjParent = pCurObject->GetParent();
4532 pParentBasic = dynamic_cast<StarBASIC*>( pObjParent );
4533 pCurObject = pObjParent;
4534 }
4535 while( pParentBasic == nullptr && pCurObject != nullptr );
4536
4537 assert( pParentBasic != nullptr );
4538 registerComponentToBeDisposedForBasic( xComponent, pParentBasic );
4539 }
4540
4541 o_rRetAny <<= xRet;
4542 break;
4543 }
4544 }
4545 }
4546
4547 return bSuccess;
4548}
4549
4550
4551// Due to an incorrect behavior IE returns an object instead of a string
4552// in some scenarios. Calling toString at the object may correct this.
4553// Helper function used in sbxvalue.cxx
4555{
4556 bool bSuccess = false;
4557
4558 if( auto pUnoObj = dynamic_cast<SbUnoObject*>( pObj) )
4559 {
4560 // Only for native COM objects
4561 if( pUnoObj->isNativeCOMObject() )
4562 {
4563 SbxVariableRef pMeth = pObj->Find( "toString", SbxClassType::Method );
4564 if ( pMeth.is() )
4565 {
4566 SbxValues aRes;
4567 pMeth->Get( aRes );
4568 pVal->Put( aRes );
4569 bSuccess = true;
4570 }
4571 }
4572 }
4573 return bSuccess;
4574}
4575
4577{
4578 Any aRet;
4580 &aRet, reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
4581 typelib_TypeDescription * pTD = nullptr;
4582 maType.getDescription(&pTD);
4584 &aRet, getInst(), pTD,
4585 reinterpret_cast< uno_AcquireFunc >(cpp_acquire) );
4587 return aRet;
4588}
4589
4590void StructRefInfo::setValue( const Any& rValue )
4591{
4592 bool bSuccess = uno_type_assignData( getInst(),
4593 maType.getTypeLibType(),
4594 const_cast<void*>(rValue.getValue()),
4595 rValue.getValueTypeRef(),
4596 reinterpret_cast< uno_QueryInterfaceFunc >(cpp_queryInterface),
4597 reinterpret_cast< uno_AcquireFunc >(cpp_acquire),
4598 reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
4599 OSL_ENSURE(bSuccess,
4600 "StructRefInfo::setValue: ooops... the value could not be assigned!");
4601}
4602
4604{
4605 return maType.getTypeName();
4606}
4607
4609{
4610 return const_cast<char *>(static_cast<char const *>(maAny.getValue()) + mnPos);
4611}
4612
4614{
4615 return maType.getTypeClass();
4616}
4617
4618SbUnoStructRefObject::SbUnoStructRefObject( const OUString& aName_, StructRefInfo aMemberInfo ) : SbxObject( aName_ ), maMemberInfo(std::move( aMemberInfo )), mbMemberCacheInit( false )
4619{
4621}
4622
4624{
4625}
4626
4628{
4629 if ( mbMemberCacheInit )
4630 return;
4631 typelib_TypeDescription * pTD = nullptr;
4632 maMemberInfo.getType().getDescription(&pTD);
4633 for ( typelib_CompoundTypeDescription * pCompTypeDescr = reinterpret_cast<typelib_CompoundTypeDescription *>(pTD);
4634 pCompTypeDescr;
4635 pCompTypeDescr = pCompTypeDescr->pBaseTypeDescription )
4636 {
4637 typelib_TypeDescriptionReference ** ppTypeRefs = pCompTypeDescr->ppTypeRefs;
4638 rtl_uString ** ppNames = pCompTypeDescr->ppMemberNames;
4639 sal_Int32 * pMemberOffsets = pCompTypeDescr->pMemberOffsets;
4640 for ( sal_Int32 nPos = pCompTypeDescr->nMembers; nPos--; )
4641 {
4642 OUString aName( ppNames[nPos] );
4643 maFields[ aName ] = std::make_unique<StructRefInfo>( maMemberInfo.getRootAnyRef(), ppTypeRefs[nPos], maMemberInfo.getPos() + pMemberOffsets[nPos] );
4644 }
4645 }
4647 mbMemberCacheInit = true;
4648}
4649
4651{
4652 SbxVariable* pRes = SbxObject::Find( rName, t );
4653 if ( !pRes )
4654 {
4655 if ( !mbMemberCacheInit )
4657 StructFieldInfo::iterator it = maFields.find( rName );
4658 if ( it != maFields.end() )
4659 {
4660 SbxDataType eSbxType;
4661 eSbxType = unoToSbxType( it->second->getTypeClass() );
4662 SbxDataType eRealSbxType = eSbxType;
4663 Property aProp;
4664 aProp.Name = rName;
4665 aProp.Type = css::uno::Type( it->second->getTypeClass(), it->second->getTypeName() );
4666 const bool bIsStruct = aProp.Type.getTypeClass() == css::uno::TypeClass_STRUCT;
4667 SbUnoProperty* pProp = new SbUnoProperty( rName, eSbxType, eRealSbxType, std::move(aProp), 0, false, bIsStruct );
4668 SbxVariableRef xVarRef = pProp;
4669 QuickInsert( xVarRef.get() );
4670 pRes = xVarRef.get();
4671 }
4672 }
4673
4674 if( !pRes )
4675 {
4676 if( rName.equalsIgnoreAsciiCase(ID_DBG_SUPPORTEDINTERFACES) ||
4677 rName.equalsIgnoreAsciiCase(ID_DBG_PROPERTIES) ||
4678 rName.equalsIgnoreAsciiCase(ID_DBG_METHODS) )
4679 {
4680 // Create
4682
4683 // Now they have to be found regular
4684 pRes = SbxObject::Find( rName, SbxClassType::DontCare );
4685 }
4686 }
4687
4688 return pRes;
4689}
4690
4691// help method to create the dbg_-Properties
4693{
4694 Property aProp;
4695
4696 // Id == -1: display the implemented interfaces corresponding the ClassProvider
4697 SbxVariableRef xVarRef = new SbUnoProperty( ID_DBG_SUPPORTEDINTERFACES, SbxSTRING, SbxSTRING, aProp, -1, false, false );
4698 QuickInsert( xVarRef.get() );
4699
4700 // Id == -2: output the properties
4701 xVarRef = new SbUnoProperty( ID_DBG_PROPERTIES, SbxSTRING, SbxSTRING, aProp, -2, false, false );
4702 QuickInsert( xVarRef.get() );
4703
4704 // Id == -3: output the Methods
4705 xVarRef = new SbUnoProperty( ID_DBG_METHODS, SbxSTRING, SbxSTRING, std::move(aProp), -3, false, false );
4706 QuickInsert( xVarRef.get() );
4707}
4708
4710{
4711 // throw away all existing methods and properties
4712 pMethods = new SbxArray;
4713 pProps = new SbxArray;
4714
4715 if (!mbMemberCacheInit)
4717
4718 for (auto const& field : maFields)
4719 {
4720 const OUString& rName = field.first;
4721 SbxDataType eSbxType;
4722 eSbxType = unoToSbxType( field.second->getTypeClass() );
4723 SbxDataType eRealSbxType = eSbxType;
4724 Property aProp;
4725 aProp.Name = rName;
4726 aProp.Type = css::uno::Type( field.second->getTypeClass(), field.second->getTypeName() );
4727 const bool bIsStruct = aProp.Type.getTypeClass() == css::uno::TypeClass_STRUCT;
4728 SbUnoProperty* pProp = new SbUnoProperty( rName, eSbxType, eRealSbxType, std::move(aProp), 0, false, bIsStruct );
4729 SbxVariableRef xVarRef = pProp;
4730 QuickInsert( xVarRef.get() );
4731 }
4732
4733 // Create Dbg_-Properties
4735}
4736
4737 // output the value
4739{
4740 return maMemberInfo.getValue();
4741}
4742
4744{
4745 OUStringBuffer aRet("Properties of object " + getDbgObjectName() );
4746
4747 sal_uInt32 nPropCount = pProps->Count();
4748 sal_uInt32 nPropsPerLine = 1 + nPropCount / 30;
4749 for( sal_uInt32 i = 0; i < nPropCount; i++ )
4750 {
4751 SbxVariable* pVar = pProps->Get(i);
4752 if( pVar )
4753 {
4754 OUStringBuffer aPropStr;
4755 if( (i % nPropsPerLine) == 0 )
4756 {
4757 aPropStr.append( "\n" );
4758 }
4759 // output the type and name
4760 // Is it in Uno a sequence?
4761 SbxDataType eType = pVar->GetFullType();
4762
4763 const OUString& aName( pVar->GetName() );
4764 StructFieldInfo::iterator it = maFields.find( aName );
4765
4766 if ( it != maFields.end() )
4767 {
4768 const StructRefInfo& rPropInfo = *it->second;
4769
4770 if( eType == SbxOBJECT )
4771 {
4772 if( rPropInfo.getTypeClass() == TypeClass_SEQUENCE )
4773 {
4775 }
4776 }
4777 }
4778 aPropStr.append( Dbg_SbxDataType2String( eType )
4779 + " " + pVar->GetName() );
4780
4781 if( i == nPropCount - 1 )
4782 {
4783 aPropStr.append( "\n" );
4784 }
4785 else
4786 {
4787 aPropStr.append( "; " );
4788 }
4789 aRet.append( aPropStr );
4790 }
4791 }
4792 return aRet.makeStringAndClear();
4793}
4794
4796{
4797 if ( !mbMemberCacheInit )
4799 const SbxHint* pHint = dynamic_cast<const SbxHint*>(&rHint);
4800 if( !pHint )
4801 return;
4802
4803 SbxVariable* pVar = pHint->GetVar();
4804 SbUnoProperty* pProp = dynamic_cast<SbUnoProperty*>( pVar );
4805 if( pProp )
4806 {
4807 StructFieldInfo::iterator it = maFields.find( pProp->GetName() );
4808 // handle get/set of members of struct
4809 if( pHint->GetId() == SfxHintId::BasicDataWanted )
4810 {
4811 // Test-Properties
4812 sal_Int32 nId = pProp->nId;
4813 if( nId < 0 )
4814 {
4815 // Id == -1: Display implemented interfaces according the ClassProvider
4816 if( nId == -1 ) // Property ID_DBG_SUPPORTEDINTERFACES"
4817 {
4818 OUString aRet = OUString::Concat( ID_DBG_SUPPORTEDINTERFACES )
4819 + " not available.\n(TypeClass is not TypeClass_INTERFACE)\n";
4820
4821 pVar->PutString( aRet );
4822 }
4823 // Id == -2: output properties
4824 else if( nId == -2 ) // Property ID_DBG_PROPERTIES
4825 {
4826 // by now all properties must be established
4827 implCreateAll();
4828 OUString aRetStr = Impl_DumpProperties();
4829 pVar->PutString( aRetStr );
4830 }
4831 // Id == -3: output the methods
4832 else if( nId == -3 ) // Property ID_DBG_METHODS
4833 {
4834 // by now all properties must be established
4835 implCreateAll();
4836 OUString aRet = "Methods of object "
4838 + "\nNo methods found\n";
4839 pVar->PutString( aRet );
4840 }
4841 return;
4842 }
4843
4844 if ( it != maFields.end() )
4845 {
4846 Any aRetAny = it->second->getValue();
4847 unoToSbxValue( pVar, aRetAny );
4848 }
4849 else
4851 }
4852 else if( pHint->GetId() == SfxHintId::BasicDataChanged )
4853 {
4854 if ( it != maFields.end() )
4855 {
4856 // take over the value from Uno to Sbx
4857 Any aAnyValue = sbxToUnoValue( pVar, pProp->aUnoProp.Type, &pProp->aUnoProp );
4858 it->second->setValue( aAnyValue );
4859 }
4860 else
4862 }
4863 }
4864 else
4865 SbxObject::Notify( rBC, rHint );
4866}
4867
4869{
4870 if (!mbMemberCacheInit)
4871 {
4873 }
4874 StructFieldInfo::iterator it = maFields.find( rMemberName );
4875
4876 css::uno::Type aFoundType;
4877 sal_Int32 nFoundPos = -1;
4878
4879 if ( it != maFields.end() )
4880 {
4881 aFoundType = it->second->getType();
4882 nFoundPos = it->second->getPos();
4883 }
4884 StructRefInfo aRet( maMemberInfo.getRootAnyRef(), aFoundType, nFoundPos );
4885 return aRet;
4886}
4887
4889{
4890 OUString aName = GetClassName();
4891 if( aName.isEmpty() )
4892 {
4893 aName += "Unknown";
4894 }
4895 OUStringBuffer aRet;
4896 if( aName.getLength() > 20 )
4897 {
4898 aRet.append( "\n" );
4899 }
4900 aRet.append( "\"" + aName + "\":" );
4901 return aRet.makeStringAndClear();
4902}
4903
4904/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XPropertyListType t
const Any & any
void SAL_CALL uno_any_construct(uno_Any *pDest, void *pSource, typelib_TypeDescription *pTypeDescr, uno_AcquireFunc acquire) SAL_THROW_EXTERN_C()
void SAL_CALL uno_any_destruct(uno_Any *pValue, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
AnyEventRef aEvent
double d
SbMethodRef xMethod
css::uno::Sequence< OUString > & getNames()
Definition: sbunoobj.hxx:320
ErrCode Call(SbxValue *pRet, SbxVariable *pCaller=nullptr)
Definition: sbxmod.cxx:2054
bool createCOMWrapperForIface(css::uno::Any &o_rRetAny, SbClassModuleObject *pProxyClassModuleObject)
Definition: sbunoobj.cxx:4474
std::unique_ptr< SbClassData > pClassData
Definition: sbmod.hxx:68
SbUnoClass(const OUString &aName_)
Definition: sbunoobj.hxx:219
virtual SbxVariable * Find(const OUString &, SbxClassType) override
Definition: sbunoobj.cxx:3322
const css::uno::Reference< css::reflection::XIdlClass > m_xClass
Definition: sbunoobj.hxx:216
virtual SbxObjectRef CreateObject(const OUString &) override
Definition: sbunoobj.cxx:2874
virtual SbxBaseRef Create(sal_uInt16 nSbxId, sal_uInt32) override
Definition: sbunoobj.cxx:2868
css::uno::Reference< css::reflection::XIdlMethod > m_xUnoMethod
Definition: sbunoobj.hxx:157
virtual ~SbUnoMethod() override
Definition: sbunoobj.cxx:2502
std::unique_ptr< css::uno::Sequence< css::reflection::ParamInfo > > pParamInfoSeq
Definition: sbunoobj.hxx:158
SbUnoMethod * pPrev
Definition: sbunoobj.hxx:161
bool isInvocationBased() const
Definition: sbunoobj.hxx:175
const css::uno::Sequence< css::reflection::ParamInfo > & getParamInfos()
Definition: sbunoobj.cxx:2539
SbUnoMethod * pNext
Definition: sbunoobj.hxx:162
SbUnoMethod(const OUString &aName_, SbxDataType eSbxType, css::uno::Reference< css::reflection::XIdlMethod > const &xUnoMethod_, bool bInvocation)
Definition: sbunoobj.cxx:2482
virtual SbxInfo * GetInfo() override
Definition: sbunoobj.cxx:2514
css::uno::Reference< css::beans::XMaterialHolder > mxMaterialHolder
Definition: sbunoobj.hxx:105
css::uno::Reference< css::beans::XIntrospectionAccess > mxUnoAccess
Definition: sbunoobj.hxx:104
SbUnoObject(const OUString &aName_, const css::uno::Any &aUnoObj_)
Definition: sbunoobj.cxx:2284
void implCreateAll()
Definition: sbunoobj.cxx:2758
bool isNativeCOMObject() const
Definition: sbunoobj.hxx:142
css::uno::Any getUnoAny()
Definition: sbunoobj.cxx:2823
const css::uno::Reference< css::script::XInvocation > & getInvocation() const
Definition: sbunoobj.hxx:138
void doIntrospection()
Definition: sbunoobj.cxx:2375
virtual ~SbUnoObject() override
Definition: sbunoobj.cxx:2369
static bool getDefaultPropName(SbUnoObject const *pUnoObj, OUString &sDfltProp)
Definition: sbunoobj.cxx:113
void Notify(SfxBroadcaster &, const SfxHint &rHint) override
Definition: sbunoobj.cxx:1982
void implCreateDbgProperties()
Definition: sbunoobj.cxx:2741
css::uno::Reference< css::script::XInvocation > mxInvocation
Definition: sbunoobj.hxx:106
bool bNativeCOMObject
Definition: sbunoobj.hxx:110
css::uno::Any maTmpUnoObj
Definition: sbunoobj.hxx:111
bool bNeedIntrospection
Definition: sbunoobj.hxx:109
const css::uno::Reference< css::beans::XIntrospectionAccess > & getIntrospectionAccess() const
Definition: sbunoobj.hxx:137
std::shared_ptr< SbUnoStructRefObject > maStructInfo
Definition: sbunoobj.hxx:112
virtual SbxVariable * Find(const OUString &, SbxClassType) override
Definition: sbunoobj.cxx:2578
css::uno::Reference< css::beans::XExactName > mxExactName
Definition: sbunoobj.hxx:107
css::uno::Reference< css::beans::XExactName > mxExactNameInvocation
Definition: sbunoobj.hxx:108
void createAllProperties()
Definition: sbunoobj.hxx:132
sal_Int32 nId
Definition: sbunoobj.hxx:186
SbUnoProperty(const SbUnoProperty &)=delete
css::beans::Property aUnoProp
Definition: sbunoobj.hxx:185
virtual ~SbUnoProperty() override
Definition: sbunoobj.cxx:2574
bool isInvocationBased() const
Definition: sbunoobj.hxx:200
bool isUnoStruct() const
Definition: sbunoobj.hxx:199
virtual SbxInfo * GetInfo() override
Definition: sbunoobj.cxx:3675
const css::uno::Reference< css::reflection::XServiceConstructorDescription > & getServiceCtorDesc() const
Definition: sbunoobj.hxx:275
SbUnoServiceCtor(const OUString &aName_, css::uno::Reference< css::reflection::XServiceConstructorDescription > const &xServiceCtorDesc)
Definition: sbunoobj.cxx:3665
virtual ~SbUnoServiceCtor() override
Definition: sbunoobj.cxx:3671
const css::uno::Reference< css::reflection::XServiceTypeDescription2 > m_xServiceTypeDesc
Definition: sbunoobj.hxx:244
virtual SbxVariable * Find(const OUString &, SbxClassType) override
Definition: sbunoobj.cxx:3473
bool m_bNeedsInit
Definition: sbunoobj.hxx:245
void Notify(SfxBroadcaster &, const SfxHint &rHint) override
Definition: sbunoobj.cxx:3514
SbUnoSingleton(const OUString &aName_)
Definition: sbunoobj.cxx:3706
void Notify(SfxBroadcaster &, const SfxHint &rHint) override
Definition: sbunoobj.cxx:3713
OUString Impl_DumpProperties()
Definition: sbunoobj.cxx:4743
virtual ~SbUnoStructRefObject() override
Definition: sbunoobj.cxx:4623
void implCreateDbgProperties()
Definition: sbunoobj.cxx:4692
OUString getDbgObjectName() const
Definition: sbunoobj.cxx:4888
StructFieldInfo maFields
Definition: sbunoobj.hxx:76
SbUnoStructRefObject(const OUString &aName_, StructRefInfo aMemberInfo)
Definition: sbunoobj.cxx:4618
void createAllProperties()
Definition: sbunoobj.hxx:94
virtual SbxVariable * Find(const OUString &, SbxClassType) override
Definition: sbunoobj.cxx:4650
void Notify(SfxBroadcaster &, const SfxHint &rHint) override
Definition: sbunoobj.cxx:4795
css::uno::Any getUnoAny()
Definition: sbunoobj.cxx:4738
StructRefInfo maMemberInfo
Definition: sbunoobj.hxx:77
StructRefInfo getStructMember(const OUString &rMember)
Definition: sbunoobj.cxx:4868
bool IsReschedule() const
Definition: runtime.hxx:178
bool IsCompatibility() const
Definition: runtime.hxx:180
void EnableReschedule(bool bEnable)
Definition: runtime.hxx:177
static bool isVBAEnabled()
Definition: runtime.cxx:115
Definition: sbx.hxx:95
sal_uInt32 Count() const
Definition: sbxarray.cxx:87
SbxVariable * Get(sal_uInt32)
Definition: sbxarray.cxx:108
void Put(SbxVariable *, sal_uInt32)
Definition: sbxarray.cxx:123
void SetFlags(SbxFlagBits n)
Definition: sbxcore.hxx:102
void SetFlag(SbxFlagBits n)
Definition: sbxcore.hxx:108
SbxFlagBits GetFlags() const
Definition: sbxcore.hxx:105
void ResetFlag(SbxFlagBits n)
Definition: sbxcore.hxx:111
SbxVariable * Get(SbxArray *)
Definition: sbxarray.cxx:538
void unoAddDim(sal_Int32, sal_Int32)
Definition: sbxarray.cxx:450
void Put(SbxVariable *, const sal_Int32 *)
Definition: sbxarray.cxx:499
Definition: sbx.hxx:81
SbxVariable * GetVar() const
Definition: sbx.hxx:85
SbxArray * GetProperties()
Definition: sbxobj.hxx:79
virtual SbxVariable * Find(const OUString &, SbxClassType)
Definition: sbxobj.cxx:182
const OUString & GetClassName() const
Definition: sbxobj.hxx:56
void SetClassName(const OUString &rNew)
Definition: sbxobj.hxx:57
SbxArray * GetMethods()
Definition: sbxobj.hxx:78
void Remove(const OUString &, SbxClassType)
Definition: sbxobj.cxx:499
SbxArrayRef pMethods
Definition: sbxobj.hxx:34
void QuickInsert(SbxVariable *)
Definition: sbxobj.cxx:457
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: sbxobj.cxx:140
void SetDfltProperty(const OUString &r)
Definition: sbxobj.cxx:295
SbxArrayRef pProps
Definition: sbxobj.hxx:35
bool IsNull() const
Definition: sbxvar.hxx:125
sal_Unicode GetChar() const
Definition: sbxvar.hxx:140
sal_uInt32 GetULong() const
Definition: sbxvar.hxx:160
OUString GetOUString() const
Definition: sbxvalue.cxx:380
bool PutInt64(sal_Int64)
bool PutString(const OUString &)
Definition: sbxvalue.cxx:585
bool PutDouble(double)
SbxBase * GetObject() const
Definition: sbxvar.hxx:157
bool PutEmpty()
Definition: sbxvalue.cxx:550
void fillAutomationDecimal(css::bridge::oleautomation::Decimal &rAutomationDec) const
Definition: sbxvalue.cxx:575
SbxDataType GetFullType() const
Definition: sbxvar.hxx:131
bool PutSingle(float)
bool PutBool(bool)
Definition: sbxvalue.cxx:543
bool IsEmpty() const
Definition: sbxvar.hxx:124
bool PutULong(sal_uInt32)
sal_uInt64 GetUInt64() const
Definition: sbxvar.hxx:144
bool PutCurrency(sal_Int64)
void PutDecimal(css::bridge::oleautomation::Decimal const &rAutomationDec)
Definition: sbxvalue.cxx:566
void PutDate(double)
Definition: sbxvalue.cxx:597
sal_uInt8 GetByte() const
Definition: sbxvar.hxx:158
bool GetBool() const
Definition: sbxvar.hxx:153
bool PutInteger(sal_Int16)
bool PutObject(SbxBase *)
sal_Int64 GetInt64() const
Definition: sbxvar.hxx:143
sal_Int32 GetLong() const
Definition: sbxvar.hxx:142
sal_Int16 GetInteger() const
Definition: sbxvar.hxx:141
double GetDate() const
Definition: sbxvar.hxx:151
bool PutUShort(sal_uInt16)
float GetSingle() const
Definition: sbxvar.hxx:149
sal_uInt16 GetUShort() const
Definition: sbxvar.hxx:159
bool PutLong(sal_Int32)
bool PutChar(sal_Unicode)
bool PutUInt64(sal_uInt64)
double GetDouble() const
Definition: sbxvar.hxx:150
bool Put(const SbxValues &)
Definition: sbxvalue.cxx:393
const SbxObject * GetParent() const
Definition: sbxvar.hxx:296
void ClearComListener()
Definition: sbxvar.cxx:401
SfxBroadcaster & GetBroadcaster()
Definition: sbxvar.cxx:102
void SetName(const OUString &)
Definition: sbxvar.cxx:192
void SetParameters(SbxArray *p)
Definition: sbxvar.cxx:178
virtual SbxDataType GetType() const override
Definition: sbxvar.cxx:321
SbxArray * GetParameters() const
Definition: sbxvar.cxx:111
const OUString & GetName(SbxNameType=SbxNameType::NONE) const
Definition: sbxvar.cxx:199
SbxVariable()
Definition: sbxvar.cxx:43
SbxInfoRef pInfo
Definition: sbxvar.hxx:256
bool IsBroadcaster() const
Definition: sbxvar.hxx:293
SfxHintId GetId() const
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
SbxArrayRef const & getUnoListeners()
Definition: sb.cxx:1764
static ErrCode GetSfxFromVBError(sal_uInt16 nError)
Definition: sb.cxx:1482
static void Error(ErrCode, const OUString &rMsg={})
Definition: sb.cxx:1683
static void FatalError(ErrCode)
Definition: sb.cxx:1691
void * getInst()
Definition: sbunoobj.cxx:4608
css::uno::Any & maAny
Definition: sbunoobj.hxx:46
const css::uno::Type & getType() const
Definition: sbunoobj.hxx:53
sal_Int32 mnPos
Definition: sbunoobj.hxx:48
sal_Int32 getPos() const
Definition: sbunoobj.hxx:52
css::uno::Any getValue()
Definition: sbunoobj.cxx:4576
css::uno::TypeClass getTypeClass() const
Definition: sbunoobj.cxx:4613
void setValue(const css::uno::Any &)
Definition: sbunoobj.cxx:4590
css::uno::Any & getRootAnyRef()
Definition: sbunoobj.hxx:55
css::uno::Type maType
Definition: sbunoobj.hxx:47
OUString getTypeName() const
Definition: sbunoobj.cxx:4603
bool isEmpty() const
Definition: sbunoobj.hxx:60
std::vector< OUString > aConstCache
Definition: sbunoobj.hxx:368
SbxVariable * getVBAConstant(const OUString &rName)
Definition: sbunoobj.cxx:3279
static VBAConstantHelper & instance()
Definition: sbunoobj.cxx:3212
bool isVBAConstantType(std::u16string_view rName)
Definition: sbunoobj.cxx:3262
std::unordered_map< OUString, css::uno::Any > aConstHash
Definition: sbunoobj.hxx:369
css::uno::Type const & get()
T * get() const
bool is() const
int nCount
sal_Bool SAL_CALL uno_type_assignData(void *pDest, typelib_TypeDescriptionReference *pDestType, void *pSource, typelib_TypeDescriptionReference *pSourceType, uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
std::vector< Reference< css::datatransfer::clipboard::XClipboardListener > > m_aListeners
float u
float x
EmbeddedObjectRef * pObject
Reference< XIdlClass > m_xListenerType
Any m_Helper
Reference< XAllListener > m_xAllListener
Any aHelper
Reference< XTypeConverter > xConverter
Reference< XMultiServiceFactory > xSMgr
Reference< XSingleServiceFactory > xFactory
DocumentType eType
std::mutex m_aMutex
sal_Int32 nIndex
OUString aName
Reference< XIntrospection > xIntrospection
Reference< XIdlReflection > xCoreReflection
Reference< XTypeConverter > xTypeConverter
void * p
sal_Int64 n
sal_uInt16 nPos
const char * pLib
struct _typelib_TypeDescription typelib_TypeDescription
@ Exception
bool hasProperty(const OUString &_rName, const Reference< XPropertySet > &_rxSet)
Reference< XMultiServiceFactory > getProcessServiceFactory()
Reference< XComponentContext > getProcessComponentContext()
Type
rtl::OUString getTypeName(rtl::OUString const &rEnvDcp)
bool enum2int(sal_Int32 &rnEnum, const css::uno::Any &rAny)
css::uno::Any int2enum(sal_Int32 nEnum, const css::uno::Type &rType)
int i
index
css::beans::Optional< css::uno::Any > getValue(std::u16string_view id)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
args
dictionary props
SVX_DLLPUBLIC OUString getProperty(css::uno::Reference< css::beans::XPropertyContainer > const &rxPropertyContainer, OUString const &rName)
void dispose()
def invoke(object, methodname, argTuple)
sal_Int16 nId
Reference< XInvocation2 > xInvocation
RegError REGISTRY_CALLTYPE setValue(RegKeyHandle hKey, rtl_uString *keyName, RegValueType valueType, RegValue pData, sal_uInt32 valueSize)
#define ERRCODE_BASIC_EXCEPTION
Definition: sberrors.hxx:153
#define ERRCODE_BASIC_INVALID_OBJECT
Definition: sberrors.hxx:41
#define ERRCODE_BASIC_PROP_READONLY
Definition: sberrors.hxx:39
#define ERRCODE_BASIC_OUT_OF_RANGE
Definition: sberrors.hxx:28
#define ERRCODE_BASIC_MATH_OVERFLOW
Definition: sberrors.hxx:27
#define ERRCODE_BASIC_BAD_ARGUMENT
Definition: sberrors.hxx:26
#define ERRCODE_BASIC_PROPERTY_NOT_FOUND
Definition: sberrors.hxx:113
#define ERRCODE_BASIC_NOT_OPTIONAL
Definition: sberrors.hxx:51
SbiGlobals * GetSbData()
Definition: sbintern.cxx:26
SbUnoObject * createOLEObject_Impl(const OUString &aType)
Definition: sbunoobj.cxx:234
static OUString Dbg_SbxDataType2String(SbxDataType eType)
Definition: sbunoobj.cxx:1782
void registerComponentToBeDisposedForBasic(const Reference< XComponent > &xComponent, StarBASIC *pBasic)
Definition: sbunoobj.cxx:4431
void clearNativeObjectWrapperVector()
Definition: sbunoobj.cxx:456
static void implHandleAnyException(const Any &_rCaughtException)
Definition: sbunoobj.cxx:415
void clearUnoMethods()
Definition: sbunoobj.cxx:2470
static OUString Impl_DumpMethods(SbUnoObject &rUnoObj)
Definition: sbunoobj.cxx:1900
static DisposeItemVector GaDisposeItemVector
Definition: sbunoobj.cxx:4410
static void implAppendExceptionMsg(OUStringBuffer &_inout_rBuffer, const Exception &_e, std::u16string_view _rExceptionType, sal_Int32 _nLevel)
Definition: sbunoobj.cxx:283
static StarBasicDisposeItem * lcl_getOrCreateItemForBasic(StarBASIC *pBasic)
Definition: sbunoobj.cxx:4418
void RTL_Impl_CreateUnoServiceWithArguments(SbxArray &rPar)
Definition: sbunoobj.cxx:2974
SbUnoClass * findUnoClass(const OUString &rName)
Definition: sbunoobj.cxx:3298
static void processAutomationParams(SbxArray *pParams, Sequence< Any > &args, sal_uInt32 nParamCount)
Definition: sbunoobj.cxx:1451
static Any convertAny(const Any &rVal, const Type &aDestType)
Definition: sbunoobj.cxx:320
std::vector< StarBasicDisposeItem * > DisposeItemVector
Definition: sbunoobj.cxx:4408
void clearUnoMethodsForBasic(StarBASIC const *pBasic)
Definition: sbunoobj.cxx:2429
static SbxObject * lcl_getNativeObject(sal_uInt32 nIndex)
Definition: sbunoobj.cxx:468
static OUString Impl_GetInterfaceInfo(const Reference< XInterface > &x, const Reference< XIdlClass > &xClass, sal_uInt16 nRekLevel)
Definition: sbunoobj.cxx:1544
static Any implRekMultiDimArrayToSequence(SbxDimArray *pArray, const Type &aElemType, sal_Int32 nMaxDimIndex, sal_Int32 nActualDim, sal_Int32 *pActualIndices, sal_Int32 *pLowerBounds, sal_Int32 *pUpperBounds)
Definition: sbunoobj.cxx:1075
static OUString implGetExceptionMsg(const Exception &e, std::u16string_view aExceptionType_)
Definition: sbunoobj.cxx:302
static OUString Impl_GetSupportedInterfaces(SbUnoObject &rUnoObj)
Definition: sbunoobj.cxx:1731
void RTL_Impl_HasInterfaces(SbxArray &rPar)
Definition: sbunoobj.cxx:3035
static SbUnoMethod * pFirst
Definition: sbunoobj.cxx:2427
void SbRtl_CreateUnoListener(StarBASIC *pBasic, SbxArray &rPar, bool)
Definition: sbunoobj.cxx:4003
static OUString Impl_DumpProperties(SbUnoObject &rUnoObj)
Definition: sbunoobj.cxx:1826
void RTL_Impl_CreateUnoValue(SbxArray &rPar)
Definition: sbunoobj.cxx:4074
static void implHandleBasicErrorException(BasicErrorException const &e)
Definition: sbunoobj.cxx:360
void SetSbUnoObjectDfltPropName(SbxObject *pObj)
Definition: sbunoobj.cxx:145
static SbUnoObjectRef Impl_CreateUnoStruct(const OUString &aClassName)
Definition: sbunoobj.cxx:2837
static Reference< XIdlReflection > getCoreReflection_Impl()
Definition: sbunoobj.cxx:160
static OUString getDbgObjectNameImpl(SbUnoObject &rUnoObj)
Definition: sbunoobj.cxx:1580
static bool implGetTypeByName(const OUString &rName, Type &rRetType)
Definition: sbunoobj.cxx:1144
static Reference< XTypeDescriptionEnumeration > getTypeDescriptorEnumeration(const OUString &sSearchRoot, const Sequence< TypeClass > &types, TypeDescriptionSearchDepth depth)
Definition: sbunoobj.cxx:3192
void RTL_Impl_GetDefaultContext(SbxArray &rPar)
Definition: sbunoobj.cxx:4061
SbUnoService * findUnoService(const OUString &rName)
Definition: sbunoobj.cxx:3448
void registerComListenerVariableForBasic(SbxVariable *pVar, StarBASIC *pBasic)
Definition: sbunoobj.cxx:4437
void RTL_Impl_EqualUnoObjects(SbxArray &rPar)
Definition: sbunoobj.cxx:3127
bool handleToStringForCOMObjects(SbxObject *pObj, SbxValue *pVal)
Definition: sbunoobj.cxx:4554
static Reference< XHierarchicalNameAccess > const & getTypeProvider_Impl()
Definition: sbunoobj.cxx:184
constexpr OUStringLiteral ID_DBG_PROPERTIES
Definition: sbunoobj.cxx:104
static Any sbxToUnoValueImpl(const SbxValue *pVar, bool bBlockConversionToSmallestType=false)
Definition: sbunoobj.cxx:984
void RTL_Impl_CreateUnoStruct(SbxArray &rPar)
Definition: sbunoobj.cxx:2906
void unoToSbxValue(SbxVariable *pVar, const Any &aValue)
Definition: sbunoobj.cxx:610
static sal_uInt32 lcl_registerNativeObjectWrapper(SbxObject *pNativeObj)
Definition: sbunoobj.cxx:461
std::vector< WeakReference< XComponent > > ComponentRefVector
Definition: sbunoobj.cxx:4389
static DisposeItemVector::iterator lcl_findItemForBasic(StarBASIC const *pBasic)
Definition: sbunoobj.cxx:4412
char const aSeqLevelStr[]
Definition: sbunoobj.cxx:107
SbUnoSingleton * findUnoSingleton(const OUString &rName)
Definition: sbunoobj.cxx:3681
SbxVariable * getDefaultProp(SbxVariable *pRef)
Definition: sbunoobj.cxx:126
static Type getUnoTypeForSbxBaseType(SbxDataType eType)
Definition: sbunoobj.cxx:817
static OUString getDbgObjectName(SbUnoObject &rUnoObj)
Definition: sbunoobj.cxx:1597
SbxObjectRef GetSbUnoObject(const OUString &aName, const Any &aUnoObj_)
Definition: sbunoobj.cxx:2882
static void implSequenceToMultiDimArray(SbxDimArray *&pArray, Sequence< sal_Int32 > &indices, Sequence< sal_Int32 > &sizes, const Any &aValue, sal_Int32 dimension, bool bIsZeroIndex, Type const *pType)
Definition: sbunoobj.cxx:526
Reference< XInterface > createComListener(const Any &aControlAny, const OUString &aVBAType, std::u16string_view aPrefix, const SbxObjectRef &xScopeObj)
Definition: sbunoobj.cxx:4361
static Type getUnoTypeForSbxValue(const SbxValue *pVal)
Definition: sbunoobj.cxx:853
static Any invokeAutomationMethod(const OUString &Name, Sequence< Any > const &args, SbxArray *pParams, sal_uInt32 nParamCount, Reference< XInvocation > const &rxInvocation, INVOKETYPE invokeType)
Definition: sbunoobj.cxx:1506
static SbxDataType unoToSbxType(TypeClass eType)
Definition: sbunoobj.cxx:480
void disposeComVariablesForBasic(StarBASIC const *pBasic)
Definition: sbunoobj.cxx:4444
static void implHandleWrappedTargetException(const Any &_rWrappedTargetException)
Definition: sbunoobj.cxx:366
constexpr OUStringLiteral ID_DBG_METHODS
Definition: sbunoobj.cxx:105
static Reference< XHierarchicalNameAccess > const & getCoreReflection_HierarchicalNameAccess_Impl()
Definition: sbunoobj.cxx:167
bool checkUnoObjectType(SbUnoObject &rUnoObj, const OUString &rClass)
Definition: sbunoobj.cxx:1644
void createAllObjectProperties(SbxObject *pObj)
Definition: sbunoobj.cxx:2888
Any sbxToUnoValue(const SbxValue *pVar)
Definition: sbunoobj.cxx:1137
void RTL_Impl_CreateUnoService(SbxArray &rPar)
Definition: sbunoobj.cxx:2929
constexpr OUStringLiteral ID_DBG_SUPPORTEDINTERFACES
Definition: sbunoobj.cxx:103
static Reference< XInterface > createAllListenerAdapter(const Reference< XInvocationAdapterFactory2 > &xInvocationAdapterFactory, const Reference< XIdlClass > &xListenerType, const Reference< XAllListener > &xListener, const Any &Helper)
Definition: sbunoobj.cxx:3892
OUString getBasicObjectTypeName(SbxObject *pObj)
Definition: sbunoobj.cxx:1612
static Reference< XTypeConverter > const & getTypeConverter_Impl()
Definition: sbunoobj.cxx:210
std::vector< ObjectItem > NativeObjectWrapperVector
Definition: sbunoobj.cxx:448
void RTL_Impl_GetProcessServiceManager(SbxArray &rPar)
Definition: sbunoobj.cxx:3023
static Reference< XIdlClass > TypeToIdlClass(const Type &rType)
Definition: sbunoobj.cxx:348
void RTL_Impl_IsUnoStruct(SbxArray &rPar)
Definition: sbunoobj.cxx:3093
static OUString pItem
Definition: sbxcoll.cxx:30
constexpr auto SbxMAXLNG
Definition: sbxdef.hxx:190
SbxBOOL
Definition: sbxdef.hxx:215
constexpr auto SbxMAXINT
Definition: sbxdef.hxx:187
constexpr sal_uInt16 SbxMAXUINT
Definition: sbxdef.hxx:189
SbxDataType
Definition: sbxdef.hxx:37
@ SbxOBJECT
Definition: sbxdef.hxx:47
@ SbxSALINT64
Definition: sbxdef.hxx:75
@ SbxLONG
Definition: sbxdef.hxx:41
@ SbxCARRAY
Definition: sbxdef.hxx:66
@ SbxARRAY
Definition: sbxdef.hxx:80
@ SbxSALUINT64
Definition: sbxdef.hxx:76
@ SbxHRESULT
Definition: sbxdef.hxx:63
@ SbxNULL
Definition: sbxdef.hxx:39
@ SbxDIMARRAY
Definition: sbxdef.hxx:65
@ SbxBYTE
Definition: sbxdef.hxx:55
@ SbxEMPTY
Definition: sbxdef.hxx:38
@ SbxUINT
Definition: sbxdef.hxx:60
@ SbxUSERDEF
Definition: sbxdef.hxx:67
@ SbxDECIMAL
Definition: sbxdef.hxx:77
@ SbxVOID
Definition: sbxdef.hxx:62
@ SbxLPWSTR
Definition: sbxdef.hxx:70
@ SbxULONG
Definition: sbxdef.hxx:57
@ SbxUSHORT
Definition: sbxdef.hxx:56
@ SbxERROR
Definition: sbxdef.hxx:48
@ SbxDATE
Definition: sbxdef.hxx:45
@ SbxPOINTER
Definition: sbxdef.hxx:64
@ SbxCURRENCY
Definition: sbxdef.hxx:44
@ SbxLPSTR
Definition: sbxdef.hxx:68
@ SbxVARIANT
Definition: sbxdef.hxx:51
@ SbxINT
Definition: sbxdef.hxx:59
@ SbxDATAOBJECT
Definition: sbxdef.hxx:52
@ SbxSINGLE
Definition: sbxdef.hxx:42
@ SbxCoreSTRING
Definition: sbxdef.hxx:71
@ SbxCHAR
Definition: sbxdef.hxx:54
@ SbxSTRING
Definition: sbxdef.hxx:46
@ SbxINTEGER
Definition: sbxdef.hxx:40
@ SbxDOUBLE
Definition: sbxdef.hxx:43
SbxClassType
Definition: sbxdef.hxx:27
SbxFlagBits
Definition: sbxdef.hxx:131
constexpr auto SbxMININT
Definition: sbxdef.hxx:188
bool bBlockCompilerError
Definition: sbintern.hxx:135
SbiInstance * pInst
Definition: sbintern.hxx:108
OUString Name
void SAL_CALL typelib_typedescription_release(typelib_TypeDescription *pTD) SAL_THROW_EXTERN_C()
void SAL_CALL typelib_typedescription_getByName(typelib_TypeDescription **ppRet, rtl_uString *pName) SAL_THROW_EXTERN_C()
unsigned char sal_Bool
signed char sal_Int8