fwk: Constructor feature for single-instance UIElementFactoryManager.
Change-Id: Iaa6b6bf8f132e2f8efb9ae71e9302e6be19347c9
This commit is contained in:
parent
e9a23fd78c
commit
a64c6c448d
@ -20,37 +20,18 @@
|
|||||||
#ifndef INCLUDED_FRAMEWORK_INC_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX
|
#ifndef INCLUDED_FRAMEWORK_INC_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX
|
||||||
#define INCLUDED_FRAMEWORK_INC_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX
|
#define INCLUDED_FRAMEWORK_INC_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX
|
||||||
|
|
||||||
/** Attention: stl headers must(!) be included at first. Otherwise it can make trouble
|
#include <sal/config.h>
|
||||||
with solaris headers ...
|
|
||||||
*/
|
|
||||||
#include <vector>
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
#include <threadhelp/threadhelpbase.hxx>
|
#include <com/sun/star/beans/PropertyValue.hpp>
|
||||||
#include <macros/generic.hxx>
|
|
||||||
#include <macros/xinterface.hxx>
|
|
||||||
#include <macros/xtypeprovider.hxx>
|
|
||||||
#include <macros/xserviceinfo.hxx>
|
|
||||||
#include <stdtypes.h>
|
|
||||||
|
|
||||||
#include <com/sun/star/lang/XServiceInfo.hpp>
|
|
||||||
#include <com/sun/star/ui/XUIElementFactoryManager.hpp>
|
|
||||||
#include <com/sun/star/container/XContainerListener.hpp>
|
#include <com/sun/star/container/XContainerListener.hpp>
|
||||||
#include <com/sun/star/container/XNameAccess.hpp>
|
#include <com/sun/star/container/XNameAccess.hpp>
|
||||||
#include "com/sun/star/frame/XModuleManager2.hpp"
|
|
||||||
|
|
||||||
#include <cppuhelper/implbase1.hxx>
|
#include <cppuhelper/implbase1.hxx>
|
||||||
#include <cppuhelper/implbase2.hxx>
|
|
||||||
#include <rtl/ustring.hxx>
|
#include <rtl/ustring.hxx>
|
||||||
|
|
||||||
namespace framework
|
namespace framework {
|
||||||
{
|
|
||||||
|
|
||||||
class ConfigurationAccess_FactoryManager : // interfaces
|
class ConfigurationAccess_FactoryManager : public ::cppu::WeakImplHelper1< ::com::sun::star::container::XContainerListener>
|
||||||
// baseclasses
|
|
||||||
// Order is necessary for right initialization!
|
|
||||||
private ThreadHelpBase ,
|
|
||||||
public ::cppu::WeakImplHelper1< ::com::sun::star::container::XContainerListener>
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConfigurationAccess_FactoryManager( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& rxContext, const OUString& _sRoot );
|
ConfigurationAccess_FactoryManager( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& rxContext, const OUString& _sRoot );
|
||||||
@ -85,6 +66,7 @@ namespace framework
|
|||||||
|
|
||||||
sal_Bool impl_getElementProps( const ::com::sun::star::uno::Any& rElement, OUString& rType, OUString& rName, OUString& rModule, OUString& rServiceSpecifier ) const;
|
sal_Bool impl_getElementProps( const ::com::sun::star::uno::Any& rElement, OUString& rType, OUString& rName, OUString& rModule, OUString& rServiceSpecifier ) const;
|
||||||
|
|
||||||
|
mutable osl::Mutex m_aMutex;
|
||||||
OUString m_aPropType;
|
OUString m_aPropType;
|
||||||
OUString m_aPropName;
|
OUString m_aPropName;
|
||||||
OUString m_aPropModule;
|
OUString m_aPropModule;
|
||||||
@ -97,35 +79,6 @@ namespace framework
|
|||||||
sal_Bool m_bConfigAccessInitialized;
|
sal_Bool m_bConfigAccessInitialized;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class UIElementFactoryManager : private 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::XUIElementFactoryManager>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
UIElementFactoryManager( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
|
|
||||||
virtual ~UIElementFactoryManager();
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
// XUIElementFactoryRegistration
|
|
||||||
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > SAL_CALL getRegisteredFactories( ) throw (::com::sun::star::uno::RuntimeException);
|
|
||||||
virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElementFactory > SAL_CALL getFactory( const OUString& ResourceURL, const OUString& ModuleIdentifier ) throw (::com::sun::star::uno::RuntimeException);
|
|
||||||
virtual void SAL_CALL registerFactory( const OUString& aType, const OUString& aName, const OUString& aModuleIdentifier, const OUString& aFactoryImplementationName ) throw (::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
|
|
||||||
virtual void SAL_CALL deregisterFactory( const OUString& aType, const OUString& aName, const OUString& aModuleIdentifier ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
sal_Bool m_bConfigRead;
|
|
||||||
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
|
|
||||||
::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 > m_xModuleManager;
|
|
||||||
ConfigurationAccess_FactoryManager* m_pConfigAccess;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace framework
|
} // namespace framework
|
||||||
|
|
||||||
#endif // INCLUDED_FRAMEWORK_INC_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX
|
#endif // INCLUDED_FRAMEWORK_INC_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX
|
@ -34,7 +34,6 @@
|
|||||||
)
|
)
|
||||||
=================================================================================================================*/
|
=================================================================================================================*/
|
||||||
#include <services/desktop.hxx>
|
#include <services/desktop.hxx>
|
||||||
#include <uifactory/uielementfactorymanager.hxx>
|
|
||||||
#include <uiconfiguration/moduleuicfgsupplier.hxx>
|
#include <uiconfiguration/moduleuicfgsupplier.hxx>
|
||||||
#include <uifactory/menubarfactory.hxx>
|
#include <uifactory/menubarfactory.hxx>
|
||||||
#include <uifactory/toolboxfactory.hxx>
|
#include <uifactory/toolboxfactory.hxx>
|
||||||
@ -49,7 +48,6 @@
|
|||||||
|
|
||||||
COMPONENTGETFACTORY ( fwk,
|
COMPONENTGETFACTORY ( fwk,
|
||||||
IFFACTORY( ::framework::Desktop ) else
|
IFFACTORY( ::framework::Desktop ) else
|
||||||
IFFACTORY( ::framework::UIElementFactoryManager ) else
|
|
||||||
IFFACTORY( ::framework::ModuleUIConfigurationManagerSupplier ) else
|
IFFACTORY( ::framework::ModuleUIConfigurationManagerSupplier ) else
|
||||||
IFFACTORY( ::framework::MenuBarFactory ) else
|
IFFACTORY( ::framework::MenuBarFactory ) else
|
||||||
IFFACTORY( ::framework::ToolBoxFactory ) else
|
IFFACTORY( ::framework::ToolBoxFactory ) else
|
||||||
|
@ -17,30 +17,28 @@
|
|||||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <uifactory/uielementfactorymanager.hxx>
|
#include <sal/config.h>
|
||||||
#include <uifactory/windowcontentfactorymanager.hxx>
|
|
||||||
#include <threadhelp/resetableguard.hxx>
|
|
||||||
#include "services.h"
|
|
||||||
|
|
||||||
#include "helper/mischelper.hxx"
|
#include <uifactory/windowcontentfactorymanager.hxx>
|
||||||
|
#include <uifactory/configurationaccessfactorymanager.hxx>
|
||||||
|
#include <helper/mischelper.hxx>
|
||||||
|
|
||||||
#include <com/sun/star/beans/PropertyValue.hpp>
|
#include <com/sun/star/beans/PropertyValue.hpp>
|
||||||
#include <com/sun/star/beans/XPropertySet.hpp>
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
||||||
#include <com/sun/star/configuration/theDefaultProvider.hpp>
|
#include <com/sun/star/configuration/theDefaultProvider.hpp>
|
||||||
#include <com/sun/star/container/XNameAccess.hpp>
|
|
||||||
#include <com/sun/star/container/XNameContainer.hpp>
|
|
||||||
#include <com/sun/star/container/XContainer.hpp>
|
#include <com/sun/star/container/XContainer.hpp>
|
||||||
|
#include <com/sun/star/container/XContainerListener.hpp>
|
||||||
|
#include <com/sun/star/lang/XServiceInfo.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/XModuleManager2.hpp>
|
||||||
|
#include <com/sun/star/ui/XUIElementFactoryManager.hpp>
|
||||||
|
|
||||||
#include <rtl/ustrbuf.hxx>
|
#include <rtl/ustrbuf.hxx>
|
||||||
#include <cppuhelper/weak.hxx>
|
#include <cppuhelper/compbase2.hxx>
|
||||||
|
#include <cppuhelper/supportsservice.hxx>
|
||||||
#include <vcl/svapp.hxx>
|
#include <vcl/svapp.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::beans;
|
using namespace com::sun::star::beans;
|
||||||
@ -49,16 +47,13 @@ using namespace com::sun::star::configuration;
|
|||||||
using namespace com::sun::star::container;
|
using namespace com::sun::star::container;
|
||||||
using namespace ::com::sun::star::ui;
|
using namespace ::com::sun::star::ui;
|
||||||
using namespace ::com::sun::star::frame;
|
using namespace ::com::sun::star::frame;
|
||||||
|
using namespace framework;
|
||||||
//_________________________________________________________________________________________________________________
|
|
||||||
// Namespace
|
|
||||||
//_________________________________________________________________________________________________________________
|
|
||||||
|
|
||||||
namespace framework
|
namespace framework
|
||||||
{
|
{
|
||||||
|
|
||||||
// global function needed by both implementations
|
// global function needed by both implementations
|
||||||
OUString getHashKeyFromStrings( const OUString& aType, const OUString& aName, const OUString& aModuleName )
|
static OUString getHashKeyFromStrings( const OUString& aType, const OUString& aName, const OUString& aModuleName )
|
||||||
{
|
{
|
||||||
OUStringBuffer aKey( aType );
|
OUStringBuffer aKey( aType );
|
||||||
aKey.appendAscii( "^" );
|
aKey.appendAscii( "^" );
|
||||||
@ -69,13 +64,7 @@ OUString getHashKeyFromStrings( const OUString& aType, const OUString& aName, co
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//*****************************************************************************************************************
|
|
||||||
// Configuration access class for UIElementFactoryManager implementation
|
|
||||||
//*****************************************************************************************************************
|
|
||||||
|
|
||||||
|
|
||||||
ConfigurationAccess_FactoryManager::ConfigurationAccess_FactoryManager( const Reference< XComponentContext >& rxContext, const OUString& _sRoot ) :
|
ConfigurationAccess_FactoryManager::ConfigurationAccess_FactoryManager( const Reference< XComponentContext >& rxContext, const OUString& _sRoot ) :
|
||||||
ThreadHelpBase(),
|
|
||||||
m_aPropType( "Type" ),
|
m_aPropType( "Type" ),
|
||||||
m_aPropName( "Name" ),
|
m_aPropName( "Name" ),
|
||||||
m_aPropModule( "Module" ),
|
m_aPropModule( "Module" ),
|
||||||
@ -89,7 +78,7 @@ ConfigurationAccess_FactoryManager::ConfigurationAccess_FactoryManager( const Re
|
|||||||
ConfigurationAccess_FactoryManager::~ConfigurationAccess_FactoryManager()
|
ConfigurationAccess_FactoryManager::~ConfigurationAccess_FactoryManager()
|
||||||
{
|
{
|
||||||
// SAFE
|
// SAFE
|
||||||
ResetableGuard aLock( m_aLock );
|
osl::MutexGuard g(m_aMutex);
|
||||||
|
|
||||||
Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY );
|
Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY );
|
||||||
if ( xContainer.is() )
|
if ( xContainer.is() )
|
||||||
@ -99,7 +88,7 @@ ConfigurationAccess_FactoryManager::~ConfigurationAccess_FactoryManager()
|
|||||||
OUString ConfigurationAccess_FactoryManager::getFactorySpecifierFromTypeNameModule( const OUString& rType, const OUString& rName, const OUString& rModule ) const
|
OUString ConfigurationAccess_FactoryManager::getFactorySpecifierFromTypeNameModule( const OUString& rType, const OUString& rName, const OUString& rModule ) const
|
||||||
{
|
{
|
||||||
// SAFE
|
// SAFE
|
||||||
ResetableGuard aLock( m_aLock );
|
osl::MutexGuard g(m_aMutex);
|
||||||
|
|
||||||
FactoryManagerMap::const_iterator pIter =
|
FactoryManagerMap::const_iterator pIter =
|
||||||
m_aFactoryManagerMap.find( getHashKeyFromStrings( rType, rName, rModule ));
|
m_aFactoryManagerMap.find( getHashKeyFromStrings( rType, rName, rModule ));
|
||||||
@ -134,7 +123,7 @@ OUString ConfigurationAccess_FactoryManager::getFactorySpecifierFromTypeNameModu
|
|||||||
void ConfigurationAccess_FactoryManager::addFactorySpecifierToTypeNameModule( const OUString& rType, const OUString& rName, const OUString& rModule, const OUString& rServiceSpecifier )
|
void ConfigurationAccess_FactoryManager::addFactorySpecifierToTypeNameModule( const OUString& rType, const OUString& rName, const OUString& rModule, const OUString& rServiceSpecifier )
|
||||||
{
|
{
|
||||||
// SAFE
|
// SAFE
|
||||||
ResetableGuard aLock( m_aLock );
|
osl::MutexGuard g(m_aMutex);
|
||||||
|
|
||||||
OUString aHashKey = getHashKeyFromStrings( rType, rName, rModule );
|
OUString aHashKey = getHashKeyFromStrings( rType, rName, rModule );
|
||||||
|
|
||||||
@ -150,7 +139,7 @@ void ConfigurationAccess_FactoryManager::addFactorySpecifierToTypeNameModule( co
|
|||||||
void ConfigurationAccess_FactoryManager::removeFactorySpecifierFromTypeNameModule( const OUString& rType, const OUString& rName, const OUString& rModule )
|
void ConfigurationAccess_FactoryManager::removeFactorySpecifierFromTypeNameModule( const OUString& rType, const OUString& rName, const OUString& rModule )
|
||||||
{
|
{
|
||||||
// SAFE
|
// SAFE
|
||||||
ResetableGuard aLock( m_aLock );
|
osl::MutexGuard g(m_aMutex);
|
||||||
|
|
||||||
OUString aHashKey = getHashKeyFromStrings( rType, rName, rModule );
|
OUString aHashKey = getHashKeyFromStrings( rType, rName, rModule );
|
||||||
|
|
||||||
@ -165,7 +154,7 @@ void ConfigurationAccess_FactoryManager::removeFactorySpecifierFromTypeNameModul
|
|||||||
Sequence< Sequence< PropertyValue > > ConfigurationAccess_FactoryManager::getFactoriesDescription() const
|
Sequence< Sequence< PropertyValue > > ConfigurationAccess_FactoryManager::getFactoriesDescription() const
|
||||||
{
|
{
|
||||||
// SAFE
|
// SAFE
|
||||||
ResetableGuard aLock( m_aLock );
|
osl::MutexGuard g(m_aMutex);
|
||||||
|
|
||||||
Sequence< Sequence< PropertyValue > > aSeqSeq;
|
Sequence< Sequence< PropertyValue > > aSeqSeq;
|
||||||
|
|
||||||
@ -213,7 +202,7 @@ void SAL_CALL ConfigurationAccess_FactoryManager::elementInserted( const Contain
|
|||||||
OUString aService;
|
OUString aService;
|
||||||
|
|
||||||
// SAFE
|
// SAFE
|
||||||
ResetableGuard aLock( m_aLock );
|
osl::MutexGuard g(m_aMutex);
|
||||||
|
|
||||||
if ( impl_getElementProps( aEvent.Element, aType, aName, aModule, aService ))
|
if ( impl_getElementProps( aEvent.Element, aType, aName, aModule, aService ))
|
||||||
{
|
{
|
||||||
@ -232,7 +221,7 @@ void SAL_CALL ConfigurationAccess_FactoryManager::elementRemoved ( const Contain
|
|||||||
OUString aService;
|
OUString aService;
|
||||||
|
|
||||||
// SAFE
|
// SAFE
|
||||||
ResetableGuard aLock( m_aLock );
|
osl::MutexGuard g(m_aMutex);
|
||||||
|
|
||||||
if ( impl_getElementProps( aEvent.Element, aType, aName, aModule, aService ))
|
if ( impl_getElementProps( aEvent.Element, aType, aName, aModule, aService ))
|
||||||
{
|
{
|
||||||
@ -251,7 +240,7 @@ void SAL_CALL ConfigurationAccess_FactoryManager::elementReplaced( const Contain
|
|||||||
OUString aService;
|
OUString aService;
|
||||||
|
|
||||||
// SAFE
|
// SAFE
|
||||||
ResetableGuard aLock( m_aLock );
|
osl::MutexGuard g(m_aMutex);
|
||||||
|
|
||||||
if ( impl_getElementProps( aEvent.Element, aType, aName, aModule, aService ))
|
if ( impl_getElementProps( aEvent.Element, aType, aName, aModule, aService ))
|
||||||
{
|
{
|
||||||
@ -268,14 +257,14 @@ void SAL_CALL ConfigurationAccess_FactoryManager::disposing( const EventObject&
|
|||||||
{
|
{
|
||||||
// SAFE
|
// SAFE
|
||||||
// remove our reference to the config access
|
// remove our reference to the config access
|
||||||
ResetableGuard aLock( m_aLock );
|
osl::MutexGuard g(m_aMutex);
|
||||||
m_xConfigAccess.clear();
|
m_xConfigAccess.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigurationAccess_FactoryManager::readConfigurationData()
|
void ConfigurationAccess_FactoryManager::readConfigurationData()
|
||||||
{
|
{
|
||||||
// SAFE
|
// SAFE
|
||||||
ResetableGuard aLock( m_aLock );
|
osl::MutexGuard g(m_aMutex);
|
||||||
|
|
||||||
if ( !m_bConfigAccessInitialized )
|
if ( !m_bConfigAccessInitialized )
|
||||||
{
|
{
|
||||||
@ -288,7 +277,8 @@ void ConfigurationAccess_FactoryManager::readConfigurationData()
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_xConfigAccess.set( m_xConfigProvider->createInstanceWithArguments(SERVICENAME_CFGREADACCESS,aArgs ), UNO_QUERY );
|
m_xConfigAccess.set( m_xConfigProvider->createInstanceWithArguments(
|
||||||
|
"com.sun.star.configuration.ConfigurationAccess", aArgs ), UNO_QUERY );
|
||||||
}
|
}
|
||||||
catch ( const WrappedTargetException& )
|
catch ( const WrappedTargetException& )
|
||||||
{
|
{
|
||||||
@ -319,8 +309,6 @@ void ConfigurationAccess_FactoryManager::readConfigurationData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY );
|
Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY );
|
||||||
aLock.unlock();
|
|
||||||
// UNSAFE
|
|
||||||
if ( xContainer.is() )
|
if ( xContainer.is() )
|
||||||
{
|
{
|
||||||
m_xConfigListener = new WeakContainerListener(this);
|
m_xConfigListener = new WeakContainerListener(this);
|
||||||
@ -356,33 +344,81 @@ sal_Bool ConfigurationAccess_FactoryManager::impl_getElementProps( const Any& aE
|
|||||||
return sal_True;
|
return sal_True;
|
||||||
}
|
}
|
||||||
|
|
||||||
//*****************************************************************************************************************
|
} // framework
|
||||||
// XInterface, XTypeProvider, XServiceInfo
|
|
||||||
//*****************************************************************************************************************
|
|
||||||
DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2 ( UIElementFactoryManager ,
|
|
||||||
::cppu::OWeakObject ,
|
|
||||||
"com.sun.star.ui.UIElementFactoryManager",
|
|
||||||
IMPLEMENTATIONNAME_UIELEMENTFACTORYMANAGER
|
|
||||||
)
|
|
||||||
|
|
||||||
DEFINE_INIT_SERVICE ( UIElementFactoryManager, {} )
|
namespace {
|
||||||
|
|
||||||
|
typedef ::cppu::WeakComponentImplHelper2<
|
||||||
|
css::lang::XServiceInfo,
|
||||||
|
css::ui::XUIElementFactoryManager> UIElementFactoryManager_BASE;
|
||||||
|
|
||||||
|
class UIElementFactoryManager : private osl::Mutex,
|
||||||
|
public UIElementFactoryManager_BASE
|
||||||
|
{
|
||||||
|
virtual void SAL_CALL disposing() SAL_OVERRIDE;
|
||||||
|
public:
|
||||||
|
UIElementFactoryManager( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
|
||||||
|
virtual ~UIElementFactoryManager();
|
||||||
|
|
||||||
|
virtual OUString SAL_CALL getImplementationName()
|
||||||
|
throw (css::uno::RuntimeException)
|
||||||
|
{
|
||||||
|
return OUString("com.sun.star.comp.framework.UIElementFactoryManager");
|
||||||
|
}
|
||||||
|
|
||||||
|
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.UIElementFactoryManager");
|
||||||
|
return aSeq;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
// XUIElementFactoryRegistration
|
||||||
|
virtual css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > SAL_CALL getRegisteredFactories( ) throw (css::uno::RuntimeException);
|
||||||
|
virtual css::uno::Reference< css::ui::XUIElementFactory > SAL_CALL getFactory( const OUString& ResourceURL, const OUString& ModuleIdentifier ) throw (css::uno::RuntimeException);
|
||||||
|
virtual void SAL_CALL registerFactory( const OUString& aType, const OUString& aName, const OUString& aModuleIdentifier, const OUString& aFactoryImplementationName ) throw (css::container::ElementExistException, css::uno::RuntimeException);
|
||||||
|
virtual void SAL_CALL deregisterFactory( const OUString& aType, const OUString& aName, const OUString& aModuleIdentifier ) throw (css::container::NoSuchElementException, css::uno::RuntimeException);
|
||||||
|
|
||||||
|
private:
|
||||||
|
sal_Bool m_bConfigRead;
|
||||||
|
css::uno::Reference< css::uno::XComponentContext > m_xContext;
|
||||||
|
ConfigurationAccess_FactoryManager* m_pConfigAccess;
|
||||||
|
};
|
||||||
|
|
||||||
UIElementFactoryManager::UIElementFactoryManager( const Reference< XComponentContext >& rxContext ) :
|
UIElementFactoryManager::UIElementFactoryManager( const Reference< XComponentContext >& rxContext ) :
|
||||||
ThreadHelpBase( &Application::GetSolarMutex() ),
|
UIElementFactoryManager_BASE(*static_cast<osl::Mutex *>(this)),
|
||||||
m_bConfigRead( sal_False ),
|
m_bConfigRead( sal_False ),
|
||||||
m_xContext(rxContext)
|
m_xContext(rxContext)
|
||||||
{
|
{
|
||||||
m_pConfigAccess = new ConfigurationAccess_FactoryManager( rxContext, OUString( "/org.openoffice.Office.UI.Factories/Registered/UIElementFactories" ) );
|
m_pConfigAccess = new ConfigurationAccess_FactoryManager(rxContext,
|
||||||
|
"/org.openoffice.Office.UI.Factories/Registered/UIElementFactories");
|
||||||
m_pConfigAccess->acquire();
|
m_pConfigAccess->acquire();
|
||||||
m_xModuleManager = ModuleManager::create( rxContext );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UIElementFactoryManager::~UIElementFactoryManager()
|
UIElementFactoryManager::~UIElementFactoryManager()
|
||||||
{
|
{
|
||||||
ResetableGuard aLock( m_aLock );
|
disposing();
|
||||||
|
}
|
||||||
|
|
||||||
// reduce reference count
|
void SAL_CALL UIElementFactoryManager::disposing()
|
||||||
m_pConfigAccess->release();
|
{
|
||||||
|
osl::MutexGuard g(rBHelper.rMutex);
|
||||||
|
if (m_pConfigAccess)
|
||||||
|
{
|
||||||
|
// reduce reference count
|
||||||
|
m_pConfigAccess->release();
|
||||||
|
m_pConfigAccess = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// XUIElementFactory
|
// XUIElementFactory
|
||||||
@ -391,8 +427,9 @@ Reference< XUIElement > SAL_CALL UIElementFactoryManager::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 )
|
||||||
{
|
{
|
||||||
// SAFE
|
Reference< XFrame > xFrame;
|
||||||
ResetableGuard aLock( m_aLock );
|
{ // SAFE
|
||||||
|
osl::MutexGuard g(rBHelper.rMutex);
|
||||||
|
|
||||||
if ( !m_bConfigRead )
|
if ( !m_bConfigRead )
|
||||||
{
|
{
|
||||||
@ -400,27 +437,22 @@ throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::l
|
|||||||
m_pConfigAccess->readConfigurationData();
|
m_pConfigAccess->readConfigurationData();
|
||||||
}
|
}
|
||||||
|
|
||||||
const OUString aPropFrame( "Frame" );
|
|
||||||
|
|
||||||
OUString aModuleId;
|
|
||||||
PropertyValue aPropValue;
|
|
||||||
Reference< XFrame > xFrame;
|
|
||||||
|
|
||||||
// Retrieve the frame instance from the arguments to determine the module identifier. This must be provided
|
// Retrieve the frame instance from the arguments to determine the module identifier. This must be provided
|
||||||
// to the search function. An empty module identifier is provided if the frame is missing or the module id cannot
|
// to the search function. An empty module identifier is provided if the frame is missing or the module id cannot
|
||||||
// retrieve from it.
|
// retrieve from it.
|
||||||
for ( int i = 0; i < Args.getLength(); i++ )
|
for ( int i = 0; i < Args.getLength(); i++ )
|
||||||
{
|
{
|
||||||
if ( Args[i].Name.equals( aPropFrame ))
|
if ( Args[i].Name == "Frame")
|
||||||
Args[i].Value >>= xFrame;
|
Args[i].Value >>= xFrame;
|
||||||
}
|
}
|
||||||
|
} // SAFE
|
||||||
|
|
||||||
Reference< XModuleManager2 > xManager( m_xModuleManager );
|
Reference< XModuleManager2 > xManager = ModuleManager::create( m_xContext );
|
||||||
aLock.unlock();
|
|
||||||
|
|
||||||
// Determine the module identifier
|
// Determine the module identifier
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
OUString aModuleId;
|
||||||
if ( xFrame.is() && xManager.is() )
|
if ( xFrame.is() && xManager.is() )
|
||||||
aModuleId = xManager->identify( xFrame );
|
aModuleId = xManager->identify( xFrame );
|
||||||
|
|
||||||
@ -440,7 +472,7 @@ Sequence< Sequence< PropertyValue > > SAL_CALL UIElementFactoryManager::getRegis
|
|||||||
throw ( RuntimeException )
|
throw ( RuntimeException )
|
||||||
{
|
{
|
||||||
// SAFE
|
// SAFE
|
||||||
ResetableGuard aLock( m_aLock );
|
osl::MutexGuard g(rBHelper.rMutex);
|
||||||
|
|
||||||
if ( !m_bConfigRead )
|
if ( !m_bConfigRead )
|
||||||
{
|
{
|
||||||
@ -454,7 +486,9 @@ throw ( RuntimeException )
|
|||||||
Reference< XUIElementFactory > SAL_CALL UIElementFactoryManager::getFactory( const OUString& aResourceURL, const OUString& aModuleId )
|
Reference< XUIElementFactory > SAL_CALL UIElementFactoryManager::getFactory( const OUString& aResourceURL, const OUString& aModuleId )
|
||||||
throw ( RuntimeException )
|
throw ( RuntimeException )
|
||||||
{
|
{
|
||||||
ResetableGuard aLock( m_aLock );
|
OUString aServiceSpecifier;
|
||||||
|
{ // SAFE
|
||||||
|
osl::MutexGuard g(rBHelper.rMutex);
|
||||||
|
|
||||||
if ( !m_bConfigRead )
|
if ( !m_bConfigRead )
|
||||||
{
|
{
|
||||||
@ -467,13 +501,11 @@ throw ( RuntimeException )
|
|||||||
|
|
||||||
WindowContentFactoryManager::RetrieveTypeNameFromResourceURL( aResourceURL, aType, aName );
|
WindowContentFactoryManager::RetrieveTypeNameFromResourceURL( aResourceURL, aType, aName );
|
||||||
|
|
||||||
Reference< XComponentContext > xContext( m_xContext );
|
aServiceSpecifier = m_pConfigAccess->getFactorySpecifierFromTypeNameModule( aType, aName, aModuleId );
|
||||||
|
} // SAFE
|
||||||
|
|
||||||
OUString aServiceSpecifier = m_pConfigAccess->getFactorySpecifierFromTypeNameModule( aType, aName, aModuleId );
|
|
||||||
|
|
||||||
aLock.unlock();
|
|
||||||
if ( !aServiceSpecifier.isEmpty() )
|
if ( !aServiceSpecifier.isEmpty() )
|
||||||
return Reference< XUIElementFactory >( xContext->getServiceManager()->createInstanceWithContext(aServiceSpecifier, xContext), UNO_QUERY );
|
return Reference< XUIElementFactory >( m_xContext->getServiceManager()->createInstanceWithContext(aServiceSpecifier, m_xContext), UNO_QUERY );
|
||||||
else
|
else
|
||||||
return Reference< XUIElementFactory >();
|
return Reference< XUIElementFactory >();
|
||||||
}
|
}
|
||||||
@ -482,7 +514,7 @@ void SAL_CALL UIElementFactoryManager::registerFactory( const OUString& aType, c
|
|||||||
throw ( ElementExistException, RuntimeException )
|
throw ( ElementExistException, RuntimeException )
|
||||||
{
|
{
|
||||||
// SAFE
|
// SAFE
|
||||||
ResetableGuard aLock( m_aLock );
|
osl::MutexGuard g(rBHelper.rMutex);
|
||||||
|
|
||||||
if ( !m_bConfigRead )
|
if ( !m_bConfigRead )
|
||||||
{
|
{
|
||||||
@ -498,7 +530,7 @@ void SAL_CALL UIElementFactoryManager::deregisterFactory( const OUString& aType,
|
|||||||
throw ( NoSuchElementException, RuntimeException )
|
throw ( NoSuchElementException, RuntimeException )
|
||||||
{
|
{
|
||||||
// SAFE
|
// SAFE
|
||||||
ResetableGuard aLock( m_aLock );
|
osl::MutexGuard g(rBHelper.rMutex);
|
||||||
|
|
||||||
if ( !m_bConfigRead )
|
if ( !m_bConfigRead )
|
||||||
{
|
{
|
||||||
@ -510,6 +542,31 @@ throw ( NoSuchElementException, RuntimeException )
|
|||||||
// SAFE
|
// SAFE
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace framework
|
struct Instance {
|
||||||
|
explicit Instance(
|
||||||
|
css::uno::Reference<css::uno::XComponentContext> const & context):
|
||||||
|
instance(static_cast<cppu::OWeakObject *>(
|
||||||
|
new UIElementFactoryManager(context)))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
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_UIElementFactoryManager_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: */
|
||||||
|
@ -18,7 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <uifactory/windowcontentfactorymanager.hxx>
|
#include <uifactory/windowcontentfactorymanager.hxx>
|
||||||
#include <uifactory/uielementfactorymanager.hxx>
|
|
||||||
|
#include <uifactory/configurationaccessfactorymanager.hxx>
|
||||||
#include <threadhelp/resetableguard.hxx>
|
#include <threadhelp/resetableguard.hxx>
|
||||||
#include "services.h"
|
#include "services.h"
|
||||||
|
|
||||||
@ -29,8 +30,9 @@
|
|||||||
#include <com/sun/star/container/XContainer.hpp>
|
#include <com/sun/star/container/XContainer.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/awt/XControlModel.hpp>
|
#include <com/sun/star/frame/XModuleManager2.hpp>
|
||||||
#include <com/sun/star/awt/XControl.hpp>
|
#include <com/sun/star/lang/XServiceInfo.hpp>
|
||||||
|
#include <com/sun/star/uno/XComponentContext.hpp>
|
||||||
|
|
||||||
#include <rtl/ustrbuf.hxx>
|
#include <rtl/ustrbuf.hxx>
|
||||||
#include <cppuhelper/weak.hxx>
|
#include <cppuhelper/weak.hxx>
|
||||||
|
@ -145,7 +145,8 @@
|
|||||||
constructor="com_sun_star_comp_framework_UIConfigurationManager_get_implementation">
|
constructor="com_sun_star_comp_framework_UIConfigurationManager_get_implementation">
|
||||||
<service name="com.sun.star.ui.UIConfigurationManager"/>
|
<service name="com.sun.star.ui.UIConfigurationManager"/>
|
||||||
</implementation>
|
</implementation>
|
||||||
<implementation name="com.sun.star.comp.framework.UIElementFactoryManager">
|
<implementation name="com.sun.star.comp.framework.UIElementFactoryManager"
|
||||||
|
constructor="com_sun_star_comp_framework_UIElementFactoryManager_get_implementation">
|
||||||
<service name="com.sun.star.ui.UIElementFactoryManager"/>
|
<service name="com.sun.star.ui.UIElementFactoryManager"/>
|
||||||
<singleton name="com.sun.star.ui.theUIElementFactoryManager"/>
|
<singleton name="com.sun.star.ui.theUIElementFactoryManager"/>
|
||||||
</implementation>
|
</implementation>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user