summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2020-07-25 18:19:20 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-07-26 10:41:52 +0200
commit8a05c64a5bbf9b6ad7af8e94e7b970f1323a22c5 (patch)
treead963de32713418067c5ae9ea4436ee28b175625 /sfx2
parent5406f8a3cd53ada63472bd62e5b9a886e2866c6f (diff)
starmath: create instances with uno constructors
See tdf#74608 for motivation. And adjust the sfx2 model factory code to cope with UNO constructor functions. Change-Id: I7e57fb3136ad0b3caadd511ea63cf98d3c03ab3d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99446 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/doc/sfxmodelfactory.cxx28
1 files changed, 26 insertions, 2 deletions
diff --git a/sfx2/source/doc/sfxmodelfactory.cxx b/sfx2/source/doc/sfxmodelfactory.cxx
index 354df9db5450..fbb1b24382de 100644
--- a/sfx2/source/doc/sfxmodelfactory.cxx
+++ b/sfx2/source/doc/sfxmodelfactory.cxx
@@ -23,6 +23,8 @@
#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include <comphelper/namedvaluecollection.hxx>
#include <cppuhelper/implbase.hxx>
@@ -79,6 +81,10 @@ namespace sfx2
virtual Reference< XInterface > SAL_CALL createInstance( ) override;
virtual Reference< XInterface > SAL_CALL createInstanceWithArguments( const Sequence< Any >& aArguments ) override;
+ static css::uno::Reference<css::uno::XInterface> create(
+ const css::uno::Sequence<css::uno::Any> & rxArgs,
+ std::function<css::uno::Reference<css::uno::XInterface>(SfxModelFlags)> creationFunc);
+
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( ) override;
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
@@ -142,7 +148,18 @@ namespace sfx2
}
- Reference< XInterface > SAL_CALL SfxModelFactory::createInstanceWithArguments( const Sequence< Any >& _rArguments )
+ Reference< XInterface > SAL_CALL SfxModelFactory::createInstanceWithArguments( const Sequence< Any >& _rArguments )
+ {
+ return create(_rArguments,
+ [&](SfxModelFlags _nCreationFlags)
+ {
+ return m_pComponentFactoryFunc(m_xServiceFactory, _nCreationFlags).get();
+ });
+ }
+
+ css::uno::Reference<css::uno::XInterface> SfxModelFactory::create(
+ const css::uno::Sequence<css::uno::Any> & _rArguments,
+ std::function<css::uno::Reference<css::uno::XInterface>(SfxModelFlags)> creationFunc)
{
::comphelper::NamedValueCollection aArgs( _rArguments );
const bool bEmbeddedObject = aArgs.getOrDefault( "EmbeddedObject", false );
@@ -154,7 +171,7 @@ namespace sfx2
| ( bScriptSupport ? SfxModelFlags::NONE : SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS )
| ( bDocRecoverySupport ? SfxModelFlags::NONE : SfxModelFlags::DISABLE_DOCUMENT_RECOVERY );
- Reference< XInterface > xInstance( (*m_pComponentFactoryFunc)( m_xServiceFactory, nCreationFlags ) );
+ Reference< XInterface > xInstance( creationFunc(nCreationFlags ) );
// to mimic the behaviour of the default factory's createInstanceWithArguments, we initialize
// the object with the given arguments, stripped by the three special ones
@@ -194,6 +211,13 @@ namespace sfx2
return m_aServiceNames;
}
+ css::uno::Reference<css::uno::XInterface> createSfxModelInstance(
+ const css::uno::Sequence<css::uno::Any> & rxArgs,
+ std::function<css::uno::Reference<css::uno::XInterface>(SfxModelFlags)> creationFunc)
+ {
+ return SfxModelFactory::create(rxArgs, creationFunc);
+ }
+
Reference< XSingleServiceFactory > createSfxModelFactory( const Reference< XMultiServiceFactory >& _rxServiceFactory,
const OUString& _rImplementationName, const SfxModelFactoryFunc _pComponentFactoryFunc,
const Sequence< OUString >& _rServiceNames )