fdo#46808, XMultiServiceFactory to XComponentContext

Change-Id: I2ca9a2930a921c600f5e93cc2e66d461220ea87d
This commit is contained in:
Noel Grandin
2013-05-21 15:01:22 +02:00
parent 03c3cd9093
commit 122e4bc598
11 changed files with 30 additions and 26 deletions

View File

@@ -34,7 +34,6 @@
#include <com/sun/star/util/XUpdatable.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <rtl/ustring.hxx>
#include <cppuhelper/propshlp.hxx>
@@ -60,7 +59,7 @@ class UIConfigElementWrapperBase : public ::com::sun::star::lang::XTypeProvider
// public methods
//-------------------------------------------------------------------------------------------------------------
public:
UIConfigElementWrapperBase( sal_Int16 nType,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xServiceFactory );
UIConfigElementWrapperBase( sal_Int16 nType );
virtual ~UIConfigElementWrapperBase();
// XInterface
@@ -132,8 +131,7 @@ class UIConfigElementWrapperBase : public ::com::sun::star::lang::XTypeProvider
m_bConfigListening : 1,
m_bDisposed : 1,
m_bNoClose : 1;
OUString m_aResourceURL;
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceFactory;
OUString m_aResourceURL;
com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > m_xConfigSource;
com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > m_xConfigData;
com::sun::star::uno::WeakReference< com::sun::star::frame::XFrame > m_xWeakFrame;

View File

@@ -40,7 +40,7 @@ class MenuBarWrapper : public UIConfigElementWrapperBase,
{
public:
MenuBarWrapper(
const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& xContext );
virtual ~MenuBarWrapper();
//---------------------------------------------------------------------------------------------------------
@@ -80,6 +80,7 @@ class MenuBarWrapper : public UIConfigElementWrapperBase,
sal_Bool m_bRefreshPopupControllerCache : 1;
com::sun::star::uno::Reference< com::sun::star::lang::XComponent > m_xMenuBarManager;
PopupControllerCache m_aPopupControllerCache;
com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
};
} // namespace framework

View File

@@ -25,7 +25,7 @@
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
namespace framework
{
@@ -34,7 +34,7 @@ class StatusBarWrapper : public UIConfigElementWrapperBase
{
public:
StatusBarWrapper(
const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext );
virtual ~StatusBarWrapper();
// XComponent
@@ -51,6 +51,7 @@ class StatusBarWrapper : public UIConfigElementWrapperBase
private:
::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xStatusBarManager;
com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
};
} // namespace framework

View File

@@ -26,6 +26,7 @@
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/ui/XUIFunctionListener.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
namespace framework
{
@@ -35,7 +36,7 @@ class ToolBarWrapper : public ::com::sun::star::ui::XUIFunctionListener,
public UIConfigElementWrapperBase
{
public:
ToolBarWrapper( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
ToolBarWrapper( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& xContext );
virtual ~ToolBarWrapper();
// XInterface
@@ -74,6 +75,7 @@ class ToolBarWrapper : public ::com::sun::star::ui::XUIFunctionListener,
private:
com::sun::star::uno::Reference< com::sun::star::lang::XComponent > m_xToolBarManager;
com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
};
}

View File

@@ -89,7 +89,7 @@ DEFINE_XTYPEPROVIDER_10 ( UIConfigElementWrapperBase
::com::sun::star::ui::XUIConfigurationListener
)
UIConfigElementWrapperBase::UIConfigElementWrapperBase( sal_Int16 nType,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xServiceFactory )
UIConfigElementWrapperBase::UIConfigElementWrapperBase( sal_Int16 nType )
: ThreadHelpBase ( &Application::GetSolarMutex() )
, ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType >( m_aLock.getShareableOslMutex() )
, ::cppu::OPropertySetHelper ( *(static_cast< ::cppu::OBroadcastHelper* >(this)) )
@@ -101,7 +101,6 @@ UIConfigElementWrapperBase::UIConfigElementWrapperBase( sal_Int16 nType,const ::
, m_bConfigListening ( sal_False )
, m_bDisposed ( sal_False )
, m_bNoClose ( sal_False )
, m_xServiceFactory ( _xServiceFactory )
, m_aListenerContainer ( m_aLock.getShareableOslMutex() )
{
}

View File

@@ -83,10 +83,11 @@ DEFINE_XTYPEPROVIDER_11 ( MenuBarWrapper ,
)
MenuBarWrapper::MenuBarWrapper(
const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xServiceManager
const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext
)
: UIConfigElementWrapperBase( UIElementType::MENUBAR,xServiceManager ),
m_bRefreshPopupControllerCache( sal_True )
: UIConfigElementWrapperBase( UIElementType::MENUBAR ),
m_bRefreshPopupControllerCache( sal_True ),
m_xContext( rxContext )
{
}
@@ -138,7 +139,7 @@ void SAL_CALL MenuBarWrapper::initialize( const Sequence< Any >& aArguments ) th
pVCLMenuBar = new MenuBar();
}
Reference< XModuleManager2 > xModuleManager = ModuleManager::create( comphelper::getComponentContext(m_xServiceFactory) );
Reference< XModuleManager2 > xModuleManager = ModuleManager::create( m_xContext );
try
{
@@ -151,7 +152,7 @@ void SAL_CALL MenuBarWrapper::initialize( const Sequence< Any >& aArguments ) th
Reference< XURLTransformer > xTrans;
try
{
xTrans.set( URLTransformer::create(::comphelper::getComponentContext(m_xServiceFactory)) );
xTrans.set( URLTransformer::create(m_xContext) );
m_xConfigData = m_xConfigSource->getSettings( m_aResourceURL, sal_False );
if ( m_xConfigData.is() )
{
@@ -183,7 +184,7 @@ void SAL_CALL MenuBarWrapper::initialize( const Sequence< Any >& aArguments ) th
// support. This feature is currently used for "Inplace editing"!
Reference< XDispatchProvider > xDispatchProvider;
MenuBarManager* pMenuBarManager = new MenuBarManager( comphelper::getComponentContext(m_xServiceFactory),
MenuBarManager* pMenuBarManager = new MenuBarManager( m_xContext,
xFrame,
xTrans,
xDispatchProvider,

View File

@@ -54,9 +54,10 @@ namespace framework
{
StatusBarWrapper::StatusBarWrapper(
const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xServiceManager
const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext
)
: UIConfigElementWrapperBase( UIElementType::STATUSBAR,xServiceManager )
: UIConfigElementWrapperBase( UIElementType::STATUSBAR ),
m_xContext( rxContext )
{
}
@@ -79,7 +80,7 @@ void SAL_CALL StatusBarWrapper::dispose() throw (::com::sun::star::uno::RuntimeE
m_xStatusBarManager.clear();
m_xConfigSource.clear();
m_xConfigData.clear();
m_xServiceFactory.clear();
m_xContext.clear();
m_bDisposed = sal_True;
}
@@ -113,7 +114,7 @@ void SAL_CALL StatusBarWrapper::initialize( const Sequence< Any >& aArguments )
sal_uLong nStyles = WinBits( WB_LEFT | WB_3DLOOK );
pStatusBar = new FrameworkStatusBar( pWindow, nStyles );
pStatusBarManager = new StatusBarManager( m_xServiceFactory, xFrame, m_aResourceURL, pStatusBar );
pStatusBarManager = new StatusBarManager( Reference<XMultiServiceFactory>(m_xContext->getServiceManager(), UNO_QUERY_THROW), xFrame, m_aResourceURL, pStatusBar );
((FrameworkStatusBar*)pStatusBar)->SetStatusBarManager( pStatusBarManager );
m_xStatusBarManager = Reference< XComponent >( static_cast< OWeakObject *>( pStatusBarManager ), UNO_QUERY );
pStatusBar->SetUniqueId( HID_STATUSBAR );

View File

@@ -54,8 +54,9 @@ using namespace ::com::sun::star::ui;
namespace framework
{
ToolBarWrapper::ToolBarWrapper( const Reference< XMultiServiceFactory >& xServiceManager ) :
UIConfigElementWrapperBase( UIElementType::TOOLBAR,xServiceManager )
ToolBarWrapper::ToolBarWrapper( const Reference< XComponentContext >& rxContext ) :
UIConfigElementWrapperBase( UIElementType::TOOLBAR ),
m_xContext( rxContext )
{
}
@@ -152,7 +153,7 @@ void SAL_CALL ToolBarWrapper::initialize( const Sequence< Any >& aArguments ) th
sal_uLong nStyles = WB_LINESPACING | WB_BORDER | WB_SCROLL | WB_MOVEABLE | WB_3DLOOK | WB_DOCKABLE | WB_SIZEABLE | WB_CLOSEABLE;
pToolBar = new ToolBox( pWindow, nStyles );
pToolBarManager = new ToolBarManager( comphelper::getComponentContext(m_xServiceFactory), xFrame, m_aResourceURL, pToolBar );
pToolBarManager = new ToolBarManager( m_xContext, xFrame, m_aResourceURL, pToolBar );
m_xToolBarManager = Reference< XComponent >( static_cast< OWeakObject *>( pToolBarManager ), UNO_QUERY );
pToolBar->WillUsePopupMode( bPopupMode );
}

View File

@@ -87,7 +87,7 @@ throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::l
{
// SAFE
ResetableGuard aLock( m_aLock );
MenuBarWrapper* pMenuBarWrapper = new MenuBarWrapper( m_xServiceManager );
MenuBarWrapper* pMenuBarWrapper = new MenuBarWrapper( comphelper::getComponentContext(m_xServiceManager) );
Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pMenuBarWrapper, UNO_QUERY );
Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = m_xModuleManager;
aLock.unlock();

View File

@@ -74,7 +74,7 @@ throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::l
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarFactory::createUIElement" );
// SAFE
ResetableGuard aLock( m_aLock );
StatusBarWrapper* pWrapper = new StatusBarWrapper( m_xServiceManager );
StatusBarWrapper* pWrapper = new StatusBarWrapper( comphelper::getComponentContext(m_xServiceManager) );
Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pWrapper, UNO_QUERY );
Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = m_xModuleManager;
aLock.unlock();

View File

@@ -70,7 +70,7 @@ Reference< XUIElement > SAL_CALL ToolBoxFactory::createUIElement(
throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException )
{
ResetableGuard aLock( m_aLock );
ToolBarWrapper* pWrapper = new ToolBarWrapper( m_xServiceManager );
ToolBarWrapper* pWrapper = new ToolBarWrapper( comphelper::getComponentContext(m_xServiceManager) );
Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pWrapper, UNO_QUERY );
Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = m_xModuleManager;
aLock.unlock();