fwk: Constructor feature for single-instance framework::Desktop.

Change-Id: Id582e672c0b41a35d25361f7dfe970a767880b2a
This commit is contained in:
Matúš Kukan
2014-01-16 22:30:54 +01:00
parent ce02519c5c
commit 2d46ef6da5
5 changed files with 131 additions and 142 deletions

View File

@@ -20,16 +20,11 @@
#ifndef INCLUDED_FRAMEWORK_INC_SERVICES_DESKTOP_HXX #ifndef INCLUDED_FRAMEWORK_INC_SERVICES_DESKTOP_HXX
#define INCLUDED_FRAMEWORK_INC_SERVICES_DESKTOP_HXX #define INCLUDED_FRAMEWORK_INC_SERVICES_DESKTOP_HXX
#include <sal/config.h>
#include <classes/framecontainer.hxx> #include <classes/framecontainer.hxx>
#include <threadhelp/threadhelpbase.hxx>
#include <helper/oframes.hxx>
#include <macros/generic.hxx>
#include <macros/xinterface.hxx>
#include <macros/xtypeprovider.hxx>
#include <macros/xserviceinfo.hxx>
#include <com/sun/star/frame/XUntitledNumbers.hpp> #include <com/sun/star/frame/XUntitledNumbers.hpp>
#include <com/sun/star/frame/XController.hpp> #include <com/sun/star/frame/XController.hpp>
#include <com/sun/star/frame/XDesktop2.hpp> #include <com/sun/star/frame/XDesktop2.hpp>
#include <com/sun/star/frame/XTerminateListener.hpp> #include <com/sun/star/frame/XTerminateListener.hpp>
@@ -38,7 +33,7 @@
#include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/frame/XFramesSupplier.hpp> #include <com/sun/star/frame/XFramesSupplier.hpp>
#include <com/sun/star/frame/XFrames.hpp> #include <com/sun/star/frame/XFrames.hpp>
#include <com/sun/star/lang/XServiceName.hpp> #include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp>
#include <com/sun/star/frame/XDispatchProviderInterception.hpp> #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
#include <com/sun/star/frame/XComponentLoader.hpp> #include <com/sun/star/frame/XComponentLoader.hpp>
@@ -53,11 +48,10 @@
#include <com/sun/star/frame/XDispatchRecorderSupplier.hpp> #include <com/sun/star/frame/XDispatchRecorderSupplier.hpp>
#include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/uno/XComponentContext.hpp>
#include <unotools/cmdoptions.hxx>
#include <cppuhelper/propshlp.hxx>
#include <cppuhelper/implbase6.hxx>
#include <comphelper/numberedcollection.hxx> #include <comphelper/numberedcollection.hxx>
#include <cppuhelper/compbase6.hxx>
#include <cppuhelper/propshlp.hxx>
#include <unotools/cmdoptions.hxx>
namespace framework{ namespace framework{
@@ -91,15 +85,10 @@ enum ELoadState
XEventListener XEventListener
XInteractionHandler XInteractionHandler
@base ThreadHelpBase
TransactionBase
OBroadcastHelper
OPropertySetHelper
@devstatus ready to use @devstatus ready to use
@threadsafe yes @threadsafe yes
*//*-*************************************************************************************************************/ *//*-*************************************************************************************************************/
typedef ::cppu::WeakImplHelper6< typedef cppu::WeakComponentImplHelper6<
css::lang::XServiceInfo , css::lang::XServiceInfo ,
css::frame::XDesktop2 , css::frame::XDesktop2 ,
css::frame::XTasksSupplier , css::frame::XTasksSupplier ,
@@ -107,14 +96,11 @@ typedef ::cppu::WeakImplHelper6<
css::task::XInteractionHandler , css::task::XInteractionHandler ,
css::frame::XUntitledNumbers > Desktop_BASE; css::frame::XUntitledNumbers > Desktop_BASE;
class Desktop : // base classes class Desktop : private osl::Mutex,
// Order is necessary for right initialization! private ThreadHelpBase,
private ThreadHelpBase , private TransactionBase,
private TransactionBase , public Desktop_BASE,
public ::cppu::OBroadcastHelper , public cppu::OPropertySetHelper
public ::cppu::OPropertySetHelper ,
// interfaces
public Desktop_BASE
{ {
// internal used types, const etcpp. // internal used types, const etcpp.
private: private:
@@ -130,8 +116,17 @@ class Desktop : // base classes
Desktop( const css::uno::Reference< css::uno::XComponentContext >& xContext ); Desktop( const css::uno::Reference< css::uno::XComponentContext >& xContext );
virtual ~Desktop( ); virtual ~Desktop( );
void constructorInit();
// XServiceInfo // XServiceInfo
DECLARE_XSERVICEINFO virtual OUString SAL_CALL getImplementationName()
throw (css::uno::RuntimeException);
virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
throw (css::uno::RuntimeException);
virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
throw (css::uno::RuntimeException);
// XInterface // XInterface
virtual void SAL_CALL acquire() throw () virtual void SAL_CALL acquire() throw ()
@@ -274,8 +269,7 @@ class Desktop : // base classes
virtual void SAL_CALL removeFrameActionListener ( const css::uno::Reference< css::frame::XFrameActionListener >& xListener ) throw( css::uno::RuntimeException ); virtual void SAL_CALL removeFrameActionListener ( const css::uno::Reference< css::frame::XFrameActionListener >& xListener ) throw( css::uno::RuntimeException );
// XComponent // XComponent
using cppu::OPropertySetHelper::disposing; virtual void SAL_CALL disposing() throw( css::uno::RuntimeException );
virtual void SAL_CALL dispose ( ) throw( css::uno::RuntimeException );
virtual void SAL_CALL addEventListener ( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw( css::uno::RuntimeException ); virtual void SAL_CALL addEventListener ( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw( css::uno::RuntimeException );
virtual void SAL_CALL removeEventListener ( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw( css::uno::RuntimeException ); virtual void SAL_CALL removeEventListener ( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw( css::uno::RuntimeException );
@@ -407,7 +401,6 @@ class Desktop : // base classes
//------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------
private: private:
static sal_Bool implcp_ctor ( const css::uno::Reference< css::uno::XComponentContext >& xFactory );
static sal_Bool implcp_addEventListener ( const css::uno::Reference< css::lang::XEventListener >& xListener ); static sal_Bool implcp_addEventListener ( const css::uno::Reference< css::lang::XEventListener >& xListener );
static sal_Bool implcp_removeEventListener ( const css::uno::Reference< css::lang::XEventListener >& xListener ); static sal_Bool implcp_removeEventListener ( const css::uno::Reference< css::lang::XEventListener >& xListener );

View File

@@ -33,10 +33,8 @@
IFFACTORIE( Service2 ) IFFACTORIE( Service2 )
) )
=================================================================================================================*/ =================================================================================================================*/
#include <services/desktop.hxx>
COMPONENTGETFACTORY ( fwk, COMPONENTGETFACTORY ( fwk,
IFFACTORY( ::framework::Desktop )
) )
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -17,12 +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 <loadenv/loadenv.hxx> #include <services/desktop.hxx>
#include <loadenv/loadenv.hxx>
#include <loadenv/targethelper.hxx> #include <loadenv/targethelper.hxx>
#include <services/desktop.hxx>
#include <helper/ocomponentaccess.hxx> #include <helper/ocomponentaccess.hxx>
#include <helper/oframes.hxx>
#include <dispatch/dispatchprovider.hxx> #include <dispatch/dispatchprovider.hxx>
#include <dispatch/interceptionhelper.hxx> #include <dispatch/interceptionhelper.hxx>
@@ -30,7 +31,6 @@
#include <threadhelp/transactionguard.hxx> #include <threadhelp/transactionguard.hxx>
#include <threadhelp/writeguard.hxx> #include <threadhelp/writeguard.hxx>
#include <threadhelp/readguard.hxx> #include <threadhelp/readguard.hxx>
#include <services.h>
#include <general.h> #include <general.h>
#include <properties.h> #include <properties.h>
@@ -61,80 +61,77 @@
#include <com/sun/star/document/UpdateDocMode.hpp> #include <com/sun/star/document/UpdateDocMode.hpp>
#include <com/sun/star/frame/XTerminateListener2.hpp> #include <com/sun/star/frame/XTerminateListener2.hpp>
#include <cppuhelper/queryinterface.hxx> #include <comphelper/sequence.hxx>
#include <cppuhelper/typeprovider.hxx> #include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/proptypehlp.hxx>
#include <rtl/ustrbuf.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <tools/errinf.hxx> #include <tools/errinf.hxx>
#include <comphelper/extract.hxx> #include <comphelper/extract.hxx>
#include <fwkdllapi.h>
namespace framework{ namespace framework{
//***************************************************************************************************************** OUString SAL_CALL Desktop::getImplementationName()
// XInterface, XTypeProvider, XServiceInfo throw (css::uno::RuntimeException)
//***************************************************************************************************************** {
return OUString("com.sun.star.comp.framework.Desktop");
}
DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2( Desktop, sal_Bool SAL_CALL Desktop::supportsService(OUString const & ServiceName)
::cppu::OWeakObject, throw (css::uno::RuntimeException)
"com.sun.star.frame.Desktop", {
IMPLEMENTATIONNAME_DESKTOP return cppu::supportsService(this, ServiceName);
) }
DEFINE_INIT_SERVICE ( Desktop, css::uno::Sequence<OUString> SAL_CALL Desktop::getSupportedServiceNames()
{ throw (css::uno::RuntimeException)
/*Attention {
I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance() css::uno::Sequence< OUString > aSeq(1);
to create a new instance of this class by our own supported service factory. aSeq[0] = OUString("com.sun.star.frame.Desktop");
see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further information! return aSeq;
*/ }
//------------------------------------------------------------------------------------------------------------- void Desktop::constructorInit()
// Initialize a new XFrames-helper-object to handle XIndexAccess and XElementAccess. {
// We hold member as reference ... not as pointer too! // Initialize a new XFrames-helper-object to handle XIndexAccess and XElementAccess.
// Attention: We share our frame container with this helper. Container is threadsafe himself ... So I think we can do that. // We hold member as reference ... not as pointer too!
// But look on dispose() for right order of deinitialization. // Attention: We share our frame container with this helper. Container is threadsafe himself ... So I think we can do that.
OFrames* pFramesHelper = new OFrames( this, &m_aChildTaskContainer ); // But look on dispose() for right order of deinitialization.
m_xFramesHelper = css::uno::Reference< css::frame::XFrames >( static_cast< ::cppu::OWeakObject* >(pFramesHelper), css::uno::UNO_QUERY ); OFrames* pFramesHelper = new OFrames( this, &m_aChildTaskContainer );
m_xFramesHelper = css::uno::Reference< css::frame::XFrames >( static_cast< ::cppu::OWeakObject* >(pFramesHelper), css::uno::UNO_QUERY );
//------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------
// Initialize a new dispatchhelper-object to handle dispatches. // Initialize a new dispatchhelper-object to handle dispatches.
// We use these helper as slave for our interceptor helper ... not directly! // We use these helper as slave for our interceptor helper ... not directly!
// But he is event listener on THIS instance! // But he is event listener on THIS instance!
DispatchProvider* pDispatchHelper = new DispatchProvider( m_xContext, this ); DispatchProvider* pDispatchHelper = new DispatchProvider( m_xContext, this );
css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( static_cast< ::cppu::OWeakObject* >(pDispatchHelper), css::uno::UNO_QUERY ); css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( static_cast< ::cppu::OWeakObject* >(pDispatchHelper), css::uno::UNO_QUERY );
//------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------
// Initialize a new interception helper object to handle dispatches and implement an interceptor mechanism. // Initialize a new interception helper object to handle dispatches and implement an interceptor mechanism.
// Set created dispatch provider as slowest slave of it. // Set created dispatch provider as slowest slave of it.
// Hold interception helper by reference only - not by pointer! // Hold interception helper by reference only - not by pointer!
// So it's easiear to destroy it. // So it's easiear to destroy it.
InterceptionHelper* pInterceptionHelper = new InterceptionHelper( this, xDispatchProvider ); InterceptionHelper* pInterceptionHelper = new InterceptionHelper( this, xDispatchProvider );
m_xDispatchHelper = css::uno::Reference< css::frame::XDispatchProvider >( static_cast< ::cppu::OWeakObject* >(pInterceptionHelper), css::uno::UNO_QUERY ); m_xDispatchHelper = css::uno::Reference< css::frame::XDispatchProvider >( static_cast< ::cppu::OWeakObject* >(pInterceptionHelper), css::uno::UNO_QUERY );
OUStringBuffer sUntitledPrefix (256); OUStringBuffer sUntitledPrefix (256);
sUntitledPrefix.append (FWK_RESSTR(STR_UNTITLED_DOCUMENT)); sUntitledPrefix.append (FWK_RESSTR(STR_UNTITLED_DOCUMENT));
sUntitledPrefix.appendAscii (" "); sUntitledPrefix.appendAscii (" ");
::comphelper::NumberedCollection* pNumbers = new ::comphelper::NumberedCollection (); ::comphelper::NumberedCollection* pNumbers = new ::comphelper::NumberedCollection ();
m_xTitleNumberGenerator = css::uno::Reference< css::frame::XUntitledNumbers >(static_cast< ::cppu::OWeakObject* >(pNumbers), css::uno::UNO_QUERY_THROW); m_xTitleNumberGenerator = css::uno::Reference< css::frame::XUntitledNumbers >(static_cast< ::cppu::OWeakObject* >(pNumbers), css::uno::UNO_QUERY_THROW);
pNumbers->setOwner ( static_cast< ::cppu::OWeakObject* >(this) ); pNumbers->setOwner ( static_cast< ::cppu::OWeakObject* >(this) );
pNumbers->setUntitledPrefix ( sUntitledPrefix.makeStringAndClear () ); pNumbers->setUntitledPrefix ( sUntitledPrefix.makeStringAndClear () );
// Safe impossible cases // Safe impossible cases
// We can't work without this helper! // We can't work without this helper!
SAL_WARN_IF( !m_xFramesHelper.is(), "fwk", "Desktop::Desktop(): Frames helper is not valid. XFrames, XIndexAccess and XElementAcces are not supported!"); SAL_WARN_IF( !m_xFramesHelper.is(), "fwk", "Desktop::Desktop(): Frames helper is not valid. XFrames, XIndexAccess and XElementAcces are not supported!");
SAL_WARN_IF( !m_xDispatchHelper.is(), "fwk", "Desktop::Desktop(): Dispatch helper is not valid. XDispatch will not work correctly!" ); SAL_WARN_IF( !m_xDispatchHelper.is(), "fwk", "Desktop::Desktop(): Dispatch helper is not valid. XDispatch will not work correctly!" );
// Enable object for real working! // Enable object for real working!
// Otherwise all calls will be rejected ... // Otherwise all calls will be rejected ...
m_aTransactionManager.setWorkingMode( E_WORK ); m_aTransactionManager.setWorkingMode( E_WORK );
} }
)
/*-************************************************************************************************************//** /*-************************************************************************************************************//**
@short standard constructor to create instance by factory @short standard constructor to create instance by factory
@@ -158,14 +155,10 @@ DEFINE_INIT_SERVICE ( Desktop,
@onerror We throw an ASSERT in debug version or do nothing in relaese version. @onerror We throw an ASSERT in debug version or do nothing in relaese version.
*//*-*************************************************************************************************************/ *//*-*************************************************************************************************************/
Desktop::Desktop( const css::uno::Reference< css::uno::XComponentContext >& xContext ) Desktop::Desktop( const css::uno::Reference< css::uno::XComponentContext >& xContext )
// Init baseclasses first
// Attention: Don't change order of initialization!
// ThreadHelpBase is a struct with a lock as member. We can't use a lock as direct member!
// We must guarantee right initialization and a valid value of this to initialize other baseclasses!
: ThreadHelpBase ( &Application::GetSolarMutex() ) : ThreadHelpBase ( &Application::GetSolarMutex() )
, TransactionBase ( ) , TransactionBase ( )
, ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType > ( m_aLock.getShareableOslMutex() ) , Desktop_BASE ( *static_cast<osl::Mutex *>(this) )
, ::cppu::OPropertySetHelper ( *(static_cast< ::cppu::OBroadcastHelper* >(this)) ) , cppu::OPropertySetHelper( cppu::WeakComponentImplHelperBase::rBHelper )
// Init member // Init member
, m_bIsTerminated ( sal_False ) // see dispose() for further information! , m_bIsTerminated ( sal_False ) // see dispose() for further information!
, m_xContext ( xContext ) , m_xContext ( xContext )
@@ -187,9 +180,6 @@ Desktop::Desktop( const css::uno::Reference< css::uno::XComponentContext >& xCon
, m_xSfxTerminator ( ) , m_xSfxTerminator ( )
, m_xTitleNumberGenerator ( ) , m_xTitleNumberGenerator ( )
{ {
// Safe impossible cases
// We don't accept all incoming parameter.
SAL_WARN_IF( implcp_ctor( xContext ), "fwk", "Desktop::Desktop(): Invalid parameter detected!" );
} }
/*-************************************************************************************************************//** /*-************************************************************************************************************//**
@@ -401,22 +391,22 @@ void SAL_CALL Desktop::addTerminateListener( const css::uno::Reference< css::fra
// SYCNHRONIZED -> // SYCNHRONIZED ->
WriteGuard aWriteLock( m_aLock ); WriteGuard aWriteLock( m_aLock );
if( sImplementationName.equals(IMPLEMENTATIONNAME_SFXTERMINATOR) ) if( sImplementationName == "com.sun.star.comp.sfx2.SfxTerminateListener" )
{ {
m_xSfxTerminator = xListener; m_xSfxTerminator = xListener;
return; return;
} }
if( sImplementationName.equals(IMPLEMENTATIONNAME_PIPETERMINATOR) ) if( sImplementationName == "com.sun.star.comp.OfficeIPCThreadController" )
{ {
m_xPipeTerminator = xListener; m_xPipeTerminator = xListener;
return; return;
} }
if( sImplementationName.equals(IMPLEMENTATIONNAME_QUICKLAUNCHER) ) if( sImplementationName == "com.sun.star.comp.desktop.QuickstartWrapper" )
{ {
m_xQuickLauncher = xListener; m_xQuickLauncher = xListener;
return; return;
} }
if( sImplementationName.equals(IMPLEMENTATIONNAME_SWTHREADMANAGER) ) if( sImplementationName == "com.sun.star.util.comp.FinalThreadManager" )
{ {
m_xSWThreadManager = xListener; m_xSWThreadManager = xListener;
return; return;
@@ -444,25 +434,25 @@ void SAL_CALL Desktop::removeTerminateListener( const css::uno::Reference< css::
// SYCNHRONIZED -> // SYCNHRONIZED ->
WriteGuard aWriteLock( m_aLock ); WriteGuard aWriteLock( m_aLock );
if( sImplementationName.equals(IMPLEMENTATIONNAME_SFXTERMINATOR) ) if( sImplementationName == "com.sun.star.comp.sfx2.SfxTerminateListener" )
{ {
m_xSfxTerminator.clear(); m_xSfxTerminator.clear();
return; return;
} }
if( sImplementationName.equals(IMPLEMENTATIONNAME_PIPETERMINATOR) ) if( sImplementationName == "com.sun.star.comp.OfficeIPCThreadController" )
{ {
m_xPipeTerminator.clear(); m_xPipeTerminator.clear();
return; return;
} }
if( sImplementationName.equals(IMPLEMENTATIONNAME_QUICKLAUNCHER) ) if( sImplementationName == "com.sun.star.comp.desktop.QuickstartWrapper" )
{ {
m_xQuickLauncher.clear(); m_xQuickLauncher.clear();
return; return;
} }
if( sImplementationName.equals(IMPLEMENTATIONNAME_SWTHREADMANAGER) ) if( sImplementationName == "com.sun.star.util.comp.FinalThreadManager" )
{ {
m_xSWThreadManager.clear(); m_xSWThreadManager.clear();
return; return;
@@ -607,13 +597,10 @@ css::uno::Reference< css::lang::XComponent > SAL_CALL Desktop::loadComponentFrom
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
SAL_INFO( "fwk.desktop", "framework (as96863) ::Desktop::loadComponentFromURL" ); SAL_INFO( "fwk.desktop", "framework (as96863) ::Desktop::loadComponentFromURL" );
ReadGuard aReadLock(m_aLock);
css::uno::Reference< css::frame::XComponentLoader > xThis(static_cast< css::frame::XComponentLoader* >(this), css::uno::UNO_QUERY); css::uno::Reference< css::frame::XComponentLoader > xThis(static_cast< css::frame::XComponentLoader* >(this), css::uno::UNO_QUERY);
css::uno::Reference< css::uno::XComponentContext > xContext = m_xContext;
aReadLock.unlock();
SAL_INFO( "fwk.desktop", "PERFORMANCE - Desktop::loadComponentFromURL()" ); SAL_INFO( "fwk.desktop", "PERFORMANCE - Desktop::loadComponentFromURL()" );
return LoadEnv::loadComponentFromURL(xThis, xContext, sURL, sTargetFrameName, nSearchFlags, lArguments); return LoadEnv::loadComponentFromURL(xThis, m_xContext, sURL, sTargetFrameName, nSearchFlags, lArguments);
} }
/*-************************************************************************************************************//** /*-************************************************************************************************************//**
@@ -1001,13 +988,6 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::findFrame( const OUS
// force using of "if() else if() ..." // force using of "if() else if() ..."
//----------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------
// get threadsafe some necessary member which are necessary for following functionality
/* SAFE { */
ReadGuard aReadLock( m_aLock );
css::uno::Reference< css::uno::XComponentContext> xContext = m_xContext;
aReadLock.unlock();
/* } SAFE */
//----------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------
// I.I) "_blank" // I.I) "_blank"
// create a new task as child of this desktop instance // create a new task as child of this desktop instance
@@ -1015,7 +995,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::findFrame( const OUS
//----------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------
if ( sTargetFrameName==SPECIALTARGET_BLANK ) if ( sTargetFrameName==SPECIALTARGET_BLANK )
{ {
TaskCreator aCreator( xContext ); TaskCreator aCreator( m_xContext );
xTarget = aCreator.createTask(sTargetFrameName,sal_False); xTarget = aCreator.createTask(sTargetFrameName,sal_False);
} }
@@ -1051,13 +1031,6 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::findFrame( const OUS
// But note: Such flags are not valid for the desktop - especialy SIBLINGS or PARENT. // But note: Such flags are not valid for the desktop - especialy SIBLINGS or PARENT.
//------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------
// get threadsafe some necessary member which are necessary for following functionality
/* SAFE { */
aReadLock.lock();
OUString sOwnName = m_sName;
aReadLock.unlock();
/* } SAFE */
//------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------
// II.I) SELF // II.I) SELF
// Check for right name. If it's the searched one return ourself - otherwise // Check for right name. If it's the searched one return ourself - otherwise
@@ -1065,7 +1038,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::findFrame( const OUS
//------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------
if ( if (
(nSearchFlags & css::frame::FrameSearchFlag::SELF) && (nSearchFlags & css::frame::FrameSearchFlag::SELF) &&
(sOwnName == sTargetFrameName ) (m_sName == sTargetFrameName)
) )
{ {
xTarget = this; xTarget = this;
@@ -1113,7 +1086,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::findFrame( const OUS
(nSearchFlags & css::frame::FrameSearchFlag::CREATE) (nSearchFlags & css::frame::FrameSearchFlag::CREATE)
) )
{ {
TaskCreator aCreator( xContext ); TaskCreator aCreator( m_xContext );
xTarget = aCreator.createTask(sTargetFrameName,sal_False); xTarget = aCreator.createTask(sTargetFrameName,sal_False);
} }
} }
@@ -1121,8 +1094,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::findFrame( const OUS
return xTarget; return xTarget;
} }
//============================================================================= void SAL_CALL Desktop::disposing()
void SAL_CALL Desktop::dispose()
throw( css::uno::RuntimeException ) throw( css::uno::RuntimeException )
{ {
// Safe impossible cases // Safe impossible cases
@@ -1652,7 +1624,8 @@ css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL Desktop::getPropert
{ {
// Create structure of propertysetinfo for baseclass "OPropertySetHelper". // Create structure of propertysetinfo for baseclass "OPropertySetHelper".
// (Use method "getInfoHelper()".) // (Use method "getInfoHelper()".)
static css::uno::Reference< css::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); static css::uno::Reference< css::beans::XPropertySetInfo > xInfo(
cppu::OPropertySetHelper::createPropertySetInfo( getInfoHelper() ) );
pInfo = &xInfo; pInfo = &xInfo;
} }
} }
@@ -1931,13 +1904,6 @@ void Desktop::impl_sendNotifyTerminationEvent()
return (nNonClosedFrames < 1); return (nNonClosedFrames < 1);
} }
//*****************************************************************************************************************
// We work with valid servicemanager only.
sal_Bool Desktop::implcp_ctor( const css::uno::Reference< css::uno::XComponentContext >& xContext )
{
return !xContext.is();
}
// We work with valid listener only. // We work with valid listener only.
sal_Bool Desktop::implcp_addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) sal_Bool Desktop::implcp_addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener )
{ {
@@ -1952,4 +1918,34 @@ sal_Bool Desktop::implcp_removeEventListener( const css::uno::Reference< css::la
} // namespace framework } // namespace framework
namespace {
struct Instance {
explicit Instance(
css::uno::Reference<css::uno::XComponentContext> const & context):
instance(static_cast<cppu::OWeakObject *>(new framework::Desktop(context)))
{
static_cast<framework::Desktop *>(static_cast<cppu::OWeakObject *>
(instance.get()))->constructorInit();
}
css::uno::Reference<css::uno::XInterface> instance;
};
struct Singleton:
public rtl::StaticWithArg<
Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
{};
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
com_sun_star_comp_framework_Desktop_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
return cppu::acquire(static_cast<cppu::OWeakObject *>(
Singleton::get(context).instance.get()));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -36,7 +36,8 @@
constructor="com_sun_star_comp_framework_ControlMenuController_get_implementation"> constructor="com_sun_star_comp_framework_ControlMenuController_get_implementation">
<service name="com.sun.star.frame.PopupMenuController"/> <service name="com.sun.star.frame.PopupMenuController"/>
</implementation> </implementation>
<implementation name="com.sun.star.comp.framework.Desktop"> <implementation name="com.sun.star.comp.framework.Desktop"
constructor="com_sun_star_comp_framework_Desktop_get_implementation">
<service name="com.sun.star.frame.Desktop"/> <service name="com.sun.star.frame.Desktop"/>
<singleton name="com.sun.star.frame.theDesktop"/> <singleton name="com.sun.star.frame.theDesktop"/>
</implementation> </implementation>

View File

@@ -48,6 +48,7 @@ core_factory_list = [
core_constructor_list = [ core_constructor_list = [
# framework/util/fwk.component # framework/util/fwk.component
"com_sun_star_comp_framework_AutoRecovery_get_implementation", "com_sun_star_comp_framework_AutoRecovery_get_implementation",
"com_sun_star_comp_framework_Desktop_get_implementation",
"com_sun_star_comp_framework_Frame_get_implementation", "com_sun_star_comp_framework_Frame_get_implementation",
"com_sun_star_comp_framework_JobExecutor_get_implementation", "com_sun_star_comp_framework_JobExecutor_get_implementation",
"com_sun_star_comp_framework_LayoutManager_get_implementation", "com_sun_star_comp_framework_LayoutManager_get_implementation",