diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-01-09 17:18:57 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-01-28 18:52:22 +0100 |
commit | b2c89e7236d71d92a96430db0a7eca14b41c227a (patch) | |
tree | 632a5874b1213649771af1ac2333442885fdd83c /framework | |
parent | 54f606c666c6d9e642090074d9d2aa4b6a3bec22 (diff) |
fwk: Constructor feature for one instance UICategoryDescription.
Change-Id: I56c906c9eeafb625dee65eec9fe39ea3aee66251
Diffstat (limited to 'framework')
-rw-r--r-- | framework/inc/uiconfiguration/uicategorydescription.hxx | 58 | ||||
-rw-r--r-- | framework/source/register/registerservices.cxx | 2 | ||||
-rw-r--r-- | framework/source/uiconfiguration/uicategorydescription.cxx | 101 | ||||
-rw-r--r-- | framework/util/fwk.component | 3 |
4 files changed, 68 insertions, 96 deletions
diff --git a/framework/inc/uiconfiguration/uicategorydescription.hxx b/framework/inc/uiconfiguration/uicategorydescription.hxx deleted file mode 100644 index e3b9d6a8519a..000000000000 --- a/framework/inc/uiconfiguration/uicategorydescription.hxx +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- 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_UICONFIGURATION_UICATEGORYDESCRIPTION_HXX -#define INCLUDED_FRAMEWORK_INC_UICONFIGURATION_UICATEGORYDESCRIPTION_HXX - -/** Attention: stl headers must(!) be included at first. Otherwise it can make trouble - with solaris headers ... -*/ -#include <vector> -#include <list> -#include <boost/unordered_map.hpp> - -#include <threadhelp/threadhelpbase.hxx> -#include <macros/generic.hxx> -#include <macros/xserviceinfo.hxx> -#include <uielement/uicommanddescription.hxx> -#include <stdtypes.h> - -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XTypeProvider.hpp> -#include <com/sun/star/container/XNameAccess.hpp> -#include <com/sun/star/frame/XModuleManager.hpp> - -namespace framework -{ -class UICategoryDescription : public UICommandDescription -{ - public: - UICategoryDescription( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ); - virtual ~UICategoryDescription(); - - DECLARE_XSERVICEINFO - private: - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > impl_createConfigAccess(const OUString& _sName); -}; - -} // namespace framework - -#endif // __FRAMEWORK_SERVICES_UICOMMANDCATEGORY_HXX_ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/source/register/registerservices.cxx b/framework/source/register/registerservices.cxx index a6e0fee39582..3fe64816fa06 100644 --- a/framework/source/register/registerservices.cxx +++ b/framework/source/register/registerservices.cxx @@ -42,7 +42,6 @@ #include <uifactory/toolboxfactory.hxx> #include "uiconfiguration/windowstateconfiguration.hxx" #include <uifactory/statusbarfactory.hxx> -#include <uiconfiguration/uicategorydescription.hxx> #include <services/sessionlistener.hxx> #include <services/taskcreatorsrv.hxx> @@ -61,7 +60,6 @@ COMPONENTGETFACTORY ( fwk, IFFACTORY( ::framework::WindowStateConfiguration ) else IFFACTORY( ::framework::ToolbarControllerFactory ) else IFFACTORY( ::framework::StatusBarFactory ) else - IFFACTORY( ::framework::UICategoryDescription ) else IFFACTORY( ::framework::SessionListener ) else IFFACTORY( ::framework::StatusbarControllerFactory ) else IFFACTORY( ::framework::SessionListener ) else diff --git a/framework/source/uiconfiguration/uicategorydescription.cxx b/framework/source/uiconfiguration/uicategorydescription.cxx index d93cfe2c28b0..43ee09b4bfcb 100644 --- a/framework/source/uiconfiguration/uicategorydescription.cxx +++ b/framework/source/uiconfiguration/uicategorydescription.cxx @@ -17,9 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "uiconfiguration/uicategorydescription.hxx" -#include <threadhelp/resetableguard.hxx> -#include "services.h" +#include <uielement/uicommanddescription.hxx> #include "properties.h" @@ -31,17 +29,17 @@ #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/lang/XServiceInfo.hpp> #include <rtl/ustrbuf.hxx> #include <cppuhelper/implbase2.hxx> +#include <cppuhelper/supportsservice.hxx> #include <unotools/configmgr.hxx> #include <vcl/mnemonic.hxx> #include <comphelper/sequence.hxx> -//_________________________________________________________________________________________________________________ -// Defines -//_________________________________________________________________________________________________________________ +#include <boost/unordered_map.hpp> using namespace com::sun::star::uno; using namespace com::sun::star::lang; @@ -49,10 +47,9 @@ using namespace com::sun::star::beans; using namespace com::sun::star::configuration; using namespace com::sun::star::container; using namespace ::com::sun::star::frame; +using namespace framework; -//_________________________________________________________________________________________________________________ -// Namespace -//_________________________________________________________________________________________________________________ +namespace { struct ModuleToCategory { @@ -65,17 +62,9 @@ static const char CONFIGURATION_ROOT_ACCESS[] = "/org.openoffice.O static const char CONFIGURATION_CATEGORY_ELEMENT_ACCESS[] = "/Commands/Categories"; static const char CONFIGURATION_PROPERTY_NAME[] = "Name"; -namespace framework -{ - -//***************************************************************************************************************** -// Configuration access class for PopupMenuControllerFactory implementation -//***************************************************************************************************************** - -class ConfigurationAccess_UICategory : // Order is necessary for right initialization! - private ThreadHelpBase , - public ::cppu::WeakImplHelper2<XNameAccess,XContainerListener> +class ConfigurationAccess_UICategory : public ::cppu::WeakImplHelper2<XNameAccess,XContainerListener> { + osl::Mutex aMutex; public: ConfigurationAccess_UICategory( const OUString& aModuleName, const Reference< XNameAccess >& xGenericUICommands, const Reference< XComponentContext >& rxContext ); virtual ~ConfigurationAccess_UICategory(); @@ -135,7 +124,6 @@ class ConfigurationAccess_UICategory : // Order is necessary for right initializ //***************************************************************************************************************** ConfigurationAccess_UICategory::ConfigurationAccess_UICategory( const OUString& aModuleName, const Reference< XNameAccess >& rGenericUICategories, const Reference< XComponentContext >& rxContext ) : - ThreadHelpBase(), m_aConfigCategoryAccess( CONFIGURATION_ROOT_ACCESS ), m_aPropUIName( CONFIGURATION_PROPERTY_NAME ), m_xGenericUICategories( rGenericUICategories ), @@ -152,7 +140,7 @@ ConfigurationAccess_UICategory::ConfigurationAccess_UICategory( const OUString& ConfigurationAccess_UICategory::~ConfigurationAccess_UICategory() { // SAFE - ResetableGuard aLock( m_aLock ); + osl::MutexGuard g(aMutex); Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY ); if ( xContainer.is() ) xContainer->removeContainerListener(m_xConfigListener); @@ -162,7 +150,7 @@ ConfigurationAccess_UICategory::~ConfigurationAccess_UICategory() Any SAL_CALL ConfigurationAccess_UICategory::getByName( const OUString& rId ) throw ( NoSuchElementException, WrappedTargetException, RuntimeException) { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard g(aMutex); if ( !m_bConfigAccessInitialized ) { initializeConfigAccess(); @@ -290,7 +278,7 @@ Any ConfigurationAccess_UICategory::getUINameFromCache( const OUString& rId ) Sequence< OUString > ConfigurationAccess_UICategory::getAllIds() { // SAFE - ResetableGuard aLock( m_aLock ); + osl::MutexGuard g(aMutex); if ( !m_bConfigAccessInitialized ) { @@ -345,7 +333,8 @@ sal_Bool ConfigurationAccess_UICategory::initializeConfigAccess() aPropValue.Value <<= m_aConfigCategoryAccess; aArgs[0] <<= aPropValue; - m_xConfigAccess = Reference< XNameAccess >( m_xConfigProvider->createInstanceWithArguments(SERVICENAME_CFGREADACCESS,aArgs ),UNO_QUERY ); + m_xConfigAccess = Reference< XNameAccess >( m_xConfigProvider->createInstanceWithArguments( + "com.sun.star.configuration.ConfigurationAccess", aArgs ),UNO_QUERY ); if ( m_xConfigAccess.is() ) { // Add as container listener @@ -387,7 +376,7 @@ void SAL_CALL ConfigurationAccess_UICategory::disposing( const EventObject& aEve { // SAFE // remove our reference to the config access - ResetableGuard aLock( m_aLock ); + osl::MutexGuard g(aMutex); Reference< XInterface > xIfac1( aEvent.Source, UNO_QUERY ); Reference< XInterface > xIfac2( m_xConfigAccess, UNO_QUERY ); @@ -395,17 +384,35 @@ void SAL_CALL ConfigurationAccess_UICategory::disposing( const EventObject& aEve m_xConfigAccess.clear(); } -//***************************************************************************************************************** -// XInterface, XTypeProvider, XServiceInfo -//***************************************************************************************************************** +class UICategoryDescription : public UICommandDescription +{ +public: + UICategoryDescription( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual ~UICategoryDescription(); -DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2 ( UICategoryDescription , - ::cppu::OWeakObject , - "com.sun.star.ui.UICategoryDescription", - OUString("com.sun.star.comp.framework.UICategoryDescription") - ) + virtual OUString SAL_CALL getImplementationName() + throw (css::uno::RuntimeException) + { + return OUString("com.sun.star.comp.framework.UICategoryDescription"); + } -DEFINE_INIT_SERVICE ( UICategoryDescription, {} ) + 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.UICategoryDescription"); + return aSeq; + } + +private: + virtual css::uno::Reference< css::container::XNameAccess > impl_createConfigAccess(const OUString& _sName); +}; UICategoryDescription::UICategoryDescription( const Reference< XComponentContext >& rxContext ) : UICommandDescription(rxContext,true) @@ -433,6 +440,30 @@ Reference< XNameAccess > UICategoryDescription::impl_createConfigAccess(const OU return new ConfigurationAccess_UICategory( _sName, m_xGenericUICommands, m_xContext ); } -} // namespace framework +struct Instance { + explicit Instance( + css::uno::Reference<css::uno::XComponentContext> const & context): + instance(static_cast<cppu::OWeakObject *>( + new UICategoryDescription(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_UICategoryDescription_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: */ diff --git a/framework/util/fwk.component b/framework/util/fwk.component index 0692040f2688..98f36f8d2f2d 100644 --- a/framework/util/fwk.component +++ b/framework/util/fwk.component @@ -125,7 +125,8 @@ <implementation name="com.sun.star.comp.framework.ToolBarFactory"> <service name="com.sun.star.ui.ToolBarFactory"/> </implementation> - <implementation name="com.sun.star.comp.framework.UICategoryDescription"> + <implementation name="com.sun.star.comp.framework.UICategoryDescription" + constructor="com_sun_star_comp_framework_UICategoryDescription_get_implementation"> <service name="com.sun.star.ui.UICategoryDescription"/> <singleton name="com.sun.star.ui.theUICategoryDescription"/> </implementation> |