26#include <com/sun/star/beans/PropertyValue.hpp>
27#include <com/sun/star/lang/XServiceInfo.hpp>
28#include <com/sun/star/frame/XUIControllerFactory.hpp>
34using namespace css::uno;
35using namespace css::lang;
36using namespace css::beans;
37using namespace css::container;
38using namespace css::frame;
44 css::lang::XServiceInfo,
45 css::frame::XUIControllerFactory > UIControllerFactory_BASE;
47class UIControllerFactory :
public UIControllerFactory_BASE
50 virtual ~UIControllerFactory()
override;
53 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithContext(
const OUString& aServiceSpecifier,
const css::uno::Reference< css::uno::XComponentContext >& Context )
override;
54 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArgumentsAndContext(
const OUString& ServiceSpecifier,
const css::uno::Sequence< css::uno::Any >& Arguments,
const css::uno::Reference< css::uno::XComponentContext >& Context )
override;
55 virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames()
override;
58 virtual sal_Bool SAL_CALL hasController(
const OUString& aCommandURL,
const OUString& aModuleName )
override;
59 virtual void SAL_CALL registerController(
const OUString& aCommandURL,
const OUString& aModuleName,
const OUString& aControllerImplementationName )
override;
60 virtual void SAL_CALL deregisterController(
const OUString& aCommandURL,
const OUString& aModuleName )
override;
63 UIControllerFactory(
const css::uno::Reference< css::uno::XComponentContext >& xContext, std::u16string_view rUINode );
65 css::uno::Reference< css::uno::XComponentContext >
m_xContext;
69 virtual void disposing(std::unique_lock<std::mutex>&)
final override;
72UIControllerFactory::UIControllerFactory(
73 const Reference< XComponentContext >& xContext,
74 std::u16string_view rConfigurationNode )
79 OUString::Concat(
"/org.openoffice.Office.UI.Controller/Registered/")
80 + rConfigurationNode);
83UIControllerFactory::~UIControllerFactory()
89void UIControllerFactory::disposing(std::unique_lock<std::mutex>&)
91 m_pConfigAccess.clear();
95Reference< XInterface > SAL_CALL UIControllerFactory::createInstanceWithContext(
96 const OUString& aServiceSpecifier,
97 const Reference< XComponentContext >& )
105 m_pConfigAccess->readConfigurationData();
108 OUString aServiceName = m_pConfigAccess->getServiceFromCommandModule( aServiceSpecifier, std::u16string_view() );
109 if ( !aServiceName.isEmpty() )
112 return Reference< XInterface >();
116Reference< XInterface > SAL_CALL UIControllerFactory::createInstanceWithArgumentsAndContext(
117 const OUString& ServiceSpecifier,
118 const Sequence< Any >& Arguments,
119 const Reference< XComponentContext >& )
121 static constexpr OUStringLiteral aPropModuleName( u
"ModuleIdentifier" );
124 PropertyValue aPropValue;
129 for ( Any
const & arg : Arguments )
131 if (( arg >>= aPropValue ) && ( aPropValue.Name == aPropModuleName ))
138 Sequence< Any > aNewArgs( Arguments );
140 sal_Int32 nAppendIndex = aNewArgs.getLength();
141 aNewArgs.realloc( aNewArgs.getLength() + 2 );
142 auto pNewArgs = aNewArgs.getArray();
146 aPropValue.Name =
"CommandURL";
147 aPropValue.Value <<= ServiceSpecifier;
148 pNewArgs[nAppendIndex] <<= aPropValue;
152 OUString aValue = m_pConfigAccess->getValueFromCommandModule( ServiceSpecifier, aPropName );
153 aPropValue.Name =
"Value";
154 aPropValue.Value <<= aValue;
155 pNewArgs[nAppendIndex+1] <<= aPropValue;
158 OUString aServiceName;
165 m_pConfigAccess->readConfigurationData();
168 aServiceName = m_pConfigAccess->getServiceFromCommandModule( ServiceSpecifier, aPropName );
171 if ( !aServiceName.isEmpty() )
172 return m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( aServiceName, aNewArgs,
m_xContext );
174 return Reference< XInterface >();
178Sequence< OUString > SAL_CALL UIControllerFactory::getAvailableServiceNames()
180 return Sequence< OUString >();
184sal_Bool SAL_CALL UIControllerFactory::hasController(
185 const OUString& aCommandURL,
186 const OUString& aModuleName )
193 m_pConfigAccess->readConfigurationData();
196 return ( !m_pConfigAccess->getServiceFromCommandModule( aCommandURL, aModuleName ).isEmpty() );
199void SAL_CALL UIControllerFactory::registerController(
200 const OUString& aCommandURL,
201 const OUString& aModuleName,
202 const OUString& aControllerImplementationName )
210 m_pConfigAccess->readConfigurationData();
213 m_pConfigAccess->addServiceToCommandModule( aCommandURL, aModuleName, aControllerImplementationName );
217void SAL_CALL UIControllerFactory::deregisterController(
218 const OUString& aCommandURL,
219 const OUString& aModuleName )
227 m_pConfigAccess->readConfigurationData();
230 m_pConfigAccess->removeServiceFromCommandModule( aCommandURL, aModuleName );
234class PopupMenuControllerFactory :
public UIControllerFactory
237 explicit PopupMenuControllerFactory(
const css::uno::Reference< css::uno::XComponentContext >& xContext );
241 return "com.sun.star.comp.framework.PopupMenuControllerFactory";
251 return {
"com.sun.star.frame.PopupMenuControllerFactory"};
256PopupMenuControllerFactory::PopupMenuControllerFactory(
const Reference< XComponentContext >& xContext ) :
257 UIControllerFactory( xContext,
u"PopupMenu" )
261class ToolbarControllerFactory :
public UIControllerFactory
264 explicit ToolbarControllerFactory(
const css::uno::Reference< css::uno::XComponentContext >& xContext );
268 return "com.sun.star.comp.framework.ToolBarControllerFactory";
278 return {
"com.sun.star.frame.ToolbarControllerFactory"};
283ToolbarControllerFactory::ToolbarControllerFactory(
const Reference< XComponentContext >& xContext ) :
284 UIControllerFactory( xContext,
u"ToolBar" )
288class StatusbarControllerFactory :
public UIControllerFactory
291 explicit StatusbarControllerFactory(
const css::uno::Reference< css::uno::XComponentContext >& xContext );
295 return "com.sun.star.comp.framework.StatusBarControllerFactory";
305 return {
"com.sun.star.frame.StatusbarControllerFactory"};
310StatusbarControllerFactory::StatusbarControllerFactory(
const Reference< XComponentContext >& xContext ) :
311 UIControllerFactory( xContext,
u"StatusBar" )
317extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
319 css::uno::XComponentContext *context,
320 css::uno::Sequence<css::uno::Any>
const &)
322 return cppu::acquire(
new PopupMenuControllerFactory(context));
325extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
327 css::uno::XComponentContext *context,
328 css::uno::Sequence<css::uno::Any>
const &)
330 return cppu::acquire(
new ToolbarControllerFactory(context));
333extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
335 css::uno::XComponentContext *context,
336 css::uno::Sequence<css::uno::Any>
const &)
338 return cppu::acquire(
new StatusbarControllerFactory(context));
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)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_framework_StatusBarControllerFactory_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_framework_PopupMenuControllerFactory_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_framework_ToolBarControllerFactory_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)