diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-01-09 16:42:06 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-01-10 16:29:02 +0100 |
commit | da68b2d30c3b25d633936d08c5f476e99de0e5d5 (patch) | |
tree | 6d62ef2bb790e905de82aa5e78b3a0076a84d48f | |
parent | a2317de0c3ef6094f67a6684ab395382f34b0f80 (diff) |
fwk: Use constructor feature for WindowContentFactoryManager.
Change-Id: I6786bc1d76fd57edc8dfacb667b53deab792bd20
-rw-r--r-- | framework/inc/helper/mischelper.hxx | 28 | ||||
-rw-r--r-- | framework/inc/uifactory/windowcontentfactorymanager.hxx | 74 | ||||
-rw-r--r-- | framework/source/register/registerservices.cxx | 2 | ||||
-rw-r--r-- | framework/source/uifactory/uielementfactorymanager.cxx | 3 | ||||
-rw-r--r-- | framework/source/uifactory/windowcontentfactorymanager.cxx | 90 | ||||
-rw-r--r-- | framework/util/fwk.component | 3 |
6 files changed, 73 insertions, 127 deletions
diff --git a/framework/inc/helper/mischelper.hxx b/framework/inc/helper/mischelper.hxx index 6689b3301566..070dc98aa333 100644 --- a/framework/inc/helper/mischelper.hxx +++ b/framework/inc/helper/mischelper.hxx @@ -88,6 +88,34 @@ inline bool IsScriptTypeMatchingToLanguage( sal_Int16 nScriptType, LanguageType return 0 != (nScriptType & SvtLanguageOptions::GetScriptTypeOfLanguage( nLang )); } +inline void RetrieveTypeNameFromResourceURL( const OUString& aResourceURL, OUString& aType, OUString& aName ) +{ + const sal_Int32 RESOURCEURL_PREFIX_SIZE = 17; + const char RESOURCEURL_PREFIX[] = "private:resource/"; + + if (( aResourceURL.startsWith( RESOURCEURL_PREFIX ) ) && + ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE )) + { + OUString aTmpStr( aResourceURL.copy( RESOURCEURL_PREFIX_SIZE )); + sal_Int32 nToken = 0; + sal_Int32 nPart = 0; + do + { + OUString sToken = aTmpStr.getToken( 0, '/', nToken); + if ( !sToken.isEmpty() ) + { + if ( nPart == 0 ) + aType = sToken; + else if ( nPart == 1 ) + aName = sToken; + else + break; + nPart++; + } + } + while( nToken >=0 ); + } +} class FWI_DLLPUBLIC LanguageGuessingHelper { diff --git a/framework/inc/uifactory/windowcontentfactorymanager.hxx b/framework/inc/uifactory/windowcontentfactorymanager.hxx deleted file mode 100644 index a92303e585b3..000000000000 --- a/framework/inc/uifactory/windowcontentfactorymanager.hxx +++ /dev/null @@ -1,74 +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_UIFACTORY_WINDOWCONTENTFACTORYMANAGER_HXX -#define INCLUDED_FRAMEWORK_INC_UIFACTORY_WINDOWCONTENTFACTORYMANAGER_HXX - -/** Attention: stl headers must(!) be included at first. Otherwise it can make trouble - with solaris headers ... -*/ -#include <vector> -#include <list> - -#include <threadhelp/threadhelpbase.hxx> -#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/container/XNameAccess.hpp> -#include "com/sun/star/frame/XModuleManager2.hpp" - -#include <cppuhelper/implbase2.hxx> -#include <rtl/ustring.hxx> - -namespace framework -{ - -class ConfigurationAccess_FactoryManager; -class WindowContentFactoryManager : 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::lang::XSingleComponentFactory> -{ - public: - WindowContentFactoryManager( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& rxContext ); - virtual ~WindowContentFactoryManager(); - - // XInterface, XTypeProvider, XServiceInfo - DECLARE_XSERVICEINFO - - // XSingleComponentFactory - virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithContext( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& Context ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArgumentsAndContext( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& Context ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); - - static void RetrieveTypeNameFromResourceURL( const OUString& aResourceURL, OUString& aType, OUString& aName ); - private: - - sal_Bool m_bConfigRead; - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 > m_xModuleManager; - ConfigurationAccess_FactoryManager* m_pConfigAccess; -}; - -} // namespace framework - -#endif // INCLUDED_FRAMEWORK_INC_UIFACTORY_WINDOWCONTENTFACTORYMANAGER_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/source/register/registerservices.cxx b/framework/source/register/registerservices.cxx index 617bd1f1f281..7e3fb68e948d 100644 --- a/framework/source/register/registerservices.cxx +++ b/framework/source/register/registerservices.cxx @@ -56,7 +56,6 @@ #include <services/taskcreatorsrv.hxx> #include <uiconfiguration/imagemanager.hxx> -#include <uifactory/windowcontentfactorymanager.hxx> #include <services/substitutepathvars.hxx> #include <services/pathsettings.hxx> #include <services/ContextChangeEventMultiplexer.hxx> @@ -85,7 +84,6 @@ COMPONENTGETFACTORY ( fwk, IFFACTORY( ::framework::SessionListener ) else IFFACTORY( ::framework::TaskCreatorService ) else IFFACTORY( ::framework::ImageManager ) else - IFFACTORY( ::framework::WindowContentFactoryManager ) else IFFACTORY( ::framework::SubstitutePathVariables ) else IFFACTORY( ::framework::PathSettings ) else IFFACTORY( ::framework::ContextChangeEventMultiplexer ) diff --git a/framework/source/uifactory/uielementfactorymanager.cxx b/framework/source/uifactory/uielementfactorymanager.cxx index d1dd274e3501..6d52f970690a 100644 --- a/framework/source/uifactory/uielementfactorymanager.cxx +++ b/framework/source/uifactory/uielementfactorymanager.cxx @@ -18,7 +18,6 @@ */ #include <uifactory/uielementfactorymanager.hxx> -#include <uifactory/windowcontentfactorymanager.hxx> #include <threadhelp/resetableguard.hxx> #include "services.h" @@ -465,7 +464,7 @@ throw ( RuntimeException ) OUString aType; OUString aName; - WindowContentFactoryManager::RetrieveTypeNameFromResourceURL( aResourceURL, aType, aName ); + RetrieveTypeNameFromResourceURL( aResourceURL, aType, aName ); Reference< XComponentContext > xContext( m_xContext ); diff --git a/framework/source/uifactory/windowcontentfactorymanager.cxx b/framework/source/uifactory/windowcontentfactorymanager.cxx index b66c473b2d2a..2cf90ec857f8 100644 --- a/framework/source/uifactory/windowcontentfactorymanager.cxx +++ b/framework/source/uifactory/windowcontentfactorymanager.cxx @@ -17,43 +17,55 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <uifactory/windowcontentfactorymanager.hxx> #include <uifactory/uielementfactorymanager.hxx> #include <threadhelp/resetableguard.hxx> +#include <threadhelp/threadhelpbase.hxx> +#include <helper/mischelper.hxx> +#include <macros/xinterface.hxx> +#include <macros/xtypeprovider.hxx> +#include <macros/xserviceinfo.hxx> #include "services.h" #include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/beans/XPropertySet.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/frame/ModuleManager.hpp> +#include "com/sun/star/frame/XModuleManager2.hpp" #include <com/sun/star/frame/XFrame.hpp> -#include <com/sun/star/awt/XControlModel.hpp> -#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <cppuhelper/implbase2.hxx> +#include <rtl/ref.hxx> #include <rtl/ustrbuf.hxx> #include <cppuhelper/weak.hxx> #include <tools/urlobj.hxx> #include <tools/diagnose_ex.h> #include <vcl/svapp.hxx> -//_________________________________________________________________________________________________________________ -// Defines -//_________________________________________________________________________________________________________________ - using namespace ::com::sun::star; +using namespace framework; -//_________________________________________________________________________________________________________________ -// Namespace -//_________________________________________________________________________________________________________________ +namespace { -namespace framework +class WindowContentFactoryManager : 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::lang::XSingleComponentFactory> { + public: + WindowContentFactoryManager( const css::uno::Reference< css::uno::XComponentContext>& rxContext ); + virtual ~WindowContentFactoryManager(); + + // XInterface, XTypeProvider, XServiceInfo + DECLARE_XSERVICEINFO + + // XSingleComponentFactory + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithContext( const css::uno::Reference< css::uno::XComponentContext >& Context ) throw (css::uno::Exception, css::uno::RuntimeException); + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArgumentsAndContext( const css::uno::Sequence< css::uno::Any >& Arguments, const css::uno::Reference< css::uno::XComponentContext >& Context ) throw (css::uno::Exception, css::uno::RuntimeException); + + private: + sal_Bool m_bConfigRead; + css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager; + ConfigurationAccess_FactoryManager* m_pConfigAccess; +}; -//***************************************************************************************************************** -// XInterface, XTypeProvider, XServiceInfo -//***************************************************************************************************************** DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2 ( WindowContentFactoryManager , ::cppu::OWeakObject , "com.sun.star.ui.WindowContentFactoryManager", @@ -79,35 +91,6 @@ WindowContentFactoryManager::~WindowContentFactoryManager() m_pConfigAccess->release(); } -void WindowContentFactoryManager::RetrieveTypeNameFromResourceURL( const OUString& aResourceURL, OUString& aType, OUString& aName ) -{ - const sal_Int32 RESOURCEURL_PREFIX_SIZE = 17; - const char RESOURCEURL_PREFIX[] = "private:resource/"; - - if (( aResourceURL.startsWith( RESOURCEURL_PREFIX ) ) && - ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE )) - { - OUString aTmpStr( aResourceURL.copy( RESOURCEURL_PREFIX_SIZE )); - sal_Int32 nToken = 0; - sal_Int32 nPart = 0; - do - { - OUString sToken = aTmpStr.getToken( 0, '/', nToken); - if ( !sToken.isEmpty() ) - { - if ( nPart == 0 ) - aType = sToken; - else if ( nPart == 1 ) - aName = sToken; - else - break; - nPart++; - } - } - while( nToken >=0 ); - } -} - // XSingleComponentFactory uno::Reference< uno::XInterface > SAL_CALL WindowContentFactoryManager::createInstanceWithContext( const uno::Reference< uno::XComponentContext >& /*xContext*/ ) @@ -214,6 +197,17 @@ throw (uno::Exception, uno::RuntimeException) return xWindow; } -} // namespace framework +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +com_sun_star_comp_framework_WindowContentFactoryManager_get_implementation( + css::uno::XComponentContext * context, + uno_Sequence * arguments) +{ + assert(arguments != 0 && arguments->nElements == 0); (void) arguments; + rtl::Reference<WindowContentFactoryManager> x(new WindowContentFactoryManager(context)); + x->acquire(); + return static_cast<cppu::OWeakObject *>(x.get()); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/util/fwk.component b/framework/util/fwk.component index e8da69204835..544c8f32e719 100644 --- a/framework/util/fwk.component +++ b/framework/util/fwk.component @@ -130,7 +130,8 @@ <implementation name="com.sun.star.comp.framework.URLTransformer"> <service name="com.sun.star.util.URLTransformer"/> </implementation> - <implementation name="com.sun.star.comp.framework.WindowContentFactoryManager"> + <implementation name="com.sun.star.comp.framework.WindowContentFactoryManager" + constructor="com_sun_star_comp_framework_WindowContentFactoryManager_get_implementation"> <service name="com.sun.star.ui.WindowContentFactoryManager"/> </implementation> <implementation name="com.sun.star.comp.framework.WindowStateConfiguration" |