25#include <com/sun/star/beans/PropertyValue.hpp>
26#include <com/sun/star/frame/ModuleManager.hpp>
27#include <com/sun/star/frame/UnknownModuleException.hpp>
28#include <com/sun/star/frame/XModuleManager2.hpp>
29#include <com/sun/star/frame/XFrame.hpp>
30#include <com/sun/star/lang/XServiceInfo.hpp>
31#include <com/sun/star/lang/XSingleComponentFactory.hpp>
32#include <com/sun/star/uno/XComponentContext.hpp>
46 css::lang::XServiceInfo,
47 css::lang::XSingleComponentFactory > WindowContentFactoryManager_BASE;
49class WindowContentFactoryManager :
public WindowContentFactoryManager_BASE
52 explicit WindowContentFactoryManager( css::uno::Reference< css::uno::XComponentContext> xContext );
56 return "com.sun.star.comp.framework.WindowContentFactoryManager";
66 return {
"com.sun.star.ui.WindowContentFactoryManager"};
70 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithContext(
const css::uno::Reference< css::uno::XComponentContext >& Context )
override;
71 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArgumentsAndContext(
const css::uno::Sequence< css::uno::Any >& Arguments,
const css::uno::Reference< css::uno::XComponentContext >& Context )
override;
74 virtual void disposing(std::unique_lock<std::mutex>&)
override;
76 css::uno::Reference< css::uno::XComponentContext >
m_xContext;
81WindowContentFactoryManager::WindowContentFactoryManager( uno::Reference< uno::XComponentContext > xContext ) :
87 "/org.openoffice.Office.UI.WindowContentFactories/Registered/ContentFactories"))
90void WindowContentFactoryManager::disposing(std::unique_lock<std::mutex>&)
92 m_pConfigAccess.clear();
96uno::Reference< uno::XInterface > SAL_CALL WindowContentFactoryManager::createInstanceWithContext(
97 const uno::Reference< uno::XComponentContext >& )
99 uno::Reference< uno::XInterface > xWindow;
103uno::Reference< uno::XInterface > SAL_CALL WindowContentFactoryManager::createInstanceWithArgumentsAndContext(
104 const uno::Sequence< uno::Any >& Arguments,
const uno::Reference< uno::XComponentContext >& Context )
106 uno::Reference< uno::XInterface > xWindow;
107 uno::Reference< frame::XFrame >
xFrame;
108 OUString aResourceURL;
110 for (
auto const & arg : Arguments )
112 beans::PropertyValue aPropValue;
113 if ( arg >>= aPropValue )
115 if ( aPropValue.Name ==
"Frame" )
116 aPropValue.Value >>=
xFrame;
117 else if ( aPropValue.Name ==
"ResourceURL" )
118 aPropValue.Value >>= aResourceURL;
126 uno::Reference< frame::XModuleManager2 > xModuleManager =
130 if (
xFrame.is() && xModuleManager.is() )
131 aModuleId = xModuleManager->identify( uno::Reference< uno::XInterface >( xFrame, uno::UNO_QUERY ) );
133 catch (
const frame::UnknownModuleException& )
138 if ( !aType.isEmpty() &&
140 !aModuleId.isEmpty() )
143 uno::Reference< uno::XInterface > xHolder(
static_cast<cppu::OWeakObject*
>(
this), uno::UNO_QUERY );
150 throw css::lang::DisposedException(
151 "disposed",
static_cast<OWeakObject *
>(
this));
156 m_pConfigAccess->readConfigurationData();
158 aImplementationName = m_pConfigAccess->getFactorySpecifierFromTypeNameModule( aType, aName, aModuleId );
163 uno::Reference< lang::XMultiServiceFactory > xServiceManager( Context->getServiceManager(), uno::UNO_QUERY );
164 if ( xServiceManager.is() )
166 uno::Reference< lang::XSingleComponentFactory >
xFactory(
167 xServiceManager->createInstance( aImplementationName ), uno::UNO_QUERY );
173 xWindow =
xFactory->createInstanceWithArgumentsAndContext( Arguments, Context );
175 catch ( uno::Exception& )
188 xWindow = createInstanceWithContext(Context);
196extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
198 css::uno::XComponentContext *context,
199 css::uno::Sequence<css::uno::Any>
const &)
201 return cppu::acquire(
new WindowContentFactoryManager(context));
#define DBG_UNHANDLED_EXCEPTION(...)
Reference< XSingleServiceFactory > xFactory
OUString aImplementationName
css::uno::Reference< css::uno::XComponentContext > m_xContext
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
void RetrieveTypeNameFromResourceURL(std::u16string_view aResourceURL, OUString &aType, OUString &aName)
Reference< XFrame > xFrame
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_framework_WindowContentFactoryManager_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)