Kaydet (Commit) 813b0f60 authored tarafından Matúš Kukan's avatar Matúš Kukan

fwk: Constructor feature for single-instance FooBarFactories.

Converted them as usual service implementations.
Otherwise - if static singletons are used -
it does not show menu for some reason.

Change-Id: I0673d0bfbba268728a3fa676f2af95aa6c74bbb2
üst 094f92bb
...@@ -20,36 +20,48 @@ ...@@ -20,36 +20,48 @@
#ifndef INCLUDED_FRAMEWORK_INC_UIFACTORY_MENUBARFACTORY_HXX #ifndef INCLUDED_FRAMEWORK_INC_UIFACTORY_MENUBARFACTORY_HXX
#define INCLUDED_FRAMEWORK_INC_UIFACTORY_MENUBARFACTORY_HXX #define INCLUDED_FRAMEWORK_INC_UIFACTORY_MENUBARFACTORY_HXX
#include <stdtypes.h>
#include <threadhelp/threadhelpbase.hxx>
#include <macros/generic.hxx>
#include <macros/xinterface.hxx>
#include <macros/xtypeprovider.hxx>
#include <macros/xserviceinfo.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XTypeProvider.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/ui/XUIElementFactory.hpp> #include <com/sun/star/ui/XUIElementFactory.hpp>
#include <com/sun/star/frame/XModuleManager2.hpp> #include <com/sun/star/frame/XModuleManager2.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <toolkit/awt/vclxmenu.hxx> #include <toolkit/awt/vclxmenu.hxx>
#include <cppuhelper/implbase2.hxx> #include <cppuhelper/implbase2.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
namespace framework namespace framework
{ {
class MenuBarFactory : protected ThreadHelpBase , // Struct for right initalization of mutex member! Must be first of baseclasses. typedef ::cppu::WeakImplHelper2<
public ::cppu::WeakImplHelper2< com::sun::star::lang::XServiceInfo, css::lang::XServiceInfo,
::com::sun::star::ui::XUIElementFactory> css::ui::XUIElementFactory> MenuBarFactory_BASE;
class MenuBarFactory : public MenuBarFactory_BASE
{ {
public: public:
MenuBarFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ); MenuBarFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
virtual ~MenuBarFactory(); virtual ~MenuBarFactory();
// XInterface, XTypeProvider, XServiceInfo virtual OUString SAL_CALL getImplementationName()
DECLARE_XSERVICEINFO throw (css::uno::RuntimeException)
{
return OUString("com.sun.star.comp.framework.MenuBarFactory");
}
virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
throw (css::uno::RuntimeException)
{
return cppu::supportsService(this, ServiceName);
}
virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
throw (css::uno::RuntimeException)
{
css::uno::Sequence< OUString > aSeq(1);
aSeq[0] = OUString("com.sun.star.ui.UIElementFactory");
return aSeq;
}
// XUIElementFactory // XUIElementFactory
virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > SAL_CALL createUIElement( const OUString& ResourceURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Args ) throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > SAL_CALL createUIElement( const OUString& ResourceURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Args ) throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
...@@ -63,10 +75,7 @@ namespace framework ...@@ -63,10 +75,7 @@ namespace framework
,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext); ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext);
protected: protected:
MenuBarFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,bool );
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 > m_xModuleManager;
}; };
} }
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_FRAMEWORK_INC_UIFACTORY_STATUSBARFACTORY_HXX
#define INCLUDED_FRAMEWORK_INC_UIFACTORY_STATUSBARFACTORY_HXX
#include <stdtypes.h>
#include <macros/xserviceinfo.hxx>
#include <services.h>
#include <uifactory/menubarfactory.hxx>
#include <rtl/ustring.hxx>
namespace framework
{
class StatusBarFactory : public MenuBarFactory
{
public:
StatusBarFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
// XInterface, XTypeProvider, XServiceInfo
DECLARE_XSERVICEINFO
// XUIElementFactory
virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > SAL_CALL createUIElement( const OUString& ResourceURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Args ) throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
};
}
#endif // INCLUDED_FRAMEWORK_INC_UIFACTORY_STATUSBARFACTORY_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_FRAMEWORK_INC_UIFACTORY_TOOLBOXFACTORY_HXX
#define INCLUDED_FRAMEWORK_INC_UIFACTORY_TOOLBOXFACTORY_HXX
#include <stdtypes.h>
#include <macros/xserviceinfo.hxx>
#include <services.h>
#include <uifactory/menubarfactory.hxx>
#include <cppuhelper/weak.hxx>
#include <rtl/ustring.hxx>
namespace framework
{
class ToolBoxFactory : public MenuBarFactory
{
public:
ToolBoxFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
// XInterface, XTypeProvider, XServiceInfo
DECLARE_XSERVICEINFO
// XUIElementFactory
virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > SAL_CALL createUIElement( const OUString& ResourceURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Args ) throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
};
}
#endif // SFX_TOOLBOXFACTORY_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -34,20 +34,14 @@ ...@@ -34,20 +34,14 @@
) )
=================================================================================================================*/ =================================================================================================================*/
#include <services/desktop.hxx> #include <services/desktop.hxx>
#include <uifactory/menubarfactory.hxx>
#include <uifactory/toolboxfactory.hxx>
#include "uiconfiguration/windowstateconfiguration.hxx" #include "uiconfiguration/windowstateconfiguration.hxx"
#include <uifactory/statusbarfactory.hxx>
#include <services/sessionlistener.hxx> #include <services/sessionlistener.hxx>
#include <services/ContextChangeEventMultiplexer.hxx> #include <services/ContextChangeEventMultiplexer.hxx>
COMPONENTGETFACTORY ( fwk, COMPONENTGETFACTORY ( fwk,
IFFACTORY( ::framework::Desktop ) else IFFACTORY( ::framework::Desktop ) else
IFFACTORY( ::framework::MenuBarFactory ) else
IFFACTORY( ::framework::ToolBoxFactory ) else
IFFACTORY( ::framework::WindowStateConfiguration ) else IFFACTORY( ::framework::WindowStateConfiguration ) else
IFFACTORY( ::framework::StatusBarFactory ) else
IFFACTORY( ::framework::SessionListener ) else IFFACTORY( ::framework::SessionListener ) else
IFFACTORY( ::framework::SessionListener ) else IFFACTORY( ::framework::SessionListener ) else
IFFACTORY( ::framework::ContextChangeEventMultiplexer ) IFFACTORY( ::framework::ContextChangeEventMultiplexer )
......
...@@ -19,26 +19,20 @@ ...@@ -19,26 +19,20 @@
#include <uifactory/menubarfactory.hxx> #include <uifactory/menubarfactory.hxx>
#include <threadhelp/resetableguard.hxx>
#include "services.h"
#include <uielement/menubarwrapper.hxx> #include <uielement/menubarwrapper.hxx>
#include <com/sun/star/util/XURLTransformer.hpp>
#include <com/sun/star/frame/ModuleManager.hpp> #include <com/sun/star/frame/ModuleManager.hpp>
#include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp> #include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp> #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <vcl/menu.hxx> #include <vcl/menu.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
//_________________________________________________________________________________________________________________
// Defines
//_________________________________________________________________________________________________________________
using namespace com::sun::star::uno; using namespace com::sun::star::uno;
using namespace com::sun::star::lang; using namespace com::sun::star::lang;
using namespace com::sun::star::frame; using namespace com::sun::star::frame;
...@@ -49,27 +43,8 @@ using namespace ::com::sun::star::ui; ...@@ -49,27 +43,8 @@ using namespace ::com::sun::star::ui;
namespace framework namespace framework
{ {
//***************************************************************************************************************** MenuBarFactory::MenuBarFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext )
// XInterface, XTypeProvider, XServiceInfo : m_xContext( xContext )
//*****************************************************************************************************************
DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2( MenuBarFactory ,
::cppu::OWeakObject ,
SERVICENAME_MENUBARFACTORY ,
IMPLEMENTATIONNAME_MENUBARFACTORY
)
DEFINE_INIT_SERVICE ( MenuBarFactory, {} )
MenuBarFactory::MenuBarFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ) :
ThreadHelpBase()
, m_xContext( xContext )
, m_xModuleManager( ModuleManager::create( xContext ) )
{
}
MenuBarFactory::MenuBarFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,bool ) :
ThreadHelpBase(&Application::GetSolarMutex())
, m_xContext( xContext )
, m_xModuleManager( ModuleManager::create( xContext ) )
{ {
} }
...@@ -84,11 +59,11 @@ Reference< XUIElement > SAL_CALL MenuBarFactory::createUIElement( ...@@ -84,11 +59,11 @@ Reference< XUIElement > SAL_CALL MenuBarFactory::createUIElement(
throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ) throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException )
{ {
// SAFE // SAFE
ResetableGuard aLock( m_aLock ); SolarMutexClearableGuard g;
MenuBarWrapper* pMenuBarWrapper = new MenuBarWrapper( m_xContext ); MenuBarWrapper* pMenuBarWrapper = new MenuBarWrapper( m_xContext );
Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pMenuBarWrapper, UNO_QUERY ); Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pMenuBarWrapper, UNO_QUERY );
Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = m_xModuleManager; Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = ModuleManager::create( m_xContext );
aLock.unlock(); g.clear();
CreateUIElement(ResourceURL, Args, "MenuOnly", "private:resource/menubar/", xMenuBar, xModuleManager, m_xContext); CreateUIElement(ResourceURL, Args, "MenuOnly", "private:resource/menubar/", xMenuBar, xModuleManager, m_xContext);
return xMenuBar; return xMenuBar;
} }
...@@ -184,4 +159,12 @@ void MenuBarFactory::CreateUIElement(const OUString& ResourceURL ...@@ -184,4 +159,12 @@ void MenuBarFactory::CreateUIElement(const OUString& ResourceURL
} // namespace framework } // namespace framework
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
com_sun_star_comp_framework_MenuBarFactory_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
return cppu::acquire(new framework::MenuBarFactory(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -17,27 +17,15 @@ ...@@ -17,27 +17,15 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <uifactory/statusbarfactory.hxx> #include <com/sun/star/frame/ModuleManager.hpp>
#include <uifactory/menubarfactory.hxx>
#include <uifactory/menubarfactory.hxx>
#include <uielement/statusbarwrapper.hxx> #include <uielement/statusbarwrapper.hxx>
#include <threadhelp/resetableguard.hxx>
#include <com/sun/star/util/XURLTransformer.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
#include <cppuhelper/supportsservice.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
//_________________________________________________________________________________________________________________
// Defines
//_________________________________________________________________________________________________________________
using namespace com::sun::star::uno; using namespace com::sun::star::uno;
using namespace com::sun::star::lang; using namespace com::sun::star::lang;
using namespace com::sun::star::frame; using namespace com::sun::star::frame;
...@@ -45,22 +33,41 @@ using namespace com::sun::star::beans; ...@@ -45,22 +33,41 @@ using namespace com::sun::star::beans;
using namespace com::sun::star::util; using namespace com::sun::star::util;
using namespace ::com::sun::star::ui; using namespace ::com::sun::star::ui;
namespace framework using namespace framework;
namespace {
class StatusBarFactory : public MenuBarFactory
{ {
public:
StatusBarFactory( const css::uno::Reference< css::uno::XComponentContext >& xContext );
virtual OUString SAL_CALL getImplementationName()
throw (css::uno::RuntimeException)
{
return OUString("com.sun.star.comp.framework.StatusBarFactory");
}
virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
throw (css::uno::RuntimeException)
{
return cppu::supportsService(this, ServiceName);
}
//***************************************************************************************************************** virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
// XInterface, XTypeProvider, XServiceInfo throw (css::uno::RuntimeException)
//***************************************************************************************************************** {
DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2( StatusBarFactory , css::uno::Sequence< OUString > aSeq(1);
::cppu::OWeakObject , aSeq[0] = OUString("com.sun.star.ui.StatusBarFactory");
SERVICENAME_STATUSBARFACTORY , return aSeq;
IMPLEMENTATIONNAME_STATUSBARFACTORY }
)
DEFINE_INIT_SERVICE ( StatusBarFactory, {} ) // XUIElementFactory
virtual css::uno::Reference< css::ui::XUIElement > SAL_CALL createUIElement( const OUString& ResourceURL, const css::uno::Sequence< css::beans::PropertyValue >& Args ) throw ( css::container::NoSuchElementException, css::lang::IllegalArgumentException, css::uno::RuntimeException );
};
StatusBarFactory::StatusBarFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ) : StatusBarFactory::StatusBarFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ) :
MenuBarFactory( xContext,true ) MenuBarFactory( xContext )
{ {
} }
...@@ -71,15 +78,23 @@ Reference< XUIElement > SAL_CALL StatusBarFactory::createUIElement( ...@@ -71,15 +78,23 @@ Reference< XUIElement > SAL_CALL StatusBarFactory::createUIElement(
throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ) throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException )
{ {
// SAFE // SAFE
ResetableGuard aLock( m_aLock ); SolarMutexClearableGuard g;
StatusBarWrapper* pWrapper = new StatusBarWrapper( m_xContext ); StatusBarWrapper* pWrapper = new StatusBarWrapper( m_xContext );
Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pWrapper, UNO_QUERY ); Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pWrapper, UNO_QUERY );
Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = m_xModuleManager; Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = ModuleManager::create( m_xContext );
aLock.unlock(); g.clear();
MenuBarFactory::CreateUIElement(ResourceURL, Args, NULL, "private:resource/statusbar/", xMenuBar, xModuleManager, m_xContext ); MenuBarFactory::CreateUIElement(ResourceURL, Args, NULL, "private:resource/statusbar/", xMenuBar, xModuleManager, m_xContext );
return xMenuBar; return xMenuBar;
} }
} }
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
com_sun_star_comp_framework_StatusBarFactory_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
return cppu::acquire(new StatusBarFactory(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -17,25 +17,13 @@ ...@@ -17,25 +17,13 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <uifactory/toolboxfactory.hxx> #include <com/sun/star/frame/ModuleManager.hpp>
#include <uielement/toolbarwrapper.hxx>
#include <threadhelp/resetableguard.hxx>
#include <com/sun/star/util/XURLTransformer.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
#include <cppuhelper/supportsservice.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
#include <uielement/toolbarwrapper.hxx>
//_________________________________________________________________________________________________________________ #include <uifactory/menubarfactory.hxx>
// Defines
//_________________________________________________________________________________________________________________
using namespace com::sun::star::uno; using namespace com::sun::star::uno;
using namespace com::sun::star::lang; using namespace com::sun::star::lang;
...@@ -43,23 +31,43 @@ using namespace com::sun::star::frame; ...@@ -43,23 +31,43 @@ using namespace com::sun::star::frame;
using namespace com::sun::star::beans; using namespace com::sun::star::beans;
using namespace com::sun::star::util; using namespace com::sun::star::util;
using namespace ::com::sun::star::ui; using namespace ::com::sun::star::ui;
using namespace framework;
namespace framework namespace {
class ToolBoxFactory : public MenuBarFactory
{ {
public:
ToolBoxFactory( const css::uno::Reference< css::uno::XComponentContext >& xContext );
virtual OUString SAL_CALL getImplementationName()
throw (css::uno::RuntimeException)
{
return OUString("com.sun.star.comp.framework.ToolBarFactory");
}
virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
throw (css::uno::RuntimeException)
{
return cppu::supportsService(this, ServiceName);
}
//***************************************************************************************************************** virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
// XInterface, XTypeProvider, XServiceInfo throw (css::uno::RuntimeException)
//***************************************************************************************************************** {
DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2( ToolBoxFactory , css::uno::Sequence< OUString > aSeq(1);
::cppu::OWeakObject , aSeq[0] = OUString("com.sun.star.ui.ToolBarFactory");
SERVICENAME_TOOLBARFACTORY , return aSeq;
IMPLEMENTATIONNAME_TOOLBARFACTORY }
)
DEFINE_INIT_SERVICE ( ToolBoxFactory, {} ) // XUIElementFactory
virtual css::uno::Reference< css::ui::XUIElement > SAL_CALL createUIElement(
const OUString& ResourceURL, const css::uno::Sequence< css::beans::PropertyValue >& Args )
throw ( css::container::NoSuchElementException, css::lang::IllegalArgumentException, css::uno::RuntimeException );
};
ToolBoxFactory::ToolBoxFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ) : ToolBoxFactory::ToolBoxFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ) :
MenuBarFactory( xContext,true ) MenuBarFactory( xContext )
{ {
} }
...@@ -69,15 +77,23 @@ Reference< XUIElement > SAL_CALL ToolBoxFactory::createUIElement( ...@@ -69,15 +77,23 @@ Reference< XUIElement > SAL_CALL ToolBoxFactory::createUIElement(
const Sequence< PropertyValue >& Args ) const Sequence< PropertyValue >& Args )
throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ) throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException )
{ {
ResetableGuard aLock( m_aLock ); SolarMutexClearableGuard g;
ToolBarWrapper* pWrapper = new ToolBarWrapper( m_xContext ); ToolBarWrapper* pWrapper = new ToolBarWrapper( m_xContext );
Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pWrapper, UNO_QUERY ); Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pWrapper, UNO_QUERY );
Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = m_xModuleManager; Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = ModuleManager::create(m_xContext);
aLock.unlock(); g.clear();
CreateUIElement(ResourceURL, Args, "PopupMode", "private:resource/toolbar/", xMenuBar, xModuleManager, m_xContext); CreateUIElement(ResourceURL, Args, "PopupMode", "private:resource/toolbar/", xMenuBar, xModuleManager, m_xContext);
return xMenuBar; return xMenuBar;
} }
} }
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
com_sun_star_comp_framework_ToolBarFactory_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
return cppu::acquire(new ToolBoxFactory(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -70,7 +70,8 @@ ...@@ -70,7 +70,8 @@
constructor="com_sun_star_comp_framework_LayoutManager_get_implementation"> constructor="com_sun_star_comp_framework_LayoutManager_get_implementation">
<service name="com.sun.star.frame.LayoutManager"/> <service name="com.sun.star.frame.LayoutManager"/>
</implementation> </implementation>
<implementation name="com.sun.star.comp.framework.MenuBarFactory"> <implementation name="com.sun.star.comp.framework.MenuBarFactory"
constructor="com_sun_star_comp_framework_MenuBarFactory_get_implementation">
<service name="com.sun.star.ui.UIElementFactory"/> <service name="com.sun.star.ui.UIElementFactory"/>
</implementation> </implementation>
<implementation name="com.sun.star.comp.framework.ModuleAcceleratorConfiguration" <implementation name="com.sun.star.comp.framework.ModuleAcceleratorConfiguration"
...@@ -117,7 +118,8 @@ ...@@ -117,7 +118,8 @@
<service name="com.sun.star.frame.StatusbarControllerFactory"/> <service name="com.sun.star.frame.StatusbarControllerFactory"/>
<singleton name="com.sun.star.frame.theStatusbarControllerFactory"/> <singleton name="com.sun.star.frame.theStatusbarControllerFactory"/>
</implementation> </implementation>
<implementation name="com.sun.star.comp.framework.StatusBarFactory"> <implementation name="com.sun.star.comp.framework.StatusBarFactory"
constructor="com_sun_star_comp_framework_StatusBarFactory_get_implementation">
<service name="com.sun.star.ui.StatusBarFactory"/> <service name="com.sun.star.ui.StatusBarFactory"/>
</implementation> </implementation>
<implementation name="com.sun.star.comp.framework.StatusIndicatorFactory" <implementation name="com.sun.star.comp.framework.StatusIndicatorFactory"
...@@ -133,7 +135,8 @@ ...@@ -133,7 +135,8 @@
<service name="com.sun.star.frame.ToolbarControllerFactory"/> <service name="com.sun.star.frame.ToolbarControllerFactory"/>
<singleton name="com.sun.star.frame.theToolbarControllerFactory"/> <singleton name="com.sun.star.frame.theToolbarControllerFactory"/>
</implementation> </implementation>
<implementation name="com.sun.star.comp.framework.ToolBarFactory"> <implementation name="com.sun.star.comp.framework.ToolBarFactory"
constructor="com_sun_star_comp_framework_ToolBarFactory_get_implementation">
<service name="com.sun.star.ui.ToolBarFactory"/> <service name="com.sun.star.ui.ToolBarFactory"/>
</implementation> </implementation>
<implementation name="com.sun.star.comp.framework.UICategoryDescription" <implementation name="com.sun.star.comp.framework.UICategoryDescription"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment