23 #include <rtl/string.hxx>
26 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
37 public cppu::WeakImplHelper<lang::XSingleComponentFactory,
42 : m_rServiceDecl(rServiceDecl) {}
52 virtual uno::Reference<uno::XInterface> SAL_CALL createInstanceWithContext(
53 uno::Reference<uno::XComponentContext>
const& xContext )
override;
54 virtual uno::Reference<uno::XInterface> SAL_CALL
55 createInstanceWithArgumentsAndContext(
56 uno::Sequence<uno::Any>
const& args,
57 uno::Reference<uno::XComponentContext>
const& xContext )
override;
65 ServiceDecl::Factory::~Factory()
70 OUString ServiceDecl::Factory::getImplementationName()
75 sal_Bool ServiceDecl::Factory::supportsService( OUString
const& name )
77 return m_rServiceDecl.supportsService(name);
80 uno::Sequence<OUString> ServiceDecl::Factory::getSupportedServiceNames()
82 return m_rServiceDecl.getSupportedServiceNames();
86 uno::Reference<uno::XInterface> ServiceDecl::Factory::createInstanceWithContext(
87 uno::Reference<uno::XComponentContext>
const& xContext )
89 return m_rServiceDecl.m_createFunc(
90 m_rServiceDecl, uno::Sequence<uno::Any>(), xContext );
93 uno::Reference<uno::XInterface>
94 ServiceDecl::Factory::createInstanceWithArgumentsAndContext(
95 uno::Sequence<uno::Any >
const& args,
96 uno::Reference<uno::XComponentContext>
const& xContext )
98 return m_rServiceDecl.m_createFunc(
99 m_rServiceDecl, args, xContext );
102 void * ServiceDecl::getFactory(
char const* pImplName )
const
104 if (rtl_str_compare(m_pImplName, pImplName) == 0) {
105 lang::XSingleComponentFactory *
const pFac(
new Factory(*
this) );
112 uno::Sequence<OUString> ServiceDecl::getSupportedServiceNames()
const
114 std::vector<OUString> vec;
116 OString
const str(m_pServiceNames);
119 std::string_view
const token(
o3tl::getToken(str, 0, cDelim, nIndex ) );
120 vec.emplace_back( token.data(), token.size(),
121 RTL_TEXTENCODING_ASCII_US );
128 bool ServiceDecl::supportsService( std::u16string_view name )
const
130 OString
const str(m_pServiceNames);
133 std::string_view
const token(
o3tl::getToken(str, 0, cDelim, nIndex ) );
141 OUString ServiceDecl::getImplementationName()
const
143 return OUString::createFromAscii(m_pImplName);
147 std::initializer_list<ServiceDecl const *> args )
149 for (
auto const i: args) {
150 assert(
i !=
nullptr);
151 void *
fac =
i->getFactory(pImplName);
152 if (fac !=
nullptr) {
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
Class to declare a service implementation.
bool equalsAscii(std::u16string_view s1, const char *s2)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
OUString getImplementationName() const
void * component_getFactoryHelper(const char *pImplName, std::initializer_list< ServiceDecl const * > args)
ServiceDecl const & m_rServiceDecl
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
Copy from a container into a Sequence.
Factory(ServiceDecl const &rServiceDecl)