22#include <com/sun/star/beans/XPropertySet.hpp>
23#include <com/sun/star/container/XNameAccess.hpp>
24#include <com/sun/star/embed/ElementModes.hpp>
25#include <com/sun/star/frame/ModuleManager.hpp>
26#include <com/sun/star/io/XOutputStream.hpp>
27#include <com/sun/star/ui/ModuleUIConfigurationManager.hpp>
28#include <com/sun/star/lang/XServiceInfo.hpp>
29#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
30#include <com/sun/star/ui/XUIConfigurationManager.hpp>
31#include <com/sun/star/ui/XModuleUIConfigurationManager2.hpp>
32#include <com/sun/star/frame/XModuleManager2.hpp>
37#include <unordered_map>
52 css::lang::XServiceInfo,
53 css::ui::XModuleUIConfigurationManagerSupplier >
54 ModuleUIConfigurationManagerSupplier_BASE;
56class ModuleUIConfigurationManagerSupplier :
public ModuleUIConfigurationManagerSupplier_BASE
59 explicit ModuleUIConfigurationManagerSupplier(
const css::uno::Reference< css::uno::XComponentContext >& rxContext );
60 virtual ~ModuleUIConfigurationManagerSupplier()
override;
64 return "com.sun.star.comp.framework.ModuleUIConfigurationManagerSupplier";
74 return {
"com.sun.star.ui.ModuleUIConfigurationManagerSupplier"};
78 virtual css::uno::Reference< css::ui::XUIConfigurationManager > SAL_CALL getUIConfigurationManager(
const OUString& ModuleIdentifier )
override;
81 virtual void disposing(std::unique_lock<std::mutex>&)
final override;
83 typedef std::unordered_map< OUString, css::uno::Reference< css::ui::XModuleUIConfigurationManager2 > > ModuleToModuleCfgMgr;
87 ModuleToModuleCfgMgr m_aModuleToModuleUICfgMgrMap;
88 css::uno::Reference< css::frame::XModuleManager2 > m_xModuleMgr;
89 css::uno::Reference< css::uno::XComponentContext >
m_xContext;
93 m_xModuleMgr( ModuleManager::
create( xContext ) )
101 for (
const OUString& rName : aNameSeq )
109ModuleUIConfigurationManagerSupplier::~ModuleUIConfigurationManagerSupplier()
115void ModuleUIConfigurationManagerSupplier::disposing(std::unique_lock<std::mutex>&)
118 for (
auto const& elem : m_aModuleToModuleUICfgMgrMap)
121 if ( xComponent.is() )
122 xComponent->dispose();
124 m_aModuleToModuleUICfgMgrMap.clear();
125 m_xModuleMgr.clear();
134 ModuleToModuleCfgMgr::iterator pIter = m_aModuleToModuleUICfgMgrMap.find( sModuleIdentifier );
135 if ( pIter == m_aModuleToModuleUICfgMgrMap.end() )
136 throw NoSuchElementException();
140 if ( !pIter->second.is() )
146 m_xModuleMgr->getByName(sModuleIdentifier) >>= lProps;
147 for (PropertyValue
const & rProp : std::as_const(lProps))
149 if ( rProp.Name ==
"ooSetupFactoryShortName" )
151 rProp.Value >>= sShort;
156 catch(
const Exception& )
161 if (sShort.isEmpty())
162 throw NoSuchElementException();
164 pIter->second = css::ui::ModuleUIConfigurationManager::createDefault(
m_xContext, sShort, sModuleIdentifier);
167 return pIter->second;
172extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
174 css::uno::XComponentContext *context,
175 css::uno::Sequence<css::uno::Any>
const &)
177 return cppu::acquire(
new ModuleUIConfigurationManagerSupplier(context));
css::uno::Reference< css::uno::XComponentContext > m_xContext
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_framework_ModuleUIConfigurationManagerSupplier_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)