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 @@
#ifndef 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/XTypeProvider.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/ui/XUIElementFactory.hpp>
#include <com/sun/star/frame/XModuleManager2.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <toolkit/awt/vclxmenu.hxx>
#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <rtl/ustring.hxx>
namespace framework
{
class MenuBarFactory : protected ThreadHelpBase , // Struct for right initalization of mutex member! Must be first of baseclasses.
public ::cppu::WeakImplHelper2< com::sun::star::lang::XServiceInfo,
::com::sun::star::ui::XUIElementFactory>
typedef ::cppu::WeakImplHelper2<
css::lang::XServiceInfo,
css::ui::XUIElementFactory> MenuBarFactory_BASE;
class MenuBarFactory : public MenuBarFactory_BASE
{
public:
MenuBarFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
virtual ~MenuBarFactory();
// XInterface, XTypeProvider, XServiceInfo
DECLARE_XSERVICEINFO
virtual OUString SAL_CALL getImplementationName()
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
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
,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext);
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::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 @@
)
=================================================================================================================*/
#include <services/desktop.hxx>
#include <uifactory/menubarfactory.hxx>
#include <uifactory/toolboxfactory.hxx>
#include "uiconfiguration/windowstateconfiguration.hxx"
#include <uifactory/statusbarfactory.hxx>
#include <services/sessionlistener.hxx>
#include <services/ContextChangeEventMultiplexer.hxx>
COMPONENTGETFACTORY ( fwk,
IFFACTORY( ::framework::Desktop ) else
IFFACTORY( ::framework::MenuBarFactory ) else
IFFACTORY( ::framework::ToolBoxFactory ) else
IFFACTORY( ::framework::WindowStateConfiguration ) else
IFFACTORY( ::framework::StatusBarFactory ) else
IFFACTORY( ::framework::SessionListener ) else
IFFACTORY( ::framework::SessionListener ) else
IFFACTORY( ::framework::ContextChangeEventMultiplexer )
......
......@@ -19,26 +19,20 @@
#include <uifactory/menubarfactory.hxx>
#include <threadhelp/resetableguard.hxx>
#include "services.h"
#include <uielement/menubarwrapper.hxx>
#include <com/sun/star/util/XURLTransformer.hpp>
#include <com/sun/star/frame/ModuleManager.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/theModuleUIConfigurationManagerSupplier.hpp>
#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <vcl/menu.hxx>
#include <vcl/svapp.hxx>
#include <rtl/ustrbuf.hxx>
//_________________________________________________________________________________________________________________
// Defines
//_________________________________________________________________________________________________________________
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::frame;
......@@ -49,27 +43,8 @@ using namespace ::com::sun::star::ui;
namespace framework
{
//*****************************************************************************************************************
// XInterface, XTypeProvider, XServiceInfo
//*****************************************************************************************************************
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 ) )
MenuBarFactory::MenuBarFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext )
: m_xContext( xContext )
{
}
......@@ -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 )
{
// SAFE
ResetableGuard aLock( m_aLock );
SolarMutexClearableGuard g;
MenuBarWrapper* pMenuBarWrapper = new MenuBarWrapper( m_xContext );
Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pMenuBarWrapper, UNO_QUERY );
Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = m_xModuleManager;
aLock.unlock();
Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = ModuleManager::create( m_xContext );
g.clear();
CreateUIElement(ResourceURL, Args, "MenuOnly", "private:resource/menubar/", xMenuBar, xModuleManager, m_xContext);
return xMenuBar;
}
......@@ -184,4 +159,12 @@ void MenuBarFactory::CreateUIElement(const OUString& ResourceURL
} // 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: */
......@@ -17,27 +17,15 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <uifactory/statusbarfactory.hxx>
#include <uifactory/menubarfactory.hxx>
#include <com/sun/star/frame/ModuleManager.hpp>
#include <uifactory/menubarfactory.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 <rtl/ustrbuf.hxx>
//_________________________________________________________________________________________________________________
// Defines
//_________________________________________________________________________________________________________________
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::frame;
......@@ -45,22 +33,41 @@ using namespace com::sun::star::beans;
using namespace com::sun::star::util;
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);
}
//*****************************************************************************************************************
// XInterface, XTypeProvider, XServiceInfo
//*****************************************************************************************************************
DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2( StatusBarFactory ,
::cppu::OWeakObject ,
SERVICENAME_STATUSBARFACTORY ,
IMPLEMENTATIONNAME_STATUSBARFACTORY
)
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.StatusBarFactory");
return aSeq;
}
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 ) :
MenuBarFactory( xContext,true )
MenuBarFactory( xContext )
{
}
......@@ -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 )
{
// SAFE
ResetableGuard aLock( m_aLock );
SolarMutexClearableGuard g;
StatusBarWrapper* pWrapper = new StatusBarWrapper( m_xContext );
Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pWrapper, UNO_QUERY );
Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = m_xModuleManager;
aLock.unlock();
Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = ModuleManager::create( m_xContext );
g.clear();
MenuBarFactory::CreateUIElement(ResourceURL, Args, NULL, "private:resource/statusbar/", xMenuBar, xModuleManager, m_xContext );
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: */
......@@ -17,25 +17,13 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <uifactory/toolboxfactory.hxx>
#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 <com/sun/star/frame/ModuleManager.hpp>
#include <cppuhelper/supportsservice.hxx>
#include <vcl/svapp.hxx>
#include <rtl/ustrbuf.hxx>
//_________________________________________________________________________________________________________________
// Defines
//_________________________________________________________________________________________________________________
#include <uielement/toolbarwrapper.hxx>
#include <uifactory/menubarfactory.hxx>
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
......@@ -43,23 +31,43 @@ using namespace com::sun::star::frame;
using namespace com::sun::star::beans;
using namespace com::sun::star::util;
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);
}
//*****************************************************************************************************************
// XInterface, XTypeProvider, XServiceInfo
//*****************************************************************************************************************
DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2( ToolBoxFactory ,
::cppu::OWeakObject ,
SERVICENAME_TOOLBARFACTORY ,
IMPLEMENTATIONNAME_TOOLBARFACTORY
)
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.ToolBarFactory");
return aSeq;
}
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 ) :
MenuBarFactory( xContext,true )
MenuBarFactory( xContext )
{
}
......@@ -69,15 +77,23 @@ Reference< XUIElement > SAL_CALL ToolBoxFactory::createUIElement(
const Sequence< PropertyValue >& Args )
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 );
Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pWrapper, UNO_QUERY );
Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = m_xModuleManager;
aLock.unlock();
Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = ModuleManager::create(m_xContext);
g.clear();
CreateUIElement(ResourceURL, Args, "PopupMode", "private:resource/toolbar/", xMenuBar, xModuleManager, m_xContext);
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: */
......@@ -70,7 +70,8 @@
constructor="com_sun_star_comp_framework_LayoutManager_get_implementation">
<service name="com.sun.star.frame.LayoutManager"/>
</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"/>
</implementation>
<implementation name="com.sun.star.comp.framework.ModuleAcceleratorConfiguration"
......@@ -117,7 +118,8 @@
<service name="com.sun.star.frame.StatusbarControllerFactory"/>
<singleton name="com.sun.star.frame.theStatusbarControllerFactory"/>
</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"/>
</implementation>
<implementation name="com.sun.star.comp.framework.StatusIndicatorFactory"
......@@ -133,7 +135,8 @@
<service name="com.sun.star.frame.ToolbarControllerFactory"/>
<singleton name="com.sun.star.frame.theToolbarControllerFactory"/>
</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"/>
</implementation>
<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