29#include <osl/diagnose.h>
31#include <com/sun/star/container/XContentEnumerationAccess.hpp>
32#include <com/sun/star/frame/XModel.hpp>
33#include <com/sun/star/lang/XMultiServiceFactory.hpp>
34#include <com/sun/star/lang/XServiceInfo.hpp>
35#include <com/sun/star/lang/XServiceName.hpp>
36#include <com/sun/star/lang/XSingleServiceFactory.hpp>
37#include <com/sun/star/lang/XSingleComponentFactory.hpp>
38#include <com/sun/star/reflection/XIdlClass.hpp>
39#include <com/sun/star/beans/XIntrospectionAccess.hpp>
40#include <com/sun/star/beans/theIntrospection.hpp>
41#include <com/sun/star/beans/MethodConcept.hpp>
42#include <com/sun/star/beans/XPropertySet.hpp>
43#include <com/sun/star/beans/PropertyValue.hpp>
44#include <com/sun/star/table/XCellRange.hpp>
45#include <com/sun/star/lang/Locale.hpp>
46#include <com/sun/star/sheet/XCompatibilityNames.hpp>
47#include <com/sun/star/sheet/NoConvergenceException.hpp>
48#include <com/sun/star/sheet/XAddIn.hpp>
49#include <com/sun/star/sheet/XVolatileResult.hpp>
63#include <compiler.hxx>
64#include <document.hxx>
69#define SC_CALLERPOS_NONE (-1)
73 sal_uInt16 nCat, OUString sHelp,
74 uno::Reference<reflection::XIdlMethod> xFunc,
78 aOriginalName( rNam ),
82 aDescription(
std::move( aDesc )),
83 xFunction(
std::move( xFunc )),
84 aObject(
std::move( aO )),
88 sHelpId(
std::move( sHelp )),
89 bCompInitialized( false )
112 uno::Reference<sheet::XAddIn> xAddIn;
115 uno::Reference<sheet::XCompatibilityNames> xComp( xAddIn, uno::UNO_QUERY );
118 OUString aMethodName =
xFunction->getName();
119 const uno::Sequence< sheet::LocalizedName> aCompNames( xComp->getCompatibilityNames( aMethodName ));
121 for (
const sheet::LocalizedName& rCompName : aCompNames)
146 if (!rEnglishName.isEmpty())
159 const ::std::vector<LocalizedName>& rCompNames =
GetCompNames();
160 if ( !rCompNames.empty() )
162 const OUString& aSearch( rDestLang.
getBcp47());
165 ::std::vector<LocalizedName>::const_iterator itNames = std::find_if(rCompNames.begin(), rCompNames.end(),
166 [&aSearch](
const LocalizedName& rName) { return rName.maLocale == aSearch; });
167 if (itNames != rCompNames.end())
169 rRetExcelName = (*itNames).maName;
176 if (aSearch !=
"en-US")
178 aFallbackSearch.emplace_back(
"en-US");
181 aFallbackSearch.emplace_back(
"en");
184 for (
const auto& rSearch : aFallbackSearch)
186 for (
const auto& rCompName : rCompNames)
190 if (std::find(aFallbackLocales.begin(), aFallbackLocales.end(), rSearch) != aFallbackLocales.end())
192 rRetExcelName = rCompName.maName;
201 rRetExcelName = rCompNames[0].maName;
234 bInitialized( false )
259 uno::Reference<container::XContentEnumerationAccess> xEnAc( xManager, uno::UNO_QUERY );
262 uno::Reference<container::XEnumeration> xEnum =
263 xEnAc->createContentEnumeration(
"com.sun.star.sheet.AddIn" );
267 while ( xEnum->hasMoreElements() )
269 uno::Any aAddInAny = xEnum->nextElement();
273 uno::Reference<uno::XInterface> xIntFac;
274 aAddInAny >>= xIntFac;
280 uno::Reference<uno::XInterface> xInterface;
281 uno::Reference<uno::XComponentContext> xCtx(
283 uno::Reference<lang::XSingleComponentFactory> xCFac( xIntFac, uno::UNO_QUERY );
286 xInterface = xCFac->createInstanceWithContext(xCtx);
291 if (!xInterface.is())
293 uno::Reference<lang::XSingleServiceFactory> xFac( xIntFac, uno::UNO_QUERY );
296 xInterface = xFac->createInstance();
302 }
catch (
const uno::Exception& ) {
303 SAL_WARN (
"sc",
"Failed to initialize create instance of sheet.AddIn" );
345#define CFG_FUNCPROP_DISPLAYNAME 0
346#define CFG_FUNCPROP_DESCRIPTION 1
347#define CFG_FUNCPROP_CATEGORY 2
348#define CFG_FUNCPROP_COUNT 3
368 const OUString sSlash(
'/');
379 uno::Sequence<OUString> aFunctionNames = rAddInConfig.
GetNodeNames( aFunctionsPath );
380 sal_Int32 nNewCount = aFunctionNames.getLength();
388 std::unique_ptr<std::unique_ptr<ScUnoAddInFuncData>[]> ppNew(
new std::unique_ptr<ScUnoAddInFuncData>[
nFuncCount]);
408 const OUString* pFuncNameArray = aFunctionNames.getConstArray();
409 for ( sal_Int32 nFuncPos = 0; nFuncPos < nNewCount; nFuncPos++ )
414 OUString aFuncName = aServiceName +
"." + pFuncNameArray[nFuncPos];
420 OUString aEnglishName;
422 OUString aDescription;
427 OUString aFuncPropPath = aFunctionsPath + sSlash + pFuncNameArray[nFuncPos] + sSlash;
429 uno::Sequence<OUString> aFuncPropNames{
434 uno::Sequence<uno::Any> aFuncProperties = rAddInConfig.
GetProperties( aFuncPropNames );
440 OUString aCategoryName;
448 uno::Sequence<OUString> aDisplayNamePropNames( &aDisplayNamePath, 1 );
450 uno::Sequence<uno::Any> aDisplayNameProperties = aAllLocalesConfig.
GetProperties( aDisplayNamePropNames );
451 if ( aDisplayNameProperties.getLength() == 1 )
453 uno::Sequence<beans::PropertyValue> aLocalEntries;
454 if ( aDisplayNameProperties[0] >>= aLocalEntries )
456 for (
const beans::PropertyValue& rConfig : std::as_const(aLocalEntries) )
463 rConfig.Value >>=
aName;
465 if (aLocale ==
"en-US" && !
aName.isEmpty())
466 aEnglishName =
aName;
467 else if (aEnglishName.isEmpty() && (aLocale ==
"en" || aLocale.startsWith(
"en-")))
468 aEnglishName =
aName;
472 bool bNeedEnglish = aEnglishName.isEmpty();
476 ::std::vector<ScUnoAddInFuncData::LocalizedName> aCompNames;
479 uno::Sequence<OUString> aCompPropNames( &aCompPath, 1 );
481 uno::Sequence<uno::Any> aCompProperties = aAllLocalesConfig.
GetProperties( aCompPropNames );
482 if ( aCompProperties.getLength() == 1 )
484 uno::Sequence<beans::PropertyValue> aLocalEntries;
485 if ( aCompProperties[0] >>= aLocalEntries )
487 for (
const beans::PropertyValue& rConfig : std::as_const(aLocalEntries) )
494 rConfig.Value >>=
aName;
495 if (!
aName.isEmpty())
497 aCompNames.emplace_back( aLocale,
aName);
501 if (aLocale ==
"en-US")
502 aEnglishName =
aName;
503 else if (aEnglishName.isEmpty() && (aLocale ==
"en" || aLocale.startsWith(
"en-")))
504 aEnglishName =
aName;
513 std::unique_ptr<ScAddInArgDesc[]> pVisibleArgs;
518 const uno::Sequence<OUString> aArgumentNames = rAddInConfig.
GetNodeNames( aArgumentsPath );
519 sal_Int32 nArgumentCount = aArgumentNames.getLength();
520 if ( nArgumentCount )
523 uno::Sequence<OUString> aArgPropNames( nArgumentCount * 2 );
524 OUString* pPropNameArray = aArgPropNames.getArray();
527 for (
const OUString& rArgName : aArgumentNames )
529 OUString aOneArgPath = aArgumentsPath + sSlash + rArgName + sSlash;
531 pPropNameArray[
nIndex++] = aOneArgPath
533 pPropNameArray[
nIndex++] = aOneArgPath
537 uno::Sequence<uno::Any> aArgProperties = rAddInConfig.
GetProperties( aArgPropNames );
538 if ( aArgProperties.getLength() == aArgPropNames.getLength() )
540 const OUString* pArgNameArray = aArgumentNames.getConstArray();
541 const uno::Any* pPropArray = aArgProperties.getConstArray();
543 OUString sDescription;
549 nVisibleCount = nArgumentCount;
553 for ( sal_Int32 nArgument = 0; nArgument < nArgumentCount; nArgument++ )
556 pPropArray[
nIndex++] >>= sDescription;
562 pVisibleArgs[nArgument] = aDesc;
567 OUString sHelpId = aHelpIdGenerator.
GetHelpId( pFuncNameArray[nFuncPos] );
569 uno::Reference<reflection::XIdlMethod> xFunc;
575 aFuncName, aLocalName, aDescription,
580 pData->SetCompNames( std::move(aCompNames) );
585 pData->GetOriginalName(),
588 pData->GetUpperName(),
591 pData->GetUpperLocal(),
594 if (aEnglishName.isEmpty())
595 SAL_WARN(
"sc.core",
"no English name for " << aLocalName <<
" " << aFuncName);
602 pData->SetEnglishName(aEnglishName);
611 sal_Int32
nPos = aFullName.lastIndexOf(
'.' );
615 OUString aServiceName = aFullName.copy( 0,
nPos );
620 uno::Reference<uno::XInterface> xInterface( xServiceFactory->createInstance( aServiceName ) );
625 catch (
const uno::Exception &)
627 SAL_WARN (
"sc",
"Failed to create addin component '"
628 << aServiceName <<
"'");
653 const ::std::vector<ScUnoAddInFuncData::LocalizedName>& rNames = pFuncData->
GetCompNames();
654 auto bFound = std::any_of(rNames.begin(), rNames.end(),
656 return ScGlobal::getCharClass().uppercase( rName.maName ) == aUpperCmp; });
672 return rName == rType.getTypeName();
679 if ( !xClass.is() )
return false;
681 switch (xClass->getTypeClass())
683 case uno::TypeClass_ANY:
684 case uno::TypeClass_ENUM:
685 case uno::TypeClass_BOOLEAN:
686 case uno::TypeClass_CHAR:
687 case uno::TypeClass_BYTE:
688 case uno::TypeClass_SHORT:
689 case uno::TypeClass_UNSIGNED_SHORT:
690 case uno::TypeClass_LONG:
691 case uno::TypeClass_UNSIGNED_LONG:
692 case uno::TypeClass_FLOAT:
693 case uno::TypeClass_DOUBLE:
694 case uno::TypeClass_STRING:
697 case uno::TypeClass_INTERFACE:
702 OUString
sName = xClass->getName();
713 OUString
sName = xClass->getName();
728 uno::TypeClass
eType = xClass->getTypeClass();
730 if (
eType == uno::TypeClass_LONG )
733 if (
eType == uno::TypeClass_DOUBLE )
736 if (
eType == uno::TypeClass_STRING )
740 OUString
sName = xClass->getName();
771 uno::Reference<sheet::XAddIn> xAddIn( xInterface, uno::UNO_QUERY );
772 uno::Reference<lang::XServiceName> xName( xInterface, uno::UNO_QUERY );
773 if ( !(xAddIn.is() && xName.is()) )
789 std::vector<FuncNameData> aFuncNameData;
791 OUString aServiceName( xName->getServiceName() );
798 uno::Reference<beans::XIntrospection> xIntro = beans::theIntrospection::get( xContext );
801 uno::Reference<beans::XIntrospectionAccess> xAcc = xIntro->inspect(aObject);
805 uno::Sequence< uno::Reference<reflection::XIdlMethod> >
aMethods =
806 xAcc->getMethods( beans::MethodConcept::ALL );
815 std::unique_ptr<std::unique_ptr<ScUnoAddInFuncData>[]> ppNew(
new std::unique_ptr<ScUnoAddInFuncData>[
nFuncCount]);
833 const uno::Reference<reflection::XIdlMethod>* pArray =
aMethods.getConstArray();
834 for (
tools::Long nFuncPos=0; nFuncPos<nNewCount; nFuncPos++)
838 uno::Reference<reflection::XIdlMethod> xFunc = pArray[nFuncPos];
842 uno::Reference<reflection::XIdlClass> xClass =
843 xFunc->getDeclaringClass();
848 OUString
sName = xClass->getName();
861 uno::Reference<reflection::XIdlClass> xReturn =
862 xFunc->getReturnType();
868 OUString aFuncU = xFunc->getName();
871 OUString aFuncName = aServiceName +
"." + aFuncU;
877 uno::Sequence<reflection::ParamInfo> aParams =
878 xFunc->getParameterInfos();
880 const reflection::ParamInfo* pParArr = aParams.getConstArray();
882 for (nParamPos=0; nParamPos<nParamCount; nParamPos++)
884 if ( pParArr[nParamPos].aMode != reflection::ParamMode_IN )
886 uno::Reference<reflection::XIdlClass> xParClass =
887 pParArr[nParamPos].aType;
892 nCallerPos = nParamPos;
899 xAddIn->getProgrammaticCategoryName( aFuncU ) );
901 OUString sHelpId = aHelpIdGenerator.
GetHelpId( aFuncU );
906 aLocalName = xAddIn->
907 getDisplayFunctionName( aFuncU );
909 catch(uno::Exception&)
914 OUString aDescription;
917 aDescription = xAddIn->
918 getFunctionDescription( aFuncU );
920 catch(uno::Exception&)
922 aDescription =
"###";
925 std::unique_ptr<ScAddInArgDesc[]> pVisibleArgs;
926 if ( nVisibleCount > 0 )
931 for (nParamPos=0; nParamPos<nParamCount; nParamPos++)
933 uno::Reference<reflection::XIdlClass> xParClass =
934 pParArr[nParamPos].aType;
942 getDisplayArgumentName( aFuncU, nParamPos );
944 catch(uno::Exception&)
952 getArgumentDescription( aFuncU, nParamPos );
954 catch(uno::Exception&)
963 aDesc.
eType = eArgType;
964 aDesc.
aName = aArgName;
970 pVisibleArgs[nDestPos++] = aDesc;
973 OSL_ENSURE( nDestPos==nVisibleCount,
"wrong count" );
977 aFuncName, aLocalName, aDescription,
980 nVisibleCount, pVisibleArgs.get(), nCallerPos ) );
984 pData->GetOriginalName(),
987 pData->GetUpperName(),
990 pData->GetUpperLocal(),
993 aFuncNameData.push_back({aFuncU,
pData});
1000 xAddIn->setLocale( aEnglishLanguageTag.
getLocale());
1001 for (
const auto& rFunc : aFuncNameData)
1003 OUString aEnglishName;
1006 aEnglishName = xAddIn->getDisplayFunctionName( rFunc.aFuncU );
1008 catch(uno::Exception&)
1011 if (aEnglishName.isEmpty()
1012 && rFunc.pData->GetExcelName( aEnglishLanguageTag, aEnglishName,
false ))
1017 if (rFunc.pData->GetLocalName().endsWith(
"_ADD") && !aEnglishName.endsWith(
"_ADD"))
1018 aEnglishName +=
"_ADD";
1019 else if (rFunc.pData->GetLocalName().endsWith(
"_EXCEL2003") && !aEnglishName.endsWith(
"_EXCEL2003"))
1020 aEnglishName +=
"_EXCEL2003";
1021 SAL_WARN(
"sc.core",
"obtaining English name for " << rFunc.pData->GetLocalName() <<
" "
1022 << rFunc.pData->GetOriginalName() <<
" as ExcelName '" << aEnglishName <<
"'");
1024 SAL_WARN_IF(aEnglishName.isEmpty(),
"sc.core",
"no English name for "
1025 << rFunc.pData->GetLocalName() <<
" " << rFunc.pData->GetOriginalName());
1026 rFunc.pData->SetEnglishName(aEnglishName);
1027 pEnglishHashMap->emplace( rFunc.pData->GetUpperEnglish(), rFunc.pData);
1032 bool bEnglishFunctionNames )
1044 bEnglishFunctionNames);
1056 if ( pArguments[
nPos].aInternalName == rArgIntName )
1057 return &pArguments[
nPos];
1063 std::u16string_view rServiceName )
1065 const bool bEnglishFunctionNames =
SC_MOD()->GetFormulaOptions().GetUseEnglishFuncName();
1066 uno::Reference<lang::XLocalizable> xLoc( xInterface, uno::UNO_QUERY );
1080 uno::Reference<beans::XIntrospection> xIntro = beans::theIntrospection::get(xContext);
1082 aObject <<= xInterface;
1083 uno::Reference<beans::XIntrospectionAccess> xAcc = xIntro->inspect(aObject);
1087 const uno::Sequence< uno::Reference<reflection::XIdlMethod> >
aMethods =
1088 xAcc->getMethods( beans::MethodConcept::ALL );
1089 for (
const uno::Reference<reflection::XIdlMethod>& xFunc :
aMethods)
1093 OUString aFuncU = xFunc->getName();
1096 OUString aFuncName = OUString::Concat(rServiceName) +
"." + aFuncU;
1111 const uno::Sequence<reflection::ParamInfo> aParams =
1112 xFunc->getParameterInfos();
1114 const reflection::ParamInfo* pParArr = aParams.getConstArray();
1115 for (
tools::Long nParamPos=0; nParamPos<nParamCount; nParamPos++)
1117 if ( pParArr[nParamPos].aMode != reflection::ParamMode_IN )
1119 uno::Reference<reflection::XIdlClass> xParClass =
1120 pParArr[nParamPos].aType;
1125 nCallerPos = nParamPos;
1131 std::unique_ptr<ScAddInArgDesc[]> pVisibleArgs;
1132 if ( nVisibleCount > 0 )
1137 for (
const auto& rParam : aParams)
1139 uno::Reference<reflection::XIdlClass> xParClass =
1158 aDesc.
eType = eArgType;
1163 pVisibleArgs[nDestPos++] = aDesc;
1166 OSL_ENSURE( nDestPos==nVisibleCount,
"wrong count" );
1170 pOldData->
SetArguments( nVisibleCount, pVisibleArgs.get() );
1173 if ( pFunctionList )
1193 ScAddInHashMap::const_iterator iLook(
pLocalHashMap->find( rUpperName ) );
1195 return iLook->second->GetOriginalName();
1202 ScAddInHashMap::const_iterator iLook(
pNameHashMap->find( rUpperName ) );
1204 return iLook->second->GetOriginalName();
1210 return iLook->second->GetOriginalName();
1218 return iLook->second->GetOriginalName();
1231 ScAddInHashMap::const_iterator iLook(
pExactHashMap->find( rName ) );
1236 if ( bComplete && !pFuncData->
GetFunction().is() )
1262 ScAddInHashMap::const_iterator iLook(
pExactHashMap->find( rName ) );
1264 rName = iLook->second->GetUpperLocal();
1289 bool bEnglishFunctionNames )
1309 if (aDesc.isEmpty())
1315 rDesc.
nArgCount =
static_cast<sal_uInt16
>(nArgCount);
1318 bool bMultiple =
false;
1326 for (
tools::Long nArg=0; nArg<nArgCount; nArg++ )
1335 OUString aDefName =
"arg" + OUString::number( nArg+1 );
1356 bValidCount( false ),
1363 OSL_ENSURE(
pFuncData,
"Function Data missing" );
1371 if ( nParamCount >= nDescCount && nDescCount > 0 &&
1374 tools::Long nVarCount = nParamCount - ( nDescCount - 1 );
1378 else if ( nParamCount <= nDescCount )
1383 if ( !pArgs[
i].bOptional )
1389 aArgs.realloc( nDescCount );
1428 uno::Reference<uno::XInterface> xInt( pObjSh->
GetBaseModel(), uno::UNO_QUERY );
1443 if ( nVarPos <
aVarArg.getLength() )
1444 aVarArg.getArray()[nVarPos] = rValue;
1447 OSL_FAIL(
"wrong argument number");
1454 OSL_FAIL(
"wrong argument number");
1470 OSL_ENSURE(
aArgs.getLength() ==
nCount,
"wrong argument count" );
1481 if (nCallPos>nUserLen)
1483 OSL_FAIL(
"wrong CallPos");
1484 nCallPos = nUserLen;
1488 uno::Sequence<uno::Any> aRealArgs( nDestLen );
1489 uno::Any* pDest = aRealArgs.getArray();
1491 pDest = std::copy_n(std::cbegin(
aArgs), nCallPos, pDest);
1492 *pDest = aCallerAny;
1493 std::copy(std::next(std::cbegin(
aArgs), nCallPos), std::cend(
aArgs), std::next(pDest));
1505 uno::Reference<reflection::XIdlMethod> xFunction;
1513 if ( !xFunction.is() )
1521 aAny = xFunction->invoke( aObject, rCallArgs );
1523 catch(lang::IllegalArgumentException&)
1525 nErrCode = FormulaError::IllegalArgument;
1527 catch(
const reflection::InvocationTargetException& rWrapped)
1529 if ( rWrapped.TargetException.getValueType().equals(
1531 nErrCode = FormulaError::IllegalArgument;
1532 else if ( rWrapped.TargetException.getValueType().equals(
1534 nErrCode = FormulaError::NoConvergence;
1538 catch(uno::Exception&)
1543 if (
nErrCode == FormulaError::NONE)
1547template <
typename T>
1550 if (!pRowSeq->hasElements())
1553 auto pRow = std::max_element(pRowSeq->begin(), pRowSeq->end(),
1554 [](
const uno::Sequence<T>&
a,
const uno::Sequence<T>& b) {
1555 return a.getLength() < b.getLength(); });
1556 return pRow->getLength();
1566 uno::TypeClass eClass = rNewRes.getValueTypeClass();
1567 const uno::Type& aType = rNewRes.getValueType();
1570 case uno::TypeClass_VOID:
1571 nErrCode = FormulaError::NotAvailable;
1574 case uno::TypeClass_ENUM:
1575 case uno::TypeClass_BOOLEAN:
1576 case uno::TypeClass_CHAR:
1577 case uno::TypeClass_BYTE:
1578 case uno::TypeClass_SHORT:
1579 case uno::TypeClass_UNSIGNED_SHORT:
1580 case uno::TypeClass_LONG:
1581 case uno::TypeClass_UNSIGNED_LONG:
1582 case uno::TypeClass_FLOAT:
1583 case uno::TypeClass_DOUBLE:
1585 uno::TypeClass eMyClass;
1591 case uno::TypeClass_STRING:
1598 case uno::TypeClass_INTERFACE:
1601 uno::Reference<uno::XInterface> xInterface;
1602 rNewRes >>= xInterface;
1603 if ( xInterface.is() )
1604 xVarRes.set( xInterface, uno::UNO_QUERY );
1612 if ( aType.equals(
cppu::UnoType<uno::Sequence< uno::Sequence<sal_Int32> >>::get() ) )
1614 const uno::Sequence< uno::Sequence<sal_Int32> >* pRowSeq =
nullptr;
1617 uno::Sequence< uno::Sequence<sal_Int32> > aSequence;
1618 if ( rNewRes >>= aSequence )
1619 pRowSeq = &aSequence;
1623 sal_Int32 nRowCount = pRowSeq->getLength();
1625 if ( nMaxColCount && nRowCount )
1627 const uno::Sequence<sal_Int32>* pRowArr = pRowSeq->getConstArray();
1629 static_cast<SCSIZE>(nMaxColCount),
1630 static_cast<SCSIZE>(nRowCount), 0.0);
1631 for (sal_Int32 nRow=0; nRow<nRowCount; nRow++)
1633 sal_Int32 nColCount = pRowArr[nRow].getLength();
1634 const sal_Int32* pColArr = pRowArr[nRow].getConstArray();
1635 for (sal_Int32 nCol=0; nCol<nColCount; nCol++)
1636 xMatrix->PutDouble( pColArr[nCol],
1637 static_cast<SCSIZE>(nCol),
1638 static_cast<SCSIZE>(nRow) );
1639 for (sal_Int32 nCol=nColCount; nCol<nMaxColCount; nCol++)
1641 static_cast<SCSIZE>(nCol),
1642 static_cast<SCSIZE>(nRow) );
1647 else if ( aType.equals(
cppu::UnoType<uno::Sequence< uno::Sequence<double> >>::get() ) )
1649 const uno::Sequence< uno::Sequence<double> >* pRowSeq =
nullptr;
1652 uno::Sequence< uno::Sequence<double> > aSequence;
1653 if ( rNewRes >>= aSequence )
1654 pRowSeq = &aSequence;
1658 sal_Int32 nRowCount = pRowSeq->getLength();
1660 if ( nMaxColCount && nRowCount )
1662 const uno::Sequence<double>* pRowArr = pRowSeq->getConstArray();
1664 static_cast<SCSIZE>(nMaxColCount),
1665 static_cast<SCSIZE>(nRowCount), 0.0);
1666 for (sal_Int32 nRow=0; nRow<nRowCount; nRow++)
1668 sal_Int32 nColCount = pRowArr[nRow].getLength();
1669 const double* pColArr = pRowArr[nRow].getConstArray();
1670 for (sal_Int32 nCol=0; nCol<nColCount; nCol++)
1671 xMatrix->PutDouble( pColArr[nCol],
1672 static_cast<SCSIZE>(nCol),
1673 static_cast<SCSIZE>(nRow) );
1674 for (sal_Int32 nCol=nColCount; nCol<nMaxColCount; nCol++)
1676 static_cast<SCSIZE>(nCol),
1677 static_cast<SCSIZE>(nRow) );
1682 else if ( aType.equals(
cppu::UnoType<uno::Sequence< uno::Sequence<OUString> >>::get() ) )
1684 const uno::Sequence< uno::Sequence<OUString> >* pRowSeq =
nullptr;
1687 uno::Sequence< uno::Sequence<OUString> > aSequence;
1688 if ( rNewRes >>= aSequence )
1689 pRowSeq = &aSequence;
1693 sal_Int32 nRowCount = pRowSeq->getLength();
1695 if ( nMaxColCount && nRowCount )
1697 const uno::Sequence<OUString>* pRowArr = pRowSeq->getConstArray();
1699 static_cast<SCSIZE>(nMaxColCount),
1700 static_cast<SCSIZE>(nRowCount), 0.0);
1701 for (sal_Int32 nRow=0; nRow<nRowCount; nRow++)
1703 sal_Int32 nColCount = pRowArr[nRow].getLength();
1704 const OUString* pColArr = pRowArr[nRow].getConstArray();
1705 for (sal_Int32 nCol=0; nCol<nColCount; nCol++)
1711 for (sal_Int32 nCol=nColCount; nCol<nMaxColCount; nCol++)
1721 else if ( aType.equals(
cppu::UnoType<uno::Sequence< uno::Sequence<uno::Any> >>::get() ) )
constexpr OUStringLiteral CFGSTR_ADDINFUNCTIONS
static sal_Int32 lcl_GetMaxColCount(const uno::Sequence< uno::Sequence< T > > *pRowSeq)
static sal_uInt16 lcl_GetCategory(std::u16string_view rName)
constexpr OUStringLiteral CFGSTR_COMPATIBILITYNAME
#define CFG_FUNCPROP_CATEGORY
static void lcl_UpdateFunctionList(const ScFunctionList &rFunctionList, const ScUnoAddInFuncData &rFuncData, bool bEnglishFunctionNames)
static bool IsTypeName(std::u16string_view rName, const uno::Type &rType)
#define CFG_FUNCPROP_COUNT
constexpr OUStringLiteral CFGPATH_ADDINS
constexpr OUStringLiteral CFGSTR_PARAMETERS
#define CFG_FUNCPROP_DISPLAYNAME
constexpr OUStringLiteral CFGSTR_CATEGORY
constexpr OUStringLiteral CFGSTR_DISPLAYNAME
constexpr OUStringLiteral CFGSTR_DESCRIPTION
#define SC_CALLERPOS_NONE
static ScAddInArgumentType lcl_GetArgType(const uno::Reference< reflection::XIdlClass > &xClass)
static bool lcl_ValidReturnType(const uno::Reference< reflection::XIdlClass > &xClass)
#define CFG_FUNCPROP_DESCRIPTION
static const ScAddInArgDesc * lcl_FindArgDesc(const ScUnoAddInFuncData &rFuncData, std::u16string_view rArgIntName)
std::unordered_map< OUString, const ScUnoAddInFuncData * > ScAddInHashMap
@ SC_ADDINARG_VALUE_OR_ARRAY
any
@ SC_ADDINARG_INTEGER
long
@ SC_ADDINARG_STRING
string
@ SC_ADDINARG_VARARGS
sequence<any>
@ SC_ADDINARG_STRING_ARRAY
sequence<sequence<string>>
@ SC_ADDINARG_INTEGER_ARRAY
sequence<sequence<long>>
@ SC_ADDINARG_DOUBLE
double
@ SC_ADDINARG_CALLER
XPropertySet.
@ SC_ADDINARG_DOUBLE_ARRAY
sequence<sequence<double>>
@ SC_ADDINARG_CELLRANGE
XCellRange.
@ SC_ADDINARG_MIXED_ARRAY
sequence<sequence<any>>
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
static const AllSettings & GetSettings()
OUString uppercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
const OUString & getBcp47(bool bResolveSystem=true) const
static OUString convertToBcp47(LanguageType nLangID)
::std::vector< OUString > getFallbackStrings(bool bIncludeFullBcp47) const
css::uno::Sequence< css::uno::Any > GetProperties(const css::uno::Sequence< OUString > &rNames)
static bool ConvertAnyToDouble(double &o_fVal, css::uno::TypeClass &o_eClass, const css::uno::Any &rAny)
Convert a uno::Any to double if possible, including integer types.
static const CharClass * GetCharClassEnglish()
SC_DLLPUBLIC svl::SharedStringPool & GetSharedStringPool()
Stores and generates human readable descriptions for spreadsheet-functions, e.g. functions used in fo...
std::vector< OUString > maDefArgDescs
Description(s) of parameter(s)
sal_uInt16 nArgCount
All parameter count, suppressed and unsuppressed.
std::vector< OUString > maDefArgNames
Parameter name(s)
OUString sHelpId
HelpId of function.
void Clear()
Clears the object.
sal_uInt16 nCategory
Function category.
std::optional< OUString > mxFuncDesc
Description of function.
ParameterFlags * pDefArgFlags
Flags for each parameter.
std::optional< OUString > mxFuncName
Function name.
bool bIncomplete
Incomplete argument info (set for add-in info from configuration)
List of spreadsheet functions.
const ScFuncDesc * GetFunction(sal_uInt32 nIndex) const
sal_uInt32 GetCount() const
static ScFunctionList * GetStarCalcFunctionList()
static bool HasStarCalcFunctionList()
static SC_DLLPUBLIC const CharClass & getCharClass()
css::uno::Sequence< css::uno::Any > GetProperties(const css::uno::Sequence< OUString > &rNames)
Matrix data type that can store values of mixed types.
static ScMatrixRef CreateMixedMatrix(const css::uno::Any &rAny)
Convert a sequence of mixed elements to ScMatrix.
ScUnoAddInCall(ScDocument &rDoc, ScUnoAddInCollection &rColl, const OUString &rName, tools::Long nParamCount)
void SetResult(const css::uno::Any &rNewRes)
ScAddInArgumentType GetArgType(tools::Long nPos)
css::uno::Reference< css::sheet::XVolatileResult > xVarRes
css::uno::Sequence< css::uno::Any > aVarArg
void SetCaller(const css::uno::Reference< css::uno::XInterface > &rInterface)
void ExecuteCallWithArgs(css::uno::Sequence< css::uno::Any > &rCallArgs)
const ScUnoAddInFuncData * pFuncData
css::uno::Sequence< css::uno::Any > aArgs
void SetParam(tools::Long nPos, const css::uno::Any &rValue)
css::uno::Reference< css::uno::XInterface > xCaller
void SetCallerFromObjectShell(const SfxObjectShell *pSh)
std::unique_ptr< ScAddInHashMap > pLocalHashMap
localized name upper
void LocalizeString(OUString &rName)
modify rName - input: exact name
bool FillFunctionDesc(tools::Long nFunc, ScFuncDesc &rDesc, bool bEnglishFunctionNames)
const ScUnoAddInFuncData * GetFuncData(const OUString &rName, bool bComplete=false)
Only if bComplete is set, the function reference and argument types are initialized (component may ha...
void ReadFromAddIn(const css::uno::Reference< css::uno::XInterface > &xInterface)
void UpdateFromAddIn(const css::uno::Reference< css::uno::XInterface > &xInterface, std::u16string_view rServiceName)
static bool FillFunctionDescFromData(const ScUnoAddInFuncData &rFuncData, ScFuncDesc &rDesc, bool bEnglishFunctionNames)
std::unique_ptr< ScAddInHashMap > pEnglishHashMap
English name upper.
bool GetCalcName(const OUString &rExcelName, OUString &rRetCalcName)
leave rRetCalcName unchanged, if no matching name is found
void LoadComponent(const ScUnoAddInFuncData &rFuncData)
tools::Long GetFuncCount()
bool GetExcelName(const OUString &rCalcName, LanguageType eDestLang, OUString &rRetExcelName)
leave rRetExcelName unchanged, if no matching name is found
std::unique_ptr< std::unique_ptr< ScUnoAddInFuncData >[]> ppFuncData
OUString FindFunction(const OUString &rUpperName, bool bLocalFirst)
User entered name. rUpperName MUST already be upper case!
std::unique_ptr< ScAddInHashMap > pExactHashMap
exact internal name
std::unique_ptr< ScAddInHashMap > pNameHashMap
internal name upper
void SetFunction(const css::uno::Reference< css::reflection::XIdlMethod > &rNewFunc, const css::uno::Any &rNewObj)
OUString aUpperName
for entering formulas
const ScAddInArgDesc * GetArguments() const
const OUString & GetHelpId() const
tools::Long GetCallerPos() const
OUString aUpperEnglish
for Function Wizard and tooltips
css::uno::Reference< css::reflection::XIdlMethod > xFunction
ScUnoAddInFuncData(const OUString &rNam, const OUString &rLoc, OUString aDesc, sal_uInt16 nCat, OUString, css::uno::Reference< css::reflection::XIdlMethod > aFunc, css::uno::Any aO, tools::Long nAC, const ScAddInArgDesc *pAD, tools::Long nCP)
const OUString & GetUpperLocal() const
const ::std::vector< LocalizedName > & GetCompNames() const
sal_uInt16 GetCategory() const
const OUString & GetDescription() const
const OUString & GetUpperEnglish() const
bool GetExcelName(const LanguageTag &rDestLang, OUString &rRetExcelName, bool bFallbackToAny=true) const
void SetCallerPos(tools::Long nNewPos)
void SetCompNames(::std::vector< LocalizedName > &&rNew)
mutable ::std::vector< LocalizedName > maCompNames
const css::uno::Any & GetObject() const
std::unique_ptr< ScAddInArgDesc[]> pArgDescs
OUString aUpperLocal
for entering formulas
tools::Long GetArgumentCount() const
const css::uno::Reference< css::reflection::XIdlMethod > & GetFunction() const
const OUString & GetLocalName() const
void SetEnglishName(const OUString &rEnglishName)
Takes care of handling an empty name after upper local name was set.
void SetArguments(tools::Long nNewCount, const ScAddInArgDesc *pNewDescs)
const OUString & GetOriginalName() const
Generates help IDs for standard Calc AddIns.
OUString GetHelpId(std::u16string_view rFuncName) const
css::uno::Reference< css::frame::XModel3 > GetBaseModel() const
SharedString intern(const OUString &rStr)
static const SharedString & getEmptyString()
static css::uno::Sequence< OUString > GetNodeNames(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const OUString &rNode, ConfigNameFormat eFormat)
Sequence< OUString > aServiceNames
#define SC_FUNCGROUP_COUNT
#define LANGUAGE_ENGLISH_US
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
std::unique_ptr< sal_Int32[]> pData
const LanguageTag & getLocale()
Reference< XMultiServiceFactory > getProcessServiceFactory()
Reference< XComponentContext > getProcessComponentContext()
Reference< XComponentContext > getComponentContext(Reference< XMultiServiceFactory > const &factory)
bool equalsAscii(std::u16string_view s1, std::string_view s2)
#define ID_FUNCTION_GRP_ADDINS
constexpr Method aMethods[]
ScAddInArgumentType eType
OUString aInternalName
used to match configuration and reflection information
Stores whether a parameter is optional or suppressed.
bool bOptional
Parameter is optional.