22#include <com/sun/star/container/XContentEnumerationAccess.hpp>
23#include <com/sun/star/lang/XServiceInfo.hpp>
24#include <com/sun/star/lang/XSingleComponentFactory.hpp>
25#include <com/sun/star/beans/XPropertySet.hpp>
26#include <com/sun/star/beans/PropertyValue.hpp>
27#include <com/sun/star/sheet/XSolver.hpp>
28#include <com/sun/star/sheet/XSolverDescription.hpp>
30#include <osl/diagnose.h>
40 uno::Sequence<OUString>& rDescriptions )
42 rImplNames.realloc(0);
43 rDescriptions.realloc(0);
45 uno::Reference<uno::XComponentContext> xCtx(
48 uno::Reference<container::XContentEnumerationAccess> xEnAc(
49 xCtx->getServiceManager(), uno::UNO_QUERY );
53 uno::Reference<container::XEnumeration> xEnum =
59 while ( xEnum->hasMoreElements() )
61 uno::Any aAny = xEnum->nextElement();
62 uno::Reference<lang::XServiceInfo> xInfo;
66 uno::Reference<lang::XSingleComponentFactory> xCFac( xInfo, uno::UNO_QUERY );
69 OUString
sName = xInfo->getImplementationName();
73 uno::Reference<sheet::XSolver> xSolver(
74 xCFac->createInstanceWithContext(xCtx), uno::UNO_QUERY );
75 uno::Reference<sheet::XSolverDescription> xDesc( xSolver, uno::UNO_QUERY );
76 OUString sDescription;
78 sDescription = xDesc->getComponentDescription();
80 if ( sDescription.isEmpty() )
83 rImplNames.realloc(
nCount+1 );
85 rDescriptions.realloc(
nCount+1 );
86 rDescriptions.getArray()[
nCount] = sDescription;
89 catch (
const css::uno::Exception&)
100 uno::Reference<sheet::XSolver> xSolver;
102 uno::Reference<uno::XComponentContext> xCtx(
105 uno::Reference<container::XContentEnumerationAccess> xEnAc(
106 xCtx->getServiceManager(), uno::UNO_QUERY );
109 uno::Reference<container::XEnumeration> xEnum =
113 while ( xEnum->hasMoreElements() && !xSolver.is() )
115 uno::Any aAny = xEnum->nextElement();
116 uno::Reference<lang::XServiceInfo> xInfo;
120 uno::Reference<lang::XSingleComponentFactory> xCFac( xInfo, uno::UNO_QUERY );
123 OUString
sName = xInfo->getImplementationName();
124 if (
sName == rImplName )
125 xSolver.set( xCFac->createInstanceWithContext(xCtx), uno::UNO_QUERY );
132 SAL_WARN_IF( !xSolver.is(),
"sc.ui",
"can't get solver" );
138 uno::Sequence<beans::PropertyValue> aDefaults;
140 uno::Reference<sheet::XSolver> xSolver =
GetSolver( rImplName );
141 uno::Reference<beans::XPropertySet> xPropSet( xSolver, uno::UNO_QUERY );
142 if ( !xPropSet.is() )
150 uno::Reference<beans::XPropertySetInfo> xInfo = xPropSet->getPropertySetInfo();
151 OSL_ENSURE( xInfo.is(),
"can't get property set info" );
155 const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties();
156 const sal_Int32 nSize = aPropSeq.getLength();
157 aDefaults.realloc(nSize);
158 auto pDefaults = aDefaults.getArray();
159 sal_Int32 nValid = 0;
160 for (
const beans::Property& rProp : aPropSeq)
162 uno::Any aValue = xPropSet->getPropertyValue( rProp.Name );
163 uno::TypeClass eClass = aValue.getValueTypeClass();
165 if ( eClass == uno::TypeClass_BOOLEAN || eClass == uno::TypeClass_LONG || eClass == uno::TypeClass_DOUBLE )
166 pDefaults[nValid++] = beans::PropertyValue( rProp.Name, -1, aValue, beans::PropertyState_DIRECT_VALUE );
168 aDefaults.realloc(nValid);
static void GetImplementations(css::uno::Sequence< OUString > &rImplNames, css::uno::Sequence< OUString > &rDescriptions)
static css::uno::Sequence< css::beans::PropertyValue > GetDefaults(std::u16string_view rImplName)
static css::uno::Reference< css::sheet::XSolver > GetSolver(std::u16string_view rImplName)
#define TOOLS_INFO_EXCEPTION(area, stream)
#define SAL_WARN_IF(condition, area, stream)
Reference< XComponentContext > getProcessComponentContext()
constexpr OUStringLiteral SCSOLVER_SERVICE